SlideShare a Scribd company logo
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)	
  
	
  
	
  

More Related Content

PDF
F9 Microkernel code reading - part 1
PDF
Building Network Functions with eBPF & BCC
PDF
Linux Kernel Platform Development: Challenges and Insights
PDF
Translation Cache Policies for Dynamic Binary Translation
PPTX
Embedded TCP/IP stack for FreeRTOS
PPT
Bootloader and MMU (english)
PDF
ARM Architecture and Meltdown/Spectre
PPT
Concurrency bug identification through kernel panic log (english)
F9 Microkernel code reading - part 1
Building Network Functions with eBPF & BCC
Linux Kernel Platform Development: Challenges and Insights
Translation Cache Policies for Dynamic Binary Translation
Embedded TCP/IP stack for FreeRTOS
Bootloader and MMU (english)
ARM Architecture and Meltdown/Spectre
Concurrency bug identification through kernel panic log (english)

What's hot (20)

PPTX
Tiny ML for spark Fun Edge
PPTX
Linux Initialization Process (2)
PDF
Emerging Persistent Memory Hardware and ZUFS - PM-based File Systems in User ...
PPTX
QEMU and Raspberry Pi. Instant Embedded Development
PPTX
Kernel Proc Connector and Containers
PDF
Fun with FUSE
PDF
BSD Sockets API in Zephyr RTOS - SFO17-108
PPTX
Raspberry Pi I/O控制與感測器讀取
PDF
New Zephyr features: LWM2M / FOTA Framework - SFO17-113
PPTX
Linux Kernel Booting Process (1) - For NLKB
PDF
Linux SMEP bypass techniques
PPTX
Linux Device Tree
PDF
FreeBSD and Drivers
PPTX
U-boot and Android Verified Boot 2.0
PDF
Linux on ARM 64-bit Architecture
PDF
Davide Berardi - Linux hardening and security measures against Memory corruption
PPTX
Dead Lock Analysis of spin_lock() in Linux Kernel (english)
PPTX
Linux Interrupts
PPTX
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
PDF
Linux Kernel Debugging Essentials workshop
Tiny ML for spark Fun Edge
Linux Initialization Process (2)
Emerging Persistent Memory Hardware and ZUFS - PM-based File Systems in User ...
QEMU and Raspberry Pi. Instant Embedded Development
Kernel Proc Connector and Containers
Fun with FUSE
BSD Sockets API in Zephyr RTOS - SFO17-108
Raspberry Pi I/O控制與感測器讀取
New Zephyr features: LWM2M / FOTA Framework - SFO17-113
Linux Kernel Booting Process (1) - For NLKB
Linux SMEP bypass techniques
Linux Device Tree
FreeBSD and Drivers
U-boot and Android Verified Boot 2.0
Linux on ARM 64-bit Architecture
Davide Berardi - Linux hardening and security measures against Memory corruption
Dead Lock Analysis of spin_lock() in Linux Kernel (english)
Linux Interrupts
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
Linux Kernel Debugging Essentials workshop
Ad

Similar to F9 microkernel app development part 1 (20)

PDF
GPU Programming on CPU - Using C++AMP
PPTX
CS345 09 - Ch04 Threads operating system1.pptx
PDF
C from FW
ODP
A tour of F9 microkernel and BitSec hypervisor
PPTX
Segmentation Faults, Page Faults, Processes, Threads, and Tasks
PPT
Introduction to Microprocessor & Microcontroller.ppt
PPTX
fpga1 - What is.pptx
PPTX
Modern CPUs and Caches - A Starting Point for Programmers
PDF
F9 microkernel code reading part 4 memory management
ODP
CompilersAndLibraries
PDF
Embedded systems development Defcon 19
PPTX
2019 session 5 describe different basic programming codes and languages
PPTX
Gpgpu intro
PDF
Embedded system Design introduction _ Karakola
PDF
Introduction to Microkernels
PPTX
F9 microkernel app development part 2 gpio meets led
PDF
Threads and processes
PPTX
Programming Assignment Help
PDF
Creating an Embedded System Lab
PDF
Dark Silicon, Mobile Devices, and Possible Open-Source Solutions
GPU Programming on CPU - Using C++AMP
CS345 09 - Ch04 Threads operating system1.pptx
C from FW
A tour of F9 microkernel and BitSec hypervisor
Segmentation Faults, Page Faults, Processes, Threads, and Tasks
Introduction to Microprocessor & Microcontroller.ppt
fpga1 - What is.pptx
Modern CPUs and Caches - A Starting Point for Programmers
F9 microkernel code reading part 4 memory management
CompilersAndLibraries
Embedded systems development Defcon 19
2019 session 5 describe different basic programming codes and languages
Gpgpu intro
Embedded system Design introduction _ Karakola
Introduction to Microkernels
F9 microkernel app development part 2 gpio meets led
Threads and processes
Programming Assignment Help
Creating an Embedded System Lab
Dark Silicon, Mobile Devices, and Possible Open-Source Solutions
Ad

