clean up the way bootinfo information is passed and used: move the version
number passed by the boot block into a register, change the kernel's bootinfo handing so that it always uses bootinfo to get bootinfo-ish values (filling them in if the boot blocks didn't pass them), and make versioning a small bit more sane.
This commit is contained in:
parent
eef219fd43
commit
92d17b5b50
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: autoconf.c,v 1.29 1998/01/09 17:06:35 drochner Exp $ */
|
||||
/* $NetBSD: autoconf.c,v 1.30 1998/02/12 01:53:18 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.29 1998/01/09 17:06:35 drochner Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.30 1998/02/12 01:53:18 cgd Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -63,7 +63,6 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.29 1998/01/09 17:06:35 drochner Exp $
|
||||
struct device *booted_device;
|
||||
int booted_partition;
|
||||
struct bootdev_data *bootdev_data;
|
||||
char boot_dev[128];
|
||||
|
||||
void parse_prom_bootdev __P((void));
|
||||
int atoi __P((char *));
|
||||
@ -107,7 +106,7 @@ cpu_rootconf()
|
||||
|
||||
if (booted_device == NULL)
|
||||
printf("WARNING: can't figure what device matches \"%s\"\n",
|
||||
boot_dev);
|
||||
bootinfo.booted_dev);
|
||||
setroot(booted_device, booted_partition, alpha_nam2blk);
|
||||
}
|
||||
|
||||
@ -123,10 +122,10 @@ parse_prom_bootdev()
|
||||
booted_partition = 0;
|
||||
bootdev_data = NULL;
|
||||
|
||||
prom_getenv(PROM_E_BOOTED_DEV, boot_dev, sizeof(boot_dev));
|
||||
bcopy(boot_dev, hacked_boot_dev, sizeof hacked_boot_dev);
|
||||
bcopy(bootinfo.booted_dev, hacked_boot_dev,
|
||||
min(sizeof bootinfo.booted_dev, sizeof hacked_boot_dev));
|
||||
#if 0
|
||||
printf("parse_prom_bootdev: boot dev = \"%s\"\n", boot_dev);
|
||||
printf("parse_prom_bootdev: boot dev = \"%s\"\n", hacked_boot_dev);
|
||||
#endif
|
||||
|
||||
i = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: locore.s,v 1.38 1997/11/03 04:22:02 ross Exp $ */
|
||||
/* $NetBSD: locore.s,v 1.39 1998/02/12 01:53:19 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.38 1997/11/03 04:22:02 ross Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.39 1998/02/12 01:53:19 cgd Exp $");
|
||||
|
||||
#ifndef EVCNT_COUNTERS
|
||||
#include <machine/intrcnt.h>
|
||||
@ -102,7 +102,7 @@ Lstart1: LDGP(pv)
|
||||
/*
|
||||
* Call alpha_init() to do pre-main initialization.
|
||||
* alpha_init() gets the arguments we were called with,
|
||||
* which are already in a0, a1, a2, and a3.
|
||||
* which are already in a0, a1, a2, a3, and a4.
|
||||
*/
|
||||
CALL(alpha_init)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.101 1998/02/11 00:05:33 cgd Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.102 1998/02/12 01:53:21 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.101 1998/02/11 00:05:33 cgd Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.102 1998/02/12 01:53:21 cgd Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -174,11 +174,7 @@ u_int64_t cycles_per_usec;
|
||||
/* number of cpus in the box. really! */
|
||||
int ncpus;
|
||||
|
||||
char boot_flags[64];
|
||||
char booted_kernel[64];
|
||||
|
||||
int bootinfo_valid;
|
||||
struct bootinfo bootinfo;
|
||||
struct bootinfo_kernel bootinfo;
|
||||
|
||||
struct platform platform;
|
||||
|
||||
@ -205,11 +201,12 @@ void netintr __P((void));
|
||||
void printregs __P((struct reg *));
|
||||
|
||||
void
|
||||
alpha_init(pfn, ptb, bim, bip)
|
||||
alpha_init(pfn, ptb, bim, bip, biv)
|
||||
u_long pfn; /* first free PFN number */
|
||||
u_long ptb; /* PFN of current level 1 page table */
|
||||
u_long bim; /* bootinfo magic */
|
||||
u_long bip; /* bootinfo pointer */
|
||||
u_long biv; /* bootinfo version */
|
||||
{
|
||||
extern char kernel_text[], _end[];
|
||||
struct mddt *mddtp;
|
||||
@ -261,23 +258,46 @@ alpha_init(pfn, ptb, bim, bip)
|
||||
* Check for a bootinfo from the boot program.
|
||||
*/
|
||||
if (bim == BOOTINFO_MAGIC) {
|
||||
/*
|
||||
* Have boot info. Copy it to our own storage.
|
||||
* We'll sanity-check it later.
|
||||
*/
|
||||
bcopy((void *)bip, &bootinfo, sizeof(bootinfo));
|
||||
switch (bootinfo.version) {
|
||||
case 1:
|
||||
bootinfo_valid = 1;
|
||||
break;
|
||||
if (biv == 0) { /* backward compat */
|
||||
biv = *(u_long *)bip;
|
||||
bip += 8;
|
||||
}
|
||||
switch (biv) {
|
||||
case 1: {
|
||||
struct bootinfo_v1 *v1p = (struct bootinfo_v1 *)bip;
|
||||
|
||||
bootinfo.ssym = v1p->ssym;
|
||||
bootinfo.esym = v1p->esym;
|
||||
bcopy(v1p->boot_flags, bootinfo.boot_flags,
|
||||
min(sizeof v1p->boot_flags,
|
||||
sizeof bootinfo.boot_flags));
|
||||
bcopy(v1p->booted_kernel, bootinfo.booted_kernel,
|
||||
min(sizeof v1p->booted_kernel,
|
||||
sizeof bootinfo.booted_kernel));
|
||||
/* booted dev not provided by boot block */
|
||||
prom_getenv(PROM_E_BOOTED_DEV, bootinfo.booted_dev,
|
||||
sizeof bootinfo.booted_dev);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
printf("warning: unknown bootinfo version %d\n",
|
||||
bootinfo.version);
|
||||
biv);
|
||||
goto nobootinfo;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
printf("warning: boot program did not pass bootinfo\n");
|
||||
|
||||
nobootinfo:
|
||||
bootinfo.ssym = (u_long)_end;
|
||||
bootinfo.esym = (u_long)_end;
|
||||
prom_getenv(PROM_E_BOOTED_OSFLAGS, bootinfo.boot_flags,
|
||||
sizeof bootinfo.boot_flags);
|
||||
prom_getenv(PROM_E_BOOTED_FILE, bootinfo.booted_kernel,
|
||||
sizeof bootinfo.booted_kernel);
|
||||
prom_getenv(PROM_E_BOOTED_DEV, bootinfo.booted_dev,
|
||||
sizeof bootinfo.booted_dev);
|
||||
}
|
||||
|
||||
/*
|
||||
* Point interrupt/exception vectors to our own.
|
||||
*/
|
||||
@ -314,20 +334,12 @@ alpha_init(pfn, ptb, bim, bip)
|
||||
*/
|
||||
kernstart = trunc_page(kernel_text) - 2 * PAGE_SIZE;
|
||||
#ifdef DDB
|
||||
if (bootinfo_valid) {
|
||||
/*
|
||||
* Save the kernel symbol table.
|
||||
*/
|
||||
switch (bootinfo.version) {
|
||||
case 1:
|
||||
ksym_start = (void *)bootinfo.un.v1.ssym;
|
||||
ksym_end = (void *)bootinfo.un.v1.esym;
|
||||
break;
|
||||
}
|
||||
kernend = (vm_offset_t)round_page(ksym_end);
|
||||
} else
|
||||
ksym_start = (void *)bootinfo.ssym;
|
||||
ksym_end = (void *)bootinfo.esym;
|
||||
kernend = (vm_offset_t)round_page(ksym_end);
|
||||
#else
|
||||
kernend = (vm_offset_t)round_page(_end);
|
||||
#endif
|
||||
kernend = (vm_offset_t)round_page(_end);
|
||||
|
||||
/*
|
||||
* Find out how much memory is available, by looking at
|
||||
@ -546,33 +558,13 @@ alpha_init(pfn, ptb, bim, bip)
|
||||
|
||||
/*
|
||||
* Look at arguments passed to us and compute boothowto.
|
||||
* Also, get kernel name so it can be used in user-land.
|
||||
*/
|
||||
if (bootinfo_valid) {
|
||||
switch (bootinfo.version) {
|
||||
case 1:
|
||||
bcopy(bootinfo.un.v1.boot_flags, boot_flags,
|
||||
sizeof(boot_flags));
|
||||
bcopy(bootinfo.un.v1.booted_kernel, booted_kernel,
|
||||
sizeof(booted_kernel));
|
||||
}
|
||||
} else {
|
||||
prom_getenv(PROM_E_BOOTED_OSFLAGS, boot_flags,
|
||||
sizeof(boot_flags));
|
||||
prom_getenv(PROM_E_BOOTED_FILE, booted_kernel,
|
||||
sizeof(booted_kernel));
|
||||
}
|
||||
|
||||
#if 0
|
||||
printf("boot flags = \"%s\"\n", boot_flags);
|
||||
printf("booted kernel = \"%s\"\n", booted_kernel);
|
||||
#endif
|
||||
|
||||
boothowto = RB_SINGLE;
|
||||
#ifdef KADB
|
||||
boothowto |= RB_KDB;
|
||||
#endif
|
||||
for (p = boot_flags; p && *p != '\0'; p++) {
|
||||
for (p = bootinfo.boot_flags; p && *p != '\0'; p++) {
|
||||
/*
|
||||
* Note that we'd really like to differentiate case here,
|
||||
* but the Alpha AXP Architecture Reference Manual
|
||||
@ -1470,7 +1462,8 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
|
||||
&alpha_unaligned_sigbus));
|
||||
|
||||
case CPU_BOOTED_KERNEL:
|
||||
return (sysctl_rdstring(oldp, oldlenp, newp, booted_kernel));
|
||||
return (sysctl_rdstring(oldp, oldlenp, newp,
|
||||
bootinfo.booted_kernel));
|
||||
|
||||
default:
|
||||
return (EOPNOTSUPP);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: autoconf.h,v 1.11 1997/08/11 23:43:38 cgd Exp $ */
|
||||
/* $NetBSD: autoconf.h,v 1.12 1998/02/12 01:53:22 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
|
||||
@ -87,11 +87,15 @@ struct bootdev_data {
|
||||
*
|
||||
* a0 contains first free page frame number
|
||||
* a1 contains page number of current level 1 page table
|
||||
* if a2 contains BOOTINFO_MAGIC:
|
||||
* if a2 contains BOOTINFO_MAGIC and a4 is nonzero:
|
||||
* a3 contains pointer (BEVA) to bootinfo
|
||||
* a4 contains bootinfo version number
|
||||
* if a2 contains BOOTINFO_MAGIC and a4 contains 0 (backward compat):
|
||||
* a3 contains pointer (BEVA) to bootinfo version
|
||||
* (u_long), then the bootinfo
|
||||
*/
|
||||
|
||||
#define BOOTINFO_MAGIC 0xdeadbeeffeedface
|
||||
#define BOOTINFO_MAGIC 0xdeadbeeffeedface
|
||||
|
||||
struct bootinfo_v1 {
|
||||
u_long ssym; /* 0: start of kernel sym table */
|
||||
@ -103,18 +107,28 @@ struct bootinfo_v1 {
|
||||
int (*cngetc) __P((void)); /* 160: console getc pointer */
|
||||
void (*cnputc) __P((int)); /* 168: console putc pointer */
|
||||
void (*cnpollc) __P((int)); /* 176: console pollc pointer */
|
||||
/* 184: total size */
|
||||
u_long pad[9]; /* 184: rsvd for future use */
|
||||
/* 256: total size */
|
||||
};
|
||||
|
||||
struct bootinfo {
|
||||
u_long version; /* 0: version number */
|
||||
union { /* 8: union: */
|
||||
struct bootinfo_v1 v1; /* version 1 boot info */
|
||||
char pad[256]; /* space rsvd for future use */
|
||||
} un; /* */
|
||||
/* 264: total size */
|
||||
/*
|
||||
* Kernel-internal structure used to hold important bits of boot
|
||||
* information. NOT to be used by boot blocks.
|
||||
*
|
||||
* Note that not all of the fields from the bootinfo struct(s)
|
||||
* passed by the boot blocks aren't here (because they're not currently
|
||||
* used by the kernel!). Fields here which aren't supplied by the
|
||||
* bootinfo structure passed by the boot blocks are supposed to be
|
||||
* filled in at startup with sane contents.
|
||||
*/
|
||||
struct bootinfo_kernel {
|
||||
u_long ssym; /* start of syms */
|
||||
u_long esym; /* end of syms */
|
||||
char boot_flags[64]; /* boot flags */
|
||||
char booted_kernel[64]; /* name of booted kernel */
|
||||
char booted_dev[64]; /* name of booted device */
|
||||
};
|
||||
|
||||
|
||||
#ifdef EVCNT_COUNTERS
|
||||
extern struct evcnt clock_intr_evcnt;
|
||||
#endif
|
||||
@ -122,3 +136,4 @@ extern struct evcnt clock_intr_evcnt;
|
||||
extern struct device *booted_device;
|
||||
extern int booted_partition;
|
||||
extern struct bootdev_data *bootdev_data;
|
||||
extern struct bootinfo_kernel bootinfo;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cpu.h,v 1.18 1997/09/23 23:17:49 mjacob Exp $ */
|
||||
/* $NetBSD: cpu.h,v 1.19 1998/02/12 01:53:23 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
@ -144,7 +144,7 @@ void XentMM __P((u_int64_t, u_int64_t, u_int64_t)); /* MAGIC */
|
||||
void XentRestart __P((void)); /* MAGIC */
|
||||
void XentSys __P((u_int64_t, u_int64_t, u_int64_t)); /* MAGIC */
|
||||
void XentUna __P((u_int64_t, u_int64_t, u_int64_t)); /* MAGIC */
|
||||
void alpha_init __P((u_long, u_long, u_long, u_long));
|
||||
void alpha_init __P((u_long, u_long, u_long, u_long, u_long));
|
||||
void ast __P((struct trapframe *));
|
||||
int badaddr __P((void *, size_t));
|
||||
int badaddr_read __P((void *, size_t, void *));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: boot.c,v 1.7 1998/01/29 22:13:25 ross Exp $ */
|
||||
/* $NetBSD: boot.c,v 1.8 1998/02/12 01:53:24 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -47,6 +47,7 @@
|
||||
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/prom.h>
|
||||
#include <machine/rpb.h>
|
||||
|
||||
#include <machine/pte.h>
|
||||
|
||||
@ -57,7 +58,7 @@ int loadfile __P((char *, u_int64_t *));
|
||||
char boot_file[128];
|
||||
char boot_flags[128];
|
||||
|
||||
struct bootinfo bootinfo;
|
||||
struct bootinfo_v1 bootinfo_v1;
|
||||
|
||||
extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[];
|
||||
|
||||
@ -115,24 +116,23 @@ main()
|
||||
/*
|
||||
* Fill in the bootinfo for the kernel.
|
||||
*/
|
||||
bzero(&bootinfo, sizeof(bootinfo));
|
||||
bootinfo.version = 1;
|
||||
bootinfo.un.v1.ssym = ssym;
|
||||
bootinfo.un.v1.esym = esym;
|
||||
bcopy(name, bootinfo.un.v1.booted_kernel,
|
||||
sizeof(bootinfo.un.v1.booted_kernel));
|
||||
bcopy(boot_flags, bootinfo.un.v1.boot_flags,
|
||||
sizeof(bootinfo.un.v1.boot_flags));
|
||||
bootinfo.un.v1.hwrpb = NULL;
|
||||
bootinfo.un.v1.hwrpbsize = 0;
|
||||
bootinfo.un.v1.cngetc = NULL;
|
||||
bootinfo.un.v1.cnputc = NULL;
|
||||
bootinfo.un.v1.cnpollc = NULL;
|
||||
bzero(&bootinfo_v1, sizeof(bootinfo_v1));
|
||||
bootinfo_v1.ssym = ssym;
|
||||
bootinfo_v1.esym = esym;
|
||||
bcopy(name, bootinfo_v1.booted_kernel,
|
||||
sizeof(bootinfo_v1.booted_kernel));
|
||||
bcopy(boot_flags, bootinfo_v1.boot_flags,
|
||||
sizeof(bootinfo_v1.boot_flags));
|
||||
bootinfo_v1.hwrpb = (void *)HWRPB_ADDR;
|
||||
bootinfo_v1.hwrpbsize = ((struct rpb *)HWRPB_ADDR)->rpb_size;
|
||||
bootinfo_v1.cngetc = NULL;
|
||||
bootinfo_v1.cnputc = NULL;
|
||||
bootinfo_v1.cnpollc = NULL;
|
||||
|
||||
(void)printf("Entering %s at 0x%lx...\n", name, entry);
|
||||
alpha_pal_imb();
|
||||
(*(void (*)())entry)(ffp_save, ptbr_save,
|
||||
BOOTINFO_MAGIC, &bootinfo, 0);
|
||||
BOOTINFO_MAGIC, &bootinfo_v1, 1, 0);
|
||||
}
|
||||
|
||||
(void)printf("Boot failed! Halting...\n");
|
||||
|
Loading…
Reference in New Issue
Block a user