Linux zImage layout

Layout of the first bytes of a zImage and the image in memory at Linux boot:

 ------------|--------|-----------------------------------------------
 file-offset | memory | comment
 (hex)       |        |
 ------------|--------|-----------------------------------------------
             |  01000 | Swapper_pg_dir
             |  02000 | pg0 , page 0
             |  03000 | empty_bad_page
             |  04000 | empty_bad_page_table
             |  05000 | empty_zero_page
             |        | Starting here, "head.s", the start32-code,
             |        |  copies:
             |        |   First 2Kb from 90000 to 05000
             |        |   2Kb of command line to 05800
             |        |   (see below: CL_OFFSET)
             |        |  NOTE: Because this page is available only
             |        |       during the first few steps of kernel
             |        |       initialization, the kernel (main.c)
             |        |       copies the command line to a static buffer
             |        |       "command_line" of only 80 bytes!
             |        |       You MUST patch it, if the resulting
             |        |       command line size is greater or the
             |        |       kernel will hang!  (>=1.0.5 is fixed)
             |  10000 | Start of Linux kernel (boot/head.s)
             |        |
             |  7c000 | Here the BIOS normally loads a boot sector
 0000 - 0200 |  90000 | Bootsector (512 bytes)
             |        |
             |        | Within this, BEFORE setup has run:
 01F2 - WORD |  901f2 |   MOUNT_ROOT_RDONLY, =0 "rw" else "ro"
 01F8 - WORD |  901f8 |   RAM-DISK size
 01FA - WORD |  901fa |   VGA-Mode
             |        |         -3 = ask
             |        |         -2 = Extended VGA
             |        |         -1 = Normal VGA
             |        |          0 = as "0" was entered
             |        |          n = as "n" was entered
 01FC - WORD |  901fc |   Root Device (high=Major, low=minor)
 01FE - WORD |  901fe |   Bootsector magic (0x55aa)
             |        |
             |        | Within this, AFTER setup has run:
             |  90000 |   Saved cursor position
             |  90002 |   Extended memory size in Kb (from int 0x15)
             |  90080 |   hd0-disk-parameter from intvector 0x41
             |  90090 |   hd1-disk-parameter from intvector 0x46
             |  90020 |   CL_MAGIC, WORD, commandline magic number (=0xA33F)
             |  90022 |   CL_OFFSET, WORD, commandline offset
             |        |   Address of commandline is calculated:
             |        |    0x90000 + contents of 0x90022
             |        |   The command line is parsed by "init/main.c"
             |        |   Value of NAME=XXXX is put into the environment
             |        |   and can then be interpreted by the drivers
             |        |   and /etc/rc. The variable "root=xxxx" is
             |        |   interpreted by main.c directly, "single" is
             |        |   interpreted by init or simpleinit.
 0200 - 09ff |  90200 | setup routine ( 2Kb )
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License