OpenCBM
imgcopy.h
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version
5  * 2 of the License, or (at your option) any later version.
6  *
7  * Copyright 1999-2001 Michael Klein <michael(dot)klein(at)puffin(dot)lb(dot)shuttle(dot)de>
8  * Copyright 2011-2011 Thomas Winkler <t(dot)winkler(at)tirol(dot)com>
9 */
10 
11 /* $Id: imgcopy.h,v 1.8 2011-04-03 diddl Exp $ */
12 
13 #ifndef IMGCOPY_H
14 #define IMGCOPY_H
15 
16 //#define LIBIMGCOPY_DEBUG /* enable state logging and debugging */
17 
18 
19 /* standard .d80 track count */
20 #define D80_TRACKS 77
21 /* standard .d82 track count */
22 #define D81_TRACKS 80
23 /* standard .d82 track count */
24 #define D82_TRACKS 154
25 /* absolute limit. may not work with all drives */
26 #define TOT_TRACKS D82_TRACKS
27 
28 
29 #define D80_STD_BLOCKS ((39 * 29) + (14 * 27) + (11 * 25) + (13 * 23))
30 
31 #define D80_BLOCKS (D80_STD_BLOCKS)
32 #define D82_BLOCKS (D80_STD_BLOCKS *2)
33 
34 #define D81_BLOCKS (40 * D81_TRACKS)
35 
36 
37 #define D80_MAX_SECTORS 29
38 #define D81_MAX_SECTORS 40
39 
40 
41 #define MAX_SECTORS D81_MAX_SECTORS
42 #define MAX_TRACKS D82_TRACKS
43 
44 
45 
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 /*
52  * known BAM modes
53  */
54 typedef enum
55 {
56  bm_ignore = 0, /* all sectors */
57  bm_allocated = 1, /* allocated sectors */
58  bm_save = 2 /* allocated sectors + BAM track */
59 } imgcopy_bam_mode;
60 
61 
62 //
63 // supported types of image file
64 //
65 typedef enum
66 {
67  cbm_it_unknown = -1,
68  D64 = 0, /* all D64 types */
69  D71 = 1, /* D71 */
70  D80 = 2, /* D80 */
71  D81 = 3, /* D81 */
72  D82 = 4 /* D82 */
73 } imgcopy_image_type;
74 
75 
76 typedef enum
77 {
78  em_always,
79  em_on_error,
80  em_never
81 } imgcopy_error_mode;
82 
83 typedef enum
84 {
85  bs_invalid = 0,
86  bs_dont_copy = 1,
87  bs_must_copy = 2,
88  bs_error = 3,
89  bs_copied = 4
90 } imgcopy_bam_status;
91 
92 typedef struct
93 {
94  int warp;
95  int retries;
96  int interleave;
97  int start_track;
98  int end_track;
99  int two_sided;
100  int transfer_mode;
101  int cat_track;
102  int bam_track;
103  int max_tracks;
104  int block_count;
105  imgcopy_image_type image_type; // selected imagetype cause image filename extension
106  imgcopy_image_type image_type_std; // standard imagetype for drive type
107  enum cbm_device_type_e drive_type;
108  imgcopy_bam_mode bam_mode;
109  imgcopy_error_mode error_mode;
111 
112 typedef struct
113 {
114  int track;
115  int sector;
116  int read_result;
117  int write_result;
118  int sectors_processed;
119  int total_sectors;
120  imgcopy_settings *settings;
121  char bam[MAX_TRACKS+1][MAX_SECTORS+1];
123 
124 typedef enum
125 {
126  sev_fatal,
127  sev_warning,
128  sev_info,
129  sev_debug
130 } imgcopy_severity_e;
131 
132 typedef void (*imgcopy_message_cb)(int imgcopy_severity_e, const char *format, ...);
133 typedef int (*imgcopy_status_cb)(imgcopy_status status);
134 
135 
136 
137 // Prototypes
138 
139 
140 
141 
142 
143 #ifdef LIBIMGCOPY_DEBUG
144 /*
145  * print out the state of internal counters that are used on read
146  * and write transfers for debugging rare protocol races and hangups
147  */
148 extern void printDebugLibImgCounters(imgcopy_message_cb msg_cb);
149 #endif
150 
151 /*
152  * Build '\0'-terminated list of '\0'-terminated transfer mode names.
153  * Memory should be free()'d after use.
154  */
155 extern char * imgcopy_get_transfer_modes(void);
156 
157 /*
158  * parse transfer mode name ("serial1", "s2", "parallel"...) abbreviations
159  * are possible
160  */
161 extern int imgcopy_get_transfer_mode_index(const char *name);
162 
163 /*
164  * find out if "auto" transfer mode was specified. If yet, determine
165  * the best transfer mode we can use.
166  */
167 extern int imgcopy_check_auto_transfer_mode(CBM_FILE cbm_fd,
168  int auto_transfermode,
169  int drive);
170 
171 /*
172  * returns malloc()'d pointer to default settings.
173  * must be free()'d after use.
174  */
175 extern imgcopy_settings *imgcopy_get_default_settings(void);
176 
177 /*
178  * return number of sectors on a given track, -1 if invalid
179  */
180 extern int imgcopy_sector_count(imgcopy_settings *, int track);
181 
182 extern int imgcopy_read_image(CBM_FILE cbm_fd,
183  imgcopy_settings *settings,
184  int src_drive,
185  const char *dst_image,
186  imgcopy_message_cb msg_cb,
187  imgcopy_status_cb status_cb);
188 
189 extern int imgcopy_write_image(CBM_FILE cbm_fd,
190  imgcopy_settings *settings,
191  const char *src_image,
192  int dst_drive,
193  imgcopy_message_cb msg_cb,
194  imgcopy_status_cb status_cb);
195 
196 extern void imgcopy_cleanup(void);
197 
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 
203 #endif /* IMGCOPY_H */
#define CBM_FILE
Definition: opencbm.h:87
cbm_device_type_e
Definition: opencbm.h:114