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/MSINIT.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/MSINIT.ASM')
| -rw-r--r-- | v4.0/src/DOS/MSINIT.ASM | 667 |
1 files changed, 667 insertions, 0 deletions
diff --git a/v4.0/src/DOS/MSINIT.ASM b/v4.0/src/DOS/MSINIT.ASM new file mode 100644 index 0000000..cbd9eaf --- /dev/null +++ b/v4.0/src/DOS/MSINIT.ASM | |||
| @@ -0,0 +1,667 @@ | |||
| 1 | ; SCCSID = @(#)msinit.asm 1.2 85/07/23 | ||
| 2 | ; TITLE MSINIT.ASM -- MS-DOS INITIALIZATION CODE | ||
| 3 | ; AN000 version 4.0 Jan. 1988 | ||
| 4 | ; AN007 PTM 3957 - fake version for IBMCACHE.COM | ||
| 5 | ; AN008 PTM 4070 - fake version for MS WINDOWS | ||
| 6 | include sysvar.inc | ||
| 7 | include doscntry.inc | ||
| 8 | include fastopen.inc | ||
| 9 | |||
| 10 | I_need DMAAdd,DWORD ; current dma address | ||
| 11 | I_need DPBHead,DWORD ; long pointer to DPB chain | ||
| 12 | I_need SFT_Addr,DWORD ; pointer to open file list | ||
| 13 | I_need NumIO,BYTE ; number of physical drives | ||
| 14 | I_need BuffHead,DWORD ; pointer to buffer chain | ||
| 15 | I_need EndMem,WORD ; first unavailable address in memory | ||
| 16 | I_need CurrentPDB,WORD ; current process ID | ||
| 17 | I_need CreatePDB,BYTE ; TRUE => create a new PDB | ||
| 18 | I_need Arena_Head,WORD ; paragraph address of head of arena | ||
| 19 | I_need sfTabl,BYTE ; internal file table | ||
| 20 | I_need SysInitVar,BYTE ; label for internal structures | ||
| 21 | I_need NulDev,DWORD ; long pointer to device chain | ||
| 22 | I_need BCon,DWORD ; pointer to console device | ||
| 23 | I_need BClock,DWORD ; pointer to clock device | ||
| 24 | I_need CallUnit,BYTE ; unit field in dd packet | ||
| 25 | I_need CallBPB,DWORD ; returned BPB from DD | ||
| 26 | I_need Maxsec,WORD | ||
| 27 | I_need Dskchret,BYTE | ||
| 28 | I_need Devcall,BYTE | ||
| 29 | i_need Header,BYTE | ||
| 30 | I_need JShare,DWORD | ||
| 31 | I_need COUNTRY_CDPG,BYTE ; country info table, DOS 3.3 | ||
| 32 | I_need SysInitTable,BYTE ; sys init table for SYSINIT | ||
| 33 | I_need FastOpenTable,BYTE ; table for FASTOPEN | ||
| 34 | I_need FETCHI_TAG,WORD ; TAG CHECK | ||
| 35 | I_need Special_Entries,WORD ; address of special entries ;AN007; | ||
| 36 | I_need IFS_DOS_CALL,DWORD ; IFS IBMDOS CALL entry ;AN000; | ||
| 37 | I_need HASHINITVAR,WORD ; hash table variables ;AN000; | ||
| 38 | I_need Packet_Temp,WORD ; used for initial Hash table;AN000; | ||
| 39 | I_need BUF_HASH_PTR,DWORD ; used for initial Hash table;AN000; | ||
| 40 | I_need SWAP_ALWAYS_AREA,DWORD ; swap always area addr ;AN000; | ||
| 41 | I_need SWAP_ALWAYS_AREA_LEN,WORD; swap always area length ;AN000; | ||
| 42 | I_need SWAP_IN_DOS,DWORD ; swap in dos area ;AN000; | ||
| 43 | I_need SWAP_IN_DOS_LEN,WORD ; swap in dos area length ;AN000; | ||
| 44 | I_need SWAP_AREA_LEN,WORD ; swap area length ;AN000; | ||
| 45 | I_need SWAP_START,BYTE ; swap start addr ;AN000; | ||
| 46 | I_need SWAP_ALWAYS,BYTE ; swap always addr ;AN000; | ||
| 47 | I_need Hash_Temp,WORD ; temporary Hash table ;AN000; | ||
| 48 | |||
| 49 | CODE SEGMENT BYTE PUBLIC 'CODE' | ||
| 50 | Extrn IRETT:NEAR,INT2F:NEAR,CALL_ENTRY:NEAR,QUIT:NEAR,IFS_DOSCALL:FAR | ||
| 51 | Extrn COMMAND:NEAR,ABSDRD:NEAR,ABSDWRT:NEAR | ||
| 52 | CODE ENDS | ||
| 53 | |||
| 54 | DATA SEGMENT WORD PUBLIC 'DATA' | ||
| 55 | ORG 0 ; reset to beginning of data segment | ||
| 56 | |||
| 57 | Public MSINI001S,MSINI001E | ||
| 58 | MSINI001S label byte | ||
| 59 | INITBLOCK DB 110H DUP(0) ; Allow for segment round up | ||
| 60 | |||
| 61 | INITSP DW ? | ||
| 62 | INITSS DW ? | ||
| 63 | MSINI001E label byte | ||
| 64 | |||
| 65 | ASSUME CS:DOSGROUP,SS:NOTHING | ||
| 66 | |||
| 67 | MOVDPB: | ||
| 68 | DOSAssume CS,<DS,ES>,"MovDPB" | ||
| 69 | ; This section of code is safe from being overwritten by block move | ||
| 70 | MOV SS,CS:[INITSS] | ||
| 71 | MOV SP,CS:[INITSP] | ||
| 72 | REP MOVS BYTE PTR [DI],[SI] | ||
| 73 | CLD | ||
| 74 | MOV WORD PTR ES:[DMAADD+2],DX | ||
| 75 | MOV SI,WORD PTR [DPBHEAD] ; Address of first DPB | ||
| 76 | MOV WORD PTR ES:[DPBHEAD+2],ES | ||
| 77 | MOV WORD PTR ES:[sft_addr+2],ES | ||
| 78 | MOV CL,[NUMIO] ; Number of DPBs | ||
| 79 | XOR CH,CH | ||
| 80 | SETFINDPB: | ||
| 81 | MOV WORD PTR ES:[SI.dpb_next_dpb+2],ES | ||
| 82 | MOV ES:[SI.dpb_first_access],-1 ; Never accessed before | ||
| 83 | ADD SI,DPBSIZ ; Point to next DPB | ||
| 84 | LOOP SETFINDPB | ||
| 85 | SUB SI,DPBSIZ | ||
| 86 | MOV WORD PTR ES:[SI.dpb_next_dpb+2],-1 | ||
| 87 | |||
| 88 | ;; PUSH ES | ||
| 89 | ;; MOV DI,OFFSET DOSGroup:SYSBUF + 0Fh | ||
| 90 | ;; RCR DI,1 | ||
| 91 | ;; SHR DI,1 | ||
| 92 | ;; SHR DI,1 | ||
| 93 | ;; SHR DI,1 | ||
| 94 | ;; MOV AX,ES | ||
| 95 | ;; ADD AX,DI | ||
| 96 | ;; MOV ES,AX | ||
| 97 | ;; ASSUME ES:NOTHING | ||
| 98 | ;; XOR DI,DI | ||
| 99 | |||
| 100 | ; MOV DI,OFFSET DOSGroup:SYSBUF ; Set up one default buffer | ||
| 101 | ; MOV WORD PTR [BUFFHEAD+2],ES | ||
| 102 | ; MOV WORD PTR [BUFFHEAD],DI | ||
| 103 | ;; MOV WORD PTR [Hash_Temp+4],ES ;LB. intitialize one Hash entry ;AN000; | ||
| 104 | ;; MOV WORD PTR [Hash_Temp+2],DI ;LB. ;AN000; | ||
| 105 | ;; MOV WORD PTR [Hash_Temp+6],0 ;LB. dirty count =0 ;AN000; | ||
| 106 | ;; MOV WORD PTR ES:[DI.buf_ID],00FFH | ||
| 107 | ;; MOV WORD PTR ES:[DI.buf_next],DI ;;;1/19/88 | ||
| 108 | ;; MOV WORD PTR ES:[DI.buf_prev],DI ;;;1/19/88 | ||
| 109 | |||
| 110 | ;; POP ES | ||
| 111 | MOV SI,OFFSET DOSGROUP:Version_Fake_Table ;MS.;AN007;move special | ||
| 112 | MOV DI,ES:[Special_Entries] ;MS.;AN007;entries | ||
| 113 | MOV CX,ES:[Temp_Var] ;MS.;AN007; | ||
| 114 | REP MOVSB ;MS.;AN007; | ||
| 115 | |||
| 116 | ASSUME ES:DOSGroup | ||
| 117 | |||
| 118 | PUSH ES | ||
| 119 | INC DX ; Leave enough room for the ARENA | ||
| 120 | MOV SI,EndMem | ||
| 121 | invoke $Dup_PDB | ||
| 122 | ; MOV BYTE PTR [CreatePDB],0FFh ; create jfns and set CurrentPDB | ||
| 123 | ; invoke $CREATE_PROCESS_DATA_BLOCK ; Set up segment | ||
| 124 | ASSUME DS:NOTHING,ES:NOTHING | ||
| 125 | POP ES | ||
| 126 | DOSAssume CS,<ES>,"INIT/CreateProcess" | ||
| 127 | ; | ||
| 128 | ; set up memory arena | ||
| 129 | ;SPECIAL NOTE FOR HIGHMEM VERSION | ||
| 130 | ; At this point a process header has been built where the start of the CONSTANTS | ||
| 131 | ; segment as refed by CS is. From this point until the return below be careful | ||
| 132 | ; about references off of CS. | ||
| 133 | ; | ||
| 134 | MOV AX,[CurrentPDB] | ||
| 135 | MOV ES:[CurrentPDB],AX ; Put it in the REAL location | ||
| 136 | MOV BYTE PTR ES:[CreatePDB],0h ; reset flag in REAL location | ||
| 137 | DEC AX | ||
| 138 | MOV ES:[arena_head],AX | ||
| 139 | PUSH DS | ||
| 140 | MOV DS,AX | ||
| 141 | MOV DS:[arena_signature],arena_signature_end | ||
| 142 | MOV DS:[arena_owner],arena_owner_system | ||
| 143 | SUB AX,ES:[ENDMEM] | ||
| 144 | NEG AX | ||
| 145 | DEC AX | ||
| 146 | MOV DS:[arena_size],AX | ||
| 147 | POP DS | ||
| 148 | |||
| 149 | MOV DI,OFFSET DOSGROUP:sftabl + SFTable ; Point to sft 0 | ||
| 150 | MOV AX,3 | ||
| 151 | STOSW ; Adjust Refcount | ||
| 152 | MOV DI,OFFSET DOSGROUP:SySInitTable | ||
| 153 | |||
| 154 | IF NOT Installed | ||
| 155 | invoke NETWINIT | ||
| 156 | ; ELSE | ||
| 157 | ; invoke NETWINIT | ||
| 158 | ; %OUT Random NETWINIT done at install | ||
| 159 | ENDIF | ||
| 160 | |||
| 161 | procedure XXX,FAR | ||
| 162 | RET | ||
| 163 | EndProc XXX | ||
| 164 | DATA ENDS | ||
| 165 | |||
| 166 | ; the next segment defines a new class that MUST appear last in the link map. | ||
| 167 | ; This defines several important locations for the initialization process that | ||
| 168 | ; must be the first available locations of free memory. | ||
| 169 | |||
| 170 | LAST SEGMENT PARA PUBLIC 'LAST' | ||
| 171 | PUBLIC SYSBUF | ||
| 172 | PUBLIC MEMSTRT | ||
| 173 | |||
| 174 | SYSBUF LABEL WORD | ||
| 175 | ASSUME CS:DOSGROUP,DS:NOTHING,ES:NOTHING,SS:NOTHING | ||
| 176 | |||
| 177 | INITIRET: ; Temp IRET instruction | ||
| 178 | IRET | ||
| 179 | |||
| 180 | entry DOSINIT | ||
| 181 | CLI | ||
| 182 | CLD | ||
| 183 | MOV [ENDMEM],DX | ||
| 184 | MOV [INITSP],SP | ||
| 185 | MOV [INITSS],SS | ||
| 186 | MOV AX,CS | ||
| 187 | MOV SS,AX | ||
| 188 | ASSUME SS:DOSGROUP | ||
| 189 | MOV SP,OFFSET DOSGROUP:INITSTACK | ||
| 190 | MOV WORD PTR [NULDEV+2],DS | ||
| 191 | MOV WORD PTR [NULDEV],SI ; DS:SI Points to CONSOLE Device | ||
| 192 | |||
| 193 | PUSH DS ; Need Crit vector inited to use DEVIOCALL | ||
| 194 | XOR AX,AX | ||
| 195 | MOV DS,AX | ||
| 196 | MOV AX,OFFSET DOSGROUP:INITIRET | ||
| 197 | MOV DS:[addr_int_IBM],AX | ||
| 198 | MOV AX,CS | ||
| 199 | MOV DS:[addr_int_IBM+2],AX | ||
| 200 | POP DS | ||
| 201 | |||
| 202 | CALL CHARINIT | ||
| 203 | PUSH SI ; Save pointer to header | ||
| 204 | PUSH CS | ||
| 205 | POP ES | ||
| 206 | ASSUME ES:DOSGROUP | ||
| 207 | MOV DI,OFFSET DOSGROUP:sftabl + SFTable ; Point to sft 0 | ||
| 208 | MOV AX,3 | ||
| 209 | STOSW ; Refcount | ||
| 210 | DEC AL | ||
| 211 | errnz sf_mode-(sf_ref_count+2) | ||
| 212 | STOSW ; Access rd/wr, compatibility | ||
| 213 | XOR AL,AL | ||
| 214 | errnz sf_attr-(sf_mode+2) | ||
| 215 | STOSB ; attribute | ||
| 216 | MOV AL,devid_device_EOF OR devid_device OR ISCIN OR ISCOUT | ||
| 217 | errnz sf_flags-(sf_attr+1) | ||
| 218 | STOSW ; Flags | ||
| 219 | MOV AX,SI | ||
| 220 | errnz sf_devptr-(sf_flags+2) | ||
| 221 | STOSW ; Device pointer in devptr | ||
| 222 | MOV AX,DS | ||
| 223 | STOSW | ||
| 224 | XOR AX,AX | ||
| 225 | errnz sf_firclus-(sf_devptr+4) | ||
| 226 | STOSW ; firclus | ||
| 227 | errnz sf_time-(sf_firclus+2) | ||
| 228 | STOSW ; time | ||
| 229 | errnz sf_date-(sf_time+2) | ||
| 230 | STOSW ; date | ||
| 231 | DEC AX | ||
| 232 | errnz sf_size-(sf_date+2) | ||
| 233 | STOSW ; size | ||
| 234 | STOSW | ||
| 235 | INC AX | ||
| 236 | errnz sf_position-(sf_size+4) | ||
| 237 | STOSW ; position | ||
| 238 | STOSW | ||
| 239 | ADD DI,sf_name - sf_cluspos ;Point at name | ||
| 240 | ADD SI,SDEVNAME ; Point to name | ||
| 241 | MOV CX,4 | ||
| 242 | REP MOVSW ; Name | ||
| 243 | MOV CL,3 | ||
| 244 | MOV AL," " | ||
| 245 | REP STOSB ; Extension | ||
| 246 | POP SI ; Get back pointer to header | ||
| 247 | OR BYTE PTR [SI.SDEVATT],ISCIN OR ISCOUT | ||
| 248 | MOV WORD PTR [BCON],SI | ||
| 249 | MOV WORD PTR [BCON+2],DS | ||
| 250 | CHAR_INIT_LOOP: | ||
| 251 | LDS SI,DWORD PTR [SI] ; AUX device | ||
| 252 | CALL CHARINIT | ||
| 253 | TEST BYTE PTR [SI.SDEVATT],ISCLOCK | ||
| 254 | JZ CHAR_INIT_LOOP | ||
| 255 | MOV WORD PTR [BCLOCK],SI | ||
| 256 | MOV WORD PTR [BCLOCK+2],DS | ||
| 257 | MOV BP,OFFSET DOSGROUP:MEMSTRT ; ES:BP points to DPB | ||
| 258 | PERDRV: | ||
| 259 | LDS SI,DWORD PTR [SI] ; Next device | ||
| 260 | CMP SI,-1 | ||
| 261 | JZ CONTINIT | ||
| 262 | CALL CHARINIT | ||
| 263 | TEST [SI.SDEVATT],DEVTYP | ||
| 264 | JNZ PERDRV ; Skip any other character devs | ||
| 265 | MOV CL,[CALLUNIT] | ||
| 266 | XOR CH,CH | ||
| 267 | MOV [SI.SDEVNAME],CL ; Number of units in name field | ||
| 268 | MOV DL,[NUMIO] | ||
| 269 | XOR DH,DH | ||
| 270 | ADD [NUMIO],CL | ||
| 271 | PUSH DS | ||
| 272 | PUSH SI | ||
| 273 | LDS BX,[CALLBPB] | ||
| 274 | PERUNIT: | ||
| 275 | MOV SI,[BX] ; DS:SI Points to BPB | ||
| 276 | INC BX | ||
| 277 | INC BX ; On to next BPB | ||
| 278 | MOV ES:[BP.dpb_drive],DL | ||
| 279 | MOV ES:[BP.dpb_UNIT],DH | ||
| 280 | PUSH BX | ||
| 281 | PUSH CX | ||
| 282 | PUSH DX | ||
| 283 | invoke $SETDPB | ||
| 284 | MOV AX,ES:[BP.dpb_sector_size] | ||
| 285 | CMP AX,[MAXSEC] | ||
| 286 | JBE NOTMAX | ||
| 287 | MOV [MAXSEC],AX | ||
| 288 | NOTMAX: | ||
| 289 | |||
| 290 | POP DX | ||
| 291 | POP CX | ||
| 292 | POP BX | ||
| 293 | MOV AX,DS ; Save DS | ||
| 294 | POP SI | ||
| 295 | POP DS | ||
| 296 | MOV WORD PTR ES:[BP.dpb_driver_addr],SI | ||
| 297 | MOV WORD PTR ES:[BP.dpb_driver_addr+2],DS | ||
| 298 | PUSH DS | ||
| 299 | PUSH SI | ||
| 300 | INC DH | ||
| 301 | INC DL | ||
| 302 | MOV DS,AX | ||
| 303 | ADD BP,DPBSIZ | ||
| 304 | LOOP PERUNIT | ||
| 305 | POP SI | ||
| 306 | POP DS | ||
| 307 | JMP PERDRV | ||
| 308 | |||
| 309 | CONTINIT: | ||
| 310 | PUSH CS | ||
| 311 | POP DS | ||
| 312 | ASSUME DS:DOSGROUP | ||
| 313 | ; | ||
| 314 | ; BP has the current offset to the allocated DPBs. Calculate true address of | ||
| 315 | ; buffers, FATs, free space | ||
| 316 | ; | ||
| 317 | MOV DI,BP ; First byte after current DPBs | ||
| 318 | ; | ||
| 319 | ; Compute location of first buffer. If we are to make buffers paragraph | ||
| 320 | ; aligned, change this code to make sure that AX = 0 mod 16 and change the | ||
| 321 | ; setting of the segment address part of BuffHead to make sure that the offset | ||
| 322 | ; is zero. Alternatively, this may be done by making segment LAST paragraph | ||
| 323 | ; aligned. | ||
| 324 | ; | ||
| 325 | ;;; MOV BP,[MAXSEC] ; get size of buffer | ||
| 326 | MOV AX,OFFSET DOSGROUP:SYSBUF | ||
| 327 | ; | ||
| 328 | ; Compute location of DPBs | ||
| 329 | ; | ||
| 330 | ;;; ADD AX,BP ; One I/O buffer | ||
| 331 | ;;; ADD AX,BUFINSIZ | ||
| 332 | MOV WORD PTR [DPBHEAD],AX ; True start of DPBs | ||
| 333 | MOV DX,AX | ||
| 334 | SUB DX,OFFSET DOSGROUP:SYSBUF | ||
| 335 | MOV BP,DX | ||
| 336 | ADD BP,DI ; Allocate buffer space | ||
| 337 | SUB BP,ADJFAC ; True address of free memory | ||
| 338 | PUSH BP | ||
| 339 | MOV DI,OFFSET DOSGROUP:MEMSTRT ; Current start of DPBs | ||
| 340 | ADD DI,dpb_next_dpb ; Point at dpb_next_dpb field | ||
| 341 | MOV CL,[NUMIO] | ||
| 342 | XOR CH,CH | ||
| 343 | TRUEDPBAD: | ||
| 344 | ADD AX,DPBSIZ ; Compute address of next DPB | ||
| 345 | STOSW ; Set the link to next DPB | ||
| 346 | ADD DI,DPBSIZ-2 ; Point at next address | ||
| 347 | LOOP TRUEDPBAD | ||
| 348 | SUB DI,DPBSIZ ; Point at last dpb_next_dpb field | ||
| 349 | MOV AX,-1 | ||
| 350 | STOSW ; End of list | ||
| 351 | |||
| 352 | MOV [Special_Entries],BP ;MS.;AN007 save starting address of Special entries | ||
| 353 | MOV SI,OFFSET DOSGROUP:Version_Fake_Table ;MS.;AN007 | ||
| 354 | MOV DX,SI ;MS.;AN007 | ||
| 355 | XOR AH,AH ;MS.;AN007 | ||
| 356 | NextEntry: ;MS.;AN007 | ||
| 357 | LODSB ;MS.;AN007 get name length | ||
| 358 | OR AL,AL ;MS.;AN007 end of list | ||
| 359 | JZ endlist ;MS.;AN007 yes | ||
| 360 | ADD SI,AX ;MS.;AN007 position to | ||
| 361 | ADD SI,3 ;MS.;AN007 next entry | ||
| 362 | JMP NextEntry ;MS.;AN007 | ||
| 363 | endlist: ;MS.;AN007 | ||
| 364 | SUB SI,DX ;MS.;AN007 | ||
| 365 | MOV [Temp_Var],SI ;MS.;AN007 si = total table length | ||
| 366 | ADD BP,SI ;MS.;AN007 | ||
| 367 | |||
| 368 | |||
| 369 | ADD BP,15 ; True start of free space (round up to segment) | ||
| 370 | RCR BP,1 | ||
| 371 | MOV CL,3 | ||
| 372 | SHR BP,CL ; Number of segments for DOS resources | ||
| 373 | ;;;;;; MOV [IBMDOS_SIZE],BP ;MS. save it for information | ||
| 374 | MOV DX,CS | ||
| 375 | ADD DX,BP ; First free segment | ||
| 376 | MOV BX,0FH | ||
| 377 | MOV CX,[ENDMEM] | ||
| 378 | |||
| 379 | IF HIGHMEM | ||
| 380 | SUB CX,BP | ||
| 381 | MOV BP,CX ; Segment of DOS | ||
| 382 | MOV DX,CS ; Program segment | ||
| 383 | ENDIF | ||
| 384 | |||
| 385 | IF NOT HIGHMEM | ||
| 386 | MOV BP,CS | ||
| 387 | ENDIF | ||
| 388 | |||
| 389 | ; BP has segment of DOS (whether to load high or run in place) | ||
| 390 | ; DX has program segment (whether after DOS or overlaying DOS) | ||
| 391 | ; CX has size of memory in paragraphs (reduced by DOS size if HIGHMEM) | ||
| 392 | MOV [ENDMEM],CX | ||
| 393 | MOV ES,BP | ||
| 394 | ASSUME ES:DOSGROUP | ||
| 395 | |||
| 396 | IF HIGHMEM | ||
| 397 | XOR SI,SI | ||
| 398 | MOV DI,SI | ||
| 399 | MOV CX,OFFSET DOSGROUP:SYSBUF ;# bytes to move | ||
| 400 | SHR CX,1 ;# words to move (carry set if odd) | ||
| 401 | REP MOVSW ; Move DOS to high memory | ||
| 402 | JNC NOTODD | ||
| 403 | MOVSB | ||
| 404 | NOTODD: | ||
| 405 | ENDIF | ||
| 406 | |||
| 407 | MOV WORD PTR ES:[DSKCHRET+3],ES | ||
| 408 | XOR AX,AX | ||
| 409 | MOV DS,AX | ||
| 410 | MOV ES,AX | ||
| 411 | ASSUME DS:NOTHING,ES:NOTHING | ||
| 412 | MOV DI,INTBASE+2 | ||
| 413 | MOV AX,BP ; Final DOS segment to AX | ||
| 414 | |||
| 415 | EXTRN DIVOV:near | ||
| 416 | MOV WORD PTR DS:[0],OFFSET DOSGROUP:DIVOV ; Set default divide trap address | ||
| 417 | MOV DS:[2],AX | ||
| 418 | |||
| 419 | ; Set vectors 20-28 and 2A-3F to point to IRET. | ||
| 420 | |||
| 421 | MOV CX,17 | ||
| 422 | REP STOSW ; Set 9 segments | ||
| 423 | ; Sets segs for INTs 20H-28H | ||
| 424 | ADD DI,6 ; Skip INT 29H vector (FAST CON) as it may | ||
| 425 | ; already be set. | ||
| 426 | MOV CX,43 | ||
| 427 | REP STOSW ; Set 22 segments | ||
| 428 | ; Sets segs for vectors 2AH-3FH | ||
| 429 | |||
| 430 | MOV DI,INTBASE | ||
| 431 | MOV AX,OFFSET DOSGROUP:IRETT | ||
| 432 | MOV CX,9 ; Set 9 offsets (skip 2 between each) | ||
| 433 | ; Sets offsets for INTs 20H-28H | ||
| 434 | |||
| 435 | ISET1: | ||
| 436 | STOSW | ||
| 437 | ADD DI,2 | ||
| 438 | LOOP ISET1 | ||
| 439 | |||
| 440 | ADD DI,4 ; Skip vector 29H | ||
| 441 | |||
| 442 | MOV CX,22 ; Set 22 offsets (skip 2 between each) | ||
| 443 | ; Sets offsets for INTs 2AH-3FH | ||
| 444 | |||
| 445 | ISET2: | ||
| 446 | STOSW | ||
| 447 | ADD DI,2 | ||
| 448 | LOOP ISET2 | ||
| 449 | |||
| 450 | MOV AX,BP ; Final DOS segment to AX | ||
| 451 | |||
| 452 | IF installed | ||
| 453 | ; the following two are in the Code segment, thus the CS | ||
| 454 | ; overrides | ||
| 455 | MOV WORD PTR DS:[02FH * 4],OFFSET DOSGROUP:INT2F | ||
| 456 | ENDIF | ||
| 457 | |||
| 458 | ; Set up entry point call at vectors 30-31H | ||
| 459 | MOV BYTE PTR DS:[ENTRYPOINT],mi_Long_JMP | ||
| 460 | MOV WORD PTR DS:[ENTRYPOINT+1],OFFSET DOSGROUP:CALL_ENTRY | ||
| 461 | MOV WORD PTR DS:[ENTRYPOINT+3],AX | ||
| 462 | |||
| 463 | IF ALTVECT | ||
| 464 | MOV DI,ALTBASE+2 | ||
| 465 | MOV CX,15 | ||
| 466 | REP STOSW ; Set 8 segments (skip 2 between each) | ||
| 467 | ENDIF | ||
| 468 | |||
| 469 | MOV WORD PTR DS:[addr_int_abort],OFFSET DOSGROUP:QUIT | ||
| 470 | MOV WORD PTR DS:[addr_int_command],OFFSET DOSGROUP:COMMAND | ||
| 471 | MOV WORD PTR DS:[addr_int_terminate],100H | ||
| 472 | MOV WORD PTR DS:[addr_int_terminate+2],DX | ||
| 473 | MOV WORD PTR DS:[addr_int_disk_read],OFFSET DOSGROUP:ABSDRD ; INT 25 | ||
| 474 | MOV WORD PTR DS:[addr_int_disk_write],OFFSET DOSGROUP:ABSDWRT ; INT 26 | ||
| 475 | EXTRN Stay_resident:NEAR | ||
| 476 | MOV WORD PTR DS:[addr_int_keep_process],OFFSET DOSGROUP:Stay_resident | ||
| 477 | |||
| 478 | PUSH CS | ||
| 479 | POP DS | ||
| 480 | PUSH CS | ||
| 481 | POP ES | ||
| 482 | ASSUME DS:DOSGROUP,ES:DOSGROUP | ||
| 483 | ; | ||
| 484 | ; Initialize the jump table for the sharer... | ||
| 485 | ; | ||
| 486 | MOV DI,OFFSET DOSGroup:JShare | ||
| 487 | MOV AX,CS | ||
| 488 | MOV CX,15 | ||
| 489 | JumpTabLoop: | ||
| 490 | ADD DI,2 ; skip offset | ||
| 491 | STOSW ; drop in segment | ||
| 492 | LOOP JumpTabLoop | ||
| 493 | |||
| 494 | MOV AX,OFFSET DOSGROUP:INITBLOCK | ||
| 495 | ADD AX,0Fh ; round to a paragraph | ||
| 496 | MOV CL,4 | ||
| 497 | SHR AX,CL | ||
| 498 | MOV DI,DS | ||
| 499 | ADD DI,AX | ||
| 500 | INC DI | ||
| 501 | MOV [CurrentPDB],DI | ||
| 502 | PUSH BP | ||
| 503 | PUSH DX ; Save COMMAND address | ||
| 504 | MOV AX,[ENDMEM] | ||
| 505 | MOV DX,DI | ||
| 506 | |||
| 507 | invoke SETMEM ; Basic Header | ||
| 508 | ASSUME DS:NOTHING,ES:NOTHING | ||
| 509 | PUSH CS | ||
| 510 | POP DS | ||
| 511 | ASSUME DS:DOSGROUP | ||
| 512 | MOV DI,PDB_JFN_Table | ||
| 513 | XOR AX,AX | ||
| 514 | STOSW | ||
| 515 | STOSB ; 0,1 and 2 are CON device | ||
| 516 | MOV AL,0FFH | ||
| 517 | MOV CX,FilPerProc - 3 | ||
| 518 | REP STOSB ; Rest are unused | ||
| 519 | PUSH CS | ||
| 520 | POP ES | ||
| 521 | ASSUME ES:DOSGROUP | ||
| 522 | MOV WORD PTR [sft_addr+2],DS ; Must be set to print messages | ||
| 523 | |||
| 524 | ; After this points the char device functions for CON will work for | ||
| 525 | ; printing messages | ||
| 526 | |||
| 527 | IF (NOT IBM) OR (DEBUG) | ||
| 528 | IF NOT ALTVECT | ||
| 529 | MOV SI,OFFSET DOSGROUP:HEADER | ||
| 530 | OUTMES: | ||
| 531 | LODS CS:BYTE PTR [SI] | ||
| 532 | CMP AL,"$" | ||
| 533 | JZ OUTDONE | ||
| 534 | invoke OUT | ||
| 535 | JMP SHORT OUTMES | ||
| 536 | OUTDONE: | ||
| 537 | PUSH CS ; OUT stomps on segments | ||
| 538 | POP DS | ||
| 539 | PUSH CS | ||
| 540 | POP ES | ||
| 541 | ENDIF | ||
| 542 | ENDIF | ||
| 543 | |||
| 544 | ;F.C Modification start DOS 3.3 | ||
| 545 | MOV SI,OFFSET DOSGROUP:COUNTRY_CDPG ;F.C. for DOS 3.3 country info | ||
| 546 | ; table address | ||
| 547 | MOV WORD PTR ES:[SI.ccUcase_ptr + 2],ES ; initialize double word | ||
| 548 | MOV WORD PTR ES:[SI.ccFileUcase_ptr + 2],ES ; pointers with DOSGROUP | ||
| 549 | MOV WORD PTR ES:[SI.ccFileChar_ptr + 2],ES | ||
| 550 | MOV WORD PTR ES:[SI.ccCollate_ptr + 2],ES | ||
| 551 | MOV WORD PTR ES:[SI.ccMono_ptr + 2],ES | ||
| 552 | MOV WORD PTR ES:[SI.ccDBCS_ptr + 2],ES ; 2/16/KK | ||
| 553 | |||
| 554 | MOV SI,OFFSET DOSGROUP:SysInitTable | ||
| 555 | MOV WORD PTR ES:[SI.SYSI_Country_Tab + 2],ES | ||
| 556 | MOV WORD PTR ES:[SI.SYSI_InitVars + 2],ES | ||
| 557 | |||
| 558 | MOV WORD PTR ES:[BUFFHEAD+2],ES ;LB. DOS 4.00 buffer head pointer ;AN000; | ||
| 559 | MOV SI,OFFSET DOSGROUP:HASHINITVAR ;LB. points to Hashinitvar ;AN000; | ||
| 560 | MOV WORD PTR ES:[BUFFHEAD],SI ;LB. ;AN000; | ||
| 561 | MOV WORD PTR ES:[BUF_HASH_PTR+2],ES ;LB. ;AN000; | ||
| 562 | MOV SI,OFFSET DOSGROUP:Hash_Temp ;LB. ;AN000; | ||
| 563 | MOV WORD PTR ES:[BUF_HASH_PTR],SI ;LB. ;AN000; | ||
| 564 | |||
| 565 | MOV SI,OFFSET DOSGROUP:FastOpenTable | ||
| 566 | MOV WORD PTR ES:[SI.FASTOPEN_NAME_CACHING + 2],ES | ||
| 567 | MOV ES:[FETCHI_TAG],22642 ; TAG for IBM, | ||
| 568 | ; Fetchi's serial # = 822642 | ||
| 569 | MOV WORD PTR ES:[IFS_DOS_CALL+2],ES ;IFS. ;AN000; | ||
| 570 | MOV SI,OFFSET DOSGROUP:IFS_DOSCALL ;IFS. ;AN000; | ||
| 571 | MOV WORD PTR ES:[IFS_DOS_CALL],SI ;IFS. ;AN000; | ||
| 572 | |||
| 573 | MOV DI,OFFSET DOSGROUP:SWAP_START ;IFS. ;AN000; | ||
| 574 | MOV CX,OFFSET DOSGROUP:SWAP_END ;IFS. ;AN000; | ||
| 575 | MOV DX,OFFSET DOSGroup:Swap_Always ;IFS. ;AN000; | ||
| 576 | MOV BP,CX ;IFS. ;AN000; | ||
| 577 | SUB BP,DI ;IFS. ;AN000; | ||
| 578 | SHR BP,1 ;IFS. div by 2, remainder in carry ;AN000; | ||
| 579 | ADC BP,0 ;IFS. div by 2 + round up ;AN000; | ||
| 580 | SHL BP,1 ;IFS. round up to 2 boundary. ;AN000; | ||
| 581 | MOV ES:[SWAP_AREA_LEN],BP ;IFS. ;AN000; | ||
| 582 | |||
| 583 | SUB CX,DX ;IFS. ;AN000; | ||
| 584 | SUB DX,DI ;IFS. ;AN000; | ||
| 585 | SHR CX,1 ;IFS. div by 2, remainder in carry ;AN000; | ||
| 586 | ADC CX,0 ;IFS. div by 2 + round up ;AN000; | ||
| 587 | SHL CX,1 ;IFS. round up to 2 boundary. ;AN000; | ||
| 588 | MOV ES:[SWAP_IN_DOS_LEN],CX ;IFS. ;AN000; | ||
| 589 | MOV WORD PTR ES:[SWAP_ALWAYS_AREA],DI ;IFS. ;AN000; | ||
| 590 | MOV WORD PTR ES:[SWAP_ALWAYS_AREA+2],ES ;IFS. ;AN000; | ||
| 591 | OR DX,8000H ;IFS. ;AN000; | ||
| 592 | MOV ES:[SWAP_ALWAYS_AREA_LEN],DX ;IFS. ;AN000; | ||
| 593 | MOV DI,OFFSET DOSGroup:Swap_Always ;IFS. ;AN000; | ||
| 594 | MOV WORD PTR ES:[SWAP_IN_DOS],DI ;IFS. ;AN000; | ||
| 595 | MOV WORD PTR ES:[SWAP_IN_DOS+2],ES ;IFS. ;AN000; | ||
| 596 | |||
| 597 | |||
| 598 | |||
| 599 | ;F.C Modification end DOS 3.3 | ||
| 600 | |||
| 601 | ; Move the FATs into position | ||
| 602 | POP DX ; Restore COMMAND address | ||
| 603 | POP BP | ||
| 604 | POP CX ; True address of free memory | ||
| 605 | MOV SI,OFFSET DOSGROUP:MEMSTRT ; Place to move DPBs from | ||
| 606 | MOV DI,WORD PTR [DPBHEAD] ; Place to move DPBs to | ||
| 607 | SUB CX,DI ; Total length of DPBs | ||
| 608 | CMP DI,SI | ||
| 609 | JBE MOVJMP ; Are we moving to higher or lower memory? | ||
| 610 | DEC CX ; Move backwards to higher memory | ||
| 611 | ADD DI,CX | ||
| 612 | ADD SI,CX | ||
| 613 | INC CX | ||
| 614 | STD | ||
| 615 | MOVJMP: | ||
| 616 | MOV ES,BP | ||
| 617 | ASSUME ES:DOSGROUP | ||
| 618 | JMP MOVDPB | ||
| 619 | |||
| 620 | CHARINIT: | ||
| 621 | ASSUME DS:NOTHING,ES:NOTHING | ||
| 622 | ; DS:SI Points to device header | ||
| 623 | MOV [DEVCALL.REQLEN],DINITHL | ||
| 624 | MOV [DEVCALL.REQUNIT],0 | ||
| 625 | MOV [DEVCALL.REQFUNC],DEVINIT | ||
| 626 | MOV [DEVCALL.REQSTAT],0 | ||
| 627 | PUSH ES | ||
| 628 | PUSH BX | ||
| 629 | PUSH AX | ||
| 630 | MOV BX,OFFSET DOSGROUP:DEVCALL | ||
| 631 | PUSH CS | ||
| 632 | POP ES | ||
| 633 | invoke DEVIOCALL2 | ||
| 634 | POP AX | ||
| 635 | POP BX | ||
| 636 | POP ES | ||
| 637 | RET | ||
| 638 | |||
| 639 | Public MSINI002S,MSINI002E | ||
| 640 | MSINI002S label byte | ||
| 641 | |||
| 642 | DB 100H DUP(?) | ||
| 643 | INITSTACK LABEL BYTE | ||
| 644 | DW ? | ||
| 645 | DB "ADD SPECIAL ENTRIES",0 ;AN007 tiltle | ||
| 646 | ;The following entries don't expect version 4.0 | ||
| 647 | ;The entry format: name_length, name, expected version, fake count | ||
| 648 | ;fake_count: ff means the version will be reset when Abort or Exec is encountered | ||
| 649 | ; n means the version will be reset after n DOS version calls are issued | ||
| 650 | ; | ||
| 651 | Version_Fake_Table: ;AN007 starting address for special | ||
| 652 | DB 12,"IBMCACHE.COM",3,40,255 ;AN007 ibmcache 1 | ||
| 653 | DB 12,"IBMCACHE.SYS",3,40,255 ;AN007 ibmcache 2 | ||
| 654 | DB 12,"DXMA0MOD.SYS",3,40,255 ;AN007 lan support 3 | ||
| 655 | DB 10,"WIN200.BIN" ,3,40,4 ;AN008 windows 4 | ||
| 656 | DB 9,"PSCPG.COM" ,3,40,255 ;AN008 vittoria 5 | ||
| 657 | DB 11,"DCJSS02.EXE" ,3,40,255 ;AN008 netview 6 | ||
| 658 | DB 8,"ISAM.EXE" ,3,40,255 ;AN008 basic 7 | ||
| 659 | DB 9,"ISAM2.EXE" ,3,40,255 ;AN008 basic 8 | ||
| 660 | DB 12,"DFIA0MOD.SYS",3,40,255 ;AN008 lan support 9 | ||
| 661 | DB 20 dup(0) ;AN007 | ||
| 662 | |||
| 663 | MEMSTRT LABEL WORD | ||
| 664 | MSINI002E label byte | ||
| 665 | ADJFAC EQU MEMSTRT-SYSBUF | ||
| 666 | |||
| 667 | LAST ENDS | ||