source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm @ 175

Last change on this file since 175 was 175, checked in by gregli@…, 13 years ago

ifdef of existing serial code, in preperation for checkin

File size: 3.9 KB
RevLine 
[150]1; Project name  :   XTIDE Universal BIOS
[3]2; Description   :   Functions for detecting drive for the BIOS.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Detects all IDE hard disks to be controlled by this BIOS.
9;
10; DetectDrives_FromAllIDEControllers
11;   Parameters:
12;       DS:     RAMVARS segment
13;       ES:     BDA segment (zero)
14;   Returns:
15;       Nothing
16;   Corrupts registers:
17;       All (not segments)
18;--------------------------------------------------------------------
19DetectDrives_FromAllIDEControllers:
[33]20    call    RamVars_GetIdeControllerCountToCX
[3]21    mov     bp, ROMVARS.ideVars0            ; CS:BP now points to first IDEVARS
22.DriveDetectLoop:
[175]23    call    .DetectDrives_WithIDEVARS       ; Detect Master and Slave
[3]24    add     bp, BYTE IDEVARS_size           ; Point to next IDEVARS
25    loop    .DriveDetectLoop
[175]26
27%ifdef MODULE_SERIAL
28    test    BYTE [es:BDA.bKBFlgs1], (1<<2)
29;;  jz      .done
30    mov     bp, ROMVARS.ideVarsAutoSerial
31;;; fall-through       
32%else
[3]33    ret
[175]34%endif
[3]35
36;--------------------------------------------------------------------
37; Detects IDE hard disks by using information from IDEVARS.
38;
39; DetectDrives_WithIDEVARS
40;   Parameters:
41;       CS:BP:      Ptr to IDEVARS
42;       DS:         RAMVARS segment
43;       ES:         Zero (BDA segment)
44;   Returns:
45;       Nothing
46;   Corrupts registers:
47;       AX, BX, DX, SI, DI
48;--------------------------------------------------------------------
[175]49.DetectDrives_WithIDEVARS:
[3]50    push    cx
[97]51    mov     ax, g_szMaster
[150]52    mov     bh, MASK_DRVNHEAD_SET                               ; Select Master drive
[98]53    call    StartDetectionWithDriveSelectByteInBHandStringInAX  ; Detect and create DPT + BOOTNFO
[3]54
[97]55    mov     ax, g_szSlave
[150]56    mov     bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV
[98]57    call    StartDetectionWithDriveSelectByteInBHandStringInAX
[3]58    pop     cx
[175]59.done: 
[3]60    ret
61
[175]62       
[3]63;--------------------------------------------------------------------
[98]64; StartDetectionWithDriveSelectByteInBHandStringInAX
[3]65;   Parameters:
[98]66;       AX:     Offset to "Master" or "Slave" string
[3]67;       BH:     Drive Select byte for Drive and Head Register
68;       CS:BP:  Ptr to IDEVARS for the drive
69;       DS:     RAMVARS segment
70;       ES:     Zero (BDA segment)
71;   Returns:
[98]72;       Nothing
[3]73;   Corrupts registers:
[98]74;       AX, BX, CX, DX, SI, DI
[3]75;--------------------------------------------------------------------
[98]76StartDetectionWithDriveSelectByteInBHandStringInAX:
77    call    DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP
[120]78    ; Fall to .ReadAtaInfoFromHardDisk
[3]79
80;--------------------------------------------------------------------
[120]81; .ReadAtaInfoFromHardDisk
[3]82;   Parameters:
83;       BH:     Drive Select byte for Drive and Head Register
84;       CS:BP:  Ptr to IDEVARS for the drive
85;       DS:     RAMVARS segment
86;       ES:     Zero (BDA segment)
87;   Returns:
88;       CF:     Cleared if ATA-information read successfully
89;               Set if any error
90;   Corrupts registers:
[150]91;       AX, BL, CX, DX, SI, DI
[3]92;--------------------------------------------------------------------
[120]93.ReadAtaInfoFromHardDisk:
[150]94    mov     si, BOOTVARS.rgbAtaInfo     ; ES:SI now points to ATA info location
95    push    es
96    push    si
97    push    bx
98    call    Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
99    pop     bx
100    pop     si
101    pop     es
[120]102    jnc     SHORT CreateBiosTablesForHardDisk
103    ; Fall to .ReadAtapiInfoFromDrive
[3]104
[120]105.ReadAtapiInfoFromDrive:                ; Not yet implemented
106    ;call   ReadAtapiInfoFromDrive      ; Assume CD-ROM
107    ;jnc    SHORT _CreateBiosTablesForCDROM
108    jmp     DetectPrint_DriveNotFound
[3]109
[120]110
[3]111;--------------------------------------------------------------------
[98]112; CreateBiosTablesForHardDisk
[3]113;   Parameters:
114;       BH:     Drive Select byte for Drive and Head Register
115;       CS:BP:  Ptr to IDEVARS for the drive
[150]116;       ES:SI   Ptr to ATA information for the drive
[3]117;       DS:     RAMVARS segment
[98]118;       ES:     BDA/Bootnfo segment
[3]119;   Returns:
[98]120;       Nothing
[3]121;   Corrupts registers:
[98]122;       AX, BX, CX, DX, SI, DI
[3]123;--------------------------------------------------------------------
[98]124CreateBiosTablesForHardDisk:
[3]125    call    CreateDPT_FromAtaInformation
126    jc      SHORT .InvalidAtaInfo
127    call    BootInfo_CreateForHardDisk
[98]128    jmp     DetectPrint_DriveNameFromBootnfoInESBX
[3]129.InvalidAtaInfo:
[98]130    jmp     DetectPrint_DriveNotFound
Note: See TracBrowser for help on using the repository browser.