diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-05-14 18:14:21 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2017-05-14 18:14:21 +0200 |
commit | 5bebcc939adc868110a91b9bd0c013208f6f1779 (patch) | |
tree | 80e1a2527fb0b8b65e9fdaeef5a6362348821db5 /src | |
parent | 1ebfde4d30acd27d1b3817f33bf9cf76655e3183 (diff) | |
download | abaos-5bebcc939adc868110a91b9bd0c013208f6f1779.tar.gz abaos-5bebcc939adc868110a91b9bd0c013208f6f1779.tar.bz2 |
fixes in vga.c setting the hardware cursor correctly
reading VGA hardware cursor from stage2 in boot loader for last messages
Diffstat (limited to 'src')
-rw-r--r-- | src/boot.asm | 3 | ||||
-rw-r--r-- | src/kernel.c | 4 | ||||
-rw-r--r-- | src/stage2_functions.asm | 32 | ||||
-rw-r--r-- | src/vga.c | 11 |
4 files changed, 44 insertions, 6 deletions
diff --git a/src/boot.asm b/src/boot.asm index 377ec66..3257a56 100644 --- a/src/boot.asm +++ b/src/boot.asm @@ -118,6 +118,9 @@ BEGIN_PROTECTED_MODE: ; call our kernel call c_entry +; restore cursor variables from VGA hardware + call read_hardware_vga_cursor + ; "kernel halted" message, when we terminate the C kernel HALT_OS: mov si, MESSAGE_HALTED diff --git a/src/kernel.c b/src/kernel.c index 61281e9..5021813 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -28,12 +28,12 @@ void entry( void ) x_pos++; } vga_put_char_at( &vga, x_pos, y_pos, bar[i%4] ); - for( int j = 0; j < 1500; j++ ) { + for( int j = 0; j < 150; j++ ) { } } vga_put_char_at( &vga, x_pos, y_pos, '.' ); vga_put_newline( &vga ); - + //~ vga_set_color( &vga, VGA_COLOR_WHITE ); //~ vga_set_background_color( &vga, VGA_COLOR_RED ); //~ vga_clear_screen( &vga ); diff --git a/src/stage2_functions.asm b/src/stage2_functions.asm index 11a77c0..2954d62 100644 --- a/src/stage2_functions.asm +++ b/src/stage2_functions.asm @@ -137,6 +137,38 @@ update_vga_cursor: pop eax ret +; read cursor from hardware +read_hardware_vga_cursor: + push eax + push ebx + push ecx + push edx + xor eax, eax + xor ebx, ebx + mov al, 0eh + mov dx, 3d4h + out dx, al + mov dx, 3d5h + in al, dx + mov bh, al + mov al, 0fh + mov dx, 3d4h + out dx, al + mov dx, 3d5h + in al, dx + mov bl, al + mov ax, bx + mov edx, 0 + mov cx, VIDEO_COLS + div cx + mov [CURSOR_X], dx + mov [CURSOR_Y], ax + pop edx + pop ecx + pop ebx + pop eax + ret + ; check whether the end of the loaded image contains in fact the magic ; string (avoid truncation of image) check_magic: @@ -19,6 +19,8 @@ void vga_init( vga_t *vga ) vga->color = VGA_COLOR_DARK_GREY; vga->background_color = VGA_COLOR_BLACK; + // make sure we use the 0x3dx VGA ports, is done + // in assembly in stage 2 too port8_init( &vga->crtc_misc_port, 0x3d2 ); port8_write( &vga->crtc_misc_port, 1 ); @@ -54,10 +56,7 @@ void vga_set_cursor( vga_t *vga, const int x, const int y ) } void vga_set_cursor_from_hardware( vga_t *vga ) -{ - vga->cursor_x = 0; - vga->cursor_y = 0; - +{ uint16_t hw_cursor_pos; port8_write( &vga->crtc_index_port, 14 ); @@ -176,6 +175,8 @@ void vga_put_char( vga_t *vga, const char c ) scroll_screen( vga ); } } + + vga_set_cursor_on_hardware( vga ); } void vga_put_string( vga_t *vga, const char *s ) @@ -201,6 +202,8 @@ void vga_put_newline( vga_t *vga ) if( vga->cursor_y >= vga->res_y ) { scroll_screen( vga ); } + + vga_set_cursor_on_hardware( vga ); } |