File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed
Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ binaries: $(bt_stage1) $(bt_stage2) $(kernel_core) $(rm_static)
101101# Note: Relying on default value doesn't guarantee bin size.
102102SECTOR_COUNT_BT_STAGE1 = 1
103103SECTOR_COUNT_SHARED_LIBRARY = 1
104- SECTOR_COUNT_BT_STAGE2 = 11
104+ SECTOR_COUNT_BT_STAGE2 = 12
105105SECTOR_COUNT_KERNEL = 47
106106
107107SECTOR_START_BT_STAGE1 = 0
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ extern entry_stage
88extern gdtr
99global enter_protected_mode
1010global label_exit
11+ global call_int_0x15
1112
1213[SECTION .text]
1314 mov eax , 0x0
@@ -43,6 +44,16 @@ global label_exit
4344 HLT
4445 JMP label_exit
4546
47+ call_int_0x15:
48+ push ebp
49+ mov ebp , esp
50+
51+ mov ax , [ ebp + 0x08 ]
52+ int 0x15
53+
54+ pop ebp
55+ ret
56+
4657
4758[SECTION .data]
4859 bl_stage_2 db "Bootloader: Stage 2"
Original file line number Diff line number Diff line change @@ -16,6 +16,30 @@ char DIGIT_TO_HEX[] = "0123456789ABCDEF";
1616
1717extern void enter_protected_mode ();
1818extern void label_exit ();
19+ extern unsigned short call_int_0x15 (unsigned short ax );
20+
21+ void enable_a20 () {
22+ int ax ;
23+ ax = call_int_0x15 (0x2403 );
24+ if (!ax ) {
25+ print_log ("BIOS A20-gate not supported" );
26+ label_exit ();
27+ }
28+
29+ ax = call_int_0x15 (0x2402 );
30+ if (ax == 1 ) {
31+ print_log ("BIOS A20-gate already enabled" );
32+ return ;
33+ }
34+
35+ ax = call_int_0x15 (0x2401 );
36+ if (!ax ) {
37+ print_log ("BIOS A20-gate enabling attempt failed" );
38+ label_exit ();
39+ }
40+
41+ print_log ("BIOS A20-gate enabled" );
42+ }
1943
2044char * get_memdump_8byte (void * address ) {
2145 static char shared_memdump [17 ];
@@ -62,6 +86,7 @@ void entry_stage() {
6286 load_static_library ();
6387 load_kernel ();
6488
89+ enable_a20 ();
6590 populate_gdt_table (& gdtr , gdt_table , GDT_TABLE_SIZE , 0 );
6691
6792 // Enter_protected_mode never returns.
You can’t perform that action at this time.
0 commit comments