From: Tom Storey <tom@snnap.net>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Building for m68k
Date: Fri, 24 Apr 2020 12:29:51 +1000 [thread overview]
Message-ID: <CAFDgZgWhZeQ18C5w8ejqTvSc+6A8v-v0fe5mCSYODvBUZM-zSQ@mail.gmail.com> (raw)
In-Reply-To: <20200424012043.GB11469@brightrain.aerifal.cx>
[-- Attachment #1: Type: text/plain, Size: 1573 bytes --]
Ah yeah. Cool.
I did something similar in a recent Z80 based project, shouldn't be too
difficult to do that on m68k.
Only trouble I can see arising from this is enabling and disabling
interrupts is privileged, and from the 68010 onwards you can't even see the
status register to know if interrupts are on/off outside of supervisor
mode, so you wouldn't be able to execute this code from any application
running in user mode.
I suppose that is why it's better trapped as an invalid instruction and
emulated lower down?
On Fri, Apr 24, 2020, 11:20 Rich Felker <dalias@libc.org> wrote:
> On Fri, Apr 24, 2020 at 11:14:38AM +1000, Tom Storey wrote:
> > Sorry to ask what sounds like a dumb question, but is
> >
> > cli;nonatomic_cas;sti
> >
> > basically "disable interrupts, do something equivalent to cas, re-enable
> > interrupts"?
>
> Yeah. Basically:
>
> static inline int a_cas(volatile int *p, int t, int s)
> {
> __asm__ __volatile__("cli" : : : "memory");
> if (*p==t) *p=s; else t=*p;
> __asm__ __volatile__("sti" : : : "memory");
> return t;
> }
>
> where cli and sti are replaced with the m68k instructions for those
> operations. Of course if you might have code that already has
> interrupts disabled somewhere calling libc stuff, you may need to make
> it save the old interrupt state and restore it rather than just sti.
> See the sh2 version (runtime selected so it's in __sh_cas_imask in
> src/thread/sh/atomics.s and atomic_arch.h just calls the
> runtime-selected function) for an example of code doing this
>
> Rich
>
[-- Attachment #2: Type: text/html, Size: 2210 bytes --]
next prev parent reply other threads:[~2020-04-24 2:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-23 2:05 Tom Storey
2020-04-23 2:32 ` Rich Felker
2020-04-23 5:04 ` Tom Storey
2020-04-23 16:30 ` Rich Felker
2020-04-24 0:36 ` Tom Storey
2020-04-24 0:51 ` Rich Felker
2020-04-24 1:14 ` Tom Storey
2020-04-24 1:20 ` Rich Felker
2020-04-24 2:29 ` Tom Storey [this message]
2020-04-24 2:37 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFDgZgWhZeQ18C5w8ejqTvSc+6A8v-v0fe5mCSYODvBUZM-zSQ@mail.gmail.com \
--to=tom@snnap.net \
--cc=dalias@libc.org \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).