10 Jul 2018

29616

0

GSoC 2018 - boot sector finished

Hi all!

Sorry, haven’t written anything for a while. Let me tell you what have been done since last post.

BTRFS boot sector

TL;DR: It works!

Boot sector works!

I’ve been able to load main bootloader code from freeldr.sys into memory, transfer control to it and get on error message (freeldr.sys can’t find its config file - I haven’t written second-stage BTRFS code yet).

It was not that easy because we are in x86 real mode when running boot sector thus only about 1mb of memory is available. Another interesting thing is about BTRFS internal structures - most fields in BTRFS filesystem are 64-bit long. In real mode the largest registers you can use are 32-bit so you have to do some tricks every time you need to work with 64-bit numbers (use adc and sbb instructions for example).

Nevertheless, my boot sector code works fine now. It requires some more refactoring and testing on larger filesystems (right now I use a small 3gb image for developing) but it reliably loads freeldr.sys in my case and I can move on.

BTRFS support in second stage bootloader

Freeldr.sys must support full read-only access to filesystem unlike boot sector. While the boot sector should only read one specific file from root directory, freeldr.sys have to read random files from different directories.

Before starting development of this functionality, I had to turn on debug output from FreeLoader. That required some diving into the code but finally I was able to switch some #defines and use Bochs emulator “e9 port hack” to get debug output in console:

Debug output in Bochs

After that I started implementing the filesystem support in freeldr.sys

So BTRFS support on second-stage bootloader is in progress right now. See you next week!

This blog post represents the personal opinion of the author and is not representative of the position of the ReactOS Project.

The Blog Posts

Opinions, technical details, side projects or lovely kittens created directly by the ReactOS Devs.

Their opinions are theirs, so...well...any injuries, wounds, or dead-kittens due them, are..well..their own responsibility.

Visit the "Project News" for official statements.