OpenCBM
d82copy.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 #ifndef D82COPY_H
12 #define D82COPY_H
13 
14 //#define LIBD82COPY_DEBUG /* enable state logging and debugging */
15 
16 
17 /* standard .d80 track count */
18 #define D80_TRACKS 77
19 /* standard .d82 track count */
20 #define D82_TRACKS 154
21 /* absolute limit. may not work with all drives */
22 #define TOT_TRACKS D82_TRACKS
23 
24 
25 #define STD_BLOCKS ((39 * 29) + (14 * 27) + (11 * 25) + (13 * 23))
26 #define D80_BLOCKS (STD_BLOCKS)
27 #define D82_BLOCKS (STD_BLOCKS *2)
28 
29 
30 #define MAX_SECTORS 29
31 #define MAX_TRACKS D82_TRACKS
32 
33 
34 
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * known BAM modes
42  */
43 typedef enum
44 {
45  bm_ignore = 0, /* all sectors */
46  bm_allocated = 1, /* allocated sectors */
47  bm_save = 2 /* allocated sectors + BAM track */
48 } d82copy_bam_mode;
49 
50 typedef enum
51 {
52  em_always,
53  em_on_error,
54  em_never
55 } d82copy_error_mode;
56 
57 typedef enum
58 {
59  bs_invalid = 0,
60  bs_dont_copy = 1,
61  bs_must_copy = 2,
62  bs_error = 3,
63  bs_copied = 4
64 } d82copy_bam_status;
65 
66 typedef struct
67 {
68  int warp;
69  int retries;
70  int interleave;
71  int start_track;
72  int end_track;
73  int two_sided;
74  int transfer_mode;
75  enum cbm_device_type_e drive_type;
76  d82copy_bam_mode bam_mode;
77  d82copy_error_mode error_mode;
79 
80 typedef struct
81 {
82  int track;
83  int sector;
84  int read_result;
85  int write_result;
86  int sectors_processed;
87  int total_sectors;
88  d82copy_settings *settings;
89  char bam[MAX_TRACKS][MAX_SECTORS+1];
91 
92 typedef enum
93 {
94  sev_fatal,
95  sev_warning,
96  sev_info,
97  sev_debug
98 } d82copy_severity_e;
99 
100 typedef void (*d82copy_message_cb)(int d82copy_severity_e, const char *format, ...);
101 typedef int (*d82copy_status_cb)(d82copy_status status);
102 
103 #ifdef LIBD82COPY_DEBUG
104 /*
105  * print out the state of internal counters that are used on read
106  * and write transfers for debugging rare protocol races and hangups
107  */
108 extern void printDebugLibD82Counters(d82copy_message_cb msg_cb);
109 #endif
110 
111 /*
112  * Build '\0'-terminated list of '\0'-terminated transfer mode names.
113  * Memory should be free()'d after use.
114  */
115 extern char *d82copy_get_transfer_modes();
116 
117 /*
118  * parse transfer mode name ("serial1", "s2", "parallel"...) abbreviations
119  * are possible
120  */
121 extern int d82copy_get_transfer_mode_index(const char *name);
122 
123 /*
124  * find out if "auto" transfer mode was specified. If yet, determine
125  * the best transfer mode we can use.
126  */
127 extern int d82copy_check_auto_transfer_mode(CBM_FILE cbm_fd,
128  int auto_transfermode,
129  int drive);
130 
131 /*
132  * returns malloc()'d pointer to default settings.
133  * must be free()'d after use.
134  */
135 extern d82copy_settings *d82copy_get_default_settings(void);
136 
137 /*
138  * return number of sectors on a given track, -1 if invalid
139  */
140 extern int d82copy_sector_count(int two_sided, int track);
141 
142 extern int d82copy_read_image(CBM_FILE cbm_fd,
143  d82copy_settings *settings,
144  int src_drive,
145  const char *dst_image,
146  d82copy_message_cb msg_cb,
147  d82copy_status_cb status_cb);
148 
149 extern int d82copy_write_image(CBM_FILE cbm_fd,
150  d82copy_settings *settings,
151  const char *src_image,
152  int dst_drive,
153  d82copy_message_cb msg_cb,
154  d82copy_status_cb status_cb);
155 
156 extern void d82copy_cleanup(void);
157 
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif /* D82COPY_H */
#define CBM_FILE
Definition: opencbm.h:87
cbm_device_type_e
Definition: opencbm.h:114