* Fix a stack of warnings.
* Make it possible to type a filename to boot1 so that it is possible to recover from fatally broken versions of /boot/loader. * Make a start at a CD boot program (not yet functional).
This commit is contained in:
parent
83a11f5f70
commit
70e65e7344
@ -1,6 +1,6 @@
|
||||
# $FreeBSD$
|
||||
|
||||
SUBDIR= libalpha
|
||||
SUBDIR+= boot1 boot2 netboot
|
||||
SUBDIR+= boot1 boot2 netboot cdboot
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <machine/prom.h>
|
||||
#include <machine/rpb.h>
|
||||
|
||||
#define DEBUGxx
|
||||
|
||||
@ -152,7 +153,7 @@ devread(char *buf, int block, size_t size)
|
||||
prom_read(prom_fd, size, buf, block);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
devclose()
|
||||
{
|
||||
if (prom_fd) {
|
||||
@ -161,35 +162,36 @@ devclose()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
getfilename(char *filename)
|
||||
{
|
||||
int c;
|
||||
char *p;
|
||||
char *p = filename;
|
||||
|
||||
puts("Boot: ");
|
||||
|
||||
while ((c = getchar()) != '\n') {
|
||||
if (c == '\b') {
|
||||
while ((c = getchar()) != '\r') {
|
||||
if (c == '\b' || c == 0177) {
|
||||
if (p > filename) {
|
||||
puts("\b \b");
|
||||
p--;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
putchar(c);
|
||||
*p++ = c;
|
||||
}
|
||||
}
|
||||
putchar('\n');
|
||||
*p = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
loadfile(char *name, char *addr)
|
||||
{
|
||||
int n;
|
||||
char filename[512];
|
||||
char *p;
|
||||
|
||||
restart:
|
||||
puts("Loading ");
|
||||
puts(name);
|
||||
puts("\n");
|
||||
@ -205,32 +207,46 @@ loadfile(char *name, char *addr)
|
||||
do {
|
||||
n = readit(p, 1024);
|
||||
p += n;
|
||||
if (ischar()) {
|
||||
puts("Stop!\n");
|
||||
devclose();
|
||||
getfilename(filename);
|
||||
name = filename;
|
||||
goto restart;
|
||||
}
|
||||
twiddle();
|
||||
} while (n > 0);
|
||||
|
||||
devclose();
|
||||
}
|
||||
|
||||
void
|
||||
static inline u_long rpcc()
|
||||
{
|
||||
u_long v;
|
||||
__asm__ __volatile__ ("rpcc %0" : "=r"(v));
|
||||
return v & 0xffffffff;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
char *loadaddr = (char*) SECONDARY_LOAD_ADDRESS;
|
||||
char *name = "/boot/loader";
|
||||
char *p;
|
||||
char filename[512];
|
||||
void (*entry) __P((void));
|
||||
|
||||
int i;
|
||||
u_long start, freq;
|
||||
int i;
|
||||
|
||||
init_prom_calls();
|
||||
|
||||
loadfile("/boot/loader", loadaddr);
|
||||
|
||||
start = rpcc();
|
||||
freq = ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq;
|
||||
while (rpcc() < start + freq) {
|
||||
if (ischar()) {
|
||||
getfilename(filename);
|
||||
name = filename;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
loadfile(name, loadaddr);
|
||||
|
||||
entry = (void (*)())loadaddr;
|
||||
(*entry)();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
70
sys/boot/alpha/cdboot/Makefile
Normal file
70
sys/boot/alpha/cdboot/Makefile
Normal file
@ -0,0 +1,70 @@
|
||||
# $NetBSD: Makefile,v 1.12 1998/02/19 14:18:36 drochner Exp $
|
||||
|
||||
BASE= cdboot
|
||||
PROG= ${BASE}
|
||||
NOMAN=
|
||||
NEWVERSWHAT= "SRM CD9660 boot" alpha
|
||||
|
||||
.PATH: ${.CURDIR}/../common
|
||||
|
||||
# i386-specific bootstrap sources
|
||||
SRCS+= main.c conf.c
|
||||
|
||||
# Always add MI sources
|
||||
.PATH: ${.CURDIR}/../../common
|
||||
.include <${.CURDIR}/../../common/Makefile.inc>
|
||||
CFLAGS+= -mno-fp-regs
|
||||
CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}
|
||||
CFLAGS+= -I${.CURDIR}/../../.. -I.
|
||||
CFLAGS+= -I${.OBJDIR}
|
||||
CFLAGS+= -DCDBOOT
|
||||
|
||||
CLEANFILES+= vers.c vers.o gensetdefs.o gensetdefs setdef0.o setdef1.o \
|
||||
setdefs.h start.o
|
||||
CLEANFILES+= ${BASE} ${BASE}.sym ${BASE}.list
|
||||
|
||||
CFLAGS+= -Wall
|
||||
|
||||
CFLAGS+= -I${LIBSTANDDIR}
|
||||
CFLAGS+= -I${.CURDIR}/..
|
||||
CRT= start.o
|
||||
STRIP=
|
||||
BINDIR?= /boot
|
||||
|
||||
all: ${BASE}
|
||||
|
||||
vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
|
||||
sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
|
||||
${CC} -c vers.c
|
||||
|
||||
${BASE}: ${BASE}.sym
|
||||
objcopy -O binary ${BASE}.sym ${BASE}
|
||||
|
||||
${BASE}.nosym: ${BASE}.sym
|
||||
cp ${BASE}.sym ${BASE}.nosym
|
||||
strip ${BASE}.nosym
|
||||
|
||||
${BASE}.sym: ${OBJS} ${LIBSTAND} ${LIBALPHA} ${CRT} vers.o setdef0.o setdef1.o
|
||||
${LD} -o ${BASE}.sym -M -e start -N -Ttext ${PRIMARY_LOAD_ADDRESS} \
|
||||
${CRT} setdef0.o ${OBJS} setdef1.o \
|
||||
vers.o ${LIBSTAND} ${LIBALPHA} ${LIBSTAND} >${.OBJDIR}/${BASE}.list
|
||||
|
||||
start.o: ${.CURDIR}/../libalpha/start.S
|
||||
${CC} -c ${CFLAGS} $<
|
||||
|
||||
setdef0.o: setdefs.h
|
||||
|
||||
setdef1.o: setdefs.h
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
setdefs.h: gensetdefs ${OBJS}
|
||||
@echo Generating linker sets
|
||||
@./gensetdefs ${OBJS} >setdefs.h
|
||||
|
||||
gensetdefs: gensetdefs.o
|
||||
${CC} -static gensetdefs.o -o $@
|
||||
|
||||
gensetdefs.o: gensetdefs.c
|
||||
${CC} -c $<
|
||||
|
86
sys/boot/alpha/cdboot/conf.c
Normal file
86
sys/boot/alpha/cdboot/conf.c
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* $Id$
|
||||
* From: $NetBSD: conf.c,v 1.2 1997/03/22 09:03:29 thorpej Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997
|
||||
* Matthias Drochner. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed for the NetBSD Project
|
||||
* by Matthias Drochner.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <stand.h>
|
||||
#include "libalpha/libalpha.h"
|
||||
#include "dev_net.h"
|
||||
|
||||
/*
|
||||
* We could use linker sets for some or all of these, but
|
||||
* then we would have to control what ended up linked into
|
||||
* the bootstrap. So it's easier to conditionalise things
|
||||
* here.
|
||||
*
|
||||
* XXX rename these arrays to be consistent and less namespace-hostile
|
||||
*/
|
||||
|
||||
/* Exported for libstand */
|
||||
struct devsw *devsw[] = {
|
||||
&srmdisk,
|
||||
NULL
|
||||
};
|
||||
|
||||
struct fs_ops *file_system[] = {
|
||||
&cd9660_fsops,
|
||||
&zipfs_fsops,
|
||||
NULL
|
||||
};
|
||||
|
||||
/* Exported for alpha only */
|
||||
/*
|
||||
* Sort formats so that those that can detect based on arguments
|
||||
* rather than reading the file go first.
|
||||
*/
|
||||
extern struct module_format alpha_elf;
|
||||
|
||||
struct module_format *module_formats[] = {
|
||||
&alpha_elf,
|
||||
NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* Consoles
|
||||
*
|
||||
* We don't prototype these in libalpha.h because they require
|
||||
* data structures from bootstrap.h as well.
|
||||
*/
|
||||
extern struct console promconsole;
|
||||
|
||||
struct console *consoles[] = {
|
||||
&promconsole,
|
||||
NULL
|
||||
};
|
7
sys/boot/alpha/cdboot/version
Normal file
7
sys/boot/alpha/cdboot/version
Normal file
@ -0,0 +1,7 @@
|
||||
$Id: version,v 1.1.1.1 1998/08/21 03:17:42 msmith Exp $
|
||||
|
||||
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
|
||||
file is important. Make sure the current version number is on line 6.
|
||||
|
||||
0.1: Initial i386 version, germinated from the NetBSD i386
|
||||
standalone, but enormously modified.
|
@ -68,9 +68,8 @@ extend_heap()
|
||||
{
|
||||
struct rpb *hwrpb = (struct rpb *)HWRPB_ADDR;
|
||||
struct mddt *mddtp;
|
||||
struct mddt_cluster *memc;
|
||||
struct mddt_cluster *memc = 0;
|
||||
int i;
|
||||
unsigned long total = 0;
|
||||
unsigned long startpfn;
|
||||
vm_offset_t startva;
|
||||
vm_offset_t startpte;
|
||||
@ -107,7 +106,7 @@ extend_heap()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i;
|
||||
@ -188,6 +187,8 @@ main(void)
|
||||
open("/boot", O_RDONLY);
|
||||
|
||||
interact(); /* doesn't return */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot);
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include <machine/bootinfo.h>
|
||||
#include "bootstrap.h"
|
||||
|
||||
extern char *alpha_fmtdev(void *vdev);
|
||||
|
||||
/*
|
||||
* Copy the environment into the load area starting at (addr).
|
||||
* Each variable is formatted as <name>=<value>, with a single nul
|
||||
|
@ -63,7 +63,7 @@
|
||||
static int bd_init(void);
|
||||
static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize);
|
||||
static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize);
|
||||
static int bd_open(struct open_file *f, void *vdev);
|
||||
static int bd_open(struct open_file *f, ...);
|
||||
static int bd_close(struct open_file *f);
|
||||
static void bd_print(int verbose);
|
||||
|
||||
@ -147,9 +147,10 @@ bd_print(int verbose)
|
||||
* slice before it?)
|
||||
*/
|
||||
static int
|
||||
bd_open(struct open_file *f, void *vdev)
|
||||
bd_open(struct open_file *f, ...)
|
||||
{
|
||||
struct alpha_devdesc *dev = vdev;
|
||||
va_list args;
|
||||
struct alpha_devdesc *dev;
|
||||
struct dos_partition *dptr;
|
||||
struct open_disk *od;
|
||||
struct disklabel *lp;
|
||||
@ -158,6 +159,10 @@ bd_open(struct open_file *f, void *vdev)
|
||||
int unit;
|
||||
prom_return_t ret;
|
||||
|
||||
va_start(args, f);
|
||||
dev = va_arg(args, struct alpha_devdesc*);
|
||||
va_end(args);
|
||||
|
||||
unit = dev->d_kind.srmdisk.unit;
|
||||
if (unit >= nbdinfo) {
|
||||
D(printf("attempt to open nonexistent disk\n"));
|
||||
|
@ -57,7 +57,7 @@ Lstartgp:
|
||||
subq a1,a0,a1
|
||||
CALL(bzero)
|
||||
|
||||
#if defined(NETBOOT) || defined(LOADER)
|
||||
#if defined(CDBOOT) || defined(NETBOOT) || defined(LOADER)
|
||||
lda sp,stack + STACK_SIZE - ENTRY_FRAME
|
||||
#endif
|
||||
|
||||
@ -84,6 +84,6 @@ LEAF(cpu_number, 0)
|
||||
RET
|
||||
END(cpu_number)
|
||||
|
||||
#if defined(NETBOOT) || defined(LOADER)
|
||||
#if defined(CDBOOT) || defined(NETBOOT) || defined(LOADER)
|
||||
BSS(stack, STACK_SIZE)
|
||||
#endif
|
||||
|
@ -79,9 +79,8 @@ static int netdev_sock = -1;
|
||||
static int netdev_opens;
|
||||
|
||||
static int net_init(void);
|
||||
static int net_open(struct open_file *, void *vdev);
|
||||
static int net_open(struct open_file *, ...);
|
||||
static int net_close(struct open_file *);
|
||||
static int net_ioctl();
|
||||
static int net_strategy();
|
||||
|
||||
static int net_getparams(int sock);
|
||||
@ -108,12 +107,15 @@ net_init(void)
|
||||
* This is declared with variable arguments...
|
||||
*/
|
||||
int
|
||||
net_open(struct open_file *f, void *vdev)
|
||||
net_open(struct open_file *f, ...)
|
||||
{
|
||||
va_list args;
|
||||
char *devname; /* Device part of file name (or NULL). */
|
||||
int error = 0;
|
||||
|
||||
devname = vdev;
|
||||
va_start(args, f);
|
||||
devname = va_arg(args, char*);
|
||||
va_end(args);
|
||||
|
||||
/* On first open, do netif open, mount, etc. */
|
||||
if (netdev_opens == 0) {
|
||||
@ -172,12 +174,6 @@ net_close(f)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
net_ioctl()
|
||||
{
|
||||
return EIO;
|
||||
}
|
||||
|
||||
int
|
||||
net_strategy()
|
||||
{
|
||||
@ -202,6 +198,8 @@ int try_bootp = 1;
|
||||
int bootp(int sock);
|
||||
#endif
|
||||
|
||||
extern n_long ip_convertaddr(char *p);
|
||||
|
||||
static int
|
||||
net_getparams(sock)
|
||||
int sock;
|
||||
|
@ -227,7 +227,7 @@ aout_loadimage(struct loaded_module *mp, int fd, vm_offset_t loadaddr, struct ex
|
||||
addr += sizeof(ehdr->a_syms);
|
||||
|
||||
/* symbol table */
|
||||
printf("symbols=[0x%x+0x%lx", sizeof(ehdr->a_syms), ehdr->a_syms);
|
||||
printf("symbols=[0x%lx+0x%lx", sizeof(ehdr->a_syms), ehdr->a_syms);
|
||||
if (archsw.arch_readin(fd, addr, ehdr->a_syms) != ehdr->a_syms)
|
||||
return(0);
|
||||
addr += ehdr->a_syms;
|
||||
@ -237,7 +237,7 @@ aout_loadimage(struct loaded_module *mp, int fd, vm_offset_t loadaddr, struct ex
|
||||
archsw.arch_copyin(&ss, addr, sizeof(ss));
|
||||
addr += sizeof(ss);
|
||||
ss -= sizeof(ss);
|
||||
printf("+0x%x+0x%x]", sizeof(ss), ss);
|
||||
printf("+0x%lx+0x%x]", sizeof(ss), ss);
|
||||
if (archsw.arch_readin(fd, addr, ss) != ss)
|
||||
return(0);
|
||||
addr += ss;
|
||||
|
Loading…
Reference in New Issue
Block a user