Move the kcopy() function from trap.c to machdep.c. Add a prototype.

This commit is contained in:
Benno Rice 2002-05-28 07:36:36 +00:00
parent 6af587dcab
commit 37d87c9ff8
5 changed files with 61 additions and 60 deletions

View File

@ -961,3 +961,33 @@ cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t sz)
pcpu->pc_current_asngen = 1;
}
/*
* kcopy(const void *src, void *dst, size_t len);
*
* Copy len bytes from src to dst, aborting if we encounter a fatal
* page fault.
*
* kcopy() _must_ save and restore the old fault handler since it is
* called by uiomove(), which may be in the path of servicing a non-fatal
* page fault.
*/
int
kcopy(const void *src, void *dst, size_t len)
{
struct thread *td;
faultbuf env, *oldfault;
int rv;
td = PCPU_GET(curthread);
oldfault = td->td_pcb->pcb_onfault;
if ((rv = setfault(env)) != 0) {
td->td_pcb->pcb_onfault = oldfault;
return rv;
}
memcpy(dst, src, len);
td->td_pcb->pcb_onfault = oldfault;
return (0);
}

View File

@ -570,36 +570,6 @@ setusr(u_int content)
:: "n"(USER_SR), "r"(content));
}
/*
* kcopy(const void *src, void *dst, size_t len);
*
* Copy len bytes from src to dst, aborting if we encounter a fatal
* page fault.
*
* kcopy() _must_ save and restore the old fault handler since it is
* called by uiomove(), which may be in the path of servicing a non-fatal
* page fault.
*/
int
kcopy(const void *src, void *dst, size_t len)
{
struct thread *td;
faultbuf env, *oldfault;
int rv;
td = PCPU_GET(curthread);
oldfault = td->td_pcb->pcb_onfault;
if ((rv = setfault(env)) != 0) {
td->td_pcb->pcb_onfault = oldfault;
return rv;
}
memcpy(dst, src, len);
td->td_pcb->pcb_onfault = oldfault;
return (0);
}
int
badaddr(void *addr, size_t size)
{

View File

@ -92,5 +92,6 @@ get_cyclecount(void)
void savectx(struct pcb *);
void fork_trampoline(void);
int kcopy(const void *, void *, size_t);
#endif /* _MACHINE_CPU_H_ */

View File

@ -961,3 +961,33 @@ cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t sz)
pcpu->pc_current_asngen = 1;
}
/*
* kcopy(const void *src, void *dst, size_t len);
*
* Copy len bytes from src to dst, aborting if we encounter a fatal
* page fault.
*
* kcopy() _must_ save and restore the old fault handler since it is
* called by uiomove(), which may be in the path of servicing a non-fatal
* page fault.
*/
int
kcopy(const void *src, void *dst, size_t len)
{
struct thread *td;
faultbuf env, *oldfault;
int rv;
td = PCPU_GET(curthread);
oldfault = td->td_pcb->pcb_onfault;
if ((rv = setfault(env)) != 0) {
td->td_pcb->pcb_onfault = oldfault;
return rv;
}
memcpy(dst, src, len);
td->td_pcb->pcb_onfault = oldfault;
return (0);
}

View File

@ -570,36 +570,6 @@ setusr(u_int content)
:: "n"(USER_SR), "r"(content));
}
/*
* kcopy(const void *src, void *dst, size_t len);
*
* Copy len bytes from src to dst, aborting if we encounter a fatal
* page fault.
*
* kcopy() _must_ save and restore the old fault handler since it is
* called by uiomove(), which may be in the path of servicing a non-fatal
* page fault.
*/
int
kcopy(const void *src, void *dst, size_t len)
{
struct thread *td;
faultbuf env, *oldfault;
int rv;
td = PCPU_GET(curthread);
oldfault = td->td_pcb->pcb_onfault;
if ((rv = setfault(env)) != 0) {
td->td_pcb->pcb_onfault = oldfault;
return rv;
}
memcpy(dst, src, len);
td->td_pcb->pcb_onfault = oldfault;
return (0);
}
int
badaddr(void *addr, size_t size)
{