SlideShare uma empresa Scribd logo
1 de 5
Baixar para ler offline
I nternational Journal Of Computational Engineering Research (ijceronline.com) Vol. 2 Issue. 8



           Development Of Embedded Ethernet Drivers For Arm9
                      1,
                           T.Satyanarayna 2, S.Latha(Associate Proffesor)
            1,2,
     ,         Dept of Electronics & Co mmunication Engineering, Aurora Technological & Research Institute,
                           .               Jawaharlal Nehru Technological Un iversity.

Abstract
         with the widely application of ARM technique, building the embedded operating system
based on ARM processor has been a hot point of research. In this paper, the design of network device
driver in Linu x operating system based on ARM920T processor is imple mented on the S3C2410- S development
platform made in Beijing universal pioneering technology. Focused on discussing imp lementation principle of
embedded Linu x network drivers and detailed to analysis of the frame structure of the program code.

Keywords-A RM9 processor; embedded linu x; net work device driver; CS8900A

1. Introduction
         Now the people more and more like open-source software. As a powerful and stable open-source
operating system, Linu x is acclaimed by the thousands of computer expert and amateur. In the embedded field,
Linu x can be cured in dozens of megabytes of memory chips or SCM after small cutting. So that it can be used in
a specific context of embedded Linu x. Strong network support functions of Linu x ach ieved support for multiple
protocols including TCP / IP, and it meets the demand for embedded systems application networking for the 21st
century. Therefore, when developing and debugging embedded systems, network interface almost become
indispensable module.

2. INTRODUCTION OF LINUX NETWORK DEVICE DRIVER
         Linu x network device driver is an important part of Linu x network application. The whole Linu x
Network driver follows the common interface. For each network interface, it uses a device data structure. Generally,
the network device is a physical device, such as Ethernet card.Network driver must solve two problems: first, not
all network device driver based on Linu x kernel have control equipment; second, Ethernet device in the system
is always called / dev/eth0, dev/eth1 etc., regardless of the underlying device driver. When initialization routines
of each network device are called, the driver will return a status, whichindicating whether it is orientation
to an instance of the driven controller. If the driver does not find any device, then the entries pointed to the
device lists by the „dev_base‟ will be deleted. If the driver can find a device, then the rest of the device data
structure is filled by this device information and the address of support function in network device driver.

3. Architecture Of Linux Network Device Driver
          Shown in Fig. 1, the architecture of Linu x netwo rk driver can be divided into four levels. Linu x kernel
source code provided the network device interface and the code above level. Therefore the main work wh ich
transplanting specific network hardware drivers is to complete the corresponding code of the device driver
function layer. According to the specific bottom hardware features, Structure variable of network device
interface „struct net_device‟ type is defined and corresponding operation function and interrupt handling program
are imp lemented.




                                       Figure 1.Architecture of Linu x network driver

4. Ethernet Controller Chip Cs8900a Cs8900a
         is a 16-bit Ethernet controller p roduced byCIRRUS LOGIC, embedded on-chip RAM , 10VASE-
T transceiver filter and direct ISA bus interface. The salient feature of the chip is flexible to use, and it can
dynamically adjust according to needs for its physical layer interface, data transfer mode and work mode, and it
can adapt to different application environment through setting internal reg ister.
CS8900A can be operated in memory mode and I / O

||Issn 2250-3005(online)||                          ||December|| 2012                               Page 280
I nternational Journal Of Computational Engineering Research (ijceronline.com) Vol. 2 Issue. 8



mode. When CS8900A is configured to Memory Mode operation, its internal registers and frame buffer are
mappedto a serial 4KB host memory block, the host can directly access CS8900A's internal registers and frame
buffer through the block.

5. Design And The Implementation Principle Of Network Driver
         Linu x network system can comp lete data transfer between all levels through the socket buffer
sk_buff, data structure sk_buff is each protocol data processing object. sk_buff is the media of exchange data
between driver and network. When the driver sends data to the network, data source and data length must be
obtained. Data must be saved in sk_buff also after the driver received data fro m thenetwork. Thus upper layer
protocol can process it.For the actual development of Ethernet driver, corresponding template program in
the kernel source tree can be consulted, focused on understanding the implementation principle    of   network
driver   and program structural framework. Then the code is rewritten to develop specific hardware, and
achieve the appropriate operation function. Through transplanting and preparing     the     embedded
CS8900A network card driver on embedded development board (S3C2410 processor) to show the
implementation principles of network driver.
A.     Initi alization Functi on
           Initialization of network equipment is co mpleted mainly by initialization function which is referred by
init function pointer in device data structure. After the kernel load the network driver module, in itializat ion
process will be called. First it is necessary to detect whether network physical device exist, which is
completed by detecting the physical device hardware characteristic. Then the resource equipment needed is
configured, such as interrupts. Next the device„device‟ data structure is constructed. The relevant variable in the
device is initialized by detected data, and finally thedevice is registered to the Linu x kernel and applies memory
space.In this instance, the initialization function is “_init cs8900a_s3c2410(void)”.
In the network device driver, the device „device‟ data structure is dev_cs89x0, which is defined as follows.
#ifdef MODULE static struct net_device dev_cs89x0={
‟‟‟‟,
0, 0, 0, 0,0, 00, 0, 0, NULL,NULL};The function „cs89x0_probe‟ detect the existence of the network physical
device, but device init ialization is comp leted by two functions „cs89x0_probe‟ and„cs89x0_probe1‟
together. In „cs89x0_probe1‟, the function pointers of „device‟ data structure are filled.After comp letion of
filling pointer, to register by„register_netdev‟ (struct net_device * dev) function. Two function

