60
61 static int dadk_chkerr(struct cmpkt *pktp);
62 static int dadk_ioprep(struct dadk *dadkp, struct cmpkt *pktp);
63 static int dadk_iosetup(struct dadk *dadkp, struct cmpkt *pktp);
64 static int dadk_ioretry(struct cmpkt *pktp, int action);
65
66 static struct cmpkt *dadk_pktprep(struct dadk *dadkp, struct cmpkt *in_pktp,
67 struct buf *bp, void (*cb_func)(struct buf *), int (*func)(caddr_t),
68 caddr_t arg);
69
70 static int dadk_pkt(opaque_t com_data, struct buf *bp, int (*func)(caddr_t),
71 caddr_t arg);
72 static void dadk_transport(opaque_t com_data, struct buf *bp);
73 static int dadk_ctl_ioctl(struct dadk *, uint32_t, uintptr_t, int);
74
75 struct tgcom_objops dadk_com_ops = {
76 nodev,
77 nodev,
78 dadk_pkt,
79 dadk_transport,
80 0, 0
81 };
82
83 /*
84 * architecture dependent allocation restrictions for dadk_iob_alloc(). For
85 * x86, we'll set dma_attr_addr_hi to dadk_max_phys_addr and dma_attr_sgllen
86 * to dadk_sgl_size during _init().
87 */
88 #if defined(__sparc)
89 static ddi_dma_attr_t dadk_alloc_attr = {
90 DMA_ATTR_V0, /* version number */
91 0x0, /* lowest usable address */
92 0xFFFFFFFFull, /* high DMA address range */
93 0xFFFFFFFFull, /* DMA counter register */
94 1, /* DMA address alignment */
95 1, /* DMA burstsizes */
96 1, /* min effective DMA size */
97 0xFFFFFFFFull, /* max DMA xfer size */
98 0xFFFFFFFFull, /* segment boundary */
99 1, /* s/g list length */
100 512, /* granularity of device */
136 dadk_init,
137 dadk_free,
138 dadk_probe,
139 dadk_attach,
140 dadk_open,
141 dadk_close,
142 dadk_ioctl,
143 dadk_strategy,
144 dadk_setgeom,
145 dadk_getgeom,
146 dadk_iob_alloc,
147 dadk_iob_free,
148 dadk_iob_htoc,
149 dadk_iob_xfer,
150 dadk_dump,
151 dadk_getphygeom,
152 dadk_set_bbhobj,
153 dadk_check_media,
154 dadk_inquiry,
155 dadk_cleanup,
156 0
157 };
158
159 /*
160 * Local static data
161 */
162
163 #ifdef DADK_DEBUG
164 #define DENT 0x0001
165 #define DERR 0x0002
166 #define DIO 0x0004
167 #define DGEOM 0x0010
168 #define DSTATE 0x0020
169 static int dadk_debug = DGEOM;
170
171 #endif /* DADK_DEBUG */
172
173 static int dadk_check_media_time = 3000000; /* 3 Second State Check */
174 static int dadk_dk_maxphys = 0x80000;
175
176 static char *dadk_cmds[] = {
231 "\026ICRC error during UDMA", /* DERR_ICRC */
232 "\027reserved", /* DERR_RESV */
233 NULL
234 };
235
236 static char *dadk_name = "Disk";
237
238 /*
239 * This is the loadable module wrapper
240 */
241 #include <sys/modctl.h>
242
243 extern struct mod_ops mod_miscops;
244
245 static struct modlmisc modlmisc = {
246 &mod_miscops, /* Type of module */
247 "Direct Attached Disk"
248 };
249
250 static struct modlinkage modlinkage = {
251 MODREV_1, (void *)&modlmisc, NULL
252 };
253
254 int
255 _init(void)
256 {
257 #ifdef DADK_DEBUG
258 if (dadk_debug & DENT)
259 PRF("dadk_init: call\n");
260 #endif
261
262 #if defined(__x86)
263 /* set the max physical address for iob allocs on x86 */
264 dadk_alloc_attr.dma_attr_addr_hi = dadk_max_phys_addr;
265
266 /*
267 * set the sgllen for iob allocs on x86. If this is set less than
268 * the number of pages the buffer will take (taking into account
269 * alignment), it would force the allocator to try and allocate
270 * contiguous pages.
271 */
|
60
61 static int dadk_chkerr(struct cmpkt *pktp);
62 static int dadk_ioprep(struct dadk *dadkp, struct cmpkt *pktp);
63 static int dadk_iosetup(struct dadk *dadkp, struct cmpkt *pktp);
64 static int dadk_ioretry(struct cmpkt *pktp, int action);
65
66 static struct cmpkt *dadk_pktprep(struct dadk *dadkp, struct cmpkt *in_pktp,
67 struct buf *bp, void (*cb_func)(struct buf *), int (*func)(caddr_t),
68 caddr_t arg);
69
70 static int dadk_pkt(opaque_t com_data, struct buf *bp, int (*func)(caddr_t),
71 caddr_t arg);
72 static void dadk_transport(opaque_t com_data, struct buf *bp);
73 static int dadk_ctl_ioctl(struct dadk *, uint32_t, uintptr_t, int);
74
75 struct tgcom_objops dadk_com_ops = {
76 nodev,
77 nodev,
78 dadk_pkt,
79 dadk_transport,
80 { NULL, NULL }
81 };
82
83 /*
84 * architecture dependent allocation restrictions for dadk_iob_alloc(). For
85 * x86, we'll set dma_attr_addr_hi to dadk_max_phys_addr and dma_attr_sgllen
86 * to dadk_sgl_size during _init().
87 */
88 #if defined(__sparc)
89 static ddi_dma_attr_t dadk_alloc_attr = {
90 DMA_ATTR_V0, /* version number */
91 0x0, /* lowest usable address */
92 0xFFFFFFFFull, /* high DMA address range */
93 0xFFFFFFFFull, /* DMA counter register */
94 1, /* DMA address alignment */
95 1, /* DMA burstsizes */
96 1, /* min effective DMA size */
97 0xFFFFFFFFull, /* max DMA xfer size */
98 0xFFFFFFFFull, /* segment boundary */
99 1, /* s/g list length */
100 512, /* granularity of device */
136 dadk_init,
137 dadk_free,
138 dadk_probe,
139 dadk_attach,
140 dadk_open,
141 dadk_close,
142 dadk_ioctl,
143 dadk_strategy,
144 dadk_setgeom,
145 dadk_getgeom,
146 dadk_iob_alloc,
147 dadk_iob_free,
148 dadk_iob_htoc,
149 dadk_iob_xfer,
150 dadk_dump,
151 dadk_getphygeom,
152 dadk_set_bbhobj,
153 dadk_check_media,
154 dadk_inquiry,
155 dadk_cleanup,
156 { NULL }
157 };
158
159 /*
160 * Local static data
161 */
162
163 #ifdef DADK_DEBUG
164 #define DENT 0x0001
165 #define DERR 0x0002
166 #define DIO 0x0004
167 #define DGEOM 0x0010
168 #define DSTATE 0x0020
169 static int dadk_debug = DGEOM;
170
171 #endif /* DADK_DEBUG */
172
173 static int dadk_check_media_time = 3000000; /* 3 Second State Check */
174 static int dadk_dk_maxphys = 0x80000;
175
176 static char *dadk_cmds[] = {
231 "\026ICRC error during UDMA", /* DERR_ICRC */
232 "\027reserved", /* DERR_RESV */
233 NULL
234 };
235
236 static char *dadk_name = "Disk";
237
238 /*
239 * This is the loadable module wrapper
240 */
241 #include <sys/modctl.h>
242
243 extern struct mod_ops mod_miscops;
244
245 static struct modlmisc modlmisc = {
246 &mod_miscops, /* Type of module */
247 "Direct Attached Disk"
248 };
249
250 static struct modlinkage modlinkage = {
251 MODREV_1, { (void *)&modlmisc, NULL }
252 };
253
254 int
255 _init(void)
256 {
257 #ifdef DADK_DEBUG
258 if (dadk_debug & DENT)
259 PRF("dadk_init: call\n");
260 #endif
261
262 #if defined(__x86)
263 /* set the max physical address for iob allocs on x86 */
264 dadk_alloc_attr.dma_attr_addr_hi = dadk_max_phys_addr;
265
266 /*
267 * set the sgllen for iob allocs on x86. If this is set less than
268 * the number of pages the buffer will take (taking into account
269 * alignment), it would force the allocator to try and allocate
270 * contiguous pages.
271 */
|