--- ac_clean/arch/um/include/user_util.h Sun Apr 22 12:59:17 2001 +++ ac/arch/um/include/user_util.h Sun Apr 22 13:21:45 2001 @@ -146,6 +146,7 @@ extern void ptrace_cont_pid(int pid); extern void create_pid_file(char *name); extern void remap_profiling_buffers(void); +extern int load_initrd(char *filename, void *buf, int size); #endif /* --- ac_clean/arch/um/kernel/mem.c Sun Apr 22 12:59:17 2001 +++ ac/arch/um/kernel/mem.c Sun Apr 22 13:22:37 2001 @@ -108,13 +108,19 @@ #ifdef CONFIG_BLK_DEV_INITRD -/* It's unclear to me whether the area start -> end is in kernel memory, so - * this does nothing for now... - */ - void free_initrd_mem(unsigned long start, unsigned long end) { + if (start < end) + printk ("Freeing initrd memory: %ldk freed\n", + (end - start) >> 10); + for (; start < end; start += PAGE_SIZE) { + ClearPageReserved(virt_to_page(start)); + set_page_count(virt_to_page(start), 1); + free_page(start); + totalram_pages++; + } } + #endif int do_check_pgt_cache(int low, int high) --- ac_clean/arch/um/kernel/um_arch.c Sun Apr 22 12:59:17 2001 +++ ac/arch/um/kernel/um_arch.c Sun Apr 22 13:33:27 2001 @@ -11,6 +11,9 @@ #include "linux/bootmem.h" #include "linux/spinlock.h" #include "linux/utsname.h" +#ifdef CONFIG_BLK_DEV_INITRD +#include "linux/blk.h" +#endif #include "asm/page.h" #include "asm/pgtable.h" #include "asm/ptrace.h" @@ -158,6 +161,22 @@ exit(0); } +#ifdef CONFIG_BLK_DEV_INITRD +static void read_initrd(char *initrd) +{ + void *area; + int size; + + size = file_size(initrd); + if(size == -1) return; + area = alloc_bootmem(size); + if(area == NULL) return; + if(load_initrd(initrd, area, size) == -1) return; + initrd_start = (unsigned long) area; + initrd_end = initrd_start + size; +} +#endif + extern unsigned long _stext, _etext, _sdata, _edata, __bss_start, _end; extern int debug_trace; @@ -171,6 +190,9 @@ unsigned int i, have_root, add; char *retptr; void *sp; +#ifdef CONFIG_BLK_DEV_INITRD + char *initrd = NULL; +#endif remap_data(ROUND_DOWN(&_stext), ROUND_UP(&_etext)); remap_data(ROUND_DOWN(&_sdata), ROUND_UP(&_edata)); @@ -223,6 +245,10 @@ else if(!strcmp(argv[i], "--help")){ Usage(); } +#ifdef CONFIG_BLK_DEV_INITRD + else if(!strncmp(argv[i], "initrd=", strlen("initrd="))) + initrd = &argv[i][strlen("initrd=")]; +#endif if(add) add_arg(saved_command_line, argv[i]); } if(have_root == 0) add_arg(saved_command_line, DEFAULT_COMMAND_LINE); @@ -247,11 +273,14 @@ free_bootmem(__pa(physmem) + bootmap_size, high_physmem - physmem - bootmap_size); +#ifdef CONFIG_BLK_DEV_INITRD + if(initrd != NULL) read_initrd(initrd); +#endif init_task.thread.kernel_stack = (unsigned long) &init_task + 2 * PAGE_SIZE; -#ifndef __SMP__ +#ifndef CONFIG_SMP current = &init_task; -#endif +#endif protect(((unsigned long) &init_task) + PAGE_SIZE, PAGE_SIZE, 0, 0, 0); stack_protections(init_task.thread.kernel_stack, 2 * PAGE_SIZE); sp = (void *) init_task.thread.kernel_stack + 2 * PAGE_SIZE - --- ac_clean/arch/um/kernel/user_util.c Sun Apr 22 12:59:17 2001 +++ ac/arch/um/kernel/user_util.c Sun Apr 22 13:33:58 2001 @@ -182,6 +182,22 @@ return(buf.st_size); } +int load_initrd(char *filename, void *buf, int size) +{ + int fd, n; + + if((fd = open(filename, O_RDONLY)) == -1){ + printk("Opening '%s' failed - errno = %d\n", filename, errno); + return(-1); + } + if((n = read(fd, buf, size)) != size){ + printk("Read of %d bytes from '%s' returned %d, errno = %d\n", + size, filename, n, errno); + return(-1); + } + return(0); +} + void stop(void) { while(1) sleep(1000000); --- ac_clean/include/asm-um/unistd.h Sun Apr 22 13:01:03 2001 +++ ac/include/asm-um/unistd.h Sun Apr 22 13:49:42 2001 @@ -46,6 +46,11 @@ #include "asm/arch/unistd.h" +static inline pid_t wait(int * wait_stat) +{ + return waitpid(-1,wait_stat,0); +} + #ifdef __SAVE_KERNEL_SYSCALLS__ #define __KERNEL_SYSCALLS__ __SAVE_KERNEL_SYSCALLS__ #endif