]> git.sur5r.net Git - freertos/blob - Demo/RX600_RX63N-RSK_Renesas/RTOSDemo/Renesas-Files/board/rskrx63n/sbrk.c
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / RX600_RX63N-RSK_Renesas / RTOSDemo / Renesas-Files / board / rskrx63n / sbrk.c
1 /***********************************************************************************************************************\r
2 * DISCLAIMER\r
3 * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No \r
4 * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all \r
5 * applicable laws, including copyright laws. \r
6 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING\r
7 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, \r
8 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM \r
9 * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES \r
10 * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS \r
11 * SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r
12 * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of \r
13 * this software. By using this software, you agree to the additional terms and conditions found by accessing the \r
14 * following link:\r
15 * http://www.renesas.com/disclaimer \r
16 *\r
17 * Copyright (C) 2012 Renesas Electronics Corporation. All rights reserved.    \r
18 ***********************************************************************************************************************/\r
19 /***********************************************************************************************************************\r
20 * File Name        : sbrk.c\r
21 * Device(s)    : RX\r
22 * Description  : Configures the MCU heap memory.  The size of the heap is defined by the macro HEAPSIZE below.\r
23 ***********************************************************************************************************************/\r
24 /***********************************************************************************************************************\r
25 * History : DD.MM.YYYY Version  Description\r
26 *         : 26.10.2011 1.00     First Release\r
27 *         : 12.03.2012 1.10     Heap size is now defined in r_bsp_config.h, not sbrk.h.\r
28 ***********************************************************************************************************************/\r
29 /***********************************************************************************************************************\r
30 Includes   <System Includes> , "Project Includes"\r
31 ***********************************************************************************************************************/\r
32 /* Provides standard definitions used in this file */
33 #include <stddef.h>
34 /* Defines standard input/output functions used in this file */
35 #include <stdio.h>
36 /* Defines standard variable types used in this file */
37 #include <stdint.h>\r
38 /* Used for getting HEAP_BYTES macro. */\r
39 #include "platform.h"
40 \r
41 /***********************************************************************************************************************\r
42 Macro definitions\r
43 ***********************************************************************************************************************/\r
44
45 /***********************************************************************************************************************
46 Function Prototypes
47 ***********************************************************************************************************************/
48 /* Memory allocation function prototype declaration */
49 int8_t  *sbrk(size_t size);
50
51 /***********************************************************************************************************************
52 Global Variables
53 ***********************************************************************************************************************/
54 //const size_t _sbrk_size=      /* Specifies the minimum unit of */
55 /* the defined heap area */
56 extern int8_t *_s1ptr;
57
58 union HEAP_TYPE
59 {
60     int32_t  dummy;             /* Dummy for 4-byte boundary */
61     int8_t heap[HEAP_BYTES];    /* Declaration of the area managed by sbrk*/
62 };
63 /* Declare memory heap area */
64 static union HEAP_TYPE heap_area;
65 /* End address allocated by sbrk    */
66 static int8_t *brk=(int8_t *)&heap_area;
67
68 /***********************************************************************************************************************\r
69 * Function name: sbrk\r
70 * Description  : This function configures MCU memory area allocation.\r
71 * Arguments    : size - \r
72 *                    assigned area size\r
73 * Return value : Start address of allocated area (pass)\r
74 *                -1 (failure)\r
75 ***********************************************************************************************************************/\r
76 int8_t  *sbrk(size_t size)                      
77 {
78     int8_t  *p;
79
80     if (brk+size > heap_area.heap+HEAP_BYTES)
81     {
82         /* Empty area size  */
83         p = (int8_t *)-1;
84     }
85     else
86     {
87         /* Area assignment */
88         p = brk;  
89
90         /* End address update */                           
91         brk += size;                           
92     }
93
94     /* Return result */
95     return p;
96 }