From a5530f90f06f60794851f24b57cd2ddb05c9a4af Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Mon, 1 May 2017 20:42:35 +0200 Subject: more fooling around with VGA module --- doc/LINKS.TODO | 5 +++++ src/kernel.c | 13 +++++++++++-- src/vga.c | 16 ++++++++++++++-- src/vga.h | 1 + 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/doc/LINKS.TODO b/doc/LINKS.TODO index 76e88a7..65e754f 100644 --- a/doc/LINKS.TODO +++ b/doc/LINKS.TODO @@ -1 +1,6 @@ https://github.com/cs107e/cs107e.github.io +http://wiki.osdev.org/Calling_Conventions +http://wiki.osdev.org/Linker_Scripts +http://wiki.osdev.org/Printing_To_Screen +http://wiki.osdev.org/Exceptions#General_Protection_Fault +https://en.wikipedia.org/wiki/X86_calling_conventions diff --git a/src/kernel.c b/src/kernel.c index de14d8f..60d0dd3 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -13,7 +13,7 @@ void entry( void ) volatile char msg[] = "ABAOS"; vga_put_string_at( &vga, 0, 0, (const char *)msg ); // doesn't work - vga_put_string_at( &vga, 0, 1, "ABAOS2" ); + //~ vga_put_string_at( &vga, 0, 1, "ABAOS2" ); // clang 4.0.0 needs volatile otherwise it takes a random value // from the register in the second vga_put_char_at below??! @@ -26,7 +26,7 @@ void entry( void ) pos++; } vga_put_char_at( &vga, pos, 0, bar[i%4] ); - for( int j = 0; j < 3000; j++ ) { + for( int j = 0; j < 1500; j++ ) { } } vga_put_char_at( &vga, pos, 0, '.' ); @@ -34,4 +34,13 @@ void entry( void ) vga_set_color( &vga, VGA_COLOR_WHITE ); vga_set_background_color( &vga, VGA_COLOR_RED ); vga_clear_screen( &vga ); + + for( int i = 0; i < 50; i++ ) { + for( int j = 0; j < i; j++ ) { + vga_put_char( &vga, '-' ); + } + vga_put_char( &vga, '>' ); + vga_put_string( &vga, (const char *)msg ); + vga_put_newline( &vga ); + } } diff --git a/src/vga.c b/src/vga.c index 0133ddf..524b6d7 100644 --- a/src/vga.c +++ b/src/vga.c @@ -30,7 +30,7 @@ void vga_clear_screen( vga_t *vga ) *(VIDEO_MEMORY+i+1) = calculate_color_cell( vga ); } - //~ vga_set_cursor( vga, 0, 0 ); + vga_set_cursor( vga, 0, 0 ); } void vga_set_cursor( vga_t *vga, const int x, const int y ) @@ -102,7 +102,7 @@ void vga_put_char( vga_t *vga, const char c ) vga->cursor_y++; if( vga->cursor_y >= vga->res_y ) { // TODO: implement scrolling - vga->res_y = 0; + vga->cursor_y = 0; } } } @@ -114,3 +114,15 @@ void vga_put_string( vga_t *vga, const char *s ) } } +void vga_put_newline( vga_t *vga ) +{ + vga->cursor_x = 0; + vga->cursor_y++; + if( vga->cursor_y >= vga->res_y ) { + // TODO: implement scrolling + vga->cursor_y = 0; + } +} + + + diff --git a/src/vga.h b/src/vga.h index 9664e2c..5ecd88e 100644 --- a/src/vga.h +++ b/src/vga.h @@ -43,5 +43,6 @@ void vga_put_char_at( vga_t *vga, const int x, const int y, const char c ); void vga_put_string_at( vga_t *vga, const int x, const int y, const char *s ); void vga_put_char( vga_t *vga, const char c ); void vga_put_string( vga_t *vga, const char *s ); +void vga_put_newline( vga_t *vga ); #endif /* VGA_H */ -- cgit v1.2.3-54-g00ecf