add port definition for mcf UART driver
[linux-2.6/next.git] / arch / um / kernel / initrd.c
blob16dc43e9d940e305bfe2f42a9a5c35be05eb0a9c
1 /*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
6 #include "linux/init.h"
7 #include "linux/bootmem.h"
8 #include "linux/initrd.h"
9 #include "asm/types.h"
10 #include "kern_util.h"
11 #include "initrd.h"
12 #include "init.h"
13 #include "os.h"
15 /* Changed by uml_initrd_setup, which is a setup */
16 static char *initrd __initdata = NULL;
18 static int __init read_initrd(void)
20 void *area;
21 long long size;
22 int err;
24 if(initrd == NULL)
25 return 0;
27 err = os_file_size(initrd, &size);
28 if(err)
29 return 0;
31 area = alloc_bootmem(size);
32 if(area == NULL)
33 return 0;
35 if(load_initrd(initrd, area, size) == -1)
36 return 0;
38 initrd_start = (unsigned long) area;
39 initrd_end = initrd_start + size;
40 return 0;
43 __uml_postsetup(read_initrd);
45 static int __init uml_initrd_setup(char *line, int *add)
47 initrd = line;
48 return 0;
51 __uml_setup("initrd=", uml_initrd_setup,
52 "initrd=<initrd image>\n"
53 " This is used to boot UML from an initrd image. The argument is the\n"
54 " name of the file containing the image.\n\n"
57 int load_initrd(char *filename, void *buf, int size)
59 int fd, n;
61 fd = os_open_file(filename, of_read(OPENFLAGS()), 0);
62 if(fd < 0){
63 printk("Opening '%s' failed - err = %d\n", filename, -fd);
64 return -1;
66 n = os_read_file(fd, buf, size);
67 if(n != size){
68 printk("Read of %d bytes from '%s' failed, err = %d\n", size,
69 filename, -n);
70 return -1;
73 os_close_file(fd);
74 return 0;