1 #pragma once
2 #ifndef SRC_INCLUDE_FILESYS_H_INCLUDED
3 #define SRC_INCLUDE_FILESYS_H_INCLUDED 1
4 
5 
6  /*
7   * UAE - The Un*x Amiga Emulator
8   *
9   * Unix file system handler for AmigaDOS
10   *
11   * Copyright 1997 Bernd Schmidt
12   */
13 
14 struct hardfilehandle;
15 struct mountedinfo;
16 struct uaedev_config_info;
17 struct uae_prefs;
18 
19 #define MAX_HDF_CACHE_BLOCKS 128
20 #define MAX_SCSI_SENSE 36
21 struct hdf_cache
22 {
23 	bool valid;
24 	uae_u8 *data;
25 	uae_u64 block;
26 	bool dirty;
27 	int readcount;
28 	int writecount;
29 	time_t lastaccess;
30 };
31 
32 struct hardfiledata {
33     uae_u64 virtsize; // virtual size
34     uae_u64 physsize; // physical size (dynamic disk)
35     uae_u64 offset;
36     struct uaedev_config_info ci;
37     struct hardfilehandle *handle;
38     int handle_valid;
39     int dangerous;
40     int flags;
41     uae_u8 *cache;
42     int cache_valid;
43     uae_u64 cache_offset;
44     TCHAR vendor_id[8 + 1];
45     TCHAR product_id[16 + 1];
46     TCHAR product_rev[4 + 1];
47     TCHAR device_name[256];
48     /* geometry from possible RDSK block */
49     int rdbcylinders;
50     int rdbsectors;
51     int rdbheads;
52     uae_u8 *virtual_rdb;
53     uae_u64 virtual_size;
54     int unitnum;
55     int byteswap;
56     int adide;
57     int hfd_type;
58 
59     uae_u8 *vhd_header;
60     uae_u32 vhd_bamoffset;
61     uae_u32 vhd_bamsize;
62     uae_u32 vhd_blocksize;
63     uae_u8 *vhd_sectormap;
64     uae_u64 vhd_sectormapblock;
65     uae_u32 vhd_bitmapsize;
66     uae_u64 vhd_footerblock;
67 
68 	void *chd_handle;
69 
70     int drive_empty;
71     TCHAR *emptyname;
72 
73 	struct hdf_cache bcache[MAX_HDF_CACHE_BLOCKS];
74 	uae_u8 scsi_sense[MAX_SCSI_SENSE];
75 
76 	struct uaedev_config_info delayedci;
77 	int reinsertdelay;
78 	bool isreinsert;
79 };
80 
81 #define HFD_FLAGS_REALDRIVE 1
82 
83 struct hd_hardfiledata {
84     struct hardfiledata hfd;
85     uae_u64 size;
86     int cyls;
87     int heads;
88     int secspertrack;
89     int cyls_def;
90     int secspertrack_def;
91     int heads_def;
92     int ansi_version;
93 };
94 
95 #define HD_CONTROLLER_UAE 0
96 #define HD_CONTROLLER_IDE0 1
97 #define HD_CONTROLLER_IDE1 2
98 #define HD_CONTROLLER_IDE2 3
99 #define HD_CONTROLLER_IDE3 4
100 #define HD_CONTROLLER_SCSI0 5
101 #define HD_CONTROLLER_SCSI1 6
102 #define HD_CONTROLLER_SCSI2 7
103 #define HD_CONTROLLER_SCSI3 8
104 #define HD_CONTROLLER_SCSI4 9
105 #define HD_CONTROLLER_SCSI5 10
106 #define HD_CONTROLLER_SCSI6 11
107 #define HD_CONTROLLER_PCMCIA_SRAM 12
108 #define HD_CONTROLLER_PCMCIA_IDE 13
109 
110 #define FILESYS_VIRTUAL 0
111 #define FILESYS_HARDFILE 1
112 #define FILESYS_HARDFILE_RDB 2
113 #define FILESYS_HARDDRIVE 3
114 #define FILESYS_CD 4
115 
116 #define MAX_FILESYSTEM_UNITS 30
117 
118 struct uaedev_mount_info;
119 extern struct uaedev_mount_info options_mountinfo;
120 
121 struct hardfiledata *get_hardfile_data (int nr);
122 #define FILESYS_MAX_BLOCKSIZE 2048
123 
124 int hdf_open (struct hardfiledata *hfd, const TCHAR *altname);
125 int hdf_dup (struct hardfiledata *dhfd, const struct hardfiledata *shfd);
126 void hdf_close (struct hardfiledata *hfd);
127 int hdf_read_rdb (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
128 int hdf_read (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
129 int hdf_write (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
130 int hdf_getnumharddrives (void);
131 TCHAR *hdf_getnameharddrive (int index, int flags, int *sectorsize, int *dangerousdrive);
132 int isspecialdrive(const TCHAR *name);
133 int get_native_path(uae_u32 lock, TCHAR *out);
134 void hardfile_do_disk_change (struct uaedev_config_data *uci, bool insert);
135 void hardfile_send_disk_change (struct hardfiledata *hfd, bool insert);
136 int hardfile_media_change (struct hardfiledata *hfd, struct uaedev_config_info *ci, bool inserted, bool timer);
137 
138 void hdf_hd_close(struct hd_hardfiledata *hfd);
139 int hdf_hd_open(struct hd_hardfiledata *hfd);
140 
141 
142 int vhd_create (const TCHAR *name, uae_u64 size, uae_u32);
143 
144 int hdf_init_target (void);
145 int hdf_open_target (struct hardfiledata *hfd, const TCHAR *name);
146 int hdf_dup_target (struct hardfiledata *dhfd, const struct hardfiledata *shfd);
147 void hdf_close_target (struct hardfiledata *hfd);
148 int hdf_read_target (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
149 int hdf_write_target (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
150 int hdf_resize_target (struct hardfiledata *hfd, uae_u64 newsize);
151 void getchsgeometry (uae_u64 size, int *pcyl, int *phead, int *psectorspertrack);
152 void getchsgeometry_hdf (struct hardfiledata *hfd, uae_u64 size, int *pcyl, int *phead, int *psectorspertrack);
153 void getchspgeometry (uae_u64 total, int *pcyl, int *phead, int *psectorspertrack, bool idegeometry);
154 
155 void setsystime (void);
156 
157 //int set_filesys_unit (int nr, struct uaedev_config_info *ci);
158 //int add_filesys_unit (struct uaedev_config_info *ci);
159 
160 /** REMOVEME:
161   * nowhere used
162 **/
163 #if 0
164 int hardfile_remount (int nr);
165 #endif // 0
166 
167 #endif // SRC_INCLUDE_FILESYS_H_INCLUDED
168