Skip to content

Commit

Permalink
fix boot entry type
Browse files Browse the repository at this point in the history
  • Loading branch information
icexin committed Jul 31, 2021
1 parent fe92c9c commit 565bb8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
21 changes: 4 additions & 17 deletions boot/boot64main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
5 changes: 3 additions & 2 deletions boot/multiboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 565bb8c

Please sign in to comment.