blob: f3761fb29871aec334e04725c45e3a7d4a9a648e (
plain)
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
|
/*
* CHU - driver for CH375 in disk mode
* Copyright (C) 2024 Javier S. Pedro
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
#ifndef CHUDISK_H
#define CHUDISK_H
#include <stdbool.h>
#include "inc/dosdrv.h"
#define MAX_UNITS 4
#define SECTOR_SIZE 512
// Configuration values shared between driver init code and resident code
/* Used by ch375.h, too. */
extern unsigned short ch375_port;
extern unsigned char num_units;
extern bool read_only;
extern bool show_fat32;
extern struct chudisk_data
{
/** Pointers to all BPBs, to return to DOS during init. */
DOS_BPB * bpb_ptrs[MAX_UNITS];
/** Whether we are ready to handle IO, i.e. disk init, partitions scanned. */
bool ready;
uint32_t sectors;
uint32_t bytesPerSector;
struct chudisk_unit {
/** Whether the partition exists (start_sector points to it) */
bool exists;
/** Note in theory may be zero (superfloppy) */
uint32_t start_sector;
/** Number of sectors for this partition. */
uint32_t sectors;
/** Whether the partition's BPB was loaded. */
bool ready;
/** DOS device params (contains BPB), only valid if 'ready'. */
DOS_BPB bpb;
} unit[MAX_UNITS];
} data;
// Functions called by both init part and resident part
extern void driver_init(DOS_DRS __far *drs);
extern char resident_end;
extern uint8_t wait_for_ch375_result(unsigned int max_ticks);
// CHUDISK IOCTLs
// These are used with the DISK major
// TODO Not sure we can really happily add custom minors here,
// but then again DOS outright refuses to accept any other major
enum CHUDISK_IOCTL_DISK_MINOR {
CHUDISK_IOCTL_DISK_READ_ABS_SECTOR = 0xC1
};
typedef _Packed union CHUDISK_IOCTL_DISK_DATA
{
struct CHUDISK_RWABSSECTOR {
uint32_t sector;
uint8_t sectors;
void far * buffer;
} rwabs;
} CHUDISK_IOCTL_DISK_DATA;
#endif // CHUDISK_H
|