summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2025-10-19 21:46:11 -0500
committerDanny Holman <dholman@gymli.org>2025-10-19 21:46:11 -0500
commitca01a62fbc49df5e33bad4200c6defd9983560a8 (patch)
tree33abb40a1a7e3b5c398f1bac9195a9d09411d70e
parentinclude: create the basics of a libc (diff)
downloadbox-ca01a62fbc49df5e33bad4200c6defd9983560a8.tar.gz
box-ca01a62fbc49df5e33bad4200c6defd9983560a8.tar.zst
box-ca01a62fbc49df5e33bad4200c6defd9983560a8.zip
bootstrap: stage1: use the new headers
Have the first stage of the bootloader take advantage of the new files in /usr/include. Signed-off-by: Danny Holman <dholman@gymli.org>
-rw-r--r--bootstrap/stage1/firmware/efi/alloc.c5
-rw-r--r--bootstrap/stage1/firmware/efi/efi.c16
-rw-r--r--bootstrap/stage1/include/tty.h1
3 files changed, 15 insertions, 7 deletions
diff --git a/bootstrap/stage1/firmware/efi/alloc.c b/bootstrap/stage1/firmware/efi/alloc.c
index d57e481..09d3793 100644
--- a/bootstrap/stage1/firmware/efi/alloc.c
+++ b/bootstrap/stage1/firmware/efi/alloc.c
@@ -18,10 +18,7 @@
*/
#include <bootabi/efi.h>
-
-#ifndef NULL
-#define NULL (void*)(0)
-#endif
+#include <stddef.h>
extern uint64_t errno;
extern efi_loaded_image_protocol_t *lip;
diff --git a/bootstrap/stage1/firmware/efi/efi.c b/bootstrap/stage1/firmware/efi/efi.c
index 140a9a6..169ae1f 100644
--- a/bootstrap/stage1/firmware/efi/efi.c
+++ b/bootstrap/stage1/firmware/efi/efi.c
@@ -188,11 +188,21 @@ uint64_t efi_main(void *handle, efi_system_t *st) {
params->firmware_id = FIRMWARE_UEFI;
efi_bootparam_t *uefi_params = balloc(sizeof(efi_bootparam_t));
uefi_params->st = st;
- uefi_params->gop_info = gop->mode->info;
- params->stack_ptr = balloc(4096);
- memset(params->stack_ptr, 0, 4096);
+ uefi_params->gop_mode = gop->mode;
params->firmware_params = (void*)uefi_params;
+ uint64_t heap_addr;
+ status = st->bootsrv->allocate_pages(AllocateAnyPages,
+ LoaderData,
+ 30,
+ &heap_addr);
+ if (status != 0) {
+ print_error(status);
+ return 0;
+ }
+ params->heap_ptr = (void*)heap_addr;
+ params->stack_ptr = balloc(4096);
+
if (load_mmap(uefi_params) == NULL) {
print_error(errno);
return 0;
diff --git a/bootstrap/stage1/include/tty.h b/bootstrap/stage1/include/tty.h
index af0d8f9..b693685 100644
--- a/bootstrap/stage1/include/tty.h
+++ b/bootstrap/stage1/include/tty.h
@@ -21,6 +21,7 @@
#define BOOTSTRAP_TTY_H
#include <stdint.h>
+#include <stddef.h>
void tty_putchar(char c);
char tty_getchar(void);