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

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

Additional space optimizations, including making IdleProcessing an option in MENUEVENT. Note the fall-through from one file to another, but that there are assembler checks to ensure the proper linkage is maintained. First version of StringsCompress.pl, a perl script to make StringsCompressed.asm from Strings.asm.

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