Full Code of tomaka/os for AI

main 9bf924ce2997 cached
247 files
3.2 MB
856.4k tokens
1714 symbols
1 requests
Download .txt
Showing preview only (3,424K chars total). Download the full file or copy to clipboard to get everything.
Repository: tomaka/os
Branch: main
Commit: 9bf924ce2997
Files: 247
Total size: 3.2 MB

Directory structure:
gitextract_fwagyvzx/

├── .dockerignore
├── .github/
│   ├── dependabot.yml
│   └── workflows/
│       └── ci.yml
├── .gitignore
├── Cargo.toml
├── LICENSE
├── README.md
├── docs/
│   ├── authorizations.md
│   ├── interfaces.md
│   ├── introduction.md
│   └── messages.md
├── interface-wrappers/
│   ├── disk/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── disk.rs
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── ethernet/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       ├── interface.rs
│   │       └── lib.rs
│   ├── framebuffer/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── hardware/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       ├── lib.rs
│   │       └── malloc.rs
│   ├── interface/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── kernel-debug/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       └── lib.rs
│   ├── kernel-log/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── loader/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── log/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── pci/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── random/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── syscalls/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── block_on.rs
│   │       ├── emit.rs
│   │       ├── ffi.rs
│   │       ├── lib.rs
│   │       ├── response.rs
│   │       └── traits.rs
│   ├── system-time/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── tcp/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── time/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── delay.rs
│   │       ├── ffi.rs
│   │       ├── instant.rs
│   │       └── lib.rs
│   └── video-output/
│       ├── Cargo.toml
│       └── src/
│           ├── ffi.rs
│           ├── lib.rs
│           └── video_output.rs
├── kernel/
│   ├── core/
│   │   ├── Cargo.toml
│   │   ├── benches/
│   │   │   ├── keccak.rs
│   │   │   └── keccak.wasm
│   │   └── src/
│   │       ├── extrinsics/
│   │       │   ├── log_calls.rs
│   │       │   └── wasi.rs
│   │       ├── extrinsics.rs
│   │       ├── id_pool.rs
│   │       ├── lib.rs
│   │       ├── module.rs
│   │       ├── primitives.rs
│   │       ├── scheduler/
│   │       │   ├── extrinsics/
│   │       │   │   └── calls.rs
│   │       │   ├── extrinsics.rs
│   │       │   ├── ipc/
│   │       │   │   ├── notifications_queue.rs
│   │       │   │   └── waiting_threads.rs
│   │       │   ├── ipc.rs
│   │       │   ├── processes/
│   │       │   │   ├── tests.rs
│   │       │   │   └── wakers.rs
│   │       │   ├── processes.rs
│   │       │   ├── tests/
│   │       │   │   ├── basic_module.rs
│   │       │   │   ├── emit_not_available.rs
│   │       │   │   └── trapping_module.rs
│   │       │   ├── tests.rs
│   │       │   └── vm.rs
│   │       ├── scheduler.rs
│   │       ├── system/
│   │       │   ├── interfaces.rs
│   │       │   └── pending_answers.rs
│   │       └── system.rs
│   ├── core-proc-macros/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       └── lib.rs
│   └── standalone/
│       ├── Cargo.toml
│       ├── build.rs
│       └── src/
│           ├── arch/
│           │   ├── arm/
│           │   │   ├── executor.rs
│           │   │   ├── log.rs
│           │   │   ├── misc.rs
│           │   │   ├── time_aarch64.rs
│           │   │   └── time_arm.rs
│           │   ├── arm.rs
│           │   ├── riscv/
│           │   │   ├── executor.rs
│           │   │   ├── interrupts.rs
│           │   │   ├── log.rs
│           │   │   └── misc.rs
│           │   ├── riscv.rs
│           │   ├── x86_64/
│           │   │   ├── acpi.rs
│           │   │   ├── ap_boot.rs
│           │   │   ├── apic/
│           │   │   │   ├── io_apic.rs
│           │   │   │   ├── io_apics.rs
│           │   │   │   ├── local.rs
│           │   │   │   ├── pic.rs
│           │   │   │   ├── timers.rs
│           │   │   │   └── tsc_sync.rs
│           │   │   ├── apic.rs
│           │   │   ├── boot.rs
│           │   │   ├── executor.rs
│           │   │   ├── gdt.rs
│           │   │   ├── interrupts.rs
│           │   │   ├── panic.rs
│           │   │   └── pit.rs
│           │   └── x86_64.rs
│           ├── arch.rs
│           ├── hardware.rs
│           ├── kernel.rs
│           ├── klog/
│           │   ├── logger.rs
│           │   ├── native.rs
│           │   └── video.rs
│           ├── klog.rs
│           ├── lib.rs
│           ├── mem_alloc.rs
│           ├── pci/
│           │   ├── native.rs
│           │   └── pci.rs
│           ├── pci.rs
│           ├── random/
│           │   ├── native.rs
│           │   └── rng.rs
│           ├── random.rs
│           └── time.rs
├── kernel-standalone-builder/
│   ├── Cargo.toml
│   ├── build.rs
│   ├── res/
│   │   ├── rpi-firmware/
│   │   │   └── boot/
│   │   │       ├── COPYING.linux
│   │   │       ├── LICENCE.broadcom
│   │   │       ├── bcm2711-rpi-4-b.dtb
│   │   │       ├── start.elf
│   │   │       └── start4.elf
│   │   └── specs/
│   │       ├── aarch64-freestanding.json
│   │       ├── aarch64-freestanding.ld
│   │       ├── arm-freestanding.json
│   │       ├── arm-freestanding.ld
│   │       ├── riscv-hifive.json
│   │       ├── riscv-hifive.ld
│   │       ├── x86_64-multiboot2.json
│   │       └── x86_64-multiboot2.ld
│   ├── simpleboot/
│   │   ├── README.md
│   │   ├── simpleboot/
│   │   │   ├── .gitignore
│   │   │   ├── Kconfig
│   │   │   ├── Kconfig.name
│   │   │   ├── LICENSE
│   │   │   ├── Makefile
│   │   │   ├── README.md
│   │   │   ├── distrib/
│   │   │   │   ├── PKGBUILD
│   │   │   │   ├── simpleboot
│   │   │   │   ├── simpleboot-1.0.0.ebuild
│   │   │   │   ├── simpleboot-9999.ebuild
│   │   │   │   ├── simpleboot_1.0.0-amd64.deb
│   │   │   │   └── simpleboot_1.0.0-armhf.deb
│   │   │   ├── docs/
│   │   │   │   ├── ABI.md
│   │   │   │   ├── README.md
│   │   │   │   └── coreboot.md
│   │   │   ├── example/
│   │   │   │   ├── Makefile
│   │   │   │   ├── README.md
│   │   │   │   ├── bochs.rc
│   │   │   │   ├── gdb.rc
│   │   │   │   ├── kernel.c
│   │   │   │   ├── linux.c
│   │   │   │   └── simpleboot.cfg
│   │   │   ├── simpleboot.h
│   │   │   └── src/
│   │   │       ├── Makefile
│   │   │       ├── boot_x86.asm
│   │   │       ├── cdemu_x86.asm
│   │   │       ├── data.h
│   │   │       ├── inflate.h
│   │   │       ├── loader.h
│   │   │       ├── loader_cb.c
│   │   │       ├── loader_rpi.c
│   │   │       ├── loader_x86.c
│   │   │       ├── misc/
│   │   │       │   ├── bin2h.c
│   │   │       │   └── deb_control
│   │   │       ├── rombios_x86.asm
│   │   │       ├── romfoss_x86.asm
│   │   │       └── simpleboot.c
│   │   └── wrapper.c
│   └── src/
│       ├── bin/
│       │   └── main.rs
│       ├── binary.rs
│       ├── build.rs
│       ├── emulator.rs
│       ├── image.rs
│       ├── lib.rs
│       ├── simpleboot.rs
│       └── test.rs
├── programs/
│   ├── .cargo/
│   │   └── config.toml
│   ├── .dockerignore
│   ├── Cargo.toml
│   ├── compositor/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── lib.rs
│   │       ├── main.rs
│   │       └── rect.rs
│   ├── diagnostics-http-server/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       └── main.rs
│   ├── dummy-system-time/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       └── main.rs
│   ├── e1000/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── device.rs
│   │       └── main.rs
│   ├── hello-world/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       └── main.rs
│   ├── log-to-kernel/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       └── main.rs
│   ├── network-manager/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── interface.rs
│   │       ├── lib.rs
│   │       ├── main.rs
│   │       ├── manager.rs
│   │       └── port_assign.rs
│   ├── pci-printer/
│   │   ├── Cargo.toml
│   │   ├── build/
│   │   │   └── pci.ids
│   │   ├── build.rs
│   │   └── src/
│   │       └── main.rs
│   ├── rpi-framebuffer/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── mailbox.rs
│   │       ├── main.rs
│   │       └── property.rs
│   ├── stub/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       └── main.rs
│   ├── third-party/
│   │   ├── README.md
│   │   └── wasm-timer/
│   │       ├── Cargo.toml
│   │       └── src/
│   │           └── lib.rs
│   └── vga-vbe/
│       ├── Cargo.toml
│       └── src/
│           ├── interpreter/
│           │   └── tests.rs
│           ├── interpreter.rs
│           ├── main.rs
│           └── vbe.rs
└── rust-toolchain

================================================
FILE CONTENTS
================================================

================================================
FILE: .dockerignore
================================================
target


================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: github-actions
  directory: "/"
  labels: []
  rebase-strategy: disabled  # Redundant with mergify
  schedule:
    interval: daily
- package-ecosystem: cargo
  directory: "/kernel-standalone-builder"
  labels: []
  rebase-strategy: disabled  # Redundant with mergify
  schedule:
    interval: daily
- package-ecosystem: cargo
  directory: "/programs"
  labels: []
  rebase-strategy: disabled  # Redundant with mergify
  schedule:
    interval: daily
- package-ecosystem: cargo
  directory: "/"
  labels: []
  rebase-strategy: disabled  # Redundant with mergify
  schedule:
    interval: daily


================================================
FILE: .github/workflows/ci.yml
================================================
name: Continuous integration

on:
  pull_request:

jobs:
  build-programs:
    name: Build WASM programs
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Install Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: nightly-2025-03-14
        target: wasm32-wasip1
        override: true
    - name: Install dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y cmake
    - uses: actions/cache@v4.2.3
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          programs/target
        key: programs-cargo-${{ hashFiles('./programs/Cargo.lock') }}
    - name: Build programs
      run: cargo build --manifest-path ./programs/Cargo.toml --workspace --exclude stub --locked --verbose --release --target=wasm32-wasip1
    - name: Upload WASM programs
      uses: actions/upload-artifact@v4
      with:
        name: wasm-programs
        path: programs/target

  test-core:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/cache@v4.2.3
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: core-cargo-${{ hashFiles('**/Cargo.lock') }}
    - name: Install nightly Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: nightly-2025-03-14
        target: wasm32-wasip1
        override: true
    - name: Test redshirt-core
      run: cargo test --package redshirt-core

  build-test-standalone:
    name: Build and test standalone kernel
    needs: build-programs
    runs-on: ubuntu-20.04  # TODO: for the more recent QEmu version compared to ubuntu-18
    strategy:
      matrix:
        #target: [x86_64-multiboot2, arm-rpi2]  # TODO: not implemented
        target: [x86_64-multiboot2]
    steps:
    - uses: actions/checkout@v4
    - name: Download WASM programs
      uses: actions/download-artifact@v4
      with:
        name: wasm-programs
    - name: Install required packages
      run: |
        sudo apt-get update
        sudo apt-get install -y clang lld libisoburn1 xorriso grub-pc-bin mtools
    - run: |
        sudo apt-get install qemu-utils qemu-system-x86
      if: ${{ matrix.target == 'x86_64-multiboot2'}}
    - uses: actions/cache@v4.2.3
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          kernel-standalone-builder/target
          target
        key: standalone-kernel-cargo-${{ hashFiles('**/Cargo.lock') }}
    - name: Install nightly Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: nightly-2025-03-14
        target: wasm32-wasip1
        override: true
    - name: Install rust-src
      run: rustup component add rust-src
    - name: Build kernel
      run: cargo run --manifest-path=./kernel-standalone-builder/Cargo.toml -- build-image --target ${{ matrix.target }} --device-type cdrom --out image
    - name: Test kernel
      run: cargo run --manifest-path=./kernel-standalone-builder/Cargo.toml -- emulator-test --target ${{ matrix.target }} --emulator qemu
    - name: Upload generated kernel
      uses: actions/upload-artifact@v4
      with:
        name: kernel-${{ matrix.target }}
        path: image

  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v4
      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
      - name: Install rustfmt
        run: rustup component add rustfmt
      - name: Run cargo fmt on root workspace
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check
      - name: Run cargo fmt on programs workspace
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all --manifest-path=programs/Cargo.toml -- --check
      - name: Run cargo fmt on standalone tester workspace
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all --manifest-path=kernel-standalone-builder/Cargo.toml -- --check

  intra-doc-links:
    name: Check intra-doc links
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v4
      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly-2025-03-14
          target: wasm32-wasip1
          override: true
      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y clang
      - uses: actions/cache@v4.2.3
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            programs/target
            kernel-standalone-builder/target
            target
          key: intra-doc-links-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
      - name: Check core intra-doc links
        run: RUSTDOCFLAGS="--deny broken_intra_doc_links" cargo doc --verbose --workspace --no-deps --document-private-items
      - name: Check programs intra-doc links
        run: RUSTDOCFLAGS="--deny broken_intra_doc_links" cargo doc --verbose --manifest-path programs/Cargo.toml --workspace --no-deps --document-private-items

  all-ci:
    # This dummy job depends on all the mandatory checks. It succeeds if and only if CI is
    # considered successful.
    needs: [build-test-standalone, fmt, intra-doc-links]
    runs-on: ubuntu-latest
    steps:
     - run: echo Success


================================================
FILE: .gitignore
================================================
target


================================================
FILE: Cargo.toml
================================================
[workspace]
members = [
    "kernel/core",
    "kernel/core-proc-macros",
    "kernel/standalone",
    "interface-wrappers/disk",
    "interface-wrappers/ethernet",
    "interface-wrappers/framebuffer",
    "interface-wrappers/hardware",
    "interface-wrappers/interface",
    "interface-wrappers/kernel-debug",
    "interface-wrappers/kernel-log",
    "interface-wrappers/loader",
    "interface-wrappers/log",
    "interface-wrappers/pci",
    "interface-wrappers/random",
    "interface-wrappers/syscalls",
    "interface-wrappers/system-time",
    "interface-wrappers/tcp",
    "interface-wrappers/time",
    "interface-wrappers/video-output",
]

[profile.dev]
opt-level = 1

[profile.dev.package."*"]
opt-level = 3

[profile.test.package."*"]
opt-level = 3

[profile.release]
opt-level = 3
lto = true
codegen-units = 1
panic = 'abort'


================================================
FILE: LICENSE
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    Copyright (C) 2019-2020  Pierre Krieger

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    Copyright (C) 2019-2021  Pierre Krieger
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.


================================================
FILE: README.md
================================================
The **redshirt** operating system is an experiment to build some kind of operating-system-like
environment where executables are all in Wasm and are loaded from an IPFS-like decentralized
network.

See the `docs/introduction.md` file for an introduction.

# How to test

**Important**: At the moment, most of the compilation requires a nightly version of Rust. See also https://github.com/tomaka/redshirt/issues/300.
Your C compiler must be recent enough to be capable of compiling to WebAssembly. This is for example the case for clang 9. See also https://github.com/tomaka/redshirt/issues/257.

You also need to install the `wasm32-wasip1` target, as the Wasm programs are compiled for Wasi, and the `rust-src` component in order to build the standalone kernel.

```
rustup toolchain install --target=wasm32-wasip1 nightly
rustup component add --toolchain=nightly rust-src
```

Building the freestanding kernel is then done through the utility called `standalone-builder`:

```
cd kernel-standalone-builder
cargo +nightly run -- emulator-run --emulator qemu --target x86_64-multiboot2
```

# Repository structure

Short overview of the structure of the repository:

- `docs` contains a description of what redshirt is and how it works. Start with `docs/introduction.md`.
- `interface-wrappers` contains crates that provide definitions and helpers for Wasm programs to use
  (examples: `tcp` for TCP/IP, `window` for windowing).
- `kernel` contains the code required to run the kernel.
- `kernel-standalone-kernel` contains a utility allowing to run and test the standalone kernel.
- `programs` contains Wasm programs.

# Contributing

Please note that so far this is mostly a personal project. I reserve the right to change anything
at any time, including the license.


================================================
FILE: docs/authorizations.md
================================================
It is generally desirable to limit as much as possible the rights that a program has.

In redshirt, there is no system-wide rights management. Instead, each interface holds a list of which program can have access to the capabilities that they provide.

For example, it is the network manager program that holds a list of the programs that are allowed to open TCP connections.

By default, all programs should be banned from using anything, and must instead be whitelisted. For example, when you create a new process, it is by default prevented from using the TCP connection. One must then send a message to the TCP interface to inform the network manager that the newly-created process is allowed to open TCP connections.


================================================
FILE: docs/interfaces.md
================================================
This document contains information about interfaces, plus a list of interfaces that exist.

# Interfaces designing

## Does this warrant an interface?

Interfaces are fundamentally related to code re-use and synchronizing components.

It is for example theoretically possible for an HTTP server to communicate directly with the networking card of the machine and to directly issue read commands to hard-disk drives. This can be done by statically linking the server to device drivers.

In practice, however, doing so has two big drawbacks:

- Even if we suppose that the HTTP server supports all hardware that has ever existed, new incompatible hardware gets constantly released. As such, the HTTP server would stop working on newer machines unless it gets updated.
- Multiple programs trying to access the same hardware will conflict with each other.

Because of these two drawbacks, the hardware should be abstracted behind an interface. The first drawback is solved because the interface user and the interface handler can both be updated separately, and the second drawback is solved by having multiple interface users communicate with the same interface handler.

If, however, we take the example of font rendering (turning font files into bitmaps), none of these two drawbacks apply. Consequently, there shouldn't be an interface dedicated to font rendering.

## Updating an interface

It sometimes happens that interfaces need a modification. Interfaces are considered immutable, and modifying an interface can in practice be done only by creating a different interface (that closely resembles the old one) with a different hash.

Simply switching everything to the new interface, however, would break all the existing softwares that use the former interface.

In order to remedy to this, there are two solutions:

- Interface handlers can register both the old and the new hash.
- There can be a program can acts as a conversion layer between the old and the new hash, accepting messages from the old interface, translating them, and re-emitting them.

## Avoiding cross-interface concerns

The list of interfaces will never be set in marble, and each version of an interface is in principle unrelated to the previous versions of that interface. As such, an interface must **never** depend on another interface.

For example, in the Linux world, creating an OpenGL context requires passing an X11 display. This means that a hypothetical equivalent redshirt OpenGL interface would depend on the equivalent redshirt X11 interface. This is forbidden.

If an equivalent of OpenGL+X11 had to be designed, one could create an interface that combines all of OpenGL and X11 together.

Keep in mind that there is no one-to-one relation between interfaces and messages. For example an interface can combine into one the messaages of multiple other interfaces. "Elegance", "minimalism" or "code reuse" are not valid reasons to split an interface in multiple parts.

# Kernel-handled interfaces

Some interfaces, such as the `interface` interface, must be handled by the kernel. There is no other way that would lead to a correct implementation.

# Determining an interface hash

Undesigned at the moment.

# List of existing or planned interfaces

And now for a list. This list is most likely not up-to-date.

This list contains human-friendly names, but remember that interfaces are defined by their hash.

- `audio-playback`: Playing sounds.
- `device-tree`: Accessing hardware devices described by a DeviceTree (if any).
- `disks`: Registering disks potentially containing files.
- `ethernet`: Registering Ethernet interfaces.
- `files`: Opening/reading/writing files on a specific disk.
- `framebuffer`: Drawing a RGB buffer to an unspecified location.
- `hardware`: Accessing physical memory. Note: will most likely disappear to be superceded by `pci` and `device-tree`.
- `hid`: Accessing human-interface devices (keyboard, mouse, joysticks, etc.).
- `interface`: Registering interfaces.
- `kernel-debug`: Gathering information and statistics about the kernel. Supposed to be shown to users.
- `kernel-log`: Indicating to the kernel how to write its logs.
- `loader`: Loading content-addressed resources.
- `log`: Sending out logs destined to the user.
- `pci`: Accessing PCI devices (if any): reading/writing their memory-mapped memory/registers and waiting for interrupts.
- `random`: Generating random values.
- `system-time`: Managing the real time clock.
- `tcp`: TCP/IP sockets.
- `time`: Getting the value of the monotonic clock and waiting.
- `udp`: UDP packets.
- `usb`: Accessing USB devices (if any).
- `video-output`: Registering video outputs that will be presented to the user. Typically a video card connected to a monitor.
- `webgpu`: Issuing WebGPU draw calls to an unspecified location.


================================================
FILE: docs/introduction.md
================================================
# Introduction

Redshirt is similar to an operating system. It allows executing programs that communicate with each other via messages.

# Programs

The concept of a **program** is the same as in an operating system. It is a list of instructions that are executed and that have access to some memory.

Contrary to most operating systems, the instruction set of programs in redshirt is [WebAssembly](https://webassembly.org/) (also referred to as "Wasm").

Using WebAssembly as the instructions set has two consequences:

- All programs are cross-platform.
- Programs are not executed directly by the CPU, but by an interpreter or must first be translated into native code.

Thanks to the second point, we can eliminate the need for mechanisms such as paging/virtual memory and privilege levels. In other words, we don't make use of any of the sandboxing measures normally provided by the CPU.

## How are programs actually executed?

At the time of the writing of this documentation, we use [the `wasmi` crate](https://docs.rs/wasmi) to execute programs.

It has been measured that compiling a program and executing it with `wasmi` is approximately ten times slower than compiling the same program for the native architecture and executing it.
This measurement has been performed within Linux and this doesn't account, however, for the overhead introduced by the CPU's sandboxing measures.

Crates such as [`wasmtime`](https://docs.rs/wasmtime) should make it possible to considerably boost the performance of programs. Comparing a well-optimized HTTP server compiled for the native architecture to a badly-optimized HTTP server executed by `wasmtime` showed that the latter was capable of serving half of the requests per second of the former.

## Limitations of sandboxing

One design issue that hasn't been solved at the time of this writing is  [preemption](https://en.wikipedia.org/wiki/Preemption_(computing)). In other words: how to run multiple CPU-intensive programs on the same CPU? In a typical operating system, the CPU receives periodic interrupts during which the operating system swaps the current thread for another.

Ideally, we would like to avoid relying on the CPU receiving interrupts and instead rely on [cooperating multitasking](https://en.wikipedia.org/wiki/Cooperative_multitasking). It is possible to make the WebAssembly interpreter or JIT insert periodic checks that interrupt the execution if a certain time has passed, but these checks are generally thought to be prohibitively expensive.

Additionally, at the time of this writing, redshirt doesn't enforce any limit on the memory that Wasm programs can use. This is however only a matter of implementation.

## About threads

WebAssembly at the moment doesn't specify any threading model or any memory model.

While redshirt has experimental support for creating multiple threads within a single process, WebAssembly-targeting compilers work under the assumption that only a single thread exists at any given point in time. As an example, LLVM stores the current stack pointer in a global variable.

Consequently, while experimental support exists, it isn't possible at the moment for programs to create secondary threads.

# Messages and interfaces

Programs are totally sandboxed, except for their capability to send messages to other processes and receive messages sent by other processes.

It is not possible, however, to send a message to a specific process (through a PID for instance). Instead, when you send a message, what you target is an **interface**.

Here is how it works:

- Program A registers itself towards the operating system to be the handler of a specific interface I.
- Program B sends a message whose destination is I.
- Program A receives the message that B has sent.
- Optionally, A can send a single answer to B's message.

In this example, B doesn't know about the existence of A. However, A knows about the existence of B so that it can properly track resources allocation.

Interfaces are referred to by a hash.

## What is the hash of an interface?

In the initial design, interfaces are defined by a list of messages and answers. The hash of an interface corresponds to the hash of the definition of these messages.

This is however quite difficult to implement in practice, and at the moment the hash is randomly generated manually (by visiting https://random.org) when a new interface is defined.

## Answers

Each message emitted accepts either zero or one answer. The sender indicates to the operating system whether it expects an answer.

If the emitter indicates that it expects an answer, a unique **message ID** gets assigned. This identifier is later passed to the interface handler for it to indicate which message it is answering.

## Message bodies and answer bodies

The actual message's body and the answer's body consist of an opaque buffer of data.

The way this body must be interpreted depends on the interface the message is targetting.


================================================
FILE: docs/messages.md
================================================
Contains details about the messages passing system.

# Syscalls

There exists five syscalls at the moment:

- `next_notification`
- `emit_message`
- `emit_answer`
- `emit_message_error`
- `cancel_message`

Describing their exact API/ABI here would be redundant. Please read the source code of the `syscalls` crate.

In WebAssembly, imported functions always belong to a namespace. The namespace of these five functions is `redshirt`.

# Emitting a message

The `emit_message` syscall requires passing:

- A target interface.
- A message body.
- A flag indicating whether or not an answer is expected.
- A flag indicating whether or not the function is allowed to wait in case there is no interface handler or the interface handler is overwhelmed.

If an answer is expected, a `MessageId` gets assigned and is returned to the caller.

If no interface handler exists for the target interface, or if the interface handler isn't capable of accepting a message at the moment, the function will either wait or immediately return with an error, depending on the function parameters.

## System initialization

At system initialization, the kernel is tasked to start all the programs that the user has requested to start.

The kernel doesn't know in advance which program is going to use or register which interface, so it simply starts everything at the same time.

Consequently, it is possible (in particular shortly after the system's initialization) for a program to try emit a message on an interface that hasn't been registered yet but is going to be in the near future.

It is, consequently, recommended to leave the `allow_block` flag on.

## Limits

(Note: this is not yet implemented at the time of this writing)

There exists a limit to the number of simultaneous `MessageId`s held by a specific process. Messages continue to count towards the limit as long as they haven't been answered, even if they have been cancelled (see below).

This mechanism can be compared to the `ulimits` in the Linux world.

Note that this limit is not supposed to be normally reached under normal circumstances, and serves mostly as a protection against accidental infinite loops.

# Waiting for notifications

Each process is characterized by a queue of notifications that can be retrieved using this function. A notification only consists, at the moment, of an answer to a previously-emitted message.

The `next_notification` syscall allows querying the operating system for notifications. It is similar to `epoll` in the Linux world.

The parameters of this syscall are:

- A list of `MessageId`s whose answer to query.
- A flag indicating whether to wait or not.

If a notification in the queue matches one of the elements in the list, then this notification is retrieved. Otherwise, the function will block if the flag is set or return immediately if it is not.

Notifications contain the `MessageId`, whether the message has been successful or not, and the body of the answer.

## Limit to the queue size

(note: this isn't implemented at the time of writing)

If the number of notifications in a queue is higher than a certain limit, then emitting a message on the registered interfaces will block the emitter.

# Answering messages

Messages can be answer either by a "success" answer, containing a body, or by an "error" answer, via respectively the `emit_answer` and `emit_message_error` syscalls.

If an interface handler crashes, then all of the messages that it was supposed to answer are automatically answered with an error.

After a message has been answered, the corresponding `MessageId` is no longer valid.

# Cancelling messages

The `cancel_message` syscall allows one to notify the kernel that it is no longer interested in the answer to a previously-emitted message.

The message continues to be processed normally, and the interface handler isn't made aware of the cancellation.

The difference is that answers to cancelled messages are not pushed in the queue of notifications of the sending process.

Cancelling a message makes it possible to avoid the awkward situation where one needs to somehow call `next_notification` with that message only to discard the answer immediately after. Having to call `next_notification` even when we've free'd all the other resources associated with the message can be very annoying to deal with by itself.

# Backpressure

Under the design described above, an interface handler has no way to pro-actively notify an interface user of something happening.

For example the network manager has no way to tell the program that has opened a TCP socket that a message has arrived on that socket.

Instead, the interface user must emit a message asking the interface handler for the next event that happens. When the handler wants to notify the user of something, it can do so by answering that message.

This scheme permits proper backpressure to apply. A message sender is guaranteed to not receive more answers that it has emitted messages. It prevents a possible deadlock where a handler is waiting for more room in a process's queue, while the process is waiting for more room in the handler's queue.

There is, however, a possible deadlock if A tries to send to B, B sends to C, and C sends to A, while all three queues are full. This need to be solved.


================================================
FILE: interface-wrappers/disk/Cargo.toml
================================================
[package]
name = "redshirt-disk-interface"
version = "0.1.0"
license = "GPL-3.0-or-later"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
edition = "2018"

[dependencies]
futures = "0.3.13"
redshirt-syscalls = { path = "../syscalls" }
parity-scale-codec = { version = "1.3.6", features = ["derive"] }
rand = "0.8.3"


================================================
FILE: interface-wrappers/disk/src/disk.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Registering disks.
//!
//! This module allows you to register your disk. Reading and writing commands can then be issued
//! towards this disk.
//!
//! Use this if you're writing for example an ATA/ATAPI or USB driver.
//!
//! # Usage
//!
//! - Call [`register_disk`] in order to notify of the existence of a disk.
//! - You obtain a [`DiskRegistration`] that you can use to obtain the commands that need to be
//!   executed by the disk.
//! - Dropping the [`DiskRegistration`] unregisters the disk.
//!

use crate::ffi;
use core::fmt;
use futures::{lock::Mutex, prelude::*};
use redshirt_syscalls::{Decode as _, Encode as _, EncodedMessage};

/// Configuration of an interface to register.
#[derive(Debug)]
pub struct DiskConfig {
    /// `True` if the disk accepts write commands. `False` is the disk can only be read, for
    /// example for CD-ROMs.
    pub allow_write: bool,

    /// Size, in bytes, of a sector.
    pub sector_size: u32,

    /// Number of sectors on the disk.
    pub num_sectors: u32,
}

/// Registers a new disk.
pub async fn register_disk(config: DiskConfig) -> DiskRegistration {
    unsafe {
        let id = rand::random();

        redshirt_syscalls::emit_message_without_response(&ffi::INTERFACE, &{
            ffi::DiskMessage::RegisterDisk {
                id,
                allow_write: config.allow_write,
                sector_size: config.sector_size,
                num_sectors: config.num_sectors,
            }
        })
        .unwrap();

        DiskRegistration {
            id,
            commands: Mutex::new((0..10).map(|_| build_commands_future(id)).collect()),
        }
    }
}

/// Registered disk.
///
/// Destroying this object will unregister the interface.
pub struct DiskRegistration {
    /// Identifier of the interface in the disks manager.
    id: u64,

    /// Futures that will resolve once we receive a command that the disk must execute.
    commands: Mutex<stream::FuturesOrdered<redshirt_syscalls::MessageResponseFuture<Vec<u8>>>>,
}

/// Build a `Future` resolving to the next command to execute by the disk.
fn build_commands_future(disk_id: u64) -> redshirt_syscalls::MessageResponseFuture<Vec<u8>> {
    unsafe {
        let message = ffi::DiskMessage::DiskNextCommand(disk_id).encode();
        let msg_id = redshirt_syscalls::MessageBuilder::new()
            .add_data(&message)
            .emit_with_response_raw(&ffi::INTERFACE)
            .unwrap();
        redshirt_syscalls::message_response(msg_id)
    }
}

impl DiskRegistration {
    /// Returns the next command that the disk must execute.
    ///
    /// > **Note**: It is possible to call this method multiple times on the same
    /// >           [`DiskRegistration`]. If that is done, no guarantee exists as to which
    /// >           `Future` finishes first.
    pub async fn next_command(&self) -> Command {
        let mut commands = self.commands.lock().await;
        let data = commands.next().await.unwrap();
        commands.push(build_commands_future(self.id));
        // TODO: extra copy when decoding :-/
        let decoded = ffi::DiskCommand::decode(EncodedMessage(data)).unwrap();
        match decoded {
            ffi::DiskCommand::StartRead {
                id,
                sector_lba,
                num_sectors,
            } => Command::Read(ReadCommand {
                id,
                sector_lba,
                num_sectors,
            }),
            ffi::DiskCommand::StartWrite {
                id,
                sector_lba,
                data,
            } => Command::Write(WriteCommand {
                id,
                sector_lba,
                data,
            }),
        }
    }
}

impl fmt::Debug for DiskRegistration {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.debug_tuple("DiskRegistration").field(&self.id).finish()
    }
}

impl Drop for DiskRegistration {
    fn drop(&mut self) {
        unsafe {
            let message = ffi::DiskMessage::UnregisterDisk(self.id);
            redshirt_syscalls::emit_message_without_response(&ffi::INTERFACE, &message).unwrap();
        }
    }
}

/// Command received from the disks manager.
pub enum Command {
    /// See [`ReadCommand`].
    Read(ReadCommand),
    /// See [`WriteCommand`].
    Write(WriteCommand),
}

/// Read command received from the disks manager. The registerer must read data from the disk.
pub struct ReadCommand {
    id: ffi::ReadId,
    sector_lba: u64,
    num_sectors: u32,
}

impl ReadCommand {
    /// Returns the first sector to read from.
    pub fn sector_lba(&self) -> u64 {
        self.sector_lba
    }

    /// Returns the number of sectors to read.
    pub fn num_sectors(&self) -> u32 {
        self.num_sectors
    }

    /// Report that the read has finished. Contains the data read from the disk.
    pub fn report_finished(self, data: Vec<u8>) {
        unsafe {
            let message = ffi::DiskMessage::ReadFinished(self.id, data);
            redshirt_syscalls::emit_message_without_response(&ffi::INTERFACE, &message).unwrap();
        }
    }
}

/// Write command received from the disks manager. The registerer must write data to the disk.
pub struct WriteCommand {
    id: ffi::WriteId,
    sector_lba: u64,
    data: Vec<u8>,
}

impl WriteCommand {
    /// Data to write to the disk.
    pub fn data(&self) -> &[u8] {
        &self.data
    }

    /// Returns the first sector to write to.
    pub fn sector_lba(&self) -> u64 {
        self.sector_lba
    }

    /// Report that the write has finished.
    pub fn report_finished(self) {
        unsafe {
            let message = ffi::DiskMessage::WriteFinished(self.id);
            redshirt_syscalls::emit_message_without_response(&ffi::INTERFACE, &message).unwrap();
        }
    }
}


================================================
FILE: interface-wrappers/disk/src/ffi.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

use parity_scale_codec::{Decode, Encode};
use redshirt_syscalls::InterfaceHash;

// TODO: this has been randomly generated; instead should be a hash or something
pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
    0x99, 0x94, 0xca, 0x60, 0xcf, 0x73, 0x7b, 0x59, 0xf7, 0xdc, 0x0c, 0xc4, 0xf0, 0x57, 0x42, 0x2e,
    0x79, 0xa7, 0xb6, 0x81, 0xbb, 0xf8, 0x4e, 0x24, 0x8e, 0xbf, 0x1a, 0x8f, 0x2c, 0xf6, 0xea, 0xc8,
]);

#[derive(Debug, Encode, Decode)]
pub enum DiskMessage {
    /// Notify of the existence of a new disk.
    // TODO: what if this id was already registered?
    RegisterDisk {
        /// Unique per-process identifier.
        id: u64,
        /// True if writing to this disk is allowed.
        allow_write: bool,
        /// Size, in bytes, of a sector of the disk.
        sector_size: u32,
        /// Number of sectors on the disk.
        num_sectors: u32,
    },

    /// Removes a previously-registered disk.
    UnregisterDisk(u64),

    /// Asks for the next command the disk must execute.
    ///
    /// Must answer with a [`DiskCommand`].
    DiskNextCommand(u64),

    /// Report that a [`DiskCommand::StartRead`] has finished.
    ///
    /// Has no response.
    ReadFinished(ReadId, Vec<u8>),

    /// Report that a [`DiskCommand::StartWrite`] has finished.
    ///
    /// Has no response.
    WriteFinished(WriteId),
}

#[derive(Debug, Encode, Decode)]
pub enum DiskCommand {
    StartRead {
        id: ReadId,
        sector_lba: u64,
        num_sectors: u32,
    },
    StartWrite {
        id: WriteId,
        sector_lba: u64,
        data: Vec<u8>,
    },
}

#[derive(Debug, Encode, Decode, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ReadId(pub u64);

#[derive(Debug, Encode, Decode, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct WriteId(pub u64);


================================================
FILE: interface-wrappers/disk/src/lib.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Disk registration and commands issuance.
//!
//! # Overview
//!
//! This interface allows indicating the presence of a disk on the machine by registering it. The
//! registered disk can then receive commands (such as reading and writing data) that it must
//! execute.
//!
//! The word "disk" should be understood as in a hard disk drive (HDD), solid-state drive (SSD),
//! CD-ROM drive, floppy disk drive, and anything similar.
//!
//! It is recommended to **not** register disks that aren't actual physical objects connected to
//! the machine (such as disks accessed over the network, or equivalents to UNIX's `losetup`).
//! Redshirt tries to be as explicit as possible and to keep its abstractions as close as possible
//! to the objects being abstracted.
//!
//! Users of this interface are expected to be ATA/ATAPI drivers, USB drivers, and similar. The
//! handler of this interface is expected to be a filesystem manager that determines the list of
//! partitions and handles the file systems.
//!
//! # About disks
//!
//! In the abstraction exposed by this interface, a disk is composed of a certain number of
//! sectors, each having a certain size. The size of all sectors is identical. These sectors are
//! indexed from `0` to `num_sectors - 1`.
//!
//! The sector index is typically referred to by the term "LBA sector". *LBA* designates the fact
//! that each sector is addressed through a index ranging linearly from `0` to `num_sectors - 1`,
//! as opposed to the older *CHS* addressing where sectors were referred to a by a head number,
//! cylinder number, and sectors offset. CHS addressing isn't used in this interface.
//!
//! It is not possible to partially read or write a sector. The sector has to be read entirely,
//! or written entirely.
//!
//! # Flushing
//!
//! The interface requires each disk write to be confirmed by sending a message on the interface
//! after it has been performed. This is important in order for the upper layer to be capable of
//! handling problematic situations such as a power outage.
//!
//! Consequently, while the disk driver is allowed to maintain a write cache, it must not report
//! a write success after the data has been put in cache, but after it has been written to disk.
//!
//! In the interval of time between the moment the writing is issued and the moment it is
//! confirmed, the upper layers should consider that the sector is physically in an undefined
//! state.

pub mod disk;
pub mod ffi;


================================================
FILE: interface-wrappers/ethernet/Cargo.toml
================================================
[package]
name = "redshirt-ethernet-interface"
version = "0.1.0"
license = "GPL-3.0-or-later"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
edition = "2018"

[dependencies]
futures = "0.3.13"
redshirt-syscalls = { path = "../syscalls" }
parity-scale-codec = { version = "1.3.6", features = ["derive"] }
rand = "0.8.3"


================================================
FILE: interface-wrappers/ethernet/src/ffi.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

use parity_scale_codec::{Decode, Encode};
use redshirt_syscalls::InterfaceHash;

// TODO: this has been randomly generated; instead should be a hash or something
pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
    0x56, 0xf0, 0xad, 0x54, 0x6c, 0x6d, 0x91, 0xce, 0xc2, 0x10, 0x88, 0xf6, 0x32, 0x2b, 0x66, 0x45,
    0xd4, 0xcf, 0xbe, 0xa3, 0xf7, 0x03, 0x13, 0xcd, 0x04, 0x65, 0xfd, 0x7f, 0x06, 0xd4, 0x24, 0xa1,
]);

#[derive(Debug, Encode, Decode)]
pub enum NetworkMessage {
    /// Notify of the existence of a new Ethernet interface.
    // TODO: what if this id was already registered?
    RegisterInterface {
        /// Unique per-process identifier.
        id: u64,
        /// MAC address of the interface.
        mac_address: [u8; 6],
    },

    /// Removes a previously-registered interface.
    UnregisterInterface(u64),

    /// Notify when an interface has received data (e.g. from the outside world). Must answer with
    /// a `()` when the send is finished and we're ready to accept a new packet.
    ///
    /// The packet must be an Ethernet frame without the CRC.
    InterfaceOnData(u64, Vec<u8>),

    /// Asks for the next packet of data to send out through this interface (e.g. going towards
    /// the outside world). Must answer with a `Vec<u8>`.
    ///
    /// The packet must be an Ethernet frame without the CRC.
    InterfaceWaitData(u64),
}


================================================
FILE: interface-wrappers/ethernet/src/interface.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Registering Ethernet interfaces.
//!
//! This module allows you to register your Ethernet interface. TCP and UDP sockets will then use
//! it to communicate with the outside.
//!
//! Use this if you're writing for example a networking driver or a VPN.
//!
//! # Usage
//!
//! - Call [`register_interface`] in order to notify of the existence of an interface.
//! - You obtain a [`NetInterfaceRegistration`] that you can use to report packets that came from
//! the wire, and from which you can obtain packets to send to the wire.
//! - Dropping the [`NetInterfaceRegistration`] unregisters the interface.
//!

use crate::ffi;
use core::fmt;
use futures::{
    lock::{Mutex, MutexGuard},
    prelude::*,
};
use redshirt_syscalls::Encode as _;

/// Configuration of an interface to register.
#[derive(Debug)]
pub struct InterfaceConfig {
    /// MAC address of the interface.
    ///
    /// If this is a virtual device, feel free to randomly generate a MAC address.
    pub mac_address: [u8; 6],
}

/// Registers a new network interface.
pub async fn register_interface(config: InterfaceConfig) -> NetInterfaceRegistration {
    unsafe {
        let id = rand::random();

        redshirt_syscalls::emit_message_without_response(&ffi::INTERFACE, &{
            ffi::NetworkMessage::RegisterInterface {
                id,
                mac_address: config.mac_address,
            }
        })
        .unwrap();

        NetInterfaceRegistration {
            id,
            packet_from_net: Mutex::new(None),
            packet_to_net: Mutex::new((0..10).map(|_| build_packet_to_net(id)).collect()),
        }
    }
}

/// Registered network interface.
///
/// Destroying this object will unregister the interface.
pub struct NetInterfaceRegistration {
    /// Identifier of the interface in the network manager.
    id: u64,

    /// Futures that will resolve once we receive a packet from the network manager to send to the
    /// network.
    packet_to_net: Mutex<stream::FuturesOrdered<redshirt_syscalls::MessageResponseFuture<Vec<u8>>>>,

    /// Future that will resolve once we have successfully delivered a packet from the network,
    /// and are ready to deliver a next one.
    // TODO: should probably change to send multiple packets in parallel
    packet_from_net: Mutex<Option<redshirt_syscalls::MessageResponseFuture<()>>>,
}

/// Build a `Future` resolving to the next packet to send to the network.
///
/// Only one such `Future` must be alive at any given point in time.
fn build_packet_to_net(interface_id: u64) -> redshirt_syscalls::MessageResponseFuture<Vec<u8>> {
    unsafe {
        let message = ffi::NetworkMessage::InterfaceWaitData(interface_id).encode();
        let msg_id = redshirt_syscalls::MessageBuilder::new()
            .add_data(&message)
            .emit_with_response_raw(&ffi::INTERFACE)
            .unwrap();
        redshirt_syscalls::message_response(msg_id)
    }
}

impl NetInterfaceRegistration {
    /// Wait until the network manager is ready to accept a packet coming from the network.
    ///
    /// Returns a [`PacketFromNetwork`] object that allows you to transmit the packet.
    ///
    /// > **Note**: It is possible to call this method multiple times on the same
    /// >           [`NetInterfaceRegistration`]. If that is done, no guarantee exists as to which
    /// >           `Future` finishes first.
    pub async fn packet_from_network<'a>(&'a self) -> PacketFromNetwork<'a> {
        // Wait for the previous send to be finished.
        let mut packet_from_net = self.packet_from_net.lock().await;
        if let Some(fut) = packet_from_net.as_mut() {
            fut.await;
        }
        *packet_from_net = None;

        PacketFromNetwork {
            parent: self,
            send_future: packet_from_net,
        }
    }

    /// Returns the next packet to send to the network.
    ///
    /// > **Note**: It is possible to call this method multiple times on the same
    /// >           [`NetInterfaceRegistration`]. If that is done, no guarantee exists as to which
    /// >           `Future` finishes first.
    pub async fn packet_to_send(&self) -> Vec<u8> {
        let mut packet_to_net = self.packet_to_net.lock().await;
        let data = packet_to_net.next().await.unwrap();
        packet_to_net.push(build_packet_to_net(self.id));
        data
    }
}

impl fmt::Debug for NetInterfaceRegistration {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.debug_tuple("NetInterfaceRegistration")
            .field(&self.id)
            .finish()
    }
}

impl Drop for NetInterfaceRegistration {
    fn drop(&mut self) {
        unsafe {
            let message = ffi::NetworkMessage::UnregisterInterface(self.id);
            redshirt_syscalls::emit_message_without_response(&ffi::INTERFACE, &message).unwrap();
        }
    }
}

/// Allows you to transmit a packet received from the network to the manager.
#[must_use]
pub struct PacketFromNetwork<'a> {
    parent: &'a NetInterfaceRegistration,
    send_future: MutexGuard<'a, Option<redshirt_syscalls::MessageResponseFuture<()>>>,
}

impl<'a> PacketFromNetwork<'a> {
    /// Send the packet to the manager.
    pub fn send(mut self, data: impl Into<Vec<u8>>) {
        unsafe {
            debug_assert!(self.send_future.is_none());
            let message =
                ffi::NetworkMessage::InterfaceOnData(self.parent.id, data.into()).encode();
            let msg_id = redshirt_syscalls::MessageBuilder::new()
                .add_data(&message)
                .emit_with_response_raw(&ffi::INTERFACE)
                .unwrap();
            let fut = redshirt_syscalls::message_response(msg_id);
            *self.send_future = Some(fut);
        }
    }
}


================================================
FILE: interface-wrappers/ethernet/src/lib.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Ethernet interfaces.
//!
//! This interface allows registering Ethernet interfaces that conform to the requirements
//! described in [RFC1122](https://tools.ietf.org/html/rfc1122).
//!
//! Users of this interface can notify of the presence of an Ethernet interface, after which it
//! can notify of Ethernet frames having been received on this interface, and request Ethernet
//! frames to be sent on the interface.
//!
//! The Ethernet frames that are communicated contain:
//!
//! - The destination MAC.
//! - The source MAC.
//! - An optional 802.1Q tag.
//! - The Ethertype field.
//! - The payload.
//!
//! Most notably, they **don't** include any preamble, delimiter, interpacket gap, and checksum.
//!
//! # Networking overview
//!
//! This section provides some overview of networking in general.
//!
//! ## Link layer routing
//!
//! Each Ethernet interface registered with this interface possesses a MAC address, and is assumed
//! to be directly connected to zero, one, or more other machines.
//!
//! Thanks to the ARP or NDP protocols, it is possible to broadcast a request on the Ethernet
//! interface asking who we are connected to. The nodes that receive the request respond with their
//! IP and MAC address. If later we want to send a direct message to one of these nodes, we simply
//! emit an Ethernet frame with the MAC address of the destination.
//!
//! Note that being "directly connected" to a node doesn't necessarily mean that there exists a
//! physical cable between us and this node. Hubs, switches, or Wifi routers, can act as an
//! intermediary.
//!
//! ## IP layer routing
//!
//! All of the registered Ethernet interfaces are considered as being part of one single network
//! (typically the Internet).
//!
//! > **Note**: This doesn't mean that we are free to send out packets on any interface that we
//! >           want and expect the routing to make the packet find its way. In particular, this
//! >           single network can be disjoint.
//!
//! Nodes on this network (i.e. something with an IP address) can be split into two categories:
//!
//! - Nodes we are directly connected to, as described in the previous section. It is possible to
//! send a direct message to these nodes by writing bytes on the right interface.
//! - Nodes we are *not* directly connected to.
//!
//! The implementer of this interface maintains what we call a *routing table*. A routing table is
//! a collection of entries, each entry consisting of:
//!
//! - A "pattern", kind of similar to a regex for example. This pattern consists of an IP address
//! and mask. An IP address matches that pattern if
//! `(ip_addr & pattern.mask) == (pattern.ip & pattern.mask)`.
//! - A gateway. This is the IP address of a node that we are physically connected to and that is
//! in charge of relaying packets to nodes that match the given pattern.
//! - The network interface the gateway is connected to.
//!
//! When we want to reach the node with a specific IP address, we look through the table until
//! we find an entry whose pattern matches the target IP address. If multiple entries are matching,
//! we pick the one with the most specific mask.
//!
//! The gateway is then expected to properly direct the packet towards its rightful destination.
//!

pub mod ffi;
pub mod interface;


================================================
FILE: interface-wrappers/framebuffer/Cargo.toml
================================================
[package]
name = "redshirt-framebuffer-interface"
version = "0.1.0"
license = "GPL-3.0-or-later"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
edition = "2018"

[dependencies]
futures = "0.3"
parity-scale-codec = { version = "1.3.6", features = ["derive"] }
redshirt-random-interface = { path = "../random", default-features = false }
redshirt-syscalls = { path = "../syscalls", default-features = false }


================================================
FILE: interface-wrappers/framebuffer/src/ffi.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//!
//!
//! Message format:
//!
//! The type of message depends on the first byte:
//!
//! - 0: Creates a framebuffer. Next 4 bytes are a "framebuffer ID" as decided by the message
//! emitter. Next 4 bytes are the width in little endian. Next 4 bytes are the height in little
//! endian.
//! - 1: Destroys a framebuffer. Next 4 bytes are the framebuffer ID.
//! - 2: Set framebuffer content. Next 4 bytes are the framebuffer ID. The rest is 3 * width *
//! height values. The rest is RGB triplets.
//! - 3: Send back the next input event. Next 4 bytes are the framebuffer ID. The answer consists
//! in an input event whose format is a SCALE-encoding of the [`Event`] struct below.
//!
//! There actually exists two interfaces that use the same messages format: with events, or without
//! events. Messages whose first byte is `3` are invalid in the "without events" interface.

use redshirt_syscalls::InterfaceHash;

// TODO: this has been randomly generated; instead should be a hash or something
pub const INTERFACE_WITH_EVENTS: InterfaceHash = InterfaceHash::from_raw_hash([
    0xfc, 0x60, 0x2e, 0x6e, 0xf2, 0x43, 0x9c, 0xa0, 0x40, 0x88, 0x81, 0x7d, 0xe5, 0xaf, 0xb6, 0x90,
    0x9e, 0x57, 0xc6, 0xc2, 0x5e, 0xbf, 0x02, 0x5b, 0x87, 0x7f, 0xaa, 0xae, 0xbe, 0xd5, 0x19, 0x9c,
]);

// TODO: this has been randomly generated; instead should be a hash or something
pub const INTERFACE_WITHOUT_EVENTS: InterfaceHash = InterfaceHash::from_raw_hash([
    0xdf, 0x67, 0x74, 0x34, 0xd8, 0x0d, 0xc5, 0x9e, 0xf0, 0x6e, 0xb9, 0x44, 0xce, 0xaa, 0xc4, 0xde,
    0x8d, 0x2f, 0xdf, 0x39, 0x0a, 0xe6, 0xa8, 0x29, 0x3c, 0x8f, 0x88, 0x76, 0x5b, 0xe9, 0x1c, 0x70,
]);

/// Event that can be reported by a framebuffer.
///
/// > **Note**: These events are designed to take into account the possibility that some events are
/// >           lost. This can happen if the recipient queues messages too slowly.
#[derive(Debug, Clone, parity_scale_codec::Encode, parity_scale_codec::Decode)]
pub enum Event {
    /// A keyboard key has been pressed or released.
    KeyboardChange {
        /// Scancode as defined in the USB HID Usage tables.
        ///
        /// See table 12 on page 53:
        /// https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf
        scancode: u16,

        /// New state of the given key.
        new_state: ElementState,
    },

    /// The cursor has moved over the framebuffer.
    CursorMoved {
        /// New position of the cursor in millipixels relative to the top-left hand corner of the
        /// framebuffer. `None` if the cursor is not on the framebuffer.
        ///
        /// Please note that these are millipixels. As such, you have to divide them by 1000 to
        /// obtain a value in pixels.
        new_position: Option<(u64, u64)>,
    },

    /// A mouse button has been pressed or released.
    MouseButtonChange {
        /// Which mouse button is concerned.
        button: MouseButton,

        /// New state of the given button.
        new_state: ElementState,
    },
}

#[derive(Debug, Clone, parity_scale_codec::Encode, parity_scale_codec::Decode)]
pub enum MouseButton {
    /// Typically but not necessarily the left mouse button.
    Main,
    /// Typically but not necessarily the right mouse button.
    Secondary,
}

#[derive(Debug, Clone, parity_scale_codec::Encode, parity_scale_codec::Decode)]
pub enum ElementState {
    Pressed,
    Released,
}


================================================
FILE: interface-wrappers/framebuffer/src/lib.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Framebuffer interface.
//!
//! Allows drawing an image.
//!
//! > **Note**: The fate of this interface is kind of vague. It is also unclear whether
//! >           keyboard/mouse input should be handled here as well. Use at your own risks.

#![no_std]

extern crate alloc;

use alloc::collections::VecDeque;
use core::convert::TryFrom as _;
use redshirt_syscalls::{InterfaceHash, MessageId};

pub mod ffi;

/// Framebuffer containing pixel data.
pub struct Framebuffer {
    /// Identifier of the framebuffer. Used for all communications.
    id: u32,

    /// Interface used for this framebuffer.
    interface: &'static InterfaceHash,

    /// Width of the framebuffer in pixels.
    width: u32,
    /// Height of the framebuffer in pixels.
    height: u32,

    /// List of active messages that will be responded with incoming events.
    ///
    /// The capacity of this container also corresponds to the number of elements that we want to
    /// have in it at any given moment. In other words, there is no field in this struct indicating
    /// the number of events because that'd be redundant with `event_messages.capacity()`.
    event_messages: VecDeque<MessageId>,
}

impl Framebuffer {
    /// Initializes a new framebuffer of the given width and height.
    pub async fn new(with_events: bool, width: u32, height: u32) -> Self {
        let id = unsafe {
            let mut out = [0; 4];
            redshirt_random_interface::generate_in(&mut out).await;
            u32::from_le_bytes(out)
        };

        let interface = if with_events {
            &ffi::INTERFACE_WITH_EVENTS
        } else {
            &ffi::INTERFACE_WITHOUT_EVENTS
        };

        unsafe {
            let id_le_bytes = id.to_le_bytes();
            let width_le_bytes = width.to_le_bytes();
            let height_le_bytes = height.to_le_bytes();
            redshirt_syscalls::MessageBuilder::new()
                .add_data_raw(&[0])
                .add_data_raw(&id_le_bytes[..])
                .add_data_raw(&width_le_bytes[..])
                .add_data_raw(&height_le_bytes[..])
                .emit_without_response(interface)
                .unwrap();
        }

        let num_events_queue = if with_events { 10 } else { 0 };

        let mut fb = Framebuffer {
            id,
            interface,
            width,
            height,
            event_messages: VecDeque::with_capacity(num_events_queue),
        };
        fb.fill_event_messages();
        fb
    }

    /// Sets the data in the framebuffer.
    ///
    /// The size of `data` must be `width * height * 3`.
    pub fn set_data(&self, data: &[u8]) {
        unsafe {
            assert_eq!(
                data.len(),
                usize::try_from(
                    self.width
                        .checked_mul(self.height)
                        .unwrap()
                        .checked_mul(3)
                        .unwrap()
                )
                .unwrap()
            );

            let id_le_bytes = self.id.to_le_bytes();
            redshirt_syscalls::MessageBuilder::new()
                .add_data_raw(&[2])
                .add_data_raw(&id_le_bytes[..])
                .add_data_raw(data)
                .emit_without_response(self.interface)
                .unwrap();
        }
    }

    /// Returns the next event that the framebuffer receives.
    // TODO: proper return type
    pub async fn next_event(&mut self) -> u32 {
        if let Some(first_event) = self.event_messages.front() {
            let event: u32 = redshirt_syscalls::message_response(*first_event).await; // TODO: proper event type
            self.event_messages.pop_front();
            self.fill_event_messages();
            event
        } else {
            futures::future::pending().await
        }
    }

    /// Pushes back events to `event_messages` until we reach the maximum.
    fn fill_event_messages(&mut self) {
        while self.event_messages.len() < self.event_messages.capacity() {
            let new_event = unsafe {
                redshirt_syscalls::MessageBuilder::new()
                    .add_data_raw(&[3])
                    .add_data_raw(&self.id.to_le_bytes()[..])
                    .emit_with_response_raw(self.interface)
                    .unwrap()
            };

            self.event_messages.push_back(new_event);
        }
    }
}

impl Drop for Framebuffer {
    fn drop(&mut self) {
        unsafe {
            let id_le_bytes = self.id.to_le_bytes();
            redshirt_syscalls::MessageBuilder::new()
                .add_data_raw(&[1])
                .add_data_raw(&id_le_bytes[..])
                .emit_without_response(self.interface)
                .unwrap();
        }
    }
}


================================================
FILE: interface-wrappers/hardware/Cargo.toml
================================================
[package]
name = "redshirt-hardware-interface"
version = "0.1.0"
license = "GPL-3.0-or-later"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
edition = "2018"

[dependencies]
futures = { version = "0.3.13", default-features = false }
redshirt-syscalls = { path = "../syscalls", default-features = false }
parity-scale-codec = { version = "1.3.6", default-features = false, features = ["derive"] }

[features]
default = ["std"]
std = []


================================================
FILE: interface-wrappers/hardware/src/ffi.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

use alloc::vec::Vec;
use parity_scale_codec::{Decode, Encode};
use redshirt_syscalls::InterfaceHash;

// TODO: this has been randomly generated; instead should be a hash or something
pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
    0x24, 0x5d, 0x25, 0x5e, 0x37, 0xf1, 0x8a, 0xce, 0x23, 0xd6, 0x68, 0xe9, 0xe2, 0xd8, 0xd1, 0xbc,
    0x37, 0xf3, 0xd3, 0x3c, 0xad, 0x55, 0xf8, 0xd9, 0x22, 0x3a, 0x57, 0xd1, 0x54, 0x46, 0x7b, 0x78,
]);

/// Message in destination to the hardware interface handler.
#[derive(Debug, Encode, Decode)]
pub enum HardwareMessage {
    /// Allocate RAM. Must answer with a `u64`. The value `0` is returned if the allocation is
    /// too large.
    ///
    /// This is useful in situations where you want to pass a pointer to a device.
    Malloc {
        /// Size to allocate.
        size: u64,
        /// Alignment of the pointer to return.
        ///
        /// The returned value modulo `alignment` must be equal to 0.
        alignment: u64,
    },
    /// Opposite of malloc.
    Free {
        /// Value previously returned after a malloc message.
        ptr: u64,
    },
    /// Request to perform some access on the physical memory or ports.
    ///
    /// All operations must be performed in order.
    ///
    /// If there is at least one memory or port read, the response must be a
    /// `Vec<HardwareAccessResponse>` where each element corresponds to a read. No response is
    /// expected if there are only writes.
    // TODO: should we enforce some limits in the amount of data that can be returned in a response?
    HardwareAccess(Vec<Operation>),

    /// Ask the handler to send back a response when the interrupt with the given number is
    /// triggered.
    ///
    /// > **Note**: If called with a non-hardware interrupt, no response will ever come back.
    // TODO: how to not miss any interrupt? we instead need some registration system or something
    InterruptWait(u32),
}

/// Request to perform accesses to physical memory or to ports.
#[derive(Debug, Encode, Decode)]
pub enum Operation {
    PhysicalMemoryMemset {
        address: u64,
        len: u64,
        value: u8,
    },
    PhysicalMemoryWriteU8 {
        address: u64,
        data: Vec<u8>,
    },
    /// Uses the platform's native endianess.
    PhysicalMemoryWriteU16 {
        address: u64,
        data: Vec<u16>,
    },
    /// Uses the platform's native endianess.
    PhysicalMemoryWriteU32 {
        address: u64,
        data: Vec<u32>,
    },
    PhysicalMemoryReadU8 {
        address: u64,
        len: u32,
    },
    PhysicalMemoryReadU16 {
        address: u64,
        /// Number of `u16`s to read.
        len: u32,
    },
    PhysicalMemoryReadU32 {
        address: u64,
        /// Number of `u32`s to read.
        len: u32,
    },
    /// Write data to a port.
    ///
    /// If the hardware doesn't support this operation, then nothing happens.
    PortWriteU8 {
        port: u32,
        data: u8,
    },
    /// Write data to a port.
    ///
    /// If the hardware doesn't support this operation, then nothing happens.
    PortWriteU16 {
        port: u32,
        data: u16,
    },
    /// Write data to a port.
    ///
    /// If the hardware doesn't support this operation, then nothing happens.
    PortWriteU32 {
        port: u32,
        data: u32,
    },
    /// Reads data from a port.
    ///
    /// If the hardware doesn't support this operation, then `0` is produced.
    PortReadU8 {
        port: u32,
    },
    /// Reads data from a port.
    ///
    /// If the hardware doesn't support this operation, then `0` is produced.
    PortReadU16 {
        port: u32,
    },
    /// Reads data from a port.
    ///
    /// If the hardware doesn't support this operation, then `0` is produced.
    PortReadU32 {
        port: u32,
    },
}

/// Response to a [`HardwareMessage::HardwareAccess`].
#[derive(Debug, Encode, Decode)]
pub enum HardwareAccessResponse {
    /// Sent back in response to a [`Operation::PhysicalMemoryReadU8`].
    PhysicalMemoryReadU8(Vec<u8>),
    /// Sent back in response to a [`Operation::PhysicalMemoryReadU16`].
    PhysicalMemoryReadU16(Vec<u16>),
    /// Sent back in response to a [`Operation::PhysicalMemoryReadU32`].
    PhysicalMemoryReadU32(Vec<u32>),
    /// Sent back in response to a [`Operation::PortReadU8`].
    PortReadU8(u8),
    /// Sent back in response to a [`Operation::PortReadU16`].
    PortReadU16(u16),
    /// Sent back in response to a [`Operation::PortReadU32`].
    PortReadU32(u32),
}


================================================
FILE: interface-wrappers/hardware/src/lib.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Access to physical hardware.
//!
//! Use this interface if you're writing a device driver.

#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

use alloc::{vec, vec::Vec};
use core::convert::TryFrom as _;
use futures::prelude::*;

pub mod ffi;
pub mod malloc;

/// Builder for write-only hardware operations.
pub struct HardwareWriteOperationsBuilder {
    operations: Vec<ffi::Operation>,
}

impl HardwareWriteOperationsBuilder {
    pub fn new() -> Self {
        HardwareWriteOperationsBuilder {
            operations: Vec::new(),
        }
    }

    pub fn with_capacity(capacity: usize) -> Self {
        HardwareWriteOperationsBuilder {
            operations: Vec::with_capacity(capacity),
        }
    }

    pub unsafe fn memset(&mut self, address: u64, len: u64, value: u8) {
        self.operations.push(ffi::Operation::PhysicalMemoryMemset {
            address,
            len,
            value,
        });
    }

    pub unsafe fn write(&mut self, address: u64, data: impl Into<Vec<u8>>) {
        self.operations.push(ffi::Operation::PhysicalMemoryWriteU8 {
            address,
            data: data.into(),
        });
    }

    pub unsafe fn write_one_u32(&mut self, address: u64, data: u32) {
        self.operations
            .push(ffi::Operation::PhysicalMemoryWriteU32 {
                address,
                data: vec![data],
            });
    }

    pub unsafe fn port_write_u8(&mut self, port: u32, data: u8) {
        self.operations
            .push(ffi::Operation::PortWriteU8 { port, data });
    }

    pub unsafe fn port_write_u16(&mut self, port: u32, data: u16) {
        self.operations
            .push(ffi::Operation::PortWriteU16 { port, data });
    }

    pub unsafe fn port_write_u32(&mut self, port: u32, data: u32) {
        self.operations
            .push(ffi::Operation::PortWriteU32 { port, data });
    }

    pub fn send(self) {
        unsafe {
            if self.operations.is_empty() {
                return;
            }

            let msg = ffi::HardwareMessage::HardwareAccess(self.operations);
            redshirt_syscalls::emit_message_without_response(&ffi::INTERFACE, &msg).unwrap();
        }
    }
}

/// Writes the given data to the given physical memory address location.
pub unsafe fn write(address: u64, data: impl Into<Vec<u8>>) {
    let mut builder = HardwareWriteOperationsBuilder::with_capacity(1);
    builder.write(address, data);
    builder.send();
}

/// Reads memory to a buffer.
pub async unsafe fn read_to(address: u64, mut out: &mut [u8]) {
    let mut ops = HardwareOperationsBuilder::new();
    ops.read(address, &mut out);
    ops.send().await;
}

/// Reads memory.
pub async unsafe fn read(address: u64, len: u32) -> Vec<u8> {
    let len_usize = usize::try_from(len).unwrap();
    let mut out = Vec::with_capacity(len_usize);
    out.set_len(len_usize);
    let mut ops = HardwareOperationsBuilder::new();
    ops.read(address, &mut out);
    ops.send().await;
    out
}

/// Reads a single `u32` from the given memory address.
#[cfg(feature = "std")]
pub async unsafe fn read_one_u32(address: u64) -> u32 {
    let mut ops = HardwareOperationsBuilder::new();
    let mut out = [0];
    ops.read_u32(address, &mut out);
    ops.send().await;
    out[0]
}

pub unsafe fn write_one_u32(address: u64, data: u32) {
    let mut builder = HardwareWriteOperationsBuilder::with_capacity(1);
    builder.write_one_u32(address, data);
    builder.send();
}

pub unsafe fn port_write_u8(port: u32, data: u8) {
    let mut builder = HardwareWriteOperationsBuilder::with_capacity(1);
    builder.port_write_u8(port, data);
    builder.send();
}

pub unsafe fn port_write_u16(port: u32, data: u16) {
    let mut builder = HardwareWriteOperationsBuilder::with_capacity(1);
    builder.port_write_u16(port, data);
    builder.send();
}

pub unsafe fn port_write_u32(port: u32, data: u32) {
    let mut builder = HardwareWriteOperationsBuilder::with_capacity(1);
    builder.port_write_u32(port, data);
    builder.send();
}

/// Reads the given port.
pub async unsafe fn port_read_u8(port: u32) -> u8 {
    let mut builder = HardwareOperationsBuilder::with_capacity(1);
    let mut out = 0;
    builder.port_read_u8(port, &mut out);
    builder.send().await;
    out
}

pub async unsafe fn port_read_u16(port: u32) -> u16 {
    let mut builder = HardwareOperationsBuilder::with_capacity(1);
    let mut out = 0;
    builder.port_read_u16(port, &mut out);
    builder.send().await;
    out
}

pub async unsafe fn port_read_u32(port: u32) -> u32 {
    let mut builder = HardwareOperationsBuilder::with_capacity(1);
    let mut out = 0;
    builder.port_read_u32(port, &mut out);
    builder.send().await;
    out
}

/// Builder for read and write hardware operations.
pub struct HardwareOperationsBuilder<'a> {
    operations: Vec<ffi::Operation>,
    out: Vec<Out<'a>>,
}

enum Out<'a> {
    MemReadU8(&'a mut [u8]),
    MemReadU16(&'a mut [u16]),
    MemReadU32(&'a mut [u32]),
    PortU8(&'a mut u8),
    PortU16(&'a mut u16),
    PortU32(&'a mut u32),
    Discard,
}

impl<'a> HardwareOperationsBuilder<'a> {
    pub fn new() -> Self {
        HardwareOperationsBuilder {
            operations: Vec::new(),
            out: Vec::new(),
        }
    }

    pub fn with_capacity(capacity: usize) -> Self {
        HardwareOperationsBuilder {
            operations: Vec::with_capacity(capacity),
            out: Vec::with_capacity(capacity),
        }
    }

    pub unsafe fn read(&mut self, address: u64, out: &'a mut (impl ?Sized + AsMut<[u8]>)) {
        let out = out.as_mut();
        self.operations.push(ffi::Operation::PhysicalMemoryReadU8 {
            address,
            len: out.len() as u32, // TODO: don't use `as`
        });
        self.out.push(Out::MemReadU8(out));
    }

    pub unsafe fn read_u16(&mut self, address: u64, out: &'a mut (impl ?Sized + AsMut<[u16]>)) {
        let out = out.as_mut();
        self.operations.push(ffi::Operation::PhysicalMemoryReadU16 {
            address,
            len: out.len() as u32, // TODO: don't use `as`
        });
        self.out.push(Out::MemReadU16(out));
    }

    pub unsafe fn read_u32(&mut self, address: u64, out: &'a mut (impl ?Sized + AsMut<[u32]>)) {
        let out = out.as_mut();
        self.operations.push(ffi::Operation::PhysicalMemoryReadU32 {
            address,
            len: out.len() as u32, // TODO: don't use `as`
        });
        self.out.push(Out::MemReadU32(out));
    }

    pub unsafe fn memset(&mut self, address: u64, len: u64, value: u8) {
        self.operations.push(ffi::Operation::PhysicalMemoryMemset {
            address,
            len,
            value,
        });
    }

    pub unsafe fn write(&mut self, address: u64, data: impl Into<Vec<u8>>) {
        self.operations.push(ffi::Operation::PhysicalMemoryWriteU8 {
            address,
            data: data.into(),
        });
    }

    pub unsafe fn write_one_u32(&mut self, address: u64, data: u32) {
        self.operations
            .push(ffi::Operation::PhysicalMemoryWriteU32 {
                address,
                data: vec![data],
            });
    }

    pub unsafe fn port_write_u8(&mut self, port: u32, data: u8) {
        self.operations
            .push(ffi::Operation::PortWriteU8 { port, data });
    }

    pub unsafe fn port_write_u16(&mut self, port: u32, data: u16) {
        self.operations
            .push(ffi::Operation::PortWriteU16 { port, data });
    }

    pub unsafe fn port_write_u32(&mut self, port: u32, data: u32) {
        self.operations
            .push(ffi::Operation::PortWriteU32 { port, data });
    }

    pub unsafe fn port_read_u8(&mut self, port: u32, out: &'a mut u8) {
        self.operations.push(ffi::Operation::PortReadU8 { port });
        self.out.push(Out::PortU8(out));
    }

    pub unsafe fn port_read_u16(&mut self, port: u32, out: &'a mut u16) {
        self.operations.push(ffi::Operation::PortReadU16 { port });
        self.out.push(Out::PortU16(out));
    }

    pub unsafe fn port_read_u32(&mut self, port: u32, out: &'a mut u32) {
        self.operations.push(ffi::Operation::PortReadU32 { port });
        self.out.push(Out::PortU32(out));
    }

    pub unsafe fn port_read_u8_discard(&mut self, port: u32) {
        self.operations.push(ffi::Operation::PortReadU8 { port });
        self.out.push(Out::Discard);
    }

    pub unsafe fn port_read_u16_discard(&mut self, port: u32) {
        self.operations.push(ffi::Operation::PortReadU16 { port });
        self.out.push(Out::Discard);
    }

    pub unsafe fn port_read_u32_discard(&mut self, port: u32) {
        self.operations.push(ffi::Operation::PortReadU32 { port });
        self.out.push(Out::Discard);
    }

    pub fn send(self) -> impl Future<Output = ()> + 'a {
        unsafe {
            let msg = ffi::HardwareMessage::HardwareAccess(self.operations);
            let out = self.out;
            redshirt_syscalls::emit_message_with_response(&ffi::INTERFACE, msg)
                .unwrap()
                .then(move |response: Vec<ffi::HardwareAccessResponse>| {
                    for (response_elem, out) in response.into_iter().zip(out) {
                        match (response_elem, out) {
                            (_, Out::Discard) => {}
                            (ffi::HardwareAccessResponse::PortReadU8(val), Out::PortU8(out)) => {
                                *out = val
                            }
                            (ffi::HardwareAccessResponse::PortReadU16(val), Out::PortU16(out)) => {
                                *out = val
                            }
                            (ffi::HardwareAccessResponse::PortReadU32(val), Out::PortU32(out)) => {
                                *out = val
                            }
                            (
                                ffi::HardwareAccessResponse::PhysicalMemoryReadU8(val),
                                Out::MemReadU8(out),
                            ) => out.copy_from_slice(&val),
                            (
                                ffi::HardwareAccessResponse::PhysicalMemoryReadU16(val),
                                Out::MemReadU16(out),
                            ) => out.copy_from_slice(&val),
                            (
                                ffi::HardwareAccessResponse::PhysicalMemoryReadU32(val),
                                Out::MemReadU32(out),
                            ) => out.copy_from_slice(&val),
                            _ => unreachable!(),
                        }
                    }

                    future::ready(())
                })
        }
    }
}


================================================
FILE: interface-wrappers/hardware/src/malloc.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Allocation of physical memory.
//!
//! There are situations where it is necessary to pass to a device a pointer to a region of
//! memory. This is where this module comes into play.

use crate::{ffi, HardwareOperationsBuilder, HardwareWriteOperationsBuilder};

use alloc::{boxed::Box, vec, vec::Vec};
use core::{convert::TryFrom, marker::PhantomData, mem, ptr, slice};
use futures::prelude::*;

/// Buffer located in physical memory.
pub struct PhysicalBuffer<T: ?Sized> {
    /// Location of the buffer in physical memory.
    ptr: u64,
    /// Size in bytes of the buffer.
    size: u64,
    /// Marker to pin the `T` generic.
    marker: PhantomData<Box<T>>,
}

impl<T> PhysicalBuffer<T> {
    /// Creates a new buffer and moves `data` into it.
    ///
    /// > **Note**: `data` will **not** be free'd if you drop the buffer. In other words, it is as
    /// >           if you called `std::mem::forget(data)`. You should preferably not pass anything
    /// >           else than plain data, or call [`PhysicalBuffer::take`].
    ///
    pub fn new(data: T) -> impl Future<Output = Self> {
        let size = u64::try_from(mem::size_of_val(&data)).unwrap();
        let align = u64::try_from(mem::align_of_val(&data)).unwrap();

        malloc(size, align).map(move |ptr| {
            let buf = PhysicalBuffer {
                ptr,
                size,
                marker: PhantomData,
            };
            buf.write(data);
            buf
        })
    }

    /// Overwrites the content of the buffer with a new value.
    ///
    /// This moves `data` into the buffer. The previous value is **not** dropped, but simply
    /// leaked out.
    pub fn write(&self, data: T) {
        unsafe {
            let mut data_buf = Vec::<u8>::with_capacity(mem::size_of_val(&data));
            ptr::write_unaligned(data_buf.as_mut_ptr() as *mut T, data);
            data_buf.set_len(data_buf.capacity());

            let mut builder = HardwareWriteOperationsBuilder::with_capacity(1);
            builder.write(self.ptr, data_buf);
            builder.send();
        }
    }

    /// Reads back the content of the buffer and destroys the buffer.
    pub fn take(self) -> impl Future<Output = T> {
        unsafe { self.read_inner() }
    }

    /// Returns a copy of the content of the buffer.
    pub fn read(&self) -> impl Future<Output = T>
    where
        T: Copy,
    {
        unsafe { self.read_inner() }
    }

    /// Reads the content of the buffer and returns a copy.
    ///
    /// # Safety
    ///
    /// This function performs a copy of the content of the buffer. This is only safe if `T`
    /// implements `Copy`, or if you guarantee that no multiple copies of the same object are
    /// being read. In other words, this function is meant to be called from within
    /// [`PhysicalBuffer::take`] or [`PhysicalBuffer::read`].
    unsafe fn read_inner(&self) -> impl Future<Output = T> {
        // Note: we can't use `HardwareOperationsBuilder`, as this would require an `async`
        // function or block, which aren't available in `no_std` environments at the time of
        // writing.

        let msg =
            ffi::HardwareMessage::HardwareAccess(vec![ffi::Operation::PhysicalMemoryReadU8 {
                address: self.ptr,
                len: u32::try_from(mem::size_of::<T>()).unwrap(),
            }]);

        redshirt_syscalls::emit_message_with_response(&ffi::INTERFACE, msg)
            .unwrap()
            .map(move |mut response: Vec<ffi::HardwareAccessResponse>| {
                debug_assert_eq!(response.len(), 1);
                let buf = match response.remove(0) {
                    ffi::HardwareAccessResponse::PhysicalMemoryReadU8(val) => val,
                    _ => unreachable!(),
                };
                ptr::read_unaligned(buf.as_ptr() as *const T)
            })
    }
}

impl<T> PhysicalBuffer<[T]> {
    /// Allocates a new buffer with uninitialized contents.
    pub async fn new_uninit_slice(len: usize) -> PhysicalBuffer<[mem::MaybeUninit<T>]> {
        Self::new_uninit_slice_with_align(len, mem::align_of::<T>()).await
    }

    /// Allocates a new buffer with uninitialized contents.
    pub async fn new_uninit_slice_with_align(
        len: usize,
        align: usize,
    ) -> PhysicalBuffer<[mem::MaybeUninit<T>]> {
        let size = u64::try_from(mem::size_of::<T>())
            .unwrap()
            .checked_mul(u64::try_from(len).unwrap())
            .unwrap();
        let align = u64::try_from(align).unwrap();

        PhysicalBuffer {
            ptr: malloc(size, align).await,
            size,
            marker: PhantomData,
        }
    }

    /// Returns the number of elements in the buffer.
    pub fn len(&self) -> usize {
        usize::try_from(self.size / u64::try_from(mem::size_of::<T>()).unwrap()).unwrap()
    }

    pub fn write_one(&self, idx: usize, value: T) {
        unsafe {
            if idx >= self.len() {
                panic!()
            }

            let mut ops = HardwareWriteOperationsBuilder::with_capacity(1);
            ops.write(
                self.ptr + u64::try_from(idx * mem::size_of::<T>()).unwrap(),
                slice::from_raw_parts(&value as *const T as *const u8, mem::size_of::<T>())
                    .to_vec(),
            );
            ops.send();

            mem::forget(value);
        }
    }
}

impl<T: Copy> PhysicalBuffer<[T]> {
    pub async fn read_one(&self, idx: usize) -> Option<T> {
        unsafe {
            if idx >= self.len() {
                return None;
            }

            let mut out = mem::MaybeUninit::<T>::uninit();

            let mut ops = HardwareOperationsBuilder::with_capacity(1);
            ops.read(
                self.ptr + u64::try_from(idx * mem::size_of::<T>()).unwrap(),
                slice::from_raw_parts_mut(out.as_mut_ptr() as *mut u8, mem::size_of::<T>()),
            );
            ops.send().await;

            Some(out.assume_init())
        }
    }

    pub async fn read_slice(&self, idx: usize, out: &mut [T]) {
        unsafe {
            assert!(idx + out.len() <= self.len());

            let mut ops = HardwareOperationsBuilder::with_capacity(1);
            ops.read(
                self.ptr + u64::try_from(idx * mem::size_of::<T>()).unwrap(),
                slice::from_raw_parts_mut(
                    out.as_mut_ptr() as *mut u8,
                    out.len() * mem::size_of::<T>(),
                ),
            );
            ops.send().await;
        }
    }

    pub fn write_slice(&self, idx: usize, data: &[T]) {
        unsafe {
            assert!(idx + data.len() <= self.len());

            let mut ops = HardwareWriteOperationsBuilder::with_capacity(1);
            ops.write(
                self.ptr + u64::try_from(idx * mem::size_of::<T>()).unwrap(),
                slice::from_raw_parts(data.as_ptr() as *const u8, data.len() * mem::size_of::<T>())
                    .to_vec(),
            );
            ops.send();
        }
    }
}

impl<T> PhysicalBuffer<[mem::MaybeUninit<T>]> {
    /// Converts to an actual buffer.
    pub unsafe fn assume_init(self) -> PhysicalBuffer<[T]> {
        let size = self.size;
        let ptr = self.ptr;
        mem::forget(self);

        PhysicalBuffer {
            ptr,
            size,
            marker: PhantomData,
        }
    }
}

impl<T: ?Sized> PhysicalBuffer<T> {
    /// Returns the location in physical memory of the buffer.
    pub fn pointer(&self) -> u64 {
        self.ptr
    }
}

impl<T: ?Sized> Drop for PhysicalBuffer<T> {
    fn drop(&mut self) {
        free(self.ptr)
    }
}

/// Allocates physical memory.
///
/// # Panic
///
/// Panics if the allocation fails, for example if `size` is too large to be acceptable.
///
pub fn malloc(size: u64, alignment: u64) -> impl Future<Output = u64> {
    unsafe {
        let msg = ffi::HardwareMessage::Malloc { size, alignment };
        redshirt_syscalls::emit_message_with_response(&ffi::INTERFACE, msg)
            .unwrap()
            .map(move |ptr: u64| {
                assert_ne!(ptr, 0);
                debug_assert_eq!(ptr % alignment, 0);
                ptr
            })
    }
}

/// Frees physical memory previously allocated with [`malloc`].
pub fn free(ptr: u64) {
    unsafe {
        let msg = ffi::HardwareMessage::Free { ptr };
        redshirt_syscalls::emit_message_without_response(&ffi::INTERFACE, &msg).unwrap();
    }
}


================================================
FILE: interface-wrappers/interface/Cargo.toml
================================================
[package]
name = "redshirt-interface-interface"
version = "0.1.0"
license = "GPL-3.0-or-later"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
edition = "2018"

[dependencies]
futures = { version = "0.3.13", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "1.3.6", default-features = false, features = ["derive"] }
redshirt-syscalls = { path = "../syscalls", default-features = false }


================================================
FILE: interface-wrappers/interface/src/ffi.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

use alloc::vec::Vec;
use core::{convert::TryFrom as _, num::NonZeroU64};
use redshirt_syscalls::{EncodedMessage, InterfaceHash, MessageId, Pid};

// TODO: this has been randomly generated; instead should be a hash or something
pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
    0x49, 0x6e, 0x56, 0x14, 0x8c, 0xd4, 0x2b, 0xc3, 0x9b, 0x4e, 0xbf, 0x5e, 0xb6, 0x2c, 0x60, 0x4d,
    0x7d, 0xd5, 0x70, 0x92, 0x4d, 0x4f, 0x70, 0xdf, 0xb3, 0xda, 0xf6, 0xfe, 0xdc, 0x65, 0x93, 0x8a,
]);

#[derive(Debug, parity_scale_codec::Encode, parity_scale_codec::Decode)]
pub enum InterfaceMessage {
    Register(InterfaceHash),
    NextMessage(NonZeroU64),
    Answer(MessageId, Result<Vec<u8>, ()>),
}

#[derive(Debug, parity_scale_codec::Encode, parity_scale_codec::Decode)]
pub struct InterfaceRegisterResponse {
    pub result: Result<NonZeroU64, InterfaceRegisterError>,
}

#[derive(Debug, Clone, parity_scale_codec::Encode, parity_scale_codec::Decode)]
pub enum InterfaceRegisterError {
    /// There already exists a process registered for this interface.
    AlreadyRegistered,
}

/// Either a decoded interface notification or a decoded process destroyed notification.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DecodedInterfaceOrDestroyed {
    /// Interface notification.
    Interface(DecodedInterfaceNotification),
    /// Process destroyed notification.
    ProcessDestroyed(DecodedProcessDestroyedNotification),
}

/// Attempt to decode a notification.
pub fn decode_notification(buffer: &[u8]) -> Result<DecodedInterfaceOrDestroyed, ()> {
    if buffer.is_empty() {
        return Err(());
    }

    match buffer[0] {
        0 => decode_interface_notification(buffer).map(DecodedInterfaceOrDestroyed::Interface),
        2 => decode_process_destroyed_notification(buffer)
            .map(DecodedInterfaceOrDestroyed::ProcessDestroyed),
        _ => Err(()),
    }
}

/// Builds a interface notification from its raw components.
pub fn build_interface_notification(
    interface: &InterfaceHash,
    message_id: Option<MessageId>,
    emitter_pid: Pid,
    actual_data: &EncodedMessage,
) -> InterfaceNotificationBuilder {
    let mut buffer = Vec::with_capacity(1 + 32 + 8 + 8 + actual_data.0.len());
    buffer.push(0);
    buffer.extend_from_slice(interface.as_ref());
    buffer.extend_from_slice(&message_id.map(u64::from).unwrap_or(0).to_le_bytes());
    buffer.extend_from_slice(&u64::from(emitter_pid).to_le_bytes());
    buffer.extend_from_slice(&actual_data.0);

    debug_assert_eq!(buffer.capacity(), buffer.len());
    InterfaceNotificationBuilder { data: buffer }
}

#[derive(Debug, Clone)]
pub struct InterfaceNotificationBuilder {
    data: Vec<u8>,
}

impl InterfaceNotificationBuilder {
    /// Returns the [`MessageId`] that was put in the builder.
    pub fn message_id(&self) -> Option<MessageId> {
        let id = u64::from_le_bytes([
            self.data[33],
            self.data[34],
            self.data[35],
            self.data[36],
            self.data[37],
            self.data[38],
            self.data[39],
            self.data[40],
        ]);

        MessageId::try_from(id).ok()
    }

    pub fn len(&self) -> usize {
        self.data.len()
    }

    pub fn into_bytes(self) -> Vec<u8> {
        // TODO: return EncodedMessage
        self.data
    }
}

pub fn decode_interface_notification(buffer: &[u8]) -> Result<DecodedInterfaceNotification, ()> {
    if buffer.len() < 1 + 32 + 8 + 8 {
        return Err(());
    }

    if buffer[0] != 0x0 {
        return Err(());
    }

    Ok(DecodedInterfaceNotification {
        interface: InterfaceHash::from({
            let mut hash = [0; 32];
            hash.copy_from_slice(&buffer[1..33]);
            hash
        }),
        message_id: {
            let id = u64::from_le_bytes([
                buffer[33], buffer[34], buffer[35], buffer[36], buffer[37], buffer[38], buffer[39],
                buffer[40],
            ]);

            MessageId::try_from(id).ok()
        },
        emitter_pid: From::from(u64::from_le_bytes([
            buffer[41], buffer[42], buffer[43], buffer[44], buffer[45], buffer[46], buffer[47],
            buffer[48],
        ])),
        actual_data: EncodedMessage(buffer[49..].to_vec()),
    })
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DecodedInterfaceNotification {
    /// Interface the message concerns.
    // TODO: remove
    pub interface: InterfaceHash,
    /// Id of the message. Can be used for answering. `None` if no answer is expected.
    pub message_id: Option<MessageId>,
    /// Id of the process that emitted the message.
    ///
    /// This should be used for security purposes, so that a process can't modify another process'
    /// resources.
    pub emitter_pid: Pid,
    pub actual_data: EncodedMessage,
}

pub fn build_process_destroyed_notification(pid: Pid) -> ProcessDestroyedNotificationBuilder {
    let mut buffer = Vec::with_capacity(1 + 8);
    buffer.push(2);
    buffer.extend_from_slice(&u64::from(pid).to_le_bytes());

    debug_assert_eq!(buffer.capacity(), buffer.len());
    ProcessDestroyedNotificationBuilder { data: buffer }
}

#[derive(Debug, Clone)]
pub struct ProcessDestroyedNotificationBuilder {
    data: Vec<u8>,
}

impl ProcessDestroyedNotificationBuilder {
    pub fn len(&self) -> usize {
        self.data.len()
    }

    pub fn into_bytes(self) -> Vec<u8> {
        self.data
    }
}

pub fn decode_process_destroyed_notification(
    buffer: &[u8],
) -> Result<DecodedProcessDestroyedNotification, ()> {
    if buffer.len() != 1 + 8 {
        return Err(());
    }

    if buffer[0] != 0x2 {
        return Err(());
    }

    Ok(DecodedProcessDestroyedNotification {
        pid: From::from(u64::from_le_bytes([
            buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], buffer[8],
        ])),
    })
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DecodedProcessDestroyedNotification {
    /// Identifier of the process that got destroyed.
    pub pid: Pid,
}


================================================
FILE: interface-wrappers/interface/src/lib.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Interfaces registration.

#![no_std]

extern crate alloc;

use core::{mem, num::NonZeroU64};
use futures::prelude::*;
use redshirt_syscalls::{Encode, EncodedMessage, InterfaceHash, MessageId};

pub use ffi::{DecodedInterfaceOrDestroyed, InterfaceRegisterError};

pub mod ffi;

/// Registers the current program as the provider for the given interface hash.
///
/// > **Note**: Interface hashes can be found in the various `ffi` modules of the crates in the
/// >           `interface-wrappers` directory, although that is subject to change.
///
/// Returns an error if there was already a program registered for that interface.
pub async fn register_interface(
    hash: InterfaceHash,
) -> Result<Registration, InterfaceRegisterError> {
    let msg = ffi::InterfaceMessage::Register(hash);
    // Unwrapping is ok because there's always something that handles interface registration.
    let id = {
        let msg: ffi::InterfaceRegisterResponse =
            unsafe { redshirt_syscalls::emit_message_with_response(&ffi::INTERFACE, msg) }
                .unwrap()
                .await;
        msg.result?
    };

    let mut registration = Registration {
        id,
        messages: stream::FuturesOrdered::new(),
    };

    for _ in 0..32 {
        registration.add_message();
    }

    Ok(registration)
}

/// Registered interface.
pub struct Registration {
    /// Identifier of the interface registration.
    id: NonZeroU64,
    /// Futures that will resolve when a message is received on the interface.
    messages: stream::FuturesOrdered<redshirt_syscalls::MessageResponseFuture<EncodedMessage>>,
}

impl Registration {
    /// Returns the next message received on this interface.
    pub async fn next_message_raw(&mut self) -> DecodedInterfaceOrDestroyed {
        let message = self.messages.next().await.unwrap();
        self.add_message();
        ffi::decode_notification(&message.0).unwrap()
    }

    fn add_message(&mut self) {
        self.messages.push(unsafe {
            let message = ffi::InterfaceMessage::NextMessage(self.id).encode();
            let msg_id = redshirt_syscalls::MessageBuilder::new()
                .add_data(&EncodedMessage(message.0))
                .emit_with_response_raw(&ffi::INTERFACE)
                .unwrap();
            redshirt_syscalls::message_response(msg_id)
        });
    }
}

impl Drop for Registration {
    fn drop(&mut self) {
        // Before dropping the registration, cancel all existing messages.
        let _ = mem::take(&mut self.messages);

        // TODO: unregister; unregistrations aren't supported at the moment
    }
}

/// Answers the given message.
pub fn emit_answer(message_id: MessageId, msg: impl Encode) {
    #[cfg(target_arch = "wasm32")] // TODO: we should have a proper operating system name instead
    fn imp(message_id: MessageId, msg: impl Encode) {
        unsafe {
            // TODO: more optimized version ; right now there's extra copies below
            redshirt_syscalls::emit_message_without_response(
                &ffi::INTERFACE,
                ffi::InterfaceMessage::Answer(message_id, Ok(msg.encode().0)),
            )
            .unwrap()
        }
    }
    #[cfg(not(target_arch = "wasm32"))]
    fn imp(_: MessageId, _: impl Encode) {
        unreachable!()
    }
    imp(message_id, msg)
}

/// Answers the given message by notifying of an error in the message.
pub fn emit_message_error(message_id: MessageId) {
    #[cfg(target_arch = "wasm32")] // TODO: we should have a proper operating system name instead
    fn imp(message_id: MessageId) {
        unsafe {
            // TODO: more optimized version ; right now there's extra copies below
            redshirt_syscalls::emit_message_without_response(
                &ffi::INTERFACE,
                ffi::InterfaceMessage::Answer(message_id, Err(())),
            )
            .unwrap()
        }
    }
    #[cfg(not(target_arch = "wasm32"))]
    fn imp(_: MessageId) {
        unreachable!()
    }
    imp(message_id)
}


================================================
FILE: interface-wrappers/kernel-debug/Cargo.toml
================================================
[package]
name = "redshirt-kernel-debug-interface"
version = "0.1.0"
license = "GPL-3.0-or-later"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
edition = "2018"

[dependencies]
redshirt-syscalls = { path = "../syscalls", default-features = false }


================================================
FILE: interface-wrappers/kernel-debug/src/lib.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Gathering kernel metrics.
//!
//! This interface provides a way to gather information from the kernel. In particular, the kernel
//! returns [Prometheus](https://prometheus.io) metrics.
//!
//! # Message format
//!
//! - Sender sends a message with an empty body.
//! - Handler sends back a Prometheus-compatible UTF-8 message.
//!
//! See [this page](https://prometheus.io/docs/instrumenting/exposition_formats/#text-format-details)
//! for more information about the format.
//!

#![no_std]

extern crate alloc;

use alloc::{string::String, vec::Vec};
use redshirt_syscalls::InterfaceHash;

// TODO: this has been randomly generated; instead should be a hash or something
pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
    0x8c, 0xb4, 0xc6, 0xee, 0xc9, 0x29, 0xc5, 0xce, 0xaf, 0x46, 0x28, 0x74, 0x9e, 0x96, 0x72, 0x58,
    0xea, 0xd2, 0xa2, 0xa2, 0xd6, 0xeb, 0x7d, 0xc8, 0xe3, 0x95, 0x0c, 0x0e, 0x53, 0xde, 0x8c, 0xba,
]);

/// Loads metrics from the kernel, as a Prometheus-compatible UTF-8 string.
pub async fn get_prometheus_metrics() -> String {
    unsafe {
        let response: redshirt_syscalls::EncodedMessage =
            redshirt_syscalls::emit_message_with_response(
                &INTERFACE,
                redshirt_syscalls::EncodedMessage(Vec::new()),
            )
            .unwrap()
            .await;

        String::from_utf8(response.0).unwrap()
    }
}


================================================
FILE: interface-wrappers/kernel-log/Cargo.toml
================================================
[package]
name = "redshirt-kernel-log-interface"
version = "0.1.0"
license = "GPL-3.0-or-later"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
edition = "2018"

[dependencies]
parity-scale-codec = { version = "1.3.6", default-features = false, features = ["derive"] }
redshirt-syscalls = { path = "../syscalls", default-features = false }


================================================
FILE: interface-wrappers/kernel-log/src/ffi.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

/// Communication between a process and the interface handler.
///
/// A message consists of either:
///
/// - A `0` byte followed with a UTF-8 log message.
/// - A `1` byte followed with a SCALE-codec-encoded [`KernelLogMethod`].
///
use parity_scale_codec::{Decode, Encode};
use redshirt_syscalls::InterfaceHash;

// TODO: this has been randomly generated; instead should be a hash or something
pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
    0xcd, 0xba, 0x59, 0xb1, 0xb6, 0x5e, 0xd4, 0x9a, 0xfe, 0x25, 0xd0, 0x7c, 0x04, 0x1f, 0xae, 0x82,
    0x5b, 0xf3, 0xc9, 0xca, 0x89, 0x48, 0x81, 0xe0, 0x3b, 0x3a, 0xd2, 0x76, 0x29, 0x04, 0x21, 0x1b,
]);

/// How the kernel should log messages.
#[derive(Debug, Clone, Encode, Decode)]
pub struct KernelLogMethod {
    /// If `true`, log messages should be shown. If `false`, they should be buffered up (to a
    /// certain limit) and will be shown as soon as `enabled` is true.
    pub enabled: bool,

    /// If `Some`, the logs will be printed on a video framebuffer.
    pub framebuffer: Option<FramebufferInfo>,

    /// If `Some`, logs will be emitted on an UART.
    pub uart: Option<UartInfo>,
}

/// Information about how the kernel should print on an UART.
///
/// In order to write, the kernel should repeatidly read a value from `wait_address` until
/// its value, when AND-ed with `wait_mask`, is equal to `wait_compare_equal_if_ready`. Then it
/// should write a value to `write_address`.
#[derive(Debug, Clone, Encode, Decode)]
pub struct UartInfo {
    /// Where to read the value to compare.
    pub wait_address: UartAccess,
    /// Mask to apply (by AND'ing) to the value read from `wait_address`.
    pub wait_mask: u32,
    /// Compares the value (after the mask is applied) with this reference value. If equal, the
    /// UART is ready.
    pub wait_compare_equal_if_ready: u32,
    /// Where to write the output when ready.
    pub write_address: UartAccess,
}

/// How to access either the value to compare or where to write the output.
#[derive(Debug, Clone, Encode, Decode)]
pub enum UartAccess {
    /// 32bits at a specific memory location.
    MemoryMappedU32(u64),
    /// Single byte (8bits) on I/O port. Typically on x86/amd64 systems.
    IoPortU8(u16),
}

/// Information about how the kernel should print on the framebuffer.
#[derive(Debug, Clone, Encode, Decode)]
pub struct FramebufferInfo {
    /// Location in physical memory where the framebuffer starts.
    pub address: u64,
    /// Width of the screen, either in pixels or characters.
    pub width: u32,
    /// Height of the screen, either in pixels or characters.
    pub height: u32,
    /// In order to reach the second line of pixels or characters, one has to advance this number of bytes.
    pub pitch: u64,
    /// Number of bytes a pixel or a character occupies in memory.
    pub bytes_per_character: u8,
    /// Format of the framebuffer's data.
    pub format: FramebufferFormat,
}

/// Format of the framebuffer's data.
#[derive(Debug, Clone, Encode, Decode)]
pub enum FramebufferFormat {
    /// One ASCII character followed with one byte of characteristics.
    Text,
    Rgb {
        red_size: u8,
        red_position: u8,
        green_size: u8,
        green_position: u8,
        blue_size: u8,
        blue_position: u8,
    },
}


================================================
FILE: interface-wrappers/kernel-log/src/lib.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Kernel logging.
//!
//! This interface permits two things:
//!
//! - Send logs for the kernel to print.
//! - Configure how the kernel prints logs.
//!
//! It is important for programs such as video drivers to keep the kernel up-to-date with how
//! logs should be displayed. In the case of a kernel panic, the kernel will use the information
//! contained in the latest received message in order to show diagnostics to the user.

#![no_std]

extern crate alloc;

use parity_scale_codec::Encode as _;

pub mod ffi;
pub use ffi::KernelLogMethod;

/// Appends a single ASCII string to the kernel logs.
///
/// This function always adds a single entry to the logs. An entry can made up of multiple lines
/// (separated with `\n`), but the lines are notably *not* split into multiple entries.
///
/// > **Note**: The message is expected to be in ASCII. It will otherwise be considered invalid
/// >           and get discarded.
///
/// # About `\r` vs `\n`
///
/// In order to follow the Unix world, the character `\n` (LF, 0xA) means "new line". The
/// character `\r` (CR, 0xD) is ignored.
///
pub fn log(msg: &[u8]) {
    unsafe {
        redshirt_syscalls::MessageBuilder::new()
            .add_data_raw(&[0][..])
            .add_data_raw(msg)
            .emit_without_response(&ffi::INTERFACE)
            .unwrap();
    }
}

/// Sets how the kernel should log messages.
pub async fn configure_kernel(method: KernelLogMethod) {
    unsafe {
        let encoded = method.encode();
        redshirt_syscalls::MessageBuilder::new()
            .add_data_raw(&[1][..])
            .add_data_raw(&encoded)
            .emit_with_response::<()>(&ffi::INTERFACE)
            .unwrap()
            .await;
    }
}


================================================
FILE: interface-wrappers/loader/Cargo.toml
================================================
[package]
name = "redshirt-loader-interface"
version = "0.1.0"
license = "GPL-3.0-or-later"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
edition = "2018"

[dependencies]
futures = { version = "0.3.13", default-features = false }
redshirt-syscalls = { path = "../syscalls", default-features = false }
parity-scale-codec = { version = "1.3.6", default-features = false, features = ["derive"] }


================================================
FILE: interface-wrappers/loader/src/ffi.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

use alloc::vec::Vec;
use parity_scale_codec::{Decode, Encode};
use redshirt_syscalls::InterfaceHash;

// TODO: this has been randomly generated; instead should be a hash or something
pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
    0x1c, 0x72, 0xb5, 0x18, 0x7f, 0x73, 0x52, 0xfd, 0xf7, 0xa7, 0x81, 0xe2, 0xa8, 0x46, 0x51, 0xd7,
    0xb3, 0xc6, 0x2d, 0x24, 0x31, 0x88, 0x96, 0x95, 0x6e, 0xfc, 0x7d, 0x4d, 0x86, 0x3f, 0xff, 0xa6,
]);

#[derive(Debug, Encode, Decode)]
pub enum LoaderMessage {
    /// Load the data corresponding to the blake3 hash passed as parameter.
    Load([u8; 32]),
}

#[derive(Debug, Encode, Decode)]
pub struct LoadResponse {
    pub result: Result<Vec<u8>, ()>,
}


================================================
FILE: interface-wrappers/loader/src/lib.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Loading WASM programs.
//!
//! This interface is a bit special, as it is used by the kernel in order to load WASM programs.

#![no_std]

extern crate alloc;

use alloc::vec::Vec;
use futures::prelude::*;

pub mod ffi;

/// Tries to load a WASM module based on its hash.
///
/// Returns either the binary content of the module, or an error if no module with that hash
/// could be found.
// TODO: better error type
pub fn load(hash: [u8; 32]) -> impl Future<Output = Result<Vec<u8>, ()>> {
    unsafe {
        let msg = ffi::LoaderMessage::Load(hash);
        match redshirt_syscalls::emit_message_with_response(&ffi::INTERFACE, msg) {
            Ok(fut) => fut.map(|rep: ffi::LoadResponse| rep.result).left_future(),
            Err(_) => future::ready(Err(())).right_future(),
        }
    }
}


================================================
FILE: interface-wrappers/log/Cargo.toml
================================================
[package]
name = "redshirt-log-interface"
version = "0.1.0"
license = "GPL-3.0-or-later"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
edition = "2018"

[dependencies]
log = "0.4.14"
redshirt-syscalls = { path = "../syscalls", default-features = false }


================================================
FILE: interface-wrappers/log/src/ffi.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Communication between a process and the interface handler.
//!
//! A log message consists of one byte indicating the log level, followed with the log message
//! itself encoded in UTF-8.
//!
//! Log levels:
//!
//! - Error: 4
//! - Warn: 3
//! - Info: 2
//! - Debug: 1
//! - Trace: 0
//!

use core::{convert::TryFrom, fmt, str};
use redshirt_syscalls::{Decode, EncodedMessage, InterfaceHash};

// TODO: this has been randomly generated; instead should be a hash or something
pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
    0xa6, 0xbc, 0x8d, 0xc3, 0x43, 0xbd, 0xdd, 0x3b, 0x44, 0x2f, 0x06, 0x40, 0xa8, 0x40, 0xad, 0x4f,
    0x25, 0x57, 0x23, 0x91, 0x79, 0xc8, 0x16, 0x07, 0x6f, 0xab, 0xa9, 0xd6, 0x38, 0xca, 0x01, 0x8b,
]);

/// Log level of a message.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Level {
    Error,
    Warn,
    Info,
    Debug,
    Trace,
}

impl From<Level> for u8 {
    fn from(level: Level) -> u8 {
        match level {
            Level::Error => 4,
            Level::Warn => 3,
            Level::Info => 2,
            Level::Debug => 1,
            Level::Trace => 0,
        }
    }
}

impl TryFrom<u8> for Level {
    type Error = InvalidLevelError;

    fn try_from(value: u8) -> Result<Self, InvalidLevelError> {
        Ok(match value {
            4 => Level::Error,
            3 => Level::Warn,
            2 => Level::Info,
            1 => Level::Debug,
            0 => Level::Trace,
            n => return Err(InvalidLevelError(n)),
        })
    }
}

/// Error that can happen when decoding a [`Level`].
#[derive(Debug)]
pub struct InvalidLevelError(u8);

impl InvalidLevelError {
    /// Returns the value that failed to decode.
    pub fn value(&self) -> u8 {
        self.0
    }
}

impl fmt::Display for InvalidLevelError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "Invalid log level")
    }
}

/// Decoded version of a message on the log interface.
pub struct DecodedLogMessage {
    level: Level,
    buffer: EncodedMessage,
}

impl DecodedLogMessage {
    /// Returns the log level of the message.
    pub fn level(&self) -> Level {
        self.level
    }

    /// Returns the message itself.
    pub fn message(&self) -> &str {
        // We checked the validity when decoding.
        str::from_utf8(&self.buffer.0[1..]).unwrap()
    }
}

impl Decode for DecodedLogMessage {
    type Error = DecodeError;

    fn decode(buffer: EncodedMessage) -> Result<Self, DecodeError> {
        if buffer.0.is_empty() {
            return Err(DecodeError::LevelMissing);
        }
        let level = Level::try_from(buffer.0[0]).map_err(DecodeError::LevelDecodeError)?;
        let _ = str::from_utf8(&buffer.0[1..]).map_err(DecodeError::NotUtf8)?;
        Ok(DecodedLogMessage { level, buffer })
    }
}

/// Error that can happen when decoding a log message.
#[derive(Debug)]
pub enum DecodeError {
    LevelMissing,
    LevelDecodeError(InvalidLevelError),
    NotUtf8(str::Utf8Error),
}

impl fmt::Display for DecodeError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            DecodeError::LevelMissing => write!(f, "Missing log level"),
            DecodeError::LevelDecodeError(_) => write!(f, "Invalid log level"),
            DecodeError::NotUtf8(_) => write!(f, "Not UTF-8 error"),
        }
    }
}


================================================
FILE: interface-wrappers/log/src/lib.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Logging.
//!
//! This interface allows a program to send out messages for the purpose of being logged.
//!
//! How these logs are handled is at the discretion of the rest of the system, but the intent is
//! for them to be shown to a human being if desired.
//!
//! # The `log` crate
//!
//! This interface provides a backend for the `log` crate.
//!
//! Example usage:
//!
//! ```no_run
//! redshirt_log_interface::init();
//! log::debug!("debug log message here");
//! ```

#![no_std]

extern crate alloc;

use alloc::format;

pub mod ffi;

pub use ffi::Level;
pub use log;

/// Appends a single string to the logs of the program.
///
/// This function always adds a single entry to the logs. An entry can made up of multiple lines
/// (separated with `\n`), but the lines are notably *not* split into multiple entries.
///
/// # About `\r` vs `\n`
///
/// In order to follow the Unix world, the character `\n` (LF, 0xA) means "new line". The
/// character `\r` (CR, 0xD) is ignored.
///
pub fn emit_log(level: Level, msg: &str) {
    unsafe {
        let level: [u8; 1] = [u8::from(level)];
        redshirt_syscalls::MessageBuilder::new()
            .add_data_raw(&level[..])
            .add_data_raw(msg.as_bytes())
            .emit_without_response(&ffi::INTERFACE)
            .unwrap();
    }
}

/// Attempts to initializes the global logger.
///
/// # Panic
///
/// This function will panic if it is called more than once, or if another library has already
/// initialized a global logger.
pub fn try_init() -> Result<(), log::SetLoggerError> {
    static LOGGER: GlobalLogger = GlobalLogger;
    let res = log::set_logger(&LOGGER);
    if res.is_ok() {
        log::set_max_level(log::LevelFilter::Trace);
    }
    res
}

/// Initializes the global logger.
///
/// # Panic
///
/// This function will panic if it is called more than once, or if another library has already
/// initialized a global logger.
pub fn init() {
    try_init().unwrap();
}

/// The logger.
///
/// Implements the [`Log`](log::Log) trait.
pub struct GlobalLogger;

impl log::Log for GlobalLogger {
    fn enabled(&self, _: &log::Metadata) -> bool {
        true
    }

    fn log(&self, record: &log::Record) {
        let level = match record.level() {
            log::Level::Error => Level::Error,
            log::Level::Warn => Level::Warn,
            log::Level::Info => Level::Info,
            log::Level::Debug => Level::Debug,
            log::Level::Trace => Level::Trace,
        };

        let message = format!("{} -- {}", record.target(), record.args());
        emit_log(level, &message)
    }

    fn flush(&self) {}
}


================================================
FILE: interface-wrappers/pci/Cargo.toml
================================================
[package]
name = "redshirt-pci-interface"
version = "0.1.0"
license = "GPL-3.0-or-later"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
edition = "2018"

[dependencies]
futures = { version = "0.3.13", default-features = false }
redshirt-syscalls = { path = "../syscalls", default-features = false }
parity-scale-codec = { version = "1.3.6", default-features = false, features = ["derive"] }


================================================
FILE: interface-wrappers/pci/src/ffi.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

use alloc::vec::Vec;
use parity_scale_codec::{Decode, Encode};
use redshirt_syscalls::InterfaceHash;

// TODO: this has been randomly generated; instead should be a hash or something
pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
    0x2d, 0x93, 0xd0, 0x48, 0xab, 0x88, 0x1c, 0x95, 0x87, 0xf5, 0x5c, 0x3b, 0xe6, 0x4d, 0x8f, 0x65,
    0x3f, 0x37, 0x4c, 0x4e, 0xad, 0xea, 0x15, 0xcc, 0xf0, 0x17, 0x44, 0x0f, 0x6d, 0x6e, 0x5d, 0xc8,
]);

/// Message in destination to the PCI interface handler.
#[derive(Debug, Encode, Decode)]
pub enum PciMessage {
    /// Request list of PCI devices. Answered with a [`GetDevicesListResponse`].
    GetDevicesList,

    /// Makes the current process as the "owner" of the given PCI device.
    ///
    /// Returns a SCALE-encoded `Ok(())` if the locking worked, and a SCALE-encoded `Err(())` if
    /// the device has already been locked.
    // TODO: no, proper answer
    LockDevice(PciDeviceBdf),

    /// Unlocks a previously-locked device.
    ///
    /// Has no effect if the device wasn't locked by the current process.
    ///
    /// Doesn't return any answer.
    ///
    /// Answers all the pending [`PciMessage::NextInterrupt`] messages for this device.
    UnlockDevice(PciDeviceBdf),

    /// Sets the `COMMAND` register.
    ///
    /// Has no effect if the device wasn't locked by the current process.
    ///
    /// Doesn't return any answer.
    SetCommand {
        location: PciDeviceBdf,
        bus_master: bool,
        memory_space: bool,
        io_space: bool,
    },

    /// Produces a [`NextInterruptResponse`] answer when the next interrupt from the PCI device
    /// happens. The PCI must have been locked.
    ///
    /// Note that multiple PCI devices might share the same interrupt line, and spurious answers
    /// might therefore happen. The `status` register of the PCI device is not necessarily checked.
    ///
    /// For clean-up reasons, answers are also triggered if you unlock the device.
    NextInterrupt(PciDeviceBdf),

    /// Read or write the configuration space of a device.
    // TODO: forbid writing some parts such as the BARs
    ConfigurationSpaceOperations {
        /// Device to access. Must have been previously locked.
        device: PciDeviceBdf,
        operations: Vec<MemoryOperation>,
    },

    /// Read or write the mapped memory of a PCI device.
    ///
    /// Answers with a SCALE-encoded `Vec<MemoryAccessResponse>` containins one element per
    /// successful read.
    BarMemoryOperations {
        /// Device to access. Must have been previously locked.
        device: PciDeviceBdf,
        /// Which BAR (Base Address Register) is concerned. Must in the range `0..6`.
        bar_offset: u8,
        /// List of operations to perform.
        operations: Vec<MemoryOperation>,
    },

    /// Read or write the I/O ports accessing a PCI device.
    ///
    /// Answers with a SCALE-encoded `Vec<IoAccessResponse>` containins one element per
    /// successful read.
    BarIoOperations {
        /// Device to access. Must have been previously locked.
        device: PciDeviceBdf,
        /// Which BAR (Base Address Register) is concerned. Must in the range `0..6`.
        bar_offset: u8,
        /// List of operations to perform.
        operations: Vec<IoOperation>,
    },
}

/// Response to [`PciMessage::GetDevicesList`].
#[derive(Debug, Encode, Decode)]
pub struct GetDevicesListResponse {
    /// List of PCI devices available on the system.
    pub devices: Vec<PciDeviceInfo>,
}

/// Response to [`PciMessage::NextInterrupt`].
#[derive(Debug, Encode, Decode)]
pub enum NextInterruptResponse {
    /// Success. We got an interrupt.
    Interrupt,

    /// Returned if the specified device isn't locked.
    BadDevice,

    /// Returned if the specified device was locked but got unlocked before an interrupt happened.
    Unlocked,
}

/// Location of a PCI device according to the controller.
///
/// > **Note**: The acronym BDF stands for "Bus, Device, Function".
#[derive(Debug, Clone, PartialEq, Eq, Hash, Encode, Decode)]
pub struct PciDeviceBdf {
    pub bus: u8,
    pub device: u8,
    pub function: u8,
}

/// Description of a single PCI device.
#[derive(Debug, Clone, Encode, Decode)]
pub struct PciDeviceInfo {
    /// Location of the device on the machine. Uniquely identifies each device.
    pub location: PciDeviceBdf,

    pub vendor_id: u16,
    pub device_id: u16,

    pub class_code: u8,
    pub subclass: u8,
    pub prog_if: u8,
    pub revision_id: u8,

    pub base_address_registers: Vec<PciBaseAddressRegister>,
    // TODO: add more fields
}

/// Description of a single PCI device.
// TODO: actually figure out PCI and adjust this
#[derive(Debug, Clone, Encode, Decode)]
pub enum PciBaseAddressRegister {
    Memory { base_address: u64 },
    Io { base_address: u32 },
}

/// Request to perform accesses to memory-mapped memory.
#[derive(Debug, Encode, Decode)]
pub enum MemoryOperation {
    Memset {
        offset: u64,
        len: u64,
        value: u8,
    },
    WriteU8 {
        offset: u64,
        data: Vec<u8>,
    },
    /// Uses the platform's native endianess.
    WriteU16 {
        offset: u64,
        data: Vec<u16>,
    },
    /// Uses the platform's native endianess.
    WriteU32 {
        offset: u64,
        data: Vec<u32>,
    },
    ReadU8 {
        offset: u64,
        len: u32,
    },
    ReadU16 {
        offset: u64,
        /// Number of `u16`s to read.
        len: u32,
    },
    ReadU32 {
        offset: u64,
        /// Number of `u32`s to read.
        len: u32,
    },
}

/// Request to perform accesses to I/O ports.
#[derive(Debug, Encode, Decode)]
pub enum IoOperation {
    /// Write data to a port.
    WriteU8 {
        /// Offset of the port from the value in the BAR.
        port_offset: u32,
        /// Data to write.
        data: u8,
    },
    /// Write data to a port.
    WriteU16 {
        /// Offset of the port from the value in the BAR.
        port_offset: u32,
        /// Data to write.
        data: u16,
    },
    /// Write data to a port.
    WriteU32 {
        /// Offset of the port from the value in the BAR.
        port_offset: u32,
        /// Data to write.
        data: u32,
    },
    /// Reads data from a port.
    ReadU8 {
        /// Offset of the port from the value in the BAR.
        port_offset: u32,
    },
    /// Reads data from a port.
    ReadU16 {
        /// Offset of the port from the value in the BAR.
        port_offset: u32,
    },
    /// Reads data from a port.
    ReadU32 {
        /// Offset of the port from the value in the BAR.
        port_offset: u32,
    },
}

/// Response to a [`PciMessage::BarMemoryOperations`].
#[derive(Debug, Encode, Decode)]
pub enum MemoryAccessResponse {
    /// Sent back in response to a [`MemoryOperation::ReadU8`].
    ReadU8(Vec<u8>),
    /// Sent back in response to a [`MemoryOperation::ReadU16`].
    ReadU16(Vec<u16>),
    /// Sent back in response to a [`MemoryOperation::ReadU32`].
    ReadU32(Vec<u32>),
}

/// Response to a [`PciMessage::BarIoOperations`].
#[derive(Debug, Encode, Decode)]
pub enum IoAccessResponse {
    /// Sent back in response to a [`IoOperation::ReadU8`].
    ReadU8(u8),
    /// Sent back in response to a [`IoOperation::ReadU16`].
    ReadU16(u16),
    /// Sent back in response to a [`IoOperation::ReadU32`].
    ReadU32(u32),
}


================================================
FILE: interface-wrappers/pci/src/lib.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Access to PCI devices.
//!
//! Use this interface if you're writing a device driver.

#![no_std]

extern crate alloc;

pub use self::ffi::{PciBaseAddressRegister, PciDeviceBdf, PciDeviceInfo};

use alloc::vec::Vec;
use futures::prelude::*;

pub mod ffi;

/// Returns the list of PCI devices available on the system.
pub fn get_pci_devices() -> impl Future<Output = Vec<PciDeviceInfo>> {
    unsafe {
        let msg = ffi::PciMessage::GetDevicesList;
        // TODO: don't unwrap?
        redshirt_syscalls::emit_message_with_response(&ffi::INTERFACE, msg)
            .unwrap()
            .map(|response: ffi::GetDevicesListResponse| response.devices)
    }
}

// TODO: provide a good API for all this

/// Active lock of a PCI device.
///
/// While this struct is alive, no other program can lock that same PCI device.
pub struct PciDeviceLock {
    device: ffi::PciDeviceBdf,
}

impl PciDeviceLock {
    // TODO: shouldn't be public?
    pub async fn lock(bdf: ffi::PciDeviceBdf) -> Result<Self, ()> {
        let result: Result<(), ()> = unsafe {
            let msg = ffi::PciMessage::LockDevice(bdf.clone());
            redshirt_syscalls::emit_message_with_response(&ffi::INTERFACE, msg)
                .unwrap()
                .await
        };

        result?;

        Ok(PciDeviceLock { device: bdf })
    }

    pub fn set_command(&self, bus_master: bool, memory_space: bool, io_space: bool) {
        unsafe {
            redshirt_syscalls::emit_message_without_response(&ffi::INTERFACE, &{
                ffi::PciMessage::SetCommand {
                    location: self.device.clone(),
                    bus_master,
                    memory_space,
                    io_space,
                }
            })
            .unwrap();
        }
    }

    /// Waits until the device produces an interrupt.
    ///
    /// The returned future is disconnected from the [`PciDeviceLock`]. However, polling the
    /// future after its corresponding [`PciDeviceLock`] has been destroyed will panic.
    ///
    /// > **Note**: Be aware that this `Future` only returns the *next* interrupt that happens.
    /// >           PCI devices typically provide a way for the driver to know the reason why an
    /// >           interrupt happened. In order to not miss any follow-up interrupt, call this
    /// >           function *before* reading the reason, but only await on the returned Future
    /// >           *after* reading the reason.
    pub fn next_interrupt(&self) -> impl Future<Output = ()> + Send + 'static {
        let bdf = self.device.clone();

        // We send the message outside of the `async` block in order to be sure that the message
        // gets sent before the user starts polling the `Future`.
        let response = {
            let msg = ffi::PciMessage::NextInterrupt(bdf);
            unsafe { redshirt_syscalls::emit_message_with_response(&ffi::INTERFACE, msg) }.unwrap()
        };

        async move {
            response
                .map(|response: ffi::NextInterruptResponse| match response {
                    ffi::NextInterruptResponse::Interrupt => {}
                    ffi::NextInterruptResponse::BadDevice => panic!(),
                    ffi::NextInterruptResponse::Unlocked => unreachable!(),
                })
                .await
        }
    }
}

impl Drop for PciDeviceLock {
    fn drop(&mut self) {
        unsafe {
            let msg = ffi::PciMessage::UnlockDevice(self.device.clone());
            redshirt_syscalls::emit_message_without_response(&ffi::INTERFACE, msg).unwrap();
        }
    }
}


================================================
FILE: interface-wrappers/random/Cargo.toml
================================================
[package]
name = "redshirt-random-interface"
version = "0.1.0"
license = "GPL-3.0-or-later"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
edition = "2018"

[dependencies]
redshirt-syscalls = { path = "../syscalls", default-features = false }
parity-scale-codec = { version = "1.3.6", default-features = false, features = ["derive"] }

[features]
default = ["std"]
std = []


================================================
FILE: interface-wrappers/random/src/ffi.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

use alloc::vec::Vec;
use parity_scale_codec::{Decode, Encode};
use redshirt_syscalls::InterfaceHash;

// TODO: this has been randomly generated; instead should be a hash or something
pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
    0xfb, 0x83, 0xa5, 0x46, 0xfd, 0xf1, 0x50, 0x7a, 0xef, 0x8c, 0xb6, 0x8f, 0xa5, 0x44, 0x49, 0x21,
    0x53, 0xe5, 0x83, 0xda, 0xf0, 0x66, 0xbc, 0x1a, 0xd2, 0x18, 0xfd, 0x00, 0x54, 0x7f, 0xdb, 0x25,
]);

#[derive(Debug, Encode, Decode)]
pub enum RandomMessage {
    /// Ask to generate cryptographically-secure list of random numbers of the given length.
    ///
    /// The length is a `u16`, so the maximum size is 64kiB and there's no need to handle potential
    /// errors about the length being too long to fit in memory. Call multiple times to obtain
    /// more.
    Generate { len: u16 },
}

#[derive(Debug, Encode, Decode)]
pub struct GenerateResponse {
    /// Random bytes. Must be of the requested length.
    pub result: Vec<u8>,
}


================================================
FILE: interface-wrappers/random/src/lib.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Generating cryptographically-secure random data.

#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

use alloc::vec::Vec;
use core::convert::TryFrom as _;

pub mod ffi;

/// Generate `len` bytes of random data and returns them.
pub async fn generate(len: usize) -> Vec<u8> {
    unsafe {
        let mut out = Vec::with_capacity(len);
        out.set_len(len);
        generate_in(&mut out).await;
        out
    }
}

/// Fills `out` with randomly-generated data.
pub async fn generate_in(out: &mut [u8]) {
    for chunk in out.chunks_mut(usize::from(u16::max_value())) {
        let msg = ffi::RandomMessage::Generate {
            len: u16::try_from(chunk.len()).unwrap(),
        };
        let rep: ffi::GenerateResponse = unsafe {
            redshirt_syscalls::emit_message_with_response(&ffi::INTERFACE, msg)
                .unwrap()
                .await
        };
        chunk.copy_from_slice(&rep.result);
    }
}

/// Generates a random `u8`.
pub async fn generate_u8() -> u8 {
    let mut buf = [0; 1];
    generate_in(&mut buf).await;
    buf[0]
}

/// Generates a random `u16`.
pub async fn generate_u16() -> u16 {
    let mut buf = [0; 2];
    generate_in(&mut buf).await;
    u16::from_ne_bytes(buf)
}

/// Generates a random `u32`.
pub async fn generate_u32() -> u32 {
    let mut buf = [0; 4];
    generate_in(&mut buf).await;
    u32::from_ne_bytes(buf)
}

/// Generates a random `u64`.
pub async fn generate_u64() -> u64 {
    let mut buf = [0; 8];
    generate_in(&mut buf).await;
    u64::from_ne_bytes(buf)
}

/// Generates a random `u128`.
pub async fn generate_u128() -> u128 {
    let mut buf = [0; 16];
    generate_in(&mut buf).await;
    u128::from_ne_bytes(buf)
}


================================================
FILE: interface-wrappers/syscalls/Cargo.toml
================================================
[package]
name = "redshirt-syscalls"
version = "0.1.0"
license = "GPL-3.0-or-later"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
edition = "2018"

[dependencies]
futures = { version = "0.3.13", default-features = false, features = ["alloc"] }
generic-array = { version = "0.14.4", default-features = false }
hashbrown = { version = "0.9.1", default-features = false }
lazy_static = { version = "1.4.0", features = ["spin_no_std"] }
nohash-hasher = { version = "0.2.0", default-features = false }
parity-scale-codec = { version = "1.3.6", default-features = false, features = ["derive"] }
pin-project = "1.0.5"
slab = { version = "0.4.9", default-features = false }
spinning_top = "0.2.2"


================================================
FILE: interface-wrappers/syscalls/src/block_on.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! As explained in the crate root, the futures of this crate can only work with [`block_on`], and
//! vice-versa.
//!
//! The way it works is the following:
//!
//! - We hold a global buffer of interface messages waiting to be processed, and a global buffer
//!   of responses that have been received and that are waiting to be processed.
//!
//! - We also hold a global buffer of message IDs that we want a response for, and an associated
//!   `core::task::Waker`.
//!
//! - When one of the `Future`s gets polled, it first look whether an interface message or a
//!   response is available in one of the buffers. If not, it registers a waker using the
//!   [`register_message_waker`] function.
//!
//! - The [`block_on`] function polls the `Future` passed to it, which optionally calls
//!   [`register_message_waker`], then asks the kernel for responses to the message IDs that have
//!   been registered. Once one or more messages have come back, we poll the `Future` again.
//!   Repeat until the `Future` has ended.
//!

use crate::{ffi, MessageId};
use alloc::{sync::Arc, vec::Vec};
use core::{
    sync::atomic::{AtomicBool, Ordering},
    task::{Context, Poll, Waker},
};
use futures::{prelude::*, task};
use hashbrown::HashMap;
use nohash_hasher::BuildNoHashHasher;
use slab::Slab;
use spinning_top::Spinlock;

/// Registers a message ID and an associated waker. The `block_on` function will then ask the
/// kernel for a message corresponding to this ID. If one is received, the `Waker` is called.
///
/// Registering multiple wakers for the same message is a logic error.
pub(crate) fn register_message_waker(message_id: MessageId, waker: Waker) -> WakerRegistration {
    let mut state = (&*STATE).lock();

    let index = state.wakers.insert(Some(waker));

    if state.message_ids.len() <= index {
        state.message_ids.resize(index + 1, 0);
    }

    debug_assert_eq!(state.message_ids[index], 0);
    state.message_ids[index] = From::from(message_id);

    WakerRegistration { index }
}

/// If a response to this message ID has previously been obtained, extracts it for processing.
pub(crate) fn peek_response(msg_id: MessageId) -> Option<Vec<u8>> {
    let mut state = (&*STATE).lock();
    state.pending_messages.remove(&msg_id)
}

pub(crate) struct WakerRegistration {
    /// Index within `STATE::message_ids` and `STATE::wakers`.
    index: usize,
}

impl WakerRegistration {
    /// Modifies the registered waker.
    pub fn update(&self, waker: &Waker) {
        let mut state = (&*STATE).lock();
        match &mut state.wakers[self.index] {
            Some(w) if w.will_wake(waker) => {}
            w @ _ => *w = Some(waker.clone()),
        }
    }
}

impl Drop for WakerRegistration {
    fn drop(&mut self) {
        let mut state = (&*STATE).lock();
        state.message_ids[self.index] = 0;
        state.wakers.remove(self.index);

        // Reclaim memory if possible.
        if state.wakers.is_empty() {
            state.wakers.shrink_to_fit();
            state.message_ids = Vec::new();
        }
    }
}

/// Blocks the current thread until the [`Future`](core::future::Future) passed as parameter
/// finishes.
pub fn block_on<T>(future: impl Future<Output = T>) -> T {
    futures::pin_mut!(future);

    // This `Arc<AtomicBool>` will be set to true if we are waken up during the polling.
    let woken_up = Arc::new(AtomicBool::new(false));
    let waker = {
        struct Notify(Arc<AtomicBool>);
        impl task::ArcWake for Notify {
            fn wake_by_ref(arc_self: &Arc<Self>) {
                arc_self.0.store(true, Ordering::SeqCst);
            }
        }
        task::waker(Arc::new(Notify(woken_up.clone())))
    };

    let mut context = Context::from_waker(&waker);

    loop {
        // We poll the future continuously until it is either Ready, or the waker stops being
        // invoked during the polling.
        loop {
            if let Poll::Ready(val) = Future::poll(future.as_mut(), &mut context) {
                return val;
            }

            // If the waker has been used during the polling of this future, then we have to pol
            // again.
            if woken_up.swap(false, Ordering::SeqCst) {
                continue;
            } else {
                break;
            }
        }

        let mut state = (&*STATE).lock();

        // `block` indicates whether we should block the thread or just peek. Always `true` during
        // the first iteration, and `false` in further iterations.
        let mut block = true;

        // We process in a loop all pending messages.
        while let Some(raw) = next_notification(&mut state.message_ids, block) {
            block = false;

            let msg = ffi::decode_notification(&raw).unwrap();

            // Value is zero-ed by the kernel.
            debug_assert_eq!(state.message_ids[msg.index_in_list as usize], 0);
            if let Some(waker) = state.wakers[msg.index_in_list as usize].take() {
                waker.wake();
            }

            let _was_in = state.pending_messages.insert(msg.message_id, raw);
            debug_assert!(_was_in.is_none());
        }

        debug_assert!(!block);
    }
}

lazy_static::lazy_static! {
    // TODO: we're using a Mutex, which is ok for as long as WASM doesn't have threads
    // if WASM ever gets threads and no pre-emptive multitasking, then we might spin forever
    static ref STATE: Spinlock<BlockOnState> = {
        Spinlock::new(BlockOnState {
            message_ids: Vec::new(),
            wakers: Slab::new(),
            pending_messages: HashMap::with_capacity_and_hasher(6, Default::default()),
        })
    };
}

/// State of the global `block_on` mechanism.
///
/// This is instantiated only once.
struct BlockOnState {
    /// List of messages for which we are waiting for a response. A pointer to this list is passed
    /// to the kernel.
    message_ids: Vec<u64>,

    /// List whose length is identical to [`BlockOnState::message_ids`]. For each element in
    /// [`BlockOnState::message_ids`], contains a corresponding `Waker` that must be waken up
    /// when a response comes.
    wakers: Slab<Option<Waker>>,

    /// Queue of response messages waiting to be delivered.
    ///
    /// > **Note**: We have to maintain this queue as a global variable rather than a per-future
    /// >           channel, otherwise dropping a `Future` would silently drop messages that have
    /// >           already been received.
    pending_messages: HashMap<MessageId, Vec<u8>, BuildNoHashHasher<u64>>,
}

/// Checks whether a new message arrives, optionally blocking the thread.
///
/// If `block` is true, then the return value is always `Some`.
///
/// See the `next_notification` FFI function for the semantics of `to_poll`.
pub(crate) fn next_notification(to_poll: &mut [u64], block: bool) -> Option<Vec<u8>> {
    next_notification_impl(to_poll, block)
}

#[cfg(target_arch = "wasm32")] // TODO: we should have a proper operating system name instead
fn next_notification_impl(to_poll: &mut [u64], block: bool) -> Option<Vec<u8>> {
    unsafe {
        let flags = if block { 1 } else { 0 };

        let mut out = Vec::<u64>::with_capacity(4);
        loop {
            let ret = crate::ffi::next_notification(
                to_poll.as_mut_ptr(),
                to_poll.len() as u32,
                out.as_mut_ptr() as *mut u8,
                out.capacity() as u32 * 8,
                flags,
            ) as usize;
            if ret == 0 {
                debug_assert!(!block);
                return None;
            }
            if ret > out.capacity() * 8 {
                out.reserve(8 * (1 + (ret - 1) / 8));
                continue;
            }
            let out_slice = core::slice::from_raw_parts(out.as_ptr() as *const u8, ret);
            // TODO: don't use to_vec(), ideally
            return Some(out_slice.to_vec());
        }
    }
}

#[cfg(not(target_arch = "wasm32"))]
fn next_notification_impl(_: &mut [u64], _: bool) -> Option<Vec<u8>> {
    unimplemented!()
}


================================================
FILE: interface-wrappers/syscalls/src/emit.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

use crate::{Decode, Encode, EncodedMessage, InterfaceHash, MessageId};
use core::{
    convert::TryFrom as _,
    fmt,
    marker::PhantomData,
    mem::MaybeUninit,
    pin::Pin,
    task::{Context, Poll},
};
use futures::prelude::*;
use generic_array::{
    sequence::Concat as _,
    typenum::consts::{U0, U2},
    ArrayLength, GenericArray,
};

/// Prototype for a message in construction.
///
/// Use this struct if you want to send out a message split between multiple slices.
pub struct MessageBuilder<'a, TLen: ArrayLength<u32>> {
    /// Parameter for the FFI function.
    allow_delay: bool,
    /// Array of slices, passed to the FFI function.
    array: GenericArray<u32, TLen>,
    /// Pin the lifetime. The lifetime corresponds to the lifetime of buffers pointer to
    /// within `array`.
    marker: PhantomData<&'a ()>,
}

impl<'a> MessageBuilder<'a, U0> {
    /// Start building an empty message.
    pub fn new() -> Self {
        MessageBuilder {
            allow_delay: true,
            array: Default::default(),
            marker: PhantomData,
        }
    }
}

impl<'a, TLen> MessageBuilder<'a, TLen>
where
    TLen: ArrayLength<u32>,
{
    /// If called, emitting the message will fail if no interface handler is available. Otherwise,
    /// emitting the message will block the thread until a handler is available.
    pub fn with_no_delay(mut self) -> Self {
        self.allow_delay = false;
        self
    }

    /// Append a slice of message data to the builder.
    ///
    /// > **Note**: This operation is cheap and doesn't perform any copy of the message data
    /// >           itself.
    pub fn add_data<TOutLen>(self, buffer: &'a EncodedMessage) -> MessageBuilder<'a, TOutLen>
    where
        TLen: core::ops::Add<U2, Output = TOutLen>,
        TOutLen: ArrayLength<u32>,
    {
        self.add_data_raw(&buffer.0)
    }

    /// Append a slice of message data to the builder.
    ///
    /// > **Note**: This operation is cheap and doesn't perform any copy of the message data
    /// >           itself.
    pub fn add_data_raw<TOutLen>(self, buffer: &'a [u8]) -> MessageBuilder<'a, TOutLen>
    where
        TLen: core::ops::Add<U2, Output = TOutLen>,
        TOutLen: ArrayLength<u32>,
    {
        let mut new_pair = GenericArray::<u32, U2>::default();
        new_pair[0] = u32::try_from(buffer.as_ptr() as usize).unwrap();
        new_pair[1] = u32::try_from(buffer.len()).unwrap();

        MessageBuilder {
            allow_delay: self.allow_delay,
            array: self.array.concat(new_pair),
            marker: self.marker,
        }
    }

    /// Emit the message and returns a `Future` that will yield the response.
    // TODO: could we remove the error type?
    pub unsafe fn emit_with_response<T>(
        self,
        interface: &InterfaceHash,
    ) -> Result<impl Future<Output = T>, EmitErr>
    where
        T: Decode,
    {
        let msg_id = self.emit_with_response_raw(interface)?;
        let response_fut = crate::message_response(msg_id);
        Ok(EmitMessageWithResponse {
            inner: Some(response_fut),
            msg_id,
        })
    }

    /// Emit the message and returns the emitted [`MessageId`].
    // TODO: could we remove the error type?
    pub unsafe fn emit_with_response_raw(
        self,
        interface: &InterfaceHash,
    ) -> Result<MessageId, EmitErr> {
        Ok(self.emit_raw(interface, true)?.unwrap())
    }

    /// Emit the message. The message doesn't expect any response. If the handler tries to
    /// respond, the response will be ignored.
    // TODO: could we remove the error type?
    pub unsafe fn emit_without_response(self, interface: &InterfaceHash) -> Result<(), EmitErr> {
        let out = self.emit_raw(interface, false)?;
        debug_assert!(out.is_none());
        Ok(())
    }

    /// Emit the message. You can decide at runtime whether or not the message expects a response.
    ///
    /// If `needs_answer` is `true`, then on success a `Some` will always be returned.
    /// If `needs_answer` is `false`, then on success a `None` will always be returned.
    // TODO: could we remove the error type?
    pub unsafe fn emit_raw(
        self,
        interface: &InterfaceHash,
        needs_answer: bool,
    ) -> Result<Option<MessageId>, EmitErr> {
        self.emit_raw_impl(interface, needs_answer)
    }

    #[cfg(target_arch = "wasm32")] // TODO: we should have a proper operating system name instead
    unsafe fn emit_raw_impl(
        self,
        interface: &InterfaceHash,
        needs_answer: bool,
    ) -> Result<Option<MessageId>, EmitErr> {
        let flags = {
            let mut flags = 0;
            if needs_answer {
                flags |= 1 << 0;
            }
            if self.allow_delay {
                flags |= 1 << 1;
            }
            flags
        };

        let mut message_id_out = MaybeUninit::uninit();

        let ret = crate::ffi::emit_message(
            interface as *const InterfaceHash as *const _,
            self.array.as_ptr(),
            u32::try_from(self.array.len() / 2).unwrap(),
            flags,
            message_id_out.as_mut_ptr(),
        );

        if ret != 0 {
            return Err(EmitErr::BadInterface);
        }

        if needs_answer {
            Ok(Some(MessageId::from_u64_unchecked(
                message_id_out.assume_init(),
            )))
        } else {
            Ok(None)
        }
    }

    #[cfg(not(target_arch = "wasm32"))]
    unsafe fn emit_raw_impl(
        self,
        _: &InterfaceHash,
        _: bool,
    ) -> Result<Option<MessageId>, EmitErr> {
        unimplemented!()
    }
}

impl<'a> Default for MessageBuilder<'a, U0> {
    fn default() -> Self {
        MessageBuilder::new()
    }
}

impl<'a, TLen> fmt::Debug for MessageBuilder<'a, TLen>
where
    TLen: ArrayLength<u32>,
{
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.debug_tuple("MessageBuilder").finish()
    }
}

/// Emits a message destined to the handler of the given interface.
///
/// Returns `Ok` if the message has been successfully dispatched. Returns an error if no handler
/// is available for that interface.
/// Whether this function succeeds only depends on whether an interface handler is available. This
/// function doesn't perform any validity check on the message itself.
///
/// # Safety
///
/// While the action of sending a message is totally safe, the message itself might instruct the
/// environment to perform actions that would lead to unsafety.
///
pub unsafe fn emit_message_without_response<'a>(
    interface: &InterfaceHash,
    msg: impl Encode,
) -> Result<(), EmitErr> {
    let msg = msg.encode();
    MessageBuilder::new()
        .add_data(&msg)
        .emit_without_response(interface)
}

/// Emis a message, then waits for a response to come back.
///
/// Returns `Ok` if the message has been successfully dispatched. Returns an error if no handler
/// is available for that interface.
/// Whether this function succeeds only depends on whether an interface handler is available. This
/// function doesn't perform any validity check on the message itself.
///
/// The returned future will cancel the message if it is dropped early.
///
/// # Safety
///
/// While the action of sending a message is totally safe, the message itself might instruct the
/// environment to perform actions that would lead to unsafety.
///
pub unsafe fn emit_message_with_response<'a, T: Decode>(
    interface: &InterfaceHash,
    msg: impl Encode,
) -> Result<impl Future<Output = T>, EmitErr> {
    let msg = msg.encode();
    MessageBuilder::new()
        .add_data(&msg)
        .emit_with_response(interface)
}

/// Cancel the given message. No answer will be received.
///
/// Has no effect if the message is invalid.
pub fn cancel_message(message_id: MessageId) {
    #[cfg(target_arch = "wasm32")] // TODO: we should have a proper operating system name instead
    fn imp(message_id: MessageId) {
        unsafe { crate::ffi::cancel_message(&u64::from(message_id)) }
    }
    #[cfg(not(target_arch = "wasm32"))]
    fn imp(_: MessageId) {
        unreachable!()
    }
    imp(message_id)
}

/// Error that can be retuend by functions that emit a message.
#[derive(Debug)]
pub enum EmitErr {
    /// The given interface has no handler.
    BadInterface,
}

impl fmt::Display for EmitErr {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            EmitErr::BadInterface => write!(f, "The given interface has no handler"),
        }
    }
}

/// Future that drives [`emit_message_with_response`] to completion.
#[must_use]
#[pin_project::pin_project(PinnedDrop)]
pub struct EmitMessageWithResponse<T> {
    #[pin]
    inner: Option<crate::MessageResponseFuture<T>>,
    // TODO: redundant with `inner`
    msg_id: MessageId,
}

impl<T: Decode> Future for EmitMessageWithResponse<T> {
    type Output = T;

    fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
        unsafe {
            let mut this = self.project();
            let val = match this
                .inner
                .as_mut()
                .map_unchecked_mut(|opt| opt.as_mut().unwrap())
                .poll(cx)
            {
                Poll::Ready(val) => val,
                Poll::Pending => return Poll::Pending,
            };
            *this.inner = None;
            Poll::Ready(val)
        }
    }
}

#[pin_project::pinned_drop]
impl<T> PinnedDrop for EmitMessageWithResponse<T> {
    fn drop(self: Pin<&mut Self>) {
        if self.inner.is_some() {
            let _ = cancel_message(self.msg_id);
        }
    }
}


================================================
FILE: interface-wrappers/syscalls/src/ffi.rs
================================================
// Copyright (C) 2019-2021  Pierre Krieger
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

use crate::{EncodedMessageRef, MessageId};

use alloc::vec::Vec;
use core::convert::TryFrom as _;

#[cfg(target_arch = "wasm32")] // TODO: we should have a proper operating system name instead
#[link(wasm_import_module = "redshirt")]
extern "C" {
    /// Asks for the next notification.
    ///
    /// The `to_poll` parameter must be a list (whose length is `to_poll_len`) of messages whose
    /// answer to poll. Entries in this list equal to `0` are ignored. If a notification is
    /// successfully pulled, the corresponding entry in `to_poll` is set to `0`.
    ///
    /// Flags is a bitfield, defined as:
    ///
    /// - Bit 0: the `block` flag. If set, then this function puts the thread to sleep until a
    /// notification is available. Otherwise, this function returns as soon as possible.
    ///
    /// If the function returns 0, then there is no notification available and nothing has been
    /// written.
    /// This function never returns 0 if the `block` flag is set.
    /// If the function returns a value larger than `out_len`, then a notification is available
    /// whose  length is the value that has been returned, but nothing has been written in `out`.
    /// If the function returns value inferior or equal to `out_len` (and different from 0), then
    /// a notification has been written in `out`. `out` must be 8-bytes-aligned.
    ///
    /// Messages, amongst the set that matches `to_poll`, are always returned in the order they
    /// have been received. In particular, this function does **not** search the queue of
    /// notifications for a notification that fits in `out_len`. It will however skip the
    /// notifications in the queue that do not match any entry in `to_poll`.
    ///
    /// Messages written in `out` can be decoded using [`decode_notification`].
    ///
    /// When this function is being called, a "lock" is being held on the memory pointed by
    /// `to_poll` and `out`. In particular, it is invalid to modify these buffers while the
    /// function is running.
    pub(crate) fn next_notification(
        to_poll: *mut u64,
        to_poll_len: u32,
Download .txt
gitextract_fwagyvzx/

├── .dockerignore
├── .github/
│   ├── dependabot.yml
│   └── workflows/
│       └── ci.yml
├── .gitignore
├── Cargo.toml
├── LICENSE
├── README.md
├── docs/
│   ├── authorizations.md
│   ├── interfaces.md
│   ├── introduction.md
│   └── messages.md
├── interface-wrappers/
│   ├── disk/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── disk.rs
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── ethernet/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       ├── interface.rs
│   │       └── lib.rs
│   ├── framebuffer/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── hardware/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       ├── lib.rs
│   │       └── malloc.rs
│   ├── interface/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── kernel-debug/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       └── lib.rs
│   ├── kernel-log/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── loader/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── log/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── pci/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── random/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── syscalls/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── block_on.rs
│   │       ├── emit.rs
│   │       ├── ffi.rs
│   │       ├── lib.rs
│   │       ├── response.rs
│   │       └── traits.rs
│   ├── system-time/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── tcp/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── ffi.rs
│   │       └── lib.rs
│   ├── time/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── delay.rs
│   │       ├── ffi.rs
│   │       ├── instant.rs
│   │       └── lib.rs
│   └── video-output/
│       ├── Cargo.toml
│       └── src/
│           ├── ffi.rs
│           ├── lib.rs
│           └── video_output.rs
├── kernel/
│   ├── core/
│   │   ├── Cargo.toml
│   │   ├── benches/
│   │   │   ├── keccak.rs
│   │   │   └── keccak.wasm
│   │   └── src/
│   │       ├── extrinsics/
│   │       │   ├── log_calls.rs
│   │       │   └── wasi.rs
│   │       ├── extrinsics.rs
│   │       ├── id_pool.rs
│   │       ├── lib.rs
│   │       ├── module.rs
│   │       ├── primitives.rs
│   │       ├── scheduler/
│   │       │   ├── extrinsics/
│   │       │   │   └── calls.rs
│   │       │   ├── extrinsics.rs
│   │       │   ├── ipc/
│   │       │   │   ├── notifications_queue.rs
│   │       │   │   └── waiting_threads.rs
│   │       │   ├── ipc.rs
│   │       │   ├── processes/
│   │       │   │   ├── tests.rs
│   │       │   │   └── wakers.rs
│   │       │   ├── processes.rs
│   │       │   ├── tests/
│   │       │   │   ├── basic_module.rs
│   │       │   │   ├── emit_not_available.rs
│   │       │   │   └── trapping_module.rs
│   │       │   ├── tests.rs
│   │       │   └── vm.rs
│   │       ├── scheduler.rs
│   │       ├── system/
│   │       │   ├── interfaces.rs
│   │       │   └── pending_answers.rs
│   │       └── system.rs
│   ├── core-proc-macros/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       └── lib.rs
│   └── standalone/
│       ├── Cargo.toml
│       ├── build.rs
│       └── src/
│           ├── arch/
│           │   ├── arm/
│           │   │   ├── executor.rs
│           │   │   ├── log.rs
│           │   │   ├── misc.rs
│           │   │   ├── time_aarch64.rs
│           │   │   └── time_arm.rs
│           │   ├── arm.rs
│           │   ├── riscv/
│           │   │   ├── executor.rs
│           │   │   ├── interrupts.rs
│           │   │   ├── log.rs
│           │   │   └── misc.rs
│           │   ├── riscv.rs
│           │   ├── x86_64/
│           │   │   ├── acpi.rs
│           │   │   ├── ap_boot.rs
│           │   │   ├── apic/
│           │   │   │   ├── io_apic.rs
│           │   │   │   ├── io_apics.rs
│           │   │   │   ├── local.rs
│           │   │   │   ├── pic.rs
│           │   │   │   ├── timers.rs
│           │   │   │   └── tsc_sync.rs
│           │   │   ├── apic.rs
│           │   │   ├── boot.rs
│           │   │   ├── executor.rs
│           │   │   ├── gdt.rs
│           │   │   ├── interrupts.rs
│           │   │   ├── panic.rs
│           │   │   └── pit.rs
│           │   └── x86_64.rs
│           ├── arch.rs
│           ├── hardware.rs
│           ├── kernel.rs
│           ├── klog/
│           │   ├── logger.rs
│           │   ├── native.rs
│           │   └── video.rs
│           ├── klog.rs
│           ├── lib.rs
│           ├── mem_alloc.rs
│           ├── pci/
│           │   ├── native.rs
│           │   └── pci.rs
│           ├── pci.rs
│           ├── random/
│           │   ├── native.rs
│           │   └── rng.rs
│           ├── random.rs
│           └── time.rs
├── kernel-standalone-builder/
│   ├── Cargo.toml
│   ├── build.rs
│   ├── res/
│   │   ├── rpi-firmware/
│   │   │   └── boot/
│   │   │       ├── COPYING.linux
│   │   │       ├── LICENCE.broadcom
│   │   │       ├── bcm2711-rpi-4-b.dtb
│   │   │       ├── start.elf
│   │   │       └── start4.elf
│   │   └── specs/
│   │       ├── aarch64-freestanding.json
│   │       ├── aarch64-freestanding.ld
│   │       ├── arm-freestanding.json
│   │       ├── arm-freestanding.ld
│   │       ├── riscv-hifive.json
│   │       ├── riscv-hifive.ld
│   │       ├── x86_64-multiboot2.json
│   │       └── x86_64-multiboot2.ld
│   ├── simpleboot/
│   │   ├── README.md
│   │   ├── simpleboot/
│   │   │   ├── .gitignore
│   │   │   ├── Kconfig
│   │   │   ├── Kconfig.name
│   │   │   ├── LICENSE
│   │   │   ├── Makefile
│   │   │   ├── README.md
│   │   │   ├── distrib/
│   │   │   │   ├── PKGBUILD
│   │   │   │   ├── simpleboot
│   │   │   │   ├── simpleboot-1.0.0.ebuild
│   │   │   │   ├── simpleboot-9999.ebuild
│   │   │   │   ├── simpleboot_1.0.0-amd64.deb
│   │   │   │   └── simpleboot_1.0.0-armhf.deb
│   │   │   ├── docs/
│   │   │   │   ├── ABI.md
│   │   │   │   ├── README.md
│   │   │   │   └── coreboot.md
│   │   │   ├── example/
│   │   │   │   ├── Makefile
│   │   │   │   ├── README.md
│   │   │   │   ├── bochs.rc
│   │   │   │   ├── gdb.rc
│   │   │   │   ├── kernel.c
│   │   │   │   ├── linux.c
│   │   │   │   └── simpleboot.cfg
│   │   │   ├── simpleboot.h
│   │   │   └── src/
│   │   │       ├── Makefile
│   │   │       ├── boot_x86.asm
│   │   │       ├── cdemu_x86.asm
│   │   │       ├── data.h
│   │   │       ├── inflate.h
│   │   │       ├── loader.h
│   │   │       ├── loader_cb.c
│   │   │       ├── loader_rpi.c
│   │   │       ├── loader_x86.c
│   │   │       ├── misc/
│   │   │       │   ├── bin2h.c
│   │   │       │   └── deb_control
│   │   │       ├── rombios_x86.asm
│   │   │       ├── romfoss_x86.asm
│   │   │       └── simpleboot.c
│   │   └── wrapper.c
│   └── src/
│       ├── bin/
│       │   └── main.rs
│       ├── binary.rs
│       ├── build.rs
│       ├── emulator.rs
│       ├── image.rs
│       ├── lib.rs
│       ├── simpleboot.rs
│       └── test.rs
├── programs/
│   ├── .cargo/
│   │   └── config.toml
│   ├── .dockerignore
│   ├── Cargo.toml
│   ├── compositor/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── lib.rs
│   │       ├── main.rs
│   │       └── rect.rs
│   ├── diagnostics-http-server/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       └── main.rs
│   ├── dummy-system-time/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       └── main.rs
│   ├── e1000/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── device.rs
│   │       └── main.rs
│   ├── hello-world/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       └── main.rs
│   ├── log-to-kernel/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       └── main.rs
│   ├── network-manager/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── interface.rs
│   │       ├── lib.rs
│   │       ├── main.rs
│   │       ├── manager.rs
│   │       └── port_assign.rs
│   ├── pci-printer/
│   │   ├── Cargo.toml
│   │   ├── build/
│   │   │   └── pci.ids
│   │   ├── build.rs
│   │   └── src/
│   │       └── main.rs
│   ├── rpi-framebuffer/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       ├── mailbox.rs
│   │       ├── main.rs
│   │       └── property.rs
│   ├── stub/
│   │   ├── Cargo.toml
│   │   └── src/
│   │       └── main.rs
│   ├── third-party/
│   │   ├── README.md
│   │   └── wasm-timer/
│   │       ├── Cargo.toml
│   │       └── src/
│   │           └── lib.rs
│   └── vga-vbe/
│       ├── Cargo.toml
│       └── src/
│           ├── interpreter/
│           │   └── tests.rs
│           ├── interpreter.rs
│           ├── main.rs
│           └── vbe.rs
└── rust-toolchain
Download .txt
SYMBOL INDEX (1714 symbols across 145 files)

FILE: interface-wrappers/disk/src/disk.rs
  type DiskConfig (line 38) | pub struct DiskConfig {
  function register_disk (line 51) | pub async fn register_disk(config: DiskConfig) -> DiskRegistration {
  type DiskRegistration (line 75) | pub struct DiskRegistration {
    method next_command (line 101) | pub async fn next_command(&self) -> Command {
    method fmt (line 131) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function build_commands_future (line 84) | fn build_commands_future(disk_id: u64) -> redshirt_syscalls::MessageResp...
  method drop (line 137) | fn drop(&mut self) {
  type Command (line 146) | pub enum Command {
  type ReadCommand (line 154) | pub struct ReadCommand {
    method sector_lba (line 162) | pub fn sector_lba(&self) -> u64 {
    method num_sectors (line 167) | pub fn num_sectors(&self) -> u32 {
    method report_finished (line 172) | pub fn report_finished(self, data: Vec<u8>) {
  type WriteCommand (line 181) | pub struct WriteCommand {
    method data (line 189) | pub fn data(&self) -> &[u8] {
    method sector_lba (line 194) | pub fn sector_lba(&self) -> u64 {
    method report_finished (line 199) | pub fn report_finished(self) {

FILE: interface-wrappers/disk/src/ffi.rs
  constant INTERFACE (line 20) | pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
  type DiskMessage (line 26) | pub enum DiskMessage {
  type DiskCommand (line 60) | pub enum DiskCommand {
  type ReadId (line 74) | pub struct ReadId(pub u64);
  type WriteId (line 77) | pub struct WriteId(pub u64);

FILE: interface-wrappers/ethernet/src/ffi.rs
  constant INTERFACE (line 20) | pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
  type NetworkMessage (line 26) | pub enum NetworkMessage {

FILE: interface-wrappers/ethernet/src/interface.rs
  type InterfaceConfig (line 41) | pub struct InterfaceConfig {
  function register_interface (line 49) | pub async fn register_interface(config: InterfaceConfig) -> NetInterface...
  type NetInterfaceRegistration (line 72) | pub struct NetInterfaceRegistration {
    method packet_from_network (line 108) | pub async fn packet_from_network<'a>(&'a self) -> PacketFromNetwork<'a> {
    method packet_to_send (line 127) | pub async fn packet_to_send(&self) -> Vec<u8> {
    method fmt (line 136) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function build_packet_to_net (line 89) | fn build_packet_to_net(interface_id: u64) -> redshirt_syscalls::MessageR...
  method drop (line 144) | fn drop(&mut self) {
  type PacketFromNetwork (line 154) | pub struct PacketFromNetwork<'a> {
  function send (line 161) | pub fn send(mut self, data: impl Into<Vec<u8>>) {

FILE: interface-wrappers/framebuffer/src/ffi.rs
  constant INTERFACE_WITH_EVENTS (line 37) | pub const INTERFACE_WITH_EVENTS: InterfaceHash = InterfaceHash::from_raw...
  constant INTERFACE_WITHOUT_EVENTS (line 43) | pub const INTERFACE_WITHOUT_EVENTS: InterfaceHash = InterfaceHash::from_...
  type Event (line 53) | pub enum Event {
  type MouseButton (line 87) | pub enum MouseButton {
  type ElementState (line 95) | pub enum ElementState {

FILE: interface-wrappers/framebuffer/src/lib.rs
  type Framebuffer (line 34) | pub struct Framebuffer {
    method new (line 56) | pub async fn new(with_events: bool, width: u32, height: u32) -> Self {
    method set_data (line 98) | pub fn set_data(&self, data: &[u8]) {
    method next_event (line 124) | pub async fn next_event(&mut self) -> u32 {
    method fill_event_messages (line 136) | fn fill_event_messages(&mut self) {
  method drop (line 152) | fn drop(&mut self) {

FILE: interface-wrappers/hardware/src/ffi.rs
  constant INTERFACE (line 21) | pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
  type HardwareMessage (line 28) | pub enum HardwareMessage {
  type Operation (line 66) | pub enum Operation {
  type HardwareAccessResponse (line 143) | pub enum HardwareAccessResponse {

FILE: interface-wrappers/hardware/src/lib.rs
  type HardwareWriteOperationsBuilder (line 32) | pub struct HardwareWriteOperationsBuilder {
    method new (line 37) | pub fn new() -> Self {
    method with_capacity (line 43) | pub fn with_capacity(capacity: usize) -> Self {
    method memset (line 49) | pub unsafe fn memset(&mut self, address: u64, len: u64, value: u8) {
    method write (line 57) | pub unsafe fn write(&mut self, address: u64, data: impl Into<Vec<u8>>) {
    method write_one_u32 (line 64) | pub unsafe fn write_one_u32(&mut self, address: u64, data: u32) {
    method port_write_u8 (line 72) | pub unsafe fn port_write_u8(&mut self, port: u32, data: u8) {
    method port_write_u16 (line 77) | pub unsafe fn port_write_u16(&mut self, port: u32, data: u16) {
    method port_write_u32 (line 82) | pub unsafe fn port_write_u32(&mut self, port: u32, data: u32) {
    method send (line 87) | pub fn send(self) {
  function write (line 100) | pub unsafe fn write(address: u64, data: impl Into<Vec<u8>>) {
  function read_to (line 107) | pub async unsafe fn read_to(address: u64, mut out: &mut [u8]) {
  function read (line 114) | pub async unsafe fn read(address: u64, len: u32) -> Vec<u8> {
  function read_one_u32 (line 126) | pub async unsafe fn read_one_u32(address: u64) -> u32 {
  function write_one_u32 (line 134) | pub unsafe fn write_one_u32(address: u64, data: u32) {
  function port_write_u8 (line 140) | pub unsafe fn port_write_u8(port: u32, data: u8) {
  function port_write_u16 (line 146) | pub unsafe fn port_write_u16(port: u32, data: u16) {
  function port_write_u32 (line 152) | pub unsafe fn port_write_u32(port: u32, data: u32) {
  function port_read_u8 (line 159) | pub async unsafe fn port_read_u8(port: u32) -> u8 {
  function port_read_u16 (line 167) | pub async unsafe fn port_read_u16(port: u32) -> u16 {
  function port_read_u32 (line 175) | pub async unsafe fn port_read_u32(port: u32) -> u32 {
  type HardwareOperationsBuilder (line 184) | pub struct HardwareOperationsBuilder<'a> {
  type Out (line 189) | enum Out<'a> {
  function new (line 200) | pub fn new() -> Self {
  function with_capacity (line 207) | pub fn with_capacity(capacity: usize) -> Self {
  function read (line 214) | pub unsafe fn read(&mut self, address: u64, out: &'a mut (impl ?Sized + ...
  function read_u16 (line 223) | pub unsafe fn read_u16(&mut self, address: u64, out: &'a mut (impl ?Size...
  function read_u32 (line 232) | pub unsafe fn read_u32(&mut self, address: u64, out: &'a mut (impl ?Size...
  function memset (line 241) | pub unsafe fn memset(&mut self, address: u64, len: u64, value: u8) {
  function write (line 249) | pub unsafe fn write(&mut self, address: u64, data: impl Into<Vec<u8>>) {
  function write_one_u32 (line 256) | pub unsafe fn write_one_u32(&mut self, address: u64, data: u32) {
  function port_write_u8 (line 264) | pub unsafe fn port_write_u8(&mut self, port: u32, data: u8) {
  function port_write_u16 (line 269) | pub unsafe fn port_write_u16(&mut self, port: u32, data: u16) {
  function port_write_u32 (line 274) | pub unsafe fn port_write_u32(&mut self, port: u32, data: u32) {
  function port_read_u8 (line 279) | pub unsafe fn port_read_u8(&mut self, port: u32, out: &'a mut u8) {
  function port_read_u16 (line 284) | pub unsafe fn port_read_u16(&mut self, port: u32, out: &'a mut u16) {
  function port_read_u32 (line 289) | pub unsafe fn port_read_u32(&mut self, port: u32, out: &'a mut u32) {
  function port_read_u8_discard (line 294) | pub unsafe fn port_read_u8_discard(&mut self, port: u32) {
  function port_read_u16_discard (line 299) | pub unsafe fn port_read_u16_discard(&mut self, port: u32) {
  function port_read_u32_discard (line 304) | pub unsafe fn port_read_u32_discard(&mut self, port: u32) {
  function send (line 309) | pub fn send(self) -> impl Future<Output = ()> + 'a {

FILE: interface-wrappers/hardware/src/malloc.rs
  type PhysicalBuffer (line 28) | pub struct PhysicalBuffer<T: ?Sized> {
  function new (line 44) | pub fn new(data: T) -> impl Future<Output = Self> {
  function write (line 63) | pub fn write(&self, data: T) {
  function take (line 76) | pub fn take(self) -> impl Future<Output = T> {
  function read (line 81) | pub fn read(&self) -> impl Future<Output = T>
  function read_inner (line 96) | unsafe fn read_inner(&self) -> impl Future<Output = T> {
  function new_uninit_slice (line 122) | pub async fn new_uninit_slice(len: usize) -> PhysicalBuffer<[mem::MaybeU...
  function new_uninit_slice_with_align (line 127) | pub async fn new_uninit_slice_with_align(
  function len (line 145) | pub fn len(&self) -> usize {
  function write_one (line 149) | pub fn write_one(&self, idx: usize, value: T) {
  function read_one (line 169) | pub async fn read_one(&self, idx: usize) -> Option<T> {
  function read_slice (line 188) | pub async fn read_slice(&self, idx: usize, out: &mut [T]) {
  function write_slice (line 204) | pub fn write_slice(&self, idx: usize, data: &[T]) {
  function assume_init (line 221) | pub unsafe fn assume_init(self) -> PhysicalBuffer<[T]> {
  function pointer (line 236) | pub fn pointer(&self) -> u64 {
  method drop (line 242) | fn drop(&mut self) {
  function malloc (line 253) | pub fn malloc(size: u64, alignment: u64) -> impl Future<Output = u64> {
  function free (line 267) | pub fn free(ptr: u64) {

FILE: interface-wrappers/interface/src/ffi.rs
  constant INTERFACE (line 21) | pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
  type InterfaceMessage (line 27) | pub enum InterfaceMessage {
  type InterfaceRegisterResponse (line 34) | pub struct InterfaceRegisterResponse {
  type InterfaceRegisterError (line 39) | pub enum InterfaceRegisterError {
  type DecodedInterfaceOrDestroyed (line 46) | pub enum DecodedInterfaceOrDestroyed {
  function decode_notification (line 54) | pub fn decode_notification(buffer: &[u8]) -> Result<DecodedInterfaceOrDe...
  function build_interface_notification (line 68) | pub fn build_interface_notification(
  type InterfaceNotificationBuilder (line 86) | pub struct InterfaceNotificationBuilder {
    method message_id (line 92) | pub fn message_id(&self) -> Option<MessageId> {
    method len (line 107) | pub fn len(&self) -> usize {
    method into_bytes (line 111) | pub fn into_bytes(self) -> Vec<u8> {
  function decode_interface_notification (line 117) | pub fn decode_interface_notification(buffer: &[u8]) -> Result<DecodedInt...
  type DecodedInterfaceNotification (line 149) | pub struct DecodedInterfaceNotification {
  function build_process_destroyed_notification (line 163) | pub fn build_process_destroyed_notification(pid: Pid) -> ProcessDestroye...
  type ProcessDestroyedNotificationBuilder (line 173) | pub struct ProcessDestroyedNotificationBuilder {
    method len (line 178) | pub fn len(&self) -> usize {
    method into_bytes (line 182) | pub fn into_bytes(self) -> Vec<u8> {
  function decode_process_destroyed_notification (line 187) | pub fn decode_process_destroyed_notification(
  type DecodedProcessDestroyedNotification (line 206) | pub struct DecodedProcessDestroyedNotification {

FILE: interface-wrappers/interface/src/lib.rs
  function register_interface (line 36) | pub async fn register_interface(
  type Registration (line 62) | pub struct Registration {
    method next_message_raw (line 71) | pub async fn next_message_raw(&mut self) -> DecodedInterfaceOrDestroyed {
    method add_message (line 77) | fn add_message(&mut self) {
  method drop (line 90) | fn drop(&mut self) {
  function emit_answer (line 99) | pub fn emit_answer(message_id: MessageId, msg: impl Encode) {
  function emit_message_error (line 119) | pub fn emit_message_error(message_id: MessageId) {

FILE: interface-wrappers/kernel-debug/src/lib.rs
  constant INTERFACE (line 38) | pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
  function get_prometheus_metrics (line 44) | pub async fn get_prometheus_metrics() -> String {

FILE: interface-wrappers/kernel-log/src/ffi.rs
  constant INTERFACE (line 27) | pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
  type KernelLogMethod (line 34) | pub struct KernelLogMethod {
  type UartInfo (line 52) | pub struct UartInfo {
  type UartAccess (line 66) | pub enum UartAccess {
  type FramebufferInfo (line 75) | pub struct FramebufferInfo {
  type FramebufferFormat (line 92) | pub enum FramebufferFormat {

FILE: interface-wrappers/kernel-log/src/lib.rs
  function log (line 49) | pub fn log(msg: &[u8]) {
  function configure_kernel (line 60) | pub async fn configure_kernel(method: KernelLogMethod) {

FILE: interface-wrappers/loader/src/ffi.rs
  constant INTERFACE (line 21) | pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
  type LoaderMessage (line 27) | pub enum LoaderMessage {
  type LoadResponse (line 33) | pub struct LoadResponse {

FILE: interface-wrappers/loader/src/lib.rs
  function load (line 34) | pub fn load(hash: [u8; 32]) -> impl Future<Output = Result<Vec<u8>, ()>> {

FILE: interface-wrappers/log/src/ffi.rs
  constant INTERFACE (line 34) | pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
  type Level (line 41) | pub enum Level {
    type Error (line 62) | type Error = InvalidLevelError;
    method try_from (line 64) | fn try_from(value: u8) -> Result<Self, InvalidLevelError> {
  function from (line 50) | fn from(level: Level) -> u8 {
  type InvalidLevelError (line 78) | pub struct InvalidLevelError(u8);
    method value (line 82) | pub fn value(&self) -> u8 {
    method fmt (line 88) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type DecodedLogMessage (line 94) | pub struct DecodedLogMessage {
    method level (line 101) | pub fn level(&self) -> Level {
    method message (line 106) | pub fn message(&self) -> &str {
  type Error (line 113) | type Error = DecodeError;
  method decode (line 115) | fn decode(buffer: EncodedMessage) -> Result<Self, DecodeError> {
  type DecodeError (line 127) | pub enum DecodeError {
    method fmt (line 134) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

FILE: interface-wrappers/log/src/lib.rs
  function emit_log (line 55) | pub fn emit_log(level: Level, msg: &str) {
  function try_init (line 72) | pub fn try_init() -> Result<(), log::SetLoggerError> {
  function init (line 87) | pub fn init() {
  type GlobalLogger (line 94) | pub struct GlobalLogger;
    method enabled (line 97) | fn enabled(&self, _: &log::Metadata) -> bool {
    method log (line 101) | fn log(&self, record: &log::Record) {
    method flush (line 114) | fn flush(&self) {}

FILE: interface-wrappers/pci/src/ffi.rs
  constant INTERFACE (line 21) | pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
  type PciMessage (line 28) | pub enum PciMessage {
  type GetDevicesListResponse (line 106) | pub struct GetDevicesListResponse {
  type NextInterruptResponse (line 113) | pub enum NextInterruptResponse {
  type PciDeviceBdf (line 128) | pub struct PciDeviceBdf {
  type PciDeviceInfo (line 136) | pub struct PciDeviceInfo {
  type PciBaseAddressRegister (line 155) | pub enum PciBaseAddressRegister {
  type MemoryOperation (line 162) | pub enum MemoryOperation {
  type IoOperation (line 200) | pub enum IoOperation {
  type MemoryAccessResponse (line 241) | pub enum MemoryAccessResponse {
  type IoAccessResponse (line 252) | pub enum IoAccessResponse {

FILE: interface-wrappers/pci/src/lib.rs
  function get_pci_devices (line 32) | pub fn get_pci_devices() -> impl Future<Output = Vec<PciDeviceInfo>> {
  type PciDeviceLock (line 47) | pub struct PciDeviceLock {
    method lock (line 53) | pub async fn lock(bdf: ffi::PciDeviceBdf) -> Result<Self, ()> {
    method set_command (line 66) | pub fn set_command(&self, bus_master: bool, memory_space: bool, io_spa...
    method next_interrupt (line 90) | pub fn next_interrupt(&self) -> impl Future<Output = ()> + Send + 'sta...
  method drop (line 113) | fn drop(&mut self) {

FILE: interface-wrappers/random/src/ffi.rs
  constant INTERFACE (line 21) | pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
  type RandomMessage (line 27) | pub enum RandomMessage {
  type GenerateResponse (line 37) | pub struct GenerateResponse {

FILE: interface-wrappers/random/src/lib.rs
  function generate (line 28) | pub async fn generate(len: usize) -> Vec<u8> {
  function generate_in (line 38) | pub async fn generate_in(out: &mut [u8]) {
  function generate_u8 (line 53) | pub async fn generate_u8() -> u8 {
  function generate_u16 (line 60) | pub async fn generate_u16() -> u16 {
  function generate_u32 (line 67) | pub async fn generate_u32() -> u32 {
  function generate_u64 (line 74) | pub async fn generate_u64() -> u64 {
  function generate_u128 (line 81) | pub async fn generate_u128() -> u128 {

FILE: interface-wrappers/syscalls/src/block_on.rs
  function register_message_waker (line 53) | pub(crate) fn register_message_waker(message_id: MessageId, waker: Waker...
  function peek_response (line 69) | pub(crate) fn peek_response(msg_id: MessageId) -> Option<Vec<u8>> {
  type WakerRegistration (line 74) | pub(crate) struct WakerRegistration {
    method update (line 81) | pub fn update(&self, waker: &Waker) {
  method drop (line 91) | fn drop(&mut self) {
  function block_on (line 106) | pub fn block_on<T>(future: impl Future<Output = T>) -> T {
  type BlockOnState (line 181) | struct BlockOnState {
  function next_notification (line 204) | pub(crate) fn next_notification(to_poll: &mut [u64], block: bool) -> Opt...
  function next_notification_impl (line 209) | fn next_notification_impl(to_poll: &mut [u64], block: bool) -> Option<Ve...
  function next_notification_impl (line 238) | fn next_notification_impl(_: &mut [u64], _: bool) -> Option<Vec<u8>> {

FILE: interface-wrappers/syscalls/src/emit.rs
  type MessageBuilder (line 35) | pub struct MessageBuilder<'a, TLen: ArrayLength<u32>> {
  function new (line 47) | pub fn new() -> Self {
  function with_no_delay (line 62) | pub fn with_no_delay(mut self) -> Self {
  function add_data (line 71) | pub fn add_data<TOutLen>(self, buffer: &'a EncodedMessage) -> MessageBui...
  function add_data_raw (line 83) | pub fn add_data_raw<TOutLen>(self, buffer: &'a [u8]) -> MessageBuilder<'...
  function emit_with_response (line 101) | pub unsafe fn emit_with_response<T>(
  function emit_with_response_raw (line 118) | pub unsafe fn emit_with_response_raw(
  function emit_without_response (line 128) | pub unsafe fn emit_without_response(self, interface: &InterfaceHash) -> ...
  function emit_raw (line 139) | pub unsafe fn emit_raw(
  function emit_raw_impl (line 148) | unsafe fn emit_raw_impl(
  function emit_raw_impl (line 188) | unsafe fn emit_raw_impl(
  method default (line 198) | fn default() -> Self {
  function fmt (line 207) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function emit_message_without_response (line 224) | pub unsafe fn emit_message_without_response<'a>(
  function emit_message_with_response (line 248) | pub unsafe fn emit_message_with_response<'a, T: Decode>(
  function cancel_message (line 261) | pub fn cancel_message(message_id: MessageId) {
  type EmitErr (line 275) | pub enum EmitErr {
    method fmt (line 281) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type EmitMessageWithResponse (line 291) | pub struct EmitMessageWithResponse<T> {
  type Output (line 299) | type Output = T;
  method poll (line 301) | fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
  method drop (line 321) | fn drop(self: Pin<&mut Self>) {

FILE: interface-wrappers/syscalls/src/ffi.rs
  function next_notification (line 53) | pub(crate) fn next_notification(
  function emit_message (line 94) | pub(crate) fn emit_message(
  function cancel_message (line 115) | pub(crate) fn cancel_message(message_id: *const u64);
  function build_notification (line 120) | pub fn build_notification(
  type NotificationBuilder (line 143) | pub struct NotificationBuilder {
    method set_index_in_list (line 149) | pub fn set_index_in_list(&mut self, value: u32) {
    method message_id (line 153) | pub fn message_id(&self) -> MessageId {
    method len (line 167) | pub fn len(&self) -> usize {
    method into_bytes (line 171) | pub fn into_bytes(self) -> Vec<u8> {
  function decode_notification (line 176) | pub fn decode_notification(buffer: &[u8]) -> Result<DecodedNotificationR...
  type DecodedNotificationRef (line 208) | pub struct DecodedNotificationRef<'a> {
  function response_message_encode_decode (line 229) | fn response_message_encode_decode() {

FILE: interface-wrappers/syscalls/src/lib.rs
  type Pid (line 102) | pub struct Pid(u64);
    method from (line 105) | fn from(id: NonZeroU64) -> Pid {
    method from (line 111) | fn from(id: u64) -> Pid {
    method fmt (line 123) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function from (line 117) | fn from(pid: Pid) -> u64 {
  type ThreadId (line 134) | pub struct ThreadId(u64);
    method from (line 137) | fn from(id: NonZeroU64) -> ThreadId {
    method from (line 143) | fn from(id: u64) -> ThreadId {
    method fmt (line 155) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function from (line 149) | fn from(tid: ThreadId) -> u64 {
  type MessageId (line 165) | pub struct MessageId(NonZeroU64);
    method from_u64_unchecked (line 173) | pub unsafe fn from_u64_unchecked(id: u64) -> Self {
    type Error (line 179) | type Error = InvalidMessageIdErr;
    method try_from (line 181) | fn try_from(id: u64) -> Result<Self, Self::Error> {
    type Error (line 190) | type Error = InvalidMessageIdErr;
    method try_from (line 192) | fn try_from(id: NonZeroU64) -> Result<Self, Self::Error> {
    method fmt (line 210) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  method from (line 198) | fn from(mid: MessageId) -> NonZeroU64 {
  function from (line 204) | fn from(mid: MessageId) -> u64 {
  type InvalidMessageIdErr (line 217) | pub struct InvalidMessageIdErr;
    method fmt (line 220) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type InterfaceHash (line 227) | pub struct InterfaceHash([u8; 32]);
    method from_raw_hash (line 231) | pub const fn from_raw_hash(hash: [u8; 32]) -> Self {
    method as_ref (line 237) | fn as_ref(&self) -> &[u8] {
    method from (line 249) | fn from(hash: [u8; 32]) -> InterfaceHash {
    method eq (line 255) | fn eq(&self, other: &[u8; 32]) -> bool {
    method fmt (line 267) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function from (line 243) | fn from(interface: InterfaceHash) -> [u8; 32] {
  function eq (line 261) | fn eq(&self, other: &InterfaceHash) -> bool {

FILE: interface-wrappers/syscalls/src/response.rs
  function message_response_sync_raw (line 29) | pub fn message_response_sync_raw(msg_id: MessageId) -> EncodedMessage {
  function message_response (line 41) | pub fn message_response<T: Decode>(msg_id: MessageId) -> MessageResponse...
  type MessageResponseFuture (line 59) | pub struct MessageResponseFuture<T> {
  type Output (line 70) | type Output = T;
  method poll (line 72) | fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {

FILE: interface-wrappers/syscalls/src/traits.rs
  type EncodedMessage (line 24) | pub struct EncodedMessage(pub Vec<u8>);
    method decode (line 44) | pub fn decode<T: Decode>(self) -> Result<T, T::Error> {
    method from (line 84) | fn from(msg: EncodedMessageRef<'a>) -> Self {
    method as_ref (line 90) | fn as_ref(&self) -> &[u8] {
    method fmt (line 96) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type Encode (line 27) | pub trait Encode {
    method encode (line 29) | fn encode(self) -> EncodedMessage;
    method encode (line 50) | fn encode(self) -> EncodedMessage {
    method encode (line 59) | fn encode(self) -> EncodedMessage {
  type Decode (line 33) | pub trait Decode {
    method decode (line 38) | fn decode(buffer: EncodedMessage) -> Result<Self, Self::Error>
    type Error (line 65) | type Error = core::convert::Infallible;
    method decode (line 67) | fn decode(buffer: EncodedMessage) -> Result<Self, Self::Error> {
    type Error (line 76) | type Error = ();
    method decode (line 78) | fn decode(buffer: EncodedMessage) -> Result<Self, Self::Error> {
  type EncodedMessageRef (line 103) | pub struct EncodedMessageRef<'a>(&'a [u8]);
  function from (line 106) | fn from(buf: &'a [u8]) -> EncodedMessageRef<'a> {
  function as_ref (line 112) | fn as_ref(&self) -> &[u8] {
  function from (line 118) | fn from(msg: &'a EncodedMessage) -> Self {
  function fmt (line 124) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

FILE: interface-wrappers/system-time/src/ffi.rs
  constant INTERFACE (line 20) | pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
  type TimeMessage (line 26) | pub enum TimeMessage {

FILE: interface-wrappers/system-time/src/lib.rs
  function system_clock (line 27) | pub fn system_clock() -> impl Future<Output = u128> {

FILE: interface-wrappers/tcp/src/ffi.rs
  constant INTERFACE (line 20) | pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
  type TcpMessage (line 26) | pub enum TcpMessage {
  type TcpOpen (line 41) | pub struct TcpOpen {
  type TcpOpenResponse (line 55) | pub struct TcpOpenResponse {
  type TcpSocketOpen (line 61) | pub struct TcpSocketOpen {
  type TcpClose (line 70) | pub struct TcpClose {
  type TcpCloseResponse (line 75) | pub struct TcpCloseResponse {
  type TcpCloseError (line 80) | pub enum TcpCloseError {
  type TcpRead (line 91) | pub struct TcpRead {
  type TcpReadResponse (line 96) | pub struct TcpReadResponse {
  type TcpReadError (line 104) | pub enum TcpReadError {
  type TcpWrite (line 112) | pub struct TcpWrite {
  type TcpWriteResponse (line 118) | pub struct TcpWriteResponse {
  type TcpWriteError (line 123) | pub enum TcpWriteError {

FILE: interface-wrappers/tcp/src/lib.rs
  type TcpStream (line 96) | pub struct TcpStream {
    method connect (line 126) | pub fn connect(socket_addr: &SocketAddr) -> impl Future<Output = Resul...
    method new (line 133) | fn new(
    method poll_read (line 344) | fn poll_read(
    method poll_write (line 358) | fn poll_write(
    method poll_flush (line 366) | fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(...
    method poll_shutdown (line 370) | fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Resul...
  type TcpListener (line 113) | pub struct TcpListener {
    method bind (line 386) | pub fn bind(socket_addr: &SocketAddr) -> impl Future<Output = Result<T...
    method local_addr (line 403) | pub fn local_addr(&self) -> SocketAddr {
    method accept (line 408) | pub async fn accept(&self) -> (TcpStream, SocketAddr) {
  method poll_read (line 183) | fn poll_read(
  method poll_write (line 240) | fn poll_write(
  method poll_flush (line 272) | fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result...
  method poll_close (line 292) | fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result...
  method drop (line 376) | fn drop(&mut self) {

FILE: interface-wrappers/time/src/delay.rs
  type Delay (line 21) | pub struct Delay {
    method new (line 27) | pub fn new(dur: Duration) -> Delay {
    method new_at (line 31) | pub fn new_at(at: Instant) -> Delay {
    method when (line 38) | pub fn when(&self) -> Instant {
    method reset (line 42) | pub fn reset(&mut self, at: Instant) {
    method fmt (line 48) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type Output (line 54) | type Output = ();
  method poll (line 56) | fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {

FILE: interface-wrappers/time/src/ffi.rs
  constant INTERFACE (line 20) | pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
  type TimeMessage (line 26) | pub enum TimeMessage {

FILE: interface-wrappers/time/src/instant.rs
  type Instant (line 24) | pub struct Instant {
    method now (line 29) | pub fn now() -> Instant {
    method duration_since (line 34) | pub fn duration_since(&self, earlier: Instant) -> Duration {
    method elapsed (line 38) | pub fn elapsed(&self) -> Duration {
    type Output (line 44) | type Output = Instant;
    method add (line 46) | fn add(self, other: Duration) -> Instant {
    type Output (line 53) | type Output = Instant;
    method sub (line 55) | fn sub(self, other: Duration) -> Instant {
    type Output (line 62) | type Output = Duration;
    method sub (line 64) | fn sub(self, other: Instant) -> Duration {

FILE: interface-wrappers/time/src/lib.rs
  function monotonic_clock (line 34) | pub fn monotonic_clock() -> impl Future<Output = u128> {
  function monotonic_wait_until (line 42) | pub fn monotonic_wait_until(until: u128) -> impl Future<Output = ()> {
  function monotonic_wait (line 50) | pub fn monotonic_wait(duration: Duration) -> impl Future<Output = ()> {

FILE: interface-wrappers/video-output/src/ffi.rs
  constant INTERFACE (line 20) | pub const INTERFACE: InterfaceHash = InterfaceHash::from_raw_hash([
  type VideoOutputMessage (line 26) | pub enum VideoOutputMessage {
  type NextImage (line 48) | pub struct NextImage {
  type NextImageChange (line 53) | pub struct NextImageChange {
  type Format (line 63) | pub enum Format {

FILE: interface-wrappers/video-output/src/video_output.rs
  type VideoOutputConfig (line 27) | pub struct VideoOutputConfig {
  function register (line 37) | pub async fn register(config: VideoOutputConfig) -> VideoOutputRegistrat...
  type VideoOutputRegistration (line 61) | pub struct VideoOutputRegistration {
    method next_frame (line 89) | pub async fn next_frame(&self) -> ffi::NextImage {
    method fmt (line 106) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function build_frame_future (line 69) | fn build_frame_future(id: u64) -> redshirt_syscalls::MessageResponseFutu...
  method drop (line 114) | fn drop(&mut self) {

FILE: kernel-standalone-builder/build.rs
  function main (line 16) | fn main() {

FILE: kernel-standalone-builder/simpleboot/simpleboot/example/kernel.c
  function _start (line 42) | void _start(uint32_t magic, uintptr_t addr)
  function printf (line 201) | void printf(char *fmt, ...)
  function dumpuuid (line 267) | void dumpuuid(uint8_t *uuid)
  type sdt_hdr_t (line 276) | typedef struct {
  type fadt_t (line 288) | typedef struct {
  function dumpacpi (line 302) | void dumpacpi(uint64_t addr)

FILE: kernel-standalone-builder/simpleboot/simpleboot/example/linux.c
  function _start (line 57) | void _start(uint32_t dummy, linux_boot_params_t *bp)
  function printf (line 98) | void printf(char *fmt, ...)

FILE: kernel-standalone-builder/simpleboot/simpleboot/simpleboot.h
  type multiboot_info_t (line 70) | typedef struct {
  type multiboot_tag_t (line 76) | typedef struct {
  type multiboot_tag_cmdline_t (line 82) | typedef struct {
  type multiboot_tag_loader_t (line 89) | typedef struct {
  type multiboot_tag_module_t (line 96) | typedef struct {
  type multiboot_mmap_entry_t (line 112) | typedef struct {
  type multiboot_tag_mmap_t (line 119) | typedef struct {
  type multiboot_tag_framebuffer_t (line 128) | typedef struct {
  type multiboot_tag_efi64_t (line 147) | typedef struct {
  type multiboot_tag_smbios_t (line 154) | typedef struct {
  type multiboot_tag_old_acpi_t (line 164) | typedef struct {
  type multiboot_tag_new_acpi_t (line 171) | typedef struct {
  type multiboot_tag_efi64_ih_t (line 178) | typedef struct {
  type multiboot_tag_edid_t (line 185) | typedef struct {
  type multiboot_tag_smp_t (line 192) | typedef struct {
  type multiboot_tag_partuuid_t (line 201) | typedef struct {

FILE: kernel-standalone-builder/simpleboot/simpleboot/src/inflate.h
  type TINF_TREE (line 47) | typedef struct {
  type TINF_DATA (line 52) | struct TINF_DATA
  type TINF_DATA (line 53) | typedef struct TINF_DATA {
  function tinf_build_fixed_trees (line 119) | static void tinf_build_fixed_trees(TINF_TREE *lt, TINF_TREE *dt)
  function tinf_build_tree (line 144) | static void tinf_build_tree(TINF_TREE *t, const unsigned char *lengths, ...
  function uzlib_get_byte (line 175) | unsigned char uzlib_get_byte(TINF_DATA *d)
  function tinf_getbit (line 181) | static int tinf_getbit(TINF_DATA *d)
  function tinf_read_bits (line 201) | static unsigned int tinf_read_bits(TINF_DATA *d, int num, int base)
  function tinf_decode_symbol (line 219) | static int tinf_decode_symbol(TINF_DATA *d, TINF_TREE *t)
  function tinf_decode_trees (line 239) | static void tinf_decode_trees(TINF_DATA *d, TINF_TREE *lt, TINF_TREE *dt)
  function tinf_inflate_block_data (line 316) | static int tinf_inflate_block_data(TINF_DATA *d, TINF_TREE *lt, TINF_TRE...
  function tinf_inflate_uncompressed_block (line 353) | static int tinf_inflate_uncompressed_block(TINF_DATA *d)
  function uncompress (line 390) | int uncompress(uint8_t *in, uint8_t *out, uint32_t outsiz)

FILE: kernel-standalone-builder/simpleboot/simpleboot/src/loader.h
  type Elf32_Ehdr (line 60) | typedef struct {
  type Elf64_Ehdr (line 77) | typedef struct {
  type Elf32_Phdr (line 94) | typedef struct {
  type Elf64_Phdr (line 104) | typedef struct {
  type mz_hdr (line 125) | typedef struct {
  type pe_hdr (line 131) | typedef struct {
  type pe_sec (line 159) | typedef struct {
  type linux_boot_t (line 185) | typedef struct {
  type linux_e820_entry_t (line 229) | typedef struct {
  type linux_boot_params_t (line 236) | typedef struct {
  type intn_t (line 344) | typedef int64_t  intn_t;
  type boolean_t (line 345) | typedef uint8_t  boolean_t;
  type uintn_t (line 346) | typedef uint64_t uintn_t;
  type efi_status_t (line 347) | typedef uint64_t efi_status_t;
  type efi_physical_address_t (line 348) | typedef uint64_t efi_physical_address_t;
  type efi_virtual_address_t (line 349) | typedef uint64_t efi_virtual_address_t;
  type efi_allocate_type_t (line 351) | typedef enum {
  type efi_memory_type_t (line 358) | typedef enum {
  type efi_memory_descriptor_t (line 378) | typedef struct {
  type efi_locate_search_type_t (line 388) | typedef enum {
  type efi_table_header_t (line 394) | typedef struct {
  type efi_time_t (line 402) | typedef struct {
  type guid_t (line 416) | typedef struct {
  type efi_input_key_t (line 425) | typedef struct {
  type simple_input_interface_t (line 433) | typedef struct {
  type simple_text_output_mode_t (line 449) | typedef struct {
  type simple_text_output_interface_t (line 458) | typedef struct {
  type memalloc_t (line 473) | typedef struct {
  type efi_boot_services_t (line 492) | typedef struct {
  type efi_configuration_table_t (line 553) | typedef struct {
  type efi_system_table_t (line 558) | typedef struct {
  type efi_hard_disk_device_path_t (line 584) | typedef struct {
  type efi_loaded_image_protocol_t (line 600) | typedef struct {
  type efi_file_info_t (line 622) | typedef struct {
  type efi_file_handle_t (line 633) | typedef struct efi_file_handle_s efi_file_handle_t;
  type efi_simple_file_system_protocol_t (line 636) | typedef struct {
  type efi_file_handle_s (line 655) | struct efi_file_handle_s {
  type efi_gop_pixel_format_t (line 673) | typedef enum {
  type efi_gop_pixel_bitmask_t (line 681) | typedef struct {
  type efi_gop_mode_info_t (line 688) | typedef struct {
  type efi_gop_mode_t (line 697) | typedef struct {
  type efi_gop_t (line 712) | typedef struct {
  type efi_edid_t (line 724) | typedef struct {
  type gpt_header_t (line 736) | typedef struct {
  type gpt_entry_t (line 753) | typedef struct {
  type esp_bpb_t (line 764) | typedef struct {
  type esp_dir_t (line 789) | typedef struct {
  type pcirom_t (line 801) | typedef struct {
  type fb_boot_t (line 830) | typedef struct {
  type fb_mement_t (line 853) | typedef struct {
  type fb_system_t (line 861) | typedef struct {
  type fb_vidmode_t (line 886) | typedef struct {
  type fb_video_t (line 899) | typedef struct {
  type fb_storage_t (line 915) | typedef struct {
  type fb_serial_t (line 931) | typedef struct {
  type fb_input_t (line 947) | typedef struct {
  type fossbios_t (line 958) | typedef struct {
  type fb_rom_t (line 982) | typedef struct {
  type rsdp_t (line 1003) | typedef struct {
  type sdt_hdr_t (line 1011) | typedef struct {
  type rsdt_t (line 1023) | typedef struct {
  type cpu_entry_t (line 1028) | typedef struct {
  type apic_t (line 1036) | typedef struct {
  type fadt_t (line 1043) | typedef struct {

FILE: kernel-standalone-builder/simpleboot/simpleboot/src/loader_cb.c
  function usbdisk_create (line 157) | void usbdisk_create(void* dev) { if(!usbdev) usbdev = dev; }
  function usbdisk_remove (line 158) | void usbdisk_remove(void* dev) { if(usbdev == dev) usbdev = NULL; }
  function cbfs_load (line 174) | static inline size_t cbfs_load(const char *name, void *buf, size_t size)
  function cbfs_get_size (line 176) | static inline size_t cbfs_get_size(const char *name)
  function hexdump (line 235) | void hexdump(void *data, int n)
  function pb_init (line 253) | uint64_t pb_init(uint64_t size)
  function pb_draw (line 273) | void pb_draw(uint64_t curr)
  function pb_fini (line 290) | void pb_fini(void)
  function loadsec (line 312) | void loadsec(uint64_t lba, void *dst)
  function nextclu (line 348) | uint32_t nextclu(uint32_t clu)
  function page_alloc (line 364) | uint64_t page_alloc(void)
  function fw_init (line 376) | void fw_init(void)
  function fw_bootsplash (line 521) | void fw_bootsplash(void)
  function fw_open (line 563) | int fw_open(char *fn)
  function fw_read (line 674) | uint64_t fw_read(uint64_t offs, uint64_t size, void *buf)
  function fw_close (line 718) | void fw_close(void)
  function fw_loadconfig (line 726) | void fw_loadconfig(void)
  function fw_loadsetup (line 817) | void fw_loadsetup()
  function fw_loadmodules (line 915) | void fw_loadmodules(void)
  function fw_map (line 1015) | int fw_map(uint64_t phys, uint64_t virt, uint32_t size)
  function fw_loadseg (line 1048) | int fw_loadseg(uint32_t offs, uint32_t filesz, uint64_t vaddr, uint32_t ...
  function fw_loadkernel (line 1091) | int fw_loadkernel(void)

FILE: kernel-standalone-builder/simpleboot/simpleboot/src/loader_rpi.c
  function _preambule (line 60) | void __attribute__((noreturn)) /*__attribute__((naked))*/ _preambule(void)
  function memcpy (line 117) | void memcpy(void *dst, const void *src, uint32_t n){uint8_t *a=(uint8_t*...
  function memset (line 118) | void memset(void *dst, uint8_t c, uint32_t n){uint8_t *a=dst;while(n--) ...
  function memcmp (line 119) | int  memcmp(const void *s1, const void *s2, uint32_t n){
  function mbox_call (line 173) | uint8_t mbox_call(uint8_t ch)
  function mbox_lfb (line 191) | void mbox_lfb(uint32_t width, uint32_t height, uint32_t bpp)
  type psf2_t (line 383) | typedef struct { uint32_t magic, version, headersize, flags, numglyph, b...
  function console_init (line 391) | void console_init(void)
  function console_putc (line 431) | void console_putc(uint8_t c)
  function printf (line 488) | void printf(char *fmt, ...)
  function pb_init (line 568) | uint64_t pb_init(uint64_t size)
  function pb_draw (line 588) | void pb_draw(uint64_t curr)
  function pb_fini (line 605) | void pb_fini(void)
  function delayms (line 697) | void delayms(uint32_t cnt) {
  function sd_status (line 707) | int sd_status(uint32_t mask)
  function sd_int (line 716) | int sd_int(uint32_t mask)
  function sd_cmd (line 730) | int sd_cmd(uint32_t code, uint32_t arg)
  function sd_loadsec (line 760) | int sd_loadsec(uint64_t lba, void *dst)
  function sd_clk (line 780) | int sd_clk(uint32_t f)
  function sd_init (line 814) | int sd_init()
  function fw_loadsec (line 907) | int fw_loadsec(uint64_t lba, void *dst)
  function fw_alloc (line 915) | uint64_t fw_alloc(void)
  function fw_map (line 926) | int fw_map(uint64_t phys, uint64_t virt, uint32_t size)
  function fw_init (line 958) | void fw_init(void)
  function fw_fsinit (line 1005) | void fw_fsinit(void)
  function fw_bootsplash (line 1063) | void fw_bootsplash(void)
  function fw_nextclu (line 1107) | uint32_t fw_nextclu(uint32_t clu)
  function fw_open (line 1123) | int fw_open(char *fn)
  function fw_read (line 1234) | uint64_t fw_read(uint64_t offs, uint64_t size, void *buf)
  function fw_close (line 1280) | void fw_close(void)
  function fw_loadconfig (line 1288) | void fw_loadconfig(void)
  function fw_loadsetup (line 1369) | void fw_loadsetup()
  function fw_loadmodules (line 1436) | void fw_loadmodules(void)
  function fw_loadseg (line 1524) | int fw_loadseg(uint32_t offs, uint32_t filesz, uint64_t vaddr, uint32_t ...
  function fw_loadkernel (line 1553) | int fw_loadkernel(void)
  function fw_fini (line 1616) | void fw_fini(void)
  function fw_exc (line 1861) | void fw_exc(uint8_t excno, uint64_t esr, uint64_t elr, uint64_t spsr, ui...
  function _start (line 1903) | void _start(void)

FILE: kernel-standalone-builder/simpleboot/simpleboot/src/loader_x86.c
  function memcpy (line 133) | void memcpy(void *dst, const void *src, uint32_t n) { __asm__ __volatile...
  function memset (line 134) | void memset(void *dst, uint8_t c, uint32_t n) { __asm__ __volatile__("re...
  function memcmp (line 135) | int  memcmp(const void *s1, const void *s2, uint32_t n) {
  type psf2_t (line 146) | typedef struct { uint32_t magic, version, headersize, flags, numglyph, b...
  function console_init (line 157) | void console_init(void)
  function console_putc (line 188) | void console_putc(uint8_t c)
  function printf (line 276) | void printf(char *fmt, ...)
  function pb_init (line 356) | uint64_t pb_init(uint64_t size)
  function pb_draw (line 376) | void pb_draw(uint64_t curr)
  function pb_fini (line 393) | void pb_fini(void)
  function sort_map (line 420) | static void sort_map(multiboot_mmap_entry_t *dst, int num)
  function bios_loadsec (line 440) | void bios_loadsec(uint64_t lba, void *dst)
  function bios_vbe (line 520) | void bios_vbe(uint32_t width, uint32_t height, uint32_t bpp)
  function bios_e820 (line 664) | int bios_e820(multiboot_mmap_entry_t *dst)
  function bios_fallback (line 716) | void bios_fallback(void)
  function bios_pagetables (line 751) | void bios_pagetables(int g)
  function efi_gop (line 775) | void efi_gop(uint32_t width, uint32_t height, uint32_t bpp)
  function efi_edid (line 872) | void efi_edid(uint8_t **ptr, uint32_t *size)
  function efi_memmap (line 893) | int efi_memmap(multiboot_mmap_entry_t *dst)
  function efi_alloc (line 943) | uint64_t efi_alloc(void)
  function efi_physical_address_t (line 956) | efi_physical_address_t efi_allocpages(efi_allocate_type_t Type, uintn_t ...
  function efi_freepages (line 975) | void efi_freepages(void)
  function efi_open (line 992) | int efi_open(uint16_t *fn)
  function efi_read (line 1011) | uint64_t efi_read(uint64_t offs, uint64_t size, void *buf)
  function efi_close (line 1047) | void efi_close(void)
  function efi_systables (line 1056) | void efi_systables(void)
  function efi_init (line 1099) | void efi_init(void)
  function efi_freeall (line 1142) | void efi_freeall(void)
  function fb_systables (line 1157) | void fb_systables(void)
  function fb_memmap (line 1188) | int fb_memmap(multiboot_mmap_entry_t *dst)
  function fb_lfb (line 1230) | void fb_lfb(uint32_t width, uint32_t height, uint32_t bpp)
  function fw_lfb (line 1275) | void fw_lfb(uint32_t width, uint32_t height, uint32_t bpp)
  function fw_loadsec (line 1283) | void fw_loadsec(uint64_t lba, void *dst)
  function bios_sleep (line 1302) | void bios_sleep(void)
  function bios_alloc (line 1323) | uint64_t bios_alloc(void)
  function bios_nextclu (line 1334) | uint32_t bios_nextclu(uint32_t clu)
  function bios_open (line 1350) | int bios_open(uint16_t *fn)
  function bios_read (line 1447) | uint64_t bios_read(uint64_t offs, uint64_t size, void *buf)
  function bios_close (line 1491) | void bios_close(void)
  function bios_systables (line 1499) | void bios_systables(void)
  function bios_init (line 1539) | void bios_init(void)
  function fw_init (line 1623) | void fw_init(efi_handle_t image, efi_system_table_t *systab, uint16_t bdev)
  function fw_bootsplash (line 1663) | void fw_bootsplash(void)
  function fw_open (line 1707) | int fw_open(char *fn)
  function fw_read (line 1731) | uint64_t fw_read(uint64_t offs, uint64_t size, void *buf)
  function fw_close (line 1740) | void fw_close(void)
  function fw_loadconfig (line 1748) | void fw_loadconfig(void)
  function fw_loadsetup (line 1843) | void fw_loadsetup()
  function fw_loadmodules (line 1911) | void fw_loadmodules(void)
  function fw_map (line 2011) | int fw_map(uint64_t phys, uint64_t virt, uint32_t size)
  function fw_loadseg (line 2044) | int fw_loadseg(uint32_t offs, uint32_t filesz, uint64_t vaddr, uint32_t ...
  function fw_loadkernel (line 2095) | int fw_loadkernel(void)
  function fw_fini (line 2208) | void fw_fini(void)
  function fw_exc (line 2550) | void fw_exc(uint8_t excno, uint64_t exccode, uint64_t rip, uint64_t rsp)
  function efi_status_t (line 2593) | efi_status_t _start (efi_handle_t image, efi_system_table_t *systab, uin...

FILE: kernel-standalone-builder/simpleboot/simpleboot/src/misc/bin2h.c
  function main (line 33) | int main(int argc, char **argv)

FILE: kernel-standalone-builder/simpleboot/simpleboot/src/simpleboot.c
  type tm (line 65) | struct tm
  type stat (line 66) | struct stat
  type zlib_z_t (line 141) | typedef struct { uint32_t b, c, t; uint8_t *s, *d; uint16_t e[16], f[288...
  type zlib_c_t (line 142) | typedef struct { uint8_t e; uint8_t min, max; } zlib_c_t;
  type zlib_d_t (line 143) | typedef struct { uint8_t c, e; uint16_t min, max; } zlib_d_t;
  function zlib_o (line 166) | void zlib_o(uint32_t b, int n) { d.b|=b<<d.c; d.c+=n; while(d.c >= 8){ d...
  function compressBound (line 168) | uint32_t compressBound(uint32_t len) { return len + (len >> 12) + (len >...
  function compress (line 169) | uint32_t compress(uint8_t *in, uint8_t *out, uint32_t siz)
  function crc32_calc (line 245) | uint32_t crc32_calc(unsigned char *start,int length)
  function chs (line 256) | void chs(uint32_t lba, void *chs)
  function gpt_create (line 269) | void gpt_create(void)
  function setinte (line 346) | void setinte(uint32_t val, unsigned char *ptr) {
  function etbc_create (line 355) | void etbc_create(void)
  function rom_create (line 483) | void rom_create(char *path)
  function fat_finish (line 566) | void fat_finish(void)
  function fat_format (line 605) | void fat_format(void)
  function fat_findclu (line 644) | uint32_t fat_findclu(uint32_t cnt)
  function fat_dirent (line 673) | int fat_dirent(uint32_t parent, int add, char *name, int isdir, uint32_t...
  function fat_add (line 841) | int fat_add(uint32_t parent, char *name, uint8_t *content, uint32_t size)
  function status (line 876) | void status(char *msg, char *par)
  function parsedir (line 893) | void parsedir(char *directory, int parent, int calcsize, uint32_t to)
  function dev_read (line 1039) | int dev_read(void *f, uint64_t off, void *buf, uint32_t size)
  function dev_write (line 1056) | int dev_write(void *f, uint64_t off, void *buf, uint32_t size)
  function dev_close (line 1082) | void dev_close(void *f)
  function check_config (line 1095) | void check_config(char *in)
  function gethex (line 1268) | uint64_t gethex(char *ptr, int len)
  function getguid (line 1283) | void getguid(char *ptr, guid_t *guid)
  function usage (line 1300) | void usage(char *cmd)
  function simpleboot_main (line 1336) | int simpleboot_main(int argc, char **argv)

FILE: kernel-standalone-builder/simpleboot/wrapper.c
  function simpleboot_wrapper (line 5) | extern int simpleboot_wrapper(int argc, char **argv) {

FILE: kernel-standalone-builder/src/bin/main.rs
  type CliOptions (line 28) | enum CliOptions {
  type DeviceTy (line 111) | enum DeviceTy {
  type Err (line 117) | type Err = String;
  method from_str (line 119) | fn from_str(s: &str) -> Result<Self, Self::Err> {
  type Target (line 129) | enum Target {
  function from (line 137) | fn from(target: Target) -> redshirt_standalone_builder::image::Target {
  type Err (line 148) | type Err = String;
  method from_str (line 150) | fn from_str(s: &str) -> Result<Self, Self::Err> {
  type Emulator (line 162) | enum Emulator {
  function from (line 167) | fn from(emulator: Emulator) -> redshirt_standalone_builder::emulator::Em...
  function from (line 175) | fn from(emulator: Emulator) -> redshirt_standalone_builder::test::Emulat...
  type Err (line 183) | type Err = String;
  method from_str (line 185) | fn from_str(s: &str) -> Result<Self, Self::Err> {
  function main (line 193) | fn main() -> Result<(), Box<dyn error::Error + Send + Sync + 'static>> {

FILE: kernel-standalone-builder/src/binary.rs
  type Architecture (line 19) | pub enum Architecture {
  function elf_to_binary (line 29) | pub fn elf_to_binary(

FILE: kernel-standalone-builder/src/build.rs
  type Config (line 24) | pub struct Config<'a> {
  type BuildOutput (line 47) | pub struct BuildOutput {
  type Error (line 54) | pub enum Error {
  function build (line 72) | pub fn build(cfg: Config) -> Result<BuildOutput, Error> {
  function write_if_changed (line 279) | fn write_if_changed(file: impl AsRef<Path>, content: impl AsRef<[u8]>) -...

FILE: kernel-standalone-builder/src/emulator.rs
  type Config (line 21) | pub struct Config<'a> {
  type Emulator (line 37) | pub enum Emulator {
  type Error (line 43) | pub enum Error {
  function run_kernel (line 59) | pub fn run_kernel(cfg: Config) -> Result<(), Error> {

FILE: kernel-standalone-builder/src/image.rs
  type Config (line 26) | pub struct Config<'a> {
  type Target (line 45) | pub enum Target {
  type Error (line 54) | pub enum Error {
  function build_image (line 64) | pub fn build_image(config: Config) -> Result<(), Error> {
  function build_x86_multiboot2_cdrom_iso (line 136) | fn build_x86_multiboot2_cdrom_iso(
  function build_raspberry_pi_sd_card (line 175) | fn build_raspberry_pi_sd_card(

FILE: kernel-standalone-builder/src/simpleboot.rs
  function simpleboot_wrapper (line 19) | fn simpleboot_wrapper(
  function run_simpleboot (line 25) | pub fn run_simpleboot<'a>(args: impl IntoIterator<Item = &'a str>) -> Re...

FILE: kernel-standalone-builder/src/test.rs
  type Config (line 29) | pub struct Config<'a> {
  type Emulator (line 42) | pub enum Emulator {
  type Error (line 48) | pub enum Error {
  function test_kernel (line 67) | pub fn test_kernel(cfg: Config) -> Result<(), Error> {
  function run_until_line (line 169) | fn run_until_line(command: &mut Command) -> Result<(), Error> {
  function signal_when_line_detected (line 195) | fn signal_when_line_detected(read: impl io::Read + Send + 'static) -> on...

FILE: kernel/core-proc-macros/src/lib.rs
  function wat_to_bin (line 22) | pub fn wat_to_bin(tokens: proc_macro::TokenStream) -> proc_macro::TokenS...
  function build_wasm_module (line 64) | pub fn build_wasm_module(tokens: proc_macro::TokenStream) -> proc_macro:...

FILE: kernel/core/benches/keccak.rs
  function bench (line 19) | fn bench(c: &mut Criterion) {

FILE: kernel/core/src/extrinsics.rs
  type Extrinsics (line 40) | pub trait Extrinsics: Default {
    method supported_extrinsics (line 55) | fn supported_extrinsics() -> Self::Iterator;
    method new_context (line 63) | fn new_context(
    method inject_message_response (line 80) | fn inject_message_response(
    type ExtrinsicId (line 168) | type ExtrinsicId = core::convert::Infallible;
    type Context (line 169) | type Context = core::convert::Infallible;
    type Iterator (line 170) | type Iterator = iter::Empty<SupportedExtrinsic<Self::ExtrinsicId>>;
    method supported_extrinsics (line 172) | fn supported_extrinsics() -> Self::Iterator {
    method new_context (line 176) | fn new_context(
    method inject_message_response (line 186) | fn inject_message_response(
  type ExtrinsicsMemoryAccess (line 89) | pub trait ExtrinsicsMemoryAccess {
    method read_memory (line 97) | fn read_memory(&self, range: Range<u32>) -> Result<Vec<u8>, Extrinsics...
    method write_memory (line 100) | fn write_memory(&mut self, offset: u32, data: &[u8]) -> Result<(), Ext...
  type ExtrinsicsMemoryAccessErr (line 105) | pub enum ExtrinsicsMemoryAccessErr {
    method fmt (line 111) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type SupportedExtrinsic (line 123) | pub struct SupportedExtrinsic<TExtId> {
  type ExtrinsicsAction (line 145) | pub enum ExtrinsicsAction {
  type NoExtrinsics (line 165) | pub struct NoExtrinsics;

FILE: kernel/core/src/extrinsics/log_calls.rs
  type LogExtrinsics (line 34) | pub struct LogExtrinsics<TInner> {
  function new (line 43) | pub fn new(inner: TInner) -> Self {
  method default (line 55) | fn default() -> Self {
  type ExtrinsicId (line 62) | pub struct ExtrinsicId<TInner> {
  type Context (line 70) | pub struct Context<TInner> {
  type LogIterator (line 84) | pub struct LogIterator<TInner>(TInner);
  type ExtrinsicId (line 90) | type ExtrinsicId = ExtrinsicId<TInner::ExtrinsicId>;
  type Context (line 91) | type Context = Context<TInner::Context>;
  type Iterator (line 92) | type Iterator = LogIterator<TInner::Iterator>;
  method supported_extrinsics (line 94) | fn supported_extrinsics() -> Self::Iterator {
  method new_context (line 98) | fn new_context(
  method inject_message_response (line 155) | fn inject_message_response(
  type Item (line 199) | type Item = SupportedExtrinsic<ExtrinsicId<TExtId>>;
  method next (line 201) | fn next(&mut self) -> Option<Self::Item> {
  method size_hint (line 217) | fn size_hint(&self) -> (usize, Option<usize>) {

FILE: kernel/core/src/extrinsics/wasi.rs
  type WasiExtrinsics (line 37) | pub struct WasiExtrinsics {
  type FileDescriptor (line 55) | enum FileDescriptor {
  type Inode (line 71) | enum Inode {
  method default (line 81) | fn default() -> WasiExtrinsics {
  type ExtrinsicId (line 125) | pub struct ExtrinsicId(ExtrinsicIdInner);
  type ExtrinsicIdInner (line 128) | enum ExtrinsicIdInner {
  type Context (line 154) | pub struct Context(ContextInner);
  type ContextInner (line 156) | enum ContextInner {
  type ExtrinsicId (line 165) | type ExtrinsicId = ExtrinsicId;
  type Context (line 166) | type Context = Context;
  type Iterator (line 167) | type Iterator = IntoIter<SupportedExtrinsic<Self::ExtrinsicId>>;
  method supported_extrinsics (line 169) | fn supported_extrinsics() -> Self::Iterator {
  method new_context (line 307) | fn new_context(
  method inject_message_response (line 351) | fn inject_message_response(
  type WasiCallErr (line 476) | struct WasiCallErr;
    method from (line 478) | fn from(_: T) -> Self {
  function args_get (line 483) | fn args_get(
  function args_sizes_get (line 491) | fn args_sizes_get(
  function clock_time_get (line 499) | fn clock_time_get(
  function environ_get (line 537) | fn environ_get(
  function environ_sizes_get (line 545) | fn environ_sizes_get(
  function fd_close (line 553) | fn fd_close(
  function fd_fdstat_get (line 590) | fn fd_fdstat_get(
  function fd_filestat_get (line 710) | fn fd_filestat_get(
  function fd_prestat_dir_name (line 736) | fn fd_prestat_dir_name(
  function fd_prestat_get (line 782) | fn fd_prestat_get(
  function fd_read (line 846) | fn fd_read(
  function fd_seek (line 935) | fn fd_seek(
  function fd_write (line 1008) | fn fd_write(
  function path_filestat_get (line 1095) | fn path_filestat_get(
  function path_open (line 1194) | fn path_open(
  function poll_oneoff (line 1272) | fn poll_oneoff(
  function proc_exit (line 1286) | fn proc_exit(
  function random_get (line 1304) | fn random_get(
  function sched_yield (line 1332) | fn sched_yield(
  function args_or_env_get (line 1345) | fn args_or_env_get(
  function args_or_env_sizes_get (line 1375) | fn args_or_env_sizes_get(
  function filestat_from_inode (line 1397) | fn filestat_from_inode(inode: &Arc<Inode>) -> wasi::Filestat {
  function resolve_path (line 1418) | fn resolve_path(root: &Arc<Inode>, path: &str) -> Option<Arc<Inode>> {

FILE: kernel/core/src/id_pool.rs
  type IdPool (line 29) | pub struct IdPool {
    method with_seed (line 42) | pub fn with_seed(seed: [u8; 32]) -> Self {
    method assign (line 54) | pub fn assign<T: TryFrom<u64>>(&self) -> T {
    method fmt (line 82) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function ids_different (line 92) | fn ids_different() {

FILE: kernel/core/src/module.rs
  type ModuleHash (line 20) | pub struct ModuleHash([u8; 32]);
    method from (line 27) | fn from(hash: [u8; 32]) -> ModuleHash {
    method from_bytes (line 40) | pub fn from_bytes(buffer: impl AsRef<[u8]>) -> Self {
    method from_base58 (line 48) | pub fn from_base58(encoding: &str) -> Result<Self, FromBase58Error> {
    method fmt (line 60) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type FromBase58Error (line 24) | pub struct FromBase58Error {}
    method fmt (line 66) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function from (line 33) | fn from(hash: ModuleHash) -> [u8; 32] {
  function empty_wat_works (line 74) | fn empty_wat_works() {
  function simple_wat_works (line 79) | fn simple_wat_works() {

FILE: kernel/core/src/primitives.rs
  type Signature (line 23) | pub struct Signature {
    method new (line 51) | pub fn new(
    method parameters (line 62) | pub fn parameters(&self) -> impl ExactSizeIterator<Item = &ValueType> {
    method return_type (line 67) | pub fn return_type(&self) -> Option<&ValueType> {
    method from (line 92) | fn from(sig: &'a wasmi::FuncType) -> Signature {
    method from (line 101) | fn from(sig: wasmi::FuncType) -> Signature {
  function from (line 73) | fn from(sig: &'a Signature) -> wasmi::FuncType {
  function from (line 86) | fn from(sig: Signature) -> wasmi::FuncType {
  function from (line 107) | fn from(ty: ValueType) -> wasmi::core::ValType {
  type WasmValue (line 119) | pub enum WasmValue {
    method ty (line 153) | pub fn ty(&self) -> ValueType {
    method into_i32 (line 163) | pub fn into_i32(self) -> Option<i32> {
    method into_i64 (line 172) | pub fn into_i64(self) -> Option<i64> {
    method from (line 182) | fn from(val: wasmi::Val) -> Self {
    method from (line 188) | fn from(val: &'a wasmi::Val) -> Self {
  type ValueType (line 140) | pub enum ValueType {
    method from (line 208) | fn from(val: wasmi::core::ValType) -> Self {
  function from (line 198) | fn from(val: WasmValue) -> Self {

FILE: kernel/core/src/scheduler/extrinsics.rs
  type ProcessesCollectionExtrinsics (line 58) | pub struct ProcessesCollectionExtrinsics<TPud, TTud, TExt: Extrinsics> {
  type Builder (line 75) | pub struct Builder<TExt: Extrinsics> {
  type ProcAccess (line 80) | pub struct ProcAccess<'a, TPud, TTud, TExt: Extrinsics> {
  type ThreadAccess (line 93) | pub enum ThreadAccess<'a, TPud, TTud, TExt: Extrinsics> {
  type ThreadEmitMessage (line 101) | pub struct ThreadEmitMessage<'a, TPud, TTud, TExt: Extrinsics> {
  type ThreadWaitNotif (line 114) | pub struct ThreadWaitNotif<'a, TPud, TTud, TExt: Extrinsics> {
  type ThreadAccessAccess (line 125) | pub trait ThreadAccessAccess<'a> {
    method tid (line 136) | fn tid(&self) -> ThreadId;
    method pid (line 140) | fn pid(&self) -> Pid;
    method process_user_data (line 143) | fn process_user_data(&self) -> &Self::ProcessUserData;
    method user_data (line 146) | fn user_data(&mut self) -> &mut Self::ThreadUserData;
  type ThreadByIdErr (line 151) | pub enum ThreadByIdErr {
  type Extrinsic (line 160) | enum Extrinsic<TExtId> {
  type LocalProcessUserData (line 170) | struct LocalProcessUserData<TPud, TExt> {
  type LocalThreadUserData (line 180) | struct LocalThreadUserData<TTud, TExtCtxt> {
  type LocalThreadState (line 190) | enum LocalThreadState<TExtCtxt> {
  type ExecuteOut (line 247) | pub enum ExecuteOut<'a, TPud, TTud, TExt: Extrinsics> {
  type ReadyToRun (line 256) | pub struct ReadyToRun<'a, TPud, TTud, TExt: Extrinsics> {
  function run (line 270) | pub fn run(mut self) -> Option<RunOneOutcome<'a, TPud, TTud, TExt>> {
  type RunOneOutcome (line 277) | pub enum RunOneOutcome<'a, TPud, TTud, TExt: Extrinsics> {
  function execute (line 344) | pub fn execute(
  function run (line 373) | pub async fn run<'a>(&'a self) -> ExecuteOut<'a, TPud, TTud, TExt> {
  function inner_event (line 450) | fn inner_event<'a>(
  function process_by_id (line 603) | pub fn process_by_id(&self, pid: Pid) -> Option<ProcAccess<TPud, TTud, T...
  function interrupted_thread_by_id (line 620) | pub fn interrupted_thread_by_id(
  function with_seed (line 665) | pub fn with_seed(seed: [u8; 32]) -> Self {
  function reserve_pid (line 704) | pub fn reserve_pid(&mut self) -> Pid {
  function build (line 709) | pub fn build<TPud, TTud>(self) -> ProcessesCollectionExtrinsics<TPud, TT...
  function pid (line 723) | pub fn pid(&self) -> Pid {
  function user_data (line 728) | pub fn user_data(&self) -> &TPud {
  function start_thread (line 738) | pub fn start_thread(
  function abort (line 760) | pub fn abort(&self) {
  function fmt (line 770) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function from (line 778) | fn from(thread: ThreadEmitMessage<'a, TPud, TTud, TExt>) -> Self {
  function from (line 786) | fn from(thread: ThreadWaitNotif<'a, TPud, TTud, TExt>) -> Self {
  type ProcessUserData (line 794) | type ProcessUserData = TPud;
  type ThreadUserData (line 795) | type ThreadUserData = TTud;
  function tid (line 797) | fn tid(&self) -> ThreadId {
  function pid (line 804) | fn pid(&self) -> Pid {
  function process_user_data (line 811) | fn process_user_data(&self) -> &TPud {
  function user_data (line 818) | fn user_data(&mut self) -> &mut TTud {
  function fmt (line 830) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function needs_answer (line 840) | pub fn needs_answer(&mut self) -> bool {
  function emit_interface (line 851) | pub fn emit_interface(&mut self) -> &InterfaceHash {
  function allow_delay (line 860) | pub fn allow_delay(&mut self) -> bool {
  function accept_emit (line 875) | pub fn accept_emit(mut self, message_id: Option<MessageId>) -> EncodedMe...
  function refuse_emit (line 935) | pub fn refuse_emit(mut self) {
  type ProcessUserData (line 960) | type ProcessUserData = TPud;
  type ThreadUserData (line 961) | type ThreadUserData = TTud;
  function tid (line 963) | fn tid(&self) -> ThreadId {
  function pid (line 967) | fn pid(&self) -> Pid {
  function process_user_data (line 971) | fn process_user_data(&self) -> &TPud {
  function user_data (line 975) | fn user_data(&mut self) -> &mut TTud {
  function fmt (line 981) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function into_process (line 988) | pub fn into_process(self) -> ProcAccess<'a, TPud, TTud, TExt> {
  function wait_entries (line 994) | pub fn wait_entries<'b>(&'b mut self) -> impl Iterator<Item = WaitEntry>...
  function allowed_notification_size (line 1007) | pub fn allowed_notification_size(&self) -> usize {
  function block (line 1016) | pub fn block(&self) -> bool {
  function resume_notification (line 1035) | pub fn resume_notification(mut self, index: usize, notif: EncodedMessage) {
  function resume_notification_too_big (line 1099) | pub fn resume_notification_too_big(mut self, notif_size: usize) {
  function resume_no_notification (line 1122) | pub fn resume_no_notification(mut self) {
  type ProcessUserData (line 1137) | type ProcessUserData = TPud;
  type ThreadUserData (line 1138) | type ThreadUserData = TTud;
  function tid (line 1140) | fn tid(&self) -> ThreadId {
  function pid (line 1144) | fn pid(&self) -> Pid {
  function process_user_data (line 1148) | fn process_user_data(&self) -> &TPud {
  function user_data (line 1152) | fn user_data(&mut self) -> &mut TTud {
  function fmt (line 1158) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function is_ready_to_run (line 1165) | fn is_ready_to_run(&self) -> bool {
  type MemoryAccessImpl (line 1174) | struct MemoryAccessImpl<'a, 'b, TExtr, TPud, TTud>(
  method read_memory (line 1181) | fn read_memory(&self, range: Range<u32>) -> Result<Vec<u8>, ExtrinsicsMe...
  method write_memory (line 1187) | fn write_memory(&mut self, offset: u32, data: &[u8]) -> Result<(), Extri...

FILE: kernel/core/src/scheduler/extrinsics/calls.rs
  function parse_extrinsic_next_notification (line 31) | pub fn parse_extrinsic_next_notification<TExtr, TPud, TTud>(
  type NotificationWait (line 104) | pub struct NotificationWait {
  type WaitEntry (line 120) | pub enum WaitEntry {
  type ExtrinsicNextNotificationErr (line 130) | pub enum ExtrinsicNextNotificationErr {
  function parse_extrinsic_emit_message (line 148) | pub fn parse_extrinsic_emit_message<TExtr, TPud, TTud>(
  type EmitMessage (line 241) | pub struct EmitMessage {
  type ExtrinsicEmitMessageErr (line 256) | pub enum ExtrinsicEmitMessageErr {
  function parse_extrinsic_cancel_message (line 268) | pub fn parse_extrinsic_cancel_message<TExtr, TPud, TTud>(
  type ExtrinsicCancelMessageErr (line 295) | pub enum ExtrinsicCancelMessageErr {

FILE: kernel/core/src/scheduler/ipc.rs
  type Core (line 81) | pub struct Core<TExt: Extrinsics> {
  type CoreBuilder (line 103) | pub struct CoreBuilder<TExt: Extrinsics> {
  type ExecuteOut (line 112) | pub enum ExecuteOut<'a, TExt: Extrinsics> {
  function or_run (line 120) | pub fn or_run(self) -> Option<CoreRunOutcome> {
  type ReadyToRun (line 130) | pub struct ReadyToRun<'a, TExt: Extrinsics> {
  function run (line 139) | pub fn run(self) -> Option<CoreRunOutcome> {
  type CoreRunOutcome (line 147) | pub enum CoreRunOutcome {
  type Process (line 188) | struct Process {
  type CoreProcess (line 197) | pub struct CoreProcess<'a, TExt: Extrinsics> {
  function run (line 204) | pub async fn run<'a>(&'a self) -> ExecuteOut<'a, TExt> {
  function run_inner (line 214) | async fn run_inner<'a>(&'a self) -> Option<ExecuteOut<'a, TExt>> {
  function inner_event (line 232) | fn inner_event(
  function process_by_id (line 323) | pub fn process_by_id(&self, pid: Pid) -> Option<CoreProcess<TExt>> {
  function accept_interface_message (line 336) | pub fn accept_interface_message(&self, message_id: MessageId) -> Option<...
  function reject_immediate_interface_message (line 363) | pub fn reject_immediate_interface_message(&self, message_id: MessageId) {
  function answer_message (line 382) | pub fn answer_message(&self, message_id: MessageId, response: Result<Enc...
  function execute (line 408) | pub fn execute(&self, module: &[u8]) -> Result<(CoreProcess<TExt>, Threa...
  function try_resume_notification_wait (line 420) | fn try_resume_notification_wait(&self, process: extrinsics::ProcAccess<P...
  function pid (line 441) | pub fn pid(&self) -> Pid {
  function start_thread (line 447) | pub fn start_thread(
  function abort (line 458) | pub fn abort(&self) {
  function with_seed (line 468) | pub fn with_seed(seed: [u8; 64]) -> CoreBuilder<TExt> {
  function reserve_pid (line 483) | pub fn reserve_pid(&mut self) -> Pid {
  function build (line 488) | pub fn build(self) -> Core<TExt> {
  function try_resume_notification_wait_thread (line 503) | fn try_resume_notification_wait_thread<TExt: Extrinsics>(

FILE: kernel/core/src/scheduler/ipc/notifications_queue.rs
  type NotificationsQueue (line 28) | pub struct NotificationsQueue {
    method new (line 57) | pub fn new() -> NotificationsQueue {
    method total_notifications_pushed (line 67) | pub fn total_notifications_pushed(&self) -> u64 {
    method push (line 72) | pub fn push(&self, message_id: MessageId, response: Result<EncodedMess...
    method find (line 93) | pub fn find<'a>(&self, indices: impl IntoIterator<Item = &'a WaitEntry...
  type Guarded (line 34) | struct Guarded {
  type Entry (line 48) | pub struct Entry<'a> {
  function size (line 117) | pub fn size(&self) -> usize {
  function index_in_msg_ids (line 122) | pub fn index_in_msg_ids(&self) -> usize {
  function extract (line 127) | pub fn extract(mut self) -> EncodedMessage {

FILE: kernel/core/src/scheduler/ipc/waiting_threads.rs
  type WaitingThreads (line 44) | pub struct WaitingThreads {
    method new (line 65) | pub fn new() -> WaitingThreads {
    method push (line 80) | pub fn push(&self, thread_id: ThreadId) {
    method access (line 111) | pub fn access(&self) -> impl Iterator<Item = Entry> {
  type WaitingThreadsInner (line 49) | struct WaitingThreadsInner {
  type Entry (line 58) | pub struct Entry<'a> {
  function thread_id (line 140) | pub fn thread_id(&self) -> ThreadId {
  function remove (line 146) | pub fn remove(self) {
  method drop (line 159) | fn drop(&mut self) {
  function fuzz_unique_entry (line 180) | fn fuzz_unique_entry() {
  function access_checks_again_when_active (line 218) | fn access_checks_again_when_active() {
  function all_are_returned (line 240) | fn all_are_returned() {

FILE: kernel/core/src/scheduler/processes.rs
  constant PROCESSES_MIN_CAPACITY (line 146) | const PROCESSES_MIN_CAPACITY: usize = 128;
  type ProcessesCollection (line 156) | pub struct ProcessesCollection<TExtr, TPud, TTud> {
  type Process (line 212) | struct Process<TPud, TTud> {
  type ProcessLock (line 226) | struct ProcessLock<TTud> {
  type ProcessDeadState (line 240) | struct ProcessDeadState<TTud> {
  type Thread (line 249) | struct Thread {
  function execute (line 264) | pub fn execute(
  function run (line 335) | pub fn run(&self) -> RunFuture<TExtr, TPud, TTud> {
  function processes (line 343) | pub fn processes<'a>(
  function process_by_id (line 380) | pub fn process_by_id(&self, pid: Pid) -> Option<ProcAccess<TExtr, TPud, ...
  function interrupted_thread_by_id (line 404) | pub fn interrupted_thread_by_id(
  function try_report_process_death (line 427) | fn try_report_process_death(&self, process: Arc<Process<TPud, TTud>>) {
  type ProcessesCollectionBuilder (line 452) | pub struct ProcessesCollectionBuilder<TExtr> {
  function with_seed (line 467) | pub fn with_seed(seed: [u8; 32]) -> ProcessesCollectionBuilder<TExtr> {
  function reserve_pid (line 481) | pub fn reserve_pid(&mut self) -> Pid {
  function with_extrinsic (line 500) | pub fn with_extrinsic(
  function build (line 520) | pub fn build<TPud, TTud>(mut self) -> ProcessesCollection<TExtr, TPud, T...
  type RunOneOutcome (line 547) | pub enum RunOneOutcome<'a, TExtr, TPud, TTud> {
  type Trap (line 609) | pub struct Trap {
  type RunFuture (line 614) | pub struct RunFuture<'a, TExtr, TPud, TTud>(
  type Output (line 620) | type Output = RunFutureOut<'a, TExtr, TPud, TTud>;
  method poll (line 622) | fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
  type RunFutureOut (line 699) | pub enum RunFutureOut<'a, TExtr, TPud, TTud> {
  type ReadyToRun (line 708) | pub struct ReadyToRun<'a, TExtr, TPud, TTud> {
  function run (line 728) | pub fn run(mut self) -> RunOneOutcome<'a, TExtr, TPud, TTud> {
  method drop (line 871) | fn drop(&mut self) {
  type ProcAccess (line 894) | pub struct ProcAccess<'a, TExtr, TPud, TTud> {
  function pid (line 905) | pub fn pid(&self) -> Pid {
  function user_data (line 910) | pub fn user_data(&self) -> &TPud {
  function start_thread (line 920) | pub fn start_thread(
  function abort (line 952) | pub fn abort(&self) {
  function fmt (line 986) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  method clone (line 995) | fn clone(&self) -> Self {
  method drop (line 1005) | fn drop(&mut self) {
  type ThreadAccess (line 1012) | pub struct ThreadAccess<'a, TExtr, TPud, TTud> {
  type OutOfBoundsError (line 1029) | pub struct OutOfBoundsError;
  function tid (line 1036) | pub fn tid(&self) -> ThreadId {
  function pid (line 1042) | pub fn pid(&self) -> Pid {
  function process (line 1047) | pub fn process(&self) -> ProcAccess<'a, TExtr, TPud, TTud> {
  function read_memory (line 1061) | pub fn read_memory(&self, offset: u32, size: u32) -> Result<Vec<u8>, Out...
  function write_memory (line 1093) | pub fn write_memory(&mut self, offset: u32, value: &[u8]) -> Result<(), ...
  function user_data (line 1104) | pub fn user_data(&self) -> &TTud {
  function user_data_mut (line 1109) | pub fn user_data_mut(&mut self) -> &mut TTud {
  function resume (line 1118) | pub fn resume(mut self, value: Option<crate::WasmValue>) {
  function fmt (line 1147) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  method drop (line 1155) | fn drop(&mut self) {

FILE: kernel/core/src/scheduler/processes/tests.rs
  function panic_duplicate_extrinsic (line 28) | fn panic_duplicate_extrinsic() {
  function basic (line 35) | fn basic() {
  function aborting_works (line 63) | fn aborting_works() {
  function many_processes (line 87) | fn many_processes() {

FILE: kernel/core/src/scheduler/processes/wakers.rs
  type Wakers (line 22) | pub struct Wakers {
    method register (line 28) | pub fn register(&self) -> Registration {
    method notify_one (line 38) | pub fn notify_one(&self) {
    method fmt (line 50) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type Registration (line 55) | pub struct Registration<'a> {
  function set_waker (line 61) | pub fn set_waker(&mut self, waker: &Waker) {
  function fmt (line 74) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  method drop (line 80) | fn drop(&mut self) {

FILE: kernel/core/src/scheduler/tests.rs
  function send_sync (line 25) | fn send_sync() {

FILE: kernel/core/src/scheduler/tests/basic_module.rs
  function basic_module (line 21) | fn basic_module() {

FILE: kernel/core/src/scheduler/tests/emit_not_available.rs
  function emit_not_available (line 22) | fn emit_not_available() {

FILE: kernel/core/src/scheduler/tests/trapping_module.rs
  function trapping_module (line 21) | fn trapping_module() {

FILE: kernel/core/src/scheduler/vm.rs
  type ProcessStateMachine (line 79) | pub struct ProcessStateMachine<T> {
  type ThreadState (line 102) | struct ThreadState<T> {
  type ThreadExecution (line 116) | enum ThreadExecution {
  type Thread (line 125) | pub struct Thread<'a, T> {
  type ExecOutcome (line 135) | pub enum ExecOutcome<'a, T> {
  type Trap (line 193) | pub struct Trap {
  type NewErr (line 199) | pub enum NewErr {
  type ThreadStartErr (line 227) | pub enum ThreadStartErr {
  type OutOfBoundsError (line 242) | pub struct OutOfBoundsError;
  type RunErr (line 246) | pub enum RunErr {
  function new (line 268) | pub fn new(
  function is_poisoned (line 384) | pub fn is_poisoned(&self) -> bool {
  function start_thread_by_id (line 396) | pub fn start_thread_by_id(
  function start_thread_by_name (line 412) | fn start_thread_by_name(
  function num_threads (line 483) | pub fn num_threads(&self) -> usize {
  function thread (line 496) | pub fn thread(&mut self, index: usize) -> Option<Thread<T>> {
  function into_user_datas (line 505) | pub fn into_user_datas(self) -> impl ExactSizeIterator<Item = T> {
  function read_memory (line 513) | pub fn read_memory(&self, offset: u32, size: u32) -> Result<Vec<u8>, Out...
  function write_memory (line 533) | pub fn write_memory(&mut self, offset: u32, value: &[u8]) -> Result<(), ...
  function fmt (line 562) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function fmt (line 571) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function run (line 583) | pub fn run(mut self, value: Option<WasmValue>) -> Result<ExecOutcome<'a,...
  function index (line 680) | pub fn index(&self) -> usize {
  function user_data (line 685) | pub fn user_data(&mut self) -> &mut T {
  function into_user_data (line 690) | pub fn into_user_data(self) -> &'a mut T {
  function fmt (line 699) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type InterruptedTrap (line 707) | struct InterruptedTrap {
    method fmt (line 713) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function starts_if_main (line 726) | fn starts_if_main() {
  function error_if_no_main (line 741) | fn error_if_no_main() {
  function main_executes (line 758) | fn main_executes() {
  function external_call_then_resume (line 781) | fn external_call_then_resume() {
  function poisoning_works (line 817) | fn poisoning_works() {

FILE: kernel/core/src/system.rs
  type System (line 46) | pub struct System<TExtr: extrinsics::Extrinsics> {
  type Interfaces (line 86) | struct Interfaces {
  type Interface (line 92) | enum Interface {
  type InterfaceRegistration (line 112) | struct InterfaceRegistration {
  type SystemBuilder (line 124) | pub struct SystemBuilder<TExtr: extrinsics::Extrinsics> {
  type ExecuteOut (line 142) | pub enum ExecuteOut<'a, TExtr: extrinsics::Extrinsics> {
  type ReadyToRun (line 151) | pub struct ReadyToRun<'a, TExtr: extrinsics::Extrinsics> {
  function run (line 160) | pub fn run(self) -> Option<SystemRunOutcome<'a, TExtr>> {
  type SystemRunOutcome (line 170) | pub enum SystemRunOutcome<'a, TExtr: extrinsics::Extrinsics> {
  type NativeInterfaceMessage (line 204) | pub struct NativeInterfaceMessage<'a, TExtr: extrinsics::Extrinsics> {
  function extract (line 217) | pub fn extract(self) -> EncodedMessage {
  function fmt (line 227) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function execute (line 237) | pub fn execute(&self, program: &[u8]) -> Result<Pid, NewErr> {
  function run (line 249) | pub async fn run<'a>(&'a self) -> ExecuteOut<'a, TExtr> {
  function inner_event (line 267) | fn inner_event<'a>(
  function answer_message (line 481) | pub fn answer_message(&self, message_id: MessageId, response: Result<Enc...
  function set_interface_handler (line 485) | fn set_interface_handler(
  function deliver (line 515) | fn deliver(&self, delivery: interfaces::MessageDelivery) -> Result<(), (...
  type KernelDebugMetricsRequest (line 552) | pub struct KernelDebugMetricsRequest<'a, TExtr: extrinsics::Extrinsics> {
  function respond (line 563) | pub fn respond(self, metrics: &str) {
  function fmt (line 613) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function new (line 626) | pub fn new(seed: [u8; 64]) -> Self {
  function with_native_interface_handler (line 642) | pub fn with_native_interface_handler(mut self, hash: InterfaceHash) -> S...
  function with_startup_process (line 655) | pub fn with_startup_process(mut self, process: Cow<'static, [u8]>) -> Se...
  function with_main_programs (line 663) | pub fn with_main_programs(self, hashes: impl IntoIterator<Item = ModuleH...
  function with_main_program (line 680) | pub fn with_main_program(self, hash: ModuleHash) -> Self {
  function build (line 688) | pub fn build(mut self) -> Result<System<TExtr>, NewErr> {
  function send_sync (line 718) | fn send_sync() {

FILE: kernel/core/src/system/interfaces.rs
  type Interfaces (line 23) | pub struct Interfaces {
    method new (line 67) | pub fn new() -> Self {
    method emit_interface_message (line 90) | pub fn emit_interface_message(
    method emit_message_query (line 155) | pub fn emit_message_query(
    method set_interface_handler (line 196) | pub fn set_interface_handler(
  type Inner (line 29) | struct Inner {
  type Interface (line 35) | enum Interface {
  type InterfaceRegistration (line 55) | struct InterfaceRegistration {
  method default (line 237) | fn default() -> Self {
  type MessageDelivery (line 243) | pub struct MessageDelivery {
  type EmitInterfaceMessage (line 257) | pub enum EmitInterfaceMessage {
  type RegistrationId (line 271) | pub struct RegistrationId(NonZeroU64);
    method from (line 274) | fn from(v: NonZeroU64) -> RegistrationId {
  method from (line 280) | fn from(v: RegistrationId) -> NonZeroU64 {

FILE: kernel/core/src/system/pending_answers.rs
  type PendingAnswers (line 26) | pub struct PendingAnswers {
    method new (line 37) | pub fn new() -> Self {
    method add (line 45) | pub fn add(&self, message_id: MessageId, answerer_pid: Pid) {
    method remove (line 50) | pub fn remove(&self, message_id: &MessageId, if_answerer_equal: &Pid) ...
    method drain_by_answerer (line 64) | pub fn drain_by_answerer(&self, answerer_pid: &Pid) -> Vec<MessageId> {
  type Inner (line 31) | struct Inner {
  method default (line 85) | fn default() -> Self {

FILE: kernel/standalone/build.rs
  function main (line 18) | fn main() {
  function gen_font (line 32) | fn gen_font() -> Vec<u8> {

FILE: kernel/standalone/src/arch.rs
  type TimerFuture (line 75) | pub struct TimerFuture(#[pin] plat::TimerFuture);
  type Output (line 78) | type Output = ();
  method poll (line 79) | fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
  type IrqFuture (line 86) | pub struct IrqFuture(#[pin] plat::IrqFuture);
  type Output (line 89) | type Output = ();
  method poll (line 90) | fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
  type PlatformSpecific (line 97) | pub struct PlatformSpecific(#[pin] plat::PlatformSpecificImpl);
    method num_cpus (line 101) | pub fn num_cpus(self: Pin<&Self>) -> NonZeroU32 {
    method write_log (line 107) | pub fn write_log(&self, message: &str) {
    method set_logger_method (line 115) | pub fn set_logger_method(&self, method: KernelLogMethod) {
    method monotonic_clock (line 123) | pub fn monotonic_clock(self: Pin<&Self>) -> u128 {
    method timer (line 131) | pub fn timer(self: Pin<&Self>, clock_value: u128) -> TimerFuture {
    method next_irq (line 140) | pub fn next_irq(self: Pin<&Self>) -> IrqFuture {
    method write_port_u8 (line 146) | pub unsafe fn write_port_u8(self: Pin<&Self>, port: u32, data: u8) -> ...
    method write_port_u16 (line 151) | pub unsafe fn write_port_u16(self: Pin<&Self>, port: u32, data: u16) -...
    method write_port_u32 (line 156) | pub unsafe fn write_port_u32(self: Pin<&Self>, port: u32, data: u32) -...
    method read_port_u8 (line 161) | pub unsafe fn read_port_u8(self: Pin<&Self>, port: u32) -> Result<u8, ...
    method read_port_u16 (line 166) | pub unsafe fn read_port_u16(self: Pin<&Self>, port: u32) -> Result<u16...
    method read_port_u32 (line 171) | pub unsafe fn read_port_u32(self: Pin<&Self>, port: u32) -> Result<u32...
  type PortErr (line 178) | pub enum PortErr {
    method fmt (line 186) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

FILE: kernel/standalone/src/arch/arm.rs
  type PlatformSpecificImpl (line 183) | pub struct PlatformSpecificImpl {
    method num_cpus (line 195) | pub fn num_cpus(self: Pin<&Self>) -> NonZeroU32 {
    method monotonic_clock (line 199) | pub fn monotonic_clock(self: Pin<&Self>) -> u128 {
    method timer (line 203) | pub fn timer(self: Pin<&Self>, deadline: u128) -> TimerFuture {
    method next_irq (line 207) | pub fn next_irq(self: Pin<&Self>) -> IrqFuture {
    method write_log (line 211) | pub fn write_log(&self, message: &str) {
    method set_logger_method (line 215) | pub fn set_logger_method(&self, method: KernelLogMethod) {
    method write_port_u8 (line 219) | pub unsafe fn write_port_u8(self: Pin<&Self>, _: u32, _: u8) -> Result...
    method write_port_u16 (line 223) | pub unsafe fn write_port_u16(self: Pin<&Self>, _: u32, _: u16) -> Resu...
    method write_port_u32 (line 227) | pub unsafe fn write_port_u32(self: Pin<&Self>, _: u32, _: u32) -> Resu...
    method read_port_u8 (line 231) | pub unsafe fn read_port_u8(self: Pin<&Self>, _: u32) -> Result<u8, Por...
    method read_port_u16 (line 235) | pub unsafe fn read_port_u16(self: Pin<&Self>, _: u32) -> Result<u16, P...
    method read_port_u32 (line 239) | pub unsafe fn read_port_u32(self: Pin<&Self>, _: u32) -> Result<u32, P...
  function from (line 189) | fn from(ps: PlatformSpecificImpl) -> Self {
  type TimerFuture (line 244) | pub type TimerFuture = time::TimerFuture;
  type IrqFuture (line 245) | pub type IrqFuture = future::Pending<()>;
  constant GPIO_BASE (line 247) | const GPIO_BASE: usize = 0x3F200000;
  constant UART0_BASE (line 248) | const UART0_BASE: usize = 0x3F201000;
  function init_uart (line 251) | pub fn init_uart() -> UartInfo {
  function delay (line 284) | fn delay(count: i32) {

FILE: kernel/standalone/src/arch/arm/executor.rs
  function block_on (line 30) | pub fn block_on<R>(future: impl Future<Output = R>) -> R {
  type LocalWake (line 73) | struct LocalWake {
  method wake_by_ref (line 78) | fn wake_by_ref(arc_self: &Arc<Self>) {

FILE: kernel/standalone/src/arch/arm/log.rs
  function panic (line 31) | fn panic(panic_info: &core::panic::PanicInfo) -> ! {

FILE: kernel/standalone/src/arch/arm/misc.rs
  function fmod (line 20) | pub extern "C" fn fmod(x: f64, y: f64) -> f64 {
  function fmodf (line 25) | pub extern "C" fn fmodf(x: f32, y: f32) -> f32 {
  function fmin (line 29) | pub extern "C" fn fmin(a: f64, b: f64) -> f64 {
  function fminf (line 33) | pub extern "C" fn fminf(a: f32, b: f32) -> f32 {
  function fmax (line 37) | pub extern "C" fn fmax(a: f64, b: f64) -> f64 {
  function fmaxf (line 41) | pub extern "C" fn fmaxf(a: f32, b: f32) -> f32 {
  function __aeabi_d2f (line 45) | pub extern "C" fn __aeabi_d2f(a: f64) -> f32 {

FILE: kernel/standalone/src/arch/arm/time_aarch64.rs
  type TimeControl (line 29) | pub struct TimeControl {}
    method init (line 34) | pub unsafe fn init() -> Arc<TimeControl> {
    method monotonic_clock (line 38) | pub fn monotonic_clock(self: &Arc<Self>) -> u128 {
    method timer (line 47) | pub fn timer(self: &Arc<Self>, deadline: u128) -> TimerFuture {
  type TimerFuture (line 31) | pub struct TimerFuture {}
  type Output (line 53) | type Output = ();
  method poll (line 55) | fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<()> {

FILE: kernel/standalone/src/arch/arm/time_arm.rs
  type TimeControl (line 46) | pub struct TimeControl {
    method init (line 99) | pub unsafe fn init() -> Arc<TimeControl> {
    method monotonic_clock (line 114) | pub fn monotonic_clock(self: &Arc<Self>) -> u128 {
    method timer (line 122) | pub fn timer(self: &Arc<Self>, deadline: u128) -> TimerFuture {
  type Timer (line 64) | struct Timer {
  type TimerFuture (line 73) | pub struct TimerFuture {
  constant CNTFRQ (line 89) | const CNTFRQ: u32 = 0x80000000;
  type Output (line 149) | type Output = ();
  method poll (line 151) | fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<()> {
  method drop (line 212) | fn drop(&mut self) {
  function physical_counter (line 229) | fn physical_counter() -> u64 {
  function update_hardware (line 239) | fn update_hardware(timers: &mut Vec<Timer>) {

FILE: kernel/standalone/src/arch/riscv.rs
  type PlatformSpecificImpl (line 162) | pub struct PlatformSpecificImpl {}
    method num_cpus (line 171) | pub fn num_cpus(self: Pin<&Self>) -> NonZeroU32 {
    method monotonic_clock (line 177) | pub fn monotonic_clock(self: Pin<&Self>) -> u128 {
    method monotonic_clock (line 203) | pub fn monotonic_clock(self: Pin<&Self>) -> u128 {
    method timer (line 213) | pub fn timer(self: Pin<&Self>, _deadline: u128) -> TimerFuture {
    method next_irq (line 217) | pub fn next_irq(self: Pin<&Self>) -> IrqFuture {
    method write_log (line 221) | pub fn write_log(&self, message: &str) {
    method set_logger_method (line 225) | pub fn set_logger_method(&self, method: KernelLogMethod) {
    method write_port_u8 (line 229) | pub unsafe fn write_port_u8(self: Pin<&Self>, _: u32, _: u8) -> Result...
    method write_port_u16 (line 233) | pub unsafe fn write_port_u16(self: Pin<&Self>, _: u32, _: u16) -> Resu...
    method write_port_u32 (line 237) | pub unsafe fn write_port_u32(self: Pin<&Self>, _: u32, _: u32) -> Resu...
    method read_port_u8 (line 241) | pub unsafe fn read_port_u8(self: Pin<&Self>, _: u32) -> Result<u8, Por...
    method read_port_u16 (line 245) | pub unsafe fn read_port_u16(self: Pin<&Self>, _: u32) -> Result<u16, P...
    method read_port_u32 (line 249) | pub unsafe fn read_port_u32(self: Pin<&Self>, _: u32) -> Result<u32, P...
  function from (line 165) | fn from(ps: PlatformSpecificImpl) -> Self {
  type TimerFuture (line 254) | pub type TimerFuture = future::Pending<()>;
  type IrqFuture (line 255) | pub type IrqFuture = future::Pending<()>;

FILE: kernel/standalone/src/arch/riscv/executor.rs
  function block_on (line 28) | pub fn block_on<R>(future: impl Future<Output = R>) -> R {
  type LocalWake (line 67) | struct LocalWake {
  method wake_by_ref (line 72) | fn wake_by_ref(arc_self: &Arc<Self>) {

FILE: kernel/standalone/src/arch/riscv/interrupts.rs
  function init (line 21) | pub unsafe fn init() -> Interrupts {
  type Interrupts (line 30) | pub struct Interrupts {}
  method drop (line 33) | fn drop(&mut self) {
  function trap_handler (line 42) | unsafe extern "C" fn trap_handler() {
  function trap_handler (line 97) | unsafe extern "C" fn trap_handler() {
  function trap_handler_rust (line 150) | unsafe extern "C" fn trap_handler_rust() {

FILE: kernel/standalone/src/arch/riscv/log.rs
  function panic (line 29) | fn panic(panic_info: &core::panic::PanicInfo) -> ! {

FILE: kernel/standalone/src/arch/riscv/misc.rs
  function fmod (line 19) | pub extern "C" fn fmod(x: f64, y: f64) -> f64 {
  function fmodf (line 23) | pub extern "C" fn fmodf(x: f32, y: f32) -> f32 {
  function fmin (line 27) | pub extern "C" fn fmin(a: f64, b: f64) -> f64 {
  function fminf (line 31) | pub extern "C" fn fminf(a: f32, b: f32) -> f32 {
  function fmax (line 35) | pub extern "C" fn fmax(a: f64, b: f64) -> f64 {
  function fmaxf (line 39) | pub extern "C" fn fmaxf(a: f32, b: f32) -> f32 {
  function __aeabi_d2f (line 43) | pub extern "C" fn __aeabi_d2f(a: f64) -> f32 {

FILE: kernel/standalone/src/arch/x86_64.rs
  constant DEFAULT_LOG_METHOD (line 57) | const DEFAULT_LOG_METHOD: KernelLogMethod = KernelLogMethod {
  function entry_point_step3 (line 84) | pub unsafe fn entry_point_step3<
  function find_free_memory_ranges (line 380) | fn find_free_memory_ranges<'a>(
  function init_com (line 485) | unsafe fn init_com(base_port: u16) -> Result<UartInfo, ()> {
  type PlatformSpecificImpl (line 511) | pub struct PlatformSpecificImpl {
    method num_cpus (line 529) | pub fn num_cpus(self: Pin<&Self>) -> NonZeroU32 {
    method monotonic_clock (line 533) | pub fn monotonic_clock(self: Pin<&Self>) -> u128 {
    method timer (line 537) | pub fn timer(self: Pin<&Self>, clock_value: u128) -> TimerFuture {
    method next_irq (line 547) | pub fn next_irq(self: Pin<&Self>) -> IrqFuture {
    method write_log (line 566) | pub fn write_log(&self, message: &str) {
    method set_logger_method (line 570) | pub fn set_logger_method(&self, method: KernelLogMethod) {
    method write_port_u8 (line 574) | pub unsafe fn write_port_u8(self: Pin<&Self>, port: u32, data: u8) -> ...
    method write_port_u16 (line 583) | pub unsafe fn write_port_u16(self: Pin<&Self>, port: u32, data: u16) -...
    method write_port_u32 (line 592) | pub unsafe fn write_port_u32(self: Pin<&Self>, port: u32, data: u32) -...
    method read_port_u8 (line 601) | pub unsafe fn read_port_u8(self: Pin<&Self>, port: u32) -> Result<u8, ...
    method read_port_u16 (line 609) | pub unsafe fn read_port_u16(self: Pin<&Self>, port: u32) -> Result<u16...
    method read_port_u32 (line 617) | pub unsafe fn read_port_u32(self: Pin<&Self>, port: u32) -> Result<u32...
  function from (line 523) | fn from(ps: PlatformSpecificImpl) -> Self {
  type TimerFuture (line 626) | pub type TimerFuture = apic::timers::TimerFuture;
  type IrqFuture (line 628) | pub struct IrqFuture {
  type Output (line 636) | type Output = ();
  method poll (line 638) | fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<()> {
  method drop (line 667) | fn drop(&mut self) {

FILE: kernel/standalone/src/arch/x86_64/acpi.rs
  function load_acpi_tables (line 27) | pub fn load_acpi_tables(
  function parse_acpi_tables (line 74) | pub fn parse_acpi_tables(
  type DummyAcpiHandler (line 100) | pub struct DummyAcpiHandler;
    method map_physical_region (line 103) | unsafe fn map_physical_region<T>(
    method unmap_physical_region (line 117) | fn unmap_physical_region<T>(_: &acpi::PhysicalMapping<DummyAcpiHandler...
  type DummyAmlHandler (line 123) | struct DummyAmlHandler;
    method read_u8 (line 126) | fn read_u8(&self, address: usize) -> u8 {
    method read_u16 (line 131) | fn read_u16(&self, address: usize) -> u16 {
    method read_u32 (line 136) | fn read_u32(&self, address: usize) -> u32 {
    method read_u64 (line 141) | fn read_u64(&self, address: usize) -> u64 {
    method write_u8 (line 146) | fn write_u8(&mut self, address: usize, value: u8) {
    method write_u16 (line 151) | fn write_u16(&mut self, address: usize, value: u16) {
    method write_u32 (line 156) | fn write_u32(&mut self, address: usize, value: u32) {
    method write_u64 (line 161) | fn write_u64(&mut self, address: usize, value: u64) {
    method read_io_u8 (line 166) | fn read_io_u8(&self, port: u16) -> u8 {
    method read_io_u16 (line 170) | fn read_io_u16(&self, port: u16) -> u16 {
    method read_io_u32 (line 174) | fn read_io_u32(&self, port: u16) -> u32 {
    method write_io_u8 (line 178) | fn write_io_u8(&self, port: u16, value: u8) {
    method write_io_u16 (line 184) | fn write_io_u16(&self, port: u16, value: u16) {
    method write_io_u32 (line 190) | fn write_io_u32(&self, port: u16, value: u32) {
    method read_pci_u8 (line 196) | fn read_pci_u8(&self, _: u16, _: u8, _: u8, _: u8, _: u16) -> u8 {
    method read_pci_u16 (line 200) | fn read_pci_u16(&self, _: u16, _: u8, _: u8, _: u8, _: u16) -> u16 {
    method read_pci_u32 (line 204) | fn read_pci_u32(&self, _: u16, _: u8, _: u8, _: u8, _: u16) -> u32 {
    method write_pci_u8 (line 208) | fn write_pci_u8(&self, _: u16, _: u8, _: u8, _: u8, _: u16, _: u8) {
    method write_pci_u16 (line 212) | fn write_pci_u16(&self, _: u16, _: u8, _: u8, _: u8, _: u16, _: u16) {
    method write_pci_u32 (line 216) | fn write_pci_u32(&self, _: u16, _: u8, _: u8, _: u8, _: u16, _: u32) {

FILE: kernel/standalone/src/arch/x86_64/ap_boot.rs
  type ApBootAlloc (line 38) | pub struct ApBootAlloc {
  function filter_build_ap_boot_alloc (line 61) | pub unsafe fn filter_build_ap_boot_alloc<'a>(
  type Error (line 91) | pub enum Error {
    method fmt (line 97) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function boot_associated_processor (line 126) | pub unsafe fn boot_associated_processor(
  type Template (line 336) | struct Template {
  function get_template (line 344) | fn get_template() -> Template {
  type Allocation (line 488) | struct Allocation<'a, T: alloc::alloc::Allocator> {
  function new (line 495) | fn new(alloc: &'a mut T, layout: Layout) -> Self {
  function as_mut_ptr (line 504) | fn as_mut_ptr(&mut self) -> *mut u8 {
  function size (line 508) | fn size(&self) -> usize {
  method drop (line 514) | fn drop(&mut self) {
  type ApAfterBootParam (line 520) | type ApAfterBootParam = *mut Box<dyn FnOnce() -> core::convert::Infallib...
  function ap_after_boot (line 527) | extern "C" fn ap_after_boot(to_exec: usize) -> ! {

FILE: kernel/standalone/src/arch/x86_64/apic/io_apic.rs
  type IoApicControl (line 51) | pub struct IoApicControl {
    method irqs (line 123) | pub fn irqs<'a>(&'a self) -> impl Iterator<Item = u8> + 'a {
    method irq (line 134) | pub fn irq(&mut self, irq: u8) -> Option<Irq> {
    method set_irq (line 151) | fn set_irq(&mut self, irq_offset: u8, destination: ApicId, destination...
    method write_register (line 177) | unsafe fn write_register(&mut self, reg_num: u8, value: u32) {
  type IoApicDescription (line 72) | pub struct IoApicDescription {
  type Irq (line 84) | pub struct Irq<'a> {
  function init_io_apic (line 98) | pub unsafe fn init_io_apic(config: IoApicDescription) -> IoApicControl {
  function set_destination (line 190) | pub fn set_destination(&mut self, destination: ApicId, destination_inter...

FILE: kernel/standalone/src/arch/x86_64/apic/io_apics.rs
  type IoApicsControl (line 28) | pub struct IoApicsControl {
    method isa_irq (line 103) | pub fn isa_irq(&mut self, isa_irq: u8) -> Option<Irq> {
    method irqs (line 118) | pub fn irqs<'a>(&'a self) -> impl Iterator<Item = u8> + 'a {
    method irq (line 128) | pub fn irq(&mut self, irq: u8) -> Option<Irq> {
  type IsaRedirectConfig (line 37) | pub struct IsaRedirectConfig {
  type Irq (line 45) | pub struct Irq<'a> {
  function init_io_apics (line 59) | pub unsafe fn init_io_apics(
  function init_from_acpi (line 81) | pub unsafe fn init_from_acpi(info: &acpi::platform::interrupt::Apic) -> ...
  function set_destination (line 147) | pub fn set_destination(&mut self, destination: ApicId, destination_inter...

FILE: kernel/standalone/src/arch/x86_64/apic/local.rs
  type LocalApicsControl (line 30) | pub struct LocalApicsControl {
    method init_local (line 151) | pub unsafe fn init_local(&self) {
    method current_apic_id (line 180) | pub fn current_apic_id(&self) -> ApicId {
    method is_tsc_deadline_supported (line 185) | pub fn is_tsc_deadline_supported(&self) -> bool {
    method set_local_timer (line 195) | pub fn set_local_timer(&self, timer: Timer) {
    method send_interprocessor_interrupt (line 252) | pub fn send_interprocessor_interrupt(&self, target_apic_id: ApicId, ve...
    method send_interprocessor_init (line 264) | pub fn send_interprocessor_init(&self, target_apic_id: ApicId) {
    method send_interprocessor_sipi (line 276) | pub fn send_interprocessor_sipi(&self, target_apic_id: ApicId, boot_fn...
  type ApicId (line 42) | pub struct ApicId(u8);
    method from_unchecked (line 133) | pub const unsafe fn from_unchecked(val: u8) -> Self {
    method get (line 138) | pub const fn get(&self) -> u8 {
  function init (line 58) | pub unsafe fn init() -> LocalApicsControl {
  function end_of_interrupt (line 98) | pub unsafe fn end_of_interrupt() {
  type Timer (line 103) | pub enum Timer {
  constant APIC_BASE_ADDR (line 290) | const APIC_BASE_ADDR: usize = 0xfee00000;
  function send_ipi_inner (line 293) | fn send_ipi_inner(target_apic_id: ApicId, delivery: u8, vector: u8) {
  function current_apic_id (line 324) | fn current_apic_id() -> ApicId {
  function is_apic_supported (line 334) | fn is_apic_supported() -> bool {
  function is_tsc_supported (line 342) | fn is_tsc_supported() -> bool {
  function is_tsc_deadline_supported (line 350) | fn is_tsc_deadline_supported() -> bool {

FILE: kernel/standalone/src/arch/x86_64/apic/pic.rs
  function init_and_disable_pic (line 38) | pub unsafe fn init_and_disable_pic() {

FILE: kernel/standalone/src/arch/x86_64/apic/timers.rs
  function init (line 112) | pub async fn init(
  type Timers (line 153) | pub struct Timers {
    method register_timer_after (line 225) | pub fn register_timer_after(self: &Arc<Self>, after: Duration) -> Time...
    method register_timer_at (line 231) | pub fn register_timer_at(self: &Arc<Self>, when: Duration) -> TimerFut...
    method monotonic_clock (line 259) | pub fn monotonic_clock(&self) -> Duration {
    method fmt (line 281) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type Shared (line 189) | struct Shared {
  type ActiveTimerEntry (line 201) | struct ActiveTimerEntry {
  type TimerEntry (line 214) | struct TimerEntry {
  type TimerFuture (line 290) | pub struct TimerFuture {
    method fmt (line 439) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type Output (line 301) | type Output = ();
  method poll (line 303) | fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<()> {
  type TimerWaker (line 447) | struct TimerWaker {
    method wake_by_ref (line 453) | fn wake_by_ref(arc_self: &Arc<Self>) {
  function configure_apic (line 547) | fn configure_apic(
  function is_tsc_supported (line 614) | fn is_tsc_supported() -> bool {

FILE: kernel/standalone/src/arch/x86_64/apic/tsc_sync.rs
  function tsc_sync (line 64) | pub fn tsc_sync() -> (TscSyncSrc, TscSyncDst) {
  type TscSyncSrc (line 78) | pub struct TscSyncSrc {
    method sync (line 103) | pub fn sync(&mut self) {
    method fmt (line 124) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type TscSyncDst (line 83) | pub struct TscSyncDst {
    method sync (line 136) | pub fn sync(&mut self) {
    method fmt (line 196) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type Shared (line 87) | struct Shared {
  function volatile_rdtsc (line 206) | pub fn volatile_rdtsc() -> u64 {

FILE: kernel/standalone/src/arch/x86_64/boot.rs
  constant MAIN_PROCESSOR_STACK_SIZE (line 233) | pub const MAIN_PROCESSOR_STACK_SIZE: usize = 0x800000;
  type Stack (line 241) | pub struct Stack([u8; MAIN_PROCESSOR_STACK_SIZE]);
  type PagingEntry (line 250) | pub struct PagingEntry([u8; 0x1000]);
  function fmod (line 263) | pub extern "C" fn fmod(a: f64, b: f64) -> f64 {
  function fmodf (line 267) | pub extern "C" fn fmodf(a: f32, b: f32) -> f32 {
  function fmin (line 271) | pub extern "C" fn fmin(a: f64, b: f64) -> f64 {
  function fminf (line 275) | pub extern "C" fn fminf(a: f32, b: f32) -> f32 {
  function fmax (line 279) | pub extern "C" fn fmax(a: f64, b: f64) -> f64 {
  function fmaxf (line 283) | pub extern "C" fn fmaxf(a: f32, b: f32) -> f32 {

FILE: kernel/standalone/src/arch/x86_64/executor.rs
  type Executor (line 33) | pub struct Executor {
    method new (line 43) | pub fn new(local_apic: &'static LocalApicsControl) -> Self {
    method block_on (line 53) | pub fn block_on<R>(&self, future: impl Future<Output = R>) -> R {
  type Waker (line 134) | struct Waker {
  method wake_by_ref (line 156) | fn wake_by_ref(arc_self: &Arc<Self>) {

FILE: kernel/standalone/src/arch/x86_64/gdt.rs
  type Gdt (line 54) | pub struct Gdt([u64; 2]);
  type GdtPtr (line 81) | pub struct GdtPtr(GdtPtr2);
  type GdtPtr2 (line 86) | struct GdtPtr2 {

FILE: kernel/standalone/src/arch/x86_64/interrupts.rs
  function reserve_any_vector (line 66) | pub fn reserve_any_vector(min_vector: u8) -> Result<ReservedInterruptVec...
  type ReservedInterruptVector (line 86) | pub struct ReservedInterruptVector {
    method interrupt_num (line 118) | pub fn interrupt_num(&self) -> u8 {
    method register_waker (line 129) | pub fn register_waker(&self, waker: &Waker) {
    method fmt (line 136) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
  type ReserveErr (line 92) | pub enum ReserveErr {
  function process_wakers (line 99) | pub fn process_wakers() {
  function load_idt (line 111) | pub fn load_idt() {
  method drop (line 144) | fn drop(&mut self) {
  function int0 (line 456) | extern "x86-interrupt" fn int0(frame: idt::InterruptStackFrame) {
  function int1 (line 460) | extern "x86-interrupt" fn int1(_frame: idt::InterruptStackFrame) {
  function int2 (line 488) | extern "x86-interrupt" fn int2(frame: idt::InterruptStackFrame) {
  function int3 (line 492) | extern "x86-interrupt" fn int3(frame: idt::InterruptStackFrame) {
  function int4 (line 496) | extern "x86-interrupt" fn int4(frame: idt::InterruptStackFrame) {
  function int5 (line 500) | extern "x86-interrupt" fn int5(frame: idt::InterruptStackFrame) {
  function int6 (line 504) | extern "x86-interrupt" fn int6(frame: idt::InterruptStackFrame) {
  function int7 (line 508) | extern "x86-interrupt" fn int7(frame: idt::InterruptStackFrame) {
  function int8 (line 512) | extern "x86-interrupt" fn int8(_frame: idt::InterruptStackFrame, _: u64)...
  function int9 (line 524) | extern "x86-interrupt" fn int9(frame: idt::InterruptStackFrame) {
  function int10 (line 529) | extern "x86-interrupt" fn int10(frame: idt::InterruptStackFrame, _: u64) {
  function int11 (line 533) | extern "x86-interrupt" fn int11(frame: idt::InterruptStackFrame, _: u64) {
  function int12 (line 537) | extern "x86-interrupt" fn int12(frame: idt::InterruptStackFrame, _: u64) {
  function int13 (line 541) | extern "x86-interrupt" fn int13(frame: idt::InterruptStackFrame, _: u64) {
  function int14 (line 545) | extern "x86-interrupt" fn int14(frame: idt::InterruptStackFrame, _: idt:...
  function int16 (line 549) | extern "x86-interrupt" fn int16(frame: idt::InterruptStackFrame) {
  function int17 (line 553) | extern "x86-interrupt" fn int17(frame: idt::InterruptStackFrame, _: u64) {
  function int18 (line 557) | extern "x86-interrupt" fn int18(frame: idt::InterruptStackFrame) -> ! {
  function int19 (line 561) | extern "x86-interrupt" fn int19(frame: idt::InterruptStackFrame) {
  function int20 (line 565) | extern "x86-interrupt" fn int20(frame: idt::InterruptStackFrame) {
  function int30 (line 569) | extern "x86-interrupt" fn int30(frame: idt::InterruptStackFrame, _: u64) {

FILE: kernel/standalone/src/arch/x86_64/panic.rs
  function panic (line 26) | fn panic(panic_info: &core::panic::PanicInfo) -> ! {

FILE: kernel/standalone/src/arch/x86_64/pit.rs
  type PitControl (line 49) | pub struct PitControl {
    method timer (line 94) | pub fn timer(&mut self, after: Duration) -> PitFuture {
  type PitFuture (line 55) | pub struct PitFuture<'a> {
  function init_pit (line 74) | pub fn init_pit(
  type Output (line 128) | type Output = ();
  method poll (line 130) | fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<()> {
  function channel0_one_shot (line 162) | fn channel0_one_shot(ticks: u16) {
  type RaisingArc (line 174) | struct RaisingArc {
  method wake_by_ref (line 180) | fn wake_by_ref(arc_self: &Arc<Self>) {

FILE: kernel/standalone/src/hardware.rs
  type HardwareHandler (line 35) | pub struct HardwareHandler {
    method new (line 45) | pub fn new(platform_specific: Pin<Arc<PlatformSpecific>>) -> Self {
    method process_destroyed (line 52) | pub fn process_destroyed(&self, pid: Pid) {
    method interface_message (line 56) | pub fn interface_message<TExtr: Extrinsics>(
  function perform_operation (line 118) | unsafe fn perform_operation(

FILE: kernel/standalone/src/kernel.rs
  type Kernel (line 41) | pub struct Kernel {
    method init (line 67) | pub fn init(platform_specific: Pin<Arc<PlatformSpecific>>) -> Self {
    method run (line 127) | pub async fn run(&self, cpu_index: usize) -> ! {
    method handle_event (line 206) | fn handle_event(
    method report_kernel_metrics (line 311) | fn report_kernel_metrics(
  type CpuCounter (line 56) | struct CpuCounter {

FILE: kernel/standalone/src/klog/logger.rs
  type KLogger (line 24) | pub struct KLogger {
    method disabled (line 38) | pub const fn disabled() -> KLogger {
    method log_printer (line 52) | pub fn log_printer<'a>(&'a self) -> impl fmt::Write + 'a {
    method panic_printer (line 64) | pub fn panic_printer<'a>(&'a self) -> impl fmt::Write + 'a {
    method set_method (line 72) | pub fn set_method(&self, method: KernelLogMethod) {
  type Inner (line 28) | enum Inner {
  type Printer (line 90) | struct Printer<'a> {
  function write_str (line 96) | fn write_str(&mut self, message: &str) -> fmt::Result {

FILE: kernel/standalone/src/klog/native.rs
  type KernelLogNativeProgram (line 25) | pub struct KernelLogNativeProgram {
    method new (line 34) | pub fn new(platform_specific: Pin<Arc<PlatformSpecific>>) -> Self {
    method interface_message (line 41) | pub fn interface_message<TExtr: Extrinsics>(&self, message: NativeInte...

FILE: kernel/standalone/src/klog/video.rs
  type Terminal (line 19) | pub struct Terminal {
    method new (line 33) | pub const unsafe fn new(framebuffer: FramebufferInfo) -> Terminal {
    method printer (line 51) | pub fn printer<'a>(&'a mut self, color: [u8; 3]) -> impl fmt::Write + ...
    method print (line 74) | fn print(&mut self, message: &str, color: [u8; 3]) {
    method cursor_mem_address (line 98) | fn cursor_mem_address(&self) -> *mut u8 {
    method print_at_cursor (line 113) | fn print_at_cursor(&mut self, chr: u8, color: [u8; 3]) {
    method line_down (line 166) | fn line_down(&mut self) {
    method carriage_return (line 176) | fn carriage_return(&mut self) {
  constant FONT_DATA (line 189) | const FONT_DATA: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/font....
  function mix (line 191) | fn mix(v1: u8, v2: u8) -> u8 {
  function copy_row_up (line 196) | unsafe fn copy_row_up(info: &FramebufferInfo, rows_up: u32) {
  function clear_screen (line 239) | unsafe fn clear_screen(info: &FramebufferInfo) {
  function write_rgb_color (line 268) | unsafe fn write_rgb_color(dst: *mut u8, info: &FramebufferInfo, color: [...
  function term_color (line 317) | fn term_color(color: [u8; 3]) -> u8 {

FILE: kernel/standalone/src/lib.rs
  function run (line 82) | pub async fn run(platform_specific: Pin<Arc<arch::PlatformSpecific>>) ->...

FILE: kernel/standalone/src/mem_alloc.rs
  function initialize (line 37) | pub unsafe fn initialize(ranges: impl Iterator<Item = Range<usize>>) {

FILE: kernel/standalone/src/pci/native.rs
  type PciNativeProgram (line 32) | pub struct PciNativeProgram {
    method new (line 58) | pub fn new(devices: pci::PciDevices, platform_specific: Pin<Arc<Platfo...
    method next_response (line 72) | pub async fn next_response(&self) -> (MessageId, EncodedMessage) {
    method interface_message (line 107) | pub fn interface_message<TExtr: Extrinsics>(
  type LockedDevice (line 48) | struct LockedDevice {

FILE: kernel/standalone/src/pci/pci.rs
  function init_cam_pci (line 32) | pub unsafe fn init_cam_pci() -> PciDevices {
  type PciDevices (line 39) | pub struct PciDevices {
    method devices (line 67) | pub fn devices(&self) -> impl Iterator<Item = Device> {
  type DeviceBdf (line 46) | struct DeviceBdf {
  type DeviceInfo (line 53) | struct DeviceInfo {
  type Device (line 76) | pub struct Device<'a> {
  function set_command (line 83) | pub fn set_command(&mut self, bus_master: bool, memory_space: bool, io_s...
  function set_command (line 97) | pub fn set_command(&mut self, _: bool, _: bool, _: bool) {
  function bus (line 101) | pub fn bus(&self) -> u8 {
  function device (line 105) | pub fn device(&self) -> u8 {
  function function (line 109) | pub fn function(&self) -> u8 {
  function vendor_id (line 113) | pub fn vendor_id(&self) -> u16 {
  function device_id (line 117) | pub fn device_id(&self) -> u16 {
  function class_code (line 121) | pub fn class_code(&self) -> u8 {
  function subclass (line 125) | pub fn subclass(&self) -> u8 {
  function prog_if (line 129) | pub fn prog_if(&self) -> u8 {
  function revision_id (line 133) | pub fn revision_id(&self) -> u8 {
  function base_address_registers (line 137) | pub fn base_address_registers(&self) -> impl Iterator<Item = BaseAddress...
  type BaseAddressRegister (line 146) | pub enum BaseAddressRegister {
  function scan_all_buses (line 158) | fn scan_all_buses() -> Vec<DeviceInfo> {
  function scan_all_buses (line 164) | fn scan_all_buses() -> Vec<DeviceInfo> {
  function scan_bus (line 197) | fn scan_bus(bus: u8) -> impl Iterator<Item = ScanResult> {
  function scan_device (line 207) | fn scan_device(bus: u8, device: u8) -> impl Iterator<Item = ScanResult> {
  type ScanResult (line 241) | enum ScanResult {
  function scan_function (line 259) | fn scan_function(bdf: &DeviceBdf) -> Option<ScanResult> {
  function pci_cfg_read_u32 (line 365) | fn pci_cfg_read_u32(bdf: &DeviceBdf, offset: u8) -> u32 {
  function pci_cfg_write_u32 (line 387) | fn pci_cfg_write_u32(bdf: &DeviceBdf, offset: u8, data: u32) {
  function pci_cfg_prepare_port (line 400) | fn pci_cfg_prepare_port(bdf: &DeviceBdf, offset: u8) {

FILE: kernel/standalone/src/random/native.rs
  type RandomNativeProgram (line 31) | pub struct RandomNativeProgram {
    method new (line 40) | pub fn new(platform_specific: Pin<Arc<PlatformSpecific>>) -> Self {
    method fill_bytes (line 48) | pub fn fill_bytes(&self, out: &mut [u8]) {
    method interface_message (line 59) | pub fn interface_message<TExtr: Extrinsics>(

FILE: kernel/standalone/src/random/rng.rs
  type KernelRng (line 49) | pub struct KernelRng {
    method new (line 56) | pub fn new(platform_specific: Pin<Arc<PlatformSpecific>>) -> KernelRng {
  method next_u32 (line 93) | fn next_u32(&mut self) -> u32 {
  method next_u64 (line 97) | fn next_u64(&mut self) -> u64 {
  method fill_bytes (line 101) | fn fill_bytes(&mut self, dest: &mut [u8]) {
  method try_fill_bytes (line 105) | fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::E...
  function add_hardware_entropy (line 113) | fn add_hardware_entropy(hasher: &mut blake3::Hasher) {
  function add_hardware_entropy (line 132) | fn add_hardware_entropy(_: &mut blake3::Hasher) {}

FILE: kernel/standalone/src/time.rs
  type TimeHandler (line 31) | pub struct TimeHandler {
    method new (line 40) | pub fn new(platform_specific: Pin<Arc<PlatformSpecific>>) -> Self {
    method interface_message (line 47) | pub fn interface_message<TExtr: Extrinsics>(
    method next_response (line 72) | pub async fn next_response(&self) -> (MessageId, EncodedMessage) {

FILE: programs/compositor/src/lib.rs
  type Compositor (line 55) | pub struct Compositor<TFbId, TOutId, TFb, TOut> {
  type Framebuffer (line 62) | struct Framebuffer<TFb> {
  type VideoOutput (line 69) | struct VideoOutput<TOut> {
  function with_seed (line 80) | pub fn with_seed(seed: [u8; 64]) -> Self {
  function add_video_output (line 104) | pub fn add_video_output(
  function video_output_by_id (line 150) | pub fn video_output_by_id(
  function video_outputs (line 164) | pub fn video_outputs(&self) -> impl ExactSizeIterator<Item = &TOutId> {
  function add_framebuffer (line 168) | pub fn add_framebuffer(
  function framebuffer_by_id (line 218) | pub fn framebuffer_by_id(
  function framebuffers (line 232) | pub fn framebuffers(&self) -> impl ExactSizeIterator<Item = &TFbId> {
  function next_frame (line 237) | pub fn next_frame(&mut self) {
  function desktop_pixel (line 242) | fn desktop_pixel(&self, x: u32, y: u32) -> [u8; 3] {
  function blend (line 276) | fn blend(a: [u8; 4], b: [u8; 3]) -> [u8; 3] {
  type FramebufferAccess (line 291) | pub struct FramebufferAccess<'a, TFbId, TOutId, TFb, TOut> {
  function remove (line 300) | pub fn remove(self) -> TFb {
  function user_data (line 304) | pub fn user_data(&self) -> &TFb {
  function user_data_mut (line 308) | pub fn user_data_mut(&mut self) -> &mut TFb {
  function set_content (line 321) | pub fn set_content(&mut self, x_range: Range<u32>, y_range: Range<u32>, ...
  type VideoOutputAccess (line 325) | pub struct VideoOutputAccess<'a, TFbId, TOutId, TFb, TOut> {
  function remove (line 334) | pub fn remove(self) -> TOut {
  function user_data (line 342) | pub fn user_data(&self) -> &TOut {
  function user_data_mut (line 346) | pub fn user_data_mut(&mut self) -> &mut TOut {
  function drain_pending_changes (line 355) | pub fn drain_pending_changes<'b: 'a>(&'b mut self) -> impl Iterator<Item...
  type PendingChange (line 384) | pub struct PendingChange {
  type Format (line 394) | pub enum Format {
  function convert_format (line 398) | fn convert_format(pixel: [u8; 3], format: &Format) -> impl Iterator<Item...

FILE: programs/compositor/src/main.rs
  function main (line 27) | fn main() {
  function async_main (line 31) | async fn async_main() {

FILE: programs/compositor/src/rect.rs
  type Rect (line 19) | pub struct Rect {
    method intersection (line 30) | pub fn intersection(&self, other: &Rect) -> Option<Rect> {
  function line_intersect (line 43) | fn line_intersect(base: u32, len: u32, other_base: u32, other_len: u32) ...

FILE: programs/diagnostics-http-server/src/main.rs
  function main (line 21) | fn main() {
  type Accept (line 85) | struct Accept {
    type Conn (line 90) | type Conn = redshirt_tcp_interface::TcpStream;
    type Error (line 91) | type Error = std::io::Error;
    method poll_accept (line 93) | fn poll_accept(
  type Executor (line 106) | struct Executor {
    method execute (line 111) | fn execute(&self, future: T) {

FILE: programs/dummy-system-time/src/main.rs
  function main (line 20) | fn main() {
  function async_main (line 24) | async fn async_main() {

FILE: programs/e1000/src/device.rs
  type Device (line 44) | pub struct Device {
    method reset (line 143) | pub async unsafe fn reset(regs_base_address: u64) -> Result<DeviceProt...
    method mac_address (line 177) | pub fn mac_address(&self) -> [u8; 6] {
    method read_one_incoming (line 187) | pub async unsafe fn read_one_incoming(&self) -> Option<Vec<u8>> {
    method send_packet (line 255) | pub async unsafe fn send_packet<T>(&self, packet: T) -> Result<(), T>
    method on_interrupt (line 342) | pub async unsafe fn on_interrupt(&self) -> Vec<Vec<u8>> {
    method fmt (line 358) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type TransmitState (line 72) | struct TransmitState {
  constant REGS_CTRL (line 87) | const REGS_CTRL: u64 = 0x0;
  constant REGS_STATUS (line 88) | const REGS_STATUS: u64 = 0x8;
  constant REGS_FCAL (line 89) | const REGS_FCAL: u64 = 0x28;
  constant REGS_FCAH (line 90) | const REGS_FCAH: u64 = 0x2c;
  constant REGS_FCT (line 91) | const REGS_FCT: u64 = 0x30;
  constant REGS_ICR (line 92) | const REGS_ICR: u64 = 0xc0;
  constant REGS_ITR (line 93) | const REGS_ITR: u64 = 0xc4;
  constant REGS_IMS (line 94) | const REGS_IMS: u64 = 0xd0;
  constant REGS_IMC (line 95) | const REGS_IMC: u64 = 0xd8;
  constant REGS_RCTL (line 96) | const REGS_RCTL: u64 = 0x100;
  constant REGS_FCTTV (line 97) | const REGS_FCTTV: u64 = 0x170;
  constant REGS_TCTL (line 98) | const REGS_TCTL: u64 = 0x400;
  constant REGS_RDBAL (line 99) | const REGS_RDBAL: u64 = 0x2800;
  constant REGS_RDBAH (line 100) | const REGS_RDBAH: u64 = 0x2804;
  constant REGS_RDLEN (line 101) | const REGS_RDLEN: u64 = 0x2808;
  constant REGS_RDH (line 102) | const REGS_RDH: u64 = 0x2810;
  constant REGS_RDT (line 103) | const REGS_RDT: u64 = 0x2818;
  constant REGS_RDTR (line 104) | const REGS_RDTR: u64 = 0x2820;
  constant REGS_TDBAL (line 105) | const REGS_TDBAL: u64 = 0x3800;
  constant REGS_TDBAH (line 106) | const REGS_TDBAH: u64 = 0x3804;
  constant REGS_TDLEN (line 107) | const REGS_TDLEN: u64 = 0x3808;
  constant REGS_TDH (line 108) | const REGS_TDH: u64 = 0x3810;
  constant REGS_TDT (line 109) | const REGS_TDT: u64 = 0x3818;
  constant REGS_MTA_BASE (line 110) | const REGS_MTA_BASE: u64 = 0x5200;
  constant REGS_RAL (line 111) | const REGS_RAL: u64 = 0x5400;
  constant REGS_RAH (line 112) | const REGS_RAH: u64 = 0x5404;
  type ReceiveDescriptor (line 116) | struct ReceiveDescriptor {
  type TransmitDescriptor (line 130) | struct TransmitDescriptor {
  method drop (line 367) | fn drop(&mut self) {
  type InitErr (line 377) | pub enum InitErr {
  type DevicePrototype (line 383) | pub struct DevicePrototype {
    method init (line 390) | pub async fn init(self) -> Result<Device, InitErr> {
    method fmt (line 677) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  method drop (line 685) | fn drop(&mut self) {

FILE: programs/e1000/src/main.rs
  function main (line 30) | fn main() {
  function async_main (line 34) | async fn async_main() {

FILE: programs/hello-world/src/main.rs
  function main (line 16) | fn main() {

FILE: programs/log-to-kernel/src/main.rs
  function main (line 21) | fn main() {
  function async_main (line 25) | async fn async_main() -> ! {

FILE: programs/network-manager/src/interface.rs
  type NetInterfaceState (line 61) | pub struct NetInterfaceState<TSockUd> {
  type Config (line 91) | pub struct Config {
  type ConfigIpAddr (line 100) | pub enum ConfigIpAddr {
  type NetInterfaceEvent (line 127) | pub enum NetInterfaceEvent<'a, TSockUd> {
  type NetInterfaceEventStatic (line 165) | enum NetInterfaceEventStatic {
  type TcpSocket (line 180) | pub struct TcpSocket<'a, TSockUd> {
  type SocketState (line 188) | struct SocketState<TSockUd> {
  type ConnectError (line 201) | pub enum ConnectError {
  type SocketId (line 214) | pub struct SocketId(smoltcp::socket::SocketHandle);
  function new (line 218) | pub async fn new(config: Config) -> Self {
  function local_ip_prefix (line 309) | pub fn local_ip_prefix(&self) -> Option<(IpAddr, u8)> {
  function build_tcp_socket (line 326) | pub fn build_tcp_socket(
  function tcp_socket_by_id (line 391) | pub fn tcp_socket_by_id(&mut self, id: SocketId) -> Option<TcpSocket<TSo...
  function read_ethernet_cable_out (line 405) | pub fn read_ethernet_cable_out(&mut self) -> Vec<u8> {
  function inject_interface_data (line 414) | pub fn inject_interface_data(&mut self, data: impl AsRef<[u8]>) {
  function next_event (line 423) | pub async fn next_event<'a>(&'a mut self) -> NetInterfaceEvent<'a, TSock...
  function next_event_static (line 456) | async fn next_event_static(&mut self) -> NetInterfaceEventStatic {
  function fmt (line 647) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function id (line 654) | pub fn id(&self) -> SocketId {
  function close (line 665) | pub fn close(&mut self) -> Result<(), ()> {
  function close_called (line 684) | pub fn close_called(&self) -> bool {
  function closed (line 696) | pub fn closed(&self) -> bool {
  function reset (line 705) | pub fn reset(self) {
  function read (line 731) | pub fn read(&mut self) -> Vec<u8> {
  function set_write_buffer (line 764) | pub fn set_write_buffer(&mut self, mut buffer: Vec<u8>) -> Result<(), Ve...
  function user_data (line 789) | pub fn user_data(&self) -> &TSockUd {
  function into_user_data (line 795) | pub fn into_user_data(self) -> &'a mut TSockUd {
  function user_data_mut (line 801) | pub fn user_data_mut(&mut self) -> &mut TSockUd {
  function fmt (line 808) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function now (line 814) | async fn now() -> smoltcp::time::Instant {
  type RawDevice (line 820) | struct RawDevice {
    type RxToken (line 829) | type RxToken = RawDeviceRxToken<'a>;
    type TxToken (line 830) | type TxToken = RawDeviceTxToken<'a>;
    method receive (line 832) | fn receive(&'a mut self) -> Option<(Self::RxToken, Self::TxToken)> {
    method transmit (line 850) | fn transmit(&'a mut self) -> Option<Self::TxToken> {
    method capabilities (line 860) | fn capabilities(&self) -> phy::DeviceCapabilities {
  type RawDeviceRxToken (line 874) | struct RawDeviceRxToken<'a> {
  function consume (line 879) | fn consume<R, F>(mut self, _timestamp: Instant, f: F) -> Result<R, smolt...
  type RawDeviceTxToken (line 889) | struct RawDeviceTxToken<'a> {
  function consume (line 894) | fn consume<R, F>(mut self, _timestamp: Instant, len: usize, f: F) -> Res...

FILE: programs/network-manager/src/main.rs
  function main (line 30) | fn main() {
  type SocketState (line 35) | struct SocketState {
  function async_main (line 42) | async fn async_main() {

FILE: programs/network-manager/src/manager.rs
  type NetworkManager (line 34) | pub struct NetworkManager<TIfId, TIfUser, TSockUd> {
  type SocketState (line 45) | enum SocketState<TIfId, TSockUd> {
  type Device (line 65) | struct Device<TIfUser, TSockUd> {
  type NetworkManagerEvent (line 74) | pub enum NetworkManagerEvent<'a, TIfId, TIfUser, TSockUd> {
  type NetworkManagerEventStatic (line 100) | enum NetworkManagerEventStatic {
  type SocketId (line 111) | pub struct SocketId {
  function new (line 120) | pub fn new() -> Self {
  function build_tcp_socket (line 131) | pub fn build_tcp_socket(
  function tcp_socket_by_id (line 185) | pub fn tcp_socket_by_id(
  function register_interface (line 201) | pub async fn register_interface<'a>(
  function interface_by_id (line 237) | pub fn interface_by_id(&mut self, id: TIfId) -> Option<Interface<TIfId, ...
  function next_event (line 246) | pub async fn next_event<'a>(&'a mut self) -> NetworkManagerEvent<'a, TIf...
  function next_event_inner (line 347) | async fn next_event_inner<'a>(&'a mut self) -> (TIfId, NetworkManagerEve...
  function fmt (line 402) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type Interface (line 409) | pub struct Interface<'a, TIfId, TIfUser, TSockUd> {
  function unregister (line 418) | pub fn unregister(self) {
  function user_data (line 427) | pub fn user_data(&mut self) -> &mut TIfUser {
  function read_ethernet_cable_out (line 434) | pub fn read_ethernet_cable_out(&mut self) -> Vec<u8> {
  function inject_data (line 444) | pub fn inject_data(&mut self, data: impl AsRef<[u8]>) {
  function fmt (line 458) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type TcpSocket (line 465) | pub struct TcpSocket<'a, TIfId, TIfUser, TSockUd> {
  function id (line 475) | pub fn id(&self) -> SocketId {
  function user_data_mut (line 480) | pub fn user_data_mut(&mut self) -> &mut TSockUd {
  function read (line 508) | pub fn read(&mut self) -> Vec<u8> {
  function set_write_buffer (line 534) | pub fn set_write_buffer(&mut self, buffer: Vec<u8>) -> Result<(), Vec<u8...
  function close (line 559) | pub fn close(&mut self) -> Result<(), ()> {
  function close_called (line 578) | pub fn close_called(&mut self) -> bool {
  function closed (line 600) | pub fn closed(&mut self) -> bool {
  function reset (line 619) | pub fn reset(self) {
  function fmt (line 642) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

FILE: programs/network-manager/src/port_assign.rs
  type PortAssign (line 23) | pub struct PortAssign {
    method new (line 29) | pub fn new() -> PortAssign {
    method reserve (line 36) | pub fn reserve(&mut self, port: u16) -> Result<(), ()> {
    method reserve_any (line 45) | pub fn reserve_any(&mut self, min: u16) -> Option<u16> {
    method free (line 61) | pub fn free(&mut self, port: u16) -> Result<(), ()> {

FILE: programs/pci-printer/build.rs
  function main (line 19) | fn main() {

FILE: programs/pci-printer/src/main.rs
  function main (line 25) | fn main() {
  function async_main (line 30) | async fn async_main() {
  function show_class_code (line 58) | fn show_class_code(class_code: u8, subclass: u8) -> Cow<'static, str> {

FILE: programs/rpi-framebuffer/src/mailbox.rs
  type Message (line 23) | pub struct Message {
    method new (line 37) | pub fn new(channel: u8, data: u32) -> Message {
    method channel (line 46) | pub fn channel(&self) -> u8 {
    method data (line 51) | pub fn data(&self) -> u32 {
  constant BASE_IO_PERIPH (line 56) | const BASE_IO_PERIPH: u64 = 0x3f000000;
  constant MAILBOX_BASE (line 57) | const MAILBOX_BASE: u64 = BASE_IO_PERIPH + 0xb880;
  function read_mailbox (line 60) | pub async fn read_mailbox() -> Message {
  function write_mailbox (line 79) | pub async fn write_mailbox(message: Message) {

FILE: programs/rpi-framebuffer/src/main.rs
  function main (line 24) | fn main() {
  function async_main (line 28) | async fn async_main() {

FILE: programs/rpi-framebuffer/src/property.rs
  type PropertyMessageBuilder (line 20) | pub struct PropertyMessageBuilder {
    method new (line 28) | pub fn new() -> PropertyMessageBuilder {
    method add_tag (line 32) | pub fn add_tag(&mut self, tag: u32, value_buffer: &[u8]) {
    method with_tag (line 54) | pub fn with_tag(mut self, tag: u32, value_buffer: &[u8]) -> Self {
    method send (line 59) | pub async fn send(self) {
  type PropertyMessageParser (line 78) | pub struct PropertyMessageParser<'a> {
  function from_buffer (line 83) | pub fn from_buffer(buffer: impl Into<Cow<'a, [u32]>>) -> Result<Self, ()> {
  function tags (line 95) | pub fn tags<'b: 'a>(&'b self) -> impl Iterator<Item = PropertyMessagePar...
  type PropertyMessageParserTag (line 123) | pub struct PropertyMessageParserTag<'a> {
  type Packet1 (line 128) | struct Packet1 {
  type Packet2 (line 133) | struct Packet2 {
  function init (line 138) | pub async fn init() {

FILE: programs/stub/src/main.rs
  function panic (line 30) | fn panic(_: &core::panic::PanicInfo) -> ! {
  function _start (line 39) | fn _start(_: isize, _: *const *const u8) -> isize {
  function async_main (line 44) | fn async_main() -> impl Future<Output = ()> {

FILE: programs/third-party/wasm-timer/src/lib.rs
  type Delay (line 25) | pub struct Delay {
    method new (line 38) | pub fn new(dur: Duration) -> Delay {
    method new_at (line 44) | pub fn new_at(at: Instant) -> Delay {
    method when (line 50) | pub fn when(&self) -> Instant {
    method reset (line 54) | pub fn reset(&mut self, dur: Duration) {
    method reset_at (line 58) | pub fn reset_at(&mut self, at: Instant) {
    method new (line 65) | pub fn new(dur: Duration) -> Delay {
    method new_at (line 74) | pub fn new_at(at: Instant) -> Delay {
    method when (line 88) | pub fn when(&self) -> Instant {
    method reset (line 92) | pub fn reset(&mut self, dur: Duration) {
    method reset_at (line 96) | pub fn reset_at(&mut self, at: Instant) {
    method fmt (line 109) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type Output (line 115) | type Output = io::Result<()>;
  method poll (line 117) | fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {

FILE: programs/vga-vbe/src/interpreter.rs
  type Interpreter (line 21) | pub struct Interpreter {
    method from_real_machine (line 69) | pub async fn from_real_machine() -> Self {
    method from_memory (line 76) | pub async fn from_memory(first_mb: Vec<u8>) -> Self {
    method disable_io_operations (line 110) | pub fn disable_io_operations(&mut self) {
    method read_memory (line 122) | pub fn read_memory(&mut self, addr: u32, out: &mut [u8]) {
    method read_memory_nul_terminated_str (line 145) | pub fn read_memory_nul_terminated_str(&mut self, mut addr: u32) -> Str...
    method read_memory_u8 (line 157) | pub fn read_memory_u8(&mut self, addr: u32) -> u8 {
    method read_memory_u16 (line 163) | pub fn read_memory_u16(&mut self, addr: u32) -> u16 {
    method write_memory (line 169) | pub fn write_memory(&mut self, addr: u32, data: &[u8]) {
    method ax (line 185) | pub fn ax(&mut self) -> u16 {
    method set_ax (line 189) | pub fn set_ax(&mut self, value: u16) {
    method set_bx (line 194) | pub fn set_bx(&mut self, value: u16) {
    method cx (line 199) | pub fn cx(&mut self) -> u16 {
    method set_cx (line 203) | pub fn set_cx(&mut self, value: u16) {
    method dx (line 208) | pub fn dx(&mut self) -> u16 {
    method set_es_di (line 212) | pub fn set_es_di(&mut self, es: u16, di: u16) {
    method int10h (line 220) | pub fn int10h(&mut self) -> Result<(), Error> {
    method run_until_iret (line 229) | fn run_until_iret(&mut self) -> Result<(), Error> {
    method run_one (line 271) | fn run_one(&mut self, instruction: &iced_x86::Instruction) -> Result<(...
    method run_one_no_rep (line 331) | fn run_one_no_rep(&mut self, instruction: &iced_x86::Instruction) -> R...
    method run_int_opcode (line 1638) | fn run_int_opcode(&mut self, vector: u8) {
    method apply_jump (line 1660) | fn apply_jump(&mut self, instruction: &iced_x86::Instruction) {
    method stack_push (line 1689) | fn stack_push(&mut self, data: &[u8]) {
    method stack_push_value (line 1701) | fn stack_push_value(&mut self, value: Value) {
    method stack_pop (line 1719) | fn stack_pop(&mut self, out: &mut [u8]) {
    method stack_pop_u8 (line 1730) | fn stack_pop_u8(&mut self) -> u8 {
    method stack_pop_u16 (line 1736) | fn stack_pop_u16(&mut self) -> u16 {
    method stack_pop_u32 (line 1742) | fn stack_pop_u32(&mut self) -> u32 {
    method flags_is_carry (line 1748) | fn flags_is_carry(&self) -> bool {
    method flags_set_carry (line 1752) | fn flags_set_carry(&mut self, val: bool) {
    method flags_is_parity (line 1760) | fn flags_is_parity(&self) -> bool {
    method flags_set_parity (line 1764) | fn flags_set_parity(&mut self, val: bool) {
    method flags_set_parity_from_val (line 1772) | fn flags_set_parity_from_val(&mut self, val: Value) {
    method flags_is_zero (line 1780) | fn flags_is_zero(&self) -> bool {
    method flags_set_zero_from_val (line 1784) | fn flags_set_zero_from_val(&mut self, val: Value) {
    method flags_set_zero (line 1788) | fn flags_set_zero(&mut self, val: bool) {
    method flags_set_adjust (line 1796) | fn flags_set_adjust(&mut self, val: bool) {
    method flags_is_sign (line 1804) | fn flags_is_sign(&self) -> bool {
    method flags_set_sign_from_val (line 1808) | fn flags_set_sign_from_val(&mut self, val: Value) {
    method flags_set_sign (line 1812) | fn flags_set_sign(&mut self, val: bool) {
    method flags_set_trap (line 1820) | fn flags_set_trap(&mut self, val: bool) {
    method flags_set_interrupt (line 1828) | fn flags_set_interrupt(&mut self, val: bool) {
    method flags_is_direction (line 1836) | fn flags_is_direction(&self) -> bool {
    method flags_set_direction (line 1840) | fn flags_set_direction(&mut self, val: bool) {
    method flags_is_overflow (line 1848) | fn flags_is_overflow(&self) -> bool {
    method flags_set_overflow (line 1852) | fn flags_set_overflow(&mut self, val: bool) {
    method flags_check_condition (line 1862) | fn flags_check_condition(&self, condition: iced_x86::ConditionCode) ->...
    method ip (line 1889) | fn ip(&self) -> u16 {
    method dec_cx (line 1893) | fn dec_cx(&mut self) {
    method sub_si (line 1900) | fn sub_si(&mut self, n: u16) {
    method add_si (line 1907) | fn add_si(&mut self, n: u16) {
    method sub_di (line 1914) | fn sub_di(&mut self, n: u16) {
    method add_di (line 1921) | fn add_di(&mut self, n: u16) {
    method memory_operand_pointer (line 1935) | fn memory_operand_pointer(&self, instruction: &iced_x86::Instruction, ...
    method operand_size (line 1976) | fn operand_size(&mut self, instruction: &iced_x86::Instruction, op_n: ...
    method fetch_operand_value (line 2007) | fn fetch_operand_value(&mut self, instruction: &iced_x86::Instruction,...
    method register (line 2096) | fn register(&self, register: iced_x86::Register) -> Value {
    method store_in_operand (line 2140) | fn store_in_operand(&mut self, instruction: &iced_x86::Instruction, op...
    method store_in_register (line 2183) | fn store_in_register(&mut self, register: iced_x86::Register, val: Val...
  type Registers (line 32) | struct Registers {
  type Error (line 52) | pub enum Error {
    method fmt (line 60) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type Value (line 2298) | enum Value {
    method size (line 2305) | fn size(&self) -> u8 {
    method most_significant_bit (line 2313) | fn most_significant_bit(&self) -> bool {
    method least_significant_bit (line 2321) | fn least_significant_bit(&self) -> bool {
    method zero_extend_to_u32 (line 2329) | fn zero_extend_to_u32(&self) -> u32 {
    method is_zero (line 2337) | fn is_zero(&self) -> bool {
    method is_max_value (line 2345) | fn is_max_value(&self) -> bool {
  type Error (line 2355) | type Error = ();
    method fmt (line 60) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function try_from (line 2356) | fn try_from(v: Value) -> Result<Self, ()> {
  type Error (line 2366) | type Error = ();
    method fmt (line 60) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function try_from (line 2367) | fn try_from(v: Value) -> Result<Self, ()> {
  type Error (line 2377) | type Error = ();
    method fmt (line 60) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  function try_from (line 2378) | fn try_from(v: Value) -> Result<Self, ()> {

FILE: programs/vga-vbe/src/interpreter/tests.rs
  function basic_entry_point_works (line 21) | fn basic_entry_point_works() {

FILE: programs/vga-vbe/src/main.rs
  function main (line 74) | fn main() {
  function async_main (line 79) | async fn async_main() {

FILE: programs/vga-vbe/src/vbe.rs
  type VbeContext (line 20) | pub struct VbeContext {
    method modes (line 151) | pub fn modes<'a>(&'a self) -> impl ExactSizeIterator<Item = Mode<'a>> ...
    method set_current_mode (line 164) | pub async fn set_current_mode(&mut self, mode_num: u16) -> Result<(), ...
  function load_vbe_info (line 32) | pub async unsafe fn load_vbe_info() -> Result<VbeContext, Error> {
  type Mode (line 198) | pub struct Mode<'a> {
  type ModeInfo (line 203) | struct ModeInfo {
  function num (line 234) | pub fn num(&self) -> u16 {
  function pixels_dimensions (line 239) | pub fn pixels_dimensions(&self) -> (u16, u16) {
  function linear_framebuffer_location (line 245) | pub fn linear_framebuffer_location(&self) -> u64 {
  function bytes_per_scan_line (line 250) | pub fn bytes_per_scan_line(&self) -> u16 {
  function red_mask_size (line 255) | pub fn red_mask_size(&self) -> u8 {
  function red_mask_pos (line 260) | pub fn red_mask_pos(&self) -> u8 {
  function green_mask_size (line 265) | pub fn green_mask_size(&self) -> u8 {
  function green_mask_pos (line 270) | pub fn green_mask_pos(&self) -> u8 {
  function blue_mask_size (line 275) | pub fn blue_mask_size(&self) -> u8 {
  function blue_mask_pos (line 280) | pub fn blue_mask_pos(&self) -> u8 {
  function reserved_mask_size (line 285) | pub fn reserved_mask_size(&self) -> u8 {
  function reserved_mask_pos (line 290) | pub fn reserved_mask_pos(&self) -> u8 {
  type Error (line 297) | pub enum Error {
  function check_ax (line 322) | fn check_ax(ax: u16) -> Result<(), Error> {
Condensed preview — 247 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (3,523K chars).
[
  {
    "path": ".dockerignore",
    "chars": 7,
    "preview": "target\n"
  },
  {
    "path": ".github/dependabot.yml",
    "chars": 634,
    "preview": "version: 2\nupdates:\n- package-ecosystem: github-actions\n  directory: \"/\"\n  labels: []\n  rebase-strategy: disabled  # Red"
  },
  {
    "path": ".github/workflows/ci.yml",
    "chars": 5512,
    "preview": "name: Continuous integration\n\non:\n  pull_request:\n\njobs:\n  build-programs:\n    name: Build WASM programs\n    runs-on: ub"
  },
  {
    "path": ".gitignore",
    "chars": 7,
    "preview": "target\n"
  },
  {
    "path": "Cargo.toml",
    "chars": 841,
    "preview": "[workspace]\nmembers = [\n    \"kernel/core\",\n    \"kernel/core-proc-macros\",\n    \"kernel/standalone\",\n    \"interface-wrappe"
  },
  {
    "path": "LICENSE",
    "chars": 35064,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "README.md",
    "chars": 1771,
    "preview": "The **redshirt** operating system is an experiment to build some kind of operating-system-like\nenvironment where executa"
  },
  {
    "path": "docs/authorizations.md",
    "chars": 722,
    "preview": "It is generally desirable to limit as much as possible the rights that a program has.\n\nIn redshirt, there is no system-w"
  },
  {
    "path": "docs/interfaces.md",
    "chars": 4808,
    "preview": "This document contains information about interfaces, plus a list of interfaces that exist.\n\n# Interfaces designing\n\n## D"
  },
  {
    "path": "docs/introduction.md",
    "chars": 4971,
    "preview": "# Introduction\n\nRedshirt is similar to an operating system. It allows executing programs that communicate with each othe"
  },
  {
    "path": "docs/messages.md",
    "chars": 5299,
    "preview": "Contains details about the messages passing system.\n\n# Syscalls\n\nThere exists five syscalls at the moment:\n\n- `next_noti"
  },
  {
    "path": "interface-wrappers/disk/Cargo.toml",
    "chars": 328,
    "preview": "[package]\nname = \"redshirt-disk-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieger <pi"
  },
  {
    "path": "interface-wrappers/disk/src/disk.rs",
    "chars": 6475,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/disk/src/ffi.rs",
    "chars": 2540,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/disk/src/lib.rs",
    "chars": 3168,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/ethernet/Cargo.toml",
    "chars": 332,
    "preview": "[package]\nname = \"redshirt-ethernet-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieger"
  },
  {
    "path": "interface-wrappers/ethernet/src/ffi.rs",
    "chars": 2088,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/ethernet/src/interface.rs",
    "chars": 6431,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/ethernet/src/lib.rs",
    "chars": 4003,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/framebuffer/Cargo.toml",
    "chars": 420,
    "preview": "[package]\nname = \"redshirt-framebuffer-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krie"
  },
  {
    "path": "interface-wrappers/framebuffer/src/ffi.rs",
    "chars": 4107,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/framebuffer/src/lib.rs",
    "chars": 5437,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/hardware/Cargo.toml",
    "chars": 448,
    "preview": "[package]\nname = \"redshirt-hardware-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieger"
  },
  {
    "path": "interface-wrappers/hardware/src/ffi.rs",
    "chars": 5232,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/hardware/src/lib.rs",
    "chars": 11368,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/hardware/src/malloc.rs",
    "chars": 9145,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/interface/Cargo.toml",
    "chars": 432,
    "preview": "[package]\nname = \"redshirt-interface-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Kriege"
  },
  {
    "path": "interface-wrappers/interface/src/ffi.rs",
    "chars": 6727,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/interface/src/lib.rs",
    "chars": 4714,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/kernel-debug/Cargo.toml",
    "chars": 262,
    "preview": "[package]\nname = \"redshirt-kernel-debug-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Kri"
  },
  {
    "path": "interface-wrappers/kernel-debug/src/lib.rs",
    "chars": 2104,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/kernel-log/Cargo.toml",
    "chars": 352,
    "preview": "[package]\nname = \"redshirt-kernel-log-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieg"
  },
  {
    "path": "interface-wrappers/kernel-log/src/ffi.rs",
    "chars": 4006,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/kernel-log/src/lib.rs",
    "chars": 2408,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/loader/Cargo.toml",
    "chars": 407,
    "preview": "[package]\nname = \"redshirt-loader-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieger <"
  },
  {
    "path": "interface-wrappers/loader/src/ffi.rs",
    "chars": 1405,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/loader/src/lib.rs",
    "chars": 1496,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/log/Cargo.toml",
    "chars": 268,
    "preview": "[package]\nname = \"redshirt-log-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieger <pie"
  },
  {
    "path": "interface-wrappers/log/src/ffi.rs",
    "chars": 4058,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/log/src/lib.rs",
    "chars": 3324,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/pci/Cargo.toml",
    "chars": 404,
    "preview": "[package]\nname = \"redshirt-pci-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieger <pie"
  },
  {
    "path": "interface-wrappers/pci/src/ffi.rs",
    "chars": 8078,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/pci/src/lib.rs",
    "chars": 4284,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/random/Cargo.toml",
    "chars": 387,
    "preview": "[package]\nname = \"redshirt-random-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieger <"
  },
  {
    "path": "interface-wrappers/random/src/ffi.rs",
    "chars": 1693,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/random/src/lib.rs",
    "chars": 2411,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/syscalls/Cargo.toml",
    "chars": 703,
    "preview": "[package]\nname = \"redshirt-syscalls\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieger <pierre.k"
  },
  {
    "path": "interface-wrappers/syscalls/src/block_on.rs",
    "chars": 8756,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/syscalls/src/emit.rs",
    "chars": 10358,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/syscalls/src/ffi.rs",
    "chars": 9533,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/syscalls/src/lib.rs",
    "chars": 8774,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/syscalls/src/response.rs",
    "chars": 4002,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/syscalls/src/traits.rs",
    "chars": 3338,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/system-time/Cargo.toml",
    "chars": 456,
    "preview": "[package]\nname = \"redshirt-system-time-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krie"
  },
  {
    "path": "interface-wrappers/system-time/src/ffi.rs",
    "chars": 1238,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/system-time/src/lib.rs",
    "chars": 1076,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/tcp/Cargo.toml",
    "chars": 392,
    "preview": "[package]\nname = \"redshirt-tcp-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieger <pie"
  },
  {
    "path": "interface-wrappers/tcp/src/ffi.rs",
    "chars": 4524,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/tcp/src/lib.rs",
    "chars": 16740,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/time/Cargo.toml",
    "chars": 449,
    "preview": "[package]\nname = \"redshirt-time-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieger <pi"
  },
  {
    "path": "interface-wrappers/time/src/delay.rs",
    "chars": 1743,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/time/src/ffi.rs",
    "chars": 1363,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/time/src/instant.rs",
    "chars": 2117,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/time/src/lib.rs",
    "chars": 1922,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/video-output/Cargo.toml",
    "chars": 372,
    "preview": "[package]\nname = \"redshirt-video-output-interface\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Kri"
  },
  {
    "path": "interface-wrappers/video-output/src/ffi.rs",
    "chars": 2186,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/video-output/src/lib.rs",
    "chars": 1435,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "interface-wrappers/video-output/src/video_output.rs",
    "chars": 4078,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/Cargo.toml",
    "chars": 2581,
    "preview": "[package]\nname = \"redshirt-core\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieger <pierre.krieg"
  },
  {
    "path": "kernel/core/benches/keccak.rs",
    "chars": 2879,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/extrinsics/log_calls.rs",
    "chars": 7563,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/extrinsics/wasi.rs",
    "chars": 58311,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/extrinsics.rs",
    "chars": 6902,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/id_pool.rs",
    "chars": 3353,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/lib.rs",
    "chars": 7502,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/module.rs",
    "chars": 2661,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/primitives.rs",
    "chars": 6703,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/scheduler/extrinsics/calls.rs",
    "chars": 11056,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/scheduler/extrinsics.rs",
    "chars": 44022,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/scheduler/ipc/notifications_queue.rs",
    "chars": 4908,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/scheduler/ipc/waiting_threads.rs",
    "chars": 9443,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/scheduler/ipc.rs",
    "chars": 22034,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/scheduler/processes/tests.rs",
    "chars": 5363,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/scheduler/processes/wakers.rs",
    "chars": 2353,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/scheduler/processes.rs",
    "chars": 47624,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/scheduler/tests/basic_module.rs",
    "chars": 1585,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/scheduler/tests/emit_not_available.rs",
    "chars": 3740,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/scheduler/tests/trapping_module.rs",
    "chars": 1498,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/scheduler/tests.rs",
    "chars": 927,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/scheduler/vm.rs",
    "chars": 30846,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/scheduler.rs",
    "chars": 1062,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/system/interfaces.rs",
    "chars": 11106,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/system/pending_answers.rs",
    "chars": 2833,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core/src/system.rs",
    "chars": 27966,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/core-proc-macros/Cargo.toml",
    "chars": 354,
    "preview": "[package]\nname = \"redshirt-core-proc-macros\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieger <"
  },
  {
    "path": "kernel/core-proc-macros/src/lib.rs",
    "chars": 8987,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/Cargo.toml",
    "chars": 2350,
    "preview": "[package]\nname = \"redshirt-standalone-kernel\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieger "
  },
  {
    "path": "kernel/standalone/build.rs",
    "chars": 2582,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/arm/executor.rs",
    "chars": 2959,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/arm/log.rs",
    "chars": 1416,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/arm/misc.rs",
    "chars": 1415,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/arm/time_aarch64.rs",
    "chars": 1577,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/arm/time_arm.rs",
    "chars": 9983,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/arm.rs",
    "chars": 9813,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/riscv/executor.rs",
    "chars": 2534,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/riscv/interrupts.rs",
    "chars": 4567,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/riscv/log.rs",
    "chars": 1422,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/riscv/misc.rs",
    "chars": 1351,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/riscv.rs",
    "chars": 9726,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/acpi.rs",
    "chars": 6540,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/ap_boot.rs",
    "chars": 21334,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/apic/io_apic.rs",
    "chars": 7464,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/apic/io_apics.rs",
    "chars": 4965,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/apic/local.rs",
    "chars": 12958,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/apic/pic.rs",
    "chars": 2138,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/apic/timers.rs",
    "chars": 24719,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/apic/tsc_sync.rs",
    "chars": 8406,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/apic.rs",
    "chars": 852,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/boot.rs",
    "chars": 12364,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/executor.rs",
    "chars": 6991,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/gdt.rs",
    "chars": 3884,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/interrupts.rs",
    "chars": 31676,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/panic.rs",
    "chars": 1275,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64/pit.rs",
    "chars": 6548,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch/x86_64.rs",
    "chars": 25715,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/arch.rs",
    "chars": 7675,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/hardware.rs",
    "chars": 10079,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/kernel.rs",
    "chars": 15427,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/klog/logger.rs",
    "chars": 5887,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/klog/native.rs",
    "chars": 2854,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/klog/video.rs",
    "chars": 11765,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/klog.rs",
    "chars": 1366,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/lib.rs",
    "chars": 4249,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/mem_alloc.rs",
    "chars": 2124,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/pci/native.rs",
    "chars": 9470,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/pci/pci.rs",
    "chars": 12360,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/pci.rs",
    "chars": 723,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/random/native.rs",
    "chars": 2511,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/random/rng.rs",
    "chars": 4532,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/random.rs",
    "chars": 723,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel/standalone/src/time.rs",
    "chars": 3101,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel-standalone-builder/Cargo.toml",
    "chars": 614,
    "preview": "[package]\nname = \"redshirt-standalone-builder\"\nversion = \"0.1.0\"\nlicense = \"GPL-3.0-or-later\"\nauthors = [\"Pierre Krieger"
  },
  {
    "path": "kernel-standalone-builder/build.rs",
    "chars": 851,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel-standalone-builder/res/rpi-firmware/boot/COPYING.linux",
    "chars": 18693,
    "preview": "\n   NOTE! This copyright does *not* cover user programs that use kernel\n services by normal system calls - this is merel"
  },
  {
    "path": "kernel-standalone-builder/res/rpi-firmware/boot/LICENCE.broadcom",
    "chars": 1594,
    "preview": "Copyright (c) 2006, Broadcom Corporation.\nCopyright (c) 2015, Raspberry Pi (Trading) Ltd\nAll rights reserved.\n\nRedistrib"
  },
  {
    "path": "kernel-standalone-builder/res/specs/aarch64-freestanding.json",
    "chars": 690,
    "preview": "{\n    \"arch\": \"aarch64\",\n    \"data-layout\": \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128\",\n    \"disable-redzone\""
  },
  {
    "path": "kernel-standalone-builder/res/specs/aarch64-freestanding.ld",
    "chars": 793,
    "preview": "ENTRY(_entry_point)\n\nSECTIONS {\n    . = 0x80000;\n    .text : AT(ADDR(.text)) {\n        _entry_point = .;\n        /* Same"
  },
  {
    "path": "kernel-standalone-builder/res/specs/arm-freestanding.json",
    "chars": 723,
    "preview": "{\n    \"arch\": \"arm\",\n    \"data-layout\": \"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64\",\n    \"emit-debug-gdb-scrip"
  },
  {
    "path": "kernel-standalone-builder/res/specs/arm-freestanding.ld",
    "chars": 808,
    "preview": "ENTRY(_entry_point)\n\nSECTIONS {\n    . = 0x8000;\n    .text : AT(ADDR(.text)) {\n        _entry_point = .;\n        /* Same "
  },
  {
    "path": "kernel-standalone-builder/res/specs/riscv-hifive.json",
    "chars": 849,
    "preview": "{\n    \"arch\": \"riscv32\",\n    \"cpu\": \"generic-rv32\",\n    \"data-layout\": \"e-m:e-p:32:32-i64:64-n32-S128\",\n    \"eliminate-f"
  },
  {
    "path": "kernel-standalone-builder/res/specs/riscv-hifive.ld",
    "chars": 910,
    "preview": "OUTPUT_ARCH(\"riscv\")\nENTRY(_entry_point)\n\nMEMORY {\n  RAM : ORIGIN = 0x80000000, LENGTH = 16K\n  FLASH : ORIGIN = 0x204000"
  },
  {
    "path": "kernel-standalone-builder/res/specs/x86_64-multiboot2.json",
    "chars": 885,
    "preview": "{\n    \"arch\": \"x86_64\",\n    \"code-model\": \"kernel\",\n    \"cpu\": \"x86-64\",\n    \"crt-objects-fallback\": \"false\",\n    \"data-"
  },
  {
    "path": "kernel-standalone-builder/res/specs/x86_64-multiboot2.ld",
    "chars": 1464,
    "preview": "OUTPUT_FORMAT(\"elf64-x86-64\")\nOUTPUT_ARCH(\"i386:x86-64\")\nENTRY(_start)\n\nMULTIBOOT2_MAGIC = 0xe85250d6;\nMULTIBOOT2_ARCH ="
  },
  {
    "path": "kernel-standalone-builder/simpleboot/README.md",
    "chars": 197,
    "preview": "The `simpleboot` directory contains a copy of <https://gitlab.com/bztsrc/simpleboot>,\nexcept that the `main` function ha"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/.gitignore",
    "chars": 74,
    "preview": "*.o\n*.img\n*.bin\n*.rom\n*.efi\n*.elf\nexample/boot\nexample/mnt\nsrc/simpleboot\n"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/Kconfig",
    "chars": 108,
    "preview": "if PAYLOAD_SIMPLEBOOT\n\nconfig PAYLOAD_FILE\n\tdefault \"payloads/external/simpleboot/src/loader_cb.elf\"\n\nendif\n"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/Kconfig.name",
    "chars": 373,
    "preview": "config PAYLOAD_SIMPLEBOOT\n\tbool \"Simpleboot\"\n\tdepends on ARCH_X86 || ARCH_ARM64\n\tselect WANT_LINEAR_FRAMEBUFFER\n\tselect "
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/LICENSE",
    "chars": 1136,
    "preview": "    Copyright (C) 2023 bzt (bztsrc@gitlab)\n\n    Permission is hereby granted, free of charge, to any person\n    obtainin"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/Makefile",
    "chars": 3160,
    "preview": "# for coreboot integration only\n# normally you'll need src/Makefile and that's it.\n\nifeq ($(CONFIG_COREBOOT_BUILD),)\ninc"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/README.md",
    "chars": 7068,
    "preview": "Simpleboot\n==========\n\n[Simpleboot](https://gitlab.com/bztsrc/simpleboot) is an all-in-one OS loader and bootable disk i"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/distrib/PKGBUILD",
    "chars": 656,
    "preview": "# Maintainer: bzt <https://gitlab.com/bztsrc/simpleboot/issues>\n# Contributor: Ramadan Ali (alicavus) <rot13: ezqa@ezqa."
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/distrib/simpleboot-1.0.0.ebuild",
    "chars": 1098,
    "preview": "# Copyright (C) 2023 dzsolt\n# Distributed under the terms of the GNU General Public License v2\n\nEAPI=7\n\nDESCRIPTION=\"Dep"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/distrib/simpleboot-9999.ebuild",
    "chars": 1098,
    "preview": "# Copyright (C) 2023 dzsolt\n# Distributed under the terms of the GNU General Public License v2\n\nEAPI=7\n\nDESCRIPTION=\"Dep"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/docs/ABI.md",
    "chars": 24462,
    "preview": "Writing Simpleboot compatible kernels\n=====================================\n\n[Simpleboot](https://gitlab.com/bztsrc/simp"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/docs/README.md",
    "chars": 11662,
    "preview": "Booting a kernel with Simpleboot\n================================\n\n[Simpleboot](https://gitlab.com/bztsrc/simpleboot) is"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/docs/coreboot.md",
    "chars": 5674,
    "preview": "Simpleboot in ROM\n=================\n\nFor backward compatiblity, you can create the disk image with the `-r` flag. This w"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/example/Makefile",
    "chars": 4027,
    "preview": "SIMPLEBOOT=../src/simpleboot\nKERNEL?=mykernel\nOVMF?=/usr/share/qemu/bios-TianoCoreEFI.bin\n# compile a \"Linux\" kernel\n#LI"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/example/README.md",
    "chars": 3385,
    "preview": "Simpleboot Example Kernels\n==========================\n\nThis directory contains the source for very minimal kernels, that"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/example/bochs.rc",
    "chars": 1414,
    "preview": "# configuration file generated by Bochs\nplugin_ctrl: unmapped=1, biosdev=1, speaker=0, extfpuirq=1, parallel=0, serial=1"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/example/gdb.rc",
    "chars": 97,
    "preview": "target remote localhost:1234\nset architecture i386:x86-64\nset style enabled off\ndisplay/4i $pc\nc\n"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/example/kernel.c",
    "chars": 14290,
    "preview": "/*\n * example/kernel.c\n * https://gitlab.com/bztsrc/simpleboot\n *\n * Copyright (C) 2023 bzt (bztsrc@gitlab), MIT license"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/example/linux.c",
    "chars": 6589,
    "preview": "/*\n * example/linux.c\n * https://gitlab.com/bztsrc/simpleboot\n *\n * Copyright (C) 2023 bzt (bztsrc@gitlab), MIT license\n"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/example/simpleboot.cfg",
    "chars": 4259,
    "preview": "#\n#  example/simpleboot.cfg\n#  https://gitlab.com/bztsrc/simpleboot\n#\n#  Copyright (C) 2023 bzt (bztsrc@gitlab), MIT lic"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/simpleboot.h",
    "chars": 6081,
    "preview": "/*\n * simpleboot.h - Multiboot2 compatible Boot header file.\n * https://codeberg.org/bzt/simpleboot\n *\n * Copyright (C) "
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/src/Makefile",
    "chars": 3294,
    "preview": "ifneq ($(LIBPAYLOAD_PATH),)\ninclude $(LIBPAYLOAD_PATH)/build/xcompile\nifneq ($(CONFIG_LP_ARCH_ARM64),)\nSTRIP=$(STRIP_arm"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/src/boot_x86.asm",
    "chars": 9285,
    "preview": ";\n;  src/boot_x86.asm\n;  https://codeberg.org/bzt/simpleboot\n;\n;  Copyright (C) 2023 bzt, MIT license\n;\n;  Permission is"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/src/cdemu_x86.asm",
    "chars": 8396,
    "preview": ";\n;  src/cdemu_x86.asm\n;  https://codeberg.org/bzt/simpleboot\n;\n;  Copyright (C) 2023 bzt, MIT license\n;\n;  Permission i"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/src/data.h",
    "chars": 314505,
    "preview": "/*\n * src/data.h\n * https://codeberg.org/bzt/simpleboot\n *\n * Copyright (C) 2023 bzt, MIT license\n *\n * Permission is he"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/src/inflate.h",
    "chars": 12134,
    "preview": "/*\n * src/inflate.h\n * https://gitlab.com/bztsrc/simpleboot\n *\n * tinflate  -  tiny inflate\n *\n * Copyright (c) 2003 by "
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/src/loader.h",
    "chars": 36970,
    "preview": "/*\n * src/loader.h\n * https://gitlab.com/bztsrc/simpleboot\n *\n * Copyright (C) 2023 bzt (bztsrc@gitlab), MIT license\n *\n"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/src/loader_cb.c",
    "chars": 76739,
    "preview": "/*\n * src/loader_cb.c\n * https://gitlab.com/bztsrc/simpleboot\n *\n * Copyright (C) 2023 bzt (bztsrc@gitlab), MIT license\n"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/src/loader_rpi.c",
    "chars": 90164,
    "preview": "/*\n * src/loader_rpi.c\n * https://gitlab.com/bztsrc/simpleboot\n *\n * Copyright (C) 2023 bzt (bztsrc@gitlab), MIT license"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/src/loader_x86.c",
    "chars": 126997,
    "preview": "/*\n * src/loader_x86.c\n * https://gitlab.com/bztsrc/simpleboot\n *\n * Copyright (C) 2023 bzt (bztsrc@gitlab), MIT license"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/src/misc/bin2h.c",
    "chars": 6341,
    "preview": "/*\n * src/misc/bin2h.c\n * https://gitlab.com/bztsrc/simpleboot\n *\n * Copyright (C) 2023 bzt (bztsrc@gitlab), MIT license"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/src/misc/deb_control",
    "chars": 400,
    "preview": "Package: simpleboot\nVersion: VERSION\nArchitecture: ARCH\nEssential: no\nSection: tools\nPriority: optional\nMaintainer: bzt\n"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/src/rombios_x86.asm",
    "chars": 8777,
    "preview": ";\n;  src/rombios_x86.asm\n;  https://codeberg.org/bzt/simpleboot\n;\n;  Copyright (C) 2023 bzt, MIT license\n;\n;  Permission"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/src/romfoss_x86.asm",
    "chars": 4910,
    "preview": ";\n;  src/romfoss_x86.asm\n;  https://codeberg.org/bzt/simpleboot\n;\n;  Copyright (C) 2023 bzt, MIT license\n;\n;  Permission"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/simpleboot/src/simpleboot.c",
    "chars": 82910,
    "preview": "/*\n * src/simpleboot.c\n * https://gitlab.com/bztsrc/simpleboot\n *\n * Copyright (C) 2023 bzt, MIT license\n *\n * Permissio"
  },
  {
    "path": "kernel-standalone-builder/simpleboot/wrapper.c",
    "chars": 303,
    "preview": "#include \"simpleboot/src/simpleboot.c\"\n\n// Note that unfortunately simpleboot calls `exit(1)` whenever something problem"
  },
  {
    "path": "kernel-standalone-builder/src/bin/main.rs",
    "chars": 8271,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel-standalone-builder/src/binary.rs",
    "chars": 1601,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel-standalone-builder/src/build.rs",
    "chars": 10165,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel-standalone-builder/src/emulator.rs",
    "chars": 5900,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel-standalone-builder/src/image.rs",
    "chars": 9278,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel-standalone-builder/src/lib.rs",
    "chars": 842,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel-standalone-builder/src/simpleboot.rs",
    "chars": 1475,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "kernel-standalone-builder/src/test.rs",
    "chars": 7872,
    "preview": "// Copyright (C) 2019-2021  Pierre Krieger\n//\n// This program is free software: you can redistribute it and/or modify\n//"
  },
  {
    "path": "programs/.cargo/config.toml",
    "chars": 486,
    "preview": "# Note: this file exists in order to provide a more convenient development environment in the\n# redshirt repository. It "
  },
  {
    "path": "programs/.dockerignore",
    "chars": 7,
    "preview": "target\n"
  },
  {
    "path": "programs/Cargo.toml",
    "chars": 535,
    "preview": "[workspace]\nmembers = [\n    \"compositor\",\n    \"diagnostics-http-server\",\n    \"dummy-system-time\",\n    \"e1000\",\n    \"hell"
  }
]

// ... and 47 more files (download for full content)

About this extraction

This page contains the full source code of the tomaka/os GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 247 files (3.2 MB), approximately 856.4k tokens, and a symbol index with 1714 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!