1: /* Types and constants shared between the generic and device dependent
   2:  * device driver code.
   3:  */
   4: 
   5: #include <minix/callnr.h>
   6: #include <minix/com.h>
   7: #include "proc.h"
   8: #include <minix/partition.h>
   9: #include <minix/u64.h>
  10: 
  11: /* Info about and entry points into the device dependent code. */
  12: struct driver {
  13:   _PROTOTYPE( char *(*dr_name), (void) );
  14:   _PROTOTYPE( int (*dr_open), (struct driver *dp, message *m_ptr) );
  15:   _PROTOTYPE( int (*dr_close), (struct driver *dp, message *m_ptr) );
  16:   _PROTOTYPE( int (*dr_ioctl), (struct driver *dp, message *m_ptr) );
  17:   _PROTOTYPE( struct device *(*dr_prepare), (int device) );
  18:   _PROTOTYPE( int (*dr_transfer), (int proc_nr, int opcode, off_t position,
  19:                                         iovec_t *iov, unsigned nr_req) );
  20:   _PROTOTYPE( void (*dr_cleanup), (void) );
  21:   _PROTOTYPE( void (*dr_geometry), (struct partition *entry) );
  22: };
  23: 
  24: #if (CHIP == INTEL)
  25: 
  26: /* Number of bytes you can DMA before hitting a 64K boundary: */
  27: #define dma_bytes_left(phys)    \
  28:    ((unsigned) (sizeof(int) == 2 ? 0 : 0x10000) - (unsigned) ((phys) & 0xFFFF))
  29: 
  30: #endif /* CHIP == INTEL */
  31: 
  32: /* Base and size of a partition in bytes. */
  33: struct device {
  34:   u64_t dv_base;
  35:   u64_t dv_size;
  36: };
  37: 
  38: #define NIL_DEV         ((struct device *) 0)
  39: 
  40: /* Functions defined by driver.c: */
  41: _PROTOTYPE( void driver_task, (struct driver *dr) );
  42: _PROTOTYPE( char *no_name, (void) );
  43: _PROTOTYPE( int do_nop, (struct driver *dp, message *m_ptr) );
  44: _PROTOTYPE( struct device *nop_prepare, (int device) );
  45: _PROTOTYPE( void nop_cleanup, (void) );
  46: _PROTOTYPE( int do_diocntl, (struct driver *dr, message *m_ptr) );
  47: 
  48: /* Parameters for the disk drive. */
  49: #define SECTOR_SIZE      512    /* physical sector size in bytes */
  50: #define SECTOR_SHIFT       9    /* for division */
  51: #define SECTOR_MASK      511    /* and remainder */
  52: 
  53: /* Size of the DMA buffer buffer in bytes. */
  54: #define DMA_BUF_SIZE    (DMA_SECTORS * SECTOR_SIZE)
  55: 
  56: #if (CHIP == INTEL)
  57: extern u8_t *tmp_buf;                   /* the DMA buffer */
  58: #else
  59: extern u8_t tmp_buf[];                  /* the DMA buffer */
  60: #endif
  61: extern phys_bytes tmp_phys;             /* phys address of DMA buffer */