diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-02-14 01:47:18 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-02-14 01:47:18 +0000 |
commit | b0dcacabaac30072bc3fc4076723cd42c5d8973d (patch) | |
tree | 3d6e37cf70f7f3b18557baccf884ca90c2da4580 /nuttx/arch/c5471/src | |
parent | 5027365b990fb1ab4a6d5626acddcafba01977f5 (diff) | |
download | px4-nuttx-b0dcacabaac30072bc3fc4076723cd42c5d8973d.tar.gz px4-nuttx-b0dcacabaac30072bc3fc4076723cd42c5d8973d.tar.bz2 px4-nuttx-b0dcacabaac30072bc3fc4076723cd42c5d8973d.zip |
Removed old CVS directories
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3292 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/c5471/src')
35 files changed, 0 insertions, 5915 deletions
diff --git a/nuttx/arch/c5471/src/Makefile b/nuttx/arch/c5471/src/Makefile deleted file mode 100644 index 1e7933b8f..000000000 --- a/nuttx/arch/c5471/src/Makefile +++ /dev/null @@ -1,125 +0,0 @@ -############################################################################ -# arch/c5471/src/Makefile -# -# 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. -# -############################################################################ - --include $(TOPDIR)/Make.defs - -CFLAGS += -I$(TOPDIR)/sched - -ASRCS = up_vectors.S up_saveusercontext.S up_fullcontextrestore.S -ifeq ($(CONFIG_DEBUG),y) -ASRCS += up_lowputc.S -endif -AOBJS = $(ASRCS:.S=.o) - -CSRCS = up_initialize.c up_initialstate.c up_idle.c up_doirq.c \ - up_irq.c up_syscall.c up_dataabort.c up_prefetchabort.c \ - up_undefinedinsn.c up_interruptcontext.c up_timerisr.c \ - up_createstack.c up_usestack.c up_releasestack.c \ - up_exit.c up_assert.c up_blocktask.c up_unblocktask.c \ - up_releasepending.c up_reprioritizertr.c up_copystate.c \ - up_schedulesigaction.c up_sigdeliver.c up_serial.c \ - up_delay.c up_allocateheap.c up_watchdog.c -COBJS = $(CSRCS:.c=.o) - -SRCS = $(ASRCS) $(CSRCS) -OBJS = $(AOBJS) $(COBJS) - -LDFLAGS = $(ARCHSCRIPT) -EXTRA_LIBS = - -LINKOBJS = up_head$(OBJEXT) -LINKLIBS = -LDPATHES = $(addprefix -L$(TOPDIR)/,$(dir $(LINKLIBS))) -LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(LINKLIBS)))) - -BOARDDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src/board - -LIBGCC = ${shell $(CC) -print-libgcc-file-name} - -all: up_head.o libarch$(LIBEXT) - -$(AOBJS) $(LINKOBJS): %.o: %.S - $(call ASSEMBLE, $<, $@) - -$(COBJS): %.o: %.c - $(call COMPILE, $<, $@) - -libarch$(LIBEXT): $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $@, $${obj}); \ - done ; ) - -board/libboard$(LIBEXT): - $(MAKE) -C board TOPDIR=$(TOPDIR) libboard$(LIBEXT) - -nuttx: $(LINKOBJS) board/libboard$(LIBEXT) - $(LD) --entry=__start $(LDFLAGS) $(LDPATHES) -L$(BOARDDIR) -o $(TOPDIR)/$@ $(LINKOBJS) \ - --start-group $(LDLIBS) -lboard --end-group $(EXTRA_LIBS) $(LIBGCC) - @$(NM) $(TOPDIR)/$@ | \ - grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ - sort > $(TOPDIR)/System.map - @export vflashstart=`$(OBJDUMP) --all-headers $(TOPDIR)/$@ | grep _vflashstart | cut -d' ' -f1`; \ - if [ ! -z "$$vflashstart" ]; then \ - $(OBJCOPY) --adjust-section-vma=.vector=0x$$vflashstart $(TOPDIR)/$@ $(TOPDIR)/$@.flashimage; \ - mv $(TOPDIR)/$@.flashimage $(TOPDIR)/$@; \ - fi -ifeq ($(CONFIG_RRLOAD_BINARY),y) - @$(TOPDIR)/tools/mkimage.sh --Prefix $(CROSSDEV) $(TOPDIR)/$@ $(TOPDIR)/$@.rr - @if [ -w /tftpboot ] ; then \ - cp -f $(TOPDIR)/$@.rr /tftpboot/$@.rr.${CONFIG_ARCH}; \ - fi -endif - -.depend: Makefile $(SRCS) - @$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep - @$(MAKE) -C board TOPDIR=$(TOPDIR) depend - @touch $@ - -depend: .depend - -clean: - @if [ -e board/Makefile ]; then \ - $(MAKE) -C board TOPDIR=$(TOPDIR) clean ; \ - fi - @rm -f libarch$(LIBEXT) *~ .*.swp - $(call CLEAN) - -distclean: clean - @if [ -e board/Makefile ]; then \ - $(MAKE) -C board TOPDIR=$(TOPDIR) distclean ; \ - fi - rm -f Make.dep .depend - --include Make.dep diff --git a/nuttx/arch/c5471/src/c5471.h b/nuttx/arch/c5471/src/c5471.h deleted file mode 100644 index 9c085d7d7..000000000 --- a/nuttx/arch/c5471/src/c5471.h +++ /dev/null @@ -1,379 +0,0 @@ -/************************************************************ - * c5471.h - * - * Copyright (C) 2007 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 Gregory Nutt nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ************************************************************/ - -#ifndef __C5471_H -#define __C5471_H - -/************************************************************ - * Included Files - ************************************************************/ - -#include <nuttx/config.h> - -#ifndef __ASSEMBLY__ -# include <sys/types.h> -#endif - -#if defined(CONFIG_ARCH_BOARD_C5471EVM) -# include <arch/board/c5471evm.h> -#else -# warning "Undefined C5471 Board" -#endif - -/************************************************************ - * Definitions - ************************************************************/ - -/* Arm7Tdmi *************************************************/ - -/* CPSR bits */ - -#define USR26_MODE 0x00 -#define FIQ26_MODE 0x01 -#define IRQ26_MODE 0x02 -#define SVC26_MODE 0x03 -#define USR_MODE 0x10 -#define FIQ_MODE 0x11 -#define IRQ_MODE 0x12 -#define SVC_MODE 0x13 -#define ABT_MODE 0x17 -#define UND_MODE 0x1b -#define SYSTEM_MODE 0x1f -#define MODE_MASK 0x1f -#define T_BIT 0x20 -#define F_BIT 0x40 -#define I_BIT 0x80 -#define CC_V_BIT (1 << 28) -#define CC_C_BIT (1 << 29) -#define CC_Z_BIT (1 << 30) -#define CC_N_BIT (1 << 31) - -/* UARTs ****************************************************/ - -#define UART_IRDA_BASE 0xffff0800 -#define UART_MODEM_BASE 0xffff1000 -#define UARTn_IO_RANGE 0x00000800 - -/* Common UART Registers. Expressed as offsets from the BASE address */ - -#define UART_RHR_OFFS 0x00000000 /* Rcv Holding Register */ -#define UART_THR_OFFS 0x00000004 /* Xmit Holding Register */ -#define UART_FCR_OFFS 0x00000008 /* FIFO Control Register */ -#define UART_RFCR_OFFS 0x00000008 /* Rcv FIFO Control Register */ -#define UART_TFCR_OFFS 0x00000008 /* Xmit FIFO Control Register */ -#define UART_SCR_OFFS 0x0000000c /* Status Control Register */ -#define UART_LCR_OFFS 0x00000010 /* Line Control Register */ -#define UART_LSR_OFFS 0x00000014 /* Line Status Register */ -#define UART_SSR_OFFS 0x00000018 /* Supplementary Status Register */ -#define UART_MCR_OFFS 0x0000001c /* Modem Control Register */ -#define UART_MSR_OFFS 0x00000020 /* Modem Status Register */ -#define UART_IER_OFFS 0x00000024 /* Interrupt Enable Register */ -#define UART_ISR_OFFS 0x00000028 /* Interrupt Status Register */ -#define UART_EFR_OFFS 0x0000002c /* Enhanced Feature Register */ -#define UART_XON1_OFFS 0x00000030 /* XON1 Character Register */ -#define UART_XON2_OFFS 0x00000034 /* XON2 Character Register */ -#define UART_XOFF1_OFFS 0x00000038 /* XOFF1 Character Register */ -#define UART_XOFF2_OFFS 0x0000003c /* XOFF2 Character Register */ -#define UART_SPR_OFFS 0x00000040 /* Scratch-pad Register */ -#define UART_DIV_115K_OFFS 0x00000044 /* Divisor for baud generation */ -#define UART_DIV_BIT_RATE_OFFS 0x00000048 /* For baud rate generation */ -#define UART_TCR_OFFS 0x0000004c /* Transmission Control Register */ -#define UART_TLR_OFFS 0x00000050 /* Trigger Level Register */ -#define UART_MDR_OFFS 0x00000054 /* Mode Definition Register */ - -/* Registers available only for the IrDA UART (absolute address). */ - -#define UART_IRDA_MDR1 0xffff0854 /* Mode Definition Register 1 */ -#define UART_IRDA_MDR2 0xffff0858 /* Mode Definition Register 2 */ -#define UART_IRDA_TXFLL 0xffff085c /* LS Xmit Frame Length Register */ -#define UART_IRDA_TXFLH 0xffff0860 /* MS Xmit Frame Length Register */ -#define UART_IRDA_RXFLL 0xffff0864 /* LS Rcvd Frame Length Register */ -#define UART_IRDA_RXFLH 0xffff0868 /* MS Rcvd Frame Length Register */ -#define UART_IRDA_SFLSR 0xffff086c /* Status FIFO Line Status Reg */ -#define UART_IRDA_SFREGL 0xffff0870 /* LS Status FIFO Register */ -#define UART_IRDA_SFREGH 0xffff0874 /* MS Status FIFO Register */ -#define UART_IRDA_BLR 0xffff0878 /* Begin of File Length Register */ -#define UART_IRDA_PULSE_WIDTH 0xffff087c /* Pulse Width Register */ -#define UART_IRDA_ACREG 0xffff0880 /* Auxiliary Control Register */ -#define UART_IRDA_PULSE_START 0xffff0884 /* Start time of pulse */ -#define UART_IRDA_RX_W_PTR 0xffff0888 /* RX FIFO write pointer */ -#define UART_IRDA_RX_R_PTR 0xffff088c /* RX FIFO read pointer */ -#define UART_IRDA_TX_W_PTR 0xffff0890 /* TX FIFO write pointer */ -#define UART_IRDA_TX_R_PTR 0xffff0894 /* TX FIFO read pointer */ -#define UART_IRDA_STATUS_W_PTR 0xffff0898 /* Write pointer of status FIFO */ -#define UART_IRDA_STATUS_R_PTR 0xffff089c /* Read pointer of status FIFO */ -#define UART_IRDA_RESUME 0xffff08a0 /* Resume register */ -#define UART_IRDA_MUX 0xffff08a4 /* Selects UART_IRDA output mux */ - -/* Registers available for the Modem UART (absolute addresses) */ - -#define UART_MODEM_MDR 0xffff1054 /* Mode Definition Register */ -#define UART_MODEM_UASR 0xffff1058 /* UART Auto-baud Status Register */ -#define UART_MODEM_RDPTR_URX 0xffff105c /* RX FIFO Read Pointer Register */ -#define UART_MODEM_WRPTR_URX 0xffff1060 /* RX FIFO Write Pointer Register */ -#define UART_MODEM_RDPTR_UTX 0xffff1064 /* TX FIFO Read Pointer Register */ -#define UART_MODEM_WRPTR_UTX 0xffff1068 /* TX FIFO Write Pointer Register */ - -/* UART Settings ********************************************/ - -/* Miscellaneous UART settings. */ - -#define UART_RX_FIFO_NOEMPTY 0x00000001 -#define UART_SSR_TXFULL 0x00000001 -#define UART_LSR_TREF 0x00000020 - -#define UART_XMIT_FIFO_SIZE 64 -#define UART_IRDA_XMIT_FIFO_SIZE 64 - -/* UART_LCR Register */ - /* Bits 31-7: Reserved */ -#define UART_LCR_BOC 0x00000040 /* Bit 6: Break Control */ - /* Bit 5: Parity Type 2 */ -#define UART_LCR_PAREVEN 0x00000010 /* Bit 4: Parity Type 1 */ -#define UART_LCR_PARODD 0x00000000 -#define UART_LCR_PAREN 0x00000008 /* Bit 3: Paity Enable */ -#define UART_LCR_PARDIS 0x00000000 -#define UART_LCR_2STOP 0x00000004 /* Bit 2: Number of stop bits */ -#define UART_LCR_1STOP 0x00000000 -#define UART_LCR_5BITS 0x00000000 /* Bits 0-1: Word-length */ -#define UART_LCR_6BITS 0x00000001 -#define UART_LCR_7BITS 0x00000002 -#define UART_LCR_8BITS 0x00000003 - -#define UART_FCR_FTL 0x00000000 -#define UART_FCR_FIFO_EN 0x00000001 -#define UART_FCR_TX_CLR 0x00000002 -#define UART_FCR_RX_CLR 0x00000004 - -#define UART_IER_RECVINT 0x00000001 -#define UART_IER_XMITINT 0x00000002 -#define UART_IER_LINESTSINT 0x00000004 -#define UART_IER_MODEMSTSINT 0x00000008 /* IrDA UART only */ -#define UART_IER_XOFFINT 0x00000020 -#define UART_IER_RTSINT 0x00000040 /* IrDA UART only */ -#define UART_IER_CTSINT 0x00000080 /* IrDA UART only */ -#define UART_IER_INTMASK 0x000000ff - -#define BAUD_115200 0x00000001 -#define BAUD_57600 0x00000002 -#define BAUD_38400 0x00000003 -#define BAUD_19200 0x00000006 -#define BAUD_9600 0x0000000C -#define BAUD_4800 0x00000018 -#define BAUD_2400 0x00000030 -#define BAUD_1200 0x00000060 - -#define MDR_UART_MODE 0x00000000 /* Both IrDA and Modem UARTs */ -#define MDR_SIR_MODE 0x00000001 /* IrDA UART only */ -#define MDR_AUTOBAUDING_MODE 0x00000002 /* Modem UART only */ -#define MDR_RESET_MODE 0x00000007 /* Both IrDA and Modem UARTs */ - -/* SPI ******************************************************/ - -#define MAX_SPI 3 - -#define SPI_REGISTER_BASE 0xffff2000 - -/* GIO ******************************************************/ - -#define MAX_GIO (35) - -#define GIO_REGISTER_BASE 0xffff2800 - -#define GPIO_IO 0xffff2800 /* Writeable when I/O is configured - * as an output; reads value on I/O - * pin when I/O is configured as an - * input */ -#define GPIO_CIO 0xffff2804 /* GPIO configuration register */ -#define GPIO_IRQA 0xffff2808 /* In conjunction with GPIO_IRQB - * determines the behavior when GPIO - * pins configured as input IRQ */ -#define GPIO_IRQB 0xffff280c /* Determines the behavior when GPIO - * pins configured as input IRQ */ -#define GPIO_DDIO 0xffff2810 /* Delta Detect Register - * (detects changes in the I/O pins) */ -#define GPIO_EN 0xffff2814 /* Selects register for muxed GPIOs */ - -#define KGIO_REGISTER_BASE 0xffff2900 - -#define KBGPIO_IO 0xffff2900 /* Keyboard I/O bits: Writeable - * when KBGPIO is configured as an - * output; reads value on I/O pin - * when KBGPIO is configured as an - * input */ -#define KBGPIO_CIO 0xffff2904 /* KBGPIO configuration register */ -#define KBGPIO_IRQA 0xffff2908 /* In conjunction with KBGPIO_IRQB - * determines the behavior when - * KBGPIO pins configured as input - * IRQ */ -#define KBGPIO_IRQB 0xffff290c /* In conjunction with KBGPIO_IRQA - * determines the behavior when - * KBGPIO pins configured as input - * IRQ */ -#define KBGPIO_DDIO 0xffff2910 /* Delta Detect Register (detects - * changes in the KBGPIO pins) */ -#define KBGPIO_EN 0xffff2914 /* Selects register for muxed - * KBGPIOs */ - -/* Timers ***************************************************/ - -#define C5471_TIMER0_CTRL 0xffff2a00 -#define C5471_TIMER0_CNT 0xffff2a04 -#define C5471_TIMER1_CTRL 0xffff2b00 -#define C5471_TIMER1_CNT 0xffff2b04 -#define C5471_TIMER2_CTRL 0xffff2c00 - -#define C5471_TIMER2_CNT 0xffff2c04 - -/* Interrupts */ - -#define HAVE_SRC_IRQ_BIN_REG 0 - -#define INT_FIRST_IO 0xffff2d00 -#define INT_IO_RANGE 0x5C - -#define IT_REG 0xffff2d00 -#define MASK_IT_REG 0xffff2d04 -#define SRC_IRQ_REG 0xffff2d08 -#define SRC_FIQ_REG 0xffff2d0c -#define SRC_IRQ_BIN_REG 0xffff2d10 -#define INT_CTRL_REG 0xffff2d18 - -#define ILR_IRQ0_REG 0xffff2d1C /* 0-Timer 0 */ -#define ILR_IRQ1_REG 0xffff2d20 /* 1-Timer 1 */ -#define ILR_IRQ2_REG 0xffff2d24 /* 2-Timer 2 */ -#define ILR_IRQ3_REG 0xffff2d28 /* 3-GPIO0 */ -#define ILR_IRQ4_REG 0xffff2d2c /* 4-Ethernet */ -#define ILR_IRQ5_REG 0xffff2d30 /* 5-KBGPIO[7:0] */ -#define ILR_IRQ6_REG 0xffff2d34 /* 6-Uart serial */ -#define ILR_IRQ7_REG 0xffff2d38 /* 7-Uart IRDA */ -#define ILR_IRQ8_REG 0xffff2d3c /* 8-KBGPIO[15:8] */ -#define ILR_IRQ9_REG 0xffff2d40 /* 9-GPIO3 */ -#define ILR_IRQ10_REG 0xffff2d44 /* 10-GPIO2 */ -#define ILR_IRQ11_REG 0xffff2d48 /* 11-I2C */ -#define ILR_IRQ12_REG 0xffff2d4c /* 12-GPIO1 */ -#define ILR_IRQ13_REG 0xffff2d50 /* 13-SPI */ -#define ILR_IRQ14_REG 0xffff2d54 /* 14-GPIO[19:4] */ -#define ILR_IRQ15_REG 0xffff2d58 /* 15-API */ - -/* I2C ******************************************************/ - -#define MAX_I2C 1 - -/* API ******************************************************/ - -#define DSPRAM_BASE 0xffe00000 /* DSPRAM base address */ -#define DSPRAM_END 0xffe03fff - -/* This is the API address range in the DSP address space. */ - -#define DSPMEM_DSP_START 0x2000 -#define DSPMEM_DSP_END 0x3fff - -/* This is the API address range in the ARM address space. */ - -#define DSPMEM_ARM_START DSPRAM_BASE /* Defined in hardware.h */ -#define DSPMEM_ARM_END DSPRAM_END - -/* DSPMEM_IN_RANGE is a generic macro to test is a value is within - * a range of values. - */ - -#define DSPMEM_IN_RANGE(addr, start, end) \ - ((((__u32)(addr)) >= (start)) && (((__u32)(addr)) <= (end))) - -/* DSPMEM_ADDR_ALIGNED verifies that a potential DSP address is - * properly word aligned. - */ - -#define DSPMEM_ADDR_ALIGNED(addr, cpu) ((((__u32)(addr)) & 1) == 0) - -/* DSPMEM_DSP_ADDR checks if a DSP address lies in within the - * DSP's API address range. - */ - -#define DSPMEM_DSP_ADDR(addr, cpu) \ - DSPMEM_IN_RANGE(addr, DSPMEM_DSP_START, DSPMEM_DSP_END) - -/* DSPMEM_ARM_ADDR checks if a ARM address lies in within the - * ARM's API address range. - */ - -#define DSPMEM_ARM_ADDR(addr) \ - DSPMEM_IN_RANGE(addr, DSPMEM_ARM_START, DSPMEM_ARM_END) - -/* DSPMEM_DSP_TO_ARM maps a DSP API address into an ARM API address */ - -#define DSPMEM_DSP_TO_ARM(addr, cpu) \ - ((((__u32)(addr) - DSPMEM_DSP_START) << 1) + DSPMEM_ARM_START) - -/* DSPMEM_ARM_TO_DSP maps an ARM API address into a DSP API address */ - -#define DSPMEM_ARM_TO_DSP(addr) \ - ((((__u32)(addr) - DSPMEM_ARM_START) >> 1) + DSPMEM_DSP_START) - -/************************************************************ - * Inline Functions - ************************************************************/ - -#ifndef __ASSEMBLY__ - -# define getreg8(a) (*(volatile ubyte *)(a)) -# define putreg8(v,a) (*(volatile ubyte *)(a) = (v)) -# define getreg32(a) (*(volatile uint32 *)(a)) -# define putreg32(v,a) (*(volatile uint32 *)(a) = (v)) - - -/* Some compiler options will convert short loads and stores into byte loads - * and stores. We don't want this to happen for IO reads and writes! - */ - -/* # define getreg16(a) (*(volatile uint16 *)(a)) */ -static inline unsigned short getreg16(unsigned int addr) -{ - unsigned short retval; - __asm__ __volatile__("\tldrh %0, [%1]\n\t" : "=r"(retval) : "r"(addr)); - return retval; -} - -/* define putreg16(v,a) (*(volatile uint16 *)(a) = (v)) */ -static inline void putreg16(uint16 val, unsigned int addr) -{ - __asm__ __volatile__("\tstrh %0, [%1]\n\t": : "r"(val), "r"(addr)); -} - -#endif - -#endif /* __C5471_H */ diff --git a/nuttx/arch/c5471/src/up_allocateheap.c b/nuttx/arch/c5471/src/up_allocateheap.c deleted file mode 100644 index 3ee7a6820..000000000 --- a/nuttx/arch/c5471/src/up_allocateheap.c +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************ - * up_allocateheap.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <debug.h> -#include <nuttx/arch.h> -#include "up_internal.h" - -/************************************************************ - * Private Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Functions - ************************************************************/ - -/************************************************************ - * Public Functions - ************************************************************/ - -/************************************************************ - * Name: up_allocate_heap - * - * Description: - * The heap may be statically allocated by - * defining CONFIG_HEAP_BASE and CONFIG_HEAP_SIZE. If these - * are not defined, then this function will be called to - * dynamically set aside the heap region. - * - ************************************************************/ - -void up_allocate_heap(FAR void **heap_start, size_t *heap_size) -{ - up_ledon(LED_HEAPALLOCATE); - *heap_start = (FAR void*)g_heapbase; - *heap_size = CONFIG_DRAM_END - g_heapbase; -} diff --git a/nuttx/arch/c5471/src/up_assert.c b/nuttx/arch/c5471/src/up_assert.c deleted file mode 100644 index 0dad02f89..000000000 --- a/nuttx/arch/c5471/src/up_assert.c +++ /dev/null @@ -1,200 +0,0 @@ -/************************************************************ - * up_assert.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <stdlib.h> -#include <assert.h> -#include <debug.h> -#include <nuttx/irq.h> -#include "os_internal.h" -#include "up_internal.h" - -/************************************************************ - * Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Functions - ************************************************************/ - -/************************************************************ - * Name: up_getsp - ************************************************************/ - -/* I don't know if the builtin to get SP is enabled */ - -static inline uint32 up_getsp(void) -{ - uint32 sp; - __asm__ - ( - "\tmov %0, sp\n\t" - : "=r"(sp) - ); - return sp; -} - -/************************************************************ - * Name: up_stackdump - ************************************************************/ - -#ifdef CONFIG_ARCH_STACKDUMP -static void up_stackdump(void) -{ - _TCB *rtcb = (_TCB*)g_readytorun.head; - uint32 sp = up_getsp(); - uint32 stack_base; - uint32 stack_size; - - if (rtcb->pid == 0) - { - stack_base = g_heapbase - 4; - stack_size = CONFIG_PROC_STACK_SIZE; - } - else - { - stack_base = (uint32)rtcb->adj_stack_ptr; - stack_size = (uint32)rtcb->adj_stack_size; - } - - lldbg("stack_base: %08x\n", stack_base); - lldbg("stack_size: %08x\n", stack_size); - lldbg("sp: %08x\n", sp); - - if (sp >= stack_base || sp < stack_base - stack_size) - { - lldbg("ERROR: Stack pointer is not within allocated stack\n"); - return; - } - else - { - uint32 stack = sp & ~0x1f; - - for (stack = sp & ~0x1f; stack < stack_base; stack += 32) - { - uint32 *ptr = (uint32*)stack; - lldbg("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n", - stack, ptr[0], ptr[1], ptr[2], ptr[3], - ptr[4], ptr[5], ptr[6], ptr[7]); - } - } -} -#else -# define up_stackdump() -#endif - -/************************************************************ - * Name: _up_assert - ************************************************************/ - -static void _up_assert(int errorcode) /* __attribute__ ((noreturn)) */ -{ - /* Are we in an interrupt handler or the idle task? */ - - if (current_regs || ((_TCB*)g_readytorun.head)->pid == 0) - { - (void)irqsave(); - for(;;) - { -#ifdef CONFIG_ARCH_LEDS - up_ledon(LED_PANIC); - up_delay(250); - up_ledoff(LED_PANIC); - up_delay(250); -#endif - } - } - else - { - exit(errorcode); - } -} - -/************************************************************ - * Public Funtions - ************************************************************/ - -/************************************************************ - * Name: up_assert - ************************************************************/ - -void up_assert(const ubyte *filename, int lineno) -{ -#if CONFIG_TASK_NAME_SIZE > 0 - _TCB *rtcb = (_TCB*)g_readytorun.head; -#endif - - up_ledon(LED_ASSERTION); -#if CONFIG_TASK_NAME_SIZE > 0 - lldbg("Assertion failed at file:%s line: %d task: %s\n", - filename, lineno, rtcb->name); -#else - lldbg("Assertion failed at file:%s line: %d\n", - filename, lineno); -#endif - up_stackdump(); - _up_assert(EXIT_FAILURE); -} - -/************************************************************ - * Name: up_assert_code - ************************************************************/ - -void up_assert_code(const ubyte *filename, int lineno, int errorcode) -{ -#if CONFIG_TASK_NAME_SIZE > 0 - _TCB *rtcb = (_TCB*)g_readytorun.head; -#endif - - up_ledon(LED_ASSERTION); -#if CONFIG_TASK_NAME_SIZE > 0 - lldbg("Assertion failed at file:%s line: %d task: %s error code: %d\n", - filename, lineno, rtcb->name, errorcode); -#else - lldbg("Assertion failed at file:%s line: %d error code: %d\n", - filename, lineno, errorcode); -#endif - up_stackdump(); - _up_assert(errorcode); -} diff --git a/nuttx/arch/c5471/src/up_blocktask.c b/nuttx/arch/c5471/src/up_blocktask.c deleted file mode 100644 index ce2f430ff..000000000 --- a/nuttx/arch/c5471/src/up_blocktask.c +++ /dev/null @@ -1,168 +0,0 @@ -/************************************************************ - * up_blocktask.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <sched.h> -#include <debug.h> -#include <nuttx/arch.h> -#include "os_internal.h" -#include "up_internal.h" - -/************************************************************ - * Private Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Funtions - ************************************************************/ - -/************************************************************ - * Public Funtions - ************************************************************/ - -/************************************************************ - * Name: up_block_task - * - * Description: - * The currently executing task at the head of - * the ready to run list must be stopped. Save its context - * and move it to the inactive list specified by task_state. - * - * Inputs: - * tcb: Refers to a task in the ready-to-run list (normally - * the task at the the head of the list). It most be - * stopped, its context saved and moved into one of the - * waiting task lists. It it was the task at the head - * of the ready-to-run list, then a context to the new - * ready to run task must be performed. - * task_state: Specifies which waiting task list should be - * hold the blocked task TCB. - * - ************************************************************/ - -void up_block_task(_TCB *tcb, tstate_t task_state) -{ - /* Verify that the context switch can be performed */ - - if ((tcb->task_state < FIRST_READY_TO_RUN_STATE) || - (tcb->task_state > LAST_READY_TO_RUN_STATE)) - { - PANIC(OSERR_BADBLOCKSTATE); - } - else - { - _TCB *rtcb = (_TCB*)g_readytorun.head; - boolean switch_needed; - - lldbg("Blocking TCB=%p\n", tcb); - - /* Remove the tcb task from the ready-to-run list. If we - * are blocking the task at the head of the task list (the - * most likely case), then a context switch to the next - * ready-to-run task is needed. In this case, it should - * also be true that rtcb == tcb. - */ - - switch_needed = sched_removereadytorun(tcb); - - /* Add the task to the specified blocked task list */ - - sched_addblocked(tcb, (tstate_t)task_state); - - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ - - if (g_pendingtasks.head) - { - switch_needed |= sched_mergepending(); - } - - /* Now, perform the context switch if one is needed */ - - if (switch_needed) - { - /* Are we in an interrupt handler? */ - - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ - - up_copystate(rtcb->xcp.regs, current_regs); - - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ - - rtcb = (_TCB*)g_readytorun.head; - lldbg("New Active Task TCB=%p\n", rtcb); - - /* Then switch contexts */ - - up_copystate(current_regs, rtcb->xcp.regs); - } - - /* Copy the user C context into the TCB at the (old) head of the - * g_readytorun Task list. if up_saveusercontext returns a non-zero - * value, then this is really the previously running task restarting! - */ - - else if (!up_saveusercontext(rtcb->xcp.regs)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ - - rtcb = (_TCB*)g_readytorun.head; - lldbg("New Active Task TCB=%p\n", rtcb); - - /* Then switch contexts */ - - up_fullcontextrestore(rtcb->xcp.regs); - } - } - } -} diff --git a/nuttx/arch/c5471/src/up_copystate.c b/nuttx/arch/c5471/src/up_copystate.c deleted file mode 100644 index bd9db8161..000000000 --- a/nuttx/arch/c5471/src/up_copystate.c +++ /dev/null @@ -1,75 +0,0 @@ -/************************************************************ - * up_copystate.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include "os_internal.h" -#include "up_internal.h" - -/************************************************************ - * Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Functions - ************************************************************/ - -/************************************************************ - * Public Funtions - ************************************************************/ - -/************************************************************ - * Name: up_undefinedinsn - ************************************************************/ - -/* A little faster than most memcpy's */ - -void up_copystate(uint32 *dest, uint32 *src) -{ - int i; - for (i = 0; i < XCPTCONTEXT_REGS; i++) - { - *dest++ = *src++; - } -} - diff --git a/nuttx/arch/c5471/src/up_createstack.c b/nuttx/arch/c5471/src/up_createstack.c deleted file mode 100644 index 5af781c51..000000000 --- a/nuttx/arch/c5471/src/up_createstack.c +++ /dev/null @@ -1,127 +0,0 @@ -/************************************************************ - * up_createstack.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <sched.h> -#include <debug.h> -#include <nuttx/kmalloc.h> -#include <nuttx/arch.h> -#include "up_internal.h" - -/************************************************************ - * Private Types - ************************************************************/ - -/************************************************************ - * Private Function Prototypes - ************************************************************/ - -/************************************************************ - * Global Functions - ************************************************************/ - -/************************************************************ - * Name: up_create_stack - * - * Description: - * Allocate a stack for a new thread and setup - * up stack-related information in the TCB. - * - * The following TCB fields must be initialized: - * adj_stack_size: Stack size after adjustment for hardware, - * processor, etc. This value is retained only for debug - * purposes. - * stack_alloc_ptr: Pointer to allocated stack - * adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The - * initial value of the stack pointer. - * - * Inputs: - * tcb: The TCB of new task - * stack_size: The requested stack size. At least this much - * must be allocated. - ************************************************************/ - -STATUS up_create_stack(_TCB *tcb, size_t stack_size) -{ - if (tcb->stack_alloc_ptr && - tcb->adj_stack_size != stack_size) - { - sched_free(tcb->stack_alloc_ptr); - tcb->stack_alloc_ptr = NULL; - } - - if (!tcb->stack_alloc_ptr) - { - tcb->stack_alloc_ptr = (uint32 *)kzmalloc(stack_size); - } - - if (tcb->stack_alloc_ptr) - { - 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 - * register, points to the lowest, valid work address - * (the "top" of the stack). Items on the stack are - * referenced as positive word offsets from sp. - */ - - top_of_stack = (uint32)tcb->stack_alloc_ptr + stack_size - 4; - - /* The Arm7Tdmi stack must be aligned at word (4 byte) - * boundaries. If necessary top_of_stack must be rounded - * down to the next boundary - */ - - top_of_stack &= ~3; - size_of_stack = top_of_stack - (uint32)tcb->stack_alloc_ptr + 4; - - /* Save the adjusted stack values in the _TCB */ - - tcb->adj_stack_ptr = (uint32*)top_of_stack; - tcb->adj_stack_size = size_of_stack; - - up_ledon(LED_STACKCREATED); - return OK; - } - - return ERROR; -} diff --git a/nuttx/arch/c5471/src/up_dataabort.c b/nuttx/arch/c5471/src/up_dataabort.c deleted file mode 100644 index ca1ade723..000000000 --- a/nuttx/arch/c5471/src/up_dataabort.c +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************ - * up_dataabort.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include "os_internal.h" -#include "up_internal.h" - -/************************************************************ - * Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Functions - ************************************************************/ - -/************************************************************ - * Public Funtions - ************************************************************/ - -/************************************************************ - * Name: up_dataabort - ************************************************************/ - -void up_dataabort(uint32 *regs) -{ - PANIC(OSERR_ERREXCEPTION); -} diff --git a/nuttx/arch/c5471/src/up_delay.c b/nuttx/arch/c5471/src/up_delay.c deleted file mode 100644 index 373602d53..000000000 --- a/nuttx/arch/c5471/src/up_delay.c +++ /dev/null @@ -1,102 +0,0 @@ -/************************************************************ - * up_delay.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <unistd.h> -#include <semaphore.h> -#include <string.h> -#include <errno.h> -#include <debug.h> -#include <nuttx/irq.h> -#include <nuttx/arch.h> -#include <nuttx/fs.h> -#include <arch/serial.h> -#include "c5471.h" -#include "os_internal.h" -#include "up_internal.h" - -/************************************************************ - * Definitions - ************************************************************/ - -#define LOOPS_PER_MSEC 1250 - -/************************************************************ - * Private Types - ************************************************************/ - -/************************************************************ - * Private Function Prototypes - ************************************************************/ - -/************************************************************ - * Private Variables - ************************************************************/ - -/************************************************************ - * Private Functions - ************************************************************/ - - -/************************************************************ - * Public Funtions - ************************************************************/ - -/************************************************************ - * Name: up_delay - * - * Description: - * Delay inline for the requested number of milliseconds. - * NOT multi-tasking friendly. - * - ************************************************************/ - -void up_delay(int milliseconds) -{ - volatile int i; - volatile int j; - - for (i = 0; i < milliseconds; i++) - { - for (j = 0; j < LOOPS_PER_MSEC; j++) - { - } - } -} diff --git a/nuttx/arch/c5471/src/up_doirq.c b/nuttx/arch/c5471/src/up_doirq.c deleted file mode 100644 index 73d6f8a76..000000000 --- a/nuttx/arch/c5471/src/up_doirq.c +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************ - * up_doirq.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <nuttx/irq.h> -#include <nuttx/arch.h> -#include <assert.h> -#include "c5471.h" -#include "os_internal.h" -#include "up_internal.h" - -/************************************************************ - * Definitions - ************************************************************/ - -/************************************************************ - * Public Data - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Functions - ************************************************************/ - -/************************************************************ - * Public Funtions - ************************************************************/ - -void up_doirq(int irq, uint32* regs) -{ - up_ledon(LED_INIRQ); -#ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(OSERR_ERREXCEPTION); -#else - if ((unsigned)irq < NR_IRQS) - { - /* Current regs non-zero indicates that we are processing - * an interrupt; current_regs is also used to manage - * interrupt level context switches. - */ - - current_regs = regs; - - /* Mask and acknowledge the interrupt */ - - up_maskack_irq(irq); - - /* Deliver the IRQ */ - - irq_dispatch(irq, regs); - - /* Indicate that we are no long in an interrupt handler */ - - current_regs = NULL; - - /* Unmask the last interrupt (global interrupts are still - * disabled. - */ - - up_enable_irq(irq); - } - up_ledoff(LED_INIRQ); -#endif -} diff --git a/nuttx/arch/c5471/src/up_exit.c b/nuttx/arch/c5471/src/up_exit.c deleted file mode 100644 index 4d117fce4..000000000 --- a/nuttx/arch/c5471/src/up_exit.c +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************** - * up_exit.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 <nuttx/config.h> -#include <sys/types.h> -#include <sched.h> -#include <debug.h> -#include <nuttx/arch.h> -#include "os_internal.h" -#include "up_internal.h" - -#ifdef CONFIG_DUMP_ON_EXIT -#include <nuttx/fs.h> -#endif - -/**************************************************************************** - * Private Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _up_dumponexit - * - * Description: - * Dump the state of all tasks whenever on task exits. This is debug - * instrumentation that was added to check file-related reference counting - * but could be useful again sometime in the future. - * - ****************************************************************************/ - -#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG) -static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg) -{ - int i; - - lldbg(" TCB=%p name=%s\n", tcb, tcb->argv[0]); - if (tcb->filelist) - { - lldbg(" filelist refcount=%d\n", - tcb->filelist->fl_crefs); - - for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++) - { - struct inode *inode = tcb->filelist->fl_files[i].f_inode; - if (inode) - { - lldbg(" fd=%d refcount=%d\n", - i, inode->i_crefs); - } - } - } - - if (tcb->streams) - { - lldbg(" streamlist refcount=%d\n", - tcb->streams->sl_crefs); - - for (i = 0; i < CONFIG_NFILE_STREAMS; i++) - { - struct file_struct *filep = &tcb->streams->sl_streams[i]; - if (filep->fs_filedes >= 0) - { - lldbg(" fd=%d nbytes=%d\n", - filep->fs_filedes, - filep->fs_bufpos - filep->fs_bufstart); - } - } - } -} -#endif - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _exit - * - * Description: - * This function causes the currently executing task to cease - * to exist. This is a special case of task_delete() where the task to - * be deleted is the currently executing task. It is more complex because - * a context switch must be perform to the the next ready to run task. - * - ****************************************************************************/ - -void _exit(int status) -{ - _TCB* tcb; - - /* Disable interrupts. They will be restored when the next - * task is started. - */ - - (void)irqsave(); - - lldbg("TCB=%p exitting\n", tcb); - -#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG) - lldbg("Other tasks:\n"); - sched_foreach(_up_dumponexit, NULL); -#endif - - /* Destroy the task at the head of the ready to run list. */ - - (void)task_deletecurrent(); - - /* Now, perform the context switch to the new ready-to-run task at the - * head of the list. - */ - - tcb = (_TCB*)g_readytorun.head; - lldbg("New Active Task TCB=%p\n", tcb); - - /* Then switch contexts */ - - up_fullcontextrestore(tcb->xcp.regs); -} - diff --git a/nuttx/arch/c5471/src/up_fullcontextrestore.S b/nuttx/arch/c5471/src/up_fullcontextrestore.S deleted file mode 100644 index 4d0303ba2..000000000 --- a/nuttx/arch/c5471/src/up_fullcontextrestore.S +++ /dev/null @@ -1,117 +0,0 @@ -/************************************************************************** - * up_fullcontextrestore.S - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/irq.h> -#include "up_internal.h" - -/************************************************************************** - * Private Definitions - **************************************************************************/ - -/************************************************************************** - * Private Types - **************************************************************************/ - -/************************************************************************** - * Private Function Prototypes - **************************************************************************/ - -/************************************************************************** - * Global Variables - **************************************************************************/ - -/************************************************************************** - * Private Variables - **************************************************************************/ - -/************************************************************************** - * Private Functions - **************************************************************************/ - -/************************************************************************** - * Public Functions - **************************************************************************/ - -/************************************************************************** - * Name: up_fullcontextrestore - **************************************************************************/ - - .globl up_fullcontextrestore - .type up_fullcontextrestore, function -up_fullcontextrestore: - - /* On entry, a1 (r0) holds address of the register save area */ - - /* Recover all registers except for r0, r1, R15, and CPSR */ - - add r1, r0, #(4*REG_R2) /* Offset to REG_R2 storage */ - ldmia r1, {r2-r14} /* Recover registers */ - - /* Create a stack frame to hold the PC */ - - sub sp, sp, #(3*4) /* Frame for three registers */ - ldr r1, [r0, #(4*REG_R0)] /* Fetch the stored r0 value */ - str r1, [sp] /* Save it at the top of the stack */ - ldr r1, [r0, #(4*REG_R1)] /* Fetch the stored r1 value */ - str r1, [sp, #4] /* Save it in the stack */ - ldr r1, [r0, #(4*REG_PC)] /* Fetch the stored pc value */ - str r1, [sp, #8] /* Save it at the bottom of the frame */ - - /* Now we can restore the CPSR. We wait until we are completely - * finished with the context save data to do this. Restore the CPSR - * may re-enable and interrupts and we couldt be in a context - * where save structure is only protected by interrupts being disabled. - */ - - ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the stored CPSR value */ - msr cpsr, r1 /* Set the CPSR */ - - /* Now recover r0 and r1 */ - - ldr r0, [sp] - ldr r1, [sp, #4] - add sp, sp, #(2*4) - - /* Then return to the address at the stop of the stack, - * destroying the stack frame - */ - - ldr pc, [sp], #4 - .size up_fullcontextrestore, . - up_fullcontextrestore - diff --git a/nuttx/arch/c5471/src/up_head.S b/nuttx/arch/c5471/src/up_head.S deleted file mode 100644 index d681a177e..000000000 --- a/nuttx/arch/c5471/src/up_head.S +++ /dev/null @@ -1,162 +0,0 @@ -/************************************************************ - * up_head.S - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include "up_internal.h" -#include "c5471.h" - -/************************************************************ - * Macros - ************************************************************/ - - /* This macro will modify r0, r1, r2 and r14 */ - -#ifdef CONFIG_DEBUG - .macro showprogress, code - mov r0, #\code - bl up_lowputc - .endm -#else - .macro showprogress, code - .endm -#endif - -/************************************************************ - * OS Entry Point - ************************************************************/ - -/* We assume the bootloader has already initialized most of the h/w for - * us and that only leaves us having to do some os specific things - * below. - */ - .text - .global __start - .type __start, #function -__start: - - /* First, setup initial processor mode */ - - mov r0, #(SVC_MODE | I_BIT | F_BIT ) - msr cpsr, r0 - - showprogress 'A' - - /* Setup system stack (and get the BSS range) */ - - adr r0, LC0 - ldmia r0, {r4, r5, sp} - - /* Clear system BSS section */ - - mov r0, #0 -1: cmp r4, r5 - strcc r0, [r4], #4 - bcc 1b - - showprogress 'B' - - /* Copy system .data sections to new home in RAM. */ - -#ifdef CONFIG_BOOT_FROM_FLASH - - adr r3, LC2 - ldmia r3, {r0, r1, r2} - -1: ldmia r0!, {r3 - r10} - stmia r1!, {r3 - r10} - cmp r1, r2 - blt 1b - -#endif - /* Perform early serial initialization */ - - mov fp, #0 - bl up_earlyserialinit - -#ifdef CONFIG_DEBUG - mov r0, #'C' - bl up_putc - mov r0, #'\n' - bl up_putc -#endif - /* Initialize onboard LEDs */ - -#ifdef CONFIG_ARCH_LEDS - bl up_ledinit -#endif - - /* Then jump to OS entry */ - - b os_start - - /* Variables: - * _sbss is the start of the BSS region (see ld.script) - * _ebss is the end of the BSS regsion (see ld.script) - * The idle task stack starts at the end of BSS and is - * of size CONFIG_PROC_STACK_SIZE. The heap continues - * from there until the end of memory. See g_heapbase - * below. - */ - -LC0: .long _sbss - .long _ebss - .long _ebss+CONFIG_PROC_STACK_SIZE-4 - -#ifdef CONFIG_BOOT_FROM_FLASH -LC2: .long _eronly /* Where .data defaults are stored in FLASH */ - .long _sdata /* Where .data needs to reside in SDRAM */ - .long _edata -#endif - .size __start, .-__start - - /* This global variable is unsigned long g_heapbase and is - * exported from here only because of its coupling to LCO - * above. - */ - - .data - .align 4 - .globl g_heapbase - .type g_heapbase, object -g_heapbase: - .long _ebss+CONFIG_PROC_STACK_SIZE - .size g_heapbase, .-g_heapbase - - .end - diff --git a/nuttx/arch/c5471/src/up_idle.c b/nuttx/arch/c5471/src/up_idle.c deleted file mode 100644 index 9a6bc9900..000000000 --- a/nuttx/arch/c5471/src/up_idle.c +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************ - * up_idle.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <nuttx/arch.h> -#include "up_internal.h" - -/************************************************************ - * Private Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Funtions - ************************************************************/ - -/************************************************************ - * Public Funtions - ************************************************************/ - -/************************************************************ - * Name: up_idle - * - * Description: - * up_idle() is the logic that will be executed when their - * is no other ready-to-run task. This is processor idle - * time and will continue until some interrupt occurs to - * cause a context switch from the idle task. - * - * Processing in this state may be processor-specific. e.g., - * this is where power management operations might be - * performed. - * - ************************************************************/ - -void up_idle(void) -{ -#if defined(CONFIG_SUPPRESS_INTERRUPTS) || defined(CONFIG_SUPPRESS_TIMER_INTS) - /* If the system is idle and there are no timer interrupts, - * then process "fake" timer interrupts. Hopefully, something - * will wake up. - */ - - sched_process_timer(); -#endif -} - diff --git a/nuttx/arch/c5471/src/up_initialize.c b/nuttx/arch/c5471/src/up_initialize.c deleted file mode 100644 index 04ca68914..000000000 --- a/nuttx/arch/c5471/src/up_initialize.c +++ /dev/null @@ -1,103 +0,0 @@ -/************************************************************ - * up_initialize.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <debug.h> -#include <nuttx/arch.h> -#include <nuttx/fs.h> -#include "up_internal.h" - -/************************************************************ - * Private Types - ************************************************************/ - -/************************************************************ - * Private Function Prototypes - ************************************************************/ - -/************************************************************ - * Global Functions - ************************************************************/ - -/************************************************************ - * Name: up_initialize - * - * Description: - * up_initialize will be called once during OS - * initialization after the basic OS services have been - * initialized. The architecture specific details of - * initializing the OS will be handled here. Such things as - * setting up interrupt service routines, starting the - * clock, and registering device drivers are some of the - * things that are different for each processor and hardware - * platform. - * - * up_initialize is called after the OS initialized but - * before the init process has been started and before the - * libraries have been initialized. OS services and driver - * services are available. - * - ************************************************************/ - -void up_initialize(void) -{ - /* Initialize global variables */ - - current_regs = NULL; - - /* Initialize the interrupt subsystem */ - - up_irqinitialize(); - - /* Initialize the system timer interrupt */ - -#if !defined(CONFIG_SUPPRESS_INTERRUPTS) && !defined(CONFIG_SUPPRESS_TIMER_INTS) - up_timerinit(); -#endif - - /* Register devices */ - - devnull_register(); /* Standard /dev/null */ - - /* Initialize the serial device driver */ - - up_serialinit(); - up_ledon(LED_IRQSENABLED); -} diff --git a/nuttx/arch/c5471/src/up_initialstate.c b/nuttx/arch/c5471/src/up_initialstate.c deleted file mode 100644 index 76792f695..000000000 --- a/nuttx/arch/c5471/src/up_initialstate.c +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************ - * up_initialstate.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <string.h> -#include <nuttx/arch.h> -#include "up_internal.h" -#include "c5471.h" - -/************************************************************ - * Private Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Funtions - ************************************************************/ - -/************************************************************ - * Public Funtions - ************************************************************/ - -/************************************************************ - * Name: up_initial_state - * - * Description: - * A new thread is being started and a new TCB - * has been created. This function is called to initialize - * the processor specific portions of the new TCB. - * - * This function must setup the intial architecture registers - * and/or stack so that execution will begin at tcb->start - * on the next context switch. - * - ************************************************************/ - -void up_initial_state(_TCB *tcb) -{ - struct xcptcontext *xcp = &tcb->xcp; - - /* Initialize the initial exception register context structure */ - - memset(xcp, 0, sizeof(struct xcptcontext)); - xcp->regs[REG_SP] = (uint32)tcb->adj_stack_ptr; - xcp->regs[REG_PC] = (uint32)tcb->start; -#ifdef CONFIG_SUPPRESS_INTERRUPTS - xcp->regs[REG_CPSR] = SVC_MODE | I_BIT | F_BIT; -#else - xcp->regs[REG_CPSR] = SVC_MODE | F_BIT; -#endif -} diff --git a/nuttx/arch/c5471/src/up_internal.h b/nuttx/arch/c5471/src/up_internal.h deleted file mode 100644 index fc3333bf9..000000000 --- a/nuttx/arch/c5471/src/up_internal.h +++ /dev/null @@ -1,168 +0,0 @@ -/************************************************************ - * up_internal.h - * - * Copyright (C) 2007 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 Gregory Nutt nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ************************************************************/ - -#ifndef __UP_INTERNAL_H -#define __UP_INTERNAL_H - -/************************************************************ - * Included Files - ************************************************************/ - -#include <nuttx/config.h> - -#if defined(CONFIG_ARCH_BOARD_C5471EVM) -# include <arch/board/c5471evm.h> -#else -# warning "Undefined C5471 Board" -#endif - -/************************************************************ - * Definitions - ************************************************************/ - -/* Bring-up debug configurations. These are here (vs defconfig) - * because these should only be controlled during low level - * board bring-up and not part of normal platform configuration. - */ - -#undef CONFIG_SUPPRESS_INTERRUPTS /* Do not enable interrupts */ -#undef CONFIG_SUPPRESS_TIMER_INTS /* No timer */ -#undef CONFIG_SUPPRESS_SERIAL_INTS /* Console will poll */ -#define CONFIG_SUPPRESS_UART_CONFIG 1 /* Do not reconfig UART */ -#undef CONFIG_DUMP_ON_EXIT /* Dump task state on exit */ - -/************************************************************ - * Public Types - ************************************************************/ - -#ifndef __ASSEMBLY__ -typedef void (*up_vector_t)(void); -#endif - -/************************************************************ - * Public Variables - ************************************************************/ - -#ifndef __ASSEMBLY__ -/* This holds a references to the current interrupt level - * register storage structure. If is non-NULL only during - * interrupt processing. - */ - -extern uint32 *current_regs; - -/* This is the beginning of heap as provided from up_head.S. - * This is the first address in DRAM after the loaded - * program+bss+idle stack. The end of the heap is - * CONFIG_DRAM_END - */ - -extern uint32 g_heapbase; -#endif - -/************************************************************ - * Inline Functions - ************************************************************/ - - -/************************************************************ - * Public Functions - ************************************************************/ - -#ifndef __ASSEMBLY__ - -/* Defined in files with the same name as the function */ - -extern void up_copystate(uint32 *dest, uint32 *src); -extern void up_dataabort(uint32 *regs); -extern void up_delay(int milliseconds); -extern void up_doirq(int irq, uint32* regs); -extern void up_fullcontextrestore(uint32 *regs) __attribute__ ((noreturn)); -extern void up_irqinitialize(void); -extern void up_prefetchabort(uint32 *regs); -extern int up_saveusercontext(uint32 *regs); -extern void up_sigdeliver(void); -extern void up_syscall(uint32 *regs); -extern int up_timerisr(int irq, uint32 *regs); -extern void up_undefinedinsn(uint32 *regs); - -#ifdef CONFIG_DEBUG -extern void up_lowputc(char ch); -#else -# define up_lowputc(ch) -#endif - -/* Defined in up_vectors.S */ - -extern void up_vectorundefinsn(void); -extern void up_vectorswi(void); -extern void up_vectorprefetch(void); -extern void up_vectordata(void); -extern void up_vectoraddrexcptn(void); -extern void up_vectorirq(void); -extern void up_vectorfiq(void); - -/* Defined in up_serial.c */ - -extern void up_earlyserialinit(void); -extern void up_serialinit(void); - -/* Defined in up_watchdog.c */ - -extern void up_wdtinit(void); - -/* Defined in up_timerisr.c */ - -extern void up_timerinit(void); - -/* Defined in up_irq.c */ - -extern void up_maskack_irq(int irq); - -/* Defined in up_leds.c */ - -#ifdef CONFIG_ARCH_LEDS -extern void up_ledinit(void); -extern void up_ledon(int led); -extern void up_ledoff(int led); -#else -# define up_ledinit() -# define up_ledon(led) -# define up_ledoff(led) -#endif - -#endif /* __ASSEMBLY__ */ - -#endif /* __UP_INTERNAL_H */ diff --git a/nuttx/arch/c5471/src/up_interruptcontext.c b/nuttx/arch/c5471/src/up_interruptcontext.c deleted file mode 100644 index b6df69ea4..000000000 --- a/nuttx/arch/c5471/src/up_interruptcontext.c +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************ - * up_interruptcontext.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <nuttx/arch.h> -#include <nuttx/irq.h> -#include "up_internal.h" - -/************************************************************ - * Private Types - ************************************************************/ - -/************************************************************ - * Private Function Prototypes - ************************************************************/ - -/************************************************************ - * Global Functions - ************************************************************/ - -/************************************************************ - * Name: up_interrupt_context - * - * Description: Return TRUE is we are currently executing in - * the interrupt handler context. - ************************************************************/ - -boolean up_interrupt_context(void) -{ - return current_regs != NULL; -} diff --git a/nuttx/arch/c5471/src/up_irq.c b/nuttx/arch/c5471/src/up_irq.c deleted file mode 100644 index fabd47b26..000000000 --- a/nuttx/arch/c5471/src/up_irq.c +++ /dev/null @@ -1,242 +0,0 @@ -/************************************************************ - * up_irq.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <nuttx/irq.h> -#include "c5471.h" -#include "os_internal.h" -#include "up_internal.h" - -/************************************************************ - * Definitions - ************************************************************/ - -#define ILR_EDGESENSITIVE 0x00000020 -#define ILR_PRIORITY 0x0000001E - -/************************************************************ - * Public Data - ************************************************************/ - -uint32 *current_regs; - -/************************************************************ - * Private Data - ************************************************************/ - -/* The value of _vflashstart is defined in ld.script. It - * could be hard-coded because we know that correct IRAM - * area is 0xffc00000. - */ - -extern int _svectors; /* Type does not matter */ - -/* The C5471 has FLASH at the low end of memory. The - * rrload bootloaer will catch all interrupts and re-vector - * them to vectors stored in IRAM. The following table is - * used to initialize those vectors. - */ - -static up_vector_t g_vectorinittab[] = -{ - (up_vector_t)NULL, - up_vectorundefinsn, - up_vectorswi, - up_vectorprefetch, - up_vectordata, - up_vectoraddrexcptn, - up_vectorirq, - up_vectorfiq -}; -#define NVECTORS ((sizeof(g_vectorinittab)) / sizeof(up_vector_t)) - -/************************************************************ - * Private Functions - ************************************************************/ - -/************************************************************ - * Name: up_ackirq - * - * Description: - * Acknowlede the IRQ.Bit 0 of the Interrupt Control - * Register == New IRQ agreement (NEW_IRQ_AGR). Reset IRQ - * output. Clear source IRQ register. Enables a new IRQ - * generation. Reset by internal logic. - * - ************************************************************/ - -static inline void up_ackirq(unsigned int irq) -{ - uint32 reg; - reg = getreg32(SRC_IRQ_REG); /* Insure appropriate IT_REG bit clears */ - putreg32(reg | 0x00000001, INT_CTRL_REG); /* write the NEW_IRQ_AGR bit. */ -} - -/************************************************************ - * Name: up_ackfiq - * - * Description: - * Acknowledge the FIQ. Bit 1 of the Interrupt Control - * Register == New FIQ agreement (NEW_FIQ_AGR). Reset FIQ - * output. Clear source FIQ register. Enables a new FIQ - * generation. Reset by internal logic. - * - ************************************************************/ - -static inline void up_ackfiq(unsigned int irq) -{ - uint32 reg; - reg = getreg32(SRC_FIQ_REG); /* Insure appropriate IT_REG bit clears */ - putreg32(reg | 0x00000002, INT_CTRL_REG); /* write the NEW_FIQ_AGR bit. */ -} - -/************************************************************ - * Name: up_vectorinitialize - ************************************************************/ - -static inline void up_vectorinitialize(void) -{ - up_vector_t *src = g_vectorinittab; - up_vector_t *dest = (up_vector_t*)&_svectors; - int i; - - for (i = 0; i < NVECTORS; i++) - { - *dest++ = *src++; - } -} - -/************************************************************ - * Public Funtions - ************************************************************/ - -/************************************************************ - * Name: up_irqinitialize - ************************************************************/ - -void up_irqinitialize(void) -{ - /* Disable all interrupts. */ - - putreg32(0x0000ffff, MASK_IT_REG); - - /* Clear any pending interrupts */ - - up_ackirq(0); - up_ackfiq(0); - putreg32(0x00000000, IT_REG); - - /* Override hardware defaults */ - - putreg32(ILR_EDGESENSITIVE | ILR_PRIORITY, ILR_IRQ2_REG); - putreg32(ILR_EDGESENSITIVE | ILR_PRIORITY, ILR_IRQ4_REG); - putreg32(ILR_PRIORITY, ILR_IRQ6_REG); - putreg32(ILR_EDGESENSITIVE | ILR_PRIORITY, ILR_IRQ15_REG); - - /* Initialize hardware interrupt vectors */ - - up_vectorinitialize(); - current_regs = NULL; - - /* And finally, enable interrupts */ - -#ifndef CONFIG_SUPPRESS_INTERRUPTS - irqrestore(SVC_MODE | F_BIT); -#endif -} - -/************************************************************ - * Name: up_disable_irq - * - * Description: - * Disable the IRQ specified by 'irq' - * - ************************************************************/ - -void up_disable_irq(int irq) -{ - if ((unsigned)irq < NR_IRQS) - { - uint32 reg = getreg32(MASK_IT_REG); - putreg32(reg | (1 << irq), MASK_IT_REG); - } -} - -/************************************************************ - * Name: up_enable_irq - * - * Description: - * Enable the IRQ specified by 'irq' - * - ************************************************************/ - -void up_enable_irq(int irq) -{ - if ((unsigned)irq < NR_IRQS) - { - uint32 reg = getreg32(MASK_IT_REG); - putreg32(reg & ~(1 << irq), MASK_IT_REG); - } -} - -/************************************************************ - * Name: up_maskack_irq - * - * Description: - * Mask the IRQ and acknowledge it - * - ************************************************************/ - -void up_maskack_irq(int irq) -{ - uint32 reg = getreg32(INT_CTRL_REG); - - /* Mask the interrupt */ - - reg = getreg32(MASK_IT_REG); - putreg32(reg | (1 << irq), MASK_IT_REG); - - /* Set the NEW_IRQ_AGR bit. This clears the IRQ src register - * enables generation of a new IRQ. - */ - - reg = getreg32(INT_CTRL_REG); - putreg32(reg | 0x00000001, INT_CTRL_REG); /* write the NEW_IRQ_AGR bit. */ -} diff --git a/nuttx/arch/c5471/src/up_lowputc.S b/nuttx/arch/c5471/src/up_lowputc.S deleted file mode 100644 index 050870c4c..000000000 --- a/nuttx/arch/c5471/src/up_lowputc.S +++ /dev/null @@ -1,127 +0,0 @@ -/************************************************************************** - * up_lowputc.S - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include "up_internal.h" -#include "c5471.h" - -/************************************************************************** - * Private Definitions - **************************************************************************/ - -/************************************************************************** - * Private Types - **************************************************************************/ - -/************************************************************************** - * Private Function Prototypes - **************************************************************************/ - -/************************************************************************** - * Global Variables - **************************************************************************/ - -/************************************************************************** - * Private Variables - **************************************************************************/ - -/************************************************************************** - * Private Functions - **************************************************************************/ - -/************************************************************************** - * Public Functions - **************************************************************************/ - -/************************************************************************** - * Name: up_lowputc - **************************************************************************/ - -/* This assembly language version has the advantage that it can does not - * require a C stack and uses only r0-r1. Hence it can be used during - * early boot phases. - */ - - .text - .global up_lowputc - .type up_lowputc, function -up_lowputc: - /* On entry, r0 holds the character to be printed */ - -#ifdef CONFIG_SERIAL_IRDA_CONSOLE - ldr r2, =UART_IRDA_BASE /* r2=IRDA UART base */ -#else - ldr r2, =UART_MODEM_BASE /* r2=Modem UART base */ -#endif - - /* Poll bit 0 of the UART_SSR register. When the bit - * is clear, the TX FIFO is no longer full - */ - -1: ldr r1, [r2, #UART_SSR_OFFS] - tst r1, #UART_SSR_TXFULL - bne 1b - - /* Send the character by writing it into the UART_THR - * register. - */ - - str r0, [r2, #UART_THR_OFFS] - - /* Wait for the tranmsit holding regiser (THR) to be - * emptied. This is detemined when bit 6 of the LSR - * is set. - */ - -2: ldr r1, [r2, #UART_LSR_OFFS] - tst r1, #0x00000020 - beq 2b - - /* If the character that we just sent was a linefeed, - * then send a carriage return as well. - */ - - teq r0, #'\n' - moveq r0, #'\r' - beq 1b - - /* And return */ - - mov pc, lr - diff --git a/nuttx/arch/c5471/src/up_prefetchabort.c b/nuttx/arch/c5471/src/up_prefetchabort.c deleted file mode 100644 index 7756b7c35..000000000 --- a/nuttx/arch/c5471/src/up_prefetchabort.c +++ /dev/null @@ -1,69 +0,0 @@ -/************************************************************ - * up_prefetchabort.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <nuttx/irq.h> -#include "os_internal.h" -#include "up_internal.h" - -/************************************************************ - * Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Functions - ************************************************************/ - -/************************************************************ - * Public Funtions - ************************************************************/ - -/************************************************************ - * Name: up_prefetchabort - ************************************************************/ - -void up_prefetchabort(uint32 *regs) -{ - PANIC(OSERR_ERREXCEPTION); -} diff --git a/nuttx/arch/c5471/src/up_releasepending.c b/nuttx/arch/c5471/src/up_releasepending.c deleted file mode 100644 index 2b4179687..000000000 --- a/nuttx/arch/c5471/src/up_releasepending.c +++ /dev/null @@ -1,131 +0,0 @@ -/************************************************************ - * up_releasepending.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <sched.h> -#include <debug.h> -#include <nuttx/arch.h> -#include "os_internal.h" -#include "up_internal.h" - -/************************************************************ - * Private Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Funtions - ************************************************************/ - -/************************************************************ - * Public Funtions - ************************************************************/ - -/************************************************************ - * Name: up_release_pending - * - * Description: - * Release and ready-to-run tasks that have - * collected in the pending task list. This can call a - * context switch if a new task is placed at the head of - * the ready to run list. - * - ************************************************************/ - -void up_release_pending(void) -{ - _TCB *rtcb = (_TCB*)g_readytorun.head; - - lldbg("From TCB=%p\n", rtcb); - - /* Merge the g_pendingtasks list into the g_readytorun task list */ - - /* sched_lock(); */ - if (sched_mergepending()) - { - /* The currently active task has changed! We will need to - * switch contexts. First check if we are operating in - * interrupt context: - */ - - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ - - up_copystate(rtcb->xcp.regs, current_regs); - - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ - - rtcb = (_TCB*)g_readytorun.head; - lldbg("New Active Task TCB=%p\n", rtcb); - - /* Then switch contexts */ - - up_copystate(current_regs, rtcb->xcp.regs); - } - - /* Copy the exception context into the TCB of the task that - * was currently active. if up_saveusercontext returns a non-zero - * value, then this is really the previously running task - * restarting! - */ - - else if (!up_saveusercontext(rtcb->xcp.regs)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ - - rtcb = (_TCB*)g_readytorun.head; - lldbg("New Active Task TCB=%p\n", rtcb); - - /* Then switch contexts */ - - up_fullcontextrestore(rtcb->xcp.regs); - } - } -} diff --git a/nuttx/arch/c5471/src/up_releasestack.c b/nuttx/arch/c5471/src/up_releasestack.c deleted file mode 100644 index e300c93bf..000000000 --- a/nuttx/arch/c5471/src/up_releasestack.c +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************ - * up_releasestack.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <sched.h> -#include <debug.h> -#include <nuttx/arch.h> -#include "os_internal.h" -#include "up_internal.h" - -/************************************************************ - * Private Types - ************************************************************/ - -/************************************************************ - * Private Function Prototypes - ************************************************************/ - -/************************************************************ - * Global 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) -{ - if (dtcb->stack_alloc_ptr) - { - sched_free(dtcb->stack_alloc_ptr); - dtcb->stack_alloc_ptr = NULL; - } - - dtcb->adj_stack_size = 0; -} diff --git a/nuttx/arch/c5471/src/up_reprioritizertr.c b/nuttx/arch/c5471/src/up_reprioritizertr.c deleted file mode 100644 index 58f31bba5..000000000 --- a/nuttx/arch/c5471/src/up_reprioritizertr.c +++ /dev/null @@ -1,179 +0,0 @@ -/************************************************************ - * up_reprioritizertr.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <sched.h> -#include <debug.h> -#include <nuttx/arch.h> -#include "os_internal.h" -#include "up_internal.h" - -/************************************************************ - * Private Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Funtions - ************************************************************/ - -/************************************************************ - * Public Funtions - ************************************************************/ - -/************************************************************ - * Name: up_reprioritize_rtr - * - * Description: - * Called when the priority of a running or - * ready-to-run task changes and the reprioritization will - * cause a context switch. Two cases: - * - * 1) The priority of the currently running task drops and the next - * task in the ready to run list has priority. - * 2) An idle, ready to run task's priority has been raised above the - * the priority of the current, running task and it now has the - * priority. - * - * Inputs: - * tcb: The TCB of the task that has been reprioritized - * priority: The new task priority - * - ************************************************************/ - -void up_reprioritize_rtr(_TCB *tcb, ubyte priority) -{ - /* Verify that the caller is sane */ - - if (tcb->task_state < FIRST_READY_TO_RUN_STATE || - tcb->task_state > LAST_READY_TO_RUN_STATE || - priority < SCHED_PRIORITY_MIN || - priority > SCHED_PRIORITY_MAX) - { - PANIC(OSERR_BADREPRIORITIZESTATE); - } - else - { - _TCB *rtcb = (_TCB*)g_readytorun.head; - boolean switch_needed; - - lldbg("TCB=%p PRI=%d\n", tcb, priority); - - /* Remove the tcb task from the ready-to-run list. - * sched_removereadytorun will return TRUE if we just - * remove the head of the ready to run list. - */ - - switch_needed = sched_removereadytorun(tcb); - - /* Setup up the new task priority */ - - tcb->sched_priority = (ubyte)priority; - - /* Return the task to the specified blocked task list. - * sched_addreadytorun will return TRUE if the task was - * added to the new list. We will need to perform a context - * switch only if the EXCLUSIVE or of the two calls is non-zero - * (i.e., one and only one the calls changes the head of the - * ready-to-run list). - */ - - switch_needed ^= sched_addreadytorun(tcb); - - /* Now, perform the context switch if one is needed */ - - if (switch_needed) - { - /* If we are going to do a context switch, then now is the right - * time to add any pending tasks back into the ready-to-run list. - * task list now - */ - - if (g_pendingtasks.head) - { - sched_mergepending(); - } - - /* Are we in an interrupt handler? */ - - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ - - up_copystate(rtcb->xcp.regs, current_regs); - - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ - - rtcb = (_TCB*)g_readytorun.head; - lldbg("New Active Task TCB=%p\n", rtcb); - - /* Then switch contexts */ - - up_copystate(current_regs, rtcb->xcp.regs); - } - - /* Copy the exception context into the TCB at the (old) head of the - * g_readytorun Task list. if up_saveusercontext returns a non-zero - * value, then this is really the previously running task restarting! - */ - - else if (!up_saveusercontext(rtcb->xcp.regs)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ - - rtcb = (_TCB*)g_readytorun.head; - lldbg("New Active Task TCB=%p\n", rtcb); - - /* Then switch contexts */ - - up_fullcontextrestore(rtcb->xcp.regs); - } - } - } -} diff --git a/nuttx/arch/c5471/src/up_saveusercontext.S b/nuttx/arch/c5471/src/up_saveusercontext.S deleted file mode 100644 index 142f3660f..000000000 --- a/nuttx/arch/c5471/src/up_saveusercontext.S +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************************** - * up_saveusercontext.S - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/irq.h> -#include "up_internal.h" - -/************************************************************************** - * Private Definitions - **************************************************************************/ - -/************************************************************************** - * Private Types - **************************************************************************/ - -/************************************************************************** - * Private Function Prototypes - **************************************************************************/ - -/************************************************************************** - * Global Variables - **************************************************************************/ - -/************************************************************************** - * Private Variables - **************************************************************************/ - -/************************************************************************** - * Private Functions - **************************************************************************/ - -/************************************************************************** - * Public Functions - **************************************************************************/ - -/************************************************************************** - * Name: up_saveusercontext - **************************************************************************/ - - .text - .globl up_saveusercontext - .type up_saveusercontext, function -up_saveusercontext: - /* On entry, a1 (r0) holds address of struct xcptcontext. - * Offset to the user region. - */ - - /* Make sure that the return value will be non-zero (the - * value of the other volatile registers don't matter -- - * r1-r3, ip). This function is called throught the - * noraml C calling conventions and the values of these - * registers cannot be assumed at the point of setjmp - * return. - */ - - mov ip, #1 - str ip, [r0, #(4*REG_R0)] - - /* Save the volatile registers (plus r12 which really - * doesn't need to be saved) - */ - - add r1, r0, #(4*REG_R4) - stmia r1, {r4-r14} - - /* Save the current cpsr */ - - mrs r2, cpsr /* R3 = CPSR value */ - add r1, r0, #(4*REG_CPSR) - str r2, [r1] - - /* Finally save the return address as the PC so that we - * return to the exit from this function. - */ - - add r1, r0, #(4*REG_PC) - str lr, [r1] - - /* Return 0 */ - - mov r0, #0 /* Return value == 0 */ - mov pc, lr /* Return */ - .size up_saveusercontext, . - up_saveusercontext - diff --git a/nuttx/arch/c5471/src/up_schedulesigaction.c b/nuttx/arch/c5471/src/up_schedulesigaction.c deleted file mode 100644 index 47b565e2b..000000000 --- a/nuttx/arch/c5471/src/up_schedulesigaction.c +++ /dev/null @@ -1,190 +0,0 @@ -/************************************************************ - * up_schedulesigaction.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <sched.h> -#include <debug.h> -#include <nuttx/arch.h> -#include "os_internal.h" -#include "up_internal.h" -#include "c5471.h" - -/************************************************************ - * Private Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Funtions - ************************************************************/ - -/************************************************************ - * Public Funtions - ************************************************************/ - -/************************************************************ - * Name: up_schedule_sigaction - * - * Description: - * This function is called by the OS when one or more - * signal handling actions have been queued for execution. - * The architecture specific code must configure things so - * that the 'igdeliver' callback is executed on the thread - * specified by 'tcb' as soon as possible. - * - * This function may be called from interrupt handling logic. - * - * This operation should not cause the task to be unblocked - * nor should it cause any immediate execution of sigdeliver. - * Typically, a few cases need to be considered: - * - * (1) This function may be called from an interrupt handler - * During interrupt processing, all xcptcontext structures - * should be valid for all tasks. That structure should - * be modified to invoke sigdeliver() either on return - * from (this) interrupt or on some subsequent context - * switch to the recipient task. - * (2) If not in an interrupt handler and the tcb is NOT - * the currently executing task, then again just modify - * the saved xcptcontext structure for the recipient - * task so it will invoke sigdeliver when that task is - * later resumed. - * (3) If not in an interrupt handler and the tcb IS the - * currently executing task -- just call the signal - * handler now. - * - ************************************************************/ - -void up_schedule_sigaction(_TCB *tcb, sig_deliver_t sigdeliver) -{ - /* Refuse to handle nested signal actions */ - - dbg("tcb=0x%p sigdeliver=0x%p\n", tcb, sigdeliver); - - if (!tcb->xcp.sigdeliver) - { - irqstate_t flags; - - /* Make sure that interrupts are disabled */ - - flags = irqsave(); - - /* First, handle some special cases when the signal is - * being delivered to the currently executing task. - */ - - dbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs); - - if (tcb == (_TCB*)g_readytorun.head) - { - /* CASE 1: We are not in an interrupt handler and - * a task is signalling itself for some reason. - */ - - if (!current_regs) - { - /* In this case just deliver the signal now. */ - - sigdeliver(tcb); - } - - /* CASE 2: We are in an interrupt handler AND the - * interrupted task is the same as the one that - * must receive the signal, then we will have to modify - * the return state as well as the state in the TCB. - */ - - else - { - /* Save the return lr and cpsr and one scratch register - * These will be restored by the signal trampoline after - * the signals have been delivered. - */ - - tcb->xcp.sigdeliver = sigdeliver; - tcb->xcp.saved_pc = current_regs[REG_PC]; - tcb->xcp.saved_cpsr = current_regs[REG_CPSR]; - - /* Then set up to vector to the trampoline with interrupts - * disabled - */ - - current_regs[REG_PC] = (uint32)up_sigdeliver; - current_regs[REG_CPSR] = SVC_MODE | I_BIT | F_BIT; - - /* And make sure that the saved context in the TCB - * is the same as the interrupt return context. - */ - - up_copystate(tcb->xcp.regs, current_regs); - } - } - - /* Otherwise, we are (1) signaling a task is not running - * from an interrupt handler or (2) we are not in an - * interrupt handler and the running task is signalling - * some non-running task. - */ - - else - { - /* Save the return lr and cpsr and one scratch register - * These will be restored by the signal trampoline after - * the signals have been delivered. - */ - - tcb->xcp.sigdeliver = sigdeliver; - tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC]; - tcb->xcp.saved_cpsr = tcb->xcp.regs[REG_CPSR]; - - /* Then set up to vector to the trampoline with interrupts - * disabled - */ - - tcb->xcp.regs[REG_PC] = (uint32)up_sigdeliver; - tcb->xcp.regs[REG_CPSR] = SVC_MODE | I_BIT | F_BIT; - } - - irqrestore(flags); - } -} diff --git a/nuttx/arch/c5471/src/up_serial.c b/nuttx/arch/c5471/src/up_serial.c deleted file mode 100644 index 7b2b9a24e..000000000 --- a/nuttx/arch/c5471/src/up_serial.c +++ /dev/null @@ -1,865 +0,0 @@ -/**************************************************************************** - * up_serial.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 <nuttx/config.h> -#include <sys/types.h> -#include <unistd.h> -#include <semaphore.h> -#include <string.h> -#include <errno.h> -#include <debug.h> -#include <nuttx/irq.h> -#include <nuttx/arch.h> -#include <nuttx/serial.h> -#include <arch/serial.h> -#include "c5471.h" -#include "os_internal.h" -#include "up_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -#define BASE_BAUD 115200 - -#if defined(CONFIG_UART_IRDA_HWFLOWCONTROL) || defined(CONFIG_UART_MODEM_HWFLOWCONTROL) -# define CONFIG_UART_HWFLOWCONTROL -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -struct uart_regs_s -{ - uint32 ier; - uint32 lcr; - uint32 fcr; -#ifdef CONFIG_UART_HWFLOWCONTROL - uint32 efr; - uint32 tcr; -#endif -}; - -struct up_dev_s -{ - unsigned int uartbase; /* Base address of UART registers */ - unsigned int baud_base; /* Base baud for conversions */ - unsigned int baud; /* Configured baud */ - ubyte xmit_fifo_size; /* Size of transmit FIFO */ - ubyte irq; /* IRQ associated with this UART */ - ubyte parity; /* 0=none, 1=odd, 2=even */ - ubyte bits; /* Number of bits (7 or 8) */ -#ifdef CONFIG_UART_HWFLOWCONTROL - boolean flowcontrol; /* TRUE: Hardware flow control - * is enabled. */ -#endif - boolean stopbits2; /* TRUE: Configure with 2 - * stop bits instead of 1 */ - struct uart_regs_s regs; /* Shadow copy of readonly regs */ -}; - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -static int up_setup(struct uart_dev_s *dev); -static void up_shutdown(struct uart_dev_s *dev); -static int up_attach(struct uart_dev_s *dev); -static void up_detach(struct uart_dev_s *dev); -static int up_interrupt(int irq, void *context); -static int up_ioctl(struct file *filep, int cmd, unsigned long arg); -static int up_receive(struct uart_dev_s *dev, unsigned int *status); -static void up_rxint(struct uart_dev_s *dev, boolean enable); -static boolean up_rxavailable(struct uart_dev_s *dev); -static void up_send(struct uart_dev_s *dev, int ch); -static void up_txint(struct uart_dev_s *dev, boolean enable); -static boolean up_txready(struct uart_dev_s *dev); -static boolean up_txempty(struct uart_dev_s *dev); - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -struct uart_ops_s g_uart_ops = -{ - .setup = up_setup, - .shutdown = up_shutdown, - .attach = up_attach, - .detach = up_detach, - .ioctl = up_ioctl, - .receive = up_receive, - .rxint = up_rxint, - .rxavailable = up_rxavailable, - .send = up_send, - .txint = up_txint, - .txready = up_txready, - .txempty = up_txempty, -}; - -/* I/O buffers */ - -static char g_irdarxbuffer[CONFIG_UART_IRDA_RXBUFSIZE]; -static char g_irdatxbuffer[CONFIG_UART_IRDA_TXBUFSIZE]; -static char g_modemrxbuffer[CONFIG_UART_MODEM_RXBUFSIZE]; -static char g_modemtxbuffer[CONFIG_UART_MODEM_TXBUFSIZE]; - -/* This describes the state of the C5471 serial IRDA port. */ - -static struct up_dev_s g_irdapriv = -{ - .xmit_fifo_size = UART_IRDA_XMIT_FIFO_SIZE, - .baud_base = BASE_BAUD, - .uartbase = UART_IRDA_BASE, - .baud = CONFIG_UART_IRDA_BAUD, - .irq = C5471_IRQ_UART_IRDA, - .parity = CONFIG_UART_IRDA_PARITY, - .bits = CONFIG_UART_IRDA_BITS, -#ifdef CONFIG_UART_IRDA_HWFLOWCONTROL - .flowcontrol = TRUE, -#endif - .stopbits2 = CONFIG_UART_IRDA_2STOP, -}; - -static uart_dev_t g_irdaport = -{ - .recv = - { - .size = CONFIG_UART_IRDA_RXBUFSIZE, - .buffer = g_irdarxbuffer, - }, - .xmit = - { - .size = CONFIG_UART_IRDA_TXBUFSIZE, - .buffer = g_irdatxbuffer, - }, - .ops = &g_uart_ops, - .priv = &g_irdapriv, -}; - -/* This describes the state of the C5471 serial Modem port. */ - -static struct up_dev_s g_modempriv = -{ - .xmit_fifo_size = UART_XMIT_FIFO_SIZE, - .baud_base = BASE_BAUD, - .uartbase = UART_MODEM_BASE, - .baud = CONFIG_UART_MODEM_BAUD, - .irq = C5471_IRQ_UART, - .parity = CONFIG_UART_MODEM_PARITY, - .bits = CONFIG_UART_MODEM_BITS, -#ifdef CONFIG_UART_MODEM_HWFLOWCONTROL - .flowcontrol = TRUE, -#endif - .stopbits2 = CONFIG_UART_MODEM_2STOP, -}; - -static uart_dev_t g_modemport = -{ - .recv = - { - .size = CONFIG_UART_MODEM_RXBUFSIZE, - .buffer = g_modemrxbuffer, - }, - .xmit = - { - .size = CONFIG_UART_MODEM_TXBUFSIZE, - .buffer = g_modemtxbuffer, - }, - .ops = &g_uart_ops, - .priv = &g_modempriv, -}; - -/* Now, which one with be tty0/console and which tty1? */ - -#ifdef CONFIG_SERIAL_IRDA_CONSOLE -# define CONSOLE_DEV g_irdaport -# define TTYS0_DEV g_irdaport -# define TTYS1_DEV g_modemport -#else -# define CONSOLE_DEV g_modemport -# define TTYS0_DEV g_modemport -# define TTYS1_DEV g_irdaport -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_inserial - ****************************************************************************/ - -static inline uint32 up_inserial(struct up_dev_s *priv, uint32 offset) -{ - return getreg32(priv->uartbase + offset); -} - -/**************************************************************************** - * Name: up_serialout - ****************************************************************************/ - -static inline void up_serialout(struct up_dev_s *priv, uint32 offset, uint32 value) -{ - putreg32(value, priv->uartbase + offset); -} - -/**************************************************************************** - * Name: up_disableuartint - ****************************************************************************/ - -static inline void up_disableuartint(struct up_dev_s *priv, uint16 *ier) -{ - if (ier) - { - *ier = priv->regs.ier & UART_IER_INTMASK; - } - priv->regs.ier &= ~UART_IER_INTMASK; - up_serialout(priv, UART_IER_OFFS, priv->regs.ier); -} - -/**************************************************************************** - * Name: up_restoreuartint - ****************************************************************************/ - -static inline void up_restoreuartint(struct up_dev_s *priv, uint16 ier) -{ - priv->regs.ier |= ier & (UART_IER_RECVINT|UART_IER_XMITINT); - up_serialout(priv, UART_IER_OFFS, priv->regs.ier); -} - -/**************************************************************************** - * Name: up_waittxready - ****************************************************************************/ - -static inline void up_waittxready(struct up_dev_s *priv) -{ - int tmp; - - for (tmp = 1000 ; tmp > 0 ; tmp--) - { - if ((up_inserial(priv, UART_SSR_OFFS) & UART_SSR_TXFULL) == 0) - { - break; - } - } -} -/**************************************************************************** - * Name: up_disablebreaks - ****************************************************************************/ - -static inline void up_disablebreaks(struct up_dev_s *priv) -{ - priv->regs.lcr &= ~UART_LCR_BOC; - up_serialout(priv, UART_LCR_OFFS, priv->regs.lcr); -} - -/**************************************************************************** - * Name: up_enablebreaks - ****************************************************************************/ - -static inline void up_enablebreaks(struct up_dev_s *priv) -{ - priv->regs.lcr |= UART_LCR_BOC; - up_serialout(priv, UART_LCR_OFFS, priv->regs.lcr); -} - -/**************************************************************************** - * Name: up_setrate - ****************************************************************************/ - -static inline void up_setrate(struct up_dev_s *priv, unsigned int rate) -{ - uint32 div_bit_rate; - - switch (rate) - { - case 115200: - div_bit_rate = BAUD_115200; - break; - case 57600: - div_bit_rate = BAUD_57600; - break; - case 38400: - div_bit_rate = BAUD_38400; - break; - case 19200: - div_bit_rate = BAUD_19200; - break; - case 4800: - div_bit_rate = BAUD_4800; - break; - case 2400: - div_bit_rate = BAUD_2400; - break; - case 1200: - div_bit_rate = BAUD_1200; - break; - case 9600: - default: - div_bit_rate = BAUD_9600; - break; - } - - up_serialout(priv, UART_DIV_BIT_RATE_OFFS, div_bit_rate); -} - -/**************************************************************************** - * Name: up_setup - * - * Description: - * Configure the UART baud, bits, parity, fifos, etc. This - * method is called the first time that the serial port is - * opened. - * - ****************************************************************************/ - -static int up_setup(struct uart_dev_s *dev) -{ -#ifndef CONFIG_SUPPRESS_UART_CONFIG - struct up_dev_s *priv = dev->priv; - unsigned int cval; - - if (priv->bits == 7) - { - cval = UART_LCR_7BITS; - } - else - { - cval = UART_LCR_8BITS; - } - - if (priv->stopbits2) - { - cval |= UART_LCR_2STOP; - } - - if (priv->parity == 1) /* Odd parity */ - { - cval |= (UART_LCR_PAREN|UART_LCR_PARODD); - } - else if (priv->parity == 2) /* Even parity */ - { - cval |= (UART_LCR_PAREN|UART_LCR_PAREVEN); - } - - /* Both the IrDA and MODEM UARTs support RESET and UART mode. */ - - up_serialout(priv, UART_MDR_OFFS, MDR_RESET_MODE); - up_delay(5); - up_serialout(priv, UART_MDR_OFFS, MDR_UART_MODE); - up_delay(5); - - priv->regs.ier = up_inserial(priv, UART_IER_OFFS); - priv->regs.lcr = up_inserial(priv, UART_LCR_OFFS); -#ifdef CONFIG_UART_HWFLOWCONTROL - if (priv->flowcontrol) - { - priv->regs.efr = up_inserial(priv, UART_EFR_OFFS); - priv->regs.tcr = up_inserial(priv, UART_TCR_OFFS); - } -#endif - - up_disableuartint(priv, NULL); - - up_serialout(priv, UART_EFR_OFFS, 0x0010); /* Enable fifo control */ - up_serialout(priv, UART_TFCR_OFFS, 0); /* Reset to 0 */ - up_serialout(priv, UART_RFCR_OFFS, UART_FCR_RX_CLR); /* Clear RX fifo */ - up_serialout(priv, UART_TFCR_OFFS, UART_FCR_TX_CLR); /* Clear TX fifo */ - up_serialout(priv, UART_TFCR_OFFS, UART_FCR_FIFO_EN); /* Enable RX/TX fifos */ - - up_disablebreaks(priv); - - /* Set the RX and TX trigger levels to the minimum */ - - priv->regs.fcr = (priv->regs.fcr & 0xffffffcf) | UART_FCR_FTL; - up_serialout(priv, UART_RFCR_OFFS, priv->regs.fcr); - - priv->regs.fcr = (priv->regs.fcr & 0xffffff3f) | UART_FCR_FTL; - up_serialout(priv, UART_RFCR_OFFS, priv->regs.fcr); - - up_setrate(priv, priv->baud); - - priv->regs.lcr &= 0xffffffe0; /* clear original field, and... */ - priv->regs.lcr |= (uint32)cval; /* Set new bits in that field. */ - up_serialout(priv, UART_LCR_OFFS, priv->regs.lcr); - -#ifdef CONFIG_UART_HWFLOWCONTROL - if (priv->flowcontrol) - { - /* Set the FIFO level triggers for flow control - * Halt = 48 bytes, resume = 12 bytes - */ - - priv->regs.tcr = (priv->regs.tcr & 0xffffff00) | 0x0000003c; - up_serialout(priv, UART_TCR_OFFS, priv->regs.tcr); - - /* Enable RTS/CTS flow control */ - - priv->regs.efr |= 0x000000c0; - up_serialout(priv, UART_EFR_OFFS, priv->regs.efr); - } - else - { - /* Disable RTS/CTS flow control */ - - priv->regs.efr &= 0xffffff3f; - up_serialout(priv, UART_EFR_OFFS, priv->regs.efr); - } -#endif -#endif - return OK; -} - -/**************************************************************************** - * Name: up_shutdown - * - * Description: - * Disable the UART. This method is called when the serial port is closed - * - ****************************************************************************/ - -static void up_shutdown(struct uart_dev_s *dev) -{ - struct up_dev_s *priv = (struct up_dev_s*)CONSOLE_DEV.priv; - up_disableuartint(priv, NULL); -} - -/**************************************************************************** - * Name: up_attach - * - * Description: - * Configure the UART to operation in interrupt driven mode. This method is - * called when the serial port is opened. Normally, this is just after the - * the setup() method is called, however, the serial console may operate in - * a non-interrupt driven mode during the boot phase. - * - * RX and TX interrupts are not enabled when by the attach method (unless the - * hardware supports multiple levels of interrupt enabling). The RX and TX - * interrupts are not enabled until the txint() and rxint() methods are called. - * - ****************************************************************************/ - -static int up_attach(struct uart_dev_s *dev) -{ - struct up_dev_s *priv = (struct up_dev_s*)dev->priv; - int ret; - - /* Attach and enable the IRQ */ - - ret = irq_attach(priv->irq, up_interrupt); - if (ret == OK) - { - /* Enable the interrupt (RX and TX interrupts are still disabled - * in the UART - */ - - up_enable_irq(priv->irq); - } - return ret; -} - -/**************************************************************************** - * Name: up_detach - * - * Description: - * Detach UART interrupts. This method is called when the serial port is - * closed normally just before the shutdown method is called. The exception is - * the serial console which is never shutdown. - * - ****************************************************************************/ - -static void up_detach(struct uart_dev_s *dev) -{ - struct up_dev_s *priv = (struct up_dev_s*)dev->priv; - up_disable_irq(priv->irq); - irq_detach(priv->irq); -} - -/**************************************************************************** - * Name: up_interrupt - * - * Description: - * This is the UART interrupt handler. It will be invoked - * when an interrupt received on the 'irq' It should call - * uart_transmitchars or uart_receivechar to perform the - * appropriate data transfers. The interrupt handling logic\ - * must be able to map the 'irq' number into the approprite - * uart_dev_s structure in order to call these functions. - * - ****************************************************************************/ - -static int up_interrupt(int irq, void *context) -{ - struct uart_dev_s *dev = NULL; - struct up_dev_s *priv; - volatile uint32 cause; - - if (g_irdapriv.irq == irq) - { - dev = &g_irdaport; - } - else if (g_modempriv.irq == irq) - { - dev = &g_modemport; - } - else - { - PANIC(OSERR_INTERNAL); - } - priv = (struct up_dev_s*)dev->priv; - - cause = up_inserial(priv, UART_ISR_OFFS) & 0x0000003f; - - if ((cause & 0x0000000c) == 0x0000000c) - { - uint32 ier_val = 0; - - /* Is this an interrupt from the IrDA UART? */ - - if (irq == C5471_IRQ_UART_IRDA) - { - /* Save the currently enabled IrDA UART interrupts - * so that we can restore the IrDA interrupt state - * below. - */ - - ier_val = up_inserial(priv, UART_IER_OFFS); - - /* Then disable all IrDA UART interrupts */ - - up_serialout(priv, UART_IER_OFFS, 0); - } - - /* Receive characters from the RX fifo */ - - uart_recvchars(dev); - - /* read UART_RHR to clear int condition - * toss = up_inserialchar(priv,&status); - */ - - /* Is this an interrupt from the IrDA UART? */ - - if (irq == C5471_IRQ_UART_IRDA) - { - /* Restore the IrDA UART interrupt enables */ - - up_serialout(priv, UART_IER_OFFS, ier_val); - } - } - else if ((cause & 0x0000000c) == 0x00000004) - { - uart_recvchars(dev); - } - - if ((cause & 0x00000002) != 0) - { - uart_xmitchars(dev); - } - - return OK; -} - -/**************************************************************************** - * Name: up_ioctl - * - * Description: - * All ioctl calls will be routed through this method - * - ****************************************************************************/ - -static int up_ioctl(struct file *filep, int cmd, unsigned long arg) -{ - struct inode *inode = filep->f_inode; - struct uart_dev_s *dev = inode->i_private; - struct up_dev_s *priv = (struct up_dev_s*)dev->priv; - int ret = OK; - - switch (cmd) - { - case TIOCSERGSTRUCT: - { - struct up_dev_s *user = (struct up_dev_s*)arg; - if (!user) - { - *get_errno_ptr() = EINVAL; - ret = ERROR; - } - else - { - memcpy(user, dev, sizeof(struct up_dev_s)); - } - } - break; - - case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ - { - irqstate_t flags = irqsave(); - up_enablebreaks(priv); - irqrestore(flags); - } - break; - - case TIOCCBRK: /* BSD compatibility: Turn break off, unconditionally */ - { - irqstate_t flags; - flags = irqsave(); - up_disablebreaks(priv); - irqrestore(flags); - } - break; - - default: - *get_errno_ptr() = ENOTTY; - ret = ERROR; - break; - } - - return ret; -} - -/**************************************************************************** - * Name: up_receive - * - * Description: - * Called (usually) from the interrupt level to receive one character from - * the UART. Error bits associated with the receipt are provided in the - * the return 'status'. - * - ****************************************************************************/ - -static int up_receive(struct uart_dev_s *dev, unsigned int *status) -{ - struct up_dev_s *priv = (struct up_dev_s*)dev->priv; - uint32 rhr; - uint32 lsr; - - /* Construct a 16bit status word that uses the high byte to - * hold the status bits associated with framing,parity,break - * and a low byte that holds error bits of LSR for - * conditions such as overflow, etc. - */ - - rhr = up_inserial(priv, UART_RHR_OFFS); - lsr = up_inserial(priv, UART_LSR_OFFS); - - *status = (unsigned int)((rhr & 0x0000ff00) | (lsr & 0x000000ff)); - - return rhr & 0x000000ff; -} - -/**************************************************************************** - * Name: up_rxint - * - * Description: - * Call to enable or disable RX interrupts - * - ****************************************************************************/ - -static void up_rxint(struct uart_dev_s *dev, boolean enable) -{ - struct up_dev_s *priv = (struct up_dev_s*)dev->priv; - if (enable) - { -#ifndef CONFIG_SUPPRESS_SERIAL_INTS - priv->regs.ier |= UART_IER_RECVINT; - up_serialout(priv, UART_IER_OFFS, priv->regs.ier); -#endif - } - else - { - priv->regs.ier &= ~UART_IER_RECVINT; - up_serialout(priv, UART_IER_OFFS, priv->regs.ier); - } -} - -/**************************************************************************** - * Name: up_rxavailable - * - * Description: - * Return TRUE if the receive fifo is not empty - * - ****************************************************************************/ - -static boolean up_rxavailable(struct uart_dev_s *dev) -{ - struct up_dev_s *priv = (struct up_dev_s*)dev->priv; - return up_inserial(priv, UART_LSR_OFFS) & UART_RX_FIFO_NOEMPTY; -} - -/**************************************************************************** - * Name: up_send - * - * Description: - * This method will send one byte on the UART - * - ****************************************************************************/ - -static void up_send(struct uart_dev_s *dev, int ch) -{ - struct up_dev_s *priv = (struct up_dev_s*)dev->priv; - up_serialout(priv, UART_THR_OFFS, (ubyte)ch); -} - -/**************************************************************************** - * Name: up_txint - * - * Description: - * Call to enable or disable TX interrupts - * - ****************************************************************************/ - -static void up_txint(struct uart_dev_s *dev, boolean enable) -{ - struct up_dev_s *priv = (struct up_dev_s*)dev->priv; - if (enable) - { -#ifndef CONFIG_SUPPRESS_SERIAL_INTS - priv->regs.ier |= UART_IER_XMITINT; - up_serialout(priv, UART_IER_OFFS, priv->regs.ier); -#endif - } - else - { - priv->regs.ier &= ~UART_IER_XMITINT; - up_serialout(priv, UART_IER_OFFS, priv->regs.ier); - } -} - -/**************************************************************************** - * Name: up_txready - * - * Description: - * Return TRUE if the tranmsit fifo is not full - * - ****************************************************************************/ - -static boolean up_txready(struct uart_dev_s *dev) -{ - struct up_dev_s *priv = (struct up_dev_s*)dev->priv; - return (up_inserial(priv, UART_SSR_OFFS) & UART_SSR_TXFULL) == 0; -} - -/**************************************************************************** - * Name: up_txempty - * - * Description: - * Return TRUE if the transmit fifo is empty - * - ****************************************************************************/ - -static boolean up_txempty(struct uart_dev_s *dev) -{ - struct up_dev_s *priv = (struct up_dev_s*)dev->priv; - return (up_inserial(priv, UART_LSR_OFFS) & UART_LSR_TREF) != 0; -} - -/**************************************************************************** - * Public Funtions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_serialinit - * - * Description: - * Performs the low level UART initialization early in - * debug so that the serial console will be available - * during bootup. This must be called before up_serialinit. - * - ****************************************************************************/ - -void up_earlyserialinit(void) -{ - up_disableuartint(TTYS0_DEV.priv, NULL); - up_disableuartint(TTYS1_DEV.priv, NULL); - - CONSOLE_DEV.isconsole = TRUE; - up_setup(&CONSOLE_DEV); -} - -/**************************************************************************** - * Name: up_serialinit - * - * Description: - * Register serial console and serial ports. This assumes - * that up_earlyserialinit was called previously. - * - ****************************************************************************/ - -void up_serialinit(void) -{ - (void)uart_register("/dev/console", &CONSOLE_DEV); - (void)uart_register("/dev/ttyS0", &TTYS0_DEV); - (void)uart_register("/dev/ttyS1", &TTYS1_DEV); -} - -/**************************************************************************** - * Name: up_putc - * - * Description: - * Provide priority, low-level access to support OS debug - * writes - * - ****************************************************************************/ - -int up_putc(int ch) -{ - struct up_dev_s *priv = (struct up_dev_s*)CONSOLE_DEV.priv; - uint16 ier; - - up_disableuartint(priv, &ier); - up_waittxready(priv); - up_serialout(priv, UART_THR_OFFS, (ubyte)ch); - - /* Check for LF */ - - if (ch == '\n') - { - /* Add CR */ - - up_waittxready(priv); - up_serialout(priv, UART_THR_OFFS, '\r'); - } - - up_waittxready(priv); - up_restoreuartint(priv, ier); - return ch; -} - diff --git a/nuttx/arch/c5471/src/up_sigdeliver.c b/nuttx/arch/c5471/src/up_sigdeliver.c deleted file mode 100644 index 8ec10599a..000000000 --- a/nuttx/arch/c5471/src/up_sigdeliver.c +++ /dev/null @@ -1,135 +0,0 @@ -/************************************************************ - * up_sigdeliver.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <sched.h> -#include <debug.h> -#include <nuttx/irq.h> -#include <nuttx/arch.h> -#include "os_internal.h" -#include "up_internal.h" -#include "c5471.h" - -/************************************************************ - * Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Functions - ************************************************************/ - -/************************************************************ - * Public Funtions - ************************************************************/ - -/************************************************************ - * Name: up_sigdeliver - * - * Description: - * This is the a signal handling trampoline. When a - * signal action was posted. The task context was mucked - * with and forced to branch to this location with interrupts - * disabled. - * - ************************************************************/ - -void up_sigdeliver(void) -{ - _TCB *rtcb = (_TCB*)g_readytorun.head; - uint32 regs[XCPTCONTEXT_REGS]; - sig_deliver_t sigdeliver; - - /* Save the errno. This must be preserved throughout the - * signal handling so that the the user code final gets - * the correct errno value (probably EINTR). - */ - - int saved_errno = rtcb->errno; - - up_ledon(LED_SIGNAL); - - dbg("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", - rtcb, rtcb->xcp.sigdeliver, rtcb->sigpendactionq.head); - ASSERT(rtcb->xcp.sigdeliver != NULL); - - /* Save the real return state on the stack. */ - - up_copystate(regs, rtcb->xcp.regs); - regs[REG_PC] = rtcb->xcp.saved_pc; - regs[REG_CPSR] = rtcb->xcp.saved_cpsr; - - /* Get a local copy of the sigdeliver function pointer. - * we do this so that we can nullify the sigdeliver - * function point in the TCB and accept more signal - * deliveries while processing the current pending - * signals. - */ - - sigdeliver = rtcb->xcp.sigdeliver; - rtcb->xcp.sigdeliver = NULL; - - /* Then restore the task interrupt statat. */ - - irqrestore(regs[REG_CPSR]); - - /* Deliver the signals */ - - sigdeliver(rtcb); - - /* Output any debug messaged BEFORE restoreing errno - * (becuase they may alter errno), then restore the - * original errno that is needed by the user logic - * (it is probably EINTR). - */ - - dbg("Resuming\n"); - rtcb->errno = saved_errno; - - /* Then restore the correct state for this thread of - * execution. - */ - - up_ledoff(LED_SIGNAL); - up_fullcontextrestore(regs); -} diff --git a/nuttx/arch/c5471/src/up_syscall.c b/nuttx/arch/c5471/src/up_syscall.c deleted file mode 100644 index be4cee745..000000000 --- a/nuttx/arch/c5471/src/up_syscall.c +++ /dev/null @@ -1,82 +0,0 @@ -/************************************************************ - * up_syscall.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include "c5471.h" -#include "os_internal.h" -#include "up_internal.h" - -/************************************************************ - * Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * vectors - ************************************************************/ - -/************************************************************ - * Private Functions - ************************************************************/ - -/************************************************************ - * Public Functions - ************************************************************/ - -/************************************************************ - * Name: up_syscall - * - * Description: - * SWI interrupts will vection here with insn=the SWI - * instruction and xcp=the interrupt context - * - * The handler may get the SWI number be de-referencing - * the return address saved in the xcp and decoding - * the SWI instruction - * - ************************************************************/ - -void up_syscall(uint32 *regs) -{ - PANIC(OSERR_ERREXCEPTION); -} diff --git a/nuttx/arch/c5471/src/up_timerisr.c b/nuttx/arch/c5471/src/up_timerisr.c deleted file mode 100644 index d3c03a191..000000000 --- a/nuttx/arch/c5471/src/up_timerisr.c +++ /dev/null @@ -1,125 +0,0 @@ -/************************************************************ - * up_timerisr.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <debug.h> -#include <nuttx/arch.h> -#include "clock_internal.h" -#include "up_internal.h" -#include "c5471.h" - -/************************************************************ - * Definitions - ************************************************************/ - -/* We want the general purpose timer running at the rate - * MSEC_PER_TICK. The C5471 clock is 47.5MHz and we're using - * a timer PTV value of 3 (3 == divide incoming frequency by - * 16) which then yields a 16 bitCLKS_PER_INT value - * of 29687. - * - * 47500000 / 16 = 2968750 clocks/sec - * 2968750 / 100 = 29687 clocks/ 100Hz interrupt - * - */ - -#define CLKS_PER_INT 29687 -#define CLKS_PER_INT_SHIFT 5 -#define AR 0x00000010 -#define ST 0x00000008 -#define PTV 0x00000003 - -/************************************************************ - * Private Types - ************************************************************/ - -/************************************************************ - * Private Function Prototypes - ************************************************************/ - -/************************************************************ - * Global Functions - ************************************************************/ - -/************************************************************ - * Function: up_timerisr - * - * Description: - * The timer ISR will perform a variety of services for - * various portions of the systems. - * - ************************************************************/ - -int up_timerisr(int irq, uint32 *regs) -{ - /* Process timer interrupt */ - - sched_process_timer(); - return 0; -} - -/************************************************************ - * Function: up_timerinit - * - * Description: - * This function is called during start-up to initialize - * the timer interrupt. - * - ************************************************************/ - -void up_timerinit(void) -{ - uint32 val; - - up_disable_irq(C5471_IRQ_SYSTIMER); - - /* Start the general purpose timer running in auto-reload mode - * so that an interrupt is generated at the rate MSEC_PER_TICK. - */ - - val = ((CLKS_PER_INT-1) << CLKS_PER_INT_SHIFT) | AR | ST | PTV; - putreg32(val, C5471_TIMER2_CTRL); - - /* Attach and enable the timer interrupt */ - - irq_attach(C5471_IRQ_SYSTIMER, (xcpt_t)up_timerisr); - up_enable_irq(C5471_IRQ_SYSTIMER); -} - diff --git a/nuttx/arch/c5471/src/up_unblocktask.c b/nuttx/arch/c5471/src/up_unblocktask.c deleted file mode 100644 index b12f8a98c..000000000 --- a/nuttx/arch/c5471/src/up_unblocktask.c +++ /dev/null @@ -1,162 +0,0 @@ -/************************************************************ - * up_unblocktask.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <sched.h> -#include <debug.h> -#include <nuttx/arch.h> -#include "clock_internal.h" -#include "os_internal.h" -#include "up_internal.h" - -/************************************************************ - * Private Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Funtions - ************************************************************/ - -/************************************************************ - * Public Funtions - ************************************************************/ - -/************************************************************ - * Name: up_unblock_task - * - * Description: - * A task is currently in an inactive task list - * but has been prepped to execute. Move the TCB to the - * ready-to-run list, restore its context, and start execution. - * - * Inputs: - * tcb: Refers to the tcb to be unblocked. This tcb is - * in one of the waiting tasks lists. It must be moved to - * the ready-to-run list and, if it is the highest priority - * ready to run taks, executed. - * - ************************************************************/ - -void up_unblock_task(_TCB *tcb) -{ - /* Verify that the context switch can be performed */ - - if ((tcb->task_state < FIRST_BLOCKED_STATE) || - (tcb->task_state > LAST_BLOCKED_STATE)) - { - PANIC(OSERR_BADUNBLOCKSTATE); - } - else - { - _TCB *rtcb = (_TCB*)g_readytorun.head; - - lldbg("Unblocking TCB=%p\n", tcb); - - /* Remove the task from the blocked task list */ - - sched_removeblocked(tcb); - - /* Reset its timeslice. This is only meaningful for round - * robin tasks but it doesn't hurt to do it for all tasks - */ - -#if CONFIG_RR_INTERVAL > 0 - tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK; -#endif - - /* Add the task in the correct location in the prioritized - * g_readytorun task list - */ - - if (sched_addreadytorun(tcb)) - { - /* The currently active task has changed! We need to do - * a context switch to the new task. - * - * Are we in an interrupt handler? - */ - - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ - - up_copystate(rtcb->xcp.regs, current_regs); - - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ - - rtcb = (_TCB*)g_readytorun.head; - lldbg("New Active Task TCB=%p\n", rtcb); - - /* Then switch contexts */ - - up_copystate(current_regs, rtcb->xcp.regs); - } - - /* We are not in an interrupt handler. Copy the user C context - * into the TCB of the task that was previously active. if - * up_saveusercontext returns a non-zero value, then this is really the - * previously running task restarting! - */ - - else if (!up_saveusercontext(rtcb->xcp.regs)) - { - /* Restore the exception context of the new task that is ready to - * run (probably tcb). This is the new rtcb at the head of the - * g_readytorun task list. - */ - - rtcb = (_TCB*)g_readytorun.head; - lldbg("New Active Task TCB=%p\n", rtcb); - - /* Then switch contexts */ - - up_fullcontextrestore(rtcb->xcp.regs); - } - } - } -} diff --git a/nuttx/arch/c5471/src/up_undefinedinsn.c b/nuttx/arch/c5471/src/up_undefinedinsn.c deleted file mode 100644 index 25c46b133..000000000 --- a/nuttx/arch/c5471/src/up_undefinedinsn.c +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************ - * up_undefinedinsn.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include "os_internal.h" -#include "up_internal.h" - -/************************************************************ - * Definitions - ************************************************************/ - -/************************************************************ - * Private Data - ************************************************************/ - -/************************************************************ - * Private Functions - ************************************************************/ - -/************************************************************ - * Public Functions - ************************************************************/ - -/************************************************************ - * Name: up_undefinedinsn - ************************************************************/ - -void up_undefinedinsn(uint32 *regs) -{ - PANIC(OSERR_UNDEFINEDINSN); -} diff --git a/nuttx/arch/c5471/src/up_usestack.c b/nuttx/arch/c5471/src/up_usestack.c deleted file mode 100644 index db2c1796e..000000000 --- a/nuttx/arch/c5471/src/up_usestack.c +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************ - * up_usestack.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <sched.h> -#include <debug.h> -#include <nuttx/kmalloc.h> -#include <nuttx/arch.h> -#include "up_internal.h" - -/************************************************************ - * Private Types - ************************************************************/ - -/************************************************************ - * Private Function Prototypes - ************************************************************/ - -/************************************************************ - * Global Functions - ************************************************************/ - -/************************************************************ - * Name: up_use_stack - * - * Description: - * Setup up stack-related information in the TCB - * using pre-allocated stack memory - * - * The following TCB fields must be initialized: - * adj_stack_size: Stack size after adjustment for hardware, - * processor, etc. This value is retained only for debug - * purposes. - * stack_alloc_ptr: Pointer to allocated stack - * adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The - * initial value of the stack pointer. - * - * Inputs: - * tcb: The TCB of new task - * stack_size: The allocated stack size. - * - ************************************************************/ - -STATUS up_use_stack(_TCB *tcb, void *stack, size_t stack_size) -{ - size_t top_of_stack; - size_t size_of_stack; - - if (tcb->stack_alloc_ptr) - { - sched_free(tcb->stack_alloc_ptr); - } - - /* Save the stack allocation */ - - tcb->stack_alloc_ptr = stack; - - /* The Arm7Tdmi uses a push-down stack: the stack grows - * toward loweraddresses in memory. The stack pointer - * register, points to the lowest, valid work address - * (the "top" of the stack). Items on the stack are - * referenced as positive word offsets from sp. - */ - - top_of_stack = (uint32)tcb->stack_alloc_ptr + stack_size - 4; - - /* The Arm7Tdmi stack must be aligned at word (4 byte) - * boundaries. If necessary top_of_stack must be rounded - * down to the next boundary - */ - - top_of_stack &= ~3; - size_of_stack = top_of_stack - (uint32)tcb->stack_alloc_ptr + 4; - - /* Save the adjusted stack values in the _TCB */ - - tcb->adj_stack_size = top_of_stack; - tcb->adj_stack_size = size_of_stack; - - return OK; -} diff --git a/nuttx/arch/c5471/src/up_vectors.S b/nuttx/arch/c5471/src/up_vectors.S deleted file mode 100644 index d54c43f2b..000000000 --- a/nuttx/arch/c5471/src/up_vectors.S +++ /dev/null @@ -1,449 +0,0 @@ -/************************************************************ - * up_vectors.S - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <nuttx/irq.h> -#include "c5471.h" - -/************************************************************ - * Definitions - ************************************************************/ - -/************************************************************ - * Global Data - ************************************************************/ - - .data -g_irqtmp: - .word 0 /* Saved lr */ - .word 0 /* Saved spsr */ -g_undeftmp: - .word 0 /* Saved lr */ - .word 0 /* Saved spsr */ -g_aborttmp: - .word 0 /* Saved lr */ - .word 0 /* Saved spsr */ - -/************************************************************ - * Macros - ************************************************************/ - -/************************************************************ - * Private Functions - ************************************************************/ - - .text - -/************************************************************ - * Public Functions - ************************************************************/ - - .text - -/************************************************************ - * Name: up_vectorirq - * - * Description: - * Interrupt excetpion. Entered in IRQ mode with spsr = SVC - * CPSR, lr = SVC PC - ************************************************************/ - - .global up_vectorirq - .type up_vectorirq, %function -up_vectorirq: - /* On entry, we are in IRQ mode. We are free to use - * the IRQ mode r13 and r14. - * - */ - - ldr r13, .Lirqtmp - sub lr, lr, #4 - str lr, [r13] @ save lr_IRQ - mrs lr, spsr - str lr, [r13, #4] @ save spsr_IRQ - - /* Then switch back to SVC mode */ - - bic lr, lr, #MODE_MASK /* Keep F and T bits */ - orr lr, lr, #I_BIT | SVC_MODE - msr cpsr_c, lr /* Switch to SVC mode */ - - /* Create a context structure. First set aside a stack frame - * and store r0-r12 into the frame. - */ - - sub sp, sp, #XCPTCONTEXT_SIZE - stmia sp, {r0-r12} /* Save the SVC mode regs */ - - /* Get the correct values of r13(sp) and r14(lr) in r1 and r2 */ - - add r1, sp, #XCPTCONTEXT_SIZE - mov r2, r14 - - /* Get the values for r15(pc) and CPSR in r3 and r4 */ - - ldr r0, .Lirqtmp /* Points to temp storage */ - ldmia r0, {r3, r4} /* Recover r1=lr_IRQ, r2=spsr_IRQ */ - - add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ - stmia r0, {r1-r4} - - /* Now decode the interrupt */ - -#if 0 - ldr lr, =SRC_IRQ_BIN_REG /* Fetch encoded IRQ */ - ldr r0, [lr] - and r0, r0, #0x0f /* Valid range is 0..15 */ - - /* Problems here... cannot read SRC_IRQ_BIN_REQ (and/or - * SRC_IRQ_REQ because this will clear edge triggered - * interrupts. Plus, no way to validate spurious - * interrupt. - */ -#else - ldr r6, =SRC_IRQ_REG - ldr r6, [r6] /* Get source IRQ reg */ - mov r0, #0 /* Assume IRQ0_IRQ set */ -.Lmorebits: - tst r6, #1 /* Is IRQ set? */ - bne .Lhaveirq /* Yes... we have the IRQ */ - add r0, r0, #1 /* Setup next IRQ */ - mov r6, r6, lsr #1 /* Shift right one */ - cmp r0, #16 /* Only 16 valid bits */ - bcc .Lmorebits /* Keep until we have looked - * at all bits */ - b .Lnoirqset /* If we get here, there is - * no pending interrupt */ -.Lhaveirq: -#endif - /* Then call the IRQ handler with interrupt disabled. */ - - mov fp, #0 /* Init frame pointer */ - mov r1, sp /* Get r1=xcp */ - bl up_doirq /* Call the handler */ - - /* Restore the CPSR, SVC modr registers and return */ -.Lnoirqset: - ldr r0, [sp, #(4*REG_CPSR)] /* Setup the SVC mode SPSR */ - msr spsr, r0 - ldmia sp, {r0-r15}^ /* Return */ - -.Lirqtmp: - .word g_irqtmp - - .align 5 - -/************************************************************ - * Function: up_vectorswi - * - * Description: - * SWI interrupt. We enter the SWI in SVC mode - ************************************************************/ - - .global up_vectorswi - .type up_vectorswi, %function -up_vectorswi: - - /* The c547x rrload bootloader intemediates all - * interrupts. For the* case of the SWI, it mucked - * with the stack to create some temporary registers. - * We'll have to recover from this mucking here. - */ - - ldr r14, [sp,#-0x4] /* rrload workaround */ - - /* Create a context structure. First set aside a stack frame - * and store r0-r12 into the frame. - */ - - sub sp, sp, #XCPTCONTEXT_SIZE - stmia sp, {r0-r12} /* Save the SVC mode regs */ - - /* Get the correct values of r13(sp), r14(lr), r15(pc) - * and CPSR in r1-r4 */ - - add r1, sp, #XCPTCONTEXT_SIZE - mov r2, r14 /* R14 is altered on return from SWI */ - mov r3, r14 /* Save r14 as the PC as well */ - mrs r4, spsr /* Get the saved CPSR */ - - add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ - stmia r0, {r1-r4} - - /* Then call the SWI handler with interrupt disabled. - * void up_syscall(struct xcptcontext *xcp) - */ - - mov fp, #0 /* Init frame pointer */ - mov r0, sp /* Get r0=xcp */ - bl up_syscall /* Call the handler */ - - /* Restore the CPSR, SVC modr registers and return */ - - ldr r0, [sp, #(4*REG_CPSR)] /* Setup the SVC mode SPSR */ - msr spsr, r0 - ldmia sp, {r0-r15}^ /* Return */ - - .align 5 - -/************************************************************ - * Name: up_vectordata - * - * Description: - * Data abort Exception dispatcher. Give control to data - * abort handler. This function is entered in ABORT mode - * with spsr = SVC CPSR, lr = SVC PC - * - ************************************************************/ - - .global up_vectordata - .type up_vectordata, %function -up_vectordata: - /* On entry we are free to use the ABORT mode registers - * r13 and r14 - */ - - ldr r13, .Ldaborttmp /* Points to temp storage */ - sub lr, lr, #8 /* Fixup return */ - str lr, [r13] /* Save in temp storage */ - mrs lr, spsr /* Get SPSR */ - str lr, [r13, #4] /* Save in temp storage */ - - /* Then switch back to SVC mode */ - - bic lr, lr, #MODE_MASK /* Keep F and T bits */ - orr lr, lr, #I_BIT | SVC_MODE - msr cpsr_c, lr /* Switch to SVC mode */ - - /* Create a context structure. First set aside a stack frame - * and store r0-r12 into the frame. - */ - - sub sp, sp, #XCPTCONTEXT_SIZE - stmia sp, {r0-r12} /* Save the SVC mode regs */ - - /* Get the correct values of r13(sp) and r14(lr) in r1 and r2 */ - - add r1, sp, #XCPTCONTEXT_SIZE - mov r2, r14 - - /* Get the values for r15(pc) and CPSR in r3 and r4 */ - - ldr r0, .Ldaborttmp /* Points to temp storage */ - ldmia r0, {r3, r4} /* Recover r1=lr_IRQ, r2=spsr_IRQ */ - - add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ - stmia r0, {r1-r4} - - /* Then call the data abort handler with interrupt disabled. - * void up_dataabort(struct xcptcontext *xcp) - */ - - mov fp, #0 /* Init frame pointer */ - mov r0, sp /* Get r0=xcp */ - bl up_dataabort /* Call the handler */ - - /* Restore the CPSR, SVC modr registers and return */ - - ldr r0, [sp, #(4*REG_CPSR)] /* Setup the SVC mode SPSR */ - msr spsr_cxsf, r0 - ldmia sp, {r0-r15}^ /* Return */ - -.Ldaborttmp: - .word g_aborttmp - - .align 5 - -/************************************************************ - * Name: up_vectorprefetch - * - * Description: - * Prefetch abort exception. Entered in ABT mode with - * spsr = SVC CPSR, lr = SVC PC - ************************************************************/ - - .global up_vectorprefetch - .type up_vectorprefetch, %function -up_vectorprefetch: - /* On entry we are free to use the ABORT mode registers - * r13 and r14 - */ - - ldr r13, .Lpaborttmp /* Points to temp storage */ - sub lr, lr, #4 /* Fixup return */ - str lr, [r13] /* Save in temp storage */ - mrs lr, spsr /* Get SPSR */ - str lr, [r13, #4] /* Save in temp storage */ - - /* Then switch back to SVC mode */ - - bic lr, lr, #MODE_MASK /* Keep F and T bits */ - orr lr, lr, #I_BIT | SVC_MODE - msr cpsr_c, lr /* Switch to SVC mode */ - - /* Create a context structure. First set aside a stack frame - * and store r0-r12 into the frame. - */ - - sub sp, sp, #XCPTCONTEXT_SIZE - stmia sp, {r0-r12} /* Save the SVC mode regs */ - - /* Get the correct values of r13(sp) and r14(lr) in r1 and r2 */ - - add r1, sp, #XCPTCONTEXT_SIZE - mov r2, r14 - - /* Get the values for r15(pc) and CPSR in r3 and r4 */ - - ldr r0, .Lpaborttmp /* Points to temp storage */ - ldmia r0, {r3, r4} /* Recover r1=lr_IRQ, r2=spsr_IRQ */ - - add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ - stmia r0, {r1-r4} - - /* Then call the prefetch abort handler with interrupt disabled. - * void up_prefetchabort(struct xcptcontext *xcp) - */ - - mov fp, #0 /* Init frame pointer */ - mov r0, sp /* Get r0=xcp */ - bl up_prefetchabort /* Call the handler */ - - /* Restore the CPSR, SVC modr registers and return */ - - ldr r0, [sp, #(4*REG_CPSR)] /* Setup the SVC mode SPSR */ - msr spsr_cxsf, r0 - ldmia sp, {r0-r15}^ /* Return */ - -.Lpaborttmp: - .word g_aborttmp - - .align 5 - -/************************************************************ - * Name: up_vectorundefinsn - * - * Description: - * Undefined instruction entry exception. Entered in - * UND mode, spsr = SVC CPSR, lr = SVC PC - * - ************************************************************/ - - .global up_vectorundefinsn - .type up_vectorundefinsn, %function -up_vectorundefinsn: - /* On entry we are free to use the UND mode registers - * r13 and r14 - */ - - ldr r13, .Lundeftmp /* Points to temp storage */ - str lr, [r13] /* Save in temp storage */ - mrs lr, spsr /* Get SPSR */ - str lr, [r13, #4] /* Save in temp storage */ - - /* Then switch back to SVC mode */ - - bic lr, lr, #MODE_MASK /* Keep F and T bits */ - orr lr, lr, #I_BIT | SVC_MODE - msr cpsr_c, lr /* Switch to SVC mode */ - - /* Create a context structure. First set aside a stack frame - * and store r0-r12 into the frame. - */ - - sub sp, sp, #XCPTCONTEXT_SIZE - stmia sp, {r0-r12} /* Save the SVC mode regs */ - - /* Get the correct values of r13(sp) and r14(lr) in r1 and r2 */ - - add r1, sp, #XCPTCONTEXT_SIZE - mov r2, r14 - - /* Get the values for r15(pc) and CPSR in r3 and r4 */ - - ldr r0, .Lundeftmp /* Points to temp storage */ - ldmia r0, {r3, r4} /* Recover r1=lr_IRQ, r2=spsr_IRQ */ - - add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ - stmia r0, {r1-r4} - - /* Then call the undef insn handler with interrupt disabled. - * void up_undefinedinsn(struct xcptcontext *xcp) - */ - - mov fp, #0 /* Init frame pointer */ - mov r0, sp /* Get r0=xcp */ - bl up_undefinedinsn /* Call the handler */ - - /* Restore the CPSR, SVC modr registers and return */ - - ldr r0, [sp, #(4*REG_CPSR)] /* Setup the SVC mode SPSR */ - msr spsr_cxsf, r0 - ldmia sp, {r0-r15}^ /* Return */ - -.Lundeftmp: - .word g_undeftmp - - .align 5 - -/************************************************************ - * Name: up_vectorfiq - * - * Description: - * Shouldn't happen - ************************************************************/ - - .global up_vectorfiq - .type up_vectorfiq, %function -up_vectorfiq: - subs pc, lr, #4 - -/************************************************************ - * Name: up_vectoraddrexcption - * - * Description: - * Shouldn't happen - * - ************************************************************/ - - .global up_vectoraddrexcptn - .type up_vectoraddrexcptn, %function -up_vectoraddrexcptn: - b up_vectoraddrexcptn - .end diff --git a/nuttx/arch/c5471/src/up_watchdog.c b/nuttx/arch/c5471/src/up_watchdog.c deleted file mode 100644 index efa233d4f..000000000 --- a/nuttx/arch/c5471/src/up_watchdog.c +++ /dev/null @@ -1,392 +0,0 @@ -/************************************************************************** - * up_watchdog.c - * - * Copyright (C) 2007 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 Gregory Nutt 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 <nuttx/config.h> -#include <sys/types.h> -#include <stdio.h> -#include <debug.h> -#include <errno.h> -#include <nuttx/fs.h> -#include <nuttx/irq.h> -#include <arch/watchdog.h> -#include "c5471.h" - -/************************************************************************** - * Definitions - **************************************************************************/ - -#undef CONFIG_SOFTWARE_TEST -#undef CONFIG_SOFTWARE_REBOOT -#undef CONFIG_WATCHDOG_STRICT - -#define MAX_WDT_USEC 353200 -#define MAX_PRESCALER 256 -#define C5471_TIMER_STOP 0 - -#define C5471_TIMER_PRESCALER 0x07 /* Bits 0-2: Prescale value */ -#define C5471_TIMER_STARTBIT (1 << 3) /* Bit 3: Start timer bit */ -#define C5471_TIMER_AUTORELOAD (1 << 4) /* Bit 4: Auto-reload timer */ -#define C5471_TIMER_LOADTIM (0xffff << 5) /* Bits 20-5: Load timer value */ -#define C5471_TIMER_MODE (1 << 21) /* Bit 21: Timer mode */ -#define C5471_DISABLE_VALUE1 (0xf5 << 22) /* Bits 29-22: WD disable */ -#define C5471_DISABLE_VALUE2 (0xa0 << 22) - -#define CLOCK_KHZ 47500 -#define CLOCK_MHZx2 95 - -/* Macros to manage access to to watchdog timer macros */ - -#define c5471_wdt_cntl (*(volatile uint32*)C5471_TIMER0_CTRL) -#define c5471_wdt_count (*(volatile uint32*)C5471_TIMER0_CNT) - -/************************************************************************** - * Private Types - **************************************************************************/ - -/************************************************************************** - * Private Function Prototypes - **************************************************************************/ - -/* Local implementation of timer interface */ - -static inline unsigned int wdt_prescaletoptv(unsigned int prescale); - -static int wdt_setusec(uint32 usec); -static int wdt_interrupt(int irq, void *context); - -static int wdt_open(struct file *filep); -static int wdt_close(struct file *filep); -static ssize_t wdt_read(struct file *filep, char *buffer, size_t buflen); -static ssize_t wdt_write(struct file *filep, const char *buffer, size_t buflen); -static int wdt_ioctl(struct file *filep, int cmd, uint32 arg); - -/************************************************************************** - * Private Data - **************************************************************************/ - -static boolean g_wdtopen; - -struct file_operations g_wdtops = -{ - .open = wdt_open, - .close = wdt_close, - .read = wdt_read, - .write = wdt_write, - .ioctl = wdt_ioctl, -}; - -/************************************************************************** - * Private Functions - **************************************************************************/ - -/************************************************************************** - * Name: wdt_prescaletoptv - **************************************************************************/ - -static inline unsigned int wdt_prescaletoptv(unsigned int prescale) -{ - unsigned int ptv = 0; - - if (prescale > 255) - { - ptv = 7; - } - else - { - unsigned int value = prescale >> 1; - - /* 0: 0-2 - * 1: 3-4 - * 2: 5-8 - * 3: 9-16 - * 4: 17-32 - * 5: 33-64 - * 6: 65-128 - * 7: 129- - */ - - while (value > 1) - { - value >>= 1; - ptv++; - } - } - - dbg("prescale=%d -> ptv=%d\n", prescale, ptv); - return ptv; -} - -/************************************************************************** - * Name: wdt_setusec - **************************************************************************/ - -static int wdt_setusec(uint32 usec) -{ - /* prescaler: clock / prescaler = #clock ticks per counter in ptv - * divisor: #counts until the interrupt comes. - */ - - uint32 prescaler = MAX_PRESCALER; - uint32 divisor = 1; - uint32 mode; - - dbg("usec=%d\n", usec); - - /* Calculate a value of prescaler and divisor that will be able - * to count to the usec. It may not be exact or the best - * possible set, but it's a quick and simple algorithm. - * - * divisor max = 0x10000 - * prescaler max = MAX_PRESCALER - */ - - do - { - divisor = (CLOCK_MHZx2 * usec) / (prescaler * 2); - dbg("divisor=0x%x prescaler=0x%x\n", divisor, prescaler); - - if (divisor >= 0x10000) - { - if (prescaler == MAX_PRESCALER) - { - /* This is the max possible ~2.5 seconds. */ - - dbg("prescaler=0x%x too big!\n", prescaler); - return ERROR; - } - - prescaler <<= 1; - if (prescaler > MAX_PRESCALER) - { - prescaler = MAX_PRESCALER; - } - } - } - while (divisor >= 0x10000); - - dbg("prescaler=0x%x divisor=0x%x\n", prescaler, divisor); - - mode = wdt_prescaletoptv(prescaler); - mode &= ~C5471_TIMER_AUTORELOAD; /* One shot mode. */ - mode |= divisor << 5; - dbg("mode=0x%x\n", mode); - - c5471_wdt_cntl = mode; - - /* Now start the watchdog */ - - c5471_wdt_cntl |= C5471_TIMER_STARTBIT; - dbg("cntl_timer=0x%x\n", c5471_wdt_cntl); - - return 0; -} - -/************************************************************************** - * Private Functions - **************************************************************************/ - -/************************************************************************** - * Name: wdt_interrupt - **************************************************************************/ - -static int wdt_interrupt(int irq, void *context) -{ - dbg("expired\n"); - -#if defined(CONFIG_SOFTWARE_REBOOT) -# if defined(CONFIG_SOFTWARE_TEST) - dbg(" Test only\n"); -# else - dbg(" Re-booting\n"); -# warning "Add logic to reset CPU here" -# endif -#else - dbg(" No reboot\n"); -#endif - return OK; -} - -/************************************************************************** - * Name: wdt_read - **************************************************************************/ - -static ssize_t wdt_read(struct file *filep, char *buffer, size_t buflen) -{ - /* We are going to return "NNNNNNNN NNNNNNNN." The followig logic will - * not work if the user provides a buffer smaller than 18 bytes. - */ - - dbg("buflen=%d\n", buflen); - if (buflen >= 18) - { - sprintf(buffer, "#08x %08x\n", c5471_wdt_cntl, c5471_wdt_count); - return 18; - } - return 0; -} - -/************************************************************************** - * Name: wdt_write - **************************************************************************/ - -static ssize_t wdt_write(struct file *filep, const char *buffer, size_t buflen) -{ - dbg("buflen=%d\n", buflen); - if (buflen) - { - /* Reset the timer to the maximum delay */ - - wdt_setusec(MAX_WDT_USEC); - return 1; - } - - return 0; -} - -/************************************************************************** - * Name: wdt_ioctl - **************************************************************************/ - -static int wdt_ioctl(struct file *filep, int cmd, uint32 arg) -{ - dbg("ioctl Call: cmd=0x%x arg=0x%x", cmd, arg); - - /* Process the the IOCTL command (see arch/watchdog.h) */ - - switch(cmd) - { - case WDIOC_KEEPALIVE: - wdt_setusec(MAX_WDT_USEC); - break; - - default: - *get_errno_ptr() = ENOTTY; - return ERROR; - } - - return OK; -} - -/************************************************************************** - * Name: wdt_open - **************************************************************************/ - -static int wdt_open(struct file *filep) -{ - dbg(""); - - if (g_wdtopen) - { - *get_errno_ptr() = EBUSY; - } - - /* This will automatically load the timer with its max - * count and start it running. - */ - - c5471_wdt_cntl = C5471_DISABLE_VALUE1; - c5471_wdt_cntl = C5471_DISABLE_VALUE2; - - g_wdtopen = TRUE; - return OK; -} - -/************************************************************************** - * Name: wdt_close - **************************************************************************/ - -static int wdt_close(struct file *filep) -{ - dbg(""); - - /* The task controlling the watchdog has terminated. Take the timer - * the - * watchdog in interrupt mode -- we are going to reset unless the - * reopened again soon. - */ - -#ifndef CONFIG_WATCHDOG_STRICT - c5471_wdt_cntl = C5471_TIMER_MODE; -#endif - - g_wdtopen = FALSE; - return 0; -} - -/************************************************************************** - * Public Functions - **************************************************************************/ - -/************************************************************************** - * Name: up_wdtinit - **************************************************************************/ - -int up_wdtinit(void) -{ - int ret; - - dbg("C547x Watchdog Driver\n"); - - /* Register as /dev/wdt */ - - ret = register_driver("/dev/wdt", &g_wdtops, 0666, NULL); - if (ret) - { - return ERROR; - } - - /* Register for an interrupt level callback through wdt_interrupt */ - - dbg("Attach to IRQ=%d\n", C5471_IRQ_WATCHDOG); - - /* Make sure that the timer is stopped */ - - c5471_wdt_cntl = C5471_TIMER_STOP; - - /* Request the interrupt. */ - - ret = irq_attach(C5471_IRQ_WATCHDOG, wdt_interrupt); - if (ret) - { - unregister_driver("/dev/wdt"); - return ERROR; - } - - return OK; -} |