X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Fld-acess.so_src%2Fcore.asm;fp=Usermode%2FLibraries%2Fld-acess.so_src%2Fcore.asm;h=0bf80c12c174e53247aeb39935be5fda29e94c8a;hb=270e5fe88b0666021a7a6393334db7feeb8245f8;hp=c44dc5358d77c72ef50242f3921388a4e7ba2be6;hpb=8c50e4a0672bdf9e9f6266fa5f485ad7f8b74f5b;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/ld-acess.so_src/core.asm b/Usermode/Libraries/ld-acess.so_src/core.asm index c44dc535..0bf80c12 100644 --- a/Usermode/Libraries/ld-acess.so_src/core.asm +++ b/Usermode/Libraries/ld-acess.so_src/core.asm @@ -10,9 +10,76 @@ _errno: dd 0 [section .text] -; --- Process Controll --- +; DEST +; SRC +_memcpy: + push ebp + mov ebp, esp + push edi + push esi ; DI and SI must be maintained, CX doesn't + + mov ecx, [ebp+16] + mov esi, [ebp+12] + mov edi, [ebp+8] + rep movsb + + pop esi + pop edi + pop ebp + ret + +; --- Process Control --- SYSCALL1 _exit, SYS_EXIT + +%if 0 SYSCALL2 clone, SYS_CLONE +%else +[global clone:func] +clone: + push ebp + mov ebp, esp + push ebx + + mov ebx, [ebp+12] ; Get new stack pointer + + ; Check if the new stack is being used + test ebx, ebx + jz .doCall + ; Modify it to include the calling function (and this) + %if 0 + mov eax, [ebp] ; Get old stack frame + sub eax, ebp ; Get size + sub ebx, eax ; Alter new stack pointer + push eax ; < Size + push DWORD [ebp] ; < Source + push ebx ; < Dest + call _memcpy + add esp, 4*3 ; Restore stack + ; EBX should still be the new stack pointer + mov eax, [ebp] ; Save old stack frame pointer in new stack + mov [ebx-4], eax + mov eax, [ebp-4] ; Save EBX there too + mov [ebx-8], eax + sub ebx, 8 ; Update stack pointer for system + %else + ; Quick hack, just this stack frame + mov eax, [ebp+4] + mov [ebx-4], eax ; Return + mov [ebx-8], ebx ; EBP + mov DWORD [ebx-12], 0 ; EBX + sub ebx, 12 + %endif +.doCall: + mov eax, SYS_CLONE + mov ecx, ebx ; Stack + mov ebx, [ebp+8] ; Flags + SYSCALL_OP + mov [_errno], ebx + pop ebx + pop ebp + ret +%endif + SYSCALL2 kill, SYS_KILL SYSCALL0 yield, SYS_YIELD SYSCALL0 sleep, SYS_SLEEP