Skip to content

Instantly share code, notes, and snippets.

@naoki9911
Created September 16, 2018 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naoki9911/0f629aafac3cb9652b72d365d5fdfe75 to your computer and use it in GitHub Desktop.
Save naoki9911/0f629aafac3cb9652b72d365d5fdfe75 to your computer and use it in GitHub Desktop.
VOID *vendor_table;
Status = EfiGetSystemConfigurationTable(&gEfiAcpiTableGuid,&vendor_table);
struct rsdp *acpi_rsdp = (struct rsdp *)vendor_table;
Print(L"Signature:");
UINTN i;
for(i=0;i<6;i++){
Print(L"%c",acpi_rsdp->sig[i]);
}
Print(L"\n");
Print(L"XSDT Address: %08x\n",acpi_rsdp->XsdtAddress);
Status = gBS->AllocatePages(AllocateAddress,EfiLoaderData,1,&BootParamAddr);
if(EFI_ERROR(Status)){
Print(L"Can not allocate boot param address\n");
}
struct xsdt *acpi_xsdt = (struct xsdt *)acpi_rsdp->XsdtAddress;
struct madt *acpi_madt;
struct boot_param *boot_param = (struct boot_param *)BootParamAddr;
UINTN entries = (acpi_xsdt->h.len - sizeof(acpi_xsdt->h)) / 8;
for(i=0;i<entries;i++){
struct sdt_header *h = (struct sdt_header *)acpi_xsdt->pointer_others[i];
if(!AsciiStrnCmp(h->sig,"APIC",4)){
Print(L"Signature:");
UINTN j;
for(j=0;j<4;j++){
AsciiPrint("%c",h->sig[j]);
}
Print(L"\n");
Print(L"MADT Address: %p\n",h);
acpi_madt = (struct madt *)h;
boot_param->madt_addr = (UINT64)(boot_param+sizeof(struct boot_param));
CopyMem((VOID *)(boot_param->madt_addr),(VOID *)h,h->len);
Print(L"MADR_ADDR: %x \n",boot_param->madt_addr);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment