PDA

View Full Version : Has this been done before? Pascal OS?



code_glitch
15-12-2009, 12:25 PM
I've been looking around the Internet and found this page: http://wiki.osdev.org/Pascal but I find it rather incomplete. Well actually, very. I then looked at the various C options, but, in all honesty, I cannot stand C one bit. So I had another look at the http://wiki.osdev.org/Pascal page and got a bootloader working but can't get any further.

I am using IsoMaster to write the stub.o (from stub.asm) to the boot record and boot it in virtual box. I've tested it and I know that it gets up to the line "call kmain" but cannot get it to go any further. Is there some sort of error that I am missing? Preferably, is there anyone out there that has written a good tutorial that is relatively easy to follow in how to build a kernel in pascal?

Many thanks in advance.

~~EDIT~~
I know that this is PGD and that it stands for Pascal Game Development but I thought that this would be the place where I could find the most amount of pascal programmers, and not on some other osdev forum crammed full with C coders.
~~END~~

Ñuño Martínez
15-12-2009, 12:37 PM
First I must say that IMHO C is the best option to code an operating system because it was designed for such work and Pascal is much higher level.

Anyway there are a kernel written in Pascal + Assembler: Toro (http://toro.sourceforge.net/eng/index.html). Actually I don't know how much complex it is but you'll find a lot of versions in the download page (http://sourceforge.net/projects/toro/files/). May be it helps you a bit.

code_glitch
15-12-2009, 12:52 PM
Although Toro seems good, I am now, officially, lost. What I seek to do is just get a bootsector to launch a program/procedure. Although Toro does contain it (I think) it uses all manner of complex techniques (multitasking, boot options...) which has me completely confused. Any help would much appreciated. Here is the file I have in the boot sector at the moment:



[bits 32]

[global kstart]

[extern kmain]


MULTIBOOT_MODULE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_MAP equ 1<<1
MULTIBOOT_GRAPHICS_FIELDS equ 1<<2
MULTIBOOT_ADDRESS_FIELDS equ 1<<16


MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_MODULE_ALIGN | MULTIBOOT_MEMORY_MAP
MULTIBOOT_HEADER_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)

KERNEL_STACKSIZE equ 0x4000

section .text

align 4
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_HEADER_CHECKSUM


kstart:
mov esp, KERNEL_STACK+KERNEL_STACKSIZE
push eax
push ebx
call kmain
cli
hlt

section .bss

align 32
KERNEL_STACK:
resb KERNEL_STACKSIZE


My question at the moment is, why does it not execute the kmain procedure? Does it all have to be in one file or will seperate files do? Here is the result of DIR in the folder:



autocompile.sh crt.o kernel.obj multiboot.o stub.o
autocompile.sh~ crt.ppu kernel.pas multiboot.pas system.o
console.o howtocompile.txt kernel.ppu multiboot.ppu system.pas
console.pas kernel.bak linker.script stub.asm system.ppu
console.ppu kernel.o linker.script~ stub.asm~


where stub.o is boot record...

JSoftware
15-12-2009, 03:43 PM
I've written one which is still under development. It currently works on x86 and ARM

Getting over the first part is the hardest. You just have to try a lot and read alot. If there's anything specific just send me a PM or contact me on jeppesoftware@hotmail.com

There's a bit about it here, though no source yet. I'm still looking for a way to get a source control repository http://j-software.dk/

noeska
15-12-2009, 07:20 PM
I believe that on the fpc forums there was once an hello world os source. But i cannot find it there now.

Found it: http://wiki.osdev.org/Pascal it is now a wiki page and does a bit more...

de_jean_7777
15-12-2009, 08:21 PM
I have an example of a barebone OS which you can get here (beware of ads, free hosting ::)).
http://dbx.orgfree.com/bareos/index.html
I used the code from the OSDev Pascal barebone wiki page, put it in units and done some stuff to get a buildable iso. I've provided a built iso. Read the included bareOS.txt file which explains how to build the code.

Also an interesting example, but way more complex is Free Pascal Operating System (http://code.google.com/p/fpos/). The google code page is a mess, but the OS is quite effective. Seeing as the author(s) did not update in quite some time, I'm not sure if this is going anywhere.



First I must say that IMHO C is the best option to code an operating system because it was designed for such work and Pascal is much higher level.

The above examples show that it is possible to do an OS in Pascal. There is no significant advantage of C over Pascal. Both will require the use of some assembly anyway. The higher level thing is wrong, as it is possible to use FPC for programming embedded systems (which btw, is something low level). In Delphi it is also possible, but rather difficult which makes Delphi unsuited for this task. It may be true that C may be better suited (in my opinion not, as it's as easy to do OS development in FPC as it is in C), but if you want to program in Pascal, there is no reason to use C.