source: GPL/branches/uniaud32-2.1.x/drv32/strategy.c@ 550

Last change on this file since 550 was 550, checked in by David Azarewicz, 14 years ago

merge interrupt fixes from trunk

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