MAJOR BOOT CODE REVAMP / 30 hour+ hacking session (50 if you include the
authorMatthew Dillon <dillon@dragonflybsd.org>
Mon, 19 Jul 2004 23:30:38 +0000 (23:30 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Mon, 19 Jul 2004 23:30:38 +0000 (23:30 +0000)
commitcacaceecf77dc39131bf76571e5acbff01350b2a
treeba23177ebcf09e8d277103dad972c00fc39026c7
parent1ecc48f1cf368b6e07c82916d6ab18ada2af8a02
MAJOR BOOT CODE REVAMP / 30 hour+ hacking session (50 if you include the
attempt I made last month).

* Document the code wherever possible.  The previous code had lots of
  basically useless comments.

* Consolidate constants and calculations into a single header file.  The
  previous code separately defined the constants, did not document the
  relationships (which is why it took 30+ hours to fix), and often used
  unrelated numerical optimizations to get from one constant def to another.

* Most address ORG values can now be modified in one place (bootasm.h) and
  the boot code will actually still work.  Note, however, that many ORG
  values must still be < 0x10000 due to the lack of segment register use in
  16 bit code.   This can be fixed with additional work, but not in this
  commit.

* Provide two alternative address ORG relocations for experimentation
  purposes.

* Fix what I believe to be a bug in boot2/boot2.c.  Boot2.c was accessing
  the drive/slice data stored by boot1 using the base-offset-0 linear address
  instead of the btx-client-user address.  Additionally, boot1 was storing
  the data at a location that the btx client could not access.
  (see MEM_BTX_USR_ARG)

* Fix a heap/stack collision in the loader.  The loader was setting the end
  of the heap to the end of BIOS memory without taking into account the
  fact that its stack was likely growing downward starting at the end of
  BIOS memory.

* Fix a heap calculation error in the loader.  The loader was using the
  physical address representation of the end of BIOS memory instead of the
  virtual address representatino, which can result in the loader pushing into
  BIOS memory.
30 files changed:
sys/boot/i386/boot0/Makefile
sys/boot/i386/boot0/boot0.S
sys/boot/i386/boot2/Makefile
sys/boot/i386/boot2/boot1.S
sys/boot/i386/boot2/boot2.c
sys/boot/i386/bootasm.h
sys/boot/i386/bootasmdef.c [new file with mode: 0644]
sys/boot/i386/btx/btx/btx.S
sys/boot/i386/btx/btxldr/Makefile
sys/boot/i386/btx/btxldr/btxldr.S
sys/boot/i386/btx/lib/btxcsu.S
sys/boot/i386/cdboot/cdboot.S
sys/boot/i386/libi386/amd64_tramp.S
sys/boot/i386/loader/Makefile
sys/boot/i386/loader/main.c
sys/boot/pc32/boot0/Makefile
sys/boot/pc32/boot0/boot0.S
sys/boot/pc32/boot2/Makefile
sys/boot/pc32/boot2/boot1.S
sys/boot/pc32/boot2/boot2.c
sys/boot/pc32/bootasm.h
sys/boot/pc32/bootasmdef.c [new file with mode: 0644]
sys/boot/pc32/btx/btx/btx.S
sys/boot/pc32/btx/btxldr/Makefile
sys/boot/pc32/btx/btxldr/btxldr.S
sys/boot/pc32/btx/lib/btxcsu.S
sys/boot/pc32/cdboot/cdboot.S
sys/boot/pc32/libi386/amd64_tramp.S
sys/boot/pc32/loader/Makefile
sys/boot/pc32/loader/main.c