Changeset f4f866c in mainline for uspace/srv/hw/netif/dp8390/dp8390_module.c
- Timestamp:
- 2010-04-23T21:42:26Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6c39a907
- Parents:
- 38aaacc2 (diff), 80badbe (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/netif/dp8390/dp8390_module.c
r38aaacc2 rf4f866c 50 50 #include <net_device.h> 51 51 #include <nil_interface.h> 52 #include <netif .h>53 #include <netif_ module.h>52 #include <netif_interface.h> 53 #include <netif_local.h> 54 54 55 55 #include "dp8390.h" … … 59 59 /** DP8390 module name. 60 60 */ 61 #define NAME "dp8390 network interface"61 #define NAME "dp8390" 62 62 63 63 /** Returns the device from the interrupt call. … … 95 95 }; 96 96 97 /** Network interface module global data.98 */99 netif_globals_t netif_globals;100 101 97 /** Handles the interrupt messages. 102 98 * This is the interrupt handler callback function. … … 104 100 * @param[in] call The interrupt message. 105 101 */ 106 void irq_handler(ipc_callid_t iid, ipc_call_t * call); 102 static void irq_handler(ipc_callid_t iid, ipc_call_t * call) 103 { 104 netif_device_t * device; 105 dpeth_t * dep; 106 packet_t received; 107 device_id_t device_id; 108 int phone; 109 110 device_id = IRQ_GET_DEVICE(call); 111 fibril_rwlock_write_lock(&netif_globals.lock); 112 if(find_device(device_id, &device) != EOK){ 113 fibril_rwlock_write_unlock(&netif_globals.lock); 114 return; 115 } 116 dep = (dpeth_t *) device->specific; 117 if (dep->de_mode != DEM_ENABLED){ 118 fibril_rwlock_write_unlock(&netif_globals.lock); 119 return; 120 } 121 assert(dep->de_flags &DEF_ENABLED); 122 dep->de_int_pending = 0; 123 dp_check_ints(dep, IPC_GET_ISR(call)); 124 if(dep->received_queue){ 125 received = dep->received_queue; 126 phone = device->nil_phone; 127 dep->received_queue = NULL; 128 dep->received_count = 0; 129 fibril_rwlock_write_unlock(&netif_globals.lock); 130 nil_received_msg(phone, device_id, received, NULL); 131 }else{ 132 fibril_rwlock_write_unlock(&netif_globals.lock); 133 } 134 ipc_answer_0(iid, EOK); 135 } 107 136 108 137 /** Changes the network interface state. … … 111 140 * @returns The new state. 112 141 */ 113 int change_state(device_ref device, device_state_t state); 142 static int change_state(netif_device_t * device, device_state_t state) 143 { 144 if (device->state != state) { 145 device->state = state; 146 147 printf("%s: State changed to %s\n", NAME, 148 (state == NETIF_ACTIVE) ? "active" : "stopped"); 149 150 return state; 151 } 152 153 return EOK; 154 } 114 155 115 156 int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ … … 120 161 ERROR_DECLARE; 121 162 122 device_refdevice;163 netif_device_t * device; 123 164 eth_stat_t * de_stat; 124 165 … … 147 188 ERROR_DECLARE; 148 189 149 device_refdevice;190 netif_device_t * device; 150 191 151 192 if(! address){ … … 158 199 } 159 200 160 void irq_handler(ipc_callid_t iid, ipc_call_t * call) 161 { 162 device_ref device; 163 dpeth_t * dep; 164 packet_t received; 165 device_id_t device_id; 166 int phone; 167 168 device_id = IRQ_GET_DEVICE(call); 169 fibril_rwlock_write_lock(&netif_globals.lock); 170 if(find_device(device_id, &device) != EOK){ 171 fibril_rwlock_write_unlock(&netif_globals.lock); 172 return; 173 } 174 dep = (dpeth_t *) device->specific; 175 if (dep->de_mode != DEM_ENABLED){ 176 fibril_rwlock_write_unlock(&netif_globals.lock); 177 return; 178 } 179 assert(dep->de_flags &DEF_ENABLED); 180 dep->de_int_pending = 0; 181 // remove debug print: 182 #ifdef CONFIG_DEBUG 183 printf("I%d: 0x%x\n", device_id, IPC_GET_ISR(call)); 184 #endif 185 dp_check_ints(dep, IPC_GET_ISR(call)); 186 if(dep->received_queue){ 187 received = dep->received_queue; 188 phone = device->nil_phone; 189 dep->received_queue = NULL; 190 dep->received_count = 0; 191 fibril_rwlock_write_unlock(&netif_globals.lock); 192 // remove debug dump: 193 #ifdef CONFIG_DEBUG 194 uint8_t * data; 195 data = packet_get_data(received); 196 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]); 197 #endif 198 nil_received_msg(phone, device_id, received, NULL); 199 }else{ 200 fibril_rwlock_write_unlock(&netif_globals.lock); 201 } 202 ipc_answer_0(iid, EOK); 203 } 201 204 202 205 203 int netif_probe_message(device_id_t device_id, int irq, uintptr_t io){ 206 204 ERROR_DECLARE; 207 205 208 device_refdevice;209 dpeth_t * dep; 210 211 device = ( device_ref) malloc(sizeof(device_t));206 netif_device_t * device; 207 dpeth_t * dep; 208 209 device = (netif_device_t *) malloc(sizeof(netif_device_t)); 212 210 if(! device){ 213 211 return ENOMEM; … … 218 216 return ENOMEM; 219 217 } 220 bzero(device, sizeof( device_t));218 bzero(device, sizeof(netif_device_t)); 221 219 bzero(dep, sizeof(dpeth_t)); 222 220 device->device_id = device_id; … … 233 231 return ERROR_CODE; 234 232 } 235 if(ERROR_OCCURRED( device_map_add(&netif_globals.device_map, device->device_id, device))){233 if(ERROR_OCCURRED(netif_device_map_add(&netif_globals.device_map, device->device_id, device))){ 236 234 free(dep); 237 235 free(device); … … 244 242 ERROR_DECLARE; 245 243 246 device_refdevice;244 netif_device_t * device; 247 245 dpeth_t * dep; 248 246 packet_t next; … … 257 255 do{ 258 256 next = pq_detach(packet); 259 // remove debug dump:260 #ifdef CONFIG_DEBUG261 uint8_t * data;262 data = packet_get_data(packet);263 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]);264 #endif265 257 if(do_pwrite(dep, packet, FALSE) != EBUSY){ 266 258 netif_pq_release(packet_get_id(packet)); … … 271 263 } 272 264 273 int netif_start_message( device_refdevice){265 int netif_start_message(netif_device_t * device){ 274 266 ERROR_DECLARE; 275 267 … … 290 282 } 291 283 292 int netif_stop_message( device_refdevice){284 int netif_stop_message(netif_device_t * device){ 293 285 dpeth_t * dep; 294 286 … … 302 294 } 303 295 304 int change_state(device_ref device, device_state_t state){305 device->state = state;306 printf("State changed to %s\n", (state == NETIF_ACTIVE) ? "ACTIVE" : "STOPPED");307 return state;308 }309 310 296 int netif_initialize(void){ 311 297 ipcarg_t phonehash; … … 315 301 return REGISTER_ME(SERVICE_DP8390, &phonehash); 316 302 } 317 318 #ifdef CONFIG_NETWORKING_modular319 320 #include <netif_standalone.h>321 303 322 304 /** Default thread for new connections. … … 346 328 347 329 /* Process the message */ 348 int res = netif_module_message(callid, &call, &answer, &answer_count); 330 int res = netif_module_message(NAME, callid, &call, &answer, 331 &answer_count); 349 332 350 333 /* End if said to either by the message or the processing result */ … … 370 353 ERROR_DECLARE; 371 354 372 /* Print the module label */ 373 printf("Task %d - %s\n", task_get_id(), NAME); 355 /* Start the module */ 356 if (ERROR_OCCURRED(netif_module_start(netif_client_connection))) 357 return ERROR_CODE; 374 358 375 /* Start the module */ 376 if (ERROR_OCCURRED(netif_module_start(netif_client_connection))) { 377 printf(" - ERROR %i\n", ERROR_CODE); 378 return ERROR_CODE; 379 } 380 381 return EOK; 382 } 383 384 #endif /* CONFIG_NETWORKING_modular */ 385 359 return EOK; 360 } 386 361 387 362 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.