mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
hw/cxl/events: Add event status register
The device status register block was defined. However, there were no individual registers nor any data wired up. Define the event status register [CXL 3.0; 8.2.8.3.1] as part of the device status register block. Wire up the register and initialize the event status for each log. To support CXL 3.0 the version of the device status register block needs to be 2. Change the macro to allow for setting the version. Signed-off-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Fan Ni <fan.ni@samsung.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Message-Id: <20230530133603.16934-2-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
6bda41a69b
commit
d7b84ddc3b
3 changed files with 86 additions and 8 deletions
|
@ -41,7 +41,20 @@ static uint64_t caps_reg_read(void *opaque, hwaddr offset, unsigned size)
|
|||
|
||||
static uint64_t dev_reg_read(void *opaque, hwaddr offset, unsigned size)
|
||||
{
|
||||
return 0;
|
||||
CXLDeviceState *cxl_dstate = opaque;
|
||||
|
||||
switch (size) {
|
||||
case 1:
|
||||
return cxl_dstate->dev_reg_state[offset];
|
||||
case 2:
|
||||
return cxl_dstate->dev_reg_state16[offset / size];
|
||||
case 4:
|
||||
return cxl_dstate->dev_reg_state32[offset / size];
|
||||
case 8:
|
||||
return cxl_dstate->dev_reg_state64[offset / size];
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t mailbox_reg_read(void *opaque, hwaddr offset, unsigned size)
|
||||
|
@ -236,7 +249,27 @@ void cxl_device_register_block_init(Object *obj, CXLDeviceState *cxl_dstate)
|
|||
&cxl_dstate->memory_device);
|
||||
}
|
||||
|
||||
static void device_reg_init_common(CXLDeviceState *cxl_dstate) { }
|
||||
void cxl_event_set_status(CXLDeviceState *cxl_dstate, CXLEventLogType log_type,
|
||||
bool available)
|
||||
{
|
||||
if (available) {
|
||||
cxl_dstate->event_status |= (1 << log_type);
|
||||
} else {
|
||||
cxl_dstate->event_status &= ~(1 << log_type);
|
||||
}
|
||||
|
||||
ARRAY_FIELD_DP64(cxl_dstate->dev_reg_state64, CXL_DEV_EVENT_STATUS,
|
||||
EVENT_STATUS, cxl_dstate->event_status);
|
||||
}
|
||||
|
||||
static void device_reg_init_common(CXLDeviceState *cxl_dstate)
|
||||
{
|
||||
CXLEventLogType log;
|
||||
|
||||
for (log = 0; log < CXL_EVENT_TYPE_MAX; log++) {
|
||||
cxl_event_set_status(cxl_dstate, log, false);
|
||||
}
|
||||
}
|
||||
|
||||
static void mailbox_reg_init_common(CXLDeviceState *cxl_dstate)
|
||||
{
|
||||
|
@ -258,13 +291,13 @@ void cxl_device_register_init_common(CXLDeviceState *cxl_dstate)
|
|||
ARRAY_FIELD_DP64(cap_hdrs, CXL_DEV_CAP_ARRAY, CAP_VERSION, 1);
|
||||
ARRAY_FIELD_DP64(cap_hdrs, CXL_DEV_CAP_ARRAY, CAP_COUNT, cap_count);
|
||||
|
||||
cxl_device_cap_init(cxl_dstate, DEVICE_STATUS, 1);
|
||||
cxl_device_cap_init(cxl_dstate, DEVICE_STATUS, 1, 2);
|
||||
device_reg_init_common(cxl_dstate);
|
||||
|
||||
cxl_device_cap_init(cxl_dstate, MAILBOX, 2);
|
||||
cxl_device_cap_init(cxl_dstate, MAILBOX, 2, 1);
|
||||
mailbox_reg_init_common(cxl_dstate);
|
||||
|
||||
cxl_device_cap_init(cxl_dstate, MEMORY_DEVICE, 0x4000);
|
||||
cxl_device_cap_init(cxl_dstate, MEMORY_DEVICE, 0x4000, 1);
|
||||
memdev_reg_init_common(cxl_dstate);
|
||||
|
||||
cxl_initialize_mailbox(cxl_dstate);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue