780 likes | 795 Views
Configurable OS Design for Embedded SoC Systems. Advisors: Prof. Shi-Wu Lo Prof. Chih-Wen Hsueh. Ph.D. Student: Hsin-hung Lin. Outline. Introduction Configurable OS on SOA Implementation of COS Configuration Tool for Embedded Systems
E N D
Configurable OS Design for Embedded SoC Systems Advisors: Prof. Shi-Wu Lo Prof. Chih-Wen Hsueh Ph.D. Student: Hsin-hung Lin Real-Time Systems Lab.
Outline • Introduction • Configurable OS on SOA • Implementation of COS • Configuration Tool for Embedded Systems • Performance Evaluation and Case Study • Conclusion and Future Work Hsin-hung Lin
Various Requirements Hsin-hung Lin
Various Requirements (2) Hsin-hung Lin
OS Evaluation Criteria Embedded.com June 2006 Survey Results Hsin-hung Lin
100 10 Performance Performance 1 Programmability 0.1 Months Weeks Hours Years Days Design Period Reconfigurable Processor ASIC Reconfigurable Processor FPGA DSP CPU Hsin-hung Lin
Motivation • Why general-purpose OS not work? • Poor performance. • Lack support for new applications. • Not optimally utilize the embedded platform. • Extra code. • Why not design an AP-specific OS? • Too time-consuming and expensive. • May not be compatible with existing AP. Hsin-hung Lin
Goal • Fine-granular configurable embedded OS. • Easily create or modify kernel services. • Can optimize system resources. • Better support for applications. • Footprint of the OS can be minimized. • Growth in functionality may be limitless. • Work within a familiar and proven environment. • Shorter development cycles. Hsin-hung Lin
Contribution • COS is able to fit applications by configuring kernel components or implementing new kernel features through the standardized efficient interfaces without much kernel knowledge and overhead. • BSPXML is a open and standard language to describe hardware specification and software bootstrap in embedded systems. • System configuration tool is able to automate and integrate embedded hardware and software development processes systematically. Hsin-hung Lin
Outline • Introduction • Configurable OS on SOA • Implementation of COS • Integrated System Configuration Tool • Performance Evaluation and Case Study • Conclusion and Future Work Hsin-hung Lin
Service Oriented Architecture • SOA provides better flexibility, agility and scalability to a system. • Developers are still developing a component to perform an OS service. • building the OS up from existing services. • simplify much of the work. • assure a uniform product across various other systems. Hsin-hung Lin
… User Space MP3 MPEG4 Home Control Digital Album EDF RT Task Buddy Bitmap NRT Task RM Paging PW Thread SOA Kernel Space COS MM Sched Task … Interfaces Kernel HAL BSP Tool Porting ARM MIPS ISS UniCore SOC … Configurable OS on SOA System Configuration Tool Hsin-hung Lin
Configurable OS on SOA • An Interface is the abstraction layer between the kernel and that specific OS service. • Analyze and trace various embedded OSes. • Linux, uC/OSII, eCoS, ThreadX. Hsin-hung Lin
COS COS Interface Concept Hsin-hung Lin
Kernel Configuration • Compile-time configuration. • Components that are tightly coupled with system operation. • Services need at system boot time. • Run-time configuration. • Not used at system boot time. • A default component can be specified. • Useful when various components or algorithms need to be tested. • System configuration tool. Hsin-hung Lin
Interrupt Handling • Various peripherals in embedded systems. • Different vendors may design or use different interrupt controllers. • Register definitions, • Handling mechanisms. Hsin-hung Lin
Interrupt Handling Interface void setup_if_interrupt(void); unsigned int (*get_irq_state)(void); void (*set_irq_state)(unsigned int state); // \#\# TOP HALF sub-interface \#\# void (*init_irq)(void); void (*do_irq)(unsigned int irq, void * regs); void (*ack_irq)(unsigned int irq); void (*clear_pending_irq)(void); void (*enable_irq)(void); void (*disable_irq)(void); void (*mask_irq)(unsigned int irq, int register_ID); int (*reg_irq) (unsigned int irq, void * action, void * ext_data); int (*unreg_irq)(unsigned int irq, void * ext_data); Hsin-hung Lin
Interrupt Handling Interface(2) // \#\# BOTTOM HALF sub-interface \#\# void (*init_softirq)(void); void (*do_softirq)(unsigned int softirq, void * ext_data); void (*ack_softirq)(unsigned int softirq); void (*set_pending_softirq)(unsigned int softirq); unsigned int (*get_pending_softirq)(void); void (*clear_pending_softirq)(void); void (*enable_softirq)(void); void (*disable_softirq)(void); void (*mask_softirq)(unsigned int softirq, int register_ID); int (*reg_softirq) (unsigned int softirq, void * action, void * ext_data); int (*unreg_softirq)(unsigned int softirq, void * ext_data); Hsin-hung Lin
Timer • Different embedded platforms may use different timer devices. • Number of timers, • Operation modes, • Register definitions, • Timer resolutions. Hsin-hung Lin
Timer Interface void setup_if_timer(void); void (*init_timer)(unsigned int timer_ID); void (*start_timer)(unsigned int timer_ID); void (*stop_timer)(unsigned int timer_ID); void (*set_timer_interval)(unsigned int interval, unsigned int timer_ID); void (*set_timer_periodic)(unsigned int timer_ID); void (*set_timer_oneshot)(unsigned int timer_ID); void (*set_timer_unit)(enum TIMER_UNIT timer_unit, unsigned int timer_ID); void (*get_timer_info)(unsigned int timer_ID, int *interval, int *unit, int *mode); Hsin-hung Lin
Scheduler • Various systems requirements. • Real-time, • Power-aware, • High throughput. • Use the proposed power-aware real-time scheduling as an example. Hsin-hung Lin
Scheduler (Cont.) Extending Existing Interface Current Time Timer Scheduler A Time of next timer interrupt Scheduler B Other components Scheduler C Scheduler Interface Hsin-hung Lin
Scheduler Interface struct off_sched *offsched; struct rt_time init_time; struct rt_task *sched_result; int (*start_sched)(struct rt_time); int (*end_sched)(void); struct rt_time (*schedule)(struct rt_time); int (*new_task)(struct rt_task*); int (*delete_task)(struct rt_task *); int (*new_job)(void); Hsin-hung Lin
Memory Management • Memory leak. • External fragmentation. • Inflexible design. • Poor locality of reference. • Hardware specific issues. Hsin-hung Lin
Memory Management Interface int size_phymem; int size_usemem; int size_freemem; void *freemem_list; void *usemem_list; void setup_if_mem(void); void (*mem_init)(void* para, int selection); void (*kmalloc)(int size, int flag, int selection, void *addr); int (*kfree)(void *addr, int selection); Hsin-hung Lin
File System • More needs due to multimedia. • Support more than one file systems. • An interface between APs and file systems. Hsin-hung Lin
File System Interface • Linux uses VFS (Virtual File System) as an abstraction layer for file systems to enable kernel to perform operations on various underlying file systems. • VFS defines general file operations including open(), read(), write(), llseek(), etc. • COS adapt the interface of VFS. Hsin-hung Lin
File System Interface (2) loff_t (*llseek) (struct file *, loff_t, int); ssize_t (*read) (struct file *, char *, size_t, loff_t *); ssize_t (*write) (struct file *, const char *, size_t, loff_t *); int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long); int (*mmap) (struct file *, struct vm_area_struct *); int (*open) (struct inode *, struct file *); int (*release) (struct inode *, struct file *); int (*fsync) (struct file *, struct dentry *, int datasync); Hsin-hung Lin
Outline • Introduction • Configurable OS on SOA • Implementation of COS • Integrated System Configuration Tool • Performance Evaluation and Case Study • Conclusion and Future Work Hsin-hung Lin
Embedded OS Trend Embedded Linux Market Survey, LinuxDevices.com, May 2006 Hsin-hung Lin
Implement COS in Linux • We apply the COS design to Linux and port it on a Creator ARM9 evaluation board. • Most developers are familiar with Linux programming environment and there is much support in kernel itself and related tools. • It would be easier to remove unnecessary features from a full-blown OS than to implement all needed features in a small, limited OS. Hsin-hung Lin
Implementation of COS • We patch the COS initialization functions to replace the original Linux ones of each kernel service. • When system booting, the service components are registered during kernel initialization. • COS can substitute the interfaces with actual service component implementations. • The most effort is to redirect original kernel calls to the COS interfaces and re-construct parameters to pass to the components. Hsin-hung Lin
COS Implementation Flow Memory Management2 TS Interface MM Interface IS Interface Task Scheduler Memory Management Interrupt Scheduling LinuxKernel COSKernel Module …… File System Mod Interface FS Interface …… Hsin-hung Lin
Components of COS Hsin-hung Lin
Outline • Introduction • Configurable OS on SOA • Implementation of COS • Integrated System Configuration Tool • Performance Evaluation and Case Study • Conclusion and Future Work Hsin-hung Lin
Application Libraries User level System call interface Kernel with subsystem Device driver HAL Kernel level Hardware level Hardware OS Porting Build the suitable tool chain (CPP, GCC, AS, LD) Revise the machine-dependent code Understand the hardware spec. clearly Hsin-hung Lin
BSPXML BSPDTD Element, Entity definition BSPXML Board Tree SoC • OCF: Interrupt controller • OCF: Timer • OCF: Memory controller • Basic register initialize • MMU/Cache initialize • … OCF: On Chip Function Peripheral Device • Flash driver • Serial driver • Network driver • … Related Tools • Cross compiler • Debug tool • … Define by hardware manufacturer Bootstrap • Setup the basic environment variable • Invoke hardware initial functions from hardware define • Insert the related procedure code according the demand Redefine by software developer Hsin-hung Lin
BSPXML Board SoC Timer TimerInit TimerStart TimerStop Extend by oneself Extend by oneself Device Related tools Bootstrap Extend by oneself Hsin-hung Lin
SoC Element of an Example BSPXML <BOARD name="Creator" manufacture="Microtime"> <SOC family="ARM" core="920T" manufacture="Samaung" id="S3C2410X01"> <OCF name="core" defusr="&hardware;"> <FUNC name="SetProcessorModeUsr" lang="ASM"> mrs r0,cpsr bic r0,r0,#0x1f orr r0,r0,#0x10 msr cpsr,r0 mov pc,lr </FUNC> … <OCF name="timer" defusr="&hardware;"> <FUNC name="Timer4Init" return="void" argu="void" lang="C"> int timerloadvalue, tenms=100; timerloadvalue = 50*1000000/16/2/tenms; rTCFG0 = 0x0f00; rTCNTB4 = timerloadvalue; rTCON = 0x600000; rTCON = 0x500000; </FUNC> … <FUNC name="Timer0Init" return="void" argu="void" lang="C"> //nop </FUNC> </OCF> … </SOC> </BOARD> Hsin-hung Lin
Bootstrap Element of an Example BSPXML <BOOTSTRAP> <ENV_VAR> <FLASH_START> &flash_saddr; </FLASH_START> <FLASH_END> &flash_saddr;+&flash_size;-1 </FLASH_END> <SDRAM_START> &sdram_saddr; </SDRAM_START> … </ENV_VAR> <INIT_HEAD> <BL fname=“SetProcessorModeSvc”></BL> <BL fname=“WatchdogOff”></BL> <BL fname=“InterruptAllServiceOff”></BL> … </INIT_HEAD> <INIT_CMAIN> <INVOKE fname=“SerialInit”></INVOKE> <INVOKE fname=“Timer4Init”></INVOKE> … </INIT_CMAIN> </BOOTSTRAP> Hsin-hung Lin
Hardware Manufacturer BSPXML Board Tree SoC Peripheral Device Tool chain Bootstrap BSPXML Board Tree SoC Peripheral Device Tool chain Bootstrap New Hardware Platform BSP Tool Software Developer BSPDTD Output: Bootstrap Code & Low-level Functions BSP Parser Modify or write the BSPXML Code Generator Hsin-hung Lin
Low-Level Function Provided by the BSP Tool OS kernel Related Tool StartKernel() Interface Library Component: Printf, Malloc, strcpy... BSP Components Interface Boot Procedure Component Processor-related Misc. Component : Interface Interface Memory Component: MMU, memory.. Interface Device Component : Network, Flash, LCD… Timer Component: Init, Enable… Interface Interface Interrupt Component: Init, Enable, Disable… Environment variable: Address Mapping, Makefile… Software Level Hardware Level Target Platform Hsin-hung Lin
Use of BSP Tool • For hardware manufacturer • Define hardware specification in BSPXML • Provide tool chains or support information in BSPXML • For software developer • Familiar with the BSPXML and reuse or write the Bootstrap element of the BSPXML • Use the BSP tool to parse BSPXML and generate bootstrap code Hsin-hung Lin
System Configuration Tool • Extend the BSP tool. • Open, standardize, extendable and re-usable. • Help to configure the proposed OS. • Ease the integration process. • Release porting difficulties. • Shorten the time to market. Hsin-hung Lin
System Configuration Tool (2) • Configurations will be generated as meta configuration files and are included in system building processes. • 32kB size of both instruction and data cache. • Build the corresponding verilog RTL code which the instruction and data cache size is 32kB. • COS can correctly manipulate cache of 32kB. Hsin-hung Lin
HW Testing Files HW verification BSPXML Verilog Meta File RTL Hardware Building Process OS, Toolchain, ESL OS, Toolchain, ESL OS, Toolchain, ESL BSP Tool Meta File C, C++ Java Software Building Process SW verification SW Testing Files System Development Process Hsin-hung Lin
Configuration of COS • Use of KBuild system. • Generate header file via BSPTool Hsin-hung Lin
“Kernel Configuration” Menu Hsin-hung Lin
“SOA Options” Menu (2) Hsin-hung Lin
Outline • Introduction • Configurable OS on SOA • Implementation of COS • Integrated System Configuration Tool • Performance Evaluation and Case Study • Conclusion and Future Work Hsin-hung Lin