machdep.c (208621) | machdep.c (208833) |
---|---|
1/*- 2 * Copyright (c) 2003 Peter Wemm. 3 * Copyright (c) 1992 Terrence R. Lambert. 4 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * William Jolitz. --- 25 unchanged lines hidden (view full) --- 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 39 */ 40 41#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2003 Peter Wemm. 3 * Copyright (c) 1992 Terrence R. Lambert. 4 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * William Jolitz. --- 25 unchanged lines hidden (view full) --- 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 39 */ 40 41#include <sys/cdefs.h> |
42__FBSDID("$FreeBSD: head/sys/amd64/amd64/machdep.c 208621 2010-05-28 17:50:24Z jhb $"); | 42__FBSDID("$FreeBSD: head/sys/amd64/amd64/machdep.c 208833 2010-06-05 15:59:59Z kib $"); |
43 44#include "opt_atalk.h" 45#include "opt_atpic.h" 46#include "opt_compat.h" 47#include "opt_cpu.h" 48#include "opt_ddb.h" 49#include "opt_inet.h" 50#include "opt_ipx.h" --- 1904 unchanged lines hidden (view full) --- 1955 bcopy(fpregs->fpr_xacc[i], sv_xmm->sv_xmm[i].xmm_bytes, 16); 1956} 1957 1958/* externalize from td->pcb */ 1959int 1960fill_fpregs(struct thread *td, struct fpreg *fpregs) 1961{ 1962 | 43 44#include "opt_atalk.h" 45#include "opt_atpic.h" 46#include "opt_compat.h" 47#include "opt_cpu.h" 48#include "opt_ddb.h" 49#include "opt_inet.h" 50#include "opt_ipx.h" --- 1904 unchanged lines hidden (view full) --- 1955 bcopy(fpregs->fpr_xacc[i], sv_xmm->sv_xmm[i].xmm_bytes, 16); 1956} 1957 1958/* externalize from td->pcb */ 1959int 1960fill_fpregs(struct thread *td, struct fpreg *fpregs) 1961{ 1962 |
1963 fill_fpregs_xmm(&td->td_pcb->pcb_save, fpregs); | 1963 fill_fpregs_xmm(&td->td_pcb->pcb_user_save, fpregs); |
1964 return (0); 1965} 1966 1967/* internalize to td->pcb */ 1968int 1969set_fpregs(struct thread *td, struct fpreg *fpregs) 1970{ 1971 | 1964 return (0); 1965} 1966 1967/* internalize to td->pcb */ 1968int 1969set_fpregs(struct thread *td, struct fpreg *fpregs) 1970{ 1971 |
1972 set_fpregs_xmm(fpregs, &td->td_pcb->pcb_save); | 1972 set_fpregs_xmm(fpregs, &td->td_pcb->pcb_user_save); |
1973 return (0); 1974} 1975 1976/* 1977 * Get machine context. 1978 */ 1979int 1980get_mcontext(struct thread *td, mcontext_t *mcp, int flags) --- 98 unchanged lines hidden (view full) --- 2079 td->td_pcb->pcb_full_iret = 1; 2080 return (0); 2081} 2082 2083static void 2084get_fpcontext(struct thread *td, mcontext_t *mcp) 2085{ 2086 | 1973 return (0); 1974} 1975 1976/* 1977 * Get machine context. 1978 */ 1979int 1980get_mcontext(struct thread *td, mcontext_t *mcp, int flags) --- 98 unchanged lines hidden (view full) --- 2079 td->td_pcb->pcb_full_iret = 1; 2080 return (0); 2081} 2082 2083static void 2084get_fpcontext(struct thread *td, mcontext_t *mcp) 2085{ 2086 |
2087 mcp->mc_ownedfp = fpugetregs(td, (struct savefpu *)&mcp->mc_fpstate); | 2087 mcp->mc_ownedfp = fpugetuserregs(td, 2088 (struct savefpu *)&mcp->mc_fpstate); |
2088 mcp->mc_fpformat = fpuformat(); 2089} 2090 2091static int 2092set_fpcontext(struct thread *td, const mcontext_t *mcp) 2093{ 2094 struct savefpu *fpstate; 2095 --- 8 unchanged lines hidden (view full) --- 2104 mcp->mc_ownedfp == _MC_FPOWNED_PCB) { 2105 /* 2106 * XXX we violate the dubious requirement that fpusetregs() 2107 * be called with interrupts disabled. 2108 * XXX obsolete on trap-16 systems? 2109 */ 2110 fpstate = (struct savefpu *)&mcp->mc_fpstate; 2111 fpstate->sv_env.en_mxcsr &= cpu_mxcsr_mask; | 2089 mcp->mc_fpformat = fpuformat(); 2090} 2091 2092static int 2093set_fpcontext(struct thread *td, const mcontext_t *mcp) 2094{ 2095 struct savefpu *fpstate; 2096 --- 8 unchanged lines hidden (view full) --- 2105 mcp->mc_ownedfp == _MC_FPOWNED_PCB) { 2106 /* 2107 * XXX we violate the dubious requirement that fpusetregs() 2108 * be called with interrupts disabled. 2109 * XXX obsolete on trap-16 systems? 2110 */ 2111 fpstate = (struct savefpu *)&mcp->mc_fpstate; 2112 fpstate->sv_env.en_mxcsr &= cpu_mxcsr_mask; |
2112 fpusetregs(td, fpstate); | 2113 fpusetuserregs(td, fpstate); |
2113 } else 2114 return (EINVAL); 2115 return (0); 2116} 2117 2118void 2119fpstate_drop(struct thread *td) 2120{ 2121 register_t s; 2122 | 2114 } else 2115 return (EINVAL); 2116 return (0); 2117} 2118 2119void 2120fpstate_drop(struct thread *td) 2121{ 2122 register_t s; 2123 |
2124 KASSERT(PCB_USER_FPU(td->td_pcb), ("fpstate_drop: kernel-owned fpu")); |
|
2123 s = intr_disable(); 2124 if (PCPU_GET(fpcurthread) == td) 2125 fpudrop(); 2126 /* 2127 * XXX force a full drop of the fpu. The above only drops it if we 2128 * owned it. 2129 * 2130 * XXX I don't much like fpugetregs()'s semantics of doing a full 2131 * drop. Dropping only to the pcb matches fnsave's behaviour. 2132 * We only need to drop to !PCB_INITDONE in sendsig(). But 2133 * sendsig() is the only caller of fpugetregs()... perhaps we just 2134 * have too many layers. 2135 */ | 2125 s = intr_disable(); 2126 if (PCPU_GET(fpcurthread) == td) 2127 fpudrop(); 2128 /* 2129 * XXX force a full drop of the fpu. The above only drops it if we 2130 * owned it. 2131 * 2132 * XXX I don't much like fpugetregs()'s semantics of doing a full 2133 * drop. Dropping only to the pcb matches fnsave's behaviour. 2134 * We only need to drop to !PCB_INITDONE in sendsig(). But 2135 * sendsig() is the only caller of fpugetregs()... perhaps we just 2136 * have too many layers. 2137 */ |
2136 curthread->td_pcb->pcb_flags &= ~PCB_FPUINITDONE; | 2138 curthread->td_pcb->pcb_flags &= ~(PCB_FPUINITDONE | 2139 PCB_USERFPUINITDONE); |
2137 intr_restore(s); 2138} 2139 2140int 2141fill_dbregs(struct thread *td, struct dbreg *dbregs) 2142{ 2143 struct pcb *pcb; 2144 --- 215 unchanged lines hidden --- | 2140 intr_restore(s); 2141} 2142 2143int 2144fill_dbregs(struct thread *td, struct dbreg *dbregs) 2145{ 2146 struct pcb *pcb; 2147 --- 215 unchanged lines hidden --- |