mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-03-17 22:31:18 -04:00
Add PIC32MEC14xx port and demo application.
This commit is contained in:
parent
f19497c3d6
commit
a29dc8d6c6
103 changed files with 49682 additions and 6 deletions
|
|
@ -0,0 +1,97 @@
|
|||
/*****************************************************************************
|
||||
* (c) 2014 Microchip Technology Inc. and its subsidiaries.
|
||||
* You may use this software and any derivatives exclusively with
|
||||
* Microchip products.
|
||||
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS".
|
||||
* NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
|
||||
* INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP
|
||||
* PRODUCTS, COMBINATION WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
|
||||
* IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
|
||||
* INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
|
||||
* WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
|
||||
* BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.
|
||||
* TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
|
||||
* CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF
|
||||
* FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
|
||||
* MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE
|
||||
* OF THESE TERMS.
|
||||
*****************************************************************************/
|
||||
|
||||
/** @file general_exception.c
|
||||
*MEC14xx General Exception Handler
|
||||
*/
|
||||
/** @defgroup MEC14xx Exceptions
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#include "appcfg.h"
|
||||
#include "platform.h"
|
||||
#include "MEC14xx/mec14xx.h"
|
||||
#include "MEC14xx/mec14xx_trace_inline.h"
|
||||
|
||||
typedef struct gen_except_capture
|
||||
{
|
||||
uint32_t stack_ptr;
|
||||
uint32_t cp0_status;
|
||||
uint32_t cp0_cause;
|
||||
uint32_t cp0_epc;
|
||||
uint32_t cp0_error_epc;
|
||||
uint32_t cp0_nexc;
|
||||
uint32_t cp0_nepc;
|
||||
uint32_t cp0_badvaddr;
|
||||
uint32_t ahb_err;
|
||||
} GEN_EXCEPT_CAPTURE;
|
||||
|
||||
GEN_EXCEPT_CAPTURE gexc_cap;
|
||||
|
||||
void
|
||||
__attribute__((nomips16, noreturn)) _general_exception_handler (void)
|
||||
{
|
||||
/*
|
||||
* MEC14xx Application General Exception handler
|
||||
*/
|
||||
uint32_t e;
|
||||
|
||||
/* Get current Stack Pointer. Note: this is not SP at
|
||||
* exception. XC32 wraps _general_exception_handler in
|
||||
* assembly code which saves state resulting is a
|
||||
* modified SP. Wrapper allocates 88 bytes for context
|
||||
* save. Original SP = SPcurrent + 88.
|
||||
*/
|
||||
__asm__ __volatile (
|
||||
"move %0,$sp \n\t"
|
||||
"nop \n\t"
|
||||
:"=r" (e)
|
||||
::);
|
||||
gexc_cap.stack_ptr = e;
|
||||
|
||||
gexc_cap.cp0_status = _CP0_GET_STATUS();
|
||||
gexc_cap.cp0_cause = _CP0_GET_CAUSE();
|
||||
gexc_cap.cp0_epc = _CP0_GET_EPC();
|
||||
gexc_cap.cp0_error_epc = _CP0_GET_ERROREPC();
|
||||
gexc_cap.cp0_nexc = _CP0_GET_NESTEDEXC();
|
||||
gexc_cap.cp0_nepc = _CP0_GET_NESTEDEPC();
|
||||
gexc_cap.cp0_badvaddr = _CP0_GET_BADVADDR();
|
||||
|
||||
trace0(0, AP3GENEXCEPT, 0, "Application General Exception Handler (BEV=0)");
|
||||
TRACE11(601, AP3GENEXCEPT, 0, "Current SP = 0x%08x",gexc_cap.stack_ptr);
|
||||
TRACE11(602, AP3GENEXCEPT, 0, "CP0 STATUS = 0x%08x",gexc_cap.cp0_status);
|
||||
TRACE11(603, AP3GENEXCEPT, 0, "CP0 CAUSE = 0x%08x",gexc_cap.cp0_cause);
|
||||
TRACE11(604, AP3GENEXCEPT, 0, "CP0 EPC = 0x%08x",gexc_cap.cp0_epc);
|
||||
TRACE11(605, AP3GENEXCEPT, 0, "CP0 ERROREPC = 0x%08x",gexc_cap.cp0_error_epc);
|
||||
TRACE11(606, AP3GENEXCEPT, 0, "CP0 NEXC = 0x%08x",gexc_cap.cp0_nexc);
|
||||
TRACE11(607, AP3GENEXCEPT, 0, "CP0 NEPC = 0x%08x",gexc_cap.cp0_nepc);
|
||||
TRACE11(608, AP3GENEXCEPT, 0, "CP0 BADVADDR = 0x%08x",gexc_cap.cp0_badvaddr);
|
||||
|
||||
for (;;) {
|
||||
__asm__ __volatile ("%(ssnop%)" : :);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* end general_exception.c */
|
||||
/** @}
|
||||
*/
|
||||
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
/*********************************************************************
|
||||
*
|
||||
* General Exception
|
||||
*
|
||||
*********************************************************************
|
||||
* Filename: general-exception.S
|
||||
*
|
||||
* Processor: PIC32
|
||||
*
|
||||
* Compiler: MPLAB XC32 v1.00
|
||||
* MPLAB X IDE
|
||||
* Company: Microchip Technology Inc.
|
||||
*
|
||||
* Software License Agreement
|
||||
*
|
||||
* This software is developed by Microchip Technology Inc. and its
|
||||
* subsidiaries ("Microchip").
|
||||
*
|
||||
* 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. Microchip's name may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY MICROCHIP "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* MICROCHIP 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) HOWSOEVER 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 <xc.h>
|
||||
#ifdef __LIBBUILD__
|
||||
.file 1 "general-exception.S"
|
||||
.loc 1 0
|
||||
#endif
|
||||
###################
|
||||
# Default general exception handler
|
||||
###################
|
||||
|
||||
.extern _general_exception_handler
|
||||
|
||||
.section .text.general_exception, code
|
||||
.set noreorder
|
||||
.set noat
|
||||
.set nomips16
|
||||
.globl _general_exception_context
|
||||
.ent _general_exception_context
|
||||
|
||||
_general_exception_context:
|
||||
|
||||
# Save off the non-callee saved registers that may get mucked with
|
||||
addiu sp, sp, -88
|
||||
sw $1, 4(sp)
|
||||
sw v0, 8(sp)
|
||||
sw v1, 12(sp)
|
||||
sw a0, 16(sp)
|
||||
sw a1, 20(sp)
|
||||
sw a2, 24(sp)
|
||||
sw a3, 28(sp)
|
||||
sw t0, 32(sp)
|
||||
sw t1, 36(sp)
|
||||
sw t2, 40(sp)
|
||||
sw t3, 44(sp)
|
||||
sw t4, 48(sp)
|
||||
sw t5, 52(sp)
|
||||
sw t6, 56(sp)
|
||||
sw t7, 60(sp)
|
||||
sw t8, 64(sp)
|
||||
sw t9, 68(sp)
|
||||
sw ra, 72(sp)
|
||||
mflo t0
|
||||
sw t0, 76(sp)
|
||||
mfhi t0
|
||||
sw t0, 80(sp)
|
||||
|
||||
la k0,_general_exception_handler
|
||||
nop
|
||||
|
||||
# Pass Cause and Status to the handler function
|
||||
mfc0 a0, _CP0_CAUSE
|
||||
mfc0 a1, _CP0_STATUS
|
||||
jalr k0
|
||||
nop
|
||||
|
||||
lw t0, 80(sp)
|
||||
mthi t0
|
||||
lw t0, 76(sp)
|
||||
mtlo t0
|
||||
|
||||
lw $1, 4(sp)
|
||||
lw v0, 8(sp)
|
||||
lw v1, 12(sp)
|
||||
lw a0, 16(sp)
|
||||
lw a1, 20(sp)
|
||||
lw a2, 24(sp)
|
||||
lw a3, 28(sp)
|
||||
lw t0, 32(sp)
|
||||
lw t1, 36(sp)
|
||||
lw t2, 40(sp)
|
||||
lw t3, 44(sp)
|
||||
lw t4, 48(sp)
|
||||
lw t5, 52(sp)
|
||||
lw t6, 56(sp)
|
||||
lw t7, 60(sp)
|
||||
lw t8, 64(sp)
|
||||
lw t9, 68(sp)
|
||||
lw ra, 72(sp)
|
||||
addiu sp, sp, 88
|
||||
|
||||
ehb
|
||||
eret
|
||||
|
||||
.end _general_exception_context
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue