| 1 | ; $Id: devfirst.asm,v 1.2 1999-10-27 02:02:54 bird Exp $ | 
|---|
| 2 | ; | 
|---|
| 3 | ; DevFirst - entrypoint and segment definitions | 
|---|
| 4 | ; | 
|---|
| 5 | ; Copyright (c) 1999 knut st. osmundsen | 
|---|
| 6 | ; | 
|---|
| 7 | ; Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 8 | ; | 
|---|
| 9 | .386p | 
|---|
| 10 |  | 
|---|
| 11 | ; | 
|---|
| 12 | ; Include files | 
|---|
| 13 | ; | 
|---|
| 14 | include devsegdf.inc | 
|---|
| 15 | include sas.inc | 
|---|
| 16 |  | 
|---|
| 17 | ; | 
|---|
| 18 | ; Exported symbols | 
|---|
| 19 | ; | 
|---|
| 20 | public CODE16START | 
|---|
| 21 | public DATA16START | 
|---|
| 22 | public DATA16START | 
|---|
| 23 | public DATA16_BSSSTART | 
|---|
| 24 | public DATA16_CONSTSTART | 
|---|
| 25 | public CODE16START | 
|---|
| 26 | public CODE32START | 
|---|
| 27 | public DATA32START | 
|---|
| 28 | public BSS32START | 
|---|
| 29 | public CONST32_ROSTART | 
|---|
| 30 |  | 
|---|
| 31 | public _strategyAsm0 | 
|---|
| 32 | public _strategyAsm1 | 
|---|
| 33 | public _CallGetOTEs32 | 
|---|
| 34 | public _SSToDS_16a | 
|---|
| 35 | public GetOS2KrnlMTE | 
|---|
| 36 |  | 
|---|
| 37 |  | 
|---|
| 38 | ; | 
|---|
| 39 | ; Externs | 
|---|
| 40 | ; | 
|---|
| 41 | extrn _TKSSBase16:dword | 
|---|
| 42 | extrn GETOTES32:FAR | 
|---|
| 43 | .286p | 
|---|
| 44 | extrn _strategy:near | 
|---|
| 45 |  | 
|---|
| 46 |  | 
|---|
| 47 | CODE16 segment | 
|---|
| 48 | ASSUME CS:CODE16, DS:DATA16, ES:NOTHING, SS:NOTHING | 
|---|
| 49 |  | 
|---|
| 50 | CODE16START label byte | 
|---|
| 51 |  | 
|---|
| 52 | .286p | 
|---|
| 53 | ;$win32ki entry point | 
|---|
| 54 | _strategyAsm0: | 
|---|
| 55 | push    0 | 
|---|
| 56 | jmp     _strategyAsm | 
|---|
| 57 |  | 
|---|
| 58 | ;$win32k entry point | 
|---|
| 59 | _strategyAsm1: | 
|---|
| 60 | push    1 | 
|---|
| 61 | jmp     _strategyAsm | 
|---|
| 62 |  | 
|---|
| 63 | ;; | 
|---|
| 64 | ; Stub which pushes parameters onto the stack and call the 16-bit C strategy routine. | 
|---|
| 65 | ; @returns   returns the return value of strategy(...) | 
|---|
| 66 | ; @author    knut st. osmundsen | 
|---|
| 67 | _strategyAsm proc far | 
|---|
| 68 | push    es | 
|---|
| 69 | push    bx | 
|---|
| 70 | push    ds | 
|---|
| 71 | pop     es | 
|---|
| 72 | call    _strategy | 
|---|
| 73 | pop     bx | 
|---|
| 74 | pop     es | 
|---|
| 75 | mov     word ptr es:[bx+3], ax | 
|---|
| 76 | add     sp, 2 | 
|---|
| 77 | retf | 
|---|
| 78 | _strategyAsm endp | 
|---|
| 79 |  | 
|---|
| 80 |  | 
|---|
| 81 | .386p | 
|---|
| 82 | ;; | 
|---|
| 83 | ; Thunk procedure for R0Init32. | 
|---|
| 84 | ; @cproto    USHORT NEAR CallGetOTEs32(ULONG addressOTEBuf); | 
|---|
| 85 | ; @returns   Same as GetOTEs32. | 
|---|
| 86 | ; @param     addressOTEBuf  32-bit pointer to request data. | 
|---|
| 87 | ; @status    completely implemented. | 
|---|
| 88 | ; @author    knut st. osmundsen | 
|---|
| 89 | _CallGetOTEs32 PROC NEAR | 
|---|
| 90 | ASSUME CS:CODE16 | 
|---|
| 91 | push    ds | 
|---|
| 92 | push    word ptr [esp+6]            ; push high word. | 
|---|
| 93 | push    word ptr [esp+6]            ; push low word. | 
|---|
| 94 | call    far ptr FLAT:GETOTES32 | 
|---|
| 95 | pop     ds | 
|---|
| 96 | retn | 
|---|
| 97 | _CallGetOTEs32 ENDP | 
|---|
| 98 |  | 
|---|
| 99 |  | 
|---|
| 100 | ;; | 
|---|
| 101 | ; SSToDS - stack pointer to Flat pointer. | 
|---|
| 102 | ; @cproto    extern LIN   SSToDS_16a(void NEAR *pStackVar); | 
|---|
| 103 | ; @returns   ax:dx  makes up a 32-bit flat pointer to stack. | 
|---|
| 104 | ; @param     pStackVar  Stack pointer which is to be made a flat pointer. | 
|---|
| 105 | ; @equiv     SSToDS in 32-bit code. | 
|---|
| 106 | ; @sketch    Get Flat CS | 
|---|
| 107 | ;            Get TKSSBase address. (FLAT) | 
|---|
| 108 | ;            return *TKSSBase + pStackVar. | 
|---|
| 109 | ; @status    completely  implemented. | 
|---|
| 110 | ; @author    knut st. osmundsen | 
|---|
| 111 | ; @remark    es is cs, not ds! | 
|---|
| 112 | _SSToDS_16a proc near | 
|---|
| 113 | assume CS:CODE16, DS:DATA16, ES:NOTHING | 
|---|
| 114 | mov     edx, ds:_TKSSBase16         ; get pointer held by _TKSSBase16 (pointer to stack base) | 
|---|
| 115 | call    far ptr FLAT:far_getCS      ; get flat selector. | 
|---|
| 116 | push    es | 
|---|
| 117 | mov     es,  ax | 
|---|
| 118 | assume  es:FLAT | 
|---|
| 119 | mov     eax, es:[edx]               ; get pointer to stack base | 
|---|
| 120 | pop     es | 
|---|
| 121 | movzx   edx, word ptr ss:[esp + 2]  ; 16-bit stack pointer (parameter) | 
|---|
| 122 | add     eax, edx                    ; 32-bit stack pointer in eax | 
|---|
| 123 | mov     edx, eax | 
|---|
| 124 | shr     edx, 16                     ; dx high 16-bit of 32-bit stack pointer. | 
|---|
| 125 | ret | 
|---|
| 126 | _SSToDS_16a endp | 
|---|
| 127 |  | 
|---|
| 128 | CODE16 ends | 
|---|
| 129 |  | 
|---|
| 130 |  | 
|---|
| 131 | ; | 
|---|
| 132 | ; all segments have a <segmentname>START label at the start of the segment. | 
|---|
| 133 | ; | 
|---|
| 134 |  | 
|---|
| 135 | CODE32 segment | 
|---|
| 136 | CODE32START label byte | 
|---|
| 137 |  | 
|---|
| 138 | ;; | 
|---|
| 139 | ; Gets the current cs. | 
|---|
| 140 | ; @cproto    none. | 
|---|
| 141 | ; @returns   CS | 
|---|
| 142 | ; @author    knut st. osmundsen | 
|---|
| 143 | ; @remark    internal method. called from 16-bit code... | 
|---|
| 144 | far_getCS proc far | 
|---|
| 145 | ASSUME DS:nothing, ES:nothing | 
|---|
| 146 | mov     ax,  cs | 
|---|
| 147 | retf | 
|---|
| 148 | far_getCS endp | 
|---|
| 149 |  | 
|---|
| 150 |  | 
|---|
| 151 |  | 
|---|
| 152 | ;; | 
|---|
| 153 | ; Gets the a 32-bit flat pointer to the OS/2 Kernel MTE. | 
|---|
| 154 | ; @cproto    extern PMTE _System GetOS2KrnlMTE(void); | 
|---|
| 155 | ; @returns   Pointer to kernel MTE. | 
|---|
| 156 | ; @status    completely implemented. | 
|---|
| 157 | ; @author    knut st. osmundsen | 
|---|
| 158 | GetOS2KrnlMTE PROC NEAR | 
|---|
| 159 | push    es | 
|---|
| 160 |  | 
|---|
| 161 | mov     ax,  SAS_selector               ;70h - Read-only SAS selector. | 
|---|
| 162 | mov     es,  ax | 
|---|
| 163 | xor     ebx, ebx | 
|---|
| 164 | assume  ebx: PTR SAS | 
|---|
| 165 | mov     bx,  es:[ebx].SAS_vm_data       ;SAS_vm_data (0ch) | 
|---|
| 166 | assume  ebx: PTR SAS_vm_section | 
|---|
| 167 | mov     eax, es:[ebx].SAS_vm_krnl_mte   ;SAS_vm_krnl_mte (0ch) | 
|---|
| 168 |  | 
|---|
| 169 | pop     es | 
|---|
| 170 | ret | 
|---|
| 171 | GetOS2KrnlMTE ENDP | 
|---|
| 172 |  | 
|---|
| 173 | CODE32 ends | 
|---|
| 174 |  | 
|---|
| 175 |  | 
|---|
| 176 | DATA16 segment | 
|---|
| 177 | DATA16START label byte | 
|---|
| 178 | DATA16 ends | 
|---|
| 179 |  | 
|---|
| 180 | DATA16_BSS segment | 
|---|
| 181 | DATA16_BSSSTART label byte | 
|---|
| 182 | DATA16_BSS ends | 
|---|
| 183 |  | 
|---|
| 184 | DATA16_CONST segment | 
|---|
| 185 | DATA16_CONSTSTART label byte | 
|---|
| 186 | DATA16_CONST ends | 
|---|
| 187 |  | 
|---|
| 188 | DATA32 segment | 
|---|
| 189 | DATA32START label byte | 
|---|
| 190 | DATA32 ends | 
|---|
| 191 |  | 
|---|
| 192 | BSS32 segment | 
|---|
| 193 | BSS32START label byte | 
|---|
| 194 | BSS32 ends | 
|---|
| 195 |  | 
|---|
| 196 | CONST32_RO segment | 
|---|
| 197 | CONST32_ROSTART label byte | 
|---|
| 198 | CONST32_RO ends | 
|---|
| 199 | END | 
|---|
| 200 |  | 
|---|