Changeset aadf01e in mainline for uspace/srv/net/netif
- Timestamp:
- 2010-03-07T15:13:28Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 936835e
- Parents:
- aa85487
- Location:
- uspace/srv/net/netif
- Files:
-
- 15 edited
-
dp8390/dp8390.c (modified) (55 diffs)
-
dp8390/dp8390.h (modified) (2 diffs)
-
dp8390/dp8390_drv.h (modified) (2 diffs)
-
dp8390/dp8390_module.c (modified) (7 diffs)
-
dp8390/dp8390_port.h (modified) (11 diffs)
-
dp8390/local.h (modified) (4 diffs)
-
dp8390/ne2000.c (modified) (10 diffs)
-
lo/lo.c (modified) (6 diffs)
-
netif.c (modified) (4 diffs)
-
netif.h (modified) (8 diffs)
-
netif_messages.h (modified) (1 diff)
-
netif_module.h (modified) (8 diffs)
-
netif_nil_bundle.c (modified) (2 diffs)
-
netif_remote.c (modified) (1 diff)
-
netif_standalone.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/netif/dp8390/dp8390.c
raa85487 raadf01e 67 67 * @returns EINVAL 68 68 */ 69 int queue_packet( dpeth_t * dep, packet_t packet);69 int queue_packet(dpeth_t * dep, packet_t packet); 70 70 71 71 /** Reads a memory block byte by byte. … … 74 74 * @param[in] size The memory block size in bytes. 75 75 */ 76 static void outsb( port_t port, void * buf, size_t size);76 static void outsb(port_t port, void * buf, size_t size); 77 77 78 78 /** Reads a memory block word by word. … … 81 81 * @param[in] size The memory block size in bytes. 82 82 */ 83 static void outsw( port_t port, void * buf, size_t size);83 static void outsw(port_t port, void * buf, size_t size); 84 84 85 85 //static u16_t eth_ign_proto; … … 98 98 //{ 99 99 /* I/O port, IRQ, Buffer address, Env. var. */ 100 /* { 0x280, 3, 0xD0000, "DPETH0" },101 { 0x300, 5, 0xC8000, "DPETH1" },102 { 0x380, 10, 0xD8000, "DPETH2" },100 /* { 0x280, 3, 0xD0000, "DPETH0" }, 101 { 0x300, 5, 0xC8000, "DPETH1" }, 102 { 0x380, 10, 0xD8000, "DPETH2" }, 103 103 }; 104 104 */ … … 126 126 127 127 //#if ENABLE_PCI 128 //_PROTOTYPE( static void pci_conf, (void) );128 //_PROTOTYPE(static void pci_conf, (void) ); 129 129 //#endif 130 //_PROTOTYPE( static void do_vwrite, (message *mp, int from_int,130 //_PROTOTYPE(static void do_vwrite, (message *mp, int from_int, 131 131 // int vectored) ); 132 //_PROTOTYPE( static void do_vwrite_s, (message *mp, int from_int) );133 //_PROTOTYPE( static void do_vread, (message *mp, int vectored) );134 //_PROTOTYPE( static void do_vread_s, (message *mp) );135 //_PROTOTYPE( static void do_init, (message *mp) );136 //_PROTOTYPE( static void do_int, (dpeth_t *dep) );137 //_PROTOTYPE( static void do_getstat, (message *mp) );138 //_PROTOTYPE( static void do_getstat_s, (message *mp) );139 //_PROTOTYPE( static void do_getname, (message *mp) );140 //_PROTOTYPE( static void do_stop, (message *mp) );141 _PROTOTYPE( static void dp_init, (dpeth_t *dep) );142 //_PROTOTYPE( static void dp_confaddr, (dpeth_t *dep) );143 _PROTOTYPE( static void dp_reinit, (dpeth_t *dep) );144 _PROTOTYPE( static void dp_reset, (dpeth_t *dep) );145 //_PROTOTYPE( static void dp_check_ints, (dpeth_t *dep) );146 _PROTOTYPE( static void dp_recv, (dpeth_t *dep) );147 _PROTOTYPE( static void dp_send, (dpeth_t *dep) );148 //_PROTOTYPE( static void dp8390_stop, (void) );149 _PROTOTYPE( static void dp_getblock, (dpeth_t *dep, int page,132 //_PROTOTYPE(static void do_vwrite_s, (message *mp, int from_int) ); 133 //_PROTOTYPE(static void do_vread, (message *mp, int vectored) ); 134 //_PROTOTYPE(static void do_vread_s, (message *mp) ); 135 //_PROTOTYPE(static void do_init, (message *mp) ); 136 //_PROTOTYPE(static void do_int, (dpeth_t *dep) ); 137 //_PROTOTYPE(static void do_getstat, (message *mp) ); 138 //_PROTOTYPE(static void do_getstat_s, (message *mp) ); 139 //_PROTOTYPE(static void do_getname, (message *mp) ); 140 //_PROTOTYPE(static void do_stop, (message *mp) ); 141 _PROTOTYPE(static void dp_init, (dpeth_t *dep) ); 142 //_PROTOTYPE(static void dp_confaddr, (dpeth_t *dep) ); 143 _PROTOTYPE(static void dp_reinit, (dpeth_t *dep) ); 144 _PROTOTYPE(static void dp_reset, (dpeth_t *dep) ); 145 //_PROTOTYPE(static void dp_check_ints, (dpeth_t *dep) ); 146 _PROTOTYPE(static void dp_recv, (dpeth_t *dep) ); 147 _PROTOTYPE(static void dp_send, (dpeth_t *dep) ); 148 //_PROTOTYPE(static void dp8390_stop, (void) ); 149 _PROTOTYPE(static void dp_getblock, (dpeth_t *dep, int page, 150 150 size_t offset, size_t size, void *dst) ); 151 _PROTOTYPE( static void dp_pio8_getblock, (dpeth_t *dep, int page,151 _PROTOTYPE(static void dp_pio8_getblock, (dpeth_t *dep, int page, 152 152 size_t offset, size_t size, void *dst) ); 153 _PROTOTYPE( static void dp_pio16_getblock, (dpeth_t *dep, int page,153 _PROTOTYPE(static void dp_pio16_getblock, (dpeth_t *dep, int page, 154 154 size_t offset, size_t size, void *dst) ); 155 _PROTOTYPE( static int dp_pkt2user, (dpeth_t *dep, int page,156 int length) );157 //_PROTOTYPE( static int dp_pkt2user_s, (dpeth_t *dep, int page,155 _PROTOTYPE(static int dp_pkt2user, (dpeth_t *dep, int page, 156 int length) ); 157 //_PROTOTYPE(static int dp_pkt2user_s, (dpeth_t *dep, int page, 158 158 // int length) ); 159 _PROTOTYPE( static void dp_user2nic, (dpeth_t *dep, iovec_dat_t *iovp,160 vir_bytes offset, int nic_addr, vir_bytes count) );161 //_PROTOTYPE( static void dp_user2nic_s, (dpeth_t *dep, iovec_dat_s_t *iovp,159 _PROTOTYPE(static void dp_user2nic, (dpeth_t *dep, iovec_dat_t *iovp, 160 vir_bytes offset, int nic_addr, vir_bytes count) ); 161 //_PROTOTYPE(static void dp_user2nic_s, (dpeth_t *dep, iovec_dat_s_t *iovp, 162 162 // vir_bytes offset, int nic_addr, vir_bytes count) ); 163 _PROTOTYPE( static void dp_pio8_user2nic, (dpeth_t *dep,163 _PROTOTYPE(static void dp_pio8_user2nic, (dpeth_t *dep, 164 164 iovec_dat_t *iovp, vir_bytes offset, 165 int nic_addr, vir_bytes count) );166 //_PROTOTYPE( static void dp_pio8_user2nic_s, (dpeth_t *dep,165 int nic_addr, vir_bytes count) ); 166 //_PROTOTYPE(static void dp_pio8_user2nic_s, (dpeth_t *dep, 167 167 // iovec_dat_s_t *iovp, vir_bytes offset, 168 168 // int nic_addr, vir_bytes count) ); 169 _PROTOTYPE( static void dp_pio16_user2nic, (dpeth_t *dep,169 _PROTOTYPE(static void dp_pio16_user2nic, (dpeth_t *dep, 170 170 iovec_dat_t *iovp, vir_bytes offset, 171 int nic_addr, vir_bytes count) );172 //_PROTOTYPE( static void dp_pio16_user2nic_s, (dpeth_t *dep,171 int nic_addr, vir_bytes count) ); 172 //_PROTOTYPE(static void dp_pio16_user2nic_s, (dpeth_t *dep, 173 173 // iovec_dat_s_t *iovp, vir_bytes offset, 174 174 // int nic_addr, vir_bytes count) ); 175 _PROTOTYPE( static void dp_nic2user, (dpeth_t *dep, int nic_addr,175 _PROTOTYPE(static void dp_nic2user, (dpeth_t *dep, int nic_addr, 176 176 iovec_dat_t *iovp, vir_bytes offset, vir_bytes count) ); 177 //_PROTOTYPE( static void dp_nic2user_s, (dpeth_t *dep, int nic_addr,177 //_PROTOTYPE(static void dp_nic2user_s, (dpeth_t *dep, int nic_addr, 178 178 // iovec_dat_s_t *iovp, vir_bytes offset, vir_bytes count) ); 179 _PROTOTYPE( static void dp_pio8_nic2user, (dpeth_t *dep, int nic_addr,179 _PROTOTYPE(static void dp_pio8_nic2user, (dpeth_t *dep, int nic_addr, 180 180 iovec_dat_t *iovp, vir_bytes offset, vir_bytes count) ); 181 //_PROTOTYPE( static void dp_pio8_nic2user_s, (dpeth_t *dep, int nic_addr,181 //_PROTOTYPE(static void dp_pio8_nic2user_s, (dpeth_t *dep, int nic_addr, 182 182 // iovec_dat_s_t *iovp, vir_bytes offset, vir_bytes count) ); 183 _PROTOTYPE( static void dp_pio16_nic2user, (dpeth_t *dep, int nic_addr,183 _PROTOTYPE(static void dp_pio16_nic2user, (dpeth_t *dep, int nic_addr, 184 184 iovec_dat_t *iovp, vir_bytes offset, vir_bytes count) ); 185 //_PROTOTYPE( static void dp_pio16_nic2user_s, (dpeth_t *dep, int nic_addr,185 //_PROTOTYPE(static void dp_pio16_nic2user_s, (dpeth_t *dep, int nic_addr, 186 186 // iovec_dat_s_t *iovp, vir_bytes offset, vir_bytes count) ); 187 _PROTOTYPE( static void dp_next_iovec, (iovec_dat_t *iovp) );188 //_PROTOTYPE( static void dp_next_iovec_s, (iovec_dat_s_t *iovp) );189 _PROTOTYPE( static void conf_hw, (dpeth_t *dep) );190 //_PROTOTYPE( static void update_conf, (dpeth_t *dep, dp_conf_t *dcp) );191 _PROTOTYPE( static void map_hw_buffer, (dpeth_t *dep) );192 //_PROTOTYPE( static int calc_iovec_size, (iovec_dat_t *iovp) );193 //_PROTOTYPE( static int calc_iovec_size_s, (iovec_dat_s_t *iovp) );194 _PROTOTYPE( static void reply, (dpeth_t *dep, int err, int may_block) );195 //_PROTOTYPE( static void mess_reply, (message *req, message *reply) );196 _PROTOTYPE( static void get_userdata, (int user_proc,187 _PROTOTYPE(static void dp_next_iovec, (iovec_dat_t *iovp) ); 188 //_PROTOTYPE(static void dp_next_iovec_s, (iovec_dat_s_t *iovp) ); 189 _PROTOTYPE(static void conf_hw, (dpeth_t *dep) ); 190 //_PROTOTYPE(static void update_conf, (dpeth_t *dep, dp_conf_t *dcp) ); 191 _PROTOTYPE(static void map_hw_buffer, (dpeth_t *dep) ); 192 //_PROTOTYPE(static int calc_iovec_size, (iovec_dat_t *iovp) ); 193 //_PROTOTYPE(static int calc_iovec_size_s, (iovec_dat_s_t *iovp) ); 194 _PROTOTYPE(static void reply, (dpeth_t *dep, int err, int may_block) ); 195 //_PROTOTYPE(static void mess_reply, (message *req, message *reply) ); 196 _PROTOTYPE(static void get_userdata, (int user_proc, 197 197 vir_bytes user_addr, vir_bytes count, void *loc_addr) ); 198 //_PROTOTYPE( static void get_userdata_s, (int user_proc,198 //_PROTOTYPE(static void get_userdata_s, (int user_proc, 199 199 // cp_grant_id_t grant, vir_bytes offset, vir_bytes count, 200 200 // void *loc_addr) ); 201 //_PROTOTYPE( static void put_userdata, (int user_proc,201 //_PROTOTYPE(static void put_userdata, (int user_proc, 202 202 // vir_bytes user_addr, vir_bytes count, void *loc_addr) ); 203 //_PROTOTYPE( static void put_userdata_s, (int user_proc,203 //_PROTOTYPE(static void put_userdata_s, (int user_proc, 204 204 // cp_grant_id_t grant, size_t count, void *loc_addr) ); 205 _PROTOTYPE( static void insb, (port_t port, void *buf, size_t size) );206 _PROTOTYPE( static void insw, (port_t port, void *buf, size_t size) );207 //_PROTOTYPE( static void do_vir_insb, (port_t port, int proc,205 _PROTOTYPE(static void insb, (port_t port, void *buf, size_t size) ); 206 _PROTOTYPE(static void insw, (port_t port, void *buf, size_t size) ); 207 //_PROTOTYPE(static void do_vir_insb, (port_t port, int proc, 208 208 // vir_bytes buf, size_t size) ); 209 //_PROTOTYPE( static void do_vir_insw, (port_t port, int proc,209 //_PROTOTYPE(static void do_vir_insw, (port_t port, int proc, 210 210 // vir_bytes buf, size_t size) ); 211 //_PROTOTYPE( static void do_vir_outsb, (port_t port, int proc,211 //_PROTOTYPE(static void do_vir_outsb, (port_t port, int proc, 212 212 // vir_bytes buf, size_t size) ); 213 //_PROTOTYPE( static void do_vir_outsw, (port_t port, int proc,213 //_PROTOTYPE(static void do_vir_outsw, (port_t port, int proc, 214 214 // vir_bytes buf, size_t size) ); 215 215 216 int do_probe( dpeth_t * dep){216 int do_probe(dpeth_t * dep){ 217 217 /* This is the default, try to (re)locate the device. */ 218 218 conf_hw(dep); … … 230 230 * dp8390_dump * 231 231 *===========================================================================*/ 232 void dp8390_dump( dpeth_t * dep)232 void dp8390_dump(dpeth_t * dep) 233 233 { 234 234 // dpeth_t *dep; … … 282 282 * do_init * 283 283 *===========================================================================*/ 284 int do_init( dpeth_t * dep, int mode){284 int do_init(dpeth_t * dep, int mode){ 285 285 if (dep->de_mode == DEM_DISABLED) 286 286 { … … 303 303 } 304 304 assert(dep->de_mode == DEM_ENABLED); 305 assert(dep->de_flags & DEF_ENABLED);305 assert(dep->de_flags &DEF_ENABLED); 306 306 307 307 dep->de_flags &= ~(DEF_PROMISC | DEF_MULTI | DEF_BROAD); 308 308 309 if (mode & DL_PROMISC_REQ)309 if (mode &DL_PROMISC_REQ) 310 310 dep->de_flags |= DEF_PROMISC | DEF_MULTI | DEF_BROAD; 311 if (mode & DL_MULTI_REQ)311 if (mode &DL_MULTI_REQ) 312 312 dep->de_flags |= DEF_MULTI; 313 if (mode & DL_BROAD_REQ)313 if (mode &DL_BROAD_REQ) 314 314 dep->de_flags |= DEF_BROAD; 315 315 … … 329 329 * do_stop * 330 330 *===========================================================================*/ 331 void do_stop( dpeth_t * dep){332 if(( dep->de_mode != DEM_SINK ) && ( dep->de_mode == DEM_ENABLED ) && ( dep->de_flags & DEF_ENABLED)){333 outb_reg0( dep, DP_CR, CR_STP | CR_DM_ABORT);334 ( dep->de_stopf )( dep);331 void do_stop(dpeth_t * dep){ 332 if((dep->de_mode != DEM_SINK) && (dep->de_mode == DEM_ENABLED) && (dep->de_flags &DEF_ENABLED)){ 333 outb_reg0(dep, DP_CR, CR_STP | CR_DM_ABORT); 334 (dep->de_stopf)(dep); 335 335 336 336 dep->de_flags = DEF_EMPTY; … … 338 338 } 339 339 340 int queue_packet( dpeth_t * dep, packet_t packet){341 packet_t tmp;342 343 if( dep->packet_count >= MAX_PACKETS){344 netif_pq_release( packet_get_id( packet));340 int queue_packet(dpeth_t * dep, packet_t packet){ 341 packet_t tmp; 342 343 if(dep->packet_count >= MAX_PACKETS){ 344 netif_pq_release(packet_get_id(packet)); 345 345 return ELIMIT; 346 346 } 347 347 348 348 tmp = dep->packet_queue; 349 while( pq_next( tmp)){350 tmp = pq_next( tmp);351 } 352 if( pq_add( & tmp, packet, 0, 0 ) != EOK){349 while(pq_next(tmp)){ 350 tmp = pq_next(tmp); 351 } 352 if(pq_add(&tmp, packet, 0, 0) != EOK){ 353 353 return EINVAL; 354 354 } 355 if( ! dep->packet_count){355 if(! dep->packet_count){ 356 356 dep->packet_queue = packet; 357 357 } … … 363 363 * based on do_vwrite * 364 364 *===========================================================================*/ 365 int do_pwrite( dpeth_t * dep, packet_t packet, int from_int)365 int do_pwrite(dpeth_t * dep, packet_t packet, int from_int) 366 366 { 367 367 // int port, count, size; … … 386 386 } 387 387 assert(dep->de_mode == DEM_ENABLED); 388 assert(dep->de_flags & DEF_ENABLED);389 if( dep->packet_queue && ( ! from_int)){390 // if (dep->de_flags & DEF_SEND_AVAIL){388 assert(dep->de_flags &DEF_ENABLED); 389 if(dep->packet_queue && (! from_int)){ 390 // if (dep->de_flags &DEF_SEND_AVAIL){ 391 391 // panic("", "dp8390: send already in progress", NO_NUM); 392 return queue_packet( dep, packet);392 return queue_packet(dep, packet); 393 393 } 394 394 … … 402 402 // reply(dep, OK, FALSE); 403 403 // return; 404 // return queue_packet( dep, packet);404 // return queue_packet(dep, packet); 405 405 // } 406 // assert(!(dep->de_flags & DEF_PACK_SEND));406 // assert(!(dep->de_flags &DEF_PACK_SEND)); 407 407 408 408 /* if (vectored) … … 419 419 } 420 420 else 421 { 421 { 422 422 dep->de_write_iovec.iod_iovec[0].iov_addr = 423 423 (vir_bytes) mp->DL_ADDR; … … 430 430 } 431 431 */ 432 size = packet_get_data_length( packet);433 dep->de_write_iovec.iod_iovec[0].iov_addr = ( vir_bytes ) packet_get_data( packet);432 size = packet_get_data_length(packet); 433 dep->de_write_iovec.iod_iovec[0].iov_addr = (vir_bytes) packet_get_data(packet); 434 434 dep->de_write_iovec.iod_iovec[0].iov_size = size; 435 435 dep->de_write_iovec.iod_iovec_s = 1; … … 449 449 outb_reg0(dep, DP_TPSR, dep->de_sendq[sendq_head].sq_sendpage); 450 450 outb_reg0(dep, DP_TBCR1, size >> 8); 451 outb_reg0(dep, DP_TBCR0, size & 0xff);451 outb_reg0(dep, DP_TBCR0, size &0xff); 452 452 outb_reg0(dep, DP_CR, CR_TXP | CR_EXTRA);/* there it goes.. */ 453 453 } … … 470 470 471 471 assert(dep->de_mode == DEM_ENABLED); 472 assert(dep->de_flags & DEF_ENABLED);472 assert(dep->de_flags &DEF_ENABLED); 473 473 return EOK; 474 474 } … … 516 516 /* Step 4: */ 517 517 dp_rcr_reg = 0; 518 if (dep->de_flags & DEF_PROMISC)518 if (dep->de_flags &DEF_PROMISC) 519 519 dp_rcr_reg |= RCR_AB | RCR_PRO | RCR_AM; 520 if (dep->de_flags & DEF_BROAD)520 if (dep->de_flags &DEF_BROAD) 521 521 dp_rcr_reg |= RCR_AB; 522 if (dep->de_flags & DEF_MULTI)522 if (dep->de_flags &DEF_MULTI) 523 523 dp_rcr_reg |= RCR_AM; 524 524 outb_reg0(dep, DP_RCR, dp_rcr_reg); … … 621 621 622 622 dp_rcr_reg = 0; 623 if (dep->de_flags & DEF_PROMISC)623 if (dep->de_flags &DEF_PROMISC) 624 624 dp_rcr_reg |= RCR_AB | RCR_PRO | RCR_AM; 625 if (dep->de_flags & DEF_BROAD)625 if (dep->de_flags &DEF_BROAD) 626 626 dp_rcr_reg |= RCR_AB; 627 if (dep->de_flags & DEF_MULTI)627 if (dep->de_flags &DEF_MULTI) 628 628 dp_rcr_reg |= RCR_AM; 629 629 outb_reg0(dep, DP_RCR, dp_rcr_reg); … … 642 642 outb_reg0(dep, DP_RBCR0, 0); 643 643 outb_reg0(dep, DP_RBCR1, 0); 644 for (i= 0; i < 0x1000 && ((inb_reg0(dep, DP_ISR) & ISR_RST) == 0); i++)644 for (i= 0; i < 0x1000 && ((inb_reg0(dep, DP_ISR) &ISR_RST) == 0); i++) 645 645 ; /* Do nothing */ 646 646 outb_reg0(dep, DP_TCR, TCR_1EXTERNAL|TCR_OFST); … … 649 649 650 650 /* Acknowledge the ISR_RDC (remote dma) interrupt. */ 651 for (i= 0; i < 0x1000 && ((inb_reg0(dep, DP_ISR) & ISR_RDC) == 0); i++)651 for (i= 0; i < 0x1000 && ((inb_reg0(dep, DP_ISR) &ISR_RDC) == 0); i++) 652 652 ; /* Do nothing */ 653 outb_reg0(dep, DP_ISR, inb_reg0(dep, DP_ISR) & ~ISR_RDC);653 outb_reg0(dep, DP_ISR, inb_reg0(dep, DP_ISR) &~ISR_RDC); 654 654 655 655 /* Reset the transmit ring. If we were transmitting a packet, we … … 674 674 int size, sendq_tail; 675 675 676 if (!(dep->de_flags & DEF_ENABLED))676 if (!(dep->de_flags &DEF_ENABLED)) 677 677 panic("", "dp8390: got premature interrupt", NO_NUM); 678 678 … … 683 683 break; 684 684 outb_reg0(dep, DP_ISR, isr); 685 if (isr & (ISR_PTX|ISR_TXE))686 { 687 if (isr & ISR_TXE)685 if (isr &(ISR_PTX|ISR_TXE)) 686 { 687 if (isr &ISR_TXE) 688 688 { 689 689 #if DEBUG 690 { printf("%s: got send Error\n", dep->de_name);}690 {printf("%s: got send Error\n", dep->de_name);} 691 691 #endif 692 692 dep->de_stat.ets_sendErr++; … … 696 696 tsr = inb_reg0(dep, DP_TSR); 697 697 698 if (tsr & TSR_PTX) dep->de_stat.ets_packetT++;698 if (tsr &TSR_PTX) dep->de_stat.ets_packetT++; 699 699 #if 0 /* Reserved in later manuals, should be ignored */ 700 if (!(tsr & TSR_DFR))700 if (!(tsr &TSR_DFR)) 701 701 { 702 702 /* In most (all?) implementations of … … 707 707 } 708 708 #endif 709 if (tsr & TSR_COL) dep->de_stat.ets_collision++;710 if (tsr & TSR_ABT) dep->de_stat.ets_transAb++;711 if (tsr & TSR_CRS) dep->de_stat.ets_carrSense++;712 if (tsr & TSR_FU709 if (tsr &TSR_COL) dep->de_stat.ets_collision++; 710 if (tsr &TSR_ABT) dep->de_stat.ets_transAb++; 711 if (tsr &TSR_CRS) dep->de_stat.ets_carrSense++; 712 if (tsr &TSR_FU 713 713 && ++dep->de_stat.ets_fifoUnder <= 10) 714 714 { … … 716 716 dep->de_name); 717 717 } 718 if (tsr & TSR_CDH718 if (tsr &TSR_CDH 719 719 && ++dep->de_stat.ets_CDheartbeat <= 10) 720 720 { … … 722 722 dep->de_name); 723 723 } 724 if (tsr & TSR_OWC) dep->de_stat.ets_OWC++;724 if (tsr &TSR_OWC) dep->de_stat.ets_OWC++; 725 725 } 726 726 sendq_tail= dep->de_sendq_tail; … … 747 747 dep->de_sendq[sendq_tail].sq_sendpage); 748 748 outb_reg0(dep, DP_TBCR1, size >> 8); 749 outb_reg0(dep, DP_TBCR0, size & 0xff);749 outb_reg0(dep, DP_TBCR0, size &0xff); 750 750 outb_reg0(dep, DP_CR, CR_TXP | CR_EXTRA); 751 751 } 752 // if (dep->de_flags & DEF_SEND_AVAIL)752 // if (dep->de_flags &DEF_SEND_AVAIL) 753 753 dp_send(dep); 754 754 } 755 755 756 if (isr & ISR_PRX)756 if (isr &ISR_PRX) 757 757 { 758 758 /* Only call dp_recv if there is a read request */ 759 // if (dep->de_flags) & DEF_READING)759 // if (dep->de_flags) &DEF_READING) 760 760 dp_recv(dep); 761 761 } 762 762 763 if (isr & ISR_RXE) dep->de_stat.ets_recvErr++;764 if (isr & ISR_CNT)763 if (isr &ISR_RXE) dep->de_stat.ets_recvErr++; 764 if (isr &ISR_CNT) 765 765 { 766 766 dep->de_stat.ets_CRCerr += inb_reg0(dep, DP_CNTR0); … … 768 768 dep->de_stat.ets_missedP += inb_reg0(dep, DP_CNTR2); 769 769 } 770 if (isr & ISR_OVW)770 if (isr &ISR_OVW) 771 771 { 772 772 dep->de_stat.ets_OVW++; 773 773 #if 0 774 { printW(); printf(775 "%s: got overwrite warning\n", dep->de_name); }774 {printW(); printf( 775 "%s: got overwrite warning\n", dep->de_name);} 776 776 #endif 777 /* if (dep->de_flags & DEF_READING)777 /* if (dep->de_flags &DEF_READING) 778 778 { 779 779 printf( … … 782 782 } 783 783 */ } 784 if (isr & ISR_RDC)784 if (isr &ISR_RDC) 785 785 { 786 786 /* Nothing to do */ 787 787 } 788 if (isr & ISR_RST)788 if (isr &ISR_RST) 789 789 { 790 790 /* this means we got an interrupt but the ethernet … … 794 794 */ 795 795 #if 0 796 { printW(); printf(797 "%s: NIC stopped\n", dep->de_name); }796 {printW(); printf( 797 "%s: NIC stopped\n", dep->de_name);} 798 798 #endif 799 799 dep->de_flags |= DEF_STOPPED; … … 802 802 isr = inb_reg0(dep, DP_ISR); 803 803 } 804 // if ((dep->de_flags & (DEF_READING|DEF_STOPPED)) ==804 // if ((dep->de_flags &(DEF_READING|DEF_STOPPED)) == 805 805 // (DEF_READING|DEF_STOPPED)) 806 if ((dep->de_flags & DEF_STOPPED) == DEF_STOPPED)806 if ((dep->de_flags &DEF_STOPPED) == DEF_STOPPED) 807 807 { 808 808 /* The chip is stopped, and all arrived packets are … … 874 874 dep->de_stat.ets_packetR++; 875 875 } 876 */ else if (header.dr_status & RSR_FO)876 */ else if (header.dr_status &RSR_FO) 877 877 { 878 878 /* This is very serious, so we issue a warning and … … 883 883 next = curr; 884 884 } 885 else if ((header.dr_status & RSR_PRX) &&886 (dep->de_flags & DEF_ENABLED))885 else if ((header.dr_status &RSR_PRX) && 886 (dep->de_flags &DEF_ENABLED)) 887 887 { 888 888 // if (dep->de_safecopy_read) … … 914 914 packet_t packet; 915 915 916 // if (!(dep->de_flags & DEF_SEND_AVAIL))916 // if (!(dep->de_flags &DEF_SEND_AVAIL)) 917 917 // return; 918 918 919 if( dep->packet_queue){919 if(dep->packet_queue){ 920 920 packet = dep->packet_queue; 921 dep->packet_queue = pq_detach( packet);922 do_pwrite( dep, packet, TRUE);923 netif_pq_release( packet_get_id( packet));921 dep->packet_queue = pq_detach(packet); 922 do_pwrite(dep, packet, TRUE); 923 netif_pq_release(packet_get_id(packet)); 924 924 -- dep->packet_count; 925 925 } 926 // if( ! dep->packet_queue){926 // if(! dep->packet_queue){ 927 927 // dep->de_flags &= ~DEF_SEND_AVAIL; 928 928 // } … … 967 967 { 968 968 offset = page * DP_PAGESIZE + offset; 969 outb_reg0(dep, DP_RBCR0, size & 0xFF);969 outb_reg0(dep, DP_RBCR0, size &0xFF); 970 970 outb_reg0(dep, DP_RBCR1, size >> 8); 971 outb_reg0(dep, DP_RSAR0, offset & 0xFF);971 outb_reg0(dep, DP_RSAR0, offset &0xFF); 972 972 outb_reg0(dep, DP_RSAR1, offset >> 8); 973 973 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); … … 987 987 { 988 988 offset = page * DP_PAGESIZE + offset; 989 outb_reg0(dep, DP_RBCR0, size & 0xFF);989 outb_reg0(dep, DP_RBCR0, size &0xFF); 990 990 outb_reg0(dep, DP_RBCR1, size >> 8); 991 outb_reg0(dep, DP_RSAR0, offset & 0xFF);991 outb_reg0(dep, DP_RSAR0, offset &0xFF); 992 992 outb_reg0(dep, DP_RSAR1, offset >> 8); 993 993 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); 994 994 995 assert (!(size & 1));995 assert (!(size &1)); 996 996 insw(dep->de_data_port, dst, size); 997 997 } … … 1005 1005 { 1006 1006 int last, count; 1007 packet_t packet;1008 1009 // if (!(dep->de_flags & DEF_READING))1007 packet_t packet; 1008 1009 // if (!(dep->de_flags &DEF_READING)) 1010 1010 // return EGENERIC; 1011 1011 1012 packet = netif_packet_get_1( length ); 1013 if( ! packet ) return ENOMEM; 1014 dep->de_read_iovec.iod_iovec[0].iov_addr = ( vir_bytes ) packet_suffix( packet, length ); 1012 packet = netif_packet_get_1(length); 1013 if(! packet){ 1014 return ENOMEM; 1015 } 1016 dep->de_read_iovec.iod_iovec[0].iov_addr = (vir_bytes) packet_suffix(packet, length); 1015 1017 dep->de_read_iovec.iod_iovec[0].iov_size = length; 1016 1018 dep->de_read_iovec.iod_iovec_s = 1; … … 1028 1030 sizeof(dp_rcvhdr_t), &dep->de_tmp_iovec, 0, count); 1029 1031 (dep->de_nic2userf)(dep, dep->de_startpage * DP_PAGESIZE, 1030 &dep->de_read_iovec, count, length - count);1032 &dep->de_read_iovec, count, length - count); 1031 1033 } 1032 1034 else … … 1040 1042 // dep->de_flags &= ~DEF_READING; 1041 1043 1042 if( dep->received_count >= MAX_PACKETS){1043 netif_pq_release( packet_get_id( packet));1044 if(dep->received_count >= MAX_PACKETS){ 1045 netif_pq_release(packet_get_id(packet)); 1044 1046 return ELIMIT; 1045 1047 }else{ 1046 if( pq_add( & dep->received_queue, packet, 0, 0 ) == EOK){1048 if(pq_add(&dep->received_queue, packet, 0, 0) == EOK){ 1047 1049 ++ dep->received_count; 1048 1050 }else{ 1049 netif_pq_release( packet_get_id( packet));1051 netif_pq_release(packet_get_id(packet)); 1050 1052 } 1051 1053 } … … 1119 1121 outb_reg0(dep, DP_ISR, ISR_RDC); 1120 1122 1121 outb_reg0(dep, DP_RBCR0, count & 0xFF);1123 outb_reg0(dep, DP_RBCR0, count &0xFF); 1122 1124 outb_reg0(dep, DP_RBCR1, count >> 8); 1123 outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF);1125 outb_reg0(dep, DP_RSAR0, nic_addr &0xFF); 1124 1126 outb_reg0(dep, DP_RSAR1, nic_addr >> 8); 1125 1127 outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA); … … 1154 1156 for (i= 0; i<100; i++) 1155 1157 { 1156 if (inb_reg0(dep, DP_ISR) & ISR_RDC)1158 if (inb_reg0(dep, DP_ISR) &ISR_RDC) 1157 1159 break; 1158 1160 } … … 1181 1183 int odd_byte; 1182 1184 1183 ecount= (count+1) & ~1;1185 ecount= (count+1) &~1; 1184 1186 odd_byte= 0; 1185 1187 1186 1188 outb_reg0(dep, DP_ISR, ISR_RDC); 1187 outb_reg0(dep, DP_RBCR0, ecount & 0xFF);1189 outb_reg0(dep, DP_RBCR0, ecount &0xFF); 1188 1190 outb_reg0(dep, DP_RBCR1, ecount >> 8); 1189 outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF);1191 outb_reg0(dep, DP_RSAR0, nic_addr &0xFF); 1190 1192 outb_reg0(dep, DP_RSAR1, nic_addr >> 8); 1191 1193 outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA); … … 1234 1236 continue; 1235 1237 } 1236 ecount= bytes & ~1;1238 ecount= bytes &~1; 1237 1239 if (ecount != 0) 1238 1240 { … … 1271 1273 for (i= 0; i<100; i++) 1272 1274 { 1273 if (inb_reg0(dep, DP_ISR) & ISR_RDC)1275 if (inb_reg0(dep, DP_ISR) &ISR_RDC) 1274 1276 break; 1275 1277 } … … 1343 1345 vir_bytes bytes; 1344 1346 1345 outb_reg0(dep, DP_RBCR0, count & 0xFF);1347 outb_reg0(dep, DP_RBCR0, count &0xFF); 1346 1348 outb_reg0(dep, DP_RBCR1, count >> 8); 1347 outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF);1349 outb_reg0(dep, DP_RSAR0, nic_addr &0xFF); 1348 1350 outb_reg0(dep, DP_RSAR1, nic_addr >> 8); 1349 1351 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); … … 1395 1397 int odd_byte; 1396 1398 1397 ecount= (count+1) & ~1;1399 ecount= (count+1) &~1; 1398 1400 odd_byte= 0; 1399 1401 1400 outb_reg0(dep, DP_RBCR0, ecount & 0xFF);1402 outb_reg0(dep, DP_RBCR0, ecount &0xFF); 1401 1403 outb_reg0(dep, DP_RBCR1, ecount >> 8); 1402 outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF);1404 outb_reg0(dep, DP_RSAR0, nic_addr &0xFF); 1403 1405 outb_reg0(dep, DP_RSAR1, nic_addr >> 8); 1404 1406 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); … … 1445 1447 continue; 1446 1448 } 1447 ecount= bytes & ~1;1449 ecount= bytes &~1; 1448 1450 if (ecount != 0) 1449 1451 { … … 1502 1504 dpeth_t *dep; 1503 1505 { 1504 // static eth_stat_t empty_stat = {0, 0, 0, 0, 0, 0 /* ,... */ };1506 // static eth_stat_t empty_stat = {0, 0, 0, 0, 0, 0 /* ,... */}; 1505 1507 1506 1508 // int ifnr; … … 1551 1553 return; 1552 1554 }else{ 1553 printf( "map_hw_buffer: no buffer!\n");1555 printf("map_hw_buffer: no buffer!\n"); 1554 1556 } 1555 1557 … … 1584 1586 1585 1587 status = 0; 1586 if (dep->de_flags & DEF_PACK_SEND)1588 if (dep->de_flags &DEF_PACK_SEND) 1587 1589 status |= DL_PACK_SEND; 1588 if (dep->de_flags & DEF_PACK_RECV)1590 if (dep->de_flags &DEF_PACK_RECV) 1589 1591 status |= DL_PACK_RECV; 1590 1592 … … 1633 1635 size_t i; 1634 1636 1635 for( i = 0; i < size; ++ i){1636 *(( uint8_t * ) buf + i ) = inb( port);1637 for(i = 0; i < size; ++ i){ 1638 *((uint8_t *) buf + i) = inb(port); 1637 1639 } 1638 1640 } … … 1642 1644 size_t i; 1643 1645 1644 for( i = 0; i * 2 < size; ++ i){1645 *(( uint16_t * ) buf + i ) = inw( port);1646 for(i = 0; i * 2 < size; ++ i){ 1647 *((uint16_t *) buf + i) = inw(port); 1646 1648 } 1647 1649 } … … 1651 1653 size_t i; 1652 1654 1653 for( i = 0; i < size; ++ i){1654 outb( port, *(( uint8_t * ) buf + i));1655 for(i = 0; i < size; ++ i){ 1656 outb(port, *((uint8_t *) buf + i)); 1655 1657 } 1656 1658 } … … 1660 1662 size_t i; 1661 1663 1662 for( i = 0; i * 2 < size; ++ i){1663 outw( port, *(( uint16_t * ) buf + i));1664 for(i = 0; i * 2 < size; ++ i){ 1665 outw(port, *((uint16_t *) buf + i)); 1664 1666 } 1665 1667 } -
uspace/srv/net/netif/dp8390/dp8390.h
raa85487 raadf01e 255 255 struct iovec_dat; 256 256 //struct iovec_dat_s; 257 _PROTOTYPE( typedef void (*dp_initf_t), (struct dpeth *dep) );258 _PROTOTYPE( typedef void (*dp_stopf_t), (struct dpeth *dep) );259 _PROTOTYPE( typedef void (*dp_user2nicf_t), (struct dpeth *dep,257 _PROTOTYPE(typedef void (*dp_initf_t), (struct dpeth *dep) ); 258 _PROTOTYPE(typedef void (*dp_stopf_t), (struct dpeth *dep) ); 259 _PROTOTYPE(typedef void (*dp_user2nicf_t), (struct dpeth *dep, 260 260 struct iovec_dat *iovp, vir_bytes offset, 261 int nic_addr, vir_bytes count) );262 //_PROTOTYPE( typedef void (*dp_user2nicf_s_t), (struct dpeth *dep,261 int nic_addr, vir_bytes count) ); 262 //_PROTOTYPE(typedef void (*dp_user2nicf_s_t), (struct dpeth *dep, 263 263 // struct iovec_dat_s *iovp, vir_bytes offset, 264 264 // int nic_addr, vir_bytes count) ); 265 _PROTOTYPE( typedef void (*dp_nic2userf_t), (struct dpeth *dep,265 _PROTOTYPE(typedef void (*dp_nic2userf_t), (struct dpeth *dep, 266 266 int nic_addr, struct iovec_dat *iovp, 267 vir_bytes offset, vir_bytes count) );268 //_PROTOTYPE( typedef void (*dp_nic2userf_s_t), (struct dpeth *dep,267 vir_bytes offset, vir_bytes count) ); 268 //_PROTOTYPE(typedef void (*dp_nic2userf_s_t), (struct dpeth *dep, 269 269 // int nic_addr, struct iovec_dat_s *iovp, 270 270 // vir_bytes offset, vir_bytes count) ); 271 271 //#if 0 272 //_PROTOTYPE( typedef void (*dp_getheaderf_t), (struct dpeth *dep,272 //_PROTOTYPE(typedef void (*dp_getheaderf_t), (struct dpeth *dep, 273 273 // int page, struct dp_rcvhdr *h, u16_t *eth_type) ); 274 274 //#endif 275 _PROTOTYPE( typedef void (*dp_getblock_t), (struct dpeth *dep,275 _PROTOTYPE(typedef void (*dp_getblock_t), (struct dpeth *dep, 276 276 int page, size_t offset, size_t size, void *dst) ); 277 277 … … 313 313 /** Outgoing packets queue. 314 314 */ 315 packet_t packet_queue;315 packet_t packet_queue; 316 316 /** Outgoing packets count. 317 317 */ 318 int packet_count;318 int packet_count; 319 319 320 320 /** Received packets queue. 321 321 */ 322 packet_t received_queue;322 packet_t received_queue; 323 323 /** Received packets count. 324 324 */ 325 int received_count;325 int received_count; 326 326 327 327 /* The de_base_port field is the starting point of the probe. -
uspace/srv/net/netif/dp8390/dp8390_drv.h
raa85487 raadf01e 64 64 * @returns EXDEV if the network interface was not recognized. 65 65 */ 66 int do_probe( dpeth_t * dep);66 int do_probe(dpeth_t * dep); 67 67 68 68 /** Sends a packet. … … 72 72 * @returns 73 73 */ 74 int do_pwrite( dpeth_t * dep, packet_t packet, int from_int);74 int do_pwrite(dpeth_t * dep, packet_t packet, int from_int); 75 75 76 76 /** Prints out network interface information. 77 77 * @param[in] dep The network interface structure. 78 78 */ 79 void dp8390_dump( dpeth_t * dep);79 void dp8390_dump(dpeth_t * dep); 80 80 81 81 #endif -
uspace/srv/net/netif/dp8390/dp8390_module.c
raa85487 raadf01e 68 68 * @param[in] call The interrupt call. 69 69 */ 70 #define IRQ_GET_DEVICE( call ) ( device_id_t ) IPC_GET_METHOD( * call)70 #define IRQ_GET_DEVICE(call) (device_id_t) IPC_GET_METHOD(*call) 71 71 72 72 /** Returns the interrupt status register from the interrupt call. 73 73 * @param[in] call The interrupt call. 74 74 */ 75 #define IPC_GET_ISR( call ) ( int ) IPC_GET_ARG2( * call)75 #define IPC_GET_ISR(call) (int) IPC_GET_ARG2(*call) 76 76 77 77 /** DP8390 kernel interrupt command sequence. 78 78 */ 79 79 static irq_cmd_t dp8390_cmds[] = { 80 { .cmd = CMD_PIO_READ_8,80 { .cmd = CMD_PIO_READ_8, 81 81 .addr = NULL, 82 82 .dstarg = 2 … … 95 95 */ 96 96 static irq_code_t dp8390_code = { 97 sizeof( dp8390_cmds ) / sizeof( irq_cmd_t),97 sizeof(dp8390_cmds) / sizeof(irq_cmd_t), 98 98 dp8390_cmds 99 99 }; … … 106 106 * @see NAME 107 107 */ 108 void module_print_name( void);108 void module_print_name(void); 109 109 110 110 /** Handles the interrupt messages. … … 113 113 * @param[in] call The interrupt message. 114 114 */ 115 void irq_handler( ipc_callid_t iid, ipc_call_t * call);115 void irq_handler(ipc_callid_t iid, ipc_call_t * call); 116 116 117 117 /** Changes the network interface state. … … 120 120 * @returns The new state. 121 121 */ 122 int change_state( device_ref device, device_state_t state);123 124 int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){122 int change_state(device_ref device, device_state_t state); 123 124 int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 125 125 return ENOTSUP; 126 126 } 127 127 128 int netif_get_device_stats( device_id_t device_id, device_stats_ref stats ){ 129 ERROR_DECLARE; 130 131 device_ref device; 132 eth_stat_t * de_stat; 133 134 if( ! stats ) return EBADMEM; 135 ERROR_PROPAGATE( find_device( device_id, & device )); 136 de_stat = & (( dpeth_t * ) device->specific )->de_stat; 137 null_device_stats( stats ); 128 int netif_get_device_stats(device_id_t device_id, device_stats_ref stats){ 129 ERROR_DECLARE; 130 131 device_ref device; 132 eth_stat_t * de_stat; 133 134 if(! stats){ 135 return EBADMEM; 136 } 137 ERROR_PROPAGATE(find_device(device_id, &device)); 138 de_stat = &((dpeth_t *) device->specific)->de_stat; 139 null_device_stats(stats); 138 140 stats->receive_errors = de_stat->ets_recvErr; 139 141 stats->send_errors = de_stat->ets_sendErr; … … 151 153 } 152 154 153 void module_print_name( void ){ 154 printf( "%s", NAME ); 155 } 156 157 int netif_get_addr_message( device_id_t device_id, measured_string_ref address ){ 158 ERROR_DECLARE; 159 160 device_ref device; 161 162 if( ! address ) return EBADMEM; 163 ERROR_PROPAGATE( find_device( device_id, & device )); 164 address->value = ( char * ) ( & (( dpeth_t * ) device->specific )->de_address ); 165 address->length = CONVERT_SIZE( ether_addr_t, char, 1 ); 166 return EOK; 167 } 168 169 void irq_handler( ipc_callid_t iid, ipc_call_t * call ) 155 void module_print_name(void){ 156 printf("%s", NAME); 157 } 158 159 int netif_get_addr_message(device_id_t device_id, measured_string_ref address){ 160 ERROR_DECLARE; 161 162 device_ref device; 163 164 if(! address){ 165 return EBADMEM; 166 } 167 ERROR_PROPAGATE(find_device(device_id, &device)); 168 address->value = (char *) (&((dpeth_t *) device->specific)->de_address); 169 address->length = CONVERT_SIZE(ether_addr_t, char, 1); 170 return EOK; 171 } 172 173 void irq_handler(ipc_callid_t iid, ipc_call_t * call) 170 174 { 171 device_ref device;172 dpeth_t * dep;173 packet_t received;174 device_id_t device_id;175 int phone;176 177 device_id = IRQ_GET_DEVICE( call);178 fibril_rwlock_write_lock( & netif_globals.lock);179 if( find_device( device_id, & device ) != EOK){180 fibril_rwlock_write_unlock( & netif_globals.lock);175 device_ref device; 176 dpeth_t * dep; 177 packet_t received; 178 device_id_t device_id; 179 int phone; 180 181 device_id = IRQ_GET_DEVICE(call); 182 fibril_rwlock_write_lock(&netif_globals.lock); 183 if(find_device(device_id, &device) != EOK){ 184 fibril_rwlock_write_unlock(&netif_globals.lock); 181 185 return; 182 186 } 183 dep = ( dpeth_t *) device->specific;184 if ( dep->de_mode != DEM_ENABLED){185 fibril_rwlock_write_unlock( & netif_globals.lock);187 dep = (dpeth_t *) device->specific; 188 if (dep->de_mode != DEM_ENABLED){ 189 fibril_rwlock_write_unlock(&netif_globals.lock); 186 190 return; 187 191 } 188 assert( dep->de_flags &DEF_ENABLED);192 assert(dep->de_flags &DEF_ENABLED); 189 193 dep->de_int_pending = 0; 190 194 // remove debug print: 191 printf( "I%d: 0x%x\n", device_id, IPC_GET_ISR( call));192 dp_check_ints( dep, IPC_GET_ISR( call));193 if( dep->received_queue){195 printf("I%d: 0x%x\n", device_id, IPC_GET_ISR(call)); 196 dp_check_ints(dep, IPC_GET_ISR(call)); 197 if(dep->received_queue){ 194 198 received = dep->received_queue; 195 199 phone = device->nil_phone; 196 200 dep->received_queue = NULL; 197 201 dep->received_count = 0; 198 fibril_rwlock_write_unlock( & netif_globals.lock);202 fibril_rwlock_write_unlock(&netif_globals.lock); 199 203 // remove debug dump: 200 uint8_t * data;201 data = packet_get_data( received);202 printf( "Receiving packet:\n\tid\t= %d\n\tlength\t= %d\n\tdata\t= %.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX\n\t\t%.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX\n", packet_get_id( received ), packet_get_data_length( received ), data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ], data[ 8 ], data[ 9 ], data[ 10 ], data[ 11 ], data[ 12 ], data[ 13 ], data[ 14 ], data[ 15 ], data[ 16 ], data[ 17 ], data[ 18 ], data[ 19 ], data[ 20 ], data[ 21 ], data[ 22 ], data[ 23 ], data[ 24 ], data[ 25 ], data[ 26 ], data[ 27 ], data[ 28 ], data[ 29 ], data[ 30 ], data[ 31 ], data[ 32 ], data[ 33 ], data[ 34 ], data[ 35 ], data[ 36 ], data[ 37 ], data[ 38 ], data[ 39 ], data[ 40 ], data[ 41 ], data[ 42 ], data[ 43 ], data[ 44 ], data[ 45 ], data[ 46 ], data[ 47 ], data[ 48 ], data[ 49 ], data[ 50 ], data[ 51 ], data[ 52 ], data[ 53 ], data[ 54 ], data[ 55 ], data[ 56 ], data[ 57 ], data[ 58 ], data[ 59 ]);203 nil_received_msg( phone, device_id, received, NULL);204 uint8_t * data; 205 data = packet_get_data(received); 206 printf("Receiving packet:\n\tid\t= %d\n\tlength\t= %d\n\tdata\t= %.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX\n\t\t%.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX\n", packet_get_id(received), packet_get_data_length(received), data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15], data[16], data[17], data[18], data[19], data[20], data[21], data[22], data[23], data[24], data[25], data[26], data[27], data[28], data[29], data[30], data[31], data[32], data[33], data[34], data[35], data[36], data[37], data[38], data[39], data[40], data[41], data[42], data[43], data[44], data[45], data[46], data[47], data[48], data[49], data[50], data[51], data[52], data[53], data[54], data[55], data[56], data[57], data[58], data[59]); 207 nil_received_msg(phone, device_id, received, NULL); 204 208 }else{ 205 fibril_rwlock_write_unlock( & netif_globals.lock ); 206 } 207 ipc_answer_0( iid, EOK ); 208 } 209 210 int netif_probe_message( device_id_t device_id, int irq, uintptr_t io ){ 211 ERROR_DECLARE; 212 213 device_ref device; 214 dpeth_t * dep; 215 216 device = ( device_ref ) malloc( sizeof( device_t )); 217 if( ! device ) return ENOMEM; 218 dep = ( dpeth_t * ) malloc( sizeof( dpeth_t )); 219 if( ! dep ){ 220 free( device ); 209 fibril_rwlock_write_unlock(&netif_globals.lock); 210 } 211 ipc_answer_0(iid, EOK); 212 } 213 214 int netif_probe_message(device_id_t device_id, int irq, uintptr_t io){ 215 ERROR_DECLARE; 216 217 device_ref device; 218 dpeth_t * dep; 219 220 device = (device_ref) malloc(sizeof(device_t)); 221 if(! device){ 221 222 return ENOMEM; 222 223 } 223 bzero( device, sizeof( device_t )); 224 bzero( dep, sizeof( dpeth_t )); 224 dep = (dpeth_t *) malloc(sizeof(dpeth_t)); 225 if(! dep){ 226 free(device); 227 return ENOMEM; 228 } 229 bzero(device, sizeof(device_t)); 230 bzero(dep, sizeof(dpeth_t)); 225 231 device->device_id = device_id; 226 232 device->nil_phone = -1; 227 device->specific = ( void *) dep;233 device->specific = (void *) dep; 228 234 device->state = NETIF_STOPPED; 229 235 dep->de_irq = irq; 230 236 dep->de_mode = DEM_DISABLED; 231 237 //TODO address? 232 if( ERROR_OCCURRED( pio_enable(( void * ) io, DP8390_IO_SIZE, ( void ** ) & dep->de_base_port))233 || ERROR_OCCURRED( do_probe( dep))){234 free( dep);235 free( device);238 if(ERROR_OCCURRED(pio_enable((void *) io, DP8390_IO_SIZE, (void **) &dep->de_base_port)) 239 || ERROR_OCCURRED(do_probe(dep))){ 240 free(dep); 241 free(device); 236 242 return ERROR_CODE; 237 243 } 238 if( ERROR_OCCURRED( device_map_add( & netif_globals.device_map, device->device_id, device))){239 free( dep);240 free( device);244 if(ERROR_OCCURRED(device_map_add(&netif_globals.device_map, device->device_id, device))){ 245 free(dep); 246 free(device); 241 247 return ERROR_CODE; 242 248 } … … 244 250 } 245 251 246 int netif_send_message( device_id_t device_id, packet_t packet, services_t sender){247 ERROR_DECLARE; 248 249 device_ref device;250 dpeth_t * dep;251 packet_t next;252 253 ERROR_PROPAGATE( find_device( device_id, & device));254 if( device->state != NETIF_ACTIVE){255 netif_pq_release( packet_get_id( packet));252 int netif_send_message(device_id_t device_id, packet_t packet, services_t sender){ 253 ERROR_DECLARE; 254 255 device_ref device; 256 dpeth_t * dep; 257 packet_t next; 258 259 ERROR_PROPAGATE(find_device(device_id, &device)); 260 if(device->state != NETIF_ACTIVE){ 261 netif_pq_release(packet_get_id(packet)); 256 262 return EFORWARD; 257 263 } 258 dep = ( dpeth_t *) device->specific;264 dep = (dpeth_t *) device->specific; 259 265 // process packet queue 260 266 do{ 261 next = pq_detach( packet);267 next = pq_detach(packet); 262 268 // remove debug dump: 263 uint8_t * data;264 data = packet_get_data( packet);265 printf( "Sending packet:\n\tid\t= %d\n\tlength\t= %d\n\tdata\t= %.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX\n\t\t%.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX\n", packet_get_id( packet ), packet_get_data_length( packet ), data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ], data[ 8 ], data[ 9 ], data[ 10 ], data[ 11 ], data[ 12 ], data[ 13 ], data[ 14 ], data[ 15 ], data[ 16 ], data[ 17 ], data[ 18 ], data[ 19 ], data[ 20 ], data[ 21 ], data[ 22 ], data[ 23 ], data[ 24 ], data[ 25 ], data[ 26 ], data[ 27 ], data[ 28 ], data[ 29 ], data[ 30 ], data[ 31 ], data[ 32 ], data[ 33 ], data[ 34 ], data[ 35 ], data[ 36 ], data[ 37 ], data[ 38 ], data[ 39 ], data[ 40 ], data[ 41 ], data[ 42 ], data[ 43 ], data[ 44 ], data[ 45 ], data[ 46 ], data[ 47 ], data[ 48 ], data[ 49 ], data[ 50 ], data[ 51 ], data[ 52 ], data[ 53 ], data[ 54 ], data[ 55 ], data[ 56 ], data[ 57 ], data[ 58 ], data[ 59 ]);266 267 if( do_pwrite( dep, packet, FALSE ) != EBUSY){268 netif_pq_release( packet_get_id( packet));269 uint8_t * data; 270 data = packet_get_data(packet); 271 printf("Sending packet:\n\tid\t= %d\n\tlength\t= %d\n\tdata\t= %.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX\n\t\t%.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX\n", packet_get_id(packet), packet_get_data_length(packet), data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15], data[16], data[17], data[18], data[19], data[20], data[21], data[22], data[23], data[24], data[25], data[26], data[27], data[28], data[29], data[30], data[31], data[32], data[33], data[34], data[35], data[36], data[37], data[38], data[39], data[40], data[41], data[42], data[43], data[44], data[45], data[46], data[47], data[48], data[49], data[50], data[51], data[52], data[53], data[54], data[55], data[56], data[57], data[58], data[59]); 272 273 if(do_pwrite(dep, packet, FALSE) != EBUSY){ 274 netif_pq_release(packet_get_id(packet)); 269 275 } 270 276 packet = next; 271 }while( packet);272 return EOK; 273 } 274 275 int netif_start_message( device_ref device){276 ERROR_DECLARE; 277 278 dpeth_t * dep;279 280 if( device->state != NETIF_ACTIVE){281 dep = ( dpeth_t *) device->specific;282 dp8390_cmds[ 0 ].addr = ( void * ) ( uintptr_t ) ( dep->de_dp8390_port + DP_ISR);283 dp8390_cmds[ 2 ].addr = dp8390_cmds[ 0].addr;284 ERROR_PROPAGATE( ipc_register_irq( dep->de_irq, device->device_id, device->device_id, & dp8390_code));285 if( ERROR_OCCURRED( do_init( dep, DL_BROAD_REQ))){286 ipc_unregister_irq( dep->de_irq, device->device_id);277 }while(packet); 278 return EOK; 279 } 280 281 int netif_start_message(device_ref device){ 282 ERROR_DECLARE; 283 284 dpeth_t * dep; 285 286 if(device->state != NETIF_ACTIVE){ 287 dep = (dpeth_t *) device->specific; 288 dp8390_cmds[0].addr = (void *) (uintptr_t) (dep->de_dp8390_port + DP_ISR); 289 dp8390_cmds[2].addr = dp8390_cmds[0].addr; 290 ERROR_PROPAGATE(ipc_register_irq(dep->de_irq, device->device_id, device->device_id, &dp8390_code)); 291 if(ERROR_OCCURRED(do_init(dep, DL_BROAD_REQ))){ 292 ipc_unregister_irq(dep->de_irq, device->device_id); 287 293 return ERROR_CODE; 288 294 } 289 return change_state( device, NETIF_ACTIVE);290 } 291 return EOK; 292 } 293 294 int netif_stop_message( device_ref device){295 dpeth_t * dep;296 297 if( device->state != NETIF_STOPPED){298 dep = ( dpeth_t *) device->specific;299 do_stop( dep);300 ipc_unregister_irq( dep->de_irq, device->device_id);301 return change_state( device, NETIF_STOPPED);302 } 303 return EOK; 304 } 305 306 int change_state( device_ref device, device_state_t state){295 return change_state(device, NETIF_ACTIVE); 296 } 297 return EOK; 298 } 299 300 int netif_stop_message(device_ref device){ 301 dpeth_t * dep; 302 303 if(device->state != NETIF_STOPPED){ 304 dep = (dpeth_t *) device->specific; 305 do_stop(dep); 306 ipc_unregister_irq(dep->de_irq, device->device_id); 307 return change_state(device, NETIF_STOPPED); 308 } 309 return EOK; 310 } 311 312 int change_state(device_ref device, device_state_t state){ 307 313 device->state = state; 308 printf( "State changed to %s\n", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED");314 printf("State changed to %s\n", (state == NETIF_ACTIVE) ? "ACTIVE" : "STOPPED"); 309 315 return state; 310 316 } 311 317 312 int netif_initialize( void){313 ipcarg_t phonehash;314 315 async_set_interrupt_received( irq_handler);316 317 return REGISTER_ME( SERVICE_DP8390, & phonehash);318 int netif_initialize(void){ 319 ipcarg_t phonehash; 320 321 async_set_interrupt_received(irq_handler); 322 323 return REGISTER_ME(SERVICE_DP8390, &phonehash); 318 324 } 319 325 -
uspace/srv/net/netif/dp8390/dp8390_port.h
raa85487 raadf01e 48 48 * @param[in] params The function parameters definition. 49 49 */ 50 #define _PROTOTYPE( function, params) function params50 #define _PROTOTYPE(function, params) function params 51 51 52 52 /** Success error code. … … 70 70 * @returns 1 if the second is greater than the first. 71 71 */ 72 #define memcmp( first, second, size ) bcmp(( char * ) ( first ), ( char * ) ( second ), ( size))72 #define memcmp(first, second, size) bcmp((char *) (first), (char *) (second), (size)) 73 73 74 74 /** Reads 1 byte. … … 76 76 * @returns The read value. 77 77 */ 78 #define inb( port ) pio_read_8(( ioport8_t * ) ( port))78 #define inb(port) pio_read_8((ioport8_t *) (port)) 79 79 80 80 /** Reads 1 word (2 bytes). … … 82 82 * @returns The read value. 83 83 */ 84 #define inw( port ) pio_read_16(( ioport16_t * ) ( port))84 #define inw(port) pio_read_16((ioport16_t *) (port)) 85 85 86 86 /** Writes 1 byte. … … 88 88 * @param[in] value The value to be written. 89 89 */ 90 #define outb( port, value ) pio_write_8(( ioport8_t * ) ( port ), ( value))90 #define outb(port, value) pio_write_8((ioport8_t *) (port), (value)) 91 91 92 92 /** Writes 1 word (2 bytes). … … 94 94 * @param[in] value The value to be written. 95 95 */ 96 #define outw( port, value ) pio_write_16(( ioport16_t * ) ( port ), ( value))96 #define outw(port, value) pio_write_16((ioport16_t *) (port), (value)) 97 97 98 98 /** Prints out the driver critical error. 99 99 * Does not call the system panic(). 100 100 */ 101 #define panic( ... ) printf( "%s%s%d", __VA_ARGS__)101 #define panic(...) printf("%s%s%d", __VA_ARGS__) 102 102 103 103 /** Copies a memory block. … … 111 111 * @returns EOK. 112 112 */ 113 #define sys_vircopy( proc, src_s, src, me, dst_s, dst, bytes ) ({ memcpy(( void * )( dst ), ( void * )( src ), ( bytes )); EOK;})113 #define sys_vircopy(proc, src_s, src, me, dst_s, dst, bytes) ({memcpy((void *)(dst), (void *)(src), (bytes)); EOK;}) 114 114 115 115 /** Reads a memory block byte by byte. … … 119 119 * @param[in] bytes The block size in bytes. 120 120 */ 121 #define do_vir_insb( port, proc, dst, bytes ) insb(( port ), ( void * )( dst ), ( bytes))121 #define do_vir_insb(port, proc, dst, bytes) insb((port), (void *)(dst), (bytes)) 122 122 123 123 /** Reads a memory block word by word (2 bytes). … … 127 127 * @param[in] bytes The block size in bytes. 128 128 */ 129 #define do_vir_insw( port, proc, dst, bytes ) insw(( port ), ( void * )( dst ), ( bytes))129 #define do_vir_insw(port, proc, dst, bytes) insw((port), (void *)(dst), (bytes)) 130 130 131 131 /** Writes a memory block byte by byte. … … 135 135 * @param[in] bytes The block size in bytes. 136 136 */ 137 #define do_vir_outsb( port, proc, src, bytes ) outsb(( port ), ( void * )( src ), ( bytes))137 #define do_vir_outsb(port, proc, src, bytes) outsb((port), (void *)(src), (bytes)) 138 138 139 139 /** Writes a memory block word by word (2 bytes). … … 143 143 * @param[in] bytes The block size in bytes. 144 144 */ 145 #define do_vir_outsw( port, proc, src, bytes ) outsw(( port ), ( void * )( src ), ( bytes))145 #define do_vir_outsw(port, proc, src, bytes) outsw((port), (void *)(src), (bytes)) 146 146 147 147 /* com.h */ -
uspace/srv/net/netif/dp8390/local.h
raa85487 raadf01e 66 66 * @returns 0 otherwise. 67 67 */ 68 //_PROTOTYPE( int el2_probe, (struct dpeth*dep) );68 //_PROTOTYPE(int el2_probe, (struct dpeth*dep) ); 69 69 70 70 /* ne2000.c */ … … 74 74 * @returns 0 otherwise. 75 75 */ 76 int ne_probe( struct dpeth * dep);77 //_PROTOTYPE( int ne_probe, (struct dpeth *dep) );78 //_PROTOTYPE( void ne_init, (struct dpeth *dep) );76 int ne_probe(struct dpeth * dep); 77 //_PROTOTYPE(int ne_probe, (struct dpeth *dep) ); 78 //_PROTOTYPE(void ne_init, (struct dpeth *dep) ); 79 79 80 80 /* rtl8029.c */ … … 84 84 * @returns 0 otherwise. 85 85 */ 86 //_PROTOTYPE( int rtl_probe, (struct dpeth *dep) );86 //_PROTOTYPE(int rtl_probe, (struct dpeth *dep) ); 87 87 88 88 /* wdeth.c */ … … 92 92 * @returns 0 otherwise. 93 93 */ 94 //_PROTOTYPE( int wdeth_probe, (struct dpeth*dep) );94 //_PROTOTYPE(int wdeth_probe, (struct dpeth*dep) ); 95 95 96 96 #endif -
uspace/srv/net/netif/dp8390/ne2000.c
raa85487 raadf01e 70 70 * @param[in] millis The number of milliseconds to sleep. 71 71 */ 72 #define milli_delay( millis ) usleep(( millis ) * 1000)72 #define milli_delay(millis) usleep((millis) * 1000) 73 73 74 74 /** Type definition of the testing function. 75 75 */ 76 _PROTOTYPE( typedef int (*testf_t), (dpeth_t *dep, int pos, u8_t *pat) );76 _PROTOTYPE(typedef int (*testf_t), (dpeth_t *dep, int pos, u8_t *pat) ); 77 77 78 78 /** First data pattern. 79 79 */ 80 u8_t pat0[]= { 0x00, 0x00, 0x00, 0x00};80 u8_t pat0[]= {0x00, 0x00, 0x00, 0x00}; 81 81 82 82 /** Second data pattern. 83 83 */ 84 u8_t pat1[]= { 0xFF, 0xFF, 0xFF, 0xFF};84 u8_t pat1[]= {0xFF, 0xFF, 0xFF, 0xFF}; 85 85 86 86 /** Third data pattern. 87 87 */ 88 u8_t pat2[]= { 0xA5, 0x5A, 0x69, 0x96};88 u8_t pat2[]= {0xA5, 0x5A, 0x69, 0x96}; 89 89 90 90 /** Fourth data pattern. 91 91 */ 92 u8_t pat3[]= { 0x96, 0x69, 0x5A, 0xA5};92 u8_t pat3[]= {0x96, 0x69, 0x5A, 0xA5}; 93 93 94 94 /** Tests 8 bit NE2000 network interface. … … 114 114 */ 115 115 static void ne_stop(dpeth_t *dep); 116 //_PROTOTYPE( static void milli_delay, (unsigned long millis) );116 //_PROTOTYPE(static void milli_delay, (unsigned long millis) ); 117 117 118 118 /** Initializes the NE2000 network interface. … … 150 150 /* Reset the dp8390 */ 151 151 outb_reg0(dep, DP_CR, CR_STP | CR_DM_ABORT); 152 for (i= 0; i < 0x1000 && ((inb_reg0(dep, DP_ISR) & ISR_RST) == 0); i++)152 for (i= 0; i < 0x1000 && ((inb_reg0(dep, DP_ISR) &ISR_RST) == 0); i++) 153 153 ; /* Do nothing */ 154 154 155 155 /* Check if the dp8390 is really there */ 156 if ((inb_reg0(dep, DP_CR) & (CR_STP|CR_DM_ABORT)) !=156 if ((inb_reg0(dep, DP_CR) &(CR_STP|CR_DM_ABORT)) != 157 157 (CR_STP|CR_DM_ABORT)) 158 158 { … … 186 186 f= test_8; 187 187 } 188 if (f(dep, loc1, pat0) && f(dep, loc1, pat1) && 189 f(dep, loc1, pat2) && f(dep, loc1, pat3) && 190 f(dep, loc2, pat0) && f(dep, loc2, pat1) && 188 if (f(dep, loc1, pat0) && f(dep, loc1, pat1) && 189 f(dep, loc1, pat2) && f(dep, loc1, pat3) && 190 f(dep, loc2, pat0) && f(dep, loc2, pat1) && 191 191 f(dep, loc2, pat2) && f(dep, loc2, pat3)) 192 192 { … … 297 297 outb_reg0(dep, DP_RBCR0, 4); 298 298 outb_reg0(dep, DP_RBCR1, 0); 299 outb_reg0(dep, DP_RSAR0, pos & 0xFF);299 outb_reg0(dep, DP_RSAR0, pos &0xFF); 300 300 outb_reg0(dep, DP_RSAR1, pos >> 8); 301 301 outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA); … … 306 306 for (i= 0; i<N; i++) 307 307 { 308 if (inb_reg0(dep, DP_ISR) & ISR_RDC)308 if (inb_reg0(dep, DP_ISR) &ISR_RDC) 309 309 break; 310 310 } … … 321 321 outb_reg0(dep, DP_RBCR0, 4); 322 322 outb_reg0(dep, DP_RBCR1, 0); 323 outb_reg0(dep, DP_RSAR0, pos & 0xFF);323 outb_reg0(dep, DP_RSAR0, pos &0xFF); 324 324 outb_reg0(dep, DP_RSAR1, pos >> 8); 325 325 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); … … 349 349 outb_reg0(dep, DP_RBCR0, 4); 350 350 outb_reg0(dep, DP_RBCR1, 0); 351 outb_reg0(dep, DP_RSAR0, pos & 0xFF);351 outb_reg0(dep, DP_RSAR0, pos &0xFF); 352 352 outb_reg0(dep, DP_RSAR1, pos >> 8); 353 353 outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA); … … 360 360 for (i= 0; i<N; i++) 361 361 { 362 if (inb_reg0(dep, DP_ISR) & ISR_RDC)362 if (inb_reg0(dep, DP_ISR) &ISR_RDC) 363 363 break; 364 364 } … … 375 375 outb_reg0(dep, DP_RBCR0, 4); 376 376 outb_reg0(dep, DP_RBCR1, 0); 377 outb_reg0(dep, DP_RSAR0, pos & 0xFF);377 outb_reg0(dep, DP_RSAR0, pos &0xFF); 378 378 outb_reg0(dep, DP_RSAR1, pos >> 8); 379 379 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); -
uspace/srv/net/netif/lo/lo.c
raa85487 raadf01e 64 64 /** Default address length. 65 65 */ 66 #define DEFAULT_ADDR_LEN ( sizeof( DEFAULT_ADDR ) / sizeof( char))66 #define DEFAULT_ADDR_LEN (sizeof(DEFAULT_ADDR) / sizeof(char)) 67 67 68 68 /** Loopback module name. … … 80 80 * @returns EOK otherwise. 81 81 */ 82 int change_state_message( device_ref device, device_state_t state);82 int change_state_message(device_ref device, device_state_t state); 83 83 84 84 /** Creates and returns the loopback network interface structure. … … 89 89 * @returns ENOMEM if there is not enough memory left. 90 90 */ 91 int create( device_id_t device_id, device_ref * device);91 int create(device_id_t device_id, device_ref * device); 92 92 93 93 /** Prints the module name. 94 94 * @see NAME 95 95 */ 96 void module_print_name( void);97 98 int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){96 void module_print_name(void); 97 98 int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 99 99 return ENOTSUP; 100 100 } 101 101 102 int netif_get_addr_message( device_id_t device_id, measured_string_ref address ){ 103 if( ! address ) return EBADMEM; 102 int netif_get_addr_message(device_id_t device_id, measured_string_ref address){ 103 if(! address){ 104 return EBADMEM; 105 } 104 106 address->value = str_dup(DEFAULT_ADDR); 105 107 address->length = DEFAULT_ADDR_LEN; … … 107 109 } 108 110 109 int netif_get_device_stats( device_id_t device_id, device_stats_ref stats){111 int netif_get_device_stats(device_id_t device_id, device_stats_ref stats){ 110 112 ERROR_DECLARE; 111 113 112 device_ref device; 113 114 if( ! stats ) return EBADMEM; 115 ERROR_PROPAGATE( find_device( device_id, & device )); 116 memcpy( stats, ( device_stats_ref ) device->specific, sizeof( device_stats_t )); 117 return EOK; 118 } 119 120 int change_state_message( device_ref device, device_state_t state ){ 121 if( device->state != state ){ 114 device_ref device; 115 116 if(! stats){ 117 return EBADMEM; 118 } 119 ERROR_PROPAGATE(find_device(device_id, &device)); 120 memcpy(stats, (device_stats_ref) device->specific, sizeof(device_stats_t)); 121 return EOK; 122 } 123 124 int change_state_message(device_ref device, device_state_t state){ 125 if(device->state != state){ 122 126 device->state = state; 123 printf( "State changed to %s\n", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED");127 printf("State changed to %s\n", (state == NETIF_ACTIVE) ? "ACTIVE" : "STOPPED"); 124 128 return state; 125 129 } … … 127 131 } 128 132 129 int create( device_id_t device_id, device_ref * device){130 int index;131 132 if( device_map_count( & netif_globals.device_map ) > 0){133 int create(device_id_t device_id, device_ref * device){ 134 int index; 135 136 if(device_map_count(&netif_globals.device_map) > 0){ 133 137 return EXDEV; 134 138 }else{ 135 * device = ( device_ref ) malloc( sizeof( device_t )); 136 if( !( * device )) return ENOMEM; 137 ( ** device ).specific = malloc( sizeof( device_stats_t )); 138 if( ! ( ** device ).specific ){ 139 free( * device ); 139 *device = (device_ref) malloc(sizeof(device_t)); 140 if(!(*device)){ 140 141 return ENOMEM; 141 142 } 142 null_device_stats(( device_stats_ref )( ** device ).specific ); 143 ( ** device ).device_id = device_id; 144 ( ** device ).nil_phone = -1; 145 ( ** device ).state = NETIF_STOPPED; 146 index = device_map_add( & netif_globals.device_map, ( ** device ).device_id, * device ); 147 if( index < 0 ){ 148 free( * device ); 149 free(( ** device ).specific ); 150 * device = NULL; 143 (** device).specific = malloc(sizeof(device_stats_t)); 144 if(! (** device).specific){ 145 free(*device); 146 return ENOMEM; 147 } 148 null_device_stats((device_stats_ref)(** device).specific); 149 (** device).device_id = device_id; 150 (** device).nil_phone = -1; 151 (** device).state = NETIF_STOPPED; 152 index = device_map_add(&netif_globals.device_map, (** device).device_id, * device); 153 if(index < 0){ 154 free(*device); 155 free((** device).specific); 156 *device = NULL; 151 157 return index; 152 158 } … … 155 161 } 156 162 157 int netif_initialize( void){158 ipcarg_t phonehash;159 160 return REGISTER_ME( SERVICE_LO, & phonehash);161 } 162 163 void module_print_name( void){164 printf( "%s", NAME);165 } 166 167 int netif_probe_message( device_id_t device_id, int irq, uintptr_t io){163 int netif_initialize(void){ 164 ipcarg_t phonehash; 165 166 return REGISTER_ME(SERVICE_LO, &phonehash); 167 } 168 169 void module_print_name(void){ 170 printf("%s", NAME); 171 } 172 173 int netif_probe_message(device_id_t device_id, int irq, uintptr_t io){ 168 174 ERROR_DECLARE; 169 175 170 device_ref device;176 device_ref device; 171 177 172 178 // create a new device 173 ERROR_PROPAGATE( create( device_id, & device));179 ERROR_PROPAGATE(create(device_id, &device)); 174 180 // print the settings 175 printf("New device created:\n\tid\t= %d\n", device->device_id );176 return EOK; 177 } 178 179 int netif_send_message( device_id_t device_id, packet_t packet, services_t sender){181 printf("New device created:\n\tid\t= %d\n", device->device_id); 182 return EOK; 183 } 184 185 int netif_send_message(device_id_t device_id, packet_t packet, services_t sender){ 180 186 ERROR_DECLARE; 181 187 182 device_ref device;183 size_t length;184 packet_t next;185 int phone;186 187 ERROR_PROPAGATE( find_device( device_id, & device));188 if( device->state != NETIF_ACTIVE){189 netif_pq_release( packet_get_id( packet));188 device_ref device; 189 size_t length; 190 packet_t next; 191 int phone; 192 193 ERROR_PROPAGATE(find_device(device_id, &device)); 194 if(device->state != NETIF_ACTIVE){ 195 netif_pq_release(packet_get_id(packet)); 190 196 return EFORWARD; 191 197 } 192 198 next = packet; 193 199 do{ 194 ++ (( device_stats_ref ) device->specific)->send_packets;195 ++ (( device_stats_ref ) device->specific)->receive_packets;196 length = packet_get_data_length( next);197 (( device_stats_ref ) device->specific)->send_bytes += length;198 (( device_stats_ref ) device->specific)->receive_bytes += length;199 next = pq_next( next);200 }while( next);200 ++ ((device_stats_ref) device->specific)->send_packets; 201 ++ ((device_stats_ref) device->specific)->receive_packets; 202 length = packet_get_data_length(next); 203 ((device_stats_ref) device->specific)->send_bytes += length; 204 ((device_stats_ref) device->specific)->receive_bytes += length; 205 next = pq_next(next); 206 }while(next); 201 207 phone = device->nil_phone; 202 fibril_rwlock_write_unlock( & netif_globals.lock);203 nil_received_msg( phone, device_id, packet, sender);204 fibril_rwlock_write_lock( & netif_globals.lock);205 return EOK; 206 } 207 208 int netif_start_message( device_ref device){209 return change_state_message( device, NETIF_ACTIVE);210 } 211 212 int netif_stop_message( device_ref device){213 return change_state_message( device, NETIF_STOPPED);208 fibril_rwlock_write_unlock(&netif_globals.lock); 209 nil_received_msg(phone, device_id, packet, sender); 210 fibril_rwlock_write_lock(&netif_globals.lock); 211 return EOK; 212 } 213 214 int netif_start_message(device_ref device){ 215 return change_state_message(device, NETIF_ACTIVE); 216 } 217 218 int netif_stop_message(device_ref device){ 219 return change_state_message(device, NETIF_STOPPED); 214 220 } 215 221 -
uspace/srv/net/netif/netif.c
raa85487 raadf01e 64 64 extern netif_globals_t netif_globals; 65 65 66 DEVICE_MAP_IMPLEMENT( device_map, device_t)66 DEVICE_MAP_IMPLEMENT(device_map, device_t) 67 67 68 68 /** @name Message processing functions … … 77 77 * @returns ELIMIT if there is another module registered. 78 78 */ 79 int register_message( device_id_t device_id, int phone);79 int register_message(device_id_t device_id, int phone); 80 80 81 81 /*@}*/ 82 82 83 int netif_probe_req( int netif_phone, device_id_t device_id, int irq, int io){84 int result;85 86 fibril_rwlock_write_lock( & netif_globals.lock);87 result = netif_probe_message( device_id, irq, io);88 fibril_rwlock_write_unlock( & netif_globals.lock);89 return result; 90 } 91 92 int netif_send_msg( int netif_phone, device_id_t device_id, packet_t packet, services_t sender){93 int result;94 95 fibril_rwlock_write_lock( & netif_globals.lock);96 result = netif_send_message( device_id, packet, sender);97 fibril_rwlock_write_unlock( & netif_globals.lock);98 return result; 99 } 100 101 int netif_start_req( int netif_phone, device_id_t device_id){102 ERROR_DECLARE; 103 104 device_ref device;105 int result;106 int phone;107 108 fibril_rwlock_write_lock( & netif_globals.lock);109 if( ERROR_OCCURRED( find_device( device_id, & device))){110 fibril_rwlock_write_unlock( & netif_globals.lock);83 int netif_probe_req(int netif_phone, device_id_t device_id, int irq, int io){ 84 int result; 85 86 fibril_rwlock_write_lock(&netif_globals.lock); 87 result = netif_probe_message(device_id, irq, io); 88 fibril_rwlock_write_unlock(&netif_globals.lock); 89 return result; 90 } 91 92 int netif_send_msg(int netif_phone, device_id_t device_id, packet_t packet, services_t sender){ 93 int result; 94 95 fibril_rwlock_write_lock(&netif_globals.lock); 96 result = netif_send_message(device_id, packet, sender); 97 fibril_rwlock_write_unlock(&netif_globals.lock); 98 return result; 99 } 100 101 int netif_start_req(int netif_phone, device_id_t device_id){ 102 ERROR_DECLARE; 103 104 device_ref device; 105 int result; 106 int phone; 107 108 fibril_rwlock_write_lock(&netif_globals.lock); 109 if(ERROR_OCCURRED(find_device(device_id, &device))){ 110 fibril_rwlock_write_unlock(&netif_globals.lock); 111 111 return ERROR_CODE; 112 112 } 113 result = netif_start_message( device);114 if( result > NETIF_NULL){113 result = netif_start_message(device); 114 if(result > NETIF_NULL){ 115 115 phone = device->nil_phone; 116 fibril_rwlock_write_unlock( & netif_globals.lock);117 nil_device_state_msg( phone, device_id, result);116 fibril_rwlock_write_unlock(&netif_globals.lock); 117 nil_device_state_msg(phone, device_id, result); 118 118 return EOK; 119 119 }else{ 120 fibril_rwlock_write_unlock( & netif_globals.lock);121 } 122 return result; 123 } 124 125 int netif_stop_req( int netif_phone, device_id_t device_id){126 ERROR_DECLARE; 127 128 device_ref device;129 int result;130 int phone;131 132 fibril_rwlock_write_lock( & netif_globals.lock);133 if( ERROR_OCCURRED( find_device( device_id, & device))){134 fibril_rwlock_write_unlock( & netif_globals.lock);120 fibril_rwlock_write_unlock(&netif_globals.lock); 121 } 122 return result; 123 } 124 125 int netif_stop_req(int netif_phone, device_id_t device_id){ 126 ERROR_DECLARE; 127 128 device_ref device; 129 int result; 130 int phone; 131 132 fibril_rwlock_write_lock(&netif_globals.lock); 133 if(ERROR_OCCURRED(find_device(device_id, &device))){ 134 fibril_rwlock_write_unlock(&netif_globals.lock); 135 135 return ERROR_CODE; 136 136 } 137 result = netif_stop_message( device);138 if( result > NETIF_NULL){137 result = netif_stop_message(device); 138 if(result > NETIF_NULL){ 139 139 phone = device->nil_phone; 140 fibril_rwlock_write_unlock( & netif_globals.lock);141 nil_device_state_msg( phone, device_id, result);140 fibril_rwlock_write_unlock(&netif_globals.lock); 141 nil_device_state_msg(phone, device_id, result); 142 142 return EOK; 143 143 }else{ 144 fibril_rwlock_write_unlock( & netif_globals.lock);145 } 146 return result; 147 } 148 149 int netif_stats_req( int netif_phone, device_id_t device_id, device_stats_ref stats){144 fibril_rwlock_write_unlock(&netif_globals.lock); 145 } 146 return result; 147 } 148 149 int netif_stats_req(int netif_phone, device_id_t device_id, device_stats_ref stats){ 150 150 int res; 151 151 152 fibril_rwlock_read_lock( & netif_globals.lock);153 res = netif_get_device_stats( device_id, stats);154 fibril_rwlock_read_unlock( & netif_globals.lock);152 fibril_rwlock_read_lock(&netif_globals.lock); 153 res = netif_get_device_stats(device_id, stats); 154 fibril_rwlock_read_unlock(&netif_globals.lock); 155 155 return res; 156 156 } 157 157 158 int netif_get_addr_req( int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data ){ 159 ERROR_DECLARE; 160 161 measured_string_t translation; 162 163 if( !( address && data )) return EBADMEM; 164 fibril_rwlock_read_lock( & netif_globals.lock ); 165 if( ! ERROR_OCCURRED( netif_get_addr_message( device_id, & translation ))){ 166 * address = measured_string_copy( & translation ); 167 ERROR_CODE = ( * address ) ? EOK : ENOMEM; 168 } 169 fibril_rwlock_read_unlock( & netif_globals.lock ); 170 * data = ( ** address ).value; 158 int netif_get_addr_req(int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data){ 159 ERROR_DECLARE; 160 161 measured_string_t translation; 162 163 if(!(address && data)){ 164 return EBADMEM; 165 } 166 fibril_rwlock_read_lock(&netif_globals.lock); 167 if(! ERROR_OCCURRED(netif_get_addr_message(device_id, &translation))){ 168 *address = measured_string_copy(&translation); 169 ERROR_CODE = (*address) ? EOK : ENOMEM; 170 } 171 fibril_rwlock_read_unlock(&netif_globals.lock); 172 *data = (** address).value; 171 173 return ERROR_CODE; 172 174 } 173 175 174 int netif_bind_service( services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver ){ 175 return EOK; 176 } 177 178 int find_device( device_id_t device_id, device_ref * device ){ 179 if( ! device ) return EBADMEM; 180 * device = device_map_find( & netif_globals.device_map, device_id ); 181 if( ! * device ) return ENOENT; 182 if(( ** device ).state == NETIF_NULL ) return EPERM; 183 return EOK; 184 } 185 186 void null_device_stats( device_stats_ref stats ){ 187 bzero( stats, sizeof( device_stats_t )); 188 } 189 190 int register_message( device_id_t device_id, int phone ){ 191 ERROR_DECLARE; 192 193 device_ref device; 194 195 ERROR_PROPAGATE( find_device( device_id, & device )); 196 if( device->nil_phone > 0 ) return ELIMIT; 176 int netif_bind_service(services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver){ 177 return EOK; 178 } 179 180 int find_device(device_id_t device_id, device_ref * device){ 181 if(! device){ 182 return EBADMEM; 183 } 184 *device = device_map_find(&netif_globals.device_map, device_id); 185 if(! * device){ 186 return ENOENT; 187 } 188 if((** device).state == NETIF_NULL) return EPERM; 189 return EOK; 190 } 191 192 void null_device_stats(device_stats_ref stats){ 193 bzero(stats, sizeof(device_stats_t)); 194 } 195 196 int register_message(device_id_t device_id, int phone){ 197 ERROR_DECLARE; 198 199 device_ref device; 200 201 ERROR_PROPAGATE(find_device(device_id, &device)); 202 if(device->nil_phone > 0){ 203 return ELIMIT; 204 } 197 205 device->nil_phone = phone; 198 printf( "New receiver of the device %d registered:\n\tphone\t= %d\n", device->device_id, device->nil_phone);199 return EOK; 200 } 201 202 int netif_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){203 ERROR_DECLARE; 204 205 size_t length;206 device_stats_t stats;207 packet_t packet;208 measured_string_t address;209 210 // printf( "message %d - %d\n", IPC_GET_METHOD( * call ), NET_NETIF_FIRST);211 * answer_count = 0;212 switch( IPC_GET_METHOD( * call)){206 printf("New receiver of the device %d registered:\n\tphone\t= %d\n", device->device_id, device->nil_phone); 207 return EOK; 208 } 209 210 int netif_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 211 ERROR_DECLARE; 212 213 size_t length; 214 device_stats_t stats; 215 packet_t packet; 216 measured_string_t address; 217 218 // printf("message %d - %d\n", IPC_GET_METHOD(*call), NET_NETIF_FIRST); 219 *answer_count = 0; 220 switch(IPC_GET_METHOD(*call)){ 213 221 case IPC_M_PHONE_HUNGUP: 214 222 return EOK; 215 223 case NET_NETIF_PROBE: 216 return netif_probe_req( 0, IPC_GET_DEVICE( call ), NETIF_GET_IRQ( call ), NETIF_GET_IO( call));224 return netif_probe_req(0, IPC_GET_DEVICE(call), NETIF_GET_IRQ(call), NETIF_GET_IO(call)); 217 225 case IPC_M_CONNECT_TO_ME: 218 fibril_rwlock_write_lock( & netif_globals.lock);219 ERROR_CODE = register_message( IPC_GET_DEVICE( call ), IPC_GET_PHONE( call));220 fibril_rwlock_write_unlock( & netif_globals.lock);226 fibril_rwlock_write_lock(&netif_globals.lock); 227 ERROR_CODE = register_message(IPC_GET_DEVICE(call), IPC_GET_PHONE(call)); 228 fibril_rwlock_write_unlock(&netif_globals.lock); 221 229 return ERROR_CODE; 222 230 case NET_NETIF_SEND: 223 ERROR_PROPAGATE( packet_translate( netif_globals.net_phone, & packet, IPC_GET_PACKET( call)));224 return netif_send_msg( 0, IPC_GET_DEVICE( call ), packet, IPC_GET_SENDER( call));231 ERROR_PROPAGATE(packet_translate(netif_globals.net_phone, &packet, IPC_GET_PACKET(call))); 232 return netif_send_msg(0, IPC_GET_DEVICE(call), packet, IPC_GET_SENDER(call)); 225 233 case NET_NETIF_START: 226 return netif_start_req( 0, IPC_GET_DEVICE( call));234 return netif_start_req(0, IPC_GET_DEVICE(call)); 227 235 case NET_NETIF_STATS: 228 fibril_rwlock_read_lock( & netif_globals.lock);229 if( ! ERROR_OCCURRED( async_data_read_receive( & callid, & length))){230 if( length < sizeof( device_stats_t)){236 fibril_rwlock_read_lock(&netif_globals.lock); 237 if(! ERROR_OCCURRED(async_data_read_receive(&callid, &length))){ 238 if(length < sizeof(device_stats_t)){ 231 239 ERROR_CODE = EOVERFLOW; 232 240 }else{ 233 if( ! ERROR_OCCURRED( netif_get_device_stats( IPC_GET_DEVICE( call ), & stats))){234 ERROR_CODE = async_data_read_finalize( callid, & stats, sizeof( device_stats_t));241 if(! ERROR_OCCURRED(netif_get_device_stats(IPC_GET_DEVICE(call), &stats))){ 242 ERROR_CODE = async_data_read_finalize(callid, &stats, sizeof(device_stats_t)); 235 243 } 236 244 } 237 245 } 238 fibril_rwlock_read_unlock( & netif_globals.lock);246 fibril_rwlock_read_unlock(&netif_globals.lock); 239 247 return ERROR_CODE; 240 248 case NET_NETIF_STOP: 241 return netif_stop_req( 0, IPC_GET_DEVICE( call));249 return netif_stop_req(0, IPC_GET_DEVICE(call)); 242 250 case NET_NETIF_GET_ADDR: 243 fibril_rwlock_read_lock( & netif_globals.lock);244 if( ! ERROR_OCCURRED( netif_get_addr_message( IPC_GET_DEVICE( call ), & address))){245 ERROR_CODE = measured_strings_reply( & address, 1);251 fibril_rwlock_read_lock(&netif_globals.lock); 252 if(! ERROR_OCCURRED(netif_get_addr_message(IPC_GET_DEVICE(call), &address))){ 253 ERROR_CODE = measured_strings_reply(&address, 1); 246 254 } 247 fibril_rwlock_read_unlock( & netif_globals.lock);255 fibril_rwlock_read_unlock(&netif_globals.lock); 248 256 return ERROR_CODE; 249 257 } 250 return netif_specific_message( callid, call, answer, answer_count);251 } 252 253 int netif_init_module( async_client_conn_t client_connection){254 ERROR_DECLARE; 255 256 async_set_client_connection( client_connection);257 netif_globals.net_phone = connect_to_service( SERVICE_NETWORKING);258 device_map_initialize( & netif_globals.device_map);259 ERROR_PROPAGATE( pm_init());260 fibril_rwlock_initialize( & netif_globals.lock);261 if( ERROR_OCCURRED(netif_initialize())){258 return netif_specific_message(callid, call, answer, answer_count); 259 } 260 261 int netif_init_module(async_client_conn_t client_connection){ 262 ERROR_DECLARE; 263 264 async_set_client_connection(client_connection); 265 netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING); 266 device_map_initialize(&netif_globals.device_map); 267 ERROR_PROPAGATE(pm_init()); 268 fibril_rwlock_initialize(&netif_globals.lock); 269 if(ERROR_OCCURRED(netif_initialize())){ 262 270 pm_destroy(); 263 271 return ERROR_CODE; … … 266 274 } 267 275 268 int netif_run_module( void){276 int netif_run_module(void){ 269 277 async_manager(); 270 278 … … 273 281 } 274 282 275 void netif_pq_release( packet_id_t packet_id){276 pq_release( netif_globals.net_phone, packet_id);277 } 278 279 packet_t netif_packet_get_1( size_t content){280 return packet_get_1( netif_globals.net_phone, content);283 void netif_pq_release(packet_id_t packet_id){ 284 pq_release(netif_globals.net_phone, packet_id); 285 } 286 287 packet_t netif_packet_get_1(size_t content){ 288 return packet_get_1(netif_globals.net_phone, content); 281 289 } 282 290 -
uspace/srv/net/netif/netif.h
raa85487 raadf01e 69 69 * @see device.h 70 70 */ 71 DEVICE_MAP_DECLARE( device_map, device_t);71 DEVICE_MAP_DECLARE(device_map, device_t); 72 72 73 73 /** Network interface device specific data. … … 76 76 /** Device identifier. 77 77 */ 78 device_id_t device_id;78 device_id_t device_id; 79 79 /** Receiving network interface layer phone. 80 80 */ 81 int nil_phone;81 int nil_phone; 82 82 /** Actual device state. 83 83 */ 84 device_state_t state;84 device_state_t state; 85 85 /** Driver specific data. 86 86 */ 87 void * specific;87 void * specific; 88 88 }; 89 89 … … 93 93 /** Networking module phone. 94 94 */ 95 int net_phone;95 int net_phone; 96 96 /** Device map. 97 97 */ 98 device_map_t device_map;98 device_map_t device_map; 99 99 /** Safety lock. 100 100 */ 101 fibril_rwlock_t lock;101 fibril_rwlock_t lock; 102 102 }; 103 103 … … 109 109 * @returns EPERM if the device is not initialized. 110 110 */ 111 int find_device( device_id_t device_id, device_ref * device);111 int find_device(device_id_t device_id, device_ref * device); 112 112 113 113 /** Clears the usage statistics. 114 114 * @param[in] stats The usage statistics. 115 115 */ 116 void null_device_stats( device_stats_ref stats);116 void null_device_stats(device_stats_ref stats); 117 117 118 118 // prepared for future optimalizations … … 120 120 * @param[in] packet_id The packet identifier. 121 121 */ 122 void netif_pq_release( packet_id_t packet_id);122 void netif_pq_release(packet_id_t packet_id); 123 123 124 124 /** Allocates new packet to handle the given content size. … … 127 127 * @returns NULL if there is an error. 128 128 */ 129 packet_t netif_packet_get_1( size_t content);129 packet_t netif_packet_get_1(size_t content); 130 130 131 131 /** Processes the netif module messages. … … 140 140 * @see IS_NET_NETIF_MESSAGE() 141 141 */ 142 int netif_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);142 int netif_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count); 143 143 144 144 /** Initializes the netif module. … … 148 148 * @returns Other error codes as defined for each specific module message function. 149 149 */ 150 int netif_init_module( async_client_conn_t client_connection);150 int netif_init_module(async_client_conn_t client_connection); 151 151 152 152 /** Starts and maintains the netif module until terminated. 153 153 * @returns EOK after the module is terminated. 154 154 */ 155 int netif_run_module( void);155 int netif_run_module(void); 156 156 157 157 #endif -
uspace/srv/net/netif/netif_messages.h
raa85487 raadf01e 79 79 * @param[in] call The message call structure. 80 80 */ 81 #define NETIF_GET_IRQ( call ) ( int ) IPC_GET_ARG2( * call)81 #define NETIF_GET_IRQ(call) (int) IPC_GET_ARG2(*call) 82 82 83 83 /** Returns the input/output address message parameter. 84 84 * @param[in] call The message call structure. 85 85 */ 86 #define NETIF_GET_IO( call ) ( int ) IPC_GET_ARG3( * call)86 #define NETIF_GET_IO(call) (int) IPC_GET_ARG3(*call) 87 87 88 88 /*@}*/ -
uspace/srv/net/netif/netif_module.h
raa85487 raadf01e 50 50 /** Initializes the specific module. 51 51 */ 52 int netif_initialize( void);52 int netif_initialize(void); 53 53 54 54 /** Probes the existence of the device. … … 60 60 * @returns Other error codes as defined for the specific module message implementation. 61 61 */ 62 int netif_probe_message( device_id_t device_id, int irq, uintptr_t io);62 int netif_probe_message(device_id_t device_id, int irq, uintptr_t io); 63 63 64 64 /** Sends the packet queue. … … 71 71 * @returns Other error codes as defined for the specific module message implementation. 72 72 */ 73 int netif_send_message( device_id_t device_id, packet_t packet, services_t sender);73 int netif_send_message(device_id_t device_id, packet_t packet, services_t sender); 74 74 75 75 /** Starts the device. … … 79 79 * @returns Other error codes as defined for the specific module message implementation. 80 80 */ 81 int netif_start_message( device_ref device);81 int netif_start_message(device_ref device); 82 82 83 83 /** Stops the device. … … 87 87 * @returns Other error codes as defined for the specific module message implementation. 88 88 */ 89 int netif_stop_message( device_ref device);89 int netif_stop_message(device_ref device); 90 90 91 91 /** Returns the device local hardware address. … … 98 98 * @returns Other error codes as defined for the specific module message implementation. 99 99 */ 100 int netif_get_addr_message( device_id_t device_id, measured_string_ref address);100 int netif_get_addr_message(device_id_t device_id, measured_string_ref address); 101 101 102 102 /** Processes the netif driver specific message. … … 110 110 * @returns Other error codes as defined for the specific module message implementation. 111 111 */ 112 int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);112 int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count); 113 113 114 114 /** Returns the device usage statistics. … … 119 119 * @returns Other error codes as defined for the specific module message implementation. 120 120 */ 121 int netif_get_device_stats( device_id_t device_id, device_stats_ref stats);121 int netif_get_device_stats(device_id_t device_id, device_stats_ref stats); 122 122 123 123 #endif -
uspace/srv/net/netif/netif_nil_bundle.c
raa85487 raadf01e 61 61 * @returns Other error codes as defined for each specific module message function. 62 62 */ 63 int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);63 int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count); 64 64 65 65 /** Starts the bundle network interface module. … … 69 69 * @returns Other error codes as defined for each specific module message function. 70 70 */ 71 int module_start( async_client_conn_t client_connection);71 int module_start(async_client_conn_t client_connection); 72 72 73 int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){74 if( IS_NET_NIL_MESSAGE( call ) || ( IPC_GET_METHOD( * call ) == IPC_M_CONNECT_TO_ME)){75 return nil_message( callid, call, answer, answer_count);73 int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 74 if(IS_NET_NIL_MESSAGE(call) || (IPC_GET_METHOD(*call) == IPC_M_CONNECT_TO_ME)){ 75 return nil_message(callid, call, answer, answer_count); 76 76 }else{ 77 return netif_message( callid, call, answer, answer_count);77 return netif_message(callid, call, answer, answer_count); 78 78 } 79 79 } 80 80 81 int module_start( async_client_conn_t client_connection){81 int module_start(async_client_conn_t client_connection){ 82 82 ERROR_DECLARE; 83 83 84 ERROR_PROPAGATE( netif_init_module( client_connection));85 if( ERROR_OCCURRED( nil_initialize( netif_globals.net_phone))){84 ERROR_PROPAGATE(netif_init_module(client_connection)); 85 if(ERROR_OCCURRED(nil_initialize(netif_globals.net_phone))){ 86 86 pm_destroy(); 87 87 return ERROR_CODE; -
uspace/srv/net/netif/netif_remote.c
raa85487 raadf01e 49 49 #include "netif_messages.h" 50 50 51 int netif_get_addr_req( int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data){52 return generic_get_addr_req( netif_phone, NET_NETIF_GET_ADDR, device_id, address, data);51 int netif_get_addr_req(int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data){ 52 return generic_get_addr_req(netif_phone, NET_NETIF_GET_ADDR, device_id, address, data); 53 53 } 54 54 55 int netif_probe_req( int netif_phone, device_id_t device_id, int irq, int io){56 return async_req_3_0( netif_phone, NET_NETIF_PROBE, device_id, irq, io);55 int netif_probe_req(int netif_phone, device_id_t device_id, int irq, int io){ 56 return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, io); 57 57 } 58 58 59 int netif_send_msg( int netif_phone, device_id_t device_id, packet_t packet, services_t sender){60 return generic_send_msg( netif_phone, NET_NETIF_SEND, device_id, packet_get_id( packet ), sender, 0);59 int netif_send_msg(int netif_phone, device_id_t device_id, packet_t packet, services_t sender){ 60 return generic_send_msg(netif_phone, NET_NETIF_SEND, device_id, packet_get_id(packet), sender, 0); 61 61 } 62 62 63 int netif_start_req( int netif_phone, device_id_t device_id){64 return async_req_1_0( netif_phone, NET_NETIF_START, device_id);63 int netif_start_req(int netif_phone, device_id_t device_id){ 64 return async_req_1_0(netif_phone, NET_NETIF_START, device_id); 65 65 } 66 66 67 int netif_stop_req( int netif_phone, device_id_t device_id){68 return async_req_1_0( netif_phone, NET_NETIF_STOP, device_id);67 int netif_stop_req(int netif_phone, device_id_t device_id){ 68 return async_req_1_0(netif_phone, NET_NETIF_STOP, device_id); 69 69 } 70 70 71 int netif_stats_req( int netif_phone, device_id_t device_id, device_stats_ref stats){72 aid_t message_id;73 ipcarg_t result;71 int netif_stats_req(int netif_phone, device_id_t device_id, device_stats_ref stats){ 72 aid_t message_id; 73 ipcarg_t result; 74 74 75 if( ! stats ) return EBADMEM; 76 message_id = async_send_1( netif_phone, NET_NETIF_STATS, ( ipcarg_t ) device_id, NULL ); 77 async_data_read_start( netif_phone, stats, sizeof( * stats )); 78 async_wait_for( message_id, & result ); 79 return ( int ) result; 75 if(! stats){ 76 return EBADMEM; 77 } 78 message_id = async_send_1(netif_phone, NET_NETIF_STATS, (ipcarg_t) device_id, NULL); 79 async_data_read_start(netif_phone, stats, sizeof(*stats)); 80 async_wait_for(message_id, &result); 81 return (int) result; 80 82 } 81 83 82 int netif_bind_service( services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver){83 return bind_service( service, device_id, me, 0, receiver);84 int netif_bind_service(services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver){ 85 return bind_service(service, device_id, me, 0, receiver); 84 86 } 85 87 -
uspace/srv/net/netif/netif_standalone.c
raa85487 raadf01e 50 50 * @returns Other error codes as defined for each specific module message function. 51 51 */ 52 int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);52 int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count); 53 53 54 54 /** Starts the network interface module. … … 58 58 * @returns Other error codes as defined for each specific module message function. 59 59 */ 60 int module_start( async_client_conn_t client_connection);60 int module_start(async_client_conn_t client_connection); 61 61 62 int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){63 return netif_message( callid, call, answer, answer_count);62 int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 63 return netif_message(callid, call, answer, answer_count); 64 64 } 65 65 66 int module_start( async_client_conn_t client_connection){66 int module_start(async_client_conn_t client_connection){ 67 67 ERROR_DECLARE; 68 68 69 ERROR_PROPAGATE( netif_init_module( client_connection));69 ERROR_PROPAGATE(netif_init_module(client_connection)); 70 70 return netif_run_module(); 71 71 }
Note:
See TracChangeset
for help on using the changeset viewer.
