UbixOS  2.0
sys_call.S
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2002-2018 The UbixOS Project.
3  * All rights reserved.
4  *
5  * This was developed by Christopher W. Olsen for the UbixOS Project.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted
8  * provided that the following conditions are met:
9  *
10  * 1) Redistributions of source code must retain the above copyright notice, this list of
11  * conditions, the following disclaimer and the list of authors.
12  * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13  * conditions, the following disclaimer and the list of authors in the documentation and/or
14  * other materials provided with the distribution.
15  * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16  * endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 .globl _sys_call
30 .text
31 .code32
32 
33 _B4:
34 _B3:
35 nop
36 
37 _ast:
38 
39 _astRet:
40 
41 _sysCall_MrOlsen:
42 //MrOlsen 2018-01-14 push $0x2
43 //MrOlsen 2018-01-14 sub $0x4,%esp
44 pusha
45 push %ds
46 push %es
47 push %fs
48 push %gs
49 mov $0x10,%eax
50 mov %eax,%ds
51 mov %eax,%es
52 mov %eax,%fs
53 cld
54 push %esp
55 call sys_call
56 add $0x4,%esp
57 cmpb $0x13,0x38(%esp)
58 je _B4
59 testl $0x2000,0x3c(%esp) /* Test If VM */
60 jz _notVM
61 jmp _isVM
62 _notVM:
63 testb $0x3,0x38(%esp) /* See If We're In User CS (GDT Entry 5) */
64 jz _popFS
65 jmp _popFS /* TMP BECAUSE ABOVE ISN'T RIGHT */
66 cli
67 mov %fs:0x0,%eax
68 testl $0x10800,0x80(%eax) /* Document This */
69 je _popFS
70 sti
71 push %esp
72 call _ast
73 add $0x4,%esp
74 jmp _astRet
75 _isVM:
76 hlt
77 
78 _popFS:
79 pop %gs
80 pop %fs
81 pop %es
82 pop %ds
83 popa
84 //MrOlsen 2018-01-14 add $0x8,%esp
85 iret
86 
87 _sys_call:
88 push $0x0
89 push $0x80
90 pusha
91 push %ds
92 push %es
93 push %fs
94 push %gs
95 mov $0x10,%eax
96 mov %eax, %ds
97 mov %eax, %es
98 mov %eax, %fs
99 cld
100 push %esp
101 call sys_call
102 add $0x4,%esp /* Remove Stack Pointer From Stack */
103 pop %gs
104 pop %fs
105 pop %es
106 pop %ds
107 popa
108 add $0x8,%esp //Back Out Error Code & trap_no
109 iret