{
pci_device_t *pci;
u32_t iobase;
+ unsigned long cmd_out_cnt;
+ unsigned long irq_cnt;
} ide_drive_t;
ide_drive_t drv;
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);
}
+
+void ide_printd()
+{
+ printd(MPL_IDE, "ide cmd cnt %d irq cnt %d", drv.cmd_out_cnt, drv.irq_cnt);
+}
void ide_cmd_out(Dev dev, u32 nsect, u64 sect_nr, u32 cmd)
{
+ drv.cmd_out_cnt++;
+
outb(0x00, REG_CTL(dev));
outb(0x40, REG_DEVSEL(dev));
outb((u8)((sect_nr>>16)&0xFF), REG_LBAH(dev));
outb(cmd, REG_CMD(dev));
+
+ ide_printd();
}
u8_t idest = inb(REG_STATUS(0));
u8_t pcist = inb(drv.iobase+PCI_IDE_STATUS);
printk(" ide status %02x pci status %02x\n", idest, pcist);
-
}
nsect = (count + SECT_SIZE -1)/SECT_SIZE;
ide_cmd_out(0, nsect, sect_nr, HD_CMD_READ_EXT);
-
- printd(4, "ide_debug\n");
}
DECLARE_MUTEX(mutex);
{
u8_t status = inb(REG_STATUS(0));
- memset(buf, 0xEE, 1024);
+ drv.irq_cnt++;
status = inb(drv.iobase+PCI_IDE_STATUS);
if(0 == (status & PCI_IDE_STATUS_INTR))
insl(REG_DATA(0), buf, (512>>2));
u16_t sig = *((u16_t *) (buf+510));
- printd(11, "hard disk data %04x", sig);
+ printk("hard disk data %04x\n", sig);
+ ide_printd();
up(&mutex);
}
void ide_init()
{
+ memset((void *)&drv, 0, sizeof(drv));
init_pci_controller(PCI_VENDORID_INTEL, 0x2829);
init_pci_controller(PCI_VENDORID_INTEL, 0x7010);
ide_read_identify();
- printd(6, "BUFF ADDR %08x", buf);
+ ide_printd();
}
void debug_sched();
void vga_dbg_toggle();
int debug_wait_queue_put(unsigned int v);
+
+unsigned long kbd_cnt = 0;
void kbd_handler(unsigned int irq, pt_regs_t * regs, void *dev_id)
{
unsigned char scan_code;
scan_code = inb(0x60);
+ printd(MPL_KEYBOARD, "keyboard:%d scan code %02x", kbd_cnt++, scan_code);
+
if(scan_code == 0x01) // Esc
reboot();
if(scan_code == 0x14) // t
debug_sched();
- if(scan_code == 0x39) // Space
- vga_dbg_toggle();
-
-
if(scan_code == 0x3B) // F1
vga_switch(0);
if(scan_code == 0x3C) // F2
if(scan_code == 0x3E) // F4
vga_switch(3);
- if(scan_code == 0x43) // F9
+ if(scan_code == 0x3F) // F5
debug_wait_queue_put(0);
- if(scan_code == 0x44) // F10
+ if(scan_code == 0x40) // F6
debug_wait_queue_put(1);
- if(scan_code == 0x57) // F11
+ if(scan_code == 0x41) // F7
debug_wait_queue_put(2);
- if(scan_code == 0x58) // F12
+ if(scan_code == 0x42) // F8
debug_wait_queue_put(7);
+ if(scan_code == 0x43); // F9
+ if(scan_code == 0x44); // F10
+ if(scan_code == 0x57); // F11
+ if(scan_code == 0x58) // F12
+ vga_dbg_toggle();
+
#if 1
- printd(10, "CNSL HEAD : %d", cnsl_rd_q.head++);
cnsl_rd_q.data[0] = (char) scan_code;
wake_up(&cnsl_rd_q.wait);
#endif
*/
#include <io.h>
+#include <irq.h>
typedef struct {
u8_t c;
base = s->id*MAX_LINES_PER_SCREEN*CHARS_PER_LINE;
offset = base + s->offset;
+ unsigned long flags;
+ irq_save(flags);
outb(VGA_CRTC_CURSOR_H, VGA_CRTC_ADDR);
outb((offset>>8) & 0xFF, VGA_CRTC_DATA);
outb(VGA_CRTC_CURSOR_L, VGA_CRTC_ADDR);
outb(offset & 0xFF, VGA_CRTC_DATA);
+ irq_restore(flags);
}
void vga_clear(vga_screen_t *s, unsigned int b, unsigned int e)
int printk(char *fmtstr, ...);
int printd(unsigned int line, const char *fmtstr, ...);
+
+// monitor print line
+enum {
+ MPL_CLOCK,
+ MPL_KEYBOARD,
+ MPL_IDE,
+ MPL_PREEMPT,
+ MPL_ROOT,
+ MPL_TASK_1,
+ MPL_TASK_2,
+ MPL_END
+};
+
unsigned long esp;
unsigned long eip;
- unsigned long weight;
+ long weight;
pid_t pid;
pid_t ppid;
char __initdata kernel_init_stack[KRNL_INIT_STACK_SIZE] __attribute__ ((__aligned__(PAGE_SIZE)));
-static unsigned int eid = 1;
-void debug_sem();
int debug_wait_queue_get();
void init_task_entry()
{
- printk("%s\n", __func__);
- unsigned int id = eid++;
- int i = 0;
+ int cnt = 0;
+ pid_t id = sysc_getpid();
+
while(1)
{
- i++;
- printd(id+1, "task:%d [%08x] cnt:%d preempt_cnt %d", id, current, i, current->preempt_cnt);
+ printd(MPL_TASK_1+id-1, "task:%d [%08x] weight %d cnt %d", id, current, current->weight, cnt++);
int v = debug_wait_queue_get();
printk("task:%d wait queue get %d\n", id, v);
}
}
- int cnt;
+ int cnt = 0;
while(1)
{
- printd(1, "root_task [%08x] cnt:%d preempt_cnt %d", current, cnt++, root_task.preempt_cnt);
- printd(9, "pid %d ppid %d state %d weight %d", root_task.pid, root_task.ppid, root_task.state, root_task.weight);
+ printd(MPL_ROOT, "root:0 [%08x] weight %d cnt %d", current, root_task.weight, cnt++);
asm("sti;hlt;");
//sysc_test();
//syscall0(SYSC_TEST);
.depth = 0
};
-static int preempt = 0;
-
__attribute__ ((regparm(1))) void irq_handler(pt_regs_t *regs)
{
unsigned int irq = regs->irq;
irq_action_t *action = p->action;
- //atomic_inc(&(current->preempt_cnt));
- atomic_inc(&preempt);
+ atomic_inc(&(current->preempt_cnt));
unsigned long esp;
- printd(8, "preempt : %d", preempt);
- //asm("movl %%esp, %%eax":"=a"(esp));
- //printd(8, "preempt_cnt:%d current %08x esp %08x", current->preempt_cnt, current, esp);
- //printk("preempt_cnt:%d current %08x esp %08x\n", current->preempt_cnt, current, esp);
-
-#if 0
- esp >>= 16;
- if(esp != 0xC013 && esp != 0xC7FF)
- {
- asm("cli");
- printk("FUCK\n");
- while(1);
- }
-#endif
+ asm("movl %%esp, %%eax":"=a"(esp));
+ printd(MPL_PREEMPT, "current %08x preempt %d esp %08x", current, current->preempt_cnt, esp);
p->chip->ack(irq);
sti();
cli();
p->chip->enable(irq);
- atomic_dec(&preempt);
- //atomic_dec(&(current->preempt_cnt));
+ atomic_dec(&(current->preempt_cnt));
}
task_union *next = sel;
if(prev != sel)
- {
- //unsigned long flags;
- //irq_save(flags);
- //LOAD_CR3(root_task.cr3);
context_switch(prev, next);
- //irq_restore(flags);
- }
}
void debug_sched()