Compare commits

..

3 Commits

Author SHA1 Message Date
352db828e7 Modify existing Makefile to allow compilation of UEFI app.
Added targets for the main files - BOOTX64.EFI, data.c and entry.c
Also minor formatting changes, but whatever.
2019-07-17 15:45:24 +01:00
ab9be9fd4f Finalize removal of BIOS/GRUB artifacts. 2019-07-17 15:44:29 +01:00
c59a95ebfa Populate UEFI entry point. 2019-07-17 15:17:01 +01:00
7 changed files with 71 additions and 22 deletions

View File

@ -0,0 +1,52 @@
/************************
*** Team Kitty, 2019 ***
*** Sync ***
***********************/
/* The entry point of the UEFI app.
* When the firmware loads the app,
* it calls the efi_main function.
*
* When it is called, the processor
* is running in 32-bit Protected mode.
* It is given a map of memory, and there
* are a bunch of Boot Services provided
* by the UEFI firmware.
*
* See uefi/docs for more information.
*/
//Example stolen from osdev.org/uefi_bare_bones
#include <efi.h>
#include <efilib.h>
EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
EFI_STATUS Status;
EFI_INPUT_KEY Key;
/* Store the system table for future use in other functions */
ST = SystemTable;
/* Say hi */
Status = ST->ConOut->OutputString(ST->ConOut, L"Hello World\n\r");
if (EFI_ERROR(Status))
return Status;
/* Now wait for a keystroke before continuing, otherwise your
message will flash off the screen before you see it.
First, we need to empty the console input buffer to flush
out any keystrokes entered before this point */
Status = ST->ConIn->Reset(ST->ConIn, FALSE);
if (EFI_ERROR(Status))
return Status;
/* Now wait until a key becomes available. This is a simple
polling implementation. You could try and use the WaitForKey
event instead if you like */
while ((Status = ST->ConIn->ReadKeyStroke(ST->ConIn, &Key)) == EFI_NOT_READY) ;
return Status;
}

View File

@ -1,7 +0,0 @@
set timeout=10
set default=0
menuentry "ProjectRED" {
multiboot /boot/red.kernel
boot
}

View File

@ -1,5 +0,0 @@
defualt=0
timeout=0
title ProjectRED
kernel /boot/kernel.elf

Binary file not shown.

View File

@ -28,26 +28,26 @@ CPPFLAGS:=$(CPPFLAGS) $(KERNEL_ARCH_CPPFLAGS)
LDFLAGS:=$(LDFLAGS) $(KERNEL_ARCH_LDFLAGS) LDFLAGS:=$(LDFLAGS) $(KERNEL_ARCH_LDFLAGS)
LIBS:=$(LIBS) $(KERNEL_ARCH_LIBS) LIBS:=$(LIBS) $(KERNEL_ARCH_LIBS)
KERNEL_OBJS= \ KERNEL_OBJS= \
$(KERNEL_ARCH_OBJS) \ $(KERNEL_ARCH_OBJS) \
kernel/utils.o \ kernel/utils.o \
kernel/serial.o \ kernel/serial.o \
kernel/interrupts.o \ kernel/interrupts.o \
kernel/descriptor_tables.o\ kernel/descriptor_tables.o \
kernel/kernel.o kernel/kernel.o
OBJS=\ OBJS=\
$(KERNEL_OBJS) $(KERNEL_OBJS)
LINK_LIST=\ LINK_LIST=\
$(LDFLAGS) \ $(LDFLAGS) \
$(KERNEL_OBJS) \ $(KERNEL_OBJS) \
$(LIBS) \ $(LIBS) \
.PHONY: all clean install install-headers install-kernel .PHONY: all clean install install-headers install-kernel
.SUFFIXES: .o .c .s .SUFFIXES: .o .c .s
all: red.kernel all: BOOTX64.EFI
red.kernel: $(OBJS) $(ARCHDIR)/linker.ld red.kernel: $(OBJS) $(ARCHDIR)/linker.ld
$(CC) -T $(ARCHDIR)/linker.ld -o $@ $(CFLAGS) $(LINK_LIST) $(CC) -T $(ARCHDIR)/linker.ld -o $@ $(CFLAGS) $(LINK_LIST)
@ -88,4 +88,13 @@ gen-iso:
-o red.iso \ -o red.iso \
iso iso
BOOTX64.EFI: arch/uefi/entry.o efi/lib/data.o
$(EFI-CC) -nostdlib -Wl,-dll -shared -Wl,--subsystem,10 -e efi_main -o BOOTX64.EFI arch/uefi/entry.o data.o -lgcc
arch/uefi/entry.o:
$(EFI-CC) -ffreestanding -Iinclude/efi/ -Iinclude/efi/x86_64 -Iinclude/efi/protocol -c -o arch/uefi/entry.o arch/uefi/entry.c
efi/lib/data.o:
$(EFI-CC) -ffreestanding -Iinclude/efi/ -Iinclude/efi/x86_64 -Iinclude/efi/protocol -c -o data.o efi/lib/data.c
-include $(OBJS:.o=.d) -include $(OBJS:.o=.d)

Binary file not shown.