From 4d024aa9a43d2f5c243a3e2b31335e502b74638f Mon Sep 17 00:00:00 2001 From: AceVest Date: Fri, 1 Aug 2014 21:40:05 +0800 Subject: [PATCH] edit wording --- bin/shell.c | 5 +++++ boot/cmdline.c | 3 +-- drivers/ide.c | 6 +++--- drivers/keyboard.c | 2 +- include/printk.h | 2 +- include/task.h | 3 ++- kernel/clock.c | 2 +- kernel/init.c | 4 ++-- kernel/irq.c | 4 ++-- kernel/pci.c | 4 +--- kernel/sched.c | 18 +++++++++++++++++- kernel/setup.c | 2 ++ kernel/syscall.c | 4 ++-- mm/mm.c | 2 +- 14 files changed, 41 insertions(+), 20 deletions(-) diff --git a/bin/shell.c b/bin/shell.c index 2a05453..cd4d509 100644 --- a/bin/shell.c +++ b/bin/shell.c @@ -13,11 +13,16 @@ #include #include +void systest(); +void sysdebug(unsigned int v); int main() { while(1) { + systest(); + sysdebug(0xAABBCCDD); + printf("shell# "); char cmd[256]; read(0, cmd, 256); diff --git a/boot/cmdline.c b/boot/cmdline.c index 4dab581..d75b14e 100644 --- a/boot/cmdline.c +++ b/boot/cmdline.c @@ -39,10 +39,9 @@ void parse_cmdline(const char *cmdline) printk("cmdline: %s\n", system.cmdline); get_value("root", value); - printk("root device %s\n", value); assert(value[0]=='h' && value[1]=='d' && value[2] == 'a'); system.root_dev = MAKE_DEV(DEV_MAJOR_HDA, atoi(value+3)); - printk("root device %08x\n", system.root_dev); + printk("root device %s [0x%08x]\n", value, system.root_dev); get_value("delay", value); system.delay = atoi(value); diff --git a/drivers/ide.c b/drivers/ide.c index bd21d89..f7a81a8 100644 --- a/drivers/ide.c +++ b/drivers/ide.c @@ -75,7 +75,7 @@ unsigned int HD_CHL1_CTL_BASE = 0x376; void ide_printl() { - printl(MPL_IDE, "ide pio_cnt %d dma_cnt %d irq_cnt %d", drv.pio_cnt, drv.dma_cnt, drv.irq_cnt); + printl(MPL_IDE, "ide pio cnt %d dma cnt %d irq cnt %d", drv.pio_cnt, drv.dma_cnt, drv.irq_cnt); } void ide_cmd_out(dev_t dev, u32 sect_cnt, u64 sect_nr, u32 cmd) @@ -190,7 +190,7 @@ void ide_pci_init(pci_device_t *pci) HD_CHL1_CTL_BASE = pci->bars[3] ? pci->bars[3] : HD_CHL1_CTL_BASE; printk("channel0: cmd %04x ctl %04x channel1: cmd %04x ctl %04x\n", HD_CHL0_CMD_BASE, HD_CHL0_CTL_BASE, HD_CHL1_CMD_BASE, HD_CHL1_CTL_BASE); - printl(18, "channel0: cmd %04x ctl %04x channel1: cmd %04x ctl %04x", HD_CHL0_CMD_BASE, HD_CHL0_CTL_BASE, HD_CHL1_CMD_BASE, HD_CHL1_CTL_BASE); + //printl(18, "channel0: cmd %04x ctl %04x channel1: cmd %04x ctl %04x", HD_CHL0_CMD_BASE, HD_CHL0_CTL_BASE, HD_CHL1_CMD_BASE, HD_CHL1_CTL_BASE); } @@ -223,7 +223,7 @@ void init_pci_controller(unsigned int classcode) if(pci != 0 && pci->intr_line < 16) { printk("found pci vendor %04x device %04x class %04x intr %d\n", pci->vendor, pci->device, pci->classcode, pci->intr_line); - printl(17, "found pci vendor %04x device %04x class %04x intr %d", pci->vendor, pci->device, pci->classcode, pci->intr_line); + //printl(17, "found pci vendor %04x device %04x class %04x intr %d", pci->vendor, pci->device, pci->classcode, pci->intr_line); ide_pci_init(pci); drv.pci = pci; } diff --git a/drivers/keyboard.c b/drivers/keyboard.c index 3d790f9..aa70b45 100644 --- a/drivers/keyboard.c +++ b/drivers/keyboard.c @@ -72,7 +72,7 @@ void kbd_handler(unsigned int irq, pt_regs_t * regs, void *dev_id) void kbd_debug(unsigned char scan_code) { static unsigned long kbd_cnt = 0; - printl(MPL_KEYBOARD, "keyboard:%d scan code %02x", kbd_cnt++, scan_code); + printl(MPL_KEYBOARD, "keyboard irq: %d scan code %02x", kbd_cnt++, scan_code); if(scan_code == 0x01) // Esc reboot(); diff --git a/include/printk.h b/include/printk.h index ecaf06b..07717c0 100644 --- a/include/printk.h +++ b/include/printk.h @@ -21,7 +21,7 @@ int printk(const char *fmtstr, ...); int printd(const char *fmtstr, ...); int printlo(unsigned int line, unsigned int offset, const char *fmtstr, ...); -#define printl(line, fmt, args...) printlo(line, 0, fmt, ## args) +#define printl(line, fmt, args...) printlo(line, 1, fmt, ## args) #define printll(line, fmt, args...) printlo(line, 0, fmt, ## args) #define printlr(line, fmt, args...) printlo(line, 40, fmt, ## args) diff --git a/include/task.h b/include/task.h index 5fe509f..8cfa109 100644 --- a/include/task.h +++ b/include/task.h @@ -30,7 +30,8 @@ enum TASK_UNUSED, TASK_RUNNING, TASK_WAIT, - TASK_EXITING + TASK_EXITING, + TASK_END, }; #define TASK_NAME_SIZE 32 diff --git a/kernel/clock.c b/kernel/clock.c index 3c565d3..100762a 100644 --- a/kernel/clock.c +++ b/kernel/clock.c @@ -25,5 +25,5 @@ void clk_handler(unsigned int irq, pt_regs_t * regs, void *dev_id) jiffies++; //printd("^"); - printl(MPL_CLOCK, "clock irq:%d", jiffies); + printl(MPL_CLOCK, "clock irq: %d", jiffies); } diff --git a/kernel/init.c b/kernel/init.c index 5c8156e..e4ed24d 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -72,8 +72,8 @@ void root_task_entry() { sysc_test(); //printl(MPL_ROOT, "root:0 [%08x] weight %d cnt %d", current, root_task.weight, cnt++); - //asm("sti;hlt;"); - //sysc_test(); + asm("sti;hlt;"); + sysc_test(); //syscall0(SYSC_TEST); } } diff --git a/kernel/irq.c b/kernel/irq.c index fdf72dd..ed48e87 100644 --- a/kernel/irq.c +++ b/kernel/irq.c @@ -58,7 +58,7 @@ __attribute__ ((regparm(1))) void irq_handler(pt_regs_t *regs) unsigned long esp; asm("movl %%esp, %%eax":"=a"(esp)); - printl(MPL_PREEMPT, "current %08x cr3 %08x preempt %d esp %08x", current, current->cr3, current->preempt_cnt, esp); + printl(MPL_PREEMPT, "current %08x cr3 %08x preempt %d esp %08x", current, current->cr3, current->preempt_cnt, esp); p->chip->ack(irq); sti(); @@ -79,7 +79,7 @@ int request_irq(unsigned int irq, const char *devname, void *dev_id) { - irq_action_t * p; + irq_action_t *p; if(irq >= NR_IRQS) return -EINVAL; diff --git a/kernel/pci.c b/kernel/pci.c index 81113c4..9e5a47a 100644 --- a/kernel/pci.c +++ b/kernel/pci.c @@ -67,8 +67,6 @@ void scan_pci_bus(int bus) int i; printk("scanning pci bus %d\n", bus); - system_delay(); - for(dev=0; dev<32; dev++) { for(devfn =0; devfn<8; devfn++) @@ -169,7 +167,7 @@ void dump_pci_dev() list_for_each(p, &pci_devs) { pci_device_t *pci = list_entry(p, pci_device_t, list); - printk("vendor %04x device %04x class %04x intr %02d ", pci->vendor, pci->device, pci->classcode, pci->intr_line); + printk("vendor %04x device %04x class %04x intr %3d ", pci->vendor, pci->device, pci->classcode, pci->intr_line); printk("%s\n", pci_get_info(pci->classcode, pci->progif)); continue; switch(pci->hdr_type) diff --git a/kernel/sched.c b/kernel/sched.c index 7e7cd41..fa337f1 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -142,6 +142,21 @@ task_union *find_task(pid_t pid) return p; } +static const char *task_state(unsigned int state) +{ + static const char s[][16] = { + " ERROR", + "RUNNING", + " WAIT", + "EXITING", + }; + + if(state >= TASK_END) + state = TASK_UNUSED; + + return s[state]; +} + unsigned long schedule() { static turn = 0; @@ -151,11 +166,12 @@ unsigned long schedule() unsigned long iflags; irq_save(iflags); + printl(MPL_ROOT, "root:%d [%08x] cnt %u", root_task.pid, &root_task, root_task.cnt); list_for_each_safe(pos, t, &root_task.list) { p = list_entry(pos, task_union, list); - printl(MPL_ROOT+p->pid, "task:%d [%08x] state %02x TURN %d turn %d cnt %u", p->pid, p, p->state, turn, p->weight, p->cnt); + printl(MPL_ROOT+p->pid, "task:%d [%08x] state %s cnt %u", p->pid, p, task_state(p->state), p->cnt); if(p->state != TASK_RUNNING) { diff --git a/kernel/setup.c b/kernel/setup.c index d7bbf11..90c4818 100644 --- a/kernel/setup.c +++ b/kernel/setup.c @@ -82,6 +82,8 @@ void setup_kernel() printl(MPL_TITLE, " SYSTEM MONITOR"); printl(MPL_ROOTDEV, "root device %08x", system.root_dev); + system_delay(); + setup_tasks(); setup_irqs(); diff --git a/kernel/syscall.c b/kernel/syscall.c index a932720..06b620c 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -52,8 +52,8 @@ int sysc_test() { static unsigned int cnt=0; current->cnt++; - printl(MPL_TEST, "sysc_test cnt %u current %08x cnt %u", - cnt++, current, current->cnt); + printl(MPL_TEST, "systest cnt %u current %08x cnt %u ", + cnt++, current, cnt); return 0; } diff --git a/mm/mm.c b/mm/mm.c index 26e6d56..0433691 100644 --- a/mm/mm.c +++ b/mm/mm.c @@ -61,7 +61,7 @@ void e820_print_map() { struct e820_entry *p = boot_params.e820map.map + i; - printk("[%02d] 0x%08x - 0x%08x size %- 10d %8dKB %5dMB ", i, p->addr, p->addr + p->size - 1, p->size, p->size>>10, p->size>>20); + printk(" [%02d] 0x%08x - 0x%08x size %- 10d %8dKB %5dMB ", i, p->addr, p->addr + p->size - 1, p->size, p->size>>10, p->size>>20); e820_print_type(p->type); -- 2.44.0