From bff63a4337eb3388617d230970c5eb2684d6a215 Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Sun, 19 Dec 2021 01:16:51 +0000 Subject: i don't know what i'm doing anymore --- kernel/Makefile | 7 +----- kernel/entry.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ kernel/entry_efi.c | 69 ------------------------------------------------------ 3 files changed, 70 insertions(+), 75 deletions(-) create mode 100644 kernel/entry.c delete mode 100644 kernel/entry_efi.c (limited to 'kernel') diff --git a/kernel/Makefile b/kernel/Makefile index 7caf69c..407c4bb 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -5,11 +5,6 @@ VPATH := ../lib TARGET := kernel.os .DEFAULT: $(TARGET) -# EFI API for temporary things - -EFIAPIDIR := /usr/local/include/efi - -CPPFLAGS += -I../api -I$(EFIAPIDIR) -I$(EFIAPIDIR)/$(ARCH) -I$(EFIAPIDIR)/protocol CFLAGS += -Wno-unused-const-variable -Wno-unused-function -fvisibility=hidden -g LIBDIRS += -L$(dir $(shell $(CC) -print-libgcc-file-name)) @@ -18,7 +13,7 @@ LDFLAGS += -z max-page-size=4096 --export-dynamic LOADLIBES := -lgcc SOBJS := -GOBJS := entry_efi.o kprint.o serial.o port.o main.o memory.o \ +GOBJS := entry.o kprint.o serial.o port.o main.o memory.o \ memset.o memcpy.o memmove.o memcmp.o cpu.o exceptions.o \ panic.o IOBJS := diff --git a/kernel/entry.c b/kernel/entry.c new file mode 100644 index 0000000..5eecaf2 --- /dev/null +++ b/kernel/entry.c @@ -0,0 +1,69 @@ +#include "cpu.h" +#include "serial.h" +#include "kprint.h" +#include "memory.h" +#include "panic.h" + +#include + +#include + +#include +#include +#include +#include + +static void efi_memory_init(struct efi_memory_map_data *map) +{ + // FIXME: bad girl shit: overwriting on aliased pointers. + // this is a temporary solution to shortcomings with + // loader boot data. it's sort-of OK because the memory_range struct + // is smaller than EFI_MEMORY_DESCRIPTOR. it's still not good. + struct memory_range *ranges = (struct memory_range *)map->data; + int entries = map->size / map->descsize; + + for (int i = 0; i < entries; i++) + { + EFI_MEMORY_DESCRIPTOR *desc; + desc = (EFI_MEMORY_DESCRIPTOR *)((char *)map->data + i * map->descsize); + + enum memory_range_type type; + phys_addr_t base; + size_t size; + + base = desc->PhysicalStart; + size = desc->NumberOfPages * EFI_PAGE_SIZE; + + switch (desc->Type) + { + case EfiConventionalMemory: + case EfiBootServicesData: + case EfiBootServicesCode: + case EfiLoaderData: + case EfiLoaderCode: + type = AVAILABLE_MEMORY; + break; + case SystemMemoryType: + type = SYSTEM_MEMORY; + break; + default: + type = RESERVED_MEMORY; + } + + ranges[i].type = type; + ranges[i].base = base; + ranges[i].size = size; + } + + memory_init(ranges, entries); +} + +noreturn void kernel_entry(struct efi_boot_data *data) +{ + (void)data; + cpu_init(); + serial_init(); + kputs(" i'm in\r\n"); + efi_memory_init(data->memory_map); + halt(); +} diff --git a/kernel/entry_efi.c b/kernel/entry_efi.c deleted file mode 100644 index 5eecaf2..0000000 --- a/kernel/entry_efi.c +++ /dev/null @@ -1,69 +0,0 @@ -#include "cpu.h" -#include "serial.h" -#include "kprint.h" -#include "memory.h" -#include "panic.h" - -#include - -#include - -#include -#include -#include -#include - -static void efi_memory_init(struct efi_memory_map_data *map) -{ - // FIXME: bad girl shit: overwriting on aliased pointers. - // this is a temporary solution to shortcomings with - // loader boot data. it's sort-of OK because the memory_range struct - // is smaller than EFI_MEMORY_DESCRIPTOR. it's still not good. - struct memory_range *ranges = (struct memory_range *)map->data; - int entries = map->size / map->descsize; - - for (int i = 0; i < entries; i++) - { - EFI_MEMORY_DESCRIPTOR *desc; - desc = (EFI_MEMORY_DESCRIPTOR *)((char *)map->data + i * map->descsize); - - enum memory_range_type type; - phys_addr_t base; - size_t size; - - base = desc->PhysicalStart; - size = desc->NumberOfPages * EFI_PAGE_SIZE; - - switch (desc->Type) - { - case EfiConventionalMemory: - case EfiBootServicesData: - case EfiBootServicesCode: - case EfiLoaderData: - case EfiLoaderCode: - type = AVAILABLE_MEMORY; - break; - case SystemMemoryType: - type = SYSTEM_MEMORY; - break; - default: - type = RESERVED_MEMORY; - } - - ranges[i].type = type; - ranges[i].base = base; - ranges[i].size = size; - } - - memory_init(ranges, entries); -} - -noreturn void kernel_entry(struct efi_boot_data *data) -{ - (void)data; - cpu_init(); - serial_init(); - kputs(" i'm in\r\n"); - efi_memory_init(data->memory_map); - halt(); -} -- cgit v1.3.1-1-g115d