#include <types.h>
-#define outb_p(value,port)({ \
-__asm__("outb %%al,%%dx;nop;nop;nop;nop" \
-: \
-:"a" (value),"d" (port)); \
+#define outb_p(value,port)({ \
+__asm__("outb %%al,%%dx;nop;nop;nop;nop" \
+: \
+:"a" (value),"d" (port)); \
})
-#define inb_p(port)({ \
-u8 _bt; \
-__asm__("inb %%dx,%%al;nop;nop;nop;nop" \
-:"=a" (_bt) \
-:"d" (port)); \
-_bt; \
+#define inb_p(port)({ \
+u8 _bt; \
+__asm__("inb %%dx,%%al;nop;nop;nop;nop" \
+:"=a" (_bt) \
+:"d" (port)); \
+_bt; \
})
-#define outb(value,port)({ \
-__asm__("outb %%al,%%dx" \
-: \
-:"a" (value),"d" (port)); \
+#define outb(value,port)({ \
+__asm__("outb %%al,%%dx" \
+: \
+:"a" (value),"d" (port)); \
})
-#define outw(value,port)({ \
-__asm__("outw %%ax,%%dx" \
-: \
-:"a" (value),"d" (port)); \
+#define outw(value,port)({ \
+__asm__("outw %%ax,%%dx" \
+: \
+:"a" (value),"d" (port)); \
})
-#define outl(value,port)({ \
-__asm__("outl %%eax,%%dx" \
-: \
-:"a" (value),"d" (port)); \
+#define outl(value,port)({ \
+__asm__("outl %%eax,%%dx" \
+: \
+:"a" (value),"d" (port)); \
})
-#define inb(port)({ \
+#define inb(port)({ \
u8 _bt; \
-asm("inb %%dx,%%al" \
-:"=a" (_bt) \
-:"d" (port)); \
-_bt; \
+asm("inb %%dx,%%al" \
+:"=a" (_bt) \
+:"d" (port)); \
+_bt; \
})
-#define inw(port)({ \
-u16 _bt; \
-asm("inw %%dx,%%ax" \
-:"=a" (_bt) \
-:"d" (port)); \
-_bt; \
+#define inw(port)({ \
+u16 _bt; \
+asm("inw %%dx,%%ax" \
+:"=a" (_bt) \
+:"d" (port)); \
+_bt; \
})
-#define inl(port)({ \
-u16 _bt; \
-asm("inl %%dx,%%eax" \
-:"=a" (_bt) \
-:"d" (port)); \
-_bt; \
+#define inl(port)({ \
+u16 _bt; \
+asm("inl %%dx,%%eax" \
+:"=a" (_bt) \
+:"d" (port)); \
+_bt; \
})
-#define BUILDIO(bwl, type) \
-static inline void ins##bwl(int port, void *buf, unsigned long count) \
-{ \
- asm volatile( "cld;rep;ins" #bwl \
- : "+c"(count), "+D"(buf) : "d"(port)); \
+#define BUILDIO(bwl, type) \
+static inline void ins##bwl(int port, void *buf, unsigned long count) \
+{ \
+ asm volatile( "cld;rep;ins" #bwl \
+ : "+c"(count), "+D"(buf) : "d"(port)); \
}
*--------------------------------------------------------------------------
*/
-#ifndef _IRQ_H
+#ifndef _IRQ_H
#define _IRQ_H
#include "system.h"
-#define NR_IRQS 224
#define FIRST_IRQ_VECT 0x20
+#define NR_IRQS (0xFF-FIRST_IRQ_VECT)
-typedef struct
+typedef struct irq_chip
{
const char *name;
int (*enable)(unsigned int irq);
int (*disable)(unsigned int irq);
void (*ack)(unsigned int irq);
-} IrqChip, *pIrqChip;
+} irq_chip_t;
typedef struct irqaction
{
const char *dev_name;
void *dev_id;
struct irqaction *next;
-} IrqAction, *pIrqAction;
+} irq_action_t;
-typedef struct
+typedef struct irq_desc
{
- pIrqChip chip;
- pIrqAction action;
+ irq_chip_t * chip;
+ irq_action_t * action;
unsigned int status;
unsigned int depth;
-} IrqDesc, *pIrqDesc;
+} irq_desc_t;
-extern IrqChip i8259_chip;
-extern IrqDesc irq_desc[];
-extern IrqDesc no_irq_desc;
+extern irq_chip_t i8259_chip;
+extern irq_desc_t irq_desc[];
+extern irq_desc_t no_irq_desc;
int request_irq(unsigned int irq,
//void (*handler)(pPtRegs, unsigned int),
void (*handler)(unsigned int, pPtRegs, void *),
#include <printk.h>
#include <system.h>
-//void clk_handler(pPtRegs regs, unsigned int irq)
+
+static unsigned int jiffies = 0;
+
void clk_handler(unsigned int irq, pPtRegs regs, void *dev_id)
{
- //printk("^");
+ jiffies++;
+
+ printk("^%d^ ", jiffies);
//printk("%s ", dev_id);
}
#include "i8259.h"
#include "irq.h"
-IrqChip i8259_chip =
+irq_chip_t i8259_chip =
{
.name = "XT-PIC",
.enable = enable_i8259_irq,
#include <errno.h>
#include <assert.h>
-IrqDesc 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;}
-IrqChip no_irq_chip =
+irq_chip_t no_irq_chip =
{
.name = "none",
.enable = enable_no_irq_chip,
.disable = disable_no_irq_chip
};
-IrqDesc no_irq_desc =
+irq_desc_t no_irq_desc =
{
.chip = &no_irq_chip,
.action = NULL,
{
unsigned int irq = regs->irq;
- pIrqDesc p = irq_desc + irq;
- pIrqAction action = p->action;
+ irq_desc_t * p = irq_desc + irq;
+ irq_action_t * action = p->action;
p->chip->ack(irq);
while(action)
{
}
-/*
-int request_irq( unsigned int irq,
- void (*handler)(pPtRegs, unsigned int),
- const char *devname,
- void *dev_id)
-*/
int request_irq( unsigned int irq,
void (*handler)(unsigned int, pPtRegs, void *),
const char *devname,
void *dev_id)
{
- pIrqAction p;
+ irq_action_t * p;
if(irq >= NR_IRQS)
return -EINVAL;
p = p->next;
}
- p = kmalloc_old(sizeof(IrqAction));
+ p = (irq_action_t *) kmalloc(sizeof(irq_action_t), 0);
if(p == NULL)
return -ENOMEM;
void setup_sysc()
{
- wrmsr(MSR_SYSENTER_CS, SELECTOR_KRNL_CS, 0);
- wrmsr(MSR_SYSENTER_EIP, syscall_entry, 0);
- wrmsr(MSR_SYSENTER_ESP, ¤t, 0);
-
+ wrmsr(MSR_SYSENTER_CS, SELECTOR_KRNL_CS, 0);
+ wrmsr(MSR_SYSENTER_EIP, syscall_entry, 0);
+ wrmsr(MSR_SYSENTER_ESP, ¤t, 0);
init_sysc_handler_table();
-
}
printk("kmem objsize %d size %d \n", cache->objsize, cache->size);
}
+#if 0
list_head_t *p;
list_for_each(p, &slub_caches)
{
printk("kmalloc addr %08x\n", (unsigned long) addr);
addrs[i] = addr;
}
+#endif
}
extern void setup_pci();
extern void set_tss();
extern void show_logo();
-//extern void setup_tTasks();
extern void setup_tasks();
extern void setup_root_dev();
extern void setup_hd();
init_mm();
- while(1);
setup_gdt();
setup_idt();
detect_cpu();
- //setup_tTasks();
- setup_irqs();
set_tss();
+
setup_sysc();
setup_pci();
+ setup_irqs();
+
while(1); // TODO MODIFY CODE BELOW
irq_desc[i].chip = &i8259_chip;
}
- //extern void kbd_handler(pPtRegs, unsigned int);
- //extern void clk_handler(pPtRegs, unsigned int);
+ //extern void kbd_handler(pPtRegs, unsigned int); //extern void clk_handler(pPtRegs, unsigned int);
//extern void hd_handler(pPtRegs, unsigned int);
void kbd_handler(unsigned int irq, pPtRegs regs, void *dev_id);
void clk_handler(unsigned int irq, pPtRegs regs, void *dev_id);
void hd_handler(unsigned int irq, pPtRegs regs, void *dev_id);
request_irq(0x00, clk_handler, "Intel 8254", "Clock Chip");
request_irq(0x01, kbd_handler, "Intel 8042", "PS/2 Keyboard");
- request_irq(0x0E, hd_handler, "IDE", "IDE");
+ request_irq(0x0E, hd_handler, "IDE", "IDE");
enable_irq(0x00);
enable_irq(0x01);
enable_irq(0x0E);
-
+ asm("sti");
/*
pIRQAction pKbdAction, pClkAction;