adding simulator support for OS X

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1645 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
liamstask 2010-02-20 19:55:00 +00:00
parent 0fc33d4753
commit a90a90ffcf
4 changed files with 28 additions and 9 deletions

View File

@ -92,7 +92,6 @@ OPT = -ggdb -O2 -fomit-frame-pointer
# End of user defines # End of user defines
############################################################################################## ##############################################################################################
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR)) INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
DEFS = $(DDEFS) $(UDEFS) DEFS = $(DDEFS) $(UDEFS)
@ -100,9 +99,21 @@ ADEFS = $(DADEFS) $(UADEFS)
OBJS = $(ASRC:.s=.o) $(SRC:.c=.o) OBJS = $(ASRC:.s=.o) $(SRC:.c=.o)
LIBS = $(DLIBS) $(ULIBS) LIBS = $(DLIBS) $(ULIBS)
LDFLAGS = -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
ASFLAGS = -Wa,-amhls=$(<:.s=.lst) $(ADEFS) 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 # Generate dependency information
CPFLAGS += -MD -MP -MF .dep/$(@F).d CPFLAGS += -MD -MP -MF .dep/$(@F).d

View File

@ -59,7 +59,11 @@ static struct timeval tick = {0, 1000000 / CH_FREQUENCY};
*/ */
void hal_lld_init(void) { void hal_lld_init(void) {
#if defined(__APPLE__)
puts("ChibiOS/RT simulator (OS X)\n");
#else
puts("ChibiOS/RT simulator (Linux)\n"); puts("ChibiOS/RT simulator (Linux)\n");
#endif
gettimeofday(&nextcnt, NULL); gettimeofday(&nextcnt, NULL);
timeradd(&nextcnt, &tick, &nextcnt); timeradd(&nextcnt, &tick, &nextcnt);
} }

View File

@ -38,6 +38,9 @@ static void __dummy(Thread *otp, Thread *ntp) {
#if defined(WIN32) #if defined(WIN32)
asm volatile (".globl @port_switch@8 \n\t" \ asm volatile (".globl @port_switch@8 \n\t" \
"@port_switch@8:"); "@port_switch@8:");
#elif defined(__APPLE__)
asm volatile (".globl _port_switch \n\t" \
"_port_switch:");
#else #else
asm volatile (".globl port_switch \n\t" \ asm volatile (".globl port_switch \n\t" \
"port_switch:"); "port_switch:");
@ -69,7 +72,7 @@ void port_halt(void) {
*/ */
void threadexit(void) { void threadexit(void) {
#if defined(WIN32) #if defined(WIN32) || defined (__APPLE__)
asm volatile ("push %eax \n\t" \ asm volatile ("push %eax \n\t" \
"call _chThdExit"); "call _chThdExit");
#else #else

View File

@ -92,6 +92,7 @@ struct context {
uint8_t *esp = (uint8_t *)workspace + wsize; \ uint8_t *esp = (uint8_t *)workspace + wsize; \
APUSH(esp, 0); \ APUSH(esp, 0); \
APUSH(esp, 0); \ APUSH(esp, 0); \
APUSH(esp, 0); \
APUSH(esp, arg); \ APUSH(esp, arg); \
APUSH(esp, threadexit); \ APUSH(esp, threadexit); \
esp -= sizeof(struct intctx); \ esp -= sizeof(struct intctx); \