summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-06-17 21:15:31 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-06-17 21:15:31 +0000
commit5a0722f9d657233ed85bdcf75a9a14ea321a1a28 (patch)
tree3ce9d8153ebbd5259472394eca8ef369cfcfd455
parentd8ee4cfaf8afacfe8ff455900ed391af4f642888 (diff)
downloadpx4-nuttx-5a0722f9d657233ed85bdcf75a9a14ea321a1a28.tar.gz
px4-nuttx-5a0722f9d657233ed85bdcf75a9a14ea321a1a28.tar.bz2
px4-nuttx-5a0722f9d657233ed85bdcf75a9a14ea321a1a28.zip
Straighten out conditional compilation
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1896 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/arch/arm/include/arch.h37
-rw-r--r--nuttx/binfmt/binfmt_dumpmodule.c2
-rw-r--r--nuttx/binfmt/binfmt_execmodule.c5
-rw-r--r--nuttx/binfmt/binfmt_globals.c9
-rw-r--r--nuttx/binfmt/binfmt_loadmodule.c3
-rw-r--r--nuttx/binfmt/binfmt_register.c3
-rw-r--r--nuttx/binfmt/binfmt_unloadmodule.c4
-rw-r--r--nuttx/binfmt/binfmt_unregister.c3
-rw-r--r--nuttx/binfmt/nxflat.c4
-rw-r--r--nuttx/include/nuttx/arch.h17
-rw-r--r--nuttx/include/nuttx/sched.h2
-rw-r--r--nuttx/sched/sched_releasetcb.c2
-rw-r--r--nuttx/sched/wd_internal.h2
-rw-r--r--nuttx/sched/wd_start.c4
-rw-r--r--nuttx/tools/mkconfig.c13
15 files changed, 93 insertions, 17 deletions
diff --git a/nuttx/arch/arm/include/arch.h b/nuttx/arch/arm/include/arch.h
index d97353ba1..88c0706db 100644
--- a/nuttx/arch/arm/include/arch.h
+++ b/nuttx/arch/arm/include/arch.h
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/include/arch.h
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -48,6 +48,41 @@
* Definitions
****************************************************************************/
+/* This identifies the register the is used by the processor as the PIC base
+ * register. It is usually r9 or r10
+ */
+
+#define PIC_REG r10
+#define PIC_REG_STRING "r10"
+
+/* Macros to get and set the PIC base register. picbase is assumed to be
+ * of type (void*) and that it will fit into a uint32. These must be
+ * inline so that they will be compatible with the ABIs rules for
+ * preserving the PIC register
+ */
+
+#define up_getpicbase(ppicbase) \
+do { \
+ uint32 picbase; \
+ __asm__ \
+ ( \
+ "\tmov %0, " PIC_REG_STRING "\n\t" \
+ : "=r"(picbase) \
+ ); \
+ *ppicbase = (FAR void*)picbase; \
+} while (0)
+
+#define up_setpicbase(picbase) \
+do { \
+ uint32 _picbase = (uint32)picbase; \
+ __asm__ \
+ ( \
+ "\tmov " PIC_REG_STRING ", %0\n\t" \
+ : : "r"(_picbase) : PIC_REG_STRING \
+ ); \
+} while (0)
+
+
/****************************************************************************
* Inline functions
****************************************************************************/
diff --git a/nuttx/binfmt/binfmt_dumpmodule.c b/nuttx/binfmt/binfmt_dumpmodule.c
index 190889d64..ee8913066 100644
--- a/nuttx/binfmt/binfmt_dumpmodule.c
+++ b/nuttx/binfmt/binfmt_dumpmodule.c
@@ -48,7 +48,7 @@
#include "binfmt_internal.h"
-#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_BINFMT)
+#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_BINFMT) && !defined(CONFIG_BINFMT_DISABLE)
/****************************************************************************
* Pre-processor Definitions
diff --git a/nuttx/binfmt/binfmt_execmodule.c b/nuttx/binfmt/binfmt_execmodule.c
index 21c1bf6ac..de65c15cf 100644
--- a/nuttx/binfmt/binfmt_execmodule.c
+++ b/nuttx/binfmt/binfmt_execmodule.c
@@ -51,6 +51,8 @@
#include "os_internal.h"
#include "binfmt_internal.h"
+#ifndef CONFIG_BINFMT_DISABLE
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -142,11 +144,13 @@ int exec_module(FAR const struct binary_s *bin, int priority)
/* Add the DSpace address as the PIC base address */
+#ifdef CONFIG_PIC
tcb->picbase = bin->dspace;
/* Re-initialize the task's initial state to account for the new PIC base */
up_initial_state(tcb);
+#endif
/* Get the assigned pid before we start the task */
@@ -181,4 +185,5 @@ errout:
return ERROR;
}
+#endif /* CONFIG_BINFMT_DISABLE */
diff --git a/nuttx/binfmt/binfmt_globals.c b/nuttx/binfmt/binfmt_globals.c
index 535160cff..b6985840d 100644
--- a/nuttx/binfmt/binfmt_globals.c
+++ b/nuttx/binfmt/binfmt_globals.c
@@ -42,6 +42,8 @@
#include <nuttx/binfmt.h>
+#ifndef CONFIG_BINFMT_DISABLE
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -61,7 +63,10 @@ FAR struct binfmt_s *g_binfmts;
* Private Functions
****************************************************************************/
-/***********************************************************************
+/****************************************************************************
* Public Functions
- ***********************************************************************/
+ ****************************************************************************/
+
+#endif /* CONFIG_BINFMT_DISABLE */
+
diff --git a/nuttx/binfmt/binfmt_loadmodule.c b/nuttx/binfmt/binfmt_loadmodule.c
index b73b6223e..7ab613c02 100644
--- a/nuttx/binfmt/binfmt_loadmodule.c
+++ b/nuttx/binfmt/binfmt_loadmodule.c
@@ -48,6 +48,8 @@
#include "binfmt_internal.h"
+#ifndef CONFIG_BINFMT_DISABLE
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -136,4 +138,5 @@ int load_module(const char *filename, FAR struct binary_s *bin)
return OK;
}
+#endif /* CONFIG_BINFMT_DISABLE */
diff --git a/nuttx/binfmt/binfmt_register.c b/nuttx/binfmt/binfmt_register.c
index 2323062ec..90b417723 100644
--- a/nuttx/binfmt/binfmt_register.c
+++ b/nuttx/binfmt/binfmt_register.c
@@ -49,6 +49,8 @@
#include "binfmt_internal.h"
+#ifndef CONFIG_BINFMT_DISABLE
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -99,4 +101,5 @@ int register_binfmt(FAR struct binfmt_s *binfmt)
return -EINVAL;
}
+#endif /* CONFIG_BINFMT_DISABLE */
diff --git a/nuttx/binfmt/binfmt_unloadmodule.c b/nuttx/binfmt/binfmt_unloadmodule.c
index ff745171a..e8de31f10 100644
--- a/nuttx/binfmt/binfmt_unloadmodule.c
+++ b/nuttx/binfmt/binfmt_unloadmodule.c
@@ -50,6 +50,8 @@
#include "binfmt_internal.h"
+#ifndef CONFIG_BINFMT_DISABLE
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -103,3 +105,5 @@ int unload_module(FAR const struct binary_s *bin)
return OK;
}
+#endif /* CONFIG_BINFMT_DISABLE */
+
diff --git a/nuttx/binfmt/binfmt_unregister.c b/nuttx/binfmt/binfmt_unregister.c
index 62c156a61..f964d02a3 100644
--- a/nuttx/binfmt/binfmt_unregister.c
+++ b/nuttx/binfmt/binfmt_unregister.c
@@ -49,6 +49,8 @@
#include "binfmt_internal.h"
+#ifndef CONFIG_BINFMT_DISABLE
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -133,4 +135,5 @@ int unregister_binfmt(FAR struct binfmt_s *binfmt)
return ret;
}
+#endif /* CONFIG_BINFMT_DISABLE */
diff --git a/nuttx/binfmt/nxflat.c b/nuttx/binfmt/nxflat.c
index 94b15a32c..e9c2b9961 100644
--- a/nuttx/binfmt/nxflat.c
+++ b/nuttx/binfmt/nxflat.c
@@ -49,6 +49,8 @@
#include <nuttx/binfmt.h>
#include <nuttx/nxflat.h>
+#ifdef CONFIG_NXFLAT
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -235,3 +237,5 @@ void nxflat_uninitialize(void)
unregister_binfmt(&g_nxflatbinfmt);
}
+#endif /* CONFIG_NXFLAT */
+
diff --git a/nuttx/include/nuttx/arch.h b/nuttx/include/nuttx/arch.h
index a51227680..f3cb5c184 100644
--- a/nuttx/include/nuttx/arch.h
+++ b/nuttx/include/nuttx/arch.h
@@ -33,8 +33,8 @@
*
****************************************************************************/
-#ifndef __ARCH_H
-#define __ARCH_H
+#ifndef __INCLUDE_NUTTX_ARCH_H
+#define __INCLUDE_NUTTX_ARCH_H
/****************************************************************************
* Included Files
@@ -367,15 +367,16 @@ EXTERN void up_allocate_heap(FAR void **heap_start, size_t *heap_size);
* Name: up_setpicbase, up_getpicbase
*
* Description:
- * It NXFLAT external modules are supported, then these macros must
- * defined to (1) get or get the PIC base register value. These must
- * be done with in-line assembly.
+ * It NXFLAT external modules (or any other binary format that requires)
+ * PIC) are supported, then these macros must defined to (1) get or get
+ * the PIC base register value. These must be implemented with in-line
+ * assembly.
*
****************************************************************************/
-#ifndef CONFIG_NXFLAT
+#ifndef CONFIG_PIC
# define up_setpicbase(picbase)
-# define up_getpicbase()
+# define up_getpicbase(ppicbase)
#endif
/****************************************************************************
@@ -529,5 +530,5 @@ EXTERN int up_putc(int ch);
}
#endif
-#endif /* __ARCH_H */
+#endif /* __INCLUDE_NUTTX_ARCH_H */
diff --git a/nuttx/include/nuttx/sched.h b/nuttx/include/nuttx/sched.h
index 21feb7db0..520d73047 100644
--- a/nuttx/include/nuttx/sched.h
+++ b/nuttx/include/nuttx/sched.h
@@ -216,7 +216,7 @@ struct _TCB
/* External Module Support ****************************************************/
-#ifdef CONFIG_NXFLAT
+#ifdef CONFIG_PIC
FAR void *picbase; /* Allocated area for .bss and .data */
#endif
diff --git a/nuttx/sched/sched_releasetcb.c b/nuttx/sched/sched_releasetcb.c
index 35821b597..567db2021 100644
--- a/nuttx/sched/sched_releasetcb.c
+++ b/nuttx/sched/sched_releasetcb.c
@@ -137,7 +137,7 @@ int sched_releasetcb(FAR _TCB *tcb)
/* Delete the tasks's allocated DSpace region (external modules only) */
-#ifdef CONFIG_NXFLAT
+#ifdef CONFIG_PIC
if (tcb->picbase)
{
sched_free(tcb->picbase);
diff --git a/nuttx/sched/wd_internal.h b/nuttx/sched/wd_internal.h
index 581f0c5da..216d82079 100644
--- a/nuttx/sched/wd_internal.h
+++ b/nuttx/sched/wd_internal.h
@@ -65,7 +65,7 @@ struct wdog_s
{
FAR struct wdog_s *next; /* Support for singly linked lists. */
wdentry_t func; /* Function to execute when delay expires */
-#ifdef CONFIG_NXFLAT
+#ifdef CONFIG_PIC
FAR void *picbase; /* PIC base address */
#endif
int lag; /* Timer associated with the delay */
diff --git a/nuttx/sched/wd_start.c b/nuttx/sched/wd_start.c
index d27f066f5..ea9117459 100644
--- a/nuttx/sched/wd_start.c
+++ b/nuttx/sched/wd_start.c
@@ -158,8 +158,8 @@ STATUS wd_start(WDOG_ID wdog, int delay, wdentry_t wdentry, int argc, ...)
/* Save the data in the watchdog structure */
wdog->func = wdentry; /* Function to execute when delay expires */
-#ifdef CONFIG_NXFLAT
- wdog->picbase = up_getpicbase();
+#ifdef CONFIG_PIC
+ up_getpicbase(&wdog->picbase);
#endif
wdog->argc = argc;
diff --git a/nuttx/tools/mkconfig.c b/nuttx/tools/mkconfig.c
index 1486586dd..b4afe7bf7 100644
--- a/nuttx/tools/mkconfig.c
+++ b/nuttx/tools/mkconfig.c
@@ -220,6 +220,19 @@ int main(int argc, char **argv, char **envp)
printf("#if defined(__NXFLAT__) && !defined(CONFIG_NXFLAT)\n");
printf("# error \"NXFLAT support not enabled in this configuration\"\n");
printf("#endif\n\n");
+ printf("/* NXFLAT requires PIC support in the TCBs. */\n\n");
+ printf("#if defined(CONFIG_NXFLAT)\n");
+ printf("# undef CONFIG_PIC\n");
+ printf("# define CONFIG_PIC 1\n");
+ printf("#endif\n\n");
+ printf("/* Binary format support is disabled if no binary formats are\n");
+ printf(" * configured (at present, NXFLAT is the only supported binary.\n");
+ printf(" * format).\n");
+ printf(" */\n\n");
+ printf("#if !defined(CONFIG_NXFLAT)\n");
+ printf("# undef CONFIG_BINFMT_DISABLE\n");
+ printf("# define CONFIG_BINFMT_DISABLE 1\n");
+ printf("#endif\n\n");
printf("/* The correct way to disable RR scheduling is to set the\n");
printf(" * timeslice to zero.\n");
printf(" */\n\n");