From 565bb8cd2569a292d70be87482d8fe93279a8970 Mon Sep 17 00:00:00 2001 From: icexin Date: Sat, 31 Jul 2021 22:18:15 +0800 Subject: [PATCH] fix boot entry type --- boot/boot64main.c | 21 ++++----------------- boot/multiboot.c | 5 +++-- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/boot/boot64main.c b/boot/boot64main.c index ce6ae53..b3d50d6 100644 --- a/boot/boot64main.c +++ b/boot/boot64main.c @@ -2,27 +2,14 @@ typedef unsigned short uint16; typedef unsigned int uint32; typedef unsigned long uint64; -uint16 (*screen)[25][80] = (uint16(*)[25][80])(0xb8000); -void puts(int line, char *str); +typedef void (*go_entry_t)(uint32, uint32); void boot64main(uint32 gomain, uint32 magic, uint32 mbinfo) { - void (*gomain_entry)(uint32, uint32); - gomain_entry = (void(*)(uint32, uint32))((uint64)gomain); - gomain_entry(magic, mbinfo); - puts(2, "hello world"); + go_entry_t go_entry; + go_entry = (go_entry_t)((uint64)gomain); + go_entry(magic, mbinfo); for (;;) { } } - -void puts(int line, char *str) -{ - char *p = str; - int i = 0; - for (; *p != 0; p++) - { - (*screen)[line][i] = (uint16)(*p | 0x700); - i++; - } -} \ No newline at end of file diff --git a/boot/multiboot.c b/boot/multiboot.c index da81474..119ab6f 100644 --- a/boot/multiboot.c +++ b/boot/multiboot.c @@ -21,18 +21,19 @@ extern char _binary_boot64_elf_start[]; void memcpy(char *dst, char *src, int count); void memset(char *addr, char data, int cnt); uint64 loadelf(char *image); +typedef void (*boot64_entry_t)(uint32, uint32, uint32); void multibootmain(unsigned long magic, multiboot_info_t *mbi) { uint64 entry_addr = 0; - void (*boot64_entry)(uint32, uint32, uint32); + boot64_entry_t boot64_entry; entry_addr = loadelf(_binary_boot64_elf_start); if (entry_addr == 0) { return; } - boot64_entry = (void (*)(uint32, uint32, uint32))((uint32)entry_addr); + boot64_entry = (boot64_entry_t)((uint32)entry_addr); entry_addr = loadelf(_binary_kernel_elf_start); if (entry_addr == 0)