subr_syscall.c (72200) | subr_syscall.c (72276) |
---|---|
1/*- 2 * Copyright (C) 1994, David Greenman 3 * Copyright (c) 1990, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the University of Utah, and William Jolitz. 8 * --- 21 unchanged lines hidden (view full) --- 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 | 1/*- 2 * Copyright (C) 1994, David Greenman 3 * Copyright (c) 1990, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the University of Utah, and William Jolitz. 8 * --- 21 unchanged lines hidden (view full) --- 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 |
38 * $FreeBSD: head/sys/kern/subr_trap.c 72200 2001-02-09 06:11:45Z bmilekic $ | 38 * $FreeBSD: head/sys/kern/subr_trap.c 72276 2001-02-10 02:20:34Z jhb $ |
39 */ 40 41/* 42 * 386 Trap and System call handling 43 */ 44 45#include "opt_clock.h" 46#include "opt_cpu.h" --- 53 unchanged lines hidden (view full) --- 100#include <ddb/ddb.h> 101 102#include <sys/sysctl.h> 103 104int (*pmath_emulate) __P((struct trapframe *)); 105 106extern void trap __P((struct trapframe frame)); 107extern int trapwrite __P((unsigned addr)); | 39 */ 40 41/* 42 * 386 Trap and System call handling 43 */ 44 45#include "opt_clock.h" 46#include "opt_cpu.h" --- 53 unchanged lines hidden (view full) --- 100#include <ddb/ddb.h> 101 102#include <sys/sysctl.h> 103 104int (*pmath_emulate) __P((struct trapframe *)); 105 106extern void trap __P((struct trapframe frame)); 107extern int trapwrite __P((unsigned addr)); |
108extern void syscall2 __P((struct trapframe frame)); | 108extern void syscall __P((struct trapframe frame)); |
109extern void ast __P((struct trapframe frame)); 110 111static int trap_pfault __P((struct trapframe *, int, vm_offset_t)); 112static void trap_fatal __P((struct trapframe *, vm_offset_t)); 113void dblfault_handler __P((void)); 114 115extern inthand_t IDTVEC(syscall); 116 --- 90 unchanged lines hidden (view full) --- 207 * Charge system time if profiling. 208 */ 209 if (p->p_sflag & PS_PROFIL) { 210 mtx_unlock_spin(&sched_lock); 211 /* XXX - do we need Giant? */ 212 if (!mtx_owned(&Giant)) 213 mtx_lock(&Giant); 214 mtx_lock_spin(&sched_lock); | 109extern void ast __P((struct trapframe frame)); 110 111static int trap_pfault __P((struct trapframe *, int, vm_offset_t)); 112static void trap_fatal __P((struct trapframe *, vm_offset_t)); 113void dblfault_handler __P((void)); 114 115extern inthand_t IDTVEC(syscall); 116 --- 90 unchanged lines hidden (view full) --- 207 * Charge system time if profiling. 208 */ 209 if (p->p_sflag & PS_PROFIL) { 210 mtx_unlock_spin(&sched_lock); 211 /* XXX - do we need Giant? */ 212 if (!mtx_owned(&Giant)) 213 mtx_lock(&Giant); 214 mtx_lock_spin(&sched_lock); |
215 addupc_task(p, frame->tf_eip, | 215 addupc_task(p, TRAPF_PC(frame), |
216 (u_int)(p->p_sticks - oticks) * psratio); 217 } 218 curpriority = p->p_priority; 219 mtx_unlock_spin(&sched_lock); 220} 221 222/* 223 * Exception, fault, and trap interface to the FreeBSD kernel. --- 846 unchanged lines hidden (view full) --- 1070 1071 if (rv != KERN_SUCCESS) 1072 return 1; 1073 1074 return (0); 1075} 1076 1077/* | 216 (u_int)(p->p_sticks - oticks) * psratio); 217 } 218 curpriority = p->p_priority; 219 mtx_unlock_spin(&sched_lock); 220} 221 222/* 223 * Exception, fault, and trap interface to the FreeBSD kernel. --- 846 unchanged lines hidden (view full) --- 1070 1071 if (rv != KERN_SUCCESS) 1072 return 1; 1073 1074 return (0); 1075} 1076 1077/* |
1078 * syscall2 - MP aware system call request C handler | 1078 * syscall - MP aware system call request C handler |
1079 * 1080 * A system call is essentially treated as a trap except that the 1081 * MP lock is not held on entry or return. We are responsible for 1082 * obtaining the MP lock if necessary and for handling ASTs 1083 * (e.g. a task switch) prior to return. 1084 * 1085 * In general, only simple access and manipulation of curproc and 1086 * the current stack is allowed without having to hold MP lock. 1087 */ 1088void | 1079 * 1080 * A system call is essentially treated as a trap except that the 1081 * MP lock is not held on entry or return. We are responsible for 1082 * obtaining the MP lock if necessary and for handling ASTs 1083 * (e.g. a task switch) prior to return. 1084 * 1085 * In general, only simple access and manipulation of curproc and 1086 * the current stack is allowed without having to hold MP lock. 1087 */ 1088void |
1089syscall2(frame) | 1089syscall(frame) |
1090 struct trapframe frame; 1091{ 1092 caddr_t params; 1093 int i; 1094 struct sysent *callp; 1095 struct proc *p = curproc; 1096 u_quad_t sticks; 1097 int error; --- 175 unchanged lines hidden (view full) --- 1273 1274void 1275ast(frame) 1276 struct trapframe frame; 1277{ 1278 struct proc *p = CURPROC; 1279 u_quad_t sticks; 1280 | 1090 struct trapframe frame; 1091{ 1092 caddr_t params; 1093 int i; 1094 struct sysent *callp; 1095 struct proc *p = curproc; 1096 u_quad_t sticks; 1097 int error; --- 175 unchanged lines hidden (view full) --- 1273 1274void 1275ast(frame) 1276 struct trapframe frame; 1277{ 1278 struct proc *p = CURPROC; 1279 u_quad_t sticks; 1280 |
1281 KASSERT(TRAPF_USERMODE(&frame), ("ast in kernel mode")); 1282 1283 /* 1284 * We check for a pending AST here rather than in the assembly as 1285 * acquiring and releasing mutexes in assembly is not fun. 1286 */ |
|
1281 mtx_lock_spin(&sched_lock); | 1287 mtx_lock_spin(&sched_lock); |
1288 if (!(astpending() || resched_wanted())) { 1289 mtx_unlock_spin(&sched_lock); 1290 return; 1291 } 1292 |
|
1282 sticks = p->p_sticks; | 1293 sticks = p->p_sticks; |
1283 | 1294 |
1284 astoff(); | 1295 astoff(); |
1296 mtx_intr_enable(&sched_lock); |
|
1285 atomic_add_int(&cnt.v_soft, 1); 1286 if (p->p_sflag & PS_OWEUPC) { 1287 p->p_sflag &= ~PS_OWEUPC; 1288 mtx_unlock_spin(&sched_lock); 1289 mtx_lock(&Giant); 1290 mtx_lock_spin(&sched_lock); 1291 addupc_task(p, p->p_stats->p_prof.pr_addr, 1292 p->p_stats->p_prof.pr_ticks); --- 23 unchanged lines hidden --- | 1297 atomic_add_int(&cnt.v_soft, 1); 1298 if (p->p_sflag & PS_OWEUPC) { 1299 p->p_sflag &= ~PS_OWEUPC; 1300 mtx_unlock_spin(&sched_lock); 1301 mtx_lock(&Giant); 1302 mtx_lock_spin(&sched_lock); 1303 addupc_task(p, p->p_stats->p_prof.pr_addr, 1304 p->p_stats->p_prof.pr_ticks); --- 23 unchanged lines hidden --- |