Recent

Author Topic: Writing OS (bare metal with FPC)  (Read 5002 times)

bzt

  • Newbie
  • Posts: 2
Writing OS (bare metal with FPC)
« on: January 16, 2021, 04:39:42 am »
Dear All,

I've created a multiplatform OS loader, 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 itself is
  • Free and Open Source (MIT licensed)
  • is a 64 bit higher-half kernel (mapped at the negative address range)
  • draws on a linear frame buffer, and says Hello using PC Screen Font (the same font format that Linux Console uses)
  • works on IBM PC and should work on Raspberry Pi (3 and above) too.
Maybe 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

MarkMLl

  • Hero Member
  • *****
  • Posts: 6647
Re: Writing OS (bare metal with FPC)
« Reply #1 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
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

bzt

  • Newbie
  • Posts: 2
Re: Writing OS (bare metal with FPC)
« Reply #2 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