Hoshi Operating System

Hoshi Operating System icon

An operating system (OS) maps a model of computation, defined by its kernel interface. onto the underlying hardware. A. simple and intuitive model of computation makes it easy for programmers to write applications. An efficient implementation of the mapping makes the applications run fast. Typical as interfaces for von Neumann hardware include pro- cesses (CPU). address spaces (memory), and I/O devices (I/O). An as for distributed and multiprocessor systems must support parallel processing and inter-process communications.

Hoshi 星 is an custom hobby operating system for the x86_64 platform. It’s not Linux but it is POSIX-compliant and runs on a custom kernel named Yukiko 幸子. It is written from scratch in C, including the kernel, boot-loader, standard library, GUI library and all major components.

It has a mode called HoshiMin (yes, I know) where it boots into console with minimal applications (but with network support active), minimal memory pressure (under 64MB used) no GUI window manager and kernel debugging dumped into the first serial port.

星 development started in 2015 and I am not looking for contributors. This page is still work-in-progress after so many years and it might not be updated with the latest changes in the tree.

Keep in mind that I have no intention of releasing the source code or an ISO, for now.

Requirements

  • x86_64 CPU.
  • 256MB RAM.

Features

  • boots from a MBR using a custom bootloader.
  • has a Graphical User Interface with APIs.
  • multithreading.
  • has a network stack supporting IPv4 and IPv6, DNS, ICMP, TCP and UDP.
  • custom filesystem named HOFS (Hoshi File System), ISO 9660 filesystem, FAT32.
  • implements the POSIX API using a basic C library.
  • the GNU toolchain (binutils and GCC can run native on Hoshi).
  • can be compiled on a modern system using GCC 10.
  • has an Internet Relay Chat (IRC) client.
  • has a Mail client with support for POP3 and SMTP.
  • Universal Serial Bus (USB) EHCI and xHCI support.
  • Symmetric Multiprocessing (SMP).
  • audio support and drivers.
  • runs Doom and Quake.
  • has a custom web browser.
  • has Nyancat.

Hardware support

  • Graphics: BGA for now.
  • Input devices: PS/2 mouse and keyboard.
  • PCI, VGA text mode, APIC.
  • Storage devices: AHCI and IDE.
  • Ethernet cards: Intel PRO/1000 (82540EM / 82545EM) and AMD PCNet (Am79C970A / Am79C973).
  • Boots and runs on bare-metal and VirtualBox, QEMU, VMware, UTM (QEMU under the hood) or Parallels.

Ports

Applications

  • Coreutils written from scratch.
  • Text file editor.
  • Akari, the code editor with syntax highlighting.
  • Internet Relay Chat client.
  • Painter, painting application.
  • SysInfo, reporting various system information.
  • Mail client.
  • Terminal.
  • Calculator.
  • Font viewer.
  • Image viewer with support for BMP, PNG and JPEG.
  • Notes, todo and contacts.

Servers

  • echo
  • httpd
  • sshd
  • ftpd

Games

  • 2048
  • Mines
  • Tetris
  • Breakout
  • Doom
  • Space Invaders
  • Pacman
  • Quake
  • Memory

Components

Akimitsu

Akimitsu 昭光 is the GUI compositor and window manager.

HoSH

HoSH is the simple (and basic) POSIX-compliant 星 shell.

Keiko

Keiko 恵子 is the network manager, responsible for loading the correct network card driver, initializing it and bootstrapping the whole network stack.

Masashi

Masashi 雅志 is the two-stage boot-loader.

Akimitsu GUI controls

  • Buttons
  • Check boxes
  • Combo boxes
  • Images
  • Menus
  • Progress bars
  • Radio boxes
  • Scroll bars
  • Tabs
  • Text fields
  • Toolbars

Syscalls

The full list of 星 syscalls:

exit, write, pwrite, read, pread, open, close, ioctl, lseek, raise, stat, lstat, pause, fstat, chmod, fchmod, fsync, chown, fchown, mkdir, ftruncate, unlink, rmdir, dup, dup2, dup3, insmod, chdir, getcwd, mmap, munmap, rmmod, link, symlink, readlink, sleep, utime, umask, shutdown, uname, sigwait, sigsuspend, mcast, fpoll, oxperm, dxperm, fchxperm, chxperm, haveperm, sync, nice, procstat, cpuno, kill, time, nanotime, down, routetable, systat, statvfs, fstatvfs, chroot, modstat, mv, pathctlat, pathctl, flock_set, flock_get, fcntl_setfl, fcntl_getfl, fcntl_getfd, fcntl_setfd, bindif, block_on, unblock, unique, alarm, exec, sigaction, sigprocmask, getparsz, getpars, fsbase, gsbase, mprotect, fork, waitpid, yield, realpath, seterrnoptr, geterrnoptr, unmount, send, recv, getgroups, setgroups, getpid, getuid, geteuid, getsuid, getgid, getegid, getsgid, getppid, setsid, setpgid, getsid, getpgid, setuid, setgid, setreuid, setregid, seteuid, setegid, pthread_create, pthread_self, pthread_join, pthread_detach, pthread_kill, pthread_exit, aclput, aclclear, getdent, socket, bind, sendto, recvfrom, getsockname, listen, connect, getpeername, accept, accept4, setsockopt, getsockopt, sockerr

Statistics

$ cloc src --quiet
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
C                              728          35559          50874         143889
C/C++ Header                   272           9256          21993          26385
Assembly                        34            403            270           1964
make                            53            319             22           1166
Bourne Shell                    24            167             69            915
CSS                              2            166            129            680
Markdown                         1             38              0             85
JSON                             1              0              0             43
JavaScript                       2              2              1             35
HTML                             3              0              0             33
C++                              1              2              6              5
Python                           1              1              0              2
-------------------------------------------------------------------------------
SUM:                          1122          45913          73364         175202
-------------------------------------------------------------------------------

The Python, C++, HTML, CSS, JavaScript and JSON files are just demos for Akari and not part of the 星 source code.

Building

Once 星 source code has been downloaded, it is possible to build a cross-compiler. Create a directory called cross next to the src directory. Then inside this directory, run the following:

$ ../src/setup-toolchain.sh --sysroot=/sysroot

The sysroot does not have to be /sysroot but that’s just what I use. The script will download the source code for binutils and GCC and then patch it to support 星. It will also download all other dependencies (mpfr, gmp, mpc). This should take a few minutes. The next step is to run from the same directory:

$ sudo ./build-toolchain.sh

This installs the C compiler and binutils. It also creates symlinks under /usr/local/bin so that you can invoke commands like x86_64-hoshi-gcc without explicitly including them in your PATH. If you want to build the C++ compiler, you must first install the Hoshi C library in the sysroot, and then you can run:

$ sudo ./build-cpp-toolchain.sh

After the C++ compiler is built you can remove the cross directory unless you want to rebuild the toolchain again.

Suppose that you want to build a live ISO yourself, to start, create a working directory next to the src directory, called build and cd inside.

$ mkdir build && cd build
$ ../src/configure.sh --sysroot=/sysroot --iso

or if you’re building HoshiMin:

$ mkdir build-min && cd build-min
$ ../src/configure.sh --sysroot=/sysroot --min

The sysroot does not have to be /sysroot, but that’s just what I use. It must be consistent with where the sysroot of the cross-compiler resides.

$ make

If everything went well, you should now have a file called hoshi.iso. Congratulations, you can now boot it!