1 2SECTION code_driver 3 4PUBLIC ide_setup_lba 5 6EXTERN __IO_IDE_LBA0, __IO_IDE_LBA1, __IO_IDE_LBA2, __IO_IDE_LBA3 7 8EXTERN ide_write_byte 9 10EXTERN ideStatus 11 12;------------------------------------------------------------------------------ 13; IDE internal subroutines 14; 15; These routines talk to the drive, using the low level I/O. 16; Normally a program should not call these directly. 17;------------------------------------------------------------------------------ 18 19; set up the drive LBA registers 20; LBA is contained in BCDE registers 21 22ide_setup_lba: 23 push hl 24 ld a, __IO_IDE_LBA0 25 call ide_write_byte ;set LBA0 0:7 26 ld e, d 27 ld a, __IO_IDE_LBA1 28 call ide_write_byte ;set LBA1 8:15 29 ld e, c 30 ld a, __IO_IDE_LBA2 31 call ide_write_byte ;set LBA2 16:23 32 ld a, b 33 and 00001111b ;lowest 4 bits used only 34 or 11100000b ;to enable LBA address mode 35 ld hl, ideStatus ;set bit 4 accordingly 36 bit 0, (hl) 37 jr z, ide_setup_master 38 or $10 ;if it is a slave, set that bit 39ide_setup_master: 40 ld e, a 41 ld a, __IO_IDE_LBA3 42 call ide_write_byte ;set LBA3 24:27 + bits 5:7=111 43 pop hl 44 ret 45