1 #ifndef _FTAPE_RW_H
2 #define _FTAPE_RW_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #include "fdc-io.h"
35 #include "kernel-interface.h"
36
37 #define GET2( address, offset) *(short*)(address + offset)
38 #define GET4( address, offset) *(long*)(address + offset)
39 #define PUT2( address, offset, value) *(short*)(address + offset) = value
40 #define PUT4( address, offset, value) *(long*)(address + offset) = value
41
42 enum runner_status_enum {
43 idle = 0,
44 running,
45 do_abort,
46 aborting,
47 logical_eot,
48 end_of_tape,
49 buffer_overrun,
50 buffer_underrun,
51 };
52
53 typedef struct {
54 byte *address;
55 volatile buffer_state_enum status;
56 volatile byte *ptr;
57 volatile unsigned bytes;
58 volatile unsigned segment_id;
59
60
61
62
63 volatile unsigned long bad_sector_map;
64
65
66
67
68 volatile unsigned long soft_error_map;
69
70
71
72
73 volatile unsigned long hard_error_map;
74
75
76
77 volatile int retry;
78
79
80
81 volatile unsigned int skip;
82
83
84
85 volatile unsigned data_offset;
86
87
88
89 volatile unsigned sector_offset;
90
91
92
93 volatile unsigned sector_count;
94
95
96
97 volatile unsigned remaining;
98
99
100
101
102 volatile unsigned next_segment;
103
104
105
106 volatile int deleted;
107
108 volatile byte head;
109 volatile byte cyl;
110 volatile byte sect;
111 } buffer_struct;
112
113 typedef struct {
114 int active;
115 int error;
116 int offset;
117 } ftape_fast_start_struct;
118
119 typedef struct {
120 int id;
121 int size;
122 int free;
123 } ftape_last_segment_struct;
124
125 typedef struct {
126 int track;
127 volatile int known;
128 volatile int bot;
129 volatile int eot;
130 volatile int segment;
131 volatile int sector;
132 } location_record;
133
134 typedef enum {
135 fmt_normal = 2, fmt_1100ft = 3, fmt_wide = 4, fmt_425ft = 5
136 } format_type;
137
138
139
140 extern int tracing;
141 extern byte trace_id;
142 extern buffer_struct buffer[];
143 extern location_record location;
144 extern volatile ftape_fast_start_struct ftape_fast_start;
145 extern byte deblock_buffer[(SECTORS_PER_SEGMENT - 3) * SECTOR_SIZE];
146 extern byte scratch_buffer[(SECTORS_PER_SEGMENT - 3) * SECTOR_SIZE];
147 extern ftape_last_segment_struct ftape_last_segment;
148 extern int header_segment_1;
149 extern int header_segment_2;
150 extern int used_header_segment;
151 extern unsigned int fast_seek_segment_time;
152 extern volatile int tape_running;
153 extern format_type format_code;
154
155
156
157 extern int count_ones(unsigned long mask);
158 extern int valid_segment_no(unsigned segment);
159 extern int setup_new_segment(buffer_struct * buff, unsigned int segment_id,
160 int offset);
161 extern int calc_next_cluster(buffer_struct * buff);
162 extern buffer_struct *next_buffer(volatile int *x);
163 extern int ftape_read_id(void);
164 extern void ftape_tape_parameters(byte drive_configuration);
165 extern int wait_segment(buffer_state_enum state);
166 extern int ftape_dumb_stop(void);
167 extern int ftape_start_tape(int segment_id, int offset);
168
169
170
171 extern int setup_fdc_and_dma(buffer_struct * buff, byte operation);
172
173 #endif