1 /*************************************************************************** 2 * * 3 * LIBDSK: General floppy and diskimage access library * 4 * Copyright (C) 2001-3, 2015 John Elliott <seasip.webmaster@gmail.com> * 5 * * 6 * This library is free software; you can redistribute it and/or * 7 * modify it under the terms of the GNU Library General Public * 8 * License as published by the Free Software Foundation; either * 9 * version 2 of the License, or (at your option) any later version. * 10 * * 11 * This library is distributed in the hope that it will be useful, * 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 14 * Library General Public License for more details. * 15 * * 16 * You should have received a copy of the GNU Library General Public * 17 * License along with this library; if not, write to the Free * 18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 19 * MA 02111-1307, USA * 20 * * 21 ***************************************************************************/ 22 23 /* Declarations for the IMD driver. We handle this like the CFI and APRIDISK 24 * drivers, by unpacking the disc image into memory. 25 * 26 */ 27 28 typedef struct 29 { 30 unsigned char imds_cylinder; /* Cylinder ID */ 31 unsigned char imds_head; /* Head ID */ 32 unsigned char imds_sector; /* Sector ID */ 33 unsigned char imds_status; /* Status */ 34 unsigned short imds_seclen; /* Length of sector on disk */ 35 unsigned short imds_datalen; /* Length of (compressed) data */ 36 unsigned char imds_data[1]; /* Data */ 37 } IMD_SECTOR; 38 39 40 typedef struct 41 { 42 unsigned char imdt_mode; /* Recording mode */ 43 unsigned char imdt_cylinder; /* Cylinder */ 44 unsigned char imdt_head; /* Head and flags */ 45 unsigned char imdt_sectors; /* Sector count */ 46 unsigned short imdt_seclen; /* Default sector length */ 47 IMD_SECTOR *imdt_sec[1]; /* Pointers to sector data */ 48 } IMD_TRACK; 49 50 51 typedef struct 52 { 53 DSK_DRIVER imd_super; 54 IMD_TRACK **imd_tracks; 55 char *imd_filename; 56 dsk_ltrack_t imd_ntracks; 57 int imd_dirty; 58 int imd_readonly; 59 dsk_psect_t imd_sec; 60 } IMD_DSK_DRIVER; 61 62 dsk_err_t imd_open(DSK_DRIVER *self, const char *filename); 63 dsk_err_t imd_creat(DSK_DRIVER *self, const char *filename); 64 dsk_err_t imd_close(DSK_DRIVER *self); 65 dsk_err_t imd_read(DSK_DRIVER *self, const DSK_GEOMETRY *geom, 66 void *buf, dsk_pcyl_t cylinder, 67 dsk_phead_t head, dsk_psect_t sector); 68 dsk_err_t imd_write(DSK_DRIVER *self, const DSK_GEOMETRY *geom, 69 const void *buf, dsk_pcyl_t cylinder, 70 dsk_phead_t head, dsk_psect_t sector); 71 dsk_err_t imd_format(DSK_DRIVER *self, DSK_GEOMETRY *geom, 72 dsk_pcyl_t cylinder, dsk_phead_t head, 73 const DSK_FORMAT *format, unsigned char filler); 74 dsk_err_t imd_xseek(DSK_DRIVER *self, const DSK_GEOMETRY *geom, 75 dsk_pcyl_t cylinder, dsk_phead_t head); 76 dsk_err_t imd_status(DSK_DRIVER *self, const DSK_GEOMETRY *geom, 77 dsk_phead_t head, unsigned char *result); 78 dsk_err_t imd_secid(DSK_DRIVER *self, const DSK_GEOMETRY *geom, 79 dsk_pcyl_t cyl, dsk_phead_t head, DSK_FORMAT *result); 80 81 dsk_err_t imd_getgeom(DSK_DRIVER *self, DSK_GEOMETRY *geom); 82 83 dsk_err_t imd_xread(DSK_DRIVER *self, const DSK_GEOMETRY *geom, 84 void *buf, dsk_pcyl_t cylinder, dsk_phead_t head, 85 dsk_pcyl_t cyl_expected, dsk_phead_t head_expected, 86 dsk_psect_t sector, size_t sector_size, int *deleted); 87 88 dsk_err_t imd_xwrite(DSK_DRIVER *self, const DSK_GEOMETRY *geom, 89 const void *buf, dsk_pcyl_t cylinder, dsk_phead_t head, 90 dsk_pcyl_t cyl_expected, dsk_phead_t head_expected, 91 dsk_psect_t sector, size_t sector_size, int deleted); 92 93