1/* 2 * Copyright (c) 1994 William F. Jolitz. 3 * 386BSD Copyright Restrictions Apply. All Other Rights Reserved. 4 * 5 * $Id: addupc_i386.s,v 1.1 94/10/19 17:39:53 bill Exp $ 6 * 7 * addupc(int pc, struct uprof *up, int ticks): 8 * update profiling information for the user process. 9 * [XXX move back to machine indep kernel in C] 10 */ 11 12#include "asm.h" 13#include "assym.s" 14 15ENTRY(addupc) 16 pushl %ebp 17 movl %esp,%ebp 18 movl 12(%ebp),%edx /* up */ 19 movl 8(%ebp),%eax /* pc */ 20 21 subl PR_OFF(%edx),%eax /* pc -= up->pr_off */ 22 jl L1 /* if (pc < 0) return */ 23 24 shrl $1,%eax /* praddr = pc >> 1 */ 25 imull PR_SCALE(%edx),%eax /* praddr *= up->pr_scale */ 26 shrl $15,%eax /* praddr = praddr << 15 */ 27 andl $-2,%eax /* praddr &= ~1 */ 28 29 cmpl PR_SIZE(%edx),%eax /* if (praddr > up->pr_size) return */ 30 ja L1 31 32/* addl %eax,%eax /* praddr -> word offset */ 33 addl PR_BASE(%edx),%eax /* praddr += up-> pr_base */ 34 movl 16(%ebp),%ecx /* ticks */ 35 36 movl _curproc, %edx 37 movl $proffault, PMD_ONFAULT(%edx) 38 addw %cx, (%eax) /* storage location += ticks */ 39 movl $0, PMD_ONFAULT(%edx) 40L1: 41 leave 42 ret 43 44proffault: 45 /* if we get a fault, then kill profiling all together */ 46 movl $0, PMD_ONFAULT(%edx) /* squish the fault handler */ 47 movl 12(%ebp), %ecx 48 movl $0,PR_SCALE(%ecx) /* up->pr_scale = 0 */ 49 leave 50 ret 51