2010年11月11日 星期四

OS case stusy

1.mm(virtual memory -> physical memory) GDT ( Global Descriptor Table )
  • 0 NULL
  • 1 kernel code
  • 2 kernel data
  • 3 user space code
  • 4 user space data
entry point
  • base -> entry address
  • limit -> entry size
ex: gdt_set_gate(0, 0, 0, 0, 0); // Null segment gdt_set_gate(1, 0, 0xFFFFFFFF, 0x9A, 0xCF); // Code segment gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF); // Data segment gdt_set_gate(3, 0, 0xFFFFFFFF, 0xFA, 0xCF); // User mode code segment gdt_set_gate(4, 0, 0xFFFFFFFF, 0xF2, 0xCF); // User mode data segment IDT(interrupt description table) Faults, traps and exceptions ex:
  • 0 - Division by zero exception
  • 1 - Debug exception
  • 2 - Non maskable interrupt
  • 3 - Breakpoint exception
TSS(task state segment) @ system_call store each tasks info to kernel schedule , such as eax,ebx,esp... ex: // A struct describing a Task State Segment. struct tss_entry_struct { u32int prev_tss; // The previous TSS - if we used hardware task switching this would form a linked list. u32int esp0; // The stack pointer to load when we change to kernel mode. u32int ss0; // The stack segment to load when we change to kernel mode. u32int esp1; // Unused... .... } paging @ virtual memory call block -> used hole -> unused level directory -> tables(1024) -> entries(1024) frame @ physical memory call 2.VFS and the initrd VFS (virtual file system) define the file loc, uid, and i_node link list ex : /usr/bin/ -> ./ls /dev/tty/ initrd (initial ramdisk) boot image loc floop, disc, usb, ... linux 0.0.1 http://kerneltrap.org/Linux/Dusting_Off_the_0.01_Kernel http://www.cppblog.com/jake1036/archive/2010/11/13/133530.aspx http://mapopa.blogspot.com/2010/07/error-bad-register-name-sil.html http://manpages.ubuntu.com/manpages/gutsy/man1/as86.1.html http://www.cppblog.com/jake1036/archive/2010/11/13/133530.aspx JAME'S micro kernel http://www.jamesmolloy.co.uk/tutorial_html/4.-The%20GDT%20and%20IDT.html http://www.osdever.net/tutorials/index http://en.wikipedia.org/wiki/Task_State_Segment http://www.faqs.org/docs/Linux-HOWTO/KernelAnalysis-HOWTO.html#ss5.4 x86 instruction set http://siyobik.info/index.php?module=x86 nasm http://www.nasm.us/doc/nasmdoc0.html

沒有留言:

張貼留言