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