From 020d0208d7af30b0d0cf2785d73aaf7140be873d Mon Sep 17 00:00:00 2001 From: thorpej Date: Thu, 24 Jul 1997 23:52:10 +0000 Subject: [PATCH] - Two additional arguments to alpha_init(): bootinfo magic number, and pointer to boot program's bootinfo structure. If the bootinfo magic matches, save a copy of the bootinfo structure, and use it to determine booted kernel name, the boot flags, and the location of the kernel symbol table. If the magic number does not match, revert to the old method of finding this information (sans symbol table info). - Add some additonal DDB glue. --- sys/arch/alpha/alpha/machdep.c | 107 ++++++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 10 deletions(-) diff --git a/sys/arch/alpha/alpha/machdep.c b/sys/arch/alpha/alpha/machdep.c index 586503d7978a..1f09b2d9b379 100644 --- a/sys/arch/alpha/alpha/machdep.c +++ b/sys/arch/alpha/alpha/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.80 1997/06/12 15:46:19 mrg Exp $ */ +/* $NetBSD: machdep.c,v 1.81 1997/07/24 23:52:10 thorpej Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. @@ -30,7 +30,7 @@ #include /* Config options headers */ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.80 1997/06/12 15:46:19 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.81 1997/07/24 23:52:10 thorpej Exp $"); #include #include @@ -75,6 +75,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.80 1997/06/12 15:46:19 mrg Exp $"); #include +#include #include #include #include @@ -116,6 +117,14 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.80 1997/06/12 15:46:19 mrg Exp $"); #include #endif +#ifdef DDB +#include +#include +#include +#include +#include +#endif + #include "le_ioasic.h" /* for le_iomem creation */ vm_map_t buffer_map; @@ -173,6 +182,14 @@ int ncpus; char boot_flags[64]; char booted_kernel[64]; +int bootinfo_valid; +struct bootinfo bootinfo; + +#ifdef DDB +/* start and end of kernel symbol table */ +void *ksym_start, *ksym_end; +#endif + /* for cpu_sysctl() */ int alpha_unaligned_print = 1; /* warn about unaligned accesses */ int alpha_unaligned_fix = 1; /* fix up unaligned accesses */ @@ -186,9 +203,11 @@ void netintr __P((void)); void printregs __P((struct reg *)); void -alpha_init(pfn, ptb) +alpha_init(pfn, ptb, bim, bip) 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 */ { extern char _end[]; caddr_t start, v; @@ -224,6 +243,27 @@ alpha_init(pfn, ptb) */ init_prom_interface(); + /* + * 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; + + default: + printf("warning: bogus bootinfo version %d\n", + bootinfo.version); + } + } else + printf("warning: boot program did not pass bootinfo\n"); + /* * Point interrupt/exception vectors to our own. */ @@ -356,7 +396,25 @@ alpha_init(pfn, ptb) if (PAGE_SIZE != 8192) panic("page size %d != 8192?!", PAGE_SIZE); - v = (caddr_t)alpha_round_page(_end); + /* + * Find the first free page. + */ +#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; + } + v = (caddr_t)alpha_round_page(ksym_end); + } else +#endif + v = (caddr_t)alpha_round_page(_end); + /* * Init mapping for u page(s) for proc 0 */ @@ -524,7 +582,8 @@ unknown_cputype: */ proc0paddr->u_pcb.pcb_hw.apcb_ksp = (u_int64_t)proc0paddr + USPACE - sizeof(struct trapframe); - proc0.p_md.md_tf = (struct trapframe *)proc0paddr->u_pcb.pcb_hw.apcb_ksp; + proc0.p_md.md_tf = + (struct trapframe *)proc0paddr->u_pcb.pcb_hw.apcb_ksp; #ifdef NEW_PMAP pmap_activate(kernel_pmap, &proc0paddr->u_pcb.pcb_hw, 0); @@ -534,13 +593,23 @@ unknown_cputype: * Look at arguments passed to us and compute boothowto. * Also, get kernel name so it can be used in user-land. */ - prom_getenv(PROM_E_BOOTED_OSFLAGS, boot_flags, sizeof(boot_flags)); + 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); -#endif - prom_getenv(PROM_E_BOOTED_FILE, booted_kernel, - sizeof(booted_kernel)); -#if 0 printf("booted kernel = \"%s\"\n", booted_kernel); #endif @@ -567,6 +636,13 @@ unknown_cputype: break; #endif +#if defined(KGDB) || defined(DDB) + case 'd': /* break into the kernel debugger ASAP */ + case 'D': + boothowto |= RB_KDB; + break; +#endif + case 'h': /* always halt, never reboot */ case 'H': boothowto |= RB_HALT; @@ -615,6 +691,17 @@ consinit() (*cpu_fn_switch->cons_init)(); pmap_unmap_prom(); + +#ifdef DDB + db_machine_init(); + ddb_init(ksym_start, ksym_end); + if (boothowto & RB_KDB) + Debugger(); +#endif +#ifdef KGDB + if (boothowto & RB_KDB) + kgdb_connect(0); +#endif } void