1 | /* $Id: strategy.c,v 1.1.1.1 2003/07/02 13:56:56 eleph Exp $ */
|
---|
2 | /*
|
---|
3 | * Strategy entry point
|
---|
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 | #define INCL_NOPMAPI
|
---|
26 | #define INCL_DOSINFOSEG // Need Global info seg in rm.cpp algorithms
|
---|
27 | #include <os2.h>
|
---|
28 |
|
---|
29 | #include <devhelp.h>
|
---|
30 | #include <devrp.h>
|
---|
31 | #include <devown.h>
|
---|
32 | #include "strategy.h"
|
---|
33 | #include <ossidc32.h>
|
---|
34 | #include <dbgos2.h>
|
---|
35 |
|
---|
36 | ULONG StratRead(RP __far *_rp);
|
---|
37 | ULONG StratIOCtl(RP __far *_rp);
|
---|
38 | ULONG StratClose(RP __far *_rp);
|
---|
39 |
|
---|
40 | ULONG DiscardableInit(RPInit __far*);
|
---|
41 |
|
---|
42 | ULONG deviceOwner = DEV_NO_OWNER;
|
---|
43 | ULONG numOS2Opens = 0;
|
---|
44 |
|
---|
45 | //******************************************************************************
|
---|
46 | //******************************************************************************
|
---|
47 | ULONG StratOpen(RP __far*)
|
---|
48 | {
|
---|
49 | if (numOS2Opens == 0) {
|
---|
50 | deviceOwner = DEV_PDD_OWNER;
|
---|
51 | }
|
---|
52 | numOS2Opens++;
|
---|
53 | return RPDONE;
|
---|
54 | }
|
---|
55 | //******************************************************************************
|
---|
56 | //******************************************************************************
|
---|
57 | #pragma off (unreferenced)
|
---|
58 | static ULONG StratWrite(RP __far* _rp)
|
---|
59 | #pragma on (unreferenced)
|
---|
60 | {
|
---|
61 | return RPDONE | RPERR;
|
---|
62 | }
|
---|
63 | //******************************************************************************
|
---|
64 | // External initialization entry-point
|
---|
65 | //******************************************************************************
|
---|
66 | ULONG StratInit(RP __far* _rp)
|
---|
67 | {
|
---|
68 | ULONG rc;
|
---|
69 |
|
---|
70 | RPInit __far* rp = (RPInit __far*)_rp;
|
---|
71 | rc = DiscardableInit(rp);
|
---|
72 | dprintf(("StratInit End rc=%d", rc));
|
---|
73 | return rc;
|
---|
74 | }
|
---|
75 | //******************************************************************************
|
---|
76 | // External initialization complete entry-point
|
---|
77 | #ifdef ACPI
|
---|
78 | // See desription in irq.cpp
|
---|
79 | #include "irqos2.h" //PS+++
|
---|
80 | #ifdef __cplusplus
|
---|
81 | extern "C" {
|
---|
82 | #endif
|
---|
83 | ULONG InitCompleteWas = 0; //PS+++ Indication of InitComplete call
|
---|
84 | struct SaveIRQForSlot
|
---|
85 | {
|
---|
86 | ULONG ulSlotNo;
|
---|
87 | BYTE LowIRQ;
|
---|
88 | BYTE HighIRQ;
|
---|
89 | BYTE Pin;
|
---|
90 | };
|
---|
91 | extern struct SaveIRQForSlot sISRHigh[];
|
---|
92 | extern int SaveIRQCounter;
|
---|
93 | #ifdef __cplusplus
|
---|
94 | }
|
---|
95 | #endif
|
---|
96 | #endif //ACPI
|
---|
97 | //******************************************************************************
|
---|
98 | #pragma off (unreferenced)
|
---|
99 | ULONG StratInitComplete(RP __far* _rp)
|
---|
100 | #pragma on (unreferenced)
|
---|
101 | {
|
---|
102 | #ifdef ACPI
|
---|
103 | //PS+++ Begin
|
---|
104 | ULONG i, rc = 0;
|
---|
105 |
|
---|
106 | InitCompleteWas = 1;
|
---|
107 | for (i = 0; i < SaveIRQCounter; i++)
|
---|
108 | {
|
---|
109 | dprintf(("Close IRQ%d - Open IRQ%d",(ULONG)sISRHigh[i].LowIRQ,(ULONG)sISRHigh[i].HighIRQ));
|
---|
110 | if (sISRHigh[i].HighIRQ)
|
---|
111 | {
|
---|
112 | ALSA_FreeIrq(sISRHigh[i].LowIRQ);
|
---|
113 | if (!ALSA_SetIrq(sISRHigh[i].HighIRQ, sISRHigh[i].ulSlotNo, 1))
|
---|
114 | {
|
---|
115 | return (RPERR_COMMAND | RPDONE);
|
---|
116 | }
|
---|
117 | }
|
---|
118 | }
|
---|
119 | #endif
|
---|
120 | //PS++ End
|
---|
121 | dprintf(("StratInitComplete"));
|
---|
122 | return(RPDONE);
|
---|
123 | }
|
---|
124 | //******************************************************************************
|
---|
125 | //******************************************************************************
|
---|
126 | #pragma off (unreferenced)
|
---|
127 | ULONG StratShutdown(RP __far *_rp)
|
---|
128 | #pragma on (unreferenced)
|
---|
129 | {
|
---|
130 | RPShutdown __far *rp = (RPShutdown __far *)_rp;
|
---|
131 |
|
---|
132 | dprintf(("StratShutdown Start %d", rp->Function));
|
---|
133 | if(rp->Function == 1) {//end of shutdown
|
---|
134 | OSS32_Shutdown();
|
---|
135 | }
|
---|
136 | dprintf(("StratShutdown End"));
|
---|
137 | return(RPDONE);
|
---|
138 | }
|
---|
139 | //******************************************************************************
|
---|
140 | //******************************************************************************
|
---|
141 | // Handle unsupported requests
|
---|
142 | static ULONG StratError(RP __far*)
|
---|
143 | {
|
---|
144 | return RPERR_COMMAND | RPDONE;
|
---|
145 | }
|
---|
146 | //******************************************************************************
|
---|
147 | // Strategy dispatch table
|
---|
148 | //
|
---|
149 | // This table is used by the strategy routine to dispatch strategy requests
|
---|
150 | //******************************************************************************
|
---|
151 | typedef ULONG (*RPHandler)(RP __far* rp);
|
---|
152 | RPHandler StratDispatch[] =
|
---|
153 | {
|
---|
154 | StratInit, // 00 (BC): Initialization
|
---|
155 | StratError, // 01 (B ): Media check
|
---|
156 | StratError, // 02 (B ): Build BIOS parameter block
|
---|
157 | StratError, // 03 ( ): Unused
|
---|
158 | StratRead, // 04 (BC): Read
|
---|
159 | StratError, // 05 ( C): Nondestructive read with no wait
|
---|
160 | StratError, // 06 ( C): Input status
|
---|
161 | StratError, // 07 ( C): Input flush
|
---|
162 | StratWrite, // 08 (BC): Write
|
---|
163 | StratError, // 09 (BC): Write verify
|
---|
164 | StratError, // 0A ( C): Output status
|
---|
165 | StratError, // 0B ( C): Output flush
|
---|
166 | StratError, // 0C ( ): Unused
|
---|
167 | StratOpen, // 0D (BC): Open
|
---|
168 | StratClose, // 0E (BC): Close
|
---|
169 | StratError, // 0F (B ): Removable media check
|
---|
170 | StratIOCtl, // 10 (BC): IO Control
|
---|
171 | StratError, // 11 (B ): Reset media
|
---|
172 | StratError, // 12 (B ): Get logical unit
|
---|
173 | StratError, // 13 (B ): Set logical unit
|
---|
174 | StratError, // 14 ( C): Deinstall character device driver
|
---|
175 | StratError, // 15 ( ): Unused
|
---|
176 | StratError, // 16 (B ): Count partitionable fixed disks
|
---|
177 | StratError, // 17 (B ): Get logical unit mapping of fixed disk
|
---|
178 | StratError, // 18 ( ): Unused
|
---|
179 | StratError, // 19 ( ): Unused
|
---|
180 | StratError, // 1A ( ): Unused
|
---|
181 | StratError, // 1B ( ): Unused
|
---|
182 | StratShutdown, // 1C (BC): Notify start or end of system shutdown
|
---|
183 | StratError, // 1D (B ): Get driver capabilities
|
---|
184 | StratError, // 1E ( ): Unused
|
---|
185 | StratInitComplete // 1F (BC): Notify end of initialization
|
---|
186 | };
|
---|
187 | //******************************************************************************
|
---|
188 | // Strategy entry point
|
---|
189 | //
|
---|
190 | // The strategy entry point must be declared according to the STRATEGY
|
---|
191 | // calling convention, which fetches arguments from the correct registers.
|
---|
192 | //******************************************************************************
|
---|
193 | ULONG Strategy(RP __far* rp);
|
---|
194 | #pragma aux (STRATEGY) Strategy "ALSA_STRATEGY";
|
---|
195 | ULONG Strategy(RP __far* rp)
|
---|
196 | {
|
---|
197 | if (rp->Command < sizeof(StratDispatch)/sizeof(StratDispatch[0]))
|
---|
198 | return(StratDispatch[rp->Command](rp));
|
---|
199 | else return(RPERR_COMMAND | RPDONE);
|
---|
200 | }
|
---|
201 | //******************************************************************************
|
---|
202 | //******************************************************************************
|
---|