Initial commit
[nyankernel.git] / README
blobc0e21508f06bdc8099f6d33fdc64d5be095053ea
1 This uses aggressively stripped down/derived and "gcc/clang/icc free" linux based
2 code. There is not intent to deviate that much from linux internal design.
4 In this current state, this is minimaly tested bootstrap code, you get:
5  - boot cpu core.
6  - ring0 in kernel virtual address space.
7  - hardware tracer with usb dbc (currently enabled by default, see below for how to use it).
8  - 2MiB page allocator properly inited (based on efi memory map, and currently untested).
10 Development happened on amd zen2 cpu/msi uefi motherboard.
11         
12 Used sdk:
13  - c compilers: tcc and cproc (gcc/clang/icc should work, but are not recommended as those are
14    filthy toxic).
15  - assemblers: binutils as, nasm/yasm, fasmg. Namely intel syntax, you have a vim syntax highlighter
16                in $src_dir/vim.
17  - linker: binutils ld.
19 Build scripts are brutally simple and idiotic on purpose:
20  1 - run $src_dir/configure in your $build_dir (currently the configuration is hardcoded)
21  2 - configure the sdk at the start of $src_dir/arch/x64/kernel/make_vmnyan.sh
22  3 - build the kernel running $src_dir/arch/x64/kernel/make_vmnyan.sh in your $build_dir
23  4 - configure the sdk at the start of $src_dir/arch/x64/boot/efi/make_os_loader.sh
24  5 - build the uefi os loader running $src_dir/arch/x64/boot/efi/make_os_loader.s in your $build_dir
26 usb dbc hardware tracer: usb dbc requires a modern hardware controller (usually from usb3). You need
27 another computer with a usb dbc enabled driver, a usb host-to-host cable. Then you need to discover
28 the "first" default (in pci enumeration order) usb dbc port on the traced computer (or manually
29 select it, see below, but it is not recommended):
30         1 - boot on the nyankernel efi os loader: bootx64.efi (efi shell of efi boot entry). Then it
31             will hang waiting for an handcheck from the tracer computer, see below.
32         2 - plug the usb host-to-host cable on the "first" default usb dbc port and the other side
33             on the traced computer and the tracer computer.
34         3 - check the traced computer is properly announced on the tracer computer. On elf/linux,
35             dmesg command.
36         4 - get ready to download the trace messages on the tracer computer: on elf/linux, it 
37             usually means something like: cat /dev/ttyUSB0 >/tmp/mytracefile
38         5 - handcheck: send a random line from the tracer computer to the traced computer. On 
39             elf/linux, it usually means something like: echo "I am ready to trace" >/dev/ttyUSB0
40         6 - Flush the file buffers on the tracer computer, then inspect the content of your trace
41             file. On elf/linux, sync;cat /tmp/mytracefile
43 Manual selection of the usb dbc port on the traced system: on the efi boot command (efi shell or efi
44 boot entry), use the "dbc=GGGGBBDDFF" command line option, with GGGG being the pci group, BB the bus
45 number, DD, the device number, FF the function number, all using hexadecimal radix. For example, in
46 your efi boot command (efi shell or efi boot entry): bootx64.efi dbc=0000a0201
48 NOTE: It is easier to look for the default usb dbc ports using the tracer computer: once bootx64.efi
49 runs, plug the usb host-to-host cable on the traced computer until you see it properly detected
50 and configured on the tracer computer.
52 WARNING: a nasty usb dbc hardware bug from the amd matisse usb controller (cpu and motheboard) was
53          worked around (not idea if it was fixed on Zen3 or Zen4).
55 Future would go the following ways:
56  - using 2MiB pages, not 4KiB pages.
57  - only relocatable kernel.
58  - initrd only in kernel image.
59  - 4lvls and 5lvls are different kernels. 
60  - turn on and off, aka no hibernation or suspend to ram.
61  - no swap.
62  - no hotplug for core components: cpu/ram/etc.
63  - physical address mapping of memory from from the hardware should be as low as possible. But
64    binary trees may happen for "struct page" from/to pfn mapping.
65  - iommu.
67 Misc:
68  - In assembly, we relax the stack alignment from the sysv abi for function calls. The assembly code
69    must know if it calls such a function or not (usually generic c code).