ftape-rw.h 3.7 KB

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