#define USER 040 /* user-mode flag added to type */
struct sysent sysent
[128];
* Called from the trap handler when a processor trap occurs.
trap(sp
, type
, code
, pc
, psl
)
register int *locr0
= ((int *)&psl
)-PS
;
if (USERMODE(locr0
[PS
])) {
printf("trap type %d, code = %x\n", type
, code
);
case PROTFLT
+ USER
: /* protection fault */
case PRIVINFLT
+ USER
: /* privileged instruction fault */
case RESADFLT
+ USER
: /* reserved addressing fault */
case RESOPFLT
+ USER
: /* resereved operand fault */
case RESCHED
+ USER
: /* Allow process switch */
* If the user SP is above the stack segment,
* grow the stack automatically.
case SEGFLT
+ USER
: /* segmentation exception */
if(grow((unsigned)locr0
[SP
]) || grow(code
))
case TABLEFLT
: /* allow page table faults in kernel mode */
case TABLEFLT
+ USER
: /* page table fault */
panic("page table fault");
case PAGEFLT
: /* allow page faults in kernel mode */
case PAGEFLT
+ USER
: /* page fault */
pagein(code
); /* bring in page containing virtual addr */
case BPTFLT
+ USER
: /* bpt instruction fault */
case TRCTRAP
+ USER
: /* trace trap */
locr0
[PS
] &= ~PSL_T
; /* turn off trace bit */
case XFCFLT
+ USER
: /* xfc instruction fault */
case COMPATFLT
+ USER
: /* compatibility mode fault */
if (p
->p_cursig
|| ISSIG(p
))
* Since we are u.u_procp, clock will normally just change
* our priority without moving us from one queue to another
* (since the running process is not on a queue.)
* If that happened after we setrq ourselves but before we
* swtch()'ed, we might not be on the queue indicated by
if (u
.u_prof
.pr_scale
&& (syst
-= u
.u_vm
.vm_stime
))
addupc((caddr_t
)locr0
[PC
], &u
.u_prof
, (int)-syst
);
* Called from the trap handler when a system call occurs
syscall(sp
, type
, code
, pc
, psl
)
register int *locr0
= ((int *)&psl
)-PS
;
register caddr_t params
; /* known to be r10 below */
register int i
; /* known to be r9 below */
register struct sysent
*callp
;
if (!USERMODE(locr0
[PS
]))
params
= (caddr_t
)locr0
[AP
] + NBPW
;
callp
= &sysent
[code
&0177];
if (i
= callp
->sy_narg
* sizeof (int)) {
asm("prober $3,r9,(r10)"); /* GROT */
asm("bnequ ok"); /* GROT */
u
.u_error
= EFAULT
; /* GROT */
asm("movc3 r9,(r10),_u+U_ARG"); /* GROT */
u
.u_dirp
= (caddr_t
)u
.u_arg
[0];
u
.u_r
.r_val2
= locr0
[R1
];
if (u
.u_error
== 0 && u
.u_eosys
== JUSTRETURN
)
if (u
.u_eosys
== RESTARTSYS
)
else if (u
.u_eosys
== SIMULATERTI
)
locr0
[PS
] |= PSL_C
; /* carry bit */
locr0
[R0
] = u
.u_r
.r_val1
;
locr0
[R1
] = u
.u_r
.r_val2
;
if (p
->p_cursig
|| ISSIG(p
))
* Since we are u.u_procp, clock will normally just change
* our priority without moving us from one queue to another
* (since the running process is not on a queue.)
* If that happened after we setrq ourselves but before we
* swtch()'ed, we might not be on the queue indicated by
if (u
.u_prof
.pr_scale
&& (syst
-= u
.u_vm
.vm_stime
))
addupc((caddr_t
)locr0
[PC
], &u
.u_prof
, (int)-syst
);
* nonexistent system call-- set fatal error code.