Esempio n. 1
0
int main(struct multiboot *mboot_ptr)
{
	// All our initialisation calls will go in here.
	init_descriptor_tables();
	monitor_clear();
	initialise_paging();
//	init_timer(3);

	int res = 0;

	monitor_clear();
	monitor_write(str);
	monitor_write("\n\r");
	monitor_write_hex(0xbadacacd);
	monitor_write_hex(0xbada0000);
	monitor_write("\n\r");
	monitor_write_dec(0xadacacd);
	monitor_write("\n\r");
	monitor_write_dec(1234567890);

	//memcpy(0xb8000+80*2*5,0xb8000,80*2*5);
	//memset(0xb8000,76,80*2*5);

	asm volatile ("int $0x3");

	//u32int *ptr = (u32int*)0x0ffffff;
	//u32int do_page_fault = *ptr;
	

	return 0;
}
Esempio n. 2
0
void isr_handler(registers_t regs)
{
    monitor_write_dec(z);
    monitor_put('-');
    monitor_write("recieved interrupt: ");
    monitor_write_dec(regs.int_no);
    monitor_write(", add: ");
    monitor_write_hex(regs.cs);
    monitor_put(':');
    monitor_write_hex(regs.eip);
    monitor_put('\n');
    ++z;
}
Esempio n. 3
0
File: main.c Progetto: Nov11/jamesos
//写个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;
}
Esempio n. 4
0
// This gets called from our ASM interrupt handler stub.
void irq_handler(registers_t regs)
{
   // Send an EOI (end of interrupt) signal to the PICs.
   // If this interrupt involved the slave.
   if (regs.int_no >= 40)
   {
       // Send reset signal to slave.
       outb(0xA0, 0x20);
   }
   // Send reset signal to master. (As well as slave, if necessary).
   outb(0x20, 0x20);

   if (interrupt_handlers[regs.int_no] != 0)
   {
       isr_t handler = interrupt_handlers[regs.int_no];
       handler(regs);
   }
	else
	{
		// Unhandled IRQ, log it !
		monitor_set_forecolor(e_color_magenta);
		monitor_write("IRQ");
		monitor_write_hex(regs.int_no);
		monitor_write(" raised!\n");
		monitor_set_forecolor(e_color_white);
	}
}
Esempio n. 5
0
void isr_handler(registers_t regs)
{
    monitor_write("received interrupt: ");
    monitor_write_hex(regs.int_no);
    monitor_put('\n');

    if (interrupt_handlers[regs.int_no] != 0) {
        isr_t handler = interrupt_handlers[regs.int_no];
        handler(regs);
    }

    if (regs.int_no == 13) {
        monitor_write("gp error : ");
        monitor_write_hex(regs.err_code);
        monitor_write("\n");
    }
}
Esempio n. 6
0
int main(struct multiboot *mboot_ptr)
{
  // All our initialisation calls will go in here.
  monitor_clear();
  monitor_write("Hello world!\n");
  monitor_write_hex(12345678);
  monitor_write("\n");
  monitor_write_dec(12345678);
  monitor_write("\n");
  return 0xDEADBABA;
}
Esempio n. 7
0
// Tests a forking iteration.
void fork_disp() {

  // Create a new process in a new address space which is a clone of this.
  int ret = fork();

  printf("fork() returned ");
  monitor_write_hex(ret);
  printf(", and getpid() returned ");
  monitor_write_hex(getpid());
  printf("\n============================================================================\n");

  if (ret == 0) {
      // You are the child
      printf("Now writing to the kernel as the Child.\n");
  }
  else {
      // You are parent
      printf("Now writing to the kernel as the Parent.\n");
  }
  
}
Esempio n. 8
0
void prtf(const char* format, ...)
{
	const char** arg = &format;//存format的地址
	int c;

	//arg是format这个参数的下一个参数的地址,也就是字符串后第一个参数的地址
	arg++;
	while((c = *format++) != 0){
		if(c == '\\'){
			c = *format++;
			switch(c){
				case 'n':
					monitor_put('\n');
					break;
				case 't':
					monitor_put('\t');
					break;
			}
		}else if(c == '%'){
			c = *format++;
			switch(c){
				case 'u':
					monitor_write_dec(*(u32int*)arg);
					break;
				case 'x':
					monitor_write_hex(*(u32int*)arg);
					break;
				case 's':
					monitor_write(*arg);
					break;
				case 'p':
					monitor_write_hex(*(u32int*)arg);
					break;
			}
			arg++;
		}else{
			monitor_put(c);
		}
	}
}
Esempio n. 9
0
int main(struct multiboot *mboot_ptr)
{
  // All our initialisation calls will go in here.
  
  //init descriptor tables
  init_descriptor_tables();
  //Testing screen instructions
  monitor_clear();
  monitor_write("Hello World");
  u32int n = 0xDEADBABA;

  monitor_write("\n");
  monitor_write_hex(n);
  
  monitor_write("\n");
  n = 1234567890;
  
  monitor_write_dec(n);

  asm volatile ("int $0x1");
  //asm volatile ("int $0x4");

  return 0xDEADBABA;
}
Esempio n. 10
0
int main(struct multiboot *mboot_ptr, u32int initial_stack)
{
    initial_esp = initial_stack;
    // Initialise all the ISRs and segmentation
    init_descriptor_tables();
    // Initialise the screen (by clearing it)
    monitor_clear();
    // Initialise the PIT to 100Hz
    asm volatile("sti");
    init_timer(50);

    // Find the location of our initial ramdisk.
    ASSERT(mboot_ptr->mods_count > 0);
    u32int initrd_location = *((u32int*)mboot_ptr->mods_addr);
    u32int initrd_end = *(u32int*)(mboot_ptr->mods_addr+4);
    // Don't trample our module with placement accesses, please!
    placement_address = initrd_end;

    // Start paging.
    initialise_paging();

    // Start multitasking.
    initialise_tasking();

    // Initialise the initial ramdisk, and set it as the filesystem root.
    fs_root = initialise_initrd(initrd_location);

    // Create a new process in a new address space which is a clone of this.
    int ret = fork();

    monitor_write("fork() returned ");
    monitor_write_hex(ret);
    monitor_write(", and getpid() returned ");
    monitor_write_hex(getpid());
    monitor_write("\n============================================================================\n");

    // The next section of code is not reentrant so make sure we aren't interrupted during.
    asm volatile("cli");
    // list the contents of /
    int i = 0;
    struct dirent *node = 0;
    while ( (node = readdir_fs(fs_root, i)) != 0)
    {
        monitor_write("Found file ");
        monitor_write(node->name);
        fs_node_t *fsnode = finddir_fs(fs_root, node->name);

        if ((fsnode->flags&0x7) == FS_DIRECTORY)
        {
            monitor_write("\n\t(directory)\n");
        }
        else
        {
            monitor_write("\n\t contents: \"");
            char buf[256];
            u32int sz = read_fs(fsnode, 0, 256, buf);
            int j;
            for (j = 0; j < sz; j++)
                monitor_put(buf[j]);
            
            monitor_write("\"\n");
        }
        i++;
    }
    monitor_write("\n");

    asm volatile("sti");

    return 0;
}