Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TUTORIALS: Reorganise tutorials and add inline solutions #106

Open
wants to merge 178 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
316e67f
update dynamic-libraries-1
bbrcknl Apr 19, 2024
13aaf81
update dynamic-libraries-2
bbrcknl Apr 19, 2024
d7c3e60
update dynamic-libraries-3
bbrcknl Apr 19, 2024
b96bd72
update dynamic-libraries-4
bbrcknl Apr 19, 2024
ca003e0
update hello-camkes
bbrcknl Apr 19, 2024
76b2d48
update hello-camkes-1 - missing one solution
bbrcknl Apr 19, 2024
487920a
update hello-camkes-2
bbrcknl Apr 19, 2024
5917493
update hello-camkes-timer
bbrcknl Apr 19, 2024
afb746e
update camkes-vm
bbrcknl Apr 19, 2024
ea0d14f
update camkes-cross-vm
bbrcknl Apr 19, 2024
fa98bab
update hello-world.md
bbrcknl Mar 14, 2024
d584045
update hello-world.md
bbrcknl Mar 14, 2024
c79fa1e
merge tutorials accidentally committed to origin/master
bbrcknl Mar 14, 2024
b737147
update capabilities.md
bbrcknl Mar 14, 2024
844c926
update hello-world - minor change
bbrcknl Mar 25, 2024
930604a
update capabilities - minor change
bbrcknl Mar 25, 2024
aa918b6
update untyped
bbrcknl Mar 25, 2024
6b85b9e
update mapping tutorial
bbrcknl Mar 25, 2024
ff150f7
update threads tutorial
bbrcknl Mar 25, 2024
5dbd89c
update ipc tutorial
bbrcknl Mar 25, 2024
e1859a4
update notifications tutorial
bbrcknl Mar 25, 2024
27b9b0f
update interrupts tutorial
bbrcknl Mar 25, 2024
64b5b5a
update fault-handlers tutorial
bbrcknl Mar 25, 2024
02e04ea
update mcs tutorial
bbrcknl Mar 25, 2024
5e8e6cc
update hello-world with new instructions
bbrcknl Apr 29, 2024
74528cd
add tutorials solutions call macro
bbrcknl Apr 29, 2024
fc3890a
add macro - init with solutions - to md files
bbrcknl Apr 29, 2024
5f09c69
update link in macros
bbrcknl May 10, 2024
bfc0125
remove out of date help block
bbrcknl May 10, 2024
c7472b3
reorder section on containers
bbrcknl May 10, 2024
d502fd3
fix syntax error
bbrcknl May 10, 2024
bb61dea
remove out of date help_block
bbrcknl May 10, 2024
6fa81ed
fix syntax error
bbrcknl May 10, 2024
70e748a
fix syntax error
bbrcknl May 10, 2024
495abe8
fix syntax error
bbrcknl May 10, 2024
0c9a07d
fix syntax errors for tuts to render on docsite
bbrcknl May 13, 2024
397cd2c
clean up - formatting
bbrcknl May 13, 2024
6d6a602
remove erroneous cd
bbrcknl May 13, 2024
a3c1f1e
update tut headings for crosslinking with docsite
bbrcknl May 16, 2024
124e98f
fix errors in tute explanations
bbrcknl May 20, 2024
876af19
make last solution more detailed
bbrcknl May 24, 2024
e01cd45
fix error in solution
bbrcknl May 24, 2024
ce1cbb7
update link to tut code in macros
bbrcknl May 24, 2024
3a9bdec
add further details to fault handlers tut
bbrcknl May 24, 2024
91b3fdd
fix errors in dynamic-1 tut
bbrcknl May 24, 2024
6e71d3f
fix errors in dynamic-2 tut
bbrcknl May 24, 2024
537962f
fix errors in dynamic-3 tut
bbrcknl May 24, 2024
a5d24e5
fix errors in hello-camkes-1
bbrcknl May 26, 2024
1155381
fix errors in hello-camkes-2
bbrcknl May 27, 2024
203c810
fix errors in hello-camkes-timer
bbrcknl May 27, 2024
da1c2a8
fix wording for copyright
bbrcknl May 28, 2024
73de0d8
fix trailing whitespaces
bbrcknl May 28, 2024
627629a
fix trailing whitespace
bbrcknl May 28, 2024
f464856
attempt to fix tutorial error for threads
bbrcknl May 29, 2024
60e6574
attempt to fix tutorial error for hello-camkes-1
bbrcknl May 29, 2024
830c595
attempt to fix tutorial error for fault-handlers
bbrcknl May 29, 2024
821649f
add newline at end of macros.py
bbrcknl May 29, 2024
41f15d8
attempt to fix tutorial error for hello-camkes-1
bbrcknl May 29, 2024
4702a24
attempt to fix tutorial error for hello-camkes-1
bbrcknl May 29, 2024
054919e
attempt to fix tutorial error for hello-camkes-1
bbrcknl May 29, 2024
9674fc8
fix trailing whitespace camkes-1
bbrcknl May 29, 2024
7fd0a3e
update dynamic-libraries-1
bbrcknl Apr 19, 2024
5704961
update dynamic-libraries-2
bbrcknl Apr 19, 2024
e7c1345
update dynamic-libraries-3
bbrcknl Apr 19, 2024
2ba15be
update dynamic-libraries-4
bbrcknl Apr 19, 2024
98f2d30
update hello-camkes
bbrcknl Apr 19, 2024
b4c4e93
update hello-camkes-1 - missing one solution
bbrcknl Apr 19, 2024
fe915a0
update hello-camkes-2
bbrcknl Apr 19, 2024
a089784
update hello-camkes-timer
bbrcknl Apr 19, 2024
3564d36
update camkes-vm
bbrcknl Apr 19, 2024
6171549
update camkes-cross-vm
bbrcknl Apr 19, 2024
db5fc05
update hello-world.md
bbrcknl Mar 14, 2024
dfcc054
update hello-world.md
bbrcknl Mar 14, 2024
134688d
merge tutorials accidentally committed to origin/master
bbrcknl Mar 14, 2024
ec43a6b
update capabilities.md
bbrcknl Mar 14, 2024
6f6e332
update hello-world - minor change
bbrcknl Mar 25, 2024
d45ef0a
update capabilities - minor change
bbrcknl Mar 25, 2024
74ac5ab
update untyped
bbrcknl Mar 25, 2024
3f3ff76
update mapping tutorial
bbrcknl Mar 25, 2024
ca79b33
update threads tutorial
bbrcknl Mar 25, 2024
1f4dcee
update ipc tutorial
bbrcknl Mar 25, 2024
cc6da30
update notifications tutorial
bbrcknl Mar 25, 2024
e0e60b1
update interrupts tutorial
bbrcknl Mar 25, 2024
7d151c5
update fault-handlers tutorial
bbrcknl Mar 25, 2024
73fb5de
update mcs tutorial
bbrcknl Mar 25, 2024
a9050cd
update hello-world with new instructions
bbrcknl Apr 29, 2024
7b3038c
add tutorials solutions call macro
bbrcknl Apr 29, 2024
838ccaa
add macro - init with solutions - to md files
bbrcknl Apr 29, 2024
cd4190f
update link in macros
bbrcknl May 10, 2024
e6af316
remove out of date help block
bbrcknl May 10, 2024
987382a
reorder section on containers
bbrcknl May 10, 2024
2aac0df
fix syntax error
bbrcknl May 10, 2024
b9ce39a
remove out of date help_block
bbrcknl May 10, 2024
14b7ccb
fix syntax error
bbrcknl May 10, 2024
d82e294
fix syntax error
bbrcknl May 10, 2024
af7b468
fix syntax error
bbrcknl May 10, 2024
2c240a3
fix syntax errors for tuts to render on docsite
bbrcknl May 13, 2024
46609a3
clean up - formatting
bbrcknl May 13, 2024
47a5d20
remove erroneous cd
bbrcknl May 13, 2024
c4d43d3
update tut headings for crosslinking with docsite
bbrcknl May 16, 2024
fe01615
fix errors in tute explanations
bbrcknl May 20, 2024
4bdb4d3
make last solution more detailed
bbrcknl May 24, 2024
14f9288
fix error in solution
bbrcknl May 24, 2024
9043a1e
update link to tut code in macros
bbrcknl May 24, 2024
836de00
add further details to fault handlers tut
bbrcknl May 24, 2024
0ff9073
fix errors in dynamic-1 tut
bbrcknl May 24, 2024
990d5e3
fix errors in dynamic-2 tut
bbrcknl May 24, 2024
eea7991
fix errors in dynamic-3 tut
bbrcknl May 24, 2024
3254b9b
fix errors in hello-camkes-1
bbrcknl May 26, 2024
0507cbf
fix errors in hello-camkes-2
bbrcknl May 27, 2024
cf4e5c8
fix errors in hello-camkes-timer
bbrcknl May 27, 2024
fce1e65
fix wording for copyright
bbrcknl May 28, 2024
b3be044
fix trailing whitespaces
bbrcknl May 28, 2024
06ccdac
fix trailing whitespace
bbrcknl May 28, 2024
65573f2
attempt to fix tutorial error for threads
bbrcknl May 29, 2024
b0a4596
attempt to fix tutorial error for hello-camkes-1
bbrcknl May 29, 2024
077886f
attempt to fix tutorial error for fault-handlers
bbrcknl May 29, 2024
d455df4
add newline at end of macros.py
bbrcknl May 29, 2024
25d74e5
attempt to fix tutorial error for hello-camkes-1
bbrcknl May 29, 2024
5a38a66
attempt to fix tutorial error for hello-camkes-1
bbrcknl May 29, 2024
f9b87bb
attempt to fix tutorial error for hello-camkes-1
bbrcknl May 29, 2024
ce32484
fix trailing whitespace camkes-1
bbrcknl May 29, 2024
2f934ec
fix links to docsite with new tutorials structure
bbrcknl Jul 18, 2024
186d40d
fix copyright info
bbrcknl Jul 18, 2024
ce3af61
remove duplicated solutions - capabilities
bbrcknl Jul 19, 2024
5cb4292
fix copyright header
bbrcknl Jul 19, 2024
563cdd9
remove duplicated solutions - untyped
bbrcknl Jul 19, 2024
b4882f7
remove duplicated solutions - mapping
bbrcknl Jul 19, 2024
5926835
remove most duplicated solutions - threads
bbrcknl Jul 19, 2024
237f0f1
remove duplicated solutions - ipc
bbrcknl Jul 19, 2024
fbb0854
remove duplicated solutions - notifications
bbrcknl Jul 19, 2024
d05e3b6
remove duplicated solutions - interrupts
bbrcknl Jul 19, 2024
c6b48e2
fix typos - fault handlerss
bbrcknl Jul 19, 2024
22bfaba
remove duplicated solutions - mcs
bbrcknl Jul 19, 2024
e98f540
fix merge conflicts
bbrcknl Jul 21, 2024
3b7c8dc
fix errors caused in merge
bbrcknl Jul 22, 2024
d6df214
remove duplicated solutions - dynamics1-3
bbrcknl Jul 22, 2024
293cf9e
remove most duplicate solutions - dynamics4
bbrcknl Jul 22, 2024
c55cd9d
fix copyright info broken by merge
bbrcknl Jul 22, 2024
9101fbd
remove duplicated solutions - hello-camkes-1
bbrcknl Jul 24, 2024
6935cb2
remove duplicated solutions - hello-camkes-2
bbrcknl Jul 24, 2024
7beb7c4
fix filter error
bbrcknl Jul 24, 2024
d3ad5b1
remove duplicated solutions - hello-camkes-timer
bbrcknl Jul 24, 2024
58d9de3
fix compilation errors - hello-camkes-1
bbrcknl Jul 25, 2024
114e940
fix compilation errors - hello-camkes-2
bbrcknl Jul 25, 2024
5aecf8b
add comments (headings) to solutions
bbrcknl Jul 26, 2024
d54f074
fix timer tut compilation issues
bbrcknl Jul 26, 2024
23794cc
fix typo
bbrcknl Jul 26, 2024
8975d2b
add code to render onsite links when compiling for docsite
bbrcknl Jul 29, 2024
e2abd56
fix trailing white space errors
bbrcknl Jul 29, 2024
7257e8b
fix newline error in template
bbrcknl Jul 29, 2024
00a46ea
adding prerequisites back into tutes
bbrcknl Jul 29, 2024
db709bf
remove debugging code
bbrcknl Jul 29, 2024
ca6ab63
fix trailing white space
bbrcknl Jul 29, 2024
576caf4
attempt fix of template str error
bbrcknl Jul 29, 2024
2f28430
attempt fix of template str error
bbrcknl Jul 29, 2024
857ac4c
minor fixes for clarity
bbrcknl Jul 31, 2024
5afd603
minor fixes for clarity - mcs
bbrcknl Jul 31, 2024
3380115
restore original copyright
bbrcknl Jul 31, 2024
caa47e9
replace dynamic-libraries with libraries
bbrcknl Jul 31, 2024
d04cc82
Update template.py
bbrcknl Aug 1, 2024
7eda41c
change filenames - dynamic-libraries to libraries
bbrcknl Aug 1, 2024
0e94207
fix error - hello-camkes-1
bbrcknl Aug 1, 2024
4809eec
fix error - hello-camkes-2
bbrcknl Aug 1, 2024
2d70097
fix error - hello-camkes-timer
bbrcknl Aug 2, 2024
5199f2d
fix code errors hello-camkes-1
bbrcknl Aug 2, 2024
cc1dab3
revert accidental commit of old hello-camkes-timer code
bbrcknl Aug 2, 2024
2955796
add link to slide presentation to camkes0-2 tutes
bbrcknl Aug 2, 2024
ad950e3
fix error
bbrcknl Aug 5, 2024
847e643
fix inline content for hello-camkes-timer to pass test
bbrcknl Aug 9, 2024
002b2e7
add instruction for camkes-vm tutes
bbrcknl Aug 11, 2024
ab0dace
change tutorials/ -> Tutorials/
bbrcknl Aug 12, 2024
59352eb
fix style errors
bbrcknl Aug 12, 2024
999c9fd
fix camkes 2 truncation issue
bbrcknl Aug 23, 2024
57b5b84
remove solution style
bbrcknl Aug 23, 2024
3d6f196
Merge branch 'master' into update_tutorials
bbrcknl Aug 23, 2024
b2f91ad
update camkes and library headers
bbrcknl Aug 26, 2024
8acabc1
Merge branch 'master' into update_tutorials
bbrcknl Oct 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ jobs:
matrix:
app:
- capabilities
- dynamic-1
- dynamic-2
- dynamic-3
- dynamic-4
- libraries-1
- libraries-2
- libraries-3
- libraries-4
- hello-camkes-0
- hello-camkes-1
- hello-camkes-2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright 2017, Data61, CSIRO (ABN 41 687 119 230).
Copyright 2024, seL4 Project a Series of LF Projects, LLC..
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't legally remove existing copyright holders, except when:

  • You have the permission of the original copyright holders.
  • Or all original content has been replaced.
  • Or the copyright statement was added in error.