More from Benux Wei (6)

PDF
F9 Microkernel code reading part 2 scheduling
PDF
While software engineer meets 3d printer
PDF
Real practice of Networking design on specialized for ARM Cortex-M
PDF
Tdd with python unittest for embedded c
PDF
Stm32 f4 first touch
PDF
Preparation for mit ose lab4
F9 Microkernel code reading part 2 scheduling
While software engineer meets 3d printer
Real practice of Networking design on specialized for ARM Cortex-M
Tdd with python unittest for embedded c
Stm32 f4 first touch
Preparation for mit ose lab4

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Encapsulation theory and applications.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Cloud computing and distributed systems.
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
KodekX | Application Modernization Development
PPTX
Spectroscopy.pptx food analysis technology
PDF
Empathic Computing: Creating Shared Understanding
PDF
MIND Revenue Release Quarter 2 2025 Press Release
Unlocking AI with Model Context Protocol (MCP)
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Dropbox Q2 2025 Financial Results & Investor Presentation
Building Integrated photovoltaic BIPV_UPV.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
NewMind AI Weekly Chronicles - August'25 Week I
Encapsulation theory and applications.pdf
Review of recent advances in non-invasive hemoglobin estimation
Cloud computing and distributed systems.
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Digital-Transformation-Roadmap-for-Companies.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
20250228 LYD VKU AI Blended-Learning.pptx
KodekX | Application Modernization Development
Spectroscopy.pptx food analysis technology
Empathic Computing: Creating Shared Understanding
MIND Revenue Release Quarter 2 2025 Press Release

F9 microkernel app development part 1

  • 1. Part  1  :  App  Development   ben6   2014-­‐03-­‐10   F9-­‐Microkernel  
  • 2. Agenda   •  F9  user  mode  API  introduc?on   •  F9  API  for  basic  app   •  Analyzing  l4test  app   •  Your  first  f9  app  prac?ce   F9  
  • 3. 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()  
  • 4. reading  user/apps/pingpong   •  Learn  from  reading,  then  prac?ce   •  Entry:  main.c:  main()  
  • 5. •  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      
  • 6. 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          }  
  • 7. __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  
  • 8. Expanded  apps/pingpong/main.c   gcc  -­‐E  main.c  -­‐I../../include  -­‐I../../../include  |  grep  -­‐v  "^$"    Expansion  let  you   easy  to  know  whole   code  structure  
  • 9. user_text:  f9.ld   __USER_TEXT   __ISR_VECTOR   INIT_HOOK(_hook,   _level)  
  • 10. L4_Msg   •  L4_Msg_t  msg;   •  L4_MsgClear   •  L4_MsgAppend   •  L4_MsgLoad   •  L4_Send    
  • 11. Agenda   •  F9  user  mode  API  introduc?on   •  F9  API  for  basic  app   •  Analyzing  l4test  app   •  Your  first  f9  app  prac?ce   F9  
  • 12. Analyzing  l4test  app   •  Code  reading   – Start  from  apps/l4test/main.c    
  • 13. Agenda   •  F9  user  mode  API  introduc?on   •  F9  API  for  basic  app   •  Analyzing  l4test  app   •  Your  first  f9  app  prac?ce   F9  
  • 14. 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);  
  • 15. 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);  
  • 16. 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    
  • 18. 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)