Zero page cleanup

Martin Mares (mj@ucw.cz)
Tue, 8 Sep 1998 21:46:16 +0200


Hi Linus,

This patch cleans up handling of the zero page on i386 and adds a documentation
file explaining its layout (this should prevent people from breaking things
by overwriting unexpectedly placed variables -- it has already happened several
times). The PS/2 system description table got moved to a sane area and truncated
to 16 bytes (the kernel uses only first 4 bytes anyway).

Have a nice fortnight

-- 
Martin `MJ' Mares   <mj@ucw.cz>   http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
"You have new nail."

diff -uN /tmp/linux-mj/Documentation/i386/zero-page.txt linux/Documentation/i386/zero-page.txt --- /tmp/linux-mj/Documentation/i386/zero-page.txt Thu Jan 1 01:00:00 1970 +++ linux/Documentation/i386/zero-page.txt Sat Jun 6 11:24:25 1998 @@ -0,0 +1,73 @@ +Summary of empty_zero_page layout (kernel point of view) + ( collected by Hans Lermen and Martin Mares ) + +The contents of empty_zero_page are used to pass parameters from the +16-bit realmode code of the kernel to the 32-bit part. References/settings +to it mainly are in: + + arch/i386/boot/setup.S + arch/i386/boot/video.S + arch/i386/kernel/head.S + arch/i386/kernel/setup.c + + +Offset Type Description +------ ---- ----------- + 0 32 bytes struct screen_info, SCREEN_INFO + ATTENTION, overlaps the following !!! + 2 unsigned short EXT_MEM_K, extended memory size in Kb (from int 0x15) + 0x20 unsigned short CL_MAGIC, commandline magic number (=0xA33F) + 0x22 unsigned short CL_OFFSET, commandline offset + Address of commandline is calculated: + 0x90000 + contents of CL_OFFSET + (only taken, when CL_MAGIC = 0xA33F) + 0x40 20 bytes struct apm_bios_info, APM_BIOS_INFO + 0x80 16 bytes hd0-disk-parameter from intvector 0x41 + 0x90 16 bytes hd1-disk-parameter from intvector 0x46 + + 0xa0 16 bytes System description table truncated to 16 bytes. + ( struct sys_desc_table_struct ) + 0xb0 - 0x1df Free. Add more parameters here if you really need them. + +0x1e0 unsigned long ALT_MEM_K, alternative mem check, in Kb +0x1f1 char size of setup.S, number of sectors +0x1f2 unsigned short MOUNT_ROOT_RDONLY (if !=0) +0x1f4 unsigned short size of compressed kernel-part in the + (b)zImage-file (in 16 byte units, rounded up) +0x1f6 unsigned short swap_dev (unused AFAIK) +0x1f8 unsigned short RAMDISK_FLAGS +0x1fa unsigned short VGA-Mode (old one) +0x1fc unsigned short ORIG_ROOT_DEV (high=Major, low=minor) +0x1ff char AUX_DEVICE_INFO + +0x200 short jump to start of setup code aka "reserved" field. +0x202 4 bytes Signature for SETUP-header, ="HdrS" +0x206 unsigned short Version number of header format + Current version is 0x0201... +0x208 8 bytes (used by setup.S for communication with boot loaders, + look there) +0x210 char LOADER_TYPE, = 0, old one + else it is set by the loader: + 0xTV: T=0 for LILO + 1 for Loadlin + 2 for bootsect-loader + 3 for SYSLINUX + 4 for ETHERBOOT + V = version +0x211 char loadflags: + bit0 = 1: kernel is loaded high (bzImage) + bit7 = 1: Heap and pointer (see below) set by boot + loader. +0x212 unsigned short (setup.S) +0x214 unsigned long KERNEL_START, where the loader started the kernel +0x218 unsigned long INITRD_START, address of loaded ramdisk image +0x21c unsigned long INITRD_SIZE, size in bytes of ramdisk image +0x220 4 bytes (setup.S) +0x224 unsigned short setup.S heap end pointer +0x226 - 0x7ff setup.S code. + +0x800 string, 2K max COMMAND_LINE, the kernel commandline as + copied using CL_OFFSET. + Note: this will be copied once more by setup.c + into a local buffer which is only 256 bytes long. + ( #define COMMAND_LINE_SIZE 256 ) diff -uN /tmp/linux-mj/arch/i386/boot/setup.S linux/arch/i386/boot/setup.S --- /tmp/linux-mj/arch/i386/boot/setup.S Sat Sep 5 17:14:23 1998 +++ linux/arch/i386/boot/setup.S Tue Sep 8 10:23:07 1998 @@ -145,7 +145,7 @@ jne bad_sig jmp good_sig1 -! Routine to print ASCII string at DS:SI +! Routine to print ASCIIz string at DS:SI prtstr: lodsb and al,al @@ -345,7 +345,7 @@ mov ds,ax mov ds,ax xor ax,ax - mov [0x220], ax ! set table length to 0 + mov [0xa0], ax ! set table length to 0 mov ah, #0xc0 stc int 0x15 ! puts feature table at es:bx @@ -357,9 +357,13 @@ sub ax, #DELTA_INITSEG ! aka #INITSEG mov es,ax mov si,bx - mov di,#0x220 + mov di,#0xa0 mov cx,(si) add cx,#2 ! table length is a short + cmp cx,#0x10 + jc sysdesc_ok + mov cx,#0x10 ! we keep only first 16 bytes +sysdesc_ok: rep movsb pop ds diff -uN /tmp/linux-mj/arch/i386/kernel/setup.c linux/arch/i386/kernel/setup.c --- /tmp/linux-mj/arch/i386/kernel/setup.c Sat Sep 5 17:14:23 1998 +++ linux/arch/i386/kernel/setup.c Tue Sep 8 10:23:18 1998 @@ -86,13 +86,12 @@ * This is set up by the setup-routine at boot-time */ #define PARAM ((unsigned char *)empty_zero_page) +#define SCREEN_INFO (*(struct screen_info *) (PARAM+0)) #define EXT_MEM_K (*(unsigned short *) (PARAM+2)) #define ALT_MEM_K (*(unsigned long *) (PARAM+0x1e0)) -#ifdef CONFIG_APM -#define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAM+64)) -#endif +#define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAM+0x40)) #define DRIVE_INFO (*(struct drive_info_struct *) (PARAM+0x80)) -#define SCREEN_INFO (*(struct screen_info *) (PARAM+0)) +#define SYS_DESC_TABLE (*(struct sys_desc_table_struct*)(PARAM+0xa0)) #define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAM+0x1F2)) #define RAMDISK_FLAGS (*(unsigned short *) (PARAM+0x1F8)) #define ORIG_ROOT_DEV (*(unsigned short *) (PARAM+0x1FC)) @@ -101,7 +100,6 @@ #define KERNEL_START (*(unsigned long *) (PARAM+0x214)) #define INITRD_START (*(unsigned long *) (PARAM+0x218)) #define INITRD_SIZE (*(unsigned long *) (PARAM+0x21c)) -#define SYS_DESC_TABLE (*(struct sys_desc_table_struct*)(PARAM+0x220)) #define COMMAND_LINE ((char *) (PARAM+2048)) #define COMMAND_LINE_SIZE 256

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/faq.html