Compare commits

...

2 Commits

Author SHA1 Message Date
Ani Sinha 1293bb9c34
Merge c7e8c56c1b into d99198819c 2024-11-22 04:33:17 +01:00
Ani Sinha c7e8c56c1b chid: prepare chid_match function to accomodate other device types
Since currently there is only one device type (devicetree), chid_match()
compares the descriptor value of this device type directly and errors out for
other descriptors. When other device types will be added, this logic will fail.

Introduce DEVICE_TYPE_MAX to denote maximum value of a device type and use
the corresponding descriptor to do validations in chid_match.
2024-11-21 20:10:26 +05:30
2 changed files with 3 additions and 1 deletions

View File

@ -113,7 +113,7 @@ EFI_STATUS chid_match(const void *hwid_buffer, size_t hwid_length, const Device
if (devices[n_devices].descriptor == DEVICE_DESCRIPTOR_EOL) if (devices[n_devices].descriptor == DEVICE_DESCRIPTOR_EOL)
break; break;
if (devices[n_devices].descriptor != DEVICE_DESCRIPTOR_DEVICETREE) if (devices[n_devices].descriptor >= DEVICE_DESCRIPTOR_MAX)
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
n_devices++; n_devices++;
} }

View File

@ -16,6 +16,7 @@ enum {
* - CoCo Bring-Your-Own-Firmware * - CoCo Bring-Your-Own-Firmware
* - ACPI DSDT Overrides * - ACPI DSDT Overrides
* - */ * - */
_DEVICE_TYPE_MAX,
}; };
#define DEVICE_SIZE_FROM_DESCRIPTOR(u) ((uint32_t) (u) & UINT32_C(0x0FFFFFFF)) #define DEVICE_SIZE_FROM_DESCRIPTOR(u) ((uint32_t) (u) & UINT32_C(0x0FFFFFFF))
@ -23,6 +24,7 @@ enum {
#define DEVICE_MAKE_DESCRIPTOR(type, size) (((uint32_t) (size) | ((uint32_t) type << 28))) #define DEVICE_MAKE_DESCRIPTOR(type, size) (((uint32_t) (size) | ((uint32_t) type << 28)))
#define DEVICE_DESCRIPTOR_DEVICETREE DEVICE_MAKE_DESCRIPTOR(DEVICE_TYPE_DEVICETREE, sizeof(Device)) #define DEVICE_DESCRIPTOR_DEVICETREE DEVICE_MAKE_DESCRIPTOR(DEVICE_TYPE_DEVICETREE, sizeof(Device))
#define DEVICE_DESCRIPTOR_MAX DEVICE_MAKE_DESCRIPTOR(_DEVICE_TYPE_MAX, sizeof(Device))
#define DEVICE_DESCRIPTOR_EOL UINT32_C(0) #define DEVICE_DESCRIPTOR_EOL UINT32_C(0)
typedef struct Device { typedef struct Device {