You need a cross compiler installed on your system, specifically for the i686 system (other CC's might work, I think i386 does, see Virtualization for my intended setup and architecture description to figure out if your desired CC works). Currently, it is not in my roadmap (yet) to support lots of architectures.
I followed these instructions
to install my cross compiler in ~/opt/cross
. If you already
have a cross compiler, just change CROSS_COMPILER_ROOT
in the Makefile
to your root and
associated commands.
This all should work fine on i386
target if you happen to compile gcc for i386
target instead of i686
.
I'm not sure when i686 instructions are going to break i386 cpus (both are 32 bit cpus). I tried this a few times and everything worked. Someday I would like to know (TODO)
My setup, overall, is:
- 64 bit CPU
- 32 bit OS (compiled using i686 cross compiler)
- 32 bit applications will be able to be run
Note
- You wouldn't be able to write a 64 bit application using my OS unless you switched to 64 bit mode in the OS. I'll do that one day, but for now I'm keeping things simple and using 32 bit.
Qemu:
$ sudo apt-get install qemu-system
NASM:
$ sudo apt install nasm
A bunch of other stuff, like build essentials, make etc. I'll list them some day, but if you have qemu and make installed, you can probably figure out what you don't have installed just by running the below commands in Building and running
I've been running this on a virtualized x86_64
processor. (see my note in Terminology about backwards compatability between x86_64 and x86, e.g. i686)
Pretty simple:
$ make clean
$ make
$ qemu-system-x86_64 build/os.bin
Here's a nice summary of intel cpu architecture (chapter 2.1). Although, often in the intel software development manuals you can't just search for jargon terms, so the list below is a bit of a cross reference for each jargon-y word and a word you can search for in the intel manual:
Here's another nice explanation of i
related jargon
TLDR, intel's names make no sense :). Frequently, these words are just missused / loaded and it's just best to understand the history.
x86
: (2.1.1) Refers to a processors in the 8086 family. (80186 80286 80386 80486...). Usually, it means compatability with the 80386 32 bit instruction set because 16 bit only is so old (TODO - this isn't perfectly accurate)i686
: (2.1.6) Intel686. P6 Family Microarchitecture on the Pentium Pro. One of the 6th generation ofx86
processor.i386
: (2.1.3) Intel386. AKA 80386. First 32 bit (TODO - fact check)x86_64
The 64-bit instruction set (sometimes called amd64) brother ofx86
- backwards compatible to
x86
(iex86
instructions can run onx86_64
processors)
- backwards compatible to
- A 32-bit OS will run on a 32-bit or 64-bit processor without any problem.
- A 32-bit application will run on a 32-bit or 64-bit OS without any problem.
- But a 64-bit application will only run on a 64-bit OS and a 64-bit OS will only run on a 64-bit processor
Clearing things up because I haven't seen it stated in the official Intel manuals
- An official mega byte (MB) is 1000^2 bytes.
- An official mebi byte (MiB) is 1024^2 bytes
Intel says MB
in their reference manuals because MiB wasn't introduced until later and they didn't want to change all their manuals / references. For all intents and purposes, in the intel manuals, MB means 1024^2, which conforms with intuition (e.g. 4 GBytes is 4x2^30 bytes, or 2^2x2^30=2^32 bytes, which fits on a 32 bit number).
- Intel Software Development Manual Volume 1A (Basic Architecture)
- Not going to help you write code, but useful in learning about basics of computer stuff
- Intel Software Development Manual Volume 3A (System Programming Guide Part 1)
- Good reference for GDT, protected mode, paging, etc. (The above also talks about paging, and segmentation)
- OS Dev Wiki
- Eventually, I'll remove these as this grows, but this is the small subset of the wiki I've referenced so far:
- Setting up a gcc cross compiler
- GDT and GDT Tutorial
- Protected mode
- Segmentation
- Rolling your own bootloader
- Bootloader theory
- Assembly cheat sheet
- Daedalus Community - Making an OS
- NASM Reference
- NASM cheat sheet
- Assembly Programming Topics
- TODO - go through this tutorial
- Just a good website
- (Search for TODO's in code base for minor improvements)
- Set paging bit in cr0 and re work bootloader to implement paging
- Study what comes after the bootloader.
- VGA driver and standard print library support
- printing to the screen
- setting the screen graphics
- robust-ness