new FreeBSD
This commit is contained in:
parent
2494fc9fa0
commit
b4d5d19438
2 changed files with 45 additions and 59 deletions
|
|
@ -5,50 +5,51 @@ _tas:
|
||||||
xchgl %eax, 0(%ecx)
|
xchgl %eax, 0(%ecx)
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.globl setmcontext
|
.globl getcontext
|
||||||
setmcontext:
|
getcontext:
|
||||||
movl 4(%esp), %edx
|
movl 4(%esp), %eax
|
||||||
movl 8(%edx), %fs
|
addl $16, %eax /* point to mcontext */
|
||||||
movl 12(%edx), %es
|
|
||||||
movl 16(%edx), %ds
|
movl %fs, 8(%eax)
|
||||||
movl 76(%edx), %ss
|
movl %es, 12(%eax)
|
||||||
movl 20(%edx), %edi
|
movl %ds, 16(%eax)
|
||||||
movl 24(%edx), %esi
|
movl %ss, 76(%eax)
|
||||||
movl 28(%edx), %ebp
|
movl %edi, 20(%eax)
|
||||||
movl %esp, %ecx
|
movl %esi, 24(%eax)
|
||||||
movl 72(%edx), %esp
|
movl %ebp, 28(%eax)
|
||||||
pushl 60(%edx) /* eip */
|
movl %ebx, 36(%eax)
|
||||||
pushl 44(%edx) /* ecx */
|
movl %edx, 40(%eax)
|
||||||
pushl 48(%edx) /* eax */
|
movl %ecx, 44(%eax)
|
||||||
movl 36(%edx), %ebx
|
|
||||||
movl 40(%edx), %edx
|
movl $1, 48(%eax) /* %eax */
|
||||||
movl 12(%ecx), %eax
|
movl (%esp), %ecx /* %eip */
|
||||||
popl %eax
|
movl %ecx, 60(%eax)
|
||||||
popl %ecx
|
leal 4(%esp), %ecx /* %esp */
|
||||||
|
movl %ecx, 72(%eax)
|
||||||
|
|
||||||
|
movl 44(%eax), %ecx /* restore %ecx */
|
||||||
|
movl $0, %eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.globl getmcontext
|
.globl setcontext
|
||||||
getmcontext:
|
setcontext:
|
||||||
pushl %edx
|
movl 4(%esp), %eax
|
||||||
movl 8(%esp), %edx
|
addl $16, %eax /* point to mcontext */
|
||||||
movl %fs, 8(%edx)
|
|
||||||
movl %es, 12(%edx)
|
|
||||||
movl %ds, 16(%edx)
|
|
||||||
movl %ss, 76(%edx)
|
|
||||||
movl %edi, 20(%edx)
|
|
||||||
movl %esi, 24(%edx)
|
|
||||||
movl %ebp, 28(%edx)
|
|
||||||
movl %ebx, 36(%edx)
|
|
||||||
movl $1, 48(%edx)
|
|
||||||
popl %eax
|
|
||||||
movl %eax, 40(%edx)
|
|
||||||
movl %ecx, 44(%edx)
|
|
||||||
movl (%esp), %eax /* eip */
|
|
||||||
movl %eax, 60(%edx)
|
|
||||||
movl %esp, %eax
|
|
||||||
addl $4, %eax /* setmcontext will re-push the eip */
|
|
||||||
movl %eax, 72(%edx)
|
|
||||||
movl 40(%edx), %edx
|
|
||||||
xorl %eax, %eax
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
movl 8(%eax), %fs
|
||||||
|
movl 12(%eax), %es
|
||||||
|
movl 16(%eax), %ds
|
||||||
|
movl 76(%eax), %ss
|
||||||
|
movl 20(%eax), %edi
|
||||||
|
movl 24(%eax), %esi
|
||||||
|
movl 28(%eax), %ebp
|
||||||
|
movl 36(%eax), %ebx
|
||||||
|
movl 40(%eax), %edx
|
||||||
|
movl 72(%eax), %esp
|
||||||
|
|
||||||
|
movl 60(%eax), %ecx /* push new %eip */
|
||||||
|
pushl %ecx
|
||||||
|
|
||||||
|
movl 44(%eax), %ecx
|
||||||
|
movl 48(%eax), %eax
|
||||||
|
ret
|
||||||
|
|
|
||||||
|
|
@ -18,21 +18,6 @@ makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
|
||||||
ucp->uc_mcontext.mc_esp = (int)sp;
|
ucp->uc_mcontext.mc_esp = (int)sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int getmcontext(mcontext_t*);
|
|
||||||
extern int setmcontext(mcontext_t*);
|
|
||||||
|
|
||||||
int
|
|
||||||
getcontext(ucontext_t *uc)
|
|
||||||
{
|
|
||||||
return getmcontext(&uc->uc_mcontext);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setcontext(ucontext_t *uc)
|
|
||||||
{
|
|
||||||
setmcontext(&uc->uc_mcontext);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
swapcontext(ucontext_t *oucp, ucontext_t *ucp)
|
swapcontext(ucontext_t *oucp, ucontext_t *ucp)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue