From 1cfb7b77e51b3b05e48cc6c209007cd67a2cf81d Mon Sep 17 00:00:00 2001
From: Richard Barry <ribarry@amazon.com>
Date: Thu, 20 Jun 2013 14:59:11 +0000
Subject: [PATCH] Add retarget.c to RVDS project to ensure semihosting is not
 used.

---
 .../CORTEX_A9_RZ_R7S72100_IAR_DS-5/.cproject  |   2 +-
 .../Source/Full-Demo/main_full.c              |   2 +-
 .../Source/RenesasFiles/common/resetprg.c     |   6 -
 .../Source/RenesasFiles/common/retarget.c     | 149 ++++++++++++++++++
 .../target_scripts/init_RZ-A1H.ds             |   1 +
 5 files changed, 152 insertions(+), 8 deletions(-)
 create mode 100644 FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/RenesasFiles/common/retarget.c

diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/.cproject b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/.cproject
index 52969dd3e2..5b91ada31e 100644
--- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/.cproject
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/.cproject
@@ -27,7 +27,7 @@
 									<listOptionValue builtIn="false" value="ARM_SIM"/>
 								</option>
 								<option id="com.arm.tool.c.compiler.baremetal.exe.debug.option.opt.799477241" name="Optimization level" superClass="com.arm.tool.c.compiler.baremetal.exe.debug.option.opt" value="com.arm.tool.c.compiler.option.optlevel.min" valueType="enumerated"/>
-								<option id="com.arm.tool.c.compiler.option.optfor.2031421359" name="Optimize for" superClass="com.arm.tool.c.compiler.option.optfor" value="com.arm.tool.c.compiler.option.optfor.size" valueType="enumerated"/>
+								<option id="com.arm.tool.c.compiler.option.optfor.2031421359" name="Optimize for" superClass="com.arm.tool.c.compiler.option.optfor" value="com.arm.tool.c.compiler.option.optfor.time" valueType="enumerated"/>
 								<option id="com.arm.tool.c.compiler.option.targetcpu.1542570835" name="Target CPU (--cpu)" superClass="com.arm.tool.c.compiler.option.targetcpu" value="Cortex-A9" valueType="string"/>
 								<option id="com.arm.tool.c.compiler.option.endian.1071397580" name="Byte order" superClass="com.arm.tool.c.compiler.option.endian" value="com.arm.tool.c.compiler.option.endian.little" valueType="enumerated"/>
 								<option id="com.arm.tool.c.compiler.option.inst.1331808544" name="Instruction set" superClass="com.arm.tool.c.compiler.option.inst" value="com.arm.tool.c.compiler.option.inst.arm" valueType="enumerated"/>
diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/main_full.c b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/main_full.c
index 3c893cebf9..0731cedd99 100644
--- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/main_full.c
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/Full-Demo/main_full.c
@@ -169,7 +169,7 @@ configINCLUDE_FAT_SL_DEMO to 1 to include the FreeRTOS+FAT SL (and therefore
 also FreeRTOS+CLI) demo in the build.  Set configINCLUDE_FAT_SL_DEMO to 0 to
 include the COM test tasks.  The COM test tasks require a loop back connector
 to be fitted to the UART port. */
-#define mainINCLUDE_FAT_SL_DEMO				0
+#define mainINCLUDE_FAT_SL_DEMO				1
 
 /* Priorities for the demo application tasks. */
 #define mainSEM_TEST_PRIORITY				( tskIDLE_PRIORITY + 1UL )
diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/RenesasFiles/common/resetprg.c b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/RenesasFiles/common/resetprg.c
index 7ec022f20d..926dd75c0b 100644
--- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/RenesasFiles/common/resetprg.c
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/RenesasFiles/common/resetprg.c
@@ -98,12 +98,6 @@ void $Sub$$main(void)
     /* ==== INTC setting ==== */
     R_INTC_Init();
 
