### Build and install Binutils Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/c/cross_compiler.md Compile and install Binutils from source. ```sh mkdir build-binutils cd build-binutils ../binutils-2.35.1/configure --prefix="$PREFIX" --disable-nls --disable-werror make -j$(nproc) make install ``` -------------------------------- ### Install TFTP and Apache Packages Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/pxe.md Install necessary packages for setting up a TFTP server. ```bash sudo apt-get install apache2 tftpd-hpa inetutils-inetd nasm ``` -------------------------------- ### Build and install GCC Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/c/cross_compiler.md Compile and install GCC from source after downloading prerequisites. ```sh # Use a GCC script to download all necessary prerequisites cd gcc-10.2.0 ./contrib/download_prerequisites cd ../ mkdir build-gcc cd build-gcc ../gcc-10.2.0/configure --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ make -j$(nproc) make install ``` -------------------------------- ### Install Rust Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Installs Rust using the official installation script. This is a prerequisite for building Theseus OS. ```bash curl https://sh.rustup.rs -sSf | sh ``` -------------------------------- ### Run the automated installation script Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/c/cross_compiler.md Use the provided script to automate the GCC and Binutils installation process. ```sh ./scripts/install_x86_64-elf-gcc.sh $HOME/src $HOME/opt ``` -------------------------------- ### Install required system packages Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/c/cross_compiler.md Install the necessary dependencies on the host system before building. ```sh sudo apt-get install gcc build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo gcc-multilib ``` -------------------------------- ### Install ARM Binutils and GCC on MacOS Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Installs the ARM cross-compiler and binutils on macOS using Homebrew, if not already installed by the build setup script. ```zsh brew install aarch64-elf-gcc aarch64-elf-binutils ``` -------------------------------- ### Configure destination directory Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/c/cross_compiler.md Set up the installation path for the built packages. ```sh mkdir $DEST export PREFIX="$DEST/gcc-10.2.0" ``` -------------------------------- ### Install mdBook Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/README.md Install the required version of mdBook to build the documentation. ```sh cargo +stable install mdbook ``` -------------------------------- ### Application Crate Structure Example Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/app/app.md An example file structure for a new application crate named `my_app`. The directory name must match the crate name in `Cargo.toml`. ```toml [package] name = "my_app" ... ``` -------------------------------- ### Build and Run Theseus in QEMU Source: https://context7.com/theseus-os/theseus/llms.txt Commands to clone the repository, install dependencies, and execute the OS in a QEMU environment. ```bash # Clone the repository with submodules git clone --recurse-submodules --depth 1 https://github.com/theseus-os/Theseus.git cd Theseus # Install Rust (if not already installed) curl https://sh.rustup.rs -sSf | sh # Install dependencies (Debian/Ubuntu) sudo apt-get install make gcc nasm pkg-config grub-pc-bin mtools xorriso qemu qemu-kvm wget # Build and run in QEMU make run # Build with KVM acceleration for faster execution make run host=yes # Build for aarch64 architecture make ARCH=aarch64 run # Build full OS image with all features make full ``` -------------------------------- ### Install QEMU and ARM GCC on Arch Linux Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Installs the required QEMU system emulator and ARM cross-compiler for building Theseus on Arch Linux. ```bash sudo pacman -S aarch64-linux-gnu-gcc qemu-system-aarch64 ``` -------------------------------- ### Install QEMU and ARM GCC on Debian/Ubuntu Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Installs the necessary QEMU system emulator and ARM cross-compiler for building Theseus on Debian-based Linux distributions. ```bash sudo apt-get install qemu-system-arm gcc-aarch64-linux-gnu ``` -------------------------------- ### Install DHCP Server Package Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/pxe.md Install the Internet Systems Consortium DHCP server package. ```bash sudo apt-get install isc-dhcp-server ``` -------------------------------- ### Install KVM for QEMU Acceleration Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Install KVM on your Linux system to significantly speed up QEMU execution. This is recommended for a smoother development experience. ```sh sudo apt-get install kvm ``` -------------------------------- ### Attach GDB to QEMU Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Start GDB and attach it to the running QEMU instance on port 1234. Symbols are not yet supported. ```shell gdb-multiarch -ex "target remote :1234" ``` -------------------------------- ### Install Docker Engine on Ubuntu Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Convenience script to install Docker Engine on Ubuntu systems. ```sh ./docker/install_docker_ubuntu.sh ``` -------------------------------- ### Setup TAP Network Interface Source: https://github.com/theseus-os/theseus/blob/theseus_main/tools/receive_udp_messages/README.txt Configure a TAP network interface on the host machine for QEMU. This allows the guest OS to communicate with the host network. Ensure you have the necessary permissions to create and manage network interfaces. ```bash sudo ip tuntap add name tap0 mode tap user $USER sudo ip link set tap0 up sudo ip addr add 192.168.69.100/24 dev tap0 ``` -------------------------------- ### Install Fedora Dependencies Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Installs build dependencies for Theseus OS on Fedora. This command uses dnf to install required packages. ```bash sudo dnf install make gcc nasm pkg-config grub2 mtools xorriso qemu wget ``` -------------------------------- ### Example TheseusBuild.toml configuration Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/building/rust_builds_out_of_tree.md Configuration file generated by the build tool to define parameters for replicating the Theseus build environment. ```toml target = "x86_64-unknown-theseus" rustflags = "--emit=obj -C debuginfo=2 -C code-model=large -C relocation-model=static -D unused-must-use -Z merge-functions=disabled -Z share-generics=no" cargoflags = "--release" host_deps = "./host_deps" ``` -------------------------------- ### Install Arch Linux Dependencies Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Installs build dependencies for Theseus OS on Arch Linux. This command uses pacman to install required packages. ```bash sudo pacman -S make gcc nasm pkg-config grub mtools xorriso qemu wget ``` -------------------------------- ### Install GDB Dependencies for OS Debugging Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Install the necessary packages on your Linux host to build a patched version of GDB that is compatible with 64-bit OSes running in QEMU. ```sh sudo apt-get install texinfo flex bison python-dev ncurses-dev ``` -------------------------------- ### Install gdb-multiarch Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Install the required gdb-multiarch package for debugging aarch64 targets. ```shell sudo apt-get install gdb-multiarch ``` -------------------------------- ### Install and invoke theseus_cargo Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/building/rust_builds_out_of_tree.md Commands to install the build tool from source and execute it to build an out-of-tree crate. ```sh cargo install --path="tools/theseus_cargo" --root=$INSTALL_DIR ``` ```sh $INSTALL_DIR/theseus_cargo --input "build/deps/" build ``` -------------------------------- ### Run MacOS Build Setup Script Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Execute this script to set up the build environment on macOS. If issues arise, remove the specified build directories and rerun. ```sh sh ./scripts/mac_os_build_setup.sh ``` -------------------------------- ### Install VirtualBox on Debian-based Systems Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/virtual_machine/virtual_machine.md Use this command to install the VirtualBox package on Ubuntu and other Debian-based Linux distributions. Replace `<...>` with the actual version number. ```sh sudo dpkg -i virtualbox-<...>.deb ``` -------------------------------- ### Attach GDB to QEMU Instance Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Start GDB and attach it to a running QEMU instance of Theseus OS. QEMU will pause execution until you issue GDB commands like 'n' (next) or 'c' (continue). ```sh make gdb ``` -------------------------------- ### Install Linux Dependencies Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Installs necessary build dependencies for Theseus OS on Debian-based Linux distributions. Includes tools like make, gcc, nasm, and QEMU. ```bash sudo apt-get install make gcc nasm pkg-config grub-pc-bin mtools xorriso qemu qemu-kvm wget ``` -------------------------------- ### Verify cross-compiler installation Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/c/cross_compiler.md Check the version of the newly built cross-compiler. ```sh $DEST/cross/bin/$TARGET-gcc --version ``` -------------------------------- ### Install mdBook Linkcheck Plugin Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/README.md Optional plugin to verify links within the documentation. ```sh cargo +stable install mdbook-linkcheck ``` -------------------------------- ### Troubleshoot mdBook Installation Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/README.md Commands to reset and reinstall mdBook if build issues occur. ```sh cargo uninstall mdbook rustup toolchain update stable cargo +stable install mdbook ``` -------------------------------- ### Make VMware installer executable Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/virtual_machine/virtual_machine.md Before installing VMware Workstation Player on Linux, you need to make the downloaded .bundle file executable. Replace '<...>' with the actual version number. ```shell chmod +x VMware-Player-<...>.bundle sudo ./VMware-Player-<...>.bundle ``` -------------------------------- ### Identify QEMU Serial Port Mapping Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/headless.md Example output from QEMU indicating the host-side PTY device mapping for the guest serial port. ```text char device redirected to /dev/pts/3 (label serial1-base) ``` -------------------------------- ### Navigate Filesystem Path (Rust) Source: https://context7.com/theseus-os/theseus/llms.txt Access a file or directory at a given path relative to a starting directory using `path.get()`. Handles both files and directories, and returns `None` if the path is not found. ```rust // Navigate filesystem let path = Path::from("/apps/my_app"); match path.get(&cwd) { Some(FileOrDir::File(file)) => { let locked = file.lock(); println!("Found file: {}", locked.get_absolute_path()); } Some(FileOrDir::Dir(dir)) => { let locked = dir.lock(); println!("Found directory: {}", locked.get_absolute_path()); // List directory contents for name in locked.list() { println!(" {}", name); } } None => println!("Path not found"), } ``` -------------------------------- ### Build and View Documentation Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/README.md Use the make command to build and serve the book locally. ```sh make view-book ``` -------------------------------- ### Build and Run C Programs via Makefile Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/c/programs.md Sequence of commands to build the OS, the C library, the test program, and launch the QEMU emulator. ```sh make # 1. Build Theseus OS itself make tlibc # 2. Build tlibc, Theseus's libc make c_test # 3. Build a sample C program make orun # 4. Run Theseus in QEMU (without rebuilding anything) ``` -------------------------------- ### Configure TFTP Server Options Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/pxe.md Set TFTP daemon to run and specify the root directory for TFTP boot files. ```bash RUN_DAEMON="yes" OPTIONS="-l -s /var/lib/tftpboot" ``` -------------------------------- ### Make PXE Bootable ISO Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/pxe.md Create an updated ISO image and copy it to the TFTP boot folder for subsequent PXE boots. ```bash make pxe ``` -------------------------------- ### Build and Run Theseus OS Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Builds and runs the Theseus OS in QEMU. Navigate to the project directory and execute this command. ```bash cd Theseus make run ``` -------------------------------- ### Rust Nano Core Initialization Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/design/booting.md The `nano_core_start` function is the first Rust code to execute. It handles essential bootstrap tasks like logging, VGA display, exception handlers, and setting up the initial virtual memory environment. ```rust nano_core_start() ``` -------------------------------- ### Configure DHCP Server Subnet and Boot Options Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/pxe.md Define the network subnet, IP range, and PXE boot parameters in the DHCP configuration file. ```bash subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.20 192.168.1.30; option routers 192.168.1.1; option broadcast-address 192.168.1.255; default-lease-time 600; max-lease-time 7200; } allow booting; allow bootp; option option-128 code 128 = string; option option-129 code 129 = text; next-server 192.168.1.105; filename "pxelinux.0"; ``` -------------------------------- ### Launch QEMU with VFIO Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/virtual_machine/pci_passthrough.md Pass a specific PCI device slot to QEMU using the vfio flag. ```sh make run vfio=59:00.0 ``` -------------------------------- ### Configure PXE Boot Menu Entry for Theseus Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/pxe.md Add a menu entry to the PXE configuration file to allow booting the Theseus ISO using memdisk. ```bash label theseus menu label Theseus root (hd0,0) kernel theseus/memdisk append iso initrd=theseus/theseus-x86_64.iso raw ``` -------------------------------- ### Clone and Use Limine Bootloader Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Clone the Limine bootloader repository and pass `bootloader=limine` to the make command to use it instead of GRUB. ```sh git clone https://github.com/limine-bootloader/limine.git limine-prebuilt ``` ```sh git -C limine-prebuilt reset --hard 3f6a330 ``` ```makefile make run bootloader=limine ``` -------------------------------- ### Boot Theseus on USB Drive Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Write the Theseus OS image to a USB drive for booting on real hardware. Ensure 'sdc' is the correct device node for your USB drive and not a partition. ```sh make usb drive=sdc ``` -------------------------------- ### Remove MacOS Build Directories Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Use this command to clean up build artifacts on macOS if the build setup script fails. ```sh rm -rf /tmp/theseus_tools_src ``` -------------------------------- ### Review Documentation Locally Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/contribute/git.md Builds and displays the project documentation in a browser to verify formatting and hyperlinks before submission. ```sh make view-doc ``` -------------------------------- ### Set PATH for x86_64 Homebrew Binaries on MacOS Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Adjust the system PATH if both x86 and ARM Homebrew binaries are installed on macOS. ```sh export PATH=/usr/local/Homebrew/bin:$PATH ``` -------------------------------- ### Get Current Working Directory (Rust) Source: https://context7.com/theseus-os/theseus/llms.txt Retrieve the current working directory of the task using `task::with_current_task` and accessing the `working_dir` field from the environment. ```rust use fs_node::{FileOrDir, File, Directory, FsNode, DirRef, FileRef}; use path::Path; use io::{ByteReader, ByteWriter}; // Get current working directory let cwd: DirRef = task::with_current_task(|t| { t.get_env().lock().working_dir.clone() }).expect("Failed to get current task"); ``` -------------------------------- ### Copy Memdisk and Theseus ISO to TFTP Boot Directory Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/pxe.md Place the compiled memdisk binary and the Theseus ISO image into the designated TFTP boot folder for network access. ```bash sudo mkdir /var/lib/tftpboot/theseus sudo cp /root/syslinux-*/memdisk/memdisk /var/lib/tftpboot/theseus/ sudo cp /Theseus/build/theseus-x86_64.iso /var/lib/tftpboot/theseus/ ``` -------------------------------- ### Build Theseus ISO Image Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/usb.md Run this command to generate an ISO image of the Theseus OS. This is useful for host environments like WSL where direct device access is not available. The resulting ISO can then be burned to a USB drive using tools like Rufus. ```shell make iso ``` -------------------------------- ### Get Task by ID (Rust) Source: https://context7.com/theseus-os/theseus/llms.txt Retrieve a task by its ID using `get_task`. This returns an `Option>`, which needs to be upgraded to a strong reference. ```rust // Get task by ID if let Some(weak_ref) = get_task(task_id) { if let Some(task) = weak_ref.upgrade() { println!("Found task: {}", task.name); } } ``` -------------------------------- ### Build and Boot Theseus to USB Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/usb.md Use this command to build the Theseus OS image and write it directly to a USB device. Ensure the device node specified is the correct USB disk, not a partition. ```shell make boot usb=sdc ``` -------------------------------- ### Get Cloned Current Task (Rust) Source: https://context7.com/theseus-os/theseus/llms.txt Retrieve a cloned reference to the current task using `get_my_current_task`. Use this when a separate copy of the task information is needed. ```rust // Get cloned reference to current task let my_task = get_my_current_task().expect("No current task"); println!("Task pinned to CPU: {:?}", my_task.pinned_cpu()); ``` -------------------------------- ### Build and View Theseus Documentation Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Commands to build the source-level documentation (rustdoc) and the book-style documentation (Markdown) for Theseus locally. ```sh make view-doc ``` ```sh make view-book ``` -------------------------------- ### Read Typed Data from Mapped Memory (Rust) Source: https://context7.com/theseus-os/theseus/llms.txt Read data of a specific type from a mapped memory region using `mapped.as_type()`. The offset is relative to the start of the mapped region. ```rust // Read typed data from mapped memory let value: &u32 = mapped.as_type(128) .expect("Failed to read as u32"); ``` -------------------------------- ### Get Current Task Reference (Rust) Source: https://context7.com/theseus-os/theseus/llms.txt Obtain a non-cloned reference to the current task using `with_current_task`. This is the preferred method for accessing task information without unnecessary copying. ```rust use task::{ get_my_current_task, with_current_task, get_task, all_tasks, schedule, ExitValue, KillReason }; // Get reference to current task (preferred - no clone) with_current_task(|current| { println!("Current task: {} (id: {})", current.name, current.id); println!("Running on CPU: {:?}", current.running_on_cpu()); }).expect("Failed to get current task"); ``` -------------------------------- ### Add User to Docker Group Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md After installing Docker, add your user to the 'docker' group to run Docker commands without root privileges. Log out and back in for changes to take effect. ```sh sudo groupadd docker; sudo usermod -aG docker $USER ``` -------------------------------- ### Create and Write to File (Rust) Source: https://context7.com/theseus-os/theseus/llms.txt This snippet outlines the conceptual process of creating and writing to a file. Actual file creation is typically handled by specific filesystem implementations (e.g., ramfs, fatfs). ```rust // Create and write to a file let parent_dir = cwd.lock(); // Files are typically created through specific filesystem implementations // like ramfs, fatfs, etc. ``` -------------------------------- ### Create Contiguous Mapping (Rust) Source: https://context7.com/theseus-os/theseus/llms.txt Create a memory mapping that guarantees contiguous physical frames using `create_contiguous_mapping`. Returns the mapped virtual address range and the starting physical address. ```rust // Create contiguous physical memory mapping let (mapped, phys_addr) = create_contiguous_mapping( 8192, // 2 pages PteFlags::VALID | PteFlags::WRITABLE ).expect("Failed to create contiguous mapping"); println!("Mapped to physical address: {:?}", phys_addr); ``` -------------------------------- ### Configure TFTP Server for inetd Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/pxe.md Add TFTP service configuration to inetd.conf to allow network access. ```bash tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot ``` -------------------------------- ### Send UDP Packet with Socat Source: https://github.com/theseus-os/theseus/blob/theseus_main/tools/receive_udp_messages/README.txt Send a UDP packet to a specified address and port using the `socat` utility. This is useful for testing network connectivity from the host to a target machine. The example sends the string "abcdefg" to 192.168.66.969. ```bash socat stdio udp4-connect:192.168.66.969 <<<"abcdefg" ``` -------------------------------- ### Build and Test tlibc in Theseus OS Source: https://github.com/theseus-os/theseus/blob/theseus_main/tlibc/README.md A sequence of commands to build the main Theseus ISO, package tlibc into it, build a statically linked C executable, and run the ISO in QEMU. ```sh # build the main Theseus ISO make # build tlibc and package it into the ISO make c_test # build a dummy C executable, statically link it to tlibc, and package it into the ISO make tlibc # run the ISO in QEMU, without rebuilding make orun ``` -------------------------------- ### Build and Run Theseus for aarch64 Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Build Theseus for the aarch64 architecture and run it in QEMU. Use `run_pause` for paused execution. ```shell make ARCH=aarch64 run ## or use `run_pause` ``` -------------------------------- ### Verify GCC Configuration Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/c/cross_compiler.md Check that the no-red-zone library path is correctly generated. ```sh x86_64-elf-gcc -print-libgcc-file-name x86_64-elf-gcc -mno-red-zone -print-libgcc-file-name ``` -------------------------------- ### Initialize Git Submodules Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Initializes and updates all Git submodules for the Theseus OS project. This command is essential after cloning the repository. ```bash git submodule update --init --recursive ``` -------------------------------- ### Build Full Theseus OS Image Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Compiles a comprehensive Theseus OS image with all features and crates enabled. `make all` is an alternative target. ```makefile make full ## or `make all` ``` -------------------------------- ### Download and Extract Syslinux for Memdisk Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/pxe.md Obtain the syslinux utility, which includes the memdisk file required for booting ISOs via PXE. ```bash wget https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-5.10.tar.gz tar -xzvf syslinux-*.tar.gz ``` -------------------------------- ### Run Theseus in QEMU using Makefile Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/virtual_machine/virtual_machine.md This command automatically builds and runs Theseus in a QEMU virtual machine. QEMU is the primary test environment and recommended emulator. ```shell make run ``` -------------------------------- ### Run Theseus in Bochs using Makefile Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/virtual_machine/virtual_machine.md This command attempts to run Theseus in a Bochs virtual machine. Bochs is supported but its configuration may be out of date and it runs slower than QEMU. ```shell make bochs ``` -------------------------------- ### Set cfg options via command line Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/building/configuration.md Pass multiple configuration options to the build process using the THESEUS_CONFIG environment variable. ```sh make run THESEUS_CONFIG="cfg_option_1 cfg_option_2" ``` -------------------------------- ### Define Multilib Options Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/c/cross_compiler.md Add these lines to a new file in the gcc source tree at $SRC/gcc-10.2.0/gcc/config/i386. ```text MULTILIB_OPTIONS += mno-red-zone MULTILIB_DIRNAMES += no-red-zone ``` -------------------------------- ### Build and Run Theseus OS on ARMv8 (aarch64) Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md Builds and runs the Theseus OS image targeting the ARMv8 (aarch64) architecture using QEMU. Note that a full build of all crates is not yet supported on aarch64. ```bash make ARCH=aarch64 run ``` -------------------------------- ### Build Docker Image for Theseus OS Source: https://github.com/theseus-os/theseus/blob/theseus_main/README.md This command builds the Docker image containing all necessary dependencies for building and running Theseus OS. ```sh ./docker/build_docker.sh ``` -------------------------------- ### Initial Assembly Code Entry Point (x86_64) Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/design/booting.md This is the initial assembly code executed by the Theseus kernel after being loaded by a Multiboot2-compliant bootloader. It sets up basic hardware and transitions to 64-bit long mode before calling the Rust entry point. ```assembly kernel/nano_core/src/boot/arch_x86_64/boot.asm ``` -------------------------------- ### Edit inetd Configuration Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/running/pxe.md Add the TFTP service to the inetd configuration file. ```bash sudo nano /etc/inetd.conf ``` -------------------------------- ### Application Entry Point Function Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/app/app.md Applications must expose a public `main` function as their entry point. If `main` is not public, it may be removed by compiler optimizations. ```rust pub fn main(args: Vec) -> isize { ... } ``` -------------------------------- ### Error: No matching package found Source: https://github.com/theseus-os/theseus/blob/theseus_main/tools/uefi_builder/README.md This error indicates that a required package is not found for the current target. Compiling with `-Z bindeps` can help resolve this. ```text error: no matching package named `bootloader` found ``` -------------------------------- ### Invoke copy_latest_crate_objects Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/building/rust_builds_out_of_tree.md Use the custom build tool to generate prebuilt dependency files from existing build artifacts. ```mk cargo run ... tools/copy_latest_crate_objects -- \ --input "target/.../deps" \ --output-deps "build/deps/" \ --output-sysroot "build/deps/sysroot/" \ ... ``` -------------------------------- ### Implement Application I/O Source: https://context7.com/theseus-os/theseus/llms.txt Standard I/O usage for applications in Theseus, requiring the app_io crate and no_std environment. ```rust #![no_std] extern crate alloc; #[macro_use] extern crate app_io; use alloc::string::String; use alloc::vec::Vec; pub fn main(args: Vec) -> isize { // Print to stdout println!("Arguments received: {:?}", args); // Print formatted output let value = 42; println!("The answer is: {}", value); // Print without newline print!("Processing..."); // Read from stdin (when available) // Applications receive input through the shell's stdio queues 0 } ``` -------------------------------- ### Captain Initialization Routine Source: https://github.com/theseus-os/theseus/blob/theseus_main/book/src/design/booting.md The `captain` routine orchestrates the initialization of various OS subsystems, including ACPI, APIC, interrupt handlers, device drivers, and the window manager. It concludes by enabling interrupts and entering an idle loop. ```rust enable interrupts ```