]> Zhao Yanbai Git Server - kernel.git/commitdiff
support 8253
authorAceVest <zhaoyanbai@126.com>
Wed, 7 May 2014 13:53:30 +0000 (21:53 +0800)
committerAceVest <zhaoyanbai@126.com>
Wed, 7 May 2014 13:53:30 +0000 (21:53 +0800)
include/errno.h
kernel/clock.c
kernel/fork.c
kernel/init.c
kernel/irq.c
kernel/syscall.c
setup/setup.c

index bacc95466d2c0cb132bff90020bce7f0b16685a6..93f3f0039a34f44b806a99179fa221ae18cc6920 100644 (file)
@@ -1,6 +1,4 @@
-/*
- *--------------------------------------------------------------------------
- *   File Name: errno.h
+/* *-------------------------------------------------------------------------- *   File Name: errno.h
  * 
  *      Author: Zhao Yanbai [zhaoyanbai@126.com]
  *              Mon Feb  1 17:07:06 2010
@@ -10,7 +8,7 @@
  *--------------------------------------------------------------------------
  */
 
-#ifndef    _ERRNO_H
+#ifndef _ERRNO_H
 #define _ERRNO_H
 
 #define EPERM         1    /* Operation not permitted */
index a7d3e96b7bd1b3994127753f6355ea986b288823..8bc7cd22deb2ac51f5faad3e9009959d03852876 100644 (file)
@@ -19,6 +19,7 @@ void    clk_handler(unsigned int irq, pt_regs_t * regs, void *dev_id)
 {
     jiffies++;
 
-    printk("^%d^ ", jiffies);
+    printk("^");
+    //printk("^%d^ ", jiffies);
     //printk("%s ", dev_id);
 }
index 06f72f4a6945fbace52fa425fef1e26bbdc3502b..d044361187f1b66b658de9680d9a64c5b9c80815 100644 (file)
@@ -24,7 +24,7 @@ int do_fork(pt_regs_t *regs, unsigned long flags)
 {
     task_union *tsk;
     tsk = alloc_task_union();
-    printk("another task %08x flags %08x\n", tsk, flags);
+    printk("fork task %08x flags %08x\n", tsk, flags);
     if(tsk == NULL)
         panic("can not malloc PCB");
 
@@ -82,7 +82,6 @@ int do_fork(pt_regs_t *regs, unsigned long flags)
 
     if(flags & FORK_KRNL)
     {
-        printk("--dsfsdafdsaf----\n");
         tsk->eip= (unsigned long) ret_from_fork_krnl;
     }
 
index 2a8c29423da4a2ae4b14495eeb23a5b14a18d295..a9dbbde749ac5a8fc9e5917015c9235ba7afcfee 100644 (file)
@@ -26,7 +26,7 @@ void init_task_entry()
     printk("hahahha %s\n", __func__);
     while(1)
     {
-        printk("i ");
+        printk("i");
         asm("sti;hlt;");
     }
 }
@@ -42,14 +42,12 @@ void root_task_entry()
     pt_regs_t regs;
     memset((void*)&regs, 0, sizeof(regs));
     regs.edx = (unsigned long) init_task_entry;
-    cli();
     int pid = do_fork(&regs, FORK_KRNL);
