f5b3bc4166d6e8a07590dc519efc87a2dbf3309b
[openafs.git] / src / lwp / process.i386.s
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /* Sun 386i... I hope this does the right thing!!!
11  * 
12  * Written by Derek Atkins <warlord@MIT.EDU>
13  * (debugging help by Chris Provenzano <proven@mit.edu>)
14  * 11/1991
15  *
16  * "ojala que es correcto!"
17  */
18
19 #include <lwp_elf.h>
20 #if defined(__linux__) && defined(__ELF__)
21         .section .note.GNU-stack,"",%progbits
22 #endif
23
24         .file "process.s"
25
26         .data
27
28         .text
29
30 /*
31  * struct savearea {
32  *      char    *topstack;
33  * }
34  */
35
36         .set    topstack,0
37
38 /*
39  * savecontext(f, area1, newsp)
40  *      int (*f)(); struct savearea *area1; char *newsp;
41  */
42
43 /* offsets, to make my life easier! */
44         .set    f,8
45         .set    area1,12
46         .set    newsp,16
47
48 .globl  _C_LABEL(PRE_Block)
49 .globl  _C_LABEL(savecontext)
50
51 ENTRY(savecontext)
52         pushl   %ebp                    /* New Frame! */
53         movl    %esp,%ebp
54         pusha                           /* Push all registers */
55         movl    $1,_C_LABEL(PRE_Block)  /* Pre-emption code */
56         movl    area1(%ebp),%eax        /* eax = base of savearea */
57         movl    %esp,(%eax)             /* area->topstack = esp */
58         movl    newsp(%ebp),%eax        /* get new sp into eax */
59         cmpl    $0,%eax
60         je      L1                      /* if new sp is 0 then dont change esp */
61         movl    %eax,%esp               /* go ahead.  make my day! */
62 L1:
63         jmp     *f(%ebp)                        /* ebx = &f */
64
65 /*
66  * returnto(area2)
67  *      struct savearea *area2;
68  */
69
70 /* stack offset */
71         .set    area2,8
72
73 .globl  _C_LABEL(returnto)
74
75 ENTRY(returnto)
76         pushl   %ebp
77         movl    %esp, %ebp              /* New frame, to get correct pointer */
78         movl    area2(%ebp),%eax        /* eax = area2 */
79         movl    (%eax),%esp             /* restore esp */
80         popa 
81         movl    $0,_C_LABEL(PRE_Block)          /* clear it up... */
82         popl    %ebp
83         ret
84