Progress toward clean SDCC compilation

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@18 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2007-02-21 21:55:16 +00:00
parent 445e74105d
commit fb52eafa37
19 changed files with 115 additions and 48 deletions

View File

@ -142,7 +142,18 @@ include/types.h
This provides architecture/toolchain-specific definitions for
standard types. This file should typedef:
sbyte, ubyte, uint8, boolean, sint16, uint16, sint32, uint32, sint64, uint64
sbyte, ubyte, uint8, boolean, sint16, uint16, sint32, uint32
and
sint64, uint64
if the architecture supports 64-bit integers.
irqstate_t
Must be defined to the be the size required to hold the interrupt
enable/disable state.
This file will be included by include/sys/types.h and be made
available to all files.
@ -154,9 +165,9 @@ include/irq.h
- struct xcptcontext. This structures represents the saved context
of a thread.
- uint32 irqsave(void) -- Used to disable all interrupts.
- irqstate_t irqsave(void) -- Used to disable all interrupts.
- void irqrestore(uint32 flags) -- Used to restore interrupt
- void irqrestore(irqstate_t flags) -- Used to restore interrupt
enables to the same state as before irqsave was called.
This file must also define NR_IRQS, the total number of IRQs supported

View File

@ -52,7 +52,7 @@ ARCHSCRIPT = -T$(TOPDIR)/arch/$(CONFIG_ARCH)/ld.script
CROSSDEV = arm-elf-
CC = $(CROSSDEV)gcc
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
@ -62,6 +62,7 @@ CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
LDFLAGS = $(ARCHSCRIPT)
EXTRA_LIBS =
LIBEXT = .a
ifeq ("${CONFIG_DEBUG}","y")
LDFLAGS += -g

View File

@ -132,6 +132,8 @@ CONFIG_ARCH_KFREE=n
#
# General Compile environment setup
#
# CONFIG_SMALL_MEMORY - enable if your processor supports
# 16-bit addressing; disable if it supports 32-bit.
# CONFIG_HAVE_INLINE - enable if your compiler supports
# inline functions
# CONFIG_HAVE_DOUBLE - enable if your compiler supports type
@ -139,21 +141,26 @@ CONFIG_ARCH_KFREE=n
# CONFIG_HAVE_LONG_LONG - enable if your architecture supports
# long long types and if you plan to use them
# CONFIG_CAN_PASS_STRUCTS - enable if your compiler supports
# passing structures and unions as values
# passing and assiging structures and unions as values
# CONFIG_CAN_CAST_POINTERS - enable if you can cast between
# integers and pointer.
# CONFIG_HAVE_WEAKFUNCTIONS - enable if you compiler supports
# weak functions (see include/nuttx/comp
#
CONFIG_SMALL_MEMORY=n
CONFIG_HAVE_INLINE=y
CONFIG_HAVE_DOUBLE=y
CONFIG_HAVE_LONG_LONG=n
CONFIG_CAN_PASS_STRUCTS=y
CONFIG_CAN_CAST_POINTERS=y
CONFIG_HAVE_WEAKFUNCTIONS=y
#
# General build options
#
# CONFIG_RRLOAD_BINY - make the rrload binary format used with
# CONFIG_RRLOAD_BINARY - make the rrload binary format used with
# BSPs from www.ridgerun.com
#
CONFIG_RRLOAD_BINARY=y
#
@ -175,6 +182,8 @@ CONFIG_RRLOAD_BINARY=y
# CONFIG_MQ_MAXMSGSIZE - Message structures are allocated with
# a fixed payload size given by this settin (does not include
# other message structure overhead.
# CONFIG_MAX_WDOGPARMS - Maximum number of parameters that
# can be passed to a watchdog handler
# CONFIG_PREALLOC_WDOGS - The number of pre-allocated watchdog
# structures. The system manages a pool of preallocated
# watchdog structures to minimize dynamic allocations
@ -186,6 +195,7 @@ CONFIG_STDIO_BUFFER_SIZE=1024
CONFIG_NUNGET_CHARS=2
CONFIG_PREALLOC_MQ_MSGS=32
CONFIG_MQ_MAXMSGSIZE=32
CONFIG_MAX_WDOGPARMS=4
CONFIG_PREALLOC_WDOGS=32
#

View File

