1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <acpi/acpi_gnvs.h>
5 #include <acpi/acpigen.h>
13 static void acpi_create_serialio_ssdt_entry(int id
, struct global_nvs
*gnvs
)
15 char sio_name
[5] = {};
16 snprintf(sio_name
, sizeof(sio_name
), "S%1uEN", id
);
17 acpigen_write_name_byte(sio_name
, gnvs
->s0b
[id
] ? 1 : 0);
20 void acpi_create_serialio_ssdt(acpi_header_t
*ssdt
)
22 unsigned long current
= (unsigned long)ssdt
+ sizeof(acpi_header_t
);
23 struct global_nvs
*gnvs
= acpi_get_gnvs();
29 /* Fill the SSDT header */
30 memset((void *)ssdt
, 0, sizeof(acpi_header_t
));
31 memcpy(&ssdt
->signature
, "SSDT", 4);
32 ssdt
->revision
= get_acpi_table_revision(SSDT
);
33 memcpy(&ssdt
->oem_id
, OEM_ID
, 6);
34 memcpy(&ssdt
->oem_table_id
, "SERIALIO", 8);
35 ssdt
->oem_revision
= 43;
36 memcpy(&ssdt
->asl_compiler_id
, ASLC
, 4);
37 ssdt
->asl_compiler_revision
= asl_revision
;
38 ssdt
->length
= sizeof(acpi_header_t
);
39 acpigen_set_current((char *)current
);
41 /* Fill the SSDT with an entry for each SerialIO device */
42 for (id
= 0; id
< 8; id
++)
43 acpi_create_serialio_ssdt_entry(id
, gnvs
);
45 /* (Re)calculate length and checksum. */
46 current
= (unsigned long)acpigen_get_current();
47 ssdt
->length
= current
- (unsigned long)ssdt
;
48 ssdt
->checksum
= acpi_checksum((void *)ssdt
, ssdt
->length
);