Ignore:
Timestamp:
2010-04-23T21:42:26Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
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.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hw/netif/dp8390/dp8390_module.c

    r38aaacc2 rf4f866c  
    5050#include <net_device.h>
    5151#include <nil_interface.h>
    52 #include <netif.h>
    53 #include <netif_module.h>
     52#include <netif_interface.h>
     53#include <netif_local.h>
    5454
    5555#include "dp8390.h"
     
    5959/** DP8390 module name.
    6060 */
    61 #define NAME    "dp8390 network interface"
     61#define NAME  "dp8390"
    6262
    6363/** Returns the device from the interrupt call.
     
    9595};
    9696
    97 /** Network interface module global data.
    98  */
    99 netif_globals_t netif_globals;
    100 
    10197/** Handles the interrupt messages.
    10298 *  This is the interrupt handler callback function.
     
    104100 *  @param[in] call The interrupt message.
    105101 */
    106 void irq_handler(ipc_callid_t iid, ipc_call_t * call);
     102static 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}
    107136
    108137/** Changes the network interface state.
     
    111140 *  @returns The new state.
    112141 */
    113 int change_state(device_ref device, device_state_t state);
     142static 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}
    114155
    115156int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
     
    120161        ERROR_DECLARE;
    121162
    122         device_ref device;
     163        netif_device_t * device;
    123164        eth_stat_t * de_stat;
    124165
     
    147188        ERROR_DECLARE;
    148189
    149         device_ref device;
     190        netif_device_t * device;
    150191
    151192        if(! address){
     
    158199}
    159200
    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
    204202
    205203int netif_probe_message(device_id_t device_id, int irq, uintptr_t io){
    206204        ERROR_DECLARE;
    207205
    208         device_ref device;
    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));
    212210        if(! device){
    213211                return ENOMEM;
     
    218216                return ENOMEM;
    219217        }
    220         bzero(device, sizeof(device_t));
     218        bzero(device, sizeof(netif_device_t));
    221219        bzero(dep, sizeof(dpeth_t));
    222220        device->device_id = device_id;
     
    233231                return ERROR_CODE;
    234232        }
    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))){
    236234                free(dep);
    237235                free(device);
     
    244242        ERROR_DECLARE;
    245243
    246         device_ref device;
     244        netif_device_t * device;
    247245        dpeth_t * dep;
    248246        packet_t next;
     
    257255        do{
    258256                next = pq_detach(packet);
    259 //              remove debug dump:
    260 #ifdef CONFIG_DEBUG
    261                 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 #endif
    265257                if(do_pwrite(dep, packet, FALSE) != EBUSY){
    266258                        netif_pq_release(packet_get_id(packet));
     
    271263}
    272264
    273 int netif_start_message(device_ref device){
     265int netif_start_message(netif_device_t * device){
    274266        ERROR_DECLARE;
    275267
     
    290282}
    291283
    292 int netif_stop_message(device_ref device){
     284int netif_stop_message(netif_device_t * device){
    293285        dpeth_t * dep;
    294286
     
    302294}
    303295
    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 
    310296int netif_initialize(void){
    311297        ipcarg_t phonehash;
     
    315301        return REGISTER_ME(SERVICE_DP8390, &phonehash);
    316302}
    317 
    318 #ifdef CONFIG_NETWORKING_modular
    319 
    320 #include <netif_standalone.h>
    321303
    322304/** Default thread for new connections.
     
    346328               
    347329                /* 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);
    349332               
    350333                /* End if said to either by the message or the processing result */
     
    370353        ERROR_DECLARE;
    371354       
    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;
    374358       
    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}
    386361
    387362/** @}
Note: See TracChangeset for help on using the changeset viewer.