[3829] | 1 | ; $Id: dh.asm,v 1.1 2000-07-16 22:18:13 bird Exp $
|
---|
| 2 | ;
|
---|
| 3 | ; Device Helper Router.
|
---|
| 4 | ; Stack Thunker.
|
---|
| 5 | ;
|
---|
| 6 | ; Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
---|
| 7 | ;
|
---|
| 8 | ; Project Odin Software License can be found in LICENSE.TXT
|
---|
| 9 | ;
|
---|
| 10 | .386
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | ;
|
---|
| 14 | ; Include files
|
---|
| 15 | ;
|
---|
| 16 | include devsegdf.inc
|
---|
| 17 | include devhlp.inc
|
---|
| 18 |
|
---|
| 19 |
|
---|
| 20 | ;
|
---|
| 21 | ; Exported symbols
|
---|
| 22 | ;
|
---|
| 23 | public ThunkStack16To32
|
---|
| 24 | public ThunkStack32To16
|
---|
| 25 | public TKSSBase
|
---|
| 26 | public getDHRouterFarPtr
|
---|
| 27 | ;public DHRouter
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 | ;
|
---|
| 31 | ; extrns
|
---|
| 32 | ;
|
---|
| 33 | extrn DOS32ALLOCMEM:PROC
|
---|
| 34 | extrn DOS32FREEMEM:PROC
|
---|
| 35 | extrn DOS16GETINFOSEG:PROC
|
---|
| 36 | extrn _Device_Help:DWORD
|
---|
| 37 | extrn pulTKSSBase32:DWORD
|
---|
| 38 | extrn _TKSSBase16:DWORD
|
---|
| 39 | extrn _R0FlatCS16:WORD
|
---|
| 40 | extrn _R0FlatDS16:WORD
|
---|
| 41 |
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | CODE16 SEGMENT
|
---|
| 46 | ASSUME cs:CODE16, ds:FLAT
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 |
|
---|
| 50 | ;;
|
---|
| 51 | ; Devhelp routiner routine.
|
---|
| 52 | ; @cproto none
|
---|
| 53 | ; @param dl Devhelper routine.
|
---|
| 54 | ; @uses none but the ones returned.
|
---|
| 55 | ; @sketch
|
---|
| 56 | ; @status
|
---|
| 57 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
---|
| 58 | ; @remark
|
---|
| 59 | DHRouter PROC FAR
|
---|
| 60 | ASSUME cs:CODE16, ds:NOTHING, es:NOTHING, ss:NOTHING
|
---|
| 61 | ;
|
---|
| 62 | ; Preserve nearly everything (as a start)
|
---|
| 63 | ;
|
---|
| 64 | push ds
|
---|
| 65 | push es
|
---|
| 66 | push fs
|
---|
| 67 | push gs
|
---|
| 68 | push edi
|
---|
| 69 | push esi
|
---|
| 70 | push ebp
|
---|
| 71 | push edx
|
---|
| 72 | push ecx
|
---|
| 73 | push ebx
|
---|
| 74 |
|
---|
| 75 | cmp dl, DevHlp_VirtToLin
|
---|
| 76 | jne dhr1
|
---|
| 77 | call dh_VirtToLin
|
---|
| 78 | jmp dhr_ret
|
---|
| 79 |
|
---|
| 80 | dhr1:
|
---|
| 81 | cmp dl, DevHlp_VMAlloc
|
---|
| 82 | jne dhr2
|
---|
| 83 | call dh_VMAlloc
|
---|
| 84 | jmp dhr_ret
|
---|
| 85 |
|
---|
| 86 | dhr2:
|
---|
| 87 | cmp dl, DevHlp_VMFree
|
---|
| 88 | jne dhr3
|
---|
| 89 | call dh_VMFree
|
---|
| 90 | jmp dhr_ret
|
---|
| 91 |
|
---|
| 92 | dhr3:
|
---|
| 93 | cmp dl, DevHlp_GetDOSVar
|
---|
| 94 | jne dhr4
|
---|
| 95 | call dh_GetDOSVar
|
---|
| 96 | add sp, 4 ; remove ebx from stack
|
---|
| 97 | jmp dhr_ret_ebx
|
---|
| 98 |
|
---|
| 99 | dhr4:
|
---|
| 100 | cmp dl, DevHlp_VMLock
|
---|
| 101 | jne dhr5
|
---|
| 102 | call dh_VMLock
|
---|
| 103 | jmp dhr_ret
|
---|
| 104 |
|
---|
| 105 | dhr5:
|
---|
| 106 | cmp dl, DevHlp_VMUnlock
|
---|
| 107 | jne dhr6
|
---|
| 108 | call dh_VMUnlock
|
---|
| 109 | jmp dhr_ret
|
---|
| 110 |
|
---|
| 111 | dhr6:
|
---|
| 112 |
|
---|
| 113 | dhr_notimplemented:
|
---|
| 114 | stc
|
---|
| 115 | mov eax, 87 ;ERROR_INVALID_PARAMETER
|
---|
| 116 |
|
---|
| 117 | ;
|
---|
| 118 | ; Restore nearly everything (as a start)
|
---|
| 119 | ;
|
---|
| 120 | dhr_ret:
|
---|
| 121 | pop ebx
|
---|
| 122 | dhr_ret_ebx:
|
---|
| 123 | pop ecx
|
---|
| 124 | pop edx
|
---|
| 125 | pop ebp
|
---|
| 126 | pop esi
|
---|
| 127 | pop edi
|
---|
| 128 | pop gs
|
---|
| 129 | pop fs
|
---|
| 130 | pop es
|
---|
| 131 | pop ds
|
---|
| 132 | ret
|
---|
| 133 | DHRouter ENDP
|
---|
| 134 |
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 | ;;
|
---|
| 140 | ; Converts a virtual (sel:off) address to a linear address.
|
---|
| 141 | ; @cproto none
|
---|
| 142 | ; @param AX Selector
|
---|
| 143 | ; @param ESI Offset
|
---|
| 144 | ; @param DL DevHelp_VirtToLin
|
---|
| 145 | ; @returns Success:
|
---|
| 146 | ; CF clear
|
---|
| 147 | ; EAX Linear address
|
---|
| 148 | ;
|
---|
| 149 | ; Failure:
|
---|
| 150 | ; CF set
|
---|
| 151 | ; EAX Error code.
|
---|
| 152 | ;
|
---|
| 153 | ; @uses eax
|
---|
| 154 | ; @status completely impelemented.
|
---|
| 155 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
---|
| 156 | dh_VirtToLin PROC NEAR
|
---|
| 157 | ASSUME cs:CODE16, ds:NOTHING, es:NOTHING, ss:NOTHING
|
---|
| 158 | shl eax, SEL_FLAT_SHIFT
|
---|
| 159 | and eax, SEL_FLATMASK
|
---|
| 160 | add eax, esi
|
---|
| 161 | vtl_retok:
|
---|
| 162 | clc
|
---|
| 163 | ret
|
---|
| 164 |
|
---|
| 165 | vtl_reterr:
|
---|
| 166 | stc
|
---|
| 167 | ret
|
---|
| 168 | dh_VirtToLin ENDP
|
---|
| 169 |
|
---|
| 170 |
|
---|
| 171 |
|
---|
| 172 |
|
---|
| 173 | ;;
|
---|
| 174 | ; Allocates virtual memory.
|
---|
| 175 | ; @cproto none
|
---|
| 176 | ; @param ECX Amount of memory to allocate.
|
---|
| 177 | ; @param EDI Pointer to DD var containing physical address to be mapped.
|
---|
| 178 | ; -1 if not used.
|
---|
| 179 | ; @param EAX Flags. These flags are supported:
|
---|
| 180 | ; VMDHA_SWAP
|
---|
| 181 | ; VMDHA_USEHIGHMEM
|
---|
| 182 | ; VMDHA_RESERVE
|
---|
| 183 | ; @param DH DevHlp_VMAlloc
|
---|
| 184 | ;
|
---|
| 185 | ; @returns Success:
|
---|
| 186 | ; CF Clear
|
---|
| 187 | ; EAX Linear address of object.
|
---|
| 188 | ;
|
---|
| 189 | ; Failure:
|
---|
| 190 | ; CF Set.
|
---|
| 191 | ; EAX Error code. ERROR_INVALID_PARAMETER.
|
---|
| 192 | ;
|
---|
| 193 | ; @uses edx, ecx, eax
|
---|
| 194 | ; @equiv
|
---|
| 195 | ; @time
|
---|
| 196 | ; @sketch For it into an call to DosAllocMem
|
---|
| 197 | ; @status
|
---|
| 198 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
---|
| 199 | ; @remark
|
---|
| 200 | dh_VMAlloc PROC NEAR
|
---|
| 201 | ASSUME cs:CODE16, ds:NOTHING, es:NOTHING, ss:NOTHING
|
---|
| 202 |
|
---|
| 203 | ; define the flags which are used here
|
---|
| 204 | VMDHA_SWAP EQU 0004h
|
---|
| 205 | VMDHA_RESERVE EQU 0100h
|
---|
| 206 | VMDHA_USEHIGHMEM EQU 0800h
|
---|
| 207 |
|
---|
| 208 | ;
|
---|
| 209 | ; Check input parametes.
|
---|
| 210 | ;
|
---|
| 211 | mov edx, eax
|
---|
| 212 | and edx, NOT (VMDHA_SWAP OR VMDHA_USEHIGHMEM OR VMDHA_RESERVE)
|
---|
| 213 | jnz vma_reterr ; Jump if unsupported flag(s) are set.
|
---|
| 214 | cmp edi, 0ffffffffh ; Check that EDI is -1.
|
---|
| 215 | jne vma_reterr ; Jump if EDI != -1
|
---|
| 216 |
|
---|
| 217 | jmp far ptr FLAT:Thunk32_dh_VMAlloc
|
---|
| 218 | Thunk16_dh_VMAlloc::
|
---|
| 219 | or eax, eax ; Successful return from Dos32AllocMem?
|
---|
| 220 | jnz vma_reterr ; Jump on failure.
|
---|
| 221 | mov eax, edx ; EAX is now 32-bit pointer to the allocated memory.
|
---|
| 222 |
|
---|
| 223 | vma_retok:
|
---|
| 224 | clc
|
---|
| 225 | ret
|
---|
| 226 |
|
---|
| 227 | vma_reterr:
|
---|
| 228 | mov eax, 87 ; ERROR_INVALID_PARAMETER
|
---|
| 229 | stc
|
---|
| 230 | ret
|
---|
| 231 | dh_VMAlloc ENDP
|
---|
| 232 | CODE16 ENDS
|
---|
| 233 |
|
---|
| 234 |
|
---|
| 235 | CODE32 SEGMENT
|
---|
| 236 | Thunk32_dh_VMAlloc::
|
---|
| 237 | ASSUME cs:CODE32, ds:NOTHING, es:NOTHING, ss:NOTHING
|
---|
| 238 | ;
|
---|
| 239 | ; Call Dos32AllocMem to allocate the requested memory.
|
---|
| 240 | ;
|
---|
| 241 | push eax ; Make space for return pointer.
|
---|
| 242 | mov edx, esp ; Take address of return pointer.
|
---|
| 243 | test edx, 0ffff0000h
|
---|
| 244 | jnz vma_stack32 ; Jump if stack is 32-bit
|
---|
| 245 | xor edx, edx
|
---|
| 246 | mov dx, ss ; Make 32-bit pointer to return pointer.
|
---|
| 247 | shl edx, SEL_FLAT_SHIFT
|
---|
| 248 | and edx, SEL_FLATMASK
|
---|
| 249 | mov dx, sp ; EDX is now 32-bit pointer to return pointer.
|
---|
| 250 | vma_stack32:
|
---|
| 251 |
|
---|
| 252 | test eax, VMDHA_RESERVE
|
---|
| 253 | jz vma1
|
---|
| 254 | push 0043h ; Flags: OBJ_TILE | PAG_READ | PAG_WRITE
|
---|
| 255 | jmp vma2
|
---|
| 256 | vma1:
|
---|
| 257 | push 0053h ; Flags: OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE
|
---|
| 258 | vma2:
|
---|
| 259 | push ecx ; Number of bytes to allocate.
|
---|
| 260 | push edx ; Pointer to return pointer.
|
---|
| 261 | call DOS32ALLOCMEM
|
---|
| 262 | add esp, 12
|
---|
| 263 | pop edx ; Pointer to allocated memory if any...
|
---|
| 264 |
|
---|
| 265 | jmp far ptr CODE16:Thunk16_dh_VMAlloc
|
---|
| 266 | CODE32 ENDS
|
---|
| 267 |
|
---|
| 268 |
|
---|
| 269 | CODE16 SEGMENT
|
---|
| 270 | ;;
|
---|
| 271 | ; Frees memory allocated with VMAlloc.
|
---|
| 272 | ; @cproto none
|
---|
| 273 | ; @param EAX Linear address of the memory to be freed.
|
---|
| 274 | ; @returns Success:
|
---|
| 275 | ; CF Clear
|
---|
| 276 | ;
|
---|
| 277 | ; Failure:
|
---|
| 278 | ; CF Set
|
---|
| 279 | ; EAX Errorcode
|
---|
| 280 | ; ERROR_ACCESS_DENIED
|
---|
| 281 | ; ERROR_INVALID_PARAMETER
|
---|
| 282 | ;
|
---|
| 283 | ; @uses eax, ecx, edx
|
---|
| 284 | ; @status completely implemented.
|
---|
| 285 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
---|
| 286 | dh_VMFree PROC NEAR
|
---|
| 287 | ASSUME cs:CODE16, ds:NOTHING, es:NOTHING, ss:NOTHING
|
---|
| 288 | jmp far ptr FLAT:Thunk32_dh_VMFree
|
---|
| 289 | Thunk16_dh_VMFree::
|
---|
| 290 | or eax, eax
|
---|
| 291 | jnz vmf_reterr
|
---|
| 292 |
|
---|
| 293 | vmf_retok:
|
---|
| 294 | clc
|
---|
| 295 | ret
|
---|
| 296 |
|
---|
| 297 | vmf_reterr:
|
---|
| 298 | stc
|
---|
| 299 | ret
|
---|
| 300 | dh_VMFree ENDP
|
---|
| 301 | CODE16 ENDS
|
---|
| 302 |
|
---|
| 303 |
|
---|
| 304 | CODE32 SEGMENT
|
---|
| 305 | ; 32-bit part of the dh_VMFree worker
|
---|
| 306 | Thunk32_dh_VMFree::
|
---|
| 307 | ASSUME cs:CODE32, ds:NOTHING, es:NOTHING, ss:NOTHING
|
---|
| 308 | push eax
|
---|
| 309 | call DOS32FREEMEM
|
---|
| 310 | sub esp, 4
|
---|
| 311 | jmp far ptr CODE16:Thunk16_dh_VMFree
|
---|
| 312 | CODE32 ENDS
|
---|
| 313 |
|
---|
| 314 |
|
---|
| 315 | CODE16 SEGMENT
|
---|
| 316 | ;;
|
---|
| 317 | ; Get addresses of kernel variables.
|
---|
| 318 | ; @cproto none.
|
---|
| 319 | ; @param AL Index.
|
---|
| 320 | ; These indexes are supported:
|
---|
| 321 | ; DHGETDOSV_SYSINFOSEG 1
|
---|
| 322 | ; DHGETDOSV_LOCINFOSEG 2
|
---|
| 323 | ; DHGETDOSV_YIELDFLAG 7
|
---|
| 324 | ; DHGETDOSV_TCYIELDFLAG 8
|
---|
| 325 | ; DHGETDOSV_DOSTABLE 9
|
---|
| 326 | ;
|
---|
| 327 | ;
|
---|
| 328 | ; @param CX VarMember (only index 14 and 16)
|
---|
| 329 | ; @param DL DevHlp_GetDOSVar
|
---|
| 330 | ; @returns Success:
|
---|
| 331 | ; CF Clear
|
---|
| 332 | ; AX:BX Points to the index.
|
---|
| 333 | ;
|
---|
| 334 | ; Failure:
|
---|
| 335 | ; CF Set.
|
---|
| 336 | ;
|
---|
| 337 | ; @uses eax, ebx, ecx, edx
|
---|
| 338 | ; @sketch
|
---|
| 339 | ; @status
|
---|
| 340 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
---|
| 341 | ; @remark
|
---|
| 342 | dh_GetDOSVar PROC NEAR
|
---|
| 343 | ASSUME cs:CODE16, ds:NOTHING, es:NOTHING, ss:NOTHING
|
---|
| 344 | cmp al, 1
|
---|
| 345 | je gdv_12
|
---|
| 346 | cmp al, 2
|
---|
| 347 | je gdv_12
|
---|
| 348 | cmp al, 7
|
---|
| 349 | je gdv_8
|
---|
| 350 | cmp al, 8
|
---|
| 351 | je gdv_8
|
---|
| 352 | cmp al, 9
|
---|
| 353 | je gdv_9
|
---|
| 354 | jmp gdv_reterr
|
---|
| 355 |
|
---|
| 356 | gdv_12:
|
---|
| 357 | push ax
|
---|
| 358 | push ax ; make space for selGIS
|
---|
| 359 | mov ax, sp ; offset selGIS
|
---|
| 360 | push ax ; make space for selLIS
|
---|
| 361 | mov bx, sp ; offset selLIS
|
---|
| 362 | push ss
|
---|
| 363 | push ax ; &selGIS
|
---|
| 364 | push ss
|
---|
| 365 | push bx ; &selLIS
|
---|
| 366 | call far ptr DOS16GETINFOSEG
|
---|
| 367 | pop bx ; selLIS
|
---|
| 368 | pop cx ; selGIS
|
---|
| 369 | pop dx ; index parameter
|
---|
| 370 | or ax, ax ; Did it fail?
|
---|
| 371 | jnz gdv_reterr ; Jump if it failed.
|
---|
| 372 | cmp dx, 1
|
---|
| 373 | je gdv_12_1
|
---|
| 374 | mov bx, cx ; bx <- selGIS
|
---|
| 375 | gdv_12_1:
|
---|
| 376 | xor ax, ax
|
---|
| 377 | jmp gdv_retok
|
---|
| 378 |
|
---|
| 379 | gdv_7:
|
---|
| 380 | mov ebx, offset YieldFlag
|
---|
| 381 | mov ax, seg YieldFlag
|
---|
| 382 | jmp gdv_retok
|
---|
| 383 |
|
---|
| 384 | gdv_8:
|
---|
| 385 | mov ebx, offset TCYieldFlag
|
---|
| 386 | mov ax, seg TCYieldFlag
|
---|
| 387 | jmp gdv_retok
|
---|
| 388 |
|
---|
| 389 | gdv_9:
|
---|
| 390 | mov ebx, offset DosTable
|
---|
| 391 | mov ax, seg DosTable
|
---|
| 392 | jmp gdv_retok
|
---|
| 393 |
|
---|
| 394 | gdv_retok:
|
---|
| 395 | clc
|
---|
| 396 | ret
|
---|
| 397 |
|
---|
| 398 | gdv_reterr:
|
---|
| 399 | stc
|
---|
| 400 | ret
|
---|
| 401 | dh_GetDOSVar ENDP
|
---|
| 402 | CODE16 ENDS
|
---|
| 403 |
|
---|
| 404 |
|
---|
| 405 | DATA16 SEGMENT
|
---|
| 406 | ;; GetDosVar data
|
---|
| 407 | ;
|
---|
| 408 | ; The two YieldFlags
|
---|
| 409 | ;
|
---|
| 410 | YieldFlag db 0
|
---|
| 411 | TCYieldFlag db 0
|
---|
| 412 | DATA16 ENDS
|
---|
| 413 |
|
---|
| 414 |
|
---|
| 415 | DATA32 SEGMENT
|
---|
| 416 | ;
|
---|
| 417 | ; 32-bit flat stack base.
|
---|
| 418 | ;
|
---|
| 419 | TKSSBase dd 0
|
---|
| 420 | DATA32 ENDS
|
---|
| 421 |
|
---|
| 422 | DATA16 SEGMENT
|
---|
| 423 | ASSUME ds:NOTHING, es:NOTHING, ss:NOTHING
|
---|
| 424 | ;
|
---|
| 425 | ; The two dostables.
|
---|
| 426 | ;
|
---|
| 427 | DosTable db 17
|
---|
| 428 | DosTable_fph_HardError dd 0
|
---|
| 429 | DosTable_fph_UCase dd 0
|
---|
| 430 | DosTable_UnknownOrReserved1 dd 0
|
---|
| 431 | DosTable_UnknownOrReserved2 dd 0
|
---|
| 432 | DosTable_UnknownOrReserved3 dd 0
|
---|
| 433 | DosTable_fph_MemMapAlias dd 0
|
---|
| 434 | DosTable_fph_MemUnmapAlias dd 0
|
---|
| 435 | DosTable_fph_GoProtAll dd 0
|
---|
| 436 | DosTable_fph_GoRealAll dd 0
|
---|
| 437 | DosTable_fph_doshlp_RedirDev dd 0
|
---|
| 438 | DosTable_UnknownOrReserved4 dd 0
|
---|
| 439 | DosTable_UnknownOrReserved5 dd 0
|
---|
| 440 | DosTable_fph_SFFromSFN dd 0
|
---|
| 441 | DosTable_fph_SegGetInfo dd 0
|
---|
| 442 | DosTable_fph_AsgCheckDrive dd 0
|
---|
| 443 | DosTable_UnknownOrReserved6 dd 0
|
---|
| 444 | DosTable_UnknownOrReserved7 dd 0
|
---|
| 445 |
|
---|
| 446 | DosTabel2 db 19
|
---|
| 447 | DosTable2_fpErrMap24 dd 0
|
---|
| 448 | DosTable2_fpErrMap24End dd 0
|
---|
| 449 | DosTable2_fpErr_Table_24 dd 0
|
---|
| 450 | DosTable2_fpCDSAddr dd 0
|
---|
| 451 | DosTable2_fpGDT_RDR1 dd 0
|
---|
| 452 | DosTable2_fpInterrupLevel dd 0
|
---|
| 453 | DosTable2_fp_cInDos dd 0
|
---|
| 454 | DosTable2_UnknownOrReserved1 dd 0
|
---|
| 455 | DosTable2_UnknownOrReserved2 dd 0
|
---|
| 456 | DosTable2_R0FlatCS dw seg FLAT:CODE32
|
---|
| 457 | dw 0
|
---|
| 458 | DosTable2_R0FlatDS dw seg FLAT:DATA32
|
---|
| 459 | dw 0
|
---|
| 460 | DosTable2_pTKSSBase dd offset FLAT:DATA32:TKSSBase
|
---|
| 461 | DosTable2_pintSwitchStack dd 0
|
---|
| 462 | DosTable2_pprivatStack dd 0
|
---|
| 463 | DosTable2_fpPhysDiskTablePtr dd 0
|
---|
| 464 | DosTable2_pforceEMHandler dd 0
|
---|
| 465 | DosTable2_pReserveVM dd 0
|
---|
| 466 | DosTable2_p_pgpPageDir dd 0
|
---|
| 467 | DosTable2_UnknownOrReserved3 dd 0
|
---|
| 468 | DATA16 ENDS
|
---|
| 469 |
|
---|
| 470 |
|
---|
| 471 | CODE16 SEGMENT
|
---|
| 472 |
|
---|
| 473 |
|
---|
| 474 | ;;
|
---|
| 475 | ; VMLock stub.
|
---|
| 476 | ; @returns NO_ERROR. (0)
|
---|
| 477 | ; @param ignored.
|
---|
| 478 | ; @uses eax
|
---|
| 479 | ; @status stub.
|
---|
| 480 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
---|
| 481 | dh_VMLock PROC NEAR
|
---|
| 482 | xor eax, eax
|
---|
| 483 | clc
|
---|
| 484 | ret
|
---|
| 485 | dh_VMLock ENDP
|
---|
| 486 |
|
---|
| 487 |
|
---|
| 488 |
|
---|
| 489 | ;;
|
---|
| 490 | ; VMUnlock stub.
|
---|
| 491 | ; @returns NO_ERROR. (0)
|
---|
| 492 | ; @param ignored.
|
---|
| 493 | ; @uses eax
|
---|
| 494 | ; @status stub.
|
---|
| 495 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
---|
| 496 | dh_VMUnlock PROC NEAR
|
---|
| 497 | xor eax, eax
|
---|
| 498 | clc
|
---|
| 499 | ret
|
---|
| 500 | dh_VMUnlock ENDP
|
---|
| 501 |
|
---|
| 502 |
|
---|
| 503 | CODE16 ENDS
|
---|
| 504 |
|
---|
| 505 |
|
---|
| 506 |
|
---|
| 507 |
|
---|
| 508 | CODE32 SEGMENT
|
---|
| 509 | ;;
|
---|
| 510 | ; Initiates the Device_Help function pointer.
|
---|
| 511 | ;
|
---|
| 512 | ; During startup the C library startup routines needs to use the heap.
|
---|
| 513 | ; So the heap has to work before main is able to initiate it. The heap
|
---|
| 514 | ; uses device helpers so they have to be initiated too. So, this init
|
---|
| 515 | ; routine is called during heap init, _rmem_init.
|
---|
| 516 | ;
|
---|
| 517 | ; @cproto void _Optlink dhinit(void)
|
---|
| 518 | ; @returns NO_ERROR.
|
---|
| 519 | ; @param none.
|
---|
| 520 | ; @uses eax
|
---|
| 521 | ; @sketch
|
---|
| 522 | ; @status completly implemented
|
---|
| 523 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
---|
| 524 | ; @remark
|
---|
| 525 | dhinit PROC NEAR
|
---|
| 526 | ASSUME cs:CODE32, ds:FLAT, es:NOTHING, ss:NOTHING
|
---|
| 527 | ;
|
---|
| 528 | ; _Device_Help - d16globl.c
|
---|
| 529 | ;
|
---|
| 530 | if 0 ;done during device init.
|
---|
| 531 | mov ax, seg DHRouter
|
---|
| 532 | shl eax, 16
|
---|
| 533 | mov ax, offset DHRouter
|
---|
| 534 | mov _Device_Help, eax
|
---|
| 535 | endif
|
---|
| 536 |
|
---|
| 537 | ;
|
---|
| 538 | ; pulTKSSBase32
|
---|
| 539 | ; DosTable2_pTKSSBase
|
---|
| 540 | ; DosTable2_R0FlatCS
|
---|
| 541 | ; DosTable2_R0FlatDS
|
---|
| 542 | ;
|
---|
| 543 | mov eax, offset FLAT:TKSSBase
|
---|
| 544 | mov pulTKSSBase32, eax ; We need it as our testing subsystem uses it too.
|
---|
| 545 | if 0 ; not neede any longer
|
---|
| 546 | ;mov DosTable2_pTKSSBase, eax
|
---|
| 547 | ;mov _TKSSBase16, eax
|
---|
| 548 |
|
---|
| 549 | ;xor eax, eax
|
---|
| 550 | ;mov ax, seg FLAT:CODE32
|
---|
| 551 | ;mov DosTable2_R0FlatCS, ax
|
---|
| 552 | ;mov _R0FlatCS16, ax
|
---|
| 553 |
|
---|
| 554 | ;mov ax, seg FLAT:DATA32
|
---|
| 555 | ;mov DosTable2_R0FlatDS, ax
|
---|
| 556 | ;mov _R0FlatDS16, ax
|
---|
| 557 | endif
|
---|
| 558 |
|
---|
| 559 | ;
|
---|
| 560 | ; return NO_ERROR
|
---|
| 561 | ;
|
---|
| 562 | xor eax, eax
|
---|
| 563 | ret
|
---|
| 564 | dhinit ENDP
|
---|
| 565 |
|
---|
| 566 |
|
---|
| 567 | ;;
|
---|
| 568 | ; Gets the a 16-bit far pointer to the DHRouter routine.
|
---|
| 569 | ; @cproto ULONG _Optlink getDHRouterFarPtr(VOID); /* dh.asm */
|
---|
| 570 | ; @returns 16-bit far pointer to the DHRouter routine.
|
---|
| 571 | ; @uses EAX
|
---|
| 572 | ; @status completely implemented.
|
---|
| 573 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
---|
| 574 | ; @remark
|
---|
| 575 | getDHRouterFarPtr PROC NEAR
|
---|
| 576 | ASSUME cs:CODE32, ds:FLAT, es:NOTHING, ss:NOTHING
|
---|
| 577 | mov ax, seg CODE16:DHRouter
|
---|
| 578 | shl eax, 16
|
---|
| 579 | mov ax, offset CODE16:DHRouter
|
---|
| 580 | ret
|
---|
| 581 | getDHRouterFarPtr ENDP
|
---|
| 582 |
|
---|
| 583 |
|
---|
| 584 |
|
---|
| 585 |
|
---|
| 586 |
|
---|
| 587 | ;;
|
---|
| 588 | ; Thunks the stack from 16-bits to 32-bits.
|
---|
| 589 | ; !The stack has to be 16-bits on entry!
|
---|
| 590 | ; @cproto VOID _Optlink ThunkStack16To32(VOID)
|
---|
| 591 | ; @returns void
|
---|
| 592 | ; Stack is 32-bits!
|
---|
| 593 | ; EBP and SS:ESP is thunked
|
---|
| 594 | ;
|
---|
| 595 | ; @uses EAX, EDX
|
---|
| 596 | ; @sketch
|
---|
| 597 | ; @status completly implemented.
|
---|
| 598 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
---|
| 599 | ; @remark RING 3 only.
|
---|
| 600 | ThunkStack16To32 PROC NEAR
|
---|
| 601 | ASSUME cs:CODE32, ds:FLAT, es:NOTHING, ss:NOTHING
|
---|
| 602 | movzx esp, sp ; Make sure high end of esp is zero.
|
---|
| 603 | mov ax, ss ; Find the linary base of the segment addressed by ss.
|
---|
| 604 | shl eax, SEL_FLAT_SHIFT
|
---|
| 605 | and eax, SEL_FLATMASK
|
---|
| 606 | mov ax, sp ; Add the segment offset, which is sp.
|
---|
| 607 | ; eax is now the linear stack address equal to ss:sp.
|
---|
| 608 |
|
---|
| 609 | mov dx, seg FLAT:DATA32 ; ALP bug? Can't: push seg FLAT:DATA32
|
---|
| 610 | ; Have to move it to dx before pushing it.
|
---|
| 611 | push dx ; Make lss quad word: new ss, new esp
|
---|
| 612 | push eax
|
---|
| 613 | lss esp, ss:[esp] ; load new ss and esp values.
|
---|
| 614 |
|
---|
| 615 | ;
|
---|
| 616 | ; Fix ebp
|
---|
| 617 | ; Creates new ebp from high word of esp and low word of ebp.
|
---|
| 618 | ;
|
---|
| 619 | mov eax, esp
|
---|
| 620 | mov ax, bp
|
---|
| 621 | mov ebp, eax
|
---|
| 622 |
|
---|
| 623 | ;
|
---|
| 624 | ; Update TKSSBase
|
---|
| 625 | ;
|
---|
| 626 | push ds
|
---|
| 627 | mov ds, dx
|
---|
| 628 | ASSUME ds:FLAT
|
---|
| 629 | mov TKSSBase, 0
|
---|
| 630 | pop ds
|
---|
| 631 | ret
|
---|
| 632 | ThunkStack16To32 ENDP
|
---|
| 633 |
|
---|
| 634 |
|
---|
| 635 | ;;
|
---|
| 636 | ; Thunks the stack from 32-bits to 16-bits.
|
---|
| 637 | ; !The stack has to be 32-bits on entry!
|
---|
| 638 | ; @cproto VOID _Optlink ThunkStack32To16(VOID)
|
---|
| 639 | ; @returns void
|
---|
| 640 | ; Stack is 16-bits!
|
---|
| 641 | ; EBP and SS:ESP is thunked
|
---|
| 642 | ;
|
---|
| 643 | ; @uses EAX, EDX
|
---|
| 644 | ; @sketch
|
---|
| 645 | ; @status completly implemented.
|
---|
| 646 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
---|
| 647 | ; @remark RING 3 only.
|
---|
| 648 | ThunkStack32To16 PROC NEAR
|
---|
| 649 | ASSUME cs:CODE32, ds:FLAT, es:NOTHING, ss:NOTHING
|
---|
| 650 |
|
---|
| 651 | mov edx, esp ; save esp for later use (setting TKSSBase).
|
---|
| 652 |
|
---|
| 653 | ;
|
---|
| 654 | ; calc LDT selector from linear esp and load new ss:esp.
|
---|
| 655 | ;
|
---|
| 656 | mov eax, esp
|
---|
| 657 | shr eax, SEL_FLAT_SHIFT
|
---|
| 658 | or ax, SEL_LDT_RPL3 ; ax new ss LDT (RING3).
|
---|
| 659 | rol eax, 16
|
---|
| 660 | mov ax, sp
|
---|
| 661 | push eax
|
---|
| 662 | lss sp, dword ptr [esp] ; load ss:sp.
|
---|
| 663 | movzx esp, sp ; Zero upper part of esp.
|
---|
| 664 | ; Stack is now 16 bits
|
---|
| 665 | ;
|
---|
| 666 | ; Fix ebp
|
---|
| 667 | ;
|
---|
| 668 | movzx ebp, bp ; Zero upper part of ebp.
|
---|
| 669 |
|
---|
| 670 | ;
|
---|
| 671 | ; Update TKSSBase
|
---|
| 672 | ;
|
---|
| 673 | push ds
|
---|
| 674 | mov ax, seg FLAT:DATA32
|
---|
| 675 | mov ds, ax
|
---|
| 676 | ASSUME ds:FLAT
|
---|
| 677 | xor dx, dx ; zero lower word of dx to get linear
|
---|
| 678 | ; address of 16-bits stack base
|
---|
| 679 | mov TKSSBase, edx
|
---|
| 680 | pop ds
|
---|
| 681 |
|
---|
| 682 | ret
|
---|
| 683 | ThunkStack32To16 ENDP
|
---|
| 684 |
|
---|
| 685 |
|
---|
| 686 | CODE32 ENDS
|
---|
| 687 |
|
---|
| 688 | end
|
---|
| 689 |
|
---|