changeset 20:5e184d4c01b8

test uefi call wrapper now
author taiki
date Sun, 10 Feb 2013 00:15:05 +0900
parents 2fbe46f63d4c
children e3accb15b1bb
files boot/bootx64.c boot/bootx64.efi boot/config.c
diffstat 3 files changed, 35 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/boot/bootx64.c	Fri Feb 08 19:12:05 2013 +0900
+++ b/boot/bootx64.c	Sun Feb 10 00:15:05 2013 +0900
@@ -8,6 +8,13 @@
 #include "bootx64.h"
 #include "mach-o/mach_o.h"
 
+extern EFI_STATUS open(fs_t *fs, EFI_FILE_HANDLE *fd, CHAR16 *name); 
+extern EFI_STATUS close(fs_t *fs, EFI_FILE_HANDLE *fd);
+extern EFI_STATUS read(fs_t *fs, EFI_FILE_HANDLE *fd, VOID *buf, UINTN *size);
+extern EFI_STATUS seek(fs_t *fs, EFI_FILE_HANDLE *fd, UINTN newpos);
+extern EFI_STATUS load(fs_t *fs, EFI_FILE_HANDLE *fd, CHAR16 *kname);
+extern EFI_STATUS config_fs(fs_t *fs,EFI_HANDLE boot_handle, dev_tab_t *boot_dev);
+
 static inline void
 start_kernel()
 {
@@ -24,10 +31,11 @@
     CHAR16 *kname = L"kernel";
     Print(L"Boot start. %s\n", kname);
 
-    uefi_call_wrapper(BS->SetWatchdogTimer, 4, 0, 0x0, 0, NULL);
+    EFI_STATUS status = uefi_call_wrapper(BS->SetWatchdogTimer, 4, 0, 0x0, 0, NULL);
+    if (EFI_ERROR(status)) return status;
     Print(L"Set watchdog timer.\n");
 
-    EFI_STATUS status = uefi_call_wrapper(BS->HandleProtocol, 3, image, &LoadedImageProtocol, (VOID **) &info);
+    status = uefi_call_wrapper(BS->HandleProtocol, 3, image, &LoadedImageProtocol, (VOID **) &info);
     if (EFI_ERROR(status)) {
         Print(L"Load error.\n");
         return EFI_LOAD_ERROR;
@@ -35,7 +43,7 @@
 
     fs_t fs;
     dev_tab_t boot_dev;
-    status = config_fs(info->DeviceHandle, &fs, &boot_dev);
+    status = config_fs(&fs, info->DeviceHandle ,&boot_dev);
 
     EFI_FILE_HANDLE fd;
     open(&fs, &fd, kname);
Binary file boot/bootx64.efi has changed
--- a/boot/config.c	Fri Feb 08 19:12:05 2013 +0900
+++ b/boot/config.c	Sun Feb 10 00:15:05 2013 +0900
@@ -87,43 +87,53 @@
 }
 
 EFI_STATUS
-config_fs(fs_t *fs, EFI_HANDLE boot_handle, dev_tab_t *boot_dev)
+config_fs(EFI_HANDLE boot_handle, fs_t *fs, dev_tab_t *boot_dev)
 {
-    UINTN i;
-    EFI_GUID *proto = NULL;
-
     Print(L"configure filesystems for all volume. \n");
 
     UINTN size = 0;
-    uefi_call_wrapper(BS->LocateHandle, 5, ByProtocol, &FileSystemProtocol, NULL, &size, NULL);
+    EFI_STATUS status = uefi_call_wrapper(BS->LocateHandle, 5, ByProtocol, &FileSystemProtocol, NULL, &size, NULL);
     if (size == 0) return EFI_UNSUPPORTED;
+    if (EFI_ERROR(status)) Print(L"efi unsupported. can not get handler.\n");
 
     Print(L"find device, size=%d\n", size);
 
-    dev_tab_t *dev_tab = NULL;
+    EFI_HANDLE *eh_tab = NULL;
 
     /* alloc */
-    EFI_STATUS status = uefi_call_wrapper(BS->AllocatePool, 3, EfiLoaderData, size, (VOID **)dev_tab);
-    if (EFI_ERROR(status)) { 
+    status = uefi_call_wrapper(BS->AllocatePool, 3, EfiLoaderData, size, (VOID **)eh_tab);
+    if (EFI_NOT_FOUND != status) { 
         Print(L"can not allocate.\n");
         return status;
     }
 
+    status = uefi_call_wrapper(BS->LocateHandle, 5, ByProtocol, &FileSystemProtocol, NULL, &size, (VOID **)eh_tab);
+    if (EFI_NOT_FOUND == status) Print(L"EFI_NOT_FOUND\n");
+    if (EFI_BUFFER_TOO_SMALL == status) Print(L"EFI_BUFFER_TOO_SMALL.\n");
+    if (EFI_INVALID_PARAMETER == status) Print(L"EFI_INVALID_PARAMETER.\n");
+    if (EFI_ERROR(status)) { 
+        Print(L"can not get handler.\n");
+        return status;
+    }
+    
     UINTN ndev = size / sizeof(EFI_HANDLE);
 
+    UINTN i;
     for (i = 0; i < ndev; i++) {
         VOID *fs = NULL;
-        config_fs_one(dev_tab[i].dev, fs);
-        dev_tab[i].fs = fs;
+        //config_fs_one(eh_tab[i].dev, fs);
+        //dev_tab[i].fs = fs;
+        config_fs_one(eh_tab[i], fs);
     }
 
+    EFI_GUID proto = LOCALFS_PROTOCOL;
     status = uefi_call_wrapper(BS->LocateHandle, 5, ByProtocol, proto, NULL, &size, NULL);
     if (EFI_ERROR(status)) {
         Print(L"No useable filesystem found.\n");
         return status;
     }
     
-    SetMem(proto, sizeof(EFI_HANDLE), 0);
+    SetMem(&proto, sizeof(EFI_HANDLE), 0);
 
     uefi_call_wrapper(BS->LocateHandle, 5, ByProtocol, &proto, NULL, &size, NULL);
 
@@ -141,8 +151,9 @@
     UINTN idx = 0;
 
     for (i=0; i<size; i++) { 
-        dev_tab[idx].dev = tab[i];
-        if (tab[i] == boot_handle) boot_dev = dev_tab + idx;
+        //dev_tab[idx].dev = tab[i];
+        eh_tab[idx] = tab[i];
+        // if (tab[i] == boot_handle) boot_dev = eh_tab + idx;
         idx++;
     }