diff --git a/ChangeLog b/ChangeLog index 2e17f8eb1e..3ba81d4a7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3243,3 +3243,7 @@ for testing the changes to the uIP web server (see apps/ChangeLog.txt). * lib/stdio/lib_perror.c: Remove CONFIG_LIBC_PERROR_DEVNAME. What was I thinking? Arbitrary streams cannot be shared by different tasks. + * tools/mksyscall.c, csvparser.c, and csvparser.h: Separate CSV parsing + logic from mksyscall.c into files where it can be shared. + * tools/mksymtab.c: Add a tool that can be used to convert a CSV file + into a NuttX-style symbol table. diff --git a/Documentation/NuttXDemandPaging.html b/Documentation/NuttXDemandPaging.html index c238161a82..082edd21b7 100644 --- a/Documentation/NuttXDemandPaging.html +++ b/Documentation/NuttXDemandPaging.html @@ -8,7 +8,6 @@
Last Updated: August 12, 2010
Last Updated: June 29, 2012
+Last Updated: September 1, 2012
+ There is a small helper program available in nuttx/tools
call mksymtab
.
+ mksymtab
can be sued to generate symbol tables for the NuttX base code that would be usable by the typical NXFLAT application.
+ mksymtab
builds symbol tables from common-separated value (CSV) files.
+ In particular, the CSV files:
+
nuttx/syscall/syscall.csv
that describes the NuttX RTOS interface, and
+ nuttx/lib/lib/csv
that describes the NuttX C library interface.
+ +USAGE: ./mksymtab <cvs-file> <symtab-file> + +Where: + + <cvs-file> : The path to the input CSV file + <symtab-file>: The path to the output symbol table file + -d : Enable debug output ++
+ For example, +
++cd nuttx/tools +cat ../syscall/syscall.csv ../lib/lib.csv | sort >tmp.csv +./mksymtab.exe tmp.csv tmp.c ++ +
Below is a snippet from an NXFLAT make file (simplified from NuttX @@ -639,8 +678,7 @@ any following arguments.
ldr r1, .L0 <-- Fetch the offset to 'x' - ldr r0, [r10, r1] <-- Load the value of 'x' with PIC - offset + ldr r0, [r10, r1] <-- Load the value of 'x' with PIC offset` ... .L0: .word x <-- Offset to 'x'@@ -652,8 +690,7 @@ any following arguments.
ldr r1, .L0 <-- Fetch the offset to the GOT entry - ldr r1, [r10,r1] <-- Fetch the (relocated) address - of 'x' from the GOT + ldr r1, [r10,r1] <-- Fetch the (relocated) address of 'x' from the GOT ldr r0, [r1, #0] <-- Fetch the value of 'x' ... .L1 .word x(GOT) <-- Offset to entry in the GOT @@ -667,9 +704,9 @@ any following arguments. execution time.- NXFLAT (like XFLAT) can work even better with + NXFLAT (like XFLAT) can work even better without the GOT. - Patches again older version of GCC exist to eliminate the GOT indirections. + Patches against older version of GCC exist to eliminate the GOT indirections. Several are available here if you are inspired to port them to a new GCC version.
@@ -735,7 +772,7 @@ any following arguments. XFLAT discussion.- Patches again older version of GCC exist to correct this GCC behavior. + Patches against older version of GCC exist to correct this GCC behavior. Several are available here if you are inspired to port them to a new GCC version.
diff --git a/configs/README.txt b/configs/README.txt index dc9d8d88e8..1b405b3e45 100644 --- a/configs/README.txt +++ b/configs/README.txt @@ -7,6 +7,7 @@ Table of Contents o Summary of Files o Supported Architectures o Configuring NuttX + o Building Symbol Tables Board-Specific Configurations ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1805,3 +1806,26 @@ command line like: cd tools ./configure.sh -a/ + +Building Symbol Tables +^^^^^^^^^^^^^^^^^^^^^^ + +Symbol tables are needed at several of the binfmt interfaces in order to bind +a module to the base code. These symbol tables can be tricky to create and +will probably have to be tailored for any specific application, balancing +the number of symbols and the size of the symbol table against the symbols +required by the applications. + +The top-level System.map file is one good source of symbol information +(which, or course, was just generated from the top-level nuttx file +using the GNU 'nm' tool). + +There are also common-separated value (CSV) values in the source try that +provide information about symbols. In particular: + + nuttx/syscall/syscall.csv - Describes the NuttX RTOS interface, and + nuttx/lib/lib.csv - Describes the NuttX C library interface. + +There is a tool at nuttx/tools/mksymtab that will use these CSV files as +input to generate a generic symbol table. See nuttx/tools/README.txt for +more information about using the mksymtab tool. diff --git a/lib/README.txt b/lib/README.txt index 7de8580485..63d1c343c0 100644 --- a/lib/README.txt +++ b/lib/README.txt @@ -80,3 +80,5 @@ Each type field has a format as follows: cannot cast a union sigval to a uinptr_t either. Rather, we need to cast a specific union member fieldname to uintptr_t. +NOTE: The tool mksymtab can be used to generate a symbol table from this CSV +file. See nuttx/tools/README.txt for further details about the use of mksymtab. diff --git a/lib/lib.csv b/lib/lib.csv index a55d5dbfe4..aa63653f5c 100644 --- a/lib/lib.csv +++ b/lib/lib.csv @@ -1,170 +1,170 @@ -"_inet_ntoa","#include ","#if !defined(CONFIG_NET_IPv6) && !defined(CONFIG_CAN_PASS_STRUCTS)","FAR char","in_addr_t" -"abort","#include ","","void" -"abs","#include ","","int","int" -"asprintf","#include ","","int","FAR char **","const char *","..." -"avsprintf","#include ","","int","FAR char **","const char *","va_list" -"b16atan2","#include ","","b16_t","b16_t","b16_t" -"b16cos","#include ","","b16_t","b16_t" -"b16divb16","#include ","","b16_t","b16_t","b16_t" -"b16mulb16","#include ","","b16_t","b16_t","b16_t" -"b16sin","#include ","","b16_t","b16_t" -"b16sqr","#include ","","b16_t","b16_t" -"basename","#include ","","FAR char","FAR char *" -"cfgetspeed","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","speed_t","FAR const struct termios *" -"cfsetspeed","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","FAR struct termios *","speed_t" -"chdir","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_ENVIRON)","int","FAR const char *" -"crc32","#include ","","uint32_t","FAR const uint8_t *","size_t" -"crc32part","#include ","","uint32_t","FAR const uint8_t *","size_t","uint32_t" -"dbg","#include ","#if !defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG)","int","const char *","..." -"dbg_enable","#include ","#ifdef CONFIG_DEBUG_ENABLE","void","bool" -"dirname","#include ","","FAR char","FAR char *" -"dq_addafter","#include ","","void","FAR dq_entry_t *","FAR dq_entry_t *","FAR dq_queue_t *" -"dq_addbefore","#include ","","void","FAR dq_entry_t *","FAR dq_entry_t *","FAR dq_queue_t *" -"dq_addfirst","#include ","","void","FAR dq_entry_t *","dq_queue_t *" -"dq_addlast","#include ","","void","FAR dq_entry_t *","dq_queue_t *" -"dq_rem","#include ","","void","FAR dq_entry_t *","dq_queue_t *" -"dq_remfirst","#include ","","FAR dq_entry_t","dq_queue_t *" -"dq_remlast","#include ","","FAR dq_entry_t","dq_queue_t *" -"ether_ntoa","#include ","","FAR char","FAR const struct ether_addr *" -"fclose","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *" -"fdopen","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","FAR FILE","int","FAR const char *" -"fflush","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *" -"fgetc","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *" -"fgetpos","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","FAR fpos_t *" -"fgets","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","FAR char","FAR char *","int","FAR FILE *" -"fileno","#include ","","int","FAR FILE *" -"fopen","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","FAR FILE","FAR const char *","FAR const char *" -"fprintf","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","FAR const char *","..." -"fputc","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","int c","FAR FILE *" -"fputs","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR const char *","FAR FILE *" -"fread","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","size_t","FAR void *","size_t","size_t","FAR FILE *" -"fseek","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","long int","int" -"fsetpos","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","FAR fpos_t *" -"ftell","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","long","FAR FILE *" -"fwrite","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","size_t","FAR const void *","size_t","size_t","FAR FILE *" -"getcwd","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_ENVIRON)","FAR char","FAR char *","size_t" -"getopt","#include ","","int","int","FAR char *const[]","FAR const char *" -"getoptargp","#include ","","FAR char *" -"getoptindp","#include ","","int" -"getoptoptp","#include ","","int" -"gets","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","FAR char","FAR char *" -"gmtime","#include ","","struct tm","const time_t *" -"gmtime_r","#include ","","FAR struct tm","FAR const time_t *","FAR struct tm *" -"htonl","#include ","","uint32_t","uint32_t" -"htons","#include ","","uint16_t","uint16_t" -"imaxabs","#include ","","intmax_t","intmax_t" -"inet_addr","#include ","","in_addr_t","FAR const char " -"inet_ntoa","#include ","#if !defined(CONFIG_NET_IPv6) && defined(CONFIG_CAN_PASS_STRUCTS)","FAR char","struct in_addr" -"inet_ntop","#include ","","FAR const char","int","FAR const void *","FAR char *","socklen_t" -"inet_pton","#include ","","int","int","FAR const char *","FAR void *" -"labs","#include ","","long int","long int" -"lib_dumpbuffer","#include ","","void","FAR const char *","FAR const uint8_t *","unsigned int" -"lib_lowprintf","#include ","","int","FAR const char *","..." -"lib_rawprintf","#include ","","int","FAR const char *","..." -"llabs","#include ","#ifdef CONFIG_HAVE_LONG_LONG","long long int","long long int" -"lldbg","#include ","#if !defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG) && defined(CONFIG_ARCH_LOWPUTC)","int","const char *","..." -"llvdbg","#include ","#if !defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_ARCH_LOWPUTC)","int","const char *","..." +"_inet_ntoa","arpa/inet.h","!defined(CONFIG_NET_IPv6) && !defined(CONFIG_CAN_PASS_STRUCTS)","FAR char","in_addr_t" +"abort","stdlib.h","","void" +"abs","stdlib.h","","int","int" +"asprintf","stdio.h","","int","FAR char **","const char *","..." +"avsprintf","stdio.h","","int","FAR char **","const char *","va_list" +"b16atan2","fixedmath.h","","b16_t","b16_t","b16_t" +"b16cos","fixedmath.h","","b16_t","b16_t" +"b16divb16","fixedmath.h","","b16_t","b16_t","b16_t" +"b16mulb16","fixedmath.h","","b16_t","b16_t","b16_t" +"b16sin","fixedmath.h","","b16_t","b16_t" +"b16sqr","fixedmath.h","","b16_t","b16_t" +"basename","libgen.h","","FAR char","FAR char *" +"cfgetspeed","termios.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","speed_t","FAR const struct termios *" +"cfsetspeed","termios.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","FAR struct termios *","speed_t" +"chdir","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_ENVIRON)","int","FAR const char *" +"crc32","crc32.h","","uint32_t","FAR const uint8_t *","size_t" +"crc32part","crc32.h","","uint32_t","FAR const uint8_t *","size_t","uint32_t" +"dbg","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG)","int","const char *","..." +"dbg_enable","debug.h","defined(CONFIG_DEBUG_ENABLE)","void","bool" +"dirname","libgen.h","","FAR char","FAR char *" +"dq_addafter","queue.h","","void","FAR dq_entry_t *","FAR dq_entry_t *","FAR dq_queue_t *" +"dq_addbefore","queue.h","","void","FAR dq_entry_t *","FAR dq_entry_t *","FAR dq_queue_t *" +"dq_addfirst","queue.h","","void","FAR dq_entry_t *","dq_queue_t *" +"dq_addlast","queue.h","","void","FAR dq_entry_t *","dq_queue_t *" +"dq_rem","queue.h","","void","FAR dq_entry_t *","dq_queue_t *" +"dq_remfirst","queue.h","","FAR dq_entry_t","dq_queue_t *" +"dq_remlast","queue.h","","FAR dq_entry_t","dq_queue_t *" +"ether_ntoa","netinet/ether.h","","FAR char","FAR const struct ether_addr *" +"fclose","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *" +"fdopen","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","FAR FILE","int","FAR const char *" +"fflush","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *" +"fgetc","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *" +"fgetpos","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","FAR fpos_t *" +"fgets","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","FAR char","FAR char *","int","FAR FILE *" +"fileno","stdio.h","","int","FAR FILE *" +"fopen","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","FAR FILE","FAR const char *","FAR const char *" +"fprintf","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","FAR const char *","..." +"fputc","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","int c","FAR FILE *" +"fputs","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR const char *","FAR FILE *" +"fread","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","size_t","FAR void *","size_t","size_t","FAR FILE *" +"fseek","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","long int","int" +"fsetpos","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","FAR fpos_t *" +"ftell","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","long","FAR FILE *" +"fwrite","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","size_t","FAR const void *","size_t","size_t","FAR FILE *" +"getcwd","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_ENVIRON)","FAR char","FAR char *","size_t" +"getopt","unistd.h","","int","int","FAR char *const[]","FAR const char *" +"getoptargp","unistd.h","","FAR char *" +"getoptindp","unistd.h","","int" +"getoptoptp","unistd.h","","int" +"gets","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","FAR char","FAR char *" +"gmtime","time.h","","struct tm","const time_t *" +"gmtime_r","time.h","","FAR struct tm","FAR const time_t *","FAR struct tm *" +"htonl","arpa/inet.h","","uint32_t","uint32_t" +"htons","arpa/inet.h","","uint16_t","uint16_t" +"imaxabs","stdlib.h","","intmax_t","intmax_t" +"inet_addr","arpa/inet.h","","in_addr_t","FAR const char " +"inet_ntoa","arpa/inet.h","!defined(CONFIG_NET_IPv6) && defined(CONFIG_CAN_PASS_STRUCTS)","FAR char","struct in_addr" +"inet_ntop","arpa/inet.h","","FAR const char","int","FAR const void *","FAR char *","socklen_t" +"inet_pton","arpa/inet.h","","int","int","FAR const char *","FAR void *" +"labs","stdlib.h","","long int","long int" +"lib_dumpbuffer","debug.h","","void","FAR const char *","FAR const uint8_t *","unsigned int" +"lib_lowprintf","debug.h","","int","FAR const char *","..." +"lib_rawprintf","debug.h","","int","FAR const char *","..." +"llabs","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","long long int","long long int" +"lldbg","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG) && defined(CONFIG_ARCH_LOWPUTC)","int","const char *","..." +"llvdbg","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_ARCH_LOWPUTC)","int","const char *","..." "match","","","int","const char *","const char *" -"memccpy","#include ","","FAR void","FAR void *","FAR const void *","int c","size_t" -"memchr","#include ","","FAR void","FAR const void *","int c","size_t" -"memcmp","#include ","","int","FAR const void *","FAR const void *","size_t" -"memcpy","#include ","","FAR void","FAR void *","FAR const void *","size_t" -"memmove","#include ","","FAR void","FAR void *","FAR const void *","size_t" -"memset","#include ","","FAR void","FAR void *","int c","size_t" -"mktime","#include ","","time_t","const struct tm *" -"mq_getattr","#include ","#ifndef CONFIG_DISABLE_MQUEUE","int","mqd_t","struct mq_attr *" -"mq_setattr","#include ","#ifndef CONFIG_DISABLE_MQUEUE","int","mqd_t","const struct mq_attr *","struct mq_attr *" -"ntohl","#include ","","uint32_t","uint32_t" -"ntohs","#include ","","uint16_t","uint16_t" -"perror","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","void","FAR const char *" -"printf","#include ","","int","const char *","..." -"pthread_attr_destroy","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_attr_t *" -"pthread_attr_getinheritsched","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR const pthread_attr_t *","FAR int *" -"pthread_attr_getschedparam","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_attr_t *","FAR struct sched_param *" -"pthread_attr_getschedpolicy","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_attr_t *","int *" -"pthread_attr_getstacksize","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_attr_t *","FAR long *" -"pthread_attr_init","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_attr_t *" -"pthread_attr_setinheritsched","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_attr_t *","int" -"pthread_attr_setschedparam","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_attr_t *","FAR const struct sched_param *" -"pthread_attr_setschedpolicy","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_attr_t *","int" -"pthread_attr_setstacksize","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_attr_t *","long" -"pthread_barrierattr_destroy","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_barrierattr_t *" -"pthread_barrierattr_getpshared","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR const pthread_barrierattr_t *","FAR int *" -"pthread_barrierattr_init","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_barrierattr_t *" -"pthread_barrierattr_setpshared","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_barrierattr_t *","int" -"pthread_condattr_destroy","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_condattr_t *" -"pthread_condattr_init","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_condattr_t *" -"pthread_mutexattr_destroy","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_mutexattr_t *" -"pthread_mutexattr_getpshared","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_mutexattr_t *","FAR int *" -"pthread_mutexattr_gettype","#include ","#if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_MUTEX_TYPES)","int","const pthread_mutexattr_t *","int *" -"pthread_mutexattr_init","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_mutexattr_t *" -"pthread_mutexattr_setpshared","#include ","#ifndef CONFIG_DISABLE_PTHREAD","int","FAR pthread_mutexattr_t *","int " -"pthread_mutexattr_settype","#include ","#if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_MUTEX_TYPES)","int","pthread_mutexattr_t *","int" -"puts","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR const char *" -"qsort","#include ","","void","void *","size_t","size_t","int(*)(const void *","const void *)" -"rand","#include ","","int" -"readdir_r","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0","int","FAR DIR *","FAR struct dirent *","FAR struct dirent **" +"memccpy","string.h","","FAR void","FAR void *","FAR const void *","int c","size_t" +"memchr","string.h","","FAR void","FAR const void *","int c","size_t" +"memcmp","string.h","","int","FAR const void *","FAR const void *","size_t" +"memcpy","string.h","","FAR void","FAR void *","FAR const void *","size_t" +"memmove","string.h","","FAR void","FAR void *","FAR const void *","size_t" +"memset","string.h","","FAR void","FAR void *","int c","size_t" +"mktime","time.h","","time_t","const struct tm *" +"mq_getattr","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","mqd_t","struct mq_attr *" +"mq_setattr","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","mqd_t","const struct mq_attr *","struct mq_attr *" +"ntohl","arpa/inet.h","","uint32_t","uint32_t" +"ntohs","arpa/inet.h","","uint16_t","uint16_t" +"perror","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","void","FAR const char *" +"printf","stdio.h","","int","const char *","..." +"pthread_attr_destroy","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_attr_t *" +"pthread_attr_getinheritsched","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR const pthread_attr_t *","FAR int *" +"pthread_attr_getschedparam","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_attr_t *","FAR struct sched_param *" +"pthread_attr_getschedpolicy","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_attr_t *","int *" +"pthread_attr_getstacksize","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_attr_t *","FAR long *" +"pthread_attr_init","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_attr_t *" +"pthread_attr_setinheritsched","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_attr_t *","int" +"pthread_attr_setschedparam","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_attr_t *","FAR const struct sched_param *" +"pthread_attr_setschedpolicy","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_attr_t *","int" +"pthread_attr_setstacksize","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_attr_t *","long" +"pthread_barrierattr_destroy","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_barrierattr_t *" +"pthread_barrierattr_getpshared","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR const pthread_barrierattr_t *","FAR int *" +"pthread_barrierattr_init","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_barrierattr_t *" +"pthread_barrierattr_setpshared","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_barrierattr_t *","int" +"pthread_condattr_destroy","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_condattr_t *" +"pthread_condattr_init","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_condattr_t *" +"pthread_mutexattr_destroy","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_mutexattr_t *" +"pthread_mutexattr_getpshared","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_mutexattr_t *","FAR int *" +"pthread_mutexattr_gettype","pthread.h","!defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_MUTEX_TYPES)","int","const pthread_mutexattr_t *","int *" +"pthread_mutexattr_init","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_mutexattr_t *" +"pthread_mutexattr_setpshared","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_mutexattr_t *","int " +"pthread_mutexattr_settype","pthread.h","!defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_MUTEX_TYPES)","int","pthread_mutexattr_t *","int" +"puts","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR const char *" +"qsort","stdlib.h","","void","void *","size_t","size_t","int(*)(const void *","const void *)" +"rand","stdlib.h","","int" +"readdir_r","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","int","FAR DIR *","FAR struct dirent *","FAR struct dirent **" "rint","","","double_t","double_t" -"sched_get_priority_max","#include ","","int","int" -"sched_get_priority_min","#include ","","int","int" -"sem_getvalue","#include ","","int","FAR sem_t *","FAR int *" -"sem_init","#include ","","int","FAR sem_t *","int","unsigned int" -"sigaddset","#include ","#ifndef CONFIG_DISABLE_SIGNALS","int","FAR sigset_t *","int" -"sigdelset","#include ","#ifndef CONFIG_DISABLE_SIGNALS","int","FAR sigset_t *","int" -"sigemptyset","#include ","#ifndef CONFIG_DISABLE_SIGNALS","int","FAR sigset_t *" -"sigfillset","#include ","#ifndef CONFIG_DISABLE_SIGNALS","int","FAR sigset_t *" -"sigismember","#include ","#ifndef CONFIG_DISABLE_SIGNALS","int","FAR const sigset_t *","int" -"snprintf","#include ","","int","FAR char *","size_t","const char *","..." -"sprintf","#include ","","int","FAR char *","const char *","..." -"sq_addafter","#include ","","void","FAR sq_entry_t *","FAR sq_entry_t *","FAR sq_queue_t *" -"sq_addfirst","#include ","","void","FAR sq_entry_t *","sq_queue_t *" -"sq_addlast","#include ","","void","FAR sq_entry_t *","sq_queue_t *" -"sq_rem","#include ","","void","FAR sq_entry_t *","sq_queue_t *" -"sq_remafter","#include ","","FAR sq_entry_t","FAR sq_entry_t *","sq_queue_t *" -"sq_remfirst","#include ","","FAR sq_entry_t","sq_queue_t *" -"sq_remlast","#include ","","FAR sq_entry_t","sq_queue_t *" -"srand","#include ","","void","unsigned int" -"sscanf","#include ","","int","const char *","const char *","..." -"strcasecmp","#include ","","int","FAR const char *","FAR const char *" -"strcasestr","#include ","","FAR char","FAR const char *","FAR const char *" -"strcat","#include ","","FAR char","FAR char *","FAR const char *" -"strchr","#include ","","FAR char","FAR const char *","int" -"strcmp","#include ","","int","FAR const char *","FAR const char *" -"strcpy","#include ","","FAR char","char *","FAR const char *" -"strcspn","#include ","","size_t","FAR const char *","FAR const char *" -"strdup","#include ","","FAR char","FAR const char *" -"strerror","#include ","","FAR const char","int" -"strftime","#include ","","size_t","char *","size_t","const char *","const struct tm *" -"strlen","#include ","","size_t","FAR const char *" -"strncasecmp","#include ","","int","FAR const char *","FAR const char *","size_t" -"strncat","#include ","","FAR char","FAR char *","FAR const char *","size_t" -"strncmp","#include ","","int","FAR const char *","FAR const char *","size_t" -"strncpy","#include ","","FAR char","char *","FAR const char *","size_t" -"strndup","#include ","","FAR char","FAR const char *","size_t" -"strnlen","#include ","","size_t","FAR const char *","size_t" -"strpbrk","#include ","","FAR char","FAR const char *","FAR const char *" -"strrchr","#include ","","FAR char","FAR const char *","int" -"strspn","#include ","","size_t","FAR const char *","FAR const char *" -"strstr","#include ","","FAR char","FAR const char *","FAR const char *" -"strtod","#include ","","double_t","const char *str","char **endptr" -"strtok","#include ","","FAR char","FAR char *","FAR const char *" -"strtok_r","#include ","","FAR char","FAR char *","FAR const char *","FAR char **" -"strtol","#include ","","long","const char *","char **","int" -"strtoll","#include ","#ifdef CONFIG_HAVE_LONG_LONG","long long","const char *nptr","char **endptr","int base" -"strtoul","#include ","","unsigned long","const char *","char **","int" -"strtoull","#include ","#ifdef CONFIG_HAVE_LONG_LONG","unsigned long long","const char *","char **","int" -"tcflush","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","int","int" -"tcgetattr","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","int","FAR struct termios *" -"tcsetattr","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","int","int","FAR const struct termios *" -"telldir","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0","off_t","FAR DIR *" -"time","#include ","","time_t","time_t *" -"ub16divub16","#include ","","ub16_t","ub16_t","ub16_t" -"ub16mulub16","#include ","","ub16_t","ub16_t","ub16_t" -"ub16sqr","#include ","","ub16_t","ub16_t" -"ungetc","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","int","FAR FILE *" -"vdbg","#include ","#if !defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_VERBOSE)","int","const char *","..." -"vfprintf","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","const char *","va_list" -"vprintf","#include ","#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR const char *","va_list" -"vsnprintf","#include ","","int","FAR char *","size_t","const char *","va_list" -"vsprintf","#include ","","int","FAR char *","const char *","va_list" -"vsscanf","#include ","","int","char *","const char *","va_list" +"sched_get_priority_max","sched.h","","int","int" +"sched_get_priority_min","sched.h","","int","int" +"sem_getvalue","semaphore.h","","int","FAR sem_t *","FAR int *" +"sem_init","semaphore.h","","int","FAR sem_t *","int","unsigned int" +"sigaddset","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR sigset_t *","int" +"sigdelset","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR sigset_t *","int" +"sigemptyset","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR sigset_t *" +"sigfillset","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR sigset_t *" +"sigismember","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR const sigset_t *","int" +"snprintf","stdio.h","","int","FAR char *","size_t","const char *","..." +"sprintf","stdio.h","","int","FAR char *","const char *","..." +"sq_addafter","queue.h","","void","FAR sq_entry_t *","FAR sq_entry_t *","FAR sq_queue_t *" +"sq_addfirst","queue.h","","void","FAR sq_entry_t *","sq_queue_t *" +"sq_addlast","queue.h","","void","FAR sq_entry_t *","sq_queue_t *" +"sq_rem","queue.h","","void","FAR sq_entry_t *","sq_queue_t *" +"sq_remafter","queue.h","","FAR sq_entry_t","FAR sq_entry_t *","sq_queue_t *" +"sq_remfirst","queue.h","","FAR sq_entry_t","sq_queue_t *" +"sq_remlast","queue.h","","FAR sq_entry_t","sq_queue_t *" +"srand","stdlib.h","","void","unsigned int" +"sscanf","stdio.h","","int","const char *","const char *","..." +"strcasecmp","string.h","","int","FAR const char *","FAR const char *" +"strcasestr","string.h","","FAR char","FAR const char *","FAR const char *" +"strcat","string.h","","FAR char","FAR char *","FAR const char *" +"strchr","string.h","","FAR char","FAR const char *","int" +"strcmp","string.h","","int","FAR const char *","FAR const char *" +"strcpy","string.h","","FAR char","char *","FAR const char *" +"strcspn","string.h","","size_t","FAR const char *","FAR const char *" +"strdup","string.h","","FAR char","FAR const char *" +"strerror","string.h","","FAR const char","int" +"strftime","time.h","","size_t","char *","size_t","const char *","const struct tm *" +"strlen","string.h","","size_t","FAR const char *" +"strncasecmp","string.h","","int","FAR const char *","FAR const char *","size_t" +"strncat","string.h","","FAR char","FAR char *","FAR const char *","size_t" +"strncmp","string.h","","int","FAR const char *","FAR const char *","size_t" +"strncpy","string.h","","FAR char","char *","FAR const char *","size_t" +"strndup","string.h","","FAR char","FAR const char *","size_t" +"strnlen","string.h","","size_t","FAR const char *","size_t" +"strpbrk","string.h","","FAR char","FAR const char *","FAR const char *" +"strrchr","string.h","","FAR char","FAR const char *","int" +"strspn","string.h","","size_t","FAR const char *","FAR const char *" +"strstr","string.h","","FAR char","FAR const char *","FAR const char *" +"strtod","stdlib.h","","double_t","const char *str","char **endptr" +"strtok","string.h","","FAR char","FAR char *","FAR const char *" +"strtok_r","string.h","","FAR char","FAR char *","FAR const char *","FAR char **" +"strtol","string.h","","long","const char *","char **","int" +"strtoll","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","long long","const char *nptr","char **endptr","int base" +"strtoul","stdlib.h","","unsigned long","const char *","char **","int" +"strtoull","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","unsigned long long","const char *","char **","int" +"tcflush","termios.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","int","int" +"tcgetattr","termios.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","int","FAR struct termios *" +"tcsetattr","termios.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","int","int","FAR const struct termios *" +"telldir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","off_t","FAR DIR *" +"time","time.h","","time_t","time_t *" +"ub16divub16","fixedmath.h","","ub16_t","ub16_t","ub16_t" +"ub16mulub16","fixedmath.h","","ub16_t","ub16_t","ub16_t" +"ub16sqr","fixedmath.h","","ub16_t","ub16_t" +"ungetc","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","int","FAR FILE *" +"vdbg","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_VERBOSE)","int","const char *","..." +"vfprintf","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","const char *","va_list" +"vprintf","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","int","FAR const char *","va_list" +"vsnprintf","stdio.h","","int","FAR char *","size_t","const char *","va_list" +"vsprintf","stdio.h","","int","FAR char *","const char *","va_list" +"vsscanf","stdio.h","","int","char *","const char *","va_list" diff --git a/syscall/README.txt b/syscall/README.txt index 0b77f50bfc..ed5e6081d7 100644 --- a/syscall/README.txt +++ b/syscall/README.txt @@ -108,6 +108,10 @@ Each type field has a format as follows: cannot cast a union sigval to a uinptr_t either. Rather, we need to cast a specific union member fieldname to uintptr_t. +NOTE: This CSV file is used both to support the generate of trap information, +but also for the generation of symbol tables. See nuttx/tools/README.txt +and nuttx/lib/README.txt for further information. + Auto-Generated Files ==================== diff --git a/tools/Makefile.export b/tools/Makefile.export index fa2909972a..ce4842187a 100644 --- a/tools/Makefile.export +++ b/tools/Makefile.export @@ -2,7 +2,7 @@ # Makefile.export # # Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt +# Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/tools/Makefile.host b/tools/Makefile.host index cf421aa3bf..33b7aaab2b 100644 --- a/tools/Makefile.host +++ b/tools/Makefile.host @@ -58,8 +58,13 @@ mkversion: mkconfig.c cfgparser.c # mksyscall - Convert a CSV file into syscall stubs and proxies -mksyscall: mksyscall.c - @gcc $(CFLAGS) -o mksyscall mksyscall.c +mksyscall: mksyscall.c csvparser.c + @gcc $(CFLAGS) -o mksyscall mksyscall.c csvparser.c + +# mksymtab - Convert a CSV file into a symbol table + +mksymtab: mksymtab.c csvparser.c + @gcc $(CFLAGS) -o mksymtab mksymtab.c csvparser.c # bdf-converter - Converts a BDF font to the NuttX font format diff --git a/tools/README.txt b/tools/README.txt index 2a3416adb7..ae19be2738 100755 --- a/tools/README.txt +++ b/tools/README.txt @@ -67,7 +67,7 @@ mkversion.c, cfgparser.c, and cfgparser.h .version file in the top level directory into include/nuttx/version.h. version.h provides version information that can be included by C files. -mksyscall.c +mksyscall.c, cvsparser.c, and cvsparser.h This is a C file that is used to build mksyscall program. The mksyscall program is used during the initial NuttX build by the logic in the top- @@ -89,6 +89,26 @@ mksyscall.c accept this CVS file as input and generate all of the required proxy or stub files as output. See syscall/README.txt for additonal information. +mksymtab.c, cvsparser.c, and cvsparser.h + + This is a C file that is used to build symbol tables from common-separated + value (CSV) files. This tool is not used during the NuttX build, but + can be used as needed to generate files. + + USAGE: ./mksymtab + + Where: + + : The path to the input CSV file + : The path to the output symbol table file + -d : Enable debug output + + Example: + + cd nuttx/tools + cat ../syscall/syscall.csv ../lib/lib.csv | sort >tmp.csv + ./mksymtab.exe tmp.csv tmp.c + pic32mx This directory contains build tools used only for PIC32MX platforms diff --git a/tools/cfgparser.h b/tools/cfgparser.h index 02de42928b..b1c4bae762 100644 --- a/tools/cfgparser.h +++ b/tools/cfgparser.h @@ -2,7 +2,7 @@ * tools/cfgpaser.h * * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/tools/configure.sh b/tools/configure.sh index 3aaed06817..8b4a3e4860 100755 --- a/tools/configure.sh +++ b/tools/configure.sh @@ -2,7 +2,7 @@ # configure.sh # # Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt +# Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/tools/csvparser.c b/tools/csvparser.c new file mode 100644 index 0000000000..739e5e1f8b --- /dev/null +++ b/tools/csvparser.c @@ -0,0 +1,205 @@ +/**************************************************************************** + * tools/csvparser.c + * + * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "csvparser.h" + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +bool g_debug; +char g_line[LINESIZE+1]; +char g_parm[MAX_FIELDS][MAX_PARMSIZE]; +int g_lineno; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static char *skip_space(char *ptr) +{ + while (*ptr && isspace((int)*ptr)) ptr++; + return ptr; +} + +static char *copy_parm(char *src, char *dest) +{ + char *start = src; + int i; + + for (i = 0; i < MAX_PARMSIZE; i++) + { + if (*src == '"') + { + *dest = '\0'; + return src; + } + else if (*src == '\n' || *src == '\0') + { + fprintf(stderr, "%d: Unexpected end of line: \"%s\"\n", g_lineno, start); + exit(4); + } + else + { + *dest++ = *src++; + } + } + + fprintf(stderr, "%d: Parameter too long: \"%s\"\n", g_lineno, start); + exit(3); +} + +static char *find_parm(char *ptr) +{ + char *start = ptr; + + if (*ptr != '"') + { + fprintf(stderr, "%d: I'm confused: \"%s\"\n", g_lineno, start); + exit(5); + } + ptr++; + + ptr = skip_space(ptr); + if (*ptr == '\n' || *ptr == '\0') + { + return NULL; + } + else if (*ptr != ',') + { + fprintf(stderr, "%d: Expected ',': \"%s\"\n", g_lineno, start); + exit(6); + } + ptr++; + + ptr = skip_space(ptr); + if (*ptr != '"') + { + fprintf(stderr, "%d: Expected \": \"%s\"\n", g_lineno, start); + exit(7); + } + ptr++; + + return ptr; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +char *read_line(FILE *stream) +{ + char *ptr; + + for (;;) + { + g_line[LINESIZE] = '\0'; + if (!fgets(g_line, LINESIZE, stream)) + { + return NULL; + } + else + { + g_lineno++; + if (g_debug) + { + printf("Line: %s\n", g_line); + } + + ptr = skip_space(g_line); + if (*ptr && *ptr != '#' && *ptr != '\n') + { + return ptr; + } + } + } +} + +int parse_csvline(char *ptr) +{ + int nparms; + int i; + + /* Format "arg1","arg2","arg3",... Spaces will be tolerated outside of the + * quotes. Any initial spaces have already been skipped so the first thing + * should be '"'. + */ + + if (*ptr != '"') + { + fprintf(stderr, "%d: Bad line: \"%s\"\n", g_lineno, g_line); + exit(2); + } + + ptr++; + nparms = 0; + + do + { + ptr = copy_parm(ptr, &g_parm[nparms][0]); + nparms++; + ptr = find_parm(ptr); + } + while (ptr); + + if (g_debug) + { + printf("Parameters: %d\n", nparms); + for (i = 0; i < nparms; i++) + { + printf(" Parm%d: \"%s\"\n", i+1, g_parm[i]); + } + } + return nparms; +} diff --git a/tools/csvparser.h b/tools/csvparser.h new file mode 100644 index 0000000000..872dc3c020 --- /dev/null +++ b/tools/csvparser.h @@ -0,0 +1,76 @@ +/**************************************************************************** + * tools/csvparser.h + * + * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __TOOLS_CSVPARSER_H +#define __TOOLS_CSVPARSER_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define LINESIZE (PATH_MAX > 256 ? PATH_MAX : 256) + +#define MAX_FIELDS 16 +#define MAX_PARMSIZE 128 +#define NAME_INDEX 0 +#define HEADER_INDEX 1 +#define COND_INDEX 2 +#define RETTYPE_INDEX 3 +#define PARM1_INDEX 4 + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +extern bool g_debug; +extern char g_line[LINESIZE+1]; +extern char g_parm[MAX_FIELDS][MAX_PARMSIZE]; +extern int g_lineno; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +char *read_line(FILE *stream); +int parse_csvline(char *ptr); + +#endif /* __TOOLS_CSVPARSER_H */ diff --git a/tools/define.sh b/tools/define.sh index 8b2b0e364c..c53cb92a83 100755 --- a/tools/define.sh +++ b/tools/define.sh @@ -2,7 +2,7 @@ # tools/define.sh # # Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt +# Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/tools/indent.sh b/tools/indent.sh index 938502e0f9..739b791bdc 100755 --- a/tools/indent.sh +++ b/tools/indent.sh @@ -3,7 +3,7 @@ # tools/indent.sh # # Copyright (C) 2008, 2010 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt +# Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/tools/link.sh b/tools/link.sh index 7927d65c83..da1e6e7ae5 100755 --- a/tools/link.sh +++ b/tools/link.sh @@ -3,7 +3,7 @@ # tools/link.sh # # Copyright (C) 2008 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt +# Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/tools/mkdeps.sh b/tools/mkdeps.sh index 6d83f2ca01..acb6001509 100755 --- a/tools/mkdeps.sh +++ b/tools/mkdeps.sh @@ -3,7 +3,7 @@ # tools/mkdeps.sh # # Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt +# Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/tools/mknulldeps.sh b/tools/mknulldeps.sh index 6dc3e9635b..033205e6fb 100755 --- a/tools/mknulldeps.sh +++ b/tools/mknulldeps.sh @@ -2,7 +2,7 @@ # tools/mknulldeps.sh # # Copyright (C) 2008 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt +# Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/tools/mkromfsimg.sh b/tools/mkromfsimg.sh index b628d24196..b774119800 100755 --- a/tools/mkromfsimg.sh +++ b/tools/mkromfsimg.sh @@ -3,7 +3,7 @@ # tools/mkromfsimg.sh # # Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt +# Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/tools/mksymtab.c b/tools/mksymtab.c new file mode 100644 index 0000000000..14101f3d9d --- /dev/null +++ b/tools/mksymtab.c @@ -0,0 +1,277 @@ +/**************************************************************************** + * tools/mksymtab.c + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "csvparser.h" + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +#define MAX_HEADER_FILES 500 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const char *g_hdrfiles[MAX_HEADER_FILES]; +static int nhdrfiles; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static void show_usage(const char *progname) +{ + fprintf(stderr, "USAGE: %s \n\n", progname); + fprintf(stderr, "Where:\n\n"); + fprintf(stderr, " : The path to the input CSV file\n"); + fprintf(stderr, " : The path to the output symbol table file\n"); + fprintf(stderr, " -d : Enable debug output\n"); + exit(EXIT_FAILURE); +} + +static bool check_hdrfile(const char *hdrfile) +{ + int i; + + for (i = 0; i < nhdrfiles; i++) + { + if (strcmp(g_hdrfiles[i], hdrfile) == 0) + { + return true; + } + } + + return false; +} + +static void add_hdrfile(const char *hdrfile) +{ + if (!check_hdrfile(hdrfile)) + { + if (nhdrfiles > MAX_HEADER_FILES) + { + fprintf(stderr, "ERROR: Too man header files. Increase MAX_HEADER_FILES\n"); + exit(EXIT_FAILURE); + } + + g_hdrfiles[nhdrfiles] = strdup(hdrfile); + nhdrfiles++; + } +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int main(int argc, char **argv, char **envp) +{ + char *csvpath; + char *symtab; + char *terminator; + char *ptr; + bool cond; + FILE *instream; + FILE *outstream; + int ch; + int i; + + /* Parse command line options */ + + g_debug = false; + + while ((ch = getopt(argc, argv, ":d")) > 0) + { + switch (ch) + { + case 'd' : + g_debug = true; + break; + + case '?' : + fprintf(stderr, "Unrecognized option: %c\n", optopt); + show_usage(argv[0]); + + case ':' : + fprintf(stderr, "Missing option argument, option: %c\n", optopt); + show_usage(argv[0]); + + break; + fprintf(stderr, "Unexpected option: %c\n", ch); + show_usage(argv[0]); + } + } + + if (optind >= argc) + { + fprintf(stderr, "Missing and \n"); + show_usage(argv[0]); + } + + csvpath = argv[optind]; + optind++; + + if (optind >= argc) + { + fprintf(stderr, "Missing \n"); + show_usage(argv[0]); + } + + symtab = argv[optind]; + optind++; + + if (optind < argc) + { + fprintf(stderr, "Unexpected garbage at the end of the line\n"); + show_usage(argv[0]); + } + + /* Open the CSV file for reading */ + + instream = fopen(csvpath, "r"); + if (!instream) + { + fprintf(stderr, "open %s failed: %s\n", csvpath, strerror(errno)); + exit(EXIT_FAILURE); + } + + /* Open the Symbol table file for writing */ + + outstream = fopen(symtab, "w"); + if (!outstream) + { + fprintf(stderr, "open %s failed: %s\n", csvpath, strerror(errno)); + exit(EXIT_FAILURE); + } + + /* Get all of the header files that we need to include */ + + while ((ptr = read_line(instream)) != NULL) + { + /* Parse the line from the CVS file */ + + int nargs = parse_csvline(ptr); + if (nargs < PARM1_INDEX) + { + fprintf(stderr, "Only %d arguments found: %s\n", nargs, g_line); + exit(EXIT_FAILURE); + } + + /* Add the header file to the list of header files we need to include */ + + add_hdrfile(g_parm[HEADER_INDEX]); + } + + /* Back to the beginning */ + + rewind(instream); + + /* Output up-front file boilerplate */ + + fprintf(outstream, "/* %s: Auto-generated symbol table. Do not edit */\n\n", symtab); + fprintf(outstream, "#include \n"); + fprintf(outstream, "#include \n\n"); + + /* Output all of the require header files */ + + for (i = 0; i < nhdrfiles; i++) + { + fprintf(outstream, "#include <%s>\n", g_hdrfiles[i]); + } + + /* Now the symbol table itself */ + + fprintf(outstream, "\nstruct symtab_s g_symtab[] =\n"); + fprintf(outstream, "{\n"); + + /* Parse each line in the CVS file */ + + terminator = ""; + while ((ptr = read_line(instream)) != NULL) + { + /* Parse the line from the CVS file */ + + int nargs = parse_csvline(ptr); + if (nargs < PARM1_INDEX) + { + fprintf(stderr, "Only %d arguments found: %s\n", nargs, g_line); + exit(EXIT_FAILURE); + } + + /* Output any conditional compilation */ + + cond = (g_parm[COND_INDEX] && strlen(g_parm[COND_INDEX]) > 0); + if (cond) + { + fprintf(outstream, "%s#if %s\n", terminator, g_parm[COND_INDEX]); + terminator = ""; + } + + /* Output the symbol table entry */ + + fprintf(outstream, "%s { \"%s\", (FAR const void *)%s }", + terminator, g_parm[NAME_INDEX], g_parm[NAME_INDEX]); + terminator = ",\n"; + + if (cond) + { + fprintf(outstream, "%s#endif", terminator); + terminator = "\n"; + } + } + + fprintf(outstream, "\n};\n"); + + /* Close the CSV and symbol table files and exit */ + + fclose(instream); + fclose(outstream); + return EXIT_SUCCESS; +} diff --git a/tools/mksyscall.c b/tools/mksyscall.c index a8f2cf99b7..a75e82d280 100644 --- a/tools/mksyscall.c +++ b/tools/mksyscall.c @@ -1,8 +1,8 @@ /**************************************************************************** * tools/mksyscall.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -41,174 +41,26 @@ #include #include #include -#include -#include #include -#include #include +#include "csvparser.h" + /**************************************************************************** * Definitions ****************************************************************************/ -#define LINESIZE (PATH_MAX > 256 ? PATH_MAX : 256) - -#define MAX_FIELDS 16 -#define MAX_PARMSIZE 128 -#define NAME_INDEX 0 -#define HEADER_INDEX 1 -#define COND_INDEX 2 -#define RETTYPE_INDEX 3 -#define PARM1_INDEX 4 - /**************************************************************************** * Private Data ****************************************************************************/ -static bool g_debug; static bool g_inline; -static char g_line[LINESIZE+1]; -static char g_parm[MAX_FIELDS][MAX_PARMSIZE]; static FILE *g_stubstream; -static int g_lineno; /**************************************************************************** * Private Functions ****************************************************************************/ -static char *skip_space(char *ptr) -{ - while (*ptr && isspace(*ptr)) ptr++; - return ptr; -} - -static char *read_line(FILE *stream) -{ - char *ptr; - - for (;;) - { - g_line[LINESIZE] = '\0'; - if (!fgets(g_line, LINESIZE, stream)) - { - return NULL; - } - else - { - g_lineno++; - if (g_debug) - { - printf("Line: %s\n", g_line); - } - - ptr = skip_space(g_line); - if (*ptr && *ptr != '#' && *ptr != '\n') - { - return ptr; - } - } - } -} - -static char *copy_parm(char *src, char *dest) -{ - char *start = src; - int i; - - for (i = 0; i < MAX_PARMSIZE; i++) - { - if (*src == '"') - { - *dest = '\0'; - return src; - } - else if (*src == '\n' || *src == '\0') - { - fprintf(stderr, "%d: Unexpected end of line: \"%s\"\n", g_lineno, start); - exit(4); - } - else - { - *dest++ = *src++; - } - } - - fprintf(stderr, "%d: Parameter too long: \"%s\"\n", g_lineno, start); - exit(3); -} - -static char *find_parm(char *ptr) -{ - char *start = ptr; - - if (*ptr != '"') - { - fprintf(stderr, "%d: I'm confused: \"%s\"\n", g_lineno, start); - exit(5); - } - ptr++; - - ptr = skip_space(ptr); - if (*ptr == '\n' || *ptr == '\0') - { - return NULL; - } - else if (*ptr != ',') - { - fprintf(stderr, "%d: Expected ',': \"%s\"\n", g_lineno, start); - exit(6); - } - ptr++; - - ptr = skip_space(ptr); - if (*ptr != '"') - { - fprintf(stderr, "%d: Expected \": \"%s\"\n", g_lineno, start); - exit(7); - } - ptr++; - - return ptr; -} - -static int parse_csvline(char *ptr) -{ - int nparms; - int i; - - /* Format "arg1","arg2","arg3",... Spaces will be tolerated outside of the - * quotes. Any initial spaces have already been skipped so the first thing - * should be '"'. - */ - - if (*ptr != '"') - { - fprintf(stderr, "%d: Bad line: \"%s\"\n", g_lineno, g_line); - exit(2); - } - - ptr++; - nparms = 0; - - do - { - ptr = copy_parm(ptr, &g_parm[nparms][0]); - nparms++; - ptr = find_parm(ptr); - } - while (ptr); - - if (g_debug) - { - printf("Parameters: %d\n", nparms); - for (i = 0; i < nparms; i++) - { - printf(" Parm%d: \"%s\"\n", i+1, g_parm[i]); - } - } - return nparms; -} - static bool is_vararg(const char *type, int index, int nparms) { if (strcmp(type,"...") == 0) @@ -719,6 +571,7 @@ static void show_usage(const char *progname) fprintf(stderr, "\t-p : Generate proxies\n"); fprintf(stderr, "\t-s : Generate stubs\n"); fprintf(stderr, "\t-i : Generate proxies as static inline functions\n"); + fprintf(stderr, "\t-d : Enable debug output\n"); exit(1); } diff --git a/tools/mkversion.c b/tools/mkversion.c index f2086d13a5..32068df38b 100644 --- a/tools/mkversion.c +++ b/tools/mkversion.c @@ -2,7 +2,7 @@ * tools/mkversion.c * * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions