@@ 1,12 1,56 @@
# scalc but it's an operating system
## How do I run this beauty?
TODO: more professional guide coming soon
1. Download a cross-compiler for `riscv64-linux-musl` off of
2. Install `qemu-system-riscv64`, `parted` and `mtools` somehow
3. Build u-Boot according to [qemu-riscv64 instructions](https://github.com/u-boot/u-boot/blob/master/doc/board/emulation/qemu-riscv.rst) into `../u-boot`
3. Run `make`
4. Run `make run` to start the emulator :)
What if we replace all big kernels and userspace with just a calculator? This
should be enough.
![Screenshot of a QEMU window with scalc-os doing simple operations](https://0x0.st/oH7-.png)
This project takes a lot of inspiration from [scalc], hence the name. It
implements only the surface functionality though - decimal integers and
`+`, `-`, `/`, `*`, `%` operations plus additional commands:
* `.` - print last value in the stack
* `d` - drop last value from the stack
Interactions are done through the default input device, in case of most systems,
that would be serial. Entering a number to push it onto the stack works as
expected, but the number has to be followed with any character to mark its
## Running in QEMU
Throughout the build, a cross-compiler will be used. If one is not
configured already, it's recommended to use `riscv64-linux-musl` from [musl.cc].
If anything else is used, make sure to set `$CROSS_COMPILE` to reflect that.
Also - POSIX `dd`, `parted` and `mtools` are needed to build the disk image.
$ make CROSS_COMPILE=riscv64-other-prefix-
To run it, a u-Boot build is necessary (by default, looked up in `../u-boot`),
see [official QEMU instructions] for more info.
$ make run
Default u-Boot configuration does not work correctly and isn't going to boot
the image. So, press any key to pause startup and enter boot shell, then run:
=> virtio scan
=> load virtio 0:1 $kernel_addr_r /efi/boot/bootriscv64.efi
=> bootefi $kernel_addr_r
To not type this out every time, go to u-Boot source directory and run
`make menuconfig`. In the menu, go into "Boot options", tick "Enable a default
value for bootcmd" and set "bootcmd value" to `virtio scan; load virtio 0:1 $kernel_addr_r /efi/boot/bootriscv64.efi; bootefi $kernel_addr_r`.
After that, save the configuration and rebuild u-Boot.
[official QEMU instructions]: https://github.com/u-boot/u-boot/blob/master/doc/board/emulation/qemu-riscv.rst