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
;
29 /* Head of the taglist */
30 tag
->hdr
.tag
= ATAG_CORE
;
31 tag
->hdr
.size
= tag_size(tag_core
);
32 tag
->u
.core
.flags
= 1;
33 tag
->u
.core
.pagesize
= PAGE_SIZE
;
34 tag
->u
.core
.rootdev
= 0;
36 /* Build up one tagged block for each memory region */
38 nr_banks
=(unsigned int) buffer
[0];
39 for (j
=0;j
<nr_banks
;j
++){
40 /* search the lowest address and put it into the next entry */
41 /* not a fast sort algorithm, but there are at most 8 entries */
42 /* and this is used only once anyway */
44 for (i
=0;i
<(unsigned int) buffer
[0];i
++){
45 if (buffer
[2*i
+1]<m
) {
52 tag
->hdr
.tag
= ATAG_MEM
;
53 tag
->hdr
.size
= tag_size(tag_mem32
);
54 tag
->u
.mem
.size
= buffer
[2*k
+2];
55 tag
->u
.mem
.start
= buffer
[2*k
+1];
57 size
+= buffer
[2*k
+2];
59 buffer
[2*k
+1]=0xffffffff; /* mark as copied */
62 /* The command line */
64 tag
->hdr
.tag
= ATAG_CMDLINE
;
66 c
=(unsigned char *)(&buffer
[34]);
68 while (*c
) tag
->u
.cmdline
.cmdline
[j
++]=*c
++;
70 tag
->u
.cmdline
.cmdline
[j
]=0;
71 tag
->hdr
.size
= (j
+ 7 + sizeof(struct tag_header
)) >> 2;
73 /* Hardware revision */
75 tag
->hdr
.tag
= ATAG_REVISION
;
76 tag
->hdr
.size
= tag_size(tag_revision
);
77 tag
->u
.revision
.rev
= ((unsigned char) buffer
[33])-'0';
79 /* End of the taglist */
86 typedef int (*ofw_handle_t
)(void *);
88 /* Everything below is called with a wrong MMU setting.
89 * This means: no string constants, no initialization of
90 * arrays, no global variables! This is ugly but I didn't
91 * want to write this in assembler :-)
95 of_decode_int(const unsigned char *p
)
97 unsigned int i
= *p
++ << 8;
104 OF_finddevice(ofw_handle_t openfirmware
, char *name
)
106 unsigned int args
[8];
121 args
[0]=(unsigned int)service
;
124 args
[3]=(unsigned int)name
;
126 if (openfirmware(args
) == -1)
132 OF_getproplen(ofw_handle_t openfirmware
, int handle
, char *prop
)
134 unsigned int args
[8];
149 args
[0] = (unsigned int)service
;
152 args
[3] = (unsigned int)handle
;
153 args
[4] = (unsigned int)prop
;
155 if (openfirmware(args
) == -1)
161 OF_getprop(ofw_handle_t openfirmware
, int handle
, char *prop
, void *buf
, unsigned int buflen
)
163 unsigned int args
[8];
175 args
[0] = (unsigned int)service
;
178 args
[3] = (unsigned int)handle
;
179 args
[4] = (unsigned int)prop
;
180 args
[5] = (unsigned int)buf
;
183 if (openfirmware(args
) == -1)
188 asmlinkage
void ofw_init(ofw_handle_t o
, int *nomr
, int *pointer
)
190 int phandle
,i
,mem_len
,buffer
[32];
202 phandle
=OF_finddevice(o
,temp
);
209 mem_len
= OF_getproplen(o
,phandle
, temp
);
210 OF_getprop(o
,phandle
, temp
, buffer
, mem_len
);
213 for (i
=0; i
<=mem_len
/4; i
++) pointer
[i
]=of_decode_int((const unsigned char *)&buffer
[i
]);
224 phandle
=OF_finddevice(o
,temp
);
236 mem_len
= OF_getproplen(o
,phandle
, temp
);
237 OF_getprop(o
,phandle
, temp
, buffer
, mem_len
);
238 if (mem_len
> 128) mem_len
=128;
239 for (i
=0; i
<=mem_len
/4; i
++) pointer
[i
+33]=buffer
[i
];
244 phandle
=OF_finddevice(o
,temp
);
257 mem_len
= OF_getproplen(o
,phandle
, temp
);
258 OF_getprop(o
,phandle
, temp
, buffer
, mem_len
);
259 * ((unsigned char *) &pointer
[32]) = ((unsigned char *) buffer
)[mem_len
-2];