예제 #1
0
파일: kmain.c 프로젝트: deepai/OSLearning
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;
}
예제 #2
0
파일: main.c 프로젝트: kiljacken/EmilOS
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;
}
예제 #3
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;
}
예제 #4
0
파일: kernel.c 프로젝트: zzh8829/OSPP
void kernel_main(uint32_t mb_addr, uint32_t mb_magic)
{
	if(mb_magic != MULTIBOOT_BOOTLOADER_MAGIC)
	{
		kprintf(PANIC,"Wrong Bootloader Magic\n");
		for(;;);
	}

	multiboot_info_t* mb_info = (multiboot_info_t*)mb_addr;
	vbe_info_t* vbe_info = (vbe_info_t *)(mb_info->vbe_mode_info);

	uint32_t top = mb_info->mem_upper;
	uint32_t bot = mb_info->mem_lower;
	uint32_t mem = top+bot;

	clear_console();

	char version[20];
	get_version(version);
	kp("Welcome to ZOS v%s",version);

	kp("System Information");
	kp("	Booting Flag: 0x%x",mb_info->flags);
	if(check_flag(mb_info->flags,0))
		kp("	Available Memory: %d KB / %d MB",mem,mem/1024);
	if(check_flag(mb_info->flags,1))
		kp("	Booting Device: 0x%x",mb_info->boot_device);
	if(check_flag(mb_info->flags,2))
	{
		if(strlen((char*)mb_info->cmdline)>1)
			kp("	Booting Command: %s",(char*)mb_info->cmdline);
	}
	if(check_flag(mb_info->flags,3))
		{}
	if(check_flag(mb_info->flags,4))
		{}
	if(check_flag(mb_info->flags,5))
		kernel_elf = elf_from_multiboot(mb_info);
	if(check_flag(mb_info->flags,6))
	{
		/*
		multiboot_memory_map_t *mmap;
		kp ("mmap_addr = 0x%x, mmap_length = 0x%x",
			(unsigned) mb_info->mmap_addr, (unsigned) mb_info->mmap_length);
		for (mmap = (multiboot_memory_map_t *) mb_info->mmap_addr;
			(unsigned long) mmap < mb_info->mmap_addr + mb_info->mmap_length;
			mmap = (multiboot_memory_map_t *) ((unsigned long) mmap
			+ mmap->size + sizeof (mmap->size)))
		{
			kp (" size = 0x%x, base_addr = 0x%x%x,"
			" length = 0x%x%x, type = 0x%x",
			(unsigned) mmap->size,
			mmap->addr >> 32,
			mmap->addr & 0xffffffff,
			mmap->len >> 32,
			mmap->len & 0xffffffff,
			(unsigned) mmap->type);
		}
		*/		
	}
	gdt_init();		/* Global Descriptor Table */
	idt_init();		/* Interrupt Descriptor Table */
	isrs_init();	/* Interrupt Service Requests */
	irq_init();		/* Hardware Interrupt Requests */ 

	open_serial_output();

	timer_init();
	paging_init(mem);
	heap_init();
	
	keyboard_init();

	//pci_init();
	kp("login: "******"Welcome to ZOS\n",
		"Hello!\n",
		"abcdefghijklmnopqrstuvwxyz1234567890\n",
		0
	};
	for(int i=0;i!=3;i++)
	{
		for(int j = 0;j!=strlen(str[i]);j++)
		{
			gfx_print(str[i][j]);
		}
	}
	

	void render(window_t* win)
	{
	}

	void update(window_t* win)
	{
		surface_fill(win->surface,0,rgb(255,255,255));

		key_event_t* head;
		int len;
		keyboard_event_get(&head,&len);
		for(int i=0;i!=len;i++)
		{
			key_event_t* eve = head+i;
			if(eve->type == KEY_DOWN)
			{
				gfx_print(eve->character);
			}
		}
		keyboard_event_clear();
		
		rect_t trect = {0,0,720,20};
		for(int i=0;i!=24;i++)
		{
			if(strlen(gfx_con_buf[i]))
			{
				surface_t* surf = font_render(gfx_con_buf[i],col);
				surface_blend(surf,0,win->surface,&trect);
				surface_free(surf);
			}
			trect.y += 20;
		}
	}