/* * 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 . */ #ifndef CHUDISK_H #define CHUDISK_H #include #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