Lazarus

Free Pascal => Other OS => Topic started by: bzt on January 16, 2021, 04:39:42 am

Title: Writing OS (bare metal with FPC)
Post by: bzt on January 16, 2021, 04:39:42 am
Dear All,

I've created a multiplatform OS loader (https://gitlab.com/bztsrc/bootboot), and as for the example Hello World kernel I managed to port it to Pascal and compile with FPC successfully! It was quite a journey because writing system.pas is not documented at all (plus all the forum post are outdated, and things like you have to define "jmp_buf" when FPC actually complains about missing "tjmpbuf" etc.). Other than the lack of some docs on this niche segment, FPC turned out to be a very useful and handy tool, and I managed to create a minimal kernel without the need of any Assembly! :-)

The kernel.pas (https://gitlab.com/bztsrc/bootboot/-/tree/master/mykernel-pas) itself isMaybe this source is going to be useful to someone! Any suggestion on the code is very welcome, because I'm not that experienced with Pascal.

Cheers,
bzt
Title: Re: Writing OS (bare metal with FPC)
Post by: MarkMLl on January 16, 2021, 10:02:06 am
Well done, but quite frankly I'd focus on I/O being serial to start with because of the many different types of video configuration.

When I did this sort of thing it was bare-metal '386 in protected mode, and I ended up writing some of the tools as well.

MarkMLl
Title: Re: Writing OS (bare metal with FPC)
Post by: bzt on January 16, 2021, 08:40:35 pm
Well done, but quite frankly I'd focus on I/O being serial to start with because of the many different types of video configuration.
Thanks! Have no worries, the UART (no matter if it's 16550, PL011 or FTDI chip) is also initialized and configured for 115200 baud, 8 data bits, no parity and 1 stop bit on all platforms and ready to be used by the kernel. All you need is an RS-232 cable and minicom / PuTTY running on the other side. The loader also takes care of the many different video configurations (and firmware, like VESA, GOP, VC MailBox etc.), so your kernel gets a consistent, 32 bits packed pixel linear frame buffer no matter the platform.

When I did this sort of thing it was bare-metal '386 in protected mode, and I ended up writing some of the tools as well.

MarkMLl
Yeah, I've given up protmode long long time ago. This is for 64 bits only (x86_64 and AArch64), and one of my goals was to use vanilla compilers and toolchains without patches and third party tools as much as possible. For the kernels I've used just the native language to be multiplatform, without Assembly hacks.The only tool I provide is the bootable disk image creator (which is a dependency-free all-in-one portable command line tool).

Cheers,
bzt
TinyPortal © 2005-2018