Changeset aadf01e in mainline for uspace/srv/net/netif


Ignore:
Timestamp:
2010-03-07T15:13:28Z (16 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
936835e
Parents:
aa85487
Message:

Coding style (no functional change)

Location:
uspace/srv/net/netif
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/netif/dp8390/dp8390.c

    raa85487 raadf01e  
    6767 *  @returns EINVAL
    6868 */
    69 int     queue_packet( dpeth_t * dep, packet_t packet );
     69int queue_packet(dpeth_t * dep, packet_t packet);
    7070
    7171/** Reads a memory block byte by byte.
     
    7474 *  @param[in] size The memory block size in bytes.
    7575 */
    76 static void outsb( port_t port, void * buf, size_t size );
     76static void outsb(port_t port, void * buf, size_t size);
    7777
    7878/** Reads a memory block word by word.
     
    8181 *  @param[in] size The memory block size in bytes.
    8282 */
    83 static void outsw( port_t port, void * buf, size_t size );
     83static void outsw(port_t port, void * buf, size_t size);
    8484
    8585//static u16_t eth_ign_proto;
     
    9898//{
    9999        /* 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"     },
    103103};
    104104*/
     
    126126
    127127//#if ENABLE_PCI
    128 //_PROTOTYPE( static void pci_conf, (void)                              );
     128//_PROTOTYPE(static void pci_conf, (void)                               );
    129129//#endif
    130 //_PROTOTYPE( static void do_vwrite, (message *mp, int from_int,
     130//_PROTOTYPE(static void do_vwrite, (message *mp, int from_int,
    131131//                                                      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,
    150150                                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,
    152152                                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,
    154154                                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,
    158158//                                                      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,
    162162//              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,
    164164                                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,
    167167//                              iovec_dat_s_t *iovp, vir_bytes offset,
    168168//                              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,
    170170                                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,
    173173//                              iovec_dat_s_t *iovp, vir_bytes offset,
    174174//                              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,
    176176                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,
    178178//              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,
    180180                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,
    182182//              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,
    184184                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,
    186186//              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,
    197197                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,
    199199//              cp_grant_id_t grant, vir_bytes offset, vir_bytes count,
    200200//              void *loc_addr) );
    201 //_PROTOTYPE( static void put_userdata, (int user_proc,
     201//_PROTOTYPE(static void put_userdata, (int user_proc,
    202202//              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,
    204204//              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,
    208208//                                      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,
    210210//                                      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,
    212212//                                      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,
    214214//                                      vir_bytes buf, size_t size)     );
    215215
    216 int do_probe( dpeth_t * dep ){
     216int do_probe(dpeth_t * dep){
    217217        /* This is the default, try to (re)locate the device. */
    218218        conf_hw(dep);
     
    230230 *                              dp8390_dump                                  *
    231231 *===========================================================================*/
    232 void dp8390_dump( dpeth_t * dep )
     232void dp8390_dump(dpeth_t * dep)
    233233{
    234234//      dpeth_t *dep;
     
    282282 *                              do_init                                      *
    283283 *===========================================================================*/
    284 int do_init( dpeth_t * dep, int mode ){
     284int do_init(dpeth_t * dep, int mode){
    285285        if (dep->de_mode == DEM_DISABLED)
    286286        {
     
    303303        }
    304304        assert(dep->de_mode == DEM_ENABLED);
    305         assert(dep->de_flags & DEF_ENABLED);
     305        assert(dep->de_flags &DEF_ENABLED);
    306306
    307307        dep->de_flags &= ~(DEF_PROMISC | DEF_MULTI | DEF_BROAD);
    308308
    309         if (mode & DL_PROMISC_REQ)
     309        if (mode &DL_PROMISC_REQ)
    310310                dep->de_flags |= DEF_PROMISC | DEF_MULTI | DEF_BROAD;
    311         if (mode & DL_MULTI_REQ)
     311        if (mode &DL_MULTI_REQ)
    312312                dep->de_flags |= DEF_MULTI;
    313         if (mode & DL_BROAD_REQ)
     313        if (mode &DL_BROAD_REQ)
    314314                dep->de_flags |= DEF_BROAD;
    315315
     
    329329 *                              do_stop                                      *
    330330 *===========================================================================*/
    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 );
     331void 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);
    335335
    336336                dep->de_flags = DEF_EMPTY;
     
    338338}
    339339
    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 ));
     340int 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));
    345345                return ELIMIT;
    346346        }
    347347
    348348        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){
    353353                return EINVAL;
    354354        }
    355         if( ! dep->packet_count ){
     355        if(! dep->packet_count){
    356356                dep->packet_queue = packet;
    357357        }
     
    363363 *                      based on        do_vwrite                                    *
    364364 *===========================================================================*/
    365 int do_pwrite( dpeth_t * dep, packet_t packet, int from_int )
     365int do_pwrite(dpeth_t * dep, packet_t packet, int from_int)
    366366{
    367367//      int port, count, size;
     
    386386        }
    387387        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){
    391391//              panic("", "dp8390: send already in progress", NO_NUM);
    392                 return queue_packet( dep, packet );
     392                return queue_packet(dep, packet);
    393393        }
    394394
     
    402402//              reply(dep, OK, FALSE);
    403403//              return;
    404 //              return queue_packet( dep, packet );
     404//              return queue_packet(dep, packet);
    405405//      }
    406 //      assert(!(dep->de_flags & DEF_PACK_SEND));
     406//      assert(!(dep->de_flags &DEF_PACK_SEND));
    407407
    408408/*      if (vectored)
     
    419419        }
    420420        else
    421         {  
     421        {
    422422                dep->de_write_iovec.iod_iovec[0].iov_addr =
    423423                        (vir_bytes) mp->DL_ADDR;
     
    430430        }
    431431*/
    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);
    434434        dep->de_write_iovec.iod_iovec[0].iov_size = size;
    435435        dep->de_write_iovec.iod_iovec_s = 1;
     
    449449                outb_reg0(dep, DP_TPSR, dep->de_sendq[sendq_head].sq_sendpage);
    450450                outb_reg0(dep, DP_TBCR1, size >> 8);
    451                 outb_reg0(dep, DP_TBCR0, size & 0xff);
     451                outb_reg0(dep, DP_TBCR0, size &0xff);
    452452                outb_reg0(dep, DP_CR, CR_TXP | CR_EXTRA);/* there it goes.. */
    453453        }
     
    470470
    471471        assert(dep->de_mode == DEM_ENABLED);
    472         assert(dep->de_flags & DEF_ENABLED);
     472        assert(dep->de_flags &DEF_ENABLED);
    473473        return EOK;
    474474}
     
    516516        /* Step 4: */
    517517        dp_rcr_reg = 0;
    518         if (dep->de_flags & DEF_PROMISC)
     518        if (dep->de_flags &DEF_PROMISC)
    519519                dp_rcr_reg |= RCR_AB | RCR_PRO | RCR_AM;
    520         if (dep->de_flags & DEF_BROAD)
     520        if (dep->de_flags &DEF_BROAD)
    521521                dp_rcr_reg |= RCR_AB;
    522         if (dep->de_flags & DEF_MULTI)
     522        if (dep->de_flags &DEF_MULTI)
    523523                dp_rcr_reg |= RCR_AM;
    524524        outb_reg0(dep, DP_RCR, dp_rcr_reg);
     
    621621
    622622        dp_rcr_reg = 0;
    623         if (dep->de_flags & DEF_PROMISC)
     623        if (dep->de_flags &DEF_PROMISC)
    624624                dp_rcr_reg |= RCR_AB | RCR_PRO | RCR_AM;
    625         if (dep->de_flags & DEF_BROAD)
     625        if (dep->de_flags &DEF_BROAD)
    626626                dp_rcr_reg |= RCR_AB;
    627         if (dep->de_flags & DEF_MULTI)
     627        if (dep->de_flags &DEF_MULTI)
    628628                dp_rcr_reg |= RCR_AM;
    629629        outb_reg0(dep, DP_RCR, dp_rcr_reg);
     
    642642        outb_reg0(dep, DP_RBCR0, 0);
    643643        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++)
    645645                ; /* Do nothing */
    646646        outb_reg0(dep, DP_TCR, TCR_1EXTERNAL|TCR_OFST);
     
    649649
    650650        /* 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++)
    652652                ; /* 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);
    654654
    655655        /* Reset the transmit ring. If we were transmitting a packet, we
     
    674674        int size, sendq_tail;
    675675
    676         if (!(dep->de_flags & DEF_ENABLED))
     676        if (!(dep->de_flags &DEF_ENABLED))
    677677                panic("", "dp8390: got premature interrupt", NO_NUM);
    678678
     
    683683                        break;
    684684                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)
    688688                        {
    689689#if DEBUG
    690  { printf("%s: got send Error\n", dep->de_name); }
     690 {printf("%s: got send Error\n", dep->de_name);}
    691691#endif
    692692                                dep->de_stat.ets_sendErr++;
     
    696696                                tsr = inb_reg0(dep, DP_TSR);
    697697
    698                                 if (tsr & TSR_PTX) dep->de_stat.ets_packetT++;
     698                                if (tsr &TSR_PTX) dep->de_stat.ets_packetT++;
    699699#if 0   /* Reserved in later manuals, should be ignored */
    700                                 if (!(tsr & TSR_DFR))
     700                                if (!(tsr &TSR_DFR))
    701701                                {
    702702                                        /* In most (all?) implementations of
     
    707707                                }
    708708#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_FU
     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_FU
    713713                                        && ++dep->de_stat.ets_fifoUnder <= 10)
    714714                                {
     
    716716                                                dep->de_name);
    717717                                }
    718                                 if (tsr & TSR_CDH
     718                                if (tsr &TSR_CDH
    719719                                        && ++dep->de_stat.ets_CDheartbeat <= 10)
    720720                                {
     
    722722                                                dep->de_name);
    723723                                }
    724                                 if (tsr & TSR_OWC) dep->de_stat.ets_OWC++;
     724                                if (tsr &TSR_OWC) dep->de_stat.ets_OWC++;
    725725                        }
    726726                        sendq_tail= dep->de_sendq_tail;
     
    747747                                        dep->de_sendq[sendq_tail].sq_sendpage);
    748748                                outb_reg0(dep, DP_TBCR1, size >> 8);
    749                                 outb_reg0(dep, DP_TBCR0, size & 0xff);
     749                                outb_reg0(dep, DP_TBCR0, size &0xff);
    750750                                outb_reg0(dep, DP_CR, CR_TXP | CR_EXTRA);
    751751                        }
    752 //                      if (dep->de_flags & DEF_SEND_AVAIL)
     752//                      if (dep->de_flags &DEF_SEND_AVAIL)
    753753                                dp_send(dep);
    754754                }
    755755
    756                 if (isr & ISR_PRX)
     756                if (isr &ISR_PRX)
    757757                {
    758758                        /* Only call dp_recv if there is a read request */
    759 //                      if (dep->de_flags) & DEF_READING)
     759//                      if (dep->de_flags) &DEF_READING)
    760760                                dp_recv(dep);
    761761                }
    762762               
    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)
    765765                {
    766766                        dep->de_stat.ets_CRCerr += inb_reg0(dep, DP_CNTR0);
     
    768768                        dep->de_stat.ets_missedP += inb_reg0(dep, DP_CNTR2);
    769769                }
    770                 if (isr & ISR_OVW)
     770                if (isr &ISR_OVW)
    771771                {
    772772                        dep->de_stat.ets_OVW++;
    773773#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);}
    776776#endif
    777 /*                      if (dep->de_flags & DEF_READING)
     777/*                      if (dep->de_flags &DEF_READING)
    778778                        {
    779779                                printf(
     
    782782                        }
    783783*/              }
    784                 if (isr & ISR_RDC)
     784                if (isr &ISR_RDC)
    785785                {
    786786                        /* Nothing to do */
    787787                }
    788                 if (isr & ISR_RST)
     788                if (isr &ISR_RST)
    789789                {
    790790                        /* this means we got an interrupt but the ethernet
     
    794794                         */
    795795#if 0
    796                          { printW(); printf(
    797                                 "%s: NIC stopped\n", dep->de_name); }
     796                         {printW(); printf(
     797                                "%s: NIC stopped\n", dep->de_name);}
    798798#endif
    799799                        dep->de_flags |= DEF_STOPPED;
     
    802802                isr = inb_reg0(dep, DP_ISR);
    803803        }
    804 //      if ((dep->de_flags & (DEF_READING|DEF_STOPPED)) ==
     804//      if ((dep->de_flags &(DEF_READING|DEF_STOPPED)) ==
    805805//                                              (DEF_READING|DEF_STOPPED))
    806         if ((dep->de_flags & DEF_STOPPED) == DEF_STOPPED )
     806        if ((dep->de_flags &DEF_STOPPED) == DEF_STOPPED)
    807807        {
    808808                /* The chip is stopped, and all arrived packets are
     
    874874                        dep->de_stat.ets_packetR++;
    875875                }
    876 */              else if (header.dr_status & RSR_FO)
     876*/              else if (header.dr_status &RSR_FO)
    877877                {
    878878                        /* This is very serious, so we issue a warning and
     
    883883                        next = curr;
    884884                }
    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))
    887887                {
    888888//                      if (dep->de_safecopy_read)
     
    914914        packet_t packet;
    915915
    916 //      if (!(dep->de_flags & DEF_SEND_AVAIL))
     916//      if (!(dep->de_flags &DEF_SEND_AVAIL))
    917917//              return;
    918918
    919         if( dep->packet_queue ){
     919        if(dep->packet_queue){
    920920                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));
    924924                -- dep->packet_count;
    925925        }
    926 //      if( ! dep->packet_queue ){
     926//      if(! dep->packet_queue){
    927927//              dep->de_flags &= ~DEF_SEND_AVAIL;
    928928//      }
     
    967967{
    968968        offset = page * DP_PAGESIZE + offset;
    969         outb_reg0(dep, DP_RBCR0, size & 0xFF);
     969        outb_reg0(dep, DP_RBCR0, size &0xFF);
    970970        outb_reg0(dep, DP_RBCR1, size >> 8);
    971         outb_reg0(dep, DP_RSAR0, offset & 0xFF);
     971        outb_reg0(dep, DP_RSAR0, offset &0xFF);
    972972        outb_reg0(dep, DP_RSAR1, offset >> 8);
    973973        outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA);
     
    987987{
    988988        offset = page * DP_PAGESIZE + offset;
    989         outb_reg0(dep, DP_RBCR0, size & 0xFF);
     989        outb_reg0(dep, DP_RBCR0, size &0xFF);
    990990        outb_reg0(dep, DP_RBCR1, size >> 8);
    991         outb_reg0(dep, DP_RSAR0, offset & 0xFF);
     991        outb_reg0(dep, DP_RSAR0, offset &0xFF);
    992992        outb_reg0(dep, DP_RSAR1, offset >> 8);
    993993        outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA);
    994994
    995         assert (!(size & 1));
     995        assert (!(size &1));
    996996        insw(dep->de_data_port, dst, size);
    997997}
     
    10051005{
    10061006        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))
    10101010//              return EGENERIC;
    10111011
    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);
    10151017        dep->de_read_iovec.iod_iovec[0].iov_size = length;
    10161018        dep->de_read_iovec.iod_iovec_s = 1;
     
    10281030                        sizeof(dp_rcvhdr_t), &dep->de_tmp_iovec, 0, count);
    10291031                (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);
    10311033        }
    10321034        else
     
    10401042//      dep->de_flags &= ~DEF_READING;
    10411043
    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));
    10441046                return ELIMIT;
    10451047        }else{
    1046                 if( pq_add( & dep->received_queue, packet, 0, 0 ) == EOK ){
     1048                if(pq_add(&dep->received_queue, packet, 0, 0) == EOK){
    10471049                        ++ dep->received_count;
    10481050                }else{
    1049                         netif_pq_release( packet_get_id( packet ));
     1051                        netif_pq_release(packet_get_id(packet));
    10501052                }
    10511053        }
     
    11191121        outb_reg0(dep, DP_ISR, ISR_RDC);
    11201122
    1121         outb_reg0(dep, DP_RBCR0, count & 0xFF);
     1123        outb_reg0(dep, DP_RBCR0, count &0xFF);
    11221124        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);
    11241126        outb_reg0(dep, DP_RSAR1, nic_addr >> 8);
    11251127        outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA);
     
    11541156        for (i= 0; i<100; i++)
    11551157        {
    1156                 if (inb_reg0(dep, DP_ISR) & ISR_RDC)
     1158                if (inb_reg0(dep, DP_ISR) &ISR_RDC)
    11571159                        break;
    11581160        }
     
    11811183        int odd_byte;
    11821184
    1183         ecount= (count+1) & ~1;
     1185        ecount= (count+1) &~1;
    11841186        odd_byte= 0;
    11851187
    11861188        outb_reg0(dep, DP_ISR, ISR_RDC);
    1187         outb_reg0(dep, DP_RBCR0, ecount & 0xFF);
     1189        outb_reg0(dep, DP_RBCR0, ecount &0xFF);
    11881190        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);
    11901192        outb_reg0(dep, DP_RSAR1, nic_addr >> 8);
    11911193        outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA);
     
    12341236                                continue;
    12351237                }
    1236                 ecount= bytes & ~1;
     1238                ecount= bytes &~1;
    12371239                if (ecount != 0)
    12381240                {
     
    12711273        for (i= 0; i<100; i++)
    12721274        {
    1273                 if (inb_reg0(dep, DP_ISR) & ISR_RDC)
     1275                if (inb_reg0(dep, DP_ISR) &ISR_RDC)
    12741276                        break;
    12751277        }
     
    13431345        vir_bytes bytes;
    13441346
    1345         outb_reg0(dep, DP_RBCR0, count & 0xFF);
     1347        outb_reg0(dep, DP_RBCR0, count &0xFF);
    13461348        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);
    13481350        outb_reg0(dep, DP_RSAR1, nic_addr >> 8);
    13491351        outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA);
     
    13951397        int odd_byte;
    13961398
    1397         ecount= (count+1) & ~1;
     1399        ecount= (count+1) &~1;
    13981400        odd_byte= 0;
    13991401
    1400         outb_reg0(dep, DP_RBCR0, ecount & 0xFF);
     1402        outb_reg0(dep, DP_RBCR0, ecount &0xFF);
    14011403        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);
    14031405        outb_reg0(dep, DP_RSAR1, nic_addr >> 8);
    14041406        outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA);
     
    14451447                                continue;
    14461448                }
    1447                 ecount= bytes & ~1;
     1449                ecount= bytes &~1;
    14481450                if (ecount != 0)
    14491451                {
     
    15021504dpeth_t *dep;
    15031505{
    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        /* ,... */};
    15051507
    15061508//      int ifnr;
     
    15511553                return;
    15521554        }else{
    1553                 printf( "map_hw_buffer: no buffer!\n" );
     1555                printf("map_hw_buffer: no buffer!\n");
    15541556        }
    15551557
     
    15841586
    15851587        status = 0;
    1586         if (dep->de_flags & DEF_PACK_SEND)
     1588        if (dep->de_flags &DEF_PACK_SEND)
    15871589                status |= DL_PACK_SEND;
    1588         if (dep->de_flags & DEF_PACK_RECV)
     1590        if (dep->de_flags &DEF_PACK_RECV)
    15891591                status |= DL_PACK_RECV;
    15901592
     
    16331635        size_t i;
    16341636
    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);
    16371639        }
    16381640}
     
    16421644        size_t i;
    16431645
    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);
    16461648        }
    16471649}
     
    16511653        size_t i;
    16521654
    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));
    16551657        }
    16561658}
     
    16601662        size_t i;
    16611663
    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));
    16641666        }
    16651667}
  • uspace/srv/net/netif/dp8390/dp8390.h

    raa85487 raadf01e  
    255255struct iovec_dat;
    256256//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,
    260260                        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,
    263263//                      struct iovec_dat_s *iovp, vir_bytes offset,
    264264//                      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,
    266266                        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,
    269269//                      int nic_addr, struct iovec_dat_s *iovp,
    270270//                      vir_bytes offset, vir_bytes count)              );
    271271//#if 0
    272 //_PROTOTYPE( typedef void (*dp_getheaderf_t), (struct dpeth *dep,
     272//_PROTOTYPE(typedef void (*dp_getheaderf_t), (struct dpeth *dep,
    273273//                      int page, struct dp_rcvhdr *h, u16_t *eth_type) );
    274274//#endif
    275 _PROTOTYPE( typedef void (*dp_getblock_t), (struct dpeth *dep,
     275_PROTOTYPE(typedef void (*dp_getblock_t), (struct dpeth *dep,
    276276                int page, size_t offset, size_t size, void *dst)        );
    277277
     
    313313        /** Outgoing packets queue.
    314314         */
    315         packet_t        packet_queue;
     315        packet_t packet_queue;
    316316        /** Outgoing packets count.
    317317         */
    318         int                     packet_count;
     318        int packet_count;
    319319
    320320        /** Received packets queue.
    321321         */
    322         packet_t        received_queue;
     322        packet_t received_queue;
    323323        /** Received packets count.
    324324         */
    325         int                     received_count;
     325        int received_count;
    326326
    327327        /* The de_base_port field is the starting point of the probe.
  • uspace/srv/net/netif/dp8390/dp8390_drv.h

    raa85487 raadf01e  
    6464 *  @returns EXDEV if the network interface was not recognized.
    6565 */
    66 int     do_probe( dpeth_t * dep );
     66int do_probe(dpeth_t * dep);
    6767
    6868/** Sends a packet.
     
    7272 *  @returns
    7373 */
    74 int     do_pwrite( dpeth_t * dep, packet_t packet, int from_int );
     74int do_pwrite(dpeth_t * dep, packet_t packet, int from_int);
    7575
    7676/** Prints out network interface information.
    7777 *  @param[in] dep The network interface structure.
    7878 */
    79 void    dp8390_dump( dpeth_t * dep );
     79void dp8390_dump(dpeth_t * dep);
    8080
    8181#endif
  • uspace/srv/net/netif/dp8390/dp8390_module.c

    raa85487 raadf01e  
    6868 *  @param[in] call The interrupt call.
    6969 */
    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)
    7171
    7272/** Returns the interrupt status register from the interrupt call.
    7373 *  @param[in] call The interrupt call.
    7474 */
    75 #define IPC_GET_ISR( call )                             ( int ) IPC_GET_ARG2( * call )
     75#define IPC_GET_ISR(call)                               (int) IPC_GET_ARG2(*call)
    7676
    7777/** DP8390 kernel interrupt command sequence.
    7878 */
    7979static irq_cmd_t        dp8390_cmds[] = {
    80         {       .cmd = CMD_PIO_READ_8,
     80        {       .cmd = CMD_PIO_READ_8,
    8181                .addr = NULL,
    8282                .dstarg = 2
     
    9595 */
    9696static irq_code_t       dp8390_code = {
    97         sizeof( dp8390_cmds ) / sizeof( irq_cmd_t ),
     97        sizeof(dp8390_cmds) / sizeof(irq_cmd_t),
    9898        dp8390_cmds
    9999};
     
    106106 *  @see NAME
    107107 */
    108 void    module_print_name( void );
     108void module_print_name(void);
    109109
    110110/** Handles the interrupt messages.
     
    113113 *  @param[in] call The interrupt message.
    114114 */
    115 void    irq_handler( ipc_callid_t iid, ipc_call_t * call );
     115void irq_handler(ipc_callid_t iid, ipc_call_t * call);
    116116
    117117/** Changes the network interface state.
     
    120120 *  @returns The new state.
    121121 */
    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 ){
     122int change_state(device_ref device, device_state_t state);
     123
     124int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
    125125        return ENOTSUP;
    126126}
    127127
    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 );
     128int 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);
    138140        stats->receive_errors = de_stat->ets_recvErr;
    139141        stats->send_errors = de_stat->ets_sendErr;
     
    151153}
    152154
    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 )
     155void module_print_name(void){
     156        printf("%s", NAME);
     157}
     158
     159int 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
     173void irq_handler(ipc_callid_t iid, ipc_call_t * call)
    170174{
    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);
    181185                return;
    182186        }
    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);
    186190                return;
    187191        }
    188         assert( dep->de_flags & DEF_ENABLED);
     192        assert(dep->de_flags &DEF_ENABLED);
    189193        dep->de_int_pending = 0;
    190194//      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){
    194198                received = dep->received_queue;
    195199                phone = device->nil_phone;
    196200                dep->received_queue = NULL;
    197201                dep->received_count = 0;
    198                 fibril_rwlock_write_unlock( & netif_globals.lock );
     202                fibril_rwlock_write_unlock(&netif_globals.lock);
    199203//      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);
    204208        }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
     214int 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){
    221222                return ENOMEM;
    222223        }
    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));
    225231        device->device_id = device_id;
    226232        device->nil_phone = -1;
    227         device->specific = ( void * ) dep;
     233        device->specific = (void *) dep;
    228234        device->state = NETIF_STOPPED;
    229235        dep->de_irq = irq;
    230236        dep->de_mode = DEM_DISABLED;
    231237        //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);
    236242                return ERROR_CODE;
    237243        }
    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);
    241247                return ERROR_CODE;
    242248        }
     
    244250}
    245251
    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 ));
     252int 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));
    256262                return EFORWARD;
    257263        }
    258         dep = ( dpeth_t * ) device->specific;
     264        dep = (dpeth_t *) device->specific;
    259265        // process packet queue
    260266        do{
    261                 next = pq_detach( packet );
     267                next = pq_detach(packet);
    262268//              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));
    269275                }
    270276                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
     281int 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);
    287293                        return ERROR_CODE;
    288294                }
    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
     300int 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
     312int change_state(device_ref device, device_state_t state){
    307313        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");
    309315        return state;
    310316}
    311317
    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 );
     318int netif_initialize(void){
     319        ipcarg_t phonehash;
     320
     321        async_set_interrupt_received(irq_handler);
     322
     323        return REGISTER_ME(SERVICE_DP8390, &phonehash);
    318324}
    319325
  • uspace/srv/net/netif/dp8390/dp8390_port.h

    raa85487 raadf01e  
    4848 *  @param[in] params The function parameters definition.
    4949 */
    50 #define _PROTOTYPE( function, params ) function params
     50#define _PROTOTYPE(function, params) function params
    5151
    5252/** Success error code.
     
    7070 *  @returns 1 if the second is greater than the first.
    7171 */
    72 #define memcmp( first, second, size )   bcmp(( char * ) ( first ), ( char * ) ( second ), ( size ))
     72#define memcmp(first, second, size)     bcmp((char *) (first), (char *) (second), (size))
    7373
    7474/** Reads 1 byte.
     
    7676 *  @returns The read value.
    7777 */
    78 #define inb( port )     pio_read_8(( ioport8_t * ) ( port ))
     78#define inb(port)       pio_read_8((ioport8_t *) (port))
    7979
    8080/** Reads 1 word (2 bytes).
     
    8282 *  @returns The read value.
    8383 */
    84 #define inw( port )     pio_read_16(( ioport16_t * ) ( port ))
     84#define inw(port)       pio_read_16((ioport16_t *) (port))
    8585
    8686/** Writes 1 byte.
     
    8888 *  @param[in] value The value to be written.
    8989 */
    90 #define outb( port, value )     pio_write_8(( ioport8_t * ) ( port ), ( value ))
     90#define outb(port, value)       pio_write_8((ioport8_t *) (port), (value))
    9191
    9292/** Writes 1 word (2 bytes).
     
    9494 *  @param[in] value The value to be written.
    9595 */
    96 #define outw( port, value )     pio_write_16(( ioport16_t * ) ( port ), ( value ))
     96#define outw(port, value)       pio_write_16((ioport16_t *) (port), (value))
    9797
    9898/** Prints out the driver critical error.
    9999 *  Does not call the system panic().
    100100 */
    101 #define panic( ... )    printf( "%s%s%d", __VA_ARGS__ )
     101#define panic(...)      printf("%s%s%d", __VA_ARGS__)
    102102
    103103/** Copies a memory block.
     
    111111 *  @returns EOK.
    112112 */
    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;})
    114114
    115115/** Reads a memory block byte by byte.
     
    119119 *  @param[in] bytes The block size in bytes.
    120120 */
    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))
    122122
    123123/** Reads a memory block word by word (2 bytes).
     
    127127 *  @param[in] bytes The block size in bytes.
    128128 */
    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))
    130130
    131131/** Writes a memory block byte by byte.
     
    135135 *  @param[in] bytes The block size in bytes.
    136136 */
    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))
    138138
    139139/** Writes a memory block word by word (2 bytes).
     
    143143 *  @param[in] bytes The block size in bytes.
    144144 */
    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))
    146146
    147147/* com.h */
  • uspace/srv/net/netif/dp8390/local.h

    raa85487 raadf01e  
    6666 *  @returns 0 otherwise.
    6767 */
    68 //_PROTOTYPE( int el2_probe, (struct dpeth* dep)                                );
     68//_PROTOTYPE(int el2_probe, (struct dpeth*dep)                          );
    6969
    7070/* ne2000.c */
     
    7474 *  @returns 0 otherwise.
    7575 */
    76 int     ne_probe( struct dpeth * dep );
    77 //_PROTOTYPE( int ne_probe, (struct dpeth *dep)                         );
    78 //_PROTOTYPE( void ne_init, (struct dpeth *dep)                         );
     76int ne_probe(struct dpeth * dep);
     77//_PROTOTYPE(int ne_probe, (struct dpeth *dep)                          );
     78//_PROTOTYPE(void ne_init, (struct dpeth *dep)                          );
    7979
    8080/* rtl8029.c */
     
    8484 *  @returns 0 otherwise.
    8585 */
    86 //_PROTOTYPE( int rtl_probe, (struct dpeth *dep)                                );
     86//_PROTOTYPE(int rtl_probe, (struct dpeth *dep)                         );
    8787
    8888/* wdeth.c */
     
    9292 *  @returns 0 otherwise.
    9393 */
    94 //_PROTOTYPE( int wdeth_probe, (struct dpeth* dep)                              );
     94//_PROTOTYPE(int wdeth_probe, (struct dpeth*dep)                                );
    9595
    9696#endif
  • uspace/srv/net/netif/dp8390/ne2000.c

    raa85487 raadf01e  
    7070 *  @param[in] millis The number of milliseconds to sleep.
    7171 */
    72 #define milli_delay( millis )   usleep(( millis ) * 1000 )
     72#define milli_delay(millis)     usleep((millis) * 1000)
    7373
    7474/** Type definition of the testing function.
    7575 */
    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)   );
    7777
    7878/** First data pattern.
    7979 */
    80 u8_t    pat0[]= { 0x00, 0x00, 0x00, 0x00 };
     80u8_t    pat0[]= {0x00, 0x00, 0x00, 0x00};
    8181
    8282/** Second data pattern.
    8383 */
    84 u8_t    pat1[]= { 0xFF, 0xFF, 0xFF, 0xFF };
     84u8_t    pat1[]= {0xFF, 0xFF, 0xFF, 0xFF};
    8585
    8686/** Third data pattern.
    8787 */
    88 u8_t    pat2[]= { 0xA5, 0x5A, 0x69, 0x96 };
     88u8_t    pat2[]= {0xA5, 0x5A, 0x69, 0x96};
    8989
    9090/** Fourth data pattern.
    9191 */
    92 u8_t    pat3[]= { 0x96, 0x69, 0x5A, 0xA5 };
     92u8_t    pat3[]= {0x96, 0x69, 0x5A, 0xA5};
    9393
    9494/** Tests 8 bit NE2000 network interface.
     
    114114 */
    115115static void ne_stop(dpeth_t *dep);
    116 //_PROTOTYPE( static void milli_delay, (unsigned long millis)           );
     116//_PROTOTYPE(static void milli_delay, (unsigned long millis)            );
    117117
    118118/** Initializes the NE2000 network interface.
     
    150150                /* Reset the dp8390 */
    151151                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++)
    153153                        ; /* Do nothing */
    154154
    155155                /* 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)) !=
    157157                        (CR_STP|CR_DM_ABORT))
    158158                {
     
    186186                        f= test_8;
    187187                }
    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) && 
    191191                        f(dep, loc2, pat2) && f(dep, loc2, pat3))
    192192                {
     
    297297        outb_reg0(dep, DP_RBCR0, 4);
    298298        outb_reg0(dep, DP_RBCR1, 0);
    299         outb_reg0(dep, DP_RSAR0, pos & 0xFF);
     299        outb_reg0(dep, DP_RSAR0, pos &0xFF);
    300300        outb_reg0(dep, DP_RSAR1, pos >> 8);
    301301        outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA);
     
    306306        for (i= 0; i<N; i++)
    307307        {
    308                 if (inb_reg0(dep, DP_ISR) & ISR_RDC)
     308                if (inb_reg0(dep, DP_ISR) &ISR_RDC)
    309309                        break;
    310310        }
     
    321321        outb_reg0(dep, DP_RBCR0, 4);
    322322        outb_reg0(dep, DP_RBCR1, 0);
    323         outb_reg0(dep, DP_RSAR0, pos & 0xFF);
     323        outb_reg0(dep, DP_RSAR0, pos &0xFF);
    324324        outb_reg0(dep, DP_RSAR1, pos >> 8);
    325325        outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA);
     
    349349        outb_reg0(dep, DP_RBCR0, 4);
    350350        outb_reg0(dep, DP_RBCR1, 0);
    351         outb_reg0(dep, DP_RSAR0, pos & 0xFF);
     351        outb_reg0(dep, DP_RSAR0, pos &0xFF);
    352352        outb_reg0(dep, DP_RSAR1, pos >> 8);
    353353        outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA);
     
    360360        for (i= 0; i<N; i++)
    361361        {
    362                 if (inb_reg0(dep, DP_ISR) & ISR_RDC)
     362                if (inb_reg0(dep, DP_ISR) &ISR_RDC)
    363363                        break;
    364364        }
     
    375375        outb_reg0(dep, DP_RBCR0, 4);
    376376        outb_reg0(dep, DP_RBCR1, 0);
    377         outb_reg0(dep, DP_RSAR0, pos & 0xFF);
     377        outb_reg0(dep, DP_RSAR0, pos &0xFF);
    378378        outb_reg0(dep, DP_RSAR1, pos >> 8);
    379379        outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA);
  • uspace/srv/net/netif/lo/lo.c

    raa85487 raadf01e  
    6464/** Default address length.
    6565 */
    66 #define DEFAULT_ADDR_LEN        ( sizeof( DEFAULT_ADDR ) / sizeof( char ))
     66#define DEFAULT_ADDR_LEN        (sizeof(DEFAULT_ADDR) / sizeof(char))
    6767
    6868/** Loopback module name.
     
    8080 *  @returns EOK otherwise.
    8181 */
    82 int     change_state_message( device_ref device, device_state_t state );
     82int change_state_message(device_ref device, device_state_t state);
    8383
    8484/** Creates and returns the loopback network interface structure.
     
    8989 *  @returns ENOMEM if there is not enough memory left.
    9090 */
    91 int     create( device_id_t device_id, device_ref * device );
     91int create(device_id_t device_id, device_ref * device);
    9292
    9393/** Prints the module name.
    9494 *  @see NAME
    9595 */
    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 ){
     96void module_print_name(void);
     97
     98int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
    9999        return ENOTSUP;
    100100}
    101101
    102 int netif_get_addr_message( device_id_t device_id, measured_string_ref address ){
    103         if( ! address ) return EBADMEM;
     102int netif_get_addr_message(device_id_t device_id, measured_string_ref address){
     103        if(! address){
     104                return EBADMEM;
     105        }
    104106        address->value = str_dup(DEFAULT_ADDR);
    105107        address->length = DEFAULT_ADDR_LEN;
     
    107109}
    108110
    109 int netif_get_device_stats( device_id_t device_id, device_stats_ref stats ){
     111int netif_get_device_stats(device_id_t device_id, device_stats_ref stats){
    110112        ERROR_DECLARE;
    111113
    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
     124int change_state_message(device_ref device, device_state_t state){
     125        if(device->state != state){
    122126                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");
    124128                return state;
    125129        }
     
    127131}
    128132
    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 ){
     133int create(device_id_t device_id, device_ref * device){
     134        int index;
     135
     136        if(device_map_count(&netif_globals.device_map) > 0){
    133137                return EXDEV;
    134138        }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)){
    140141                        return ENOMEM;
    141142                }
    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;
    151157                        return index;
    152158                }
     
    155161}
    156162
    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 ){
     163int netif_initialize(void){
     164        ipcarg_t phonehash;
     165
     166        return REGISTER_ME(SERVICE_LO, &phonehash);
     167}
     168
     169void module_print_name(void){
     170        printf("%s", NAME);
     171}
     172
     173int netif_probe_message(device_id_t device_id, int irq, uintptr_t io){
    168174        ERROR_DECLARE;
    169175
    170         device_ref                      device;
     176        device_ref device;
    171177
    172178        // create a new device
    173         ERROR_PROPAGATE( create( device_id, & device ));
     179        ERROR_PROPAGATE(create(device_id, &device));
    174180        // 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
     185int netif_send_message(device_id_t device_id, packet_t packet, services_t sender){
    180186        ERROR_DECLARE;
    181187
    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));
    190196                return EFORWARD;
    191197        }
    192198        next = packet;
    193199        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);
    201207        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
     214int netif_start_message(device_ref device){
     215        return change_state_message(device, NETIF_ACTIVE);
     216}
     217
     218int netif_stop_message(device_ref device){
     219        return change_state_message(device, NETIF_STOPPED);
    214220}
    215221
  • uspace/srv/net/netif/netif.c

    raa85487 raadf01e  
    6464extern netif_globals_t netif_globals;
    6565
    66 DEVICE_MAP_IMPLEMENT( device_map, device_t )
     66DEVICE_MAP_IMPLEMENT(device_map, device_t)
    6767
    6868/** @name Message processing functions
     
    7777 *  @returns ELIMIT if there is another module registered.
    7878 */
    79 int     register_message( device_id_t device_id, int phone );
     79int register_message(device_id_t device_id, int phone);
    8080
    8181/*@}*/
    8282
    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 );
     83int 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
     92int 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
     101int 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);
    111111                return ERROR_CODE;
    112112        }
    113         result = netif_start_message( device );
    114         if( result > NETIF_NULL ){
     113        result = netif_start_message(device);
     114        if(result > NETIF_NULL){
    115115                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);
    118118                return EOK;
    119119        }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
     125int 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);
    135135                return ERROR_CODE;
    136136        }
    137         result = netif_stop_message( device );
    138         if( result > NETIF_NULL ){
     137        result = netif_stop_message(device);
     138        if(result > NETIF_NULL){
    139139                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);
    142142                return EOK;
    143143        }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
     149int netif_stats_req(int netif_phone, device_id_t device_id, device_stats_ref stats){
    150150        int res;
    151151
    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);
    155155        return res;
    156156}
    157157
    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;
     158int 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;
    171173        return ERROR_CODE;
    172174}
    173175
    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;
     176int netif_bind_service(services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver){
     177        return EOK;
     178}
     179
     180int 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
     192void null_device_stats(device_stats_ref stats){
     193        bzero(stats, sizeof(device_stats_t));
     194}
     195
     196int 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        }
    197205        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
     210int 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)){
    213221                case IPC_M_PHONE_HUNGUP:
    214222                        return EOK;
    215223                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));
    217225                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);
    221229                        return ERROR_CODE;
    222230                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));
    225233                case NET_NETIF_START:
    226                         return netif_start_req( 0, IPC_GET_DEVICE( call ));
     234                        return netif_start_req(0, IPC_GET_DEVICE(call));
    227235                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)){
    231239                                        ERROR_CODE = EOVERFLOW;
    232240                                }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));
    235243                                        }
    236244                                }
    237245                        }
    238                         fibril_rwlock_read_unlock( & netif_globals.lock );
     246                        fibril_rwlock_read_unlock(&netif_globals.lock);
    239247                        return ERROR_CODE;
    240248                case NET_NETIF_STOP:
    241                         return netif_stop_req( 0, IPC_GET_DEVICE( call ));
     249                        return netif_stop_req(0, IPC_GET_DEVICE(call));
    242250                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);
    246254                        }
    247                         fibril_rwlock_read_unlock( & netif_globals.lock );
     255                        fibril_rwlock_read_unlock(&netif_globals.lock);
    248256                        return ERROR_CODE;
    249257        }
    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
     261int 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())){
    262270                pm_destroy();
    263271                return ERROR_CODE;
     
    266274}
    267275
    268 int netif_run_module( void ){
     276int netif_run_module(void){
    269277        async_manager();
    270278
     
    273281}
    274282
    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 );
     283void netif_pq_release(packet_id_t packet_id){
     284        pq_release(netif_globals.net_phone, packet_id);
     285}
     286
     287packet_t netif_packet_get_1(size_t content){
     288        return packet_get_1(netif_globals.net_phone, content);
    281289}
    282290
  • uspace/srv/net/netif/netif.h

    raa85487 raadf01e  
    6969 *  @see device.h
    7070 */
    71 DEVICE_MAP_DECLARE( device_map, device_t );
     71DEVICE_MAP_DECLARE(device_map, device_t);
    7272
    7373/** Network interface device specific data.
     
    7676        /** Device identifier.
    7777         */
    78         device_id_t     device_id;
     78        device_id_t device_id;
    7979        /** Receiving network interface layer phone.
    8080         */
    81         int             nil_phone;
     81        int nil_phone;
    8282        /** Actual device state.
    8383         */
    84         device_state_t  state;
     84        device_state_t state;
    8585        /** Driver specific data.
    8686         */
    87         void *          specific;
     87        void * specific;
    8888};
    8989
     
    9393        /** Networking module phone.
    9494         */
    95         int             net_phone;
     95        int net_phone;
    9696        /**     Device map.
    9797         */
    98         device_map_t    device_map;
     98        device_map_t device_map;
    9999        /** Safety lock.
    100100         */
    101         fibril_rwlock_t lock;
     101        fibril_rwlock_t lock;
    102102};
    103103
     
    109109 *  @returns EPERM if the device is not initialized.
    110110 */
    111 int     find_device( device_id_t device_id, device_ref * device );
     111int find_device(device_id_t device_id, device_ref * device);
    112112
    113113/** Clears the usage statistics.
    114114 *  @param[in] stats The usage statistics.
    115115 */
    116 void    null_device_stats( device_stats_ref stats );
     116void null_device_stats(device_stats_ref stats);
    117117
    118118// prepared for future optimalizations
     
    120120 *  @param[in] packet_id The packet identifier.
    121121 */
    122 void    netif_pq_release( packet_id_t packet_id );
     122void netif_pq_release(packet_id_t packet_id);
    123123
    124124/** Allocates new packet to handle the given content size.
     
    127127 *  @returns NULL if there is an error.
    128128 */
    129 packet_t netif_packet_get_1( size_t content );
     129packet_t netif_packet_get_1(size_t content);
    130130
    131131/** Processes the netif module messages.
     
    140140 *  @see IS_NET_NETIF_MESSAGE()
    141141 */
    142 int     netif_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
     142int netif_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
    143143
    144144/** Initializes the netif module.
     
    148148 *  @returns Other error codes as defined for each specific module message function.
    149149 */
    150 int     netif_init_module( async_client_conn_t client_connection );
     150int netif_init_module(async_client_conn_t client_connection);
    151151
    152152/** Starts and maintains the netif module until terminated.
    153153 *  @returns EOK after the module is terminated.
    154154 */
    155 int netif_run_module( void );
     155int netif_run_module(void);
    156156
    157157#endif
  • uspace/srv/net/netif/netif_messages.h

    raa85487 raadf01e  
    7979 *  @param[in] call The message call structure.
    8080 */
    81 #define NETIF_GET_IRQ( call )           ( int ) IPC_GET_ARG2( * call )
     81#define NETIF_GET_IRQ(call)             (int)   IPC_GET_ARG2(*call)
    8282
    8383/** Returns the input/output address message parameter.
    8484 *  @param[in] call The message call structure.
    8585 */
    86 #define NETIF_GET_IO( call )            ( int ) IPC_GET_ARG3( * call )
     86#define NETIF_GET_IO(call)              (int)   IPC_GET_ARG3(*call)
    8787
    8888/*@}*/
  • uspace/srv/net/netif/netif_module.h

    raa85487 raadf01e  
    5050/** Initializes the specific module.
    5151 */
    52 int     netif_initialize( void );
     52int netif_initialize(void);
    5353
    5454/** Probes the existence of the device.
     
    6060 *  @returns Other error codes as defined for the specific module message implementation.
    6161 */
    62 int     netif_probe_message( device_id_t device_id, int irq, uintptr_t io );
     62int netif_probe_message(device_id_t device_id, int irq, uintptr_t io);
    6363
    6464/** Sends the packet queue.
     
    7171 *  @returns Other error codes as defined for the specific module message implementation.
    7272 */
    73 int     netif_send_message( device_id_t device_id, packet_t packet, services_t sender );
     73int netif_send_message(device_id_t device_id, packet_t packet, services_t sender);
    7474
    7575/** Starts the device.
     
    7979 *  @returns Other error codes as defined for the specific module message implementation.
    8080 */
    81 int     netif_start_message( device_ref device );
     81int netif_start_message(device_ref device);
    8282
    8383/** Stops the device.
     
    8787 *  @returns Other error codes as defined for the specific module message implementation.
    8888 */
    89 int     netif_stop_message( device_ref device );
     89int netif_stop_message(device_ref device);
    9090
    9191/** Returns the device local hardware address.
     
    9898 *  @returns Other error codes as defined for the specific module message implementation.
    9999 */
    100 int     netif_get_addr_message( device_id_t device_id, measured_string_ref address );
     100int netif_get_addr_message(device_id_t device_id, measured_string_ref address);
    101101
    102102/** Processes the netif driver specific message.
     
    110110 *  @returns Other error codes as defined for the specific module message implementation.
    111111 */
    112 int     netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
     112int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
    113113
    114114/** Returns the device usage statistics.
     
    119119 *  @returns Other error codes as defined for the specific module message implementation.
    120120 */
    121 int     netif_get_device_stats( device_id_t device_id, device_stats_ref stats );
     121int netif_get_device_stats(device_id_t device_id, device_stats_ref stats);
    122122
    123123#endif
  • uspace/srv/net/netif/netif_nil_bundle.c

    raa85487 raadf01e  
    6161 *  @returns Other error codes as defined for each specific module message function.
    6262 */
    63 int     module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
     63int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
    6464
    6565/** Starts the bundle network interface module.
     
    6969 *  @returns Other error codes as defined for each specific module message function.
    7070 */
    71 int     module_start( async_client_conn_t client_connection );
     71int module_start(async_client_conn_t client_connection);
    7272
    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 );
     73int 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);
    7676        }else{
    77                 return netif_message( callid, call, answer, answer_count );
     77                return netif_message(callid, call, answer, answer_count);
    7878        }
    7979}
    8080
    81 int     module_start( async_client_conn_t client_connection ){
     81int module_start(async_client_conn_t client_connection){
    8282        ERROR_DECLARE;
    8383
    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))){
    8686                pm_destroy();
    8787                return ERROR_CODE;
  • uspace/srv/net/netif/netif_remote.c

    raa85487 raadf01e  
    4949#include "netif_messages.h"
    5050
    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 );
     51int 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);
    5353}
    5454
    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 );
     55int 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);
    5757}
    5858
    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 );
     59int 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);
    6161}
    6262
    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 );
     63int netif_start_req(int netif_phone, device_id_t device_id){
     64        return async_req_1_0(netif_phone, NET_NETIF_START, device_id);
    6565}
    6666
    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 );
     67int netif_stop_req(int netif_phone, device_id_t device_id){
     68        return async_req_1_0(netif_phone, NET_NETIF_STOP, device_id);
    6969}
    7070
    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;
     71int netif_stats_req(int netif_phone, device_id_t device_id, device_stats_ref stats){
     72        aid_t message_id;
     73        ipcarg_t result;
    7474
    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;
    8082}
    8183
    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 );
     84int 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);
    8486}
    8587
  • uspace/srv/net/netif/netif_standalone.c

    raa85487 raadf01e  
    5050 *  @returns Other error codes as defined for each specific module message function.
    5151 */
    52 int     module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
     52int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
    5353
    5454/** Starts the network interface module.
     
    5858 *  @returns Other error codes as defined for each specific module message function.
    5959 */
    60 int     module_start( async_client_conn_t client_connection );
     60int module_start(async_client_conn_t client_connection);
    6161
    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 );
     62int 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);
    6464}
    6565
    66 int     module_start( async_client_conn_t client_connection ){
     66int module_start(async_client_conn_t client_connection){
    6767        ERROR_DECLARE;
    6868
    69         ERROR_PROPAGATE( netif_init_module( client_connection ));
     69        ERROR_PROPAGATE(netif_init_module(client_connection));
    7070        return netif_run_module();
    7171}
Note: See TracChangeset for help on using the changeset viewer.