-/*
- *--------------------------------------------------------------------------
- * File Name: errno.h
+/* *-------------------------------------------------------------------------- * File Name: errno.h
*
* Author: Zhao Yanbai [zhaoyanbai@126.com]
* Mon Feb 1 17:07:06 2010
*--------------------------------------------------------------------------
*/
-#ifndef _ERRNO_H
+#ifndef _ERRNO_H
#define _ERRNO_H
#define EPERM 1 /* Operation not permitted */
{
jiffies++;
- printk("^%d^ ", jiffies);
+ printk("^");
+ //printk("^%d^ ", jiffies);
//printk("%s ", dev_id);
}
{
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");
if(flags & FORK_KRNL)
{
- printk("--dsfsdafdsaf----\n");
tsk->eip= (unsigned long) ret_from_fork_krnl;
}
printk("hahahha %s\n", __func__);
while(1)
{
- printk("i ");
+ printk("i");
asm("sti;hlt;");
}
}
pt_regs_t regs;
memset((void*)®s, 0, sizeof(regs));
regs.edx = (unsigned long) init_task_entry;
- cli();
int pid = do_fork(®s, FORK_KRNL);
- sti();
printk("pid is %d\n", pid);
while(1)
{
- printk("r ");
+ printk("r");
asm("sti;hlt;");
//sysc_test();
//syscall0(SYSC_TEST);
#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);
}
}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;
#include <bits.h>
#include <printk.h>
#include <system.h>
+#include <io.h>
extern void setup_gdt();
extern void setup_idt();
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()
{
setup_idt();
setup_gate();
+ setup_i8253();
+
detect_cpu();
set_tss();
setup_sysc();
- //setup_pci();
+ setup_pci();
setup_irqs();