make vfs & filesystems use failable copying
[minix3.git] / kernel / arch / i386 / usermapped_glo_ipc.S
blobcb3b55b344f9cf1e554518b8d4e47d84dde9522d
1 #include <minix/ipcconst.h>
2 #include <machine/asm.h>
4 /**========================================================================* */
5 /*                           IPC assembly routines                        * */
6 /**========================================================================* */
7 /* all message passing routines save ebx, but destroy eax and ecx. */
9 #define IPCFUNC(name,SETARGS,VEC,POSTTRAP)                       \
10 ENTRY(usermapped_ ## name ## _softint)                                  ;\
11         push    %ebp                                                    ;\
12         movl    %esp, %ebp                                              ;\
13         push    %ebx                                                    ;\
14         SETARGS                                                         ;\
15         int     $VEC    /* trap to the kernel */                        ;\
16         mov     %ebx, %ecx      /* save %ebx */                         ;\
17         POSTTRAP                                                        ;\
18         pop     %ebx                                                    ;\
19         pop     %ebp                                                    ;\
20         ret                                                             ;\
21 ENTRY(usermapped_ ## name ## _sysenter)                                 ;\
22         push    %ebp                                                    ;\
23         movl    %esp, %ebp                                              ;\
24         push    %ebp                                                    ;\
25         push    %edx                                                    ;\
26         push    %ebx                                                    ;\
27         push    %esi                                                    ;\
28         push    %edi                                                    ;\
29         movl    %esp, %esi      /* kernel uses %esi for restored %esp */;\
30         movl    $0f, %edx       /* kernel uses %edx for restored %eip */;\
31         movl    $VEC, %edi      /* %edi to distinguish ipc/kerncall */  ;\
32         /* !!! There is a dependency of proc_stacktrace()               ;\
33          * on this stack layout; it needs to find %ebp on it.           ;\
34          */                                                             ;\
35         SETARGS                 /* call-specific register setup */      ;\
36         sysenter                /* disappear into kernel */             ;\
37 0:                                                                      ;\
38         push    %edi            /* kernel has desired PSW in %edi */    ;\
39         popf                    /* set PSW kernel wants us to have */   ;\
40         mov     %ebx, %ecx      /* return w. state mangled; save %ebx */;\
41         pop     %edi                                                    ;\
42         pop     %esi                                                    ;\
43         pop     %ebx                                                    ;\
44         pop     %edx                                                    ;\
45         pop     %ebp                                                    ;\
46         POSTTRAP                                                        ;\
47         pop     %ebp                                                    ;\
48         ret                                                             ;\
49 ENTRY(usermapped_ ## name ## _syscall)                                  ;\
50         push    %ebp                                                    ;\
51         movl    %esp, %ebp                                              ;\
52         push    %ebp                                                    ;\
53         push    %edx                                                    ;\
54         push    %ebx                                                    ;\
55         push    %esi                                                    ;\
56         push    %edi                                                    ;\
57         movl    $VEC, %edi      /* %edi to distinguish ipc/kerncall */  ;\
58         /* !!! There is a dependency of proc_stacktrace()               ;\
59          * on this stack layout; it needs to find %ebp on it.           ;\
60          */                                                             ;\
61         SETARGS                 /* call-specific register setup */      ;\
62         movl    %ecx, %edx      /* %ecx is clobbered by SYSCALL */      ;\
63         syscall                 /* disappear into kernel */             ;\
64         push    %edi            /* kernel has desired PSW in %edi */    ;\
65         popf                    /* set PSW kernel wants us to have */   ;\
66         mov     %ebx, %ecx      /* return w. state mangled; save %ebx */;\
67         pop     %edi                                                    ;\
68         pop     %esi                                                    ;\
69         pop     %ebx                                                    ;\
70         pop     %edx                                                    ;\
71         pop     %ebp                                                    ;\
72         POSTTRAP                                                        ;\
73         pop     %ebp                                                    ;\
74         ret
76 #define IPCARGS(opcode)                                                 \
77         movl    8(%ebp), %eax   /* eax = dest-src */                    ;\
78         movl    12(%ebp), %ebx  /* ebx = message pointer */             ;\
79         movl    $opcode, %ecx                                           ;\
81 #define SENDA_ARGS              \
82         movl    12(%ebp), %eax  /* eax = count */                       ;\
83         movl    8(%ebp), %ebx   /* ebx = table */                       ;\
84         movl    $SENDA, %ecx                                            ;\
86 #define GETSTATUS                                                       \
87         push    %eax                                                    ;\
88         movl    16(%ebp), %eax      /* ecx = saved %ebx */              ;\
89         movl    %ecx,  (%eax)                                           ;\
90         pop     %eax
92 #define KERNARGS mov 8(%ebp), %eax
94 IPCFUNC(send,IPCARGS(SEND),IPCVEC_UM,)
95 IPCFUNC(receive,IPCARGS(RECEIVE),IPCVEC_UM,GETSTATUS)
96 IPCFUNC(sendrec,IPCARGS(SENDREC),IPCVEC_UM,)
97 IPCFUNC(sendnb,IPCARGS(SENDNB),IPCVEC_UM,)
98 IPCFUNC(notify,IPCARGS(NOTIFY),IPCVEC_UM,)
99 IPCFUNC(senda,SENDA_ARGS,IPCVEC_UM,)
100 IPCFUNC(do_kernel_call,KERNARGS,KERVEC_UM,)
102 .data
103 LABEL(usermapped_offset)
104 .space 4