示例#1
0
文件: main.c 项目: formatcom/NativeOS
/*
	This is the main routine for the NativeOS Kernel. It will start the
	system and jump to user mode so that the init process can run.
	At the moment no information is gathered from multiboot but I expect
	this to change in the near future.

	Multiboot will provide two arguments here: one is the magic number,
	which must be 0x2BADB002, and the other one is the data structure with
	information that might be required for some things.
*/
void kmain(unsigned int magic_number, multiboot_info_t *multiboot_ptr)
{
	gdt_init();
	idt_init();

	int i;
	for (i = 0; i < 16; i++)
		idt_set_handler(i, &bsod);

	/* Set up the core drivers. */
	VGACon_Init();
	keyboard_init();
	timer_init();

	/* Check that the magic code is valid. */
	if (magic_number != 0x2BADB002) {
		kpanic(0x88, "Wrong magic number");
	}

    unsigned int memory_amount = count_memory(multiboot_ptr);
    frames_init(memory_amount);

	printk("Starting NativeOS...\n");
	
	for(;;);
}
示例#2
0
// 体系结构相关的初始化函数
void arch_init(void)
{
    gdt_init();
    idt_init();
    clock_init();
    console_init();
}
示例#3
0
void kmain(multiboot_info_t* mbt, unsigned int magic)
{
    if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
        return;

    graphics_init();

    /* Core modules */
    gdt_init();
    idt_init();
    irq_init();
    isr_init();
    
    /* Kernel heap */
    heap_init();
    
    /* Drivers */
    timer_init();
    tasking_init();
    keyboard_init();
    
    /* Let the games begin */
    set_interrupts(ENABLED);
    
    kprintf("Running kernel tests...\n\n");
    test_kmalloc_kfree();
    test_list();
    test_tasking();
    kprintf("\nDone with kernel tests.\n");
    
    for (;;);
}
示例#4
0
/*
 * Set up proc0's TSS and LDT.
 */
