1. Remove bootinfo and just pass loader metadata to the kernel.

2. Remove mcontext.mc_sp, it is redundant.  Adjust spare space to make
   ucontext_t a nice size.
3. Raise pil in the debugger.

Submitted by:	tmm (3)
This commit is contained in:
Jake Burkholder 2001-11-18 03:02:53 +00:00
parent 4d5e57d87d
commit 62d5557bb9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=86521
5 changed files with 62 additions and 76 deletions

View File

@ -1,53 +0,0 @@
/*-
* Copyright (C) 1994 by Rodney W. Grimes, Milwaukie, Oregon 97222
* 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 as
* the first lines of this file unmodified.
* 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 by Rodney W. Grimes.
* 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 RODNEY W. GRIMES ``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 RODNEY W. GRIMES 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.
*
* from: FreeBSD: src/sys/i386/include/bootinfo.h,v 1.14 1999/12/29
* $FreeBSD$
*/
#ifndef _MACHINE_BOOTINFO_H_
#define _MACHINE_BOOTINFO_H_
/*
* Increment the version number when you break binary compatibiity.
*/
#define BOOTINFO_VERSION 1
struct bootinfo {
u_int bi_version; /* Version number of this structure. */
u_int bi_howto; /* How to boot. */
u_long bi_end; /* End of kernel space. */
u_long bi_kpa; /* Physical address of start of kernel. */
u_long bi_metadata; /* Preload modules. */
u_long bi_envp; /* Kernel environment. */
};
#endif /* !_MACHINE_BOOTINFO_H_ */

View File

@ -36,11 +36,10 @@ typedef struct __mcontext {
long mc_global[8];
long mc_out[8];
long mc_onstack;
long mc_sp;
long mc_tpc;
long mc_tnpc;
long mc_tstate;
long mc_spare[11];
long mc_spare[2];
} mcontext_t;
#endif /* !_MACHINE_UCONTEXT_H_ */

View File

@ -37,18 +37,19 @@
.set kernbase,KERNBASE
/*
* void _start(struct bootinfo *bi, u_long ofw_vec)
* void _start(caddr_t metadata, u_long o1, u_long o2, u_long o3,
* u_long ofw_vec)
*/
ENTRY(_start)
wrpr %g0, PSTATE_IE | PSTATE_PRIV | PSTATE_PEF, %pstate
mov %o0, %g1
mov %o1, %g2
mov %o4, %g2
flushw
wrpr %g0, 1, %cwp
wrpr %g0, 0, %cleanwin
wrpr %g0, 0, %pil
set kstack0 + KSTACK_PAGES * PAGE_SIZE - PCB_SIZEOF, %o0
SET(kstack0 + KSTACK_PAGES * PAGE_SIZE - PCB_SIZEOF, %l0, %o0)
sub %o0, SPOFF + CCFSZ, %sp
mov %g1, %o0

View File

@ -37,18 +37,19 @@
.set kernbase,KERNBASE
/*
* void _start(struct bootinfo *bi, u_long ofw_vec)
* void _start(caddr_t metadata, u_long o1, u_long o2, u_long o3,
* u_long ofw_vec)
*/
ENTRY(_start)
wrpr %g0, PSTATE_IE | PSTATE_PRIV | PSTATE_PEF, %pstate
mov %o0, %g1
mov %o1, %g2
mov %o4, %g2
flushw
wrpr %g0, 1, %cwp
wrpr %g0, 0, %cleanwin
wrpr %g0, 0, %pil
set kstack0 + KSTACK_PAGES * PAGE_SIZE - PCB_SIZEOF, %o0
SET(kstack0 + KSTACK_PAGES * PAGE_SIZE - PCB_SIZEOF, %l0, %o0)
sub %o0, SPOFF + CCFSZ, %sp
mov %g1, %o0

View File

