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

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

Changes to XTIDE Universal BIOS:

  • Some minor optimizations.
  • Boot menu now displays JR-IDE/ISA bus type (M8).
  • Drive detection now displays ROM segment as JR-IDE/ISA Device address.
File size: 2.9 KB
RevLine 
[117]1; Project name  :   XTIDE Universal BIOS
[3]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:
[148]12;       DL:     Translated Drive number
13;       DS:DI:  Ptr to DPT (in RAMVARS segment)
[150]14;       SS:BP:  Ptr to IDEPACK
15;   Returns with INTPACK:
[3]16;       If succesfull:
[258]17;           AH:     Hard Disk: 3 (Hard disk accessible)
18;                   Floppy:    1 (Floppy disk, without change detection)
[3]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;--------------------------------------------------------------------
26ALIGN JUMP_ALIGN
27AH15h_HandlerForReadDiskDriveSize:
[258]28%ifdef MODULE_SERIAL_FLOPPY
29    mov     cl, 1                                       ; 1 = floppy disk, no change detection
30               
31    test    dl,dl                                       ; DO NOT store the sector count if this is a 
32    jns     .FloppyDrive                                ; floppy disk, some OS's depend on this not 
33                                                        ; happening for floppies in order to boot.
34%endif
35       
[252]36    call    AH15h_GetSectorCountToBXDXAX
[258]37    mov     [bp+IDEPACK.intpack+INTPACK.cx], dx         ; HIWORD to CX
38    xchg    [bp+IDEPACK.intpack+INTPACK.dx], ax         ; LOWORD to DX, AL gets drive number
[3]39
[258]40    xor     ah, ah     
41%ifdef MODULE_SERIAL_FLOPPY             
42    mov     cl, 3                                       ; 3 = Hard Disk Accessible
43.FloppyDrive:
44       
45    call    Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH_ALHasDriveNumber   ; Store success to BDA and CF       
46    mov     BYTE [bp+IDEPACK.intpack+INTPACK.ah], cl
47%else
48    call    Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH    ; Store success to BDA and CF       
49    mov     BYTE [bp+IDEPACK.intpack+INTPACK.ah], 3
50%endif     
51       
[148]52    jmp     Int13h_ReturnFromHandlerWithoutStoringErrorCode
[150]53
54
55;--------------------------------------------------------------------
56; AH15h_GetSectorCountFromForeignDriveToDXAX:
[252]57; AH15h_GetSectorCountToBXDXAX:
[150]58;   Parameters:
[252]59;       DL:     Drive number (AH15h_GetSectorCountFromForeignDriveToDXAX only)
[150]60;       DS:     RAMVARS segment
[252]61;       DS:DI:  Ptr to DPT (AH15h_GetSectorCountToDXAX only)
[150]62;   Returns:
63;       DX:AX:  Total sector count
64;       BX:     Zero
65;   Corrupts registers:
66;       CX
67;--------------------------------------------------------------------
68AH15h_GetSectorCountFromForeignDriveToDXAX:
69    mov     ah, GET_DRIVE_PARAMETERS
70    call    Int13h_CallPreviousInt13hHandler
71    jmp     SHORT ConvertAH08hReturnValuesToSectorCount
72
[252]73AH15h_GetSectorCountToBXDXAX:
[150]74    call    AH8h_GetDriveParameters
75    ; Fall to ConvertAH08hReturnValuesToSectorCount
76
77ConvertAH08hReturnValuesToSectorCount:
[155]78    call    Address_ExtractLCHSparametersFromOldInt13hAddress
[285]79    mov     al, bh      ; AL = Max head number
80    inc     cx          ; Max cylinder number to cylinder count
81    inc     ax          ; Max head number to head count (AH=8h returns max 254 so no overflow to AH)
82    mul     bl          ; AX = Head count * Sectors per track
83    mul     cx          ; DX:AX = Total sector count for AH=0xh transfer functions
84    xor     bx, bx
[150]85    ret
Note: See TracBrowser for help on using the repository browser.