0bf80c12c174e53247aeb39935be5fda29e94c8a
[tpg/acess2.git] / Usermode / Libraries / ld-acess.so_src / core.asm
1 ;
2 ; Acess2 System Interface
3 ;
4 %include "syscalls.inc.asm"
5
6 [BITS 32]
7 [section .data]
8 [global _errno:data (4)]
9 _errno:
10         dd      0
11
12 [section .text]
13 ; DEST
14 ; SRC
15 _memcpy:
16         push ebp
17         mov ebp, esp
18         push edi
19         push esi        ; DI and SI must be maintained, CX doesn't
20         
21         mov ecx, [ebp+16]
22         mov esi, [ebp+12]
23         mov edi, [ebp+8]
24         rep movsb
25         
26         pop esi
27         pop edi
28         pop ebp
29         ret
30
31 ; --- Process Control ---
32 SYSCALL1        _exit, SYS_EXIT
33
34 %if 0
35 SYSCALL2        clone, SYS_CLONE
36 %else
37 [global clone:func]
38 clone:
39         push ebp
40         mov ebp, esp
41         push ebx
42         
43         mov ebx, [ebp+12]       ; Get new stack pointer
44         
45         ; Check if the new stack is being used
46         test ebx, ebx
47         jz .doCall
48         ; Modify it to include the calling function (and this)
49         %if 0
50         mov eax, [ebp]  ; Get old stack frame
51         sub eax, ebp    ; Get size
52         sub ebx, eax    ; Alter new stack pointer
53         push eax        ; < Size
54         push DWORD [ebp]        ; < Source
55         push ebx        ; < Dest
56         call _memcpy
57         add esp, 4*3    ; Restore stack
58         ; EBX should still be the new stack pointer
59         mov eax, [ebp]  ; Save old stack frame pointer in new stack
60         mov [ebx-4], eax
61         mov eax, [ebp-4]        ; Save EBX there too
62         mov [ebx-8], eax
63         sub ebx, 8      ; Update stack pointer for system
64         %else
65         ; Quick hack, just this stack frame
66         mov eax, [ebp+4]
67         mov [ebx-4], eax        ; Return
68         mov [ebx-8], ebx        ; EBP
69         mov DWORD [ebx-12], 0   ; EBX
70         sub ebx, 12
71         %endif
72 .doCall:
73         mov eax, SYS_CLONE
74         mov ecx, ebx    ; Stack
75         mov ebx, [ebp+8]        ; Flags
76         SYSCALL_OP
77         mov [_errno], ebx
78         pop ebx
79         pop ebp
80         ret
81 %endif
82
83 SYSCALL2        kill, SYS_KILL
84 SYSCALL0        yield, SYS_YIELD
85 SYSCALL0        sleep, SYS_SLEEP
86 SYSCALL2        waittid, SYS_WAITTID
87
88 SYSCALL0        gettid, SYS_GETTID
89 SYSCALL0        getpid, SYS_GETPID
90 SYSCALL0        getuid, SYS_GETUID
91 SYSCALL0        getgid, SYS_GETGID
92
93 SYSCALL1        setuid, SYS_SETUID
94 SYSCALL1        setgid, SYS_SETGID
95
96 SYSCALL1        SysSetName, SYS_SETNAME
97 SYSCALL2        SysGetName, SYS_GETNAME
98
99 SYSCALL1        SysSetPri, SYS_SETPRI
100
101 SYSCALL3        SysSendMessage, SYS_SENDMSG
102 SYSCALL3        SysGetMessage, SYS_GETMSG
103
104 SYSCALL3        SysSpawn, SYS_SPAWN
105 SYSCALL3        execve, SYS_EXECVE
106 SYSCALL2        SysLoadBin, SYS_LOADBIN
107 SYSCALL1        SysUnloadBin, SYS_UNLOADBIN
108
109 SYSCALL1        _SysSetFaultHandler, SYS_SETFAULTHANDLER
110
111 SYSCALL6        _SysDebug, 0x100

UCC git Repository :: git.ucc.asn.au