init_32.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * init.c: Initialize internal variables used by the PROM
  3. * library functions.
  4. *
  5. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  6. * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/init.h>
  10. #include <linux/module.h>
  11. #include <asm/openprom.h>
  12. #include <asm/oplib.h>
  13. struct linux_romvec *romvec;
  14. EXPORT_SYMBOL(romvec);
  15. enum prom_major_version prom_vers;
  16. unsigned int prom_rev, prom_prev;
  17. /* The root node of the prom device tree. */
  18. phandle prom_root_node;
  19. EXPORT_SYMBOL(prom_root_node);
  20. /* Pointer to the device tree operations structure. */
  21. struct linux_nodeops *prom_nodeops;
  22. /* You must call prom_init() before you attempt to use any of the
  23. * routines in the prom library.
  24. * It gets passed the pointer to the PROM vector.
  25. */
  26. void __init prom_init(struct linux_romvec *rp)
  27. {
  28. romvec = rp;
  29. switch(romvec->pv_romvers) {
  30. case 0:
  31. prom_vers = PROM_V0;
  32. break;
  33. case 2:
  34. prom_vers = PROM_V2;
  35. break;
  36. case 3:
  37. prom_vers = PROM_V3;
  38. break;
  39. default:
  40. prom_printf("PROMLIB: Bad PROM version %d\n",
  41. romvec->pv_romvers);
  42. prom_halt();
  43. break;
  44. }
  45. prom_rev = romvec->pv_plugin_revision;
  46. prom_prev = romvec->pv_printrev;
  47. prom_nodeops = romvec->pv_nodeops;
  48. prom_root_node = prom_getsibling(0);
  49. if ((prom_root_node == 0) || ((s32)prom_root_node == -1))
  50. prom_halt();
  51. if((((unsigned long) prom_nodeops) == 0) ||
  52. (((unsigned long) prom_nodeops) == -1))
  53. prom_halt();
  54. prom_meminit();
  55. prom_ranges_init();
  56. printk("PROMLIB: Sun Boot Prom Version %d Revision %d\n",
  57. romvec->pv_romvers, prom_rev);
  58. /* Initialization successful. */
  59. }