1 /*
2  * fsdevicetypes.h - File system device.
3  *
4  * Written by
5  *  Andreas Boose <viceteam@t-online.de>
6  *
7  * This file is part of VICE, the Versatile Commodore Emulator.
8  * See README for copyright notice.
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program; if not, write to the Free Software
22  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23  *  02111-1307  USA.
24  *
25  */
26 
27 #ifndef VICE_FSDEVICETYPES_H
28 #define VICE_FSDEVICETYPES_H
29 
30 #include "types.h"
31 
32 #define FSDEVICE_BUFFER_MAX 16
33 #define FSDEVICE_DEVICE_MAX 4
34 
35 #define FSDEVICE_TRACK_MAX   80
36 #define FSDEVICE_SECTOR_MAX  32
37 
38 enum fsmode {
39     Write, Read, Append, Directory, Relative
40 };
41 
42 struct fileio_info_s;
43 struct ioutil_dir_s;
44 struct tape_image_s;
45 
46 struct bufinfo_s {
47     struct fileio_info_s *fileio_info;
48     struct ioutil_dir_s *ioutil_dir;
49     struct tape_image_s *tape;
50     enum fsmode mode;
51     char *dir;
52     uint8_t *name;
53     int buflen;
54     uint8_t *bufp;
55     int eof;
56     int type;
57     uint8_t buffered;  /* Buffered Byte: Added to buffer reads to remove buffering from iec code */
58     int isbuffered; /* TRUE is a byte exists in the buffer above */
59     int iseof;      /* TRUE if an EOF is detected on a buffered read */
60     char *dirmask;
61                     /* REL file support */
62     int reclen;
63     int num_records;
64     int current_record;                 /* 0-based */
65     int position_in_record;             /* 0-based */
66     int current_record_length;
67     int record_is_dirty;
68 };
69 typedef struct bufinfo_s bufinfo_t;
70 
71 struct fsdevice_dev_s {
72     unsigned int eptr;
73     unsigned int elen;
74     char *errorl;
75     unsigned int cptr;
76     uint8_t *cmdbuf;
77     bufinfo_t bufinfo[FSDEVICE_BUFFER_MAX];
78     int track, sector; /* fake track/sector pointer */
79     uint8_t bam[(FSDEVICE_TRACK_MAX * FSDEVICE_SECTOR_MAX) >> 3]; /* fake bam */
80 };
81 typedef struct fsdevice_dev_s fsdevice_dev_t;
82 
83 extern fsdevice_dev_t fsdevice_dev[FSDEVICE_DEVICE_MAX];
84 
85 struct vdrive_s;
86 
87 extern void fsdevice_error(struct vdrive_s *vdrive, int code);
88 extern char *fsdevice_get_path(unsigned int unit);
89 extern int fsdevice_error_get_byte(struct vdrive_s *vdrive, uint8_t *data);
90 extern int fsdevice_flush_write_byte(struct vdrive_s *vdrive, uint8_t data);
91 
92 #endif
93