Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

rt_3c905x.c File Reference

#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/pbuf.h"
#include "lwip/sys.h"
#include "netif/etharp.h"
#include "netif/rt_3c905x_exports.h"
#include "netif/ethernetif.h"
#include <unistd.h>
#include "bcopy.h"
#include <signal.h>
#include <rtl_sema.h>

Include dependency graph for rt_3c905x.c:

Go to the source code of this file.

Data Structures

struct  rt_3c905cif

Defines

#define IFNAME0   'e'
#define IFNAME1   't'
#define COM3_SIGNAL   RTL_SIGUSR2

Functions

void rt_3c905cif_input (struct pbuf *p, struct netif *netif)
err_t rt_3c905cif_output (struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
void rt_3c905cif_ethernetif_thread (void *arg)
void rt_3com905cif_low_level_init (struct netif *netif)
err_t rt_3com905cif_low_level_output (struct netif *rt_3c905cif, struct pbuf *p)
pbufrt_3com905cif_low_level_input (struct rt_3c905cif *rt_3c905cif)
void rt_3com905cif_etharp_timer (int signo)
err_t rt_3c905cif_init (struct netif *netif)
void rt_3c905cif_close (void)

Variables

ethernetif_thread_t com3_thread
const struct eth_addr rt_3c905cif_ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}}
int rt_3c905cif_fd
netifrt_3c905cif_netif


Define Documentation

#define COM3_SIGNAL   RTL_SIGUSR2
 

Definition at line 99 of file rt_3c905x.c.

#define IFNAME0   'e'
 

Definition at line 97 of file rt_3c905x.c.

Referenced by rt_3c905cif_init(), and rt_rtl8139if_init().

#define IFNAME1   't'
 

Definition at line 98 of file rt_3c905x.c.

Referenced by rt_3c905cif_init(), and rt_rtl8139if_init().


Function Documentation

void rt_3c905cif_close void   ) 
 

Definition at line 351 of file rt_3c905x.c.

References com3_thread, and rt_3c905cif_fd.

00351                             {
00352   /* Unregistering the thread */
00353   ioctl(rt_3c905cif_fd, 4, (unsigned long) &com3_thread);
00354   /* Closing the 3Com905C-X card */
00355   close(rt_3c905cif_fd);
00356 }

void rt_3c905cif_ethernetif_thread void *  arg  )  [static]
 

Definition at line 144 of file rt_3c905x.c.

References NULL, rt_3c905cif_input(), and rt_3c905cif_netif.

Referenced by rt_3com905cif_low_level_init().

00144                                                     {
00145   struct sched_param p;
00146 
00147   p . sched_priority = 100000;
00148   pthread_setschedparam (pthread_self(), SCHED_FIFO, &p);
00149 
00150   do{
00151     rt_3c905cif_input(NULL, rt_3c905cif_netif);  
00152   }while(1);
00153 
00154 }

Here is the call graph for this function:

err_t rt_3c905cif_init struct netif netif  ) 
 

Definition at line 325 of file rt_3c905x.c.

References ARP_TMR_INTERVAL, ERR_OK, etharp_init(), netif::hwaddr, netif::hwaddr_len, IFNAME0, IFNAME1, netif::linkoutput, mem_malloc(), netif::name, NULL, netif::output, rt_3c905cif_netif, rt_3c905cif_output(), rt_3com905cif_etharp_timer(), rt_3com905cif_low_level_init(), rt_3com905cif_low_level_output(), netif::state, sys_timeout(), and sys_timeout_handler.

00326 {
00327   struct rt_3c905cif *rt_3c905cif;
00328     
00329   rt_3c905cif = mem_malloc(sizeof(struct rt_3c905cif));
00330   netif->state = rt_3c905cif;
00331   netif->name[0] = IFNAME0;
00332   netif->name[1] = IFNAME1;
00333   netif->output = rt_3c905cif_output;
00334   netif->linkoutput = rt_3com905cif_low_level_output;
00335   
00336   rt_3c905cif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
00337   netif->hwaddr_len = 6;
00338 
00339   rt_3c905cif_netif = netif; 
00340 
00341   rt_3com905cif_low_level_init(netif);
00342   etharp_init();
00343 
00344   sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)rt_3com905cif_etharp_timer, NULL);
00345 
00346   return ERR_OK;
00347 }

