The lecture by Norman Feske for Summer Systems School'12.
Genode Programming
SSS'12 - Education event, organized by ksys labs[1] in 2012, for students interested in system software development and information security.
Genode[2] - The Genode operating-system framework provides a uniform API for applications on top of 8 existing microkernels/hypervisors: Linux, L4ka::Pistachio, L4/Fiasco, OKL4, NOVA, Fiasco.OC, Codezero, and a custom kernel for the MicroBlaze architecture.
1. http://ksyslabs.org/
2. http://genode.org
ICT role in 21st century education and it's challenges.
Â
Genode Programming
1. Genode OS Framework
Programming Environment
Norman Feske
<norman.feske@genode-labs.com>
2. Outline
1. Source tree overview
2. Build system
3. Run scripts
4. Inter-process communication
5. Client-server example
Genode OS Framework Programming Environment 2
3. Outline
1. Source tree overview
2. Build system
3. Run scripts
4. Inter-process communication
5. Client-server example
Genode OS Framework Programming Environment 3
4. Get the source code
Code is hosted at GitHub:
https://github.com/genodelabs/genode
Clone the main repository:
git clone https://github.com/genodelabs/genode.git
Contains genuine Genode code only
3rd-party code not included, must be downloaded
Genode OS Framework Programming Environment 4
5. Repositories
Foster modular code base instead of one big tree
For a given project, only a subset of repositories is relevant
â Helps to focus attention to relevant parts
â Clean organization defeats ad-hoc solutions
Genode OS Framework Programming Environment 5
6. Repository shadowing
Set of used repositories deïŹned by build directory
â Selected repositories form one logical source tree
(similar to unionfs)
REPOSITORIES = <list-of-repo-directories>
Repositories can shadow each other
target description ïŹles
library description ïŹles
include-search directories
Order is REPOSITORIES list is important
Earlier entries shadow later entries
Genode OS Framework Programming Environment 6
8. Repositories in practice
Tweak existing components without breaking existing code
Want to add code? â Simply introduce a new repository
Can be hosted outside the mainline Genode tree
Use a revision control system of your choice
Genode OS Framework Programming Environment 8
9. Specs
Source repositories â coarse grained modularity
Challenges:
Multiple kernels
Multiple hardware platforms
DiïŹerent ïŹavours of implementations
ifndef-endif yields frustration, messes up test coverage
Build specs â ïŹne grained modularity
Genode OS Framework Programming Environment 9
10. Specs: Build targets express their needs
Examples:
SpeciïŹc peripheral (device driver)
Particular property of CPU architecture if code is not generic
only 32-bit
only arm v7a
Licensing conditions
Example, target.mk ïŹle
REQUIRES = x86
...
Genode OS Framework Programming Environment 10
11. Specs: Build directory deïŹnes build properties
Spec values characterize the build
Example <build-dir>/etc/specs.conf
SPECS = genode foc_panda
High-level spec values reïŹned to low-level spec values
Genode OS Framework Programming Environment 11
13. Specs: Steering the build process
Traverse <repos>/mk/spec-<value>.mk ïŹles
Platform-speciïŹc build settings (CFLAGS ...)
Include more specialized spec-<value>.mk ïŹles
Match targetâs REQUIRES against build-dirâs SPECS
Prefer specialized libraries:
<repo>/lib/mk/blit.mk generic library
<repo>/lib/mk/x86 32/blit.mk specialized library
Genode OS Framework Programming Environment 13
14. Specs: BeneïŹts
â No preprocessor-based conïŹguration
â No artiïŹcial abstractions (architecture, platform, cpu, ...)
â Easy to extend
â Easy to conïŹgure
Genode OS Framework Programming Environment 14
15. Anatomy of a repository
Directory Description
doc/ Documentation, speciïŹc for the repository
etc/ Default conïŹguration of the build process
include/ Globally visible header ïŹles
src/ Source codes and target build descriptions
lib/mk/ Library build descriptions
Genode OS Framework Programming Environment 15
17. Integration of 3rd-party source code
Download and integrate a kernel:
make -C <genode-dir>/base-nova prepare
Works uniformly for all kernels!
Genode OS Framework Programming Environment 17
18. Integration of 3rd-party source code
Ported applications and libraries reside in libports and ports.
List available 3rd-party libraries:
make -C libports
Download and integrate a set of libraries:
make -C libports prepare PKG=âlibc freetypeâ
...a lot to explore
Genode OS Framework Programming Environment 18
19. Outline
1. Source tree overview
2. Build system
3. Run scripts
4. Inter-process communication
5. Client-server example
Genode OS Framework Programming Environment 19
20. Tool chain
Needed because
C++ support libraries normally require a libc
We need C++ support
We donât want to depend on a libc
Multi-threading support is OS-speciïŹc
Linux TLS
Limit varienty of tool-chain related errors
Compiler versions
Linux distributions
â http://genode.org/download/tool-chain
Genode OS Framework Programming Environment 20
21. Build directory
<build-dir>/etc/build.conf
DeïŹnes base/ location
DeïŹnes source repositories to use
REPOSITORIES = <list-of-repo-dirs>
Make ïŹags
MAKE += -j4
Genode OS Framework Programming Environment 21
22. Build directory (II)
<build-dir>/etc/specs.conf
Included after <repos>/etc/specs.conf
DeïŹne build characteristics via spec values
SPECS = genode foc_panda
Defaults in base-<platform>/etc/specs.conf
Extend spec values
SPECS += i915
Genode OS Framework Programming Environment 22
24. Build directory creation tool
<genode-dir>/tool/create builddir
Creates templates for a variety of supported platforms:
create_builddir nova_x86_32 BUILD_DIR=/tmp/build
Revisit generated build.conf:
Enable repositories
Add make ïŹags as desired
Genode OS Framework Programming Environment 24
25. Building targets
Single target
make <rel-dir-to-target>
Example:
make drivers/atapi
Looks for target.mk within <repos>/src/drivers/atapi
Tests REQUIRES agains SPECS
Builds all libraries the target depends on
Builds target
Genode OS Framework Programming Environment 25
26. Building targets (II)
Tree of targets
make <rel-dir>
Example:
make drivers
Builds all targets within <repos>/src/drivers.
Genode OS Framework Programming Environment 26
27. Building targets (III)
List of targets
make <rel-dir> ...
Example:
make core init drivers/timer
Builds all targets found in any of the speciïŹc src/ locations
Genode OS Framework Programming Environment 27
28. Outline
1. Source tree overview
2. Build system
3. Run scripts
4. Inter-process communication
5. Client-server example
Genode OS Framework Programming Environment 28
31. Run script (II)
Located at <repos>/run/<script-name>.run
Executable from within the build directory
make run/<script-name>
Genode OS Framework Programming Environment 31
32. Run script (III)
â Single ïŹle describes a complete system scenario
â One run script works across diïŹerent kernels
â Great for bug reports
â Run script + little work = automated test case
Genode OS Framework Programming Environment 32
33. Outline
1. Source tree overview
2. Build system
3. Run scripts
4. Inter-process communication
5. Client-server example
Genode OS Framework Programming Environment 33
45. Outline
1. Source tree overview
2. Build system
3. Run scripts
4. Inter-process communication
5. Client-server example
Genode OS Framework Programming Environment 45
66. Advanced features
Extending existing RPC interfaces
GENODE_RPC_INTERFACE_INHERIT(Base_interface_type,
Rpc_func ...)
Throwing exceptions accross process boundaries
GENODE_RPC_THROW(Rpc_unlink, void, unlink,
GENODE_TYPE_LIST(Permission_denied,
Invalid_name,
Lookup_failed),
Dir_handle, Name const &);
Genode OS Framework Programming Environment 66
67. Observations
RPC stub code generated by C++ compiler
No external tools needed
No language boundary to conquer
Type safety
Genode OS Framework Programming Environment 67
68. Thank you
What we covered today Coming up next...
Programming environment Components
1. Source tree overview 1. Classes of components
2. Build system 2. UniïŹed conïŹguration
3. Run scripts concept
4. Inter-process communication 3. Session routing
5. Client-server example 4. Components overview
More information and resources:
http://genode.org
Genode OS Framework Programming Environment 68