Merge from vendor branch OPENSSH:
[dragonfly.git] / test / sysperf / upcall.S
1         /*
2          * $DragonFly: src/test/sysperf/upcall.S,v 1.2 2003/11/21 08:32:45 dillon Exp $
3          */
4         .text
5         .globl  callused_wrapper
6
7 #define CRIT_COUNT      4       /* not a good idea to hardwire this XXX */
8 #define PENDING         8       /* not a good idea to hardwire this XXX */
9
10         /*
11          * On entry:    %eax contains function
12          *              %ecx contains data
13          *              Stack: [eax,ecx,eflags,oldip]
14          */
15 callused_wrapper:
16         pushl   %edx            /* save %edx (upcall pointer) */
17         pushl   %ecx            /* func(data) */
18         call    *%eax
19         addl    $4,%esp
20         popl    %edx            /* upcall pointer */
21         incl    PENDING(%edx)   /* set pending bit (prevents upcalls) */
22         subl    $32,CRIT_COUNT(%edx) /* cleanup critical section count */
23         pushl   %esp            /* sp pointing to os supplied frame */
24         pushl   $-1             /* upcid */
25         pushl   $2              /* FETCH next */
26         call    upc_control
27         popl    %eax
28         popl    %ecx
29         popl    %edx
30         popfl
31         ret
32