init_32.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. It returns 0 on success, 1 on
  24. * failure. It gets passed the pointer to the PROM vector.
  25. */
  26. extern void prom_meminit(void);
  27. extern void prom_ranges_init(void);
  28. void __init prom_init(struct linux_romvec *rp)
  29. {
  30. romvec = rp;
  31. switch(romvec->pv_romvers) {
  32. case 0:
  33. prom_vers = PROM_V0;
  34. break;
  35. case 2:
  36. prom_vers = PROM_V2;
  37. break;
  38. case 3:
  39. prom_vers = PROM_V3;
  40. break;
  41. default:
  42. prom_printf("PROMLIB: Bad PROM version %d\n",
  43. romvec->pv_romvers);
  44. prom_halt();
  45. break;
  46. }
  47. prom_rev = romvec->pv_plugin_revision;
  48. prom_prev = romvec->pv_printrev;
  49. prom_nodeops = romvec->pv_nodeops;
  50. prom_root_node = prom_getsibling(0);
  51. if ((prom_root_node == 0) || ((s32)prom_root_node == -1))
  52. prom_halt();
  53. if((((unsigned long) prom_nodeops) == 0) ||
  54. (((unsigned long) prom_nodeops) == -1))
  55. prom_halt();
  56. prom_meminit();
  57. prom_ranges_init();
  58. printk("PROMLIB: Sun Boot Prom Version %d Revision %d\n",
  59. romvec->pv_romvers, prom_rev);
  60. /* Initialization successful. */
  61. }