prmachdep.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.8 */
#include <sys/sysmacros.h>
#include <sys/watchpoint.h>
#include <sys/archsystm.h>
#include <sys/simulate.h>
#include <vm/seg_kmem.h>
/*
* Force a thread into the kernel if it is not already there.
* This is a no-op on uniprocessors.
*/
/* ARGSUSED */
void
{
}
/*
* Return general registers.
*/
void
{
/*
* Can't copy since prgregset_t and gregset_t
* use different defines.
*/
}
}
/*
* Set general registers.
*/
void
{
/*
* setgregs will only allow the condition codes to be set.
*/
if (initial) { /* set initial values */
else
if (!fpu_exists)
}
}
#ifdef _SYSCALL32_IMPL
/*
* modify the lower 32bits of a uint64_t
*/
/*
* Convert prgregset32 to native prgregset.
*/
void
{
} else {
}
}
/*
* Return 32-bit general registers.
*/
/* conversion from 64-bit register to 32-bit register */
void
{
/*
* Can't copy since prgregset_t and gregset_t
* use different defines.
*/
}
}
#endif /* _SYSCALL32_IMPL */
/*
* Get the syscall return values for the lwp.
*/
int
{
return ((int)r->r_o0);
*rval1 = 0;
*rval2 = 0;
} else {
}
return (0);
}
/*
* Does the system support floating-point, either through hardware
* or by trapping and emulating floating-point machine instructions?
*/
int
prhasfp(void)
{
/*
* SunOS5.0 emulates floating-point if FP hardware is not present.
*/
return (1);
}
/*
* Get floating-point registers.
*/
void
{
/*
* This works only because prfpregset_t is intentionally
* constructed to be identical to fpregset_t, with additional
* space for the floating-point queue at the end.
*/
/*
* This is supposed to be a pointer to the floating point queue.
* We can't provide such a thing through the /proc interface.
*/
/*
* XXX: to be done: fetch the FP queue if it is non-empty.
*/
}
#ifdef _SYSCALL32_IMPL
void
{
/*
* This works only because prfpregset32_t is intentionally
* constructed to be identical to fpregset32_t, with additional
* space for the floating-point queue at the end.
*/
/*
* This is supposed to be a pointer to the floating point queue.
* We can't provide such a thing through the /proc interface.
*/
/*
* XXX: to be done: fetch the FP queue if it is non-empty.
*/
}
#endif /* _SYSCALL32_IMPL */
/*
* Set floating-point registers.
*/
void
{
/*
* XXX: to be done: store the FP queue if it is non-empty.
*/
/*
* We set fpu_en before calling setfpregs() in order to
* retain the semantics of this operation from older
* versions of the system. SunOS 5.4 and prior never
* queried fpu_en; they just set the registers. The
* proper operation if fpu_en is zero is to disable
* floating point in the target process, but this can
* only change after a proper end-of-life period for
* the old semantics.
*/
/*
* This works only because prfpregset_t is intentionally
* constructed to be identical to fpregset_t, with additional
* space for the floating-point queue at the end.
*/
}
#ifdef _SYSCALL32_IMPL
void
{
/*
* XXX: to be done: store the FP queue if it is non-empty.
*/
/*
* We set fpu_en before calling setfpregs() in order to
* retain the semantics of this operation from older
* versions of the system. SunOS 5.4 and prior never
* queried fpu_en; they just set the registers. The
* proper operation if fpu_en is zero is to disable
* floating point in the target process, but this can
* only change after a proper end-of-life period for
* the old semantics.
*/
/*
* This works only because prfpregset32_t is intentionally
* constructed to be identical to fpregset32_t, with additional
* space for the floating-point queue at the end.
*/
}
#endif /* _SYSCALL32_IMPL */
/*
* Does the system support extra register state?
* In a kernel that supports both an _LP64 and an _ILP32 data model,
* the answer depends on the data model of the process.
* An _LP64 process does not have extra registers.
*/
int
{
extern int xregs_exists;
if (p->p_model == DATAMODEL_LP64)
return (0);
else
return (xregs_exists);
}
/*
* Get the size of the extra registers.
*/
int
{
return (xregs_getsize(p));
}
/*
* Get extra registers.
*/
void
{
}
/*
* Set extra registers.
*/
void
{
}
/*
* Get the ancillary state registers.
*/
void
{
}
/*
* Set the ancillary state registers.
*/
void
{
}
/*
* Return the base (lower limit) of the process stack.
*/
prgetstackbase(proc_t *p)
{
return (p->p_usrstack - p->p_stksize);
}
/*
* Return the "addr" field for pr_addr in prpsinfo_t.
* This is a vestige of the past, so whatever we return is OK.
*/
prgetpsaddr(proc_t *p)
{
return ((caddr_t)p);
}
/*
* Arrange to single-step the lwp.
*/
void
{
if (watchstep)
else
}
/*
* Undo prstep().
*/
void
{
}
/*
* Return non-zero if a single-step is in effect.
*/
int
{
}
/*
* Set the PC to the specified virtual address.
*/
void
{
/*
* pc and npc must be word aligned on sparc.
* We silently make it so to avoid a watchdog reset.
*/
}
/*
* Map address "addr" in address space "as" into a kernel virtual address.
* The memory is guaranteed to be resident and locked down.
*/
{
/*
* XXX - Because of past mistakes, we have bits being returned
* by getpfnum that are actually the page type bits of the pte.
* When the object we are trying to map is a memory page with
* a page structure everything is ok and we can use the optimal
* method, ppmapin. Otherwise, we have to do something special.
*/
if (pf_is_memory(pfnum)) {
(caddr_t)-1);
}
}
/*
* Oh well, we didn't have a page struct for the object we were
* trying to map in; ppmapin doesn't handle devices, but allocating a
* heap address allows ppmapout to free virutal space when done.
*/
}
/*
* Unmap address "addr" in address space "as"; inverse of prmapin().
*/
/* ARGSUSED */
void
{
}
/*
* Prepare to single-step the lwp if requested.
* This is called by the lwp itself just before returning to user level.
*/
void
prdostep(void)
{
return;
if (p->p_model == DATAMODEL_ILP32) {
} else {
}
else {
}
} else {
/*
* Single-stepping on sparc is effected by setting nPC
* to an invalid address and expecting FLTBOUNDS to
* occur after the instruction at PC is executed.
* This is not the whole story, however; we must
* deal with branch-always instructions with the
* annul bit set as a special case here.
*
* fuword() returns -1 on error and we can't distinguish
* this from a legitimate instruction of all 1's.
* However 0xffffffff is not one of the branch-always
* instructions we are interested in. No problem.
*/
int32_t i;
instr = -1;
/*
* For ba,a and relatives, compute the
* new PC from the instruction.
*/
/*
* For ba,a %icc and ba,a %xcc, compute the
* new PC from the instruction.
*/
} else {
}
}
}
/*
* Wrap up single stepping of the lwp.
* This is called by the lwp itself just after it has taken
* the FLTBOUNDS trap. We fix up the PC and nPC to have their
* proper values after the step. We return 1 to indicate that
* this fault really is the one we are expecting, else 0.
*
* This is also called from syscall() and stop() to reset PC
* and nPC to their proper values for debugger visibility.
*/
int
prundostep(void)
{
int rc = 0;
if (p->p_model == DATAMODEL_ILP32) {
} else {
}
} else {
}
rc = 1;
} else {
}
}
return (rc);
}
/*
* Make sure the lwp is in an orderly state
* for inspection by a debugger through /proc.
* Called from stop() and from syslwp_create().
*/
/* ARGSUSED */
void
{
int watched;
/*
* Make sure we don't deadlock on a recursive call
* to prstop(). stop() tests the lwp_nostop flag.
*/
(void) flush_user_windows_to_stack(NULL);
(void) prundostep();
/*
* Attempt to fetch the last register window from the stack.
* If that fails, look for it in the pcb.
* If that fails, give up.
*/
int is64;
is64 = 0;
} else {
is64 = 1;
}
if (is64 &&
else if (!is64 &&
} else {
int i;
for (i = 0; i < mpcb->mpcb_wbcnt; i++) {
if (is64) {
(i * rw_size),
rw_size);
} else {
(struct rwindow32 *)
(i * rw_size));
}
break;
}
}
}
if (watched)
}
/*
* Make sure the floating point state is saved.
*/
if (p->p_model == DATAMODEL_ILP32)
else
else {
}
(void) save_syscall_args();
lwp->lwp_nostop = 0;
}
/*
* Fetch the user-level instruction on which the lwp is stopped.
* It was saved by the lwp itself, in prstop().
* Return non-zero if the instruction is valid.
*/
int
{
}
int
{
return (mpcb->mpcb_wbcnt);
}
void
{
}
#ifdef _SYSCALL32_IMPL
void
{
}
#endif /* _SYSCALL32_IMPL */
/*
* Called from trap() when a load or store instruction
* falls in a watched page but is not a watchpoint.
* We emulate the instruction in the kernel.
*/
int
{
int res;
int watched;
/* prevent recursive calls to pr_watch_emul() */
if (watched)
if (res == SIMU_SUCCESS) {
return (1);
}
return (0);
}