@ -177,10 +177,10 @@ struct xcptcontext
/* Save the current interrupt enable state & disable IRQs */
static inline uint32 irqsave(void)
static inline irqstate_t irqsave(void)
{
unsigned long flags;
unsigned long temp;
unsigned int flags;
unsigned int temp;
__asm__ __volatile__
(
"\tmrs %0, cpsr\n"
@ -194,7 +194,7 @@ static inline uint32 irqsave(void)
/* Restore saved IRQ & FIQ state */
static inline void irqrestore(uint32 flags)
static inline void irqrestore(irqstate_t flags)
{
__asm__ __volatile__
(
@ -204,8 +204,8 @@ static inline void irqrestore(uint32 flags)
: "memory");
}
static inline void system_call(swint_t func, uint32 parm1,
uint32 parm2, uint32 parm3)
static inline void system_call(swint_t func, int parm1,
int parm2, int parm3)
{
__asm__ __volatile__
(

View File

@ -52,6 +52,10 @@
* Type Declarations
************************************************************/
#ifndef __ASSEMBLY__
/* These are the sizes of the standard GNU types */
typedef char sbyte;
typedef unsigned char ubyte;
typedef unsigned char uint8;
@ -63,6 +67,14 @@ typedef unsigned int uint32;
typedef long long sint64;
typedef unsigned long long uint64;
/* This is the size of the interrupt state save returned by
* irqsave()
*/
typedef unsigned int irqstate_t;
#endif /* __ASSEMBLY__ */
/************************************************************
* Global Function Prototypes
************************************************************/

View File

@ -56,7 +56,7 @@ COBJS = $(CSRCS:.c=.o)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
all: up_head.o libarch.a
all: up_head.o libarch$(LIBEXT)
$(AOBJS) up_head.o: %.o: %.S
$(CC) -c $(CFLAGS) -D__ASSEMBLY__ $< -o $@
@ -64,8 +64,11 @@ $(AOBJS) up_head.o: %.o: %.S
$(COBJS): %.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
libarch.a: $(OBJS)
$(AR) rcs $@ $(OBJS)
libarch$(LIBEXT): $(OBJS)
( for obj in $(OBJS) ; do \
$(AR) $@ $${obj} || \
{ echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \
done ; )
.depend: Makefile $(SRCS)
$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
@ -74,7 +77,7 @@ libarch.a: $(OBJS)
depend: .depend
clean:
rm -f libarch.a *.o *~
rm -f libarch$(LIBEXT) *.o *~
distclean: clean
rm -f Make.dep .depend

View File

@ -63,7 +63,7 @@
* Name: up_assert
************************************************************/
void up_assert(const ubyte *filename, uint32 lineno)
void up_assert(const ubyte *filename, int lineno)
{
dbg("Assertion failed at file:%s line: %d\n",
filename, lineno);
@ -74,7 +74,7 @@ void up_assert(const ubyte *filename, uint32 lineno)
* Name: up_assert_code
************************************************************/
void up_assert_code(const ubyte *filename, uint32 lineno, uint16 errorcode)
void up_assert_code(const ubyte *filename, int lineno, int errorcode)
{
dbg("Assertion failed at file:%s line: %d error code: %d\n",
filename, lineno, errorcode);

View File

@ -78,7 +78,7 @@
* must be allocated.
************************************************************/
STATUS up_create_stack(_TCB *tcb, uint32 stack_size)
STATUS up_create_stack(_TCB *tcb, size_t stack_size)
{
if (tcb->stack_alloc_ptr &&
tcb->adj_stack_size != stack_size)
@ -94,8 +94,8 @@ STATUS up_create_stack(_TCB *tcb, uint32 stack_size)
if (tcb->stack_alloc_ptr)
{
uint32 top_of_stack;
uint32 size_of_stack;
size_t top_of_stack;
size_t size_of_stack;
/* The Arm7Tdmi uses a push-down stack: the stack grows
* toward loweraddresses in memory. The stack pointer

View File

@ -101,7 +101,7 @@ void up_schedule_sigaction(_TCB *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver)
{
uint32 flags;
irqstate_t flags;
/* Make sure that interrupts are disabled */

View File

@ -721,7 +721,7 @@ static void up_uartsetup(up_dev_t *dev)
static void shutdown(up_dev_t * dev)
{
uint32 flags;
irqstate_t flags;
uint16 msr;
/* Free the IRQ */
@ -878,7 +878,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */
{
uint32 flags = irqsave();
irqstate_t flags = irqsave();
up_enablebreaks(dev);
irqrestore(flags);
}
@ -886,7 +886,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
case TIOCCBRK: /* BSD compatibility: Turn break off, unconditionally */
{
uint32 flags;
irqstate_t flags;
flags = irqsave();
up_disablebreaks(dev);
irqrestore(flags);
@ -973,7 +973,7 @@ static int up_open(struct file *filep)
if (++dev->open_count == 1)
{
int flags = irqsave();
irqstate_t flags = irqsave();
/* If this is the console, then the UART has already
* been initialized.

View File

@ -78,10 +78,10 @@
*
************************************************************/
STATUS up_use_stack(_TCB *tcb, uint32 *stack, uint32 stack_size)
STATUS up_use_stack(_TCB *tcb, void *stack, size_t stack_size)
{
uint32 top_of_stack;
uint32 size_of_stack;
size_t top_of_stack;
size_t size_of_stack;
if (tcb->stack_alloc_ptr)
{

View File

@ -51,7 +51,7 @@ ARCHSCRIPT =
CROSSDEV =
CC = $(CROSSDEV)gcc
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
@ -61,6 +61,7 @@ CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
LDFLAGS = $(ARCHSCRIPT)
EXTRA_LIBS = -lc
LIBEXT = .a
ifeq ("${CONFIG_DEBUG}","y")
LDFLAGS += -g

View File

@ -99,6 +99,8 @@ CONFIG_ARCH_KFREE=n
#
# General Compile environment setup
#
# CONFIG_SMALL_MEMORY - enable if your processor supports
# 16-bit addressing; disable if it supports 32-bit.
# CONFIG_HAVE_INLINE - enable if your compiler supports
# inline functions
# CONFIG_HAVE_DOUBLE - enable if your compiler supports type
@ -106,21 +108,26 @@ CONFIG_ARCH_KFREE=n
# CONFIG_HAVE_LONG_LONG - enable if your architecture supports
# long long types and if you plan to use them
# CONFIG_CAN_PASS_STRUCTS - enable if your compiler supports
# passing structures and unions as values
# passing and assiging structures and unions as values
# CONFIG_CAN_CAST_POINTERS - enable if you can cast between
# integers and pointer.
# CONFIG_HAVE_WEAKFUNCTIONS - enable if you compiler supports
# weak functions (see include/nuttx/comp
#
CONFIG_SMALL_MEMORY=n
CONFIG_HAVE_INLINE=y
CONFIG_HAVE_DOUBLE=y
CONFIG_HAVE_LONG_LONG=n
CONFIG_CAN_PASS_STRUCTS=y
CONFIG_CAN_CAST_POINTERS=y
CONFIG_HAVE_WEAKFUNCTIONS=y
#
# General build options
#
# CONFIG_RRLOAD_BINY - make the rrload binary format used with
# CONFIG_RRLOAD_BINARY - make the rrload binary format used with
# BSPs from www.ridgerun.com
#
CONFIG_RRLOAD_BINARY=n
#
@ -142,6 +149,8 @@ CONFIG_RRLOAD_BINARY=n
# CONFIG_MQ_MAXMSGSIZE - Message structures are allocated with
# a fixed payload size given by this settin (does not include
# other message structure overhead.
# CONFIG_MAX_WDOGPARMS - Maximum number of parameters that
# can be passed to a watchdog handler
# CONFIG_PREALLOC_WDOGS - The number of pre-allocated watchdog
# structures. The system manages a pool of preallocated
# watchdog structures to minimize dynamic allocations
@ -153,6 +162,7 @@ CONFIG_STDIO_BUFFER_SIZE=1024
CONFIG_NUNGET_CHARS=2
CONFIG_PREALLOC_MQ_MSGS=32
CONFIG_MQ_MAXMSGSIZE=32
CONFIG_MAX_WDOGPARMS=4
CONFIG_PREALLOC_WDOGS=32
#

View File

@ -44,6 +44,8 @@
* Included Files
************************************************************/
#include <sys/types.h>
/************************************************************
* Definitions
************************************************************/
@ -72,12 +74,12 @@ struct xcptcontext
************************************************************/
#ifndef __ASSEMBLY__
static inline uint32 irqsave(void)
static inline irqstate_t irqsave(void)
{
return 0;
}
static inline void irqrestore(uint32 flags)
static inline void irqrestore(irqstate_t flags)
{
}
#endif

View File

@ -52,6 +52,10 @@
* Type Declarations
************************************************************/
#ifndef __ASSEMBLY__
/* These are the sizes of the standard GNU types */
typedef char sbyte;
typedef unsigned char ubyte;
typedef unsigned char uint8;
@ -63,6 +67,14 @@ typedef unsigned int uint32;
typedef long long sint64;
typedef unsigned long long uint64;
/* This is the size of the interrupt state save returned by
* irqsave()
*/
typedef unsigned int irqstate_t;
#endif /* __ASSEMBLY__ */
/************************************************************
* Global Function Prototypes
************************************************************/

View File

@ -49,7 +49,7 @@ COBJS = $(CSRCS:.c=.o)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
all: up_head.o libarch.a
all: up_head.o libarch$(LIBEXT)
$(AOBJS): %.o: %.S
$(CC) -c $(CFLAGS) -D__ASSEMBLY__ $< -o $@
@ -57,8 +57,11 @@ $(AOBJS): %.o: %.S
$(COBJS) up_head.o: %.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
libarch.a: $(OBJS)
$(AR) rcs $@ $(OBJS)
libarch$(LIBEXT): $(OBJS)
( for obj in $(OBJS) ; do \
$(AR) $@ $${obj} || \
{ echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \
done ; )
.depend: Makefile $(SRCS)
$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
@ -67,7 +70,7 @@ libarch.a: $(OBJS)
depend: .depend
clean:
rm -f libarch.a *.o *~
rm -f libarch$(LIBEXT) *.o *~
distclean: clean
rm -f Make.dep .depend

View File

@ -81,14 +81,14 @@
*
************************************************************/
STATUS up_create_stack(_TCB *tcb, uint32 stack_size)
STATUS up_create_stack(_TCB *tcb, size_t stack_size)
{
STATUS ret = ERROR;
/* Move up to next even word boundary if necessary */
uint32 adj_stack_size = (stack_size + 3) & ~3;
uint32 adj_stack_words = adj_stack_size >> 2;
size_t adj_stack_size = (stack_size + 3) & ~3;
size_t adj_stack_words = adj_stack_size >> 2;
/* Allocate the memory for the stack */
@ -97,9 +97,10 @@ STATUS up_create_stack(_TCB *tcb, uint32 stack_size)
{
/* This is the address of the last word in the allocation */
uint32 *adj_stack_ptr = &stack_alloc_ptr[adj_stack_words - 1];
size_t *adj_stack_ptr = &stack_alloc_ptr[adj_stack_words - 1];
/* Save the values in the TCB */
tcb->adj_stack_size = adj_stack_size;
tcb->stack_alloc_ptr = stack_alloc_ptr;
tcb->adj_stack_ptr = adj_stack_ptr;

View File

@ -64,13 +64,13 @@ int main(int argc, char **argv, char **envp)
return 0;
}
void up_assert(const ubyte *filename, uint32 line)
void up_assert(const ubyte *filename, int line)
{
fprintf(stderr, "Assertion failed at file:%s line: %d\n", filename, line);
longjmp(sim_abort, 1);
}
void up_assert_code(const ubyte *filename, uint32 line, uint16 code)
void up_assert_code(const ubyte *filename, int line, int code)
{
fprintf(stderr, "Assertion failed at file:%s line: %d error code: %d\n", filename, line, code);
longjmp(sim_abort, 1);

View File

@ -81,18 +81,19 @@
*
************************************************************/
STATUS up_use_stack(_TCB *tcb, uint32 *stack, uint32 stack_size)
STATUS up_use_stack(_TCB *tcb, void *stack, size_t stack_size)
{
/* Move up to next even word boundary if necessary */
uint32 adj_stack_size = stack_size & ~3;
uint32 adj_stack_words = adj_stack_size >> 2;
size_t adj_stack_size = stack_size & ~3;
size_t adj_stack_words = adj_stack_size >> 2;
/* This is the address of the last word in the allocation */
uint32 *adj_stack_ptr = &stack[adj_stack_words - 1];
size_t *adj_stack_ptr = &stack[adj_stack_words - 1];
/* Save the values in the TCB */
tcb->adj_stack_size = adj_stack_size;
tcb->stack_alloc_ptr = stack;
tcb->adj_stack_ptr = adj_stack_ptr;