Messages in this thread | | | Date | Fri, 29 May 1998 22:55:06 +0200 (MEST) | From | Hans Lermen <> | Subject | Re: empty_zero_page+setup on intel? |
| |
On Fri, 29 May 1998, Gerd Knorr wrote:
> Is there anywhere documented who uses which area of the empty_zero_page?
AFAIK only in the source, but I've appended a summary.
> The page which is used to pass some parameters from real to protected > mode. I checked arch/i386/kernel/setup.c. Looks like struct screen_info > starts at offset zero, next one is struct apm_bios_info at offset 64.
arch/i386/kernel/head.S tells you what is copied:
/* * Copy bootup parameters out of the way. First 2kB of * _empty_zero_page is for boot parameters, second 2kB * is for the command line. */
First one (offset 0) is the bootsector (512 bytes), some info in it is overwritten by the bootloader and/or setup.S, the rest is 'as is left'. So you will find all the params, that can be given to a kernel image via rdev. The kernel doesn't use all, but what it uses should be defined at line 86 of arch/i386/kernel/setup.c, among them:
#define PARAM empty_zero_page #define SCREEN_INFO (*(struct screen_info *) (PARAM+0)) #define EXT_MEM_K (*(unsigned short *) (PARAM+2)) #define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAM+64))
EXT_MEM_K is what is called 'unused1' in struct screen_info. However, there is also unused2, unused3 which I guess you should not touch.
However, BEHIND screen_info and BEFORE APM_BIOS_INFO there is what is defined in arch/i386/kernel/head.S:
#define CL_MAGIC_ADDR 0x90020 #define CL_OFFSET 0x90022
which is equivalent to
#define CL_MAGIC_ADDR (*(unsigned short *) (PARAM+0x20)) #define CL_OFFSET (*(unsigned short *) (PARAM+0x22))
If you overwrite that, the commandline will not be copied !! arch/i386/kernel/head.S:
cmpw $(CL_MAGIC),CL_MAGIC_ADDR jne 1f movl $ SYMBOL_NAME(empty_zero_page)+2048,%edi movzwl CL_OFFSET,%esi addl $(CL_BASE_ADDR),%esi movl $2048,%ecx rep movsb 1:
Next 512 bytes (offset 0x200) is the arch/i386/boot/setup.S header. This header was intended to be extendable for future needs (there is a header version for this), but someone without knowing this did place
#define SYS_DESC_TABLE (*(struct sys_desc_table_struct*)(PARAM+0x220))
directly within this header :-(((
For more details look at arch/i386/boot/setup.S, lines 117 and 342.
> In the meantime I noticed, it does break something. It is impossible to > pass any command line parameters if I boot up my box in graphics mode. > I suspect this is because the area between screen_info and apm_bios_info > is *not* free, but used by somebody else. But I don't know where to look > for it... > > Any Idea?
I guess the CL_* from above broke that.
Ok, in order to not do the work twice, I'll append a summary, that should perhaps go some where under linux/Documents. Anyone seeing something I missed, should complain now ( Martin ?) ;-)
Summary of empty_zero_page layout (kernel point of view) -------------------------------------------------------
Offset Type Description ------ ---- ----------- 0 18 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 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 setup.S header 0x202 4 bytes Signature for SETUP-header, ="HdrS" 0x206 unsigned short Version number of header format 0x208 8 bytes (used by setup.S) 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) 0x212 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 ??? struct sys_desc_table_struct, SYS_DESC_TABLE NOTE: This structure of variable size overlays the setup.S header, which originally has been designed to be expandable in the future. IMHO this should be fixed before 2.2 !
0x800 string, 2K max COMMAND_LINE, the kernel commandline as copied using CL_OFFSET. Note: this will be copied once more setup.c into a local buffer which is only 256 bytes long. ( #define COMMAND_LINE_SIZE 256 )
Hans <lermen@fgan.de>
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu
| |