# This is a BitKeeper generated patch for the following project: # Project Name: Linux 2.4 # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.128 -> 1.129 # arch/ppc/boot/utils/mkevimg 1.7 -> 1.8 # arch/ppc/boot/tree/main.c 1.8 -> 1.9 # arch/ppc/boot/tree/Makefile 1.6 -> 1.7 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 01/06/05 trini@bill-the-cat.bloom.county 1.129 # 4xxboot.patch # -------------------------------------------- # diff -Nru a/arch/ppc/boot/tree/Makefile b/arch/ppc/boot/tree/Makefile --- a/arch/ppc/boot/tree/Makefile Tue Jun 5 14:59:21 2001 +++ b/arch/ppc/boot/tree/Makefile Tue Jun 5 14:59:21 2001 @@ -26,12 +26,13 @@ GZIP = gzip -vf9 RM = rm -f -MKEVIMG = ../utils/mkevimg -l +MKEVIMG = ../utils/mkevimg -l -c MKIRIMG = ../utils/mkirimg +CFLAGS += -I$(TOPDIR)/drivers/net LD_ARGS = -e _start -T ld.script -Ttext 0x00200000 -Bstatic OBJS = ../common/crt0.o main.o misc.o irSect.o ../common/string.o \ - ../common/misc-common.o + ../common/misc-common.o ../common/ns16550.o LIBS = ../lib/zlib.a treeboot: $(OBJS) $(LIBS) ld.script diff -Nru a/arch/ppc/boot/tree/main.c b/arch/ppc/boot/tree/main.c --- a/arch/ppc/boot/tree/main.c Tue Jun 5 14:59:21 2001 +++ b/arch/ppc/boot/tree/main.c Tue Jun 5 14:59:21 2001 @@ -74,16 +74,6 @@ #define ALIGN_UP(x, align) (((x) + ((align) - 1)) & ~((align) - 1)) -#define stringify(s) tostring(s) -#define tostring(s) #s - -#define mtdcr(rn, v) asm volatile("mtdcr " stringify(rn) ",%0" : : "r" (v)) -#define mfdcr(rn) ({unsigned int rval; \ - asm volatile("mfdcr %0," stringify(rn) \ - : "=r" (rval)); rval;}) -#define DCRN_MALCR 0x180 /* MAL Configuration */ -#define MALCR_SR 0x80000000 /* Software Reset */ - /* Global Variables */ /* Needed by zalloc and zfree for allocating memory */ @@ -91,15 +81,11 @@ char *avail_ram; /* Indicates start of RAM available for heap */ char *end_avail; /* Indicates end of RAM available for heap */ -bd_t board_info; - -/* - * XXX - Until either the IBM boot ROM provides a way of passing arguments to - * the program it launches or until I/O is working in the boot loader, - * this is a good spot to pass in command line arguments to the kernel - * (e.g. console=tty0). - */ +/* Needed for serial I/O. +*/ +extern unsigned long *com_port; +bd_t board_info; /* ** The bootrom may change bootrom_cmdline to point to a buffer in the @@ -116,35 +102,16 @@ /* Function Prototypes */ -extern void *zalloc(void *x, unsigned items, unsigned size); - -/* serial I/O functions. - * These should have generic names, although this is similar to 16550.... - */ -static volatile unsigned char *uart0_lsr = (unsigned char *)0xef600305; -static volatile unsigned char *uart0_xcvr = (unsigned char *)0xef600300; +extern void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp); void -serial_putc(void *unused, unsigned char c) -{ - while ((*uart0_lsr & LSR_THRE) == 0); - *uart0_xcvr = c; -} - -unsigned char -serial_getc(void *unused) -{ - while ((*uart0_lsr & LSR_DR) == 0); - return (*uart0_xcvr); -} - -int -serial_tstc(void *unused) +kick_watchdog(void) { - return ((*uart0_lsr & LSR_DR) != 0); +#ifdef CONFIG_405GP + mtspr(SPRN_TSR, (TSR_ENW | TSR_WIS)); +#endif } - void start(void) { void *options; @@ -156,40 +123,34 @@ bd_t *(*get_board_info)(void) = (bd_t *(*)(void))(*(unsigned long *)BOARD_INFO_VECTOR); bd_t *bip = NULL; - volatile unsigned long *em0mr0 = (long *)0xEF600800; /* ftr fixup */ + com_port = (struct NS16550 *)serial_init(0); -#if defined(CONFIG_WALNUT) - /* turn off ethernet */ +#ifdef CONFIG_405GP + /* turn off on-chip ethernet */ /* This is to fix a problem with early walnut bootrom. */ - - mtdcr(DCRN_MALCR, MALCR_SR); /* 1st reset MAL */ - - while (mfdcr(DCRN_MALCR) & MALCR_SR) {}; /* wait for the reset */ - - *em0mr0 = 0x20000000; /* then reset EMAC */ -#endif - - -#if 0 - /* ftr revisit - remove printf()s */ - - printf("\n\nbootrom_cmdline = >%s<\n\n", bootrom_cmdline); - if (*bootrom_cmdline != '\0') { - printf("bootrom_cmdline != NULL, copying it into cmdline\n\n"); - *treeboot_bootrom_cmdline = '\0'; - strcat(treeboot_bootrom_cmdline, bootrom_cmdline); - cmdline = treeboot_bootrom_cmdline; + + { + /* Physical mapping of ethernet register space. */ + static struct ppc405_enet_regs *ppc405_enet_regp = + (struct ppc405_enet_regs *)PPC405_EM0_REG_ADDR; + + mtdcr(DCRN_MALCR, MALCR_MMSR); /* 1st reset MAL */ + + while (mfdcr(DCRN_MALCR) & MALCR_MMSR) {}; /* wait for the reset */ + + ppc405_enet_regp->em0mr0 = 0x20000000; /* then reset EMAC */ } #endif - if ((bip = get_board_info()) != NULL) memcpy(&board_info, bip, sizeof(bd_t)); /* Init RAM disk (initrd) section */ + kick_watchdog(); + if (initrdSect_start != 0 && (initrd_size = initrdSect_size) != 0) { initrd_start = (RAM_END - initrd_size) & ~0xFFF; @@ -208,6 +169,8 @@ /* Linux kernel image section */ + kick_watchdog(); + im = (unsigned char *)(imageSect_start); len = imageSect_size; dst = (void *)PROG_START; @@ -233,6 +196,7 @@ memmove(dst, im, len); } + kick_watchdog(); flush_cache(dst, len); diff -Nru a/arch/ppc/boot/utils/mkevimg b/arch/ppc/boot/utils/mkevimg --- a/arch/ppc/boot/utils/mkevimg Tue Jun 5 14:59:21 2001 +++ b/arch/ppc/boot/utils/mkevimg Tue Jun 5 14:59:21 2001 @@ -23,7 +23,8 @@ # unsigned long num_512blocks; Size, rounded-up, in 512 byte blocks # unsigned long debug_flag; Run the debugger or image after load # unsigned long entry_point; The image address to jump to after load -# unsigned long reserved[3]; +# unsigned long checksum; 32 bit checksum including header +# unsigned long reserved[2]; # } boot_block_t; # # @@ -61,6 +62,7 @@ } if ($status != 1) { + print(" -c Put checksum in load information block.\n"); print(" -h Print out this message and exit.\n"); print(" -l Linux mode; if present, copy 'image' and 'initrd' sections.\n"); print(" -v Verbose. Print out lots of ELF information.\n"); @@ -148,10 +150,14 @@ sub decode_options { - if (!getopts("hlvV")) { + if (!getopts("chlvV")) { usage(1); } + if ($opt_c) { + $do_checksum = 1; + } + if ($opt_h) { usage(0); } @@ -360,14 +366,20 @@ $output_size += $initrd_size; } - $num_blocks = $output_size / 512 + 1; + # + # Compute size with header + # + + $header = pack("H8N7", "0052504f", 0, 0, 0, 0, 0, 0, 0); + $num_blocks = ($output_size + length($header) + 511) / 512; # # Write IBM PowerPC evaluation board boot_block_t header # $header = pack("H8N7", "0052504f", $text_addr, $num_blocks, 0, - $text_addr, 0, 0, 0); + $text_addr, 0, 0, 0); + $bytes = length($header); @@ -412,18 +424,57 @@ # # Pad to a multiple of 512 bytes + # If the (size of the boot image mod 512) is between 509 and 511 bytes + # then the tftp to the Walnut fails. This may be fixed in more recent + # Walnut bootrom. # - $pad_size = 512 - (length($header) + $output_size) % 512; + $pad_size = 512 - ((length($header) + $output_size) % 512); + if ($pad_size == 512) { + $pad_size = 0; + } + + if ($pad_size != 0) { + + if ($verbose) { + print("Padding boot image by an additional $pad_size bytes.\n"); + } + + $pad_string = pack("H8","deadbeef") x 128; + + syswrite(BOOT, $pad_string, $pad_size) or + die "Could not pad boot image in output file.\n"; - if ($verbose) { - print("Padding boot image by an additional $pad_size bytes.\n"); } - $pad_string = pack(("H8","deadbeef") x 128); + # + # Compute 32 bit checksum over entire file. + # + + if ($do_checksum) { - syswrite(BOOT, $pad_string, $pad_size) or - die "Could not pad boot image in output file.\n"; + close(BOOT); + open(BOOT, "+<$ofile") || die "Cannot open output file"; + undef $/; + $temp = unpack("%32N*", ); + # Solaris and PPC Linux return 0x80000000 for "-$temp" when $temp + # is negative. "~($temp - 1)" negates $temp properly. + $csum = ~($temp - 1); + printf("Checksum = 0x%08x\r\n", $csum); + + # + # Rewrite IBM PowerPC evaluation board boot_block_t header, + # this time with the checksum included + # + + $header = pack("H8N7", "0052504f", $text_addr, $num_blocks, 0, + $text_addr, $csum, 0, 0); + + seek(BOOT, 0, 0); + syswrite(BOOT, $header, length($header)) or + die("Could not write boot image header to output file."); + + } # # Clean-up and leave