From c7fc24dc4420057f103afe8fc64524ebc25c5d37 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 25 Aug 1998 09:12:35 +0000 Subject: o Merge with Linux 2.1.116. o New Newport console code. o New G364 console code. --- arch/ppc/boot/misc.c | 144 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 111 insertions(+), 33 deletions(-) (limited to 'arch/ppc/boot/misc.c') diff --git a/arch/ppc/boot/misc.c b/arch/ppc/boot/misc.c index 33c7c3e0d..869fb9f1d 100644 --- a/arch/ppc/boot/misc.c +++ b/arch/ppc/boot/misc.c @@ -1,5 +1,7 @@ /* * misc.c + * + * $Id: misc.c,v 1.49 1998/07/26 21:29:15 geert Exp $ * * Adapted for PowerPC by Gary Thomas * @@ -11,22 +13,23 @@ #include "asm/residual.h" #include #include +#include +#include +#include #ifdef CONFIG_MBX #include bd_t hold_board_info; #endif -/* this is where the INITRD gets moved to for safe keeping */ -#define INITRD_DESTINATION /*0x00f00000*/ 0x01800000 -#ifdef CONFIG_8xx -char *avail_ram = (char *) 0x00200000; -char *end_avail = (char *) 0x00400000; -#else /* CONFIG_8xx */ -/* this will do for now - Cort */ -char *avail_ram = (char *) 0x00800000; /* start with 8M */ -/* assume 15M max since this is where we copy the initrd to -- Cort */ -char *end_avail = (char *) INITRD_DESTINATION; -#endif /* CONFIG_8xx */ +/* + * Please send me load/board info and such data for hardware not + * listed here so I can keep track since things are getting tricky + * with the different load addrs with different firmware. This will + * help to avoid breaking the load/boot process. + * -- Cort + */ +char *avail_ram; +char *end_avail; char cmd_line[256]; RESIDUAL hold_residual; @@ -306,31 +309,53 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, R extern unsigned long start; char *cp, ch; unsigned long i; + BATU *u; + BATL *l; lines = 25; cols = 80; orig_x = 0; orig_y = 24; + - -#ifndef CONFIG_8xx +#ifndef CONFIG_MBX + /* + * IBM's have the MMU on, so we have to disable it or + * things get really unhappy in the kernel when + * trying to setup the BATs with the MMU on + * -- Cort + */ + flush_instruction_cache(); + _put_HID0(_get_HID0() & ~0x0000C000); + _put_MSR(_get_MSR() & ~0x0030); vga_init(0xC0000000); - /* copy the residual data */ + if (residual) memcpy(&hold_residual,residual,sizeof(RESIDUAL)); -#endif /* CONFIG_8xx */ -#ifdef CONFIG_MBX +#else /* CONFIG_MBX */ /* copy board data */ if (residual) _bcopy((char *)residual, (char *)&hold_board_info, sizeof(hold_board_info)); -#endif /* CONFIG_8xx */ - +#endif /* CONFIG_MBX */ + + /* MBX/prep sometimes put the residual/board info at the end of mem + * assume 16M for now -- Cort + */ + end_avail = (char *)0x01000000; + /* let residual data tell us it's higher */ + if ( (unsigned long)residual > 0x00800000 ) + end_avail = (char *)PAGE_ALIGN((unsigned long)residual); puts("loaded at: "); puthex(load_addr); puts(" "); puthex((unsigned long)(load_addr + (4*num_words))); puts("\n"); - puts("relocated to: "); puthex((unsigned long)&start); - puts(" "); puthex((unsigned long)((unsigned long)&start + (4*num_words))); puts("\n"); + if ( (unsigned long)load_addr != (unsigned long)&start ) + { + puts("relocated to: "); puthex((unsigned long)&start); + puts(" "); + puthex((unsigned long)((unsigned long)&start + (4*num_words))); + puts("\n"); + } if ( residual ) { @@ -357,33 +382,85 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, R puts("\n"); } + /* we have to subtract 0x10000 here to correct for objdump including the + size of the elf header which we strip -- Cort */ zimage_start = (char *)(load_addr - 0x10000 + ZIMAGE_OFFSET); zimage_size = ZIMAGE_SIZE; - puts("zimage at: "); puthex((unsigned long)zimage_start); - puts(" "); puthex((unsigned long)(zimage_size+zimage_start)); puts("\n"); if ( INITRD_OFFSET ) initrd_start = load_addr - 0x10000 + INITRD_OFFSET; else initrd_start = 0; initrd_end = INITRD_SIZE + initrd_start; - + + /* + * setup avail_ram - this is the first part of ram usable + * by the uncompress code. -- Cort + */ + avail_ram = (char *)PAGE_ALIGN((unsigned long)zimage_start+zimage_size); + if ( ((load_addr+(num_words*4)) > (unsigned long) avail_ram) + && (load_addr <= 0x01000000) ) + avail_ram = (char *)(load_addr+(num_words*4)); + if ( (((unsigned long)&start+(num_words*4)) > (unsigned long) avail_ram) + && (load_addr <= 0x01000000) ) + avail_ram = (char *)((unsigned long)&start+(num_words*4)); + + /* relocate zimage */ + puts("zimage at: "); puthex((unsigned long)zimage_start); + puts(" "); puthex((unsigned long)(zimage_size+zimage_start)); puts("\n"); + /* + * don't relocate the zimage if it was loaded above 16M since + * things get weird if we try to relocate -- Cort + */ + if ( (unsigned long)zimage_start <= 0x01000000 ) + { + memcpy ((void *)PAGE_ALIGN(-PAGE_SIZE+(unsigned long)end_avail-zimage_size), + (void *)zimage_start, zimage_size ); + zimage_start = (char *)PAGE_ALIGN(-PAGE_SIZE+(unsigned long)end_avail-zimage_size); + end_avail = (char *)zimage_start; + puts("relocated to: "); puthex((unsigned long)zimage_start); + puts(" "); + puthex((unsigned long)zimage_size+(unsigned long)zimage_start); + puts("\n"); + } + /* relocate initrd */ if ( initrd_start ) { puts("initrd at: "); puthex(initrd_start); puts(" "); puthex(initrd_end); puts("\n"); - - memcpy ((void *)INITRD_DESTINATION,(void *)initrd_start, + /* + * Memory is really tight on the MBX (we can assume 4M) + * so put the initrd at the TOP of ram, and set end_avail + * to right after that. + * + * I should do something like this for prep, too and keep + * a variable end_of_DRAM to keep track of what we think the + * max ram is. + * -- Cort + */ + memcpy ((void *)PAGE_ALIGN(-PAGE_SIZE+(unsigned long)end_avail-INITRD_SIZE), + (void *)initrd_start, INITRD_SIZE ); - initrd_end = INITRD_DESTINATION + INITRD_SIZE; - initrd_start = INITRD_DESTINATION; - puts("Moved initrd to: "); puthex(initrd_start); + initrd_start = PAGE_ALIGN(-PAGE_SIZE+(unsigned long)end_avail-INITRD_SIZE); + initrd_end = initrd_start + INITRD_SIZE; + end_avail = (char *)initrd_start; + puts("relocated to: "); puthex(initrd_start); puts(" "); puthex(initrd_end); puts("\n"); } + + /* this is safe, just use it */ + avail_ram = (char *)0x00400000; + end_avail = (char *)0x00600000; + puts("avail ram: "); puthex((unsigned long)avail_ram); puts(" "); + puthex((unsigned long)end_avail); puts("\n"); + + #ifndef CONFIG_MBX CRT_tstc(); /* Forces keyboard to be initialized */ -#endif +#endif +#ifdef CONFIG_PREP +/* I need to fix this for mbx -- Cort */ puts("\nLinux/PPC load: "); timer = 0; cp = cmd_line; @@ -406,7 +483,7 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, R } *cp = 0; puts("\n"); - +#endif /* CONFIG_PREP */ /* mappings on early boot can only handle 16M */ if ( (int)(&cmd_line[0]) > (16<<20)) puts("cmd_line located > 16M\n"); @@ -417,13 +494,14 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, R puts("Uncompressing Linux..."); - /* these _bcopy() calls are here so I can add breakpoints to the boot for mbx -- Cort */ - /*_bcopy( (char *)0x100,(char *)&sanity, 0x2000-0x100);*/ gunzip(0, 0x400000, zimage_start, &zimage_size); - /*_bcopy( (char *)&sanity,(char *)0x100,0x2000-0x100);*/ puts("done.\n"); puts("Now booting the kernel\n"); +#ifndef CONFIG_MBX return (unsigned long)&hold_residual; +#else + return (unsigned long)&hold_board_info; +#endif } void puthex(unsigned long val) -- cgit v1.2.3