Rev 4163 | Rev 4243 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4163 | Rev 4192 | ||
---|---|---|---|
Line 19... | Line 19... | ||
19 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
19 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
20 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
20 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
21 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
21 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
22 | * |
22 | * |
23 | * Changes: |
23 | * Changes: |
24 | * 2009 Lukas Medjrech ported to HelenOS |
24 | * 2009 Lukas Mejdrech ported to HelenOS |
25 | */ |
25 | */ |
26 | 26 | ||
27 | /** @addtogroup dp8390 |
27 | /** @addtogroup dp8390 |
28 | * @{ |
28 | * @{ |
29 | */ |
29 | */ |
30 | 30 | ||
31 | #include <assert.h> |
31 | #include <assert.h> |
32 | - | ||
33 | #include <errno.h> |
32 | #include <errno.h> |
34 | 33 | ||
35 | #include "../../include/byteorder.h" |
34 | #include "../../include/byteorder.h" |
36 | 35 | ||
- | 36 | #include "../../structures/packet/packet.h" |
|
- | 37 | #include "../../structures/packet/packet_client.h" |
|
- | 38 | ||
- | 39 | #include "../netif.h" |
|
- | 40 | ||
37 | #include "dp8390_drv.h" |
41 | #include "dp8390_drv.h" |
- | 42 | #include "dp8390_module.h" |
|
38 | #include "dp8390_port.h" |
43 | #include "dp8390_port.h" |
39 | 44 | ||
40 | /* |
45 | /* |
41 | * dp8390.c |
46 | * dp8390.c |
42 | * |
47 | * |
Line 50... | Line 55... | ||
50 | */ |
55 | */ |
51 | 56 | ||
52 | #include "local.h" |
57 | #include "local.h" |
53 | #include "dp8390.h" |
58 | #include "dp8390.h" |
54 | 59 | ||
- | 60 | int queue_packet( dpeth_t * dep, packet_t packet ); |
|
- | 61 | static void outsb( port_t port, void * buf, size_t size ); |
|
- | 62 | static void outsw( port_t port, void * buf, size_t size ); |
|
- | 63 | ||
55 | //static u16_t eth_ign_proto; |
64 | //static u16_t eth_ign_proto; |
56 | //static char *progname; |
65 | //static char *progname; |
57 | 66 | ||
58 | /* Configuration */ |
67 | /* Configuration */ |
59 | /*typedef struct dp_conf |
68 | /*typedef struct dp_conf |
Line 116... | Line 125... | ||
116 | _PROTOTYPE( static void dp_recv, (dpeth_t *dep) ); |
125 | _PROTOTYPE( static void dp_recv, (dpeth_t *dep) ); |
117 | _PROTOTYPE( static void dp_send, (dpeth_t *dep) ); |
126 | _PROTOTYPE( static void dp_send, (dpeth_t *dep) ); |
118 | //_PROTOTYPE( static void dp8390_stop, (void) ); |
127 | //_PROTOTYPE( static void dp8390_stop, (void) ); |
119 | _PROTOTYPE( static void dp_getblock, (dpeth_t *dep, int page, |
128 | _PROTOTYPE( static void dp_getblock, (dpeth_t *dep, int page, |
120 | size_t offset, size_t size, void *dst) ); |
129 | size_t offset, size_t size, void *dst) ); |
121 | //_PROTOTYPE( static void dp_pio8_getblock, (dpeth_t *dep, int page, |
130 | _PROTOTYPE( static void dp_pio8_getblock, (dpeth_t *dep, int page, |
122 | // size_t offset, size_t size, void *dst) ); |
131 | size_t offset, size_t size, void *dst) ); |
123 | //_PROTOTYPE( static void dp_pio16_getblock, (dpeth_t *dep, int page, |
132 | _PROTOTYPE( static void dp_pio16_getblock, (dpeth_t *dep, int page, |
124 | // size_t offset, size_t size, void *dst) ); |
133 | size_t offset, size_t size, void *dst) ); |
125 | _PROTOTYPE( static int dp_pkt2user, (dpeth_t *dep, int page, |
134 | _PROTOTYPE( static int dp_pkt2user, (dpeth_t *dep, int page, |
126 | int length) ); |
135 | int length) ); |
127 | //_PROTOTYPE( static int dp_pkt2user_s, (dpeth_t *dep, int page, |
136 | //_PROTOTYPE( static int dp_pkt2user_s, (dpeth_t *dep, int page, |
128 | // int length) ); |
137 | // int length) ); |
129 | //_PROTOTYPE( static void dp_user2nic, (dpeth_t *dep, iovec_dat_t *iovp, |
138 | _PROTOTYPE( static void dp_user2nic, (dpeth_t *dep, iovec_dat_t *iovp, |
130 | // vir_bytes offset, int nic_addr, vir_bytes count) ); |
139 | vir_bytes offset, int nic_addr, vir_bytes count) ); |
131 | //_PROTOTYPE( static void dp_user2nic_s, (dpeth_t *dep, iovec_dat_s_t *iovp, |
140 | //_PROTOTYPE( static void dp_user2nic_s, (dpeth_t *dep, iovec_dat_s_t *iovp, |
132 | // vir_bytes offset, int nic_addr, vir_bytes count) ); |
141 | // vir_bytes offset, int nic_addr, vir_bytes count) ); |
133 | //_PROTOTYPE( static void dp_pio8_user2nic, (dpeth_t *dep, |
142 | _PROTOTYPE( static void dp_pio8_user2nic, (dpeth_t *dep, |
134 | // iovec_dat_t *iovp, vir_bytes offset, |
143 | iovec_dat_t *iovp, vir_bytes offset, |
135 | // int nic_addr, vir_bytes count) ); |
144 | int nic_addr, vir_bytes count) ); |
136 | //_PROTOTYPE( static void dp_pio8_user2nic_s, (dpeth_t *dep, |
145 | //_PROTOTYPE( static void dp_pio8_user2nic_s, (dpeth_t *dep, |
137 | // iovec_dat_s_t *iovp, vir_bytes offset, |
146 | // iovec_dat_s_t *iovp, vir_bytes offset, |
138 | // int nic_addr, vir_bytes count) ); |
147 | // int nic_addr, vir_bytes count) ); |
139 | //_PROTOTYPE( static void dp_pio16_user2nic, (dpeth_t *dep, |
148 | _PROTOTYPE( static void dp_pio16_user2nic, (dpeth_t *dep, |
140 | // iovec_dat_t *iovp, vir_bytes offset, |
149 | iovec_dat_t *iovp, vir_bytes offset, |
141 | // int nic_addr, vir_bytes count) ); |
150 | int nic_addr, vir_bytes count) ); |
142 | //_PROTOTYPE( static void dp_pio16_user2nic_s, (dpeth_t *dep, |
151 | //_PROTOTYPE( static void dp_pio16_user2nic_s, (dpeth_t *dep, |
143 | // iovec_dat_s_t *iovp, vir_bytes offset, |
152 | // iovec_dat_s_t *iovp, vir_bytes offset, |
144 | // int nic_addr, vir_bytes count) ); |
153 | // int nic_addr, vir_bytes count) ); |
145 | _PROTOTYPE( static void dp_nic2user, (dpeth_t *dep, int nic_addr, |
154 | _PROTOTYPE( static void dp_nic2user, (dpeth_t *dep, int nic_addr, |
146 | iovec_dat_t *iovp, vir_bytes offset, vir_bytes count) ); |
155 | iovec_dat_t *iovp, vir_bytes offset, vir_bytes count) ); |
147 | //_PROTOTYPE( static void dp_nic2user_s, (dpeth_t *dep, int nic_addr, |
156 | //_PROTOTYPE( static void dp_nic2user_s, (dpeth_t *dep, int nic_addr, |
148 | // iovec_dat_s_t *iovp, vir_bytes offset, vir_bytes count) ); |
157 | // iovec_dat_s_t *iovp, vir_bytes offset, vir_bytes count) ); |
149 | //_PROTOTYPE( static void dp_pio8_nic2user, (dpeth_t *dep, int nic_addr, |
158 | _PROTOTYPE( static void dp_pio8_nic2user, (dpeth_t *dep, int nic_addr, |
150 | // iovec_dat_t *iovp, vir_bytes offset, vir_bytes count) ); |
159 | iovec_dat_t *iovp, vir_bytes offset, vir_bytes count) ); |
151 | //_PROTOTYPE( static void dp_pio8_nic2user_s, (dpeth_t *dep, int nic_addr, |
160 | //_PROTOTYPE( static void dp_pio8_nic2user_s, (dpeth_t *dep, int nic_addr, |
152 | // iovec_dat_s_t *iovp, vir_bytes offset, vir_bytes count) ); |
161 | // iovec_dat_s_t *iovp, vir_bytes offset, vir_bytes count) ); |
153 | //_PROTOTYPE( static void dp_pio16_nic2user, (dpeth_t *dep, int nic_addr, |
162 | _PROTOTYPE( static void dp_pio16_nic2user, (dpeth_t *dep, int nic_addr, |
154 | // iovec_dat_t *iovp, vir_bytes offset, vir_bytes count) ); |
163 | iovec_dat_t *iovp, vir_bytes offset, vir_bytes count) ); |
155 | //_PROTOTYPE( static void dp_pio16_nic2user_s, (dpeth_t *dep, int nic_addr, |
164 | //_PROTOTYPE( static void dp_pio16_nic2user_s, (dpeth_t *dep, int nic_addr, |
156 | // iovec_dat_s_t *iovp, vir_bytes offset, vir_bytes count) ); |
165 | // iovec_dat_s_t *iovp, vir_bytes offset, vir_bytes count) ); |
157 | //_PROTOTYPE( static void dp_next_iovec, (iovec_dat_t *iovp) ); |
166 | _PROTOTYPE( static void dp_next_iovec, (iovec_dat_t *iovp) ); |
158 | //_PROTOTYPE( static void dp_next_iovec_s, (iovec_dat_s_t *iovp) ); |
167 | //_PROTOTYPE( static void dp_next_iovec_s, (iovec_dat_s_t *iovp) ); |
159 | _PROTOTYPE( static void conf_hw, (dpeth_t *dep) ); |
168 | _PROTOTYPE( static void conf_hw, (dpeth_t *dep) ); |
160 | //_PROTOTYPE( static void update_conf, (dpeth_t *dep, dp_conf_t *dcp) ); |
169 | //_PROTOTYPE( static void update_conf, (dpeth_t *dep, dp_conf_t *dcp) ); |
161 | _PROTOTYPE( static void map_hw_buffer, (dpeth_t *dep) ); |
170 | _PROTOTYPE( static void map_hw_buffer, (dpeth_t *dep) ); |
162 | //_PROTOTYPE( static int calc_iovec_size, (iovec_dat_t *iovp) ); |
171 | //_PROTOTYPE( static int calc_iovec_size, (iovec_dat_t *iovp) ); |
163 | //_PROTOTYPE( static int calc_iovec_size_s, (iovec_dat_s_t *iovp) ); |
172 | //_PROTOTYPE( static int calc_iovec_size_s, (iovec_dat_s_t *iovp) ); |
164 | _PROTOTYPE( static void reply, (dpeth_t *dep, int err, int may_block) ); |
173 | _PROTOTYPE( static void reply, (dpeth_t *dep, int err, int may_block) ); |
165 | //_PROTOTYPE( static void mess_reply, (message *req, message *reply) ); |
174 | //_PROTOTYPE( static void mess_reply, (message *req, message *reply) ); |
166 | //_PROTOTYPE( static void get_userdata, (int user_proc, |
175 | _PROTOTYPE( static void get_userdata, (int user_proc, |
167 | // vir_bytes user_addr, vir_bytes count, void *loc_addr) ); |
176 | vir_bytes user_addr, vir_bytes count, void *loc_addr) ); |
168 | //_PROTOTYPE( static void get_userdata_s, (int user_proc, |
177 | //_PROTOTYPE( static void get_userdata_s, (int user_proc, |
169 | // cp_grant_id_t grant, vir_bytes offset, vir_bytes count, |
178 | // cp_grant_id_t grant, vir_bytes offset, vir_bytes count, |
170 | // void *loc_addr) ); |
179 | // void *loc_addr) ); |
171 | //_PROTOTYPE( static void put_userdata, (int user_proc, |
180 | //_PROTOTYPE( static void put_userdata, (int user_proc, |
172 | // vir_bytes user_addr, vir_bytes count, void *loc_addr) ); |
181 | // vir_bytes user_addr, vir_bytes count, void *loc_addr) ); |
173 | //_PROTOTYPE( static void put_userdata_s, (int user_proc, |
182 | //_PROTOTYPE( static void put_userdata_s, (int user_proc, |
174 | // cp_grant_id_t grant, size_t count, void *loc_addr) ); |
183 | // cp_grant_id_t grant, size_t count, void *loc_addr) ); |
175 | //_PROTOTYPE( static void insb, (port_t port, void *buf, size_t size) ); |
184 | _PROTOTYPE( static void insb, (port_t port, void *buf, size_t size) ); |
176 | //_PROTOTYPE( static void insw, (port_t port, void *buf, size_t size) ); |
185 | _PROTOTYPE( static void insw, (port_t port, void *buf, size_t size) ); |
177 | //_PROTOTYPE( static void do_vir_insb, (port_t port, int proc, |
186 | //_PROTOTYPE( static void do_vir_insb, (port_t port, int proc, |
178 | // vir_bytes buf, size_t size) ); |
187 | // vir_bytes buf, size_t size) ); |
179 | //_PROTOTYPE( static void do_vir_insw, (port_t port, int proc, |
188 | //_PROTOTYPE( static void do_vir_insw, (port_t port, int proc, |
180 | // vir_bytes buf, size_t size) ); |
189 | // vir_bytes buf, size_t size) ); |
181 | //_PROTOTYPE( static void do_vir_outsb, (port_t port, int proc, |
190 | //_PROTOTYPE( static void do_vir_outsb, (port_t port, int proc, |
Line 256... | Line 265... | ||
256 | 265 | ||
257 | dep->de_flags = DEF_EMPTY; |
266 | dep->de_flags = DEF_EMPTY; |
258 | } |
267 | } |
259 | } |
268 | } |
260 | 269 | ||
- | 270 | int queue_packet( dpeth_t * dep, packet_t packet ){ |
|
- | 271 | packet_t tmp; |
|
- | 272 | ||
- | 273 | if( dep->packet_count > 1 ){ |
|
- | 274 | if( ! pq_add( pq_previous( dep->packet_queue ), packet, 0, 0 )){ |
|
- | 275 | return EINVAL; |
|
- | 276 | } |
|
- | 277 | }else{ |
|
- | 278 | tmp = pq_add( dep->packet_queue, packet, 0, 0 ); |
|
- | 279 | if( ! tmp ) return EINVAL; |
|
- | 280 | dep->packet_queue = tmp; |
|
- | 281 | } |
|
- | 282 | ++ dep->packet_count; |
|
- | 283 | return EBUSY; |
|
- | 284 | } |
|
- | 285 | ||
- | 286 | /*===========================================================================* |
|
- | 287 | * based on do_vwrite * |
|
- | 288 | *===========================================================================*/ |
|
- | 289 | int do_pwrite( dpeth_t * dep, packet_t packet, int from_int ) |
|
- | 290 | { |
|
- | 291 | // int port, count, size; |
|
- | 292 | int size; |
|
- | 293 | int sendq_head; |
|
- | 294 | /* dpeth_t *dep; |
|
- | 295 | ||
- | 296 | port = mp->DL_PORT; |
|
- | 297 | count = mp->DL_COUNT; |
|
- | 298 | if (port < 0 || port >= DE_PORT_NR) |
|
- | 299 | panic("", "dp8390: illegal port", port); |
|
- | 300 | dep= &de_table[port]; |
|
- | 301 | dep->de_client= mp->DL_PROC; |
|
- | 302 | */ |
|
- | 303 | if (dep->de_mode == DEM_SINK) |
|
- | 304 | { |
|
- | 305 | assert(!from_int); |
|
- | 306 | dep->de_flags |= DEF_PACK_SEND; |
|
- | 307 | reply(dep, OK, FALSE); |
|
- | 308 | // return; |
|
- | 309 | return EOK; |
|
- | 310 | } |
|
- | 311 | assert(dep->de_mode == DEM_ENABLED); |
|
- | 312 | assert(dep->de_flags & DEF_ENABLED); |
|
- | 313 | if (dep->de_flags & DEF_SEND_AVAIL){ |
|
- | 314 | // panic("", "dp8390: send already in progress", NO_NUM); |
|
- | 315 | return queue_packet( dep, packet ); |
|
- | 316 | } |
|
- | 317 | ||
- | 318 | sendq_head= dep->de_sendq_head; |
|
- | 319 | if (dep->de_sendq[sendq_head].sq_filled) |
|
- | 320 | { |
|
- | 321 | if (from_int) |
|
- | 322 | panic("", "dp8390: should not be sending\n", NO_NUM); |
|
- | 323 | // dep->de_sendmsg= *mp; |
|
- | 324 | dep->de_flags |= DEF_SEND_AVAIL; |
|
- | 325 | reply(dep, OK, FALSE); |
|
- | 326 | // return; |
|
- | 327 | return queue_packet( dep, packet ); |
|
- | 328 | } |
|
- | 329 | assert(!(dep->de_flags & DEF_PACK_SEND)); |
|
- | 330 | ||
- | 331 | /* if (vectored) |
|
- | 332 | { |
|
- | 333 | get_userdata(mp->DL_PROC, (vir_bytes) mp->DL_ADDR, |
|
- | 334 | (count > IOVEC_NR ? IOVEC_NR : count) * |
|
- | 335 | sizeof(iovec_t), dep->de_write_iovec.iod_iovec); |
|
- | 336 | dep->de_write_iovec.iod_iovec_s = count; |
|
- | 337 | dep->de_write_iovec.iod_proc_nr = mp->DL_PROC; |
|
- | 338 | dep->de_write_iovec.iod_iovec_addr = (vir_bytes) mp->DL_ADDR; |
|
- | 339 | ||
- | 340 | dep->de_tmp_iovec = dep->de_write_iovec; |
|
- | 341 | size = calc_iovec_size(&dep->de_tmp_iovec); |
|
- | 342 | } |
|
- | 343 | else |
|
- | 344 | { |
|
- | 345 | dep->de_write_iovec.iod_iovec[0].iov_addr = |
|
- | 346 | (vir_bytes) mp->DL_ADDR; |
|
- | 347 | dep->de_write_iovec.iod_iovec[0].iov_size = |
|
- | 348 | mp->DL_COUNT; |
|
- | 349 | dep->de_write_iovec.iod_iovec_s = 1; |
|
- | 350 | dep->de_write_iovec.iod_proc_nr = mp->DL_PROC; |
|
- | 351 | dep->de_write_iovec.iod_iovec_addr = 0; |
|
- | 352 | size= mp->DL_COUNT; |
|
- | 353 | } |
|
- | 354 | */ |
|
- | 355 | size = packet_get_data_length( packet ); |
|
- | 356 | dep->de_write_iovec.iod_iovec[0].iov_addr = ( vir_bytes ) packet_get_data( packet ); |
|
- | 357 | dep->de_write_iovec.iod_iovec[0].iov_size = size; |
|
- | 358 | dep->de_write_iovec.iod_iovec_s = 1; |
|
- | 359 | dep->de_write_iovec.iod_iovec_addr = NULL; |
|
- | 360 | ||
- | 361 | if (size < ETH_MIN_PACK_SIZE || size > ETH_MAX_PACK_SIZE_TAGGED) |
|
- | 362 | { |
|
- | 363 | panic("", "dp8390: invalid packet size", size); |
|
- | 364 | return EINVAL; |
|
- | 365 | } |
|
- | 366 | (dep->de_user2nicf)(dep, &dep->de_write_iovec, 0, |
|
- | 367 | dep->de_sendq[sendq_head].sq_sendpage * DP_PAGESIZE, |
|
- | 368 | size); |
|
- | 369 | dep->de_sendq[sendq_head].sq_filled= TRUE; |
|
- | 370 | if (dep->de_sendq_tail == sendq_head) |
|
- | 371 | { |
|
- | 372 | outb_reg0(dep, DP_TPSR, dep->de_sendq[sendq_head].sq_sendpage); |
|
- | 373 | outb_reg0(dep, DP_TBCR1, size >> 8); |
|
- | 374 | outb_reg0(dep, DP_TBCR0, size & 0xff); |
|
- | 375 | outb_reg0(dep, DP_CR, CR_TXP | CR_EXTRA);/* there it goes.. */ |
|
- | 376 | } |
|
- | 377 | else |
|
- | 378 | dep->de_sendq[sendq_head].sq_size= size; |
|
- | 379 | ||
- | 380 | if (++sendq_head == dep->de_sendq_nr) |
|
- | 381 | sendq_head= 0; |
|
- | 382 | assert(sendq_head < SENDQ_NR); |
|
- | 383 | dep->de_sendq_head= sendq_head; |
|
- | 384 | ||
- | 385 | dep->de_flags |= DEF_PACK_SEND; |
|
- | 386 | ||
- | 387 | /* If the interrupt handler called, don't send a reply. The reply |
|
- | 388 | * will be sent after all interrupts are handled. |
|
- | 389 | */ |
|
- | 390 | if (from_int) |
|
- | 391 | return EOK; |
|
- | 392 | reply(dep, OK, FALSE); |
|
- | 393 | ||
- | 394 | assert(dep->de_mode == DEM_ENABLED); |
|
- | 395 | assert(dep->de_flags & DEF_ENABLED); |
|
- | 396 | return EOK; |
|
- | 397 | } |
|
- | 398 | ||
261 | /*===========================================================================* |
399 | /*===========================================================================* |
262 | * dp_init * |
400 | * dp_init * |
263 | *===========================================================================*/ |
401 | *===========================================================================*/ |
264 | void dp_init(dep) |
402 | void dp_init(dep) |
265 | dpeth_t *dep; |
403 | dpeth_t *dep; |
Line 351... | Line 489... | ||
351 | dep->de_flags |= DEF_ENABLED; |
489 | dep->de_flags |= DEF_ENABLED; |
352 | for (i= 0; i<dep->de_sendq_nr; i++) |
490 | for (i= 0; i<dep->de_sendq_nr; i++) |
353 | dep->de_sendq[i].sq_filled= 0; |
491 | dep->de_sendq[i].sq_filled= 0; |
354 | dep->de_sendq_head= 0; |
492 | dep->de_sendq_head= 0; |
355 | dep->de_sendq_tail= 0; |
493 | dep->de_sendq_tail= 0; |
356 | // if (!dep->de_prog_IO) |
494 | if (!dep->de_prog_IO) |
357 | // { |
495 | { |
358 | // dep->de_user2nicf= dp_user2nic; |
496 | dep->de_user2nicf= dp_user2nic; |
359 | // dep->de_user2nicf_s= dp_user2nic_s; |
497 | // dep->de_user2nicf_s= dp_user2nic_s; |
360 | dep->de_nic2userf= dp_nic2user; |
498 | dep->de_nic2userf= dp_nic2user; |
361 | // dep->de_nic2userf_s= dp_nic2user_s; |
499 | // dep->de_nic2userf_s= dp_nic2user_s; |
362 | dep->de_getblockf= dp_getblock; |
500 | dep->de_getblockf= dp_getblock; |
363 | // } |
501 | } |
364 | // else if (dep->de_16bit) |
502 | else if (dep->de_16bit) |
365 | // { |
503 | { |
366 | // dep->de_user2nicf= dp_pio16_user2nic; |
504 | dep->de_user2nicf= dp_pio16_user2nic; |
367 | // dep->de_user2nicf_s= dp_pio16_user2nic_s; |
505 | // dep->de_user2nicf_s= dp_pio16_user2nic_s; |
368 | // dep->de_nic2userf= dp_pio16_nic2user; |
506 | dep->de_nic2userf= dp_pio16_nic2user; |
369 | // dep->de_nic2userf_s= dp_pio16_nic2user_s; |
507 | // dep->de_nic2userf_s= dp_pio16_nic2user_s; |
370 | // dep->de_getblockf= dp_pio16_getblock; |
508 | dep->de_getblockf= dp_pio16_getblock; |
371 | // } |
509 | } |
372 | // else |
510 | else |
373 | // { |
511 | { |
374 | // dep->de_user2nicf= dp_pio8_user2nic; |
512 | dep->de_user2nicf= dp_pio8_user2nic; |
375 | // dep->de_user2nicf_s= dp_pio8_user2nic_s; |
513 | // dep->de_user2nicf_s= dp_pio8_user2nic_s; |
376 | // dep->de_nic2userf= dp_pio8_nic2user; |
514 | dep->de_nic2userf= dp_pio8_nic2user; |
377 | // dep->de_nic2userf_s= dp_pio8_nic2user_s; |
515 | // dep->de_nic2userf_s= dp_pio8_nic2user_s; |
378 | // dep->de_getblockf= dp_pio8_getblock; |
516 | dep->de_getblockf= dp_pio8_getblock; |
379 | // } |
517 | } |
380 | 518 | ||
381 | /* Set the interrupt handler and policy. Do not automatically |
519 | /* Set the interrupt handler and policy. Do not automatically |
382 | * reenable interrupts. Return the IRQ line number on interrupts. |
520 | * reenable interrupts. Return the IRQ line number on interrupts. |
383 | */ |
521 | */ |
384 | /* dep->de_hook = dep->de_irq; |
522 | /* dep->de_hook = dep->de_irq; |
Line 690... | Line 828... | ||
690 | * dp_send * |
828 | * dp_send * |
691 | *===========================================================================*/ |
829 | *===========================================================================*/ |
692 | static void dp_send(dep) |
830 | static void dp_send(dep) |
693 | dpeth_t *dep; |
831 | dpeth_t *dep; |
694 | { |
832 | { |
- | 833 | packet_t packet; |
|
- | 834 | ||
695 | /* if (!(dep->de_flags & DEF_SEND_AVAIL)) |
835 | if (!(dep->de_flags & DEF_SEND_AVAIL)) |
696 | return; |
836 | return; |
697 | 837 | ||
698 | dep->de_flags &= ~DEF_SEND_AVAIL; |
838 | dep->de_flags &= ~DEF_SEND_AVAIL; |
- | 839 | while( dep->packet_queue ){ |
|
- | 840 | packet = dep->packet_queue; |
|
- | 841 | dep->packet_queue = pq_detach( packet ); |
|
- | 842 | do_pwrite( dep, packet, TRUE ); |
|
- | 843 | netif_pq_release( packet_get_id( packet )); |
|
- | 844 | -- dep->packet_count; |
|
- | 845 | } |
|
699 | switch(dep->de_sendmsg.m_type) |
846 | /* switch(dep->de_sendmsg.m_type) |
700 | { |
847 | { |
701 | case DL_WRITE: do_vwrite(&dep->de_sendmsg, TRUE, FALSE); break; |
848 | case DL_WRITE: do_vwrite(&dep->de_sendmsg, TRUE, FALSE); break; |
702 | case DL_WRITEV: do_vwrite(&dep->de_sendmsg, TRUE, TRUE); break; |
849 | case DL_WRITEV: do_vwrite(&dep->de_sendmsg, TRUE, TRUE); break; |
703 | case DL_WRITEV_S: do_vwrite_s(&dep->de_sendmsg, TRUE); break; |
850 | case DL_WRITEV_S: do_vwrite_s(&dep->de_sendmsg, TRUE); break; |
704 | default: |
851 | default: |
Line 724... | Line 871... | ||
724 | 871 | ||
725 | memcpy(dst, dep->de_locmem + offset, size); |
872 | memcpy(dst, dep->de_locmem + offset, size); |
726 | } |
873 | } |
727 | 874 | ||
728 | /*===========================================================================* |
875 | /*===========================================================================* |
- | 876 | * dp_pio8_getblock * |
|
- | 877 | *===========================================================================*/ |
|
- | 878 | static void dp_pio8_getblock(dep, page, offset, size, dst) |
|
- | 879 | dpeth_t *dep; |
|
- | 880 | int page; |
|
- | 881 | size_t offset; |
|
- | 882 | size_t size; |
|
- | 883 | void *dst; |
|
- | 884 | { |
|
- | 885 | offset = page * DP_PAGESIZE + offset; |
|
- | 886 | outb_reg0(dep, DP_RBCR0, size & 0xFF); |
|
- | 887 | outb_reg0(dep, DP_RBCR1, size >> 8); |
|
- | 888 | outb_reg0(dep, DP_RSAR0, offset & 0xFF); |
|
- | 889 | outb_reg0(dep, DP_RSAR1, offset >> 8); |
|
- | 890 | outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); |
|
- | 891 | ||
- | 892 | insb(dep->de_data_port, dst, size); |
|
- | 893 | } |
|
- | 894 | ||
- | 895 | /*===========================================================================* |
|
- | 896 | * dp_pio16_getblock * |
|
- | 897 | *===========================================================================*/ |
|
- | 898 | static void dp_pio16_getblock(dep, page, offset, size, dst) |
|
- | 899 | dpeth_t *dep; |
|
- | 900 | int page; |
|
- | 901 | size_t offset; |
|
- | 902 | size_t size; |
|
- | 903 | void *dst; |
|
- | 904 | { |
|
- | 905 | offset = page * DP_PAGESIZE + offset; |
|
- | 906 | outb_reg0(dep, DP_RBCR0, size & 0xFF); |
|
- | 907 | outb_reg0(dep, DP_RBCR1, size >> 8); |
|
- | 908 | outb_reg0(dep, DP_RSAR0, offset & 0xFF); |
|
- | 909 | outb_reg0(dep, DP_RSAR1, offset >> 8); |
|
- | 910 | outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); |
|
- | 911 | ||
- | 912 | assert (!(size & 1)); |
|
- | 913 | insw(dep->de_data_port, dst, size); |
|
- | 914 | } |
|
- | 915 | ||
- | 916 | /*===========================================================================* |
|
729 | * dp_pkt2user * |
917 | * dp_pkt2user * |
730 | *===========================================================================*/ |
918 | *===========================================================================*/ |
731 | static int dp_pkt2user(dep, page, length) |
919 | static int dp_pkt2user(dep, page, length) |
732 | dpeth_t *dep; |
920 | dpeth_t *dep; |
733 | int page, length; |
921 | int page, length; |
734 | { |
922 | { |
735 | int last, count; |
923 | int last, count; |
- | 924 | packet_t packet; |
|
736 | 925 | ||
737 | if (!(dep->de_flags & DEF_READING)) |
926 | if (!(dep->de_flags & DEF_READING)) |
738 | return EGENERIC; |
927 | return EGENERIC; |
739 | 928 | ||
- | 929 | packet = netif_packet_get_1( length ); |
|
- | 930 | if( ! packet ) return ENOMEM; |
|
- | 931 | dep->de_read_iovec.iod_iovec[0].iov_addr = ( vir_bytes ) packet_suffix( packet, length ); |
|
- | 932 | dep->de_read_iovec.iod_iovec[0].iov_size = length; |
|
- | 933 | dep->de_read_iovec.iod_iovec_s = 1; |
|
- | 934 | dep->de_read_iovec.iod_iovec_addr = NULL; |
|
- | 935 | ||
740 | last = page + (length - 1) / DP_PAGESIZE; |
936 | last = page + (length - 1) / DP_PAGESIZE; |
741 | if (last >= dep->de_stoppage) |
937 | if (last >= dep->de_stoppage) |
742 | { |
938 | { |
743 | count = (dep->de_stoppage - page) * DP_PAGESIZE - |
939 | count = (dep->de_stoppage - page) * DP_PAGESIZE - |
744 | sizeof(dp_rcvhdr_t); |
940 | sizeof(dp_rcvhdr_t); |
Line 758... | Line 954... | ||
758 | 954 | ||
759 | dep->de_read_s = length; |
955 | dep->de_read_s = length; |
760 | dep->de_flags |= DEF_PACK_RECV; |
956 | dep->de_flags |= DEF_PACK_RECV; |
761 | dep->de_flags &= ~DEF_READING; |
957 | dep->de_flags &= ~DEF_READING; |
762 | 958 | ||
- | 959 | if( netif_send_packet( dep, packet ) != EOK ){ |
|
- | 960 | netif_pq_release( packet_get_id( packet )); |
|
- | 961 | } |
|
763 | return OK; |
962 | return OK; |
764 | } |
963 | } |
765 | 964 | ||
766 | /*===========================================================================* |
965 | /*===========================================================================* |
- | 966 | * dp_user2nic * |
|
- | 967 | *===========================================================================*/ |
|
- | 968 | static void dp_user2nic(dep, iovp, offset, nic_addr, count) |
|
- | 969 | dpeth_t *dep; |
|
- | 970 | iovec_dat_t *iovp; |
|
- | 971 | vir_bytes offset; |
|
- | 972 | int nic_addr; |
|
- | 973 | vir_bytes count; |
|
- | 974 | { |
|
- | 975 | vir_bytes vir_hw;//, vir_user; |
|
- | 976 | int bytes, i, r; |
|
- | 977 | ||
- | 978 | vir_hw = (vir_bytes)dep->de_locmem + nic_addr; |
|
- | 979 | ||
- | 980 | i= 0; |
|
- | 981 | while (count > 0) |
|
- | 982 | { |
|
- | 983 | if (i >= IOVEC_NR) |
|
- | 984 | { |
|
- | 985 | dp_next_iovec(iovp); |
|
- | 986 | i= 0; |
|
- | 987 | continue; |
|
- | 988 | } |
|
- | 989 | assert(i < iovp->iod_iovec_s); |
|
- | 990 | if (offset >= iovp->iod_iovec[i].iov_size) |
|
- | 991 | { |
|
- | 992 | offset -= iovp->iod_iovec[i].iov_size; |
|
- | 993 | i++; |
|
- | 994 | continue; |
|
- | 995 | } |
|
- | 996 | bytes = iovp->iod_iovec[i].iov_size - offset; |
|
- | 997 | if (bytes > count) |
|
- | 998 | bytes = count; |
|
- | 999 | ||
- | 1000 | r= sys_vircopy(iovp->iod_proc_nr, D, |
|
- | 1001 | iovp->iod_iovec[i].iov_addr + offset, |
|
- | 1002 | SELF, D, vir_hw, bytes); |
|
- | 1003 | if (r != OK) |
|
- | 1004 | panic("DP8390", "dp_user2nic: sys_vircopy failed", r); |
|
- | 1005 | ||
- | 1006 | count -= bytes; |
|
- | 1007 | vir_hw += bytes; |
|
- | 1008 | offset += bytes; |
|
- | 1009 | } |
|
- | 1010 | assert(count == 0); |
|
- | 1011 | } |
|
- | 1012 | ||
- | 1013 | /*===========================================================================* |
|
- | 1014 | * dp_pio8_user2nic * |
|
- | 1015 | *===========================================================================*/ |
|
- | 1016 | static void dp_pio8_user2nic(dep, iovp, offset, nic_addr, count) |
|
- | 1017 | dpeth_t *dep; |
|
- | 1018 | iovec_dat_t *iovp; |
|
- | 1019 | vir_bytes offset; |
|
- | 1020 | int nic_addr; |
|
- | 1021 | vir_bytes count; |
|
- | 1022 | { |
|
- | 1023 | // phys_bytes phys_user; |
|
- | 1024 | int bytes, i; |
|
- | 1025 | ||
- | 1026 | outb_reg0(dep, DP_ISR, ISR_RDC); |
|
- | 1027 | ||
- | 1028 | outb_reg0(dep, DP_RBCR0, count & 0xFF); |
|
- | 1029 | outb_reg0(dep, DP_RBCR1, count >> 8); |
|
- | 1030 | outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF); |
|
- | 1031 | outb_reg0(dep, DP_RSAR1, nic_addr >> 8); |
|
- | 1032 | outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA); |
|
- | 1033 | ||
- | 1034 | i= 0; |
|
- | 1035 | while (count > 0) |
|
- | 1036 | { |
|
- | 1037 | if (i >= IOVEC_NR) |
|
- | 1038 | { |
|
- | 1039 | dp_next_iovec(iovp); |
|
- | 1040 | i= 0; |
|
- | 1041 | continue; |
|
- | 1042 | } |
|
- | 1043 | assert(i < iovp->iod_iovec_s); |
|
- | 1044 | if (offset >= iovp->iod_iovec[i].iov_size) |
|
- | 1045 | { |
|
- | 1046 | offset -= iovp->iod_iovec[i].iov_size; |
|
- | 1047 | i++; |
|
- | 1048 | continue; |
|
- | 1049 | } |
|
- | 1050 | bytes = iovp->iod_iovec[i].iov_size - offset; |
|
- | 1051 | if (bytes > count) |
|
- | 1052 | bytes = count; |
|
- | 1053 | ||
- | 1054 | do_vir_outsb(dep->de_data_port, iovp->iod_proc_nr, |
|
- | 1055 | iovp->iod_iovec[i].iov_addr + offset, bytes); |
|
- | 1056 | count -= bytes; |
|
- | 1057 | offset += bytes; |
|
- | 1058 | } |
|
- | 1059 | assert(count == 0); |
|
- | 1060 | ||
- | 1061 | for (i= 0; i<100; i++) |
|
- | 1062 | { |
|
- | 1063 | if (inb_reg0(dep, DP_ISR) & ISR_RDC) |
|
- | 1064 | break; |
|
- | 1065 | } |
|
- | 1066 | if (i == 100) |
|
- | 1067 | { |
|
- | 1068 | panic("", "dp8390: remote dma failed to complete", NO_NUM); |
|
- | 1069 | } |
|
- | 1070 | } |
|
- | 1071 | ||
- | 1072 | /*===========================================================================* |
|
- | 1073 | * dp_pio16_user2nic * |
|
- | 1074 | *===========================================================================*/ |
|
- | 1075 | static void dp_pio16_user2nic(dep, iovp, offset, nic_addr, count) |
|
- | 1076 | dpeth_t *dep; |
|
- | 1077 | iovec_dat_t *iovp; |
|
- | 1078 | vir_bytes offset; |
|
- | 1079 | int nic_addr; |
|
- | 1080 | vir_bytes count; |
|
- | 1081 | { |
|
- | 1082 | vir_bytes vir_user; |
|
- | 1083 | vir_bytes ecount; |
|
- | 1084 | int i, r, bytes, user_proc; |
|
- | 1085 | u8_t two_bytes[2]; |
|
- | 1086 | int odd_byte; |
|
- | 1087 | ||
- | 1088 | ecount= (count+1) & ~1; |
|
- | 1089 | odd_byte= 0; |
|
- | 1090 | ||
- | 1091 | outb_reg0(dep, DP_ISR, ISR_RDC); |
|
- | 1092 | outb_reg0(dep, DP_RBCR0, ecount & 0xFF); |
|
- | 1093 | outb_reg0(dep, DP_RBCR1, ecount >> 8); |
|
- | 1094 | outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF); |
|
- | 1095 | outb_reg0(dep, DP_RSAR1, nic_addr >> 8); |
|
- | 1096 | outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA); |
|
- | 1097 | ||
- | 1098 | i= 0; |
|
- | 1099 | while (count > 0) |
|
- | 1100 | { |
|
- | 1101 | if (i >= IOVEC_NR) |
|
- | 1102 | { |
|
- | 1103 | dp_next_iovec(iovp); |
|
- | 1104 | i= 0; |
|
- | 1105 | continue; |
|
- | 1106 | } |
|
- | 1107 | assert(i < iovp->iod_iovec_s); |
|
- | 1108 | if (offset >= iovp->iod_iovec[i].iov_size) |
|
- | 1109 | { |
|
- | 1110 | offset -= iovp->iod_iovec[i].iov_size; |
|
- | 1111 | i++; |
|
- | 1112 | continue; |
|
- | 1113 | } |
|
- | 1114 | bytes = iovp->iod_iovec[i].iov_size - offset; |
|
- | 1115 | if (bytes > count) |
|
- | 1116 | bytes = count; |
|
- | 1117 | ||
- | 1118 | user_proc= iovp->iod_proc_nr; |
|
- | 1119 | vir_user= iovp->iod_iovec[i].iov_addr + offset; |
|
- | 1120 | if (odd_byte) |
|
- | 1121 | { |
|
- | 1122 | r= sys_vircopy(user_proc, D, vir_user, |
|
- | 1123 | SELF, D, (vir_bytes)&two_bytes[1], 1); |
|
- | 1124 | if (r != OK) |
|
- | 1125 | { |
|
- | 1126 | panic("DP8390", |
|
- | 1127 | "dp_pio16_user2nic: sys_vircopy failed", |
|
- | 1128 | r); |
|
- | 1129 | } |
|
- | 1130 | outw(dep->de_data_port, *(u16_t *)two_bytes); |
|
- | 1131 | count--; |
|
- | 1132 | offset++; |
|
- | 1133 | bytes--; |
|
- | 1134 | vir_user++; |
|
- | 1135 | odd_byte= 0; |
|
- | 1136 | if (!bytes) |
|
- | 1137 | continue; |
|
- | 1138 | } |
|
- | 1139 | ecount= bytes & ~1; |
|
- | 1140 | if (ecount != 0) |
|
- | 1141 | { |
|
- | 1142 | do_vir_outsw(dep->de_data_port, user_proc, vir_user, |
|
- | 1143 | ecount); |
|
- | 1144 | count -= ecount; |
|
- | 1145 | offset += ecount; |
|
- | 1146 | bytes -= ecount; |
|
- | 1147 | vir_user += ecount; |
|
- | 1148 | } |
|
- | 1149 | if (bytes) |
|
- | 1150 | { |
|
- | 1151 | assert(bytes == 1); |
|
- | 1152 | r= sys_vircopy(user_proc, D, vir_user, |
|
- | 1153 | SELF, D, (vir_bytes)&two_bytes[0], 1); |
|
- | 1154 | if (r != OK) |
|
- | 1155 | { |
|
- | 1156 | panic("DP8390", |
|
- | 1157 | "dp_pio16_user2nic: sys_vircopy failed", |
|
- | 1158 | r); |
|
- | 1159 | } |
|
- | 1160 | count--; |
|
- | 1161 | offset++; |
|
- | 1162 | bytes--; |
|
- | 1163 | vir_user++; |
|
- | 1164 | odd_byte= 1; |
|
- | 1165 | } |
|
- | 1166 | } |
|
- | 1167 | assert(count == 0); |
|
- | 1168 | ||
- | 1169 | if (odd_byte) |
|
- | 1170 | outw(dep->de_data_port, *(u16_t *)two_bytes); |
|
- | 1171 | ||
- | 1172 | for (i= 0; i<100; i++) |
|
- | 1173 | { |
|
- | 1174 | if (inb_reg0(dep, DP_ISR) & ISR_RDC) |
|
- | 1175 | break; |
|
- | 1176 | } |
|
- | 1177 | if (i == 100) |
|
- | 1178 | { |
|
- | 1179 | panic("", "dp8390: remote dma failed to complete", NO_NUM); |
|
- | 1180 | } |
|
- | 1181 | } |
|
- | 1182 | ||
- | 1183 | /*===========================================================================* |
|
767 | * dp_nic2user * |
1184 | * dp_nic2user * |
768 | *===========================================================================*/ |
1185 | *===========================================================================*/ |
769 | static void dp_nic2user(dep, nic_addr, iovp, offset, count) |
1186 | static void dp_nic2user(dep, nic_addr, iovp, offset, count) |
770 | dpeth_t *dep; |
1187 | dpeth_t *dep; |
771 | int nic_addr; |
1188 | int nic_addr; |
772 | iovec_dat_t *iovp; |
1189 | iovec_dat_t *iovp; |
773 | vir_bytes offset; |
1190 | vir_bytes offset; |
774 | vir_bytes count; |
1191 | vir_bytes count; |
775 | { |
1192 | { |
776 | /* vir_bytes vir_hw, vir_user; |
1193 | vir_bytes vir_hw;//, vir_user; |
777 | int bytes, i, r; |
1194 | int bytes, i, r; |
778 | 1195 | ||
779 | vir_hw = (vir_bytes)dep->de_locmem + nic_addr; |
1196 | vir_hw = (vir_bytes)dep->de_locmem + nic_addr; |
780 | 1197 | ||
781 | i= 0; |
1198 | i= 0; |
Line 807... | Line 1224... | ||
807 | count -= bytes; |
1224 | count -= bytes; |
808 | vir_hw += bytes; |
1225 | vir_hw += bytes; |
809 | offset += bytes; |
1226 | offset += bytes; |
810 | } |
1227 | } |
811 | assert(count == 0); |
1228 | assert(count == 0); |
- | 1229 | } |
|
- | 1230 | ||
- | 1231 | /*===========================================================================* |
|
- | 1232 | * dp_pio8_nic2user * |
|
- | 1233 | *===========================================================================*/ |
|
- | 1234 | static void dp_pio8_nic2user(dep, nic_addr, iovp, offset, count) |
|
- | 1235 | dpeth_t *dep; |
|
- | 1236 | int nic_addr; |
|
- | 1237 | iovec_dat_t *iovp; |
|
- | 1238 | vir_bytes offset; |
|
- | 1239 | vir_bytes count; |
|
- | 1240 | { |
|
- | 1241 | // phys_bytes phys_user; |
|
- | 1242 | int bytes, i; |
|
- | 1243 | ||
- | 1244 | outb_reg0(dep, DP_RBCR0, count & 0xFF); |
|
- | 1245 | outb_reg0(dep, DP_RBCR1, count >> 8); |
|
- | 1246 | outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF); |
|
- | 1247 | outb_reg0(dep, DP_RSAR1, nic_addr >> 8); |
|
- | 1248 | outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); |
|
- | 1249 | ||
- | 1250 | i= 0; |
|
- | 1251 | while (count > 0) |
|
- | 1252 | { |
|
- | 1253 | if (i >= IOVEC_NR) |
|
- | 1254 | { |
|
- | 1255 | dp_next_iovec(iovp); |
|
- | 1256 | i= 0; |
|
- | 1257 | continue; |
|
- | 1258 | } |
|
- | 1259 | assert(i < iovp->iod_iovec_s); |
|
- | 1260 | if (offset >= iovp->iod_iovec[i].iov_size) |
|
- | 1261 | { |
|
- | 1262 | offset -= iovp->iod_iovec[i].iov_size; |
|
- | 1263 | i++; |
|
- | 1264 | continue; |
|
- | 1265 | } |
|
- | 1266 | bytes = iovp->iod_iovec[i].iov_size - offset; |
|
- | 1267 | if (bytes > count) |
|
- | 1268 | bytes = count; |
|
- | 1269 | ||
- | 1270 | do_vir_insb(dep->de_data_port, iovp->iod_proc_nr, |
|
- | 1271 | iovp->iod_iovec[i].iov_addr + offset, bytes); |
|
- | 1272 | count -= bytes; |
|
- | 1273 | offset += bytes; |
|
- | 1274 | } |
|
- | 1275 | assert(count == 0); |
|
- | 1276 | } |
|
- | 1277 | ||
- | 1278 | /*===========================================================================* |
|
- | 1279 | * dp_pio16_nic2user * |
|
- | 1280 | *===========================================================================*/ |
|
- | 1281 | static void dp_pio16_nic2user(dep, nic_addr, iovp, offset, count) |
|
- | 1282 | dpeth_t *dep; |
|
- | 1283 | int nic_addr; |
|
- | 1284 | iovec_dat_t *iovp; |
|
- | 1285 | vir_bytes offset; |
|
- | 1286 | vir_bytes count; |
|
- | 1287 | { |
|
- | 1288 | vir_bytes vir_user; |
|
- | 1289 | vir_bytes ecount; |
|
- | 1290 | int i, r, bytes, user_proc; |
|
- | 1291 | u8_t two_bytes[2]; |
|
- | 1292 | int odd_byte; |
|
- | 1293 | ||
- | 1294 | ecount= (count+1) & ~1; |
|
- | 1295 | odd_byte= 0; |
|
- | 1296 | ||
- | 1297 | outb_reg0(dep, DP_RBCR0, ecount & 0xFF); |
|
- | 1298 | outb_reg0(dep, DP_RBCR1, ecount >> 8); |
|
- | 1299 | outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF); |
|
- | 1300 | outb_reg0(dep, DP_RSAR1, nic_addr >> 8); |
|
- | 1301 | outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); |
|
- | 1302 | ||
- | 1303 | i= 0; |
|
- | 1304 | while (count > 0) |
|
812 | */ |
1305 | { |
- | 1306 | if (i >= IOVEC_NR) |
|
- | 1307 | { |
|
- | 1308 | dp_next_iovec(iovp); |
|
- | 1309 | i= 0; |
|
- | 1310 | continue; |
|
- | 1311 | } |
|
- | 1312 | assert(i < iovp->iod_iovec_s); |
|
- | 1313 | if (offset >= iovp->iod_iovec[i].iov_size) |
|
- | 1314 | { |
|
- | 1315 | offset -= iovp->iod_iovec[i].iov_size; |
|
- | 1316 | i++; |
|
813 | printf("n2u"); |
1317 | continue; |
- | 1318 | } |
|
- | 1319 | bytes = iovp->iod_iovec[i].iov_size - offset; |
|
- | 1320 | if (bytes > count) |
|
- | 1321 | bytes = count; |
|
- | 1322 | ||
- | 1323 | user_proc= iovp->iod_proc_nr; |
|
- | 1324 | vir_user= iovp->iod_iovec[i].iov_addr + offset; |
|
- | 1325 | if (odd_byte) |
|
- | 1326 | { |
|
- | 1327 | r= sys_vircopy(SELF, D, (vir_bytes)&two_bytes[1], |
|
- | 1328 | user_proc, D, vir_user, 1); |
|
- | 1329 | if (r != OK) |
|
- | 1330 | { |
|
- | 1331 | panic("DP8390", |
|
- | 1332 | "dp_pio16_nic2user: sys_vircopy failed", |
|
- | 1333 | r); |
|
- | 1334 | } |
|
- | 1335 | count--; |
|
- | 1336 | offset++; |
|
- | 1337 | bytes--; |
|
- | 1338 | vir_user++; |
|
- | 1339 | odd_byte= 0; |
|
- | 1340 | if (!bytes) |
|
- | 1341 | continue; |
|
- | 1342 | } |
|
- | 1343 | ecount= bytes & ~1; |
|
- | 1344 | if (ecount != 0) |
|
- | 1345 | { |
|
- | 1346 | do_vir_insw(dep->de_data_port, user_proc, vir_user, |
|
- | 1347 | ecount); |
|
- | 1348 | count -= ecount; |
|
- | 1349 | offset += ecount; |
|
- | 1350 | bytes -= ecount; |
|
- | 1351 | vir_user += ecount; |
|
- | 1352 | } |
|
- | 1353 | if (bytes) |
|
- | 1354 | { |
|
- | 1355 | assert(bytes == 1); |
|
- | 1356 | *(u16_t *)two_bytes= inw(dep->de_data_port); |
|
- | 1357 | r= sys_vircopy(SELF, D, (vir_bytes)&two_bytes[0], |
|
- | 1358 | user_proc, D, vir_user, 1); |
|
- | 1359 | if (r != OK) |
|
- | 1360 | { |
|
- | 1361 | panic("DP8390", |
|
- | 1362 | "dp_pio16_nic2user: sys_vircopy failed", |
|
- | 1363 | r); |
|
- | 1364 | } |
|
- | 1365 | count--; |
|
- | 1366 | offset++; |
|
- | 1367 | bytes--; |
|
- | 1368 | vir_user++; |
|
- | 1369 | odd_byte= 1; |
|
- | 1370 | } |
|
- | 1371 | } |
|
- | 1372 | assert(count == 0); |
|
- | 1373 | } |
|
- | 1374 | ||
- | 1375 | /*===========================================================================* |
|
- | 1376 | * dp_next_iovec * |
|
- | 1377 | *===========================================================================*/ |
|
- | 1378 | static void dp_next_iovec(iovp) |
|
- | 1379 | iovec_dat_t *iovp; |
|
- | 1380 | { |
|
- | 1381 | assert(iovp->iod_iovec_s > IOVEC_NR); |
|
- | 1382 | ||
- | 1383 | iovp->iod_iovec_s -= IOVEC_NR; |
|
- | 1384 | ||
- | 1385 | iovp->iod_iovec_addr += IOVEC_NR * sizeof(iovec_t); |
|
- | 1386 | ||
- | 1387 | get_userdata(iovp->iod_proc_nr, iovp->iod_iovec_addr, |
|
- | 1388 | (iovp->iod_iovec_s > IOVEC_NR ? IOVEC_NR : iovp->iod_iovec_s) * |
|
- | 1389 | sizeof(iovec_t), iovp->iod_iovec); |
|
814 | } |
1390 | } |
815 | 1391 | ||
816 | /*===========================================================================* |
1392 | /*===========================================================================* |
817 | * conf_hw * |
1393 | * conf_hw * |
818 | *===========================================================================*/ |
1394 | *===========================================================================*/ |
Line 857... | Line 1433... | ||
857 | // size_t o, size; |
1433 | // size_t o, size; |
858 | // char *buf, *abuf; |
1434 | // char *buf, *abuf; |
859 | 1435 | ||
860 | if (dep->de_prog_IO) |
1436 | if (dep->de_prog_IO) |
861 | { |
1437 | { |
862 | //#if 0 |
1438 | #if 0 |
863 | if(debug){ |
1439 | if(debug){ |
864 | printf( |
1440 | printf( |
865 | "map_hw_buffer: programmed I/O, no need to map buffer\n"); |
1441 | "map_hw_buffer: programmed I/O, no need to map buffer\n"); |
866 | } |
1442 | } |
867 | //#endif |
1443 | #endif |
868 | dep->de_locmem = (char *)-dep->de_ramsize; /* trap errors */ |
1444 | dep->de_locmem = (char *)-dep->de_ramsize; /* trap errors */ |
869 | return; |
1445 | return; |
- | 1446 | }else{ |
|
- | 1447 | printf( "map_hw_buffer: no buffer!" ); |
|
870 | } |
1448 | } |
871 | 1449 | ||
872 | // size = dep->de_ramsize + PAGE_SIZE; /* Add PAGE_SIZE for |
1450 | // size = dep->de_ramsize + PAGE_SIZE; /* Add PAGE_SIZE for |
873 | // * alignment |
1451 | // * alignment |
874 | // */ |
1452 | // */ |
Line 925... | Line 1503... | ||
925 | |
1503 | |
926 | dep->de_read_s = 0; |
1504 | dep->de_read_s = 0; |
927 | */ dep->de_flags &= ~(DEF_PACK_SEND | DEF_PACK_RECV); |
1505 | */ dep->de_flags &= ~(DEF_PACK_SEND | DEF_PACK_RECV); |
928 | } |
1506 | } |
929 | 1507 | ||
- | 1508 | /*===========================================================================* |
|
- | 1509 | * get_userdata * |
|
- | 1510 | *===========================================================================*/ |
|
- | 1511 | static void get_userdata(user_proc, user_addr, count, loc_addr) |
|
- | 1512 | int user_proc; |
|
- | 1513 | vir_bytes user_addr; |
|
- | 1514 | vir_bytes count; |
|
- | 1515 | void *loc_addr; |
|
- | 1516 | { |
|
- | 1517 | int r; |
|
- | 1518 | ||
- | 1519 | r= sys_vircopy(user_proc, D, user_addr, |
|
- | 1520 | SELF, D, (vir_bytes)loc_addr, count); |
|
- | 1521 | if (r != OK) |
|
- | 1522 | panic("DP8390", "get_userdata: sys_vircopy failed", r); |
|
- | 1523 | } |
|
- | 1524 | ||
- | 1525 | static void insb(port_t port, void *buf, size_t size) |
|
- | 1526 | { |
|
- | 1527 | int i; |
|
- | 1528 | ||
- | 1529 | for( i = 0; i < size; ++ i ){ |
|
- | 1530 | *(( uint8_t * )( buf + i )) = inb( port ); |
|
- | 1531 | } |
|
- | 1532 | } |
|
- | 1533 | ||
- | 1534 | static void insw(port_t port, void *buf, size_t size) |
|
- | 1535 | { |
|
- | 1536 | int i; |
|
- | 1537 | ||
- | 1538 | for( i = 0; i < size; i += 2 ){ |
|
- | 1539 | *(( uint16_t * )( buf + i )) = inw( port ); |
|
- | 1540 | } |
|
- | 1541 | } |
|
- | 1542 | ||
- | 1543 | static void outsb(port_t port, void *buf, size_t size) |
|
- | 1544 | { |
|
- | 1545 | int i; |
|
- | 1546 | ||
- | 1547 | for( i = 0; i < size; ++ i ){ |
|
- | 1548 | outb( port, *(( uint8_t * )( buf + i ))); |
|
- | 1549 | } |
|
- | 1550 | } |
|
- | 1551 | ||
- | 1552 | static void outsw(port_t port, void *buf, size_t size) |
|
- | 1553 | { |
|
- | 1554 | int i; |
|
- | 1555 | ||
- | 1556 | for( i = 0; i < size; i += 2 ){ |
|
- | 1557 | outw( port, *(( uint16_t * )( buf + i ))); |
|
- | 1558 | } |
|
- | 1559 | } |
|
- | 1560 | ||
930 | /* |
1561 | /* |
931 | * $PchId: dp8390.c,v 1.25 2005/02/10 17:32:07 philip Exp $ |
1562 | * $PchId: dp8390.c,v 1.25 2005/02/10 17:32:07 philip Exp $ |
932 | */ |
1563 | */ |
933 | 1564 | ||
934 | /** @} |
1565 | /** @} |