aboutsummaryrefslogtreecommitdiff
path: root/dos/chudisk.h
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2026-10-26 00:50:06 +0100
committerJavier <dev.git@javispedro.com>2026-10-26 00:50:06 +0100
commit6b8a368c51082fdd010ef5e1b0be4eb9b5059d1a (patch)
treee274d41a8dd5e912e20617a937a1fda5af91f8de /dos/chudisk.h
parent9b1cf601360fb194047e6dcc2af75c2f38c611ec (diff)
downloadchu-6b8a368c51082fdd010ef5e1b0be4eb9b5059d1a.tar.gz
chu-6b8a368c51082fdd010ef5e1b0be4eb9b5059d1a.zip
refactor common parts into inc/ch375.h and add win9x, linux drivers
Diffstat (limited to 'dos/chudisk.h')
-rw-r--r--dos/chudisk.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/dos/chudisk.h b/dos/chudisk.h
new file mode 100644
index 0000000..1d2fbe4
--- /dev/null
+++ b/dos/chudisk.h
@@ -0,0 +1,93 @@
+/*
+ * 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"
+#include "ch375dos.h"
+
+#define MAX_UNITS 4
+
+#define SECTOR_SIZE 512
+
+// Configuration values shared between driver init code and resident code
+extern struct ch375 ch375_dev;
+
+extern unsigned char num_units;
+
+extern bool read_only;
+
+extern bool show_fat32;
+
+/** Runtime data */
+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;
+
+ /** Current media: number of sectors. */
+ uint32_t sectors;
+ /** Current media: bytes per sector (usually 512). */
+ 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