Skip to content

Commit 67c2923

Browse files
committed
Move kernel_address to 16 address line because of some bug
1 parent d866398 commit 67c2923

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

include/fuzzy/memmgr/layout.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,22 @@
99
// and kernel's pid is 0.
1010
#define PID_KERNEL 0
1111

12+
/*
13+
* Bug:
14+
* Bootloader stage 2 is not able to load kernel if
15+
* memory address need 20 address lines (0x10000) in
16+
* our case.
17+
* It works as intended in QEMU but not in others.
18+
* Mitigation:
19+
* - Forcing MEMORY_KERNEL_LOCATION to be represented
20+
* by 16 address lines. For ex 0xF000.
21+
* Resolution:
22+
* - I'm not sure.
23+
*/
1224
#define MEMORY_APPBASE_LOCATION 0x10000
1325

14-
#define memmgr_app_abs_location(pid) (MEMORY_APPBASE_LOCATION + (pid)*MEMORY_APP_SIZE)
26+
#define memmgr_app_abs_location(pid) ((pid==0)?0x0F000:(MEMORY_APPBASE_LOCATION + (pid)*MEMORY_APP_SIZE))
1527
#define memmgr_app_size(pid) (MEMORY_APP_SIZE)
1628

17-
#define MEMORY_KERNEL_LOCATION memmgr_app_abs_location(PID_KERNEL)
18-
#define MEMORY_KERNEL_SIZE memmgr_app_size(PID_KERNEL)
29+
#define MEMORY_KERNEL_LOCATION (memmgr_app_abs_location(PID_KERNEL))
30+
#define MEMORY_KERNEL_SIZE (memmgr_app_size(PID_KERNEL))

src/bootloader/stage1.asm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
CLI
1818
MOV ax, 0x0000
1919
MOV es, ax ; es := 0
20+
mov sp, 0x7FF0
2021

2122
set_blinking 0
2223
clear_screen C_WHITE, C_BLACK

src/bootloader/stage2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ void entry_stage() {
8383
set_color_fg(C_WHITE);
8484

8585
print_log("");
86+
enable_a20();
8687
load_static_library();
8788
load_kernel();
8889

89-
enable_a20();
9090
populate_gdt_table(&gdtr, gdt_table, GDT_TABLE_SIZE, 0);
9191

9292
// Enter_protected_mode never returns.

0 commit comments

Comments
 (0)