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 ...@@ -16,13 +16,12 @@ HOSTCFLAGS += -Iarch/$(ARCH)/boot/include
BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd
bootdir-y := simple bootdir-y := simple
bootdir-$(CONFIG_PPC_OF) := openfirmware bootdir-$(CONFIG_PPC_OF) += openfirmware
bootdir-$(CONFIG_PPC_PREP) += prep
subdir-y := lib/ common/ images/ subdir-y := lib/ common/ images/
subdir-$(CONFIG_PPC_OF) += of1275/ subdir-$(CONFIG_PPC_OF) += of1275/
# for cleaning # for cleaning
subdir- += simple/ openfirmware/ prep/ subdir- += simple/ openfirmware/
host-progs := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree) host-progs := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree)
......
...@@ -9,8 +9,5 @@ ...@@ -9,8 +9,5 @@
# #
lib-y := string.o util.o misc-common.o \ lib-y := string.o util.o misc-common.o \
serial_stub.o serial_stub.o bootinfo.o
lib-$(CONFIG_PPC_PREP) += mpc10x_memory.o
lib-$(CONFIG_LOPEC) += mpc10x_memory.o
lib-$(CONFIG_PAL4) += cpc700_memory.o
lib-$(CONFIG_SERIAL_8250_CONSOLE) += ns16550.o lib-$(CONFIG_SERIAL_8250_CONSOLE) += ns16550.o
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* trini@mvista.com * trini@mvista.com
* Derived from arch/ppc/boot/prep/head.S (Cort Dougan, many others). * 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 * the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express * is licensed "as is" without any warranty of any kind, whether express
* or implied. * or implied.
...@@ -36,6 +36,13 @@ disable_6xx_mmu: ...@@ -36,6 +36,13 @@ disable_6xx_mmu:
*/ */
li r8,MSR_IP|MSR_FP li r8,MSR_IP|MSR_FP
mtmsr r8 mtmsr r8
isync
/* Test for a 601 */
mfpvr r10
srwi r10,r10,16
cmpi 0,r10,1 /* 601 ? */
beq .clearbats_601
/* Clear BATs */ /* Clear BATs */
li r8,0 li r8,0
...@@ -47,6 +54,7 @@ disable_6xx_mmu: ...@@ -47,6 +54,7 @@ disable_6xx_mmu:
mtspr DBAT2L,r8 mtspr DBAT2L,r8
mtspr DBAT3U,r8 mtspr DBAT3U,r8
mtspr DBAT3L,r8 mtspr DBAT3L,r8
.clearbats_601:
mtspr IBAT0U,r8 mtspr IBAT0U,r8
mtspr IBAT0L,r8 mtspr IBAT0L,r8
mtspr IBAT1U,r8 mtspr IBAT1U,r8
...@@ -68,6 +76,7 @@ disable_6xx_mmu: ...@@ -68,6 +76,7 @@ disable_6xx_mmu:
addi r8,r8,0x111 /* increment VSID */ addi r8,r8,0x111 /* increment VSID */
addis r10,r10,0x1000 /* address of next segment */ addis r10,r10,0x1000 /* address of next segment */
bdnz 3b bdnz 3b
blr
.globl disable_6xx_l1cache .globl disable_6xx_l1cache
disable_6xx_l1cache: disable_6xx_l1cache:
......
...@@ -2,4 +2,7 @@ ...@@ -2,4 +2,7 @@
# Makefile for some libs needed by zImage. # Makefile for some libs needed by zImage.
# #
CFLAGS_kbd.o += -Idrivers/char
lib-y := zlib.o div64.o 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 ...@@ -26,11 +26,12 @@ common := $(boot)/common
utils := $(boot)/utils utils := $(boot)/utils
bootlib := $(boot)/lib bootlib := $(boot)/lib
images := $(boot)/images images := $(boot)/images
of1275 := $(boot)/of1275
tftpboot := /tftpboot tftpboot := /tftpboot
# Normally, we use the 'misc.c' file for decompress_kernel and # Normally, we use the 'misc.c' file for decompress_kernel and
# whatnot. Sometimes we need to override this however. # 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 # Normally, we have our images end in .elf, but something we want to
# change this. # change this.
...@@ -89,6 +90,7 @@ zimageinitrd-$(motorola) := zImage.initrd-PPLUS ...@@ -89,6 +90,7 @@ zimageinitrd-$(motorola) := zImage.initrd-PPLUS
# Overrides previous assingment # Overrides previous assingment
extra.o-$(CONFIG_PPLUS) := legacy.o extra.o-$(CONFIG_PPLUS) := legacy.o
extra.o-$(CONFIG_LOPEC) := mpc10x_memory.o
zimage-$(pcore) := zImage-STRIPELF zimage-$(pcore) := zImage-STRIPELF
zimageinitrd-$(pcore) := zImage.initrd-STRIPELF zimageinitrd-$(pcore) := zImage.initrd-STRIPELF
...@@ -96,6 +98,12 @@ zimageinitrd-$(pcore) := zImage.initrd-STRIPELF ...@@ -96,6 +98,12 @@ zimageinitrd-$(pcore) := zImage.initrd-STRIPELF
end-$(pcore) := pcore end-$(pcore) := pcore
cacheflag-$(pcore) := -include $(clear_L2_L3) 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 end-$(CONFIG_SANDPOINT) := sandpoint
cacheflag-$(CONFIG_SANDPOINT) := -include $(clear_L2_L3) cacheflag-$(CONFIG_SANDPOINT) := -include $(clear_L2_L3)
...@@ -138,6 +146,9 @@ boot-$(CONFIG_GT64260_CONSOLE) += gt64260_tty.o ...@@ -138,6 +146,9 @@ boot-$(CONFIG_GT64260_CONSOLE) += gt64260_tty.o
endif endif
LIBS := $(common)/lib.a $(bootlib)/lib.a LIBS := $(common)/lib.a $(bootlib)/lib.a
ifeq ($(CONFIG_PPC_PREP),y)
LIBS += $(of1275)/lib.a
endif
OBJS := $(addprefix $(obj)/,$(boot-y)) OBJS := $(addprefix $(obj)/,$(boot-y))
...@@ -199,10 +210,10 @@ $(images)/zImage.initrd-TREE: $(obj)/zvmlinux.initrd $(MKTREE) ...@@ -199,10 +210,10 @@ $(images)/zImage.initrd-TREE: $(obj)/zvmlinux.initrd $(MKTREE)
$(MKTREE) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(end-y) \ $(MKTREE) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(end-y) \
$(ENTRYPOINT) $(ENTRYPOINT)
$(images)/zImage-PPLUS: $(obj)/zvmlinux $(MKPREP) $(MKBUGBOOT) $(images)/zImage-PPLUS: $(obj)/zvmlinux $(utils)/mkprep $(MKBUGBOOT)
$(MKPREP) -pbp $(obj)/zvmlinux $(images)/zImage.pplus $(MKPREP) -pbp $(obj)/zvmlinux $(images)/zImage.$(end-y)
$(MKBUGBOOT) $(obj)/zvmlinux $(images)/zImage.bugboot $(MKBUGBOOT) $(obj)/zvmlinux $(images)/zImage.bugboot
$(images)/zImage.initrd-PPLUS: $(obj)/zvmlinux.initrd $(MKPREP) $(MKBUGBOOT) $(images)/zImage.initrd-PPLUS: $(obj)/zvmlinux.initrd $(utils)/mkprep $(MKBUGBOOT)
$(MKPREP) -pbp $(obj)/zvmlinux.initrd $(images)/zImage.initrd.pplus $(MKPREP) -pbp $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(end-y)
$(MKBUGBOOT) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.bugboot $(MKBUGBOOT) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.bugboot
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* trini@mvista.com * trini@mvista.com
* Derived from arch/ppc/boot/prep/head.S (Cort Dougan, many others). * 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 * the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express * is licensed "as is" without any warranty of any kind, whether express
* or implied. * or implied.
...@@ -57,10 +57,11 @@ start_: ...@@ -57,10 +57,11 @@ start_:
isync isync
#endif #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. mr r29,r3 /* On the MBX860, r3 is the board info pointer.
* On the RPXSUPER, r3 points to the * On the RPXSUPER, r3 points to the NVRAM
* NVRAM configuration keys. * configuration keys.
* On PReP, r3 is the pointer to the residual data.
*/ */
#endif #endif
...@@ -69,7 +70,36 @@ start_: ...@@ -69,7 +70,36 @@ start_:
/* The following functions we call must not modify r3 or r4..... /* The following functions we call must not modify r3 or r4.....
*/ */
#ifdef CONFIG_6xx #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 bl disable_6xx_mmu
#endif
bl disable_6xx_l1cache bl disable_6xx_l1cache
CLEAR_CACHES CLEAR_CACHES
...@@ -99,7 +129,7 @@ start_: ...@@ -99,7 +129,7 @@ start_:
mr r3, r29 mr r3, r29
#endif #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 mr r4,r29 /* put the board info pointer where the relocate
* routine will find it * routine will find it
*/ */
......
/* /*
* arch/ppc/boot/prep/misc.c * arch/ppc/boot/simple/misc-prep.c
* *
* Adapted for PowerPC by Gary Thomas * Maintainer: Tom Rini <trini@kernel.crashing.org>
* *
* Rewritten by Cort Dougan (cort@cs.nmt.edu) * In the past: Gary Thomas, Cort Dougan <cort@cs.nmt.edu>
* One day to be replaced by a single bootloader for chrp/prep/pmac. -- Cort
*/ */
#include <linux/types.h>
#include <linux/string.h>
#include <asm/residual.h>
#include <linux/config.h> #include <linux/config.h>
#include <linux/threads.h>
#include <linux/elf.h>
#include <linux/pci_ids.h> #include <linux/pci_ids.h>
#include <asm/page.h> #include <linux/types.h>
#include <asm/processor.h> #include <asm/residual.h>
#include <asm/bootinfo.h> #include <asm/string.h>
#include <asm/mmu.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include "mpc10x.h"
#include "of1275.h" #include "of1275.h"
#include "nonstdio.h" #include "nonstdio.h"
#include "zlib.h"
/*
* 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;
/* The linker tells us where the image is. */
extern char __image_begin, __image_end;
extern char __ramdisk_begin, __ramdisk_end;
extern char _end[];
#ifdef CONFIG_CMDLINE extern int keyb_present; /* keyboard controller is present by default */
#define CMDLINE CONFIG_CMDLINE
#else
#define CMDLINE ""
#endif
char cmd_preset[] = CMDLINE;
char cmd_buf[256];
char *cmd_line = cmd_buf;
int keyb_present = 1; /* keyboard controller is present by default */
RESIDUAL hold_resid_buf; RESIDUAL hold_resid_buf;
RESIDUAL *hold_residual = &hold_resid_buf; RESIDUAL *hold_residual = &hold_resid_buf;
unsigned long initrd_size = 0; static void *OFW_interface; /* Pointer to OF, if available. */
char *zimage_start;
int zimage_size;
#if defined(CONFIG_SERIAL_8250_CONSOLE)
unsigned long com_port;
#endif /* CONFIG_SERIAL_8250_CONSOLE */
#ifdef CONFIG_VGA_CONSOLE #ifdef CONFIG_VGA_CONSOLE
char *vidmem = (char *)0xC00B8000; char *vidmem = (char *)0xC00B8000;
int lines = 25, cols = 80; int lines = 25, cols = 80;
...@@ -69,9 +32,12 @@ extern int vga_init(unsigned char *ISA_mem); ...@@ -69,9 +32,12 @@ extern int vga_init(unsigned char *ISA_mem);
extern void gunzip(void *, int, unsigned char *, int *); extern void gunzip(void *, int, unsigned char *, int *);
extern unsigned long serial_init(int chan, void *ignored); extern unsigned long serial_init(int chan, void *ignored);
extern void serial_fixups(void); extern void serial_fixups(void);
extern unsigned long get_mem_size(void); extern struct bi_record *decompress_kernel(unsigned long load_addr,
int num_words, unsigned long cksum);
extern void disable_6xx_mmu(void);
extern unsigned long mpc10x_get_mem_size(void);
void static void
writel(unsigned int val, unsigned int address) writel(unsigned int val, unsigned int address)
{ {
/* Ensure I/O operations complete */ /* Ensure I/O operations complete */
...@@ -79,24 +45,21 @@ writel(unsigned int val, unsigned int address) ...@@ -79,24 +45,21 @@ writel(unsigned int val, unsigned int address)
*(unsigned int *)address = cpu_to_le32(val); *(unsigned int *)address = cpu_to_le32(val);
} }
unsigned int
readl(unsigned int address)
{
/* Ensure I/O operations complete */
__asm__ volatile("eieio");
return le32_to_cpu(*(unsigned int *)address);
}
#define PCI_CFG_ADDR(dev,off) ((0x80<<24) | (dev<<8) | (off&0xfc)) #define PCI_CFG_ADDR(dev,off) ((0x80<<24) | (dev<<8) | (off&0xfc))
#define PCI_CFG_DATA(off) (0x80000cfc+(off&3)) #define PCI_CFG_DATA(off) (MPC10X_MAPA_CNFG_DATA+(off&3))
static void static void
pci_read_config_32(unsigned char devfn, pci_read_config_32(unsigned char devfn,
unsigned char offset, unsigned char offset,
unsigned int *val) unsigned int *val)
{ {
writel(PCI_CFG_ADDR(devfn,offset), 0x80000cf8); /* Ensure I/O operations complete */
*val = readl(PCI_CFG_DATA(offset)); __asm__ volatile("eieio");
*(unsigned int *)PCI_CFG_ADDR(devfn,offset) =
cpu_to_le32(MPC10X_MAPA_CNFG_ADDR);
/* Ensure I/O operations complete */
__asm__ volatile("eieio");
*val = le32_to_cpu(*(unsigned int *)PCI_CFG_DATA(offset));
return; return;
} }
...@@ -113,60 +76,28 @@ scroll(void) ...@@ -113,60 +76,28 @@ scroll(void)
#endif /* CONFIG_VGA_CONSOLE */ #endif /* CONFIG_VGA_CONSOLE */
unsigned long unsigned long
decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, load_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
RESIDUAL *residual, void *OFW_interface) RESIDUAL *residual, void *OFW)
{ {
int timer = 0;
extern unsigned long start;
char *cp, ch;
unsigned long TotalMemory;
int start_multi = 0; int start_multi = 0;
unsigned int pci_viddid, pci_did, tulip_pci_base, tulip_base; unsigned int pci_viddid, pci_did, tulip_pci_base, tulip_base;
/* If we have Open Firmware, initialise it immediately */ /* If we have Open Firmware, initialise it immediately */
if (OFW_interface) if (OFW) {
OFW_interface = OFW;
ofinit(OFW_interface); ofinit(OFW_interface);
}
serial_fixups();
#if defined(CONFIG_SERIAL_8250_CONSOLE)
com_port = serial_init(0, NULL);
#endif /* CONFIG_SERIAL_8250_CONSOLE */
#if defined(CONFIG_VGA_CONSOLE) #if defined(CONFIG_VGA_CONSOLE)
vga_init((unsigned char *)0xC0000000); vga_init((unsigned char *)0xC0000000);
#endif /* CONFIG_VGA_CONSOLE */ #endif /* CONFIG_VGA_CONSOLE */
/*
* Tell the user where we were loaded at and where we were relocated
* to for debugging this process.
*/
puts("loaded at: "); puthex(load_addr);
puts(" "); puthex((unsigned long)(load_addr + (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) { if (residual) {
/*
* Tell the user where the residual data is.
*/
puts("board data at: "); puthex((unsigned long)residual);
puts(" ");
puthex((unsigned long)((unsigned long)residual +
sizeof(RESIDUAL)));
puts("\nrelocated to: ");puthex((unsigned long)hold_residual);
puts(" ");
puthex((unsigned long)((unsigned long)hold_residual +
sizeof(RESIDUAL)));
puts("\n");
/* Is this Motorola PPCBug? */ /* Is this Motorola PPCBug? */
if ((1 & residual->VitalProductData.FirmwareSupports) && if ((1 & residual->VitalProductData.FirmwareSupports) &&
(1 == residual->VitalProductData.FirmwareSupplier)) { (1 == residual->VitalProductData.FirmwareSupplier)) {
unsigned char base_mod; unsigned char base_mod;
unsigned char board_type = inb(0x800) & 0xF0; unsigned char board_type = inb(0x801) & 0xF0;
/* /*
* Reset the onboard 21x4x Ethernet * Reset the onboard 21x4x Ethernet
...@@ -209,11 +140,30 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, ...@@ -209,11 +140,30 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
start_multi = 1; start_multi = 1;
} }
memcpy(hold_residual,residual,sizeof(RESIDUAL)); memcpy(hold_residual,residual,sizeof(RESIDUAL));
} else {
/* Tell the user we didn't find anything. */
puts("No residual data found.\n");
} }
/* Call decompress_kernel */
decompress_kernel(load_addr, num_words, cksum);
if (start_multi) {
residual->VitalProductData.SmpIar = (unsigned long)0xc0;
residual->Cpus[1].CpuState = CPU_GOOD;
hold_residual->VitalProductData.Reserved5 = 0xdeadbeef;
}
/* Now go and clear out the BATs and ensure that our MSR is
* correct .*/
disable_6xx_mmu();
/* Make r3 be a pointer to the residual data. */
return (unsigned long)hold_residual;
}
unsigned long
get_mem_size(void)
{
unsigned int pci_viddid, pci_did;
/* First, figure out what kind of host bridge we are on. If it's /* First, figure out what kind of host bridge we are on. If it's
* an MPC10x, we can ask it directly how much memory it has. * an MPC10x, we can ask it directly how much memory it has.
* Otherwise, see if the residual data has anything. This isn't * Otherwise, see if the residual data has anything. This isn't
...@@ -228,10 +178,10 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, ...@@ -228,10 +178,10 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
&& ((pci_did == PCI_DEVICE_ID_MOTOROLA_MPC105) && ((pci_did == PCI_DEVICE_ID_MOTOROLA_MPC105)
|| (pci_did == PCI_DEVICE_ID_MOTOROLA_MPC106) || (pci_did == PCI_DEVICE_ID_MOTOROLA_MPC106)
|| (pci_did == PCI_DEVICE_ID_MOTOROLA_MPC107))) || (pci_did == PCI_DEVICE_ID_MOTOROLA_MPC107)))
TotalMemory = get_mem_size(); return mpc10x_get_mem_size();
/* If it's not, see if we have anything in the residual data. */ /* If it's not, see if we have anything in the residual data. */
else if (residual && residual->TotalMemory) else if (hold_residual && hold_residual->TotalMemory)
TotalMemory = residual->TotalMemory; return hold_residual->TotalMemory;
else if (OFW_interface) { else if (OFW_interface) {
/* /*
* This is a 'best guess' check. We want to make sure * This is a 'best guess' check. We want to make sure
...@@ -252,174 +202,10 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, ...@@ -252,174 +202,10 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
sizeof(mem_info)) != 8) sizeof(mem_info)) != 8)
break; break;
TotalMemory = mem_info[1]; return mem_info[1];
break;
}
} else
/* Fall back to hard-coding 32MB. */
TotalMemory = 32*1024*1024;
/* assume the chunk below 8M is free */
end_avail = (char *)0x00800000;
/*
* We link ourself to 0x00800000. When we run, we relocate
* ourselves there. So we just need __image_begin for the
* start. -- Tom
*/
zimage_start = (char *)(unsigned long)(&__image_begin);
zimage_size = (unsigned long)(&__image_end) -
(unsigned long)(&__image_begin);
initrd_size = (unsigned long)(&__ramdisk_end) -
(unsigned long)(&__ramdisk_begin);
/*
* The zImage and initrd will be between start and _end, so they've
* already been moved once. We're good to go now. -- Tom
*/
avail_ram = (char *)PAGE_ALIGN((unsigned long)_end);
puts("zimage at: "); puthex((unsigned long)zimage_start);
puts(" "); puthex((unsigned long)(zimage_size+zimage_start));
puts("\n");
if ( initrd_size ) {
puts("initrd at: ");
puthex((unsigned long)(&__ramdisk_begin));
puts(" "); puthex((unsigned long)(&__ramdisk_end));puts("\n");
}
avail_ram = (char *)0x00400000;
end_avail = (char *)0x00800000;
puts("avail ram: "); puthex((unsigned long)avail_ram); puts(" ");
puthex((unsigned long)end_avail); puts("\n");
if (keyb_present)
CRT_tstc(); /* Forces keyboard to be initialized */
puts("\nLinux/PPC load: ");
cp = cmd_line;
memcpy (cmd_line, cmd_preset, sizeof(cmd_preset));
while ( *cp )
putc(*cp++);
while (timer++ < 5*1000) {
if (tstc()) {
while ((ch = getc()) != '\n' && ch != '\r') {
/* Test for backspace/delete */
if (ch == '\b' || ch == '\177') {
if (cp != cmd_line) {
cp--;
puts("\b \b");
}
/* Test for ^x/^u (and wipe the line) */
} else if (ch == '\030' || ch == '\025') {
while (cp != cmd_line) {
cp--;
puts("\b \b");
}
} else {
*cp++ = ch;
putc(ch);
}
}
break; /* Exit 'timer' loop */
}
udelay(1000); /* 1 msec */
}
*cp = 0;
puts("\nUncompressing Linux...");
/*
* If we have OF, then we have deferred setting the MSR.
* We must set it now because we are about to overwrite
* the exception table. The new MSR value will disable
* machine check exceptions and point the exception table
* to the ROM.
*/
if (OFW_interface) {
mtmsr(MSR_IP | MSR_FP);
asm volatile("isync");
}
gunzip(0, 0x400000, zimage_start, &zimage_size);
puts("done.\n");
if (start_multi) {
puts("Parking cpu1 at 0xc0\n");
residual->VitalProductData.SmpIar = (unsigned long)0xc0;
residual->Cpus[1].CpuState = CPU_GOOD;
hold_residual->VitalProductData.Reserved5 = 0xdeadbeef;
} }
{
struct bi_record *rec;
unsigned long initrd_loc;
unsigned long rec_loc = _ALIGN((unsigned long)(zimage_size) +
(1 << 20) - 1, (1 << 20));
rec = (struct bi_record *)rec_loc;
/* We need to make sure that the initrd and bi_recs do not
* overlap. */
if ( initrd_size ) {
initrd_loc = (unsigned long)(&__ramdisk_begin);
/* If the bi_recs are in the middle of the current
* initrd, move the initrd to the next MB
* boundary. */
if ((rec_loc > initrd_loc) &&
((initrd_loc + initrd_size)
> rec_loc)) {
initrd_loc = _ALIGN((unsigned long)(zimage_size)
+ (2 << 20) - 1, (2 << 20));
memmove((void *)initrd_loc, &__ramdisk_begin,
initrd_size);
puts("initrd moved: "); puthex(initrd_loc);
puts(" "); puthex(initrd_loc + initrd_size);
puts("\n");
} }
}
rec->tag = BI_FIRST;
rec->size = sizeof(struct bi_record);
rec = (struct bi_record *)((unsigned long)rec + rec->size);
rec->tag = BI_BOOTLOADER_ID;
memcpy( (void *)rec->data, "prepboot", 9);
rec->size = sizeof(struct bi_record) + 8 + 1;
rec = (struct bi_record *)((unsigned long)rec + rec->size);
rec->tag = BI_MACHTYPE;
rec->data[0] = _MACH_prep;
rec->data[1] = 0;
rec->size = sizeof(struct bi_record) + 2 *
sizeof(unsigned long);
rec = (struct bi_record *)((unsigned long)rec + rec->size);
rec->tag = BI_MEMSIZE;
rec->data[0] = TotalMemory;
rec->size = sizeof(struct bi_record) + sizeof(unsigned long);
rec = (struct bi_record *)((unsigned long)rec + rec->size);
rec->tag = BI_CMD_LINE;
memcpy( (char *)rec->data, cmd_line, strlen(cmd_line)+1);
rec->size = sizeof(struct bi_record) + strlen(cmd_line) + 1;
rec = (struct bi_record *)((unsigned long)rec + rec->size);
if ( initrd_size ) { /* Fall back to hard-coding 32MB. */
rec->tag = BI_INITRD; return 32*1024*1024;
rec->data[0] = initrd_loc;
rec->data[1] = initrd_size;
rec->size = sizeof(struct bi_record) + 2 *
sizeof(unsigned long);
rec = (struct bi_record *)((unsigned long)rec +
rec->size);
}
rec->tag = BI_LAST;
rec->size = sizeof(struct bi_record);
rec = (struct bi_record *)((unsigned long)rec + rec->size);
}
puts("Now booting the kernel\n");
return (unsigned long)hold_residual;
} }
...@@ -174,7 +174,8 @@ get_mem_size(void) ...@@ -174,7 +174,8 @@ get_mem_size(void)
} }
unsigned long 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 csr0;
int csr_id; int csr_id;
......
...@@ -99,7 +99,9 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum) ...@@ -99,7 +99,9 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
unsigned long initrd_loc, TotalMemory = 0; unsigned long initrd_loc, TotalMemory = 0;
serial_fixups(); serial_fixups();
#ifdef CONFIG_SERIAL_8250_CONSOLE
com_port = serial_init(0, NULL); com_port = serial_init(0, NULL);
#endif
#ifdef CONFIG_44x #ifdef CONFIG_44x
/* Reset MAL */ /* Reset MAL */
...@@ -269,7 +271,8 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum) ...@@ -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. */ /* Allow decompress_kernel to be hooked into. This is the default. */
void * __attribute__ ((weak)) 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); return decompress_kernel(load_addr, num_words, cksum);
} }
...@@ -52,8 +52,12 @@ MPC10X_PCI_OP(read, dword, u32 *, in_le32, 0) ...@@ -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 * 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 * 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 * 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 unsigned long
get_mem_size(void) get_mem_size(void)
{ {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* trini@mvista.com * trini@mvista.com
* Derived from arch/ppc/boot/prep/head.S (Cort Dougan, many others). * 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 * the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express * is licensed "as is" without any warranty of any kind, whether express
* or implied. * or implied.
...@@ -182,6 +182,7 @@ start_ldr: ...@@ -182,6 +182,7 @@ start_ldr:
mr r4,r7 /* Program length */ mr r4,r7 /* Program length */
mr r5,r6 /* Checksum */ mr r5,r6 /* Checksum */
mr r6,r11 /* Residual data */ mr r6,r11 /* Residual data */
mr r7,r25 /* Validated OFW interface */
bl load_kernel bl load_kernel
/* /*
...@@ -195,8 +196,18 @@ start_ldr: ...@@ -195,8 +196,18 @@ start_ldr:
/* /*
* Start at the begining. * Start at the begining.
*/ */
li r9,0x0000 li r9,0xc
mtlr r9 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 blr
.comm .stack,4096*2,4 .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