aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/GNU-Linux-GCC/Makefile17
-rw-r--r--os/hal/platforms/Linux/hal_lld.c4
-rw-r--r--os/ports/GCC/SIMIA32/chcore.c11
-rw-r--r--os/ports/GCC/SIMIA32/chcore.h5
4 files changed, 28 insertions, 9 deletions
diff --git a/demos/GNU-Linux-GCC/Makefile b/demos/GNU-Linux-GCC/Makefile
index 9d38e2637..f32f3c760 100644
--- a/demos/GNU-Linux-GCC/Makefile
+++ b/demos/GNU-Linux-GCC/Makefile
@@ -92,7 +92,6 @@ OPT = -ggdb -O2 -fomit-frame-pointer
# End of user defines
##############################################################################################
-
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
DEFS = $(DDEFS) $(UDEFS)
@@ -100,9 +99,21 @@ ADEFS = $(DADEFS) $(UADEFS)
OBJS = $(ASRC:.s=.o) $(SRC:.c=.o)
LIBS = $(DLIBS) $(ULIBS)
-LDFLAGS = -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
ASFLAGS = -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
-CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm -Wa,-alms=$(<:.c=.lst) $(DEFS)
+CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm $(DEFS)
+
+ifeq ($(HOST_OSX),yes)
+ OSX_SDK = /Developer/SDKs/MacOSX10.5.sdk
+ OSX_ARCH = -mmacosx-version-min=10.3 -arch i386
+
+ CPFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH)
+ LDFLAGS = -Wl -Map=$(PROJECT).map,-syslibroot,$(OSX_SDK),$(LIBDIR)
+ LIBS += $(OSX_ARCH)
+else
+ # Linux, or other
+ CPFLAGS += -Wa,-alms=$(<:.c=.lst)
+ LDFLAGS += -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
+endif
# Generate dependency information
CPFLAGS += -MD -MP -MF .dep/$(@F).d
diff --git a/os/hal/platforms/Linux/hal_lld.c b/os/hal/platforms/Linux/hal_lld.c
index e6679d07a..e143dd5fb 100644
--- a/os/hal/platforms/Linux/hal_lld.c
+++ b/os/hal/platforms/Linux/hal_lld.c
@@ -59,7 +59,11 @@ static struct timeval tick = {0, 1000000 / CH_FREQUENCY};
*/
void hal_lld_init(void) {
+#if defined(__APPLE__)
+ puts("ChibiOS/RT simulator (OS X)\n");
+#else
puts("ChibiOS/RT simulator (Linux)\n");
+#endif
gettimeofday(&nextcnt, NULL);
timeradd(&nextcnt, &tick, &nextcnt);
}
diff --git a/os/ports/GCC/SIMIA32/chcore.c b/os/ports/GCC/SIMIA32/chcore.c
index 2cacd7b65..3b382b957 100644
--- a/os/ports/GCC/SIMIA32/chcore.c
+++ b/os/ports/GCC/SIMIA32/chcore.c
@@ -30,7 +30,7 @@
/**
* Performs a context switch between two threads.
* @param otp the thread to be switched out
- * @param ntp the thread to be switched in
+ * @param ntp the thread to be switched in
*/
__attribute__((used))
static void __dummy(Thread *otp, Thread *ntp) {
@@ -38,6 +38,9 @@ static void __dummy(Thread *otp, Thread *ntp) {
#if defined(WIN32)
asm volatile (".globl @port_switch@8 \n\t" \
"@port_switch@8:");
+#elif defined(__APPLE__)
+ asm volatile (".globl _port_switch \n\t" \
+ "_port_switch:");
#else
asm volatile (".globl port_switch \n\t" \
"port_switch:");
@@ -56,7 +59,7 @@ static void __dummy(Thread *otp, Thread *ntp) {
}
/**
- * Halts the system. In this implementation it just exits the simulation.
+ * Halts the system. In this implementation it just exits the simulation.
*/
__attribute__((fastcall))
void port_halt(void) {
@@ -65,11 +68,11 @@ void port_halt(void) {
}
/**
- * Threads return point, it just invokes @p chThdExit().
+ * Threads return point, it just invokes @p chThdExit().
*/
void threadexit(void) {
-#if defined(WIN32)
+#if defined(WIN32) || defined (__APPLE__)
asm volatile ("push %eax \n\t" \
"call _chThdExit");
#else
diff --git a/os/ports/GCC/SIMIA32/chcore.h b/os/ports/GCC/SIMIA32/chcore.h
index a65eb9640..dc73de91f 100644
--- a/os/ports/GCC/SIMIA32/chcore.h
+++ b/os/ports/GCC/SIMIA32/chcore.h
@@ -48,7 +48,7 @@ typedef struct {
} stkalign_t __attribute__((aligned(16)));
/**
- * Generic x86 register.
+ * Generic x86 register.
*/
typedef void *regx86;
@@ -92,6 +92,7 @@ struct context {
uint8_t *esp = (uint8_t *)workspace + wsize; \
APUSH(esp, 0); \
APUSH(esp, 0); \
+ APUSH(esp, 0); \
APUSH(esp, arg); \
APUSH(esp, threadexit); \
esp -= sizeof(struct intctx); \
@@ -142,7 +143,7 @@ struct context {
/**
* IRQ prologue code, inserted at the start of all IRQ handlers enabled to
- * invoke system APIs.
+ * invoke system APIs.
*/
#define PORT_IRQ_PROLOGUE()