source: GPL/branches/uniaud32-next/drv32/strategy.c@ 677

Last change on this file since 677 was 677, checked in by Paul Smedley, 4 years ago

More code cleanups from AlexT from #os2russian

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