mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-19 17:48:33 -04:00
Add the beginnings of a Microblaze project for the KC705.
This commit is contained in:
parent
501a531d46
commit
acfbb7dd14
11 changed files with 2688 additions and 2 deletions
|
@ -0,0 +1,355 @@
|
|||
/*
|
||||
FreeRTOS V8.2.0 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* This project provides two demo applications. A simple blinky style project,
|
||||
* and a more comprehensive test and demo application. The
|
||||
* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this file) is used to
|
||||
* select between the two. The simply blinky demo is implemented and described
|
||||
* in main_blinky.c. The more comprehensive test and demo application is
|
||||
* implemented and described in main_full.c.
|
||||
*
|
||||
* This file implements the code that is not demo specific, including the
|
||||
* hardware setup and FreeRTOS hook functions.
|
||||
*
|
||||
* ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON
|
||||
* THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO
|
||||
* APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT!
|
||||
*
|
||||
*/
|
||||
|
||||
#warning Try reducing minimal stack size.
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* Scheduler include files. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Demo app includes. */
|
||||
#include "partest.h"
|
||||
|
||||
/* Xilinx includes. */
|
||||
#include "xtmrctr.h"
|
||||
#include "xil_cache.h"
|
||||
|
||||
/* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is used to select between the simply
|
||||
* blinky demo and the comprehensive test and demo application.
|
||||
*
|
||||
* When mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1 the simple blinky example
|
||||
* will be run.
|
||||
*
|
||||
* When mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0 the comprehensive test
|
||||
* and demo application will be run.
|
||||
*/
|
||||
#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Configure the hardware as necessary to run this demo.
|
||||
*/
|
||||
static void prvSetupHardware( void );
|
||||
|
||||
/*
|
||||
* See the comments at the top of this file and above the
|
||||
* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY definition.
|
||||
*/
|
||||
#if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
|
||||
extern void main_blinky( void );
|
||||
#else
|
||||
extern void main_full( void );
|
||||
#endif
|
||||
|
||||
/* Prototypes for the standard FreeRTOS callback/hook functions implemented
|
||||
within this file. */
|
||||
void vApplicationMallocFailedHook( void );
|
||||
void vApplicationIdleHook( void );
|
||||
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
|
||||
void vApplicationTickHook( void );
|
||||
|
||||
/* The dual timer is used to generate the RTOS tick interrupt. */
|
||||
static XTmrCtr xDualTimerInstance;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int main( void )
|
||||
{
|
||||
/* Configure the hardware ready to run the demo. */
|
||||
prvSetupHardware();
|
||||
|
||||
/* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
|
||||
of this file. */
|
||||
#if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
|
||||
{
|
||||
main_blinky();
|
||||
}
|
||||
#else
|
||||
{
|
||||
main_full();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Don't expect to reach here. */
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupHardware( void )
|
||||
{
|
||||
#warning Stacks are in BRAM.
|
||||
#warning Caches are disabled.
|
||||
// init_platform();
|
||||
|
||||
microblaze_disable_interrupts();
|
||||
|
||||
#if defined( XPAR_MICROBLAZE_USE_ICACHE ) && ( XPAR_MICROBLAZE_USE_ICACHE != 0 )
|
||||
{
|
||||
Xil_ICacheEnable();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined( XPAR_MICROBLAZE_USE_DCACHE ) && ( XPAR_MICROBLAZE_USE_DCACHE != 0 )
|
||||
{
|
||||
Xil_DCacheEnable();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialise the LEDs. ParTest is a historic name which used to stand for
|
||||
PARallel port TEST. */
|
||||
vParTestInitialise();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationMallocFailedHook( void )
|
||||
{
|
||||
volatile uint32_t ulDummy = 0;
|
||||
|
||||
/* Called if a call to pvPortMalloc() fails because there is insufficient
|
||||
free memory available in the FreeRTOS heap. pvPortMalloc() is called
|
||||
internally by FreeRTOS API functions that create tasks, queues, software
|
||||
timers, and semaphores. The size of the FreeRTOS heap is set by the
|
||||
configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. Force an
|
||||
assertion failure. */
|
||||
configASSERT( ulDummy != 0 );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
|
||||
{
|
||||
( void ) pcTaskName;
|
||||
( void ) pxTask;
|
||||
|
||||
/* Run time stack overflow checking is performed if
|
||||
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
|
||||
function is called if a stack overflow is detected. Force an assertion
|
||||
failuse. */
|
||||
configASSERT( ( char * ) pxTask == pcTaskName );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationIdleHook( void )
|
||||
{
|
||||
#if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )
|
||||
{
|
||||
extern void vFullDemoIdleHook( void );
|
||||
|
||||
/* When the full demo is build the idle hook is used to create some
|
||||
timers to flash LEDs. */
|
||||
vFullDemoIdleHook();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vAssertCalled( const char * pcFile, unsigned long ulLine )
|
||||
{
|
||||
volatile unsigned long ul = 0;
|
||||
|
||||
( void ) pcFile;
|
||||
( void ) ulLine;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
/* Set ul to a non-zero value using the debugger to step out of this
|
||||
function. */
|
||||
while( ul == 0 )
|
||||
{
|
||||
portNOP();
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationTickHook( void )
|
||||
{
|
||||
#if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )
|
||||
{
|
||||
extern void vFullDemoTickHook( void );
|
||||
|
||||
/* When the full demo is build the tick hook is used to demonstrate
|
||||
functions being called from an interrupt and perform some tests. */
|
||||
vFullDemoTickHook();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* This is an application defined callback function used to install the tick
|
||||
interrupt handler. It is provided as an application callback because the kernel
|
||||
will run on lots of different MicroBlaze and FPGA configurations - not all of
|
||||
which will have the same timer peripherals defined or available. This example
|
||||
uses the Dual Timer 0. If that is available on your hardware platform then this
|
||||
example callback implementation may not require modification. The name of the
|
||||
interrupt handler that must be installed is vPortTickISR(), which the function
|
||||
below declares as an extern. */
|
||||
void vApplicationSetupTimerInterrupt( void )
|
||||
{
|
||||
portBASE_TYPE xStatus;
|
||||
const unsigned char ucTimerCounterNumber = ( unsigned char ) 0U;
|
||||
const unsigned long ulCounterValue = ( ( XPAR_TMRCTR_0_CLOCK_FREQ_HZ / configTICK_RATE_HZ ) - 1UL );
|
||||
extern void vPortTickISR( void *pvUnused );
|
||||
|
||||
/* Initialise the timer/counter. */
|
||||
xStatus = XTmrCtr_Initialize( &xDualTimerInstance, XPAR_TMRCTR_0_DEVICE_ID );
|
||||
|
||||
if( xStatus == XST_SUCCESS )
|
||||
{
|
||||
/* Install the tick interrupt handler as the timer ISR.
|
||||
*NOTE* The xPortInstallInterruptHandler() API function must be used for
|
||||
this purpose. */
|
||||
xStatus = xPortInstallInterruptHandler( XPAR_INTC_0_TMRCTR_0_VEC_ID, vPortTickISR, NULL );
|
||||
}
|
||||
|
||||
if( xStatus == pdPASS )
|
||||
{
|
||||
/* Enable the timer interrupt in the interrupt controller.
|
||||
*NOTE* The vPortEnableInterrupt() API function must be used for this
|
||||
purpose. */
|
||||
vPortEnableInterrupt( XPAR_INTC_0_TMRCTR_0_VEC_ID );
|
||||
|
||||
/* Configure the timer interrupt handler. */
|
||||
XTmrCtr_SetHandler( &xDualTimerInstance, ( void * ) vPortTickISR, NULL );
|
||||
|
||||
/* Set the correct period for the timer. */
|
||||
XTmrCtr_SetResetValue( &xDualTimerInstance, ucTimerCounterNumber, ulCounterValue );
|
||||
|
||||
/* Enable the interrupts. Auto-reload mode is used to generate a
|
||||
periodic tick. Note that interrupts are disabled when this function is
|
||||
called, so interrupts will not start to be processed until the first
|
||||
task has started to run. */
|
||||
XTmrCtr_SetOptions( &xDualTimerInstance, ucTimerCounterNumber, ( XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION | XTC_DOWN_COUNT_OPTION ) );
|
||||
|
||||
/* Start the timer. */
|
||||
XTmrCtr_Start( &xDualTimerInstance, ucTimerCounterNumber );
|
||||
}
|
||||
|
||||
/* Sanity check that the function executed as expected. */
|
||||
configASSERT( ( xStatus == pdPASS ) );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* This is an application defined callback function used to clear whichever
|
||||
interrupt was installed by the the vApplicationSetupTimerInterrupt() callback
|
||||
function. It is provided as an application callback because the kernel will run
|
||||
on lots of different MicroBlaze and FPGA configurations - not all of which will
|
||||
have the same timer peripherals defined or available. This example uses the
|
||||
dual timer 0. If that is available on your hardware platform then this example
|
||||
callback implementation will not require modification provided the example
|
||||
definition of vApplicationSetupTimerInterrupt() is also not modified. */
|
||||
void vApplicationClearTimerInterrupt( void )
|
||||
{
|
||||
unsigned long ulCSR;
|
||||
|
||||
/* Clear the timer interrupt */
|
||||
ulCSR = XTmrCtr_GetControlStatusReg( XPAR_TMRCTR_0_BASEADDR, 0 );
|
||||
XTmrCtr_SetControlStatusReg( XPAR_TMRCTR_0_BASEADDR, 0, ulCSR );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void *malloc( size_t x )
|
||||
{
|
||||
/* Just to check it never gets called as there is no heap defined (other
|
||||
than the FreeRTOS heap). */
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vMainConfigTimerForRunTimeStats( void )
|
||||
{
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
uint32_t ulMainGetRunTimeCounterValue( void )
|
||||
{
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue