Changeset 14f1db0 in mainline for uspace/srv/hw/netif/dp8390/dp8390_module.c
- Timestamp:
- 2010-04-09T12:54:57Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a1caa3c2
- Parents:
- 24ab58b3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/netif/dp8390/dp8390_module.c
r24ab58b3 r14f1db0 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" … … 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); 107 108 /** Changes the network interface state. 109 * @param[in,out] device The network interface. 110 * @param[in] state The new state. 111 * @returns The new state. 112 */ 113 int change_state(device_ref device, device_state_t state); 114 115 int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 116 return ENOTSUP; 117 } 118 119 int netif_get_device_stats(device_id_t device_id, device_stats_ref stats){ 120 ERROR_DECLARE; 121 122 device_ref device; 123 eth_stat_t * de_stat; 124 125 if(! stats){ 126 return EBADMEM; 127 } 128 ERROR_PROPAGATE(find_device(device_id, &device)); 129 de_stat = &((dpeth_t *) device->specific)->de_stat; 130 null_device_stats(stats); 131 stats->receive_errors = de_stat->ets_recvErr; 132 stats->send_errors = de_stat->ets_sendErr; 133 stats->receive_crc_errors = de_stat->ets_CRCerr; 134 stats->receive_frame_errors = de_stat->ets_frameAll; 135 stats->receive_missed_errors = de_stat->ets_missedP; 136 stats->receive_packets = de_stat->ets_packetR; 137 stats->send_packets = de_stat->ets_packetT; 138 stats->collisions = de_stat->ets_collision; 139 stats->send_aborted_errors = de_stat->ets_transAb; 140 stats->send_carrier_errors = de_stat->ets_carrSense; 141 stats->send_heartbeat_errors = de_stat->ets_CDheartbeat; 142 stats->send_window_errors = de_stat->ets_OWC; 143 return EOK; 144 } 145 146 int netif_get_addr_message(device_id_t device_id, measured_string_ref address){ 147 ERROR_DECLARE; 148 149 device_ref device; 150 151 if(! address){ 152 return EBADMEM; 153 } 154 ERROR_PROPAGATE(find_device(device_id, &device)); 155 address->value = (char *) (&((dpeth_t *) device->specific)->de_address); 156 address->length = CONVERT_SIZE(ether_addr_t, char, 1); 157 return EOK; 158 } 159 160 void irq_handler(ipc_callid_t iid, ipc_call_t * call) 102 static void irq_handler(ipc_callid_t iid, ipc_call_t * call) 161 103 { 162 device_refdevice;104 netif_device_t * device; 163 105 dpeth_t * dep; 164 106 packet_t received; … … 203 145 } 204 146 147 /** Changes the network interface state. 148 * @param[in,out] device The network interface. 149 * @param[in] state The new state. 150 * @returns The new state. 151 */ 152 static int change_state(netif_device_t * device, device_state_t state) 153 { 154 if (device->state != state) { 155 device->state = state; 156 157 printf("%s: State changed to %s\n", NAME, 158 (state == NETIF_ACTIVE) ? "active" : "stopped"); 159 160 return state; 161 } 162 163 return EOK; 164 } 165 166 int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 167 return ENOTSUP; 168 } 169 170 int netif_get_device_stats(device_id_t device_id, device_stats_ref stats){ 171 ERROR_DECLARE; 172 173 netif_device_t * device; 174 eth_stat_t * de_stat; 175 176 if(! stats){ 177 return EBADMEM; 178 } 179 ERROR_PROPAGATE(find_device(device_id, &device)); 180 de_stat = &((dpeth_t *) device->specific)->de_stat; 181 null_device_stats(stats); 182 stats->receive_errors = de_stat->ets_recvErr; 183 stats->send_errors = de_stat->ets_sendErr; 184 stats->receive_crc_errors = de_stat->ets_CRCerr; 185 stats->receive_frame_errors = de_stat->ets_frameAll; 186 stats->receive_missed_errors = de_stat->ets_missedP; 187 stats->receive_packets = de_stat->ets_packetR; 188 stats->send_packets = de_stat->ets_packetT; 189 stats->collisions = de_stat->ets_collision; 190 stats->send_aborted_errors = de_stat->ets_transAb; 191 stats->send_carrier_errors = de_stat->ets_carrSense; 192 stats->send_heartbeat_errors = de_stat->ets_CDheartbeat; 193 stats->send_window_errors = de_stat->ets_OWC; 194 return EOK; 195 } 196 197 int netif_get_addr_message(device_id_t device_id, measured_string_ref address){ 198 ERROR_DECLARE; 199 200 netif_device_t * device; 201 202 if(! address){ 203 return EBADMEM; 204 } 205 ERROR_PROPAGATE(find_device(device_id, &device)); 206 address->value = (char *) (&((dpeth_t *) device->specific)->de_address); 207 address->length = CONVERT_SIZE(ether_addr_t, char, 1); 208 return EOK; 209 } 210 211 212 205 213 int netif_probe_message(device_id_t device_id, int irq, uintptr_t io){ 206 214 ERROR_DECLARE; 207 215 208 device_refdevice;209 dpeth_t * dep; 210 211 device = ( device_ref) malloc(sizeof(device_t));216 netif_device_t * device; 217 dpeth_t * dep; 218 219 device = (netif_device_t *) malloc(sizeof(netif_device_t)); 212 220 if(! device){ 213 221 return ENOMEM; … … 218 226 return ENOMEM; 219 227 } 220 bzero(device, sizeof( device_t));228 bzero(device, sizeof(netif_device_t)); 221 229 bzero(dep, sizeof(dpeth_t)); 222 230 device->device_id = device_id; … … 233 241 return ERROR_CODE; 234 242 } 235 if(ERROR_OCCURRED( device_map_add(&netif_globals.device_map, device->device_id, device))){243 if(ERROR_OCCURRED(netif_device_map_add(&netif_globals.device_map, device->device_id, device))){ 236 244 free(dep); 237 245 free(device); … … 244 252 ERROR_DECLARE; 245 253 246 device_refdevice;254 netif_device_t * device; 247 255 dpeth_t * dep; 248 256 packet_t next; … … 271 279 } 272 280 273 int netif_start_message( device_refdevice){281 int netif_start_message(netif_device_t * device){ 274 282 ERROR_DECLARE; 275 283 … … 290 298 } 291 299 292 int netif_stop_message( device_refdevice){300 int netif_stop_message(netif_device_t * device){ 293 301 dpeth_t * dep; 294 302 … … 302 310 } 303 311 304 int change_state(device_ref device, device_state_t state)305 {306 if (device->state != state) {307 device->state = state;308 309 printf("%s: State changed to %s\n", NAME,310 (state == NETIF_ACTIVE) ? "active" : "stopped");311 312 return state;313 }314 315 return EOK;316 }317 318 312 int netif_initialize(void){ 319 313 ipcarg_t phonehash; … … 323 317 return REGISTER_ME(SERVICE_DP8390, &phonehash); 324 318 } 325 326 #ifdef CONFIG_NETWORKING_modular327 328 #include <netif_standalone.h>329 319 330 320 /** Default thread for new connections. … … 386 376 } 387 377 388 #endif /* CONFIG_NETWORKING_modular */389 390 391 378 /** @} 392 379 */
Note:
See TracChangeset
for help on using the changeset viewer.