Grub4dos Internal variables, memory areas, advanced features and function calls

counter customisable

The following is a list of some grub4dos internal variables and functions from a 2013 or later version of a chenall build of grub4dos (as used in RMPrepUSB).

Memory areas used by grub4dos

The physical memory address range from 1M to 32M is reserved for grub4dos internal code and data. Grub4dos may fail to run on systems with less than 32MB of RAM. Ideally users should not use this range (32MB = 0x200,0000 = below (md)0x10000).
Some use of (md)0x300 is relatively safe if low memory is required.
Some areas below 1MB are also used by grub4dos.










Grub4dos executes grub4dos executables and kernel payloads at 32MB in memory, therefore it is best to use memory areas well above 32MB for any memory workspace if you intend to call grub4dos executables after loading kernel files, etc.

Note: In grub4dos, batch files and programs run in the same piece of memory as the 'kernel' command. Therefore you cannot use the kernel command directly from a batch file or grub4dos program.
To workaround this, either allocate memory to move the buffer by using call Fn.50 0x200000 as the very first line in menu.lst OR use configfile, e.g.
echo kernel /xxx/vmlinuz aaa bbb ccc > (md)0x220+1
echo initrd initrd.gz >> (md)0x220+1
configfile (md)0x220+1


(md) is a memory 'device'. (md)x+y where x is the start sector in memory and y is the length of memory in sectors (e.g. (md)4+2 = start at 2KB in memory for a length of 1KB. Note that the BIOS uses low memory!


Grub4dos use of memory - (md) uses 512-byte 'sectors'
=============================================
0x0007000 CMD line buffer
0x0008200 320K fixed variables + grldr program = (md)0x41 to (md)0x300
0x0050000 to the end of low memory is used by gfxmenu
0x0030000 64k sector buffer for current device = (md)0x180 to (md)0x1FF
0x0040000 unused (user) = (md)0x200 to (md)0x227
0x0045000 environment variables = (md)0x228 to (md)0x288 approx.
0x0060000 end of grub4dos variables + wkspace = (md)0x300 to (md)0x3DF
0x007C000 used to load boot code, etc. = (md)0x3E0...
0x0090000 may be used by BIOS (avoid) = (md)0x480 to (md)0x4FF
0x00A0000 graphics memory (reserved) = (md)0x500 to (md)0x5FF
0x00C0000 BIOS area (reserved) = (md)0x600 to (md)0x7FF
0x0100000 may be used by BIOS (avoid) = (md)0x800 best to avoid up to (md)0x880
0x02B0000 2.6MB HMA_ADDR = (md)0x1580
0x03E0000 FSYS_BUF = (md)0x1F00 to (md)0x1F40
0x0800000 8M for mem array workspace = (md)0x4000 to (md)0x7FFF
0x0A00000 10M-14M for page map = (md)0x5000-(md)0x6FFF
0x0F00000 15M-16M used by some systems (avoid) = (md)0x7800-(md)0x7FFF
0x1000000 16M-19M used to store background bmp = (md)0x8000-(md)0xD460 (end of buffer depends on size of bitmap, 1920x1440=0xD460, 1280x800=0x9F40, 1024x768=0x9800, 800x600=0x8EA6)
0x1800000 24MB Unifont area = (md)0xC000-0xFFFF
0x2000000 32MB Reserved memory area = (md)0x10000
0x2800000 40MB Linux temp memory area = (md)0x14000

(md)0x880-(md)0x1580 may be usable (untested)??
Avoid 15MB to 16MB as used by some BIOSes/chipsets as echo of 1MB-2MB area! (md)0x7800-7FFF

Avoid below (md)0x300 and (md)0x4000 to (md)0x7FFF area.
Preferably use (md)0x10000 and above (above 32MB). I have also used there areas without problems so far...
  • (md)0x200-(md)0x227 (20K)
  • (md)0x300-(md)0x3DF (114K)
  • (md)0x1F40-(md)0x3FFF (4M) I have used (md)0x3000-(md)0x3300 without problems
  • (md)0x9800-(md)0xBFFF (5M) If only using graphics mode 1024x768 or lower resolutions
  • (md)0x19000+ (50MB+) Should be always free

Use of around (md)0x8000 to 0x9800 can cause corruption of bitmap background when a menu is displayed in 1024x768 mode (even more used in higher res modes!).
However wenv/insmod seems to load files above 32MB - therefore use above 50MB = (md)0x19000 to be safe!

Many BIOSes use the last part of segment 9000:0 for a scratchpad. All IBM-compatible BIOSes use A000:0 - F000:FFFF.

Black areas are normally unused by grub4dos and IBM PC BIOS and hardware but are not necessarily safe to use!

(md) KB MB MEMORY SEGMENT ADDRESS
50 40 0.039 A000 000A00:0
60 48 0.0468 C000 000C00:0
80 64 0.0625 10000 001000:0
220 272 0.265