Ejemplo n.º 1
0
int main(struct multiboot *mboot_ptr)
{
	monitor_clear();
	monitor_write("Initializing GDT...\n");
 	init_descriptor_tables();
	monitor_write("GDT initialized.\n");
	//asm volatile("int $0x3");
	//asm volatile("int $0x4");
	//asm volatile("sti");
	//init_timer(50);
	initialise_paging();
	monitor_write("Paging initialized.\n");
	/*u32int *ptr = (u32int*)0xA0000000;*/
	/*u32int do_page_fault = *ptr;*/

	/*asm volatile ("int $0x3");*/
	/*asm volatile ("int $0x4");*/
	//monitor_write_dec(15);
	//monitor_write_dec(-48281);
	//monitor_write_dec(295180203);
	/*monitor_write_hex(0xFF);*/
	/*monitor_put('\n');*/
	/*monitor_write_hex(0x0);*/
	/*monitor_put('\n');*/
	/*monitor_write_hex(0xFAFABABA);*/
	/*monitor_put('\n');*/
	/*monitor_write_hex(0xABA);*/

	// All our initialisation calls will go in here.
	return 0;
}
Ejemplo n.º 2
0
int main(struct multiboot *mboot_ptr)
{
	// All our initialisation calls will go in here.
	init_descriptor_tables();
	monitor_clear();
	initialise_paging();
//	init_timer(3);

	int res = 0;

	monitor_clear();
	monitor_write(str);
	monitor_write("\n\r");
	monitor_write_hex(0xbadacacd);
	monitor_write_hex(0xbada0000);
	monitor_write("\n\r");
	monitor_write_dec(0xadacacd);
	monitor_write("\n\r");
	monitor_write_dec(1234567890);

	//memcpy(0xb8000+80*2*5,0xb8000,80*2*5);
	//memset(0xb8000,76,80*2*5);

	asm volatile ("int $0x3");

	//u32int *ptr = (u32int*)0x0ffffff;
	//u32int do_page_fault = *ptr;
	

	return 0;
}
Ejemplo n.º 3
0
void platform_init()
{
debug_print(">>PLATFORM_INIT\r\n");
debug_print("PLATFORM:");debug_print(PLATFORM_NAME);dln;
debug_print("CPU:");debug_print(CPU_NAME);dln;
init_descriptor_tables();
}
Ejemplo n.º 4
0
/*
void test(void)
{
	window win;
	char name[10]="window";
	clearscreen();
	win_init(&win,1,1,10,40,name,blightgray|fwhite,blightgray|fblack);
	win_create(&win);

	win_putchar(&win,'n');
	win_putchar(&win,'\n');

	int i;
	for(i=0;i<7;i++)
	win_putstring(&win,"testing win_putstring\n");/
	for(i=0;i<4;i++)//
	win_putstring(&win,"new line\n");

}
*/
int main(struct multiboot *mboot_ptr)
{
	welcome();		

	init_descriptor_tables();

	asm volatile("sti");
	
	init_timer(1);

	wait(1);
	win_clear(&win_boot);

	win_putstring(&win_boot,"\ninitializing timer...\t");
	wait(1);
	win_putstring(&win_boot," done");

	win_putstring(&win_boot,"\ninitializing keyboard...\t");
	init_kbd();
	wait(1);
	win_putstring(&win_boot," done");

	win_putstring(&win_boot,"\npress any key to continue...\n");

	u8int s,a;

	kbd_read(&s,&a);

	clearscreen();
	terminal();	
	
	while(1);	
    return 0;

}
Ejemplo n.º 5
0
int kernelStart(struct multiboot_info *mboot_ptr){
	 
    
		kprintf("\n\n\n\n\n\n HW init ...\n");
     
		init_descriptor_tables();
		kprintf("\t\t IDT/GDT initialised...\n");
    
		init_sysClock(100);
		kprintf("\t\t CMOS timer initialised to 100hz...\n");
		
		
		u32int memsize = (mboot_ptr->mem_lower + mboot_ptr->mem_upper) * 1024;
		init_heap(end_address + 0x1000, memsize - end_address - 0x1000);
		//kprintf("\t\t end_address: %d \n", end_address);
		kprintf("\t\t Heap initialised...\n");
		
		
		init_keyboard();
		kprintf("\t\t PS/2 keyboard initialised...\n");
		
		init_system_timer();
		kprintf("\t\t timer initialised...\n");
		
		init_application();
		kprintf("\t\t application initialised...\n");
		
		enableInterrupt();
		while(1){}	
		return 0;
}
Ejemplo n.º 6
0
void kmain(multiboot_t *mboot_ptr)
{
	clear_screen();
	print_d("%s\n",INTRODUCTION);

	init_serial();
	init_descriptor_tables();

	//asm volatile("int $0x3"); 
	//asm volatile("int $0x4");
	asm volatile("sti");
	//timer_install();
	register_keyboard();

	kernel_elf = elf_from_multiboot (mboot_ptr);

	// unregister_keyboard();

	
//	asm volatile ("int $0x3");

	//
	//enable_interrupts();
	//init_serial_port();

	// int val1 = 5;
	// int val2 = 6 - 4 - 2;
	// val1 = val1/val2;
}
Ejemplo n.º 7
0
int ldr_main(struct multiboot_info* boot_info, uint32 krnldr_size_bytes)
{
	SetColor(MakeColor(DARK_BLUE, WHITE));
	ClearScreen();

	if (krnldr_size_bytes > 40 KB)
		PANIC("Kernel Loader is too large");

	init_kallocations(KRN_LDR_BASE + krnldr_size_bytes, KRN_LDR_LIMIT);

	Print("Initializing descriptor tables.");

	INT_OFF;
	init_isr();
	init_descriptor_tables();
	init_pic();
	INT_ON;

	init_pit_timer(50, timer_callback);

	struct kernel_info* k_info = kalloc(sizeof(struct kernel_info));

	//setup AHCI
	HBA_MEM_t* abar = PCIFindAHCI();

	// initialize basic virtual memory
	vmmngr_initialize();

	uint32 ahci_base = kalloc_get_ptr() + 1024 - (uint32)kalloc_get_ptr() % 1024;
	init_ahci(abar, ahci_base);

	uint32 start, _length, position = 0;
	fsysSimpleFind("MeOs.exe", 1, &_length, &start);

	if (start == (uint32)-1 && _length == 0)
		PANIC("Kernel module could not be found!");

	while (position <= _length)
	{
		fsysSimpleRead(start + position / 512, 4096, KERNEL_BASE + position);
		position += 4096;
	}

	// after all the loading is done... enable paging
	vmmngr_paging_enable(true);

	k_info->kernel_size = _length;
	k_info->isr_handlers = interrupt_handlers;
	k_info->gdt_base = gdt_entries;
	k_info->idt_base = idt_entries;

	printfln("Executing kernel\0");
	execute_kernel(boot_info, k_info);

	ClearScreen();
	_asm cli
	_asm hlt
}
Ejemplo n.º 8
0
void initialize(u32int fg, u32int bg) {
	// Initialization calls
	update_settings(fg,bg);
	monitor_clear();
	init_descriptor_tables();
	asm("sti");
	init_keyboard();
	init_timer(1000);
}
Ejemplo n.º 9
0
Archivo: kmain.c Proyecto: rhtyd/tantra
uint32_t kmain(unsigned long magic, multiboot_info_t *mboot)
{
    if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
    {
        return 0xD15EA5E;
    }

    // Intialize framebuffer
    init_fb();

    kprintf("\nKernel loading linear address = %x", loader);
    kprintf("\nGrub magic = %x", magic);

    if (mboot->flags & (1 << 2)) {
        kprintf("\nGrub cmdline = %s", (const char*)mboot->cmdline);
    }

    uint32_t availableMemory = 0;
    multiboot_memory_map_t *mmap = (multiboot_memory_map_t*) mboot->mmap_addr;
    while (mmap < (multiboot_memory_map_t*)(mboot->mmap_addr + mboot->mmap_length)) {
        kprintf("\n  memmap type=%x size=%xkb start_addr=%x end_addr=%x", mmap->type, mmap->len/1024, (uint32_t) mmap->addr, (uint32_t) mmap->addr + mmap->len);
        if (mmap->type == MULTIBOOT_MEMORY_AVAILABLE) {
            availableMemory += mmap->len;
        }
        mmap = (multiboot_memory_map_t*) ((uint32_t)mmap + mmap->size + sizeof(uint32_t));
    }
    kprintf("\nAvailable Physical Memory = %x kB", availableMemory);

    // Initialize descriptor tables
    init_descriptor_tables();

    // Initialize timer at 100hz
    init_timer(100);

    // Initialize keyboard
    init_keyboard();

    // Initialize paging
    init_paging(availableMemory);

    // Enable interrupts
    __asm__("sti");

    kprintf("\n> ");

    // Dummy interrupts to test ISRs
    //__asm__("int $0x03");
    //__asm__("int $0x04");

    // Test page fault
    //uint32_t *ptr = (uint32_t*) 0xDEADFA11;
    //uint32_t do_page_fault = *ptr;

    // 0xBADA55 now set on eax/rax register from C
    return 0xBADA55;
}
Ejemplo n.º 10
0
int kmain(/*struct multiboot *mboot_ptr*/)
{
	init_descriptor_tables();
	keyboard_install();
	
	initfs();

	shell();
	return 0xDEADBADA;
}
Ejemplo n.º 11
0
int main(struct multiboot *mboot_ptr)
{
    // Initialise the screen (by clearing it)
    init_descriptor_tables();
    monitor_clear();
    // Write out a sample string
   // for(int i=0;i<26;i++)
     monitor_write("Hello, world!\n");
     asm volatile ("int $0x3");
 //   asm volatile ("int $0x4");
 
    return 0;
}
Ejemplo n.º 12
0
Archivo: kmain.c Proyecto: seanzzz/SOS
void kmain(void) {
  init_descriptor_tables();
  init_keyboard(0);
  screen_clear();

  // initialise_paging();
  screen_set_char_attr(0x07);
  welcome();
  // init_timer(10);
  __asm__ __volatile__ ("sti");

  // begin user process here...
  while (1) {}
}
int main(struct multiboot *mboot_ptr)
{
    // Initialise all the ISRs and segmentation
    init_descriptor_tables();
    // Initialise the screen (by clearing it)
    monitor_clear();

    // Find the location of our initial ramdisk.
    ASSERT(mboot_ptr->mods_count > 0);
    u32int initrd_location = *((u32int*)mboot_ptr->mods_addr);
    u32int initrd_end = *(u32int*)(mboot_ptr->mods_addr+4);
    // Don't trample our module with placement accesses, please!
    placement_address = initrd_end;

    // Start paging.
    initialise_paging();

    // Initialise the initial ramdisk, and set it as the filesystem root.
    fs_root = initialise_initrd(initrd_location);

    // list the contents of /
    int i = 0;
    struct dirent *node = 0;
    while ( (node = readdir_fs(fs_root, i)) != 0)
    {
        monitor_write("Found file ");
        monitor_write(node->name);
        fs_node_t *fsnode = finddir_fs(fs_root, node->name);

        if ((fsnode->flags&0x7) == FS_DIRECTORY)
        {
            monitor_write("\n\t(directory)\n");
        }
        else
        {
            monitor_write("\n\t contents: \"");
            char buf[256];
            u32int sz = read_fs(fsnode, 0, 256, buf);
            int j;
            for (j = 0; j < sz; j++)
                monitor_put(buf[j]);
            
            monitor_write("\"\n");
        }
        i++;
    }

    return 0;
}
Ejemplo n.º 14
0
int main(struct multiboot *mboot_ptr)
{
  // All our initialisation calls will go in here.
  // Initialise all the ISRs and segmentation
  init_descriptor_tables();
  
  // Clear monitor and write a test  
  monitor_clear();
  monitor_write("Hello, world!");
  
  asm volatile ("int $0x3");
  asm volatile ("int $0x4");
  
  return 0xDEADBABA;
}
Ejemplo n.º 15
0
Archivo: main.c Proyecto: hardrock12/OS
int main(struct multiboot *mboot_ptr)
{
    // Initialise all the ISRs and segmentation
    init_descriptor_tables();
    // Initialise the screen (by clearing it)
    monitor_clear();

    /*initialise_paging();
    monitor_write("Hello, paging world!\n");

    u32int *ptr = (u32int*)0xA0000000;
    u32int do_page_fault = *ptr;
*/
monitor_write("Arjun");
    return 0;
}
Ejemplo n.º 16
0
int k_main(struct multiboot *mboot_ptr)
{
  init_descriptor_tables();

  k_clrscr();

  k_printf("Hello World\n");

  k_printf("1 + 2 = %d\n", 1+2);

  asm volatile ("int $0x3");
  asm volatile ("int $0x4");

  PANIC("Halting OS");

  return 0xDEADBABA;
}
Ejemplo n.º 17
0
int kernel_main(struct multiboot *mboot_ptr)
{
    // Initialise all the ISRs and segmentation
    init_descriptor_tables();
    // Initialise the screen (by clearing it)
    monitor_clear();
    // Write out a sample string
    monitor_write("Hello, world!\n");

    asm volatile("int $0x3");
    asm volatile("int $0x4");

    asm volatile("sti");
    init_timer(50);

    return 0;
}
Ejemplo n.º 18
0
int main(struct multiboot *mboot_ptr) {
	// All our initialisation calls will go in here.
	init_descriptor_tables();

	initialize_monitor_vga();
	vga.monitor_write("Hello World!\n");
	//initialize_text_gui();
	
	asm volatile("sti");
	// initialize the timer
	init_timer(50);
	
	initialise_paging();
    vga.monitor_write("Hello, paging world!\n");

	return 0xDEADBABA;
}
Ejemplo n.º 19
0
void kernel_main() {
	initconsole();
	
	init_descriptor_tables();
	
	movecursor(0,0);

	//asm volatile("int $0x3");
    //asm volatile("int $0x4");
	
    asm volatile("sti"); // gets irq working
    init_keyboard(); // change this eventually
	render();
	startinput();
	
	while(1==1) {
		// keep kernel running
	}
}
Ejemplo n.º 20
0
int kmain(struct multiboot* mboot_ptr)
{
    clearScreen();
    init_descriptor_tables();
    __asm__ __volatile__("sti");

    uint32 initrd_location = findInitrd(mboot_ptr);
    initialize_paging();

    // Initialize the initial ramdisk, and set it as the filesystem root.
    fs_root = initialize_initrd(initrd_location);

    printIntro();

    println(PRO_TIP, 0x0F);
    kbHelp();

    launchShell();
    return 0;
}
Ejemplo n.º 21
0
void x86_kernel_main(struct multiboot *multiboot)
{
	init_output();
	init_paging(multiboot);
	init_acpi();
	init_descriptor_tables();

	kprint("Stack pointer: ");
	kprint_hexnl(read_esp());
	kprint("Mod count: ");
	kprint_hexnl(multiboot->mods_count);
	kprint("Kernel phys end : ");
	kprint_hexnl((u32)&__phys_end);
	kprint("Mod addr start : ");
	kprint_hexnl(*(u32*)(phys_to_virt(multiboot->mods_addr)));
	kprint("Mod addr end : ");
	kprint_hexnl(*(u32*)(phys_to_virt(multiboot->mods_addr) + 4));

	//init_tasking();

	kernel_main();

	if (multiboot->mods_count == 13) {
		kprint("Executing module..\n");

		typedef void (*module_fun)(void);

		u32 modaddr = phys_to_virt(multiboot->mods_addr);
		modaddr = phys_to_virt(*(u32*)modaddr);

		//kprint_hexnl(modaddr);
		//kprint_hexnl(*(u32*)modaddr);

		module_fun module = (module_fun)modaddr;

		module();
		kprint("Modadr is ");

	}
}
Ejemplo n.º 22
0
void kernel_init(struct multiboot *mboot_ptr) { 
  
  //Reprogram PICs
  cli();
  init_pics(0x20, 0x28);
  sti();
  
  //Initialize Terminal
  terminal_initialize();
  
  kinfo("Enable A20 Gate (if not already done)\n");
  //Enable A20 Gate if it is not already enabled.
  if (checkA20() = 0)
    enableA20();
  
  //Check if A20 is REALLY enabled
  if (checkA20() = 0)
    panic("Enabling A20 Gate");
  
  //Enable the timer and setting it to 50hz
  kinfo("Enable Timer (50hz)");
  init_timer(50);
  
  //Initiate the descriptor tables (gdt and idt)
  init_descriptor_tables();
  
  //Enter the protected mode
  kinfo("Enter protected mode");
  enterProtected();
  
  //Spawning the init process with argument *mboot_ptr
  kinfo("Spawning Init process...");
  init(*mboot_ptr);
  
  //The init process should NEVER die.
  //If it dies
  kerror("Init Process terminated... make a kernel panic...");
  panic("Unendable Process ended.");
}
Ejemplo n.º 23
0
void kernel_main()
{
    monitor_clear();
    /*
    monitor_write("Hello ASKernel\n");
    monitor_write("Hello World!\n");
    monitor_write_hex(0x01234567);
    monitor_write("\n");
    monitor_write_hex(0x89abcdef);
    monitor_write("\n");
    monitor_write_dec(0xffffffff);
    monitor_write("\n");
    monitor_write_dec(189064);
    monitor_write("\n");
    */

    init_descriptor_tables();


    __asm__ __volatile__("int $0x03");
    __asm__ __volatile__("int $0x04");
    __asm__ __volatile__("int $0x14");


/*
    init_timer(50);

    __asm__ __volatile__("sti");
*/


    init_paging();
    monitor_write("Hello Paging World!\n");

    uint32_t* ptr = (uint32_t*)0xa0000000;
    uint32_t do_page_fault = *ptr;
}
Ejemplo n.º 24
0
int main(struct multiboot *mboot_ptr)
{
  // All our initialisation calls will go in here.
  
  //init descriptor tables
  init_descriptor_tables();
  //Testing screen instructions
  monitor_clear();
  monitor_write("Hello World");
  u32int n = 0xDEADBABA;

  monitor_write("\n");
  monitor_write_hex(n);
  
  monitor_write("\n");
  n = 1234567890;
  
  monitor_write_dec(n);

  asm volatile ("int $0x1");
  //asm volatile ("int $0x4");

  return 0xDEADBABA;
}
Ejemplo n.º 25
0
int main(struct multiboot *mboot_ptr, u32int initial_stack)
{
    initial_esp = initial_stack;
    // Initialise all the ISRs and segmentation
    init_descriptor_tables();
    // Initialise the screen (by clearing it)
    monitor_clear();
    // Initialise the PIT to 100Hz
    asm volatile("sti");
    init_timer(50);

    // Find the location of our initial ramdisk.
    ASSERT(mboot_ptr->mods_count > 0);
    u32int initrd_location = *((u32int*)mboot_ptr->mods_addr);
    u32int initrd_end = *(u32int*)(mboot_ptr->mods_addr+4);
    // Don't trample our module with placement accesses, please!
    placement_address = initrd_end;

    // Start paging.
    initialise_paging();

    // Start multitasking.
    initialise_tasking();

    // Initialise the initial ramdisk, and set it as the filesystem root.
    fs_root = initialise_initrd(initrd_location);

    // Create a new process in a new address space which is a clone of this.
    int ret = fork();

    monitor_write("fork() returned ");
    monitor_write_hex(ret);
    monitor_write(", and getpid() returned ");
    monitor_write_hex(getpid());
    monitor_write("\n============================================================================\n");

    // The next section of code is not reentrant so make sure we aren't interrupted during.
    asm volatile("cli");
    // list the contents of /
    int i = 0;
    struct dirent *node = 0;
    while ( (node = readdir_fs(fs_root, i)) != 0)
    {
        monitor_write("Found file ");
        monitor_write(node->name);
        fs_node_t *fsnode = finddir_fs(fs_root, node->name);

        if ((fsnode->flags&0x7) == FS_DIRECTORY)
        {
            monitor_write("\n\t(directory)\n");
        }
        else
        {
            monitor_write("\n\t contents: \"");
            char buf[256];
            u32int sz = read_fs(fsnode, 0, 256, buf);
            int j;
            for (j = 0; j < sz; j++)
                monitor_put(buf[j]);
            
            monitor_write("\"\n");
        }
        i++;
    }
    monitor_write("\n");

    asm volatile("sti");

    return 0;
}