well here it is (written by me, still messy )
it reads the first sec of my disk and puts it onto the screen...
Code: Select all
void initIDEdrive()
{
}
int readsec()
{
unsigned char c=0x0,c2=0x00;
unsigned short int b;
int i=0;
//
// 1F0 -> 1F7
// 170 -> 177 (the other disk)
//
//
// outportb(0x1F6,0x101+drive+head);
// [101] [01] [000]
//
// 1*2*2*2*2*2*2*2 = 128
// 1*2*2*2*2*2 = 32
// 1*2*2*2*2 = 16
// -------
// 176
//
// outportb(0x1F6,176);
outportb(0x1F6,176);
outportb(0x1F2,1); /* 1 sector to read */
outportb(0x1F3,1); /* sector nr */
outportb(0x1F4,0x00); /* cylinder low */
outportb(0x1F5,0x00); /* cylinder high */
outportb(0x1F7,0x20); /* read with retry */
c = 208;
while (c==208){ c = inportb(0x1F7); }
printf("\n--------\n");
for (i=0; i<512; i++)
{
b = inportdd(0x1F0);
asm volatile("movw %%ax,%%bx"::"b" (b));
asm volatile("mov %%al,%%bh":"=b" (c));
asm volatile("mov %%ah,%%bl":"=b" (c2));
putc(c);
putc(c2);
// buf[i] = c;
// buf[i+2] = c2;
}
printf("\n--------\n");
// return * buf;
}