From 978f17580f7de3380d4529b0aeabf88b9f6c1aa0 Mon Sep 17 00:00:00 2001 From: acevest Date: Fri, 27 Jun 2014 00:52:55 +0800 Subject: [PATCH] re use the right code --- drivers/ide.c | 18 +++++++----------- drivers/keyboard.c | 5 ++--- kernel/clock.c | 4 ++-- kernel/init.c | 4 ++-- kernel/interrupts.S | 2 +- kernel/sched.c | 6 +++--- kernel/wait.c | 1 - 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/drivers/ide.c b/drivers/ide.c index 0e1eb66..bcaf720 100644 --- a/drivers/ide.c +++ b/drivers/ide.c @@ -116,7 +116,7 @@ void ide_debug() ide_cmd_out(0, nsect, sect_nr, HD_CMD_READ_EXT); - //printk("ide_debug\n"); + printk("ide_debug\n"); } DECLARE_MUTEX(mutex); @@ -142,7 +142,7 @@ void ide_irq() { u8_t status = inb(REG_STATUS(0)); - //memset(buf, 0xEE, 1024); + memset(buf, 0xEE, 1024); status = inb(drv.iobase+PCI_IDE_STATUS); if(0 == (status & PCI_IDE_STATUS_INTR)) @@ -154,14 +154,11 @@ void ide_irq() outb(status, drv.iobase+PCI_IDE_STATUS); outb(0x00, drv.iobase+PCI_IDE_CMD); - //insl(REG_DATA(0), buf, (512>>2)); - int i; - unsigned short sig; - for(i=0; i<256; ++i) - sig = inw(REG_DATA(0)); - //u16_t *s = (u16_t *) (buf+510); - //printd(11, "hard disk data %04x\n", sig); - //up(&mutex); + insl(REG_DATA(0), buf, (512>>2)); + u16_t sig = *((u16_t *) (buf+510)); + printd(11, "hard disk data %04x", sig); + + up(&mutex); } @@ -225,7 +222,6 @@ void ide_read_identify() if(retires == 0) panic("hard disk is not ready"); - //char buf[1024]; insl(REG_DATA(0), buf, 512>>2); print_ide_identify(buf); } diff --git a/drivers/keyboard.c b/drivers/keyboard.c index 267e982..c263536 100644 --- a/drivers/keyboard.c +++ b/drivers/keyboard.c @@ -35,7 +35,7 @@ void kbd_handler(unsigned int irq, pt_regs_t * regs, void *dev_id) if(scan_code == 0x01) // Esc reboot(); - //printk("[%02x]", scan_code); + printk("[%02x]", scan_code); if(scan_code == 0x13) // r ide_debug(); @@ -56,7 +56,7 @@ void kbd_handler(unsigned int irq, pt_regs_t * regs, void *dev_id) if(scan_code == 0x3E) // F4 debug_wait_queue_put(2); -#if 0 +#if 1 printd(10, "CNSL HEAD : %d", cnsl_rd_q.head); if((cnsl_rd_q.head+1) == cnsl_rd_q.tail) goto end; @@ -64,7 +64,6 @@ void kbd_handler(unsigned int irq, pt_regs_t * regs, void *dev_id) cnsl_rd_q.data[cnsl_rd_q.head++] = (char) scan_code; end: - wake_up(&cnsl_rd_q.wait); #endif } diff --git a/kernel/clock.c b/kernel/clock.c index 2e30ba8..5dd66df 100644 --- a/kernel/clock.c +++ b/kernel/clock.c @@ -19,6 +19,6 @@ void clk_handler(unsigned int irq, pt_regs_t * regs, void *dev_id) { jiffies++; - //printk("^"); - //printd(0, "clock: %d", jiffies); + printk("^"); + printd(0, "clock: %d", jiffies); } diff --git a/kernel/init.c b/kernel/init.c index ac2739e..4309561 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -75,8 +75,8 @@ void root_task_entry() int cnt; while(1) { - printd(1, "root_task [%08x] cnt %d preempt_cnt %08x", current, cnt++, root_task.preempt_cnt); - printd(9, "pid %d ppid %08x state %08x weight %08x", + printd(1, "root_task [%08x] cnt %d preempt_cnt %d", current, cnt++, root_task.preempt_cnt); + printd(9, "pid %d ppid %d state %d weight %d", root_task.pid, root_task.ppid, root_task.state, root_task.weight); asm("sti;hlt;"); //sysc_test(); diff --git a/kernel/interrupts.S b/kernel/interrupts.S index df965d0..e459c7c 100644 --- a/kernel/interrupts.S +++ b/kernel/interrupts.S @@ -78,7 +78,7 @@ return: resched: - #call schedule + call schedule restore_regs: diff --git a/kernel/sched.c b/kernel/sched.c index 7fcebde..31cc824 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -58,9 +58,9 @@ void init_root_tsk() root_task.preempt_cnt = 0; root_task.pid = get_next_pid(); - root_task.ppid = 1000; - root_task.state = 2000;//TASK_RUNNING; - root_task.weight = 3000;//TASK_INIT_WEIGHT; + root_task.ppid = 0; + root_task.state = TASK_RUNNING; + root_task.weight = TASK_INIT_WEIGHT; INIT_LIST_HEAD(&root_task.list); for(i=0; i