initrd_kern.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
  3. * Licensed under the GPL
  4. */
  5. #include "linux/init.h"
  6. #include "linux/bootmem.h"
  7. #include "linux/initrd.h"
  8. #include "asm/types.h"
  9. #include "user_util.h"
  10. #include "kern_util.h"
  11. #include "initrd.h"
  12. #include "init.h"
  13. #include "os.h"
  14. /* Changed by uml_initrd_setup, which is a setup */
  15. static char *initrd __initdata = NULL;
  16. static int __init read_initrd(void)
  17. {
  18. void *area;
  19. long long size;
  20. int err;
  21. if(initrd == NULL) return 0;
  22. err = os_file_size(initrd, &size);
  23. if(err) return 0;
  24. area = alloc_bootmem(size);
  25. if(area == NULL) return 0;
  26. if(load_initrd(initrd, area, size) == -1) return 0;
  27. initrd_start = (unsigned long) area;
  28. initrd_end = initrd_start + size;
  29. return 0;
  30. }
  31. __uml_postsetup(read_initrd);
  32. static int __init uml_initrd_setup(char *line, int *add)
  33. {
  34. initrd = line;
  35. return 0;
  36. }
  37. __uml_setup("initrd=", uml_initrd_setup,
  38. "initrd=<initrd image>\n"
  39. " This is used to boot UML from an initrd image. The argument is the\n"
  40. " name of the file containing the image.\n\n"
  41. );
  42. /*
  43. * Overrides for Emacs so that we follow Linus's tabbing style.
  44. * Emacs will notice this stuff at the end of the file and automatically
  45. * adjust the settings for this buffer only. This must remain at the end
  46. * of the file.
  47. * ---------------------------------------------------------------------------
  48. * Local variables:
  49. * c-file-style: "linux"
  50. * End:
  51. */