Presentation is loading. Please wait.

Presentation is loading. Please wait.

2006/1/201IGEL Co.,Ltd. / Renesas Solution Corp. Studies on User Level Device Driver in Embedded Environment ( Progress Report ) Katsuya Matsubara IGEL.

Similar presentations

Presentation on theme: "2006/1/201IGEL Co.,Ltd. / Renesas Solution Corp. Studies on User Level Device Driver in Embedded Environment ( Progress Report ) Katsuya Matsubara IGEL."— Presentation transcript:

1 2006/1/201IGEL Co.,Ltd. / Renesas Solution Corp. Studies on User Level Device Driver in Embedded Environment ( Progress Report ) Katsuya Matsubara IGEL Co.,Ltd.

2 2006/1/202IGEL Co.,Ltd. / Renesas Solution Corp. Stories so far Investigated behaviors of threads –RT Task vs Non-RT Task Number of Load Tasks Switching Time(WRITE Task->Vertual DD->Read Task)Wakeup Vertual DD->Read Task) Response Time(microsec)

3 2006/1/203IGEL Co.,Ltd. / Renesas Solution Corp. Background and Objectives Want to implement device drivers in user level –Easy to devleop –Reduce system down due to driver bugs – ( Avoid GPL ) Some issues on implementing user level device drivers –Access to I/O memory, physical memory –Forwarding of Interupttion Requests ( IRQ ) –Response performance to interuption – ‥‥ New features in Kernel 2.6 –NPTL(Native POSIX Thread Library) –Sceduler improvement ( O(1) scheduler etc. ) –Kernel preemption –….

4 2006/1/204IGEL Co.,Ltd. / Renesas Solution Corp. Facts in Development of Embedded Software More development of drivers for new devices Applications directly control devices –To minimize latency –More intimate relation between devices and applications, thant desktop PC applications Hiding hardware specification

5 2006/1/205IGEL Co.,Ltd. / Renesas Solution Corp. User Level Device Drivers Implementing Device Drivers in User Space Expected effects –Use of abundant tools/libraries (e.g. files) –Ease of development and debugging –Less system hang ups –Less distance to applications –…. Related research –Peter Chubb, “Get more device drivers out of kernel,” OLS2004.

6 2006/1/206IGEL Co.,Ltd. / Renesas Solution Corp. Features Required for Device Drivers Access to I/O Memory –Device control through register I/O, data I/O Interrupt Receipt and Handling Physical Memory Allocation and Access –Necessary for devices which access directly to memory using DMA, etc. –In case of DMA, allocation of consecutive memory may be required Lock of CPU , Realtime Interface to Applications

7 2006/1/207IGEL Co.,Ltd. / Renesas Solution Corp. Interrupt Receipt and Handling in User Level Device Drivers Interrupt Reciept by File I/O –Prepare device files for each interrupt number –read() the device file and block until interrupt occurs

8 2006/1/208IGEL Co.,Ltd. / Renesas Solution Corp. Memory Access in User Level Device Drivers Direct Access to I/O Memory with Memory Map(mmap) –open(), mmap() the /dev/mem or specific device file –Once mmap’ed, then accessible as usual For Physical Memory, Allocate, then mmap

9 2006/1/209IGEL Co.,Ltd. / Renesas Solution Corp. Interface to Applications in User Level Device Drivers As User Level Device Driver can Exist in the Same User Space as Applications, Such Interfaces as Interprocess Communications, Shared Memory, etc. can Implementable Easy to Integrate with Applications

10 2006/1/2010IGEL Co.,Ltd. / Renesas Solution Corp. CPU Lock, Realtime in User Level Device Drivers With RT Threads, to Some Extent… To be discussed

11 2006/1/2011IGEL Co.,Ltd. / Renesas Solution Corp. Implementation ( Serial Driver ) Implementation Environment –RTS7751R2D Renesas SH4 SM501 companion chip embedding UART –8250 compatible –2 modes: 1 byte I/O and FIFO buffer I/O –Linux CONFIG_PREEMPT=y Glibc 2.3.3

