2 * Copyright (C) 1996 The Australian National University.
3 * Copyright (C) 1996 Fujitsu Laboratories Limited
4 * Copyright (C) 1997 Michael A. Griffith (grif@acm.org)
5 * Copyright (C) 1997 Sun Weenie (ko@ko.reno.nv.us)
6 * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
8 * This software may be distributed under the terms of the Gnu
9 * Public License version 2 or later
11 * fake a really simple Sun prom for the SUN4
14 #include <linux/kernel.h>
15 #include <linux/string.h>
16 #include <asm/oplib.h>
17 #include <asm/idprom.h>
18 #include <asm/machines.h>
19 #include <asm/sun4prom.h>
21 #include <asm/contregs.h>
22 #include <linux/init.h>
24 static struct linux_romvec sun4romvec
;
25 static struct idprom sun4_idprom
;
35 struct property
*properties
;
38 struct property null_properties
= { NULL
, NULL
, -1 };
40 struct property root_properties
[] = {
41 {"device_type", "cpu", 4},
42 {"idprom", (char *)&sun4_idprom
, sizeof(struct idprom
)},
46 struct node nodes
[] = {
47 { 0, &null_properties
},
48 { 0, root_properties
},
49 { -1,&null_properties
}
53 static int no_nextnode(int node
)
55 if (nodes
[node
].level
== nodes
[node
+1].level
)
60 static int no_child(int node
)
62 if (nodes
[node
].level
== nodes
[node
+1].level
-1)
67 static struct property
*find_property(int node
,char *name
)
69 struct property
*prop
= &nodes
[node
].properties
[0];
70 while (prop
&& prop
->name
) {
71 if (strcmp(prop
->name
,name
) == 0) return prop
;
77 static int no_proplen(int node
,char *name
)
79 struct property
*prop
= find_property(node
,name
);
80 if (prop
) return prop
->length
;
84 static int no_getprop(int node
,char *name
,char *value
)
86 struct property
*prop
= find_property(node
,name
);
88 memcpy(value
,prop
->value
,prop
->length
);
94 static int no_setprop(int node
,char *name
,char *value
,int len
)
99 static char *no_nextprop(int node
,char *name
)
101 struct property
*prop
= find_property(node
,name
);
102 if (prop
) return prop
[1].name
;
106 static struct linux_nodeops sun4_nodeops
= {
115 static int synch_hook
;
117 struct linux_romvec
* __init
sun4_prom_init(void)
123 p
= (char *)&sun4_idprom
;
124 for (i
= 0; i
< sizeof(sun4_idprom
); i
++) {
125 __asm__
__volatile__ ("lduba [%1] %2, %0" : "=r" (x
) :
126 "r" (AC_IDPROM
+ i
), "i" (ASI_CONTROL
));
130 memset(&sun4romvec
,0,sizeof(sun4romvec
));
132 sun4_romvec
= (linux_sun4_romvec
*) SUN4_PROM_VECTOR
;
134 sun4romvec
.pv_romvers
= 40;
135 sun4romvec
.pv_nodeops
= &sun4_nodeops
;
136 sun4romvec
.pv_reboot
= sun4_romvec
->reboot
;
137 sun4romvec
.pv_abort
= sun4_romvec
->abortentry
;
138 sun4romvec
.pv_halt
= sun4_romvec
->exittomon
;
139 sun4romvec
.pv_synchook
= (void (**)(void))&synch_hook
;
140 sun4romvec
.pv_setctxt
= sun4_romvec
->setcxsegmap
;
141 sun4romvec
.pv_v0bootargs
= sun4_romvec
->bootParam
;
142 sun4romvec
.pv_nbgetchar
= sun4_romvec
->mayget
;
143 sun4romvec
.pv_nbputchar
= sun4_romvec
->mayput
;
144 sun4romvec
.pv_stdin
= sun4_romvec
->insource
;
145 sun4romvec
.pv_stdout
= sun4_romvec
->outsink
;
148 * We turn on the LEDs to let folks without monitors or
149 * terminals know we booted. Nothing too fancy now. They
150 * are all on, except for LED 5, which blinks. When we
151 * have more time, we can teach the penguin to say "By your
152 * command" or "Activating turbo boost, Michael". :-)
154 sun4_romvec
->setLEDs(NULL
);
156 printk("PROMLIB: Old Sun4 boot PROM monitor %s, romvec version %d\n",
158 sun4_romvec
->romvecversion
);