1 | /* $Id: d16strat.c,v 1.3 1999-11-10 01:45:30 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 | /*******************************************************************************
|
---|
19 | * Header Files *
|
---|
20 | *******************************************************************************/
|
---|
21 | #include <os2.h>
|
---|
22 | #include <devhdr.h>
|
---|
23 | #include <devcmd.h>
|
---|
24 | #include <strat2.h>
|
---|
25 | #include <reqpkt.h>
|
---|
26 | #include <dhcalls.h>
|
---|
27 |
|
---|
28 | /* Note that C-library function are only allowed during init! */
|
---|
29 |
|
---|
30 | #include "dev1632.h"
|
---|
31 | #include "dev16.h"
|
---|
32 |
|
---|
33 |
|
---|
34 | /*******************************************************************************
|
---|
35 | * Global Variables *
|
---|
36 | *******************************************************************************/
|
---|
37 | DDHDR aDevHdrs[2] = /* This is the first piece data in the driver!!!!!!! */
|
---|
38 | {
|
---|
39 | {
|
---|
40 | (unsigned long)(void _far *)(&aDevHdrs[1]), /* NextHeader */
|
---|
41 | DEVLEV_3 | DEV_30 | DEV_CHAR_DEV, /* SDevAtt */
|
---|
42 | (unsigned short)(void _near *)strategyAsm0, /* StrategyEP */
|
---|
43 | 0, /* InterruptEP */
|
---|
44 | "elf$ ", /* DevName */
|
---|
45 | 0, /* SDevProtCS */
|
---|
46 | 0, /* SDevProtDS */
|
---|
47 | 0, /* SDevRealCS */
|
---|
48 | 0, /* SDevRealDS */
|
---|
49 | DEV_16MB | DEV_IOCTL2 /* SDevCaps */
|
---|
50 | },
|
---|
51 | {
|
---|
52 | ~0UL, /* NextHeader */
|
---|
53 | DEVLEV_3 | DEV_30 | DEV_CHAR_DEV, /* SDevAtt */
|
---|
54 | (unsigned short)(void _near *)strategyAsm1, /* StrategyEP */
|
---|
55 | 0, /* InterruptEP */
|
---|
56 | "win32k$ ", /* DevName */
|
---|
57 | 0, /* SDevProtCS */
|
---|
58 | 0, /* SDevProtDS */
|
---|
59 | 0, /* SDevRealCS */
|
---|
60 | 0, /* SDevRealDS */
|
---|
61 | DEV_16MB | DEV_IOCTL2 /* SDevCaps */
|
---|
62 | }
|
---|
63 | };
|
---|
64 |
|
---|
65 | /* Note: All global variables must be initialized! *
|
---|
66 | * Uninitialized variables ends up in DATA32. */
|
---|
67 | PFN Device_Help = NULL;
|
---|
68 | ULONG TKSSBase16 = 0;
|
---|
69 | USHORT R0FlatCS16 = 0;
|
---|
70 | USHORT R0FlatDS16 = 0;
|
---|
71 | BOOL fInitTime = TRUE;
|
---|
72 |
|
---|
73 |
|
---|
74 | /*******************************************************************************
|
---|
75 | * Internal Functions *
|
---|
76 | *******************************************************************************/
|
---|
77 | USHORT NEAR dev0GenIOCtl(PRP_GENIOCTL pRp);
|
---|
78 | USHORT NEAR dev1GenIOCtl(PRP_GENIOCTL pRp);
|
---|
79 |
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * Strategy routine.
|
---|
83 | * @returns Status word.
|
---|
84 | * @param pRpH Pointer to request packed header. (Do not change the pointer!)
|
---|
85 | * @parma usDev Device number.
|
---|
86 | * @remark This function is called from the entrypoint in dev1st.asm
|
---|
87 | */
|
---|
88 | USHORT NEAR strategy(PRPH pRpH, unsigned short usDev)
|
---|
89 | {
|
---|
90 |
|
---|
91 | switch (pRpH->Cmd)
|
---|
92 | {
|
---|
93 | case CMDInit: /* INIT command */
|
---|
94 | if (fInitTime)
|
---|
95 | {
|
---|
96 | if (usDev == 0)
|
---|
97 | return dev0Init((PRPINITIN)pRpH, (PRPINITOUT)pRpH);
|
---|
98 | else
|
---|
99 | return dev1Init((PRPINITIN)pRpH, (PRPINITOUT)pRpH);
|
---|
100 | }
|
---|
101 | break;
|
---|
102 |
|
---|
103 | case CMDGenIOCTL: /* Generic IOCTL */
|
---|
104 | if (usDev == 0)
|
---|
105 | return dev0GenIOCtl((PRP_GENIOCTL)pRpH);
|
---|
106 | else
|
---|
107 | return dev1GenIOCtl((PRP_GENIOCTL)pRpH);
|
---|
108 |
|
---|
109 | case CMDOpen: /* device open */
|
---|
110 | case CMDClose: /* device close */
|
---|
111 | case CMDDeInstall: /* De-Install driver */
|
---|
112 | case CMDShutdown:
|
---|
113 | return STATUS_DONE;
|
---|
114 | }
|
---|
115 |
|
---|
116 | return STATUS_DONE | STATUS_ERR_UNKCMD;
|
---|
117 | }
|
---|
118 |
|
---|
119 | extern char end;
|
---|
120 |
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * Generic I/O Control - device 0.
|
---|
124 | * This will only handle the request for Ring-0 initiation.
|
---|
125 | * @returns Status word.
|
---|
126 | * @param pRp Request packet.
|
---|
127 | */
|
---|
128 | USHORT dev0GenIOCtl(PRP_GENIOCTL pRp)
|
---|
129 | {
|
---|
130 | USHORT rc;
|
---|
131 | if (pRp->Category == D16_IOCTL_CAT)
|
---|
132 | {
|
---|
133 | switch (pRp->Function)
|
---|
134 | {
|
---|
135 | case D16_IOCTL_RING0INIT:
|
---|
136 | if (fInitTime)
|
---|
137 | {
|
---|
138 | rc = R0Init16(pRp);
|
---|
139 | fInitTime = FALSE;
|
---|
140 | return rc;
|
---|
141 | }
|
---|
142 | break;
|
---|
143 |
|
---|
144 | case D16_IOCTL_GETKRNLOTES:
|
---|
145 | {
|
---|
146 | ULONG ulLin;
|
---|
147 | if (DevHelp_VirtToLin(SELECTOROF(pRp->DataPacket), OFFSETOF(pRp->DataPacket), &ulLin) != NO_ERROR)
|
---|
148 | return STATUS_DONE | STERR | ERROR_I24_INVALID_PARAMETER;
|
---|
149 | return CallGetOTEs32(ulLin);
|
---|
150 | }
|
---|
151 |
|
---|
152 | case D16_IOCTL_VERIFYPROCTAB:
|
---|
153 | if (fInitTime)
|
---|
154 | return CallVerifyProcTab32();
|
---|
155 | break;
|
---|
156 | }
|
---|
157 | }
|
---|
158 |
|
---|
159 | return STATUS_DONE | STERR | ERROR_I24_INVALID_PARAMETER;
|
---|
160 | }
|
---|
161 |
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * Generic I/O Control - device 0.
|
---|
165 | * This will forward requests to 32-bit counterpart.
|
---|
166 | * @returns Status word.
|
---|
167 | * @param pRp Request packet.
|
---|
168 | */
|
---|
169 | USHORT dev1GenIOCtl(PRP_GENIOCTL pRp)
|
---|
170 | {
|
---|
171 | pRp = pRp;
|
---|
172 | return STATUS_DONE | STERR | ERROR_I24_INVALID_PARAMETER;
|
---|
173 | }
|
---|
174 |
|
---|