view bootx64.c.0 @ 0:8d0e5be5d742

test exit boot services
author taiki
date Tue, 19 Mar 2013 14:06:26 +0900
parents
children
line wrap: on
line source

#include <efi.h>
#include <efilib.h>

EFI_STATUS
efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
    InitializeLib(image, systab);

    Print(L"test start.\n");

    EFI_STATUS status = EFI_SUCCESS;
    UINTN size = 0;

    status = uefi_call_wrapper(BS->LocateHandle, 5, ByProtocol, &FileSystemProtocol, NULL, &size, NULL);
    if (size == 0) return EFI_UNSUPPORTED;

    VOID *tmp = 0;
    size = 10 * sizeof(EFI_HANDLE);
    status = uefi_call_wrapper(BS->AllocatePool, 3, EfiLoaderData, size, &tmp);

    if (EFI_SUCCESS != status) {
        Print(L"can not allocate. %r\n", status);
        return status;
    }
    Print(L"===success allocate.\n");

    EFI_HANDLE *buffer = tmp;

    Print(L"size is %d\n", size);
    Print(L"ByProtocol %d\n", ByProtocol);
    Print(L"size %d\n", size);
    Print(L"buffer %d\n", buffer);


    status = uefi_call_wrapper(BS->LocateHandle, 5, ByProtocol, &FileSystemProtocol, NULL, &size, buffer);
    if (status != EFI_SUCCESS) {
        Print(L"can not get handler %r\n", status);
    }
    /*
    status = LibLocateHandle(ByProtocol, &FileSystemProtocol, NULL, &size, buffer);
    if (status != EFI_SUCCESS) {
        Print(L"can not get handler %r\n", status);
        return status;
    }
    */

    EFI_FILE_IO_INTERFACE *volume;
    status = uefi_call_wrapper(BS->HandleProtocol, 3, *buffer, &FileSystemProtocol, (VOID **)&volume);
    if (EFI_ERROR(status)) {
        Print(L"can not get handle protocol");
        return EFI_INVALID_PARAMETER;
    }


    while(1) {
    }


    return EFI_SUCCESS;
}