summaryrefslogtreecommitdiff
path: root/src/kernel.c
blob: 72b12228520eb832a88e741ff4e394689aa4687d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <stdint.h>
#include <stdarg.h>

#include "vga.h"
#include "serial.h"
#include "console.h"
#include "stdlib.h"
#include "stdio.h"
#include "interrupts.h"

void entry( void )
{	
//	serial_t serial;
//	serial_init( &serial );

	vga_t vga;
	vga_init( &vga );
	vga_set_color( &vga, VGA_COLOR_LIGHT_GREY );
	vga_set_background_color( &vga, VGA_COLOR_BLACK );
	
	console_t console;
	console_init( &console );
	console_add_vga_output( &console, &vga );
//	console_add_serial_output( &console, &serial );
	
	// initialize the early console of the kernel
	stdio_set_console( &console );
	puts( "Started early kernel console" );
	printf( "Kernel code and data is at 0x%X, kernel stack at 0x%X\n", 0x8400, 0x90000 );

	puts( "Initializing interrupts" );
	interrupt_t interrupt;
	interrupts_init( &interrupt );
	interrupts_enable( );
		
	console_put_string( &console, "Running.." );
	
//~ vga_put_char_at( &vga, 81, 20, 'X' );
	
	const char bar[] = "\\|/-";
	int y_pos = vga_get_cursor_y( &vga );
	int x_pos = vga_get_cursor_x( &vga );
	int i = 0;
	for( i = 0; i < 10000; i++ ) {
		if( i % 1000 == 1 ) {
			vga_put_char_at( &vga, x_pos, y_pos, '.' );
			x_pos++;
//			serial_put_char( &serial, '.' );
int y = 0;
int x = 12 / y;
printf( "Hex number is 0x%X and string is '%s'\n", x, "abaos" );			

		}
		vga_put_char_at( &vga, x_pos, y_pos, bar[i%4] );
		for( int j = 0; j < 1500; j++ ) {
		}
	}
	vga_put_char_at( &vga, x_pos, y_pos, '.' );	
//	serial_put_char( &serial, '.' );
	
	console_put_newline( &console );

	puts( "Terminating" );
}

void kernel_panic( const char *format, ... )
{
	(void)printf( "\n*** KERNEL PANIC ***\n" );
	
	va_list args;
        va_start( args, format );
        (void)vprintf( format, args );
        va_end( args );
 
	// TODO: find a clever way to jump back out of C code to the
	// termination point in stage 2
        for( ;; );
}