f9 microkernel app development part 1
DESCRIPTION
Brief about app development of F9 MicrokernelTRANSCRIPT
Part 1 : App Development
ben6 2014-‐03-‐10
F9-‐Microkernel
Agenda
• F9 user mode API introduc?on • F9 API for basic app • Analyzing l4test app • Your first f9 app prac?ce
F9
F9 user mode API introduc?on
• Due to F9-‐Microkernel is a l4 kernel. – Start it on L4test. It is basis of L4 kernel
• Use many structure Macro – Find user app entry from main()
reading user/apps/pingpong
• Learn from reading, then prac?ce • Entry: main.c: main()
• F9 API for basic app (Ex: pingpong)
• DECLARE_USER(_?d, _name, _entry, ...) • Create 2 Thread By L4_Msg API – with Info (stack size …)
• Thread 1: ping_thread – L4_Send message to pong thread
• Thread 2: pong_thread – L4_MsgStore message from ping thread
user_run?me.h:DECLARE_USER 31 user_fpage_t _user_fpages_##_name[] \ 32 __a^ribute__((sec?on(".user_data"))) = { \ 33 __VA_ARGS__ \ 34 {.base = 0x0, .size = 0x0} \ 35 }; \ 36 sta?c void _user_entry_##_name(void); \ 37 user_struct _user_struct_##_name \ 38 __a^ribute__((sec?on(".user_run?me"))) = { \ 39 .?d = _?d, \ 40 .entry = _user_entry_##_name, \ 41 .fpages = _user_fpages_##_name, \ 42 .name = #_name, \ 43 }; \ 44 sta?c void __USER_TEXT _user_entry_##_name(void) \ 45 { \ 46 _entry(&_user_struct_##_name); \ 47 while (1) \ 48 L4_Sleep(L4_Never); \ 49 }
__USER_TEXT
#define __USER_TEXT \ __a^ribute__ ((sec?on(".user_text")))
Func?on uses __USER_TEXT put into .user_text sec?on which defines by f9.ld
Expanded apps/pingpong/main.c
gcc -‐E main.c -‐I../../include -‐I../../../include | grep -‐v "^$"
Expansion let you easy to know whole
code structure
user_text: f9.ld
__USER_TEXT
__ISR_VECTOR
INIT_HOOK(_hook, _level)
L4_Msg
• L4_Msg_t msg; • L4_MsgClear • L4_MsgAppend • L4_MsgLoad • L4_Send
Agenda
• F9 user mode API introduc?on • F9 API for basic app • Analyzing l4test app • Your first f9 app prac?ce
F9
Analyzing l4test app
• Code reading – Start from apps/l4test/main.c
Agenda
• F9 user mode API introduc?on • F9 API for basic app • Analyzing l4test app • Your first f9 app prac?ce
F9
Your first f9 app hello prac?ce
• Wri?ng f9 app step by step • Clone the pingpong • Modify the name • Change to print hello in 3 ?mes with a ?me interval
• Ques?on: how to call sleep? – Reference
• l4test/l4test.h:void msec_sleep(L4_Word_t msec);
user/include/l4io.h
int vsnprinv(char *str, L4_Size_t size, const char *fmt, va_list ap); int snprinv(char *str, L4_Size_t size, const char *fmt, ...); int prinv(const char *fmt, ...); void putc(int c); int getc(void);
Lab 2 Rocks with gpio
• Use ./include/plavorm/stm32f4/gpio.h • Control the led on/off via menu app • Hint: Reference the apps/l4test/menu.c
Discussions
?
F9
References • F9 Microkernel source code and introduc?on
• GCC Naked A^ribute • ARM: Memory Model of Cortex M4
• Cortex™ -‐M4 Devices Generic User Guide pdf • tu-‐dresden's fiasco Microkernel
• General-‐purpose Input/Output (GPIO)