Hello,
I finally got round to experimenting with L4Re again, but in attempting to
investigate task creation, I seem to have some difficulties understanding the
mechanism by which tasks are typically created and how the l4_task_map
function might be used in the process.
After looking at lots of different files in the L4Re distribution, my
understanding of the basic mechanism is as follows:
1. Some memory is reserved for the UTCB of a new task, perhaps using the
l4re_ma_alloc_align …
[View More]function (or equivalent) to obtain a dataspace.
2. A task is created using l4_factory_create_task, indicating the UTCB
flexpage, with this being defined as...
l4_factory_create_task(l4re_env()->factory, new_task,
l4_fpage(utcb_start, utcb_log2size, L4_FPAGE_RW))
3. A thread is created using l4_factory_create_thread.
l4_factory_create_thread(l4re_env()->factory, new_thread)
4. The thread attributes are set using the l4_thread_control API.
5. The l4_thread_ex_regs function is used to set the instruction pointer
(program counter) and stack pointer of the thread.
6. The l4_scheduler_run_thread function is used to initiate the thread.
The expectation is that the thread will immediately fault because there is no
memory mapped at the instruction pointer location. However, it seems to me
that it should be possible to use l4_task_map to make a memory region
available within the task's address space, although I don't ever see this
function used in L4Re for anything.
(The C++ API makes it difficult to perform ad-hoc searches for such low-level
primitives, in my view, so perhaps I am missing use of the equivalent
methods.)
Tentatively, I would imagine that something like this might work:
l4_task_map(new_task, L4RE_THIS_TASK_CAP,
l4_fpage(program_start, program_log2size, L4_FPAGE_RX),
task_program_start)
Here, the program payload would be loaded into the creating task at
program_start, but the new task would be receiving the payload at
task_program_start, with the configured instruction pointer location occurring
within the receive window (after task_program_start, in other words).
There are, of course, many other considerations around creating tasks, which I
have noted from looking at the different packages (libloader, l4re_kernel,
moe, ned), and I am aware that a few other things need to be done to start a
task such as...
* Defining capability selectors and mapping appropriate capabilities to the
new task.
* Creating a stack for the task and populating it with arguments and
environment information.
* Defining a suitable pager and exception handler, with this usually being
provided by the l4re binary, as I understand it.
Also, when actually dealing with program loading generally, I realise that the
ELF binary needs to be interpreted and the appropriate regions associated with
different parts of memory, this typically being handled by the region mapper/
manager in L4Re. And there is also the matter of dynamic library loading.
But here, I am just attempting to establish the basic mechanism when a task
starts up. Unfortunately, the only discussion I found was this (after some
initial discussion about a related topic):
http://os.inf.tu-dresden.de/pipermail/l4-hackers/2014/015366.html
There are various examples in Subversion (maybe somewhere in the Git
repositories, too) that create tasks or threads, but I don't find them
particularly helpful, apparently being oriented towards very specific
applications. A previous example was referenced in the above thread for the
older L4Env system (or maybe an even earlier system):
http://os.inf.tu-dresden.de/pipermail/l4-hackers/2000/000384.html
As for why I would be wondering about such things - a question inevitably
asked in the first thread referenced above - I firstly want to be able to
understand the mechanism involved, but I also want to be able to integrate
work I have been doing on file paging into task creation.
Although I can probably do this by customising the "app model" normally used
by the different loaders, it seems that I would need to construct an
alternative l4re binary, which is rather cumbersome and perhaps a weakness of
the abstractions that are provided, these being rather oriented towards
obtaining dataspaces via the namespace API which I don't want to have to
support in my filesystem.
In any case, I wonder if there are any resources that describe the use of
l4_task_map and the details of the program environment within tasks.
Paul
[View Less]
Hi,
I am currently trying to get the L4Re running on the NXP LX2160 with U-Boot.
When I try to load a .uimage I get the following error message:
FDT and ATAGS support not compiled in
Thank you in advance for your help.
Hello everyone,
We have a question regarding the newest Kernel version available on Git (current date: 11.08.2022). We are working on an application and
have come across a problem.
In a previous Git version of the Kernel we had no problem building the .uimage file; however, with the newest update we found out that the .uimage file cannot be built.
Here the working version (older one):
Buildung local Project exampleApp
[ExampleApp_Git] ... Compiling src/main.o
[ExampleApp_Git] ==&…
[View More]gt; Linking exampleApp
[ExampleApp_Git] ==> exampleApp built
[ExampleApp_Git] ==> Installing exampleApp to local build-tree
Building L4Re uimage with Application exampleApp
make[1]: Entering directory '/home/dev/L4Re_Git/l4'
Building entry "exampleApp".
Merging images:
mod00: /home/dev/L4Re_Git/build-fiasco//fiasco [436kB]
mod01: /home/dev/L4Re_Git/build-l4re/bin/arm64_armv8a/l4f/sigma0 [36kBBuildung local Project exampleApp
[ExampleApp_Git] ... Compiling src/main.o
[ExampleApp_Git] ==> Linking exampleApp
[ExampleApp_Git] ==> exampleApp built
[ExampleApp_Git] ==> Installing exampleApp to local build-tree
Building L4Re uimage with Application exampleApp
make[1]: Entering directory '/home/dev/L4Re_Git/l4'
Building entry "exampleApp".
Merging images:
mod00: /home/dev/L4Re_Git/build-fiasco//fiasco [436kB]
mod01: /home/dev/L4Re_Git/build-l4re/bin/arm64_armv8a/l4f/sigma0 [36kB]
mod02: /home/dev/L4Re_Git/build-l4re/bin/arm64_armv8a/l4f/moe [226kB]
mod03: /home/dev/L4Re_Git/build-l4re/bin/arm64_armv8a/l4f/l4re [117kB]
mod04: /home/dev/L4Re_Git/build-l4re/bin/arm64_armv8a/l4f/exampleApp [174kB]
[bootstrap] ... Generating bootstrap.ld
[bootstrap] ... Compiling startup.o
[bootstrap] ==> Linking bootstrap.elf
[bootstrap] ==> Image post-processing bootstrap.elf
[bootstrap] ==> bootstrap.elf built
==> Installing bootstrap.elf in image directory
==> Installing bootstrap_exampleApp in image directory
==> Installing bootstrap_exampleApp.elf in image directory
[bootstrap] ... Generating bootstrap.raw
==> Installing bootstrap.raw in image directory
==> Installing bootstrap_exampleApp.raw in image directory
[bootstrap] ... Generating bootstrap.uimage
Image Name: L4 Image #3
Created: Thu Aug 11 09:11:24 2022
Image Type: AArch64 Linux Kernel Image (uncompressed)
Data Size: 1099688 Bytes = 1073.91 KiB = 1.05 MiB
Load Address: 01000000
Entry Point: 01000000
==> Installing bootstrap.uimage in image directory
==> Installing bootstrap_exampleApp.uimage in image directory
Image size(s) in bytes:
bootstrap_exampleApp.elf: 1534296
bootstrap.raw: 1099688
bootstrap.uimage: 1099752
Start address: 0x1000000
--> Build-Nr: 3
[bootstrap] ==> Installing bootstrap.elf to local build-tree
[bootstrap] ==> Installing bootstrap_exampleApp to local build-tree
[bootstrap] ==> Installing bootstrap_exampleApp.elf to local build-tree
make[1]: Leaving directory '/home/dev/L4Re_Git/l4'
DONE - bootstrap_exampleApp.uimage copied to /tftp/!
]
mod02: /home/dev/L4Re_Git/build-l4re/bin/arm64_armv8a/l4f/moe [226kB]
mod03: /home/dev/L4Re_Git/build-l4re/bin/arm64_armv8a/l4f/l4re [117kB]
mod04: /home/dev/L4Re_Git/build-l4re/bin/arm64_armv8a/l4f/exampleApp [174kB]
[bootstrap] ... Generating bootstrap.ld
[bootstrap] ... Compiling startup.o
[bootstrap] ==> Linking bootstrap.elf
[bootstrap] ==> Image post-processing bootstrap.elf
[bootstrap] ==> bootstrap.elf built
==> Installing bootstrap.elf in image directory
==> Installing bootstrap_exampleApp in image directory
==> Installing bootstrap_exampleApp.elf in image directory
[bootstrap] ... Generating bootstrap.raw
==> Installing bootstrap.raw in image directory
==> Installing bootstrap_exampleApp.raw in image directory
[bootstrap] ... Generating bootstrap.uimage
Image Name: L4 Image #3
Created: Thu Aug 11 09:11:24 2022
Image Type: AArch64 Linux Kernel Image (uncompressed)
Data Size: 1099688 Bytes = 1073.91 KiB = 1.05 MiB
Load Address: 01000000
Entry Point: 01000000
==> Installing bootstrap.uimage in image directory
==> Installing bootstrap_exampleApp.uimage in image directory
Image size(s) in bytes:
bootstrap_exampleApp.elf: 1534296
bootstrap.raw: 1099688
bootstrap.uimage: 1099752
Start address: 0x1000000
--> Build-Nr: 3
[bootstrap] ==> Installing bootstrap.elf to local build-tree
[bootstrap] ==> Installing bootstrap_exampleApp to local build-tree
[bootstrap] ==> Installing bootstrap_exampleApp.elf to local build-tree
make[1]: Leaving directory '/home/dev/L4Re_Git/l4'
DONE - bootstrap_exampleApp.uimage copied to /tftp/!
And now the faulty one (latest version):
Buildung local Project exampleApp
[ExampleApp_Git] ==> Linking exampleApp
aarch64-linux-gnu-ld: cannot find ./src/main.o: No such file or directory
make[1]: *** [/home/dev/L4Re_Git/l4/mk/prog.mk:125: exampleApp] Error 1
make: *** [/home/dev/L4Re_Git/l4//mk/binary.inc:159: /home/dev/L4Re_Git/build-l4re/ext-pkg/home/dev/L4Re_Dev/ExampleApp_Git/OBJ-arm64_armv8a-l4f] Error 2
Building L4Re uimage with Application exampleApp
make[1]: Entering directory '/home/dev/L4Re_Git/l4'
Could not find
'exampleApp'
within paths
/home/dev/L4Re_Git/build-fiasco/
/home/dev/L4Re_Git/build-l4re/bin/arm64_armv8a
/home/dev/L4Re_Git/build-l4re/bin/arm64_armv8a/l4f
/home/dev/L4Re_Git/build-l4re/lib/arm64_armv8a
/home/dev/L4Re_Git/build-l4re/lib/arm64_armv8a/l4f
Processing of entry exampleApp in /home/dev/L4Re_Git/l4/conf/modules.list failed!
make[3]: *** No rule to make target 'processing-of-module-list-failed', needed by 'mod.make.inc'. Stop.
make[2]: *** [../../../../mk/binary.inc:159: /home/dev/L4Re_Git/build-l4re/pkg/bootstrap/server/src/OBJ-arm64_armv8a] Error 2
make[1]: *** [Makefile:544: uimage] Error 2
make[1]: Leaving directory '/home/dev/L4Re_Git/l4'
make: *** [Makefile:6: do-all-make-goals] Error 2
cp: cannot stat '/home/dev/L4Re_Git/build-l4re/pkg/bootstrap/server/src/OBJ-arm64_armv8a/bootstrap_exampleApp.uimage': No such file or directory
DONE - bootstrap_exampleApp.uimage copied to /tftp/!
This does not happen if we create the image of ‘hello’.
The problem is that the main.c file in the exampleApp does not get compiled before being linked à aarch64-linux-gnu-ld: cannot find ./src/main.o: No such file or directory.
Everything was added correctly in modules.list.
Does it depend on the newest update or did we make a mistake somewhere?
In the attachment you will also find the build_all.sh file we used to build the image and also the Makefile for exampleApp.
Thank you in advance for your help.
Many regards,
Mauro, Ricardo
[View Less]