BING bootloader version 0.5 (release date Mar 5, 2002)
Chris Giese <geezer@execpc.com>, http://www.execpc.com/~geezer/os

This version of BING is not complete, but I'm releasing it
anyway. The things I wanted to do yet:

- add umount() function
- let user switch between disk partitions
- restore support for loading multiple files (kernel + RAM disk,
  kernel + tasks, microkernel + servers, etc.)
- FAT12, FAT16, ext2 first-stage loaders
- install program for first-stage loaders

================================================================
New features since version 0.4
================================================================
- Improved support for PE kernels
- Support for ELF kernels
- VFS layer
- ext2 filesystem
- Uses XMS and VCPI if run from DOS
- Works with hard disks of any geometry
- Supports LBA hard disks (> 8 Gbytes)
- Now INT 15h AH=89h method of entering pmode
- Supports 'fast' method of enabling A20
- Improved detection of conventional/extended memory size/layout

================================================================
Build, install, test
================================================================
You need DOS, Turbo C, NASM, and PARTCOPY. Get NASM here:
	http://www.web-sites.co.uk/nasm/

Get Turbo C 2.01 or Turbo C++ 1.01 here (registration required):
	http://community.borland.com/museum/

Get PARTCOPY here:
	http://www.execpc.com/~geezer/johnfine/#zero

The bootsectors have been removed from this version. For now,
BING runs only as a DOS executable.

To build, type
	make

and run BING.EXE from the DOS prompt.

================================================================
Supported features
================================================================
Kernel file formats:
	- DJGPP COFF	- Win32 PE	- ELF
Kernels must be statically linked with exactly 3 sections:
.text .data .bss

Filesystems:
	- FAT12		- FAT16		- ext2

Entering protected mode:
        - VCPI          - "raw"         - INT 15h AH=89h

Determing conventional memory size:
	- INT 12h			- INT 15h AX=E820h

Determing extended memory size:
	- XMS				- INT 15h AX=E820h
	- INT 15h AX=E801h		- INT 15h AH=88h

Allocating extended memory:
        - XMS                           - "raw"

Controlling A20 gate:
        - XMS                           - "Vectra" method
        - "fast/port 92h" method        - "AT" method

================================================================
BING-compatible kernels
================================================================
Only pmode kernels are supported for now.

The kernel will be loaded into contiguous memory on a page (4K)
boundary. The exact load address varies:
- If enough extended memory is present and XMS (HIMEM.SYS) is
  NOT present, the kernel will be loaded to 1 meg (0x100000)
- If enough extended memory and XMS are present, the kernel will
  be loaded above 1 meg. Depending on how XMS clients such as
  SMARTDRV are loaded, the kernel may straddle a 4 meg line. If
  your kernel uses paging, it will need 2 page tables in this
  case.
- If XMS is present, it will not be used if
    - there is not enough XMS memory to load the kernel
    - the XMS memory block can not be locked (Windows)
- If the kernel can't load in XMS or extended memory, BING will
  try to load it in conventional memory.

There is code in load_kernel() of file BING.C that stores system
info (conventional and extended memory sizes) in the first 4K
of the kernel BSS. This is for compatability with my own OS
(Cosmos). You can comment out this code if you want. I will try
to make the next version of BING compatible with Multiboot.

================================================================
To do
================================================================
- support Multiboot
- add support for loading and running real-mode kernels
- finish support for DOS .EXE files, with and without relocations
- maybe align conventional memory to 512-byte boundary?
- add support for DOS .COM files
- add support for binary files and chain-load bootsectors
- write code to support ISO9660 (CD-ROM) filesystem
- LARGE and HUGE models don't work with Turbo C
- for a partition > 8 gig, are the CHS values in the partition
  table valid? (err, tell me again why I need to know this?)
- .COM file is still too large. Any way to leave out the BSS
  when converting from .EXE to .COM? Or am I stuck with the
  built-in BSS because I'm using TINY model? (I think you
  get a small BSS if you COMPILE and LINK without debug info
  -- see COMFILE.MAK)

