Fleshing out PIC32 port

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3632 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2011-05-20 16:19:01 +00:00
parent 7731994b6e
commit bdb91af7c9
13 changed files with 1593 additions and 337 deletions
-2
View File
@@ -153,8 +153,6 @@ void up_initialize(void)
#ifdef CONFIG_USE_SERIALDRIVER
up_serialinit();
#elif defined(CONFIG_DEV_LOWCONSOLE)
lowconsole_init();
#endif
/* Initialize the netwok */
+59 -60
View File
@@ -95,17 +95,15 @@ typedef void (*up_vector_t)(void);
****************************************************************************/
#ifndef __ASSEMBLY__
/* This holds a references to the current interrupt level
* register storage structure. If is non-NULL only during
* interrupt processing.
/* This holds a references to the current interrupt level register storage
* structure. If is non-NULL only during interrupt processing.
*/
extern volatile uint32_t *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
/* 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_t g_heapbase;
@@ -155,27 +153,22 @@ extern uint32_t _bmxdupba_address; /* BMX register setting */
****************************************************************************/
#ifndef __ASSEMBLY__
/* Common Functions *********************************************************/
/* Common functions define in arch/mips/src/common. These may be replaced
* with chip-specific functions of the same name if needed. See also
* functions prototyped in include/nuttx/arch.h.
*/
/* Defined in files with the same name as the function */
/* Context switching */
extern void up_boot(void);
extern void up_copystate(uint32_t *dest, uint32_t *src);
extern void up_irqinitialize(void);
#ifdef CONFIG_ARCH_DMA
extern void weak_function up_dmainitialize(void);
#endif
extern void up_sigdeliver(void);
extern int up_timerisr(int irq, uint32_t *regs);
extern void up_lowputc(char ch);
/* Serial output */
extern void up_puts(const char *str);
extern void up_lowputs(const char *str);
/* Two alternative interrupt handling functions */
extern uint32_t *up_decodeirq(uint32_t *regs);
extern uint32_t *up_doirq(int irq, uint32_t *regs);
/* Defined in up_dumpstate.c */
/* Debug */
#ifdef CONFIG_ARCH_STACKDUMP
extern void up_dumpstate(void);
@@ -183,7 +176,30 @@ extern void up_dumpstate(void);
# define up_dumpstate()
#endif
/* Defined in up_allocateheap.c */
/* Common MIPS32 functions defined in arch/mips/src/MIPS32 */
/* IRQs */
extern uint32_t *up_doirq(int irq, uint32_t *regs);
/* Signals */
extern void up_sigdeliver(void);
/* Chip-specific functions **************************************************/
/* Chip specific functions defined in arch/mips/src/<chip> */
/* IRQs */
extern void up_irqinitialize(void);
extern void up_maskack_irq(int irq);
extern void up_clrpend_irq(int irq);
/* DMA */
#ifdef CONFIG_ARCH_DMA
extern void weak_function up_dmainitialize(void);
#endif
/* Memory management */
#if CONFIG_MM_REGIONS > 1
void up_addregion(void);
@@ -191,8 +207,9 @@ void up_addregion(void);
# define up_addregion()
#endif
/* Defined in up_serial.c */
/* Serial output */
extern void up_lowputc(char ch);
#if CONFIG_NFILE_DESCRIPTORS > 0
extern void up_earlyserialinit(void);
extern void up_serialinit(void);
@@ -201,44 +218,11 @@ extern void up_serialinit(void);
# define up_serialinit()
#endif
/* Defined in drivers/lowconsole.c */
#ifdef CONFIG_DEV_LOWCONSOLE
extern void lowconsole_init(void);
#else
# define lowconsole_init()
#endif
/* Defined in up_watchdog.c */
extern void up_wdtinit(void);
/* Defined in up_timerisr.c */
/* System timer */
extern void up_timerinit(void);
/* Defined in up_irq.c */
extern void up_maskack_irq(int irq);
extern void up_clrpend_irq(int irq);
/* Defined in board/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
/* Defined in board/up_network.c for board-specific ethernet implementations,
* or chip/xyx_ethernet.c for chip-specific ethernet implementations, or
* common/up_etherstub.c for a cornercase where the network is enable yet
* there is no ethernet driver to be initialized.
*/
/* Network */
#ifdef CONFIG_NET
extern void up_netinitialize(void);
@@ -246,6 +230,8 @@ extern void up_netinitialize(void);
# define up_netinitialize()
#endif
/* USB */
#ifdef CONFIG_USBDEV
extern void up_usbinitialize(void);
extern void up_usbuninitialize(void);
@@ -254,6 +240,19 @@ extern void up_usbuninitialize(void);
# define up_usbuninitialize()
#endif
#endif /* __ASSEMBLY__ */
/* Board-specific functions *************************************************/
/* Board specific functions defined in config/<board>/src */
/* LEDs */
#ifdef CONFIG_ARCH_LEDS
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 /* __ARCH_MIPS_SRC_COMMON_UP_INTERNAL_H */
+3 -2
View File
@@ -39,7 +39,7 @@ HEAD_ASRC = pic32mx-head.S
# Common MIPS files
CMN_ASRCS = up_syscall0.S up_inthandler.S up_bevhandler.S
CMN_ASRCS = up_syscall0.S
CMN_CSRCS = up_allocateheap.c up_assert.c up_blocktask.c up_copystate.c \
up_createstack.c up_doirq.c up_exit.c up_idle.c up_initialize.c \
up_initialstate.c up_interruptcontext.c up_irq.c up_lowputs.c \
@@ -61,7 +61,8 @@ endif
# Required PIC32MX files
CHIP_ASRCS =
CHIP_CSRCS = pic32mx-irq.c pic32mx-timerisr.c
CHIP_CSRCS = pic32mx-irq.c pic32mx-clockconfig.c pic32mx-lowconsole.c pic32mx-lowinit.c \
pic32mx-serial.c pic32mx-timerisr.c
# Configuration-dependent PIC32MX files
+5 -4
View File
@@ -56,7 +56,7 @@
********************************************************************************************/
#if CONFIG_ARCH_INTERRUPTSTACK > 3
.global g_stackbase
.global g_intstackbase
.global g_nestlevel
#endif
@@ -255,9 +255,9 @@
/* Restore the floating point register state */
lw k0, REG_MTLO(k1)
lw k0, REG_MFLO(k1)
mtlo k0
lw k0, REG_MTHI(k1)
lw k0, REG_MFHI(k1)
mthi k0
/* Restore general purpose registers */
@@ -368,7 +368,8 @@
* stack first.
*/
la \tmp3, g_intstack
la \tmp3, g_intstackbase
lw \tmp, (\tmp3)
sw sp, (\tmp3)
move sp, \tmp3
1:
@@ -1,103 +1,92 @@
/****************************************************************************
* arch/mips/src/mips32/up_bevexcptn.S
*
* Copyright (C) 2011 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 <arch/mips32/registers.h>
#include "chip/excptmacros.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Global Symbols
****************************************************************************/
.file "up_bevexcptn.S"
.global up_dobev
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: _bev_exception
*
* Description:
* Boot Exception Vector Handler. Jumps to bev_handler
*
* Input Parameters:
* None
*
* Returned Value:
* Does not return
*
****************************************************************************/
.section .bev_excpt,"ax",@progbits
.set noreorder
.ent _bev_exception
_bev_exception:
la k0, _bev_handler
jr k0
nop
.end _bev_exception
/****************************************************************************
* Name: _bev_handler
*
* Description:
* BEV exception handler
*
****************************************************************************/
.section .bev_handler, "ax", @progbits
.set noreorder
.ent _bev_handler
_bev_handler:
EXCPT_PROLOGUE t0 /* Save registers on stack, enable nested interrupts */
move a0, sp /* Pass register save structure as the parameter 1 */
USE_INTSTACK t0, t1, t2 /* Switch to the interrupt stack */
la t0, up_dobev /* Call up_dobev(regs) */
jalr t0, ra
di /* Disable interrupts */
RESTORE_STACK t0, t1 /* Undo the operations of USE_STACK */
EXCPT_EPILOGUE v0 /* Return to the context returned by up_dobev() */
.end _bev_handler
/**************************************************************************
* arch/mips/src/pic32mx/pic32mx-clockconfig.c
*
* Copyright (C) 2011 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 <arch/board/board.h>
#include "up_arch.h"
#include "up_internal.h"
#include "pic32mx-config.h"
#include "pic32mx-internal.h"
/**************************************************************************
* Private Definitions
**************************************************************************/
/**************************************************************************
* Private Types
**************************************************************************/
/**************************************************************************
* Private Function Prototypes
**************************************************************************/
/**************************************************************************
* Global Variables
**************************************************************************/
/**************************************************************************
* Private Variables
**************************************************************************/
/**************************************************************************
* Private Functions
**************************************************************************/
/**************************************************************************
* Public Functions
**************************************************************************/
/**************************************************************************
* Name: pic32mx_clockconfig
*
* Description:
* Called to initialize the PIC32MX clocking using the settings in board.h.
*
**************************************************************************/
void pic32mx_clockconfig(void)
{
# warning "Missing logic"
}
+103
View File
@@ -0,0 +1,103 @@
/************************************************************************************
* arch/mips/src/pic32mx/pic32mx-config.h
*
* Copyright (C) 2011 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.
*
************************************************************************************/
#ifndef __ARCH_MIPS_SRC_LPC17XX_LPC17_PIC32_H
#define __ARCH_MIPS_SRC_LPC17XX_LPC17_PIC32_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <arch/board/board.h>
#include "chip.h"
#include "pic32mx-memorymap.h"
#include "pic32mx-uart.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Configuration *********************************************************************/
/* Don't enable UARTs not supported by the chip. */
#if CHIP_NEUARTS < 1
# undef CONFIG_PIC32MX_UART1
# undef CONFIG_PIC32MX_UART2
#endif
#if CHIP_NEUARTS < 2
# undef CONFIG_PIC32MX_UART2
#endif
/* Are any UARTs enabled? */
#undef HAVE_UART_DEVICE
#if defined(CONFIG_PIC32MX_UART1) || defined(CONFIG_LPC17_UART1)
# define HAVE_UART_DEVICE 1
#endif
/* Is there a serial console? There should be at most one defined. It
* could be on any UARTn, n=0,1
*/
#if defined(CONFIG_UART1_SERIAL_CONSOLE) && defined(CONFIG_PIC32MX_UART1)
# undef CONFIG_UART2_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_UART2_SERIAL_CONSOLE) && defined(CONFIG_LPC17_UART2)
# undef CONFIG_UART1_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#else
# undef CONFIG_UART1_SERIAL_CONSOLE
# undef CONFIG_UART2_SERIAL_CONSOLE
# undef HAVE_SERIAL_CONSOLE
#endif
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Public Data
************************************************************************************/
/************************************************************************************
* Inline Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
#endif /* __ARCH_MIPS_SRC_LPC17XX_LPC17_PIC32_H */
+193 -27
View File
@@ -40,9 +40,10 @@
#include <nuttx/config.h>
#include <arch/mips32/registers.h>
#include <arch/mips32/cp0.h>
#include <arch/pic32mx/cp0.h>
#include "excptmacros.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -71,30 +72,61 @@
* 4) Uninitialized data (.bss):
* Start: _sbss
* End(+1): _ebss
*
* The following are placed outside of the "normal" memory segments -- mostly
* so that they do not have to be cleared on power up.
*
* 5) Idle thread stack:
* Start: _ebss
* End(+1): _ebss+CONFIG_IDLETHREAD_STACKSIZE
* 6) Heap Range
* 6) Optional interrupt stack
* Start: _ebss+CONFIG_IDLETHREAD_STACKSIZE
* End(+1): _ebss+CONFIG_IDLETHREAD_STACKSIZE+(CONFIG_ARCH_INTERRUPTSTACK & ~3)
* 6a) Heap (without interupt stack)
* Start: _ebss+CONFIG_IDLETHREAD_STACKSIZE
* End(+1): to the end of memory
* 6b) Heap (with interupt stack)
* Start: _ebss+CONFIG_IDLETHREAD_STACKSIZE+(CONFIG_ARCH_INTERRUPTSTACK & ~3)
* End(+1): to the end of memory
*/
#define PIC32MX_STACK_BASE _ebss
#define PIC32MX_STACK_TOP _ebss+CONFIG_IDLETHREAD_STACKSIZE-4
#define PIC32MX_HEAP_BASE _ebss+CONFIG_IDLETHREAD_STACKSIZE
#define PIC32MX_STACK_BASE _ebss
#define PIC32MX_STACK_TOP _ebss+CONFIG_IDLETHREAD_STACKSIZE-4
#if CONFIG_ARCH_INTERRUPTSTACK > 3
# define PIC32MX_INTSTACK_BASE PIC32MX_STACK_TOP
# define PIC32MX_INTSTACK_SIZE (CONFIG_ARCH_INTERRUPTSTACK & ~3)
# define PIC32MX_INTSTACK_TOP PIC32MX_STACK_TOP+PIC32MX_INTSTACK_SIZE
# define PIC32MX_HEAP_BASE PIC32MX_INTSTACK_TOP
#else
# define PIC32MX_HEAP_BASE PIC32MX_STACK_TOP
#endif
/****************************************************************************
* Global Symbols
****************************************************************************/
.file "pic32mx-head.S"
/* Exported symbols */
.globl __reset
.global __start
.global halt
#if CONFIG_ARCH_INTERRUPTSTACK > 3
.global g_intstackbase
.global g_nestlevel
#endif
.global g_heapbase
/* Imported symbols */
.global nmi_handler
.global bev_handler
.global int_handler
.global os_start
.global up_dobev
.global up_decodeirq
#ifdef CONFIG_PIC32MX_NMIHANDLER
.global up_donmi
#endif
/****************************************************************************
* Name: __reset
@@ -112,7 +144,6 @@
*
****************************************************************************/
.globl __reset
.section .reset, "ax", @progbits
.set noreorder
.ent __reset
@@ -122,6 +153,52 @@ __reset:
nop
.end __reset
/****************************************************************************
* Name: _bev_exception
*
* Description:
* Boot Exception Vector Handler. Jumps to _bev_handler
*
* Input Parameters:
* None
*
* Returned Value:
* Does not return
*
****************************************************************************/
.section .bev_excpt,"ax",@progbits
.set noreorder
.ent _bev_exception
_bev_exception:
la k0, _bev_handler
jr k0
nop
.end _bev_exception
/****************************************************************************
* Name: _int_exception
*
* Description:
* Interrupt Exception Vector Handler. Jumps to _int_handler
*
* Input Parameters:
* None
*
* Returned Value:
* Does not return
*
****************************************************************************/
.section .int_excpt,"ax",@progbits
.set noreorder
.ent _int_exception
_int_exception:
la k0, _int_handler
jr k0
nop
.end _int_exception
/****************************************************************************
* Name: __start
*
@@ -148,17 +225,19 @@ __start:
* over to the NMI handler.
*/
#ifdef CONFIG_PIC32MX_NMIHANDLER
mfc0 k0, $12 /* Load CP0 status register */
ext k0, k0, 19, 1 /* Extract NMI bit */
beqz k0, .Lnotnmi
nop
la k0, nmi_handler
la k0, _nmi_handler
jr k0
nop
/* This is not an NMI */
.Lnotnmi:
#endif
/* Initialize the stack pointer */
@@ -331,13 +410,79 @@ __start:
* necessary
*/
and a0, a0, 0
and a1, a1, 0
la t0, __start_nuttx
jr t0
nop
.end __start
/****************************************************************************
* Name: _bev_handler
*
* Description:
* BEV exception handler. Calls up_dobev()
*
****************************************************************************/
.section .bev_handler, "ax", @progbits
.set noreorder
.ent _bev_handler
_bev_handler:
EXCPT_PROLOGUE t0 /* Save registers on stack, enable nested interrupts */
move a0, sp /* Pass register save structure as the parameter 1 */
USE_INTSTACK t0, t1, t2 /* Switch to the interrupt stack */
la t0, up_dobev /* Call up_dobev(regs) */
jalr t0, ra
di /* Disable interrupts */
RESTORE_STACK t0, t1 /* Undo the operations of USE_STACK */
EXCPT_EPILOGUE v0 /* Return to the context returned by up_dobev() */
.end _bev_handler
/****************************************************************************
* Name: _int_handler
*
* Description:
* Interrupt exception handler. Calls up_decodeirq()
*
****************************************************************************/
.section .int_handler, "ax", @progbits
.set noreorder
.ent _int_handler
_int_handler:
EXCPT_PROLOGUE t0 /* Save registers on stack, enable nested interrupts */
move a0, sp /* Pass register save structure as the parameter 1 */
USE_INTSTACK t0, t1, t2 /* Switch to the interrupt stack */
la t0, up_decodeirq /* Call up_decodeirq(regs) */
jalr t0, ra
di /* Disable interrupts */
RESTORE_STACK t0, t1 /* Undo the operations of USE_STACK */
EXCPT_EPILOGUE v0 /* Return to the context returned by up_decodeirq() */
.end _int_handler
/****************************************************************************
* Name: _nmi_handler
*
* Description:
* NMI exception handler. Calls up_donmi
*
****************************************************************************/
#ifdef CONFIG_PIC32MX_NMIHANDLER
.section .nmi_handler, "ax", @progbits
.set noreorder
.ent _nmi_handler
_nmi_handler:
EXCPT_PROLOGUE t0 /* Save registers on stack, enable nested interrupts */
move a0, sp /* Pass register save structure as the parameter 1 */
USE_INTSTACK t0, t1, t2 /* Switch to the interrupt stack */
la t0, up_donmi /* Call up_donmi(regs) */
jalr t0, ra
di /* Disable interrupts */
RESTORE_STACK t0, t1 /* Undo the operations of USE_STACK */
EXCPT_EPILOGUE v0 /* Return to the context returned by up_donmi() */
.end _nmi_handler
#endif
/****************************************************************************
* Name: __start_nuttx
*
@@ -356,19 +501,14 @@ __start:
__start_nuttx:
/* Perform low level initialization */
jal up_lowinit
la t0, up_lowinit
jalr t0, ra
nop
/* Perform early serial initialization */
#ifdef CONFIG_USE_EARLYSERIALINIT
jal up_earlyserialinit
nop
#endif
/* Call os_start */
jal os_start
la t0, os_start
jalr t0, ra
nop
/* Just in case main returns, go into infinite loop */
@@ -379,15 +519,41 @@ halt:
nop
.end __start_nuttx
/* This global variable is unsigned int g_heapbase and is exported
* here only because of its coupling to idle thread stack.
*/
/****************************************************************************
* Global Data
****************************************************************************/
/* Interrupt stack variables */
#if CONFIG_ARCH_INTERRUPTSTACK > 3
/* g_instackbase is a pointer to the final, aligned word of the interrupt
* stack.
*/
.sdata
.type g_intstackbase, object
g_intstackbase:
.long PIC32MX_INTSTACK_TOP-4
.size g_intstackbase, .-g_intstackbase
/* g_nextlevel is the exception nesting level... the interrupt stack is not
* available to nested exceptions.
*/
.sbss
.type g_nestlevel, object
g_nestlevel:
.skip 4
#endif
/* This global variable is unsigned int g_heapbase and is exported here only
* because of its coupling to idle thread stack.
*/
.sdata
.align 4
.globl g_heapbase
.type g_heapbase, object
g_heapbase:
.long _ebss+CONFIG_IDLETHREAD_STACKSIZE
.long PIC32MX_HEAP_BASE
.size g_heapbase, .-g_heapbase
+53 -7
View File
@@ -49,6 +49,7 @@
#include "up_internal.h"
#include "chip.h"
#include "pic32mx-config.h"
/************************************************************************************
* Definitions
@@ -122,9 +123,7 @@ extern "C" {
* Name: pic32mx_clockconfig
*
* Description:
* Called to initialize the PIC32MX. This does whatever setup is needed to put the
* MCU in a usable state. This includes the initialization of clocking using the
* settings in board.h.
* Called to initialize the PIC32MX clocking using the settings in board.h.
*
************************************************************************************/
@@ -134,13 +133,38 @@ EXTERN void pic32mx_clockconfig(void);
* Name: pic32mx_lowsetup
*
* Description:
* Called at the very beginning of _start. Performs low level initialization
* including setup of the console UART. This UART done early so that the serial
* console is available for debugging very early in the boot sequence.
* Performs low level initialization of the console UART. This UART done early so
* that the serial console is available for debugging very early in the boot sequence.
*
************************************************************************************/
EXTERN void pic32mx_lowsetup(void);
EXTERN void pic32mx_consoleinit(void);
/******************************************************************************
* Name: pic32mx_uartreset
*
* Description:
* Reset a UART.
*
******************************************************************************/
#ifdef HAVE_UART_DEVICE
EXTERN void pic32mx_uartreset(uintptr_t uart_base);
#endif
/******************************************************************************
* Name: pic32mx_uartconfigure
*
* Description:
* Configure a UART as a RS-232 UART.
*
******************************************************************************/
#ifdef HAVE_UART_DEVICE
EXTERN void pic32mx_uartconfigure(uintptr_t uart_base, uint32_t baud,
unsigned int parity, unsigned int nbits,
bool stop2);
#endif
/************************************************************************************
* Name: pic32mx_gpioirqinitialize
@@ -156,6 +180,28 @@ EXTERN void pic32mx_gpioirqinitialize(void);
# define pic32mx_gpioirqinitialize()
#endif
/************************************************************************************
* Name: pic32mx_boardinitialize
*
* Description:
* This function must be provided by the board-specific logic in the directory
* configs/<board-name>/up_boot.c.
*
************************************************************************************/
EXTERN void pic32mx_boardinitialize(void);
/************************************************************************************
* Name: up_decodeirq
*
* Description:
* Called from assembly language logic when and interrrupt exception occurs. This
* function decodes and dispatches the interrupt.
*
************************************************************************************/
EXTERN uint32_t *up_decodeirq(uint32_t *regs);
/************************************************************************************
* Name: pic32mx_configgpio
*
+204
View File
@@ -0,0 +1,204 @@
/******************************************************************************
* arch/mips/src/pic32mx/pic32mx-lowconsole.c
*
* Copyright (C) 2011 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 <assert.h>
#include <debug.h>
#include <arch/irq.h>
#include <arch/board/board.h>
#include "up_arch.h"
#include "up_internal.h"
#include "pic32mx-config.h"
#include "pic32mx-internal.h"
/******************************************************************************
* Private Definitions
******************************************************************************/
/* Select UART parameters for the selected console */
#if defined(CONFIG_UART1_SERIAL_CONSOLE)
# define AVR32_CONSOLE_BASE PIC32MX_UART1_K1BASE
# define AVR32_CONSOLE_BAUD CONFIG_UART1_BAUD
# define AVR32_CONSOLE_BITS CONFIG_UART1_BITS
# define AVR32_CONSOLE_PARITY CONFIG_UART1_PARITY
# define AVR32_CONSOLE_2STOP CONFIG_UART1_2STOP
#elif defined(CONFIG_UART2_SERIAL_CONSOLE)
# define AVR32_CONSOLE_BASE PIC32MX_UART2_K1BASE
# define AVR32_CONSOLE_BAUD CONFIG_UART2_BAUD
# define AVR32_CONSOLE_BITS CONFIG_UART2_BITS
# define AVR32_CONSOLE_PARITY CONFIG_UART2_PARITY
# define AVR32_CONSOLE_2STOP CONFIG_UART2_2STOP
#else
# error "No CONFIG_UARTn_SERIAL_CONSOLE Setting"
#endif
/******************************************************************************
* Private Types
******************************************************************************/
/******************************************************************************
* Private Function Prototypes
******************************************************************************/
/******************************************************************************
* Global Variables
******************************************************************************/
/******************************************************************************
* Private Variables
******************************************************************************/
/******************************************************************************
* Private Functions
******************************************************************************/
/******************************************************************************
* Name: pic32mx_uartputreg
*
* Description:
* Write a value to a UART register
*
******************************************************************************/
#ifdef HAVE_UART_DEVICE
static inline void pic32mx_uartputreg(uintptr_t uart_base, unsigned int offset,
uint32_t value)
{
putreg32(value, uart_base + offset);
}
#endif
/******************************************************************************
* Name: pic32mx_uartgetreg
*
* Description:
* Get a value from a UART register
*
******************************************************************************/
#ifdef HAVE_UART_DEVICE
static inline uint32_t pic32mx_uartgetreg(uintptr_t uart_base,
unsigned int offset)
{
return getreg32(uart_base + offset);
}
#endif
/******************************************************************************
* Name: pic32mx_uartsetbaud
*
* Description:
* Configure the UART baud rate.
*
******************************************************************************/
#ifdef HAVE_UART_DEVICE
static void pic32mx_uartsetbaud(uintptr_t uart_base, uint32_t baudrate)
{
#warning "Missing logic"
}
#endif
/******************************************************************************
* Public Functions
******************************************************************************/
/******************************************************************************
* Name: pic32mx_uartreset
*
* Description:
* Reset a UART.
*
******************************************************************************/
#ifdef HAVE_UART_DEVICE
void pic32mx_uartreset(uintptr_t uart_base)
{
#warning "Missing logic"
}
#endif
/******************************************************************************
* Name: pic32mx_uartconfigure
*
* Description:
* Configure a UART as a RS-232 UART.
*
******************************************************************************/
#ifdef HAVE_UART_DEVICE
void pic32mx_uartconfigure(uintptr_t uart_base, uint32_t baud,
unsigned int parity, unsigned int nbits, bool stop2)
{
}
#endif
/******************************************************************************
* Name: pic32mx_consoleinit
*
* Description:
* Initialize a console for debug output. This function is called very
* early in the intialization sequence to configure the serial console uart
* (only).
*
******************************************************************************/
void pic32mx_consoleinit(void)
{
#warning "Missing logic"
}
/******************************************************************************
* Name: up_lowputc
*
* Description:
* Output one byte on the serial console
*
******************************************************************************/
void up_lowputc(char ch)
{
#warning "Missing logic"
}
+106 -104
View File
@@ -1,104 +1,106 @@
/****************************************************************************
* arch/mips/src/mips32/up_genexcptn.S
*
* Copyright (C) 2011 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 <arch/mips32/registers.h>
#include "chip/excptmacros.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Global Symbols
****************************************************************************/
.file "up_genexcptn.S"
.global _int_handler
.global up_decodeirq
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: _int_exception
*
* Description:
* Interrupt Exception Vector Handler. Jumps to _int_handler
*
* Input Parameters:
* None
*
* Returned Value:
* Does not return
*
****************************************************************************/
.section .int_excpt,"ax",@progbits
.set noreorder
.ent _int_exception
_int_exception:
la k0, _int_handler
jr k0
nop
.end _int_exception
/****************************************************************************
* Name: _int_handler
*
* Description:
* Interrupt exception handler
*
****************************************************************************/
.section .int_handler, "ax", @progbits
.set noreorder
.ent _int_handler
_int_handler:
EXCPT_PROLOGUE t0 /* Save registers on stack, enable nested interrupts */
move a0, sp /* Pass register save structure as the parameter 1 */
USE_INTSTACK t0, t1, t2 /* Switch to the interrupt stack */
la t0, up_decodeirq /* Call up_decodeirq(regs) */
jalr t0, ra
di /* Disable interrupts */
RESTORE_STACK t0, t1 /* Undo the operations of USE_STACK */
EXCPT_EPILOGUE v0 /* Return to the context returned by up_decodeirq() */
.end _int_handler
/**************************************************************************
* arch/mips/src/pic32/pic32mx-lowinit.c
*
* Copyright (C) 2011 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 "up_internal.h"
#include "pic32mx-internal.h"
/**************************************************************************
* Private Definitions
**************************************************************************/
/**************************************************************************
* Private Types
**************************************************************************/
/**************************************************************************
* Private Function Prototypes
**************************************************************************/
/**************************************************************************
* Global Variables
**************************************************************************/
/**************************************************************************
* Private Variables
**************************************************************************/
/**************************************************************************
* Private Functions
**************************************************************************/
/**************************************************************************
* Public Functions
**************************************************************************/
/**************************************************************************
* Name: up_lowinit
*
* Description:
* This performs basic initialization of the USART used for the serial
* console. Its purpose is to get the console output availabe as soon
* as possible.
*
**************************************************************************/
void up_lowinit(void)
{
/* Initialize MCU clocking */
pic32mx_clockconfig();
/* Initialize a console (probably a serial console) */
pic32mx_consoleinit();
/* Perform early serial initialization (so that we will have debug output
* available as soon as possible).
*/
#ifdef CONFIG_USE_EARLYSERIALINIT
up_earlyserialinit();
#endif
/* Perform board-level initialization */
pic32mx_boardinitialize();
}
File diff suppressed because it is too large Load Diff
+2 -16
View File
@@ -159,40 +159,26 @@ CONFIG_PIC32MX_IOPORTG=y
# CONFIG_UARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity
# CONFIG_UARTn_2STOP - Two stop bits
#
CONFIG_UART0_SERIAL_CONSOLE=n
CONFIG_UART1_SERIAL_CONSOLE=n
CONFIG_UART1_SERIAL_CONSOLE=y
CONFIG_UART2_SERIAL_CONSOLE=n
CONFIG_UART3_SERIAL_CONSOLE=y
CONFIG_UART0_TXBUFSIZE=256
CONFIG_UART1_TXBUFSIZE=256
CONFIG_UART2_TXBUFSIZE=256
CONFIG_UART3_TXBUFSIZE=256
CONFIG_UART0_RXBUFSIZE=256
CONFIG_UART1_RXBUFSIZE=256
CONFIG_UART2_RXBUFSIZE=256
CONFIG_UART3_RXBUFSIZE=256
CONFIG_UART0_BAUD=115200
CONFIG_UART2_BAUD=115200
CONFIG_UART3_BAUD=115200
CONFIG_UART1_BAUD=115200
CONFIG_UART2_BAUD=115200
CONFIG_UART0_BITS=8
CONFIG_UART1_BITS=8
CONFIG_UART2_BITS=8
CONFIG_UART3_BITS=8
CONFIG_UART0_PARITY=0
CONFIG_UART1_PARITY=0
CONFIG_UART2_PARITY=0
CONFIG_UART3_PARITY=0
CONFIG_UART0_2STOP=0
CONFIG_UART1_2STOP=0
CONFIG_UART2_2STOP=0
CONFIG_UART3_2STOP=0
#
# General build options
+7 -12
View File
@@ -56,8 +56,7 @@ MEMORY
* Others 0x1fc00380 KSEG1 128 1024 (1Kb)
* Interrupt 0x1fc00400 KSEG1 128 1152
* JTAG 0x1fc00480 KSEG1 16 1168
* Startup logic 0x1fc00490 KSEG0 4096-1168 4096 (4Kb)
* Exceptions 0x1fc01000 KSEG0 4096 8192 (8Kb)
* Exceptions 0x1fc00490 KSEG0 8192-1168 8192 (4Kb)
* Debug code 0x1fc02000 KSEG1 4096-16 12272
* DEVCFG3-0 0x1fc02ff0 KSEG1 16 12288 (12Kb)
*
@@ -73,8 +72,7 @@ MEMORY
kseg1_bevexcpt (rx) : ORIGIN = 0xbfc00380, LENGTH = 128
kseg1_intexcpt (rx) : ORIGIN = 0xbfc00400, LENGTH = 128
kseg1_dbgexcpt (rx) : ORIGIN = 0xbfc00480, LENGTH = 16
kseg0_bootmem (rx) : ORIGIN = 0x9fc00490, LENGTH = 4096-1168
kseg0_excptmem (rx) : ORIGIN = 0x9fc01000, LENGTH = 4096
kseg0_bootmem (rx) : ORIGIN = 0x9fc00490, LENGTH = 8192-1168
kseg1_dbgcode (rx) : ORIGIN = 0xbfc02000, LENGTH = 4096-16
kseg1_devcfg (r) : ORIGIN = 0xbfc02ff0, LENGTH = 16
@@ -90,9 +88,6 @@ OUTPUT_FORMAT("elf32-tradlittlemips")
OUTPUT_ARCH(pic32mx)
ENTRY(__start)
INPUT(up_inthandler.o);
INPUT(up_bevhandler.o);
SECTIONS
{
/* Boot FLASH sections */
@@ -135,16 +130,16 @@ SECTIONS
.start :
{
/* KSEG0 Reset startup logic */
*(.start)
} > kseg0_bootmem
/* KSEG0 exception handlers */
/* KSEG0 exception handlers */
.excpt_handlers :
{
*(.nmi_handler)
*(.bev_handler)
*(.int_handler)
} > kseg0_excptmem
} > kseg0_bootmem
.dbg_code = ORIGIN(kseg1_dbgcode);