summaryrefslogtreecommitdiff
path: root/src/mailbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailbox.c')
-rw-r--r--src/mailbox.c9
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
19static 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
24static inline Message msg_make(uint8_t channel, volatile const void* data) { 19static 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
28typedef struct Mailbox { 23typedef 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
67void mbox_write(uint8_t channel, volatile const void* mail) { 62void mbox_write(uint8_t channel, volatile const void* mail) {