| 1 | ; $Id: startup.inc,v 1.1.1.1 2003/07/02 13:56:56 eleph Exp $ | 
|---|
| 2 | ;* | 
|---|
| 3 | ;* Assembly macro and constant definitions | 
|---|
| 4 | ;* | 
|---|
| 5 | ;* (C) 2000-2002 InnoTek Systemberatung GmbH | 
|---|
| 6 | ;* (C) 2000-2001 Sander van Leeuwen (sandervl@xs4all.nl) | 
|---|
| 7 | ;* | 
|---|
| 8 | ;* This program is free software; you can redistribute it and/or | 
|---|
| 9 | ;* modify it under the terms of the GNU General Public License as | 
|---|
| 10 | ;* published by the Free Software Foundation; either version 2 of | 
|---|
| 11 | ;* the License, or (at your option) any later version. | 
|---|
| 12 | ;* | 
|---|
| 13 | ;* This program is distributed in the hope that it will be useful, | 
|---|
| 14 | ;* but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 15 | ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 16 | ;* GNU General Public License for more details. | 
|---|
| 17 | ;* | 
|---|
| 18 | ;* You should have received a copy of the GNU General Public | 
|---|
| 19 | ;* License along with this program; if not, write to the Free | 
|---|
| 20 | ;* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, | 
|---|
| 21 | ;* USA. | 
|---|
| 22 | ;* | 
|---|
| 23 |  | 
|---|
| 24 |  | 
|---|
| 25 | ; MACRO'S | 
|---|
| 26 | ;******************************************************************************* | 
|---|
| 27 | ;enter a 16:32 far function | 
|---|
| 28 | ;******************************************************************************* | 
|---|
| 29 | enter32         MACRO | 
|---|
| 30 | push    bp | 
|---|
| 31 | mov     bp, sp | 
|---|
| 32 | push    ds | 
|---|
| 33 | mov     ax, DATA16 | 
|---|
| 34 | mov     ds, ax | 
|---|
| 35 | ENDM | 
|---|
| 36 | ;******************************************************************************* | 
|---|
| 37 | ;return to 16:32 far caller | 
|---|
| 38 | ;******************************************************************************* | 
|---|
| 39 | ret32           MACRO | 
|---|
| 40 | pop     ds | 
|---|
| 41 | pop     bp | 
|---|
| 42 | db      66h                             ; Force next instruction 32-bit | 
|---|
| 43 | ret | 
|---|
| 44 | ENDM | 
|---|
| 45 |  | 
|---|
| 46 | enter16         MACRO | 
|---|
| 47 | push    bp | 
|---|
| 48 | mov     bp, sp | 
|---|
| 49 | ENDM | 
|---|
| 50 | ret16           MACRO | 
|---|
| 51 | pop     bp | 
|---|
| 52 | ret | 
|---|
| 53 | ENDM | 
|---|
| 54 |  | 
|---|
| 55 | ;pushfd/popfd trashed by fucking BUGY KernThunkStackTo32 | 
|---|
| 56 | ;fix idea by zuko | 
|---|
| 57 |  | 
|---|
| 58 | ;;****************************************************************************** | 
|---|
| 59 | ;;Need to preserve fs:ebx!! (all other registers must be saved by the caller) | 
|---|
| 60 | ;;****************************************************************************** | 
|---|
| 61 | DevThunkStackTo32 MACRO | 
|---|
| 62 | push    stacksel | 
|---|
| 63 | push    stackbase | 
|---|
| 64 | push    edx | 
|---|
| 65 | mov     edx, ss | 
|---|
| 66 | mov     stacksel, edx | 
|---|
| 67 | pushfd | 
|---|
| 68 | call    KernThunkStackTo32 | 
|---|
| 69 | popfd | 
|---|
| 70 | mov     stackbase, edx | 
|---|
| 71 | pop     edx      ;trashed by KernThunkStackTo32 | 
|---|
| 72 | ENDM | 
|---|
| 73 |  | 
|---|
| 74 | ;;****************************************************************************** | 
|---|
| 75 | ;;****************************************************************************** | 
|---|
| 76 | DevThunkStackTo32_Int MACRO | 
|---|
| 77 | push    eax | 
|---|
| 78 | push    edx | 
|---|
| 79 | pushfd | 
|---|
| 80 | call    KernThunkStackTo32 | 
|---|
| 81 | popfd | 
|---|
| 82 | pop     edx     ;trashed by KernThunkStackTo32 | 
|---|
| 83 | pop     eax     ;trashed by KernThunkStackTo32 | 
|---|
| 84 | ENDM | 
|---|
| 85 |  | 
|---|
| 86 | ;;****************************************************************************** | 
|---|
| 87 | ;;****************************************************************************** | 
|---|
| 88 | DevThunkStackTo16 MACRO | 
|---|
| 89 | push    edx | 
|---|
| 90 | push    eax | 
|---|
| 91 | pushfd | 
|---|
| 92 | call    KernThunkStackTo16 | 
|---|
| 93 | popfd | 
|---|
| 94 | pop     eax     ;trashed by KernThunkStackTo16 | 
|---|
| 95 | pop     edx     ;trashed by KernThunkStackTo16 when called in interrupt context | 
|---|
| 96 | pop     stackbase | 
|---|
| 97 | pop     stacksel | 
|---|
| 98 | ENDM | 
|---|
| 99 |  | 
|---|
| 100 | ;;****************************************************************************** | 
|---|
| 101 | ;;****************************************************************************** | 
|---|
| 102 | DevThunkStackTo16_Int MACRO | 
|---|
| 103 | push    edx | 
|---|
| 104 | push    eax | 
|---|
| 105 | pushfd | 
|---|
| 106 | call    KernThunkStackTo16 | 
|---|
| 107 | popfd | 
|---|
| 108 | pop     eax     ;trashed by KernThunkStackTo16 | 
|---|
| 109 | pop     edx     ;trashed by KernThunkStackTo16 when called in interrupt context | 
|---|
| 110 | ENDM | 
|---|
| 111 |  | 
|---|
| 112 | ;******************************************************************************* | 
|---|
| 113 | ;enter a function that needs to switch to a 16 bits stack | 
|---|
| 114 | ;******************************************************************************* | 
|---|
| 115 | enterKEERM      MACRO | 
|---|
| 116 | push    ebp | 
|---|
| 117 | mov     ebp, esp | 
|---|
| 118 | push    ds | 
|---|
| 119 | push    es | 
|---|
| 120 | push    ebx | 
|---|
| 121 | push    ecx | 
|---|
| 122 | push    edx | 
|---|
| 123 | push    esi | 
|---|
| 124 | push    edi | 
|---|
| 125 | ;to access the parameters on the 32 bits stack, once we've switched | 
|---|
| 126 | mov     edi, ebp | 
|---|
| 127 | DevThunkStackTo16_Int | 
|---|
| 128 | ENDM | 
|---|
| 129 |  | 
|---|
| 130 | ;******************************************************************************* | 
|---|
| 131 | ;switch stack from 16 bits to 32 bits and return | 
|---|
| 132 | ;******************************************************************************* | 
|---|
| 133 | retKEERM        MACRO | 
|---|
| 134 | DevThunkStackTo32_Int | 
|---|
| 135 | pop     edi | 
|---|
| 136 | pop     esi | 
|---|
| 137 | pop     edx | 
|---|
| 138 | pop     ecx | 
|---|
| 139 | pop     ebx | 
|---|
| 140 | pop     es | 
|---|
| 141 | pop     ds | 
|---|
| 142 | pop     ebp | 
|---|
| 143 | ret | 
|---|
| 144 | ENDM | 
|---|
| 145 |  | 
|---|
| 146 | ;;****************************************************************************** | 
|---|
| 147 | ;;****************************************************************************** | 
|---|
| 148 |  | 
|---|
| 149 |  | 
|---|
| 150 | ;Constants and structure definitions | 
|---|
| 151 |  | 
|---|
| 152 | ; Status word masks | 
|---|
| 153 | STERR   EQU     8000H           ; Bit 15 - Error | 
|---|
| 154 | STINTER EQU     0400H           ; Bit 10 - Interim character | 
|---|
| 155 | STBUI   EQU     0200H           ; Bit  9 - Busy | 
|---|
| 156 | STDON   EQU     0100H           ; Bit  8 - Done | 
|---|
| 157 | STECODE EQU     00FFH           ; Error code | 
|---|
| 158 |  | 
|---|
| 159 | ; Definition of the request packet header. | 
|---|
| 160 |  | 
|---|
| 161 | reqPacket       struc | 
|---|
| 162 | reqLenght       db ? | 
|---|
| 163 | reqUnit         db ? | 
|---|
| 164 | reqCommand      db ? | 
|---|
| 165 | reqStatus       dw ? | 
|---|
| 166 | reqFlags        db ? | 
|---|
| 167 | db 3 dup (?)    ; Reserved field | 
|---|
| 168 | reqLink         dd ? | 
|---|
| 169 | reqPacket       ends | 
|---|
| 170 |  | 
|---|
| 171 | rpInitIn        struc | 
|---|
| 172 | i_rph           db size reqPacket dup (?) | 
|---|
| 173 | i_unit          db ? | 
|---|
| 174 | i_devHelp       dd ? | 
|---|
| 175 | i_initArgs      dd ? | 
|---|
| 176 | i_driveNum      db ? | 
|---|
| 177 | rpInitIn        ends | 
|---|
| 178 |  | 
|---|
| 179 | rpInitOut       struc | 
|---|
| 180 | o_rph           db size reqPacket dup (?) | 
|---|
| 181 | o_unit          db ? | 
|---|
| 182 | o_codeend       dw ? | 
|---|
| 183 | o_dataend       dw ? | 
|---|
| 184 | o_bpbarray      dd ? | 
|---|
| 185 | o_status        dw ? | 
|---|
| 186 | rpInitOut       ends | 
|---|