/kernel/kernel.c

https://gitlab.com/bluehole/myos-32bit · C · 108 lines · 70 code · 8 blank · 30 comment · 4 complexity · 0f1bc6ef049714d271c5f315a8e70b8f MD5 · raw file

  1. /*
  2. |=========================================================|
  3. | This file is a part of TinyOS Copyright (C) 2008, 2012 |
  4. | ashok.s.das@gmail.com |
  5. | Adopted here for TinyOS |
  6. | ========================================================|
  7. | Our Kernel Proper |
  8. | Taken from : |
  9. | License: LGPL, GPL-V2 or latter |
  10. |=========================================================|
  11. */
  12. #include "low-io.h"
  13. #include "mboot.h"
  14. #include "vga.h"
  15. #include "gdt.h"
  16. #include "idt.h"
  17. #include "timer.h"
  18. #include "kbd.h"
  19. #include "kheap.h"
  20. #include "pci.h"
  21. #include "ide.h"
  22. #include "../driver/rtl/myrtl.h"
  23. unsigned int kend;
  24. extern unsigned start;
  25. unsigned int total_mem;
  26. int kmain(int magic,multibootInfo *mbootinfo)
  27. {
  28. init_VGA();
  29. SetBackColour(BRIGHTWHITE);
  30. SetTextColour(BRIGHTBLUE);
  31. clear();
  32. kprintf("\t****************Hello Tiny OS-32****************\n");
  33. kprintf("\t*****************Keep Patience******************\n");
  34. kprintf("\t================================================\n");
  35. if(magic != 0x2BADB002)
  36. {
  37. kprintf("BAD MULTIBOOT MAGIC!!! %010x Exiting",magic);
  38. while(1);
  39. }
  40. kend = mboot.kernel_end;
  41. show_memory_map(mbootinfo);
  42. total_mem = get_available_memory(mbootinfo);
  43. kprintf("Memory available = %08x\n",get_available_memory(mbootinfo) );
  44. show_elf_info(mbootinfo);
  45. kprintf("Starting Memory Manager(very basic: thanks Chris)\n");
  46. init_heap();
  47. SetBackColour(BLACK);
  48. SetBackColour(BLACK);
  49. SetTextColour(BRIGHTWHITE);
  50. show_memory_map(mbootinfo);
  51. kprintf("Setting up GDT\t");
  52. setup_GDT();
  53. kprintf("Done\n");
  54. kprintf("Setting up IDT\t");
  55. setup_IDT();
  56. kprintf("Done\n");
  57. kprintf("Setting up IRQs\t");
  58. irq_install();
  59. kprintf("Done\n");
  60. kprintf("\tInstalling Timer handler\t");
  61. install_timer();
  62. kprintf("Done\n");
  63. kprintf("\tInitializing Key-Board\t");
  64. install_kbd();
  65. kprintf("Done\n");
  66. // pci_bus scan, it will create a global pci_list which is a doubly linked list of pci devices found
  67. pci_scan();
  68. SetTextColour(BRIGHTWHITE);
  69. //init_floppy();
  70. kprintf("TODO:scheduler,threads OR processes, Shell,Few applications ,etc\n");
  71. enable();
  72. //clear();
  73. //init_tasks();
  74. init_ide();
  75. // this block may be used latter
  76. unsigned int *bd;
  77. bd = (unsigned int *)get_boot_dev(mbootinfo);
  78. kprintf("%0x %0x %0x %0x\n",(*bd & 0x000000ff),(*bd & 0x0000ff00)>>8,(*bd & 0x00ff0000)>>16,(*bd & 0xff000000)>>24 );
  79. unsigned char ba[5]="";
  80. strcat(ba,get_boot_dev(mbootinfo));
  81. kprintf("%0x %0x %0x %0x\n",ba[0]&0xff,ba[1]&0xff,ba[2]&0xff,ba[3]&0xff);
  82. //r_buf=(unsigned char*)kmalloc(512);
  83. //memset(r_buf,0,512);
  84. //for(i=0;i<128;i++)
  85. //kprintf("%2x ",r_buf[i]);
  86. //read_sector(0x1f0,1,&r_buf[0]);
  87. //for(i=0;i<128;i++)
  88. //kprintf("%2x ",r_buf[i]);
  89. //dump(r_buf,512);
  90. //do_page_fault= *ptr;
  91. // setVideoMode(12);
  92. // box(100,100,400,400);
  93. // init_windows();
  94. // errmsgbox("Test Error$","Hello World this is not enough$");
  95. // displaymessages(100,100,"Hello World$",4);
  96. detect_netdev();
  97. dump_irq_routines();
  98. while(1);
  99. halt();
  100. }