Repos / kernel.git / commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 064e40c)
raw | patch | inline | side by side (parent: 064e40c)
| author | zhaoyanbai <zhaoyanbai@126.com> | |
| Mon, 23 Sep 2024 08:57:32 +0000 (16:57 +0800) | ||
| committer | zhaoyanbai <zhaoyanbai@126.com> | |
| Mon, 23 Sep 2024 08:57:32 +0000 (16:57 +0800) |
| drivers/ata.c | patch | blob | history | |
| drivers/ide.c | patch | blob | history | |
| drivers/ide.h | patch | blob | history | |
| drivers/pci.c | patch | blob | history | |
| kernel/fork.c | patch | blob | history | |
| kernel/setup.c | patch | blob | history | |
| kernel/task_disk.c | patch | blob | history | |
| kernel/task_user.c | patch | blob | history | |
| kernel/wait.c | patch | blob | history |
diff --git a/drivers/ata.c b/drivers/ata.c
--- a/drivers/ata.c
+++ b/drivers/ata.c
ide_drive_type = "ATA";
} else {
if (ata_read_identify_packet(drv_no, 1, &status, identify)) {
- printk("ATAPI DEVICE\n");
+ // printk("ATAPI DEVICE\n");
drv->present = 1;
drv->type = IDE_DRIVE_TYPE_ATAPI;
ide_drive_type = "ATAPI";
// Bit 0: 1 表示设备支持软重置。
uint16_t devtype = identify[ATA_IDENT_DEVTYPE];
- printk("device type %04X\n", devtype);
+ // printk("device type %04X\n", devtype);
// 第49个word的第8个bit位表示是否支持DMA
// 第83个word的第10个bit位表示是否支持LBA48,为1表示支持。
// printk("%04x %04x %d %d\n", identify[49], 1 << 8, identify[49] & (1 << 8), (identify[49] & (1 << 8)) != 0);
if ((identify[49] & (1 << 8)) != 0) {
drv->dma = 1;
+ } else {
+ // panic("your ide disk drive do not support DMA");
}
- u64 max_lba = *(u64 *)(identify + 100);
+ u64 max_lba = 0;
+
+ // printk("identity[83] %04X\n", identify[83]);
if ((identify[83] & (1 << 10)) != 0) {
drv->lba48 = 1;
- drv->max_lba = max_lba;
+ max_lba = *(u64 *)(identify + 100);
+ } else {
+ // panic("your ide disk drive do not support LBA48");
+ max_lba = (identify[61] << 16) | identify[60];
}
+
+ drv->max_lba = max_lba;
+
+ // assert(drv->lba48 == 1);
+ // assert(drv->max_lba != 0);
+ // assert(drv->dma == 1);
#if 1
uint16_t ata_major = identify[80];
uint16_t ata_minor = identify[81];
printk("ATA/ATAPI-4 ");
}
- printk("%04X %02X\n", ata_major, ata_minor);
+ printk("[Major %04X Minor %02X]\n", ata_major, ata_minor);
#endif
- printk("Ultra DMA modes: %04x\n", identify[88]);
#if 0
uint16_t x = identify[222];
break;
}
#endif
- printk("hard disk %s %s size: %u MB\n", drv->dma == 1 ? "DMA" : "", drv->lba48 == 1 ? "LBA48" : "LBA28",
+ printk("%s %s size: %u MB ", drv->dma == 1 ? "DMA" : "", drv->lba48 == 1 ? "LBA48" : "LBA28",
(max_lba * 512) >> 20);
+ printk("Ultra DMA modes: %04x\n", identify[88]);
+
char s[64];
ata_read_identity_string(identify, 10, 19, s);
printk("SN: %s\n", s);
drv->partions[0].lba_start = 0;
drv->partions[0].lba_end = drv->max_lba;
}
+
+ for (int i = 0; i < MAX_IDE_DRIVE_CNT; i++) {
+ int drv_no = i;
+ ide_drive_t *drv = ide_drives + drv_no;
+ if (drv->present) {
+ assert(drv->dma == 1);
+ assert(drv->lba48 == 1);
+ assert(drv->max_lba > 0);
+ }
+ }
}
void ide_disk_read(dev_t dev, uint32_t sect_nr, uint32_t count, bbuffer_t *b) {
@@ -343,10 +367,10 @@ void read_partition_table(ide_drive_t *drv, uint32_t mbr_ext_offset, uint32_t lb
char *sect = kmalloc(SECT_SIZE, 0);
#if 1
- // part_no == 0 代表æ\95´å\9cº硬盘
+ // part_no == 0 代表æ\95´å\9d\97硬盘
tmp_ide_disk_read(MAKE_DISK_DEV(drv->drv_no, 0), lba_partition_table, 1, sect);
#else
- // part_no == 0 代表æ\95´å\9cº硬盘
+ // part_no == 0 代表æ\95´å\9d\97硬盘
r.dev = MAKE_DISK_DEV(drv->drv_no, 0);
r.command = DISK_REQ_READ;
r.pos = lba_partition_table;
diff --git a/drivers/ide.c b/drivers/ide.c
--- a/drivers/ide.c
+++ b/drivers/ide.c
// printk("ide irq %d handler pci status: 0x%02x\n", irq, ata_pci_bus_status());
int channel = irq == ide_pci_controller[0].irq_line ? 0 : 1;
- printk("ide[%d] irq %d handler\n", channel, irq);
+ // printk("ide[%d] irq %d handler\n", channel, irq);
ide_pci_controller_t *ide_ctrl = ide_pci_controller + channel;
atomic_inc(&ide_ctrl->irq_cnt);
diff --git a/drivers/ide.h b/drivers/ide.h
--- a/drivers/ide.h
+++ b/drivers/ide.h
int type;
int present;
int drv_no;
- int dma;
- uint64_t lba48;
+ int dma; // 是否支持DMA
+ int lba48; // 是否支持LBA48
uint64_t max_lba;
ide_pci_controller_t *ide_pci_controller;
diff --git a/drivers/pci.c b/drivers/pci.c
--- a/drivers/pci.c
+++ b/drivers/pci.c
const char *pci_intr_pin(int pin) {
switch (pin) {
case 0:
- return "NOINTPIN";
+ return "NONE#";
case 1:
return "INTA#";
case 2:
break;
}
#else
- for (int bar_inx = 0; bar_inx < BARS_CNT; bar_inx++) {
- printk("%08x ", pci->bars[bar_inx]);
- }
- printk("\n");
+ // for (int bar_inx = 0; bar_inx < BARS_CNT; bar_inx++) {
+ // printk("%08x ", pci->bars[bar_inx]);
+ // }
+ // printk("\n");
#endif
}
}
diff --git a/kernel/fork.c b/kernel/fork.c
--- a/kernel/fork.c
+++ b/kernel/fork.c
// printd("child regs: %x %x\n", child_regs, regs);
memcpy(child_regs, regs, sizeof(*regs));
- //child_regs->eflags |= 0x200;
+ // child_regs->eflags |= 0x200;
if (flags & FORK_KRNL) {
strcpy(tsk->name, (char *)(child_regs->eax));
} else {
child_regs->eip = *((unsigned long *) && fork_child);
}
- printk("%s fork %s EFLAGS %08x\n", current->name, tsk->name, regs->eflags);
+ printk("%s fork %s EFLAGS %08x\n", current->name, tsk->name, regs->eflags);
// 这一句已经不需要了,通过fork_child已经能给子进程返回0了
// child_regs->eax = 0;
diff --git a/kernel/setup.c b/kernel/setup.c
--- a/kernel/setup.c
+++ b/kernel/setup.c
boot_delay(DEFAULT_BOOT_DELAY_TICKS);
extern tty_t *const monitor_tty;
- tty_switch(monitor_tty);
+ // tty_switch(monitor_tty);
boot_delay(DEFAULT_BOOT_DELAY_TICKS);
diff --git a/kernel/task_disk.c b/kernel/task_disk.c
--- a/kernel/task_disk.c
+++ b/kernel/task_disk.c
assert(MAKE_DISK_DEV(drv_no, part_id) == r->dev);
uint64_t pos = r->pos + drv->partions[part_id].lba_start;
- //printk("pos %lu partid %d lba end %lu\n", pos, part_id, drv->partions[part_id].lba_end);
- assert(pos < drv->partions[part_id].lba_end);
+ // printk("pos %lu partid %d lba end %lu\n", pos, part_id, drv->partions[part_id].lba_end);
+ // assert(pos < drv->partions[part_id].lba_end);
+ if ((pos >= drv->partions[part_id].lba_end)) {
+ printk("pos %lu partid %d lba %u %u\n", pos, part_id, drv->partions[part_id].lba_start,
+ drv->partions[part_id].lba_end);
+ panic("INVARG");
+ }
// init_completion(&ide_ctrl->intr_complete);
diff --git a/kernel/task_user.c b/kernel/task_user.c
--- a/kernel/task_user.c
+++ b/kernel/task_user.c
: "=a"(__sysc_ret__)
: "a"(SYSC_WAIT), "c"(ring3_entry));
- for (int i = 100000000; i > 0; i--) {
+ for (int i = 10000000; i > 0; i--) {
for (int j = 1; j > 0; j--) {
asm("nop;nop;nop;");
}
diff --git a/kernel/wait.c b/kernel/wait.c
--- a/kernel/wait.c
+++ b/kernel/wait.c
irq_save(flags);
list_for_each_entry_safe(p, tmp, &head->task_list, entry) {
assert(p->task != NULL);
- printk("wakeup %s\n", p->task->name);
+ // printk("wakeup %s\n", p->task->name);
p->task->state = TASK_READY;
p->task->reason = "wake_up";