Repos / kernel.git / commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 204396f)
raw | patch | inline | side by side (parent: 204396f)
| author | zhaoyanbai <zhaoyanbai@126.com> | |
| Fri, 4 Jul 2014 16:44:48 +0000 (00:44 +0800) | ||
| committer | zhaoyanbai <zhaoyanbai@126.com> | |
| Wed, 3 Nov 2021 02:45:35 +0000 (10:45 +0800) |
| drivers/ide.c | patch | blob | history | |
| kernel/setup.c | patch | blob | history | |
| lib/vsprintf.c | patch | blob | history |
diff --git a/drivers/ide.c b/drivers/ide.c
--- a/drivers/ide.c
+++ b/drivers/ide.c
ide_printd();
outb(0x00|(pio?0:HD_CTL_NIEN), REG_CTL(dev));
- outb(0x40, REG_DEVSEL(dev));
+ outb(0x40|0x10, REG_DEVSEL(dev));
outb((u8)((sect_cnt>>8)&0xFF), REG_NSECTOR(dev)); // High
outb((u8)((sect_nr>>24)&0xFF), REG_LBAL(dev));
void ide_read_identify()
{
- outb(HD_CTL_NIEN, REG_CTL(0));
+ outb(HD_CTL_NIEN, REG_CTL(dev));
outb(0x00, REG_DEVSEL(dev));
outb(HD_CMD_IDENTIFY, REG_CMD(dev));
}
typedef struct {
- unsigned int a;
- unsigned int b;
+ unsigned char a;
+ unsigned char b;
+ unsigned char c;
+ unsigned char d;
+ unsigned char type;
+ unsigned char f;
+ unsigned char g;
+ unsigned char h;
unsigned int lba;
unsigned int sect_cnt;
} hd_part_t ;
+#if 1
+void spartition(u64_t sect_nr, u64_t base)
+{
+ base += sect_nr;
+ printk("SECT NR %d\n", sect_nr);
+ char *part_buf=kmalloc(1024, 0);
+ ide_wait_read(0, 1, base, part_buf);
+
+ hd_part_t *p = (hd_part_t *)(part_buf+PARTITION_TABLE_OFFSET);
+ int i;
+ u64_t ext = ~0UL;
+ for(i=0; i<4; ++i)
+ {
+ if(p->type == 0)
+ continue;
+ printk(" Partition[%d] [%02x] LBA %d SectCnt %d\n", i, p->type, (unsigned int)(base+p->lba), (unsigned int)(base+p->lba+p->sect_cnt));
+ if(p->type == 0x05)
+ ext = p->lba;
+
+ p++;
+ }
+
+ printk("--------------------------------------------------%d\n", ext);
+ if(ext != ~0UL)
+ spartition(ext, base);
+}
+#endif
+
+static int f = 0;
+void partition(u64_t base)
+{
+ char *part_buf = kmalloc(1024, 0);
+ ide_wait_read(0, 1, base, part_buf);
+
+ hd_part_t *p = (hd_part_t *)(part_buf+PARTITION_TABLE_OFFSET);
+
+ u16_t sig = *((u16_t *) (part_buf+510));
+ //printk("---------------------------------------------%d [%04x]\n", x, sig);
+ printk("---------------------------------------------<%d> \n", (unsigned int) base);
+
+ int i;
+ for(i=0; i<4; ++i)
+ {
+ if(p->type == 0)
+ continue;
+ printk(" Partition[%d] [%02x] LBA %d cnt %d LBABASE %d LBAEND %d\n", i, p->type, p->lba, p->sect_cnt, (unsigned int)(base+p->lba), (unsigned int)(base+p->lba+p->sect_cnt));
+
+ if(p->type == 0x05)
+ {
+ f++;
+ if(f > 1)
+ partition(p->lba+43008);
+ else
+ partition(p->lba+0);
+ }
+
+ p++;
+ }
+}
+
void ide_init()
{
memset((void *)&drv, 0, sizeof(drv));
ide_read_identify();
ide_printd();
#endif
- ide_wait_read(0, 1, 0, data);
-
- hd_part_t *p = (hd_part_t *)(data+PARTITION_TABLE_OFFSET);
- int i;
- for(i=0; i<4; ++i)
- {
- printk(" Partition %d LBA %d SectCnt %d\n", i, p->lba, p->sect_cnt);
- p++;
- }
+ //spartition(0, 0);
+ partition(0);
u16_t sig = *((u16_t *) (data+510));
printk("IDE_INIT______READ %04x\n", sig);
diff --git a/kernel/setup.c b/kernel/setup.c
--- a/kernel/setup.c
+++ b/kernel/setup.c
switch_printk_screen();
void ide_init();
ide_init();
+ switch_printk_screen();
detect_cpu();
printk("%s\n", version);
- printd(0, "-----------------------------------------------------------");
return;
while(1); // TODO MODIFY CODE BELOW
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
case 'd':
itoa(tmp, *((int*)args));
p += write_buf(p, tmp, char_fill, char_cnt, align);
-#if 0
- char_cnt -= strlen(tmp);
- if(char_cnt > 0)
- {
- while(char_cnt--)
- *p++ = char_fill;
- }
- strcpy(p, tmp);
- p += strlen(tmp);
-#endif
break;
case 's':
p += write_buf(p, (const char *)*((unsigned int *) args), char_fill, char_cnt, align);
-#if 0
- strcpy(p, (const char *)*((unsigned int *) args));
- p += strlen((const char *)*((unsigned int *) args));
-#endif
break;
case 'x':
itox(tmp, *((unsigned int *) args));
p += write_buf(p, tmp, char_fill, char_cnt, align);
-#if 0
- char_cnt -= strlen(tmp);
- if(char_cnt > 0)
- {
- while(char_cnt--)
- *p++ = char_fill;
- }
- strcpy(p, tmp);
- p += strlen(tmp);
-#endif
break;
default:
break;