]> git.ipfire.org Git - thirdparty/linux.git/blob - drivers/char/ftape/lowlevel/ftape-rw.h
Linux-2.6.12-rc2
[thirdparty/linux.git] / drivers / char / ftape / lowlevel / ftape-rw.h
1 #ifndef _FTAPE_RW_H
2 #define _FTAPE_RW_H
3
4 /*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-rw.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:25 $
26 *
27 * This file contains the definitions for the read and write
28 * functions for the QIC-117 floppy-tape driver for Linux.
29 *
30 * Claus-Justus Heine (1996/09/20): Add definition of format code 6
31 * Claus-Justus Heine (1996/10/04): Changed GET/PUT macros to cast to (__u8 *)
32 *
33 */
34
35 #include "../lowlevel/fdc-io.h"
36 #include "../lowlevel/ftape-init.h"
37 #include "../lowlevel/ftape-bsm.h"
38
39 #include <asm/unaligned.h>
40
41 #define GET2(address, offset) get_unaligned((__u16*)((__u8 *)address + offset))
42 #define GET4(address, offset) get_unaligned((__u32*)((__u8 *)address + offset))
43 #define GET8(address, offset) get_unaligned((__u64*)((__u8 *)address + offset))
44 #define PUT2(address, offset , value) put_unaligned((value), (__u16*)((__u8 *)address + offset))
45 #define PUT4(address, offset , value) put_unaligned((value), (__u32*)((__u8 *)address + offset))
46 #define PUT8(address, offset , value) put_unaligned((value), (__u64*)((__u8 *)address + offset))
47
48 enum runner_status_enum {
49 idle = 0,
50 running,
51 do_abort,
52 aborting,
53 logical_eot,
54 end_of_tape,
55 };
56
57 typedef enum ft_buffer_queue {
58 ft_queue_head = 0,
59 ft_queue_tail = 1
60 } ft_buffer_queue_t;
61
62
63 typedef struct {
64 int track; /* tape head position */
65 volatile int segment; /* current segment */
66 volatile int sector; /* sector offset within current segment */
67 volatile unsigned int bot; /* logical begin of track */
68 volatile unsigned int eot; /* logical end of track */
69 volatile unsigned int known; /* validates bot, segment, sector */
70 } location_record;
71
72 /* Count nr of 1's in pattern.
73 */
74 static inline int count_ones(unsigned long mask)
75 {
76 int bits;
77
78 for (bits = 0; mask != 0; mask >>= 1) {
79 if (mask & 1) {
80 ++bits;
81 }
82 }
83 return bits;
84 }
85
86 #define FT_MAX_NR_BUFFERS 16 /* arbitrary value */
87 /* ftape-rw.c defined global vars.
88 */
89 extern buffer_struct *ft_buffer[FT_MAX_NR_BUFFERS];
90 extern int ft_nr_buffers;
91 extern location_record ft_location;
92 extern volatile int ftape_tape_running;
93
94 /* ftape-rw.c defined global functions.
95 */
96 extern int ftape_setup_new_segment(buffer_struct * buff,
97 int segment_id,
98 int offset);
99 extern int ftape_calc_next_cluster(buffer_struct * buff);
100 extern buffer_struct *ftape_next_buffer (ft_buffer_queue_t pos);
101 extern buffer_struct *ftape_get_buffer (ft_buffer_queue_t pos);
102 extern int ftape_buffer_id (ft_buffer_queue_t pos);
103 extern void ftape_reset_buffer(void);
104 extern void ftape_tape_parameters(__u8 drive_configuration);
105 extern int ftape_wait_segment(buffer_state_enum state);
106 extern int ftape_dumb_stop(void);
107 extern int ftape_start_tape(int segment_id, int offset);
108 extern int ftape_stop_tape(int *pstatus);
109 extern int ftape_handle_logical_eot(void);
110 extern buffer_state_enum ftape_set_state(buffer_state_enum new_state);
111 #endif /* _FTAPE_RW_H */