2 * linux/arch/arm/boot/compressed/ofw-shark.c
6 * This file is used to get some basic information
7 * about the memory layout of the shark we are running
8 * on. Memory is usually divided in blocks a 8 MB.
9 * And bootargs are copied from OpenFirmware.
13 #include <linux/kernel.h>
14 #include <linux/types.h>
15 #include <asm/setup.h>
20 create_params (unsigned long *buffer
)
22 /* Is there a better address? Also change in mach-shark/core.c */
23 struct tag
*tag
= (struct tag
*) 0x08003000;
24 int j
,i
,m
,k
,nr_banks
,size
;
27 /* Head of the taglist */
28 tag
->hdr
.tag
= ATAG_CORE
;
29 tag
->hdr
.size
= tag_size(tag_core
);
30 tag
->u
.core
.flags
= 1;
31 tag
->u
.core
.pagesize
= PAGE_SIZE
;
32 tag
->u
.core
.rootdev
= 0;
34 /* Build up one tagged block for each memory region */
36 nr_banks
=(unsigned int) buffer
[0];
37 for (j
=0;j
<nr_banks
;j
++){
38 /* search the lowest address and put it into the next entry */
39 /* not a fast sort algorithm, but there are at most 8 entries */
40 /* and this is used only once anyway */
42 for (i
=0;i
<(unsigned int) buffer
[0];i
++){
43 if (buffer
[2*i
+1]<m
) {
50 tag
->hdr
.tag
= ATAG_MEM
;
51 tag
->hdr
.size
= tag_size(tag_mem32
);
52 tag
->u
.mem
.size
= buffer
[2*k
+2];
53 tag
->u
.mem
.start
= buffer
[2*k
+1];
55 size
+= buffer
[2*k
+2];
57 buffer
[2*k
+1]=0xffffffff; /* mark as copied */
60 /* The command line */
62 tag
->hdr
.tag
= ATAG_CMDLINE
;
64 c
=(unsigned char *)(&buffer
[34]);
66 while (*c
) tag
->u
.cmdline
.cmdline
[j
++]=*c
++;
68 tag
->u
.cmdline
.cmdline
[j
]=0;
69 tag
->hdr
.size
= (j
+ 7 + sizeof(struct tag_header
)) >> 2;
71 /* Hardware revision */
73 tag
->hdr
.tag
= ATAG_REVISION
;
74 tag
->hdr
.size
= tag_size(tag_revision
);
75 tag
->u
.revision
.rev
= ((unsigned char) buffer
[33])-'0';
77 /* End of the taglist */
84 typedef int (*ofw_handle_t
)(void *);
86 /* Everything below is called with a wrong MMU setting.
87 * This means: no string constants, no initialization of
88 * arrays, no global variables! This is ugly but I didn't
89 * want to write this in assembler :-)
93 of_decode_int(const unsigned char *p
)
95 unsigned int i
= *p
++ << 8;
102 OF_finddevice(ofw_handle_t openfirmware
, char *name
)
104 unsigned int args
[8];
119 args
[0]=(unsigned int)service
;
122 args
[3]=(unsigned int)name
;
124 if (openfirmware(args
) == -1)
130 OF_getproplen(ofw_handle_t openfirmware
, int handle
, char *prop
)
132 unsigned int args
[8];
147 args
[0] = (unsigned int)service
;
150 args
[3] = (unsigned int)handle
;
151 args
[4] = (unsigned int)prop
;
153 if (openfirmware(args
) == -1)
159 OF_getprop(ofw_handle_t openfirmware
, int handle
, char *prop
, void *buf
, unsigned int buflen
)
161 unsigned int args
[8];
173 args
[0] = (unsigned int)service
;
176 args
[3] = (unsigned int)handle
;
177 args
[4] = (unsigned int)prop
;
178 args
[5] = (unsigned int)buf
;
181 if (openfirmware(args
) == -1)
186 asmlinkage
void ofw_init(ofw_handle_t o
, int *nomr
, int *pointer
)
188 int phandle
,i
,mem_len
,buffer
[32];
200 phandle
=OF_finddevice(o
,temp
);
207 mem_len
= OF_getproplen(o
,phandle
, temp
);
208 OF_getprop(o
,phandle
, temp
, buffer
, mem_len
);
211 for (i
=0; i
<=mem_len
/4; i
++) pointer
[i
]=of_decode_int((const unsigned char *)&buffer
[i
]);
222 phandle
=OF_finddevice(o
,temp
);
234 mem_len
= OF_getproplen(o
,phandle
, temp
);
235 OF_getprop(o
,phandle
, temp
, buffer
, mem_len
);
236 if (mem_len
> 128) mem_len
=128;
237 for (i
=0; i
<=mem_len
/4; i
++) pointer
[i
+33]=buffer
[i
];
242 phandle
=OF_finddevice(o
,temp
);
255 mem_len
= OF_getproplen(o
,phandle
, temp
);
256 OF_getprop(o
,phandle
, temp
, buffer
, mem_len
);
257 (unsigned char) pointer
[32] = ((unsigned char *) buffer
)[mem_len
-2];