--- loader/i386/pc/linux.c.orig 2009-02-11 10:56:27.000000000 +0100 +++ loader/i386/pc/linux.c 2009-02-11 10:56:38.000000000 +0100 @@ -30,6 +30,7 @@ #include #include #include +#include #define GRUB_LINUX_CL_OFFSET 0x9000 #define GRUB_LINUX_CL_END_OFFSET 0x90FF @@ -38,11 +39,15 @@ static grub_size_t linux_mem_size; static int loaded; +static char* kernel_cl_space = NULL; +#define GRUB_LINUX_CL_MAX_SIZE 0x1000 /* maximum defined for linux kernels */ static grub_err_t grub_linux_unload (void) { grub_dl_unref (my_mod); + grub_free(kernel_cl_space); + kernel_cl_space = NULL; loaded = 0; return GRUB_ERR_NONE; } @@ -119,9 +124,14 @@ lh.loadflags |= GRUB_LINUX_FLAG_CAN_USE_HEAP; } - if (grub_le_to_cpu16 (lh.version) >= 0x0202) - lh.cmd_line_ptr = grub_linux_real_addr + GRUB_LINUX_CL_OFFSET; - else + if (grub_le_to_cpu16 (lh.version) >= 0x0202) { + if (grub_le_to_cpu16 (lh.version) >= 0x0206) { + kernel_cl_space = grub_malloc(lh.cmdline_size+1); + } else { + kernel_cl_space = grub_malloc(GRUB_LINUX_CL_MAX_SIZE); + } + lh.cmd_line_ptr = kernel_cl_space; + } else { lh.cl_magic = grub_cpu_to_le16 (GRUB_LINUX_CL_MAGIC); lh.cl_offset = grub_cpu_to_le16 (GRUB_LINUX_CL_OFFSET); @@ -245,16 +255,29 @@ ((GRUB_LINUX_MAX_SETUP_SECTS - setup_sects - 1) << GRUB_DISK_SECTOR_BITS)); + /* Choose the command line area */ + char* cl_end; + if (kernel_cl_space) { + dest = kernel_cl_space; + if (grub_le_to_cpu16 (lh.version) >= 0x0206) { + cl_end = dest + lh.cmdline_size; + } else { + cl_end = dest + GRUB_LINUX_CL_MAX_SIZE - 1; + } + } else { + dest = grub_linux_tmp_addr + GRUB_LINUX_CL_OFFSET; + cl_end = grub_linux_tmp_addr + GRUB_LINUX_CL_END_OFFSET; + } + /* Specify the boot file. */ - dest = grub_stpcpy (grub_linux_tmp_addr + GRUB_LINUX_CL_OFFSET, + dest = grub_stpcpy (dest, "BOOT_IMAGE="); dest = grub_stpcpy (dest, argv[0]); /* Copy kernel parameters. */ for (i = 1; i < argc - && dest + grub_strlen (argv[i]) + 1 < (grub_linux_tmp_addr - + GRUB_LINUX_CL_END_OFFSET); + && dest + grub_strlen (argv[i]) + 1 < cl_end; i++) { *dest++ = ' '; --- include/grub/i386/linux.h.orig 2009-02-11 10:43:01.000000000 +0100 +++ include/grub/i386/linux.h 2009-02-11 10:50:33.000000000 +0100 @@ -123,6 +123,15 @@ grub_uint16_t pad1; /* Unused */ char *cmd_line_ptr; /* Points to the kernel command line */ grub_uint32_t initrd_addr_max; /* Highest address for initrd */ + /* 2.05+ */ + grub_uint32_t kernel_alignment; /* Physical addr alignment required for kernel */ + grub_uint8_t relocatable_kernel; /* Whether kernel is relocatable or not */ + grub_uint8_t pad2[3]; /* Unused */ + /* 2.06+ */ + grub_uint32_t cmdline_size; /* Maximum size of the kernel command line */ + /* 2.07+ */ + grub_uint32_t hardware_subarch; /* Hardware subarchitecture */ + grub_uint64_t hardware_subarch_data; /* Subarchitecture-specific data */ } __attribute__ ((packed)); /* Boot parameters for Linux based on 2.6.12. This is used by the setup