diff options
| author | 2024-04-25 21:24:10 +0100 | |
|---|---|---|
| committer | 2024-04-25 22:32:27 +0000 | |
| commit | 2d04cacc5322951f187bb17e017c12920ac8ebe2 (patch) | |
| tree | 80ee017efa878dfd5344b44249e6a241f2a7f6e2 /v4.0/src/DOS/DINFO.ASM | |
| parent | Merge pull request #430 from jpbaltazar/typoptbr (diff) | |
| download | ms-dos-main.tar.gz ms-dos-main.tar.xz ms-dos-main.zip | |
Diffstat (limited to 'v4.0/src/DOS/DINFO.ASM')
| -rw-r--r-- | v4.0/src/DOS/DINFO.ASM | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/v4.0/src/DOS/DINFO.ASM b/v4.0/src/DOS/DINFO.ASM new file mode 100644 index 0000000..10738b1 --- /dev/null +++ b/v4.0/src/DOS/DINFO.ASM | |||
| @@ -0,0 +1,131 @@ | |||
| 1 | ; SCCSID = @(#)dinfo.asm 1.1 85/04/10 | ||
| 2 | ; SCCSID = @(#)dinfo.asm 1.1 85/04/10 | ||
| 3 | TITLE DISK_INFO - Internal Get Disk Info | ||
| 4 | NAME DISK_INFO | ||
| 5 | ; Low level routine for returning disk drive information from a local | ||
| 6 | ; or NET device | ||
| 7 | ; | ||
| 8 | ; DISK_INFO | ||
| 9 | ; | ||
| 10 | ; Modification history: | ||
| 11 | ; | ||
| 12 | ; Created: ARR 30 March 1983 | ||
| 13 | ; | ||
| 14 | |||
| 15 | ; | ||
| 16 | ; get the appropriate segment definitions | ||
| 17 | ; | ||
| 18 | .xlist | ||
| 19 | include dosseg.asm | ||
| 20 | |||
| 21 | CODE SEGMENT BYTE PUBLIC 'CODE' | ||
| 22 | ASSUME SS:DOSGROUP,CS:DOSGROUP | ||
| 23 | |||
| 24 | .xcref | ||
| 25 | INCLUDE DOSSYM.INC | ||
| 26 | INCLUDE DEVSYM.INC | ||
| 27 | .cref | ||
| 28 | .list | ||
| 29 | |||
| 30 | Installed = TRUE | ||
| 31 | |||
| 32 | i_need THISCDS,DWORD | ||
| 33 | i_need CURBUF,DWORD | ||
| 34 | i_need EXTERR_LOCUS,BYTE | ||
| 35 | if debug | ||
| 36 | I_need BugLev,WORD | ||
| 37 | I_need BugTyp,WORD | ||
| 38 | include bugtyp.asm | ||
| 39 | endif | ||
| 40 | |||
| 41 | Break <DISK_INFO -- Get Disk Drive Information> | ||
| 42 | |||
| 43 | ; Inputs: | ||
| 44 | ; [THISCDS] Points to the Macro List Structure of interest | ||
| 45 | ; (It MAY NOT be NUL, error not detected) | ||
| 46 | ; Function: | ||
| 47 | ; Get Interesting Drive Information | ||
| 48 | ; Returns: | ||
| 49 | ; DX = Number of free allocation units | ||
| 50 | ; BX = Total Number of allocation units on disk | ||
| 51 | ; CX = Sector size | ||
| 52 | ; AL = Sectors per allocation unit | ||
| 53 | ; AH = FAT ID BYTE | ||
| 54 | ; Carry set if error (currently user FAILed to I 24) | ||
| 55 | ; Segs except ES preserved, others destroyed | ||
| 56 | |||
| 57 | procedure DISK_INFO,NEAR | ||
| 58 | DOSAssume CS,<DS>,"Disk_Info" | ||
| 59 | ASSUME ES:NOTHING | ||
| 60 | |||
| 61 | Invoke TestNet | ||
| 62 | JNC LOCAL_INFO | ||
| 63 | IF NOT Installed | ||
| 64 | transfer NET_DISK_INFO | ||
| 65 | ELSE | ||
| 66 | MOV AX,(multNET SHL 8) OR 12 | ||
| 67 | INT 2FH | ||
| 68 | return | ||
| 69 | ENDIF | ||
| 70 | |||
| 71 | LOCAL_INFO: | ||
| 72 | MOV [EXTERR_LOCUS],errLOC_Disk | ||
| 73 | EnterCrit critDisk | ||
| 74 | invoke FATREAD_CDS ; perform media check. | ||
| 75 | JC CRIT_LEAVE | ||
| 76 | MOV BX,2 | ||
| 77 | invoke UNPACK ; Get first FAT sector into CURBUF | ||
| 78 | JC CRIT_LEAVE | ||
| 79 | LDS SI,[CURBUF] | ||
| 80 | ASSUME DS:NOTHING | ||
| 81 | MOV AH,[SI].bufinsiz ; get FAT ID BYTE | ||
| 82 | context DS | ||
| 83 | MOV CX,ES:[BP.dpb_max_cluster] | ||
| 84 | ; | ||
| 85 | ; Examine the current free count. If it indicates that we have an invalid | ||
| 86 | ; count, do the expensive calculation. | ||
| 87 | ; | ||
| 88 | MOV DX,ES:[BP.dpb_free_cnt] ; get free count | ||
| 89 | CMP DX,-1 ; is it valid? | ||
| 90 | JZ DoScan | ||
| 91 | ; | ||
| 92 | ; Check to see if it is in a reasonalbe range. If so, trust it and return. | ||
| 93 | ; Otherwise, we need to blast out an internal error message and then recompute | ||
| 94 | ; the count. | ||
| 95 | ; | ||
| 96 | CMP DX,CX ; is it in a reasonable range? | ||
| 97 | JB GotVal ; yes, trust it. | ||
| 98 | fmt TypInt,LevLog,<"Internal error: MaxClus <= FreeClus\n"> | ||
| 99 | DoScan: | ||
| 100 | XOR DX,DX | ||
| 101 | DEC CX | ||
| 102 | SCANFREE: | ||
| 103 | invoke UNPACK | ||
| 104 | JC Crit_Leave | ||
| 105 | JNZ NOTFREECLUS | ||
| 106 | INC DX ; A free one | ||
| 107 | NOTFREECLUS: | ||
| 108 | INC BX ; Next cluster | ||
| 109 | LOOP SCANFREE | ||
| 110 | DEC BX ; BX was next cluster. Convert to | ||
| 111 | ReturnVals: | ||
| 112 | DEC BX ; count | ||
| 113 | MOV AL,ES:[BP.dpb_cluster_mask] | ||
| 114 | INC AL ; Sectors/cluster | ||
| 115 | MOV CX,ES:[BP.dpb_sector_size] ; Bytes/sector | ||
| 116 | MOV ES:[BP.dpb_free_cnt],DX | ||
| 117 | CLC | ||
| 118 | CRIT_LEAVE: | ||
| 119 | LeaveCrit critDisk | ||
| 120 | return | ||
| 121 | ; | ||
| 122 | ; We have correctly computed everything previously. Load up registers for | ||
| 123 | ; return. | ||
| 124 | ; | ||
| 125 | GotVal: MOV BX,CX ; get cluster count | ||
| 126 | JMP ReturnVals | ||
| 127 | |||
| 128 | EndProc DISK_INFO | ||
| 129 | |||
| 130 | CODE ENDS | ||
| 131 | END | ||