-    sti();
 
     printk("pid is %d\n", pid);
     while(1)
     {
-        printk("r ");
+        printk("r");
         asm("sti;hlt;");
         //sysc_test();
         //syscall0(SYSC_TEST);
index a37b205b3e4f0e3d40fdb702c8f60edfa70f1268..5ce8c42bd26f51a4a7c993b587a81eeca045fb8c 100644 (file)
 #include <errno.h>
 #include <assert.h>
 
-irq_desc_t    irq_desc[NR_IRQS];
+irq_desc_t irq_desc[NR_IRQS];
 
-int    enable_no_irq_chip(unsigned int irq){return 0;}
-int    disable_no_irq_chip(unsigned int irq){return 0;}
-irq_chip_t    no_irq_chip =
+int enable_no_irq_chip(unsigned int irq){return 0;}
+int disable_no_irq_chip(unsigned int irq){return 0;}
+
+irq_chip_t no_irq_chip =
 {
-    .name        = "none",
-    .enable        = enable_no_irq_chip,
-    .disable    = disable_no_irq_chip
+    .name   = "none",
+    .enable = enable_no_irq_chip,
+    .disable= disable_no_irq_chip
 };
-irq_desc_t    no_irq_desc =
+
+irq_desc_t no_irq_desc =
 {
-    .chip    = &no_irq_chip,
-    .action    = NULL,
-    .status    = 0,
-    .depth    = 0
+    .chip   = &no_irq_chip,
+    .action = NULL,
+    .status = 0,
+    .depth  = 0
 };
-__attribute__ ((regparm(1))) void    irq_handler(pt_regs_t * regs)
+
+__attribute__ ((regparm(1))) void irq_handler(pt_regs_t *regs)
 {
 
     unsigned int irq = regs->irq;
-    irq_desc_t *    p = irq_desc + irq;
-    irq_action_t *    action = p->action;
+    irq_desc_t *p = irq_desc + irq;
+    irq_action_t *action = p->action;
+
     p->chip->ack(irq);
+    sti();
     while(action)
     {
         //action->handler(regs, irq);
         action->handler(irq, regs, action->dev_id);
         action = action->next;
     }
+
     p->chip->enable(irq);
 }
 
index 85d4657f8b78a6d83ced1e8db219c984b66b7cd7..eb4be16a0dcdf2b544982608392cf343bafb3b20 100644 (file)
@@ -62,18 +62,19 @@ void    init_sysc_handler_table()
     }while(0);
 
     /* 有没有一种宏定义可以把大写直接转成小写? */
-    _sysc_(SYSC_WRITE,        sysc_write);
+    _sysc_(SYSC_WRITE,       sysc_write);
     _sysc_(SYSC_READ_KBD,    sysc_read_kbd);
-    _sysc_(SYSC_REBOOT,        sysc_reboot);
+    _sysc_(SYSC_REBOOT,      sysc_reboot);
     _sysc_(SYSC_FORK,        sysc_fork);
     _sysc_(SYSC_EXEC,        sysc_exec);
     _sysc_(SYSC_OPEN,        sysc_open);
     _sysc_(SYSC_READ,        sysc_read);
     _sysc_(SYSC_STAT,        sysc_stat);
     _sysc_(SYSC_EXIT,        sysc_exit);
-    _sysc_(SYSC_PAUSE,        sysc_pause);
+    _sysc_(SYSC_PAUSE,       sysc_pause);
     _sysc_(SYSC_TEST,        sysc_test);
 }
+
 int    sysc_bad_syscnr()
 {
     int sysc_nr;
index 6cfa18f50f79ed6f753302a519e242096ab9759c..fe42875a2a9dcd63eeff4d4c6573b15bd788c61e 100644 (file)
@@ -16,6 +16,7 @@
 #include <bits.h>
 #include <printk.h>
 #include <system.h>
+#include <io.h>
 
 extern void setup_gdt();
 extern void setup_idt();
@@ -31,11 +32,18 @@ extern void setup_hd();
 extern void setup_fs();
 extern void setup_ext2();
 
-extern unsigned long mb_mm_lower, mb_mm_upper;
-extern unsigned long mb_mmap_addr, mb_mmap_size;
-
 extern void reboot();
 
+#define HZ 100
+#define CLOCK_TICK_RATE 1193180
+#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ)
+
+void setup_i8253()
+{
+    outb_p(0x34, 0x43);
+    outb_p(LATCH & 0xFF, 0x40);
+    outb(LATCH >> 8, 0x40);
+}
 
 void setup_kernel()
 {
@@ -49,12 +57,14 @@ void setup_kernel()
     setup_idt();
     setup_gate();
 
+    setup_i8253();
+
     detect_cpu();
 
     set_tss();
 
     setup_sysc();
-    //setup_pci();
+    setup_pci();
 
     setup_irqs();