aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-08-01 17:06:02 +0200
committerHimbeer <himbeer@disroot.org>2024-08-01 17:06:30 +0200
commit9297f20dda6951c9ad883b3ee5ac429f33092f36 (patch)
treed694455e189a626639cdb6c2e93681ac7c2bea97 /static
parentf5e9402a927189142a4b3c4b68bd0946d556f7a8 (diff)
Document new U-mode initialization approach
Diffstat (limited to 'static')
-rw-r--r--static/md/srvre/kernel/wiki.md2
-rw-r--r--static/md/srvre/kernel/wiki/errors.md1
-rw-r--r--static/md/srvre/kernel/wiki/init.md28
-rw-r--r--static/md/srvre/kernel/wiki/startup.md6
-rw-r--r--static/md/srvre/kernel/wiki/userinit.md28
5 files changed, 32 insertions, 33 deletions
diff --git a/static/md/srvre/kernel/wiki.md b/static/md/srvre/kernel/wiki.md
index 44309e8..6ef0f1b 100644
--- a/static/md/srvre/kernel/wiki.md
+++ b/static/md/srvre/kernel/wiki.md
@@ -13,7 +13,7 @@ List
====
* [Startup](/md/srvre/kernel/wiki/startup.md)
-* [userinit](/md/srvre/kernel/wiki/userinit.md)
+* [init](/md/srvre/kernel/wiki/init.md)
* [Syscalls](/md/srvre/kernel/wiki/syscalls.md)
* [Message passing](/md/srvre/kernel/wiki/msgpass.md)
* [Errors](/md/srvre/kernel/wiki/errors.md)
diff --git a/static/md/srvre/kernel/wiki/errors.md b/static/md/srvre/kernel/wiki/errors.md
index 8cbf8d1..da961cf 100644
--- a/static/md/srvre/kernel/wiki/errors.md
+++ b/static/md/srvre/kernel/wiki/errors.md
@@ -34,7 +34,6 @@ library errors) and user-friendly descriptions as well as troubleshooting tips.
| HartIdOutOfRange | A hart started with an ID that doesn't fit in an unsigned 16-bit integer. This most likely is a kernel or firmware bug. |
| NoCpusHwInfo | The embedded hardware information file does not contain CPU information. Verify that you are building for a valid platform with the correct `.hwi` file and that it is not corrupted. All platforms should have this device. |
| EmptySchedule | No processes are scheduled. Since the only option for recovery is a U-mode reboot the kernel panics to notify the user of the incident. This error occurs if all processes are terminated. |
-| NoInit | The [userinit](/md/srvre/kernel/wiki/userinit.md) does not contain an `init` file in its *root directory*. Therefore the kernel is unable to locate the init system and cannot continue, resulting in a panic. Follow the [instructions](https://git.himbeerserver.de/srvre/kernel.git/about/#create-a-userinit) *precisely* to create a [userinit](/md/srvre/kernel/wiki/userinit.md) that does contain an init system at the correct path.
| TooManyThreads | A process has reached its maximum number of threads and cannot be extended by a new one. This shouldn't be a problem in the real world since thread IDs are of type `usize` which yields a limit of 2⁶⁴ threads per process. |
| TooSmall | The binary is smaller than the ELF header size and cannot be executed. Ensure that you are starting a valid ELF file and that it is not corrupted. |
| BadEndian | The binary uses a byte order other than the native endianness of the architecture (little endian for riscv64) and cannot be executed. Recompile it for little endian if possible. |
diff --git a/static/md/srvre/kernel/wiki/init.md b/static/md/srvre/kernel/wiki/init.md
new file mode 100644
index 0000000..41ab291
--- /dev/null
+++ b/static/md/srvre/kernel/wiki/init.md
@@ -0,0 +1,28 @@
+---
+title: "init - SRVRE Kernel Wiki"
+date: "Thu Aug 1 2024"
+---
+
+The init executable is responsible for the transition to userspace
+by starting essential drivers (such as disk drivers) and bootstrapping programs
+(e.g. another init system or user login service).
+It is launched as the last step of the
+[startup procedure](/md/srvre/kernel/wiki/startup.md).
+
+The executable is embedded in the kernel binary in order to alleviate the need
+for in-kernel drivers, requiring a kernel rebuild to apply changes and making
+compiling the kernel without it impossible (and pointless).
+
+Further essential programs (including drivers) required by the init executable
+can be embedded within it or loaded using an embedded storage (disk or network)
+driver.
+
+The kernel expects a statically linked ELF executable and starts it with PID 1
+(PID 0 is a pseudo-ID used as the address space identifier (ASID) of kernel
+memory).
+
+Example programs are provided in the `examples/` directory.
+
+[Return to Wiki Main Page](/md/srvre/kernel/wiki.md)
+
+[Return to Index Page](/md/index.md)
diff --git a/static/md/srvre/kernel/wiki/startup.md b/static/md/srvre/kernel/wiki/startup.md
index 58d52a1..019ca1f 100644
--- a/static/md/srvre/kernel/wiki/startup.md
+++ b/static/md/srvre/kernel/wiki/startup.md
@@ -9,15 +9,15 @@ When the kernel starts up on the boot hart it performs the following steps:
2. Enable all interrupts
3. Configure Sv39 paging
4. Configure the PLIC (Platform-Level Interrupt Controller) if present
-6. Start `/init` from the embedded [userinit](/md/srvre/kernel/wiki/userinit.md)
+6. Start the embedded [init executable](/md/srvre/kernel/wiki/init.md)
It is legal for the init process to terminate, but only if there is at least
one process left on the hart. This is likely to change in the future.
-All other harts remain passive and do not execute S-mode code.
+All other harts remain passive and do not execute S-mode (or U-mode) code.
This is going to change when SMP is implemented.
-Any errors occuring during system startup will result in a kernel panic.
+Any errors during system startup will result in a kernel panic.
[Return to Wiki Main Page](/md/srvre/kernel/wiki.md)
diff --git a/static/md/srvre/kernel/wiki/userinit.md b/static/md/srvre/kernel/wiki/userinit.md
deleted file mode 100644
index a835002..0000000
--- a/static/md/srvre/kernel/wiki/userinit.md
+++ /dev/null
@@ -1,28 +0,0 @@
----
-title: "userinit - SRVRE Kernel Wiki"
-date: "Wed Jun 19 2024"
----
-
-The userinit is responsible for the transition to userspace
-by providing essential drivers (such as potentially temporary disk drivers)
-and bootstrapping programs (including the init system).
-It is the last step of the
-[startup procedure](/md/srvre/kernel/wiki/startup.md).
-
-The kernel cannot be built if a userinit cannot be accessed at a predefined
-path. This is because it is embedded into the kernel binary so that it can be
-accessed without requiring any in-kernel drivers.
-
-A userinit is an uncompressed `tar(1)` blob.
-The kernel searches for an `init` executable at its root
-(ignoring file permissions). This file is executed to hand over control
-to userspace and is typically responsible for starting essential drivers,
-accessing persistent storage and starting essential processes to allow
-user login. It runs with full permission potential and no user identity.
-
-See the repository [README.md](https://git.himbeerserver.de/srvre/kernel.git/about/#create-a-userinit)
-for instructions on how to create a userinit.
-
-[Return to Wiki Main Page](/md/srvre/kernel/wiki.md)
-
-[Return to Index Page](/md/index.md)