# # first.i86 - constants for assembler module # # Copyright (C) 1995-2003 Gero Kuhlmann # Copyright (C) 1996,1997 Gero Kuhlmann # and Markus Gutschke # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # $Id: first.i86,v 1.1 2003/03/09 00:43:10 gkminix Exp $ # #==================================================================== # # Include some required files from the i386 runtime library # #include "ldrec.i86" #include "bootp.i86" # #==================================================================== # # Definitions for allocating dynamic memory, which is used to hold # temporary working buffers. # # The MAX_MEM segment address must be within the range of addresses # contained in MIN_MEM number of kB. # LINUX_MEM .equ H'9000 # Standard Linux load segment HIGH_MEM .equ H'9A00 # Highest Linux segment (see boot.txt) MAX_MEM .equ H'8000 # Maximum usable segment (see SPEC.DOC) BASE_MEM .equ H'1000 # Base segment for low-loading kernel MIN_MEM .equ (HIGH_MEM / 64) # Minimum number of kB of base mem SECTSIZE .equ 512 # Size of one block of setup code LINUX_HEAP .equ 2048 # Size of linux setup heap CMDL_SIZE .equ 2048 # Size of static command line memory .aif MIN_STK_SIZE lt 4096 STACK_SIZE .equ 4096 # Size of stack memory .aelse STACK_SIZE .equ MIN_STK_SIZE # Use minimum stack size of i386 lib .aendi # Segment of Linux setup SETUP_SEG .equ (LINUX_MEM + (SECTSIZE / 16)) # Maximum size of static memory MAX_STATIC_SIZE .equ ((HIGH_MEM - LINUX_MEM) * 16) # These two constants are predefined within the Linux kernel KERNEL_LD_HIGH .equ H'00100000 # kernel high load address KERNEL_LD_LOW .equ H'00001000 # kernel low load address MAX_PATH_LEN .equ 1024 # Maximum length of path name MAX_ADDRS_LEN .equ 512 # Maximum length of IP addr string # #==================================================================== # # Vendor information for the boot rom image. These values have to be # identical to those in mknbi.h. # VENDOR_MAGIC .assignc "GK-mknbi-linux" # vendor ID VENDOR_SIZE .equ 4 # size of vendor ID in dwords VENDOR_BOOTL .equ LOADER_TAG + 0 # tag for boot loader segment VENDOR_CMDL .equ LOADER_TAG + 1 # tag for command line segment VENDOR_INIT .equ LOADER_TAG + 2 # tag for floppy boot sector VENDOR_SETUP .equ LOADER_TAG + 3 # tag for kernel setup segment VENDOR_KERNEL .equ LOADER_TAG + 4 # tag for kernel segment VENDOR_RAMDISK .equ LOADER_TAG + 5 # tag for ramdisk image # #==================================================================== # # Ramdisk images can be loaded in three different ways: # RD_AUTO -- The ramdisk image is loaded at either $100000 or right # behind the kernel image; at run-time it will be moved # to the end of physical memory or right before $1000000. # This technique guarantees maximum compatibility with # broken BIOS versions without making assumptions on the # way, the BOOT-Prom determined the end of memory. The # drawback is, that moving the image costs some extra time. # RD_EOM -- The ramdisk image is loaded right before the end of # physical memory. It is the BOOT-Proms responsibility to do # this reliably. This might cause problems with some ancient # BIOS versions, if the computer is equipped with more then # 16M of main memory. # RD_FIXED -- The user provided a fixed load address for the ramdisk # image. This entails possible compatibility restrictions # when moving the image from one client to another. OTOH, # it could be the final solution if everything else fails... # RD_AUTO .equ 0 RD_EOM .equ 1 RD_FIXED .equ 2 # #==================================================================== # # Kernel vendor flags # # KRN_USE_IP -- Newer kernels (above 2.2.x) use "ip=" instead of # "nfsaddrs=" on the command line. They should also # never remove this option if "kernel" is given as # the argument. We use this flag to tell the boot # loader. # KRN_NFS_IP -- Kernel versions 2.4.x and above need the address # of the NFS server at the beginning of the nfsroot # command line option # KRN_LOW -- The kernel has to be copied into low memory # KRN_USE_IP .equ B'00000001 KRN_NFS_IP .equ B'00000010 KRN_LOW .equ B'00000100 # #==================================================================== # # Define some special BOOTP vendor tags # BOOTP_RFC_VID .equ 128 # Vendor tag: magic identification BOOTP_RFC_CMDAD .equ 129 # Addition to kernel command line BOOTP_RFC_RDEV .equ 130 # Device by which to find root FS BOOTP_RFC_VSEL .equ 176 # index to user selected image BOOTP_VID_ID .equ H'687445E4 # #==================================================================== # # The command line descriptor is placed in the floppy boot sector area # and looks like this: # # 0x90020-0x90021 2 bytes command line magic number # 0x90022-0x90023 2 bytes command line offs. relative to floppy boot sec # 0x901FA-0x901FB 2 bytes video mode # CL_MAGIC_ADDR .equ H'20 # command line magic number CL_MAGIC .equ H'A33F # very unusual command sequence CL_OFFSET .equ H'22 # command line offset VGA_OFFSET .equ H'1FA # video mode # #==================================================================== # # The setup-header has to be changed in order to tell the kernel about a # loaded ramdisk image # # +2 4 bytes setup magic number # +6 2 bytes setup version number # +12 2 bytes segment of low-loaded kernel # +16 1 byte type of loader # +17 1 byte load flags # bit 0: loaded high # bit 7: can use heap # +18 2 bytes setup move size # +20 4 bytes protected mode start address # +24 4 bytes ramdisk image start address # +28 4 bytes ramdisk image size # +32 4 bytes floppy loader helper routine pointer # +36 2 bytes heap pointer # +40 4 bytes pointer to command line (for version 2.01+) # # This only works with Linux kernels 1.3.73 or above; that is why the # setup magic number and the setup version number need to be verified # before relying on the layout of this data structure. # SU_MAGIC_ADDR .equ 2 SU_VERSION_ADDR .equ 6 SU_SYS_SEG .equ 12 SU_TYPE_OF_LOADER .equ 16 SU_LOAD_FLAGS .equ 17 SU_MOVE_SIZE .equ 18 SU_32_START .equ 20 SU_RAMDISK_START .equ 24 SU_RAMDISK_SIZE .equ 28 SU_HEAP .equ 36 SU_CMDL_PTR .equ 40 SU_MAGIC .equ H'53726448 SU_VERSION_OLD .equ H'0201 SU_VERSION_NEW .equ H'0202 SU_MY_TYPE_OF_LOADER .equ H'41 SU_LDFLAGS_HIGH .equ B'00000001 SU_LDFLAGS_HEAP .equ B'10000000