register_netdev‟ and „unreg ister_netdev‟ are defined in file „net_init.c ‟.Since there is „init‟ function, there
should also be„cleanup‟ function, because they are essential function of each driver. The „cleanup‟ function
run when module is unloaded, wh ich comp lete mainly the work of resource release. Such as cancel device
registration, free memory, release the port, etc. All in all, it is some action contrary to init.The function of
Cancellation of network device registration is „unregister_netdevice‟ defined in file / net / core / dev.c, this
function is called in „unregister_netdev‟.
B. Open Functi on
When system response „ifconfig‟ co mmand, a network interface will be opened (closed). The „ifconfig‟
command given address to interface by calling ioctl‟ (SIOCSIFADDR). Response           of       SIOCSIFADDR is
accomplished by the kernel, and device-independent. Then, the „ifconfig‟ co mmand set IFF_UP bit of dev-> flag
to open the device by calling „ioctl‟ (SIOCSIFFLA GS). The device's open method is called through the above
called. In the network device driver, Open function is called when network device is activated, that device
status becomes fro m down to up. So a lot of initialization wo rk can be done here. In open function, operation on
the register uses two
functions: „readreg‟ and „writereg‟. „readreg‟ function is used to read the register contents, „writereg‟ function is
used to write registers, the code is as follows :
inline int readreg(struct net_ device *dev,int portno){
outw(portno,dev->base_addr+ADD_PORT);
return inw(dev->base_addr+DATA_PORT);
}inline void writereg(struct net_ device
*dev,int portno,int value){ outw(portno,dev->base_addr+ADD_PORT); outw(value,dev-
>base_addr+DATA_PORT);
}
C.   Close Functi on
        Close function (net_close) releases resources to reduce system burden. It is called when the device
status becomes fro m up to down. In addition, if the driver is loaded as a module, the macro
MOD_DEC_USE_COUNT need to call in close also, to reduce the frequency of equipment cited in order to
uninstall the driver.

||Issn 2250-3005(online)||                          ||December|| 2012                                Page 281
I nternational Journal Of Computational Engineering Research (ijceronline.com) Vol. 2 Issue. 8



D. Send Functi on
          Sending and receiving of data packets are two key processes achieving Linux network driver,
good or bad of the two processes affected directly the driver's overall running quality. First of all, when
the network device driver is loaded, device is initialized by init function pointer in the device domain calling
network device in itialization function. If the operation is successful, device is opened by open function pointer
in the device domain calling network device open function. Next, hardware packet header information is set up by
building hardware packet header function pointer hard_header in the device domain. Finally, the packet sent is
completed        through     protocol      interface     layer    function dev_queue_xmit calling function pointer
hard_start_xmit in the device domain. If        sent    successfully,     sk_buff is      released in hard_start_xmit
method, and return 0 (send success). If the device can not be process temporarily, such as the hardwareis busy,
and then return 1. At this time if the dev-> tbusy is set to non-zero, the system regards that the hardware is busy, it
will not re-send until dev-> tbusy is set to 0. tbusy's setting zero task is completed by interrupt generally.
Hardware interrupt at the end of sent, at this time tbusy can be set to 0, then call mark_bh () to notify system to re-
sent. In the case of sending unsuccessful, dev-> tbusy can not be set to non- zero, this system will try to
resent continuously. If hard_start_xmit is not sent successful, then sk_buff cannot be release. The data
which is sent in Sk_buff already contains the frame head of hardware requirement. Hardware frame head need
not be fill in send method, data can be sent directly to the hardware. sk_buff is locked, and it is assured that other
programs will not access it.
E.   Recei ve Function
          Receive function is different from receive data, network interface does not provide receive function pointer
similar to net_receive_packet, because that network device receive data is achieved through interrupts. Upon
receiving the information, an interrupt is generated, the driver will apply a sk_buff (skb) in interrupt handler, and
the data read from hardware is placed to applied buffer. Next, some informat ion is filled in sk_buff. skb-> dev =
dev judges protocol type ofreceived frame, and fills in the skb-> protocol (mult i- protocol support). Pointer
skb-> mac.raw point to the hardware data and then discard the hardware frame head (skb_pull). A lso skb->
pkt_type is set, indicating the type of data link layer. If the data packet is obtained, then net_rx() is
implemented, net_rx () is a subroutines of data reception, it is called by interrupt service routine. Last the data is
sent to the protocol layer by calling netif_rx (). netif_rx () put data into the processing queue and then return, the
real processing will be implemented after interrupted return. Thus interrupt time is reduced. After netif_rx ()
is called, the driver cannot be saved in data buffer skb. In the protocol layer, flows control of receiv ing data
packets is divided into two levels: first, netif_rx () function is limited the number of data frames fro m the physical
layer to protocol layer. Secondly, each socket has a queue, which limits the number of data frames fro m the
protocol layer to the socket layer. In transmission, the dev-> t x_queue_len
parameter in driver limits the length of the queue.


F. Interrupt Hhandler
         In the open function, the interrupt is applied, the interrupt handler is net_interrupt. The preparation of
writ ing this function is to understand the interrupt process of network control chip. For the CS8900A chip, this
process can explain the flow chart using fig. 2.
                              First kernel need to read ISQ (Interrupt Status Queue)
value, ISQ event has the following 5 types:
#define ISQ_RECEIVER_ EVENT                         0x04
                              #define ISQ_TRANSMITTER_EVENT                      0x08
                              #define ISQ_BUFFER_EVENT                           0x0c
#define ISQ_RX_MISS_ EVENT                          0x10
                             #define ISQ_TX_ COL_ EVENT                      0x12
