commit 4e2032cfc790bbe0f8686ccafbf472d2285884b0
parent ae621d8d640936605da8bed4a8312f7a997369a5
Author: Matsuda Kenji <info@mtkn.jp>
Date: Fri, 5 Apr 2024 15:09:07 +0900
change stack area
Diffstat:
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/sys/src/Makefile b/sys/src/Makefile
@@ -27,10 +27,12 @@ boot/boot.efi: boot/boot.dll
boot/boot.dll: boot/boot.c boot/utils.c
$(BOOTCC) $(BOOTCFLAGS) -o $@ boot/boot.c boot/utils.c
-kernel/main.elf: kernel/main.o kernel/draw.o kernel/alloc.o kernel/console.o kernel/memmap.ld ../lib/libc.a
- $(LD) $(LDFLAGS) -e kernel_main -T kernel/memmap.ld -o $@ \
- kernel/main.o kernel/draw.o kernel/alloc.o kernel/console.o \
+kernel/main.elf: kernel/start.o kernel/main.o kernel/draw.o kernel/alloc.o kernel/console.o kernel/memmap.ld ../lib/libc.a
+ $(LD) $(LDFLAGS) -e kernel_start -T kernel/memmap.ld -o $@ \
+ kernel/start.o kernel/main.o kernel/draw.o kernel/alloc.o kernel/console.o \
-lc
+kernel/start.o: kernel/start.s
+ $(CC) $(CFLAGS) -c -o $@ kernel/start.s
kernel/main.o: kernel/main.c ../include/uefi.h ../include/libc.h ../include/draw.h ../include/console.h
$(CC) $(CFLAGS) -c -o $@ kernel/main.c
kernel/draw.o: kernel/draw.c ../include/uefi.h ../include/libc.h ../include/draw.h ../include/console.h
diff --git a/sys/src/kernel/main.c b/sys/src/kernel/main.c
@@ -4,10 +4,13 @@
#include <console.h>
error err;
+uint8 kernel_main_stack[1024];
void
kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
{
+ EFI_GRAPHICS_OUTPUT_PROTOCOL _gop = *gop;
+ gop = &_gop;
if (init_root_window(
(uint32 *)gop->Mode->FrameBufferBase,
gop->Mode->Info->HorizontalResolution,
@@ -41,9 +44,8 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
.max = (Point){150 + 400, 100 + 300}
};
clear(&win0);
- border(&root_window, rect, 5, 0xaa666600);
- border(&root_window, rect, 0, 0x00000000);
- cons_printf(&con0, "hello window!\n");
+ border(&root_window, rect, -3, 0xaa666600);
+ cons_printf(&con0, "hello world!\n");
halt:
for(;;) { __asm__("hlt"); }
diff --git a/sys/src/kernel/start.s b/sys/src/kernel/start.s
@@ -0,0 +1,10 @@
+ .global kernel_start
+kernel_start:
+ push %rbp
+ mov %rsp, %rbx /* rbx is preserved in sysv abi. */
+ mov $(kernel_main_stack + 1024 * 1024), %rsp
+ mov %rsp, %rbp
+ call kernel_main
+ mov %rbx, %rsp
+ pop %rbp
+ ret
+\ No newline at end of file