This is my attempt at creating my own virtual machine with custom replaceable components (CPU, RAM, graphics) with the goal of creating my own operating system that runs on this virtual machine.
Currently, this is extremely incomplete and more like a proof of concept that "it might work". The RAM, video card, and CPU are currently being "virtualized", in that:
- The graphics card (named X1) is initialized (which contains a 256x256 framebuffer and 16 bytes of RAM)
- The RAM is created (which contains 4,096 bytes worth of memory)
- A device that provides random numbers (RandGen) is initialized
- A generic HDD device that can read and write files is initialized
- A memory mapper is created and the following are mapped to address space:
- RAM is mapped at
0x0000-0x0FFF
- The GPU is mapped at
0xF0F0-0xF0FF
. - The RandGen device is mapped at
0xF0E9
- The HDD is mapped at
0xF100-0xF302
.
- RAM is mapped at
- The bootloader is loaded automatically to RAM space
0x0000-0x00FF
.- The default bootloader included in the repository (compiled from assembly) just access HDD sector 0, load that to
0x0300-0x03FF
while showing a loading progress bar, and then jumps execution to0x0300
.
- The default bootloader included in the repository (compiled from assembly) just access HDD sector 0, load that to
- The default disk image in this repository was compiled from assembly and does nothing more than draw multicolored lines into the screen:
- The CPU transfers random coordinates into the GPU's address space
0xF0F0-0xF0F3
. - The CPU gets random numbers to choose a random color and saves it at GPU address
0xF0F4-0xF0F6
. - The CPU triggers a GPU line draw by writing something into
0xF0FF
.
- The CPU transfers random coordinates into the GPU's address space
The CPU is a barely-working RISC variant with A and X registers. It is a tiny bit similar to the MOS 6502 CPU. It can
- load data into A or X either from an immediate value or from address space (absolute or relative from register X)
- subtract or add X or an immediate value from A (the result is left in A)
- zero flags for when subtraction or loading results in a 0 A value
- conditional jump (if zero flag is set) and jumps
It has 4,096 bytes. That's it.
Has a 256x256 pixel RGBA8 buffer, has 16-byte RAM where the CPU can send data to, and can draw lines in any color.
Well, currently, this is extremely incomplete, too incomplete to the point that I do not know what will happen yet. However, these are things that I plan to do soon:
- DONE!
Virtualizing a hard drive - Implementing the BIOS
- DONE!
Writing a bootloader - Deciding on the CPU opcode list
- Finishing the CPU emulator
- DONE!
Writing a graphics device that can draw pixels and lines at least - DONE!
Writing a basic proof of concept program (simple looping animation?) - Writing basic keyboard device
- Writing an operating system (the hardest task, I guess)
GPL-3, I guess. Not like anyone would care about this useless project.