diff -Naurp linux-2.6.13.orig/arch/mips/Kconfig linux-2.6.13/arch/mips/Kconfig --- linux-2.6.13.orig/arch/mips/Kconfig 2005-08-29 22:16:43.000000000 -0400 +++ linux-2.6.13/arch/mips/Kconfig 2005-08-29 22:19:22.000000000 -0400 @@ -1634,6 +1634,24 @@ endmenu source "net/Kconfig" +menu "MIPS initrd options" + depends on BLK_DEV_INITRD + +config EMBEDDED_RAMDISK + bool "Embed root filesystem ramdisk into the kernel" + +config EMBEDDED_RAMDISK_IMAGE + string "Filename of gziped ramdisk image" + depends on EMBEDDED_RAMDISK + default "ramdisk.gz" + help + This is the filename of the ramdisk image to be built into the + kernel. Relative pathnames are relative to arch/mips/ramdisk/. + The ramdisk image is not part of the kernel distribution; you must + provide one yourself. + +endmenu + source "drivers/Kconfig" source "fs/Kconfig" diff -Naurp linux-2.6.13.orig/arch/mips/Makefile linux-2.6.13/arch/mips/Makefile --- linux-2.6.13.orig/arch/mips/Makefile 2005-08-29 22:16:45.000000000 -0400 +++ linux-2.6.13/arch/mips/Makefile 2005-08-29 22:19:22.000000000 -0400 @@ -254,6 +254,14 @@ libs-$(CONFIG_ARC) += arch/mips/arc/ libs-$(CONFIG_SIBYTE_CFE) += arch/mips/sibyte/cfe/ # +# ramdisk/initrd support +# You need a compressed ramdisk image, named +# CONFIG_EMBEDDED_RAMDISK_IMAGE. Relative pathnames +# are relative to arch/mips/ramdisk/. +# +core-$(CONFIG_EMBEDDED_RAMDISK) += arch/mips/ramdisk/ + +# # Board-dependent options and extra files # diff -Naurp linux-2.6.13.orig/arch/mips/kernel/setup.c linux-2.6.13/arch/mips/kernel/setup.c --- linux-2.6.13.orig/arch/mips/kernel/setup.c 2005-08-29 22:16:43.000000000 -0400 +++ linux-2.6.13/arch/mips/kernel/setup.c 2005-08-29 22:23:53.000000000 -0400 @@ -58,6 +58,8 @@ unsigned int PCI_DMA_BUS_IS_PHYS; EXPORT_SYMBOL(PCI_DMA_BUS_IS_PHYS); +extern void * __rd_start, * __rd_end; + /* * Setup information * @@ -194,68 +196,6 @@ static inline void parse_cmdline_early(v } } -static inline int parse_rd_cmdline(unsigned long* rd_start, unsigned long* rd_end) -{ - /* - * "rd_start=0xNNNNNNNN" defines the memory address of an initrd - * "rd_size=0xNN" it's size - */ - unsigned long start = 0; - unsigned long size = 0; - unsigned long end; - char cmd_line[CL_SIZE]; - char *start_str; - char *size_str; - char *tmp; - - strcpy(cmd_line, command_line); - *command_line = 0; - tmp = cmd_line; - /* Ignore "rd_start=" strings in other parameters. */ - start_str = strstr(cmd_line, "rd_start="); - if (start_str && start_str != cmd_line && *(start_str - 1) != ' ') - start_str = strstr(start_str, " rd_start="); - while (start_str) { - if (start_str != cmd_line) - strncat(command_line, tmp, start_str - tmp); - start = memparse(start_str + 9, &start_str); - tmp = start_str + 1; - start_str = strstr(start_str, " rd_start="); - } - if (*tmp) - strcat(command_line, tmp); - - strcpy(cmd_line, command_line); - *command_line = 0; - tmp = cmd_line; - /* Ignore "rd_size" strings in other parameters. */ - size_str = strstr(cmd_line, "rd_size="); - if (size_str && size_str != cmd_line && *(size_str - 1) != ' ') - size_str = strstr(size_str, " rd_size="); - while (size_str) { - if (size_str != cmd_line) - strncat(command_line, tmp, size_str - tmp); - size = memparse(size_str + 8, &size_str); - tmp = size_str + 1; - size_str = strstr(size_str, " rd_size="); - } - if (*tmp) - strcat(command_line, tmp); - -#ifdef CONFIG_64BIT - /* HACK: Guess if the sign extension was forgotten */ - if (start > 0x0000000080000000 && start < 0x00000000ffffffff) - start |= 0xffffffff00000000; -#endif - - end = start + size; - if (start && end) { - *rd_start = start; - *rd_end = end; - return 1; - } - return 0; -} #define PFN_UP(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT) #define PFN_DOWN(x) ((x) >> PAGE_SHIFT) @@ -269,40 +209,30 @@ static inline void bootmem_init(void) unsigned long start_pfn; unsigned long reserved_end = (unsigned long)&_end; #ifndef CONFIG_SGI_IP27 - unsigned long first_usable_pfn; - unsigned long bootmap_size; + unsigned long bootmap_size, max_low_pfn, first_usable_pfn; int i; #endif #ifdef CONFIG_BLK_DEV_INITRD - int initrd_reserve_bootmem = 0; + unsigned long tmp; + u32 *initrd_header; - /* Board specific code should have set up initrd_start and initrd_end */ - ROOT_DEV = Root_RAM0; - if (parse_rd_cmdline(&initrd_start, &initrd_end)) { - reserved_end = max(reserved_end, initrd_end); - initrd_reserve_bootmem = 1; - } else { - unsigned long tmp; - u32 *initrd_header; - - tmp = ((reserved_end + PAGE_SIZE-1) & PAGE_MASK) - sizeof(u32) * 2; - if (tmp < reserved_end) - tmp += PAGE_SIZE; - initrd_header = (u32 *)tmp; - if (initrd_header[0] == 0x494E5244) { - initrd_start = (unsigned long)&initrd_header[2]; - initrd_end = initrd_start + initrd_header[1]; - reserved_end = max(reserved_end, initrd_end); - initrd_reserve_bootmem = 1; - } + tmp = ((reserved_end + (PAGE_SIZE - 1)) & PAGE_MASK) - sizeof(u32) * 2; + if (tmp < reserved_end) + tmp += PAGE_SIZE; + initrd_header = (u32 *)tmp; + if (initrd_header[0] == 0x494E5244) { + initrd_start = (unsigned long)&initrd_header[2]; + initrd_end = initrd_start + initrd_header[1]; } -#endif /* CONFIG_BLK_DEV_INITRD */ + start_pfn = PFN_UP(kernel_physaddr(reserved_end + (initrd_end - initrd_start) + PAGE_SIZE)); +#else /* * Partially used pages are not usable - thus * we are rounding upwards. */ - start_pfn = PFN_UP(CPHYSADDR(reserved_end)); + start_pfn = PFN_UP(kernel_physaddr(reserved_end)); +#endif /* CONFIG_BLK_DEV_INITRD */ #ifndef CONFIG_SGI_IP27 /* Find the highest page frame number we have available. */ @@ -417,14 +347,21 @@ static inline void bootmem_init(void) /* Reserve the bootmap memory. */ reserve_bootmem(PFN_PHYS(first_usable_pfn), bootmap_size); -#endif /* CONFIG_SGI_IP27 */ +#endif #ifdef CONFIG_BLK_DEV_INITRD + /* Board specific code should have set up initrd_start and initrd_end */ + ROOT_DEV = Root_RAM0; + if (&__rd_start != &__rd_end) { + initrd_start = (unsigned long)&__rd_start; + initrd_end = (unsigned long)&__rd_end; + } initrd_below_start_ok = 1; if (initrd_start) { unsigned long initrd_size = ((unsigned char *)initrd_end) - ((unsigned char *)initrd_start); printk("Initial ramdisk at: 0x%p (%lu bytes)\n", - (void *)initrd_start, initrd_size); + (void *)initrd_start, + initrd_size); if (CPHYSADDR(initrd_end) > PFN_PHYS(max_low_pfn)) { printk("initrd extends beyond end of memory " @@ -434,11 +371,7 @@ static inline void bootmem_init(void) sizeof(long) * 2, (unsigned long long)PFN_PHYS(max_low_pfn)); initrd_start = initrd_end = 0; - initrd_reserve_bootmem = 0; } - - if (initrd_reserve_bootmem) - reserve_bootmem(CPHYSADDR(initrd_start), initrd_size); } #endif /* CONFIG_BLK_DEV_INITRD */ } diff -Naurp linux-2.6.13.orig/arch/mips/kernel/vmlinux.lds.S linux-2.6.13/arch/mips/kernel/vmlinux.lds.S --- linux-2.6.13.orig/arch/mips/kernel/vmlinux.lds.S 2005-08-29 22:16:43.000000000 -0400 +++ linux-2.6.13/arch/mips/kernel/vmlinux.lds.S 2005-08-29 22:19:22.000000000 -0400 @@ -54,6 +54,13 @@ SECTIONS *(.data) + /* Align the initial ramdisk image (INITRD) on page boundaries. */ + . = ALIGN(4096); + __rd_start = .; + *(.initrd) + . = ALIGN(4096); + __rd_end = .; + CONSTRUCTORS } _gp = . + 0x8000; diff -Naurp linux-2.6.13.orig/arch/mips/ramdisk/Makefile linux-2.6.13/arch/mips/ramdisk/Makefile --- linux-2.6.13.orig/arch/mips/ramdisk/Makefile 1969-12-31 19:00:00.000000000 -0500 +++ linux-2.6.13/arch/mips/ramdisk/Makefile 2005-08-29 22:19:22.000000000 -0400 @@ -0,0 +1,11 @@ +# +# Makefile for a ramdisk image +# + +obj-y += ramdisk.o + + +img := $(subst ",,$(CONFIG_EMBEDDED_RAMDISK_IMAGE)) +img := $(subst $(src)//,/,$(src)/$(img)) + +EXTRA_AFLAGS="-DMIPS_EMBEDDED_RAMDISK=\"$(img)\"" diff -Naurp linux-2.6.13.orig/arch/mips/ramdisk/ramdisk.S linux-2.6.13/arch/mips/ramdisk/ramdisk.S --- linux-2.6.13.orig/arch/mips/ramdisk/ramdisk.S 1969-12-31 19:00:00.000000000 -0500 +++ linux-2.6.13/arch/mips/ramdisk/ramdisk.S 2005-08-29 22:19:22.000000000 -0400 @@ -0,0 +1,8 @@ +/* + * For a detailed explanation of this file, see usr/initramfs_data.S in + * the root of this source tree. + */ + +.section .initrd,"a" +.incbin MIPS_EMBEDDED_RAMDISK +