void hd_init() { set_intr_gate(0x2e, hd_interrupt); outb_p(inb_p(0x21)&0xfb, 0x21); outb_p(inb_p(0xa1)&0xbf, 0xa1); }
_hd_interrupt: mov byte [ds:0xb8000],'D' mov byte [ds:0xb8001],0x1e jmp $
#define HD_DATA 0x1f0 void hd_out(unsigned int drive, unsigned int nsect, unsigned int sect, unsigned int head, unsigned int cyl, unsigned int cmd) { unsigned int port = HD_DATA; outb_p(0x00, ++port); //error寄存器 outb_p(0x01, ++port); //扇区数 outb_p(0x00, ++port); //LBALow outb_p(0x00, ++port); //LBAMid outb_p(0x00, ++port); //LBAHigh outb_p(0xe0, ++port); //Device寄存器 outb_p(0x20, ++port); //cmd = 0x20 读 }
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!