void
x86_64_proc0_tss_ldt_init(void)
{
	struct pcb *pcb;
	int x;

	gdt_init();

	cpu_info_primary.ci_curpcb = pcb = &proc0.p_addr->u_pcb;

	pcb->pcb_flags = 0;
	pcb->pcb_tss.tss_iobase =
	    (u_int16_t)((caddr_t)pcb->pcb_iomap - (caddr_t)&pcb->pcb_tss);
	for (x = 0; x < sizeof(pcb->pcb_iomap) / 4; x++)
		pcb->pcb_iomap[x] = 0xffffffff;

	pcb->pcb_ldt_sel = pmap_kernel()->pm_ldt_sel =
	    GSYSSEL(GLDT_SEL, SEL_KPL);
	pcb->pcb_cr0 = rcr0();
	pcb->pcb_tss.tss_rsp0 = (u_int64_t)proc0.p_addr + USPACE - 16;
	pcb->pcb_tss.tss_ist[0] = (u_int64_t)proc0.p_addr + PAGE_SIZE;
	proc0.p_md.md_regs = (struct trapframe *)pcb->pcb_tss.tss_rsp0 - 1;
	proc0.p_md.md_tss_sel = tss_alloc(pcb);

	ltr(proc0.p_md.md_tss_sel);
	lldt(pcb->pcb_ldt_sel);
}
示例#5
0
文件: kernel.c 项目: JoepDriesen/jOS
void kernel_early(multiboot_info_t* mbd, unsigned int magic)
{
	terminal_initialize();

	printf("Starting jOS Kernel\n");
	printf("===================\n\n");
	
	if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
		panic("Bootloader is not Multiboot Compliant");
	
	memory_init(mbd);

	printf("[x] Memory Initialized\n");
	
	gdt_init();
	
	printf("GDT Initialized, entering Protected Mode\n");
	
	printf("Enabling IDT:\n");

	pic_init();

	printf("\t[x] PIC IRQs remapped\n");
	
	idt_init();

	printf("\t[x] IDT Initialized\n");
	if (are_interrupts_enabled())
		printf("\t[x] Hardware Interrupts enabled\n");
	else
		printf("\t[ ] Error enabling Hardware Interrupts\n");
	
	phys_mem_management_init();
	
}
示例#6
0
文件: init.c 项目: zswek/bitch
void mm_init(void) {
    
    gdt_init();
    
    mmap_init();
    
}
示例#7
0
文件: init.c 项目: JamesLinus/levos6
int arch_early_init()
{
    int rc;

    rc = x86_serial_init();
    if (rc)
        return rc;

    rc = textmode_init();
    if (rc)
        return rc;

    rc = gdt_init();
    if (rc)
        return rc;

    rc = idt_init();
    if (rc)
        return rc;

    rc = exceptions_init();
    if (rc)
        return rc;

    rc = irq_init();
    if (rc)
        return rc;

    rc = pit_init();
    if (rc)
        return rc;

    return 0;
}
示例#8
0
文件: init.c 项目: mvanga/zion-old
int arch_main(void)
{
	/* call early initcalls */
	do_initcalls_early();

	/* map the first 4mb (phys) to 3gb (virtual) */
	paging_init_pre();
	/* get rid of trickgdt and put a proper one */
	gdt_init();
	mm_init();
	paging_alloc_init();
	/* now we can setup interrupts */
	idt_init();
	/* unmap the first 4mb of pages */
	paging_init_post();

	heap_init();

	kern_page_dir_clone();

	/* we can safely enable interrupts here */
	asm volatile("sti");

	/* call the arch initcalls */
	do_initcalls_arch();

	return main();
}
示例#9
0
文件: arch.c 项目: clandgraf/kdev
/* Called before platform-independent kernel initialization */
void arch_init(void)
{
    gdt_init();
    idt_init();
    timer_init(TIMER_HZ);
    kbc_init();
}
示例#10
0
文件: main.c 项目: MTN-Software/Panda
void kmain(u32 init_stack) {
    init_esp_start = init_stack;
    init_video();
    puts_color_str("Booting Panda OS ...\n", 0x0B);

    cli();
    time_init();
    gdt_init();
    idt_init();
    kb_init();
    mm_init();
    buf_init();
    file_init();
    inode_init();
    ide_init();
    task_init();
    timer_init();
    sysc_init();

    spawn(init_user);
    sti();
    init = 0;
    while(1) {
        if(!init) {
            printk("kernel running ...\n");
            init = 1;
        }
        sti();
        sched();
    }
}
示例#11
0
void kmain(multiboot_info_t* mbd, unsigned long magic)
{
    if(magic != MULTIBOOT_BOOTLOADER_MAGIC) {
        scrn_setmode(GREEN,BLACK);
        scrn_print("Algo salio muy muy mal. No se que mas decirte.");
        return;
    }
    scrn_cls();
    scrn_setmode(GREEN,BLACK);
    scrn_print("BIENVENIDO A juampiOS\n\t"
               "Estamos trabajando para ofrecerle "
               "el OS del futuro.\n");
    scrn_print("INICIALIZANDO GDT...");
    gdt_init();
    gdt_flush();
    scrn_print("OK\nINICIALIZANDO IDT PARA LAS EXCEPCIONES...");
    initialize_exception_handlers();
    idt_init_exceptions();
    remap_pic();
    scrn_print("OK\nINICIALIZANDO IDT PARA LAS INTERRUPCIONES Y SYSCALLS...");
    irq_init_handlers();
    syscalls_initialize();
    idt_init_interrupts();
    idt_init_syscalls();
    idt_flush();
    irq_sti_force();

    scrn_printf("OK\nCHEQUEANDO ESTADO DE LOS MODULOS...");
    scrn_printf("%u MODULOS CARGADOS\n",mbd->mods_count);

    scrn_print("CHECKEANDO ESTADO DE LA MEMORIA\n");
    // Chequeamos que la cantidad de memoria RAM presente.
    if(mbd->flags & 1) {
        scrn_printf("\tCantidad de RAM en el sistema:\n"
                    "\t\tLower: %u Kb, Upper: %u Kb\n",
                    mbd->mem_lower,mbd->mem_upper);
    } else {
        kernel_panic("Mapa de memoria de GRUB invalido");
    }
    scrn_print("INICIALIZANDO LAS ESTRUCTURAS DE MEMORIA DEL KERNEL...");
    module_t* grub_modules = (module_t*) mbd->mods_addr;
    uint kernel_end_addr = grub_modules[mbd->mods_count-1].mod_end;
    // El mapa de memoria upper es a partir del primer megabyte ergo el primer
    // lugar donde nos vamos de largo es 1024 kilobytes mas la memoria que dice GRUB
    paging_init(kernel_end_addr, (1024+mbd->mem_upper)*1024);
    scrn_printf("OK\n");

    scrn_print("INICIALIZANDO DISCO ATA\n");
    hdd_init();
    scrn_printf("INICIALIZANDO FILESYSTEM MINIX\n");
    init_disk_super_block();
    keybuffer_init(1024);
    scheduler_init();

    void * buffer = (void *) grub_modules[0].mod_start;
    jump_to_initial(buffer);

    while(1) ;
}
示例#12
0
/* Install the GDT and the IDT */
void dt_init() {
    /* Initialise the global descriptor table. */
    gdt_init();
    /* Initialise the interrupt descriptor table. */
    idt_init();
    /* Nullify all the interrupt handlers. */
    memset(&irq_handlers, 0, sizeof(isr_t)*256);
}
示例#13
0
void init()
{
gdt_init();
idt_init();
paging_init();
timer_init(50);
keyboard_init();
}
示例#14
0
/** Initialize descriptor tables for the current CPU.
 * @param cpu		CPU to initialize for. */
