1 |
cebix |
1.1 |
/* |
2 |
|
|
* common.h - Common parts of readcbm and writecbm |
3 |
|
|
* |
4 |
cebix |
1.2 |
* Written in 2003-2004 by Christian Bauer <Christian.Bauer@uni-mainz.de> |
5 |
cebix |
1.1 |
*/ |
6 |
|
|
|
7 |
|
|
#ifndef COMMON_H |
8 |
|
|
#define COMMON_H |
9 |
|
|
|
10 |
cebix |
1.2 |
#include <stdio.h> |
11 |
|
|
#include <stdlib.h> |
12 |
|
|
#include <string.h> |
13 |
|
|
#include <time.h> |
14 |
|
|
#include <unistd.h> |
15 |
|
|
#include <getopt.h> |
16 |
|
|
#include <errno.h> |
17 |
|
|
#include <sys/io.h> |
18 |
|
|
|
19 |
|
|
|
20 |
cebix |
1.3 |
/* Disk format description */ |
21 |
|
|
struct format_t { |
22 |
|
|
int sides; |
23 |
|
|
int tracks_per_side; |
24 |
|
|
const int *bps; // bps for each speed zone |
25 |
|
|
const int *std_speed; // zone for each track |
26 |
|
|
const int *num_sectors; // number of sectors for each track |
27 |
|
|
}; |
28 |
|
|
|
29 |
|
|
/* Selected format */ |
30 |
|
|
extern const struct format_t *format; |
31 |
|
|
|
32 |
cebix |
1.1 |
|
33 |
|
|
/* Maximum number of sectors per track */ |
34 |
cebix |
1.3 |
#define MAX_SECTORS 29 |
35 |
cebix |
1.1 |
|
36 |
|
|
/* Bytes per sector */ |
37 |
|
|
#define SECTOR_SIZE 256 |
38 |
|
|
|
39 |
cebix |
1.3 |
/* Track buffer */ |
40 |
|
|
extern unsigned char track_buf[MAX_SECTORS * SECTOR_SIZE]; |
41 |
|
|
|
42 |
cebix |
1.1 |
|
43 |
|
|
/* Bit rate for each speed zone */ |
44 |
cebix |
1.2 |
extern const int bps[4]; |
45 |
cebix |
1.1 |
|
46 |
cebix |
1.2 |
|
47 |
|
|
/* Drive number */ |
48 |
|
|
extern int drive_num; |
49 |
|
|
|
50 |
|
|
/* Actual RPM of the drive, and whether it's 40 or 80 tracks */ |
51 |
|
|
extern int drive_rpm; |
52 |
|
|
extern int drive_40tracks; |
53 |
|
|
|
54 |
|
|
/* Name of file to read from/write to */ |
55 |
|
|
extern const char *file_name; |
56 |
|
|
|
57 |
|
|
|
58 |
|
|
/* Catweasel controller struct */ |
59 |
|
|
extern catweasel_contr c; |
60 |
|
|
|
61 |
cebix |
1.1 |
|
62 |
|
|
/* Clock table (nominal number of Catweasel clocks per inter-flux-change gap) */ |
63 |
cebix |
1.2 |
extern int clock_table[4]; |
64 |
cebix |
1.1 |
|
65 |
|
|
/* Threshold table */ |
66 |
cebix |
1.2 |
extern int thresh_table[3]; |
67 |
|
|
|
68 |
cebix |
1.1 |
|
69 |
cebix |
1.2 |
/* |
70 |
|
|
* Parse command line arguments and set |
71 |
|
|
* c.iobase |
72 |
|
|
* c.type |
73 |
|
|
* drive_num |
74 |
|
|
* drive_rpm |
75 |
|
|
* drive_40tracks |
76 |
|
|
* file_name |
77 |
|
|
* Also initializes the catweasel_contr struct |
78 |
|
|
*/ |
79 |
|
|
extern void parse_args(int argc, char **argv); |
80 |
|
|
|
81 |
|
|
/* Obtain access to I/O ports */ |
82 |
|
|
extern void ioport_access(void); |
83 |
cebix |
1.3 |
|
84 |
|
|
/* Delay specified number of milliseconds */ |
85 |
|
|
extern void msdelay(int ms); |
86 |
|
|
|
87 |
|
|
/* Select disk format */ |
88 |
|
|
extern void select_format(int type); |
89 |
|
|
|
90 |
|
|
/* Seek to given CBM track (1..35) and select correct side and speed zone */ |
91 |
|
|
extern void seek_to(int drive, int track); |
92 |
cebix |
1.1 |
|
93 |
cebix |
1.2 |
/* Start drive */ |
94 |
|
|
extern void start_drive(int drive); |
95 |
cebix |
1.1 |
|
96 |
cebix |
1.2 |
/* Stop drive */ |
97 |
|
|
extern void stop_drive(int drive); |
98 |
cebix |
1.1 |
|
99 |
|
|
#endif |