http://blog.chinaunix.net/uid/16979052.html
全部博文(286)
发布时间:2012-07-02 10:22:46
#include volatile uint32_t timer_ticks = 0;int timer_intr(int intr_no, void *arg, struct pt_regs *regs){ timer_ticks++; return 0;}static void settimer(int hz){ /*设置定时器多长时间发送一个中断给cpu*/ uint32_t divisor = 1193180/hz; /*二进制.........【阅读全文】
发布时间:2012-07-02 10:21:42
#include #include #include struct thread_t SECTION(".task0") ALIGN(PAGE_SIZE) task0; struct thread_t *current = &task0;static struct list_t *ptask_list = &(task0.link);volatile int switch_enable=0;void task_add(struct thread_t *tsk){ list_ins.........【阅读全文】
发布时间:2012-06-29 13:55:32
#include #define MALLOC_MAGIC 0x6D92 /* must be < 0x8000 */typedef struct _malloc{ size_t size; struct _malloc *next; unsigned magic : 15; unsigned used : 1;} malloc_t;static unsigned char *heap_bot,*heap_top;void *kmalloc(size_t size).........【阅读全文】
发布时间:2012-06-29 10:43:52
#include #include static tss_t ALIGN(PAGE_SIZE) tss;tss_t *tss_get(){ return &tss;}static void tss_update(addr_t kern_stack, uint32_t kern_seg){ tss.esp0 = kern_stack; tss.ss0 = kern_seg;}static void tss_init(){ KPRI.........【阅读全文】
发布时间:2012-06-29 10:42:14
#include #include #define IDT_NUM 256static idt_entry_t idt[IDT_NUM];static void idt_load(){ idt_ptr_t ptr; /* Setup IDT descriptor. */ ptr.limit = (IDT_NUM * sizeof(idt_entry_t)) - 1; ptr.base = (uint32_t) &idt; /* Load IDT. */ load_idt(.........【阅读全文】