summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-07-05 08:42:25 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-07-05 08:42:25 +0200
commit4c7af15f04f1007d75c046b5e95dc86cb31f444d (patch)
tree1e8d69f91bc492a7cfdb7a9c07e6f6ddff2e9bf6 /src
parent05a6f2fcf4556ba9f3d0384c07554c387f6efba2 (diff)
downloadabaos-4c7af15f04f1007d75c046b5e95dc86cb31f444d.tar.gz
abaos-4c7af15f04f1007d75c046b5e95dc86cb31f444d.tar.bz2
fixed graphical screen refresh (a refreshScreen task)
cleaned up code after interrupt_enable in main thread everything works again
Diffstat (limited to 'src')
-rw-r--r--src/kernel/kernel.c92
1 files changed, 47 insertions, 45 deletions
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c
index b9beeb1..57f6d28 100644
--- a/src/kernel/kernel.c
+++ b/src/kernel/kernel.c
@@ -33,8 +33,6 @@ static jmp_buf panic_jmp_buf;
static void handle_keyboard_event( keyboard_event_t *event, void *context );
static void handle_mouse_event( mouse_event_t *event, void *context );
-static bool terminate = false;
-
typedef enum {
MODE_TEXT,
MODE_GRAPHICS
@@ -55,8 +53,9 @@ typedef struct {
static global_context_t global_context;
-static void funcA( );
-static void funcB( );
+static void funcA( void );
+static void funcB( void );
+static void refresh_screen( void );
// must be first entry in kernel.bin (0x8800) as stage 2 of
// the boot loader expects the entry point to be here!
@@ -97,6 +96,9 @@ void kernel_main( void )
task_t taskB;
task_init( &taskB, GDT_CODE_SEGMENT_SELECTOR, &funcB );
task_manager_add_task( &task_manager, &taskB );
+ task_t taskRefreshScreen;
+ task_init( &taskRefreshScreen, GDT_CODE_SEGMENT_SELECTOR, &refresh_screen );
+ task_manager_add_task( &task_manager, &taskRefreshScreen );
puts( "Initializing interrupts" );
interrupt_t interrupt;
@@ -144,43 +146,15 @@ void kernel_main( void )
puts( "Enabling interrupt handing now.." );
- // TODO: if enabling tasks, this could be our really last execution
- // in the main kernel thread
+ // enabling tasks, this is our really last execution
+ // in the main kernel thread, we never return (but for
+ // termination longjmp to TERMINATE)
interrupts_enable( );
-
- puts( "Running.." );
-
- // endless loop doing nothing, later we have to get events
- // here from queues and for instance print characters received
- // from the keyboard to stdout
- while( !terminate ) {
- // for now we are only interested in interrupts,
- // so we let the main thread sleep instead of
- // burning CPU..
- kernel_halt( );
-
- switch( global_context.mode ) {
- case MODE_TEXT:
- // nothing to draw or refresh in text mode, the
- // VGA card is doing that for us
- break;
-
- case MODE_GRAPHICS:
- // for now we must avoid races with the interrupt
- // events originating especially from the mouse
- interrupts_disable( );
-
- // as vga_t is equals to the graphical context for now
- ((widget_t *)&global_context.desktop)->vtable->draw( &global_context.desktop, &global_context.vga );
-
- vga_refresh( &global_context.vga );
-
- interrupts_enable( );
-
- break;
- }
- }
+ // we get back here on termination and kernel panic via goto after
+ // longjmp
+ // TODO: make sure we run this part of the code with the original
+ // early kernel stack and not with a task stack!
TERMINATE:
puts( "Deactivating drivers" );
driver_manager_deactivate_all( &global_context.driver_manager );
@@ -200,7 +174,7 @@ void kernel_panic( const char *format, ... )
va_end( args );
puts( "" );
- longjmp( panic_jmp_buf, 47 );
+ longjmp( panic_jmp_buf, 47 /* TODO: error code */ );
}
static void handle_keyboard_event( keyboard_event_t *event, void *context )
@@ -234,7 +208,7 @@ static void handle_keyboard_event( keyboard_event_t *event, void *context )
puts( "clear - clear screen" );
puts( "mode - switch between text/graphics mode" );
} else if( strcmp( buf, "halt" ) == 0 ) {
- terminate = true;
+ longjmp( panic_jmp_buf, 0 );
} else if( strcmp( buf, "mem" ) == 0 ) {
// TODO: print memory usage
} else if( strcmp( buf, "proc" ) == 0 ) {
@@ -378,16 +352,44 @@ static void handle_mouse_event( mouse_event_t *event, void *context )
}
}
-static void funcA( )
+static void funcA( void )
{
while( true ) {
- printf( "A" );
+ //~ printf( "A" );
+ //~ kernel_panic( "panic in task" );
}
}
-static void funcB( )
+static void funcB( void )
{
while( true ) {
- printf( "B" );
+ //~ printf( "B" );
}
}
+
+static void refresh_screen( void )
+{
+ while( true ) {
+ switch( global_context.mode ) {
+ case MODE_TEXT:
+ // nothing to draw or refresh in text mode, the
+ // VGA card is doing that for us
+ break;
+
+ case MODE_GRAPHICS:
+ // for now we must avoid races with the interrupt
+ // events originating especially from the mouse
+ interrupts_disable( );
+
+ // as vga_t is equals to the graphical context for now
+ ((widget_t *)&global_context.desktop)->vtable->draw( &global_context.desktop, &global_context.vga );
+
+ vga_refresh( &global_context.vga );
+
+ interrupts_enable( );
+
+ break;
+ }
+ }
+}
+