Here is the call graph for this function:

void rt_3c905cif_input struct pbuf p,
struct netif netif
[static]
 

Definition at line 276 of file rt_3c905x.c.

References etharp_arp_input(), etharp_ip_input(), ETHTYPE_ARP, ETHTYPE_IP, htons, netif::input, NULL, pbuf_free(), pbuf_header(), rt_3com905cif_low_level_input(), rt_3com905cif_low_level_output(), and netif::state.

Referenced by rt_3c905cif_ethernetif_thread().

00277 {
00278 
00279   /* Ethernet protocol layer */
00280   struct eth_hdr *ethhdr;
00281   struct rt_3c905cif *rt_3c905cif = netif->state;
00282   struct pbuf *q = NULL , *p = NULL;
00283   
00284   p = rt_3com905cif_low_level_input(rt_3c905cif);
00285 
00286   ethhdr = p->payload;
00287   
00288   switch(htons(ethhdr->type)) {
00289   case ETHTYPE_IP:
00290     q = etharp_ip_input(netif, p);
00291     pbuf_header(p, -14);
00292     netif->input(p, netif);
00293     break;
00294   case ETHTYPE_ARP:
00295     q = etharp_arp_input(netif, rt_3c905cif->ethaddr, p);
00296     break;
00297   default:
00298     pbuf_free(p);
00299     break;
00300   }
00301   if(q != NULL) {
00302     rt_3com905cif_low_level_output(netif, q);
00303     pbuf_free(q);
00304   }
00305 }

Here is the call graph for this function:

err_t rt_3c905cif_output struct netif netif,
struct pbuf p,
struct ip_addr ipaddr
[static]
 

Definition at line 252 of file rt_3c905x.c.

References ERR_OK, etharp_output(), ipaddr, NULL, and rt_3com905cif_low_level_output().

Referenced by rt_3c905cif_init().

00254 {
00255   
00256   p = etharp_output(netif, ipaddr, p);
00257   if(p != NULL) {
00258     rt_3com905cif_low_level_output(netif, p);
00259   }
00260   return ERR_OK;
00261 }

Here is the call graph for this function:

void rt_3com905cif_etharp_timer int  signo  ) 
 

Definition at line 308 of file rt_3c905x.c.

References ARP_TMR_INTERVAL, etharp_tmr(), NULL, rt_3com905cif_etharp_timer(), sys_timeout(), and sys_timeout_handler.

Referenced by rt_3c905cif_init(), and rt_3com905cif_etharp_timer().

00309 {
00310   etharp_tmr();
00311   sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)rt_3com905cif_etharp_timer, NULL);
00312 }

Here is the call graph for this function:

void rt_3com905cif_low_level_init struct netif netif  )  [static]
 

Definition at line 119 of file rt_3c905x.c.

References ip_addr::addr, COM3_905C_NAME, netif::ip_addr, rt_3c905cif_ethernetif_thread(), rt_3c905cif_fd, netif::state, and sys_thread_new().

Referenced by rt_3c905cif_init().

00120 {
00121   struct rt_3c905cif *rt_3c905cif;
00122   char dev_name[]={"/dev/eth0"};
00123   
00124   rt_3c905cif = netif->state;
00125   
00126   /* Do whatever else is needed to initialize interface. */  
00127   if((rt_3c905cif_fd=open(dev_name,0)) == -1)
00128     rtl_printf("ERROR OPENING /dev/%s0\n",COM3_905C_NAME);
00129 
00130   /* Obtain MAC address from network interface. */
00131   ioctl(rt_3c905cif_fd, 2, (unsigned long) rt_3c905cif->ethaddr->addr);
00132 
00133   /* We set an IP filter to the ethernet card */
00134   ioctl(rt_3c905cif_fd, 1, (unsigned long) netif->ip_addr.addr);
00135 
00136 //  rtl_printf("ADRESS: %x:%x:%x:%x:%x:%x \n",rt_3c905cif->ethaddr->addr[0],rt_3c905cif->ethaddr->addr[1],rt_3c905cif->ethaddr->addr[2],rt_3c905cif->ethaddr->addr[3],rt_3c905cif->ethaddr->addr[4],rt_3c905cif->ethaddr->addr[5]);
00137 
00138   sys_thread_new(rt_3c905cif_ethernetif_thread, netif, 0);
00139 
00140   return ;
00141 }

