| 1 | ; $Id: kdtDevHelp.asm,v 1.3 2002-10-14 15:17:05 bird Exp $
|
|---|
| 2 | ;
|
|---|
| 3 | ; Device Helper Implmenetation for Ring-3 testing.
|
|---|
| 4 | ;
|
|---|
| 5 | ; Copyright (c) 2000-2002 knut st. osmundsen <bird@anduin.net>
|
|---|
| 6 | ;
|
|---|
| 7 | ;
|
|---|
| 8 | ; This file is part of kKrnlLib.
|
|---|
| 9 | ;
|
|---|
| 10 | ; kKrnlLib is free software; you can redistribute it and/or modify
|
|---|
| 11 | ; it under the terms of the GNU General Public License as published by
|
|---|
| 12 | ; the Free Software Foundation; either version 2 of the License, or
|
|---|
| 13 | ; (at your option) any later version.
|
|---|
| 14 | ;
|
|---|
| 15 | ; kKrnlLib is distributed in the hope that it will be useful,
|
|---|
| 16 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 17 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 18 | ; GNU General Public License for more details.
|
|---|
| 19 | ;
|
|---|
| 20 | ; You should have received a copy of the GNU General Public License
|
|---|
| 21 | ; along with kKrnlLib; if not, write to the Free Software
|
|---|
| 22 | ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 23 | ;
|
|---|
| 24 | ;
|
|---|
| 25 |
|
|---|
| 26 | .386
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 | ;*******************************************************************************
|
|---|
| 30 | ;* Header Files *
|
|---|
| 31 | ;*******************************************************************************
|
|---|
| 32 | include kdtSegDef.inc
|
|---|
| 33 | include devhlp.inc
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 | ;*******************************************************************************
|
|---|
| 37 | ;* Publics *
|
|---|
| 38 | ;*******************************************************************************
|
|---|
| 39 | public kdtDHInit
|
|---|
| 40 | public kdtDHGetRouterFP
|
|---|
| 41 | public kdtStackThunk16To32
|
|---|
| 42 | public kdtStackThunk32To16
|
|---|
| 43 | public TKSSBase
|
|---|
| 44 | public pulTKSSBase32
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 | ;*******************************************************************************
|
|---|
| 48 | ;* External Globals *
|
|---|
| 49 | ;*******************************************************************************
|
|---|
| 50 | extrn DOS32ALLOCMEM:PROC
|
|---|
| 51 | extrn DOS32FREEMEM:PROC
|
|---|
| 52 | extrn DOS16GETINFOSEG:PROC
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 | ;*******************************************************************************
|
|---|
| 56 | ;* Global Variables *
|
|---|
| 57 | ;*******************************************************************************
|
|---|
| 58 | DATA32 segment
|
|---|
| 59 | pulTKSSBase32 dd 0
|
|---|
| 60 | DATA32 ends
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 | CODE16 SEGMENT
|
|---|
| 66 | ASSUME cs:CODE16, ds:FLAT
|
|---|
| 67 |
|
|---|
| 68 | ;
|
|---|
| 69 | ;Jump table (near pointers)
|
|---|
| 70 | ;
|
|---|
| 71 | apfnDHWorkers:
|
|---|
| 72 | dw offset dh_stub ; DevHlp_SchedClock EQU 0 ; 0 Called each timer tick
|
|---|
| 73 | dw offset dh_stub ; DevHlp_DevDone EQU 1 ; 1 Device I/O complete
|
|---|
| 74 | dw offset dh_stub ; DevHlp_Yield EQU 2 ; 2 yield CPU if resched set
|
|---|
| 75 | dw offset dh_stub ; DevHlp_TCYield EQU 3 ; 3 yield to time critical task
|
|---|
| 76 | dw offset dh_stub ; DevHlp_ProcBlock EQU 4 ; 4 Block on event
|
|---|
| 77 | dw offset dh_stub ; DevHlp_ProcRun EQU 5 ; 5 Unblock process
|
|---|
| 78 | dw offset dh_stub ; DevHlp_SemRequest EQU 6 ; 6 claim a semaphore
|
|---|
| 79 | dw offset dh_stub ; DevHlp_SemClear EQU 7 ; 7 release a semaphore
|
|---|
| 80 | dw offset dh_stub ; DevHlp_SemHandle EQU 8 ; 8 obtain a semaphore handle
|
|---|
| 81 | dw offset dh_stub ; DevHlp_PushRequest EQU 9 ; 9 Push the request
|
|---|
| 82 | dw offset dh_stub ; DevHlp_PullRequest EQU 10 ; A Pull next request from Q
|
|---|
| 83 | dw offset dh_stub ; DevHlp_PullParticular EQU 11 ; B Pull a specific request
|
|---|
| 84 | dw offset dh_stub ; DevHlp_SortRequest EQU 12 ; C Push request in sorted order
|
|---|
| 85 | dw offset dh_stub ; DevHlp_AllocReqPacket EQU 13 ; D allocate request packet
|
|---|
| 86 | dw offset dh_stub ; DevHlp_FreeReqPacket EQU 14 ; E free request packet
|
|---|
| 87 | dw offset dh_stub ; DevHlp_QueueInit EQU 15 ; F Init/Clear char queue
|
|---|
| 88 | dw offset dh_stub ; DevHlp_QueueFlush EQU 16 ; 10 flush queue
|
|---|
| 89 | dw offset dh_stub ; DevHlp_QueueWrite EQU 17 ; 11 Put a char in the queue
|
|---|
| 90 | dw offset dh_stub ; DevHlp_QueueRead EQU 18 ; 12 Get a char from the queue
|
|---|
| 91 | dw offset dh_stub ; DevHlp_Lock EQU 19 ; 13 Lock segment
|
|---|
| 92 | dw offset dh_stub ; DevHlp_Unlock EQU 20 ; 14 Unlock segment
|
|---|
| 93 | dw offset dh_stub ; DevHlp_PhysToVirt EQU 21 ; 15 convert physical address to virtual
|
|---|
| 94 | dw offset dh_stub ; DevHlp_VirtToPhys EQU 22 ; 16 convert virtual address to physical
|
|---|
| 95 | dw offset dh_stub ; DevHlp_PhysToUVirt EQU 23 ; 17 convert physical to LDT
|
|---|
| 96 | dw offset dh_stub ; DevHlp_AllocPhys EQU 24 ; 18 allocate physical memory
|
|---|
| 97 | dw offset dh_stub ; DevHlp_FreePhys EQU 25 ; 19 free physical memory
|
|---|
| 98 | dw offset dh_stub ; DevHlp_SetROMVector EQU 26 ; 1A set a ROM service routine vector
|
|---|
| 99 | dw offset dh_stub ; DevHlp_SetIRQ EQU 27 ; 1B set an IRQ interrupt
|
|---|
| 100 | dw offset dh_stub ; DevHlp_UnSetIRQ EQU 28 ; 1C unset an IRQ interrupt
|
|---|
| 101 | dw offset dh_stub ; DevHlp_SetTimer EQU 29 ; 1D set timer request handler
|
|---|
| 102 | dw offset dh_stub ; DevHlp_ResetTimer EQU 30 ; 1E unset timer request handler
|
|---|
| 103 | dw offset dh_stub ; DevHlp_MonitorCreate EQU 31 ; 1F create a monitor
|
|---|
| 104 | dw offset dh_stub ; DevHlp_Register EQU 32 ; 20 install a monitor
|
|---|
| 105 | dw offset dh_stub ; DevHlp_DeRegister EQU 33 ; 21 remove a monitor
|
|---|
| 106 | dw offset dh_stub ; DevHlp_MonWrite EQU 34 ; 22 pass data records to monitor
|
|---|
| 107 | dw offset dh_stub ; DevHlp_MonFlush EQU 35 ; 23 remove all data from stream
|
|---|
| 108 | dw offset dh_GetDOSVar ; DevHlp_GetDOSVar EQU 36 ; 24 Return pointer to DOS variable
|
|---|
| 109 | dw offset dh_stub ; DevHlp_SendEvent EQU 37 ; 25 an event occurred
|
|---|
| 110 | dw offset dh_stub ; DevHlp_ROMCritSection EQU 38 ; 26 ROM Critical Section
|
|---|
| 111 | dw offset dh_stub ; DevHlp_VerifyAccess EQU 39 ; 27 Verify access to memory
|
|---|
| 112 | dw offset dh_stub ; DevHlp_RAS EQU 40 ; 28 Put info in RAS trace buffer
|
|---|
| 113 | dw offset dh_stub ; DevHlp_ABIOSGetParms EQU 41 ; 29 Get ABIOS Calling Parms
|
|---|
| 114 | dw offset dh_stub ; DevHlp_AttachDD EQU 42 ; 2A Attach to a device driver
|
|---|
| 115 | dw offset dh_stub ; DevHlp_InternalError EQU 43 ; 2B Signal an internal error
|
|---|
| 116 | dw offset dh_stub ; DevHlp_ModifyPriority EQU 44 ; 2C Undocumented (used by PM)
|
|---|
| 117 | dw offset dh_stub ; DevHlp_AllocGDTSelector EQU 45 ; 2D Allocate GDT Selectors
|
|---|
| 118 | dw offset dh_stub ; DevHlp_PhysToGDTSelector EQU 46 ; 2E Convert phys addr to GDT sel
|
|---|
| 119 | dw offset dh_stub ; DevHlp_RealToProt EQU 47 ; 2F Change from real to protected mode
|
|---|
| 120 | dw offset dh_stub ; DevHlp_ProtToReal EQU 48 ; 30 Change from protected to real mode
|
|---|
| 121 | dw offset dh_stub ; DevHlp_EOI EQU 49 ; 31 Send EOI to PIC
|
|---|
| 122 | dw offset dh_stub ; DevHlp_UnPhysToVirt EQU 50 ; 32 mark completion of PhysToVirt
|
|---|
| 123 | dw offset dh_stub ; DevHlp_TickCount EQU 51 ; 33 modify timer
|
|---|
| 124 | dw offset dh_stub ; DevHlp_GetLIDEntry EQU 52 ; 34 Obtain Logical ID
|
|---|
| 125 | dw offset dh_stub ; DevHlp_FreeLIDEntry EQU 53 ; 35 Release Logical ID
|
|---|
| 126 | dw offset dh_stub ; DevHlp_ABIOSCall EQU 54 ; 36 Call ABIOS
|
|---|
| 127 | dw offset dh_stub ; DevHlp_ABIOSCommonEntry EQU 55 ; 37 Invoke Common Entry Point
|
|---|
| 128 | dw offset dh_stub ; DevHlp_GetDeviceBlock EQU 56 ; 38 Get ABIOS Device Block
|
|---|
| 129 | dw offset dh_stub ; ; 39 Reserved for Profiling Kernel
|
|---|
| 130 | dw offset dh_stub ; DevHlp_RegisterStackUsage EQU 58 ; 3A Register for stack usage
|
|---|
| 131 | dw offset dh_stub ; DevHlp_LogEntry EQU 59 ; 3B Place data in log buffer
|
|---|
| 132 | dw offset dh_stub ; DevHlp_VideoPause EQU 60 ; 3C Video pause on/off - D607
|
|---|
| 133 | dw offset dh_stub ; DevHlp_Save_Message EQU 61 ; 3D Save msg in SysInit Message Table
|
|---|
| 134 | dw offset dh_stub ; DevHlp_SegRealloc EQU 62 ; 3E Realloc DD protect mode segment
|
|---|
| 135 | dw offset dh_stub ; DevHlp_PutWaitingQueue EQU 63 ; 3F Put I/O request on waiting queue
|
|---|
| 136 | dw offset dh_stub ; DevHlp_GetWaitingQueue EQU 64 ; 40 Get I/O request from waiting queue
|
|---|
| 137 | dw offset dh_stub ; DevHlp_PhysToSys EQU 65 ; 41 Address conversion for the AOX
|
|---|
| 138 | dw offset dh_stub ; DevHlp_PhysToSysHook EQU 66 ; 42 Address conversion for the AOX
|
|---|
| 139 | dw offset dh_stub ; DevHlp_RegisterDeviceClass EQU 67 ; 43 Register DC entry point
|
|---|
| 140 | dw offset dh_stub ; Reserved for 16-bit dhs EQU 68
|
|---|
| 141 | dw offset dh_stub ; Reserved for 16-bit dhs EQU 69
|
|---|
| 142 | dw offset dh_stub ; Reserved for 16-bit dhs EQU 70
|
|---|
| 143 | dw offset dh_stub ; Reserved for 16-bit dhs EQU 71
|
|---|
| 144 | dw offset dh_stub ; Reserved for 16-bit dhs EQU 72
|
|---|
| 145 | dw offset dh_stub ; Reserved for 16-bit dhs EQU 73
|
|---|
| 146 | dw offset dh_stub ; Reserved for 16-bit dhs EQU 74
|
|---|
| 147 | dw offset dh_stub ; Reserved for 16-bit dhs EQU 75
|
|---|
| 148 | dw offset dh_stub ; Reserved for 16-bit dhs EQU 76
|
|---|
| 149 | dw offset dh_stub ; Reserved for 16-bit dhs EQU 77
|
|---|
| 150 | dw offset dh_stub ; Reserved for 16-bit dhs EQU 78
|
|---|
| 151 | dw offset dh_stub ; Reserved for 16-bit dhs EQU 79
|
|---|
| 152 | dw offset dh_stub ; DevHlp_RegisterPDD EQU 80 ; 50 Register PDD entry point with VDM manager for later PDD-VDD communication
|
|---|
| 153 | dw offset dh_stub ; DevHlp_RegisterBeep EQU 81 ; 51 register PTD beep service entry point with kernel
|
|---|
| 154 | dw offset dh_stub ; DevHlp_Beep EQU 82 ; 52 preempt beep service via PTD
|
|---|
| 155 | dw offset dh_stub ; DevHlp_FreeGDTSelector EQU 83 ; 53 Free allocated GDT selector
|
|---|
| 156 | dw offset dh_stub ; DevHlp_PhysToGDTSel EQU 84 ; 54 Convert Phys Addr to GDT sel with given access
|
|---|
| 157 | dw offset dh_VMLock ; DevHlp_VMLock EQU 85 ; 55 Lock linear address range
|
|---|
| 158 | dw offset dh_VMUnlock ; DevHlp_VMUnlock EQU 86 ; 56 Unlock address range
|
|---|
| 159 | dw offset dh_VMAlloc ; DevHlp_VMAlloc EQU 87 ; 56 Allocate memory
|
|---|
| 160 | dw offset dh_VMFree ; DevHlp_VMFree EQU 88 ; 58 Free memory or mapping
|
|---|
| 161 | dw offset dh_stub ; DevHlp_VMProcessToGlobal EQU 89 ; 59 Create global mapping to process memory
|
|---|
| 162 | dw offset dh_stub ; DevHlp_VMGlobalToProcess EQU 90 ; 5A Create process mapping to global memory
|
|---|
| 163 | dw offset dh_VirtToLin ; DevHlp_VirtToLin EQU 91 ; 5B Convert virtual address to linear
|
|---|
| 164 | dw offset dh_stub ; DevHlp_LinToGDTSelector EQU 92 ; 5C Convert linear address to virtual
|
|---|
| 165 | dw offset dh_stub ; DevHlp_GetDescInfo EQU 93 ; 5D Return descriptor information
|
|---|
| 166 | dw offset dh_stub ; DevHlp_LinToPageList EQU 94 ; 5E build pagelist array from lin addr
|
|---|
| 167 | dw offset dh_stub ; DevHlp_PageListToLin EQU 95 ; 5F map page list array to lin addr
|
|---|
| 168 | dw offset dh_stub ; DevHlp_PageListToGDTSelector EQU 96 ; 60 map page list array to GDT sel.
|
|---|
| 169 | dw offset dh_stub ; DevHlp_RegisterTmrDD EQU 97 ; 61 Register TMR Device Driver.
|
|---|
| 170 | dw offset dh_stub ; DevHlp_RegisterPerfCtrs EQU 98 ; 62 Register device driver perf. ctrs (PVW).
|
|---|
| 171 | dw offset dh_stub ; DevHlp_AllocateCtxHook EQU 99 ; 63 Allocate a context hook
|
|---|
| 172 | dw offset dh_stub ; DevHlp_FreeCtxHook EQU 100 ; 64 Free a context hook
|
|---|
| 173 | dw offset dh_stub ; DevHlp_ArmCtxHook EQU 101 ; 65 Arm a context hook
|
|---|
| 174 | dw offset dh_stub ; DevHlp_VMSetMem EQU 102 ; 66H commit/decommit memory
|
|---|
| 175 | dw offset dh_stub ; DevHlp_OpenEventSem EQU 103 ; 67H open an event semaphore
|
|---|
| 176 | dw offset dh_stub ; DevHlp_CloseEventSem EQU 104 ; 68H close an event semaphore
|
|---|
| 177 | dw offset dh_stub ; DevHlp_PostEventSem EQU 105 ; 69H post an event semaphore
|
|---|
| 178 | dw offset dh_stub ; DevHlp_ResetEventSem EQU 106 ; 6AH reset an event semaphore
|
|---|
| 179 | dw offset dh_stub ; DevHlp_RegisterFreq EQU 107 ; 6BH register PTD freq service entry point with kernel
|
|---|
| 180 | dw offset dh_stub ; DevHlp_DynamicAPI EQU 108 ; 6CH add a dynamic API
|
|---|
| 181 | dw offset dh_stub ; DevHlp_ProcRun2 EQU 109 ; 6DH Unblock process via procrun2
|
|---|
| 182 | dw offset dh_stub ; DevHlp_CreateInt13VDM EQU 110 ;6EH Create Int13 VDM (Internal Only) OEMINT13
|
|---|
| 183 | dw offset dh_stub ; DevHlp_RegisterKrnlExit EQU 111 ;6FH Used to capture Kernel Exits F78693
|
|---|
| 184 | dw offset dh_stub ; DevHlp_PMPostEventSem EQU 112 ; 70h PM Post Event Semaphore
|
|---|
| 185 | dw offset dh_stub ; reserved other os2 vers EQU 113 ; 70h PM Post Event Semaphore
|
|---|
| 186 | dw offset dh_stub ; reserved other os2 vers EQU 114 ; 70h PM Post Event Semaphore
|
|---|
| 187 | dw offset dh_stub ; reserved other os2 vers EQU 115 ; 70h PM Post Event Semaphore
|
|---|
| 188 | dw offset dh_stub ; reserved other os2 vers EQU 116 ; 70h PM Post Event Semaphore
|
|---|
| 189 | dw offset dh_stub ; reserved other os2 vers EQU 117 ; 70h PM Post Event Semaphore
|
|---|
| 190 | dw offset dh_stub ; reserved other os2 vers EQU 118 ; 70h PM Post Event Semaphore
|
|---|
| 191 | dw offset dh_stub ; reserved other os2 vers EQU 119 ; 70h PM Post Event Semaphore
|
|---|
| 192 | dw offset dh_stub ; reserved other os2 vers EQU 120 ; 70h PM Post Event Semaphore
|
|---|
| 193 | dw offset dh_stub ; reserved other os2 vers EQU 121 ; 70h PM Post Event Semaphore
|
|---|
| 194 | dw offset dh_stub ; reserved other os2 vers EQU 122 ; 70h PM Post Event Semaphore
|
|---|
| 195 | dw offset dh_stub ; reserved other os2 vers EQU 123 ; 70h PM Post Event Semaphore
|
|---|
| 196 | dw offset dh_stub ; reserved other os2 vers EQU 124 ; 70h PM Post Event Semaphore
|
|---|
| 197 | dw offset dh_stub ; DevHlp_KillProc EQU 125 ;7DH Kill Proc ;@SEC
|
|---|
| 198 | dw offset dh_stub ; DevHlp_QSysState EQU 126 ;7EH Query System State ;@SEC
|
|---|
| 199 | dw offset dh_stub ; DevHlp_OpenFile EQU 127 ; 7FH Ring-0 File system Write
|
|---|
| 200 | dw offset dh_stub ; DevHlp_CloseFile EQU 128 ; 80H Ring-0 File system Seek
|
|---|
| 201 | dw offset dh_stub ; DevHlp_ReadFile EQU 129 ; 81H Ring-0 File system Read
|
|---|
| 202 | dw offset dh_stub ; DevHlp_ReadFileAt EQU 130 ; 82H File system Read at (seek)
|
|---|
| 203 | apfnDHWorkersEnd db 0
|
|---|
| 204 |
|
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 | ;;
|
|---|
| 208 | ; Devhelp routiner routine.
|
|---|
| 209 | ; @cproto none
|
|---|
| 210 | ; @param dl Devhelper routine.
|
|---|
| 211 | ; @uses none but the ones returned.
|
|---|
| 212 | ; @sketch
|
|---|
| 213 | ; @status
|
|---|
| 214 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
|---|
| 215 | ; @remark
|
|---|
| 216 | DHRouter PROC FAR
|
|---|
| 217 | ASSUME cs:CODE16, ds:NOTHING, es:NOTHING, ss:NOTHING
|
|---|
| 218 | if 0
|
|---|
| 219 | cmp dl, 130
|
|---|
| 220 | jle dhr_ok
|
|---|
| 221 | mov eax, 87
|
|---|
| 222 | stc
|
|---|
| 223 |
|
|---|
| 224 | dhr_ok:
|
|---|
| 225 | ;
|
|---|
| 226 | ; Preserve nearly everything (as a start)
|
|---|
| 227 | ;
|
|---|
| 228 | push ds
|
|---|
| 229 | push es
|
|---|
| 230 | push fs
|
|---|
| 231 | push gs
|
|---|
| 232 | push edi
|
|---|
| 233 | push esi
|
|---|
| 234 | push ebp
|
|---|
| 235 | push edx
|
|---|
| 236 | push ecx
|
|---|
| 237 | push ebp
|
|---|
| 238 |
|
|---|
| 239 | push dx
|
|---|
| 240 | mov ebp, esp
|
|---|
| 241 | and word ptr ss:[ebp], 00ffh
|
|---|
| 242 | shl word ptr ss:[ebp], 1
|
|---|
| 243 | add word ptr ss:[ebp], offset CODE16:apfnDHWorkers
|
|---|
| 244 | call word ptr ss:[ebp]
|
|---|
| 245 | add esp, 2
|
|---|
| 246 |
|
|---|
| 247 | ;
|
|---|
| 248 | ; Restore nearly everything (as a start)
|
|---|
| 249 | ;
|
|---|
| 250 | pop ebp
|
|---|
| 251 | pop ecx
|
|---|
| 252 | pop edx
|
|---|
| 253 | pop ebp
|
|---|
| 254 | pop esi
|
|---|
| 255 | pop edi
|
|---|
| 256 | pop gs
|
|---|
| 257 | pop fs
|
|---|
| 258 | pop es
|
|---|
| 259 | pop ds
|
|---|
| 260 | ret
|
|---|
| 261 | else
|
|---|
| 262 | ;
|
|---|
| 263 | ; Preserve nearly everything (as a start)
|
|---|
| 264 | ;
|
|---|
| 265 | push ds
|
|---|
| 266 | push es
|
|---|
| 267 | push fs
|
|---|
| 268 | push gs
|
|---|
| 269 | push edi
|
|---|
| 270 | push esi
|
|---|
| 271 | push ebp
|
|---|
| 272 | push edx
|
|---|
| 273 | push ecx
|
|---|
| 274 |
|
|---|
| 275 | push ebx
|
|---|
| 276 | cmp dl, DevHlp_VirtToLin
|
|---|
| 277 | jne dhr1
|
|---|
| 278 | call dh_VirtToLin
|
|---|
| 279 | jmp dhr_ret
|
|---|
| 280 |
|
|---|
| 281 | dhr1:
|
|---|
| 282 | cmp dl, DevHlp_VMAlloc
|
|---|
| 283 | jne dhr2
|
|---|
| 284 | call dh_VMAlloc
|
|---|
| 285 | jmp dhr_ret
|
|---|
| 286 |
|
|---|
| 287 | dhr2:
|
|---|
| 288 | cmp dl, DevHlp_VMFree
|
|---|
| 289 | jne dhr3
|
|---|
| 290 | call dh_VMFree
|
|---|
| 291 | jmp dhr_ret
|
|---|
| 292 |
|
|---|
| 293 | dhr3:
|
|---|
| 294 | cmp dl, DevHlp_GetDOSVar
|
|---|
| 295 | jne dhr4
|
|---|
| 296 | call dh_GetDOSVar
|
|---|
| 297 | add sp, 4 ; remove ebx from stack
|
|---|
| 298 | jmp dhr_ret_ebx
|
|---|
| 299 |
|
|---|
| 300 | dhr4:
|
|---|
| 301 | cmp dl, DevHlp_VMLock
|
|---|
| 302 | jne dhr5
|
|---|
| 303 | call dh_VMLock
|
|---|
| 304 | jmp dhr_ret
|
|---|
| 305 |
|
|---|
| 306 | dhr5:
|
|---|
| 307 | cmp dl, DevHlp_VMUnlock
|
|---|
| 308 | jne dhr6
|
|---|
| 309 | call dh_VMUnlock
|
|---|
| 310 | jmp dhr_ret
|
|---|
| 311 |
|
|---|
| 312 | dhr6:
|
|---|
| 313 |
|
|---|
| 314 | dhr_notimplemented:
|
|---|
| 315 | stc
|
|---|
| 316 | mov eax, 87 ;ERROR_INVALID_PARAMETER
|
|---|
| 317 |
|
|---|
| 318 | ;
|
|---|
| 319 | ; Restore nearly everything (as a start)
|
|---|
| 320 | ;
|
|---|
| 321 | dhr_ret:
|
|---|
| 322 | pop ebx
|
|---|
| 323 | dhr_ret_ebx:
|
|---|
| 324 | pop ecx
|
|---|
| 325 | pop edx
|
|---|
| 326 | pop ebp
|
|---|
| 327 | pop esi
|
|---|
| 328 | pop edi
|
|---|
| 329 | pop gs
|
|---|
| 330 | pop fs
|
|---|
| 331 | pop es
|
|---|
| 332 | pop ds
|
|---|
| 333 | ret
|
|---|
| 334 | endif
|
|---|
| 335 | DHRouter ENDP
|
|---|
| 336 |
|
|---|
| 337 |
|
|---|
| 338 | dh_printf proc near
|
|---|
| 339 |
|
|---|
| 340 | dh_printf endp
|
|---|
| 341 |
|
|---|
| 342 |
|
|---|
| 343 |
|
|---|
| 344 | ;;
|
|---|
| 345 | ; Stub function which gets called when we encounter an unimplemented
|
|---|
| 346 | ; devhelper.
|
|---|
| 347 | ;
|
|---|
| 348 | ; @returns eax=87 cf
|
|---|
| 349 | ;
|
|---|
| 350 | dh_stub proc near
|
|---|
| 351 | ; DPRINTF<"dh_stub: %c"
|
|---|
| 352 | ; todo - write debug info.
|
|---|
| 353 | int 3
|
|---|
| 354 | mov eax, 87
|
|---|
| 355 | stc
|
|---|
| 356 | ret
|
|---|
| 357 | dh_stub endp
|
|---|
| 358 |
|
|---|
| 359 |
|
|---|
| 360 |
|
|---|
| 361 |
|
|---|
| 362 | ;;
|
|---|
| 363 | ; Converts a virtual (sel:off) address to a linear address.
|
|---|
| 364 | ; @cproto none
|
|---|
| 365 | ; @param AX Selector
|
|---|
| 366 | ; @param ESI Offset
|
|---|
| 367 | ; @param DL DevHelp_VirtToLin
|
|---|
| 368 | ; @returns Success:
|
|---|
| 369 | ; CF clear
|
|---|
| 370 | ; EAX Linear address
|
|---|
| 371 | ;
|
|---|
| 372 | ; Failure:
|
|---|
| 373 | ; CF set
|
|---|
| 374 | ; EAX Error code.
|
|---|
| 375 | ;
|
|---|
| 376 | ; @uses eax
|
|---|
| 377 | ; @status completely impelemented.
|
|---|
| 378 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
|---|
| 379 | dh_VirtToLin PROC NEAR
|
|---|
| 380 | ASSUME cs:CODE16, ds:NOTHING, es:NOTHING, ss:NOTHING
|
|---|
| 381 | shl eax, SEL_FLAT_SHIFT
|
|---|
| 382 | and eax, SEL_FLATMASK
|
|---|
| 383 | add eax, esi
|
|---|
| 384 | vtl_retok:
|
|---|
| 385 | clc
|
|---|
| 386 | ret
|
|---|
| 387 |
|
|---|
| 388 | vtl_reterr:
|
|---|
| 389 | stc
|
|---|
| 390 | ret
|
|---|
| 391 | dh_VirtToLin ENDP
|
|---|
| 392 |
|
|---|
| 393 |
|
|---|
| 394 |
|
|---|
| 395 |
|
|---|
| 396 | ;;
|
|---|
| 397 | ; Allocates virtual memory.
|
|---|
| 398 | ; @cproto none
|
|---|
| 399 | ; @param ECX Amount of memory to allocate.
|
|---|
| 400 | ; @param EDI Pointer to DD var containing physical address to be mapped.
|
|---|
| 401 | ; -1 if not used.
|
|---|
| 402 | ; @param EAX Flags. These flags are supported:
|
|---|
| 403 | ; VMDHA_SWAP
|
|---|
| 404 | ; VMDHA_USEHIGHMEM
|
|---|
| 405 | ; VMDHA_RESERVE
|
|---|
| 406 | ; @param DH DevHlp_VMAlloc
|
|---|
| 407 | ;
|
|---|
| 408 | ; @returns Success:
|
|---|
| 409 | ; CF Clear
|
|---|
| 410 | ; EAX Linear address of object.
|
|---|
| 411 | ;
|
|---|
| 412 | ; Failure:
|
|---|
| 413 | ; CF Set.
|
|---|
| 414 | ; EAX Error code. ERROR_INVALID_PARAMETER.
|
|---|
| 415 | ;
|
|---|
| 416 | ; @uses edx, ecx, eax
|
|---|
| 417 | ; @equiv
|
|---|
| 418 | ; @time
|
|---|
| 419 | ; @sketch For it into an call to DosAllocMem
|
|---|
| 420 | ; @status
|
|---|
| 421 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
|---|
| 422 | ; @remark
|
|---|
| 423 | dh_VMAlloc PROC NEAR
|
|---|
| 424 | ASSUME cs:CODE16, ds:NOTHING, es:NOTHING, ss:NOTHING
|
|---|
| 425 |
|
|---|
| 426 | ; define the flags which are used here
|
|---|
| 427 | VMDHA_SWAP EQU 0004h
|
|---|
| 428 | VMDHA_RESERVE EQU 0100h
|
|---|
| 429 | VMDHA_USEHIGHMEM EQU 0800h
|
|---|
| 430 |
|
|---|
| 431 | ;
|
|---|
| 432 | ; Check input parametes.
|
|---|
| 433 | ;
|
|---|
| 434 | mov edx, eax
|
|---|
| 435 | and edx, NOT (VMDHA_SWAP OR VMDHA_USEHIGHMEM OR VMDHA_RESERVE)
|
|---|
| 436 | jnz vma_reterr ; Jump if unsupported flag(s) are set.
|
|---|
| 437 | cmp edi, 0ffffffffh ; Check that EDI is -1.
|
|---|
| 438 | jne vma_reterr ; Jump if EDI != -1
|
|---|
| 439 |
|
|---|
| 440 | jmp far ptr FLAT:Thunk32_dh_VMAlloc
|
|---|
| 441 | Thunk16_dh_VMAlloc::
|
|---|
| 442 | or eax, eax ; Successful return from Dos32AllocMem?
|
|---|
| 443 | jnz vma_reterr ; Jump on failure.
|
|---|
| 444 | mov eax, edx ; EAX is now 32-bit pointer to the allocated memory.
|
|---|
| 445 |
|
|---|
| 446 | vma_retok:
|
|---|
| 447 | clc
|
|---|
| 448 | ret
|
|---|
| 449 |
|
|---|
| 450 | vma_reterr:
|
|---|
| 451 | mov eax, 87 ; ERROR_INVALID_PARAMETER
|
|---|
| 452 | stc
|
|---|
| 453 | ret
|
|---|
| 454 | dh_VMAlloc ENDP
|
|---|
| 455 | CODE16 ENDS
|
|---|
| 456 |
|
|---|
| 457 |
|
|---|
| 458 | CODE32 SEGMENT
|
|---|
| 459 | Thunk32_dh_VMAlloc::
|
|---|
| 460 | ASSUME cs:CODE32, ds:NOTHING, es:NOTHING, ss:NOTHING
|
|---|
| 461 | ;
|
|---|
| 462 | ; Call Dos32AllocMem to allocate the requested memory.
|
|---|
| 463 | ;
|
|---|
| 464 | push eax ; Make space for return pointer.
|
|---|
| 465 | mov edx, esp ; Take address of return pointer.
|
|---|
| 466 | test edx, 0ffff0000h
|
|---|
| 467 | jnz vma_stack32 ; Jump if stack is 32-bit
|
|---|
| 468 | xor edx, edx
|
|---|
| 469 | mov dx, ss ; Make 32-bit pointer to return pointer.
|
|---|
| 470 | shl edx, SEL_FLAT_SHIFT
|
|---|
| 471 | and edx, SEL_FLATMASK
|
|---|
| 472 | mov dx, sp ; EDX is now 32-bit pointer to return pointer.
|
|---|
| 473 | vma_stack32:
|
|---|
| 474 |
|
|---|
| 475 | test eax, VMDHA_RESERVE
|
|---|
| 476 | jz vma1
|
|---|
| 477 | push 0043h ; Flags: OBJ_TILE | PAG_READ | PAG_WRITE
|
|---|
| 478 | jmp vma2
|
|---|
| 479 | vma1:
|
|---|
| 480 | push 0053h ; Flags: OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE
|
|---|
| 481 | vma2:
|
|---|
| 482 | push ecx ; Number of bytes to allocate.
|
|---|
| 483 | push edx ; Pointer to return pointer.
|
|---|
| 484 | call DOS32ALLOCMEM
|
|---|
| 485 | add esp, 12
|
|---|
| 486 | pop edx ; Pointer to allocated memory if any...
|
|---|
| 487 |
|
|---|
| 488 | jmp far ptr CODE16:Thunk16_dh_VMAlloc
|
|---|
| 489 | CODE32 ENDS
|
|---|
| 490 |
|
|---|
| 491 |
|
|---|
| 492 | CODE16 SEGMENT
|
|---|
| 493 | ;;
|
|---|
| 494 | ; Frees memory allocated with VMAlloc.
|
|---|
| 495 | ; @cproto none
|
|---|
| 496 | ; @param EAX Linear address of the memory to be freed.
|
|---|
| 497 | ; @returns Success:
|
|---|
| 498 | ; CF Clear
|
|---|
| 499 | ;
|
|---|
| 500 | ; Failure:
|
|---|
| 501 | ; CF Set
|
|---|
| 502 | ; EAX Errorcode
|
|---|
| 503 | ; ERROR_ACCESS_DENIED
|
|---|
| 504 | ; ERROR_INVALID_PARAMETER
|
|---|
| 505 | ;
|
|---|
| 506 | ; @uses eax, ecx, edx
|
|---|
| 507 | ; @status completely implemented.
|
|---|
| 508 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
|---|
| 509 | dh_VMFree PROC NEAR
|
|---|
| 510 | ASSUME cs:CODE16, ds:NOTHING, es:NOTHING, ss:NOTHING
|
|---|
| 511 | jmp far ptr FLAT:Thunk32_dh_VMFree
|
|---|
| 512 | Thunk16_dh_VMFree::
|
|---|
| 513 | or eax, eax
|
|---|
| 514 | jnz vmf_reterr
|
|---|
| 515 |
|
|---|
| 516 | vmf_retok:
|
|---|
| 517 | clc
|
|---|
| 518 | ret
|
|---|
| 519 |
|
|---|
| 520 | vmf_reterr:
|
|---|
| 521 | stc
|
|---|
| 522 | ret
|
|---|
| 523 | dh_VMFree ENDP
|
|---|
| 524 | CODE16 ENDS
|
|---|
| 525 |
|
|---|
| 526 |
|
|---|
| 527 | CODE32 SEGMENT
|
|---|
| 528 | ; 32-bit part of the dh_VMFree worker
|
|---|
| 529 | Thunk32_dh_VMFree::
|
|---|
| 530 | ASSUME cs:CODE32, ds:NOTHING, es:NOTHING, ss:NOTHING
|
|---|
| 531 | push eax
|
|---|
| 532 | call DOS32FREEMEM
|
|---|
| 533 | sub esp, 4
|
|---|
| 534 | jmp far ptr CODE16:Thunk16_dh_VMFree
|
|---|
| 535 | CODE32 ENDS
|
|---|
| 536 |
|
|---|
| 537 |
|
|---|
| 538 | CODE16 SEGMENT
|
|---|
| 539 | ;;
|
|---|
| 540 | ; Get addresses of kernel variables.
|
|---|
| 541 | ; @cproto none.
|
|---|
| 542 | ; @param AL Index.
|
|---|
| 543 | ; These indexes are supported:
|
|---|
| 544 | ; DHGETDOSV_SYSINFOSEG 1
|
|---|
| 545 | ; DHGETDOSV_LOCINFOSEG 2
|
|---|
| 546 | ; DHGETDOSV_YIELDFLAG 7
|
|---|
| 547 | ; DHGETDOSV_TCYIELDFLAG 8
|
|---|
| 548 | ; DHGETDOSV_DOSTABLE 9
|
|---|
| 549 | ;
|
|---|
| 550 | ;
|
|---|
| 551 | ; @param CX VarMember (only index 14 and 16)
|
|---|
| 552 | ; @param DL DevHlp_GetDOSVar
|
|---|
| 553 | ; @returns Success:
|
|---|
| 554 | ; CF Clear
|
|---|
| 555 | ; AX:BX Points to the index.
|
|---|
| 556 | ;
|
|---|
| 557 | ; Failure:
|
|---|
| 558 | ; CF Set.
|
|---|
| 559 | ;
|
|---|
| 560 | ; @uses eax, ebx, ecx, edx
|
|---|
| 561 | ; @sketch
|
|---|
| 562 | ; @status
|
|---|
| 563 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
|---|
| 564 | ; @remark
|
|---|
| 565 | dh_GetDOSVar PROC NEAR
|
|---|
| 566 | ASSUME cs:CODE16, ds:NOTHING, es:NOTHING, ss:NOTHING
|
|---|
| 567 | cmp al, 1
|
|---|
| 568 | je gdv_12
|
|---|
| 569 | cmp al, 2
|
|---|
| 570 | je gdv_12
|
|---|
| 571 | cmp al, 7
|
|---|
| 572 | je gdv_8
|
|---|
| 573 | cmp al, 8
|
|---|
| 574 | je gdv_8
|
|---|
| 575 | cmp al, 9
|
|---|
| 576 | je gdv_9
|
|---|
| 577 | jmp gdv_reterr
|
|---|
| 578 |
|
|---|
| 579 | gdv_12:
|
|---|
| 580 | push ax
|
|---|
| 581 | push ax ; make space for selGIS
|
|---|
| 582 | mov ax, sp ; offset selGIS
|
|---|
| 583 | push ax ; make space for selLIS
|
|---|
| 584 | mov bx, sp ; offset selLIS
|
|---|
| 585 | push ss
|
|---|
| 586 | push ax ; &selGIS
|
|---|
| 587 | push ss
|
|---|
| 588 | push bx ; &selLIS
|
|---|
| 589 | call far ptr DOS16GETINFOSEG
|
|---|
| 590 | pop bx ; selLIS
|
|---|
| 591 | pop cx ; selGIS
|
|---|
| 592 | pop dx ; index parameter
|
|---|
| 593 | or ax, ax ; Did it fail?
|
|---|
| 594 | jnz gdv_reterr ; Jump if it failed.
|
|---|
| 595 | cmp dx, 1
|
|---|
| 596 | je gdv_12_1
|
|---|
| 597 | mov bx, cx ; bx <- selGIS
|
|---|
| 598 | gdv_12_1:
|
|---|
| 599 | xor ax, ax
|
|---|
| 600 | jmp gdv_retok
|
|---|
| 601 |
|
|---|
| 602 | gdv_7:
|
|---|
| 603 | mov ebx, offset YieldFlag
|
|---|
| 604 | mov ax, seg YieldFlag
|
|---|
| 605 | jmp gdv_retok
|
|---|
| 606 |
|
|---|
| 607 | gdv_8:
|
|---|
| 608 | mov ebx, offset TCYieldFlag
|
|---|
| 609 | mov ax, seg TCYieldFlag
|
|---|
| 610 | jmp gdv_retok
|
|---|
| 611 |
|
|---|
| 612 | gdv_9:
|
|---|
| 613 | mov ebx, offset DosTable
|
|---|
| 614 | mov ax, seg DosTable
|
|---|
| 615 | jmp gdv_retok
|
|---|
| 616 |
|
|---|
| 617 | gdv_retok:
|
|---|
| 618 | clc
|
|---|
| 619 | ret
|
|---|
| 620 |
|
|---|
| 621 | gdv_reterr:
|
|---|
| 622 | stc
|
|---|
| 623 | ret
|
|---|
| 624 | dh_GetDOSVar ENDP
|
|---|
| 625 | CODE16 ENDS
|
|---|
| 626 |
|
|---|
| 627 |
|
|---|
| 628 | DATA16 SEGMENT
|
|---|
| 629 |
|
|---|
| 630 | ;; GetDosVar data
|
|---|
| 631 | ;
|
|---|
| 632 | ; The two YieldFlags
|
|---|
| 633 | ;
|
|---|
| 634 | YieldFlag db 0
|
|---|
| 635 | TCYieldFlag db 0
|
|---|
| 636 | DATA16 ENDS
|
|---|
| 637 |
|
|---|
| 638 |
|
|---|
| 639 | DATA32 SEGMENT
|
|---|
| 640 | ;
|
|---|
| 641 | ; 32-bit flat stack base.
|
|---|
| 642 | ;
|
|---|
| 643 | TKSSBase dd 0
|
|---|
| 644 | DATA32 ENDS
|
|---|
| 645 |
|
|---|
| 646 | DATA16 SEGMENT
|
|---|
| 647 | ASSUME ds:NOTHING, es:NOTHING, ss:NOTHING
|
|---|
| 648 | db "DosTables:"
|
|---|
| 649 | ;
|
|---|
| 650 | ; The two dostables.
|
|---|
| 651 | ;
|
|---|
| 652 | public DosTable
|
|---|
| 653 | DosTable db 17
|
|---|
| 654 | DosTable_fph_HardError dd 0
|
|---|
| 655 | public DosTable_fph_HardError
|
|---|
| 656 | DosTable_fph_UCase dd 0
|
|---|
| 657 | DosTable_UnknownOrReserved1 dd 0
|
|---|
| 658 | DosTable_UnknownOrReserved2 dd 0
|
|---|
| 659 | DosTable_UnknownOrReserved3 dd 0
|
|---|
| 660 | DosTable_fph_MemMapAlias dd 0
|
|---|
| 661 | DosTable_fph_MemUnmapAlias dd 0
|
|---|
| 662 | DosTable_fph_GoProtAll dd 0
|
|---|
| 663 | DosTable_fph_GoRealAll dd 0
|
|---|
| 664 | DosTable_fph_doshlp_RedirDev dd 0
|
|---|
| 665 | DosTable_UnknownOrReserved4 dd 0
|
|---|
| 666 | DosTable_UnknownOrReserved5 dd 0
|
|---|
| 667 | DosTable_fph_SFFromSFN dd 0
|
|---|
| 668 | DosTable_fph_SegGetInfo dd 0
|
|---|
| 669 | DosTable_fph_AsgCheckDrive dd 0
|
|---|
| 670 | DosTable_UnknownOrReserved6 dd 0
|
|---|
| 671 | DosTable_UnknownOrReserved7 dd 0
|
|---|
| 672 |
|
|---|
| 673 | public DosTable2
|
|---|
| 674 | DosTable2 db 19
|
|---|
| 675 | public DosTable2_fpErrMap24
|
|---|
| 676 | DosTable2_fpErrMap24 dd 0
|
|---|
| 677 | DosTable2_fpErrMap24End dd 0
|
|---|
| 678 | DosTable2_fpErr_Table_24 dd 0
|
|---|
| 679 | DosTable2_fpCDSAddr dd 0
|
|---|
| 680 | DosTable2_fpGDT_RDR1 dd 0
|
|---|
| 681 | DosTable2_fpInterrupLevel dd 0
|
|---|
| 682 | DosTable2_fp_cInDos dd 0
|
|---|
| 683 | DosTable2_UnknownOrReserved1 dd 0
|
|---|
| 684 | DosTable2_UnknownOrReserved2 dd 0
|
|---|
| 685 | DosTable2_R0FlatCS dw seg FLAT:CODE32
|
|---|
| 686 | public DosTable2_R0FlatCS
|
|---|
| 687 | dw 0
|
|---|
| 688 | DosTable2_R0FlatDS dw seg FLAT:DATA32
|
|---|
| 689 | dw 0
|
|---|
| 690 | DosTable2_pTKSSBase dd offset FLAT:DATA32:TKSSBase
|
|---|
| 691 | public DosTable2_pintSwitchStack
|
|---|
| 692 | DosTable2_pintSwitchStack dd offset FLAT:CODE32:intSwitchStack
|
|---|
| 693 | DosTable2_pprivatStack dd offset FLAT:DATA32:pPrivateStack
|
|---|
| 694 | DosTable2_fpPhysDiskTablePtr dd 0
|
|---|
| 695 | DosTable2_pforceEMHandler dd 0
|
|---|
| 696 | DosTable2_pReserveVM dd 0
|
|---|
| 697 | DosTable2_p_pgpPageDir dd 0
|
|---|
| 698 | DosTable2_UnknownOrReserved3 dd 0
|
|---|
| 699 |
|
|---|
| 700 | DATA16 ENDS
|
|---|
| 701 |
|
|---|
| 702 |
|
|---|
| 703 | CODE16 SEGMENT
|
|---|
| 704 |
|
|---|
| 705 |
|
|---|
| 706 | ;;
|
|---|
| 707 | ; VMLock stub.
|
|---|
| 708 | ; @returns NO_ERROR. (0)
|
|---|
| 709 | ; @param ignored.
|
|---|
| 710 | ; @uses eax
|
|---|
| 711 | ; @status stub.
|
|---|
| 712 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
|---|
| 713 | dh_VMLock PROC NEAR
|
|---|
| 714 | xor eax, eax
|
|---|
| 715 | clc
|
|---|
| 716 | ret
|
|---|
| 717 | dh_VMLock ENDP
|
|---|
| 718 |
|
|---|
| 719 |
|
|---|
| 720 |
|
|---|
| 721 | ;;
|
|---|
| 722 | ; VMUnlock stub.
|
|---|
| 723 | ; @returns NO_ERROR. (0)
|
|---|
| 724 | ; @param ignored.
|
|---|
| 725 | ; @uses eax
|
|---|
| 726 | ; @status stub.
|
|---|
| 727 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
|---|
| 728 | dh_VMUnlock PROC NEAR
|
|---|
| 729 | xor eax, eax
|
|---|
| 730 | clc
|
|---|
| 731 | ret
|
|---|
| 732 | dh_VMUnlock ENDP
|
|---|
| 733 |
|
|---|
| 734 |
|
|---|
| 735 | CODE16 ENDS
|
|---|
| 736 |
|
|---|
| 737 |
|
|---|
| 738 |
|
|---|
| 739 |
|
|---|
| 740 | CODE32 SEGMENT
|
|---|
| 741 | ;;
|
|---|
| 742 | ; Initiates the Device_Help function pointer.
|
|---|
| 743 | ;
|
|---|
| 744 | ; During startup the C library startup routines needs to use the heap.
|
|---|
| 745 | ; So the heap has to work before main is able to initiate it. The heap
|
|---|
| 746 | ; uses device helpers so they have to be initiated too. So, this init
|
|---|
| 747 | ; routine is called during heap init, _rmem_init.
|
|---|
| 748 | ;
|
|---|
| 749 | ; @cproto void _Optlink kdtDHInit(void)
|
|---|
| 750 | ; @returns NO_ERROR.
|
|---|
| 751 | ; @param none.
|
|---|
| 752 | ; @uses eax
|
|---|
| 753 | ; @sketch
|
|---|
| 754 | ; @status completly implemented
|
|---|
| 755 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
|---|
| 756 | ; @remark
|
|---|
| 757 | kdtDHInit PROC NEAR
|
|---|
| 758 | ASSUME cs:CODE32, ds:FLAT, es:NOTHING, ss:NOTHING
|
|---|
| 759 |
|
|---|
| 760 | ;
|
|---|
| 761 | ; pulTKSSBase32
|
|---|
| 762 | ; DosTable2_pTKSSBase
|
|---|
| 763 | ; DosTable2_R0FlatCS
|
|---|
| 764 | ; DosTable2_R0FlatDS
|
|---|
| 765 | ;
|
|---|
| 766 | mov eax, offset FLAT:TKSSBase
|
|---|
| 767 | mov pulTKSSBase32, eax ; We need it as our testing subsystem uses it too.
|
|---|
| 768 | if 0 ; not neede any longer
|
|---|
| 769 | ;mov DosTable2_pTKSSBase, eax
|
|---|
| 770 | ;mov _TKSSBase16, eax
|
|---|
| 771 |
|
|---|
| 772 | ;xor eax, eax
|
|---|
| 773 | ;mov ax, seg FLAT:CODE32
|
|---|
| 774 | ;mov DosTable2_R0FlatCS, ax
|
|---|
| 775 | ;mov _R0FlatCS16, ax
|
|---|
| 776 |
|
|---|
| 777 | ;mov ax, seg FLAT:DATA32
|
|---|
| 778 | ;mov DosTable2_R0FlatDS, ax
|
|---|
| 779 | ;mov _R0FlatDS16, ax
|
|---|
| 780 | endif
|
|---|
| 781 |
|
|---|
| 782 | ;
|
|---|
| 783 | ; return NO_ERROR
|
|---|
| 784 | ;
|
|---|
| 785 | xor eax, eax
|
|---|
| 786 | ret
|
|---|
| 787 | kdtDHInit ENDP
|
|---|
| 788 |
|
|---|
| 789 |
|
|---|
| 790 | ;;
|
|---|
| 791 | ; Gets the a 16-bit far pointer to the DHRouter routine.
|
|---|
| 792 | ; @cproto ULONG _Optlink kdtDHGetRouterFP(VOID); /* dh.asm */
|
|---|
| 793 | ; @returns 16-bit far pointer to the DHRouter routine.
|
|---|
| 794 | ; @uses EAX
|
|---|
| 795 | ; @status completely implemented.
|
|---|
| 796 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
|---|
| 797 | kdtDHGetRouterFP PROC NEAR
|
|---|
| 798 | ASSUME cs:CODE32, ds:FLAT, es:NOTHING, ss:NOTHING
|
|---|
| 799 | mov ax, seg CODE16:DHRouter
|
|---|
| 800 | shl eax, 16
|
|---|
| 801 | mov ax, offset CODE16:DHRouter
|
|---|
| 802 | ret
|
|---|
| 803 | kdtDHGetRouterFP ENDP
|
|---|
| 804 |
|
|---|
| 805 |
|
|---|
| 806 |
|
|---|
| 807 |
|
|---|
| 808 |
|
|---|
| 809 | ;;
|
|---|
| 810 | ; Thunks the stack from 16-bits to 32-bits.
|
|---|
| 811 | ; !The stack has to be 16-bits on entry!
|
|---|
| 812 | ; @cproto VOID _Optlink kdtStackThunk16To32(VOID)
|
|---|
| 813 | ; @returns void
|
|---|
| 814 | ; Stack is 32-bits!
|
|---|
| 815 | ; EBP and SS:ESP is thunked
|
|---|
| 816 | ;
|
|---|
| 817 | ; @uses EAX, EDX
|
|---|
| 818 | ; @sketch
|
|---|
| 819 | ; @status completly implemented.
|
|---|
| 820 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
|---|
| 821 | ; @remark RING 3 only.
|
|---|
| 822 | kdtStackThunk16To32 PROC NEAR
|
|---|
| 823 | ASSUME cs:CODE32, ds:FLAT, es:NOTHING, ss:NOTHING
|
|---|
| 824 | movzx esp, sp ; Make sure high end of esp is zero.
|
|---|
| 825 | mov ax, ss ; Find the linary base of the segment addressed by ss.
|
|---|
| 826 | shl eax, SEL_FLAT_SHIFT
|
|---|
| 827 | and eax, SEL_FLATMASK
|
|---|
| 828 | mov ax, sp ; Add the segment offset, which is sp.
|
|---|
| 829 | ; eax is now the linear stack address equal to ss:sp.
|
|---|
| 830 |
|
|---|
| 831 | mov dx, seg FLAT:DATA32 ; ALP bug? Can't: push seg FLAT:DATA32
|
|---|
| 832 | ; Have to move it to dx before pushing it.
|
|---|
| 833 | push dx ; Make lss quad word: new ss, new esp
|
|---|
| 834 | push eax
|
|---|
| 835 | lss esp, ss:[esp] ; load new ss and esp values.
|
|---|
| 836 |
|
|---|
| 837 | ;
|
|---|
| 838 | ; Fix ebp
|
|---|
| 839 | ; Creates new ebp from high word of esp and low word of ebp.
|
|---|
| 840 | ;
|
|---|
| 841 | mov eax, esp
|
|---|
| 842 | mov ax, bp
|
|---|
| 843 | mov ebp, eax
|
|---|
| 844 |
|
|---|
| 845 | ;
|
|---|
| 846 | ; Update TKSSBase
|
|---|
| 847 | ;
|
|---|
| 848 | push ds
|
|---|
| 849 | mov ds, dx
|
|---|
| 850 | ASSUME ds:FLAT
|
|---|
| 851 | mov TKSSBase, 0
|
|---|
| 852 | pop ds
|
|---|
| 853 | ret
|
|---|
| 854 | kdtStackThunk16To32 ENDP
|
|---|
| 855 |
|
|---|
| 856 |
|
|---|
| 857 | ;;
|
|---|
| 858 | ; Thunks the stack from 32-bits to 16-bits.
|
|---|
| 859 | ; !The stack has to be 32-bits on entry!
|
|---|
| 860 | ; @cproto VOID _Optlink kdtStackThunk32To16(VOID)
|
|---|
| 861 | ; @returns void
|
|---|
| 862 | ; Stack is 16-bits!
|
|---|
| 863 | ; EBP and SS:ESP is thunked
|
|---|
| 864 | ;
|
|---|
| 865 | ; @uses EAX, EDX
|
|---|
| 866 | ; @sketch
|
|---|
| 867 | ; @status completly implemented.
|
|---|
| 868 | ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
|---|
| 869 | ; @remark RING 3 only.
|
|---|
| 870 | kdtStackThunk32To16 PROC NEAR
|
|---|
| 871 | ASSUME cs:CODE32, ds:FLAT, es:NOTHING, ss:NOTHING
|
|---|
| 872 |
|
|---|
| 873 | mov edx, esp ; save esp for later use (setting TKSSBase).
|
|---|
| 874 |
|
|---|
| 875 | ;
|
|---|
| 876 | ; calc LDT selector from linear esp and load new ss:esp.
|
|---|
| 877 | ;
|
|---|
| 878 | mov eax, esp
|
|---|
| 879 | shr eax, SEL_FLAT_SHIFT
|
|---|
| 880 | or ax, SEL_LDT_RPL3 ; ax new ss LDT (RING3).
|
|---|
| 881 | rol eax, 16
|
|---|
| 882 | mov ax, sp
|
|---|
| 883 | push eax
|
|---|
| 884 | lss sp, dword ptr [esp] ; load ss:sp.
|
|---|
| 885 | movzx esp, sp ; Zero upper part of esp.
|
|---|
| 886 | ; Stack is now 16 bits
|
|---|
| 887 | ;
|
|---|
| 888 | ; Fix ebp
|
|---|
| 889 | ;
|
|---|
| 890 | movzx ebp, bp ; Zero upper part of ebp.
|
|---|
| 891 |
|
|---|
| 892 | ;
|
|---|
| 893 | ; Update TKSSBase
|
|---|
| 894 | ;
|
|---|
| 895 | push ds
|
|---|
| 896 | mov ax, seg FLAT:DATA32
|
|---|
| 897 | mov ds, ax
|
|---|
| 898 | ASSUME ds:FLAT
|
|---|
| 899 | xor dx, dx ; zero lower word of dx to get linear
|
|---|
| 900 | ; address of 16-bits stack base
|
|---|
| 901 | mov TKSSBase, edx
|
|---|
| 902 | pop ds
|
|---|
| 903 |
|
|---|
| 904 | ret
|
|---|
| 905 | kdtStackThunk32To16 ENDP
|
|---|
| 906 |
|
|---|
| 907 | DATA32 segment
|
|---|
| 908 | db "intSwitchStack-Data:"
|
|---|
| 909 | OS2Stack_ESP dd 0 ; OS/2 kernel stack 48 ptr
|
|---|
| 910 | OS2Stack_SS dw 0
|
|---|
| 911 | pPrivateStackNew_ESP dd 0 ; private stack 48 ptr
|
|---|
| 912 | pPrivateStackNew_SS dw 0
|
|---|
| 913 | pPrivateStack dd 0 ; private stack ESP (flat)
|
|---|
| 914 | DATA32 ends
|
|---|
| 915 |
|
|---|
| 916 | public intSwitchStack
|
|---|
| 917 | intSwitchStack proc near
|
|---|
| 918 | or eax, eax
|
|---|
| 919 | jz switch_back
|
|---|
| 920 |
|
|---|
| 921 | switch_to:
|
|---|
| 922 | mov dx, ds
|
|---|
| 923 | cmp dx, seg FLAT:DATA32
|
|---|
| 924 | jz dsok
|
|---|
| 925 | int 3
|
|---|
| 926 | dsok:
|
|---|
| 927 | mov pPrivateStackNew_SS, ds
|
|---|
| 928 | mov pPrivateStackNew_ESP, eax
|
|---|
| 929 | pop eax
|
|---|
| 930 | push OS2Stack_SS
|
|---|
| 931 | push OS2Stack_ESP
|
|---|
| 932 | mov OS2Stack_SS, ss
|
|---|
| 933 | mov OS2Stack_ESP, esp
|
|---|
| 934 | lss esp, fword ptr pPrivateStackNew_ESP
|
|---|
| 935 | jmp eax
|
|---|
| 936 |
|
|---|
| 937 | switch_back:
|
|---|
| 938 | pop eax
|
|---|
| 939 | mov pPrivateStack, esp
|
|---|
| 940 | lss esp, fword ptr OS2Stack_ESP
|
|---|
| 941 | pop word ptr OS2Stack_SS
|
|---|
| 942 | pop dword ptr OS2Stack_ESP
|
|---|
| 943 | jmp eax
|
|---|
| 944 | intSwitchStack endp
|
|---|
| 945 |
|
|---|
| 946 | CODE32 ENDS
|
|---|
| 947 |
|
|---|
| 948 | end
|
|---|
| 949 |
|
|---|
| 950 |
|
|---|