📄 main.c
字号:
#include "hos.h"void start_kernel(void){ int a,i; float b=3.0; long esp; short ss; unsigned long buf[128]; char bint; unsigned long *pgdir_loc; init_screen(); printk("hos8:start kernel starts\n"); __asm__ ("lss swapper_stack_start, %%esp\n\t" "jmp L1\n\t" "swapper_stack_start:\n\t" ".long (init_task_union + 8192)\n\t" ".long 0x10\n\t" "L1:\n"::); printk("init_task_union is at:%x \n", init_task_union); __asm__ ("movl %%esp, %0\n\t" "movl %%ss, %1\n\t" :"=m"(esp),"=m"(ss):); printk("esp is %x and ss is %x\n", esp, ss); //init_screen(); tss_init(); // be ready for int //init_mm(); //make_init_task(); //current=init_task; init_interrupt(); bint=inbyte(0x21); printk("after init interr. blocked ints:%x\n",bint); //init_timer(); we want to activate timer at tha last moment bint=inbyte(0x21); printk("after init timer. blocked ints:%x\n",bint); init_kbd(); bint=inbyte(0x21); printk("after init kbd. blocked ints:%x\n",bint); // unmask all irqs // first read what ints are served //a=inbyte(0x21); //printk("21h is %x\n",a); //for(a=0;a<16;a++) unmask_irq(a); //a=inbyte(0x21); //printk("and now 21h is %x\n",a); init_floppy(); bint=inbyte(0x21); printk("after init floppy. blocked ints:%x\n",bint); // check currently serviced interrupts //outbyte(0x20, 0x9); //a=inbyte(0x20); //printk("int served at %x\n",a); //ReadSector(0,0,1, buf, buf); //ReadRelativeSector(3, buf, buf); //printk("original sect 3 is\n"); //for(a=0;a<8;a++) // printk("%x ", buf[a]); //ReadRelativeSector(0, buf, buf); //printk("sect 0 is\n"); //for(a=0;a<8;a++) // printk("%x ", buf[a]); //WriteRelativeSector(3, buf, buf); //ReadRelativeSector(3, buf, buf); //printk("now. after write. sect 3 is\n"); //for(a=0;a<8;a++) // printk("%x ", buf[a]); /* printk("Hello from hos8\n"); printk("systick = [%d]\n", systick); for(a = 0; a < 10000000; a++) ; printk("systick = [%d]\n", systick); */ //for(;;); init_mm(); make_init_task(); current=init_task; //make_init_task(); //current=init_task; //test_fs(); // test fs // enable paging printk("now enable paging\n"); wait_for_anykey(); pgdir_loc = init_task->mm.pgdir; __asm__ ("pushl %%eax\n\t" "movl %0, %%eax\n\t" "movl %%eax, %%cr3\n\t" "movl %%cr0, %%eax\n\t" "or $0x80000000, %%eax\n\t" "movl %%eax, %%cr0\n\t" "popl %%eax\n\t" ::"m"(pgdir_loc)); // force a jump to activate paging goto L1; L1:printk("paging enabled. are we still alive?\n"); wait_for_anykey(); printk("now init timer\n"); init_timer(); printk("aft init timer\n"); // init fs needs timer. init_fs(); // init fs //now test exec kernel_thread(init); //for(;;); // now move between p1 and p2 // below thread experiment will be recovered later //kernel_thread(p1_body); //kernel_thread(p2_body); for(;;){ schedule(); //printk("p0"); //for(i=0;i<10000000;i++) b=b+1.0; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -