// panic("your ide disk drive do not support DMA");
}
- u64 max_lba = 0;
+ uint64_t max_lba = 0;
// printk("identity[83] %04X\n", identify[83]);
if ((identify[83] & (1 << 10)) != 0) {
drv->lba48 = 1;
- max_lba = *(u64 *)(identify + 100);
+ max_lba = *(uint64_t *)(identify + 100);
} else {
// panic("your ide disk drive do not support LBA48");
max_lba = (identify[61] << 16) | identify[60];
// mbr_ext_offset: 在MBR中的扩展分区记录里的偏移地址
// lba_partition_table: 扩展分区的真实偏移地址
-void read_partition_table(ide_drive_t *drv, uint32_t mbr_ext_offset, uint32_t lba_partition_table, int depth) {
+void read_partition_table(ide_drive_t *drv, uint32_t mbr_ext_offset, uint64_t lba_partition_table, int depth) {
// disk_request_t r;
char *sect = kmalloc(SECT_SIZE, 0);
uint32_t part_id = 0;
// 用来计算保存下一个扩展分区的起始位置
- uint32_t lba_extended_partition = 0;
+ uint64_t lba_extended_partition = 0;
const char *pe = sect + PARTITION_TABLE_OFFSET;
for (int i = 0; i < 4; i++) {
if (part_id >= MAX_DISK_PARTIONS) {
}
// 用于计算保存下一个分区的起始位置
- uint32_t lba_offset = 0;
+ uint64_t lba_offset = 0;
if (0x05 == pt.type || 0x0F /*W95 扩展 (LBA)*/ == pt.type) {
assert(lba_extended_partition == 0); // 最多只允许有一个扩展分区
mbr_ext_offset = mbr_ext_offset != 0 ? mbr_ext_offset : pt.lba_start;
- uint32_t offset = depth == 0 ? lba_partition_table : pt.lba_start;
+ uint64_t offset = depth == 0 ? lba_partition_table : pt.lba_start;
lba_offset = mbr_ext_offset + offset;
lba_extended_partition = lba_offset;
} else {
part->flags = pt.flags;
part->type = pt.type;
part->lba_start = lba_offset;
- uint32_t size = pt.lba_end;
+ uint64_t size = pt.lba_end;
part->lba_end = part->lba_start + size;
- printk("part[%02d] %02X %10u %-10u\n", part_id, pt.type, lba_offset, part->lba_end - 1);
+ printk("part[%02d] %02X %lu %lu\n", part_id, pt.type, lba_offset, part->lba_end - 1);
}
// 每个分区16个字节
irq_desc_t no_irq_desc = {.chip = &no_irq_chip, .action = NULL, .status = 0, .depth = 0};
// 单CPU
+// 这里的代码有BUG,如果嵌套调用的话
+// __critical_zone_eflags的值会被统一设置为最里层时的eflags
+// 意味着如果IF置位了的话,必定会丢失这个信息
static volatile uint32_t __critical_zone_eflags;
void enter_critical_zone() { irq_save(__critical_zone_eflags); }
void exit_critical_zone() { irq_restore(__critical_zone_eflags); }
// 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,
+ printk("pos %lu partid %d lba %lu %lu\n", pos, part_id, drv->partions[part_id].lba_start,
drv->partions[part_id].lba_end);
panic("INVARG");
}