Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
alcinnz
alcinnz
@alcinnz@floss.social  ·  activity timestamp 2 days ago

Studying the rest of GRUB's "loader" commands specific to i386 PCs...

`initrd16` validated it got args & a kernel's loaded, validates the kernel header & determines the max-address from that under a couple different conditions, sums the min address, calls the CPU-generic init routine, allocates a chunk from the relocator getting its virtual & physical address, calls the CPU-generic load routine, records results into that header, & cleans up.

Alongside that is a `linux16` command.

1/?

  • Copy link
  • Flag this post
  • Block
alcinnz
alcinnz
@alcinnz@floss.social  ·  activity timestamp 2 days ago

`linux16` references its own module, validates it got args, opens the given file, reads a header into memory & validates it, sets some globals, normalizes that header under certain conditions, validates filesizes, parses commandline flags into that header, creates a relocator & uses it to allocate a chunk to read the file into, zeroes out heap space if header requests it, serializes commandline args into the executable, reads another chunk of the file, registers boot callbacks, & cleans up.

2/?

  • Copy link
  • Flag this comment
  • Block
alcinnz
alcinnz
@alcinnz@floss.social  ·  activity timestamp 2 days ago

`linux16` consults the memory map for where to allocate things. Whilst its boot callback gathers some new state for the CPU, resets the video mode, stops the floppydisk driver (old!), & defers to the relocator.

`plan9` validates it got args, references its own module, creates a relocator, allocates the file, allocates a pagemap (not via the relocator), iterates over attached disks opening each of them & encoding their metadata in Plan9's format, adds a nil terminator as it frees excess, ...

3/

  • Copy link
  • Flag this comment
  • Block
alcinnz
alcinnz
@alcinnz@floss.social  ·  activity timestamp 2 days ago

... normalizes the given filename & reformats it as a bootpath, reads & validates the file's header, sums up required memory & config size, relocator-allocates the config, zeroes that config out & serializes various data into it, relocator-allocates the arena, copies the header over & reads the rest of the file (split in 2), tweaks some pointers & adds padding, & sets boot callbacks.

The boot callback resets the video subsystem & defers to the relocator, having it zero out CPU state.

4/5?

  • Copy link
  • Flag this comment
  • Block
alcinnz
alcinnz
@alcinnz@floss.social  ·  activity timestamp 2 days ago

On i386 CoreBoot machines `chainloader` validates it got a single arg, clears the loader, opens the given file, creates a relocator, reads the file's header seeking back to start, branches over the magic number falling back to an error message or "Tiano", cleans up & sets boot callbacks.

In many cases it'll iterate over the file's segments reading them in. For each it to set appropriate globals, & possibly relocator-allocates the chunk to be read & possibly LZMA-decompressed.

5/6!

  • Copy link
  • Flag this comment
  • Block
alcinnz
alcinnz
@alcinnz@floss.social  ·  activity timestamp 2 days ago

For that Tiano fallback it reads a header from offset 48 & reverse-iterates over those headers until it found a valid one, locates the 1st valid section, validates various bytes in the file, branches over the machine it was compiled for to extract some fields appropriately, seeks back to start, & reads the entire file into relocator-allocated memory.

For ELF it creates a helper object (from GRUB's load-bearing abstractions), & iterates over the P-headers.

6/7!!

  • Copy link
  • Flag this comment
  • Block
alcinnz
alcinnz
@alcinnz@floss.social  ·  activity timestamp 2 days ago

For each ELF P-header it validates its a `PT_LOAD`, relocator-allocates its memory, reads the appropriate slice of the file into that memory, & zeroes out the rest.

The boot callback resets the video subsystem & defers to the relocator.

6.5/6.5 Fin for today! The rest of the i386 bootup commands!

  • Copy link
  • Flag this comment
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.2-alpha.43 no JS en
Automatic federation enabled
Log in
Instance logo
  • Explore
  • About
  • Members
  • Code of Conduct