source: trunk/src/win32k/dev16/d16strat.c@ 4164

Last change on this file since 4164 was 4164, checked in by bird, 25 years ago

Merged in the Grace branch. New Win32k!

File size: 9.2 KB
Line 
1/* $Id: d16strat.c,v 1.9 2000-09-02 21:07:56 bird Exp $
2 *
3 * d16strat.c - 16-bit strategy routine, device headers, device_helper (ptr)
4 * and 16-bit IOClts.
5 *
6 * Copyright (c) 1999 knut st. osmundsen
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 */
11
12/*******************************************************************************
13* Defined Constants *
14*******************************************************************************/
15#define INCL_DOSERRORS
16#define INCL_NOPMAPI
17
18#define NO_WIN32K_LIB_FUNCTIONS
19
20/*******************************************************************************
21* Header Files *
22*******************************************************************************/
23#include <os2.h>
24#include <devhdr.h>
25#include <devcmd.h>
26#include <strat2.h>
27#include <reqpkt.h>
28#include <dhcalls.h>
29
30/* Note that C-library function are only allowed during init! */
31
32#include "devSegDf.h"
33#include "dev1632.h"
34#include "dev16.h"
35#include "win32k.h"
36
37
38/*******************************************************************************
39* Global Variables *
40*******************************************************************************/
41DDHDR aDevHdrs[2] = /* This is the first piece data in the driver!!!!!!! */
42{
43 {
44 (unsigned long)(void _far *)(&aDevHdrs[1]), /* NextHeader */
45 DEVLEV_3 | DEV_30 | DEV_CHAR_DEV, /* SDevAtt */
46 (unsigned short)(void _near *)strategyAsm0, /* StrategyEP */
47 0, /* InterruptEP */
48 "elf$ ", /* DevName */
49 0, /* SDevProtCS */
50 0, /* SDevProtDS */
51 0, /* SDevRealCS */
52 0, /* SDevRealDS */
53 DEV_16MB | DEV_IOCTL2 /* SDevCaps */
54 },
55 {
56 ~0UL, /* NextHeader */
57 DEVLEV_3 | DEV_30 | DEV_CHAR_DEV, /* SDevAtt */
58 (unsigned short)(void _near *)strategyAsm1, /* StrategyEP */
59 0, /* InterruptEP */
60 "win32k$ ", /* DevName */
61 0, /* SDevProtCS */
62 0, /* SDevProtDS */
63 0, /* SDevRealCS */
64 0, /* SDevRealDS */
65 DEV_16MB | DEV_IOCTL2 /* SDevCaps */
66 }
67};
68
69
70
71/*******************************************************************************
72* Internal Functions *
73*******************************************************************************/
74USHORT NEAR dev0GenIOCtl(PRP_GENIOCTL pRp);
75USHORT NEAR dev1GenIOCtl(PRP_GENIOCTL pRp);
76
77
78/**
79 * Strategy routine.
80 * @returns Status word.
81 * @param pRpH Pointer to request packed header. (Do not change the pointer!)
82 * @parma usDev Device number.
83 * @remark This function is called from the entrypoint in dev1st.asm
84 */
85USHORT NEAR strategy(PRPH pRpH, unsigned short usDev)
86{
87 switch (pRpH->Cmd)
88 {
89 case CMDInit: /* INIT command */
90 if (fInitTime)
91 {
92 if (usDev == 0)
93 return dev0Init((PRPINITIN)pRpH, (PRPINITOUT)pRpH);
94 else
95 return dev1Init((PRPINITIN)pRpH, (PRPINITOUT)pRpH);
96 }
97 break;
98
99 case CMDGenIOCTL: /* Generic IOCTL */
100 if (usDev == 0)
101 return dev0GenIOCtl((PRP_GENIOCTL)pRpH);
102 else
103 return dev1GenIOCtl((PRP_GENIOCTL)pRpH);
104
105 case CMDOpen: /* device open */
106 case CMDClose: /* device close */
107 case CMDDeInstall: /* De-Install driver */
108 case CMDShutdown:
109 return STATUS_DONE;
110 }
111
112 return STATUS_DONE | STATUS_ERR_UNKCMD;
113}
114
115extern char end;
116
117
118/**
119 * Generic I/O Control - device 0.
120 * This will only handle the request for Ring-0 initiation.
121 * @returns Status word.
122 * @param pRp Request packet.
123 */
124USHORT NEAR dev0GenIOCtl(PRP_GENIOCTL pRp)
125{
126 USHORT rc;
127
128 if (pRp->Category == D16_IOCTL_CAT)
129 {
130 switch (pRp->Function)
131 {
132 /*
133 * This is the IOCtl which does the R0-initiation of the device driver.
134 * Only available at init time...
135 */
136 case D16_IOCTL_RING0INIT:
137 if (fInitTime)
138 {
139 rc = R0Init16(pRp);
140 return rc;
141 }
142 break;
143
144 /*
145 * This is the IOCtl collects info of the running kernel.
146 * Only available at init time.
147 *
148 * Since this IOCtl is issued before R0-Init is done, we'll have to
149 * init TKSSBase for both 16-bit and 32-bit code and be a bit carefull.
150 */
151 case D16_IOCTL_GETKRNLINFO:
152 if (fInitTime)
153 {
154 ULONG ulLin;
155 if (fInitTime && TKSSBase16 == 0)
156 initGetDosTableData();
157 if (DevHelp_VirtToLin(SELECTOROF(pRp->DataPacket), OFFSETOF(pRp->DataPacket),
158 &ulLin) != NO_ERROR)
159 return STATUS_DONE | STERR | ERROR_I24_INVALID_PARAMETER;
160 return CallGetKernelInfo32(ulLin);
161 }
162 break;
163
164 /*
165 * This is the IOCtl verifies the data in the ImportTab.
166 * Only available at init time.
167 *
168 * Since this IOCtl is issued before R0-Init is done, we'll have to
169 * init TKSSBase for both 16-bit and 32-bit code and be a bit carefull.
170 */
171 case D16_IOCTL_VERIFYIMPORTTAB:
172 if (fInitTime)
173 {
174 if (TKSSBase16 == 0)
175 initGetDosTableData();
176 return CallVerifyImportTab32();
177 }
178 break;
179 }
180 }
181 else if (pRp->Category == IOCTL_W32K_K32 || pRp->Category == IOCTL_W32K_ELF)
182 {
183 RP32GENIOCTL rp32Init = {0};
184 rp32Init.rph.Len = pRp->rph.Len;
185 rp32Init.rph.Unit = pRp->rph.Unit;
186 rp32Init.rph.Cmd = pRp->rph.Cmd;
187 rp32Init.rph.Status = pRp->rph.Status;
188 rp32Init.rph.Flags = pRp->rph.Flags;
189 rp32Init.rph.Link = (ULONG)pRp->rph.Link;
190 rp32Init.Category = pRp->Category;
191 rp32Init.Function = pRp->Function;
192 rp32Init.sfn = pRp->sfn;
193 rp32Init.DataLen = pRp->DataLen;
194 rp32Init.ParmLen = pRp->ParmLen;
195
196 if (DevHelp_VirtToLin(SELECTOROF(pRp->DataPacket), OFFSETOF(pRp->DataPacket),
197 (PLIN)&rp32Init.DataPacket) != NO_ERROR)
198 return STATUS_DONE | STERR | ERROR_I24_INVALID_PARAMETER;
199 if (DevHelp_VirtToLin(SELECTOROF(pRp->ParmPacket), OFFSETOF(pRp->ParmPacket),
200 (PLIN)&rp32Init.ParmPacket) != NO_ERROR)
201 return STATUS_DONE | STERR | ERROR_I24_INVALID_PARAMETER;
202
203 if (pRp->Category == IOCTL_W32K_ELF)
204 rc = CallElfIOCtl(SSToDS_16a(&rp32Init));
205 else
206 rc = CallWin32kIOCtl(SSToDS_16a(&rp32Init));
207
208 return rc;
209 }
210
211
212 return STATUS_DONE | STERR | ERROR_I24_INVALID_PARAMETER;
213}
214
215
216/**
217 * Generic I/O Control - device 0.
218 * This will forward requests to 32-bit counterpart.
219 * @returns Status word.
220 * @param pRp Request packet.
221 */
222USHORT NEAR dev1GenIOCtl(PRP_GENIOCTL pRp)
223{
224 if (pRp->Category == IOCTL_W32K_K32 || pRp->Category == IOCTL_W32K_ELF)
225 {
226 USHORT rc;
227 RP32GENIOCTL rp32Init = {0};
228 rp32Init.rph.Len = pRp->rph.Len;
229 rp32Init.rph.Unit = pRp->rph.Unit;
230 rp32Init.rph.Cmd = pRp->rph.Cmd;
231 rp32Init.rph.Status = pRp->rph.Status;
232 rp32Init.rph.Flags = pRp->rph.Flags;
233 rp32Init.rph.Link = (ULONG)pRp->rph.Link;
234 rp32Init.Category = pRp->Category;
235 rp32Init.Function = pRp->Function;
236 rp32Init.sfn = pRp->sfn;
237 rp32Init.DataLen = pRp->DataLen;
238 rp32Init.ParmLen = pRp->ParmLen;
239
240 if (DevHelp_VirtToLin(SELECTOROF(pRp->DataPacket), OFFSETOF(pRp->DataPacket),
241 (PLIN)&rp32Init.DataPacket) != NO_ERROR)
242 return STATUS_DONE | STERR | ERROR_I24_INVALID_PARAMETER;
243 if (DevHelp_VirtToLin(SELECTOROF(pRp->ParmPacket), OFFSETOF(pRp->ParmPacket),
244 (PLIN)&rp32Init.ParmPacket) != NO_ERROR)
245 return STATUS_DONE | STERR | ERROR_I24_INVALID_PARAMETER;
246
247 if (pRp->Category == IOCTL_W32K_ELF)
248 rc = CallElfIOCtl(SSToDS_16a(&rp32Init));
249 else
250 rc = CallWin32kIOCtl(SSToDS_16a(&rp32Init));
251
252 return rc;
253 }
254
255 return STATUS_DONE | STERR | ERROR_I24_INVALID_PARAMETER;
256}
257
Note: See TracBrowser for help on using the repository browser.