Sim target no longer uses Linux syscalls; works with Cygwin
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@759 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
93cc62b645
commit
2a8f3fa3a3
@ -45,24 +45,27 @@ CSRCS = up_initialize.c up_idle.c up_interruptcontext.c \
|
||||
up_releasepending.c up_reprioritizertr.c \
|
||||
up_exit.c up_schedulesigaction.c up_allocateheap.c \
|
||||
up_devconsole.c
|
||||
HOSTSRCS = up_stdio.c
|
||||
ifeq ($(CONFIG_FS_FAT),y)
|
||||
CSRCS += up_blockdevice.c up_deviceimage.c
|
||||
endif
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
CSRCS += up_uipdriver.c
|
||||
SPECSRCS += up_tapdev.c
|
||||
HOSTSRCS += up_tapdev.c
|
||||
endif
|
||||
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
SPECOBJS = $(SPECSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS) $(SPECSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS) $(SPECOBJS)
|
||||
NXOBJS = $(AOBJS) $(COBJS)
|
||||
HOSTOBJS = $(HOSTSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS) $(HOSTSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS) $(HOSTOBJS)
|
||||
|
||||
LDFLAGS = $(ARCHSCRIPT)
|
||||
STDLIBS = -lc
|
||||
STDLIBS = -lc
|
||||
ifeq ($(CONFIG_FS_FAT),y)
|
||||
STDLIBS += -lz
|
||||
STDLIBS += -lz
|
||||
endif
|
||||
|
||||
LINKOBJS = up_head$(OBJEXT)
|
||||
@ -78,18 +81,35 @@ $(AOBJS): %$(OBJEXT): %.S
|
||||
$(COBJS) $(LINKOBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
$(SPECOBJS): %$(OBJEXT): %.c
|
||||
$(HOSTOBJS): %$(OBJEXT): %.c
|
||||
$(CC) -c $(HOSTCFLAGS) $< -o $@
|
||||
|
||||
libarch$(LIBEXT): $(OBJS)
|
||||
@( for obj in $(OBJS) ; do \
|
||||
# The architecture-specific library
|
||||
libarch$(LIBEXT): $(NXOBJS)
|
||||
@( for obj in $(NXOBJS) ; do \
|
||||
$(call ARCHIVE, $@, $${obj}); \
|
||||
done ; )
|
||||
|
||||
nuttx$(EXEEXT): $(LINKOBJS)
|
||||
# A partially linked object containing only NuttX code (no interface to host OS)
|
||||
# Change the names of most symbols that conflict with libc symbols.
|
||||
|
||||
Linux-names.dat: nuttx-names.dat
|
||||
@cp $^ $@
|
||||
|
||||
Cygwin-names.dat: nuttx-names.dat
|
||||
@cat $^ | sed -e "s/^/_/g" >$@
|
||||
|
||||
nuttx.rel : $(HOSTOS)-names.dat $(LINKOBJS)
|
||||
@echo "LD: nuttx.rel"
|
||||
@$(LD) -r $(LDFLAGS) $(LDPATHES) -o $@ $(LINKOBJS) --start-group $(LDLIBS) --end-group $(EXTRA_LIBS)
|
||||
$(OBJCOPY) --redefine-syms=$(HOSTOS)-names.dat nuttx.rel
|
||||
|
||||
# Generate the final NuttX binary by linking the host-specific objects with the NuttX
|
||||
# specific objects (with munged names)
|
||||
|
||||
nuttx$(EXEEXT): nuttx.rel $(HOSTOBJS)
|
||||
@echo "LD: nuttx$(EXEEXT)"
|
||||
@$(CC) $(LDFLAGS) $(LDPATHES) -o $(TOPDIR)/$@ $(LINKOBJS) \
|
||||
-Wl,--start-group $(LDLIBS) -Wl,--end-group $(STDLIBS) $(EXTRA_LIBS)
|
||||
@$(CC) $(LDFLAGS) $(LDPATHES) -o $(TOPDIR)/$@ nuttx.rel $(HOSTOBJS) $(STDLIBS)
|
||||
@$(NM) $(TOPDIR)/$@ | \
|
||||
grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
|
||||
sort > $(TOPDIR)/System.map
|
||||
@ -101,7 +121,8 @@ nuttx$(EXEEXT): $(LINKOBJS)
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
@rm -f libarch$(LIBEXT) *~ .*.swp
|
||||
@rm -f nuttx.rel libarch$(LIBEXT) *~ .*.swp
|
||||
@rm -f nuttx.rel Linux-names.dat Cygwin-names.dat
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
|
34
arch/sim/src/nuttx-names.dat
Normal file
34
arch/sim/src/nuttx-names.dat
Normal file
@ -0,0 +1,34 @@
|
||||
calloc NXcalloc
|
||||
close NXclose
|
||||
closedir NXclosedir
|
||||
dup NXdup
|
||||
free NXfree
|
||||
fclose NXfclose
|
||||
fopen NXfopen
|
||||
fputc NXfputc
|
||||
fread NXfread
|
||||
fwrite NXfwrite
|
||||
fsync NXfsync
|
||||
gettimeofday NXgettimeofday
|
||||
ioctl NXioctl
|
||||
lseek NXlseek
|
||||
malloc NXmalloc
|
||||
malloc_init NXmalloc_init
|
||||
mkdir NXmkdir
|
||||
mount NXmount
|
||||
open NXopen
|
||||
opendir NXopendir
|
||||
read NXread
|
||||
realloc NXrealloc
|
||||
rewinddir NXrewinddir
|
||||
rmdir NXrmdir
|
||||
seekdir NXseekdir
|
||||
select NXselect
|
||||
socket NXsocket
|
||||
stat NXstat
|
||||
statfs NXstatfs
|
||||
system NXsystem
|
||||
umount NXumount
|
||||
unlink NXunlink
|
||||
write NXwrite
|
||||
zmalloc NXzmalloc
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_allocateheap.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
@ -45,25 +45,25 @@
|
||||
#include "os_internal.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static ubyte sim_heap[SIM_HEAP_SIZE];
|
||||
|
||||
/************************************************************
|
||||
* Private Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_allocate_heap
|
||||
*
|
||||
* Description:
|
||||
@ -72,7 +72,7 @@ static ubyte sim_heap[SIM_HEAP_SIZE];
|
||||
* are not defined, then this function will be called to
|
||||
* dynamically set aside the heap region.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
void up_allocate_heap(void **heap_start, size_t *heap_size)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_blocktask.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
@ -45,23 +45,23 @@
|
||||
#include "os_internal.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Private Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_block_task
|
||||
*
|
||||
* Description:
|
||||
@ -79,7 +79,7 @@
|
||||
* task_state: Specifies which waiting task list should be
|
||||
* hold the blocked task TCB.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
void up_block_task(_TCB *tcb, tstate_t task_state)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_createstack.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
@ -43,23 +43,23 @@
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Private Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_create_stack
|
||||
*
|
||||
* Description:
|
||||
@ -79,7 +79,7 @@
|
||||
* stack_size: The requested stack size. At least this much
|
||||
* must be allocated.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
STATUS up_create_stack(_TCB *tcb, size_t stack_size)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_devconsole.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@ -31,43 +31,32 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(linux) && !defined(__CYGWIN__)
|
||||
# error "Sorry, this will only work with Linux"
|
||||
#else
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#define READ 3
|
||||
#define WRITE 4
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t devconsole_read(struct file *, char *, size_t);
|
||||
static ssize_t devconsole_write(struct file *, const char *, size_t);
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static struct file_operations devconsole_fops =
|
||||
{
|
||||
@ -75,69 +64,26 @@ static struct file_operations devconsole_fops =
|
||||
.write = devconsole_write,
|
||||
};
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static inline int up_read(int fd, void* buf, size_t count)
|
||||
|
||||
static ssize_t devconsole_read(struct file *filp, char *buffer, size_t len)
|
||||
{
|
||||
uint32 result;
|
||||
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (result) \
|
||||
: "0" (READ), "b" ((uint32)(fd)), "c" ((uint32)(buf)), "d" ((uint32)(count)) \
|
||||
: "memory");
|
||||
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
static inline int up_write(int fd, const void* buf, size_t count)
|
||||
{
|
||||
uint32 result;
|
||||
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (result) \
|
||||
: "0" (WRITE), "b" ((uint32)(fd)), "c" ((uint32)(buf)), "d" ((uint32)(count)) \
|
||||
: "memory");
|
||||
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
static inline int up_check_result(int result)
|
||||
{
|
||||
if (result >= (uint32)(-(128 + 1)))
|
||||
{
|
||||
*get_errno_ptr() = -result;
|
||||
result = ERROR;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static ssize_t devconsole_read(struct file *filp, char *buffer, size_t len)
|
||||
{
|
||||
return up_check_result(up_read(1, buffer, len));
|
||||
return up_hostread(buffer, len);
|
||||
}
|
||||
|
||||
static ssize_t devconsole_write(struct file *filp, const char *buffer, size_t len)
|
||||
{
|
||||
return up_check_result(up_write(1, buffer, len));
|
||||
return up_hostwrite(buffer, len);
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
void up_devconsole(void)
|
||||
{
|
||||
(void)register_driver("/dev/console", &devconsole_fops, 0666, NULL);
|
||||
}
|
||||
|
||||
int up_putc(int ch)
|
||||
{
|
||||
char b = ch;
|
||||
(void)up_write(1, &b, 1);
|
||||
return ch;
|
||||
}
|
||||
|
||||
#endif /* linux */
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_head.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
@ -45,15 +45,15 @@
|
||||
#include <nuttx/init.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static jmp_buf sim_abort;
|
||||
|
||||
/************************************************************
|
||||
* Global Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_idle.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -31,34 +31,34 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Private Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_idle
|
||||
*
|
||||
* Description:
|
||||
@ -71,7 +71,7 @@
|
||||
* this is where power management operations might be
|
||||
* performed.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
void up_idle(void)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_initialize.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
@ -43,23 +43,23 @@
|
||||
#include <nuttx/fs.h>
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Private Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_initialize
|
||||
*
|
||||
* Description:
|
||||
@ -77,7 +77,7 @@
|
||||
* libraries have been initialized. OS services and driver
|
||||
* services are available.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
void up_initialize(void)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_initialstate.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
@ -43,23 +43,23 @@
|
||||
#include <nuttx/arch.h>
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Private Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_initial_state
|
||||
*
|
||||
* Description:
|
||||
@ -71,7 +71,7 @@
|
||||
* and/or stack so that execution will begin at tcb->start
|
||||
* on the next context switch.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
void up_initial_state(_TCB *tcb)
|
||||
{
|
||||
|
@ -107,6 +107,11 @@ extern void up_registerblockdevice(void);
|
||||
|
||||
extern char *up_deviceimage(void);
|
||||
|
||||
/* up_stdio.c *************************************************************/
|
||||
|
||||
extern size_t up_hostread(void *buffer, size_t len);
|
||||
extern size_t up_hostwrite(const void *buffer, size_t len);
|
||||
|
||||
/* up_tapdev.c ************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_interruptcontext.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@ -31,40 +31,40 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Private Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_interrupt_context
|
||||
*
|
||||
* Description:
|
||||
* Return TRUE is we are currently executing in
|
||||
* the interrupt handler context.
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
boolean up_interrupt_context(void)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_releasepending.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
@ -45,23 +45,23 @@
|
||||
#include "os_internal.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Private Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_release_pending
|
||||
*
|
||||
* Description:
|
||||
@ -70,7 +70,7 @@
|
||||
* context switch if a new task is placed at the head of
|
||||
* the ready to run list.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
void up_release_pending(void)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_releasestack.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
@ -43,30 +43,30 @@
|
||||
#include <nuttx/arch.h>
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Private Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_release_stack
|
||||
*
|
||||
* Description:
|
||||
* A task has been stopped. Free all stack
|
||||
* related resources retained int the defunct TCB.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
void up_release_stack(_TCB *dtcb)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_reprioritizertr.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
@ -45,23 +45,23 @@
|
||||
#include "os_internal.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Private Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_reprioritize_rtr
|
||||
*
|
||||
* Description:
|
||||
@ -79,7 +79,7 @@
|
||||
* tcb: The TCB of the task that has been reprioritized
|
||||
* priority: The new task priority
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
void up_reprioritize_rtr(_TCB *tcb, ubyte priority)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_schedulesigaction.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
@ -45,23 +45,23 @@
|
||||
#include "os_internal.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Private Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_schedule_sigaction
|
||||
*
|
||||
* Description:
|
||||
@ -92,7 +92,7 @@
|
||||
* currently executing task -- just call the signal
|
||||
* handler now.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
void up_schedule_sigaction(_TCB *tcb, sig_deliver_t sigdeliver)
|
||||
{
|
||||
|
82
arch/sim/src/up_stdio.c
Normal file
82
arch/sim/src/up_stdio.c
Normal file
@ -0,0 +1,82 @@
|
||||
/****************************************************************************
|
||||
* up_stdio.c
|
||||
*
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
size_t up_hostread(void *buffer, size_t len)
|
||||
{
|
||||
/* Just map to the host fread() */
|
||||
|
||||
return fread(buffer, 1, len, stdout);
|
||||
}
|
||||
|
||||
size_t up_hostwrite(const void *buffer, size_t len)
|
||||
{
|
||||
/* Just map to the host fwrite() */
|
||||
|
||||
return fwrite(buffer, 1, len, stdout);
|
||||
}
|
||||
|
||||
int up_putc(int ch)
|
||||
{
|
||||
/* Just map to the host fputc routine */
|
||||
|
||||
return fputc(ch, stdout);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
/****************************************************************************
|
||||
* up_tapdev.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Based on code from uIP which also has a BSD-like license:
|
||||
@ -84,13 +84,6 @@ extern int lib_rawprintf(const char *format, ...);
|
||||
# define UIP_IPADDR3 0
|
||||
#endif
|
||||
|
||||
#define READ 3
|
||||
#define WRITE 4
|
||||
#define OPEN 5
|
||||
#define IOCTL 54
|
||||
#define SELECT 82
|
||||
#define SOCKETCALL 102
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@ -123,93 +116,6 @@ static int gtapdevfd;
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/* This is REALLY awkward.. we need to compile using the system header files,
|
||||
* but we can't use any of the libc calls because all of the symbols are
|
||||
* defined for NuttX (read, write, etc)! So we do hand rolled syscalls
|
||||
* to get to the Linux functions.
|
||||
*/
|
||||
|
||||
static inline int up_open(const char *filename, int flags, int mode)
|
||||
{
|
||||
int result;
|
||||
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (result) \
|
||||
: "0" (OPEN), "b" ((int)(filename)), "c" ((int)(flags)), "d" ((int)(mode)) \
|
||||
: "memory");
|
||||
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
static inline int up_socketcall(int call, unsigned long *args)
|
||||
{
|
||||
int result;
|
||||
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (result) \
|
||||
: "0" (SOCKETCALL), "b" (call), "c" ((int)args) \
|
||||
: "memory");
|
||||
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
static inline int up_socket(int domain, int type, int protocol)
|
||||
{
|
||||
unsigned long args[3];
|
||||
args[0] = domain;
|
||||
args[1] = type;
|
||||
args[2] = protocol;
|
||||
return up_socketcall(SYS_SOCKET, args);
|
||||
}
|
||||
|
||||
static inline int up_read(int fd, void* buf, size_t count)
|
||||
{
|
||||
ssize_t result;
|
||||
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (result) \
|
||||
: "0" (READ), "b" ((int)(fd)), "c" ((int)(buf)), "d" ((int)(count)) \
|
||||
: "memory");
|
||||
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
static inline int up_write(int fd, const void* buf, size_t count)
|
||||
{
|
||||
ssize_t result;
|
||||
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (result) \
|
||||
: "0" (WRITE), "b" ((int)(fd)), "c" ((int)(buf)), "d" ((int)(count)) \
|
||||
: "memory");
|
||||
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
static inline int up_ioctl(int fd, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
ssize_t result;
|
||||
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (result) \
|
||||
: "0" (IOCTL), "b" ((int)(fd)), "c" ((int)(cmd)), "d" ((long)(arg)) \
|
||||
: "memory");
|
||||
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
static inline int up_select(struct sel_arg_struct *arg)
|
||||
{
|
||||
ssize_t result;
|
||||
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (result) \
|
||||
: "0" (SELECT),"b" ((struct sel_arg_struct *)(arg))
|
||||
: "memory");
|
||||
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
#ifdef TAPDEV_DEBUG
|
||||
static inline void dump_ethhdr(const char *msg, unsigned char *buf, int buflen)
|
||||
{
|
||||
@ -246,7 +152,7 @@ void tapdev_init(void)
|
||||
|
||||
/* Open the tap device */
|
||||
|
||||
gtapdevfd = up_open(DEVTAP, O_RDWR, 0644);
|
||||
gtapdevfd = open(DEVTAP, O_RDWR, 0644);
|
||||
if (gtapdevfd < 0)
|
||||
{
|
||||
lib_rawprintf("TAPDEV: open failed: %d\n", -gtapdevfd );
|
||||
@ -257,7 +163,7 @@ void tapdev_init(void)
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
ifr.ifr_flags = IFF_TAP|IFF_NO_PI;
|
||||
ret = up_ioctl(gtapdevfd, TUNSETIFF, (unsigned long) &ifr);
|
||||
ret = ioctl(gtapdevfd, TUNSETIFF, (unsigned long) &ifr);
|
||||
if (ret < 0)
|
||||
{
|
||||
lib_rawprintf("TAPDEV: ioctl failed: %d\n", -ret );
|
||||
@ -278,7 +184,7 @@ int tapdev_getmacaddr(unsigned char *macaddr)
|
||||
{
|
||||
/* Get a socket (only so that we get access to the INET subsystem) */
|
||||
|
||||
int sockfd = up_socket(PF_INET, SOCK_DGRAM, 0);
|
||||
int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd >= 0)
|
||||
{
|
||||
struct ifreq req;
|
||||
@ -290,7 +196,7 @@ int tapdev_getmacaddr(unsigned char *macaddr)
|
||||
|
||||
/* Perform the ioctl to get the MAC address */
|
||||
|
||||
ret = up_ioctl(sockfd, SIOCGIFHWADDR, (unsigned long)&req);
|
||||
ret = ioctl(sockfd, SIOCGIFHWADDR, (unsigned long)&req);
|
||||
if (!ret)
|
||||
{
|
||||
/* Return the MAC address */
|
||||
@ -304,7 +210,6 @@ int tapdev_getmacaddr(unsigned char *macaddr)
|
||||
|
||||
unsigned int tapdev_read(unsigned char *buf, unsigned int buflen)
|
||||
{
|
||||
struct sel_arg_struct arg;
|
||||
fd_set fdset;
|
||||
struct timeval tv;
|
||||
int ret;
|
||||
@ -324,19 +229,13 @@ unsigned int tapdev_read(unsigned char *buf, unsigned int buflen)
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(gtapdevfd, &fdset);
|
||||
|
||||
arg.n = gtapdevfd + 1;
|
||||
arg.inp = &fdset;
|
||||
arg.outp = NULL;
|
||||
arg.exp = NULL;
|
||||
arg.tvp = &tv;
|
||||
|
||||
ret = up_select(&arg);
|
||||
ret = select(gtapdevfd + 1, &fdset, NULL, NULL, &tv);
|
||||
if(ret == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = up_read(gtapdevfd, buf, buflen);
|
||||
ret = read(gtapdevfd, buf, buflen);
|
||||
if (ret < 0)
|
||||
{
|
||||
lib_rawprintf("TAPDEV: read failed: %d\n", -ret);
|
||||
@ -361,7 +260,7 @@ void tapdev_send(unsigned char *buf, unsigned int buflen)
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = up_write(gtapdevfd, buf, buflen);
|
||||
ret = write(gtapdevfd, buf, buflen);
|
||||
if (ret < 0)
|
||||
{
|
||||
lib_rawprintf("TAPDEV: write failed: %d", -ret);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_unblocktask.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
@ -46,23 +46,23 @@
|
||||
#include "os_internal.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Private Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_unblock_task
|
||||
*
|
||||
* Description:
|
||||
@ -76,7 +76,7 @@
|
||||
* the ready-to-run list and, if it is the highest priority
|
||||
* ready to run taks, executed.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
void up_unblock_task(_TCB *tcb)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* up_usestack.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
@ -44,23 +44,23 @@
|
||||
#include "os_internal.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Private Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
* Public Funtions
|
||||
************************************************************/
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: up_use_stack
|
||||
*
|
||||
* Description:
|
||||
@ -79,7 +79,7 @@
|
||||
* tcb: The TCB of new task
|
||||
* stack_size: The allocated stack size.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
STATUS up_use_stack(_TCB *tcb, void *stack, size_t stack_size)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user