summaryrefslogtreecommitdiff
path: root/shim
diff options
context:
space:
mode:
Diffstat (limited to 'shim')
-rw-r--r--shim/Makefile5
-rw-r--r--shim/kc_main.c (renamed from shim/entry.c)32
-rw-r--r--shim/shim.ld49
3 files changed, 12 insertions, 74 deletions
diff --git a/shim/Makefile b/shim/Makefile
index 42007b8..7183088 100644
--- a/shim/Makefile
+++ b/shim/Makefile
@@ -14,11 +14,12 @@ CFLAGS += -Wno-unused-const-variable -Wno-unused-function -fvisibility=hidden \
-g -fshort-wchar -mgeneral-regs-only
LIBDIRS += -L$(dir $(shell $(CC) -print-libgcc-file-name))
-LDSCRIPT := shim.ld
+LDSCRIPT := ../lib/component.ld
LDFLAGS += -z max-page-size=4096 --export-dynamic -pic --no-dynamic-linker
LOADLIBES := -lgcc
-OBJS := entry.o elf.o memcmp.o memcpy.o memmove.o memset.o
+OBJS := entry_x86_64.o reloc_x86_64.o kc_main.o elf64.o memcmp.o memcpy.o \
+ memmove.o memset.o
$(OBJS): CFLAGS += -fPIC
DEPS := $(patsubst %.o,%.d,$(OBJS))
diff --git a/shim/entry.c b/shim/kc_main.c
index a4d00c7..1829616 100644
--- a/shim/entry.c
+++ b/shim/kc_main.c
@@ -37,38 +37,24 @@ struct efi_loader_image kernel_image =
.path = L"\\adasoft\\sophia\\kernel.os"
};
-static struct efi_loader_image *shim_image;
static struct efi_boot_data boot_data;
-EFI_STATUS efi_shim_entry(struct efi_loader_image *image,
- struct efi_loader_interface *interface)
-{
- /* 1. load kernel and boot modules into memory
- * 2. generate page tables for kernel and boot modules
- * 2. gather boot data, store as type SystemMemoryType
- * 3. exit boot services
- * 5. ???????????
- */
-
- void *image_base = (void *)image->buffer_base;
+// TODO: split relocation code out into library
- elf_reloc(image_base);
+EFI_STATUS kc_main(struct efi_loader_interface *interface)
+{
+ // 1. load kernel and boot modules into memory
+ // 2. generate page tables for kernel and boot modules
+ // 2. gather boot data, store as type SystemMemoryType
+ // 3. exit boot services
+ // 5. ???????????
EFI_STATUS status;
- if (!image)
+ if (!interface)
{
return EFI_INVALID_PARAMETER;
}
- else if (!shim_image)
- {
- shim_image = image;
- kernel_image.image_handle = shim_image->image_handle;
- }
- else
- {
- return EFI_ALREADY_STARTED;
- }
if (!EFI_ERROR((status = interface->image_open(&kernel_image))) &&
!EFI_ERROR((status = interface->image_alloc(&kernel_image))) &&
diff --git a/shim/shim.ld b/shim/shim.ld
deleted file mode 100644
index f0643ca..0000000
--- a/shim/shim.ld
+++ /dev/null
@@ -1,49 +0,0 @@
-ENTRY(efi_shim_entry)
-
-SECTIONS
-{
- . = sizeof_headers;
-
- .rel :
- {
- *(.rel.*)
- }
-
- .rela :
- {
- *(.rela.*)
- }
-
- .text : ALIGN(4K)
- {
- PROVIDE(_text_begin = .);
- *(.text)
- . = ALIGN(4K);
- PROVIDE(_text_end = .);
- } =0xcc
-
- .data :
- {
- PROVIDE(_data_begin = .);
- *(.rodata)
- *(.data)
- }
-
- .data.rel :
- {
- *(.data.rel)
- *(.data.rel.*)
- }
-
- .bss :
- {
- *(.bss)
- PROVIDE(_data_end = .);
- }
-
- /DISCARD/ :
- {
- *(.eh_frame)
- }
-}
-