1708d4f09SSam Ravnborg /* 2708d4f09SSam Ravnborg * init.c: Initialize internal variables used by the PROM 3708d4f09SSam Ravnborg * library functions. 4708d4f09SSam Ravnborg * 5708d4f09SSam Ravnborg * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 6708d4f09SSam Ravnborg * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 7708d4f09SSam Ravnborg */ 8708d4f09SSam Ravnborg 9708d4f09SSam Ravnborg #include <linux/kernel.h> 10708d4f09SSam Ravnborg #include <linux/init.h> 116943f3daSSam Ravnborg #include <linux/module.h> 12708d4f09SSam Ravnborg 13708d4f09SSam Ravnborg #include <asm/openprom.h> 14708d4f09SSam Ravnborg #include <asm/oplib.h> 15708d4f09SSam Ravnborg 16708d4f09SSam Ravnborg struct linux_romvec *romvec; 176943f3daSSam Ravnborg EXPORT_SYMBOL(romvec); 186943f3daSSam Ravnborg 19708d4f09SSam Ravnborg enum prom_major_version prom_vers; 20708d4f09SSam Ravnborg unsigned int prom_rev, prom_prev; 21708d4f09SSam Ravnborg 22708d4f09SSam Ravnborg /* The root node of the prom device tree. */ 238d125562SAndres Salomon phandle prom_root_node; 246943f3daSSam Ravnborg EXPORT_SYMBOL(prom_root_node); 25708d4f09SSam Ravnborg 26708d4f09SSam Ravnborg /* Pointer to the device tree operations structure. */ 27708d4f09SSam Ravnborg struct linux_nodeops *prom_nodeops; 28708d4f09SSam Ravnborg 29708d4f09SSam Ravnborg /* You must call prom_init() before you attempt to use any of the 30708d4f09SSam Ravnborg * routines in the prom library. It returns 0 on success, 1 on 31708d4f09SSam Ravnborg * failure. It gets passed the pointer to the PROM vector. 32708d4f09SSam Ravnborg */ 33708d4f09SSam Ravnborg 34708d4f09SSam Ravnborg extern void prom_meminit(void); 35708d4f09SSam Ravnborg extern void prom_ranges_init(void); 36708d4f09SSam Ravnborg 37708d4f09SSam Ravnborg void __init prom_init(struct linux_romvec *rp) 38708d4f09SSam Ravnborg { 39708d4f09SSam Ravnborg romvec = rp; 40708d4f09SSam Ravnborg 41708d4f09SSam Ravnborg switch(romvec->pv_romvers) { 42708d4f09SSam Ravnborg case 0: 43708d4f09SSam Ravnborg prom_vers = PROM_V0; 44708d4f09SSam Ravnborg break; 45708d4f09SSam Ravnborg case 2: 46708d4f09SSam Ravnborg prom_vers = PROM_V2; 47708d4f09SSam Ravnborg break; 48708d4f09SSam Ravnborg case 3: 49708d4f09SSam Ravnborg prom_vers = PROM_V3; 50708d4f09SSam Ravnborg break; 51708d4f09SSam Ravnborg default: 52708d4f09SSam Ravnborg prom_printf("PROMLIB: Bad PROM version %d\n", 53708d4f09SSam Ravnborg romvec->pv_romvers); 54708d4f09SSam Ravnborg prom_halt(); 55708d4f09SSam Ravnborg break; 56708d4f09SSam Ravnborg }; 57708d4f09SSam Ravnborg 58708d4f09SSam Ravnborg prom_rev = romvec->pv_plugin_revision; 59708d4f09SSam Ravnborg prom_prev = romvec->pv_printrev; 60708d4f09SSam Ravnborg prom_nodeops = romvec->pv_nodeops; 61708d4f09SSam Ravnborg 62708d4f09SSam Ravnborg prom_root_node = prom_getsibling(0); 63*4a3a2552SAndres Salomon if ((prom_root_node == 0) || ((s32)prom_root_node == -1)) 64708d4f09SSam Ravnborg prom_halt(); 65708d4f09SSam Ravnborg 66708d4f09SSam Ravnborg if((((unsigned long) prom_nodeops) == 0) || 67708d4f09SSam Ravnborg (((unsigned long) prom_nodeops) == -1)) 68708d4f09SSam Ravnborg prom_halt(); 69708d4f09SSam Ravnborg 70708d4f09SSam Ravnborg prom_meminit(); 71708d4f09SSam Ravnborg 72708d4f09SSam Ravnborg prom_ranges_init(); 73708d4f09SSam Ravnborg 74708d4f09SSam Ravnborg printk("PROMLIB: Sun Boot Prom Version %d Revision %d\n", 75708d4f09SSam Ravnborg romvec->pv_romvers, prom_rev); 76708d4f09SSam Ravnborg 77708d4f09SSam Ravnborg /* Initialization successful. */ 78708d4f09SSam Ravnborg } 79