Changeset 95ff5c4 in mainline
- Timestamp:
- 2011-01-06T14:33:04Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d3c9b60
- Parents:
- 8f5e2527
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/netif/dp8390/dp8390.c
r8f5e2527 r95ff5c4 25 25 * @param[in] packet The outgoing packet. 26 26 * @return EOK on success. 27 * @return EINVAL 27 * @return EINVAL 28 28 */ 29 29 int queue_packet(dpeth_t * dep, packet_t *packet); … … 47 47 * genuine dp8390s 48 48 */ 49 #define CR_EXTRA 49 #define CR_EXTRA CR_STA 50 50 51 51 _PROTOTYPE(static void dp_init, (dpeth_t *dep) ); … … 78 78 _PROTOTYPE(static void insw, (port_t port, void *buf, size_t size) ); 79 79 80 int do_probe(dpeth_t * dep){ 80 int do_probe(dpeth_t *dep) 81 { 81 82 /* This is the default, try to (re)locate the device. */ 82 83 conf_hw(dep); 83 84 if (dep->de_mode == DEM_DISABLED) 84 {85 85 /* Probe failed, or the device is configured off. */ 86 return EXDEV; //ENXIO;87 }86 return EXDEV; 87 88 88 if (dep->de_mode == DEM_ENABLED) 89 89 dp_init(dep); 90 90 91 return EOK; 91 92 } 92 93 93 /*===========================================================================* 94 * dp8390_dump * 95 *===========================================================================*/ 96 void dp8390_dump(dpeth_t * dep) 94 void dp8390_dump(dpeth_t *dep) 97 95 { 98 96 // dpeth_t *dep; … … 143 141 } 144 142 145 /*===========================================================================* 146 * do_init * 147 *===========================================================================*/ 148 int do_init(dpeth_t * dep, int mode){ 143 int do_init(dpeth_t *dep, int mode) 144 { 149 145 if (dep->de_mode == DEM_DISABLED) 150 {151 146 // might call do_probe() 152 147 return EXDEV; 153 } 154 155 if (dep->de_mode == DEM_SINK) 156 { 148 149 if (dep->de_mode == DEM_SINK) { 157 150 // strncpy((char *) dep->de_address.ea_addr, "ZDP", 6); 158 151 // dep->de_address.ea_addr[5] = port; 159 // dp_confaddr(dep);160 152 // reply_mess.m_type = DL_CONF_REPLY; 161 153 // reply_mess.m3_i1 = mp->DL_PORT; … … 166 158 return EOK; 167 159 } 160 168 161 assert(dep->de_mode == DEM_ENABLED); 169 assert(dep->de_flags & DEF_ENABLED);170 162 assert(dep->de_flags & DEF_ENABLED); 163 171 164 dep->de_flags &= ~(DEF_PROMISC | DEF_MULTI | DEF_BROAD); 172 165 173 166 if (mode &DL_PROMISC_REQ) 174 167 dep->de_flags |= DEF_PROMISC | DEF_MULTI | DEF_BROAD; 168 175 169 if (mode &DL_MULTI_REQ) 176 170 dep->de_flags |= DEF_MULTI; 171 177 172 if (mode &DL_BROAD_REQ) 178 173 dep->de_flags |= DEF_BROAD; 179 174 180 175 // dep->de_client = mp->m_source; 181 176 dp_reinit(dep); 182 177 183 178 // reply_mess.m_type = DL_CONF_REPLY; 184 179 // reply_mess.m3_i1 = mp->DL_PORT; 185 180 // reply_mess.m3_i2 = DE_PORT_NR; 186 181 // *(ether_addr_t *) reply_mess.m3_ca1 = dep->de_address; 187 182 188 183 // mess_reply(mp, &reply_mess); 189 184 return EOK; 190 185 } 191 186 192 /*===========================================================================* 193 * do_stop * 194 *===========================================================================*/ 195 void do_stop(dpeth_t * dep){ 196 if((dep->de_mode != DEM_SINK) && (dep->de_mode == DEM_ENABLED) && (dep->de_flags &DEF_ENABLED)){187 void do_stop(dpeth_t *dep) 188 { 189 if ((dep->de_mode != DEM_SINK) 190 && (dep->de_mode == DEM_ENABLED) 191 && (dep->de_flags & DEF_ENABLED)) { 197 192 outb_reg0(dep, DP_CR, CR_STP | CR_DM_ABORT); 198 193 (dep->de_stopf)(dep); 199 200 194 dep->de_flags = DEF_EMPTY; 201 195 } 202 196 } 203 197 204 int queue_packet(dpeth_t * dep, packet_t *packet){ 198 int queue_packet(dpeth_t *dep, packet_t *packet) 199 { 205 200 packet_t *tmp; 206 207 if (dep->packet_count >= MAX_PACKETS){201 202 if (dep->packet_count >= MAX_PACKETS) { 208 203 netif_pq_release(packet_get_id(packet)); 209 204 return ELIMIT; 210 205 } 211 206 212 207 tmp = dep->packet_queue; 213 while (pq_next(tmp)){208 while (pq_next(tmp)) 214 209 tmp = pq_next(tmp); 215 }216 if (pq_add(&tmp, packet, 0, 0) != EOK){210 211 if (pq_add(&tmp, packet, 0, 0) != EOK) 217 212 return EINVAL; 218 }219 if (! dep->packet_count){213 214 if (!dep->packet_count) 220 215 dep->packet_queue = packet; 221 }222 ++ 216 217 ++dep->packet_count; 223 218 return EBUSY; 224 219 } 225 220 226 /*===========================================================================* 227 * based on do_vwrite * 228 *===========================================================================*/ 229 int do_pwrite(dpeth_t * dep, packet_t *packet, int from_int) 221 int do_pwrite(dpeth_t *dep, packet_t *packet, int from_int) 230 222 { 231 223 // int port, count, size; … … 241 233 dep->de_client= mp->DL_PROC; 242 234 */ 243 if (dep->de_mode == DEM_SINK) 244 { 235 if (dep->de_mode == DEM_SINK) { 245 236 assert(!from_int); 246 237 // dep->de_flags |= DEF_PACK_SEND; … … 249 240 return EOK; 250 241 } 242 251 243 assert(dep->de_mode == DEM_ENABLED); 252 244 assert(dep->de_flags &DEF_ENABLED); 253 if(dep->packet_queue && (! from_int)){ 245 246 if ((dep->packet_queue) && (!from_int)) { 254 247 // if (dep->de_flags &DEF_SEND_AVAIL){ 255 248 // panic("", "dp8390: send already in progress", NO_NUM); 256 249 return queue_packet(dep, packet); 257 250 } 258 251 259 252 sendq_head= dep->de_sendq_head; 260 // if (dep->de_sendq[sendq_head].sq_filled) 261 // { 253 // if (dep->de_sendq[sendq_head].sq_filled) { 262 254 // if (from_int) 263 255 // panic("", "dp8390: should not be sending\n", NO_NUM); … … 269 261 // } 270 262 // assert(!(dep->de_flags &DEF_PACK_SEND)); 271 272 /* if (vectored) 273 { 263 264 /* if (vectored) { 274 265 get_userdata(mp->DL_PROC, (vir_bytes) mp->DL_ADDR, 275 266 (count > IOVEC_NR ? IOVEC_NR : count) * … … 278 269 dep->de_write_iovec.iod_proc_nr = mp->DL_PROC; 279 270 dep->de_write_iovec.iod_iovec_addr = (vir_bytes) mp->DL_ADDR; 280 271 281 272 dep->de_tmp_iovec = dep->de_write_iovec; 282 273 size = calc_iovec_size(&dep->de_tmp_iovec); 283 } 284 else 285 { 274 } else { 286 275 dep->de_write_iovec.iod_iovec[0].iov_addr = 287 276 (vir_bytes) mp->DL_ADDR; … … 299 288 dep->de_write_iovec.iod_iovec_s = 1; 300 289 dep->de_write_iovec.iod_iovec_addr = (uintptr_t) NULL; 301 302 if (size < ETH_MIN_PACK_SIZE || size > ETH_MAX_PACK_SIZE_TAGGED) 303 { 290 291 if (size < ETH_MIN_PACK_SIZE || size > ETH_MAX_PACK_SIZE_TAGGED) { 304 292 panic("", "dp8390: invalid packet size", size); 305 293 return EINVAL; 306 294 } 295 307 296 (dep->de_user2nicf)(dep, &dep->de_write_iovec, 0, 308 309 297 dep->de_sendq[sendq_head].sq_sendpage * DP_PAGESIZE, 298 size); 310 299 dep->de_sendq[sendq_head].sq_filled= TRUE; 311 if (dep->de_sendq_tail == sendq_head) 312 { 300 if (dep->de_sendq_tail == sendq_head) { 313 301 outb_reg0(dep, DP_TPSR, dep->de_sendq[sendq_head].sq_sendpage); 314 302 outb_reg0(dep, DP_TBCR1, size >> 8); 315 outb_reg0(dep, DP_TBCR0, size &0xff); 316 outb_reg0(dep, DP_CR, CR_TXP | CR_EXTRA);/* there it goes.. */ 317 } 318 else 319 dep->de_sendq[sendq_head].sq_size= size; 303 outb_reg0(dep, DP_TBCR0, size & 0xff); 304 outb_reg0(dep, DP_CR, CR_TXP | CR_EXTRA); /* there it goes.. */ 305 } else 306 dep->de_sendq[sendq_head].sq_size = size; 320 307 321 308 if (++sendq_head == dep->de_sendq_nr) 322 309 sendq_head= 0; 310 323 311 assert(sendq_head < SENDQ_NR); 324 dep->de_sendq_head = sendq_head;325 312 dep->de_sendq_head = sendq_head; 313 326 314 // dep->de_flags |= DEF_PACK_SEND; 327 328 /* If the interrupt handler called, don't send a reply. The reply 315 316 /* 317 * If the interrupt handler called, don't send a reply. The reply 329 318 * will be sent after all interrupts are handled. 330 319 */ 331 320 if (from_int) 332 321 return EOK; 322 333 323 reply(dep, OK, FALSE); 334 324 335 325 assert(dep->de_mode == DEM_ENABLED); 336 assert(dep->de_flags &DEF_ENABLED); 326 assert(dep->de_flags & DEF_ENABLED); 327 337 328 return EOK; 338 329 } 339 330 340 /*===========================================================================* 341 * dp_init * 342 *===========================================================================*/ 343 void dp_init(dep) 344 dpeth_t *dep; 331 void dp_init(dpeth_t *dep) 345 332 { 346 333 int dp_rcr_reg; 347 334 int i;//, r; 348 335 349 336 /* General initialization */ 350 337 dep->de_flags = DEF_EMPTY; 351 338 (*dep->de_initf)(dep); 352 353 // dp_confaddr(dep); 354 355 if (debug) 356 { 339 340 if (debug) { 357 341 printf("%s: Ethernet address ", dep->de_name); 358 for (i= 0; i < 6; i++) 359 printf("%x%c", dep->de_address.ea_addr[i], 360 i < 5 ? ':' : '\n'); 342 for (i = 0; i < 6; i++) 343 printf("%x%c", dep->de_address.ea_addr[i], i < 5 ? ':' : '\n'); 361 344 } 362 345
Note:
See TracChangeset
for help on using the changeset viewer.