* Get machine context. */
| 2890 | * Get machine context. |
| 2891 | */ |
| 2892 | int |
| 2893 | get_mcontext(struct thread *td, mcontext_t *mcp, int flags) |
| 2894 | { |
| 2895 | struct trapframe *tp; |
| 2896 | struct segment_descriptor *sdp; |
| 2897 | |
| 2898 | tp = td->td_frame; |
| 2899 | |
| 2900 | PROC_LOCK(curthread->td_proc); |
| 2901 | mcp->mc_onstack = sigonstack(tp->tf_esp); |
| 2902 | PROC_UNLOCK(curthread->td_proc); |
| 2903 | mcp->mc_gs = td->td_pcb->pcb_gs; |
| 2904 | mcp->mc_fs = tp->tf_fs; |
| 2905 | mcp->mc_es = tp->tf_es; |
| 2906 | mcp->mc_ds = tp->tf_ds; |
| 2907 | mcp->mc_edi = tp->tf_edi; |
| 2908 | mcp->mc_esi = tp->tf_esi; |
| 2909 | mcp->mc_ebp = tp->tf_ebp; |
| 2910 | mcp->mc_isp = tp->tf_isp; |
| 2911 | mcp->mc_eflags = tp->tf_eflags; |
| 2912 | if (flags & GET_MC_CLEAR_RET) { |
| 2913 | mcp->mc_eax = 0; |
| 2914 | mcp->mc_edx = 0; |
| 2915 | mcp->mc_eflags &= ~PSL_C; |
| 2916 | } else { |
| 2917 | mcp->mc_eax = tp->tf_eax; |
| 2918 | mcp->mc_edx = tp->tf_edx; |
| 2919 | } |
| 2920 | mcp->mc_ebx = tp->tf_ebx; |
| 2921 | mcp->mc_ecx = tp->tf_ecx; |
| 2922 | mcp->mc_eip = tp->tf_eip; |
| 2923 | mcp->mc_cs = tp->tf_cs; |
| 2924 | mcp->mc_esp = tp->tf_esp; |
| 2925 | mcp->mc_ss = tp->tf_ss; |
| 2926 | mcp->mc_len = sizeof(*mcp); |
| 2927 | get_fpcontext(td, mcp, NULL, 0); |
| 2928 | sdp = &td->td_pcb->pcb_fsd; |
| 2929 | mcp->mc_fsbase = sdp->sd_hibase << 24 | sdp->sd_lobase; |
| 2930 | sdp = &td->td_pcb->pcb_gsd; |
| 2931 | mcp->mc_gsbase = sdp->sd_hibase << 24 | sdp->sd_lobase; |
| 2932 | mcp->mc_flags = 0; |
| 2933 | mcp->mc_xfpustate = 0; |
| 2934 | mcp->mc_xfpustate_len = 0; |
| 2935 | bzero(mcp->mc_spare2, sizeof(mcp->mc_spare2)); |
| 2936 | return (0); |
| 2937 | } |
| 2938 | |
| 2939 | /* |
| 2940 | * Set machine context. |
nothing calls this directly
no test coverage detected