12 2006/1/2012IGEL Co.,Ltd. / Renesas Solution Corp. Processing Interrupt Handling –Receiving Data –Emptying Send Buffer[?] I/O Memory Access –SM501 Register I/O

13 2006/1/2013IGEL Co.,Ltd. / Renesas Solution Corp. Linux Kernel Software Architecture I/O Memory Map DriverInterrupt Hook DriverSM501 UART Terminal App User Level UART D.Driver Data I/O Buffer

14 2006/1/2014IGEL Co.,Ltd. / Renesas Solution Corp. Interrupt Hook Driver static int irqhook_proc_open(struct inode *inop, struct file *filp) {... request_irq(ipp->irq, irqhook_proc_irq_handler, SA_INTERRUPT, ipp->devname, ipp);... } static ssize_t irqhook_proc_read(struct file *filp, char __user *bufp, size_t len, loff_t *ppos) {.... prepare_to_wait(&ipp->q, &wait, TASK_INTERRUPTIBLE); pending = atomic_read(&ipp->count); if (pending == 0) schedule();..... }

15 2006/1/2015IGEL Co.,Ltd. / Renesas Solution Corp. I/O Memory Map Driver int iommap_mmap(struct file *filp, struct vm_area_struct *vma) { size_t size = vma->vm_end - vma->vm_start; unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; vma->vm_flags |= VM_RESERVED; vma->vm_flags |= VM_IO; vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); /* Map each page to users' virtual memory space */ if (io_remap_page_range(vma, vma->vm_start, offset, size, vma->vm_page_prot)) return -EAGAIN; return 0; }

16 2006/1/2016IGEL Co.,Ltd. / Renesas Solution Corp. UART Driver while (1) {.... if (read(fd, &n_pending, sizeof(int) > 0) { if ((status = SM501_UART0_LINESTAT(&iomem)) & 0x01) { do { buffer[count]= SM501_UART0_RXBUFF(&iomem); status = SM501_UART0_LINESTAT(&iomem); count++; if(count >= BUFFER_SIZE){ loop++; count = 0; if(loop >= LOOP_COUNT) goto end; } while((status & 0x01)&&(max_count-- > 0)); }.... }

17 2006/1/2017IGEL Co.,Ltd. / Renesas Solution Corp. Experiment Just started experimenting… Serial I/O –Measured throughput with 1MB READ/WRITE for serial device –Used SM501 byte I/O mode –Kernel drivers are those included in –User level device driver was executed as RT task –User level device driver was integrated with serial I/O process –Connected R2D board and note PC(TeraTerm) with serial cross cable

18 2006/1/2018IGEL Co.,Ltd. / Renesas Solution Corp. Experiment Results 38.4kbps300bps ReadWriteReadWrite User Level DD29.95kbps30.68kbps210.70bps213.34bps Kernel Level DD 29.69kbps28.08kbps232.82bps232.70bps Data Size : 1MB Buffer Size : 1KB Baud Rate : 300 or 38400 bps Mesured values : Average of the 10 trial results of the same experiment

19 2006/1/2019IGEL Co.,Ltd. / Renesas Solution Corp. Impressions Negligible Overhead At least in Low Load Environment (where no one intervenes)? –ULDD is rather faster for 38.4kbps –Deserves analysis – My action item System Stability, Ease of Coding and Debugging, and Abundance of User Land Features are Attractive

20 2006/1/2020IGEL Co.,Ltd. / Renesas Solution Corp. Issues Behavior in Heavy Load Environment –RT tasks / Non-RT tasks Comparison with PC Environment Evaluation with Other Devices Summary of Characteristics of Kernel Level Device Drivers and User Level Device Drivers Seeking for Novelty…

21 2006/1/2021IGEL Co.,Ltd. / Renesas Solution Corp. Discussion

Download ppt "2006/1/201IGEL Co.,Ltd. / Renesas Solution Corp. Studies on User Level Device Driver in Embedded Environment ( Progress Report ) Katsuya Matsubara IGEL."

Similar presentations

Ads by Google