Protected Mode, OS Development,
Docs and Tutorials
Contents
Tiny OS Kernel
I didn't have to do anything sometime ago and I started then programming
an OS. It seems that I still don't quit starting serious, global and complex
projects. ;))
I program the OS with my friend - Gennady Proschaev (we discuss details,
find and fix bugs together). His coordinates go here:
Homepage = http://www.chat.ru/~genapro
E-mail = genapro@chat.ru
I would like you to memorize that:
AUTHOR CAN NOT BE RESPONSIBLE
FOR ANY KIND OF DAMAGE, DATA OR HEALTH/LIFE LOSS CAUSED BY THE PROGRAM!!!
This program shows the basics of system programming for protected
mode.
Features
- 32-bit Protected Mode Programming with 386+
- Exceptions Handling
- Timer & Keyboard Hardware Interrupts Handling
- Task Switching (Ring 0 and Ring 3 Tasks)
System Requirements
- 386 or better computer
- EGA/VGA or better color video system
- DOS 5.0 or better (without any memory managers
such as HIMEM.SYS and EMM386.EXE) or Windows 9x loaded
in the Command Prompt Only mode
Known Bugs and Problems
- Those ones I've found myself are now fixed! ;)
oskernel.zip - 20KB (TAsm 3.2+/MASM 6.11) 30th of May 2000
Back to top
Page Translation Tutorial
Two versions of the program (PAGING and NOPAGING) differ only in one
thing. The first one sets the PG bit of the CR0 register to "1", but the
second one doesn't do that. The result is also different. Programs
draw colored bars on the screen in a different order. That's because
Page Table setup so that a linear address doesn't equal to a physical
address everywhere. Detailed, order of pages that correspond to the VGA
graphics buffer is opposite to the normal order.
paging.zip - 28KB (TAsm 3.2+/MASM 6.11) 30th of May 2000
Back to top
V86 Mode Monitor Tutorial
This program is intended to show how a V86 monitor should work. It sets
up a V86 mode and launches a command interpreter (COMMAND.COM).
Features:
-
Support for up to 8 nested IRQs in a V86 Mode
-
Support for 87H function of a BIOS Int 15H
-
An asterisk flashes at the top-right edge of the screen, mentioning that
the V86 mode monitor works
Tested on a Wolfenstein 3d and
worked fine ;-)
v86.zip - 28KB (TAsm 3.2+/MASM 6.11) 30th of May 2000
Unfortunately, I discovered that this program sometimes doesn't work. There must be a bug which I'm not gonna
fix because the source code is huge and old. Better visit the following site because v86 stuff presented there is much simpler and really works:
http://welcome.to/pmode - PMode Tutorials in C and Asm
Back to top
COFF UTILS
Here goes a set of utils that allow you to make 32-bit programs for
Protected Mode (not for DPMI!!!) very easily with DJGPP C compiler and/or
NASM assembler. These utils simply make ready-relocated flat executable
programs out of COFF ".o" object files. Such executable programs are really
easy to load and run, since there is not needed relocation process any
more. I've written all these utils because programming entire programs
for PMode in pure x86 assembly language is too boring for me. I've been
interested in how to use a C or Pascal compiler for that. So here they
are...
Short description
-
Standard file name extension for the flat executables is ".com" ;-). That's
because these programs are ".com"-like. They contain a stub part that says
something like a "Not a DOS or Windows program." and exits to the OS. The
stub part also holds information needed for loading the pmode program (i.e.
ID string, format and type of the file, file pointers to the .text
and .data sections, sizes of the .text, .data and
.bss
sections plus actual size of the stack). The main util that converts COFFs
to COMs is Coff2Com.exe.
-
Since the flat executable pmode programs are not selfrun, there is also
an util (OSLoader.exe) that loads such a pmode program, does
all the needed setup (GDT, Interrupt Controller, Page Tables), switches
to protected mode and runs loaded program.
-
This package contains full well commented sources of the utils written
for TASM3.2, DJGPP C 2.95.2 and NASM 0.98. Documentation is also included.
-
Current versions are:
Coff2Com.exe - v1.4
OSLoader.exe - v2.2
I hope I've fixed all the bugs in these utils. New versions will out
only with new features, I guess.
-
Two example programs written in assembler and C shows how the package works.
Assembly example program simply prints a standard "hello world!" message
to the screen and quits.
C example program is more advanced:
-
It handles exceptions (simply quits).
-
It handles IRQs (0-timer, 1-keyboard, 3/4-standard serial
mouse).
Note: None of IRQs is passed to Real Mode. There are only PMode
handlers.
-
It can read sectors of a HDD.
-
It can perform software interrupts in V86 mode (it can set graphics
mode using BIOS Int 10h service, for example).
-
Simple memory manager has been implemented. It doesn't use all the
advantages of page translation yet, but it will.
-
The example program also have a few basic functions of a standard C
run-time library.
-
Current version of the exapmle program is 1.0 (23th of January,
2000).
Well, don't waste time anymore and download the utils. Have fun!
Feedback is welcome!
coffutil.zip - approx. 180KB
coffutil_asm_demo.zip
- approx. 5KB
coffutil_c_demo.zip -
approx. 40KB
Back to top
Boot sector that loads and runs COM/EXE programs
When people develop bootable projects they often try to fit a lot of code to
small boot sectors. They also very often put PMode initialization code so
bugs are fixed very slow because each time boot sector update and bootstrap
are needed. People also invent new formats of disk layout so that they can
load and run something from their boot sector, although they can still use
FAT12/16 as well as before. I really don't know why people make life more
difficult than it is.
Why not to make a boot sector capable to load and run standard COM and EXE
programs? You would have the only bootsector and it woudn't be changed each time
when you changed something in the project. Why not to add there support for
FAT and load a program regardless of place where it starts on the disk?
Do you like this idea? If so, check out my BootProg boot sector that
does the job very well.
Current version (v1.2) of the boot sector is intended for use
on standard diskettes that have FAT12 and primary DOS HDD partitions both
FAT12 and FAT16. I tested it on the both FDD and HDD.
I hope you understand that programs loaded by the boot sector must not
call MSDOS service functions. You may use BIOS services instead.
bootprog.zip - 50KB (NASM 0.98)
Back to top
OS Development for Dummies - OS Loader
A group of people that appear in the alt.os.development
newsgroup have started a brand-new project called OS Development for Dummies. The OS Loader stands
as a part of the project. It's a thing I've come up with. You may visit a site related to the project:
http://www.mega-tokyo.com/osd. Entire the project is held there and
the OS Loader too. Newest version OS Loader is downloadable from here.
If you wanna read the manual on the OS Loader, it's as simple as that. Just read it! :))
Back to top
Intel Manuals on x86 and x87
Intel 80386 Programmer's Reference Manual
+
Detailed Instruction List (232 KB)
Intel 80386 Programmer's Reference Manual
(in Russian) (216 KB)
Intel 80486 Programmer's Reference Manual
(in Russian) (523 KB)
Intel 80387 Programmer's Reference Manual
(121 KB)
Back to top