BROWSE.C
- normalize_path() needs work -- handle relative path names
  and handle . and .. directories properly

CONIO.C
- putch() is too slow! 2 BIOS interrupts per character displayed!
  (seems to be slow only with Turbo C 3.0 -- what's going on?)

DISKIO.C
- probe_floppy_geometry() should probe number of heads and
  number of tracks, too
- Turbo C version of memcpy2f() is slow
- add CD-ROM support

MOUNTS.C
- entries in _mounts[] should be sorted by decreasing length
  of _mounts[n].mount_pt
- if I mount a 2nd partition on a subdirectory, there is no ..
  dir, so I can't get back to the root

================================================================
Bugs and limitations of Borland tools
(Turbo C 2.0 and Turbo C++ 1.0 are free downloads)
================================================================
                TC2.0       TC++1.0     TC++3.0
bug/limitation  tool        tool        tool    work-around
--------------- -----       -------     ------- ----------------
No /L option    TLINK 2.0   TLINK 3.01  -       Use full path to
to TLINK                                        startup code/libs

TLINK /3 fails  TLINK 2.0   TLINK 3.01  -       *** NONE ***
with .EXEs

No -f option    MAKE 2.0    MAKE 3.0    -       Makefile must be
to MAKE                                         named 'makefile'

No $@ macro     MAKE 2.0    MAKE 3.0    -       Use $*.o or $*.exe
                                                instead

.SUFFIXES       MAKE 2.0    MAKE 3.0    -       Don't use it
not ignored                                     (only GNU MAKE
                                                needs it)

@&&! / !        MAKE 2.0    -           -       Create response
not supported                                   file with > and >>

No output       MAKE 2.0    -           -       *** NONE ***
redirection

No inline asm   TC 2.0      TC++ 1.0    -       Buy TASM or use
(BASM)                                          external NASM code

Buggy intr()    TC 2.0      -           -       Write your own
                                                intr()

'huge' bugs     -           -           TC++ 3.0 *** NONE ***

================================================================
Gotchas
================================================================
Compiling (tcc -v ...) or linking (tlink /v ...) with debug info
apparently implies "tlink /v /i ...". This causes the BSS to
be included in the .EXE file, with the data segment. This in
turn makes the .EXE (or .COM) file bigger.

NASM startup code gotchas:
- load ES before using REP STOSB to zero the BSS (duh)
- load DS with DGROUP for SMALL model
- do not put _TEXT in DGROUP for SMALL model
- do not declare anything "static const" in your C code
- put "resb 100h" before "..start" for TINY model, like the NASM FAQ says
- for both .COM and .EXE, DS and ES point to the PSP on entry

================================================================
Testing
================================================================
environ-
ment    memory  pmode           Pentium Bochs   486
------- ------  -----           ------- -----   ---
DOS     XMS     VCPI            CPE[0]  ?       ?
DOS     XMS     INT 15h AH=89h  ?       [1]     ?
DOS     XMS     raw             ?       ?       ?

DOS     ext     VCPI            ?       ?       ?
DOS     ext     INT 15h AH=89h  ?       [1]     ?
DOS     ext     raw             ?       ?       ?

DOS     conv    VCPI            ?       ?       ?
DOS     conv    INT 15h AH=89h  ?       [1]     ?
DOS     conv    raw             ?       ?       ?

boot    XMS     VCPI            [2]     [2]     [2]
boot    XMS     INT 15h AH=89h  [2]     [1][2]  [2]
boot    XMS     raw             [2]     [2]     [2]

boot    ext     VCPI            [2]     [2]     [2]
boot    ext     INT 15h AH=89h  ?       [1]     ?
boot    ext     raw             ?       ?       ?

boot    conv    VCPI            [2]     [2]     [2]
boot    conv    INT 15h AH=89h  ?       [1]     ?
boot    conv    raw             ?       ?       ?

[0] C=COFF kernel, P=PE kernel, E=ELF kernel
[1] Bochs BIOS does not support INT 15h AH=89h
[2] Not possible (no XMS or VCPI from bootloader)
