Commit | Line | Data |
---|---|---|
88278ca2 | 1 | /* |
1da177e4 LT |
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 | ||
1da177e4 LT |
9 | #include <linux/kernel.h> |
10 | #include <linux/init.h> | |
11 | ||
12 | #include <asm/openprom.h> | |
13 | #include <asm/oplib.h> | |
1da177e4 LT |
14 | |
15 | struct linux_romvec *romvec; | |
16 | enum prom_major_version prom_vers; | |
17 | unsigned int prom_rev, prom_prev; | |
1da177e4 LT |
18 | |
19 | /* The root node of the prom device tree. */ | |
20 | int prom_root_node; | |
21 | ||
1da177e4 LT |
22 | /* Pointer to the device tree operations structure. */ |
23 | struct linux_nodeops *prom_nodeops; | |
24 | ||
25 | /* You must call prom_init() before you attempt to use any of the | |
26 | * routines in the prom library. It returns 0 on success, 1 on | |
27 | * failure. It gets passed the pointer to the PROM vector. | |
28 | */ | |
29 | ||
30 | extern void prom_meminit(void); | |
31 | extern void prom_ranges_init(void); | |
32 | ||
33 | void __init prom_init(struct linux_romvec *rp) | |
34 | { | |
1da177e4 LT |
35 | romvec = rp; |
36 | ||
37 | switch(romvec->pv_romvers) { | |
38 | case 0: | |
39 | prom_vers = PROM_V0; | |
40 | break; | |
41 | case 2: | |
42 | prom_vers = PROM_V2; | |
43 | break; | |
44 | case 3: | |
45 | prom_vers = PROM_V3; | |
46 | break; | |
1da177e4 LT |
47 | default: |
48 | prom_printf("PROMLIB: Bad PROM version %d\n", | |
49 | romvec->pv_romvers); | |
50 | prom_halt(); | |
51 | break; | |
52 | }; | |
53 | ||
54 | prom_rev = romvec->pv_plugin_revision; | |
55 | prom_prev = romvec->pv_printrev; | |
56 | prom_nodeops = romvec->pv_nodeops; | |
57 | ||
58 | prom_root_node = prom_getsibling(0); | |
59 | if((prom_root_node == 0) || (prom_root_node == -1)) | |
60 | prom_halt(); | |
61 | ||
62 | if((((unsigned long) prom_nodeops) == 0) || | |
63 | (((unsigned long) prom_nodeops) == -1)) | |
64 | prom_halt(); | |
65 | ||
1da177e4 LT |
66 | prom_meminit(); |
67 | ||
68 | prom_ranges_init(); | |
69 | ||
1da177e4 LT |
70 | printk("PROMLIB: Sun Boot Prom Version %d Revision %d\n", |
71 | romvec->pv_romvers, prom_rev); | |
1da177e4 LT |
72 | |
73 | /* Initialization successful. */ | |
74 | return; | |
75 | } |