It is okay to add copyright holders when changing stuff, assuming the license permits changes. It's also legal to change or add a license if the new one is compatible with the original license, but you have to be very careful when doing this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh, that was a replace all, when I erroneously changed the copyright to LF 2024. Thanks for your clarification on why not to do this. I'll revert to old copyright for all the files.


SPDX-License-Identifier: CC-BY-SA-4.0
-->
Expand Down
8 changes: 4 additions & 4 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
TUTORIALS = {
'hello-world': ALL_CONFIGS,
'ipc': ALL_CONFIGS,
'dynamic-1': ALL_CONFIGS,
'dynamic-2': ALL_CONFIGS,
'dynamic-3': ALL_CONFIGS,
'dynamic-4': ALL_CONFIGS,
'libraries-1': ALL_CONFIGS,
'libraries-2': ALL_CONFIGS,
'libraries-3': ALL_CONFIGS,
'libraries-4': ALL_CONFIGS,
'hello-camkes-0': ALL_CONFIGS,
'hello-camkes-1': ALL_CONFIGS,
'hello-camkes-2': ALL_CONFIGS,
Expand Down
15 changes: 15 additions & 0 deletions template.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
except ImportError:
from yaml import Loader, Dumper

from io import StringIO


def build_render_list(args):
'''
Expand Down Expand Up @@ -64,6 +66,7 @@ def render_file(args, env, state, file):
is for dependency tracking
'''
filename = os.path.join(args.out_dir, file)

# Create required directories
if not os.path.exists(os.path.dirname(filename)):
os.makedirs(os.path.dirname(filename))
Expand All @@ -80,6 +83,18 @@ def render_file(args, env, state, file):
input = in_stream.read()
template = env.from_string(input)

if (args.__getattribute__("docsite")):
s = StringIO(input)
lines = input.split('\n')

i = 0
for line in s:
lines[i] = line.replace("https://docs.sel4.systems/Tutorials/", "/Tutorials/")
i = i + 1

new_text = ''.join(lines)
template = env.from_string(str(new_text))

out_stream.write(template.render(context.get_context(args, state)))


Expand Down
30 changes: 15 additions & 15 deletions tools/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,6 @@ def ninja_simulate_block():
```'''


def help_block():
return '''
---
## Getting help
Stuck? See the resources below.
* [FAQ](https://docs.sel4.systems/FrequentlyAskedQuestions)
* [seL4 Manual](http://sel4.systems/Info/Docs/seL4-manual-latest.pdf)
* [Debugging guide](https://docs.sel4.systems/DebuggingGuide.html)
* [seL4 Discourse forum](https://sel4.discourse.group)
* [Developer's mailing list](https://lists.sel4.systems/postorius/lists/devel.sel4.systems/)
* [Mattermost Channel](https://mattermost.trustworthy.systems/sel4-external/)
'''


def cmake_check_script(state):
return '''set(FINISH_COMPLETION_TEXT "%s")
set(START_COMPLETION_TEXT "%s")
Expand All @@ -59,7 +45,7 @@ def cmake_check_script(state):

def tutorial_init(name):
return '''```sh
# For instructions about obtaining the tutorial sources see https://docs.sel4.systems/Tutorials/#get-the-code
# For instructions about obtaining the tutorial sources see https://docs.sel4.systems/Tutorials/get-the-tutorials
#
# Follow these instructions to initialise the tutorial
# initialising the build directory with a tutorial exercise
Expand All @@ -69,3 +55,17 @@ def tutorial_init(name):
ninja
```
''' % (name, name)


def tutorial_init_with_solution(name):
return '''```sh
# For instructions about obtaining the tutorial sources see https://docs.sel4.systems/Tutorials/get-the-tutorials
#
# Follow these instructions to initialise the tutorial
# initialising the build directory with a tutorial exercise
./init --solution --tut %s
# building the tutorial exercise
cd %s_build
ninja
```
''' % (name, name)
23 changes: 17 additions & 6 deletions tutorials/camkes-vm-crossvm/camkes-vm-crossvm.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,32 @@
'crossvm'
]) ?*/

# CAmkES VM: Cross VM Connectors
# CAmkES Cross VM Connectors

This tutorial provides an introduction to using the cross virtual machine (VM) connector mechanisms
provided by seL4 and Camkes in order to connect processes in a guest Linux instance to Camkes components.

In this tutorial you will learn how to:

* Configure processes in a Linux guest VM to communicate with CAmkES components

## Prerequisites
1. [Set up your machine](https://docs.sel4.systems/Tutorials/setting-up)
2. [CAmkES VM Linux tutorial](https://docs.sel4.systems/Tutorials/camkes-vm-linux)

1. [Set up your machine](https://docs.sel4.systems/HostDependencies#camkes-build-dependencies).
1. [Camkes VM](https://docs.sel4.systems/Tutorials/camkes-vm-linux)
*Note that the instructions for this tutorial are only for Linux.*

## Outcomes
## Initialising

By the end of this tutorial, you should be able to:
/*? macros.tutorial_init("camkes-vm-crossvm") ?*/

* Configure processes in a Linux guest VM to communicate with CAmkES components
<details markdown='1'>
<summary><em>Hint:</em> tutorial solutions</summary>
<br>
All tutorials come with complete solutions. To get solutions run:

/*? macros.tutorial_init_with_solution("camkes-vm-crossvm") ?*/
</details>

## Background

Expand Down
75 changes: 53 additions & 22 deletions tutorials/camkes-vm-linux/camkes-vm-linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,52 @@

/*? declare_task_ordering(['vm-cmake-start','vm-pkg-hello-c','vm-pkg-hello-cmake','vm-cmake-hello','vm-module-poke-c','vm-module-poke-make','vm-module-poke-cmake','vm-cmake-poke','vm-init-poke']) ?*/

# CAmkES VM: Adding a Linux Guest
# CAmkES VM Linux

This tutorial provides an introduction to creating VM guests and applications on seL4 using CAmkES.

You will become familiar with:

* Creating, configuring and building guest Linux VM components in CAmkES.
* Building and installing your own Linux VM user-level programs and kernel modules.

*Note that the instructions for this tutorial are only for Linux.*

## Prerequisites
1. [Set up your machine](https://docs.sel4.systems/Tutorials/setting-up)
2. [CAmkES timer tutorial](https://docs.sel4.systems/Tutorials/hello-camkes-timer)

1. [Set up your machine](https://docs.sel4.systems/HostDependencies#camkes-build-dependencies).
1. [Camkes VM](https://docs.sel4.systems/Tutorials/camkes-vm-linux)
## CapDL Loader

## Outcomes
This tutorial uses the *capDL loader*, a root task which allocates statically
configured objects and capabilities.

By the end of this tutorial, you should be familiar with:
<details markdown='1'>
<summary>Get CapDL</summary>
The capDL loader parses
a static description of the system and the relevant ELF binaries.
It is primarily used in [Camkes](https://docs.sel4.systems/CAmkES/) projects
but we also use it in the tutorials to reduce redundant code.
The program that you construct will end up with its own CSpace and VSpace, which are separate
from the root task, meaning CSlots like `seL4_CapInitThreadVSpace` have no meaning
in applications loaded by the capDL loader.
<br>
More information about CapDL projects can be found [here](https://docs.sel4.systems/CapDL.html).
<br>
For this tutorial clone the [CapDL repo](https://github.com/sel4/capdl). This can be added in a directory that is adjacent to the tutorials-manifest directory.
</details>

* Creating, configuring and building guest Linux VM components in CAmkES.
* Building and installing your own Linux VM user-level programs and kernel modules.
## Initialising

/*? macros.tutorial_init("camkes-vm-linux") ?*/

<details markdown='1'>
<summary><em>Hint:</em> tutorial solutions</summary>
<br>
All tutorials come with complete solutions. To get solutions run:

/*? macros.tutorial_init_with_solution("camkes-vm-linux") ?*/
</details>

## Background

Expand All @@ -30,7 +61,7 @@ The starting application should boot a single, very basic Linux guest.
To build the tutorial, run:
/*? macros.ninja_block() ?*/

You can boot the tutorial on an x86 hardware platform with a multiboot boot loader,
You can boot the tutorial on an x86 hardware platform with a multiboot boot loader,
or use the [QEMU](https://www.qemu.org) simulator. **Note if you are using QEMU
it is important to ensure that your host machine has VT-x support and [KVM](https://www.linux-kvm.org/page/Main_Page)
installed. You also need to ensure you have enabled nested virtulisation with KVM guests as described
Expand All @@ -55,7 +86,7 @@ buildroot login:

You can login with the username `root` and the password `root`.

The Linux guest was built using [buildroot](https://buildroot.org/), which
The Linux guest was built using [buildroot](https://buildroot.org/), which
creates a compatible kernel and minimal root filesystem containing busybox and a in-memory file system (a ramdisk).

## VM Components
Expand Down Expand Up @@ -121,7 +152,7 @@ strings specifying:
- boot arguments to the guest Linux,
- the name of the guest Linux kernel image file,
- and the name of the guest Linux initrd file (the root filesystem to use during system initialization).

The kernel command-line is defined in the `VM_GUEST_CMDLINE` macro. The kernel image
and rootfs names are defined in the applications `CMakeLists.txt` file.
These are the names of files in a CPIO archive that gets created by the build system, and
Expand Down Expand Up @@ -178,7 +209,7 @@ GenerateCAmkESRootserver()
/*- endfilter -*/
```

The file `projects/camkes/vm/camkes_vm_helpers.cmake` provides helper functions for the VM projects,
The file `projects/camkes/vm/camkes_vm_helpers.cmake` provides helper functions for the VM projects,
including `DeclareCAmkESVM(Init0)`, which is used to define the `Init0` VM component.
Each Init component requires a corresponding `DeclareCAmkESVM` function.

Expand All @@ -188,25 +219,25 @@ in the `projects/vm-linux` folder, which contains some tools for building new li
and root filesystem images, as well as the images that these tools
produce. A fresh checkout of this project will contain some pre-built
images (`bzimage` and `rootfs.cpio`), to speed up build times.
`DecompressLinuxKernel` is used to extract the vmlinux image, which `AddToFileServer` then places

`DecompressLinuxKernel` is used to extract the vmlinux image, which `AddToFileServer` then places
in the fileserver along with the rootfs.

## Adding to the guest

In the simple buildroot guest image, the
initrd (rootfs.cpio) is also the filesystem you get access to after
logging in. To make new programs available to the guest you need to add them to the
rootfs.cpio archive. Similarly, to make new kernel modules available to
the guest they must be added to the rootfs.cpio archive also.
the guest they must be added to the rootfs.cpio archive also.

In this tutorial you will install new programs into the guest VM.

### vm-linux-helpers.cmake

The `projects/camkes/vm-linux` directory contains CMake helpers to
overlay rootfs.cpio archives with a desired set of programs, modules
and scripts.
and scripts.

#### `AddFileToOverlayDir(filename file_location root_location overlay_name)`
This helper allows you to overlay specific files onto a rootfs image. The caller specifies
Expand Down Expand Up @@ -244,7 +275,7 @@ This is a helper function for downloading the linux source. This is needed if we
This helper function is used for configuring downloaded linux source with a given Kbuild defconfig (`linux_config_location`)
and symvers file (`linux_symvers_location`).

## Exercises
## Exercises

### Adding a program

Expand Down Expand Up @@ -278,7 +309,7 @@ add_executable(hello hello.c)
target_link_libraries(hello -static)
/*-- endfilter -*/
```
Now integrate the new program with the build system.
Now integrate the new program with the build system.
Update the VM apps `CMakeLists.txt` to declare the hello application as an
external project and add it to our overlay.
Do this by replacing the line `AddToFileServer("rootfs.cpio" ${default_rootfs_file})` with the following:
Expand Down Expand Up @@ -314,7 +345,7 @@ AddToFileServer("rootfs.cpio" ${rootfs_file} DEPENDS rootfs_target)
Now rebuild the project...
/*? macros.ninja_block() ?*/
..and run it (use `root` as username and password).
You should be able to use the new program.
You should be able to use the new program.

```
Welcome to Buildroot
Expand Down Expand Up @@ -403,7 +434,7 @@ DefineLinuxModule(${CMAKE_CURRENT_LIST_DIR}/poke poke-module poke-target KERNEL_
/*-- endfilter -*/
```
Update the VM `CMakeLists.txt` file to declare the new poke module as an
external project and add it to the overlay.
external project and add it to the overlay.

At the top of the file include our linux helpers, add the following:

Expand Down Expand Up @@ -447,7 +478,7 @@ AddExternalProjFilesToOverlay(poke-module ${CMAKE_CURRENT_BINARY_DIR}/poke-modul
/*-- endfilter -*/
```

Write a custom init script that loads the new module during initialization.
Write a custom init script that loads the new module during initialization.
Create a file called `init` in our tutorial directory with the following:

```bash
Expand Down Expand Up @@ -491,7 +522,7 @@ Password:
-sh: write error: Bad address # the shell complains, but our module is being invoked!
```

### Create a hypercall
### Creating a hypercall

In `modules/poke/poke.c`, replace `printk("hi\n");` with `kvm_hypercall1(4, 0);`.
The choice of 4 is because 0..3 are already used by existing hypercalls.
Expand Down
Loading
Loading