Mercurial > hg > Members > taiki > EFITest
view bootx64.c @ 1:259b5f0e03ba
add registers.h
author | taiki |
---|---|
date | Tue, 26 Mar 2013 17:51:58 +0900 |
parents | 8d0e5be5d742 |
children | 14b7a92d960b |
line wrap: on
line source
#include <efi.h> #include <efilib.h> #include "registers.h" EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) { InitializeLib(image, systab); Print(L"test start.\n"); UINTN map_size, cookie, size, version; map_size = EFI_PAGE_SIZE * 2; EFI_MEMORY_DESCRIPTOR *md; EFI_STATUS status = uefi_call_wrapper(BS->AllocatePool, 3, EfiLoaderData, map_size, &md); if (EFI_ERROR(status)) { Print(L"error 'allocate pool' %r \n", status); } status = uefi_call_wrapper(BS->GetMemoryMap, 5, &map_size, md, &cookie, &size, &version); if (EFI_ERROR(status)) { Print(L"error 'get memory map' %r \n", status); } /* UINTN nr_map = map_size/size; UINTN i; for (i=0; i <nr_map ;i++) { EFI_MEMORY_DESCRIPTOR p = md[i]; switch (p.Type) { case EfiReservedMemoryType: Print(L"| reserved memory."); break; case EfiLoaderCode: Print(L"| loader code."); break; case EfiLoaderData: Print(L"| loader data."); break; case EfiBootServicesCode: Print(L"| boot services code."); break; case EfiBootServicesData: Print(L"| boot services data."); break; case EfiConventionalMemory: Print(L"| conventional memory."); break; case EfiUnusableMemory: Print(L"| unusable memory."); break; case EfiACPIReclaimMemory: Print(L"| ACPI reclaim memory."); break; case EfiACPIMemoryNVS: Print(L"| ACPI memory NVS."); break; case EfiMemoryMappedIO: Print(L"| memory mapped IO."); break; case EfiMemoryMappedIOPortSpace: Print(L"| memory mapped IO port space."); break; case EfiPalCode: Print(L"| pal code. "); break; case EfiMaxMemoryType: Print(L"| max memory type."); break; } } */ status = uefi_call_wrapper(BS->ExitBootServices, 2, image, cookie); if (EFI_ERROR(status)) { Print(L"error 'exit boot services' %r \n", status); } asm volatile ("cli" ::); cr0_t cr0; asm volatile("mov %%cr0,%0\n\t" : "=r" (cr0)); while(1) { } cr0.pg = 0; asm volatile("mov %0, %%cr0" : : "r" (cr0)); return EFI_SUCCESS; }