verbose printing and sanity checking functions.
[minix.git] / drivers / libdriver_asyn / driver.h
blob0737f1748139348a0549d06df2fdd4c8cb95c62d
1 /* Types and constants shared between the generic and device dependent
2 * device driver code.
3 */
5 #define _POSIX_SOURCE 1 /* tell headers to include POSIX stuff */
6 #define _MINIX 1 /* tell headers to include MINIX stuff */
7 #define _SYSTEM 1 /* get negative error number in <errno.h> */
9 /* The following are so basic, all the *.c files get them automatically. */
10 #include <minix/config.h> /* MUST be first */
11 #include <ansi.h> /* MUST be second */
12 #include <minix/type.h>
13 #include <minix/ipc.h>
14 #include <minix/com.h>
15 #include <minix/callnr.h>
16 #include <sys/types.h>
17 #include <minix/const.h>
18 #include <minix/syslib.h>
19 #include <minix/sysutil.h>
21 #include <string.h>
22 #include <limits.h>
23 #include <stddef.h>
24 #include <errno.h>
26 #include <minix/partition.h>
27 #include <minix/u64.h>
29 /* Info about and entry points into the device dependent code. */
30 struct driver {
31 _PROTOTYPE( char *(*dr_name), (void) );
32 _PROTOTYPE( int (*dr_open), (struct driver *dp, message *m_ptr) );
33 _PROTOTYPE( int (*dr_close), (struct driver *dp, message *m_ptr) );
34 _PROTOTYPE( int (*dr_ioctl), (struct driver *dp, message *m_ptr, int safe) );
35 _PROTOTYPE( struct device *(*dr_prepare), (int device) );
36 _PROTOTYPE( int (*dr_transfer), (int proc_nr, int opcode, u64_t position,
37 iovec_t *iov, unsigned nr_req, int safe) );
38 _PROTOTYPE( void (*dr_cleanup), (void) );
39 _PROTOTYPE( void (*dr_geometry), (struct partition *entry) );
40 _PROTOTYPE( void (*dr_signal), (struct driver *dp, message *m_ptr) );
41 _PROTOTYPE( void (*dr_alarm), (struct driver *dp, message *m_ptr) );
42 _PROTOTYPE( int (*dr_cancel), (struct driver *dp, message *m_ptr) );
43 _PROTOTYPE( int (*dr_select), (struct driver *dp, message *m_ptr) );
44 _PROTOTYPE( int (*dr_other), (struct driver *dp, message *m_ptr, int safe) );
45 _PROTOTYPE( int (*dr_hw_int), (struct driver *dp, message *m_ptr) );
48 /* Base and size of a partition in bytes. */
49 struct device {
50 u64_t dv_base;
51 u64_t dv_size;
54 #define NIL_DEV ((struct device *) 0)
56 /* Functions defined by driver.c: */
57 _PROTOTYPE( void driver_task, (struct driver *dr) );
58 _PROTOTYPE( char *no_name, (void) );
59 _PROTOTYPE( int do_nop, (struct driver *dp, message *m_ptr) );
60 _PROTOTYPE( struct device *nop_prepare, (int device) );
61 _PROTOTYPE( void nop_cleanup, (void) );
62 _PROTOTYPE( void nop_task, (void) );
63 _PROTOTYPE( void nop_signal, (struct driver *dp, message *m_ptr) );
64 _PROTOTYPE( void nop_alarm, (struct driver *dp, message *m_ptr) );
65 _PROTOTYPE( int nop_cancel, (struct driver *dp, message *m_ptr) );
66 _PROTOTYPE( int nop_select, (struct driver *dp, message *m_ptr) );
67 _PROTOTYPE( int do_diocntl, (struct driver *dp, message *m_ptr, int safe) );
68 _PROTOTYPE( int nop_ioctl, (struct driver *dp, message *m_ptr, int safe) );
69 _PROTOTYPE( int mq_queue, (message *m_ptr) );
71 /* Parameters for the disk drive. */
72 #define SECTOR_SIZE 512 /* physical sector size in bytes */
73 #define SECTOR_SHIFT 9 /* for division */
74 #define SECTOR_MASK 511 /* and remainder */
76 /* Size of the DMA buffer buffer in bytes. */
77 #define USE_EXTRA_DMA_BUF 0 /* usually not needed */
78 #define DMA_BUF_SIZE (DMA_SECTORS * SECTOR_SIZE)
80 #if (CHIP == INTEL)
81 extern u8_t *tmp_buf; /* the DMA buffer */
82 #else
83 extern u8_t tmp_buf[]; /* the DMA buffer */
84 #endif
85 extern phys_bytes tmp_phys; /* phys address of DMA buffer */