You need to set the high order bit (bit 7) of the device control register to 1 to read the high order bytes in command responses. This is not required when writing 48-bit LBAs. You also shouldn't need to reset it to zero again after reading the high order bytes as this is done for you on the next write to a command register.
I'm not sure how you obtain the IO address of the control registers on Linux, but once you have it, you would want to do something like:
Code:
error = inb(reg_base+1);
count_low = inb(reg_base+2);
lba_low_low = inb(reg_base+3);
lba_mid_low = inb(reg_base+4);
lba_high_low = inb(reg_base+5);
outb(ctrl_base, 0x80);
count_high = inb(reg_base+2);
lba_low_high = inb(reg_base+3);
lba_mid_high = inb(reg_base+4);
lba_high_high = inb(reg_base+5);
device = inb(reg_base+6);
status = inb(reg_base+7);
Bear in mind that many commands do not return a sector count value. The setting of the device control register to 0x80 also has the side effect of enabling interrupts although these are probably already enabled anyway.
Regards,
John.