-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtemplate.c
112 lines (95 loc) · 3.08 KB
/
template.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* Template for writing DOS device drivers in Open Watcom C
*
* Copyright (C) 2022, Eduardo Casino ([email protected])
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
#include <stdint.h>
#include <stddef.h>
#include "device.h"
#include "devinit.h"
#include "template.h"
#ifdef USE_INTERNAL_STACK
static uint8_t our_stack[STACK_SIZE];
uint8_t *stack_bottom = our_stack + STACK_SIZE;
uint32_t dos_stack;
#endif // USE_INTERNAL_STACK
request __far *fpRequest = (request __far *)0;
static uint16_t Open( void )
{
return S_DONE;
}
static uint16_t Close( void )
{
return S_DONE;
}
static driverFunction_t dispatchTable[] =
{
DeviceInit, // 0x00 Initialize
NULL, // 0x01 MEDIA Check
NULL, // 0x02 Build BPB
NULL, // 0x03 Ioctl In
NULL, // 0x04 Input (Read)
NULL, // 0x05 Non-destructive Read
NULL, // 0x06 Input Status
NULL, // 0x07 Input Flush
NULL, // 0x08 Output (Write)
NULL, // 0x09 Output with verify
NULL, // 0x0A Output Status
NULL, // 0x0B Output Flush
NULL, // 0x0C Ioctl Out
Open, // 0x0D Device Open
Close, // 0x0E Device Close
NULL, // 0x0F Removable MEDIA
NULL, // 0x10 Output till busy
NULL, // 0x11 Unused
NULL, // 0x12 Unused
NULL, // 0x13 Generic Ioctl
NULL, // 0x14 Unused
NULL, // 0x15 Unused
NULL, // 0x16 Unused
NULL, // 0x17 Get Logical Device
NULL, // 0x18 Set Logical Device
NULL // 0x19 Ioctl Query
};
static driverFunction_t currentFunction;
void __far DeviceInterrupt( void )
#pragma aux DeviceInterrupt __parm []
{
#ifdef USE_INTERNAL_STACK
switch_stack();
#endif
push_regs();
if ( fpRequest->r_command > C_MAXCMD || NULL == (currentFunction = dispatchTable[fpRequest->r_command]) )
{
fpRequest->r_status = S_DONE | S_ERROR | E_CMD;
}
else
{
fpRequest->r_status = currentFunction();
}
pop_regs();
#ifdef USE_INTERNAL_STACK
restore_stack();
#endif
}
void __far DeviceStrategy( request __far *req )
#pragma aux DeviceStrategy __parm [__es __bx]
{
fpRequest = req;
}