; Project name : XTIDE Universal BIOS ; Description : Functions for creating Disk Parameter Table. ; Section containing code SECTION .text ;-------------------------------------------------------------------- ; Creates new Disk Parameter Table for detected hard disk. ; Drive is then fully accessible using any BIOS function. ; ; CreateDPT_FromAtaInformation ; Parameters: ; BH: Drive Select byte for Drive and Head Register ; ES:SI: Ptr to 512-byte ATA information read from the drive ; CS:BP: Ptr to IDEVARS for the controller ; DS: RAMVARS segment ; ES: BDA Segment ; Returns: ; DL: Drive number for new drive ; DS:DI: Ptr to Disk Parameter Table (if succesfull) ; CF: Cleared if DPT created successfully ; Set if any error ; Corrupts registers: ; AX, BX, CX, DH ;-------------------------------------------------------------------- CreateDPT_FromAtaInformation: call FindDPT_ForNewDriveToDSDI ; Fall to .InitializeDPT ;-------------------------------------------------------------------- ; .InitializeDPT ; Parameters: ; BH: Drive Select byte for Drive and Head Register ; DS:DI: Ptr to Disk Parameter Table ; CS:BP: Ptr to IDEVARS for the controller ; Returns: ; Nothing ; Corrupts registers: ; AX ;-------------------------------------------------------------------- .InitializeDPT: mov [di+DPT.bIdevarsOffset], bp ; IDEVARS must start in first 256 bytes of ROM ; Fall to .StoreDriveSelectAndDriveControlByte ;-------------------------------------------------------------------- ; .StoreDriveSelectAndDriveControlByte ; Parameters: ; BH: Drive Select byte for Drive and Head Register ; DS:DI: Ptr to Disk Parameter Table ; ES:SI: Ptr to 512-byte ATA information read from the drive ; CS:BP: Ptr to IDEVARS for the controller ; Returns: ; Nothing ; Corrupts registers: ; AX ;-------------------------------------------------------------------- .StoreDriveSelectAndDriveControlByte: mov al, bh and ax, BYTE FLG_DRVNHEAD_DRV ; AL now has Master/Slave bit cmp [cs:bp+IDEVARS.bIRQ], ah ; Interrupts enabled? jz SHORT .StoreFlags ; If not, do not set interrupt flag or al, FLGL_DPT_ENABLE_IRQ .StoreFlags: mov [di+DPT.wFlags], ax ; Fall to .StoreAddressing ;-------------------------------------------------------------------- ; .StoreAddressing ; Parameters: ; DS:DI: Ptr to Disk Parameter Table ; ES:SI: Ptr to 512-byte ATA information read from the drive ; CS:BP: Ptr to IDEVARS for the controller ; Returns: ; Nothing ; Corrupts registers: ; AX, BX, CX, DX ;-------------------------------------------------------------------- .StoreAddressing: ; Check if CHS defined in ROMVARS call AccessDPT_GetPointerToDRVPARAMStoCSBX test byte [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERCHS ; User specified CHS? jnz SHORT .StoreUserDefinedPCHS ; Check if LBA supported call AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI test BYTE [es:si+ATA1.wCaps+1], A1_wCaps_LBA>>8 jz SHORT .StoreCHSfromAXBHBL ; Small old drive with CHS addressing only ; Check if 48-bit LBA supported test BYTE [es:si+ATA6.wSetSup83+1], A6_wSetSup83_LBA48>>8 jz SHORT .StoreLBA28addressing or BYTE [di+DPT.bFlagsLow], ADDRESSING_MODE_LBA48<