Archive for the ‘ASM’ Category

x86 Kernel (32-bit protected-mode)

Wednesday, February 23rd, 2005

OBSELENCE NOTE: This was written well over a year ago, so may be outdated (ie. may have broken links — if so, let me know and I’ll update).  Just because it’s old doesn’t mean that it’s not worth sharing!

Summary:

Kernel design can be overwhelming.  Fortunately, there are lots of resources available (just hard to find at times).  Using IRC, UseNet, the Internet and written books, it is possible to learn quite a bit about OS design and development as well as writing your own.

This kernel operates in protected-mode (must already be in protected-mode — accomplished via boot loader — look at Boot Loader (32-bit protected-mode) for an example of such a boot loader).

It loads the Global Descriptor Table (GDT), IDT & provides a basic/buggy text output routines & keyboard driver (interrupt-driven).  Note that it’s not complete, comes with no guarantees.

One book that’s an excellent resource on OS theory is Modern Operating Systems by Andrew S. Tanenbaum (published by Prentice Hall).  See below for links to UseNet groups, IRC channels & websites that I’ve found helpful.

(more…)

Boot Loader (32-bit protected-mode)

Tuesday, February 8th, 2005

OBSELENCE NOTE: This was written several years ago, so may be outdated (ie. may have broken links — if so, let me know and I’ll update).  Just because it’s old doesn’t mean that it’s not worth sharing!

Summary:

After a successful basic boot loader that boots up to 16-bit real-mode, I wanted to see what the world or protected-mode (PM) was all about!   So, I delved into it — and became confused.  Fortunately, there are lots of resources out there (check out the links below for several of them).  This boot loader fits into 512 bytes, but enters protected-mode (PM is 32-bit on the x86 platform).

This boot loader does the following:

  • Enables the A20 line (so that all of the memory is available).
  • Loads the Global Descriptor Table (GDT).
  • Enters Protected-Mode (PM).
  • Parses the FAT12 directory structure to look for and load into memory BOOTNEXT.SYS.
  • Executes (transfers control) to BOOTNEXT.SYS (currently this is a flat binary file).

After getting the boot loader working right, I delved into kernel design.  That can be overwhelming (to say the least).  Anyhow, take a look at the 32-bit protected-mode kernel if you’re wanting to see working interrupts in PM, a simple keyboard driver (protected-mode doesn’t allow use of the BIOS).

(more…)

16-bit (real-mode) Boot Loader

Tuesday, February 8th, 2005

OBSELENCE NOTE: This was written over a year ago, so may be outdated (ie. may have broken links — if so, let me know and I’ll update).  Just because it’s old doesn’t mean that it’s not worth sharing!

Background

I’ve been wanting for some time to figure out how the bootup process works and how to write a boot loader!  I’ve finally figured out the basics of how it works — kind of an art in itself once you begin to understand everything that has to go on in a 512-byte program (less than 512-bytes are actually usable for program code).

This boot loader does the following:

  • Parses the FAT12 directory structure to look for and load into memory BOOTNEXT.SYS.
  • Executes (transfers control) to BOOTNEXT.SYS (currently this is a flat binary file).

The file bootnext.asm is a simple “kernel” file that pretty much just says hello, proves that the boot loader did it’s job, etc.

One of the sample “kernels” (files that can be copied to your floppy drive as BOOTNEXT.SYS) is called bootn3.asm.  This simple “kernel” (if you want to call it that) shows how to configure interrupts in real-mode (modify the Interrupt Vector Table (IVT)).

(more…)