changeset 11:09ced7d8f64a

improve boot source.
author taiki
date Tue, 22 Jan 2013 02:39:35 +0900
parents 6c0c504fddae
children ac5d699b9787
files boot/Makefile boot/bootx64.c boot/bootx64.efi
diffstat 3 files changed, 22 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/boot/Makefile	Sat Jan 19 01:55:18 2013 +0900
+++ b/boot/Makefile	Tue Jan 22 02:39:35 2013 +0900
@@ -3,10 +3,10 @@
 EFI_INCLUDES    = -I$(EFI_INCLUDE) -I$(EFI_INCLUDE)/$(ARCH) -I$(EFI_INCLUDE)/protocol
 EFI_PATH        = /usr/local/lib
 LIB_GCC         = $(shell $(CC) -print-libgcc-file-name)
-EFI_LIBS        = -lefi -lgnuefi $(LIB_GCC)
+EFI_LIBS        = -lefi -lgnuefi $(LIB_GCC) $(EFI_PATH)/libgnuefi.a $(EFI_PATH)/libefi.a
 EFI_CRT_OBJS    = $(EFI_PATH)/crt0-efi-$(ARCH).o
 EFI_LDS         = $(EFI_PATH)/elf_$(ARCH)_efi.lds
-CFLAGS          = -O2 -fno-stack-protector -fno-strict-aliasing -fpic -fshort-wchar -Wall -Werror $(EFI_INCLUDES)
+CFLAGS          = -O2 -mno-red-zone -fno-stack-protector -fno-strict-aliasing -fpic -fshort-wchar -fno-merge-constants -Wall -Werror $(EFI_INCLUDES)
 
 ifeq ($(ARCH),x86_64)
 	CFLAGS  += -DEFI_FUNCTION_WRAPPER
--- a/boot/bootx64.c	Sat Jan 19 01:55:18 2013 +0900
+++ b/boot/bootx64.c	Tue Jan 22 02:39:35 2013 +0900
@@ -1,13 +1,32 @@
 #include <efi.h>
 #include <efilib.h>
 
+#define LOCALFS_F2FD(f)		((UINTN)(f))
+#define LOCALFS_FD2F(fd)	((EFI_FILE_HANDLE)(fd))
 
 EFI_STATUS
 efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *system_table)
 {
     InitializeLib(image, system_table);
 
-    Print(L"Hello, World\n");
+
+    //EFI_FILE_HANDLE volume, fh;
+
+    EFI_LOADED_IMAGE *info;
+    CHAR16 *kname = L"kernel";
+    Print(L"Boot start. %s , %d:\n", kname);
+
+    uefi_call_wrapper(BS->SetWatchdogTimer, 4, 0, 0x0, 0, NULL);
+    Print(L"Set watchdog timer.\n");
+
+	EFI_STATUS status = uefi_call_wrapper(BS->HandleProtocol, 3, image, &LoadedImageProtocol, (VOID **) &info);
+	// status = uefi_call_wrapper(volume->Open, 5, volume, &fh, name, EFI_FILE_MODE_READ, (UINT64)0);
+
+    if (status == EFI_SUCCESS) {
+        Print(L"Opening kernel executable file is success.\n");
+    } else {
+        Print(L"Invalid open kernel executable file.\n");
+    }
 
     while (1)
     {
Binary file boot/bootx64.efi has changed