1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-10 06:48:09 -08:00

Compare commits

..

2 Commits

Author SHA1 Message Date
Ani Sinha
bd772896c2
Merge fa5f66da59 into 5495b11360 2024-12-21 23:04:21 +01:00
Ani Sinha
fa5f66da59 hwids: add a new firmware type of device entry
This change adds a new firmware type device entry for the .hwids section.
It also adds compile time validations for them.

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. Fix chid_match() to support the new device type.

Ukify has also been adjusted to accomodate the new device type.
2024-12-13 09:37:36 +05:30
6 changed files with 9 additions and 6 deletions

0
.gitmodules vendored Normal file
View File

View File

@ -59,11 +59,17 @@ assert_cc(offsetof(Device, fw.name_offset) == 20);
assert_cc(offsetof(Device, fw.compatible_offset) == 24); assert_cc(offsetof(Device, fw.compatible_offset) == 24);
assert_cc(sizeof(Device) == 28); assert_cc(sizeof(Device) == 28);
static inline const char* device_get_name(const void *base, const Device *device) { static inline const char* device_get_devicetree_name(const void *base, const Device *device) {
if (device->descriptor != DEVICE_DESCRIPTOR_DEVICETREE)
return NULL;
return device->devicetree.name_offset == 0 ? NULL : (const char *) ((const uint8_t *) base + device->devicetree.name_offset); return device->devicetree.name_offset == 0 ? NULL : (const char *) ((const uint8_t *) base + device->devicetree.name_offset);
} }
static inline const char* device_get_compatible(const void *base, const Device *device) { static inline const char* device_get_devicetree_compatible(const void *base, const Device *device) {
if (device->descriptor != DEVICE_DESCRIPTOR_DEVICETREE)
return NULL;
return device->devicetree.compatible_offset == 0 ? NULL : (const char *) ((const uint8_t *) base + device->devicetree.compatible_offset); return device->devicetree.compatible_offset == 0 ? NULL : (const char *) ((const uint8_t *) base + device->devicetree.compatible_offset);
} }

View File

@ -1,5 +1,4 @@
{ {
"type": "devicetree",
"name": "Device 1", "name": "Device 1",
"compatible": "test,device-1", "compatible": "test,device-1",
"hwids": [ "hwids": [

View File

@ -1,5 +1,4 @@
{ {
"type": "firmware",
"name": "Device 2", "name": "Device 2",
"compatible": "test,device-2", "compatible": "test,device-2",
"hwids": [ "hwids": [

View File

@ -1,5 +1,4 @@
{ {
"type": "devicetree",
"name": "Device 3", "name": "Device 3",
"compatible": "test,device-3", "compatible": "test,device-3",
"hwids": [ "hwids": [

View File

@ -185,7 +185,7 @@ static bool pe_use_this_dtb(
if (!device || !base) if (!device || !base)
return false; return false;
const char *compatible = device_get_compatible(base, device); const char *compatible = device_get_devicetree_compatible(base, device);
if (!compatible) if (!compatible)
return false; return false;