[32] | 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)
|
---|
[587] | 7 | * Copyright (c) 2013-2015 David Azarewicz david@88watts.net
|
---|
[32] | 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>
|
---|
[547] | 30 | #include <string.h>
|
---|
[679] | 31 | #include <u32ioctl.h>
|
---|
| 32 | #include "devown.h"
|
---|
| 33 | #include "strategy.h"
|
---|
[32] | 34 |
|
---|
[587] | 35 | ULONG StratRead(REQPACKET __far *_rp);
|
---|
| 36 | ULONG StratIOCtl(REQPACKET __far *_rp);
|
---|
[32] | 37 |
|
---|
[587] | 38 | ULONG DiscardableInit(REQPACKET __far*);
|
---|
[32] | 39 | ULONG deviceOwner = DEV_NO_OWNER;
|
---|
| 40 | ULONG numOS2Opens = 0;
|
---|
| 41 |
|
---|
[587] | 42 | extern DBGINT DbgInt;
|
---|
[547] | 43 |
|
---|
[32] | 44 | //******************************************************************************
|
---|
[587] | 45 | ULONG StratOpen(REQPACKET __far* rp)
|
---|
[32] | 46 | {
|
---|
[587] | 47 | if (numOS2Opens == 0)
|
---|
| 48 | {
|
---|
| 49 | deviceOwner = DEV_PDD_OWNER;
|
---|
| 50 | }
|
---|
| 51 | numOS2Opens++;
|
---|
| 52 | return RPDONE;
|
---|
[32] | 53 | }
|
---|
[587] | 54 |
|
---|
[32] | 55 | //******************************************************************************
|
---|
[679] | 56 | ULONG 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 | //******************************************************************************
|
---|
[587] | 72 | //DAZ #pragma off (unreferenced)
|
---|
| 73 | static ULONG StratWrite(REQPACKET __far* rp)
|
---|
| 74 | //DAZ #pragma on (unreferenced)
|
---|
[32] | 75 | {
|
---|
| 76 | return RPDONE | RPERR;
|
---|
| 77 | }
|
---|
[587] | 78 |
|
---|
[32] | 79 | //******************************************************************************
|
---|
| 80 | // External initialization entry-point
|
---|
| 81 | //******************************************************************************
|
---|
[587] | 82 | ULONG StratInit(REQPACKET __far* rp)
|
---|
[32] | 83 | {
|
---|
[587] | 84 | ULONG rc;
|
---|
[32] | 85 |
|
---|
[587] | 86 | memset(&DbgInt, 0, sizeof(DbgInt));
|
---|
| 87 | DbgPrintIrq();
|
---|
[547] | 88 |
|
---|
[587] | 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;
|
---|
[32] | 95 | }
|
---|
[587] | 96 |
|
---|
[32] | 97 | //******************************************************************************
|
---|
| 98 | // External initialization complete entry-point
|
---|
| 99 | //******************************************************************************
|
---|
[587] | 100 | //DAZ #pragma off (unreferenced)
|
---|
| 101 | ULONG StratInitComplete(REQPACKET __far* rp)
|
---|
| 102 | //DAZ #pragma on (unreferenced)
|
---|
[32] | 103 | {
|
---|
[587] | 104 | DbgInt.ulState = 2;
|
---|
| 105 | DbgPrintIrq();
|
---|
| 106 | //dprintf(("StratInitComplete"));
|
---|
| 107 | return(RPDONE);
|
---|
[32] | 108 | }
|
---|
[587] | 109 |
|
---|
[32] | 110 | //******************************************************************************
|
---|
[587] | 111 | //DAZ #pragma off (unreferenced)
|
---|
| 112 | ULONG StratShutdown(REQPACKET __far *rp)
|
---|
| 113 | //DAZ #pragma on (unreferenced)
|
---|
[32] | 114 | {
|
---|
[587] | 115 | //DAZ RPShutdown __far *rp = (RPShutdown __far *)_rp;
|
---|
[32] | 116 |
|
---|
[587] | 117 | //dprintf(("StratShutdown %d", rp->Function));
|
---|
| 118 | if(rp->shutdown.Function == 1) //end of shutdown
|
---|
| 119 | {
|
---|
| 120 | OSS32_Shutdown();
|
---|
| 121 | }
|
---|
| 122 | return(RPDONE);
|
---|
[32] | 123 | }
|
---|
[587] | 124 |
|
---|
[32] | 125 | //******************************************************************************
|
---|
| 126 | // Handle unsupported requests
|
---|
[587] | 127 | static ULONG StratError(REQPACKET __far* rp)
|
---|
[32] | 128 | {
|
---|
[587] | 129 | return RPERR_BADCOMMAND | RPDONE;
|
---|
[32] | 130 | }
|
---|
[587] | 131 |
|
---|
[32] | 132 | //******************************************************************************
|
---|
| 133 | // Strategy dispatch table
|
---|
| 134 | //
|
---|
| 135 | // This table is used by the strategy routine to dispatch strategy requests
|
---|
| 136 | //******************************************************************************
|
---|
[587] | 137 | typedef ULONG (*RPHandler)(REQPACKET __far* rp);
|
---|
[32] | 138 | RPHandler StratDispatch[] =
|
---|
| 139 | {
|
---|
[587] | 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
|
---|
[32] | 172 | };
|
---|
[587] | 173 |
|
---|
[32] | 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";
|
---|
[587] | 181 | ULONG Strategy(REQPACKET __far* rp)
|
---|
[32] | 182 | {
|
---|
[587] | 183 | if (rp->bCommand < sizeof(StratDispatch)/sizeof(StratDispatch[0])) return(StratDispatch[rp->bCommand](rp));
|
---|
| 184 | else return(RPERR_BADCOMMAND | RPDONE);
|
---|
[32] | 185 | }
|
---|