Jonathan Cameron <jonathan.came...@huawei.com> writes:
> From: Ben Widawsky <ben.widaw...@intel.com> > > This is the beginning of implementing mailbox support for CXL 2.0 > devices. The implementation recognizes when the doorbell is rung, > handles the command/payload, clears the doorbell while returning error > codes and data. > > Generally the mailbox mechanism is designed to permit communication > between the host OS and the firmware running on the device. For our > purposes, we emulate both the firmware, implemented primarily in > cxl-mailbox-utils.c, and the hardware. > <snip> > + > +#define define_mailbox_handler(name) \ > + static ret_code cmd_##name(struct cxl_cmd *cmd, \ > + CXLDeviceState *cxl_dstate, uint16_t *len) > +#define declare_mailbox_handler(name) define_mailbox_handler(name) > + > +#define define_mailbox_handler_zeroed(name, size) \ > + uint16_t __zero##name = size; \ > + static ret_code cmd_##name(struct cxl_cmd *cmd, \ > + CXLDeviceState *cxl_dstate, uint16_t *len) \ > + { \ > + *len = __zero##name; \ > + memset(cmd->payload, 0, *len); \ > + return CXL_MBOX_SUCCESS; \ > + } > +#define define_mailbox_handler_const(name, data) \ > + static ret_code cmd_##name(struct cxl_cmd *cmd, \ > + CXLDeviceState *cxl_dstate, uint16_t *len) \ > + { \ > + *len = sizeof(data); \ > + memcpy(cmd->payload, data, *len); \ > + return CXL_MBOX_SUCCESS; \ > + } > +#define define_mailbox_handler_nop(name) \ > + static ret_code cmd_##name(struct cxl_cmd *cmd, \ > + CXLDeviceState *cxl_dstate, uint16_t *len) \ > + { \ > + return CXL_MBOX_SUCCESS; \ > + } I missed these #define's - can you upcase them to make it clear they are macros when used. -- Alex Bennée