Gerd Hoffmann (2): output: add support for uppercase hex numbers dsdt: add support for pnp ids as strings
src/fw/dsdt_parser.c | 21 +++++++++++-------- src/output.c | 49 ++++++++++++++++++++++++-------------------- 2 files changed, 40 insertions(+), 30 deletions(-)
... via "%X" format string.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/output.c | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/src/output.c b/src/output.c index 3c335cbb28e2..0184444c8f21 100644 --- a/src/output.c +++ b/src/output.c @@ -160,10 +160,12 @@ putuint(struct putcinfo *action, u32 val)
// Output a single digit hex character. static inline void -putsinglehex(struct putcinfo *action, u32 val) +putsinglehex(struct putcinfo *action, u32 val, int uc) { if (val <= 9) val = '0' + val; + else if (uc) + val = 'A' + val - 10; else val = 'a' + val - 10; putc(action, val); @@ -171,23 +173,23 @@ putsinglehex(struct putcinfo *action, u32 val)
// Output an integer in hexadecimal with a specified width. static void -puthex(struct putcinfo *action, u32 val, int width) +puthex(struct putcinfo *action, u32 val, int width, int uc) { switch (width) { - default: putsinglehex(action, (val >> 28) & 0xf); - case 7: putsinglehex(action, (val >> 24) & 0xf); - case 6: putsinglehex(action, (val >> 20) & 0xf); - case 5: putsinglehex(action, (val >> 16) & 0xf); - case 4: putsinglehex(action, (val >> 12) & 0xf); - case 3: putsinglehex(action, (val >> 8) & 0xf); - case 2: putsinglehex(action, (val >> 4) & 0xf); - case 1: putsinglehex(action, (val >> 0) & 0xf); + default: putsinglehex(action, (val >> 28) & 0xf, uc); + case 7: putsinglehex(action, (val >> 24) & 0xf, uc); + case 6: putsinglehex(action, (val >> 20) & 0xf, uc); + case 5: putsinglehex(action, (val >> 16) & 0xf, uc); + case 4: putsinglehex(action, (val >> 12) & 0xf, uc); + case 3: putsinglehex(action, (val >> 8) & 0xf, uc); + case 2: putsinglehex(action, (val >> 4) & 0xf, uc); + case 1: putsinglehex(action, (val >> 0) & 0xf, uc); } }
// Output an integer in hexadecimal with a minimum width. static void -putprettyhex(struct putcinfo *action, u32 val, int width, char padchar) +putprettyhex(struct putcinfo *action, u32 val, int width, char padchar, int uc) { u32 tmp = val; int count = 1; @@ -196,18 +198,18 @@ putprettyhex(struct putcinfo *action, u32 val, int width, char padchar) width -= count; while (width-- > 0) putc(action, padchar); - puthex(action, val, count); + puthex(action, val, count, uc); }
// Output 'struct pci_device' BDF as %02x:%02x.%x static void put_pci_device(struct putcinfo *action, struct pci_device *pci) { - puthex(action, pci_bdf_to_bus(pci->bdf), 2); + puthex(action, pci_bdf_to_bus(pci->bdf), 2, 0); putc(action, ':'); - puthex(action, pci_bdf_to_dev(pci->bdf), 2); + puthex(action, pci_bdf_to_dev(pci->bdf), 2, 0); putc(action, '.'); - puthex(action, pci_bdf_to_fn(pci->bdf), 1); + puthex(action, pci_bdf_to_fn(pci->bdf), 1, 0); }
static inline int @@ -220,6 +222,7 @@ static void bvprintf(struct putcinfo *action, const char *fmt, va_list args) { const char *s = fmt; + int uc; for (;; s++) { char c = GET_GLOBAL(*(u8*)s); if (!c) @@ -284,19 +287,21 @@ bvprintf(struct putcinfo *action, const char *fmt, va_list args) } putc(action, '0'); putc(action, 'x'); - puthex(action, val, 8); + puthex(action, val, 8, 0); break; + case 'X': case 'x': + uc = (c == 'X'); val = va_arg(args, s32); if (is64) { u32 upper = va_arg(args, s32); if (upper) { - putprettyhex(action, upper, field_width - 8, padchar); - puthex(action, val, 8); + putprettyhex(action, upper, field_width - 8, padchar, uc); + puthex(action, val, 8, uc); break; } } - putprettyhex(action, val, field_width, padchar); + putprettyhex(action, val, field_width, padchar, uc); break; case 'c': val = va_arg(args, int); @@ -348,7 +353,7 @@ __dprintf(const char *fmt, ...) if (cur != &MainThread) { // Show "thread id" for this debug message. debug_putc(&debuginfo, '|'); - puthex(&debuginfo, (u32)cur, 8); + puthex(&debuginfo, (u32)cur, 8, 0); debug_putc(&debuginfo, '|'); debug_putc(&debuginfo, ' '); } @@ -450,12 +455,12 @@ hexdump(const void *d, int len) while (len > 0) { if (count % 8 == 0) { putc(&debuginfo, '\n'); - puthex(&debuginfo, count*4, 8); + puthex(&debuginfo, count*4, 8, 0); putc(&debuginfo, ':'); } else { putc(&debuginfo, ' '); } - puthex(&debuginfo, *(u32*)d, 8); + puthex(&debuginfo, *(u32*)d, 8, 0); count++; len-=4; d+=4;
On 9/30/20 1:12 PM, Gerd Hoffmann wrote:
... via "%X" format string.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com
src/output.c | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé philmd@redhat.com
PNP devices can be declared using eisaid encoding ...
Name (_HID, EisaId ("PNP0103"))
... or as string ...
Name (_HID, "PNP0A06")
.. so lets support both variants.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/fw/dsdt_parser.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/fw/dsdt_parser.c b/src/fw/dsdt_parser.c index 87c1a3ac3a00..eb5496f3515a 100644 --- a/src/fw/dsdt_parser.c +++ b/src/fw/dsdt_parser.c @@ -515,7 +515,8 @@ static void parse_termlist(struct parse_state *s, }
static struct acpi_device *acpi_dsdt_find(struct acpi_device *prev, - const u8 *aml, int size) + const u8 *aml1, int size1, + const u8 *aml2, int size2) { struct acpi_device *dev; struct hlist_node *node; @@ -527,11 +528,13 @@ static struct acpi_device *acpi_dsdt_find(struct acpi_device *prev,
for (; node != NULL; node = dev->node.next) { dev = container_of(node, struct acpi_device, node); - if (!aml) + if (!aml1 && !aml2) return dev; if (!dev->hid_aml) continue; - if (memcmp(dev->hid_aml + 5, aml, size) == 0) + if (aml1 && memcmp(dev->hid_aml + 5, aml1, size1) == 0) + return dev; + if (aml2 && memcmp(dev->hid_aml + 5, aml2, size2) == 0) return dev; } return NULL; @@ -568,19 +571,21 @@ struct acpi_device *acpi_dsdt_find_string(struct acpi_device *prev,
u8 aml[10]; int len = snprintf((char*)aml, sizeof(aml), "\x0d%s", hid); - return acpi_dsdt_find(prev, aml, len); + return acpi_dsdt_find(prev, aml, len, NULL, 0); }
struct acpi_device *acpi_dsdt_find_eisaid(struct acpi_device *prev, u16 eisaid) { if (!CONFIG_ACPI_PARSE) return NULL; - u8 aml[] = { + u8 aml1[] = { 0x0c, 0x41, 0xd0, eisaid >> 8, eisaid & 0xff }; - return acpi_dsdt_find(prev, aml, 5); + u8 aml2[10]; + int len2 = snprintf((char*)aml2, sizeof(aml2), "\x0dPNP%04X", eisaid); + return acpi_dsdt_find(prev, aml1, 5, aml2, len2); }
char *acpi_dsdt_name(struct acpi_device *dev) @@ -651,9 +656,9 @@ void acpi_dsdt_parse(void)
struct acpi_device *dev; dprintf(1, "ACPI: dumping dsdt devices\n"); - for (dev = acpi_dsdt_find(NULL, NULL, 0); + for (dev = acpi_dsdt_find(NULL, NULL, 0, NULL, 0); dev != NULL; - dev = acpi_dsdt_find(dev, NULL, 0)) { + dev = acpi_dsdt_find(dev, NULL, 0, NULL, 0)) { dprintf(1, " %s", acpi_dsdt_name(dev)); if (dev->hid_aml) dprintf(1, ", hid");
On 9/30/20 1:12 PM, Gerd Hoffmann wrote:
PNP devices can be declared using eisaid encoding ...
Name (_HID, EisaId ("PNP0103"))
... or as string ...
Name (_HID, "PNP0A06")
.. so lets support both variants.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com
src/fw/dsdt_parser.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé philmd@redhat.com
On Wed, Sep 30, 2020 at 01:12:20PM +0200, Gerd Hoffmann wrote:
Gerd Hoffmann (2):
output: add support for uppercase hex numbers
dsdt: add support for pnp ids as strings
Thanks. The series looks okay to me.
-Kevin
On Wed, Sep 30, 2020 at 11:28:22AM -0400, Kevin O'Connor wrote:
On Wed, Sep 30, 2020 at 01:12:20PM +0200, Gerd Hoffmann wrote:
Gerd Hoffmann (2):
output: add support for uppercase hex numbers
dsdt: add support for pnp ids as strings
Thanks. The series looks okay to me.
Applied & pushed.
take care, Gerd