diff options
author | 3gg <3gg@shellblade.net> | 2025-10-13 20:44:06 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2025-10-13 20:44:06 -0700 |
commit | 338bd46fb6dbcb8271102ddb6b896a335eb909dc (patch) | |
tree | dafa50f732804df571521751c619de57d12299aa /src/mailbox.c | |
parent | 079cd940e727c1705e9f1b30706b9531d5aedda6 (diff) |
Diffstat (limited to 'src/mailbox.c')
-rw-r--r-- | src/mailbox.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/mailbox.c b/src/mailbox.c index aacb747..310b2b1 100644 --- a/src/mailbox.c +++ b/src/mailbox.c | |||
@@ -16,13 +16,8 @@ static inline uint8_t msg_channel(Message msg) { | |||
16 | return msg & 0xf; | 16 | return msg & 0xf; |
17 | } | 17 | } |
18 | 18 | ||
19 | static inline const void* msg_data(Message msg) { | ||
20 | // The data field is actually a pointer to the data. | ||
21 | return (const void*)((uintptr_t)(msg >> 4)); | ||
22 | } | ||
23 | |||
24 | static inline Message msg_make(uint8_t channel, volatile const void* data) { | 19 | static inline Message msg_make(uint8_t channel, volatile const void* data) { |
25 | return ((uintptr_t)(data) << 4) | (channel & 0xf); | 20 | return ((uintptr_t)(data) & ~0xf) | (channel & 0xf); |
26 | } | 21 | } |
27 | 22 | ||
28 | typedef struct Mailbox { | 23 | typedef struct Mailbox { |
@@ -61,7 +56,7 @@ const Mail* mbox_read(uint8_t channel) { | |||
61 | // Read the mail. | 56 | // Read the mail. |
62 | msg = pMailbox->inbox; | 57 | msg = pMailbox->inbox; |
63 | } while (msg_channel(msg) != channel); | 58 | } while (msg_channel(msg) != channel); |
64 | return (const Mail*)(msg_data(msg)); | 59 | return (const Mail*)((uintptr_t)msg & ~0xf); |
65 | } | 60 | } |
66 | 61 | ||
67 | void mbox_write(uint8_t channel, volatile const void* mail) { | 62 | void mbox_write(uint8_t channel, volatile const void* mail) { |