source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm @ 369

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

Removed align directives for initalization code and added define for align in boot-time calls to the assembly library (defaulting to 1), resulting in a significant savings for the AT and 386 builds. Fixed a bug with switch command line handling in the serial server. Put in CR characters in licesnse.txt, so that it properly displays on Windows. In the configurator, added default values for user supplied CHS and LBA values, defaulting to values within range when those features are enabled. Updated the copyright message in the configurator as the literal word Copyright is important.

File size: 2.9 KB
Line 
1; Project name  :   XTIDE Universal BIOS
2; Description   :   Int 13h function AH=15h, Read Disk Drive Size.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Int 13h function AH=15h, Read Disk Drive Size.
9;
10; AH15h_HandlerForReadDiskDriveSize
11;   Parameters:
12;       DL:     Translated Drive number
13;       DS:DI:  Ptr to DPT (in RAMVARS segment)
14;       SS:BP:  Ptr to IDEPACK
15;   Returns with INTPACK:
16;       If successful:
17;           AH:     Hard Disk: 3 (Hard disk accessible)
18;                   Floppy:    1 (Floppy disk, without change detection)
19;           CX:DX:  Total number of sectors
20;           CF:     0
21;       If failed:
22;           AH:     0 (Drive not present)
23;           CX:DX:  0
24;           CF:     1
25;--------------------------------------------------------------------
26AH15h_HandlerForReadDiskDriveSize:
27%ifdef MODULE_SERIAL_FLOPPY
28    mov     cl, 1                                       ; 1 = floppy disk, no change detection
29
30    test    dl,dl                                       ; DO NOT store the sector count if this is a
31    jns     .FloppyDrive                                ; floppy disk, some OS's depend on this not
32                                                        ; happening for floppies in order to boot.
33%endif
34
35    call    AH15h_GetSectorCountToBXDXAX
36    mov     [bp+IDEPACK.intpack+INTPACK.cx], dx         ; HIWORD to CX
37    xchg    [bp+IDEPACK.intpack+INTPACK.dx], ax         ; LOWORD to DX, AL gets drive number
38
39    xor     ah, ah
40%ifdef MODULE_SERIAL_FLOPPY
41    mov     cl, 3                                       ; 3 = Hard Disk Accessible
42.FloppyDrive:
43
44    call    Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH_ALHasDriveNumber   ; Store success to BDA and CF
45    mov     [bp+IDEPACK.intpack+INTPACK.ah], cl
46%else
47    call    Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH    ; Store success to BDA and CF
48    mov     BYTE [bp+IDEPACK.intpack+INTPACK.ah], 3
49%endif
50
51    jmp     Int13h_ReturnFromHandlerWithoutStoringErrorCode
52
53
54;--------------------------------------------------------------------
55; AH15h_GetSectorCountFromForeignDriveToDXAX:
56; AH15h_GetSectorCountToBXDXAX:
57;   Parameters:
58;       DL:     Drive number (AH15h_GetSectorCountFromForeignDriveToDXAX only)
59;       DS:     RAMVARS segment
60;       DS:DI:  Ptr to DPT (AH15h_GetSectorCountToDXAX only)
61;   Returns:
62;       DX:AX:  Total sector count
63;       BX:     Zero
64;   Corrupts registers:
65;       CX
66;--------------------------------------------------------------------
67AH15h_GetSectorCountFromForeignDriveToDXAX:
68    mov     ah, GET_DRIVE_PARAMETERS
69    call    Int13h_CallPreviousInt13hHandler
70    jmp     SHORT ConvertAH08hReturnValuesToSectorCount
71
72AH15h_GetSectorCountToBXDXAX:
73    call    AH8h_GetDriveParameters
74    ; Fall to ConvertAH08hReturnValuesToSectorCount
75
76ConvertAH08hReturnValuesToSectorCount:
77    call    Address_ExtractLCHSparametersFromOldInt13hAddress
78    mov     al, bh      ; AL = Max head number
79    inc     cx          ; Max cylinder number to cylinder count
80    inc     ax          ; Max head number to head count (AH=8h returns max 254 so no overflow to AH)
81    mul     bl          ; AX = Head count * Sectors per track
82    mul     cx          ; DX:AX = Total sector count for AH=0xh transfer functions
83    xor     bx, bx
84    ret
Note: See TracBrowser for help on using the repository browser.