After receiving a data packet (RxEvent), to deliver
function net_rx() to process. Interrupt handler parameter is set as follows:
Static void net_interrupt(int irq ,void *dev_id ,structpt_regs *regs




||Issn 2250-3005(online)||                           ||December|| 2012                                Page 282
I nternational Journal Of Computational Engineering Research (ijceronline.com) Vol. 2 Issue. 8




                               Figure 2.Interrupt handling flo wchart



6. DRIVER TEST
         Driver is only provided interface between kernel and user. To use the device, not only to install the driver,
but also must write an application to use it.
After the network driver is designed, the kernel module can be compiled, and the custom kernel module as part of
the system source code is compiled a new system.
A. Configuring The Kernel
In Linu x2.6 kernel, want to compile the kernel module, first it is necessary to configure and construct properly
kernel source tree in / usr / src, that is, to extract the need kernel source code to / usr / src /, and to use the
command „make menuconfig‟or „make gconfig‟ configure the kernel under the main directory of kernel source
(Here is / usr/src/linux-2.6.18.3), then using the „make all‟ to comp ile the kernel comp letely.
B. Take CS8900A NIC driver for example, introduce how to compile network device driver into the kernel.
z To       create a new directory cs8900a under the directory „drivers‟ of system source code tree;
z To copy cs8900a.c and cs8900a.h to drivers/cs890a directory;
z To co mpile „Makefile‟ file under drivers/cs890a directory;
#Makefile fo r CS8900A network Driver
obj -$(CONFIG_ DRIVER_CS8900A) +=cs8900a.o
z To comp ile „Kconfig‟ file under drivers/cs890a directory;

#Just for CS8900A network device
menu "CS8900A network device support"
config DRIVER_ CS8900A tristate "CS8900A support" This is a network driver module fo r CS8900A.
end menu
z To add a line in front of„end menu‟ statement of
„Kconfig‟     file In the „driver‟ directory source
"drivers/cs8900a/Kconfig"
In main directory of kernel source code tree, “CS8900A
network device support [y / n /?]” can be found in the option
„Device Drivers‟ through command „make menuconfig‟ or
„make gconfig‟ , if select "y", the kernel will prov ide support for network driver.
To recompile the kernel can be obtain kernel of
supported CS8900A card, then download the kernel to the development board. By configuring network
parameters, the behavior of the network card driver can be test.
7. CONCLUSION
        In recent years, Internet has a rapid development. Remote monitoring and remote maintenance
become very easy after embedded system access internet, so the network of embedded systems is very important.
Embedded system achieved internet access; its prerequisite is that system software has TCP/IP protocol
support. Fortunately, Linux kernel provides support for multiple protocols including TCP/IP. This paper
takes network chip CS8900A for examp le, and introduces the key process of imp lementing network driver.




||Issn 2250-3005(online)||                           ||December|| 2012                                Page 283
I nternational Journal Of Computational Engineering Research (ijceronline.com) Vol. 2 Issue. 8



8. Acknowledgment
        This research was supported by         the    Open Project Program of Key Laboratory of Intelligent
Manufacture of Hunan Province (Xiangtan              University),  China
( No.2009IM 03).
References
[1]   Q.Sun, Developing Detail Exp lain of Embedded Linu x Application, Beijing, Posts & Telecom Press,
      July 2006.
[2]   T.Z.Sun and W.J.Yuan, embedded design and Linu x driver development guide, Beijing,
      Publishing House of Electronics Industry, October 2009.
[3]   M.liu, Embedded system interface design and Linu x driver develop ment, Beijing, Beihang
      University Press,May 2006.
[4]   L.G.Zhou, Examp le of A RM Embedded Linu x System Build ing and
      Driver Develop ment, Beijing, BeihangUn iversity Press, 2006.
[5]   C.Qian, R.H.Xu and Q.R.Wang, “Device Driver Develop ment Based on Linu x Operating System”, Control
      & Auto mat ion,2004,(09).
[6]    Q.N.Cao, B.Zhao and           K.Y.Meng, “Design and          realizat ion of embedded linu x net work
      communication system based on ARM9 platfo rm “, Journal of Northwest University(Natural Science
      Ed it ion), 2009,(1).
[7]   J.Zhao,X.Q.Ding, “Develop ment and Implementation Principle o f Net work            Driver   Based on
      Embedded Linu x”, M icroco mputer In format ion, 2008,(17).
[8]   F.J.Li and W.D.Jin, “Research and Implementation of Netwo rk Driver in Embedded Linu x”, Modern
      Elect ronic Technique, 2005(16)
[9]   W.Su, “Design of Linu x Network Device Driver” Financial Co mputer of Huanan, 2005(06).
[10] D.Cao and K.Wang, “Research of Network Dev ice Driver based on Linu x” , Co mputer Knowledge and
      Technology, 2005( 21).
[11] Q.Wu, SH.H.Zhou and ZH.X.Ma, “Develop ment of Linu x Net work Driver                Based    on    USB
      Device”, M icroco mputer Info rmation,
      2007,(02). V12-448




||Issn 2250-3005(online)||                        ||December|| 2012                              Page 284

Mais conteúdo relacionado

Mais procurados

Message Signaled Interrupts
Message Signaled InterruptsMessage Signaled Interrupts
Message Signaled InterruptsAnshuman Biswal
 
Unit 1 intro-embedded
Unit 1 intro-embeddedUnit 1 intro-embedded
Unit 1 intro-embeddedPavithra S
 
Serial Port Device Driver
Serial Port Device DriverSerial Port Device Driver
Serial Port Device DriverEmblogic
 
computer organization and architecture
computer organization and architecturecomputer organization and architecture
computer organization and architectureIndrajaMeghavathula
 
Multi-Axis Position Control by EtherCAT | ElmoMC
Multi-Axis Position Control by EtherCAT | ElmoMCMulti-Axis Position Control by EtherCAT | ElmoMC
Multi-Axis Position Control by EtherCAT | ElmoMCElmo Motion Control
 
FPGA based synchronous multi-channel PWM generator for humanoid robot
FPGA based synchronous multi-channel PWM generator for humanoid robot FPGA based synchronous multi-channel PWM generator for humanoid robot
FPGA based synchronous multi-channel PWM generator for humanoid robot IJECEIAES
 
HA, SRX Cluster & Redundancy Groups
HA, SRX Cluster & Redundancy GroupsHA, SRX Cluster & Redundancy Groups
HA, SRX Cluster & Redundancy GroupsKashif Latif
 
Accurate Synchronization of EtherCAT Systems Using Distributed Clocks
Accurate Synchronization of EtherCAT Systems Using Distributed ClocksAccurate Synchronization of EtherCAT Systems Using Distributed Clocks
Accurate Synchronization of EtherCAT Systems Using Distributed ClocksDesign World
 
Unit 3 devices&buses
Unit 3 devices&busesUnit 3 devices&buses
Unit 3 devices&busesPavithra S
 
Blue gene detail journal
Blue gene detail journalBlue gene detail journal
Blue gene detail journalVivek Jha
 
Sybsc cs sem 3 physical computing and iot programming unit 1
Sybsc cs sem 3 physical computing and iot programming unit 1Sybsc cs sem 3 physical computing and iot programming unit 1
Sybsc cs sem 3 physical computing and iot programming unit 1WE-IT TUTORIALS
 
Device drivers and interrupt service mechanism
Device drivers and interrupt service mechanismDevice drivers and interrupt service mechanism
Device drivers and interrupt service mechanismVijay Kumar
 
EMBEDDED SYSTEM
EMBEDDED  SYSTEMEMBEDDED  SYSTEM
EMBEDDED SYSTEMAIRTEL
 
IRJET- BSIOTR IT SMART LAB using IOT
IRJET- BSIOTR IT SMART LAB using IOTIRJET- BSIOTR IT SMART LAB using IOT
IRJET- BSIOTR IT SMART LAB using IOTIRJET Journal
 
Ir da in_linux_presentation
Ir da in_linux_presentationIr da in_linux_presentation
Ir da in_linux_presentationAnshuman Biswal
 
PCI Express switch over Ethernet or Distributed IO Systems for Ubiquitous Co...
PCI Express switch over Ethernet or Distributed IO  Systems for Ubiquitous Co...PCI Express switch over Ethernet or Distributed IO  Systems for Ubiquitous Co...
PCI Express switch over Ethernet or Distributed IO Systems for Ubiquitous Co...Ganesan Narayanasamy
 

Mais procurados (20)

Interrupts of microprocessor 8085
Interrupts of microprocessor 8085Interrupts of microprocessor 8085
Interrupts of microprocessor 8085
 
Message Signaled Interrupts
Message Signaled InterruptsMessage Signaled Interrupts
Message Signaled Interrupts
 
Embedded system
Embedded systemEmbedded system
Embedded system
 
Unit 1 intro-embedded
Unit 1 intro-embeddedUnit 1 intro-embedded
Unit 1 intro-embedded
 
Serial Port Device Driver
Serial Port Device DriverSerial Port Device Driver
Serial Port Device Driver
 
419 426
419 426419 426
419 426
 
computer organization and architecture
computer organization and architecturecomputer organization and architecture
computer organization and architecture
 
Multi-Axis Position Control by EtherCAT | ElmoMC
Multi-Axis Position Control by EtherCAT | ElmoMCMulti-Axis Position Control by EtherCAT | ElmoMC
Multi-Axis Position Control by EtherCAT | ElmoMC
 
Bm36382385
Bm36382385Bm36382385
Bm36382385
 
FPGA based synchronous multi-channel PWM generator for humanoid robot
FPGA based synchronous multi-channel PWM generator for humanoid robot FPGA based synchronous multi-channel PWM generator for humanoid robot
FPGA based synchronous multi-channel PWM generator for humanoid robot
 
HA, SRX Cluster & Redundancy Groups
HA, SRX Cluster & Redundancy GroupsHA, SRX Cluster & Redundancy Groups
HA, SRX Cluster & Redundancy Groups
 
Accurate Synchronization of EtherCAT Systems Using Distributed Clocks
Accurate Synchronization of EtherCAT Systems Using Distributed ClocksAccurate Synchronization of EtherCAT Systems Using Distributed Clocks
Accurate Synchronization of EtherCAT Systems Using Distributed Clocks
 
Unit 3 devices&buses
Unit 3 devices&busesUnit 3 devices&buses
Unit 3 devices&buses
 
Blue gene detail journal
Blue gene detail journalBlue gene detail journal
Blue gene detail journal
 
Sybsc cs sem 3 physical computing and iot programming unit 1
Sybsc cs sem 3 physical computing and iot programming unit 1Sybsc cs sem 3 physical computing and iot programming unit 1
Sybsc cs sem 3 physical computing and iot programming unit 1
 
Device drivers and interrupt service mechanism
Device drivers and interrupt service mechanismDevice drivers and interrupt service mechanism
Device drivers and interrupt service mechanism
 
EMBEDDED SYSTEM
EMBEDDED  SYSTEMEMBEDDED  SYSTEM
EMBEDDED SYSTEM
 
IRJET- BSIOTR IT SMART LAB using IOT
IRJET- BSIOTR IT SMART LAB using IOTIRJET- BSIOTR IT SMART LAB using IOT
IRJET- BSIOTR IT SMART LAB using IOT
 
Ir da in_linux_presentation
Ir da in_linux_presentationIr da in_linux_presentation
Ir da in_linux_presentation
 
PCI Express switch over Ethernet or Distributed IO Systems for Ubiquitous Co...
PCI Express switch over Ethernet or Distributed IO  Systems for Ubiquitous Co...PCI Express switch over Ethernet or Distributed IO  Systems for Ubiquitous Co...
PCI Express switch over Ethernet or Distributed IO Systems for Ubiquitous Co...
 

Semelhante a International Journal of Computational Engineering Research(IJCER)

Data Acquisition and Control System for Real Time Applications
Data Acquisition and Control System for Real Time ApplicationsData Acquisition and Control System for Real Time Applications
Data Acquisition and Control System for Real Time Applicationsijsrd.com
 
ETHERNET PACKET PROCESSOR FOR SOC APPLICATION
ETHERNET PACKET PROCESSOR FOR SOC APPLICATIONETHERNET PACKET PROCESSOR FOR SOC APPLICATION
ETHERNET PACKET PROCESSOR FOR SOC APPLICATIONcscpconf
 
Design and Development of ARM9 Based Embedded Web Server
Design and Development of ARM9 Based Embedded Web ServerDesign and Development of ARM9 Based Embedded Web Server
Design and Development of ARM9 Based Embedded Web ServerIJERA Editor
 
HIGH PERFORMANCE ETHERNET PACKET PROCESSOR CORE FOR NEXT GENERATION NETWORKS
HIGH PERFORMANCE ETHERNET PACKET PROCESSOR CORE FOR NEXT GENERATION NETWORKSHIGH PERFORMANCE ETHERNET PACKET PROCESSOR CORE FOR NEXT GENERATION NETWORKS
HIGH PERFORMANCE ETHERNET PACKET PROCESSOR CORE FOR NEXT GENERATION NETWORKSijngnjournal
 
Engineer new post -hangzhou wumu technology co.,ltd.The Design of Human-Mach...
Engineer new post  -hangzhou wumu technology co.,ltd.The Design of Human-Mach...Engineer new post  -hangzhou wumu technology co.,ltd.The Design of Human-Mach...
Engineer new post -hangzhou wumu technology co.,ltd.The Design of Human-Mach...Stephanie hu
 
Dynamic classification in silicon-based forwarding engine environments
Dynamic classification in silicon-based forwarding engine environmentsDynamic classification in silicon-based forwarding engine environments
Dynamic classification in silicon-based forwarding engine environmentsTal Lavian Ph.D.
 
Nt1310 Unit 5 Algorithm
Nt1310 Unit 5 AlgorithmNt1310 Unit 5 Algorithm
Nt1310 Unit 5 AlgorithmAngie Lee
 
Juniper Networks Router Architecture
Juniper Networks Router ArchitectureJuniper Networks Router Architecture
Juniper Networks Router Architecturelawuah
 
Rodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementationRodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementationFelipe Prado
 
Secure remote protocol for fpga reconfiguration
Secure remote protocol for fpga reconfigurationSecure remote protocol for fpga reconfiguration
Secure remote protocol for fpga reconfigurationeSAT Journals
 
Secure remote protocol for fpga reconfiguration
Secure remote protocol for fpga reconfigurationSecure remote protocol for fpga reconfiguration
Secure remote protocol for fpga reconfigurationeSAT Publishing House
 
IRJET- SDN Simulation in Mininet to Provide Security Via Firewall
IRJET- SDN Simulation in Mininet to Provide Security Via FirewallIRJET- SDN Simulation in Mininet to Provide Security Via Firewall
IRJET- SDN Simulation in Mininet to Provide Security Via FirewallIRJET Journal
 
Implementation of linux based uart device driver
Implementation of linux based uart device driverImplementation of linux based uart device driver
Implementation of linux based uart device drivereSAT Publishing House
 
Openstack Workshop (Networking/Storage)
Openstack Workshop (Networking/Storage)Openstack Workshop (Networking/Storage)
Openstack Workshop (Networking/Storage)Affan Syed
 
IRJET- Autonomous Underwater Vehicle: Electronics and Software Implementation...
IRJET- Autonomous Underwater Vehicle: Electronics and Software Implementation...IRJET- Autonomous Underwater Vehicle: Electronics and Software Implementation...
IRJET- Autonomous Underwater Vehicle: Electronics and Software Implementation...IRJET Journal
 
Running head network design 1 netwo
Running head network design                             1 netwoRunning head network design                             1 netwo
Running head network design 1 netwoAKHIL969626
 
9Tuts.Com New CCNA 200-120 New CCNA New Questions 2
9Tuts.Com New CCNA 200-120 New CCNA   New Questions 29Tuts.Com New CCNA 200-120 New CCNA   New Questions 2
9Tuts.Com New CCNA 200-120 New CCNA New Questions 2Lori Head
 

Semelhante a International Journal of Computational Engineering Research(IJCER) (20)

Data Acquisition and Control System for Real Time Applications
Data Acquisition and Control System for Real Time ApplicationsData Acquisition and Control System for Real Time Applications
Data Acquisition and Control System for Real Time Applications
 
ETHERNET PACKET PROCESSOR FOR SOC APPLICATION
ETHERNET PACKET PROCESSOR FOR SOC APPLICATIONETHERNET PACKET PROCESSOR FOR SOC APPLICATION
ETHERNET PACKET PROCESSOR FOR SOC APPLICATION
 
Design and Development of ARM9 Based Embedded Web Server
Design and Development of ARM9 Based Embedded Web ServerDesign and Development of ARM9 Based Embedded Web Server
Design and Development of ARM9 Based Embedded Web Server
 
HIGH PERFORMANCE ETHERNET PACKET PROCESSOR CORE FOR NEXT GENERATION NETWORKS
HIGH PERFORMANCE ETHERNET PACKET PROCESSOR CORE FOR NEXT GENERATION NETWORKSHIGH PERFORMANCE ETHERNET PACKET PROCESSOR CORE FOR NEXT GENERATION NETWORKS
HIGH PERFORMANCE ETHERNET PACKET PROCESSOR CORE FOR NEXT GENERATION NETWORKS
 
Engineer new post -hangzhou wumu technology co.,ltd.The Design of Human-Mach...
Engineer new post  -hangzhou wumu technology co.,ltd.The Design of Human-Mach...Engineer new post  -hangzhou wumu technology co.,ltd.The Design of Human-Mach...
Engineer new post -hangzhou wumu technology co.,ltd.The Design of Human-Mach...
 
iot
iotiot
iot
 
Dynamic classification in silicon-based forwarding engine environments
Dynamic classification in silicon-based forwarding engine environmentsDynamic classification in silicon-based forwarding engine environments
Dynamic classification in silicon-based forwarding engine environments
 
Nt1310 Unit 5 Algorithm
Nt1310 Unit 5 AlgorithmNt1310 Unit 5 Algorithm
Nt1310 Unit 5 Algorithm
 
Project report,nowrin
Project report,nowrinProject report,nowrin
Project report,nowrin
 
Juniper Networks Router Architecture
Juniper Networks Router ArchitectureJuniper Networks Router Architecture
Juniper Networks Router Architecture
 
chameleon chip
chameleon chipchameleon chip
chameleon chip
 
Rodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementationRodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementation
 
Secure remote protocol for fpga reconfiguration
Secure remote protocol for fpga reconfigurationSecure remote protocol for fpga reconfiguration
Secure remote protocol for fpga reconfiguration
 
Secure remote protocol for fpga reconfiguration
Secure remote protocol for fpga reconfigurationSecure remote protocol for fpga reconfiguration
Secure remote protocol for fpga reconfiguration
 
IRJET- SDN Simulation in Mininet to Provide Security Via Firewall
IRJET- SDN Simulation in Mininet to Provide Security Via FirewallIRJET- SDN Simulation in Mininet to Provide Security Via Firewall
IRJET- SDN Simulation in Mininet to Provide Security Via Firewall
 
Implementation of linux based uart device driver
Implementation of linux based uart device driverImplementation of linux based uart device driver
Implementation of linux based uart device driver
 
Openstack Workshop (Networking/Storage)
Openstack Workshop (Networking/Storage)Openstack Workshop (Networking/Storage)
Openstack Workshop (Networking/Storage)
 
IRJET- Autonomous Underwater Vehicle: Electronics and Software Implementation...
IRJET- Autonomous Underwater Vehicle: Electronics and Software Implementation...IRJET- Autonomous Underwater Vehicle: Electronics and Software Implementation...
IRJET- Autonomous Underwater Vehicle: Electronics and Software Implementation...
 
Running head network design 1 netwo
Running head network design                             1 netwoRunning head network design                             1 netwo
Running head network design 1 netwo
 
9Tuts.Com New CCNA 200-120 New CCNA New Questions 2
9Tuts.Com New CCNA 200-120 New CCNA   New Questions 29Tuts.Com New CCNA 200-120 New CCNA   New Questions 2
9Tuts.Com New CCNA 200-120 New CCNA New Questions 2
 

International Journal of Computational Engineering Research(IJCER)

  • 1. I nternational Journal Of Computational Engineering Research (ijceronline.com) Vol. 2 Issue. 8 Development Of Embedded Ethernet Drivers For Arm9 1, T.Satyanarayna 2, S.Latha(Associate Proffesor) 1,2, , Dept of Electronics & Co mmunication Engineering, Aurora Technological & Research Institute, . Jawaharlal Nehru Technological Un iversity. Abstract with the widely application of ARM technique, building the embedded operating system based on ARM processor has been a hot point of research. In this paper, the design of network device driver in Linu x operating system based on ARM920T processor is imple mented on the S3C2410- S development platform made in Beijing universal pioneering technology. Focused on discussing imp lementation principle of embedded Linu x network drivers and detailed to analysis of the frame structure of the program code. Keywords-A RM9 processor; embedded linu x; net work device driver; CS8900A 1. Introduction Now the people more and more like open-source software. As a powerful and stable open-source operating system, Linu x is acclaimed by the thousands of computer expert and amateur. In the embedded field, Linu x can be cured in dozens of megabytes of memory chips or SCM after small cutting. So that it can be used in a specific context of embedded Linu x. Strong network support functions of Linu x ach ieved support for multiple protocols including TCP / IP, and it meets the demand for embedded systems application networking for the 21st century. Therefore, when developing and debugging embedded systems, network interface almost become indispensable module. 2. INTRODUCTION OF LINUX NETWORK DEVICE DRIVER Linu x network device driver is an important part of Linu x network application. The whole Linu x Network driver follows the common interface. For each network interface, it uses a device data structure. Generally, the network device is a physical device, such as Ethernet card.Network driver must solve two problems: first, not all network device driver based on Linu x kernel have control equipment; second, Ethernet device in the system is always called / dev/eth0, dev/eth1 etc., regardless of the underlying device driver. When initialization routines of each network device are called, the driver will return a status, whichindicating whether it is orientation to an instance of the driven controller. If the driver does not find any device, then the entries pointed to the device lists by the „dev_base‟ will be deleted. If the driver can find a device, then the rest of the device data structure is filled by this device information and the address of support function in network device driver. 3. Architecture Of Linux Network Device Driver Shown in Fig. 1, the architecture of Linu x netwo rk driver can be divided into four levels. Linu x kernel source code provided the network device interface and the code above level. Therefore the main work wh ich transplanting specific network hardware drivers is to complete the corresponding code of the device driver function layer. According to the specific bottom hardware features, Structure variable of network device interface „struct net_device‟ type is defined and corresponding operation function and interrupt handling program are imp lemented. Figure 1.Architecture of Linu x network driver 4. Ethernet Controller Chip Cs8900a Cs8900a is a 16-bit Ethernet controller p roduced byCIRRUS LOGIC, embedded on-chip RAM , 10VASE- T transceiver filter and direct ISA bus interface. The salient feature of the chip is flexible to use, and it can dynamically adjust according to needs for its physical layer interface, data transfer mode and work mode, and it can adapt to different application environment through setting internal reg ister. CS8900A can be operated in memory mode and I / O ||Issn 2250-3005(online)|| ||December|| 2012 Page 280
  • 2. I nternational Journal Of Computational Engineering Research (ijceronline.com) Vol. 2 Issue. 8 mode. When CS8900A is configured to Memory Mode operation, its internal registers and frame buffer are mappedto a serial 4KB host memory block, the host can directly access CS8900A's internal registers and frame buffer through the block. 5. Design And The Implementation Principle Of Network Driver Linu x network system can comp lete data transfer between all levels through the socket buffer sk_buff, data structure sk_buff is each protocol data processing object. sk_buff is the media of exchange data between driver and network. When the driver sends data to the network, data source and data length must be obtained. Data must be saved in sk_buff also after the driver received data fro m thenetwork. Thus upper layer protocol can process it.For the actual development of Ethernet driver, corresponding template program in the kernel source tree can be consulted, focused on understanding the implementation principle of network driver and program structural framework. Then the code is rewritten to develop specific hardware, and achieve the appropriate operation function. Through transplanting and preparing the embedded CS8900A network card driver on embedded development board (S3C2410 processor) to show the implementation principles of network driver. A. Initi alization Functi on Initialization of network equipment is co mpleted mainly by initialization function which is referred by init function pointer in device data structure. After the kernel load the network driver module, in itializat ion process will be called. First it is necessary to detect whether network physical device exist, which is completed by detecting the physical device hardware characteristic. Then the resource equipment needed is configured, such as interrupts. Next the device„device‟ data structure is constructed. The relevant variable in the device is initialized by detected data, and finally thedevice is registered to the Linu x kernel and applies memory space.In this instance, the initialization function is “_init cs8900a_s3c2410(void)”. In the network device driver, the device „device‟ data structure is dev_cs89x0, which is defined as follows. #ifdef MODULE static struct net_device dev_cs89x0={ ‟‟‟‟, 0, 0, 0, 0,0, 00, 0, 0, NULL,NULL};The function „cs89x0_probe‟ detect the existence of the network physical device, but device init ialization is comp leted by two functions „cs89x0_probe‟ and„cs89x0_probe1‟ together. In „cs89x0_probe1‟, the function pointers of „device‟ data structure are filled.After comp letion of filling pointer, to register by„register_netdev‟ (struct net_device * dev) function. Two function register_netdev‟ and „unreg ister_netdev‟ are defined in file „net_init.c ‟.Since there is „init‟ function, there should also be„cleanup‟ function, because they are essential function of each driver. The „cleanup‟ function run when module is unloaded, wh ich comp lete mainly the work of resource release. Such as cancel device registration, free memory, release the port, etc. All in all, it is some action contrary to init.The function of Cancellation of network device registration is „unregister_netdevice‟ defined in file / net / core / dev.c, this function is called in „unregister_netdev‟. B. Open Functi on When system response „ifconfig‟ co mmand, a network interface will be opened (closed). The „ifconfig‟ command given address to interface by calling ioctl‟ (SIOCSIFADDR). Response of SIOCSIFADDR is accomplished by the kernel, and device-independent. Then, the „ifconfig‟ co mmand set IFF_UP bit of dev-> flag to open the device by calling „ioctl‟ (SIOCSIFFLA GS). The device's open method is called through the above called. In the network device driver, Open function is called when network device is activated, that device status becomes fro m down to up. So a lot of initialization wo rk can be done here. In open function, operation on the register uses two functions: „readreg‟ and „writereg‟. „readreg‟ function is used to read the register contents, „writereg‟ function is used to write registers, the code is as follows : inline int readreg(struct net_ device *dev,int portno){ outw(portno,dev->base_addr+ADD_PORT); return inw(dev->base_addr+DATA_PORT); }inline void writereg(struct net_ device *dev,int portno,int value){ outw(portno,dev->base_addr+ADD_PORT); outw(value,dev- >base_addr+DATA_PORT); } C. Close Functi on Close function (net_close) releases resources to reduce system burden. It is called when the device status becomes fro m up to down. In addition, if the driver is loaded as a module, the macro MOD_DEC_USE_COUNT need to call in close also, to reduce the frequency of equipment cited in order to uninstall the driver. ||Issn 2250-3005(online)|| ||December|| 2012 Page 281
  • 3. I nternational Journal Of Computational Engineering Research (ijceronline.com) Vol. 2 Issue. 8 D. Send Functi on Sending and receiving of data packets are two key processes achieving Linux network driver, good or bad of the two processes affected directly the driver's overall running quality. First of all, when the network device driver is loaded, device is initialized by init function pointer in the device domain calling network device in itialization function. If the operation is successful, device is opened by open function pointer in the device domain calling network device open function. Next, hardware packet header information is set up by building hardware packet header function pointer hard_header in the device domain. Finally, the packet sent is completed through protocol interface layer function dev_queue_xmit calling function pointer hard_start_xmit in the device domain. If sent successfully, sk_buff is released in hard_start_xmit method, and return 0 (send success). If the device can not be process temporarily, such as the hardwareis busy, and then return 1. At this time if the dev-> tbusy is set to non-zero, the system regards that the hardware is busy, it will not re-send until dev-> tbusy is set to 0. tbusy's setting zero task is completed by interrupt generally. Hardware interrupt at the end of sent, at this time tbusy can be set to 0, then call mark_bh () to notify system to re- sent. In the case of sending unsuccessful, dev-> tbusy can not be set to non- zero, this system will try to resent continuously. If hard_start_xmit is not sent successful, then sk_buff cannot be release. The data which is sent in Sk_buff already contains the frame head of hardware requirement. Hardware frame head need not be fill in send method, data can be sent directly to the hardware. sk_buff is locked, and it is assured that other programs will not access it. E. Recei ve Function Receive function is different from receive data, network interface does not provide receive function pointer similar to net_receive_packet, because that network device receive data is achieved through interrupts. Upon receiving the information, an interrupt is generated, the driver will apply a sk_buff (skb) in interrupt handler, and the data read from hardware is placed to applied buffer. Next, some informat ion is filled in sk_buff. skb-> dev = dev judges protocol type ofreceived frame, and fills in the skb-> protocol (mult i- protocol support). Pointer skb-> mac.raw point to the hardware data and then discard the hardware frame head (skb_pull). A lso skb-> pkt_type is set, indicating the type of data link layer. If the data packet is obtained, then net_rx() is implemented, net_rx () is a subroutines of data reception, it is called by interrupt service routine. Last the data is sent to the protocol layer by calling netif_rx (). netif_rx () put data into the processing queue and then return, the real processing will be implemented after interrupted return. Thus interrupt time is reduced. After netif_rx () is called, the driver cannot be saved in data buffer skb. In the protocol layer, flows control of receiv ing data packets is divided into two levels: first, netif_rx () function is limited the number of data frames fro m the physical layer to protocol layer. Secondly, each socket has a queue, which limits the number of data frames fro m the protocol layer to the socket layer. In transmission, the dev-> t x_queue_len parameter in driver limits the length of the queue. F. Interrupt Hhandler In the open function, the interrupt is applied, the interrupt handler is net_interrupt. The preparation of writ ing this function is to understand the interrupt process of network control chip. For the CS8900A chip, this process can explain the flow chart using fig. 2. First kernel need to read ISQ (Interrupt Status Queue) value, ISQ event has the following 5 types: #define ISQ_RECEIVER_ EVENT 0x04 #define ISQ_TRANSMITTER_EVENT 0x08 #define ISQ_BUFFER_EVENT 0x0c #define ISQ_RX_MISS_ EVENT 0x10 #define ISQ_TX_ COL_ EVENT 0x12 After receiving a data packet (RxEvent), to deliver function net_rx() to process. Interrupt handler parameter is set as follows: Static void net_interrupt(int irq ,void *dev_id ,structpt_regs *regs ||Issn 2250-3005(online)|| ||December|| 2012 Page 282
  • 4. I nternational Journal Of Computational Engineering Research (ijceronline.com) Vol. 2 Issue. 8 Figure 2.Interrupt handling flo wchart 6. DRIVER TEST Driver is only provided interface between kernel and user. To use the device, not only to install the driver, but also must write an application to use it. After the network driver is designed, the kernel module can be compiled, and the custom kernel module as part of the system source code is compiled a new system. A. Configuring The Kernel In Linu x2.6 kernel, want to compile the kernel module, first it is necessary to configure and construct properly kernel source tree in / usr / src, that is, to extract the need kernel source code to / usr / src /, and to use the command „make menuconfig‟or „make gconfig‟ configure the kernel under the main directory of kernel source (Here is / usr/src/linux-2.6.18.3), then using the „make all‟ to comp ile the kernel comp letely. B. Take CS8900A NIC driver for example, introduce how to compile network device driver into the kernel. z To create a new directory cs8900a under the directory „drivers‟ of system source code tree; z To copy cs8900a.c and cs8900a.h to drivers/cs890a directory; z To co mpile „Makefile‟ file under drivers/cs890a directory; #Makefile fo r CS8900A network Driver obj -$(CONFIG_ DRIVER_CS8900A) +=cs8900a.o z To comp ile „Kconfig‟ file under drivers/cs890a directory; #Just for CS8900A network device menu "CS8900A network device support" config DRIVER_ CS8900A tristate "CS8900A support" This is a network driver module fo r CS8900A. end menu z To add a line in front of„end menu‟ statement of „Kconfig‟ file In the „driver‟ directory source "drivers/cs8900a/Kconfig" In main directory of kernel source code tree, “CS8900A network device support [y / n /?]” can be found in the option „Device Drivers‟ through command „make menuconfig‟ or „make gconfig‟ , if select "y", the kernel will prov ide support for network driver. To recompile the kernel can be obtain kernel of supported CS8900A card, then download the kernel to the development board. By configuring network parameters, the behavior of the network card driver can be test. 7. CONCLUSION In recent years, Internet has a rapid development. Remote monitoring and remote maintenance become very easy after embedded system access internet, so the network of embedded systems is very important. Embedded system achieved internet access; its prerequisite is that system software has TCP/IP protocol support. Fortunately, Linux kernel provides support for multiple protocols including TCP/IP. This paper takes network chip CS8900A for examp le, and introduces the key process of imp lementing network driver. ||Issn 2250-3005(online)|| ||December|| 2012 Page 283
  • 5. I nternational Journal Of Computational Engineering Research (ijceronline.com) Vol. 2 Issue. 8 8. Acknowledgment This research was supported by the Open Project Program of Key Laboratory of Intelligent Manufacture of Hunan Province (Xiangtan University), China ( No.2009IM 03). References [1] Q.Sun, Developing Detail Exp lain of Embedded Linu x Application, Beijing, Posts & Telecom Press, July 2006. [2] T.Z.Sun and W.J.Yuan, embedded design and Linu x driver development guide, Beijing, Publishing House of Electronics Industry, October 2009. [3] M.liu, Embedded system interface design and Linu x driver develop ment, Beijing, Beihang University Press,May 2006. [4] L.G.Zhou, Examp le of A RM Embedded Linu x System Build ing and Driver Develop ment, Beijing, BeihangUn iversity Press, 2006. [5] C.Qian, R.H.Xu and Q.R.Wang, “Device Driver Develop ment Based on Linu x Operating System”, Control & Auto mat ion,2004,(09). [6] Q.N.Cao, B.Zhao and K.Y.Meng, “Design and realizat ion of embedded linu x net work communication system based on ARM9 platfo rm “, Journal of Northwest University(Natural Science Ed it ion), 2009,(1). [7] J.Zhao,X.Q.Ding, “Develop ment and Implementation Principle o f Net work Driver Based on Embedded Linu x”, M icroco mputer In format ion, 2008,(17). [8] F.J.Li and W.D.Jin, “Research and Implementation of Netwo rk Driver in Embedded Linu x”, Modern Elect ronic Technique, 2005(16) [9] W.Su, “Design of Linu x Network Device Driver” Financial Co mputer of Huanan, 2005(06). [10] D.Cao and K.Wang, “Research of Network Dev ice Driver based on Linu x” , Co mputer Knowledge and Technology, 2005( 21). [11] Q.Wu, SH.H.Zhou and ZH.X.Ma, “Develop ment of Linu x Net work Driver Based on USB Device”, M icroco mputer Info rmation, 2007,(02). V12-448 ||Issn 2250-3005(online)|| ||December|| 2012 Page 284