__init_text void descriptor_init(cpu_t *cpu) {
	/* Initialize and load the GDT/TSS. */
	gdt_init(cpu);
	tss_init(cpu);

	/* Point the CPU to the global IDT. */
	x86_lidt(kernel_idt, (sizeof(kernel_idt) - 1));
}
示例#15
0
void arch_entry() { 
  paging_init();
  gdt_init();
  idt_init();
  isr_init();
  pic_init();
  pit_init();
}
示例#16
0
文件: pmm.c 项目: TySag/project
//pmm_init - setup a pmm to manage physical memory, build PDT&PT to setup paging mechanism 
//         - check the correctness of pmm & paging mechanism, print PDT&PT
void pmm_init(void)
{
	//We need to alloc/free the physical memory (granularity is 4KB or other size). 
	//So a framework of physical memory manager (struct pmm_manager)is defined in pmm.h
	//First we should init a physical memory manager(pmm) based on the framework.
	//Then pmm can alloc/free the physical memory. 
	//Now the first_fit/best_fit/worst_fit/buddy_system pmm are available.
	init_pmm_manager();

	// detect physical memory space, reserve already used memory,
	// then use pmm->init_memmap to create free page list
	page_init();

	//use pmm->check to verify the correctness of the alloc/free function in a pmm
	check_alloc_page();

	// create boot_pgdir, an initial page directory(Page Directory Table, PDT)
	boot_pgdir = boot_alloc_page();
	memset(boot_pgdir, 0, PGSIZE);
	boot_cr3 = PADDR(boot_pgdir);

	check_pgdir();

	static_assert(KERNBASE % PTSIZE == 0 && KERNTOP % PTSIZE == 0);

	// recursively insert boot_pgdir in itself
	// to form a virtual page table at virtual address VPT
	boot_pgdir[PDX(VPT)] = PADDR(boot_pgdir) | PTE_P | PTE_W;

	// map all physical memory to linear memory with base linear addr KERNBASE
	//linear_addr KERNBASE~KERNBASE+KMEMSIZE = phy_addr 0~KMEMSIZE
	//But shouldn't use this map until enable_paging() & gdt_init() finished.
	boot_map_segment(boot_pgdir, KERNBASE, KMEMSIZE, 0, PTE_W);

	//temporary map: 
	//virtual_addr 3G~3G+4M = linear_addr 0~4M = linear_addr 3G~3G+4M = phy_addr 0~4M   
	boot_pgdir[0] = boot_pgdir[PDX(KERNBASE)];
	boot_pgdir[1] = boot_pgdir[PDX(KERNBASE) + 1];

	enable_paging();

	//reload gdt(third time,the last time) to map all physical memory
	//virtual_addr 0~4G=liear_addr 0~4G
	//then set kernel stack(ss:esp) in TSS, setup TSS in gdt, load TSS
	gdt_init();

	//disable the map of virtual_addr 0~4M
	boot_pgdir[0] = boot_pgdir[1] = 0;

	//now the basic virtual memory map(see memalyout.h) is established.
	//check the correctness of the basic virtual memory map.
	check_boot_pgdir();

	print_pgdir(kprintf);

	slab_init();
}
示例#17
0
文件: main.c 项目: jmtoba/Gaia
// Initialisation routine - zeroes all the interrupt service routines,
// initialises the GDT and IDT.
void gaia_init(void)
{
    gdt_init();	// Initialise the global descriptor table.
    idt_init();	// Initialise the interrupt descriptor table.

//    paging_init();
    syscall_init();

    // Enable interruptions
    asm volatile("sti");
}
示例#18
0
void boot_64(uint32_t magic, uint32_t multiboot) {
  // checking multiboot magic variable.
  VGA_AT(0,0) = VGA_ENTRY('H', WHITE_ON_BLACK);
  if (magic != MULTIBOOT_BOOTLOADER_MAGIC) {
    VGA_AT(0,1) = VGA_ENTRY('!', WHITE_ON_BLACK);
    kernel_panic();
  }

  // copying multiboot data.
  VGA_AT(0,1) = VGA_ENTRY('E', WHITE_ON_BLACK);
  multiboot_info_t *info = (multiboot_info_t *)kernel_p2v((uintptr_t)multiboot);
  switch (multiboot_copy(info)) {
  case MULTIBOOT_TOO_MANY_MEMORY_MAPS:
    VGA_AT(0,2) = VGA_ENTRY('?', WHITE_ON_BLACK);
    kernel_panic();
  case MULTIBOOT_TOO_MANY_MODULES:
    VGA_AT(0,2) = VGA_ENTRY('?', WHITE_ON_BLACK);
    kernel_panic();
  case MULTIBOOT_TOO_MANY_ELF_HEADERS:
    VGA_AT(0,2) = VGA_ENTRY('.', WHITE_ON_BLACK);
    kernel_panic();
  }

  // we no longer need the original memory map at zero address.
  VGA_AT(0,2) = VGA_ENTRY('L', WHITE_ON_BLACK);
  page_set_pdpt(0, 0, 0);
  page_invalidate_all();
  
  // initialize page allocators.
  VGA_AT(0,3) = VGA_ENTRY('L', WHITE_ON_BLACK);
  lomem_init();
  himem_init();

  // initialize CPUs.
  VGA_AT(0,4) = VGA_ENTRY('B', WHITE_ON_BLACK);
  cpu_enable_features();
  cpu_init();
  service_init();
  gdt_init(); // adds per-cpu TSS into GDT.
  tss_update();

  // initialize interrupt handling.
  VGA_AT(0,5) = VGA_ENTRY('E', WHITE_ON_BLACK);
  pic_init();
  idt_init();

  // kick-start the core service.
  VGA_AT(0,6) = VGA_ENTRY('N', WHITE_ON_BLACK);
  kernel_start_core();

  // start scheduler and do stuff.
  VGA_AT(0,7) = VGA_ENTRY('D', WHITE_ON_BLACK);
  kernel_main();
}
示例#19
0
文件: kmain.c 项目: arianvp/SummerOS
uint32_t kmain(void)
{
	kcls();
	kputs("Hello, World!\n");
	gdt_init();
	idt_init();
	asm volatile("int $0x3");
	asm volatile("int $0x4");
	asm volatile("int $0x5");
	asm volatile("int $0x6");
	return 0xDEADBABA;
}
示例#20
0
void init(struct multiboot *mb)
{
	size_t i;
	for(i=0;i<TEXT_HEIGHT*TEXT_WIDTH*2;i++)
	{
		*(((char *)TEXT_BUFFER)+i)=0;
	}
	text_pos=0;
	
	printk("benaryOS booted");
	if(mb->mbs_cmdline)
	{
		printk(" with cmdline \"%s\"",(char *)mb->mbs_cmdline);
	}
	putchar('\n');
	hardware_detection();
	//Physical Memory Management
	printk("initialise PMM\n");
	pmm_init(mb);

	//Global Descriptor Table
	printk("loading GDT\n");
	gdt_init();

	//Programmable Interrupt Timer
	printk("initialise PIT\n");
	pit_init(100);

	//Programmable Interrupt Controller
	printk("initialise PIC\n");
	pic_init();

	//Interrupt Descriptor Table
	printk("initialise IDT\n");
	idt_init();

	//Paging
	printk("initialise Paging\n");
	paging_init(mb);

	//Modules
	printk("loading modules(%d)\n",mb->mbs_mods_count);
	modules_init(mb);

	printk("benaryOS running\n");
	printk("starting first task now\n");
	asm volatile("sti");
	//find_com();	

	//this will forget our thread
	asm volatile("int $0x20");
}
示例#21
0
int32_t kernel_main(multiboot_t *mboot_ptr)
{
    textmode_init();

    printf("                   _____ _                 _       ____   _____ \n                  / ____(_)               | |     / __ \\ / ____|\n                 | (___  _ _ __ ___  _ __ | | ___| |  | | (___  \n                  \\___ \\| | '_ ` _ \\| '_ \\| |/ _ \\ |  | |\\___ \\ \n                  ____) | | | | | | | |_) | |  __/ |__| |____) |\n                 |_____/|_|_| |_| |_| .__/|_|\\___|\\____/|_____/ \n                                    | |                         \n                                    |_|                         \n");
    textmode_set_colors(COLOR_RED, COLOR_BLACK);
    textmode_move_cursor(19, 6);
    printf("Version %i.%i.%i", VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
    textmode_move_cursor(19, 7);
    printf("Built %s", VERSION_DATE);
    textmode_set_colors(COLOR_GREEN, COLOR_BLACK);
    textmode_move_cursor(41, 6);
    printf("Written by Joe Biellik");
    textmode_set_colors(COLOR_LTGRAY, COLOR_BLACK);
    textmode_move_cursor(0, 9);

    fpu_init();
    gdt_init();
    idt_init();

    __asm __volatile__("sti"); // Start interrupts

    pit_init();
    serial_init();

    // Test serial
    int8_t buffer[50];
    sprintf(buffer, "SimpleOS %i.%i.%i (%s)\n", VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_DATE);
    serial_write(SERIAL_PORT_A, buffer);

    // Test RTC
    datetime_t *dt = 0;
    rtc_get(dt);
    printf("Started at %02i-%02i-%02i %02i:%02i:%02i\n\n", dt->year, dt->month, dt->day, dt->hour, dt->min, dt->sec);

    // Test CPU
    cpu_detect();

    printf("\n");

    // Test PCI
    pci_scan();

    for (;;);

    return 0x12345678;
}
示例#22
0
文件: kmain.c 项目: lygood2007/Weenix
/**
 * This is the first real C function ever called. It performs a lot of
 * hardware-specific initialization, then creates a pseudo-context to
 * execute the bootstrap function in.
 */
void
kmain()
{
        GDB_CALL_HOOK(boot);

        dbg_init();
        dbgq(DBG_CORE, "Kernel binary:\n");
        dbgq(DBG_CORE, "  text: 0x%p-0x%p\n", &kernel_start_text, &kernel_end_text);
        dbgq(DBG_CORE, "  data: 0x%p-0x%p\n", &kernel_start_data, &kernel_end_data);
        dbgq(DBG_CORE, "  bss:  0x%p-0x%p\n", &kernel_start_bss, &kernel_end_bss);

        page_init();

        pt_init();
        slab_init();
        pframe_init();

        acpi_init();
        apic_init();
	      pci_init();
        intr_init();

        gdt_init();

        /* initialize slab allocators */
#ifdef __VM__
        anon_init();
        shadow_init();
#endif
        vmmap_init();
        proc_init();
        kthread_init();

#ifdef __DRIVERS__
        bytedev_init();
        blockdev_init();
#endif

        void *bstack = page_alloc();
        pagedir_t *bpdir = pt_get();
        KASSERT(NULL != bstack && "Ran out of memory while booting.");
        context_setup(&bootstrap_context, bootstrap, 0, NULL, bstack, PAGE_SIZE, bpdir);
        context_make_active(&bootstrap_context);

        panic("\nReturned to kmain()!!!\n");
}
示例#23
0
文件: loader.c 项目: abailly/solo5
void loader_main(struct multiboot_info *mb)
{
    multiboot_module_t *mod;
    multiboot_memory_map_t *mmap;
    uint32_t kernel_entry, kernel_end;
    uint64_t max_addr = 0;
    uint64_t max_avail = 0;
    int m = 0;

    serial_init();

    printk("Memory map from multiboot info:\n");

    for (mmap = (multiboot_memory_map_t *)mb->mmap_addr; 
         (uint32_t)mmap < mb->mmap_addr + mb->mmap_length; mmap++) {
        m += mmap->len;
        printk("%d 0x%llx - 0x%llx [%d] (%d)\n", mmap->size, 
               mmap->addr, 
               mmap->addr + mmap->len, m/1024, mmap->type);
        max_addr = mmap->addr + mmap->len;
        if ( mmap->type == MULTIBOOT_MEMORY_AVAILABLE )
            max_avail = max_addr;
    }

    mod = (multiboot_module_t *) mb->mods_addr;

    printk("Found: %s\n", (char *)mod->cmdline);

    /* update mod_end with room for bss... we really should find the
       bss and fill it with zeros so the kernel doesn't need to worry
       about doing the zeroing. */
    mod->mod_end = elf_get_end(mod->mod_start);
    kernel_entry = elf_get_entry(mod->mod_start);

    printk("mod_start: 0x%lx\n", mod->mod_start);
    printk("mod_end: 0x%lx\n", mod->mod_end);
    printk("max_addr: 0x%llx\n", max_addr);
    printk("max_avail: 0x%llx\n", max_avail);

    kernel_end = ((mod->mod_end & PAGE_MASK) + PAGE_SIZE);
    pagetable_init(max_addr, kernel_end);
    gdt_init();

    to64_jump(kernel_entry, (uint32_t)mb, max_avail - 8);
}
示例#24
0
bool ir_trampoline_init(void *UNUSED(unused))
{
	// Map the trampoline area into memory
	vm_mapPageRange(vm_getKernelDirectory(), (uintptr_t)IR_TRAMPOLINE_PHYSICAL, (vm_address_t)IR_TRAMPOLINE_BEGIN, IR_TRAMPOLINE_PAGES, VM_FLAGS_KERNEL);

	// Copy the IDT section into the trampoline
	vm_address_t _idt_sectionBegin      = (vm_address_t)&idt_sectionBegin;
	vm_address_t _idt_sectionEnd        = (vm_address_t)&idt_sectionEnd;
	vm_address_t _idt_entryHandler      = (vm_address_t)&idt_entry_handler;

	memcpy(ir_trampoline_map->base, &idt_sectionBegin, _idt_sectionEnd - _idt_sectionBegin);
	ir_trampolineFixEntryCall(_idt_entryHandler - _idt_sectionBegin, _idt_sectionEnd - _idt_entryHandler);

	// Set IDT and GDT straight
	ir_idt_init(ir_trampoline_map->idt, IR_TRAMPOLINE_BEGIN - _idt_sectionBegin);
	gdt_init(ir_trampoline_map->gdt, &ir_trampoline_map->tss);

	return true;
}
示例#25
0
int main()
{
//Start video driver (must always be before loading message)
    mm_init();
    pg_init();
    real_init();
    video_init();
    video_setdriver(video_vgatext_getdriver(),0);

//Put loading message
    cli_puts("ArcaneOS Loading...\n");

//Setup kernel
    gdt_init();
    idt_init();
    isr_init();
    irq_init();
    timer_init();
    kb_init();
    ui_init();
    cpuid_init();
    cmos_init();
    rtc_init();
    acpi_init();
    power_init();
    mt_init();
    syscall_init();
    floppy_init();

    __asm__ __volatile__ ("sti");

//Enable ACPI
    acpi_enable();

//Create thread for ui
    mt_create_thread(mt_kernel_process,test,2);

//Endless loop to prevent bugs when all threads are sleeping
    for(;;)
        __asm__ __volatile__ ("hlt");
}
示例#26
0
文件: init.c 项目: RharryR/KiteOS
// Starts system
void 
init_system(multiboot_info_t* bi)
{
	// Start display
	vga_init();
	printk(" KiteOS V1.0 --- Initializing \n");
	// PIT-less wait to show user boot
	for(int i=0;i<64821125;i++);
	vga_color(0x3, 0x0);
	printk("-- STARTING LOWLEVEL KERNEL --\n");
	vga_color(0x5, 0x0);
	printk("!* Initiating GDT\n");
	gdt_init();
	printk("!* Initiating IDT\n");
	idt_init();
	printk("!* Installing Exceptions\n");
	isr_init();
	vga_color(0x4, 0x0);
	printk("*** ENTERTED PROTECTED MODE ***\n");
	vga_color(0x5, 0x0);
	printk("!* Initiating IRQ\n");
	irq_init();
	printk("!* Starting PIT\n");
	pit_init();
	printk("!* Starting RTC\n");
	rtc_init();
	printk("!* Restoring Interrupts\n");
	__asm__ __volatile__ ("sti");
	vga_color(0x3, 0x0);	
	printk("-- STARTING LOWLEVEL DRIVERS --\n");
	vga_color(0x5, 0x0);
	printk("!* Starting physical memory manager\n");
	kalloc_init((void*)bi->mmap_addr, (unsigned long)bi->mmap_length);
	printk("!* Starting keyboard driver\n");
	kb_init();
	printk("!* Starting IDE driver\n");
	ide_init(0x1F0, 0x3F6, 0x170, 0x366);
	vga_color(0x4, 0x0);
	printk("*** Initialized system successfully ***\n");
}
示例#27
0
文件: kernel.c 项目: TheFakeCake/os
void runKernel()
{
    // Initializing the GDT
    gdt_init();

    // Initializing the screen
    init_display();

    // Initializing the interruption controler (PIC)
    pic_init();

    // Initializing the IDT
    idt_init();

    // Initializing timer @ 100Hz
    timer_init(100);

    // Initializing the keyboard);
    keyboard_init();

    // Init the file system superblock
    superblock_init();

    // Enables hardware interruptions
    sti();

    #ifdef TEST

    // Runs the test procedure if test mode is enabled
    runFileSystemTests();

    #else

    // Executing the Shell
    exec_task("shell");

    #endif

    halt();
}
示例#28
0
文件: mp.c 项目: chnlkw/ucore_plus
void ap_init(void)
{
	gdt_init(per_cpu_ptr(cpus, bcpuid));
	tls_init(per_cpu_ptr(cpus, bcpuid));
	kprintf("CPU%d alive\n", myid());
	/* load new pagetable(shared with bsp) */
	pmm_init_ap();
	idt_init();		// init interrupt descriptor table

	/* test pmm */
	struct Page *p = alloc_pages(2);
	kprintf("I'm %d, get 0x%016llx(PA)\n", myid(), page2pa(p));
	free_pages(p, 2);

	lapic_init();
	proc_init_ap();

	atomic_inc(&bsync); /* let BSP know we are up */

	intr_enable();		// enable irq interrupt
	cpu_idle();
}
示例#29
0
文件: kmain.c 项目: alanbrady/rawros
// main function loaded through loader.asm
int kmain(multiboot_info_t* mbi, uint32_t magic) {
    (void)magic; /* TODO: check if multiboot loader magic number is correct */


    gdt_init();
    idt_init();

    pic_init();
    pic_set_mask(PIC1_KBD_IRQ, PIC_NO_IRQ);

    asm volatile("sti");

    fb_enable_cursor();
    clrscr();

    printk(PRINTK_FB, "Cursor position: %u\n", fb_get_cursor());

    printk(PRINTK_FB, "Cursor start: %h\n",
            (unsigned int)(fb_get_cursor_start()));

    printk(PRINTK_FB, "Cursor end:   %h\n",
            (unsigned int)(fb_get_cursor_end()));

    printk(PRINTK_FB, "Frame buffer address: %h\n", fb_get_start_address());

    print_memory_info(mbi);

    printk(PRINTK_FB, "bitsize - char:  %u\n", sizeof(char)*8);
    printk(PRINTK_FB, "bitsize - short: %u\n", sizeof(short)*8);
    printk(PRINTK_FB, "bitsize - int:   %u\n", sizeof(int)*8);
    printk(PRINTK_FB, "bitsize - long:  %u\n", sizeof(long)*8);
    printk(PRINTK_FB, "sizeof page_entry_t: %u\n", sizeof(page_entry_t));

    for (;;) {
        asm volatile("hlt");
    }

    return 0;
}
示例#30
0
文件: main.c 项目: Codnect/uniq
void kmain(mboot_info_t *mboot_info,uint32_t mboot_magic,uint32_t stack_ptr){

	
	/* vga konsol */
	init_vga_console();
	time_init();

	debug_print(KERN_INFO,"Stack pointer : \033[1;7m%P",stack_ptr);

	if(mboot_magic != MULTIBOOT_LOADER_MAGIC)
		debug_print(KERN_WARNING,"Invalid the magic number. The magic number is \033[1;31m%P",mboot_magic);
	else
		debug_print(KERN_INFO,"Valid the magic number.The magic number is \033[1;37m%P",mboot_magic);
		
	/*
	 * gdt,idt,isr ve irq
	 */
	gdt_init();	/* global tanimlayici tablosu */
	idt_init();	/* kesme tanimlayici tablosu */
	isr_init();	/* kesme servis istekleri */
	irq_init();	/* donanim kesme istekleri */
#if 0
	__int_test();
#endif
	timer_init();

	/*
	 * memory
	 */
	paging_init(mboot_info->mem_lower + mboot_info->mem_upper);
	paging_final();	
#if 0
	 __page_fault_test();
#endif
	heap_init();
	multitasking_init();

}