@@ -407,7 +407,7 @@ void acpi_lite_dump_tables(bool full_dump) {
407407 }
408408}
409409
410- status_t acpi_process_madt_entries_etc (const uint8_t search_type, const madt_entry_callback callback) {
410+ status_t acpi_process_madt_entries_etc (const uint8_t search_type, const madt_entry_callback callback, void *cookie ) {
411411 const acpi_madt_table* madt =
412412 reinterpret_cast <const acpi_madt_table*>(acpi_get_table_by_sig (ACPI_MADT_SIG));
413413 if (!madt) {
@@ -417,14 +417,17 @@ status_t acpi_process_madt_entries_etc(const uint8_t search_type, const madt_ent
417417 // bytewise array of the same table
418418 const uint8_t * madt_array = reinterpret_cast <const uint8_t *>(madt);
419419
420+ LTRACEF (" table at %p\n " , madt_array);
421+
420422 // walk the table off the end of the header, looking for the requested type
421423 size_t off = sizeof (*madt);
422424 while (off < madt->header .length ) {
423425 uint8_t type = madt_array[off];
424426 uint8_t length = madt_array[off + 1 ];
425427
428+ LTRACEF (" type %u, length %u\n " , type, length);
426429 if (type == search_type) {
427- callback (static_cast <const void *>(&madt_array[off]), length);
430+ callback (static_cast <const void *>(&madt_array[off]), length, cookie );
428431 }
429432
430433 off += length;
@@ -433,4 +436,32 @@ status_t acpi_process_madt_entries_etc(const uint8_t search_type, const madt_ent
433436 return NO_ERROR;
434437}
435438
439+ void acpi_lite_dump_madt_table () {
440+ auto local_apic_callback = [](const void *_entry, size_t entry_len, void *cookie) {
441+ const auto *entry = reinterpret_cast <const struct acpi_madt_local_apic_entry *>(_entry);
442+
443+ printf (" \t LOCAL APIC id %d, processor id %d, flags %#x\n " ,
444+ entry->apic_id , entry->processor_id , entry->flags );
445+ };
446+
447+ auto io_apic_callback = [](const void *_entry, size_t entry_len, void *cookie) {
448+ const auto *entry = reinterpret_cast <const struct acpi_madt_io_apic_entry *>(_entry);
449+
450+ printf (" \t IO APIC id %d, address %#x gsi base %u\n " ,
451+ entry->io_apic_id , entry->io_apic_address , entry->global_system_interrupt_base );
452+ };
453+
454+ auto int_source_override_callback = [](const void *_entry, size_t entry_len, void *cookie) {
455+ const auto *entry = reinterpret_cast <const struct acpi_madt_int_source_override_entry *>(_entry);
456+
457+ printf (" \t INT OVERRIDE bus %u, source %u, gsi %u, flags %#x\n " ,
458+ entry->bus , entry->source , entry->global_sys_interrupt , entry->flags );
459+ };
460+ printf (" MADT/APIC table:\n " );
461+ acpi_process_madt_entries_etc (ACPI_MADT_TYPE_LOCAL_APIC, local_apic_callback, nullptr );
462+ acpi_process_madt_entries_etc (ACPI_MADT_TYPE_IO_APIC, io_apic_callback, nullptr );
463+ acpi_process_madt_entries_etc (ACPI_MADT_TYPE_INT_SOURCE_OVERRIDE, int_source_override_callback, nullptr );
464+ }
465+
466+
436467// vim: set ts=2 sw=2 expandtab:
0 commit comments