attempt to remove misc-embedded.c
RFC 1/1 attempt to remove misc-embedded.c
Hi Tom,
This is an attempt to move remove misc-embedded.c by moving its quirks to misc.c.
It needs further fixing and cleaning, for sure.
Are there any major disagreements about the change? Might need to define a bd_t structure for all ppc's?
PS: it crashes right after
loaded at: 00002120 00C8744C relocated to: 00400020 0108534C board data at: 01083130 0108334C relocated to: 0040522C 00405448 zimage at: 00405D49 0050E525 initrd at: 0050F000 01082C6E avail ram: 01086000 08000000
Linux/PPC load: root=/dev/ram rw
Uncompressing Linux...
done.
Now booting the kernel
BDI>i
Target state : debug mode
Debug entry cause : machine check interrupt
Current PC : 0x00001280
Data address : 0x24702000
DSISR value : 0x0000014aBDI>
but shouldnt be a major thing (I haven't figured what it is).
misc.c renamed from mnt/test1/tslinux_mv21-CVS/linux-2.6/arch/ppc/boot/simple/misc.c +65 -6
@@ -25,7 +25,10 @@#include <asm/bootinfo.h> #ifdef CONFIG_44x#include <asm/ibm4xx.h> +#elif CONFIG_8xx +#include <asm/mpc8xx.h> #endif +#include <asm/reg.h> #include "nonstdio.h"
@@ -54,6 +57,16 @@ || defined(CONFIG_SERIAL_MPSC_CONSOLE)) \ && !defined(CONFIG_GEMINI)#define INTERACTIVE_CONSOLE 1 + + + +#ifdef CONFIG_EMBEDDEDBOOT +/* We need to make sure that this is before the images to ensure +* that it's in a mapped location. - Tom */ +bd_t hold_resid_buf __attribute__ ((__section__ (".data.boot"))); +bd_t *hold_residual = &hold_resid_buf; +char ramroot_string[] ="root=/dev/ram rw" ; +char netroot_string[] ="root=/dev/nfs rw ip=on" ;#endif char *avail_ram;
@@ -88,8 +101,16 @@return 0 ; } +/* Weak function for boards which don't need to build the +* board info struct because they are using PPCBoot/U-Boot. +*/ +void __attribute__ ((weak)) +embed_config (bd_t **bdp) +{ +} +struct bi_record * -decompress_kernel (unsigned long load_addr,int num_words,unsigned long cksum) +decompress_kernel (unsigned long load_addr,int num_words,unsigned long cksum,bd_t *bp) {#ifdef INTERACTIVE_CONSOLE int timer =0 ;
@@ -99,8 +120,9 @@struct bi_record *rec;unsigned long initrd_loc =0 , TotalMemory =0 ; -#if defined(CONFIG_SERIAL_8250_CONSOLE ) || defined(CONFIG_SERIAL_MPSC_CONSOLE ) - com_port =serial_init (0 ,NULL ); +embed_config (&bp); +#if defined(CONFIG_SERIAL_CONSOLE ) || defined(CONFIG_SERIAL_MPSC_CONSOLE ) + com_port =serial_init (0 , bp);#endif #if defined(CONFIG_44x) && defined(PPC44x_EMAC0_MR0)
@@ -112,6 +134,18 @@ *(volatile unsigned long *)PPC44x_EMAC0_MR0 =0x20000000 ; __asm__ __volatile__("eieio" );#endif +#ifdef CONFIG_MBX +/* Because of the way the MBX loads the ELF image, we can't +* tell where we started. We read a magic variable from the NVRAM +* that gives us the intermediate buffer load address. +*/ + load_addr = *(uint *)0xfa000020 ; + load_addr +=0x10000 ;/* Skip ELF header */ +#endif +#ifdef CONFIG_EMBEDDEDBOOT +if (bp) +memcpy (hold_residual,bp,sizeof (bd_t)); +#endif /* * Call get_mem_size(), which is memory controller dependent,
@@ -119,8 +153,15 @@*/ TotalMemory =get_mem_size (); +#ifdef CONFIG_EMBEDDEDBOOT +/* Set end of memory available to us. It is always the highest +* memory address provided by the board information. +*/ + end_avail = (char *)(bp->bi_memsize); +#else /* assume the chunk below 8M is free */ end_avail = (char *)0x00800000 ; +#endif /* * Reveal where we were loaded at and where we
@@ -136,6 +177,16 @@puthex ((unsigned long )((unsigned long )&start + (4 *num_words)));puts ("\n" ); } +if (bp) { +puts ("board data at: " );puthex ((unsigned long )bp); +puts (" " ); +puthex ((unsigned long )((unsigned long )bp +sizeof (bd_t))); +puts ("\nrelocated to: " ); +puthex ((unsigned long )hold_residual); +puts (" " ); +puthex ((unsigned long )((unsigned long )hold_residual +sizeof (bd_t))); +puts ("\n" ); + }/* * We link ourself to 0x00800000. When we run, we relocate
@@ -163,9 +214,10 @@puthex ((unsigned long )(&__ramdisk_begin));puts (" " );puthex ((unsigned long )(&__ramdisk_end));puts ("\n" ); } - +#ifndef CONFIG_EMBEDDEDBOOT avail_ram = (char *)0x00400000 ; end_avail = (char *)0x00800000 ; +#endif puts ("avail ram: " );puthex ((unsigned long )avail_ram);puts (" " );puthex ((unsigned long )end_avail);puts ("\n" );
@@ -181,11 +233,17 @@if ( (cmd_line[0 ] =='\0' ) && (cmd_preset[0 ] !='\0' ))memcpy (cmd_line, cmd_preset,sizeof (cmd_preset));#endif +#ifdef CONFIG_EMBEDDEDBOOT +if ( initrd_size ) +memcpy (cmd_line, ramroot_string,sizeof (ramroot_string)); +else +memcpy (cmd_line, netroot_string,sizeof (netroot_string)); +#endif /* Display standard Linux/PPC boot prompt for kernel args */ puts ("\nLinux/PPC load: " ); cp = cmd_line; -memcpy (cmd_line, cmd_preset,sizeof (cmd_preset)); +// memcpy (cmd_line, cmd_preset, sizeof(cmd_preset)); while ( *cp )putc (*cp++);#ifdef INTERACTIVE_CONSOLE
@@ -224,6 +282,7 @@puts ("Uncompressing Linux..." );gunzip (0x0 ,0x400000 , zimage_start, &zimage_size);puts ("done.\n" ); +flush_instruction_cache ();/* get the bi_rec address */ rec =bootinfo_addr (zimage_size);
@@ -280,5 +339,5 @@ void *ign1, void *ign2) {board_isa_init (); -return decompress_kernel (load_addr, num_words, cksum); +return decompress_kernel (load_addr, num_words, cksum, ign1); }
Quoted 7 lines · Marcelo Tosatti
Hi Tom,
This is an attempt to move remove
misc-embedded.cby moving its quirks tomisc.c.It needs further fixing and cleaning, for sure.
I like the idea of deleting misc-embedded.c, but I don't think we should haven't make many changes to misc.c (except perhaps abstracting away a few more hunks of it) as I _think_ most of the cpu-specific stuff can be moved around now to the misc-board.c files.
Quoted 2 lines
Are there any major disagreements about the change? Might need to define a
bd_tstructure for all ppc's?
That's something to be left for the flat OF tree thread. :)
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 8 lines · Tom Rini
Quoted 6 lines · Marcelo Tosatti
Hi Tom,
This is an attempt to move remove
misc-embedded.cby moving its quirks tomisc.c.
Quoted 6 lines
Quoted 1 line
It needs further fixing and cleaning, for sure.
I like the idea of deleting
misc-embedded.c, but I don't think we should haven't make many changes tomisc.c(except perhaps abstracting away a few more hunks of it) as I _think_ most of the cpu-specific stuff can be moved around now to themisc-board.cfiles.
So the plan is to move all cpu specific code in decompress_kernel() to cpu specific code :)
Including
#ifdef CONFIG_44x
/* Reset MAL */
mtdcr(DCRN_MALCR(DCRN_MAL_BASE), MALCR_MMSR);
/* Wait for reset */
while (mfdcr(DCRN_MALCR(DCRN_MAL_BASE)) & MALCR_MMSR) {};
/* Reset EMAC */
*(volatile unsigned long *)PPC44x_EMAC0_MR0 = 0x20000000;
__asm__ __volatile__("eieio");#endif
There are a few changes which are required for embedded targets, for example, passing "bd" to serial_init as its 2nd argument.
Some misc-embedded.c requirements also need to be there, in decompress_kernel().
For example
+#ifdef CONFIG_EMBEDDEDBOOT
+ /* Set end of memory available to us. It is always the highest
+ * memory address provided by the board information.
+ */
+ end_avail = (char *)(bp->bi_memsize);
+#else
/* assume the chunk below 8M is free */
end_avail = (char *)0x00800000;+#endif
And later "end_avail" setting need to be abstracted away.
Is that what you mean?
Quoted 8 lines
Quoted 2 lines
Are there any major disagreements about the change? Might need to define a
bd_tstructure for all ppc's?That's something to be left for the flat OF tree thread. :)
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 12 lines · Marcelo Tosatti
So the plan is to move all cpu specific code in
decompress_kernel()to cpu specific code :)Including
#ifdef CONFIG_44x /* Reset MAL */ mtdcr(DCRN_MALCR(DCRN_MAL_BASE), MALCR_MMSR); /* Wait for reset */ while (mfdcr(DCRN_MALCR(DCRN_MAL_BASE)) & MALCR_MMSR) {}; /* Reset EMAC */ *(volatile unsigned long *)PPC44x_EMAC0_MR0 = 0x20000000; __asm__ __volatile__("eieio");
Quoted 1 line
#endif
Hmm, strange, 2.4 has this code already moved to misc-44x.c, I wonder why this change never made it to 2.6.
Marcelo, I assume you are going to make this look like 2.4, right?
Signature · 1 line
Eugene
Quoted 15 lines · Eugene Surovegin
Quoted 12 lines · Marcelo Tosatti
So the plan is to move all cpu specific code in
decompress_kernel()to cpu specific code :)Including
#ifdef CONFIG_44x /* Reset MAL */ mtdcr(DCRN_MALCR(DCRN_MAL_BASE), MALCR_MMSR); /* Wait for reset */ while (mfdcr(DCRN_MALCR(DCRN_MAL_BASE)) & MALCR_MMSR) {}; /* Reset EMAC */ *(volatile unsigned long *)PPC44x_EMAC0_MR0 = 0x20000000; __asm__ __volatile__("eieio");Quoted 1 line
#endif
Quoted 4 lines
Hmm, strange, 2.4 has this code already moved to
misc-44x.c, I wonder why this change never made it to 2.6.Marcelo, I assume you are going to make this look like 2.4, right?
Sure, that looks better.
Ok, so we can just make something minimal as misc-4xx, for 8xx, and have everything which can be outside decompress_kernel() there.
One immediate advantage would be the INTERACTIVE_CONSOLE option.
Quoted 19 lines · Marcelo Tosatti
Quoted 18 lines · Eugene Surovegin
Quoted 12 lines · Marcelo Tosatti
So the plan is to move all cpu specific code in
decompress_kernel()to cpu specific code :)Including
#ifdef CONFIG_44x /* Reset MAL */ mtdcr(DCRN_MALCR(DCRN_MAL_BASE), MALCR_MMSR); /* Wait for reset */ while (mfdcr(DCRN_MALCR(DCRN_MAL_BASE)) & MALCR_MMSR) {}; /* Reset EMAC */ *(volatile unsigned long *)PPC44x_EMAC0_MR0 = 0x20000000; __asm__ __volatile__("eieio");Quoted 1 line
#endif
Hmm, strange, 2.4 has this code already moved to
misc-44x.c, I wonder why this change never made it to 2.6.
Quoted 6 lines
Quoted 1 line
Marcelo, I assume you are going to make this look like 2.4, right?
Sure, that looks better.
Ok, so we can just make something minimal as misc-4xx, for 8xx, and have everything which can be outside
decompress_kernel()there.
Yes, I think we're starting to understand eachother, as that sounds like what I was talking about.
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/