| 1 | /* $Id: strategy.c,v 1.1 2000/04/23 14:55:25 ktk Exp $ */
|
|---|
| 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 | //******************************************************************************
|
|---|
| 24 | extern "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 |
|
|---|
| 36 | extern ULONG StratIOCtl(RP __far *_rp);
|
|---|
| 37 | extern ULONG StratClose(RP __far *_rp);
|
|---|
| 38 | extern ULONG DiscardableInit(RPInit __far*_rp);
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 | // SvL: Needed in StratOpen
|
|---|
| 42 | ULONG deviceOwner = DEV_NO_OWNER;
|
|---|
| 43 | ULONG numOS2Opens = 0;
|
|---|
| 44 | // SvL: End
|
|---|
| 45 |
|
|---|
| 46 | ULONG StratOpen(RP __far*)
|
|---|
| 47 | {
|
|---|
| 48 | if (numOS2Opens == 0) {
|
|---|
| 49 | deviceOwner = DEV_PDD_OWNER;
|
|---|
| 50 | }
|
|---|
| 51 | numOS2Opens++;
|
|---|
| 52 | return RPDONE;
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | // External initialization entry-point
|
|---|
| 56 | ULONG StratInit(RP __far* _rp)
|
|---|
| 57 | {
|
|---|
| 58 | RPInit __far* rp = (RPInit __far*)_rp;
|
|---|
| 59 | return DiscardableInit(rp);
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 | // External initialization entry-point
|
|---|
| 64 | ULONG StratInitComplete(RP __far* )
|
|---|
| 65 | {
|
|---|
| 66 | return(RPDONE);
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | ULONG StratShutdown(RP __far *_rp)
|
|---|
| 70 | {
|
|---|
| 71 | RPShutdown __far *rp = (RPShutdown __far *)_rp;
|
|---|
| 72 |
|
|---|
| 73 | if(rp->Function == 1) {//end of shutdown
|
|---|
| 74 | OSS32_RemoveDriver();
|
|---|
| 75 | }
|
|---|
| 76 | return(RPDONE);
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | // Handle unsupported requests
|
|---|
| 80 | static ULONG StratError(RP __far*)
|
|---|
| 81 | {
|
|---|
| 82 | return RPERR_COMMAND | RPDONE;
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 | // Strategy dispatch table
|
|---|
| 87 | //
|
|---|
| 88 | // This table is used by the strategy routine to dispatch strategy requests
|
|---|
| 89 |
|
|---|
| 90 | typedef ULONG (*RPHandler)(RP __far* rp);
|
|---|
| 91 | RPHandler StratDispatch[] =
|
|---|
| 92 | {
|
|---|
| 93 | StratInit, // 00 (BC): Initialization
|
|---|
| 94 | StratError, // 01 (B ): Media check
|
|---|
| 95 | StratError, // 02 (B ): Build BIOS parameter block
|
|---|
| 96 | StratError, // 03 ( ): Unused
|
|---|
| 97 | StratError, // 04 (BC): Read
|
|---|
| 98 | StratError, // 05 ( C): Nondestructive read with no wait
|
|---|
| 99 | StratError, // 06 ( C): Input status
|
|---|
| 100 | StratError, // 07 ( C): Input flush
|
|---|
| 101 | StratError, // 08 (BC): Write
|
|---|
| 102 | StratError, // 09 (BC): Write verify
|
|---|
| 103 | StratError, // 0A ( C): Output status
|
|---|
| 104 | StratError, // 0B ( C): Output flush
|
|---|
| 105 | StratError, // 0C ( ): Unused
|
|---|
| 106 | StratOpen, // 0D (BC): Open
|
|---|
| 107 | StratClose, // 0E (BC): Close
|
|---|
| 108 | StratError, // 0F (B ): Removable media check
|
|---|
| 109 | StratIOCtl, // 10 (BC): IO Control
|
|---|
| 110 | StratError, // 11 (B ): Reset media
|
|---|
| 111 | StratError, // 12 (B ): Get logical unit
|
|---|
| 112 | StratError, // 13 (B ): Set logical unit
|
|---|
| 113 | StratError, // 14 ( C): Deinstall character device driver
|
|---|
| 114 | StratError, // 15 ( ): Unused
|
|---|
| 115 | StratError, // 16 (B ): Count partitionable fixed disks
|
|---|
| 116 | StratError, // 17 (B ): Get logical unit mapping of fixed disk
|
|---|
| 117 | StratError, // 18 ( ): Unused
|
|---|
| 118 | StratError, // 19 ( ): Unused
|
|---|
| 119 | StratError, // 1A ( ): Unused
|
|---|
| 120 | StratError, // 1B ( ): Unused
|
|---|
| 121 | StratShutdown, // 1C (BC): Notify start or end of system shutdown
|
|---|
| 122 | StratError, // 1D (B ): Get driver capabilities
|
|---|
| 123 | StratError, // 1E ( ): Unused
|
|---|
| 124 | StratInitComplete // 1F (BC): Notify end of initialization
|
|---|
| 125 | };
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 | // Strategy entry point
|
|---|
| 130 | //
|
|---|
| 131 | // The strategy entry point must be declared according to the STRATEGY
|
|---|
| 132 | // calling convention, which fetches arguments from the correct registers.
|
|---|
| 133 |
|
|---|
| 134 | ULONG Strategy(RP __far* rp);
|
|---|
| 135 | #pragma aux (STRATEGY) Strategy "SBLIVE_STRATEGY";
|
|---|
| 136 | ULONG Strategy(RP __far* rp)
|
|---|
| 137 | {
|
|---|
| 138 | if (rp->Command < sizeof(StratDispatch)/sizeof(StratDispatch[0]))
|
|---|
| 139 | return(StratDispatch[rp->Command](rp));
|
|---|
| 140 | else return(RPERR_COMMAND | RPDONE);
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|