Пример #1
0
int main(void)
{
	print("kernel : gdt loaded\n");

	init_idt();
	print("kernel : idt loaded\n");

	init_pic();
	print("kernel : pic configured\n");

	hide_cursor();

	/* Initialisation du TSS */
	asm("	movw $0x38, %ax \n \
		ltr %ax");
	print("kernel : tr loaded\n");

	/* Initialisation de la memoire */
	init_mm();
        print("kernel : paging enable\n");
        
	sti;
	print("kernel : interrupts enable\n");
            
        //init_serial();
        //print("kernel : serial port enable\n");
       // BochsConsolePrint("Bonjour\n");
	while (1);
}
Пример #2
0
void k_main(multiboot_info_t * multiboot_info)
{
	system_info.total_memory = multiboot_info->mem_upper;

	clrscr();

	printf("%s\n", &uname);
	printf("  Copyright 2005-2006 Draco Project\n");
	printf("%dM of extended memory.\n", multiboot_info->mem_upper >> 10);

	cons_attribute = 7;

	init_gdt();
	init_idt();
	init_irq(0x20, 0x28);
	paging_kernel_env(system_info.total_memory / 4);
	paging_init();
	proc_init();
	modules_init(multiboot_info);

	printf("Kernel is initialized.\n");

	sti();

	while(1);
}
Пример #3
0
int main(void)
{    
    init_global();

    init_gdt();

    init_idt();

    init_tss();

    init_virtual_memory_mapping();

    init_process();

    init_8259a();

    init_clock();

    init_keyboard();

    init_syscall();

    debug_helper();

    restart();
}
Пример #4
0
void 
lrt_pic_init(lrt_pic_handler h)
{
  LRT_Assert(has_lapic());
  
  init_idt();

  disable_pic();
  
  //Disable the pit, irq 0 could have fired and therefore
  //wouldn't have been masked and then we enable interrupts
  //so we must reset the PIT (and we may as well prevent it from firing)
  disable_pit();

  //Disable the rtc, irq 8 could have fired and therefore
  //wouldn't have been masked and then we enable interrupts
  //so we must disable it
  disable_rtc();

  acpi_init();

  enable_lapic();
  lrt_pic_myid = get_lapic_id();

  lrt_pic_mapipi(h);
  
  lrt_pic_loop();
}
Пример #5
0
void init_interrupt(void){
    map_pages(MAP_LAPIC,lapic_base,LAPIC_SIZE);
    
    init_idt();

    init_lapic(MAP_LAPIC + (lapic_base & (PAGE_SIZE - 1)));
}
Пример #6
0
void
os_init_cont(void) {
   /* Reset the GDT. Although user processes in Nanos run in Ring 0,
      they have their own virtual address space. Therefore, the
      old GDT located in physical address 0x7C00 cannot be used again. */
   init_segment();

   /* Initialize the serial port. After that, you can use printk() */
   init_serial();

   /* Set up interrupt and exception handlers,
      just as we did in the game. */
   init_idt();

   /* Initialize the intel 8259 PIC. */
   init_intr();

   /* Initialize processes. You should fill this. */
   init_proc();

   welcome();

   sti();

   /* This context now becomes the idle process. */
   while (1) {
      wait_intr();
   }
}
Пример #7
0
void init_descriptor_tables()
{
  init_gdt();
  init_idt();

  memset(&interrupt_handlers, 0, sizeof(isr_t)*256);
}
Пример #8
0
int kernel_main() {
	init_kernel_stack(KERN_HEAP_OFFSET);

	init_device_drivers();
	device_open(TTY, 0);

	k_printf("entered into main kernel..!\n");
	k_printf("and initialized device drivers.\n");

	init_gdt();
	k_printf("initialized protected mode.\n");

	check_physical_mem_size();
	k_printf("physical memory size : %d megabytes.\n", physical_mem_size>>20);

	init_paging();
	k_printf("initialized paging.\n");

	init_vfs();
	k_printf("initialized file system (fat16).\n");

	init_idt();
	k_printf("initialized interrupt.\n");

	init_tss();

	struct fat16_file_kt f;
	f = fs_open_fat16("/apps/snake.bin");
	create_task(f.buffer, f.information.file_size); 
	dump_task_queue();
	current_task = pop_task_queue();
	create_task(init1, 256);
	create_task(init2, 256);
	create_task(init3, 256);
	create_task(init4, 256);
	create_task(init5, 256);
	dump_task_queue();

	/*
	do {
		struct task_struct_kt *cur = task_head;
		do {
			k_printf("#%d - stack %x, start %x\n", cur->tid, cur->sp_page, cur->start_entry);
			cur = cur->next;
		} while (cur != task_head);
	} while(0);
	*/

	//for(;;);  // user page가 제대로 동작할때까지 막아둠.

	cli();
	SCHEDULE();
	
	for(;;);
	
	device_close(TTY, 0);

	return 0;
}
Пример #9
0
// Initialisation routine - zeroes all the interrupt service routines,
// initialises the GDT and IDT.
void init_descriptor_tables() {
  // Initialise the global descriptor table.
  init_gdt();
  // Initialise the interrupt descriptor table.
  init_idt();
  // Nullify all the interrupt handlers.
  interrupt::init();
}
Пример #10
0
// Initialize the GDT and IDT
void init_descriptor_tables()
{
    // Initialize the Global Descriptor Table
	init_gdt();
	
	// Initialize the Interrupt Descriptor Table
	init_idt();
}
Пример #11
0
void init_descriptor_tables()
{
    // Initialise the global descriptor table
    init_gdt();

    // Initialise the interrupt descriptor table
    init_idt();
}
Пример #12
0
int kernel_main() {
    init_gdt();
    init_idt();
    init_video();

    setcolor(make_color(COLOR_GREEN, COLOR_BLACK));
    printf("Hello, World!");
    newline(5);
    setcolor(make_color(COLOR_ORANGE, COLOR_BLACK));
    printf("                          ,--.\n");
    printf("                   _/ <`-'\n");
    printf("               ,-.' \\--\\_\n");
    printf("              ((`-.__\\   )\n");
    printf("               \\`'    @ (_\n");
    printf("               (        (_)\n");
    printf("              ,'`-._(`-._/\n");
    printf("           ,-'    )&&) ))\n");
    printf("        ,-'      /&&&%-'\n");
    printf("      ,' __  ,- {&&&&/\n");
    printf("     / ,'  \\|   |\\&&'\\\n");
    printf("    (       |   |' \\  `--.\n");
    printf("(%--'\\   ,--.\\   `-.`-._)))\n");
    printf(" `---'`-/__)))`-._)))\n\n");

    int count = 0;

    //Some delay before bouncing
    while (count < 10) {
        sleep(100000000);
        count++;
    }
    count = 0;
    while (true) {

        while (count < 5) {
            sleep(100000000);
            scrolldown();
            count++;
        }

        while (count < 10) {
            sleep(100000000);
            scrollup();
            count++;

        }

        if (count % 10 == 0) {
            count = 0;
        }

    }
    printf("Exiting...");


    return 0;
}
Пример #13
0
Файл: main.c Проект: NJUOS/Lab0
/* 主循环,bootloader载入game二进制文件后,就跳转到这里执行 */
void
game_init(void) {
	init_timer();
	init_idt();
	init_intr();
	enable_interrupt();
	play(); /* 这里是演示代码,显示浮动的文字和键盘扫描码 */
	assert(0); /* 此处永远不应该返回,为什么? */
}
Пример #14
0
int main(multiboot_t *mboot_ptr)
{
  monitor_clear();

  init_gdt ();
  init_idt ();
  init_timer (20);
  init_pmm (mboot_ptr->mem_upper);
  init_vmm ();

  // Find all the usable areas of memory and inform the physical memory manager about them.
  uint32_t i = mboot_ptr->mmap_addr;
  while (i < mboot_ptr->mmap_addr + mboot_ptr->mmap_length)
  {
    mmap_entry_t *me = (mmap_entry_t*) i;
    
    // Does this entry specify usable RAM?
    if (me->type == 1)
    {
      uint32_t j;
      // For every page in this entry, add to the free page stack.
      for (j = me->base_addr_low; j < me->base_addr_low+me->length_low; j += 0x1000)
      {
        pmm_free_page (j);
      }
    }

    // The multiboot specification is strange in this respect - the size member does not include "size" itself in its calculations,
    // so we must add sizeof (uint32_t).
    i += me->size + sizeof (uint32_t);
  }

  printk ("Paging initialised.\n");

  printk ("Mapping page...\n");
  uint32_t addr = 0x900000;
  map (addr, 0x500000, PAGE_PRESENT|PAGE_WRITE);
  printk ("Accessing page...\n");

  volatile uint32_t *_addr  = (volatile uint32_t*)addr;
  *_addr = 0x567;
  printk ("*addr: %x\n", *_addr);

  printk ("Unmapping page...\n");
  unmap (addr);

  printk ("Trying to access again (should page fault)...\n");
  *_addr = 0x678;
  printk ("*addr: %x\n", *_addr);

  asm volatile ("sti");

  for (;;);
  
  return 0xdeadbeef;
}
Пример #15
0
// Initialisation routine - zeroes all the interrupt service routines,
// initialises the GDT and IDT.
void init_descriptor_tables()
{

    // Initialise the global descriptor table.
    init_gdt();
    // Initialise the interrupt descriptor table.
    init_idt();
    // Nullify all the interrupt handlers.
    memset(&interrupt_handlers, 0, sizeof(isr_t)*256);
}
Пример #16
0
void kmain(uint32_t magic, multiboot_info_t* mbi) {
    clear();
    printf("Kernel is on!\n");

    if (magic != MULTIBOOT_BOOTLOADER_MAGIC) {
        printf("Invalid magic code: %x", magic);
        return;
    }

    // Check if the cpuid instruction is available
    if (check_cpuid()) {
        printf("CPUID available\n");
        if (check_apic()) {
            printf("APIC available\n");
        } else {
            printf("APIC not available\n");
        }
    } else {
        printf("CPUID not available\n");
    }

    // Init the floating point unit
    init_fpu();

    // Initialize the Interrupt Descriptor Table and Interrupt Service Routines
    init_idt();

    // Print (if available) memory map
    if (mbi->flags && MULTIBOOT_INFO_MEM_MAP) {
        uint32_t mmap_entries = mbi->mmap_length / 24;

        printf("## Memory map ##\n");
        printf("Entries: %u\n", mmap_entries);

        multiboot_memory_map_t* mmap_entry = (multiboot_memory_map_t *)
            mbi->mmap_addr;
        for (uint32_t i = 0; i < mmap_entries; ++i, ++mmap_entry) {
            printf("Entry %u\n", i);
            printf("\t.addr: %x\n", mmap_entry->addr);
            printf("\t.len: %u\n", mmap_entry->len);
            printf("\t.type: ");
            if (mmap_entry->type == MULTIBOOT_MEMORY_AVAILABLE) {
                printf("available\n");
            } else {
                printf("reserved\n");
            }
        }
    }

    // Test breakpoint interrupt
    __asm __volatile("int $0x3");

    init_timer(50); // Initialise timer to 50Hz
}
Пример #17
0
int nx_main(struct multiboot *mboot)
{
	init_gdt();
	init_idt();
	monitor_clear();
	monitor_write_str("Hello world!\n");
	init_timer(20);
	asm volatile ("sti");

	return 0;
}
Пример #18
0
void
interrupt_init()
{
	int i;

	init_idt();
	apic_init();
	for (i = 0; i < IDT_MAX_DESCS; i++) {
		tw_memset(&(handlers[i]), 0, sizeof(intr_handler_s));
	}
}
Пример #19
0
void init_interrupts (void)
{
  int i;

  init_idt();
  init_8259();

  for (i = 0; i < NO_OF_IRQS; i++)
  {
    irq_handler_table[i] = default_irq_handler;
  }
}
Пример #20
0
/* Initialize descriptor tables (duh) */
void init_descriptor_tables( void )
{
	/* global descriptor table */
	printk("Initializing GDT\n");
	init_gdt();
	/* interrupt descriptor table */
	printk("Initializing IDT\n");
	init_idt();
	/* now we can start interrupts */
	printk("Enabling interrupts\n");
	int_enable();
}
Пример #21
0
void kmain(uint32_t magic, multiboot_info_t *mboot, uintptr_t ebp) {
	monitor_clear();

	printf("Booting Dionysus!\n");

	ASSERT(magic == MULTIBOOT_BOOTLOADER_MAGIC && "Not booted with multiboot.");
	ASSERT(mboot->flags & MULTIBOOT_INFO_MEMORY && "No memory info.");
	ASSERT(mboot->flags & MULTIBOOT_INFO_MEM_MAP && "No memory map.");

	printf("Initializing GDT\n");
	init_gdt();

	printf("Initializing IDT\n");
	init_idt();

	// Check for modules
	if (mboot->flags & MULTIBOOT_INFO_MODS && mboot->mods_count) {
		multiboot_module_t *mods = (multiboot_module_t *)mboot->mods_addr;
		placement_address = mods[mboot->mods_count - 1].mod_end + KERNEL_BASE;
	}

	printf("Setting up paging\n");
	init_paging(mboot->mem_lower + mboot->mem_upper, mboot->mmap_addr,
		mboot->mmap_length);

	printf("Initializing timers\n");
	init_time();
	init_timer();

	printf("Starting task scheduling\n");
	init_tasking(ebp);
	init_syscalls();

	printf("Initializing vfs\n");
	init_vfs();

	printf("Initializing driver subsystem\n");
	init_blockdev();

	init_chardev();
	init_term();

	printf("Enumerating PCI bus(ses)\n");
	init_pci();
	dump_pci();

	init_devfs();
	ASSERT(mount(NULL, "/dev", "devfs", 0) == 0);

	init_ide();

	halt();
}
Пример #22
0
int kmain(multiboot_t *mboot_ptr)
{
  monitor_clear();
  
  printk("8888888888               d8b 888  .d88888b.   .d8888b.\n");
  printk("888                      Y8P 888 d88P\" \"Y88b d88P  Y88b\n");
  printk("888                          888 888     888 Y88b.\n");
  printk("8888888    88888b.d88b.  888 888 888     888  \"Y888b.\n");
  printk("888        888 \"888 \"88b 888 888 888     888     \"Y88b.\n");
  printk("888        888  888  888 888 888 888     888       \"888\n");
  printk("888        888  888  888 888 888 Y88b. .d88P Y88b  d88P\n");
  printk("8888888888 888  888  888 888 888  \"Y88888P\"   \"Y8888P\"\n");
  
  init_gdt ();
  init_idt ();
  init_keyboard();
  setup_x87_fpu ();
  init_timer (20);
  init_pmm (mboot_ptr->mem_upper);
  init_vmm ();
  init_heap ();

  // Find all the usable areas of memory and inform the physical memory manager about them.
  uint32_t i = mboot_ptr->mmap_addr;
  while (i < mboot_ptr->mmap_addr + mboot_ptr->mmap_length)
  {
    mmap_entry_t *me = (mmap_entry_t*) i;

    // Does this entry specify usable RAM?
    if (me->type == 1)
    {
      uint32_t j;
      // For every page in this entry, add to the free page stack.
      for (j = me->base_addr_low; j < me->base_addr_low+me->length_low; j += 0x1000)
      {
        pmm_free_page (j);
      }
    }

    // The multiboot specification is strange in this respect - the size member does not include "size" itself in its calculations,
    // so we must add sizeof (uint32_t).
    i += me->size + sizeof (uint32_t);
  }

  kernel_elf = elf_from_multiboot (mboot_ptr);

  asm volatile ("sti");

  panic ("Testing panic mechanism");
  for (;;);

  return 0xdeadbeef;
}
Пример #23
0
void main() {

  char string[40];

  char *test = (char *) 0x0;
  uint32_t addr = 0x0;

  puts(" ");
  
  printf("ab%bc", 0xff);
  
  init_idt();
  init_register_isrs();
  
  print_string("\n");

  
  
  asm volatile ("int $0x3");
  
  asm volatile ("int $0x2");
  asm volatile ("int $0x3");
	
  while(1);
  /* asm volatile ("int $0x3"); */
  
  //  init_keyboard();
  
  //  asm volatile("int $0x8");
  
  init_timer(50);

  init_paging();


  
  /* print_string(itoa((uint32_t) &test, string, 16)); */

  while(addr < 0xffffffff) {
    print_string("Testing memory position: 0x");
    puts(itoa(((uint32_t) addr), string, 16));
    string[0] = *test;
    test += 0x100000;
    addr += 0x100000;
  }
    
  

  
  
  while(1) ; // infinite loop
}
Пример #24
0
Файл: kernel.c Проект: mmitou/os
void kernel_start()
{
   init_pic();
   init_gdt();
   init_idt();
   init_graphic();

   io_sti();

   while(1);
//   halt();

}
Пример #25
0
//写个struct mulitboot 省着老有警告 用的时候再改
//grub标准里有这个http://gnu.april.org/software/grub/manual/multiboot/multiboot.html
//struct multiboot{};
int kmain(struct multiboot_info* mboot_ptr)//name is mentioned in boot.s
{
	init_gdt();
	init_idt();
	monitor_write("qhello!!@#$%^&*()[]+= bcdef:wworld! 1234");
	monitor_write("\n");
	monitor_write_hex(256);
	monitor_write("finished");
	monitor_write_dec(256);
	monitor_write("done ss");
	monitor_write_hex(kss);
	monitor_write("done esp");
	monitor_write_hex(kesp);
	
	monitor_put('\n');
	//init_gdt();
	//init_idt();
	asm volatile("int $0x3");
	asm volatile("int $0x4");
	prtf("aa bb %x %u %s 11\t \nbb\n", 10, 10, "str");	
	//asm volatile("sti");
    	//init_timer(500);
	//monitor_write_hex((u32int)&end);
	prtf("1\tend is at addr :%x end itself:%x kend:%x &kend:%x\n", (u32int)&end, end, kend, &kend);

	/*旧的paging实现
	init_paging();
	prtf("paging enabled!\n");
	u32int* ptr = (u32int*)0xa0000000;
	*ptr = 1;
	*/
	//新的paging 
	//换了个管理物理内存的方法 这个没啥大区别
	//分割物理内存管理 虚拟内存管理
	//显式映射虚拟地址
	//pmm里搞的都是物理地址 函数返回的也是物理地址
	init_pmm ((u32int)&end, 1 << 25);//32MB
	init_vmm ();
	/*prtf("mboot_ptr : %x\n", mboot_ptr);//大概0x2d000 没到640k呢
	prtf("mem_upper %x\n", mboot_ptr->mem_upper);*/
	map(0xa0000000, 0x300000, PAGE_WRITE|PAGE_PRESENT);
	prtf("mapped!\n");
	u32int* ptr = (u32int*)0xa0000000;
	*ptr = 1;
	prtf("assigned!\n");
	unmap(0xa0000000);
	prtf("unmapped!\n");
	*ptr = 2;
	prtf("end!\n");
	return 0xdeadbeef;
}
Пример #26
0
int main(multiboot_t *mboot_ptr)
{
  monitor_clear();

  init_gdt ();
  init_idt ();
  init_timer (20);
  init_pmm (mboot_ptr->mem_upper);
  init_vmm ();
  init_heap ();

  // Find all the usable areas of memory and inform the physical memory manager about them.
  uint32_t i = mboot_ptr->mmap_addr;
  while (i < mboot_ptr->mmap_addr + mboot_ptr->mmap_length)
  {
    mmap_entry_t *me = (mmap_entry_t*) i;
    
    // Does this entry specify usable RAM?
    if (me->type == 1)
    {
      uint32_t j;
      // For every page in this entry, add to the free page stack.
      for (j = me->base_addr_low; j < me->base_addr_low+me->length_low; j += 0x1000)
      {
        pmm_free_page (j);
      }
    }

    // The multiboot specification is strange in this respect - the size member does not include "size" itself in its calculations,
    // so we must add sizeof (uint32_t).
    i += me->size + sizeof (uint32_t);
  }

  kernel_elf = elf_from_multiboot (mboot_ptr);

  asm volatile ("sti");

  void *a = kmalloc (8);
  void *b = kmalloc (8);
  void *c = kmalloc (8);
  kfree (a);
  kfree (b);
  void *d = kmalloc (24);

  printk ("a: %x, b: %x, c: %x, d: %x\n", a, b, c, d);

  panic ("Testing panic mechanism");
  for (;;);
  
  return 0xdeadbeef;
}
Пример #27
0
void
game_init(void) {
	init_serial();
	init_timer();
	init_idt();
	init_intr();
	set_timer_intr_handler(timer_event);
	set_keyboard_intr_handler(keyboard_event);

	printk("game start!\n");
	enable_interrupt();
	main_loop();
	assert(0); /* main_loop是死循环,永远无法返回这里 */
}
Пример #28
0
void main(){
	// unsigned char msg[] = "Boa noite from stack";
	init_idt();
	monitor_clear();
 	monitor_write("Hello, world!");
	// screen_print_str("testando letra verde");
	// screen_print_str(msg);

	asm volatile ("int $0x0");

 	// while(1); nao precisa mais.
 	// usei instrucao hlt no boot



}
Пример #29
0
void kernel_main()
{
    /* Initialize terminal interface */
    terminal_initialize();

    init_idt();
    init_pic();
    init_keyboard();
    /* Accept Intterupt now */
    asm volatile("sti");
    printf("VOID-OS Operating System 0.01\n\n");
    printf("void-os$ ");
    for(;;) {
            asm("hlt");
    }
}
Пример #30
0
int kern_entry()
{
    init_debug();
    init_gdt();
    init_idt();

    console_clear();
    printk_color(rc_black, rc_green, "Hello, OS kernel!\n");

    init_timer(200);

    // 开启中断
    asm volatile ("sti");

    return 0;
}