changeset 9:d6a8d676a1ac

add load kernel function, but the function don't have important process
author taiki
date Sun, 30 Mar 2014 01:41:35 +0900
parents b4db4b6c8d00
children 0c55588d01b0
files bootx64.c
diffstat 1 files changed, 72 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/bootx64.c	Fri Mar 28 21:29:59 2014 +0900
+++ b/bootx64.c	Sun Mar 30 01:41:35 2014 +0900
@@ -4,9 +4,70 @@
 #include "registers.h"
 
 EFI_STATUS
+load_kernel()
+{
+    Print(L"Start load kernel.\n");
+
+    EFI_STATUS status;
+    UINTN handle_count;
+    EFI_HANDLE *handle_buffer;
+    SIMPLE_READ_FILE read_handle = NULL;
+
+    status = uefi_call_wrapper(BS->LocateHandleBuffer,
+                5,
+                ByProtocol,
+                &FileSystemProtocol,
+                NULL,
+                &handle_count,
+                &handle_buffer);
+
+    if (EFI_ERROR(status)) {
+        Print(L"LocateHandleBuffer is %r\n", status);
+    }
+
+    EFI_DEVICE_PATH *path;
+    UINTN handle_idx = 0;
+
+    for (handle_idx = 0; handle_idx < handle_count; handle_idx++) {
+        EFI_HANDLE device_handle;
+
+        //path = FileDevicePath(handle_buffer[handle_idx], kernel_image);
+
+        if (!path) {
+            status = EFI_NOT_FOUND;
+            break;
+        }
+
+        status = OpenSimpleReadFile(TRUE, NULL, 0, &path, &device_handle, &read_handle);
+
+        if (EFI_ERROR(status)) {
+            FreePool(path);
+            path = NULL;
+        }
+        break;
+    }
+
+    if (!EFI_ERROR(status)) {
+        //status = LoadImage(read_handle);
+    }
+
+    if (read_handle) {
+        CloseSimpleReadFile(read_handle);
+    }
+
+    if (path) {
+        FreePool(path);
+    }
+
+    FreePool(handle_buffer);
+
+    return status;
+}
+
+EFI_STATUS
 efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
 {
-    EFI_LOADED_IMAGE *loadedImage;
+    EFI_LOADED_IMAGE *loaded_image;
 
     InitializeLib(image, systab);
 
@@ -16,13 +77,13 @@
 
     EFI_STATUS status;
     
-    Print(L"Open Protocol\n");
+    Print(L"Open LoadedImage Protocol\n");
     status = uefi_call_wrapper(
         BS->OpenProtocol,
         6,
         image,
         &LoadedImageProtocol,
-        (void **)&loadedImage,
+        (void **)&loaded_image,
         image,
         NULL,
         EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
@@ -31,7 +92,12 @@
         Print(L"OpenProtocol is %r\n", status);
     }
 
-    Print(L"Close Protocol\n");
+    Print(L"%s\n", loaded_image->LoadOptions);
+
+    load_kernel();
+
+
+    Print(L"Close LoadedImage Protocol\n");
     status = uefi_call_wrapper(
         BS->CloseProtocol,
         4,
@@ -44,6 +110,8 @@
         Print(L"CloseProtocol is %r\n", status);
     }
 
+    Print(L"---- Faild start kernel ----\n");
 
     return EFI_SUCCESS;
 }
+