#pragma once #include // The channel takes the lower 4 bits; the data pointer the upper 28. So a mail // must be aligned to a 16-byte boundary. #define MAIL_ALIGN 16 enum { PROPERTY_CHANNEL = 8, }; typedef struct Tag { union { uint32_t all; struct { uint16_t command : 12; // Command. uint8_t type : 4; // Command type. uint8_t device : 4; // Hardware device. uint16_t zeroes : 12; // Reserved. } id; }; uint32_t size; // Buffer size. uint32_t code; // Request/response code. uint32_t data[1]; // Buffer data. } Tag; typedef struct __attribute__((aligned(MAIL_ALIGN))) Mail { uint32_t size; // Buffer size. uint32_t code; // Request/response code. Tag tags[1]; // Variable quantity. } Mail; void mbox_init(); const Mail* mbox_read(uint8_t channel); void mbox_write(uint8_t channel, const void* mail);