-    /* ==== Cache setting ==== */
-//    io_init_cache();
-
-    /* ==== Writeback Cache ==== */
-//    io_cache_writeback();
-
     L1CacheInit();
 
     /* ==== Vector base address setting ==== */
diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/RenesasFiles/common/retarget.c b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/RenesasFiles/common/retarget.c
new file mode 100644
index 0000000000..e0d1a33bfc
--- /dev/null
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/RenesasFiles/common/retarget.c
@@ -0,0 +1,149 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer
+*
+* Copyright (C) 2012 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/*******************************************************************************
+* File Name    : retarget.c
+* $Rev: $
+* $Date::                           $
+* Device(s)    : Aragon
+* Tool-Chain   : DS-5 Ver 5.13
+*              : ARM Complier
+* OS           : 
+* H/W Platform : Aragon CPU Board
+* Description  : Aragon Sample Program - Retarget standard I/O
+* Operation    : 
+* Limitations  : 
+*******************************************************************************/
+
+        #ifdef        __STANDALONE__
+
+/******************************************************************************
+Includes   <System Includes> , "Project Includes"
+******************************************************************************/
+#include <stdio.h>
+#include "r_typedefs.h"
+#include "sio_char.h"
+
+#pragma import(__use_no_semihosting)
+
+/******************************************************************************
+Typedef definitions
+******************************************************************************/
+struct __FILE
+{
+  int_t handle;
+
+  /* Whatever you require here. If the only file you are using is   */
+  /* standard output using printf() for debugging, no file handling */
+  /* is required.                                                   */
+};
+
+/******************************************************************************
+Macro definitions
+******************************************************************************/
+/* File descriptor */
+#define STDIN       (0)
+#define STDOUT      (1)
+#define STDERR      (2)
+
+#define IOSTREAM    (1)
+#define BUFF_SIZE   (256)
+
+#if 0
+#define DEFAULT_HANDLE  (0x100)
+#endif
+
+/******************************************************************************
+Imported global variables and functions (from other files)
+******************************************************************************/
+
+/******************************************************************************
+Exported global variables and functions (to be accessed by other files)
+******************************************************************************/
+FILE __stdout;
+FILE __stdin;
+#if 0
+FILE __stderr;
+#endif
+
+/******************************************************************************
+Private global variables and functions
+******************************************************************************/
+
+/******************************************************************************
+* Function Name: fgetc
+* Description  :
+* Arguments    :
+* Return Value :
+******************************************************************************/
+int_t fgetc(FILE * file_p)
+{
+    /* no character to read */
+    return EOF;
+}
+
+/******************************************************************************
+* Function Name: fputc
+* Description  :
+* Arguments    :
+* Return Value :
+******************************************************************************/
+int_t fputc(int_t channel, FILE * file_p)
+{
+     return channel;
+}
+
+/******************************************************************************
+* Function Name: ferror
+* Description  : 
+* Arguments    : 
+* Return Value : 
+******************************************************************************/
+int_t ferror(FILE * file_p)
+{
+    return 0;
+}
+
+int_t __backspace(FILE * file_p)
+{
+    return 0;
+}
+
+
+void _sys_exit(int_t returncode)
+{
+    while (1)
+    {
+        /* Do Nothing */
+    }
+}
+
+char_t * _sys_command_string(char_t * cmd, int_t len)
+{
+    return cmd;
+}
+
+    #endif        /* __STANDALONE__    �Z�~�z�X�e�B���O����    */
+
+/* End of File */
+
diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/target_scripts/init_RZ-A1H.ds b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/target_scripts/init_RZ-A1H.ds
index 0f142a8133..b8c1e51c7f 100644
--- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/target_scripts/init_RZ-A1H.ds
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/target_scripts/init_RZ-A1H.ds
@@ -52,3 +52,4 @@ mem set 0xfcfe360c 16 0x0080        # PFCE3
 mem set 0xfcfe350c 16 0x0000        # PFC3
 mem set 0xfcfe720c 16 0x0080        # PIPC3
 
+