Very initial support for booting PPC kernels on P5 boards.
This commit is contained in:
parent
14ed33e42e
commit
4905974fd1
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* $NetBSD: main.c,v 1.10 1998/11/13 22:12:35 is Exp $
|
||||
* $NetBSD: main.c,v 1.11 1999/11/28 22:10:47 is Exp $
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1996 Ignatios Souvatzis
|
||||
* Copyright (c) 1996,1999 Ignatios Souvatzis
|
||||
* Copyright (c) 1994 Michael L. Hitch
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -62,8 +62,13 @@
|
|||
|
||||
void startit __P((void *, u_long, u_long, void *, u_long, u_long, int, void *,
|
||||
int, int, u_long, u_long, u_long, int));
|
||||
void startit_end __P((void));
|
||||
int get_cpuid __P((u_int32_t *));
|
||||
#ifdef PPCBOOTER
|
||||
u_int16_t kickstart[];
|
||||
size_t kicksize;
|
||||
#else
|
||||
void startit_end __P((void));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Kernel startup interface version
|
||||
|
@ -78,7 +83,7 @@ int get_cpuid __P((u_int32_t *));
|
|||
|
||||
static long get_number(char **);
|
||||
|
||||
#define VERSION "2.1"
|
||||
#define VERSION "2.2"
|
||||
|
||||
char default_command[] = "netbsd -ASn2";
|
||||
|
||||
|
@ -108,7 +113,7 @@ pain(aio)
|
|||
/* int skip_chipmem = 0; */
|
||||
|
||||
void (*start_it)(void *, u_long, u_long, void *, u_long, u_long, int,
|
||||
void *, int, int, u_long, u_long, u_long, int) = startit;
|
||||
void *, int, int, u_long, u_long, u_long, int);
|
||||
|
||||
caddr_t kp;
|
||||
u_int16_t *kvers;
|
||||
|
@ -145,8 +150,13 @@ pain(aio)
|
|||
goto out;
|
||||
}
|
||||
|
||||
#ifdef PPCBOOTER
|
||||
printf("\2337mNetBSD/AmigaPPC bootblock " VERSION "\2330m\n%s :- ",
|
||||
kernel_name);
|
||||
#else
|
||||
printf("\2337mNetBSD/Amiga bootblock " VERSION "\2330m\n%s :- ",
|
||||
kernel_name);
|
||||
#endif
|
||||
|
||||
timelimit = 3;
|
||||
gets(linebuf);
|
||||
|
@ -332,10 +342,14 @@ pain(aio)
|
|||
goto err;
|
||||
}
|
||||
|
||||
#ifdef PPCBOOTER
|
||||
/* XXX to be done */
|
||||
#else
|
||||
if ((N_GETMAGIC(ehs) != NMAGIC) || (N_GETMID(ehs) != MID_M68K)) {
|
||||
errno = ENOEXEC;
|
||||
goto err;
|
||||
}
|
||||
#endif
|
||||
|
||||
textsz = (ehs.a_text + __LDPGSZ - 1) & (-__LDPGSZ);
|
||||
esym = 0;
|
||||
|
@ -352,23 +366,28 @@ pain(aio)
|
|||
goto err;
|
||||
ksize += ehs.a_syms + 4 + ((stringsz + 3) & ~3);
|
||||
}
|
||||
|
||||
#ifdef PPCBOOTER
|
||||
kp = alloc(ksize);
|
||||
#else
|
||||
kp = alloc(ksize + 256 + ((u_char *)startit_end - (u_char *)startit));
|
||||
#endif
|
||||
if (kp == 0) {
|
||||
errno = ENOMEM;
|
||||
goto err;
|
||||
}
|
||||
|
||||
printf("%ld", ehs.a_text);
|
||||
if (read(io, kp, ehs.a_text) != ehs.a_text)
|
||||
if (ehs.a_text && (read(io, kp, ehs.a_text) != ehs.a_text))
|
||||
goto err;
|
||||
|
||||
printf("+%ld", ehs.a_data);
|
||||
if (read(io, kp + textsz, ehs.a_data) != ehs.a_data)
|
||||
if (ehs.a_data && (read(io, kp + textsz, ehs.a_data) != ehs.a_data))
|
||||
goto err;
|
||||
|
||||
printf("+%ld", ehs.a_bss);
|
||||
|
||||
nkcd = (int *)(kp + textsz + ehs.a_data + ehs.a_bss);
|
||||
#ifndef PPCBOOTER
|
||||
kvers = (u_short *)(kp + ehs.a_entry - 2);
|
||||
|
||||
if (*kvers > KERNEL_STARTUP_VERSION_MAX && *kvers != 0x4e73) {
|
||||
|
@ -384,7 +403,6 @@ pain(aio)
|
|||
printf("\nKernel V%ld newer than bootblock V%ld\n",
|
||||
(long)*kvers, (long)KERNEL_STARTUP_VERSION);
|
||||
#endif
|
||||
nkcd = (int *)(kp + textsz + ehs.a_data + ehs.a_bss);
|
||||
if (*kvers != 0x4e73 && *kvers > 1 && S_flag && ehs.a_syms) {
|
||||
*nkcd++ = ehs.a_syms;
|
||||
printf("+[%ld", ehs.a_syms);
|
||||
|
@ -398,6 +416,7 @@ pain(aio)
|
|||
esym = (char *)(textsz + ehs.a_data + ehs.a_bss
|
||||
+ ehs.a_syms + 4 + ((stringsz + 3) & ~3));
|
||||
}
|
||||
#endif
|
||||
putchar('\n');
|
||||
|
||||
*nkcd = ncd;
|
||||
|
@ -405,10 +424,12 @@ pain(aio)
|
|||
|
||||
while ((cd = FindConfigDev(cd, -1, -1))) {
|
||||
*kcd = *cd;
|
||||
#ifndef PPCBOOTER
|
||||
if (((cpuid >> 24) == 0x7D) &&
|
||||
((u_long)kcd->addr < 0x1000000)) {
|
||||
kcd->addr += 0x3000000;
|
||||
}
|
||||
#endif
|
||||
++kcd;
|
||||
}
|
||||
|
||||
|
@ -420,6 +441,12 @@ pain(aio)
|
|||
while (nseg-- > 0)
|
||||
*kmemseg++ = *memseg++;
|
||||
|
||||
#ifdef PPCBOOTER
|
||||
/*
|
||||
* we use the ppc starter...
|
||||
*/
|
||||
start_it = startit;
|
||||
#else
|
||||
/*
|
||||
* Copy startup code to end of kernel image and set start_it.
|
||||
*/
|
||||
|
@ -427,6 +454,7 @@ pain(aio)
|
|||
(char *)startit_end - (char *)startit);
|
||||
CacheClearU();
|
||||
(caddr_t)start_it = kp + ksize + 256;
|
||||
#endif
|
||||
printf("*** Loading from %08lx to Fastmem %08lx ***\n",
|
||||
(u_long)kp, (u_long)fmem);
|
||||
/* sleep(2); */
|
||||
|
@ -448,7 +476,12 @@ pain(aio)
|
|||
#endif
|
||||
(void)getchar();
|
||||
|
||||
start_it(kp, ksize, ehs.a_entry, (void *)fmem, fmemsz, cmemsz,
|
||||
#ifdef PPCBOOTER
|
||||
startit
|
||||
#else
|
||||
start_it
|
||||
#endif
|
||||
(kp, ksize, ehs.a_entry, (void *)fmem, fmemsz, cmemsz,
|
||||
boothowto, esym, cpuid, eclock, amiga_flags, I_flag,
|
||||
aio_base >> 9, 1);
|
||||
/*NOTREACHED*/
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
# $NetBSD: Makefile,v 1.1 1999/11/28 22:10:48 is Exp $
|
||||
|
||||
### what we need:
|
||||
|
||||
DIR_TOP= ${.CURDIR}/../../../../..
|
||||
DIR_SA = ${DIR_TOP}/lib/libsa
|
||||
DIR_KERN= ${DIR_TOP}/lib/libkern
|
||||
DIR_KERN_MD= ${DIR_TOP}/lib/libkern/arch/$(MACHINE_ARCH)
|
||||
DIR_BOOT= ${.CURDIR}/../boot
|
||||
|
||||
.PATH: $(DIR_SA) $(DIR_KERN) $(DIR_KERN_MD) $(DIR_BOOT)
|
||||
|
||||
# prefer our assembler versions over assembler, and assembler over C:
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .out .o .po .so .s .S .c .cc .C .f .y .l .ln .m4 .sh
|
||||
|
||||
FILES= xxppcboot fdppcboot
|
||||
BINDIR=/usr/mdec
|
||||
|
||||
COBJS = main.o console.o xd.o twiddle.o bzero.o gets.o
|
||||
COBJS+= lseek.o open.o read.o close.o dev.o errno.o
|
||||
COBJS+= ufs.o ppcstart.o
|
||||
|
||||
SOBJS = alloc.o ashrdi3.o bcopy.o muldi3.o printf.o
|
||||
SOBJS += strlen.o strcmp.o
|
||||
SOBJS += libstubs.o
|
||||
|
||||
OBJS= $(SOBJS) $(COBJS)
|
||||
|
||||
DEFS = -DPPCBOOTER -D_STANDALONE -DINSECURE -DDEBUG_MEMORY_LIST
|
||||
|
||||
### main target: ###
|
||||
|
||||
all: ${FILES}
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
### special rules for bootblocks ###
|
||||
|
||||
INCPATH = -I${DIR_TOP} -I${DIR_TOP}/lib/libsa -I${DIR_BOOT} -I${.CURDIR} -I${.CURDIR}/../../.. -I${.CURDIR}/../aout2bb -I${.OBJDIR}
|
||||
|
||||
AFLAGS += -m68030 -l
|
||||
CAFLAGS += -Wa,-l -Wa,-m68030 ${INCPATH}
|
||||
|
||||
COPTIM= -O -fomit-frame-pointer -fcse-follow-jumps -fcse-skip-blocks -Wa,-l -m68060 -Wa,-m68030
|
||||
CFLAGS= ${COPTIM} ${INCPATH} ${DEFS} -Wall #-Wstrict-prototypes
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} -S $< -o $*.s
|
||||
${TXLT} < $*.s | ${AS} ${AFLAGS} -o $*.o
|
||||
rm $*.s
|
||||
|
||||
.s.o: ; ${CC} ${CAFLAGS} ${COPTS} -x assembler-with-cpp -o $@ -c $<
|
||||
|
||||
.S.o: ; ${CC} ${CAFLAGS} ${COPTS} -x assembler-with-cpp -o $@ -c $<
|
||||
|
||||
CLEANFILES += xxppcboot fdppcboot x.out f.out xxstart.o fdstart.o libboot.a
|
||||
|
||||
xxppcboot: x.out
|
||||
${AOUT2BB} x.out $@ || nm -u x.out
|
||||
|
||||
fdppcboot: f.out
|
||||
${AOUT2BB} f.out $@ || nm -u f.out
|
||||
|
||||
x.out: xxstart.o libboot.a
|
||||
${LD} ${LDFLAGS} -r -dc -e _start -o $@ $>
|
||||
size $@
|
||||
nm -u $@
|
||||
|
||||
f.out: fdstart.o libboot.a
|
||||
${LD} ${LDFLAGS} -r -dc -e _start -o $@ $>
|
||||
size $@
|
||||
nm -u $@
|
||||
|
||||
xxstart.o: ${DIR_BOOT}/bbstart.s
|
||||
${CC} ${CAFLAGS} ${COPTS} -x assembler-with-cpp \
|
||||
-o $@ -c $>
|
||||
|
||||
fdstart.o: ${DIR_BOOT}/bbstart.s
|
||||
${CC} -DAUTOLOAD=8192 ${CAFLAGS} ${COPTS} -x assembler-with-cpp \
|
||||
-o $@ -c $>
|
||||
|
||||
PPCCC=powerpc-netbsd-gcc
|
||||
PPCAS=powerpc-netbsd-as
|
||||
PPCLD=powerpc-netbsd-ld
|
||||
PPCOD=powerpc-netbsd-objdump
|
||||
|
||||
CLEANFILES += kickstart.o kickstart.bin kickstart68.c
|
||||
|
||||
ppcstart.o: kickstart68.c
|
||||
|
||||
kickstart68.c: kickstart.bin hex2c.awk
|
||||
hexdump kickstart.bin | awk -f ${.CURDIR}/hex2c.awk > $@
|
||||
|
||||
kickstart.bin: kickstart.o
|
||||
$(PPCLD) -Ttext=0xfff00100 -o$@ --oformat binary $?
|
||||
|
||||
kickstart.o: kickstart.S
|
||||
$(PPCCC) -DDEBUG $(COPTS) -x assembler-with-cpp -c $?
|
||||
|
||||
kickstart.lis: kickstart.o
|
||||
$(PPCOD) --disassemble-all kickstart.o
|
||||
|
||||
libboot.a: ${OBJS}
|
||||
${AR} r $@ $> && ${RANLIB} $@
|
||||
|
||||
# make sure these are built:
|
||||
|
||||
${COBJS}: ${TXLT}
|
||||
${FILES}: ${AOUT2BB}
|
|
@ -0,0 +1,8 @@
|
|||
# Copyright 1998 Ignatios Souvatzis. All rights reserved.
|
||||
BEGIN{print "/* Generated by a script --- do not edit */"}
|
||||
BEGIN{print "#include <sys/types.h>"}
|
||||
BEGIN{print "const u_int16_t kickstart[] = {"}
|
||||
BEGIN{size = 0}
|
||||
{ printf("\t"); for(i=2;i<=NF;i++) {printf("0x%s, ",$i);size += 2};printf("\n");}
|
||||
END{printf("\t0};\n");}
|
||||
END{print "const size_t kicksize = ", size ";"}
|
|
@ -0,0 +1,96 @@
|
|||
/* $NetBSD: kickstart.S,v 1.1 1999/11/28 22:10:48 is Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1998 Ignatios Souvatzis. All rights reserved.
|
||||
*/
|
||||
|
||||
#define PPC_CACHESIZE 16384
|
||||
#define PPC_LINESIZE 32
|
||||
|
||||
/*
|
||||
Memst: .long 0x08000000
|
||||
Krnst: .long 0x082f3400
|
||||
Krnsz: .long 0x00100000
|
||||
*/
|
||||
.globl _start
|
||||
_start:
|
||||
bl L2 /* we start with this address @ 0xfff00100 */
|
||||
L2:
|
||||
lis 13,0xf60000@ha
|
||||
li 14,0x08
|
||||
stb 14,0xf60000@l(13)
|
||||
#ifdef DEBUG
|
||||
lis 13,0xdff180@h
|
||||
ori 13,13,0xdff180@l
|
||||
|
||||
lis 12,1000000@h
|
||||
ori 12,12,1000000@l
|
||||
mtctr 12
|
||||
L2a:
|
||||
li 14,0x00f
|
||||
sth 14,0(13)
|
||||
sync
|
||||
li 14,0xf0f
|
||||
sth 14,0(13)
|
||||
sync
|
||||
bdnz L2a
|
||||
#endif
|
||||
mflr 3
|
||||
lwz 4,-16(3)
|
||||
lwz 5,-12(3)
|
||||
lwz 6,-8(3)
|
||||
li 7,3
|
||||
addi 8,6,3
|
||||
cmplw 4,5
|
||||
andc 8,8,7
|
||||
srwi 9,8,2
|
||||
mtctr 9
|
||||
bgt Lb0
|
||||
/* here: copying downwards and forwards */
|
||||
lwz 9,0(5)
|
||||
stw 9,0(4)
|
||||
bdz Lflush
|
||||
Lf1: lwzu 7,4(5)
|
||||
stwu 7,4(4)
|
||||
bdnz Lf1
|
||||
b Lflush
|
||||
|
||||
Lb0: add 4,4,8 /* add the rounded up length */
|
||||
add 5,5,8 /* add the rounded up length */
|
||||
Lb1: lwzu 7,-4(5)
|
||||
stwu 7,-4(4)
|
||||
bdnz Lb1
|
||||
|
||||
Lflush:
|
||||
#ifdef DEBUG
|
||||
li 14,0xff0
|
||||
sth 14,0(13)
|
||||
sync
|
||||
#endif
|
||||
li 10,PPC_CACHESIZE/PPC_LINESIZE
|
||||
li 11,PPC_LINESIZE
|
||||
/* dcbst loop */
|
||||
mtctr 10
|
||||
lwz 12,-8(3)
|
||||
Lfl1: dcbst 0,12
|
||||
add 12,12,11
|
||||
bdnz Lfl1
|
||||
sync /* and wait for past instructions to finish */
|
||||
/* icbi loop */
|
||||
mtctr 10
|
||||
lwz 12,-8(3)
|
||||
Lfl2: icbi 0,12
|
||||
add 12,12,11
|
||||
bdnz Lfl2
|
||||
sync /* and wait for past instructions to finish */
|
||||
isync /* and flush instruction queue */
|
||||
Ljump:
|
||||
#ifdef DEBUG
|
||||
li 14,0x0f0
|
||||
sth 14,0(13)
|
||||
sync
|
||||
#endif
|
||||
lwz 3,-16(3)
|
||||
mtlr 3
|
||||
blr
|
||||
/* NOTREACHED */
|
|
@ -0,0 +1,46 @@
|
|||
/* $NetBSD: ppcstart.c,v 1.1 1999/11/28 22:10:48 is Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1999 Ignatios Souvatzis. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Startit for Phase5 PPC boards.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "libstubs.h"
|
||||
|
||||
#include "kickstart68.c"
|
||||
|
||||
void
|
||||
startit(kp, ksize, entry, fmem, fmemsz, cmemsz,
|
||||
boothowto, esym, cpuid, eclock, amiga_flags, I_flag,
|
||||
bootpartoff, history)
|
||||
|
||||
u_long kp, ksize, entry, fmem, fmemsz, cmemsz,
|
||||
boothowto, esym, cpuid, eclock, amiga_flags, I_flag,
|
||||
bootpartoff, history;
|
||||
{
|
||||
int i;
|
||||
|
||||
#define ONESEC
|
||||
/* #define ONESEC for (i=0; i<1000000; i++) */
|
||||
|
||||
ONESEC *(volatile u_int16_t *)0xdff180 = 0x0f0;
|
||||
*(volatile u_int8_t *)0xf60000 = 0x10;
|
||||
ONESEC *(volatile u_int16_t *)0xdff180 = 0xf80;
|
||||
|
||||
memcpy((caddr_t)0xfff00100, kickstart, kicksize);
|
||||
*(volatile u_int32_t *)0xfff000f4 = fmem;
|
||||
*(volatile u_int32_t *)0xfff000f8 = kp;
|
||||
*(volatile u_int32_t *)0xfff000fc = ksize;
|
||||
ONESEC *(volatile u_int16_t *)0xdff180 = 0xf00;
|
||||
*(volatile u_int8_t *)0xf60000 = 0x90;
|
||||
*(volatile u_int8_t *)0xf60000 = 0x08;
|
||||
/* NOTREACHED */
|
||||
while (1) {
|
||||
*(volatile u_int16_t *)0xdff180 = 0x0f0;
|
||||
*(volatile u_int16_t *)0xdff180 = 0x00f;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue