| 1 |
/*
|
| 2 |
* common.h - Common parts of readcbm and writecbm
|
| 3 |
*
|
| 4 |
* Written in 2003-2004 by Christian Bauer <Christian.Bauer@uni-mainz.de>
|
| 5 |
*/
|
| 6 |
|
| 7 |
#ifndef COMMON_H
|
| 8 |
#define COMMON_H
|
| 9 |
|
| 10 |
#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 |
/* 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 |
|
| 33 |
/* Maximum number of sectors per track */
|
| 34 |
#define MAX_SECTORS 29
|
| 35 |
|
| 36 |
/* Bytes per sector */
|
| 37 |
#define SECTOR_SIZE 256
|
| 38 |
|
| 39 |
/* Track buffer */
|
| 40 |
extern unsigned char track_buf[MAX_SECTORS * SECTOR_SIZE];
|
| 41 |
|
| 42 |
|
| 43 |
/* Bit rate for each speed zone */
|
| 44 |
extern const int bps[4];
|
| 45 |
|
| 46 |
|
| 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 |
|
| 62 |
/* Clock table (nominal number of Catweasel clocks per inter-flux-change gap) */
|
| 63 |
extern int clock_table[4];
|
| 64 |
|
| 65 |
/* Threshold table */
|
| 66 |
extern int thresh_table[3];
|
| 67 |
|
| 68 |
|
| 69 |
/*
|
| 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 |
|
| 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 |
|
| 93 |
/* Start drive */
|
| 94 |
extern void start_drive(int drive);
|
| 95 |
|
| 96 |
/* Stop drive */
|
| 97 |
extern void stop_drive(int drive);
|
| 98 |
|
| 99 |
#endif
|