Commit 37ff5b87 authored by Tom Rini's avatar Tom Rini

PPC32: Kill off arch/ppc/boot/prep and rearrange some files.

parent bddd7645
......@@ -16,13 +16,12 @@ HOSTCFLAGS += -Iarch/$(ARCH)/boot/include
BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd
bootdir-y := simple
bootdir-$(CONFIG_PPC_OF) := openfirmware
bootdir-$(CONFIG_PPC_PREP) += prep
bootdir-$(CONFIG_PPC_OF) += openfirmware
subdir-y := lib/ common/ images/
subdir-$(CONFIG_PPC_OF) += of1275/
# for cleaning
subdir- += simple/ openfirmware/ prep/
subdir- += simple/ openfirmware/
host-progs := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree)
......
......@@ -9,8 +9,5 @@
#
lib-y := string.o util.o misc-common.o \
serial_stub.o
lib-$(CONFIG_PPC_PREP) += mpc10x_memory.o
lib-$(CONFIG_LOPEC) += mpc10x_memory.o
lib-$(CONFIG_PAL4) += cpc700_memory.o
serial_stub.o bootinfo.o
lib-$(CONFIG_SERIAL_8250_CONSOLE) += ns16550.o
......@@ -14,7 +14,7 @@
* trini@mvista.com
* Derived from arch/ppc/boot/prep/head.S (Cort Dougan, many others).
*
* 2001-2003 (c) MontaVista, Software, Inc. This file is licensed under
* 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under
* the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
......@@ -36,6 +36,13 @@ disable_6xx_mmu:
*/
li r8,MSR_IP|MSR_FP
mtmsr r8
isync
/* Test for a 601 */
mfpvr r10
srwi r10,r10,16
cmpi 0,r10,1 /* 601 ? */
beq .clearbats_601
/* Clear BATs */
li r8,0
......@@ -47,6 +54,7 @@ disable_6xx_mmu:
mtspr DBAT2L,r8
mtspr DBAT3U,r8
mtspr DBAT3L,r8
.clearbats_601:
mtspr IBAT0U,r8
mtspr IBAT0L,r8
mtspr IBAT1U,r8
......@@ -68,6 +76,7 @@ disable_6xx_mmu:
addi r8,r8,0x111 /* increment VSID */
addis r10,r10,0x1000 /* address of next segment */
bdnz 3b
blr
.globl disable_6xx_l1cache
disable_6xx_l1cache:
......
......@@ -2,4 +2,7 @@
# Makefile for some libs needed by zImage.
#
CFLAGS_kbd.o += -Idrivers/char
lib-y := zlib.o div64.o
lib-$(CONFIG_VGA_CONSOLE) += vreset.o kbd.o
# arch/ppc/boot/Makefile
#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
# for more details.
#
# Tom Rini January 2001
#
# Originally:
# arch/ppc/boot/Makefile
# Copyright (C) 1994 by Linus Torvalds
# Adapted for PowerPC by Gary Thomas
# modified by Cort (cort@cs.nmt.edu)
#
TFTPIMAGE := /tftpboot/zImage.prep
ifeq ($(CONFIG_SMP),y)
TFTPIMAGE := $(TFTPIMAGE).smp
endif
boot-y := head.o misc.o
boot-$(CONFIG_VGA_CONSOLE) += vreset.o kbd.o
boot := arch/ppc/boot
common := $(boot)/common
utils := $(boot)/utils
bootlib := $(boot)/lib
images := $(boot)/images
simple := $(boot)/simple
of1275 := $(boot)/of1275
OBJCOPYFLAGS := -O elf32-powerpc
LIBS := $(common)/lib.a $(bootlib)/lib.a $(of1275)/lib.a
targets := $(boot-y) dummy.o ../simple/legacy.o
OBJS := $(addprefix $(obj)/,$(boot-y)) $(simple)/legacy.o
# Extra include search dirs
CFLAGS_kbd.o += -Idrivers/char
zImage: initrd :=
zImage: $(images)/zImage.prep
@echo ' kernel: $@ is ready ($<)'
zImage.initrd: initrd := .initrd
zImage.initrd: $(images)/zImage.initrd.prep
@echo ' kernel: $@ is ready ($<)'
$(images)/ramdisk.image.gz:
@echo ' MISSING $@'
@echo ' RAM disk image must be provided separately'
@/bin/false
OBJCOPYFLAGS_image.o := \
--add-section=.image=$(images)/vmlinux.gz \
--set-section-flags=.image=contents,alloc,load,readonly,data
targets += image.o
$(obj)/image.o: $(obj)/dummy.o $(images)/vmlinux.gz
$(call if_changed,objcopy)
OBJCOPYFLAGS_image.initrd.o := \
--add-section=.ramdisk=$(images)/ramdisk.image.gz \
--set-section-flags=.ramdisk=contents,alloc,load,readonly,data \
--add-section=.image=$(images)/vmlinux.gz \
--set-section-flags=.image=contents,alloc,load,readonly,data
targets += image.initrd.o
$(obj)/image.initrd.o: $(obj)/dummy.o $(images)/vmlinux.gz $(images)/ramdisk.image.gz
$(call if_changed,objcopy)
LDFLAGS_zImage.bin := -Ttext 0x00800000 -Bstatic -T
LDFLAGS_zImage.initrd.bin := -Ttext 0x00800000 -Bstatic -T
targets += zImage.bin
$(obj)/zImage.bin: $(boot)/ld.script $(OBJS) $(obj)/image.o $(LIBS)
$(call if_changed,ld)
targets += zImage.initrd.bin
$(obj)/zImage.initrd.bin: $(boot)/ld.script $(OBJS) $(obj)/image.initrd.o $(LIBS)
$(call if_changed,ld)
OBJCOPYFLAGS_zImage := -R .comment -R .stab -R .stabstr
OBJCOPYFLAGS_zImage.initrd := -R .comment -R .stab -R .stabstr
targets += zImage
$(obj)/zImage: %: %.bin FORCE
$(call if_changed,objcopy)
targets += zImage.initrd
$(obj)/zImage.initrd: %: %.bin FORCE
$(call if_changed,objcopy)
quiet_cmd_mkprep = MKPREP $@
cmd_mkprep = $(utils)/mkprep -pbp $< $@
$(images)/zImage.prep: $(obj)/zImage $(utils)/mkprep
$(call cmd,mkprep)
$(images)/zImage.initrd.prep: $(obj)/zImage.initrd $(utils)/mkprep
$(call cmd,mkprep)
#
# Convinient shorthands for various targets
#
floppy: zImage
dd if=$(images)/zImage.prep of=/dev/fd0H1440 bs=64b
znetboot : zImage
cp $(images)/zImage.prep $(TFTPIMAGE)
@echo ' kernel: $@ is ready ($<)'
znetboot.initrd : zImage.initrd
cp $(images)/zImage.initrd.prep $(TFTPIMAGE)
@echo ' kernel: $@ is ready ($<)'
int main(void)
{
return 0;
}
#include <asm/ppc_asm.h>
#include <asm/reg.h>
#include <asm/cache.h>
.text
/*
* Boot loader philosophy:
* ROM loads us to some arbitrary location
* Move the boot code to the link address (8M)
* Call decompress_kernel()
* Relocate the initrd, zimage and residual data to 8M
* Decompress the kernel to 0
* Jump to the kernel entry
* -- Cort
*/
.globl start
start:
bl start_
start_:
/* Enable, invalidate, Disable L1 icache/dcache */
li r8, 0
ori r8, r8, (HID0_ICE|HID0_DCE|HID0_ICFI|HID0_DCI)
mfspr r11,HID0
or r11,r11,r8
andc r10,r11,r8
isync
mtspr HID0,r8
sync
isync
mtspr HID0,r10
sync
isync
mr r11,r3 /* Save pointer to residual/board data */
/*
* Save the OF pointer to r25, but only if the entry point is in a sane
* location; if not we store 0. If there is no entry point, or it is
* invalid, we establish the default MSR value immediately. Otherwise,
* we defer doing that, to allow OF functions to be called, until we
* begin uncompressing the kernel.
*/
lis r3,0x0fff /* r3 = 0x0fffffff */
ori r3,r3,0xffff
subc r3,r3,r5 /* r3 = (r5 <= r3) ? ~0 : 0 */
subfe r3,r3,r3
nand r3,r3,r3
and. r5,r5,r3 /* r5 will be cleared if (r5 > r3) */
bne+ haveOF
li r3,MSR_IP|MSR_FP /* Not OF: set MSR immediately */
mtmsr r3
isync
haveOF:
mr r25,r5
/* compute the size of the whole image in words. */
lis r4,start@h
ori r4,r4,start@l
lis r5,end@h
ori r5,r5,end@l
addi r5,r5,3 /* round up */
sub r5,r5,r4 /* end - start */
srwi r5,r5,2
mr r7,r5 /* Save for later use. */
/* check if we need to relocate ourselves to the link addr or were
* we loaded there to begin with -- Cort */
mflr r3
subi r3,r3,4 /* we get the nip, not the ip of the branch */
mr r8,r3
cmp 0,r3,r4
beq start_ldr /* If 0, we don't need to relocate */
/*
* no matter where we're loaded, move ourselves to -Ttext address
*/
relocate:
mflr r3 /* Compute code bias */
subi r3,r3,4
mr r8,r3
lis r4,start@h
ori r4,r4,start@l
mr r5,r7 /* Get the # of longwords again */
mtctr r5 /* Setup for loop */
li r6,0
subi r3,r3,4
subi r4,r4,4
00: lwzu r5,4(r3)
stwu r5,4(r4)
xor r6,r6,r5
bdnz 00b
lis r3,start_ldr@h
ori r3,r3,start_ldr@l
mtlr r3 /* Easiest way to do an absolute jump */
blr
start_ldr:
/* Some boards don't boot up with the I-cache enabled. Do that
* now because the decompress runs much faster that way.
* As a side effect, we have to ensure the data cache is not enabled
* so we can access the serial I/O without trouble.
*/
bl flush_instruction_cache
/* Clear all of BSS */
lis r3,edata@h
ori r3,r3,edata@l
lis r4,end@h
ori r4,r4,end@l
subi r3,r3,4
subi r4,r4,4
li r0,0
50: stwu r0,4(r3)
cmp 0,r3,r4
bne 50b
90: mr r9,r1 /* Save old stack pointer (in case it matters) */
lis r1,.stack@h
ori r1,r1,.stack@l
addi r1,r1,4096*2
subi r1,r1,256
li r2,0x000F /* Mask pointer to 16-byte boundary */
andc r1,r1,r2
/* Run loader */
mr r3,r8 /* Load point */
mr r4,r7 /* Program length */
mr r5,r6 /* Checksum */
mr r6,r11 /* Residual data */
mr r7,r25 /* Validated OFW interface */
bl decompress_kernel
/*
* We have to do this after decompress_kernel, just to make
* sure we don't wipe out things mapped in BATs which we need.
* -- Tom
*/
li r6,0
/* Test for a 601 */
mfspr r9,PVR
srwi r9,r9,16
cmpi 0,r9,1 /* 601 ? */
beq .clearbats_601
/* Clear BATS */
mtspr DBAT0U,r6
mtspr DBAT0L,r6
mtspr DBAT1U,r6
mtspr DBAT1L,r6
mtspr DBAT2U,r6
mtspr DBAT2L,r6
mtspr DBAT3U,r6
mtspr DBAT3L,r6
.clearbats_601:
mtspr IBAT0U,r6
mtspr IBAT0L,r6
mtspr IBAT1U,r6
mtspr IBAT1L,r6
mtspr IBAT2U,r6
mtspr IBAT2L,r6
mtspr IBAT3U,r6
mtspr IBAT3L,r6
isync
sync
sync
/* Set segment registers */
li r6,16 /* load up segment register values */
mtctr r6 /* for context 0 */
lis r6,0x2000 /* Ku = 1, VSID = 0 */
li r10,0
3: mtsrin r6,r10
addi r6,r6,0x111 /* increment VSID */
addis r10,r10,0x1000 /* address of next segment */
bdnz 3b
/* tell kernel we're prep, by putting 0xdeadc0de at KERNELLOAD,
* and tell the kernel to start on the 4th instruction since we
* overwrite the first 3 sometimes (which are 'nop').
*/
li r9,0xc
mtlr r9
lis r10,0xdeadc0de@h
ori r10,r10,0xdeadc0de@l
li r9,0
stw r10,0(r9)
blr
.comm .stack,4096*2,4
......@@ -26,11 +26,12 @@ common := $(boot)/common
utils := $(boot)/utils
bootlib := $(boot)/lib
images := $(boot)/images
of1275 := $(boot)/of1275
tftpboot := /tftpboot
# Normally, we use the 'misc.c' file for decompress_kernel and
# whatnot. Sometimes we need to override this however.
misc-y := misc.o ../common/bootinfo.o
misc-y := misc.o
# Normally, we have our images end in .elf, but something we want to
# change this.
......@@ -89,6 +90,7 @@ zimageinitrd-$(motorola) := zImage.initrd-PPLUS
# Overrides previous assingment
extra.o-$(CONFIG_PPLUS) := legacy.o
extra.o-$(CONFIG_LOPEC) := mpc10x_memory.o
zimage-$(pcore) := zImage-STRIPELF
zimageinitrd-$(pcore) := zImage.initrd-STRIPELF
......@@ -96,6 +98,12 @@ zimageinitrd-$(pcore) := zImage.initrd-STRIPELF
end-$(pcore) := pcore
cacheflag-$(pcore) := -include $(clear_L2_L3)
zimage-$(CONFIG_PPC_PREP) := zImage-PPLUS
zimageinitrd-$(CONFIG_PPC_PREP) := zImage.initrd-PPLUS
extra.o-$(CONFIG_PPC_PREP) := legacy.o
misc-$(CONFIG_PPC_PREP) += misc-prep.o mpc10x_memory.o
end-$(CONFIG_PPC_PREP) := prep
end-$(CONFIG_SANDPOINT) := sandpoint
cacheflag-$(CONFIG_SANDPOINT) := -include $(clear_L2_L3)
......@@ -138,6 +146,9 @@ boot-$(CONFIG_GT64260_CONSOLE) += gt64260_tty.o
endif
LIBS := $(common)/lib.a $(bootlib)/lib.a
ifeq ($(CONFIG_PPC_PREP),y)
LIBS += $(of1275)/lib.a
endif
OBJS := $(addprefix $(obj)/,$(boot-y))
......@@ -199,10 +210,10 @@ $(images)/zImage.initrd-TREE: $(obj)/zvmlinux.initrd $(MKTREE)
$(MKTREE) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(end-y) \
$(ENTRYPOINT)
$(images)/zImage-PPLUS: $(obj)/zvmlinux $(MKPREP) $(MKBUGBOOT)
$(MKPREP) -pbp $(obj)/zvmlinux $(images)/zImage.pplus
$(images)/zImage-PPLUS: $(obj)/zvmlinux $(utils)/mkprep $(MKBUGBOOT)
$(MKPREP) -pbp $(obj)/zvmlinux $(images)/zImage.$(end-y)
$(MKBUGBOOT) $(obj)/zvmlinux $(images)/zImage.bugboot
$(images)/zImage.initrd-PPLUS: $(obj)/zvmlinux.initrd $(MKPREP) $(MKBUGBOOT)
$(MKPREP) -pbp $(obj)/zvmlinux.initrd $(images)/zImage.initrd.pplus
$(images)/zImage.initrd-PPLUS: $(obj)/zvmlinux.initrd $(utils)/mkprep $(MKBUGBOOT)
$(MKPREP) -pbp $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(end-y)
$(MKBUGBOOT) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.bugboot
......@@ -7,7 +7,7 @@
* trini@mvista.com
* Derived from arch/ppc/boot/prep/head.S (Cort Dougan, many others).
*
* 2001-2003 (c) MontaVista, Software, Inc. This file is licensed under
* 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under
* the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
......@@ -57,10 +57,11 @@ start_:
isync
#endif
#if defined(CONFIG_MBX) || defined(CONFIG_RPX6)
#if defined(CONFIG_MBX) || defined(CONFIG_RPX6) || defined(CONFIG_PPC_PREP)
mr r29,r3 /* On the MBX860, r3 is the board info pointer.
* On the RPXSUPER, r3 points to the
* NVRAM configuration keys.
* On the RPXSUPER, r3 points to the NVRAM
* configuration keys.
* On PReP, r3 is the pointer to the residual data.
*/
#endif
......@@ -69,7 +70,36 @@ start_:
/* The following functions we call must not modify r3 or r4.....
*/
#ifdef CONFIG_6xx
/* On PReP we must look at the OpenFirmware pointer and sanity
* test it. On other platforms, we disable the MMU right now
* and other bits.
*/
#ifdef CONFIG_PPC_PREP
/*
* Save the OF pointer to r25, but only if the entry point is in a sane
* location; if not we store 0. If there is no entry point, or it is
* invalid, we establish the default MSR value immediately. Otherwise,
* we defer doing that, to allow OF functions to be called, until we
* begin uncompressing the kernel.
*/
lis r8,0x0fff /* r8 = 0x0fffffff */
ori r8,r8,0xffff
subc r8,r8,r5 /* r8 = (r5 <= r8) ? ~0 : 0 */
subfe r8,r8,r8
nand r8,r8,r8
and. r5,r5,r8 /* r5 will be cleared if (r5 > r8) */
bne+ haveOF
li r8,MSR_IP|MSR_FP /* Not OF: set MSR immediately */
mtmsr r8
isync
haveOF:
mr r25,r5
#else
bl disable_6xx_mmu
#endif
bl disable_6xx_l1cache
CLEAR_CACHES
......@@ -99,7 +129,7 @@ start_:
mr r3, r29
#endif
#if defined(CONFIG_MBX) || defined(CONFIG_RPX6)
#if defined(CONFIG_MBX) || defined(CONFIG_RPX6) || defined(CONFIG_PPC_PREP)
mr r4,r29 /* put the board info pointer where the relocate
* routine will find it
*/
......
......@@ -174,7 +174,8 @@ get_mem_size(void)
}
unsigned long
load_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
load_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
void *ign1, void *ign2)
{
int csr0;
int csr_id;
......
......@@ -99,7 +99,9 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
unsigned long initrd_loc, TotalMemory = 0;
serial_fixups();
#ifdef CONFIG_SERIAL_8250_CONSOLE
com_port = serial_init(0, NULL);
#endif
#ifdef CONFIG_44x
/* Reset MAL */
......@@ -269,7 +271,8 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
/* Allow decompress_kernel to be hooked into. This is the default. */
void * __attribute__ ((weak))
load_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
load_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
void *ign1, void *ign2)
{
return decompress_kernel(load_addr, num_words, cksum);
}
......@@ -52,8 +52,12 @@ MPC10X_PCI_OP(read, dword, u32 *, in_le32, 0)
* the system. This assumes that the firmware has correctly set up the memory
* controller registers. On CONFIG_PPC_PREP, we know we are being called
* under a PReP memory map. On all other machines, we assume we are under
* a CHRP memory map.
* a CHRP memory map. Further, on CONFIG_PPC_MULTIPLATFORM we must rename
* this function.
*/
#ifdef CONFIG_PPC_MULTIPLATFORM
#define get_mem_size mpc10x_get_mem_size
#endif
unsigned long
get_mem_size(void)
{
......
......@@ -9,7 +9,7 @@
* trini@mvista.com
* Derived from arch/ppc/boot/prep/head.S (Cort Dougan, many others).
*
* 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
* 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under
* the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
......@@ -182,6 +182,7 @@ start_ldr:
mr r4,r7 /* Program length */
mr r5,r6 /* Checksum */
mr r6,r11 /* Residual data */
mr r7,r25 /* Validated OFW interface */
bl load_kernel
/*
......@@ -195,8 +196,18 @@ start_ldr:
/*
* Start at the begining.
*/
li r9,0x0000
li r9,0xc
mtlr r9
#ifdef CONFIG_PPC_MULTIPLATFORM
/* tell kernel we're prep, by putting 0xdeadc0de at KERNELLOAD,
* and tell the kernel to start on the 4th instruction since we
* overwrite the first 3 sometimes (which are 'nop').
*/
lis r10,0xdeadc0de@h
ori r10,r10,0xdeadc0de@l
li r9,0
stw r10,0(r9)
#endif
blr
.comm .stack,4096*2,4
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment