mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
hw/cxl/device: Add memory device utilities
Memory devices implement extra capabilities on top of CXL devices. This adds support for that. A large part of memory devices is the mailbox/command interface. All of the mailbox handling is done in the mailbox-utils library. Longer term, new CXL devices that are being emulated may want to handle commands differently, and therefore would need a mechanism to opt in/out of the specific generic handlers. As such, this is considered sufficient for now, but may need more depth in the future. Signed-off-by: Ben Widawsky <ben.widawsky@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220429144110.25167-8-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
464e14ac43
commit
ce3b4e5c15
2 changed files with 55 additions and 4 deletions
|
@ -72,15 +72,20 @@
|
|||
#define CXL_MAILBOX_REGISTERS_LENGTH \
|
||||
(CXL_MAILBOX_REGISTERS_SIZE + CXL_MAILBOX_MAX_PAYLOAD_SIZE)
|
||||
|
||||
#define CXL_MMIO_SIZE \
|
||||
(CXL_DEVICE_CAP_REG_SIZE + CXL_DEVICE_STATUS_REGISTERS_LENGTH + \
|
||||
CXL_MAILBOX_REGISTERS_LENGTH)
|
||||
#define CXL_MEMORY_DEVICE_REGISTERS_OFFSET \
|
||||
(CXL_MAILBOX_REGISTERS_OFFSET + CXL_MAILBOX_REGISTERS_LENGTH)
|
||||
#define CXL_MEMORY_DEVICE_REGISTERS_LENGTH 0x8
|
||||
|
||||
#define CXL_MMIO_SIZE \
|
||||
(CXL_DEVICE_CAP_REG_SIZE + CXL_DEVICE_STATUS_REGISTERS_LENGTH + \
|
||||
CXL_MAILBOX_REGISTERS_LENGTH + CXL_MEMORY_DEVICE_REGISTERS_LENGTH)
|
||||
|
||||
typedef struct cxl_device_state {
|
||||
MemoryRegion device_registers;
|
||||
|
||||
/* mmio for device capabilities array - 8.2.8.2 */
|
||||
MemoryRegion device;
|
||||
MemoryRegion memory_device;
|
||||
struct {
|
||||
MemoryRegion caps;
|
||||
union {
|
||||
|
@ -153,6 +158,9 @@ REG64(CXL_DEV_CAP_ARRAY, 0) /* Documented as 128 bit register but 64 byte access
|
|||
CXL_DEVICE_CAPABILITY_HEADER_REGISTER(DEVICE_STATUS, CXL_DEVICE_CAP_HDR1_OFFSET)
|
||||
CXL_DEVICE_CAPABILITY_HEADER_REGISTER(MAILBOX, CXL_DEVICE_CAP_HDR1_OFFSET + \
|
||||
CXL_DEVICE_CAP_REG_SIZE)
|
||||
CXL_DEVICE_CAPABILITY_HEADER_REGISTER(MEMORY_DEVICE,
|
||||
CXL_DEVICE_CAP_HDR1_OFFSET +
|
||||
CXL_DEVICE_CAP_REG_SIZE * 2)
|
||||
|
||||
int cxl_initialize_mailbox(CXLDeviceState *cxl_dstate);
|
||||
void cxl_process_mailbox(CXLDeviceState *cxl_dstate);
|
||||
|
@ -209,4 +217,11 @@ REG64(CXL_DEV_BG_CMD_STS, 0x18)
|
|||
/* CXL 2.0 8.2.8.4.8 Command Payload Registers */
|
||||
REG32(CXL_DEV_CMD_PAYLOAD, 0x20)
|
||||
|
||||
REG64(CXL_MEM_DEV_STS, 0)
|
||||
FIELD(CXL_MEM_DEV_STS, FATAL, 0, 1)
|
||||
FIELD(CXL_MEM_DEV_STS, FW_HALT, 1, 1)
|
||||
FIELD(CXL_MEM_DEV_STS, MEDIA_STATUS, 2, 2)
|
||||
FIELD(CXL_MEM_DEV_STS, MBOX_READY, 4, 1)
|
||||
FIELD(CXL_MEM_DEV_STS, RESET_NEEDED, 5, 3)
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue