From 3c200891bfcffbf62ac572cd6841a09a0a69e247 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 16 Jun 2017 09:13:29 +0200 Subject: fixed loading of kernel in stage2 grossing 64k --- BUGS | 7 +++++-- src/README | 2 +- src/boot/stage2_check_magic.asm | 2 -- src/boot/stage2_real_functions.asm | 9 +++++++-- src/kernel/kernel.c | 8 ++++---- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/BUGS b/BUGS index fc5d3ac..e881db7 100644 --- a/BUGS +++ b/BUGS @@ -4,5 +4,8 @@ - optimizing the code move the kernel entry 'kernel_main' away from it's expected location at 0x8800. How can we pin it there? And not use ELF. :-) -- boot loader doesn't work beyond 64k limit - +- bochs shows us distorted text console output, why? +- printf/puts should they wipe the line to the end as we can see + old characters (e.g. BIOS messages) behind our own messages? + Also clear screen is not really a good idea, as we cannot see, + what was there before diff --git a/src/README b/src/README index 2108947..9c6b2b5 100644 --- a/src/README +++ b/src/README @@ -59,4 +59,4 @@ C library routines * string.c - string, memory functions * stdlib.c - UNIX standard library functions * stdio.c - I/O functions, printing -* setjmp - setjmp/longjmp implementation (in assembly) +* setjmp.c - setjmp/longjmp implementation (in assembly) diff --git a/src/boot/stage2_check_magic.asm b/src/boot/stage2_check_magic.asm index 7339a89..479da26 100644 --- a/src/boot/stage2_check_magic.asm +++ b/src/boot/stage2_check_magic.asm @@ -20,7 +20,6 @@ check_magic: .ok: mov si, MAGIC_OK_MSG call pm_print_string - mov edx, esi call pm_print_hex call pm_print_newline xor eax, eax @@ -28,7 +27,6 @@ check_magic: .mismatch: mov si, MAGIC_NOT_OK_MSG call pm_print_string - mov edx, esi call pm_print_hex call pm_print_newline xor eax, eax diff --git a/src/boot/stage2_real_functions.asm b/src/boot/stage2_real_functions.asm index 8b4b5af..3810963 100644 --- a/src/boot/stage2_real_functions.asm +++ b/src/boot/stage2_real_functions.asm @@ -88,9 +88,9 @@ probe_and_fix_disk_geometry: ; IN dl: drive to read from read_from_disk: - mov bx, 0 ; where to store the data + mov bx, 0x0880 ; where to store the data mov es, bx - mov bx, 0x8800 ; 3072 bytes after first sector + mov bx, 0x0 ; 3072 bytes after first sector .read_next_sector: @@ -108,6 +108,11 @@ read_from_disk: jmp .read_next_sector .next_head: + shr bx, 4 ; make it a segment offset.. + mov ax, es + add ax, bx + mov es, ax ; ..and add it to ES + mov bx, 0x0 ; we also reset bx and update es to avoid hitting the 64k wrap around point mov [CURRENT_SECTOR], BYTE 1 ; start from first sector again add [CURRENT_HEAD], BYTE 1 ; advance head mov ch, [NOF_HEADS] diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index 6f94fb9..677d760 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -42,7 +42,7 @@ void kernel_main( void ) vga_text_init( &vga_text ); vga_text_set_color( &vga_text, VGA_TEXT_COLOR_LIGHT_GREY ); vga_text_set_background_color( &vga_text, VGA_TEXT_COLOR_BLACK ); - vga_text_clear_screen( &vga_text ); +// vga_text_clear_screen( &vga_text ); console_t console; console_init( &console ); @@ -106,9 +106,9 @@ void kernel_main( void ) puts( "Activating drivers" ); driver_manager_activate_all( &driver_manager ); - if( vga_set_mode( &vga, vga_make_mode( 320, 200, 8 ) ) ) { - vga_clear_screen( &vga, vga_make_RGB( 0x00, 0x00, 0xA8 ) ); - } +// if( vga_set_mode( &vga, vga_make_mode( 320, 200, 8 ) ) ) { +// vga_clear_screen( &vga, vga_make_RGB( 0x00, 0x00, 0xA8 ) ); +// } // TODO: later, disable VGA text console in stdio and add the // graphical one.. -- cgit v1.2.3-54-g00ecf