This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Failed to load latest commit information.
1. What is Dos64stb good for? Dos64stb is a small stub that is supposed to be added to a 64-bit PE binary ( thru the link step ). It is the program that is executed when the binary is launched in DOS. Dos64stb will do this: - check if the cpu is 64-bit - check if the PE image is "acceptable" - check if enough XMS memory is available for image & paging - setup IDT and page tables for 64-bit PAE paging - read & move the image into extended memory - install a small "OS" (int 21h/31h) so one may call real-mode DOS functions that don't need pointer translation. - reprogram master PIC, so IRQs 00h-07h are mapped to Int 78h-7fh - switch to long-mode - handle base relocations - call the entry point of the loaded 64-bit image 2. Requirements to run an image with Dos64stb attached one needs: - a 64-bit CPU - an installed DOS - an installed XMS host - enough extended memory to load the image 3. How to use Dos64stb? The stub is added to a 64-bit binary thru the link step. See file Makefile for how to do this with MS link or jwlink. The image must meet the following requirements: - Subsystem has to be "native"; avoids the image being loaded in Win64 - image must contain base relocations (they must NOT be "stripped") - no dll references ("imports") are possible - base of image must be < 4 GB There are 2 samples supplied, Mon64.asm and TestC.c. Mon64 allows to display a few 64-bit resources. It also shows how the Int21 emulation installed by Dos64stb is supposed to be used. TestC, the second sample, just shows how C source may be used with the stub. TestC.mak is supplied, which creates the binary using MSVC ( and JWasm, needed to assemble the micro-printf implementation in printf.asm ). Dos64stb installs a tiny subset of the DPMI API. The functions that are supported are: - int 21h, ah=4Ch: terminate program - int 31h, ax=203h: set exception vector BL to CX:RDX - int 31h, ax=300h: simulate real-mode interrupt BL, RDI=real-mode call structure. 4. Memory Layout The 64-bit binary runs in ring 0, 64-bit long mode. The first 64 GB of memory are "identity mapped" by the stub. This may be adjusted in Dos64stb.asm. When launched, Dos64stb allocates a memory block in extended memory and initializes it like this (from lower to higher addresses): - Page Tables (default: 1+1+64 pages) - IDT (1 page) - 64-bit PE image - stack - heap (optionally) 5. License the source is distributed under the GNU GPL 2 license. See file COPYING for details. It was written by Andreas Grech.