Here is the call graph for this function:

struct pbuf* rt_3com905cif_low_level_input struct rt_3c905cif rt_3c905cif  )  [static]
 

Definition at line 209 of file rt_3c905x.c.

References bcopy(), len, NULL, pbuf_alloc(), PBUF_LINK, PBUF_POOL, rt_3c905cif_fd, sys_arch_close(), and u16_t.

Referenced by rt_3c905cif_input().

00210 {
00211   struct pbuf *p, *q;
00212   struct memory receive_buffer;
00213   unsigned char *bufptr;
00214   u16_t len;
00215   
00216   /* Obtain the size of the packet and put it into the "len"
00217      variable. */
00218   len = read(rt_3c905cif_fd,(void *) &receive_buffer,1536);
00219   
00220   /* We allocate a pbuf chain of pbufs from the pool. */
00221   p = pbuf_alloc(PBUF_LINK, len, PBUF_POOL);
00222   
00223   if(p != NULL) {
00224     /* We iterate over the pbuf chain until we have read the entire
00225        packet into the pbuf. */
00226     bufptr = receive_buffer.mem;
00227     for(q = p; q != NULL; q = q->next) {
00228       /* Read enough bytes to fill this pbuf in the chain. The
00229          avaliable data in the pbuf is given by the q->len
00230          variable. */
00231       bcopy(bufptr, q->payload, q->len);
00232       bufptr += q->len;
00233     }
00234   } else {
00235     rtl_printf("ERROR:Not enough memory!!!\n");
00236     sys_arch_close();
00237   }
00238 
00239   return p;  
00240 }

Here is the call graph for this function:

err_t rt_3com905cif_low_level_output struct netif rt_3c905cif,
struct pbuf p
 

Definition at line 168 of file rt_3c905x.c.

References bcopy(), ERR_OK, NULL, and rt_3c905cif_fd.

Referenced by rt_3c905cif_init(), rt_3c905cif_input(), and rt_3c905cif_output().

00169 {
00170 
00171   struct pbuf *q;
00172   unsigned char buf[1536];
00173   unsigned char *bufptr;  
00174 
00175   //initiate transfer;
00176   bufptr = buf;  
00177   
00178   for(q = p; q != NULL; q = q->next) {
00179     /* Send the data from the pbuf to the interface, one pbuf at a
00180        time. The size of the data in each pbuf is kept in the ->len
00181        variable. */
00182     bcopy(q->payload, bufptr, q->len);
00183     bufptr += q->len;
00184   }
00185 
00186   //signal that packet should be sent;
00187   {
00188     int tmp;
00189     int counter=0;
00190  
00191     while((tmp = write(rt_3c905cif_fd,buf,p->tot_len)) == -1){
00192       counter++;
00193       usleep(1);  
00194     }
00195   }
00196   
00197   return ERR_OK;
00198 }

Here is the call graph for this function:


Variable Documentation

ethernetif_thread_t com3_thread
 

Definition at line 101 of file rt_3c905x.c.

Referenced by rt_3c905cif_close().

const struct eth_addr rt_3c905cif_ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}} [static]
 

Definition at line 107 of file rt_3c905x.c.

int rt_3c905cif_fd [static]
 

Definition at line 108 of file rt_3c905x.c.

Referenced by rt_3c905cif_close(), rt_3com905cif_low_level_init(), rt_3com905cif_low_level_input(), and rt_3com905cif_low_level_output().

struct netif* rt_3c905cif_netif [static]
 

Definition at line 109 of file rt_3c905x.c.

Referenced by rt_3c905cif_ethernetif_thread(), and rt_3c905cif_init().


Generated on Wed Jan 14 12:59:09 2004 for RTL-lwIP-0.4 by doxygen 1.3.4