@ -81,7 +81,7 @@
#include <ddb/ddb.h>
#include <machine/bootinfo.h>
#include <machine/cache.h>
#include <machine/clock.h>
#include <machine/cpu.h>
#include <machine/fp.h>
@ -96,6 +96,12 @@
#include <machine/tstate.h>
#include <machine/ver.h>
#define MD_FETCH(mdp, info, type) ({ \
type *__p; \
__p = (type *)preload_search_info((mdp), MODINFO_METADATA | (info)); \
__p ? *__p : 0; \
})
typedef int ofw_vec_t(void *);
extern char tl0_base[];
@ -132,7 +138,7 @@ u_long ofw_tba;
static struct timecounter tick_tc;
static timecounter_get_t tick_get_timecount;
void sparc64_init(struct bootinfo *bi, ofw_vec_t *vec);
void sparc64_init(caddr_t mdp, ofw_vec_t *vec);
void sparc64_shutdown_final(void *dummy, int howto);
static void cpu_startup(void *);
@ -164,6 +170,7 @@ cpu_startup(void *arg)
tc_init(&tick_tc);
cpu_identify(clock);
cache_init(child);
vm_ksubmap_init(&kmi);
@ -186,31 +193,61 @@ tick_get_timecount(struct timecounter *tc)
}
void
sparc64_init(struct bootinfo *bi, ofw_vec_t *vec)
sparc64_init(caddr_t mdp, ofw_vec_t *vec)
{
vm_offset_t end;
vm_offset_t off;
caddr_t kmdp;
u_long ps;
end = 0;
kmdp = NULL;
/*
* Initialize openfirmware (needed for console).
*/
OF_init(vec);
cninit();
/*
* Parse metadata if present and fetch parameters. Must be before the
* console is inited so cninit gets the right value of boothowto.
*/
if (mdp != NULL) {
preload_metadata = mdp;
kmdp = preload_search_by_type("elf kernel");
if (kmdp != NULL) {
boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int);
kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);
end = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t);
}
}
/*
* Initialize the console before printing anything.
*/
cninit();
printf("sparc64_init: mdp=%p kmdp=%p boothowto=%d envp=%p end=%#lx\n",
mdp, kmdp, boothowto, kern_envp, end);
/*
* Check that the bootinfo struct is sane.
* Panic is there is no metadata. Most likely the kernel was booted
* directly, instead of through loader(8).
*/
if (bi->bi_version != BOOTINFO_VERSION)
panic("sparc64_init: bootinfo version mismatch");
if (bi->bi_metadata == 0)
panic("sparc64_init: no loader metadata");
boothowto = bi->bi_howto;
kern_envp = (char *)bi->bi_envp;
preload_metadata = (caddr_t)bi->bi_metadata;
if (mdp == NULL || kmdp == NULL) {
printf("sparc64_init: no loader metadata.\n"
"This probably means you are not using loader(8).\n");
panic("sparc64_init");
}
/*
* Sanity check the kernel end, which is important.
*/
if (end == 0) {
printf("sparc64_init: warning, kernel end not specified.\n"
"Attempting to continue anyway.\n");
end = (vm_offset_t)_end;
}
/*
* Initialize tunables.
@ -224,7 +261,7 @@ sparc64_init(struct bootinfo *bi, ofw_vec_t *vec)
/*
* Initialize virtual memory.
*/
pmap_bootstrap(bi->bi_end);
pmap_bootstrap(end);
/*
* Disable tick for now.
@ -341,7 +378,6 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
bcopy(tf->tf_global, sf.sf_uc.uc_mcontext.mc_global,
sizeof (tf->tf_global));
bcopy(tf->tf_out, sf.sf_uc.uc_mcontext.mc_out, sizeof (tf->tf_out));
sf.sf_uc.uc_mcontext.mc_sp = tf->tf_sp;
sf.sf_uc.uc_mcontext.mc_tpc = tf->tf_tpc;
sf.sf_uc.uc_mcontext.mc_tnpc = tf->tf_tnpc;
sf.sf_uc.uc_mcontext.mc_tstate = tf->tf_tstate;
@ -463,7 +499,6 @@ sigreturn(struct thread *td, struct sigreturn_args *uap)
bcopy(uc.uc_mcontext.mc_global, tf->tf_global,
sizeof(tf->tf_global));
bcopy(uc.uc_mcontext.mc_out, tf->tf_out, sizeof(tf->tf_out));
tf->tf_sp = uc.uc_mcontext.mc_sp;
tf->tf_tpc = uc.uc_mcontext.mc_tpc;
tf->tf_tnpc = uc.uc_mcontext.mc_tnpc;
tf->tf_tstate = uc.uc_mcontext.mc_tstate;
@ -593,9 +628,12 @@ setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings)
void
Debugger(const char *msg)
{
critical_t c;
printf("Debugger(\"%s\")\n", msg);
c = critical_enter();
breakpoint();
critical_exit(c);
}
int