mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
inital OSX support for native port
This commit is contained in:
parent
2c744bc1e8
commit
35f9062e37
@ -21,14 +21,26 @@ BASELIBS += $(PROJBINDIR)/${PROJECT}.a
|
||||
|
||||
PROJBINDIR =$(CURDIR)/bin
|
||||
|
||||
# clumsy way to enable building native on osx:
|
||||
BUILDOSXNATIVE = 0
|
||||
ifeq ($(CPU),native)
|
||||
ifeq ($(shell uname -s),Darwin)
|
||||
BUILDOSXNATIVE = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
## make script for your project. Build RIOT-base here!
|
||||
all: $(PROJBINDIR)/$(PROJECT).a
|
||||
@echo "Building project $(PROJECT) for $(BOARD) w/ MCU $(MCU)."
|
||||
$(MAKE) -C $(RIOTBOARD)
|
||||
$(MAKE) -C $(RIOTBASE)
|
||||
ifeq ($(BUILDOSXNATIVE),1)
|
||||
@$(LINK) $(UNDEF) -o $(PROJBINDIR)/$(PROJECT).elf $(BASELIBS) $(LINKFLAGS) -Wl,-no_pie
|
||||
else
|
||||
@$(LINK) $(UNDEF) -o $(PROJBINDIR)/$(PROJECT).elf -Wl,--start-group $(BASELIBS) -lm -Wl,--end-group -Wl,-Map=$(PROJBINDIR)/$(PROJECT).map $(LINKFLAGS)
|
||||
@$(SIZE) $(PROJBINDIR)/$(PROJECT).elf
|
||||
@$(OBJCOPY) -O ihex $(PROJBINDIR)/$(PROJECT).elf $(PROJBINDIR)/$(PROJECT).hex
|
||||
endif
|
||||
|
||||
## your make rules
|
||||
## Only basic example - modify it for larger projects!!
|
||||
|
@ -20,6 +20,11 @@
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __MACH__
|
||||
#include <mach/clock.h>
|
||||
#include <mach/mach.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <signal.h>
|
||||
@ -204,9 +209,20 @@ unsigned long hwtimer_arch_now(void)
|
||||
|
||||
DEBUG("hwtimer_arch_now()\n");
|
||||
|
||||
#ifdef __MACH__
|
||||
clock_serv_t cclock;
|
||||
mach_timespec_t mts;
|
||||
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
|
||||
clock_get_time(cclock, &mts);
|
||||
mach_port_deallocate(mach_task_self(), cclock);
|
||||
t.tv_sec = mts.tv_sec;
|
||||
t.tv_nsec = mts.tv_nsec;
|
||||
#else
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &t) == -1) {
|
||||
err(1, "hwtimer_arch_now: clock_gettime");
|
||||
}
|
||||
#endif
|
||||
|
||||
native_hwtimer_now = ts2ticks(&t);
|
||||
|
||||
DEBUG("hwtimer_arch_now(): it is now %lis %lins\n", t.tv_sec, t.tv_nsec);
|
||||
|
@ -17,11 +17,19 @@
|
||||
#include <signal.h>
|
||||
|
||||
/* TODO: choose more sensibly? */
|
||||
#ifdef __MACH__
|
||||
#define KERNEL_CONF_STACKSIZE_DEFAULT (163840)
|
||||
#define KERNEL_CONF_STACKSIZE_IDLE (163840)
|
||||
#define NATIVE_ISR_STACKSIZE (163840)
|
||||
#define TRANSCEIVER_STACK_SIZE (163840)
|
||||
#define MINIMUM_STACK_SIZE (163840)
|
||||
#else
|
||||
#define KERNEL_CONF_STACKSIZE_DEFAULT (16384)
|
||||
#define KERNEL_CONF_STACKSIZE_IDLE (16384)
|
||||
#define NATIVE_ISR_STACKSIZE (16384)
|
||||
#define TRANSCEIVER_STACK_SIZE (16384)
|
||||
#define MINIMUM_STACK_SIZE (16384)
|
||||
#endif
|
||||
|
||||
/* for cc110x_ng */
|
||||
#define RX_BUF_SIZE (10)
|
||||
|
@ -19,7 +19,13 @@
|
||||
#ifndef _CPU_H
|
||||
#define _CPU_H
|
||||
|
||||
#ifdef __MACH__
|
||||
#define _XOPEN_SOURCE
|
||||
#endif
|
||||
#include <ucontext.h>
|
||||
#ifdef __MACH__
|
||||
#undef _XOPEN_SOURCE
|
||||
#endif
|
||||
|
||||
#include "kernel_intern.h"
|
||||
#include "sched.h"
|
||||
|
@ -48,6 +48,8 @@ struct int_handler_t {
|
||||
static struct int_handler_t native_irq_handlers[255];
|
||||
char sigalt_stk[SIGSTKSZ];
|
||||
|
||||
#define SIGMAX (255) // XXX: do this properly if possible
|
||||
|
||||
void print_thread_sigmask(ucontext_t *cp)
|
||||
{
|
||||
sigset_t *p = &cp->uc_sigmask;
|
||||
@ -55,7 +57,7 @@ void print_thread_sigmask(ucontext_t *cp)
|
||||
err(1, "print_thread_sigmask: sigemptyset");
|
||||
}
|
||||
|
||||
for (int i = 1; i<(SIGRTMAX); i++) {
|
||||
for (int i = 1; i<(SIGMAX); i++) {
|
||||
if (native_irq_handlers[i].func != NULL) {
|
||||
printf("%s: %s\n",
|
||||
strsignal(i),
|
||||
@ -98,7 +100,7 @@ void native_print_signals()
|
||||
err(1, "native_print_signals(): sigprocmask");
|
||||
}
|
||||
|
||||
for (int i = 1; i<(SIGRTMAX); i++) {
|
||||
for (int i = 1; i<(SIGMAX); i++) {
|
||||
if (native_irq_handlers[i].func != NULL || i == SIGUSR1) {
|
||||
printf("%s: %s\n",
|
||||
strsignal(i),
|
||||
@ -291,8 +293,13 @@ void native_isr_entry(int sig, siginfo_t *info, void *context)
|
||||
if (_native_in_syscall == 0) {
|
||||
_native_in_isr = 1;
|
||||
DEBUG("\n\n\t\treturn to _native_sig_leave_tramp\n\n");
|
||||
#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;
|
||||
#else
|
||||
_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 {
|
||||
|
@ -15,7 +15,13 @@
|
||||
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#ifdef __MACH__
|
||||
#define _XOPEN_SOURCE
|
||||
#endif
|
||||
#include <ucontext.h>
|
||||
#ifdef __MACH__
|
||||
#undef _XOPEN_SOURCE
|
||||
#endif
|
||||
#include <err.h>
|
||||
|
||||
#include "kernel_intern.h"
|
||||
|
@ -1,5 +1,27 @@
|
||||
.text
|
||||
|
||||
#ifdef __MACH__
|
||||
.globl __native_sig_leave_tramp
|
||||
__native_sig_leave_tramp:
|
||||
pushl %eax
|
||||
pushf
|
||||
pushl %ebp
|
||||
pushl %esp
|
||||
|
||||
movl %esp, %ebp
|
||||
subl $24, %esp
|
||||
movl $__native_isr_ctx, 4(%esp)
|
||||
movl $__native_cur_ctx, (%esp)
|
||||
call _swapcontext
|
||||
|
||||
addl $24, %esp
|
||||
popl %esp
|
||||
popl %ebp
|
||||
popf
|
||||
popl %eax
|
||||
|
||||
jmp *__native_saved_eip
|
||||
#else
|
||||
.extern $_native_saved_eip
|
||||
.extern $_native_isr_ctx
|
||||
.extern $_native_cur_ctx
|
||||
@ -27,3 +49,4 @@ _native_sig_leave_tramp:
|
||||
movl $0x0, _native_in_isr;
|
||||
|
||||
jmp *_native_saved_eip
|
||||
#endif
|
||||
|
@ -1,8 +1,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __MACH__
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include "malloc.h"
|
||||
#endif
|
||||
|
||||
#include "ringbuffer.h"
|
||||
|
||||
//#define DEBUG(...) printf (__VA_ARGS__)
|
||||
|
Loading…
Reference in New Issue
Block a user