Example #1
0
void gdt_init()
{
//Setup GDT pointer
    gdtp.limit=(sizeof(struct gdt_entry)*GDT_COUNT)-1;
    gdtp.base=(unsigned int)&gdt;

//NULL Descriptor
    gdt_set_gate(0,0,0,0,0);

//Code segment
    gdt_set_gate(1,0,0xFFFFFFFF,0x9A,0xCF);

//Data segment
    gdt_set_gate(2,0,0xFFFFFFFF,0x92,0xCF);

//Code segment
    gdt_set_gate(3,0,0xFFFFFFFF,0xFA,0xCF);

//Data segment
    gdt_set_gate(4,0,0xFFFFFFFF,0xF2,0xCF);

//Task state segment
    gdt_set_gate(5,(unsigned int)&mt_task_state_segment,(unsigned int)&mt_task_state_segment + sizeof(mt_task_state_segment) + 1,0x89,0x40);

//16-bit Code segment
    gdt_set_gate(6,0,0xFFFF,0x9A,0x00);

//16-bit Data segment
    gdt_set_gate(7,0,0xFFFF,0x92,0x00);

//Setup GDT
    gdt_setup();
}
Example #2
0
/***********************************************************
 * Name:
 *	main	
 * Description:
 * 	Start Function of the Kernel	
 * Parameter:
 * ReturnValue:
 *	EXIT_SUCCESS	
 *
 **********************************************************/
void main() {

	/* Global Descriptor Table setup */
	gdt_setup();

	/* Interrupt Descriptor Table setup */
	idt_setup();

	/* Setup Interrupts */
	irq_setup();

	/* Setup Empty Devices */
	device_setup();

	/* Initialize Video Device -> Device does not send Interrupts */
	initializeDevice(0,(char *)0xB8000,DEVICE_VIDEO,NULL,IRQ_EMPTY);

	/* Initialize Keyboard Handler */
	initializeDevice(1,NULL,DEVICE_KEYBOARD,irq_keyboard_handler,IRQ_KEYBOARD);

	/* set Video Device for Console */
	setVideoDevice(getDevice(0,DEVICE_VIDEO));

	/* Initialize the Character Buffer */
	initLineBuffer();

	/* Clear Screen on Video Device */
	clear_screen();

	/* Printing OS Headers */
	printf("\t\t-------------------------\n", C437_GREEN);
	printf("\t\tWELLCOME TO "OS_NAME"\n", C437_GREEN);
	printf("\t\t-------------------------\n", C437_GREEN);

        printf("\t\t"OS_NAME" version "OS_VERSION", Copyright (C) 2012 Simon Sommer\n", C437_CYAN); 
    	printf("\t\t"OS_NAME" comes with ABSOLUTELY NO WARRANTY.\n", C437_CYAN);
    	printf("\t\tThis is free software, and you are\n", C437_CYAN); 
	printf("\t\twelcome to redistribute it under certain conditions.\n", C437_CYAN);

	/* Enable Full 4GB Memory */
	enableA20();
	printf("\t\tA20 GATE ACTIVATED\n", C437_GREEN);

	/* Gives Feedback of previus done Tasks */
	printf("\t\tGDT SETUP DONE\n", C437_GREEN);
	printf("\t\tIDT SETUP DONE\n", C437_GREEN);
	printf("\t\tIRQ SETUP DONE\n", C437_GREEN);

	/* Enable Iterrupts */
	__asm__ __volatile__ ("sti");
	printf("\t\tINTERRUPTS ENABLED\n", C437_GREEN);

	while(1);

	/* TODO: Malloc and Free Debug and Final Test */
}
Example #3
0
File: main.c Project: djays/TIK
int main()
{
    gdt_setup();    
    idt_setup();
    isr_setup();
    init_video();
    irq_setup();
    __asm__ __volatile__ ("sti");
    timer_setup();
    keyboard_setup();
    puts(" Welcome to TIK! \n");
    for (;;);
    
    return 0;
}
Example #4
0
void boot()
{
//Initialise display and print message
	video_text_cls();
	video_text_puttext("KAOS version 1\nDeveloped by Karl Hobley.\n\nCopyleft (C) 2011 Karl Hobley.\nKAOS is released under the GPLv3 Licence.\n\nBuild date: "__DATE__" "__TIME__"\n\n\n\n");

//Setup kernel
	video_text_puttext("Loading GDT          ");
	gdt_setup();
	video_text_puttext("[ DONE ]\n");

	video_text_puttext("Loading IDT          ");
	idt_setup();
	video_text_puttext("[ DONE ]\n");

	video_text_puttext("Loading ISR          ");
	isr_setup();
	video_text_puttext("[ DONE ]\n");

	video_text_puttext("Loading IRQ          ");
	irq_setup();
	video_text_puttext("[ DONE ]\n");

	video_text_puttext("Enabling Interrupts  ");
	__asm__ __volatile__("sti"); 
	video_text_puttext("[ DONE ]\n");

	video_text_puttext("Loading Timer        ");
	timer_setup();
	video_text_puttext("[ DONE ]\n");

	video_text_puttext("Loading Keyboard     ");
	keyboard_setup();
	video_text_puttext("[ DONE ]\n");

//Test panic
	volatile int a = 1;
	volatile int b = 0;
	volatile int c = a / b;
}
Example #5
0
void kernel_main(void)
{
	terminal_init();
	puts("This is BermudOS!");
	if(!is_apic_compatible())
		puts("Hardware is not APIC compatible");
	if(!has_MSR())
		puts("CPU has no MSR");
	if(!gdt_setup())
		puts("Error while setting up GDT");
	setup_interrupts();
	if(!keyboard_setup())
		puts("Error while setting up the keyboard");
	wait_sec(4);
	char bfr[KEYBOARD_BUFFER_SIZE+1];
	int i;
	for(i = 0; i < 4; ++i)
	{
		read_keyboard_buffer(bfr);
		printf("The buffer contained: %s", bfr);
	}
}