Navigation
Highlights

Release 0.0.5

The latest release, alpha testing, unstable. See "downloads".

2005-06-01

Links
Documentation

The boot code

The FreeDOS-32 boot code is the part of the FreeDOS-32 kernel which initializes the system.

Files and functions

The fd32/boot directory contains the boot code needed to initialize the kernel and some drivers and to run the first FreeDOS-32 program (it will be the FreeDOS-32 version of FreeCOM, but currently we only run some test programs). This directory contains the following files.

boot.c - the FreeDOS-32 kernel entry point

Contains the entry point (the main()function) that reads the system informations from the MultiBoot Information (MBI) structure, and uses them to initialize the system (see init.c). After that, initializes some other functionality and the statically linked drivers.

Then, it can handle the MultiBoot modules (calling process_module from modules.c) and run some embedded test. Currently, only some biosdisk test can be run: the DISK_TEST constant specifies the test to run. If it is undefined, no test is run; if it is defined to 1, a simple floppy read/write test is run, whereas if it is defined to 2 a partition test is run.

init.c - system initialization

Contains the system initialization code (see system_init()) that currently sets some exception handler and invokes the memory manager initialization (see mem.c). This file also contains the dos_init() function, that should initialize the DOS memory and resources (below 1 MB), but is currently not used (some DOS_*() functions provided by OSLib are used instead, but the boot code will be used in the future).

mem.c - memory initialization

Contains the code used to initialize the FreeDOS-32 Physical Memory Manager (PMM). The mem_init() function is used to initialize the PMM: if the boot loader provided a memory map, mem_init_from_mmap() is called, otherwise mem_init_from_size() will initialize the memory pool using the memory size information from the MBI.

After that, mem_init2() is called to remove the memory used by the kernel and the modules from the free memory pool. This file also contains some glue that permits to use the PMM to manage kernel memory (mem_*()functions).

mmap.c - memory map management

Contains two functions that can be used to manage the memory map provided by the MultiBoot loader: mmap_process() and mmap_entry(). mmap_process() simply displays the memory map and is not used by anyone, whereas mmap_entry() returns the address and size of a single entry of the memory map.

modfs.c - file operations for boot modules

Contains the implementation of a pseudo file system that permits to access MultiBoot modules using the standard FreeDOS-32 file operations (type fd32_dev_file_t). The modfs_read(), modfs_seek()and modfs_size() functions are exported through a standard character interface, so that ModFS can be transparently used by a client. In order to use ModFS, the modfs_init() function has to be called (this is currently done by process_module()in modules.c, but could be moved into init.c in the future).

modules.c - boot modules handling

Contains the code for identifying and correctly handling the modules loaded at boot time. The process_modules() function (invoked by main() in boot.c) accesses all the modules through ModFS and calls identify_module() in order to identify each of them. Then, it invokes the proper function on the module. Currently, process_dos_module() checks if a DOS executable is a stubbed DJGPP file, and in that case invokes process_coff_module(). The DJGPP COFF parser process_coff_module() and the ELF parser process_elf_module() are implemented using dynalink.