1 | /* Types and constants shared between the generic and device dependent
|
---|
2 | * device driver code.
|
---|
3 | */
|
---|
4 |
|
---|
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> */
|
---|
8 |
|
---|
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>
|
---|
20 |
|
---|
21 | #include <string.h>
|
---|
22 | #include <limits.h>
|
---|
23 | #include <stddef.h>
|
---|
24 | #include <errno.h>
|
---|
25 |
|
---|
26 | #include <minix/partition.h>
|
---|
27 | #include <minix/u64.h>
|
---|
28 |
|
---|
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) );
|
---|
35 | _PROTOTYPE( struct device *(*dr_prepare), (int device) );
|
---|
36 | _PROTOTYPE( int (*dr_transfer), (int proc_nr, int opcode, off_t position,
|
---|
37 | iovec_t *iov, unsigned nr_req) );
|
---|
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) );
|
---|
45 | _PROTOTYPE( int (*dr_hw_int), (struct driver *dp, message *m_ptr) );
|
---|
46 | };
|
---|
47 |
|
---|
48 | #if (CHIP == INTEL)
|
---|
49 |
|
---|
50 | /* Number of bytes you can DMA before hitting a 64K boundary: */
|
---|
51 | #define dma_bytes_left(phys) \
|
---|
52 | ((unsigned) (sizeof(int) == 2 ? 0 : 0x10000) - (unsigned) ((phys) & 0xFFFF))
|
---|
53 |
|
---|
54 | #endif /* CHIP == INTEL */
|
---|
55 |
|
---|
56 | /* Base and size of a partition in bytes. */
|
---|
57 | struct device {
|
---|
58 | u64_t dv_base;
|
---|
59 | u64_t dv_size;
|
---|
60 | };
|
---|
61 |
|
---|
62 | #define NIL_DEV ((struct device *) 0)
|
---|
63 |
|
---|
64 | /* Functions defined by driver.c: */
|
---|
65 | _PROTOTYPE( void driver_task, (struct driver *dr) );
|
---|
66 | _PROTOTYPE( char *no_name, (void) );
|
---|
67 | _PROTOTYPE( int do_nop, (struct driver *dp, message *m_ptr) );
|
---|
68 | _PROTOTYPE( struct device *nop_prepare, (int device) );
|
---|
69 | _PROTOTYPE( void nop_cleanup, (void) );
|
---|
70 | _PROTOTYPE( void nop_task, (void) );
|
---|
71 | _PROTOTYPE( void nop_signal, (struct driver *dp, message *m_ptr) );
|
---|
72 | _PROTOTYPE( void nop_alarm, (struct driver *dp, message *m_ptr) );
|
---|
73 | _PROTOTYPE( int nop_cancel, (struct driver *dp, message *m_ptr) );
|
---|
74 | _PROTOTYPE( int nop_select, (struct driver *dp, message *m_ptr) );
|
---|
75 | _PROTOTYPE( int do_diocntl, (struct driver *dp, message *m_ptr) );
|
---|
76 |
|
---|
77 | /* Parameters for the disk drive. */
|
---|
78 | #define SECTOR_SIZE 512 /* physical sector size in bytes */
|
---|
79 | #define SECTOR_SHIFT 9 /* for division */
|
---|
80 | #define SECTOR_MASK 511 /* and remainder */
|
---|
81 |
|
---|
82 | /* Size of the DMA buffer buffer in bytes. */
|
---|
83 | #define USE_EXTRA_DMA_BUF 0 /* usually not needed */
|
---|
84 | #define DMA_BUF_SIZE (DMA_SECTORS * SECTOR_SIZE)
|
---|
85 |
|
---|
86 | #if (CHIP == INTEL)
|
---|
87 | extern u8_t *tmp_buf; /* the DMA buffer */
|
---|
88 | #else
|
---|
89 | extern u8_t tmp_buf[]; /* the DMA buffer */
|
---|
90 | #endif
|
---|
91 | extern phys_bytes tmp_phys; /* phys address of DMA buffer */
|
---|