]> Zhao Yanbai Git Server - kernel.git/commitdiff
add printd
authoracevest <root@ace.laptop>
Mon, 23 Jun 2014 15:18:28 +0000 (23:18 +0800)
committeracevest <root@ace.laptop>
Mon, 23 Jun 2014 15:18:28 +0000 (23:18 +0800)
drivers/keyboard.c
drivers/vga.c
include/printk.h
kernel/clock.c
kernel/init.c
kernel/printk.c
kernel/syscall.S

index 2c0f9f836236ce5e42a23e4a13a026a3d083cfb5..f3cf6a9bc2638bd49831abfeaca02b210340e757 100644 (file)
@@ -25,6 +25,7 @@ void poweroff();
 void ide_debug();
 void ide_status();
 void debug_sched();
+void vga_toggle();
 
 void kbd_handler(unsigned int irq, pt_regs_t * regs, void *dev_id)
 {
@@ -34,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();
@@ -45,6 +46,9 @@ void kbd_handler(unsigned int irq, pt_regs_t * regs, void *dev_id)
     if(scan_code == 0x14)   // t
         debug_sched();
 
+    if(scan_code == 0x3B)   // F1
+        vga_toggle();
+
     if((cnsl_rd_q.head+1) == cnsl_rd_q.tail)
         goto end;
 
index 8046161880992656cde602435afa51da2e512734..882435dc981f0b549eb35fc07d3e11ffb19778b8 100644 (file)
@@ -142,3 +142,35 @@ void vga_puts(const char *buf, unsigned char color)
         p++;
     }
 }
+
+
+#define VIDEO_DBG_LINE 30
+
+void vga_toggle()
+{
+    static bool dbg = true;
+    unsigned long addr = 0;
+    if(dbg)
+    {
+        addr += VIDEO_DBG_LINE*CHARS_PER_LINE;
+    }
+
+    dbg = !dbg;
+    
+    outb(VGA_CRTC_START_ADDR_H,VGA_CRTC_ADDR);
+    outb((addr>>8)&0xFF,VGA_CRTC_DATA);
+    outb(VGA_CRTC_START_ADDR_L,VGA_CRTC_ADDR);
+    outb((addr)&0xFF,   VGA_CRTC_DATA);
+}
+
+void vga_dbg_puts(unsigned int line, const char *buf, unsigned char color)
+{
+    int i;
+    char *p = (char *) buf;
+    vga_char_t * const pv = (vga_char_t * const) (VIDEO_ADDR + (VIDEO_DBG_LINE + line) * BYTES_PER_LINE);
+
+    for(i=0; *p; ++i, ++p)
+    {
+        pv[i] = vga_char(*p, color);
+    }
+}
index 48a707bfa5bec3eb55c002afb2afa8e590687e92..3f5d314c60b5251ad6c6e75dc0763a4d358b68d8 100644 (file)
@@ -16,4 +16,5 @@
 
 #pragma once
 
-int    printk(char *fmtstr, ...);
+int printk(char *fmtstr, ...);
+int printd(unsigned int line, const char *fmtstr, ...);
index 8bc7cd22deb2ac51f5faad3e9009959d03852876..5dd66df3518c5f5195de12f11636c899b367fdad 100644 (file)
@@ -20,6 +20,5 @@ void    clk_handler(unsigned int irq, pt_regs_t * regs, void *dev_id)
     jiffies++;
 
     printk("^");
-    //printk("^%d^ ", jiffies);
-    //printk("%s ", dev_id);
+    printd(0, "clock: %d", jiffies);
 }
index 7711f45767aa3013ccaf882da3ec2ec71803fbfe..20a4317c7be8532921fe74855e91eec3328adf4a 100644 (file)
@@ -21,7 +21,7 @@ Desc    gdt[NGDT];
 
 char __initdata kernel_init_stack[KRNL_INIT_STACK_SIZE] __attribute__ ((__aligned__(PAGE_SIZE)));
 
-static unsigned int eid = 1;
+static unsigned int eid = 2;
 void debug_sem();
 void init_task_entry()
 {
@@ -31,14 +31,15 @@ void init_task_entry()
     while(1)
     {
         i++;
+
         if(i == id*100)
         {
             printk("---READ---%d\n", id);
             debug_sem();
             printk("---END----%d\n", id);
         }
-        printk("%d", id);
-        asm("sti;hlt;");
+        printd(id, "task:%d cnt:%d", id, i);
+        //asm("sti;");
     }
 }
 
@@ -68,9 +69,10 @@ void root_task_entry()
     }
 
 
+    int cnt;
     while(1)
     {
-        printk("r");
+        printd(1, "root_task cnt %d", cnt++);
         asm("sti;hlt;");
         //sysc_test();
         //syscall0(SYSC_TEST);
index a32b5f4258dfb9e665524e2c40a2b9b1b437cec6..b53a5c1dfb4b13a1118e5518b9fd299b73b5388a 100644 (file)
  *--------------------------------------------------------------------------
  */
 
-char pkbuf[1024];
-extern void     vga_puts(const char *buf, unsigned char color);
+extern void vga_puts(const char *buf, unsigned char color);
+extern void vga_dbg_puts(unsigned long line, const char *buf, unsigned char color);
+
 int printk(const char *fmtstr, ...)
 {
+    char pkbuf[1024];
     char *args = (char*)(((char*)&fmtstr)+4);
     vsprintf(pkbuf, fmtstr, args);
     vga_puts(pkbuf,0x2);
     return 0;
 }
+
+int printd(unsigned int line, const char *fmtstr, ...)
+{
+    char pkbuf[1024];
+    char *args = (char*)(((char*)&fmtstr)+4);
+    vsprintf(pkbuf, fmtstr, args);
+    vga_dbg_puts(line, pkbuf,0x2);
+    return 0;
+}
index 6dbce73a981b9a8e6974b93effec31a957a1376a..0124d36cabb529e5bf93a908bc521ce298e9e38a 100644 (file)
@@ -76,6 +76,7 @@ ret_from_fork_user:
 
 ret_from_fork_krnl:
     movl    PT_REGS_EDX(%esp), %edx
+    sti
     call    *%edx
     #call    do_exit