This creates a 8051 build that can run in 24Kb of RAM

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@26 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2007-03-01 21:05:55 +00:00
parent fb61b0b76b
commit bcd6ba97bd
52 changed files with 278 additions and 156 deletions
+11 -1
View File
@@ -46,7 +46,17 @@ is available that be used to build a NuttX-compatible arm-elf toolchain.</blockq
<h1>Memory Footprint</h1>
<p>To be provided</p>
<p>Details to be provided</p>
<p>
I have a complete build for an ARM7 target that includes most of the OS
features and a broad range of OS tests.
That builds to an executable that requires about 85Kb for .text, .data., and .bss.
</p>
<p>
I have a stripped down OS test for the 8051 target that requires only
24Kb.
</p>
<h1>Licensing</h1>
+1 -1
View File
@@ -108,7 +108,7 @@ clean:
done
$(MAKE) -C tools -f Makefile.mkconfig TOPDIR=$(TOPDIR) clean
$(MAKE) -C mm -f Makefile.test TOPDIR=$(TOPDIR) clean
rm -f $(BIN) $(BIN).rr $(BIN).stripped $(BIN).flashimage mm_test System.map *~
rm -f $(BIN) $(BIN).* mm_test *.map *~
distclean: clean clean_context
@for dir in $(SUBDIRS) ; do \
+3
View File
@@ -94,6 +94,7 @@ defconfig -- This is a configuration file similar to the Linux
o pthread_condtimedwait() depends on signals to wake
up waiting tasks.
CONFIG_DISABLE_CLOCK, CONFIG_DISABLE_PTHREAD.
CONFIG_DISABLE_SIGNALS, CONFIG_DISABLE_MQUEUE
Allow for architecture optimized implementations
@@ -108,6 +109,8 @@ defconfig -- This is a configuration file similar to the Linux
Sizes of configurable things (0 disables)
CONFIG_MAX_TASKS - The maximum number of simultaneously
active tasks. This value must be a power of two.
CONFIG_NPTHREAD_KEYS - The number of items of thread-
specific data that can be retained
CONFIG_NFILE_DESCRIPTORS - The maximum number of file
+5
View File
@@ -125,6 +125,8 @@ CONFIG_DEV_CONSOLE=y
# o pthread_condtimedwait() depends on signals to wake
# up waiting tasks.
#
CONFIG_DISABLE_CLOCK=n
CONFIG_DISABLE_PTHREAD=n
CONFIG_DISABLE_SIGNALS=n
CONFIG_DISABLE_MQUEUE=n
@@ -158,6 +160,8 @@ CONFIG_RRLOAD_BINARY=y
#
# Sizes of configurable things (0 disables)
#
# CONFIG_MAX_TASKS - The maximum number of simultaneously
# active tasks. This value must be a power of two.
# CONFIG_NPTHREAD_KEYS - The number of items of thread-
# specific data that can be retained
# CONFIG_NFILE_DESCRIPTORS - The maximum number of file
@@ -180,6 +184,7 @@ CONFIG_RRLOAD_BINARY=y
# structures. The system manages a pool of preallocated
# watchdog structures to minimize dynamic allocations
#
CONFIG_MAX_TASKS=64
CONFIG_NPTHREAD_KEYS=4
CONFIG_NFILE_DESCRIPTORS=32
CONFIG_NFILE_STREAMS=16
+5
View File
@@ -92,6 +92,8 @@ CONFIG_DEV_CONSOLE=y
# o pthread_condtimedwait() depends on signals to wake
# up waiting tasks.
#
CONFIG_DISABLE_CLOCK=n
CONFIG_DISABLE_PTHREAD=n
CONFIG_DISABLE_SIGNALS=n
CONFIG_DISABLE_MQUEUE=n
@@ -125,6 +127,8 @@ CONFIG_RRLOAD_BINARY=n
#
# Sizes of configurable things (0 disables)
#
# CONFIG_MAX_TASKS - The maximum number of simultaneously
# active tasks. This value must be a power of two.
# CONFIG_NPTHREAD_KEYS - The number of items of thread-
# specific data that can be retained
# CONFIG_NFILE_DESCRIPTORS - The maximum number of file
@@ -147,6 +151,7 @@ CONFIG_RRLOAD_BINARY=n
# structures. The system manages a pool of preallocated
# watchdog structures to minimize dynamic allocations
#
CONFIG_MAX_TASKS=64
CONFIG_NPTHREAD_KEYS=4
CONFIG_NFILE_DESCRIPTORS=32
CONFIG_NFILE_STREAMS=16
+3 -3
View File
@@ -61,11 +61,11 @@ static ssize_t devnull_write(struct file *, const char *, size_t);
static struct file_operations devnull_fops =
{
NULL, /* open */
NULL, /* close */
0, /* open */
0, /* close */
devnull_read, /* read */
devnull_write, /* write */
NULL /* ioctl */
0 /* ioctl */
};
/************************************************************
+10 -2
View File
@@ -40,13 +40,21 @@ MKDEP = $(TOPDIR)/tools/mkdeps.sh
ASRCS =
AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = main.c dev_null.c mutex.c cancel.c sem.c cond.c
CSRCS = main.c dev_null.c
ifneq ($(CONFIG_DISABLE_PTHREAD),y)
CSRCS += cancel.c cond.c mutex.c sem.c
endif
ifneq ($(CONFIG_DISABLE_SIGNALS),y)
CSRCS += timedwait.c sighand.c
CSRCS += sighand.c
ifneq ($(CONFIG_DISABLE_PTHREAD),y)
CSRCS += timedwait.c
endif
endif
ifneq ($(CONFIG_DISABLE_MQUEUE),y)
ifneq ($(CONFIG_DISABLE_PTHREAD),y)
CSRCS += mqueue.c
endif
endif
COBJS = $(CSRCS:.c=$(OBJEXT))
+8 -4
View File
@@ -50,7 +50,9 @@
* Private Data
************************************************************/
static char buffer[1024];
#if CONFIG_NFILE_DESCRIPTORS > 0
static FAR char buffer[1024];
/************************************************************
* Public Functions
@@ -64,14 +66,14 @@ int dev_null(void)
fd = open("/dev/null", O_RDWR);
if (fd < 0)
{
fprintf(stderr, "dev_null: Failed to open /dev/null\n");
printf("dev_null: ERROR Failed to open /dev/null\n");
return -1;
}
nbytes = read(fd, buffer, 1024);
if (nbytes < 0)
{
fprintf(stderr, "dev_null: Failed to read from /dev/null\n");
printf("dev_null: ERROR Failed to read from /dev/null\n");
close(fd);
return -1;
}
@@ -80,7 +82,7 @@ int dev_null(void)
nbytes = write(fd, buffer, 1024);
if (nbytes < 0)
{
fprintf(stderr, "dev_null: Failed to write to /dev/null\n");
printf("dev_null: ERROR Failed to write to /dev/null\n");
close(fd);
return -1;
}
@@ -89,3 +91,5 @@ int dev_null(void)
close(fd);
return 0;
}
#endif /*CONFIG_NFILE_DESCRIPTORS */
+27 -7
View File
@@ -64,8 +64,10 @@ static FAR char arg2[] = "Arg2";
static FAR char arg3[] = "Arg3";
static FAR char arg4[] = "Arg4";
#if CONFIG_NFILE_DESCRIPTORS > 0
static char write_data1[] = "Standard I/O Check: write fd=1\n";
static char write_data2[] = "Standard I/O Check: write fd=2\n";
#endif
static char *args[NARGS] = { arg1, arg2, arg3, arg4 };
/************************************************************
@@ -82,8 +84,8 @@ static int user_main(int argc, char *argv[])
if (argc != NARGS + 1)
{
fprintf(stderr, "user_main: Error expected argc=%d got argc=%d\n",
NARGS+1, argc);
printf("user_main: Error expected argc=%d got argc=%d\n",
NARGS+1, argc);
}
for (i = 0; i <= NARGS; i++)
@@ -95,38 +97,48 @@ static int user_main(int argc, char *argv[])
{
if (strcmp(argv[i], args[i-1]) != 0)
{
fprintf(stderr, "user_main: ERROR argv[%d]: Expected \"%s\" found \"%s\"\n",
i, argv[i], args[i-1]);
printf("user_main: ERROR argv[%d]: Expected \"%s\" found \"%s\"\n",
i, argv[i], args[i-1]);
}
}
#if CONFIG_NFILE_DESCRIPTORS > 0
/* Checkout /dev/null */
dev_null();
#endif
#ifndef CONFIG_DISABLE_PTHREAD
/* Verify pthreads and pthread mutex */
mutex_test();
#endif
#ifndef CONFIG_DISABLE_PTHREAD
/* Verify pthread cancellation */
cancel_test();
#endif
#ifndef CONFIG_DISABLE_PTHREAD
/* Verify pthreads and semaphores */
sem_test();
#endif
#ifndef CONFIG_DISABLE_PTHREAD
/* Verify pthreads and condition variables */
cond_test();
#endif
#ifndef CONFIG_DISABLE_SIGNALS
#if !defined(CONFIG_DISABLE_SIGNALS) && !defined(CONFIG_DISABLE_PTHREAD)
/* Verify pthreads and condition variable timed waits */
timedwait_test();
#endif
#ifndef CONFIG_DISABLE_MQUEUE
#if !defined(CONFIG_DISABLE_MQUEUE) && !defined(CONFIG_DISABLE_PTHREAD)
/* Verify pthreads and message queues */
mqueue_test();
@@ -165,10 +177,17 @@ int user_start(int parm1, int parm2, int parm3, int parm4)
/* Verify that we can communicate */
#if CONFIG_NFILE_DESCRIPTORS > 0
write(1, write_data1, sizeof(write_data1));
#endif
printf("user_start: Standard I/O Check: printf\n");
#if CONFIG_NFILE_DESCRIPTORS > 1
write(2, write_data2, sizeof(write_data2));
#endif
#if CONFIG_NFILE_STREAMS > 0
fprintf(stderr, "user_start: Standard I/O Check: fprintf to stderr\n");
#endif
/* Verify that we can spawn a new task */
@@ -176,11 +195,12 @@ int user_start(int parm1, int parm2, int parm3, int parm4)
arg1, arg2, arg3, arg4);
if (result == ERROR)
{
fprintf(stderr, "user_start: Failed to start user_main\n");
printf("user_start: ERROR Failed to start user_main\n");
}
else
{
printf("user_start: Started user_main at PID=%d\n", result);
}
return 0;
}
+2 -9
View File
@@ -33,31 +33,24 @@
*
************************************************************/
/************************************************************
* Compilation Switches
************************************************************/
/************************************************************
* Included Files
************************************************************/
#include <nuttx/config.h>
#if CONFIG_NFILE_DESCRIPTORS >0
#include <sys/types.h>
#include <stdio.h>
#include <sched.h>
#include <errno.h>
#include <nuttx/fs.h>
#include "fs_internal.h"
/************************************************************
* Global Functions
************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int close(int fd)
{
FAR struct filelist *list;
+2 -2
View File
@@ -43,8 +43,6 @@
#include <nuttx/config.h>
#if CONFIG_NFILE_DESCRIPTORS > 0
#include <sys/types.h>
#include <unistd.h>
#include <sched.h>
@@ -67,6 +65,8 @@
* Global Functions
************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int dup(int fildes)
{
FAR struct filelist *list;
+3 -5
View File
@@ -38,10 +38,6 @@
************************************************************/
#include <nuttx/config.h>
#if CONFIG_NFILE_DESCRIPTORS >0
#include <string.h>
#include <semaphore.h>
#include <assert.h>
@@ -49,7 +45,6 @@
#include <errno.h>
#include <nuttx/fs.h>
#include <nuttx/kmalloc.h>
#include "fs_internal.h"
/************************************************************
@@ -72,6 +67,8 @@
* Private Functions
************************************************************/
#if CONFIG_NFILE_DESCRIPTORS >0
static void _files_semtake(FAR struct filelist *list)
{
/* Take the semaphore (perhaps waiting) */
@@ -267,4 +264,5 @@ void files_release(int filedes)
}
}
}
#endif /* CONFIG_NFILE_DESCRIPTORS */
+4
View File
@@ -51,6 +51,8 @@
* Global Functions
************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int ioctl(int fd, int req, unsigned long arg)
{
FAR struct filelist *list;
@@ -83,3 +85,5 @@ int ioctl(int fd, int req, unsigned long arg)
}
return ret;
}
#endif /* CONFIG_NFILE_DESCRIPTORS */
+2 -7
View File
@@ -42,22 +42,15 @@
************************************************************/
#include <nuttx/config.h>
#if CONFIG_NFILE_DESCRIPTORS >0
#include <sys/types.h>
#include <stdio.h>
#include <sched.h>
#include <errno.h>
#ifdef CONFIG_FILE_MODE
#include <stdarg.h>
#endif
#include <nuttx/fs.h>
#include <errno.h>
#include "fs_internal.h"
/************************************************************
@@ -68,6 +61,8 @@
* Public Functions
************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int inode_checkflags(FAR struct inode *inode, int oflags)
{
if (((oflags & O_RDOK) != 0 && !inode->i_ops->read) ||
+2 -3
View File
@@ -42,9 +42,6 @@
************************************************************/
#include <nuttx/config.h>
#if CONFIG_NFILE_DESCRIPTORS >0
#include <sys/types.h>
#include <stdio.h>
#include <sched.h>
@@ -55,6 +52,8 @@
* Global Functions
************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int read(int fd, void *buf, unsigned int nbytes)
{
FAR struct filelist *list;
+2 -3
View File
@@ -42,9 +42,6 @@
************************************************************/
#include <nuttx/config.h>
#if CONFIG_NFILE_DESCRIPTORS >0
#include <sys/types.h>
#include <stdio.h>
#include <sched.h>
@@ -55,6 +52,8 @@
* Global Functions
************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int write(int fd, const void *buf, unsigned int nbytes)
{
FAR struct filelist *list;
+3
View File
@@ -74,6 +74,7 @@
# define FAR
# define NEAR
# define DSEG
# define CODE
/* Select the large, 32-bit addressing model */
@@ -127,6 +128,7 @@
#define FAR __xdata
#define NEAR __data
#define CODE __code
#if defined(SDCC_MODEL_SMALL)
# define DSEG __data
@@ -167,6 +169,7 @@
# define FAR
# define NEAR
# define DSEG
# define CODE
# undef CONFIG_SMALL_MEMORY
# undef CONFIG_HAVE_INLINE
+2 -2
View File
@@ -98,7 +98,7 @@ typedef enum tstate_e
TSTATE_TASK_PENDING = 1, /* READY_TO_RUN - Pending preemption unlock */
TSTATE_TASK_READYTORUN = 2, /* READY-TO-RUN - But not running */
TSTATE_TASK_RUNNING = 3, /* READY_TO_RUN - Aand running */
TSTATE_TASK_RUNNING = 3, /* READY_TO_RUN - And running */
TSTATE_TASK_INACTIVE = 4, /* BLOCKED - Initialized but not yet activated */
TSTATE_WAIT_SEM = 5, /* BLOCKED - Waiting for a semaphore */
@@ -200,7 +200,7 @@ struct _TCB
/* POSIX thread Specific Data ***************************************/
#if CONFIG_NPTHREAD_KEYS > 0
#if !defined(CONFIG_DISABLE_PTHREAD) && CONFIG_NPTHREAD_KEYS > 0
FAR void *pthread_data[CONFIG_NPTHREAD_KEYS];
#endif
+4 -4
View File
@@ -76,10 +76,10 @@ EXTERN size_t strcspn(const char *, const char *);
EXTERN char *strstr(const char *, const char *);
EXTERN char *strtok(FAR char *, const char *);
EXTERN void *memset(void *s, int c, size_t n);
EXTERN void *memcpy(void *dest, const void *src, size_t n);
EXTERN int memcmp(const void *s1, const void *s2, size_t n);
EXTERN void *memmove(void *dest, const void *src, size_t count);
EXTERN void *memset(FAR void *s, int c, size_t n);
EXTERN void *memcpy(FAR void *dest, FAR const void *src, size_t n);
EXTERN int memcmp(FAR const void *s1, FAR const void *s2, size_t n);
EXTERN void *memmove(FAR void *dest, FAR const void *src, size_t count);
#ifndef CONFIG_ARCH_BZERO
# define bzero(s,n) (void)memset(s,0,n)
+2 -3
View File
@@ -42,9 +42,6 @@
************************************************************/
#include <nuttx/config.h>
#if CONFIG_NFILE_STREAMS > 0
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
@@ -55,6 +52,8 @@
* Global Functions
************************************************************/
#if CONFIG_NFILE_STREAMS > 0
int fclose(FILE *stream)
{
int ret = OK;
+9 -5
View File
@@ -42,9 +42,6 @@
************************************************************/
#include <nuttx/config.h> /* for CONFIG_STDIO_BUFFER_SIZE */
#if CONFIG_NFILE_STREAMS > 0
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs.h>
@@ -83,10 +80,13 @@
************************************************************/
/************************************************************
* fflush
* Name: lib_fflushall
*
* Description:
* Called by the OS when a task exits
************************************************************/
/* Called by the OS when a task exits */
#if CONFIG_NFILE_STREAMS > 0
void lib_flushall(FAR struct streamlist *list)
{
@@ -114,6 +114,10 @@ void lib_flushall(FAR struct streamlist *list)
}
}
/************************************************************
* Name: fflush
************************************************************/
int fflush(FILE *stream)
{
#if CONFIG_STDIO_BUFFER_SIZE > 0
+6 -4
View File
@@ -42,21 +42,19 @@
************************************************************/
#include <nuttx/config.h>
#if CONFIG_NFILE_STREAMS > 0
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "lib_internal.h"
/************************************************************
* Private Functions
************************************************************/
#if CONFIG_NFILE_STREAMS > 0
static int lib_mode2oflags(const char *mode)
{
int oflags = 0;
@@ -126,10 +124,14 @@ static int lib_mode2oflags(const char *mode)
return oflags;
}
#endif /* CONFIG_NFILE_STREAMS */
/************************************************************
* Public Functions
************************************************************/
#if CONFIG_NFILE_STREAMS > 0
FAR struct file_struct *lib_fdopen(int fd, const char *mode,
FAR struct filelist *flist,
FAR struct streamlist *slist)
+5
View File
@@ -79,6 +79,8 @@
* fwrite
************************************************************/
#if CONFIG_NFILE_STREAMS > 0
size_t fread(void *ptr, size_t size, size_t n_items, FILE *stream)
{
size_t full_size = n_items * (size_t)size;
@@ -96,3 +98,6 @@ size_t fread(void *ptr, size_t size, size_t n_items, FILE *stream)
}
return items_read;
}
#endif /* CONFIG_NFILE_STREAMS */
+6 -1
View File
@@ -57,6 +57,7 @@
* Private Functions
************************************************************/
#if CONFIG_NFILE_STREAMS > 0
static void _lib_semtake(FAR struct streamlist *list)
{
/* Take the semaphore (perhaps waiting) */
@@ -71,7 +72,11 @@ static void _lib_semtake(FAR struct streamlist *list)
}
}
#define _lib_semgive(list) sem_post(&list->sl_sem)
# define _lib_semgive(list) sem_post(&list->sl_sem)
#else
# define _lib_semtake(list)
# define _lib_semgive(list)
#endif
/************************************************************
* Public Functions
+8 -1
View File
@@ -138,6 +138,14 @@ extern int lib_sprintf (struct lib_stream_s *obj,
extern int lib_vsprintf(struct lib_stream_s *obj,
const char *src, va_list ap);
/* Defined lib_rawprintf.c */
extern int lib_rawvprintf(const char *src, va_list ap);
/* Defined lib_lowprintf.c */
extern int lib_lowvprintf(const char *src, va_list ap);
/* Defined in lib_libwrite.c */
extern ssize_t lib_fwrite(const void *ptr, size_t count, FILE *stream);
@@ -158,5 +166,4 @@ extern void lib_give_semaphore(FAR struct file_struct *stream);
extern int lib_getbase(const char *nptr, const char **endptr);
#endif /* __LIB_INTERNAL_H */
+4
View File
@@ -83,6 +83,8 @@
* lib_fread
************************************************************/
#if CONFIG_NFILE_STREAMS > 0
ssize_t lib_fread(void *ptr, size_t count, FILE *stream)
{
unsigned char *dest = (unsigned char*)ptr;
@@ -255,3 +257,5 @@ ssize_t lib_fread(void *ptr, size_t count, FILE *stream)
}
return bytes_read;
}
#endif /* CONFIG_NFILE_STREAMS */
+5 -1
View File
@@ -82,6 +82,8 @@
* lib_fwrite
************************************************************/
#if CONFIG_NFILE_STREAMS > 0
ssize_t lib_fwrite(const void *ptr, size_t count, FILE *stream)
#if CONFIG_STDIO_BUFFER_SIZE > 0
{
@@ -159,4 +161,6 @@ ssize_t lib_fwrite(const void *ptr, size_t count, FILE *stream)
{
return write(stream->fs_filedes, ptr, count);
}
#endif
#endif /* CONFIG_STDIO_BUFFER_SIZE */
#endif /* CONFIG_NFILE_STREAMS */
+23 -15
View File
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
#ifdef CONFIG_ARCH_LOWPUTC
#include <stdio.h>
#include <debug.h>
#include "lib_internal.h"
@@ -61,44 +58,55 @@
* Global Function Prototypes
************************************************************/
/**********************************************************
/************************************************************
* Global Constant Data
**********************************************************/
************************************************************/
/************************************************************
* Global Variables
************************************************************/
/**********************************************************
/************************************************************
* Private Constant Data
**********************************************************/
************************************************************/
/************************************************************
* Private Variables
**********************************************************/
************************************************************/
/************************************************************
* Global Functions
**********************************************************/
************************************************************/
/************************************************************
* lib_lowprintf
**********************************************************/
* Name: lib_lowvprintf
************************************************************/
int lib_lowprintf(const char *fmt, ...)
#ifdef CONFIG_ARCH_LOWPUTC
int lib_lowvprintf(const char *fmt, va_list ap)
{
struct lib_stream_s stream;
va_list ap;
int ret;
/* Wrap the stdout in a stream object and let lib_vsprintf
* do the work.
*/
lib_lowstream(&stream);
return lib_vsprintf(&stream, fmt, ap);
}
/************************************************************
* Name: lib_lowprintf
************************************************************/
int lib_lowprintf(const char *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
ret= lib_vsprintf(&stream, fmt, ap);
ret= lib_lowvprintf(fmt, ap);
va_end(ap);
return ret;
}
+1 -1
View File
@@ -50,7 +50,7 @@
************************************************************/
#ifndef CONFIG_ARCH_MEMCMP
int memcmp(const void *s1, const void *s2, size_t n)
int memcmp(FAR const void *s1, FAR const void *s2, size_t n)
{
unsigned char *p1 = (unsigned char *)s1;
unsigned char *p2 = (unsigned char *)s2;
+1 -1
View File
@@ -50,7 +50,7 @@
************************************************************/
#ifndef CONFIG_ARCH_MEMCPY
void *memcpy(void *dest, const void *src, size_t n)
void *memcpy(FAR void *dest, FAR const void *src, size_t n)
{
unsigned char *pout = (unsigned char*)dest;
unsigned char *pin = (unsigned char*)src;
+1 -1
View File
@@ -50,7 +50,7 @@
************************************************************/
#ifndef CONFIG_ARCH_MEMMOVE
void *memmove(void *dest, const void *src, size_t count)
void *memmove(FAR void *dest, FAR const void *src, size_t count)
{
char *tmp, *s;
if (dest <= src)
+1 -1
View File
@@ -50,7 +50,7 @@
************************************************************/
#ifndef CONFIG_ARCH_MEMSET
void *memset(void *s, int c, size_t n)
void *memset(FAR void *s, int c, size_t n)
{
unsigned char *p = (unsigned char*)s;
while (n-- > 0) *p++ = c;
+12 -9
View File
@@ -81,23 +81,26 @@
**********************************************************/
/************************************************************
* printf
* Name: printf
**********************************************************/
int printf(const char *fmt, ...)
{
struct lib_stdstream_s stdstream;
va_list ap;
int ret;
/* Wrap the stdout in a stream object and let lib_vsprintf
* do the work.
*/
lib_stdstream(&stdstream, stdout);
va_start(ap, fmt);
ret= lib_vsprintf(&stdstream.public, fmt, ap);
#if CONFIG_NFILE_STREAMS > 0
ret = vfprintf(stdout, fmt, ap);
#elif CONFIG_NFILE_DESCRIPTORS > 0
ret = lib_rawvprintf(fmt, ap);
#elif defined(CONFIG_ARCH_LOWPUTC)
ret = lib_lowvprintf(fmt, ap);
#else
# warning "printf has no data sink"
#endif
va_end(ap);
return ret;
}
+9 -2
View File
@@ -81,10 +81,15 @@
************************************************************/
/************************************************************
* puts
* Name: puts
*
* Description:
* puts() writes the string s and a trailing newline to
* stdout.
************************************************************/
/* puts() writes the string s and a trailing newline to stdout. */
#if CONFIG_NFILE_STREAMS > 0
int puts(const char *s)
{
int nwritten;
@@ -109,3 +114,5 @@ int puts(const char *s)
lib_give_semaphore(stdout);
return nput;
}
#endif /* CONFIG_NFILE_STREAMS */
+21 -12
View File
@@ -57,44 +57,53 @@
* Global Function Prototypes
************************************************************/
/**********************************************************
/************************************************************
* Global Constant Data
**********************************************************/
************************************************************/
/************************************************************
* Global Variables
************************************************************/
/**********************************************************
/************************************************************
* Private Constant Data
**********************************************************/
************************************************************/
/************************************************************
* Private Variables
**********************************************************/
************************************************************/
/************************************************************
* Global Functions
**********************************************************/
************************************************************/
/************************************************************
* lib_rawprintf
**********************************************************/
* Aame: lib_rawvprintf
************************************************************/
int lib_rawprintf(const char *fmt, ...)
int lib_rawvprintf(const char *fmt, va_list ap)
{
struct lib_rawstream_s rawstream;
va_list ap;
int ret;
/* Wrap the stdout in a stream object and let lib_vsprintf
* do the work.
*/
lib_rawstream(&rawstream, 1);
return lib_vsprintf(&rawstream.public, fmt, ap);
}
/************************************************************
* Name: lib_rawprintf
************************************************************/
int lib_rawprintf(const char *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
ret= lib_vsprintf(&rawstream.public, fmt, ap);
ret= lib_rawvprintf(fmt, ap);
va_end(ap);
return ret;
}
+4
View File
@@ -45,6 +45,8 @@
* Private Functions
************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
static void rawstream_putc(struct lib_stream_s *this, int ch)
{
struct lib_rawstream_s *rthis = (struct lib_rawstream_s *)this;
@@ -75,4 +77,6 @@ void lib_rawstream(struct lib_rawstream_s *rawstream, int fd)
rawstream->fd = fd;
}
#endif /* CONFIG_NFILE_DESCRIPTORS */
+2 -5
View File
@@ -42,17 +42,12 @@
************************************************************/
#include <nuttx/config.h>
#if CONFIG_NFILE_STREAMS > 0
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <semaphore.h>
#include <errno.h>
#include <nuttx/fs.h>
#include "lib_internal.h"
@@ -76,6 +71,8 @@
* Public Functions
************************************************************/
#if CONFIG_NFILE_STREAMS > 0
void stream_semtake(FAR struct streamlist *list)
{
/* Take the semaphore (perhaps waiting) */
+2 -2
View File
@@ -43,8 +43,6 @@
#include <nuttx/config.h>
#if CONFIG_NFILE_STREAMS > 0
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs.h>
@@ -90,6 +88,8 @@
* fgetc
**********************************************************/
#if CONFIG_NFILE_STREAMS > 0
int ungetc(int c, FILE *stream)
{
#if CONFIG_NUNGET_CHARS > 0
+5
View File
@@ -83,9 +83,14 @@
* vprintf
**********************************************************/
#if CONFIG_NFILE_STREAMS > 0
int vprintf(const char *fmt, va_list ap)
{
/* vfprintf into stdout */
return vfprintf(stdout, fmt, ap);
}
#endif /* CONFIG_NFILE_STREAMS */
+4 -1
View File
@@ -100,7 +100,10 @@ SEM_SRCS = sem_initialize.c sem_init.c sem_destroy.c\
IRQ_SRCS = irq_initialize.c irq_attach.c irq_dispatch.c irq_unexpectedisr.c
CSRCS = $(MISC_SRCS) $(TSK_SRCS) $(SCHED_SRCS) $(WDOG_SRCS) $(TIME_SRCS) \
$(PTHREAD_SRCS) $(SEM_SRCS) $(IRQ_SRCS)
$(SEM_SRCS) $(IRQ_SRCS)
ifneq ($(CONFIG_DISABLE_PTHREAD),y)
CSRCS += $(PTHREAD_SRCS)
endif
ifneq ($(CONFIG_DISABLE_SIGNALS),y)
CSRCS += $(SIGNAL_SRCS)
endif
+1 -1
View File
@@ -54,7 +54,7 @@
* Global Variables
************************************************************/
xcpt_t g_irqvector[NR_IRQS+1];
FAR xcpt_t g_irqvector[NR_IRQS+1];
/************************************************************
* Private Variables
+1 -1
View File
@@ -53,7 +53,7 @@
* Public Type Declarations
************************************************************/
extern xcpt_t g_irqvector[NR_IRQS+1];
extern FAR xcpt_t g_irqvector[NR_IRQS+1];
/************************************************************
* Public Variables
+7 -6
View File
@@ -85,14 +85,13 @@ enum os_crash_codes_e
/* Although task IDs can take the (positive, non-zero)
* range of pid_t, the number of tasks that will be supported
* at any one time is (artificially) limited by the following
* definition. Limiting the number of tasks speeds certain
* at any one time is (artificially) limited by the CONFIG_MAX_TASKS
* configuration setting. Limiting the number of tasks speeds certain
* OS functions (this is the only limitation in the number of
* tasks built into the design).
*/
#define MAX_TASKS_ALLOWED 64
#define MAX_TASKS_MASK 0x3f
#define MAX_TASKS_MASK (CONFIG_MAX_TASKS-1)
#define PIDHASH(pid) ((pid) & MAX_TASKS_MASK)
/* Stubs used when there are no file descriptors */
@@ -216,14 +215,16 @@ extern sq_queue_t g_delayeddeallocations;
extern pid_t g_lastpid;
/* The following hash table is used for two things:
*
* 1. This hash table greatly speeds the determination of
* a new unique process ID for a task, and
* 2. Is used to quickly map a process ID into a TCB.
*
* It has the side effects of using more memory and limiting
* the number of tasks to MAX_TASKS_ALLOWED.
* the number of tasks to CONFIG_MAX_TASKS.
*/
extern pidhash_t g_pidhash[MAX_TASKS_ALLOWED];
extern pidhash_t g_pidhash[CONFIG_MAX_TASKS];
/* This is a table of task lists. This table is indexed by
* the task state enumeration type (tstate_t) and provides
+18 -6
View File
@@ -53,7 +53,9 @@
#ifndef CONFIG_DISABLE_MQUEUE
# include "mq_internal.h"
#endif
#include "pthread_internal.h"
#ifndef CONFIG_DISABLE_PTHREAD
# include "pthread_internal.h"
#endif
#include "clock_internal.h"
#include "irq_internal.h"
@@ -140,14 +142,16 @@ sq_queue_t g_delayeddeallocations;
pid_t g_lastpid;
/* The following hash table is used for two things:
*
* 1. This hash table greatly speeds the determination of
* a new unique process ID for a task, and
* 2. Is used to quickly map a process ID into a TCB.
* It has the side effects of using more memory and limiting
* the number of tasks to MAX_TASKS_ALLOWED.
*
* the number of tasks to CONFIG_MAX_TASKS.
*/
pidhash_t g_pidhash[MAX_TASKS_ALLOWED];
pidhash_t g_pidhash[CONFIG_MAX_TASKS];
/* This is a table of task lists. This table is indexed by
* the task state enumeration type (tstate_t) and provides
@@ -185,6 +189,10 @@ const tasklist_t g_tasklisttable[NUM_TASK_STATES] =
static FAR _TCB g_idletcb;
/* This is the name of the idle task */
static FAR char g_idlename[] = "Idle Task";
/************************************************************
* Private Function Prototypes
************************************************************/
@@ -225,7 +233,7 @@ void os_start(void)
/* Initialize the logic that determine unique process IDs. */
g_lastpid = 0;
for (i = 0; i < MAX_TASKS_ALLOWED; i++)
for (i = 0; i < CONFIG_MAX_TASKS; i++)
{
g_pidhash[i].tcb = NULL;
g_pidhash[i].pid = INVALID_PROCESS_ID;
@@ -248,10 +256,10 @@ void os_start(void)
g_idletcb.entry.main = (main_t)os_start;
#if CONFIG_TASK_NAME_SIZE > 0
strncpy(g_idletcb.name, "Idle Task", CONFIG_TASK_NAME_SIZE-1);
strncpy(g_idletcb.name, g_idlename, CONFIG_TASK_NAME_SIZE-1);
g_idletcb.argv[0] = g_idletcb.name;
#else
g_idletcb.argv[0] = "Idle Task";
g_idletcb.argv[0] = g_idlename;
#endif /* CONFIG_TASK_NAME_SIZE */
/* Then add the idle task's TCB to the head of the ready to run list */
@@ -347,21 +355,25 @@ void os_start(void)
/* Initialize the thread-specific data facility (if in link) */
#ifndef CONFIG_DISABLE_PTHREAD
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
if (pthread_initialize != NULL)
#endif
{
pthread_initialize();
}
#endif
/* Initialize the file system (needed to support device drivers) */
#if CONFIG_NFILE_DESCRIPTORS > 0
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
if (fs_initialize != NULL)
#endif
{
fs_initialize();
}
#endif
/* The processor specific details of running the operating system
* will be handled here. Such things as setting up interrupt
+2 -3
View File
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
#if CONFIG_NFILE_DESCRIPTORS > 0
#include <sched.h>
#include "os_internal.h"
@@ -68,6 +65,8 @@
*
************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
FAR struct filelist *sched_getfiles(void)
{
FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
+2 -3
View File
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
#include <sched.h>
#include "os_internal.h"
@@ -68,6 +65,8 @@
*
************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
FAR struct streamlist *sched_getstreams(void)
{
FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
+2 -3
View File
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
#if CONFIG_NFILE_DESCRIPTORS > 0
#include <sched.h>
#include <nuttx/fs.h>
#include <nuttx/lib.h>
@@ -69,6 +66,8 @@
*
************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int sched_releasefiles(_TCB *tcb)
{
if (tcb)
+2 -3
View File
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
#if CONFIG_NFILE_DESCRIPTORS > 0
#include <stdio.h>
#include <unistd.h>
#include <sched.h>
@@ -71,6 +68,8 @@
*
************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int sched_setupidlefiles(FAR _TCB *tcb)
{
int fd;
+2 -3
View File
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
#if CONFIG_NFILE_DESCRIPTORS > 0
#include <sched.h>
#include <nuttx/fs.h>
#include <nuttx/lib.h>
@@ -71,6 +68,8 @@
*
************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int sched_setuppthreadfiles(FAR _TCB *tcb)
{
FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
+2 -3
View File
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
#include <sched.h>
#include <nuttx/fs.h>
#include <nuttx/lib.h>
@@ -53,6 +50,8 @@
* Public Functions
************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
int sched_setupstreams(FAR _TCB *tcb)
{
/* Allocate file strems for the TCB */

Some files were not shown because too many files have changed in this diff Show More