mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #539 from LudwigOrtmann/native_signal_patches
Native signal patches
This commit is contained in:
commit
ca53203f1f
@ -57,8 +57,6 @@ char __isr_stack[SIGSTKSZ];
|
||||
ucontext_t native_isr_context;
|
||||
ucontext_t *_native_cur_ctx, *_native_isr_ctx;
|
||||
|
||||
int *process_heap_address;
|
||||
|
||||
volatile unsigned int _native_saved_eip;
|
||||
volatile int _native_sigpend;
|
||||
int _sig_pipefd[2];
|
||||
@ -318,32 +316,20 @@ void native_isr_entry(int sig, siginfo_t *info, void *context)
|
||||
|
||||
if (_native_in_syscall == 0) {
|
||||
DEBUG("\n\n\t\treturn to _native_sig_leave_tramp\n\n");
|
||||
#ifdef __MACH__
|
||||
/* disable interrupts in context */
|
||||
isr_set_sigmask((ucontext_t *)context);
|
||||
_native_in_isr = 1;
|
||||
#ifdef __MACH__
|
||||
_native_saved_eip = ((ucontext_t *)context)->uc_mcontext->__ss.__eip;
|
||||
((ucontext_t *)context)->uc_mcontext->__ss.__eip = (unsigned int)&_native_sig_leave_tramp;
|
||||
#elif BSD
|
||||
_native_in_isr = 1;
|
||||
_native_saved_eip = ((struct sigcontext *)context)->sc_eip;
|
||||
((struct sigcontext *)context)->sc_eip = (unsigned int)&_native_sig_leave_tramp;
|
||||
#else
|
||||
if (
|
||||
((void*)(((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP]))
|
||||
> ((void*)process_heap_address)
|
||||
) {
|
||||
//printf("\n\033[36mEIP:\t%p\nHEAP:\t%p\nnot switching\n\n\033[0m", (void*)((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP], (void*)process_heap_address);
|
||||
}
|
||||
else {
|
||||
/* disable interrupts in context */
|
||||
isr_set_sigmask((ucontext_t *)context);
|
||||
_native_in_isr = 1;
|
||||
//printf("\n\033[31mEIP:\t%p\nHEAP:\t%p\ngo switching\n\n\033[0m", (void*)((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP], (void*)process_heap_address);
|
||||
_native_saved_eip = ((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP];
|
||||
((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP] = (unsigned int)&_native_sig_leave_tramp;
|
||||
}
|
||||
//printf("\n\033[31mEIP:\t%p\ngo switching\n\n\033[0m", (void*)((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP]);
|
||||
_native_saved_eip = ((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP];
|
||||
((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP] = (unsigned int)&_native_sig_leave_tramp;
|
||||
#endif
|
||||
// TODO: change sigmask?
|
||||
}
|
||||
else {
|
||||
DEBUG("\n\n\t\treturn to syscall\n\n");
|
||||
@ -446,12 +432,6 @@ void native_interrupt_init(void)
|
||||
struct sigaction sa;
|
||||
DEBUG("XXX: native_interrupt_init()\n");
|
||||
|
||||
process_heap_address = malloc(sizeof(int));
|
||||
if (process_heap_address == NULL) {
|
||||
err(EXIT_FAILURE, "native_interrupt_init: malloc");
|
||||
}
|
||||
free(process_heap_address);
|
||||
|
||||
VALGRIND_STACK_REGISTER(__isr_stack, __isr_stack + sizeof(__isr_stack));
|
||||
VALGRIND_DEBUG("VALGRIND_STACK_REGISTER(%p, %p)\n", __isr_stack, (void*)((int)__isr_stack + sizeof(__isr_stack)));
|
||||
|
||||
|
@ -3,8 +3,9 @@
|
||||
#ifdef __MACH__
|
||||
.globl __native_sig_leave_tramp
|
||||
__native_sig_leave_tramp:
|
||||
pushf
|
||||
pusha
|
||||
pushl __native_saved_eip
|
||||
pushfl
|
||||
pushal
|
||||
|
||||
pushl __native_isr_ctx
|
||||
pushl __native_cur_ctx
|
||||
@ -14,10 +15,11 @@ __native_sig_leave_tramp:
|
||||
call _eINT
|
||||
|
||||
movl $0x0, __native_in_isr
|
||||
popa
|
||||
popf
|
||||
popal
|
||||
popfl
|
||||
|
||||
jmp *__native_saved_eip
|
||||
popl __native_saved_eip
|
||||
jmp *-4(%esp)
|
||||
#else
|
||||
.extern $_native_saved_eip
|
||||
.extern $_native_isr_ctx
|
||||
@ -27,8 +29,9 @@ __native_sig_leave_tramp:
|
||||
.globl _native_sig_leave_tramp
|
||||
|
||||
_native_sig_leave_tramp:
|
||||
pushf
|
||||
pusha
|
||||
pushl _native_saved_eip
|
||||
pushfl
|
||||
pushal
|
||||
|
||||
pushl _native_isr_ctx
|
||||
pushl _native_cur_ctx
|
||||
@ -38,8 +41,9 @@ _native_sig_leave_tramp:
|
||||
call eINT
|
||||
|
||||
movl $0x0, _native_in_isr
|
||||
popa
|
||||
popf
|
||||
popal
|
||||
popfl
|
||||
|
||||
jmp *_native_saved_eip
|
||||
popl _native_saved_eip
|
||||
jmp *-4(%esp)
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user