summaryrefslogtreecommitdiff
path: root/nuttx/include
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-06-17 18:45:48 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-06-17 18:45:48 +0000
commit7a34357c62dd8c1910f444d37f80ed18425b7fad (patch)
tree95f253c9e6737c9f270b4997c6f94b9a16a81159 /nuttx/include
parent0587988c3752c97d158b84afa34fb836b9642b62 (diff)
downloadpx4-nuttx-7a34357c62dd8c1910f444d37f80ed18425b7fad.tar.gz
px4-nuttx-7a34357c62dd8c1910f444d37f80ed18425b7fad.tar.bz2
px4-nuttx-7a34357c62dd8c1910f444d37f80ed18425b7fad.zip
Add basic module management logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1894 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/include')
-rw-r--r--nuttx/include/nuttx/binfmt.h35
-rw-r--r--nuttx/include/nuttx/nxflat.h65
-rw-r--r--nuttx/include/nxflat.h50
3 files changed, 48 insertions, 102 deletions
diff --git a/nuttx/include/nuttx/binfmt.h b/nuttx/include/nuttx/binfmt.h
index 20b27987a..4f9e0884a 100644
--- a/nuttx/include/nuttx/binfmt.h
+++ b/nuttx/include/nuttx/binfmt.h
@@ -58,21 +58,24 @@ struct binary_s
{
/* Provided to the loader */
- const char *filename; /* Full path to the binary */
- const char **argv; /* Argument list */
+ FAR const char *filename; /* Full path to the binary */
+ FAR const char **argv; /* Argument list */
/* Provided by the loader (if successful) */
main_t entrypt; /* Entry point into a program module */
- void *picbase; /* Address of the allocate .data/.bss space */
+ FAR void *ispace; /* Memory-mapped, I-space (.text) address */
+ FAR void *dspace; /* Address of the allocated .data/.bss space */
+ size_t isize; /* Size of the I-space region (needed for munmap) */
+ size_t stacksize; /* Size of the stack in bytes (unallocated) */
};
/* This describes one binary format handler */
struct binfmt_s
{
- struct binfmt_s *next; /* Supports a singly-linked list */
- int (*load)(struct binary_s *bin); /* Verify and load binary into memory */
+ FAR struct binfmt_s *next; /* Supports a singly-linked list */
+ int (*load)(FAR struct binary_s *bin); /* Verify and load binary into memory */
};
/****************************************************************************
@@ -87,10 +90,25 @@ extern "C" {
#define EXTERN extern
#endif
-/* Register/unregister a binary format */
+/* Register a binary format handler */
-EXTERN int register_binfmt(struct binfmt_s *binfmt);
-EXTERN int unregister_binfmt(struct binfmt_s *binfmt);
+EXTERN int register_binfmt(FAR struct binfmt_s *binfmt);
+
+/* Unregister a binary format handler */
+
+EXTERN int unregister_binfmt(FAR struct binfmt_s *binfmt);
+
+/* Load a module into memory */
+
+EXTERN int load_module(const char *filename, FAR struct binary_s *bin);
+
+/* Unload a (non-running) module from memory */
+
+EXTERN int unload_module(FAR const struct binary_s *bin);
+
+/* Execute a module that has been loaded into memory */
+
+EXTERN int exec_module(FAR const struct binary_s *bin);
#undef EXTERN
#if defined(__cplusplus)
@@ -98,3 +116,4 @@ EXTERN int unregister_binfmt(struct binfmt_s *binfmt);
#endif
#endif /* __INCLUDE_NUTTX_BINFMT_H */
+
diff --git a/nuttx/include/nuttx/nxflat.h b/nuttx/include/nuttx/nxflat.h
index 20fabdf7c..17f6d9f03 100644
--- a/nuttx/include/nuttx/nxflat.h
+++ b/nuttx/include/nuttx/nxflat.h
@@ -50,71 +50,42 @@
* Public Types
****************************************************************************/
-/* When DSpace is allocated, space is reserved at the beginning to
- * hold ldso-specific information. The following structure defines
- * that information. This structure can be referenced at run-time
- * using a negative offset from the PID base address.
- */
-
-struct nxflat_ldso_info
-{
- uint32 dspace; /* The beginning of ldso DSpace */
-};
-#define NXFLAT_DATA_OFFSET sizeof(struct nxflat_ldso_info)
-
-/* This struct provides a desciption of the currently loaded
- * instantiation of an xflat binary.
+/* This struct provides a desciption of the currently loaded instantiation
+ * of an nxflat binary.
*/
struct nxflat_loadinfo_s
{
- /* Instruction Space (ISpace): This region contains the flat
- * file header plus everything from the text section. Ideally,
- * will have only one text section instance in the system.
+ /* Instruction Space (ISpace): This region contains the nxflat file header
+ * plus everything from the text section. Ideally, will have only one mmap'ed
+ * text section instance in the system for each module.
*/
uint32 ispace; /* Address where hdr/text is loaded */
- /* 1st: struct nxflat_hdr_s */
- /* 2nd: text section */
- uint32 entry_offset; /* Offset from ispace to entry point */
- uint32 ispace_size; /* Size of ispace. */
-
- /* Data Space (DSpace): This region contains all information that
- * in referenced as data. There will be a unique instance of
- * DSpace for each instance of a process.
- */
+ uint32 entryoffs; /* Offset from ispace to entry point */
+ uint32 isize; /* Size of ispace. */
- uint32 dspace; /* Address where data/bss/stack/etc. is loaded */
- /* 1st: Memory set aside for ldso */
- uint32 data_size; /* 2nd: Size of data segment in dspace */
- uint32 bss_size; /* 3rd: Size of bss segment in dspace */
- /* 4th: Potential padding from relocs/mm/etc. */
- uint32 stack_size; /* 5th: Size of stack in dspace */
- uint32 dspace_size; /* Size of dspace (may be large than parts) */
-
- /* Program arguments (addresses in dspace) */
+ /* Data Space (DSpace): This region contains all information that in referenced
+ * as data (other than the stack which is separately allocated). There will be
+ * a unique instance of DSpace (and stack) for each instance of a process.
+ */
- uint32 arg_start; /* Beginning of program arguments */
- uint32 env_start; /* End of argments, beginning of env */
- uint32 env_end; /* End(+4) of env */
+ uint32 dspace; /* Address where data/bss/etc. is loaded */
+ uint32 datasize; /* Size of data segment in dspace */
+ uint32 bsssize; /* Size of bss segment in dspace */
+ uint32 stacksize; /* Size of stack (not allocated) */
+ uint32 dsize; /* Size of dspace (may be large than parts) */
/* This is temporary memory where relocation records will be loaded. */
- uint32 reloc_start; /* Start of array of struct flat_reloc */
- uint32 reloc_count; /* Number of elements in reloc array */
+ uint32 relocstart; /* Start of array of struct flat_reloc */
+ uint32 reloccount; /* Number of elements in reloc array */
/* File descriptors */
int filfd; /* Descriptor for the file being loaded */
const struct nxflat_hdr_s *header; /* A reference to the flat file header */
-
- /* At most one memory allocation will be made. These describe that
- * allocation.
- */
-
- uint32 alloc_start; /* Start of the allocation */
- uint32 alloc_size; /* Size of the allocation */
};
/****************************************************************************
diff --git a/nuttx/include/nxflat.h b/nuttx/include/nxflat.h
index 59f158dd4..b670b7976 100644
--- a/nuttx/include/nxflat.h
+++ b/nuttx/include/nxflat.h
@@ -60,16 +60,12 @@
struct nxflat_hdr_s
{
/* The "magic number identifying the file type. This field should contain
- * "NxFT"
+ * "NxFT". NOTE that there is not other versioning information other than
+ * this magic number.
*/
char h_magic[4];
- /* NXFLAT revision number number. */
-
- uint16 h_rev;
- uint16 h_pad;
-
/* The following fields provide the memory map for the nxflat binary.
*
* h_entry - Offset to the the first executable insruction from
@@ -113,7 +109,7 @@ struct nxflat_hdr_s
uint32 h_relocstart; /* Offset of relocation records */
uint32 h_reloccount; /* Number of relocation records */
- /* Imported and exported symbol tables
+ /* Imported symbol table (NOTE no symbols are exported)
*
* h_importsymbols - Offset to the beginning of an array of imported
* symbol structures (struct nxflat_import). The
@@ -123,39 +119,12 @@ struct nxflat_hdr_s
* the beginning of the file) to the name of
* a symbol string. This string is null-terminated.
* h_importcount - The number of records in the h_exportsymbols array.
- * h_exportsymbols - Offset to the beginning of an array of export
- * symbol structures (struct nxflat_export). The
- * h_importsymbols offset is relative to the
- * beginning of the file. Each entry of the
- * array contains an uint32 offset (again from
- * the beginning of the file) to the name of
- * a symbol string. This string is null-terminated.
- * h_exportcount - The number of records in the h_exportsymbols array.
- *
- * NOTE: All of the arrays referenced in the header reside in the
- * the .text section. This is possible because these arrays are
- * read-only and are only referenced by the load. Residing in text
- * also guarantees that only one copy of the array is required.
- *
- * An exception is the h_importsymbols array with will lie
- * in .data. This array contains write-able data and must have
- * a single instance per process. NOTE: The string offset contained
- * within nxflat_import still refers to strings residing in the text
- * section.
*/
uint32 h_importsymbols; /* Offset to list of imported symbols */
- uint32 h_exportsymbols; /* Offset to list of exported symbols */
uint16 h_importcount; /* Number of imported symbols */
- uint16 h_exportcount; /* Number of imported symbols */
};
-/* Legal values for the version field. */
-
-#define NXFLAT_VERSION_NONE 0 /* Invalid NXFLAT version */
-#define NXFLAT_VERSION_CURRENT 1 /* Current version */
-#define NXFLAT_VERSION_NUM 2
-
/****************************************************************************
* NXFLAT Relocation types.
*
@@ -193,17 +162,4 @@ struct nxflat_import_s
uint32 i_funcaddress; /* Resolved address of imported function */
};
-/****************************************************************************
- * Exported symbol type
- *
- * The exported symbols are an array of the following type. The fields
- * in each element are stored in native machine order.
- ****************************************************************************/
-
-struct nxflat_export_s
-{
- uint32 x_funcname; /* Offset to name of exported function */
- uint32 x_funcaddress; /* Address of exported function */
-};
-
#endif /* __INCLUDE_NXFLAT_H */