acpi: add ACPI_DEVICE_UID_ITEM
Change-Id: I6f1dba7d9d757859375e2339141ba92559d5cf9b Reviewed-on: https://review.haiku-os.org/c/haiku/+/2484 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com> Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
This commit is contained in:
parent
04ff1cfaef
commit
526752bc02
@ -139,8 +139,8 @@ typedef struct acpi_data {
|
||||
|
||||
|
||||
enum {
|
||||
ACPI_ALLOCATE_BUFFER = -1,
|
||||
ACPI_ALLOCATE_LOCAL_BUFFER = -2,
|
||||
ACPI_ALLOCATE_BUFFER = (acpi_size)-1,
|
||||
ACPI_ALLOCATE_LOCAL_BUFFER = (acpi_size)-2,
|
||||
};
|
||||
|
||||
|
||||
@ -253,7 +253,7 @@ struct acpi_module_info {
|
||||
size_t resultLength);
|
||||
|
||||
status_t (*get_device_info)(const char *path, char** hid,
|
||||
char** cidList, size_t cidListLength);
|
||||
char** cidList, size_t cidListLength, char** uid);
|
||||
uint32 (*get_object_type)(const char *path);
|
||||
status_t (*get_object)(const char *path,
|
||||
acpi_object_type **_returnValue);
|
||||
@ -318,6 +318,7 @@ enum {
|
||||
#define ACPI_DEVICE_HID_ITEM "acpi/hid"
|
||||
#define ACPI_DEVICE_PATH_ITEM "acpi/path"
|
||||
#define ACPI_DEVICE_TYPE_ITEM "acpi/type"
|
||||
#define ACPI_DEVICE_UID_ITEM "acpi/uid"
|
||||
|
||||
|
||||
typedef struct acpi_device_cookie *acpi_device;
|
||||
|
@ -113,7 +113,7 @@ typedef struct acpi_root_info {
|
||||
size_t resultLength);
|
||||
|
||||
status_t (*get_device_info)(const char *path, char **hid,
|
||||
char** cidList, size_t cidListCount);
|
||||
char** cidList, size_t cidListCount, char** uid);
|
||||
uint32 (*get_object_type)(const char *path);
|
||||
status_t (*get_object)(const char *path,
|
||||
acpi_object_type **_returnValue);
|
||||
@ -214,7 +214,7 @@ status_t get_device(const char* hid, uint32 index, char* result,
|
||||
size_t resultLength);
|
||||
|
||||
status_t get_device_info(const char* path, char** hid, char** cidList,
|
||||
size_t cidListCount);
|
||||
size_t cidListCount, char** uniqueId);
|
||||
status_t get_device_addr(const char* path, uint32* addr);
|
||||
uint32 get_object_type(const char* path);
|
||||
status_t get_object(const char* path, acpi_object_type** _returnValue);
|
||||
|
@ -534,7 +534,7 @@ get_device(const char* hid, uint32 index, char* result, size_t resultLength)
|
||||
|
||||
status_t
|
||||
get_device_info(const char *path, char** hid, char** cidList,
|
||||
size_t cidListCount)
|
||||
size_t cidListCount, char** uid)
|
||||
{
|
||||
ACPI_HANDLE handle;
|
||||
ACPI_DEVICE_INFO *info;
|
||||
@ -558,6 +558,9 @@ get_device_info(const char *path, char** hid, char** cidList,
|
||||
}
|
||||
}
|
||||
|
||||
if ((info->Valid & ACPI_VALID_UID) != 0 && uid != NULL)
|
||||
*uid = strndup(info->UniqueId.String, info->UniqueId.Length);
|
||||
|
||||
AcpiOsFree(info);
|
||||
return B_OK;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ acpi_enumerate_child_devices(device_node* node, const char* root)
|
||||
case ACPI_TYPE_PROCESSOR:
|
||||
case ACPI_TYPE_THERMAL:
|
||||
case ACPI_TYPE_DEVICE: {
|
||||
device_attr attrs[15] = {
|
||||
device_attr attrs[16] = {
|
||||
// info about device
|
||||
{ B_DEVICE_BUS, B_STRING_TYPE, { string: "acpi" }},
|
||||
|
||||
@ -103,9 +103,10 @@ acpi_enumerate_child_devices(device_node* node, const char* root)
|
||||
uint32 attrCount = 4;
|
||||
char* hid = NULL;
|
||||
char* cidList[8] = { NULL };
|
||||
char* uid = NULL;
|
||||
if (type == ACPI_TYPE_DEVICE) {
|
||||
if (get_device_info(result, &hid, (char**)&cidList, 8)
|
||||
== B_OK) {
|
||||
if (get_device_info(result, &hid, (char**)&cidList, 8,
|
||||
&uid) == B_OK) {
|
||||
if (hid != NULL) {
|
||||
attrs[attrCount].name = ACPI_DEVICE_HID_ITEM;
|
||||
attrs[attrCount].type = B_STRING_TYPE;
|
||||
@ -118,6 +119,12 @@ acpi_enumerate_child_devices(device_node* node, const char* root)
|
||||
attrs[attrCount].value.string = cidList[i];
|
||||
attrCount++;
|
||||
}
|
||||
if (uid != NULL) {
|
||||
attrs[attrCount].name = ACPI_DEVICE_UID_ITEM;
|
||||
attrs[attrCount].type = B_STRING_TYPE;
|
||||
attrs[attrCount].value.string = uid;
|
||||
attrCount++;
|
||||
}
|
||||
}
|
||||
uint32 addr;
|
||||
if (get_device_addr(result, &addr) == B_OK) {
|
||||
@ -131,6 +138,7 @@ acpi_enumerate_child_devices(device_node* node, const char* root)
|
||||
status_t status = gDeviceManager->register_node(node,
|
||||
ACPI_DEVICE_MODULE_NAME, attrs, NULL, &deviceNode);
|
||||
free(hid);
|
||||
free(uid);
|
||||
for (int i = 0; cidList[i] != NULL; i++)
|
||||
free(cidList[i]);
|
||||
if (status != B_OK)
|
||||
|
@ -115,7 +115,7 @@ dump_acpi_namespace(acpi_ns_device_info *device, char *root, int indenting)
|
||||
case ACPI_TYPE_DEVICE:
|
||||
{
|
||||
char* hid = NULL;
|
||||
device->acpi->get_device_info(result, &hid, NULL, 0);
|
||||
device->acpi->get_device_info(result, &hid, NULL, 0, NULL);
|
||||
strlcat(output, " DEVICE (", sizeof(output));
|
||||
if (hid != NULL) {
|
||||
strlcat(output, hid, sizeof(output));
|
||||
|
Loading…
Reference in New Issue
Block a user