Development

Version 0.2.0 released

Friday, September 30, 2005

Version 0.2.0 is up, download here. Changes include moving the kernel up into the higher half of memory, physical memory manager and paging up and running. A kernel heap with malloc() & free() is working using a basic first fit algorithm. The build process has changed slightly, now building the kernel as an ELF file so Grub can load it with a high virtual address into a low physical location. The elf binutils are needed to build AMOS on windows with DJGPP. Also creating the disk image is automated with a working version of mcopy which is included in the release as its not easy to find on the web.

Jumping into Virtual Memory

Thursday, September 29, 2005

So I decided to move the kernel up to the 3GB mark (ala Windows and Linux) which will better allow me to layout memory later on when multitasking comes into play. The kernel is linked against a virtual address of 0xC0001000 (physical address of 0x00101000). When grub passes control over to us I create a .setup section which is mapped virtual = physical. This setup section initializes basic paging and maps the kernel into its correct virtual address. Grub sets up a Global Descriptor Table with a code and data segment of base 0x00000000 so segmentation does not effect the address translation from logical to linear.

If we '>objdump-elf -h kernel.bin' to view the sections we get:


kernel.bin: file format elf32-i386

Sections:
Idx Name Size VMA LMA File off Algn
0 .setup 00001000 00100000 00100000 00001000 2**2
CONTENTS, ALLOC, LOAD, CODE
1 .kernel 00002000 c0001000 00101000 00002000 2**2
CONTENTS, ALLOC, LOAD, CODE
2 .data 00001000 c0003000 00103000 00004000 2**2
CONTENTS, ALLOC, LOAD, DATA
3 .bss 00003000 c0004000 00104000 00005000 2**2
ALLOC
4 .comment 000000c8 c0007000 c0007000 00005000 2**2
CONTENTS


The code to setup paging and jump into the kernel is quite short and simple:


KERNEL_VMA equ 0xC0001000

PAGE_DIRCTORY equ 0x9C000
PAGE_TABLE_1 equ 0x9D000
PAGE_TABLE_2 equ 0x9E000
PRIV equ 3

_setup:
; store the pointer to the Grub multi boot header for later
push ebx
; create a page table that identity maps the first 4MB of mem
mov eax, PAGE_TABLE_1
mov ebx, 0x00000000 | PRIV
call map
; create a page table that will map the kernel into the 3GB mark
mov eax, PAGE_TABLE_2
mov ebx, 0x00100000 | PRIV
call map
; store the first page table into the page directory
mov dword [PAGE_DIRCTORY], PAGE_TABLE_1 | PRIV
; store the second page table into the page directory entry 768 (3GB mark)
mov dword [PAGE_DIRCTORY + 768*4], PAGE_TABLE_2 | PRIV
; enable paging
mov eax, PAGE_DIRCTORY
mov cr3, eax
mov eax, cr0
or eax, 0x80000000
mov cr0, eax
; restore ebx with the pointer to the multi boot header
pop ebx
; jump into the kenel at it virtual memory address
jmp 0x08:KERNEL_VMA
map:
; loop 1024 times (number of entry's in a page table)
mov ecx, 1024
lmap:
; move next entry (ebx) into the page table (eax)
mov dword [eax], ebx
; move forward to next entry in table
add eax, 4
; move address forward by a page size
add ebx, 4096
; go again untill ecx == 0
loop lmap
ret

CVS Access

Monday, September 19, 2005

Use this link to access a web-based CVS repository viewer. To access the AMOS source tree from a CVS client you must use the following information. I recommend Eclipse as it is also the recommended development environment for AMOS and includes an integrated CVS client.

CVS Server: osamos.cvs.sourceforge.net
CVS Root: /cvsroot/osamos
Login: anonymous
Module: AMOS


If you are using a command line client you should use the following:

cvs -d:pserver:anonymous@osamos.cvs.sourceforge.net:/cvsroot/osamos login
cvs -z3 -d:pserver:anonymous@osamos.cvs.sourceforge.net:/cvsroot/osamos co -P AMOS

Status Update

Sunday, September 18, 2005

I've setup an account for the project on SourceForge.net and all the code is available through anonymous CVS via the SourceForge site. All code will be released with the GNU General Public License.

Eclipse has been configured to fully automate the build process and testing with bochs which is great. Also the Eclipse plugin CDT v3.0 was released and is well worth the upgrade. And as a bonus if your using Eclipse it ties in seamlessly with CVS which is fantastic, I simply cant recommend it enough :)

In terms of the actual project status I now have basic paging enabled. Currently all available memory is identity mapped which isn't ideal and that will be next to change. I've added a simple physical memory manager which uses the bitmap method to keep track of available page frames. I'll move over the stack method which is more efficient once I have the paging sorted out.

First Release

Saturday, September 10, 2005

Just upped the first release 0.1.0! Download it here. I have moved over to IBM's Eclipse for my IDE with the CDT plugin which provides a C/C++ development environment within Eclipse. I love Eclipse, its is fantastic for Java coding and I use WebSphere Application Developer which is based off Eclipse too for any J2EE stuff so its a smooth move over. Anything has to be better then Visual Studio 6.0! yuk :) Eclipse will be great when I get a CVS account and I can maintain the source tree with it. I think I will apply to sourceforge.net for this.

The 0.1.0 kernel sets up two Global Descriptor Tables, one segment for code and the other segment for data. The Interrupt Descriptor Table is set up and stubs are in place to handle the first 32 entries; divide by zero and like. IRQ's are also setup with appropriate stubs in place for them too. I have set up a global interrupt service routine dispatcher to dispatch all interrupts, both hardware and software, to their respective service routine. These service routines can then be added dynamically in the future as needed. Their is also some console support with a basic kprintf() implementation. So all and all things are going well. I am now going to move on to enabling paging which should be the next release.

Nearly ready for 0.1.0!

Thursday, September 08, 2005

Ok so far I have a simple C kernel booting in bochs with Grub as the bootloader. I have basic text console support, a simple GDT setup and have put inplace basic exception handling and will go on to add basic IRQ handling next. Once that's all done and somewhat stable I will probably up it to the site as the 0.1.0 release :)

Edit: Versioning will be [Major].[Minor].[Patch]

Welcome

Sunday, September 04, 2005

Welcome the AMOS development blog. I've always wanted to code a home brew operating system, for fun moreso than profit :) and have in the past dabbled in some protected mode programming and have a good grounding in OS theory so I'm finally going to go for it. This blog will track the lifecycle of the project. The chosen architecture is IA-32. For the development environment I will initially be using the bochs IA-32 emulator, NASM and DJGPP. This gives me both x86 assembly and C to develop in. To move things along at first I will use the GRUB bootloader until I write a suitable alternative myself.

The kernel itself will be monolithic. I hope to implement a complete virtual memory management system but I'll start with a physical memory manager followed by paging. Multitasking will be pre-emptive with a round-robin scheduler to begin with. I think I will initially support a file system like FAT16 to begin with as it is fairly simple. If I get anywhere close to the above I shall be very pleased and no doubt this will all change dramatically as things progress. A modest GUI and libc support would be cool too along with multiuser support :)

As an aside, here's why I chose the name AMOS:
  • The first programming language I ever learned was Easy Amos on my Amiga 600 back in 1993, a BASIC variant, it was fun and 'easy'!
  • It is the acronym for A Monolithic Operating System. And if you don't like Monolithic you could use Multitasking, Multiuser, Memory Managed and so on...
  • And best of all it is the initials and nickname of my girlfriend! :)




SourceForge.net Logo