--- /dev/null
+/*\r
+ FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.\r
+\r
+ This file is part of the FreeRTOS.org distribution.\r
+\r
+ FreeRTOS.org is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ FreeRTOS.org is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with FreeRTOS.org; if not, write to the Free Software\r
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+ A special exception to the GPL can be applied should you wish to distribute\r
+ a combined work that includes FreeRTOS.org, without being obliged to provide\r
+ the source code for any proprietary components. See the licensing section \r
+ of http://www.FreeRTOS.org for full details of how and when the exception\r
+ can be applied.\r
+\r
+ ***************************************************************************\r
+\r
+ Please ensure to read the configuration and relevant port sections of the \r
+ online documentation.\r
+\r
+ +++ http://www.FreeRTOS.org +++\r
+ Documentation, latest information, license and contact details. \r
+\r
+ +++ http://www.SafeRTOS.com +++\r
+ A version that is certified for use in safety critical systems.\r
+\r
+ +++ http://www.OpenRTOS.com +++\r
+ Commercial support, development, porting, licensing and training services.\r
+\r
+ ***************************************************************************\r
+*/\r
+\r
+/*-----------------------------------------------------------\r
+ * Implementation of functions defined in portable.h for the MicroBlaze port.\r
+ *----------------------------------------------------------*/\r
+\r
+\r
+/* Scheduler includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+\r
+/* Library includes. */\r
+#include "xexception_l.h"\r
+#include "xtime_l.h"\r
+\r
+/* Standard includes. */\r
+#include <string.h>\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+#define portCRITICAL_INTERRUPT_ENABLE ( 1UL << 14UL )\r
+#define portEXTERNAL_INTERRUPT_ENABLE ( 1UL << 16UL )\r
+#define portMACHINE_CHECK_ENABLE ( 1UL << 19UL )\r
+#define portINITIAL_MSR ( portCRITICAL_INTERRUPT_ENABLE | portEXTERNAL_INTERRUPT_ENABLE | portMACHINE_CHECK_ENABLE )\r
+\r
+/*\r
+ */\r
+static void prvSetupTimerInterrupt( void );\r
+extern void vStartFirstTask( void );\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvTickISR( void );\r
+extern void vPortYield( void );\r
+\r
+/* \r
+ * Initialise the stack of a task to look exactly as if a call to \r
+ * portSAVE_CONTEXT had been made.\r
+ * \r
+ * See the header file portable.h.\r
+ */\r
+portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
+{\r
+ /* Place a known value at the bottom of the stack for debugging. */\r
+ *pxTopOfStack = 0xDEADBEEF;\r
+ *pxTopOfStack--;\r
+\r
+ *pxTopOfStack = 0x10000001UL;; /* R0. */\r
+ pxTopOfStack--;\r
+ /* SP. */\r
+ *pxTopOfStack = 0x31313131UL; /* R31. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x30303030UL; /* R30. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x29292929UL; /* R29. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x28282828UL; /* R28. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x27272727UL; /* R27. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x26262626UL; /* R26. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x25252525UL; /* R25. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x24242424UL; /* R24. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x23232323UL; /* R23. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x22222222UL; /* R22. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x21212121UL; /* R21. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x20202020UL; /* R20. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x19191919UL; /* R19. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x18181818UL; /* R18. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x17171717UL; /* R17. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x16161616UL; /* R16. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x15151515UL; /* R15. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x14141414UL; /* R14. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x13131313UL; /* R13. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x12121212UL; /* R12. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x11111111UL; /* R11. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x10101010UL; /* R10. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x09090909UL; /* R9. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x08080808UL; /* R8. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x07070707UL; /* R7. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x06060606UL; /* R6. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x05050505UL; /* R5. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x04040404UL; /* R4. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) pvParameters;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x02020202UL; /* R2. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x00000000; /* CR. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x00000000; /* XER. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x00000000; /* LR. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x00000000; /* CTR. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = 0x00000000; /* USPRG0. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* SRR0. */\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = portINITIAL_MSR;/* SRR1. */\r
+ pxTopOfStack--;\r
+\r
+ return pxTopOfStack;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+portBASE_TYPE xPortStartScheduler( void )\r
+{\r
+extern void *pxCurrentTCB;\r
+\r
+ prvSetupTimerInterrupt();\r
+ vStartFirstTask();\r
+ \r
+ /* Should not get here as the tasks are now running! */\r
+ return pdFALSE;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortEndScheduler( void )\r
+{\r
+ /* Not implemented. */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Hardware initialisation to generate the RTOS tick. \r
+ */\r
+static void prvSetupTimerInterrupt( void )\r
+{\r
+const unsigned portLONG ulInterval = ( ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL );\r
+\r
+ XExc_Init();\r
+ XExc_mDisableExceptions( XEXC_NON_CRITICAL ) ; \r
+ XExc_RegisterHandler( XEXC_ID_PIT_INT, ( XExceptionHandler ) prvTickISR, ( void * ) 0 );\r
+ XExc_RegisterHandler( XEXC_ID_SYSTEM_CALL, ( XExceptionHandler ) vPortYield, ( void * ) 0 );\r
+\r
+ XTime_PITEnableAutoReload();\r
+ XTime_PITEnableInterrupt();\r
+ XTime_PITSetInterval( ulInterval );\r
+ XTime_PITEnableInterrupt();\r
+ \r
+ XExc_mEnableExceptions( XEXC_NON_CRITICAL ) ;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvTickISR( void )\r
+{\r
+static unsigned portLONG ulTicks = 0;\r
+\r
+ ulTicks++;\r
+ if( ulTicks >= 1000 )\r
+ {\r
+ vParTestToggleLED( 0 );\r
+ ulTicks = 0;\r
+ }\r
+ XTime_PITClearInterrupt();\r
+ \r
+ #if configUSE_PREEMPTION == 1\r
+ #endif\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+\r
+\r
+\r
--- /dev/null
+ .extern pxCurrentTCB\r
+ .extern vTaskSwitchContext\r
+\r
+ .global vStartFirstTask\r
+ .global vPortYield\r
+\r
+.set portCONTEXT_SIZE, 156\r
+.set portR0_OFFSET, 152\r
+.set portGPR_OFFSET, 32\r
+.set portCR_OFFSET, 28\r
+.set portXER_OFFSET, 24\r
+.set portLR_OFFSET, 20\r
+.set portCTR_OFFSET, 16\r
+.set portUSPRG0_OFFSET, 12\r
+.set portSRR0_OFFSET, 8\r
+.set portSRR1_OFFSET, 4\r
+\r
+.macro portRESTORE_CONTEXT\r
+\r
+ # Get the address of the TCB.\r
+ xor R0, R0, R0\r
+ addis SP, R0, pxCurrentTCB@ha\r
+ lwz SP, pxCurrentTCB@l( SP )\r
+\r
+ # Get the task stack pointer from the TCB.\r
+ lwz SP, 0( SP )\r
+\r
+ # Pop the special purpose registers\r
+ lwz R0, portSRR1_OFFSET( SP )\r
+ mtspr SRR1, R0\r
+ lwz R0, portSRR0_OFFSET( SP )\r
+ mtspr SRR0, R0\r
+ lwz R0, portUSPRG0_OFFSET( SP )\r
+ mtspr 256, R0 #USPRG0\r
+ lwz R0, portCTR_OFFSET( SP )\r
+ mtspr CTR, R0\r
+ lwz R0, portLR_OFFSET( SP )\r
+ mtspr LR, R0\r
+ lwz R0, portXER_OFFSET( SP )\r
+ mtspr XER, R0\r
+ lwz R0, portCR_OFFSET( SP )\r
+ mtcr R0\r
+\r
+ # Pop GPRs\r
+ lmw R2, portGPR_OFFSET( SP )\r
+\r
+ # Finally pop R0 and correct the stack pointer\r
+ lwz R0, portR0_OFFSET( SP )\r
+ addi R1, R1, portCONTEXT_SIZE\r
+\r
+ # Start the task running\r
+ rfi\r
+\r
+ .endm\r
+\r
+.macro portSAVE_CONTEXT\r
+\r
+ # Make room on the stack.\r
+ subi R1, R1, portCONTEXT_SIZE\r
+\r
+ # Push R0, then the GPRs\r
+ stw R0, portR0_OFFSET( SP )\r
+ stm R2, portGPR_OFFSET( SP )\r
+\r
+ # Push the SFRs\r
+ mfcr R0\r
+ stw R0, portCR_OFFSET( SP )\r
+ mfspr R0, XER\r
+ stw R0, portXER_OFFSET( SP )\r
+ mfspr R0, LR\r
+ stw R0, portLR_OFFSET( SP )\r
+ mfspr R0, CTR\r
+ stw R0, portCTR_OFFSET( SP )\r
+ mfspr R0, 256 #USPRG0\r
+ stw R0, portUSPRG0_OFFSET( SP )\r
+ mfspr R0, SRR0\r
+ stw R0, portSRR0_OFFSET( SP )\r
+ mfspr R0, SRR1\r
+ stw R0, portSRR1_OFFSET( SP )\r
+\r
+ # Get the address of the TCB.\r
+ xor R0, R0, R0\r
+ addis R2, R0, pxCurrentTCB@ha\r
+ lwz R2, pxCurrentTCB@l( R2 )\r
+\r
+ # Store the stack pointer into the TCB\r
+ stw SP, 0( R2 )\r
+\r
+ .endm\r
+\r
+vStartFirstTask:\r
+ portRESTORE_CONTEXT\r
+ rfi\r
+\r
+\r
+\r
+vPortYield:\r
+\r
+ portSAVE_CONTEXT\r
+ bl vTaskSwitchContext\r
+ portRESTORE_CONTEXT\r
+\r
+ NOP\r
+ NOP\r
--- /dev/null
+/*\r
+ FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.\r
+\r
+ This file is part of the FreeRTOS.org distribution.\r
+\r
+ FreeRTOS.org is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ FreeRTOS.org is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with FreeRTOS.org; if not, write to the Free Software\r
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+ A special exception to the GPL can be applied should you wish to distribute\r
+ a combined work that includes FreeRTOS.org, without being obliged to provide\r
+ the source code for any proprietary components. See the licensing section \r
+ of http://www.FreeRTOS.org for full details of how and when the exception\r
+ can be applied.\r
+\r
+ ***************************************************************************\r
+\r
+ Please ensure to read the configuration and relevant port sections of the \r
+ online documentation.\r
+\r
+ +++ http://www.FreeRTOS.org +++\r
+ Documentation, latest information, license and contact details. \r
+\r
+ +++ http://www.SafeRTOS.com +++\r
+ A version that is certified for use in safety critical systems.\r
+\r
+ +++ http://www.OpenRTOS.com +++\r
+ Commercial support, development, porting, licensing and training services.\r
+\r
+ ***************************************************************************\r
+*/\r
+\r
+#ifndef PORTMACRO_H\r
+#define PORTMACRO_H\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/*-----------------------------------------------------------\r
+ * Port specific definitions. \r
+ *\r
+ * The settings in this file configure FreeRTOS correctly for the\r
+ * given hardware and compiler.\r
+ *\r
+ * These settings should not be altered.\r
+ *-----------------------------------------------------------\r
+ */\r
+\r
+/* Type definitions. */\r
+#define portCHAR char\r
+#define portFLOAT float\r
+#define portDOUBLE double\r
+#define portLONG long\r
+#define portSHORT short\r
+#define portSTACK_TYPE unsigned portLONG\r
+#define portBASE_TYPE portLONG\r
+\r
+#if( configUSE_16_BIT_TICKS == 1 )\r
+ typedef unsigned portSHORT portTickType;\r
+ #define portMAX_DELAY ( portTickType ) 0xffff\r
+#else\r
+ typedef unsigned portLONG portTickType;\r
+ #define portMAX_DELAY ( portTickType ) 0xffffffff\r
+#endif\r
+/*-----------------------------------------------------------*/ \r
+\r
+/* Interrupt control macros. */\r
+#define portDISABLE_INTERRUPTS() \r
+#define portENABLE_INTERRUPTS() \r
+/*-----------------------------------------------------------*/\r
+\r
+/* Critical section macros. */\r
+void vPortEnterCritical( void );\r
+void vPortExitCritical( void );\r
+#define portENTER_CRITICAL() \r
+#define portEXIT_CRITICAL()\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Task utilities. */\r
+void vPortYield( void );\r
+#define portYIELD() asm volatile ( "SC" )\r
+#define portYIELD_FROM_ISR()\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Hardware specifics. */\r
+#define portBYTE_ALIGNMENT 8\r
+#define portSTACK_GROWTH ( -1 )\r
+#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ ) \r
+#define portNOP() asm volatile ( "NOP" )\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Task function macros as described on the FreeRTOS.org WEB site. */\r
+#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
+#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* PORTMACRO_H */\r
+\r