source: sbliveos2/trunk/drv32/strategy.c@ 145

Last change on this file since 145 was 142, checked in by ktk, 25 years ago

Import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: strategy.c 142 2000-04-23 14:55:46Z ktk $ */
2
3//******************************************************************************
4// Strategy entry point
5//
6// Copyright 2000 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//******************************************************************************
24extern "C" { // 16-bit header files are not C++ aware
25#define INCL_NOPMAPI
26#define INCL_DOSINFOSEG
27#include <os2.h>
28}
29
30#include <devhelp.h>
31#include <devrp.h>
32#include <devown.h>
33#include "strategy.h"
34#include <ossidc.h>
35
36ULONG StratIOCtl(RP __far *_rp);
37ULONG StratClose(RP __far *_rp);
38
39// SvL: Needed in StratOpen
40ULONG deviceOwner = DEV_NO_OWNER;
41ULONG numOS2Opens = 0;
42// SvL: End
43
44ULONG StratOpen(RP __far*)
45{
46 if (numOS2Opens == 0) {
47 deviceOwner = DEV_PDD_OWNER;
48 }
49 numOS2Opens++;
50 return RPDONE;
51}
52
53#pragma off (unreferenced)
54static ULONG StratWrite(RP __far* _rp)
55#pragma on (unreferenced)
56{
57 return RPDONE | RPERR;
58}
59
60extern ULONG DiscardableInit(RPInit __far*);
61
62// External initialization entry-point
63ULONG StratInit(RP __far* _rp)
64{
65 RPInit __far* rp = (RPInit __far*)_rp;
66 return DiscardableInit(rp);
67}
68
69
70// External initialization entry-point
71#pragma off (unreferenced)
72ULONG StratInitComplete(RP __far* _rp)
73#pragma on (unreferenced)
74{
75 return(RPDONE);
76}
77
78#pragma off (unreferenced)
79ULONG StratShutdown(RP __far *_rp)
80#pragma on (unreferenced)
81{
82 RPShutdown __far *rp = (RPShutdown __far *)_rp;
83
84 if(rp->Function == 1) {//end of shutdown
85 OSS32_RemoveDriver();
86 }
87 return(RPDONE);
88}
89
90// Handle unsupported requests
91static ULONG StratError(RP __far*)
92{
93 return RPERR_COMMAND | RPDONE;
94}
95
96
97// Strategy dispatch table
98//
99// This table is used by the strategy routine to dispatch strategy requests
100
101typedef ULONG (*RPHandler)(RP __far* rp);
102RPHandler StratDispatch[] =
103{
104 StratInit, // 00 (BC): Initialization
105 StratError, // 01 (B ): Media check
106 StratError, // 02 (B ): Build BIOS parameter block
107 StratError, // 03 ( ): Unused
108 StratError, // 04 (BC): Read
109 StratError, // 05 ( C): Nondestructive read with no wait
110 StratError, // 06 ( C): Input status
111 StratError, // 07 ( C): Input flush
112 StratWrite, // 08 (BC): Write
113 StratError, // 09 (BC): Write verify
114 StratError, // 0A ( C): Output status
115 StratError, // 0B ( C): Output flush
116 StratError, // 0C ( ): Unused
117 StratOpen, // 0D (BC): Open
118 StratClose, // 0E (BC): Close
119 StratError, // 0F (B ): Removable media check
120 StratIOCtl, // 10 (BC): IO Control
121 StratError, // 11 (B ): Reset media
122 StratError, // 12 (B ): Get logical unit
123 StratError, // 13 (B ): Set logical unit
124 StratError, // 14 ( C): Deinstall character device driver
125 StratError, // 15 ( ): Unused
126 StratError, // 16 (B ): Count partitionable fixed disks
127 StratError, // 17 (B ): Get logical unit mapping of fixed disk
128 StratError, // 18 ( ): Unused
129 StratError, // 19 ( ): Unused
130 StratError, // 1A ( ): Unused
131 StratError, // 1B ( ): Unused
132 StratShutdown, // 1C (BC): Notify start or end of system shutdown
133 StratError, // 1D (B ): Get driver capabilities
134 StratError, // 1E ( ): Unused
135 StratInitComplete // 1F (BC): Notify end of initialization
136};
137
138
139
140// Strategy entry point
141//
142// The strategy entry point must be declared according to the STRATEGY
143// calling convention, which fetches arguments from the correct registers.
144
145ULONG Strategy(RP __far* rp);
146#pragma aux (STRATEGY) Strategy "SBLIVE_STRATEGY";
147ULONG Strategy(RP __far* rp)
148{
149 if (rp->Command < sizeof(StratDispatch)/sizeof(StratDispatch[0]))
150 return(StratDispatch[rp->Command](rp));
151 else return(RPERR_COMMAND | RPDONE);
152}
153
154
155
Note: See TracBrowser for help on using the repository browser.