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 | * Copyright (c) 2013-2015 David Azarewicz david@88watts.net
|
---|
8 | *
|
---|
9 | * This program is free software; you can redistribute it and/or
|
---|
10 | * modify it under the terms of the GNU General Public License as
|
---|
11 | * published by the Free Software Foundation; either version 2 of
|
---|
12 | * the License, or (at your option) any later version.
|
---|
13 | *
|
---|
14 | * This program is distributed in the hope that it will be useful,
|
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
17 | * GNU General Public License for more details.
|
---|
18 | *
|
---|
19 | * You should have received a copy of the GNU General Public
|
---|
20 | * License along with this program; if not, write to the Free
|
---|
21 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
|
---|
22 | * USA.
|
---|
23 | *
|
---|
24 | */
|
---|
25 |
|
---|
26 | #define INCL_NOPMAPI
|
---|
27 | #define INCL_DOSINFOSEG // Need Global info seg in rm.cpp algorithms
|
---|
28 | #include <os2.h>
|
---|
29 |
|
---|
30 | #include <devhelp.h>
|
---|
31 | //DAZ #include <devrp.h>
|
---|
32 | #include <devown.h>
|
---|
33 | #include "strategy.h"
|
---|
34 | #include <ossidc32.h>
|
---|
35 | #include <dbgos2.h>
|
---|
36 | #include <string.h>
|
---|
37 |
|
---|
38 | ULONG StratRead(REQPACKET __far *_rp);
|
---|
39 | ULONG StratIOCtl(REQPACKET __far *_rp);
|
---|
40 | ULONG StratClose(REQPACKET __far *_rp);
|
---|
41 |
|
---|
42 | ULONG DiscardableInit(REQPACKET __far*);
|
---|
43 | ULONG deviceOwner = DEV_NO_OWNER;
|
---|
44 | ULONG numOS2Opens = 0;
|
---|
45 | extern BOOL fRewired; //pci.c
|
---|
46 |
|
---|
47 | extern DBGINT DbgInt;
|
---|
48 |
|
---|
49 | //******************************************************************************
|
---|
50 | ULONG StratOpen(REQPACKET __far* rp)
|
---|
51 | {
|
---|
52 | if (numOS2Opens == 0)
|
---|
53 | {
|
---|
54 | deviceOwner = DEV_PDD_OWNER;
|
---|
55 | }
|
---|
56 | numOS2Opens++;
|
---|
57 | return RPDONE;
|
---|
58 | }
|
---|
59 |
|
---|
60 | //******************************************************************************
|
---|
61 | //DAZ #pragma off (unreferenced)
|
---|
62 | static ULONG StratWrite(REQPACKET __far* rp)
|
---|
63 | //DAZ #pragma on (unreferenced)
|
---|
64 | {
|
---|
65 | return RPDONE | RPERR;
|
---|
66 | }
|
---|
67 |
|
---|
68 | //******************************************************************************
|
---|
69 | // External initialization entry-point
|
---|
70 | //******************************************************************************
|
---|
71 | ULONG StratInit(REQPACKET __far* rp)
|
---|
72 | {
|
---|
73 | ULONG rc;
|
---|
74 |
|
---|
75 | memset(&DbgInt, 0, sizeof(DbgInt));
|
---|
76 | DbgPrintIrq();
|
---|
77 |
|
---|
78 | //DAZ RPInit __far* rp = (RPInit __far*)_rp;
|
---|
79 | rc = DiscardableInit(rp);
|
---|
80 | //dprintf(("StratInit End rc=%d", rc));
|
---|
81 | DbgPrintIrq();
|
---|
82 | DbgInt.ulState = 1;
|
---|
83 | return rc;
|
---|
84 | }
|
---|
85 |
|
---|
86 | //******************************************************************************
|
---|
87 | // External initialization complete entry-point
|
---|
88 | //******************************************************************************
|
---|
89 | //DAZ #pragma off (unreferenced)
|
---|
90 | ULONG StratInitComplete(REQPACKET __far* rp)
|
---|
91 | //DAZ #pragma on (unreferenced)
|
---|
92 | {
|
---|
93 | DbgInt.ulState = 2;
|
---|
94 | DbgPrintIrq();
|
---|
95 | //dprintf(("StratInitComplete"));
|
---|
96 | return(RPDONE);
|
---|
97 | }
|
---|
98 |
|
---|
99 | //******************************************************************************
|
---|
100 | //DAZ #pragma off (unreferenced)
|
---|
101 | ULONG StratShutdown(REQPACKET __far *rp)
|
---|
102 | //DAZ #pragma on (unreferenced)
|
---|
103 | {
|
---|
104 | //DAZ RPShutdown __far *rp = (RPShutdown __far *)_rp;
|
---|
105 |
|
---|
106 | //dprintf(("StratShutdown %d", rp->Function));
|
---|
107 | if(rp->shutdown.Function == 1) //end of shutdown
|
---|
108 | {
|
---|
109 | OSS32_Shutdown();
|
---|
110 | }
|
---|
111 | return(RPDONE);
|
---|
112 | }
|
---|
113 |
|
---|
114 | //******************************************************************************
|
---|
115 | // Handle unsupported requests
|
---|
116 | static ULONG StratError(REQPACKET __far* rp)
|
---|
117 | {
|
---|
118 | return RPERR_BADCOMMAND | RPDONE;
|
---|
119 | }
|
---|
120 |
|
---|
121 | //******************************************************************************
|
---|
122 | // Strategy dispatch table
|
---|
123 | //
|
---|
124 | // This table is used by the strategy routine to dispatch strategy requests
|
---|
125 | //******************************************************************************
|
---|
126 | typedef ULONG (*RPHandler)(REQPACKET __far* rp);
|
---|
127 | RPHandler StratDispatch[] =
|
---|
128 | {
|
---|
129 | StratInit, // 00 (BC): Initialization
|
---|
130 | StratError, // 01 (B ): Media check
|
---|
131 | StratError, // 02 (B ): Build BIOS parameter block
|
---|
132 | StratError, // 03 ( ): Unused
|
---|
133 | StratRead, // 04 (BC): Read
|
---|
134 | StratError, // 05 ( C): Nondestructive read with no wait
|
---|
135 | StratError, // 06 ( C): Input status
|
---|
136 | StratError, // 07 ( C): Input flush
|
---|
137 | StratWrite, // 08 (BC): Write
|
---|
138 | StratError, // 09 (BC): Write verify
|
---|
139 | StratError, // 0A ( C): Output status
|
---|
140 | StratError, // 0B ( C): Output flush
|
---|
141 | StratError, // 0C ( ): Unused
|
---|
142 | StratOpen, // 0D (BC): Open
|
---|
143 | StratClose, // 0E (BC): Close
|
---|
144 | StratError, // 0F (B ): Removable media check
|
---|
145 | StratIOCtl, // 10 (BC): IO Control
|
---|
146 | StratError, // 11 (B ): Reset media
|
---|
147 | StratError, // 12 (B ): Get logical unit
|
---|
148 | StratError, // 13 (B ): Set logical unit
|
---|
149 | StratError, // 14 ( C): Deinstall character device driver
|
---|
150 | StratError, // 15 ( ): Unused
|
---|
151 | StratError, // 16 (B ): Count partitionable fixed disks
|
---|
152 | StratError, // 17 (B ): Get logical unit mapping of fixed disk
|
---|
153 | StratError, // 18 ( ): Unused
|
---|
154 | StratError, // 19 ( ): Unused
|
---|
155 | StratError, // 1A ( ): Unused
|
---|
156 | StratError, // 1B ( ): Unused
|
---|
157 | StratShutdown, // 1C (BC): Notify start or end of system shutdown
|
---|
158 | StratError, // 1D (B ): Get driver capabilities
|
---|
159 | StratError, // 1E ( ): Unused
|
---|
160 | StratInitComplete // 1F (BC): Notify end of initialization
|
---|
161 | };
|
---|
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 | //******************************************************************************
|
---|
169 | #pragma aux (STRATEGY) Strategy "ALSA_STRATEGY";
|
---|
170 | ULONG Strategy(REQPACKET __far* rp)
|
---|
171 | {
|
---|
172 | if (fRewired)
|
---|
173 | {
|
---|
174 | fRewired = FALSE;
|
---|
175 | rprintf(("Strategy: Resuming"));
|
---|
176 | OSS32_APMResume();
|
---|
177 | DbgPrintIrq();
|
---|
178 | }
|
---|
179 |
|
---|
180 | if (rp->bCommand < sizeof(StratDispatch)/sizeof(StratDispatch[0])) return(StratDispatch[rp->bCommand](rp));
|
---|
181 | else return(RPERR_BADCOMMAND | RPDONE);
|
---|
182 | }
|
---|
183 |
|
---|