source: GPL/branches/uniaud32-2.0/drv32/strategy.c@ 421

Last change on this file since 421 was 421, checked in by Paul Smedley, 16 years ago

Updates from Pasha to improve IRQ handling and resolve long delays at startup in APIC mode when using ACPI

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