solaris10-20040624
[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
21         .file "process.s"
22
23         .data
24
25         .text
26
27 /*
28  * struct savearea {
29  *      char    *topstack;
30  * }
31  */
32
33         .set    topstack,0
34
35 /*
36  * savecontext(f, area1, newsp)
37  *      int (*f)(); struct savearea *area1; char *newsp;
38  */
39
40 /* offsets, to make my life easier! */
41         .set    f,8
42         .set    area1,12
43         .set    newsp,16
44
45 .globl  _C_LABEL(PRE_Block)
46 .globl  _C_LABEL(savecontext)
47
48 ENTRY(savecontext)
49         pushl   %ebp                    /* New Frame! */
50         movl    %esp,%ebp
51         pusha                           /* Push all registers */
52         movl    $1,_C_LABEL(PRE_Block)  /* Pre-emption code */
53         movl    area1(%ebp),%eax        /* eax = base of savearea */
54         movl    %esp,(%eax)             /* area->topstack = esp */
55         movl    newsp(%ebp),%eax        /* get new sp into eax */
56         cmpl    $0,%eax
57         je      L1                      /* if new sp is 0 then dont change esp */
58         movl    %eax,%esp               /* go ahead.  make my day! */
59 L1:
60         jmp     *f(%ebp)                        /* ebx = &f */
61
62 /* Shouldn't be here....*/
63
64         call    _C_LABEL(abort)
65
66 /*
67  * returnto(area2)
68  *      struct savearea *area2;
69  */
70
71 /* stack offset */
72         .set    area2,8
73
74 .globl  _C_LABEL(returnto)
75
76 ENTRY(returnto)
77         pushl   %ebp
78         movl    %esp, %ebp              /* New frame, to get correct pointer */
79         movl    area2(%ebp),%eax        /* eax = area2 */
80         movl    (%eax),%esp             /* restore esp */
81         popa 
82         movl    $0,_C_LABEL(PRE_Block)          /* clear it up... */
83         popl    %ebp
84         ret
85
86 /* I see, said the blind man, as he picked up his hammer and saw! */
87         pushl   $1234
88         call    _C_LABEL(abort)