|
From: Andy P. <at...@us...> - 2002-04-10 18:31:29
|
Update of /cvsroot/linux-vax/kernel-2.4/arch/ppc/boot/tree
In directory usw-pr-cvs1:/tmp/cvs-serv25860/ppc/boot/tree
Added Files:
Makefile irSect.c irSect.h ld.script main.c misc.S
Log Message:
synch 2.4.15 commit 43
--- NEW FILE ---
# BK Id: SCCS/s.Makefile 1.7 06/15/01 13:16:10 paulus
#
#
# Module name: Makefile
#
# Description:
# Makefile for the IBM "tree" evaluation board Linux kernel
# boot loaders.
#
#
# Copyright (c) 1999 Grant Erickson <gr...@lc...>
#
# PPC-405 modification
# Copyright 2000-2001 MontaVista Software Inc.
# Author: MontaVista Software, Inc.
# fra...@mv... or so...@mv...
# deb...@mv...
#
HOSTCFLAGS = -O -I$(TOPDIR)/include
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
GZIP = gzip -vf9
RM = rm -f
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/ns16550.o
LIBS = ../lib/zlib.a
treeboot: $(OBJS) $(LIBS) ld.script
$(LD) -o $@ $(LD_ARGS) $(OBJS) $(LIBS)
zImage: vmlinux.img
zImage.initrd: vmlinux.initrd.img
treeboot.image: treeboot
$(OBJCOPY) --add-section=image=../images/vmlinux.gz treeboot $@
treeboot.initrd: treeboot.image ramdisk.image.gz
$(OBJCOPY) --add-section=initrd=ramdisk.image.gz treeboot.image $@
vmlinux.img: treeboot.image
$(OBJDUMP) --syms treeboot.image | grep irSectStart > irSectStart.txt
$(MKIRIMG) treeboot.image treeboot.image.out irSectStart.txt
$(MKEVIMG) treeboot.image.out ../images/vmlinux.tree.img
$(RM) treeboot.image treeboot.image.out irSectStart.txt
vmlinux.initrd.img: treeboot.initrd
$(OBJDUMP) --all-headers treeboot.initrd | grep irSectStart > irSectStart.txt
$(MKIRIMG) treeboot.initrd treeboot.initrd.out irSectStart.txt
$(MKEVIMG) treeboot.initrd.out ../images/vmlinux.tree.initrd.img
$(RM) treeboot.initrd treeboot.initrd.out irSectStart.txt
clean:
rm -f treeboot treeboot.image treeboot.initrd irSectStart.txt vmlinux.*
include $(TOPDIR)/Rules.make
--- NEW FILE ---
/*
* BK Id: SCCS/s.irSect.c 1.6 05/18/01 15:17:22 cort
*/
/*
*
* Copyright (c) 1999 Grant Erickson <gr...@lc...>
*
* Module name: irSect.c
*
* Description:
* Defines variables to hold the absolute starting address and size
* of the Linux kernel "image" and the initial RAM disk "initrd"
* sections within the boot loader.
*
*/
#include "irSect.h"
/*
* The order of globals below must not change. If more globals are added,
* you must change the script 'mkirimg' accordingly.
*
*/
/*
* irSectStart must be at beginning of file
*/
unsigned int irSectStart = 0xdeadbeaf;
unsigned int imageSect_start = 0;
unsigned int imageSect_size = 0;
unsigned int initrdSect_start = 0;
unsigned int initrdSect_size = 0;
/*
* irSectEnd must be at end of file
*/
unsigned int irSectEnd = 0xdeadbeaf;
--- NEW FILE ---
/*
* BK Id: SCCS/s.irSect.h 1.6 05/18/01 15:17:22 cort
*/
/*
*
* Copyright (c) 1999 Grant Erickson <gr...@lc...>
*
* Module name: irSect.h
*
* Description:
* Defines variables to hold the absolute starting address and size
* of the Linux kernel "image" and the initial RAM disk "initrd"
* sections within the boot loader.
*
*/
#ifndef __IRSECT_H__
#define __IRSECT_H__
#ifdef __cplusplus
extern "C" {
#endif
extern unsigned int imageSect_start;
extern unsigned int imageSect_size;
extern unsigned int initrdSect_start;
extern unsigned int initrdSect_size;
#ifdef __cplusplus
}
#endif
#endif /* __IRSECT_H__ */
--- NEW FILE ---
OUTPUT_ARCH(powerpc)
SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
/* Do we need any of these for elf?
__DYNAMIC = 0; */
SECTIONS
{
/* Read-only sections, merged into text segment: */
. = + SIZEOF_HEADERS;
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.rel.text : { *(.rel.text) }
.rela.text : { *(.rela.text) }
.rel.data : { *(.rel.data) }
.rela.data : { *(.rela.data) }
.rel.rodata : { *(.rel.rodata) }
.rela.rodata : { *(.rela.rodata) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init : { *(.init) } =0
.plt : { *(.plt) }
.text :
{
*(.text)
*(.rodata)
*(.rodata.*)
*(.rodata1)
*(.got1)
}
.fini : { *(.fini) } =0
.ctors : { *(.ctors) }
.dtors : { *(.dtors) }
_etext = .;
PROVIDE (etext = .);
/* Read-write section, merged into data segment: */
. = (. + 0x0FFF) & 0xFFFFF000;
.data :
{
*(.data)
*(.data1)
*(.sdata)
*(.sdata2)
*(.got.plt) *(.got)
*(.dynamic)
CONSTRUCTORS
}
_edata = .;
PROVIDE (edata = .);
__bss_start = .;
.bss :
{
*(.sbss) *(.scommon)
*(.dynbss)
*(.bss)
*(COMMON)
}
_end = . ;
PROVIDE (end = .);
}
--- NEW FILE ---
/*
* BK Id: SCCS/s.main.c 1.9 06/15/01 13:16:10 paulus
*/
/*
* Copyright (c) 1997 Paul Mackerras <pa...@cs...>
* Initial Power Macintosh COFF version.
* Copyright (c) 1999 Grant Erickson <gr...@lc...>
* Modifications for an ELF-based IBM evaluation board version.
* Copyright 2000-2001 MontaVista Software Inc.
* PPC405GP modifications
* Author: MontaVista Software, Inc.
* fra...@mv... or so...@mv...
* deb...@mv...
*
* Module name: main.c
*
* Description:
* This module does most of the real work for the boot loader. It
* checks the variables holding the absolute start address and size
* of the Linux kernel "image" and initial RAM disk "initrd" sections
* and if they are present, moves them to their "proper" locations.
*
* For the Linux kernel, "proper" is physical address 0x00000000.
* For the RAM disk, "proper" is the image's size below the top
* of physical memory. The Linux kernel may be in either raw
* binary form or compressed with GNU zip (aka gzip).
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
*/
#include <linux/config.h>
#include <asm/ppc4xx.h>
#include "nonstdio.h"
#include "irSect.h"
#if defined(CONFIG_SERIAL_CONSOLE)
#include "ns16550.h"
#endif /* CONFIG_SERIAL_CONSOLE */
/* Preprocessor Defines */
/*
* Location of the IBM boot ROM function pointer address for retrieving
* the board information structure.
*/
#define BOARD_INFO_VECTOR 0xFFFE0B50
/*
* Warning: the board_info doesn't contain valid data until get_board_info()
* gets called in start().
*/
#define RAM_SIZE board_info.bi_memsize
#define RAM_PBASE 0x00000000
#define RAM_PEND (RAM_PBASE + RAM_SIZE)
#define RAM_VBASE 0xC0000000
#define RAM_VEND (RAM_VBASE + RAM_SIZE)
#define RAM_START RAM_PBASE
#define RAM_END RAM_PEND
#define RAM_FREE (imageSect_start + imageSect_size + initrdSect_size)
#define PROG_START RAM_START
/* Function Macros */
#define ALIGN_UP(x, align) (((x) + ((align) - 1)) & ~((align) - 1))
/* Global Variables */
/* Needed by zalloc and zfree for allocating memory */
char *avail_ram; /* Indicates start of RAM available for heap */
char *end_avail; /* Indicates end of RAM available for heap */
/* 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
** bootrom.
*/
char *bootrom_cmdline = "";
char treeboot_bootrom_cmdline[512];
#ifdef CONFIG_CMDLINE
char *cmdline = CONFIG_CMDLINE;
#else
char *cmdline = "";
#endif
/* Function Prototypes */
extern void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp);
void
kick_watchdog(void)
{
#ifdef CONFIG_405GP
mtspr(SPRN_TSR, (TSR_ENW | TSR_WIS));
#endif
}
void start(void)
{
void *options;
int ns, oh, i;
unsigned long sa, len;
void *dst;
unsigned char *im;
unsigned long initrd_start, initrd_size;
bd_t *(*get_board_info)(void) =
(bd_t *(*)(void))(*(unsigned long *)BOARD_INFO_VECTOR);
bd_t *bip = NULL;
com_port = (struct NS16550 *)serial_init(0);
#ifdef CONFIG_405GP
/* turn off on-chip ethernet */
/* This is to fix a problem with early walnut bootrom. */
{
/* 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;
_printk("Initial RAM disk at 0x%08x (%u bytes)\n",
initrd_start, initrd_size);
memcpy((char *)initrd_start,
(char *)(initrdSect_start),
initrdSect_size);
end_avail = (char *)initrd_start;
} else {
initrd_start = initrd_size = 0;
end_avail = (char *)RAM_END;
}
/* Linux kernel image section */
kick_watchdog();
im = (unsigned char *)(imageSect_start);
len = imageSect_size;
dst = (void *)PROG_START;
/* Check for the gzip archive magic numbers */
if (im[0] == 0x1f && im[1] == 0x8b) {
/* The gunzip routine needs everything nice and aligned */
void *cp = (void *)ALIGN_UP(RAM_FREE, 8);
avail_ram = (void *)(cp + ALIGN_UP(len, 8)); /* used by zalloc() */
memcpy(cp, im, len);
/* I'm not sure what the 0x200000 parameter is for, but it works. */
/* It tells gzip the end of the area you wish to reserve, and it
* can use data past that point....unfortunately, this value
* isn't big enough (luck ran out). -- Dan
*/
gunzip(dst, 0x400000, cp, (int *)&len);
} else {
memmove(dst, im, len);
}
kick_watchdog();
flush_cache(dst, len);
sa = (unsigned long)dst;
(*(void (*)())sa)(&board_info,
initrd_start,
initrd_start + initrd_size,
cmdline,
cmdline + strlen(cmdline));
pause();
}
--- NEW FILE ---
/*
* BK Id: SCCS/s.misc.S 1.7 05/18/01 06:20:29 patch
*/
/*
* Copyright (C) Paul Mackerras 1997.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include "../../kernel/ppc_asm.tmpl"
.text
/*
* Flush the dcache and invalidate the icache for a range of addresses.
*
* flush_cache(addr, len)
*/
.global flush_cache
flush_cache:
mfpvr r5 # Get processor version register
extrwi r5,r5,16,0 # Get the version bits
cmpwi cr0,r5,0x0020 # Is this a 403-based processor?
beq 1f # Yes, it is
li r5,32 # It is not a 403, set to 32 bytes
addi r4,r4,32-1 # len += line_size - 1
srwi. r4,r4,5 # Convert from bytes to lines
b 2f
1: li r5,16 # It is a 403, set to 16 bytes
addi r4,r4,16-1 # len += line_size - 1
srwi. r4,r4,4 # Convert from bytes to lines
2: mtctr r4 # Set-up the counter register
beqlr # If it is 0, we are done
3: dcbf r0,r3 # Flush and invalidate the data line
icbi r0,r3 # Invalidate the instruction line
add r3,r3,r5 # Move to the next line
bdnz 3b # Are we done yet?
sync
isync
blr # Return to the caller
|