Getting Started

Installation Requirements

  • Windows Subsystem for Linux (Ubuntu 18.04)
  • CoreRT
  • Zenos Tooling

Windows Subsystem For Linux

Setup VS for remote debugging: https://devblogs.microsoft.com/cppblog/targeting-windows-subsystem-for-linux-from-visual-studio/

CoreRT

Under WSL we want to install the following: CoreRT Prerequisites for building

echo "deb http://llvm.org/apt/xenial/ llvm-toolchain-xenial-3.9 main" | sudo tee /etc/apt/sources.list.d/llvm.list
wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt-get update
sudo apt-get install cmake clang-3.9 libicu55 uuid-dev libcurl4-openssl-dev zlib1g-dev libkrb5-dev

Building ILC

cd vendor/corert
./build.sh clean

CoreRT binaries will be places in <repo_root>vendor\corert\bin\Linux.x64.<Config>\tools

Zenos Tooling

sudo apt install \
    gdb \
    grub-pc-bin \
    nasm \
    xorriso

Troubleshooting

If you get an error similar to:

Initializing BuildTools...
chmod: cannot access '/mnt/e/code/OsDev/zenos/vendor/corert/packages/microsoft.dotnet.buildtools/3.0.0-preview1-03220-01'$'\r''/lib/init-tools.sh': No such file or directory

run vi -b BuildToolsVersion.txt and remove trailing ^M

maybe QEMU

Tools go to: /mnt/e/code/OsDev/zenos/vendor/corert/bin/Linux.x64.Debug/sdk/libRuntime.a

Zenos Architecture

Components

  • ILCompiler(CoreRT)
  • System.Private.CoreLib
  • Zenos compiler
  • Zenos OS

Build process

  1. Build Zenos OS C# Components
  2. Build Native ZenosOS object files(ILCompiler)
  3. Build Assembly components
    • multiboot_header
    • boot
    • OS.obj
    • modules
    • dotnet
    • load_end_addr
  4. Link all object files
  5. Build ISO

Build commands

make debug
make gdb
make

Calling convention

RDI, RSI, RDX, RCX, R8, R9

Listing symbols:

readelf -s ./sdk/libPortableRuntime.a
nm -g ./sdk/libPortableRuntime.a

investigate OSGroup=AnyOS in corert https://github.com/dotnet/corert/blob/c57237f6b22f58e037b6f316ebc138e8fa5833f6/dir.props

should be able to run ./build.sh clean Release anyos

should be able to add /p:DefineConstants="MYSYMBOL1;MYSYMBOL2" to the above with the appropriate constants

GOALS:

  • blockers:
    • erroring on some unimplemented methods
  • get internalsvisibleto working so that we can access the inner types
  • see if we can get a build more aligned with a CUSTOM OS
    • to get anyos working we would need to define some types or stubs for several classes
    • INPLACE_RUNTIME;FEATURE_COMINTEROP;FEATURE_MANAGED_ETW_CHANNELS;FEATURE_MANAGED_ETW;
    • FEATURE_SYNCTABLE;netcoreapp;EETYPE_TYPE_MANAGER;
    • ES_BUILD_PN;ES_SESSION_INFO;AMD64;BIT64;PLATFORM_WINDOWS;CORERT;;DEBUGRESOURCES;SIGNED

References

https://os.phil-opp.com/