apio
80f5c790f8
All checks were successful
continuous-integration/drone/push Build is passing
Of course, using <luna/Format.h> makes it so simple. No need for duplicate code! |
||
---|---|---|
.vscode | ||
apps | ||
initrd/sys | ||
kernel | ||
libc | ||
luna | ||
tools | ||
.clang-format | ||
.drone.yml | ||
.gdbconf | ||
.gitignore | ||
CMakeLists.txt | ||
LICENSE | ||
luna.json | ||
README.md |
Luna
A simple kernel and userspace for the x86_64 platform, written mostly in C++ and C. (rewrite, listed features are currently mostly from the old version)
Features
- x86_64-compatible kernel. (Rewritten)
- Keeps track of memory. (Rewritten)
- Can read, write and execute files from a virtual file system supporting an initial ramdisk, device pseudo-filesystems... but no hard disks yet. (Not there yet)
- Preemptive multitasking, with a round-robin scheduler that can switch between tasks. (Rewritten)
- Can load ELF programs from the file system as userspace tasks. (Rewritten)
- System call interface and C Library, aiming to be mostly POSIX-compatible. (Rewriting)
- UNIX-like multitasking primitives, which allow user tasks to spawn other tasks. (Not there yet)
- Some simple userspace programs, written in C. (Not there yet)
- Simple command-line shell, allowing for interactive use of the system. (Not there yet)
- Basic multi-user system with a password file and utilities for logging in and switching users. (Not there yet)
New features (in the rewrite)
- Easier portability, no need to be restricted to x86_64.
- Fully UTF-8 aware, everywhere.
- More thread safety.
- Environment-agnostic utility library, which can be used in both kernel and userspace.
- Improved error propagation, inspired by Rust and SerenityOS.
- Better code quality and readability.
- Build system now uses CMake, which makes everything a lot easier.
Notes
- The default user is named 'selene' and you can log into it with the password 'moon'.
Setup (not broken anymore)
Although some prebuilt toolchains do exist, they have a hardcoded directory structure which is unlikely to match your setup and will thus cause problems. The best option is always to compile your own cross-toolchain, and now that the restart
branch is mature enough to do that, go for it!
To build and run Luna, you will need to build a GCC Cross-Compiler and cross-binutils for x86_64-luna
. (Yes, Luna is advanced enough that it can use its own OS-Specific Toolchain, instead of a bare metal target like x86_64-elf
. It is the first of my OS projects to be able to do so. The patches for Binutils and GCC are binutils.patch and gcc.patch).
You should start by installing the required dependencies.
Then, run tools/setup.sh
to build the toolchain.
This script will check whether you have the required versions of the toolchain already setup, and will skip building them if so. (This means that it is used by the build scripts to install the toolchain if it is missing before building, so you could skip running it manually.)
Please beware that building GCC and Binutils can take some time, depending on your machine.
Building
There are a variety of scripts for building Luna.
tools/build.sh
will build the kernel, libc and binaries.
tools/rebuild.sh
will do a full rebuild of the kernel, libc and binaries.
tools/install.sh
will install those to the system root and initial ramdisk.
tools/sync-libc.sh
will install the libc headers to the system root, build libc and install it.
tools/build-iso.sh
will build, install, and make an ISO disk image named Luna.iso.
tools/build-stable-iso.sh
does the same thing as build-iso.sh, but configures the kernel so that the version does not show the commit hash (used for stable versions).
tools/rebuild-iso.sh
will do a clean rebuild, install, and make an ISO disk image.
In most cases, you should just use run.sh
, but if you want to build without running, build-iso.sh
.
Running
You should have QEMU installed.
You can choose between 3 run scripts:
tools/run.sh
is the one you should use in most cases. It will build changed files, install, make an ISO image, and run Luna in QEMU.
tools/rebuild-and-run.sh
will rebuild, install, make an ISO, and run Luna in QEMU.
tools/debug.sh
will run Luna in QEMU with a port open for GDB to connect to. (run tools/build-debug.sh
, tools/gdb.sh
, and then tools/debug.sh
in a separate terminal for an optimal debugging experience)
Beware that running without hardware acceleration does some weird stuff with the memory map, which is why I don't use it that often.
Essentially, since run.sh
builds the toolchain if it hasn't been built, builds Luna if it hasn't been built, and runs it, you could just checkout this repo, run run.sh
, and you're done. No need for the other scripts. Those are included for more fine-grained control/building step-by-step.
You can pass any arguments you want to the run scripts, and those will be forwarded to QEMU. Example: tools/run.sh -m 512M -net none -machine q35
.
Prebuilt images
Prebuilt ISO images (numbered) for every version can be found at pub.cloudapio.eu.
These images are built manually whenever I decide to make a new version, and thus don't reflect the latest changes on the main
branch.
Every hour, my server pulls the latest commits on main
and builds an hourly ISO image. The ten most recent ones can be found in the hourly directory, and Luna-latest.iso should always be symlinked to the newest one.
These images do reflect the latest changes on the main
branch, but are obviously less stable. Additionally, an hourly image will be skipped if building the latest commit of the project fails.
Until the restart
branch gets merged, you'll have to build an ISO yourself.
Is there third-party software I can use on Luna?
No, not on this branch.
ORIGINAL ANSWER
Yes, actually! Check out the ports directory. Right now, there are very few ports, because our C Library is a bit primitive and doesn't support complex projects.
You should also keep in mind that it is not possible to compile software written in any language other than C/C++ (and C++ was added recently, its standard library doesn't work very well) for Luna right now.
But feel free to try to port some program yourself and add it to the ports directory!
Port usage:
ports/add-port.sh <port-name>
will build and add a port to the list of installed ports, and the built port will automatically get installed into the system root every time you run Luna.
ports/remove-port.sh <port-name>
will remove the port from the list of installed ports, remove built files from the system root, as well as the build directory.
ports/make-package.sh <port-name>
will compile the port and make a package archive from it, which may be used in the future with a package manager :)
License
Luna is open-source and free software under the BSD-2 License.