]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/GCC/RISC-V-RV32/chip_specific_extensions/Pulpino_Vega_RV32M1RM/freertos_risc_v_port_specific_extensions.h
Re-org of RISC-V file structure and naming step 1.
[freertos] / FreeRTOS / Source / portable / GCC / RISC-V-RV32 / chip_specific_extensions / Pulpino_Vega_RV32M1RM / freertos_risc_v_port_specific_extensions.h
1 /*\r
2  * FreeRTOS Kernel V10.1.1\r
3  * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and t\r
10 \r
11  o permit persons to whom the Software is furnished to do so,\r
12  * subject to the following conditions:\r
13  *\r
14  * The above copyright notice and this permission notice shall be included in all\r
15  * copies or substantial portions of the Software.\r
16  *\r
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
19  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
20  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
21  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
23  *\r
24  * http://www.FreeRTOS.org\r
25  * http://aws.amazon.com/freertos\r
26  *\r
27  * 1 tab == 4 spaces!\r
28  */\r
29 \r
30 /*\r
31  * The FreeRTOS kernel's RISC-V port is split between the the code that is\r
32  * common across all currently supported RISC-V chips (implementations of the\r
33  * RISC-V ISA), and code which tailors the port to a specific RISC-V chip:\r
34  *\r
35  * + The code that is common to all RISC-V chips is implemented in\r
36  *   FreeRTOS\Source\portable\GCC\RISC-V-RV32\portASM.S.  There is only one\r
37  *   portASM.S file because the same file is used no matter which RISC-V chip is\r
38  *   in use.\r
39  *\r
40  * + The code that tailors the kernel's RISC-V port to a specific RISC-V\r
41  *   chip is implemented in freertos_risc_v_port_specific_extensions.h.  There\r
42  *   is one freertos_risc_v_port_specific_extensions.h that can be used with any\r
43  *   RISC-V chip that both includes a standard CLINT and does not add to the\r
44  *   base set of RISC-V registers.  There are additional\r
45  *   freertos_risc_v_port_specific_extensions.h files for RISC-V implementations\r
46  *   that do not include a standard CLINT or do add to the base set of RISC-V\r
47  *   registers.\r
48  *\r
49  * CARE MUST BE TAKEN TO INCLDUE THE CORRECT\r
50  * freertos_risc_v_port_specific_extensions.h HEADER FILE FOR THE CHIP\r
51  * IN USE.  To include the correct freertos_risc_v_port_specific_extensions.h\r
52  * header file ensure the path to the correct header file is in the assembler's\r
53  * include path.\r
54  *\r
55  * This freertos_risc_v_port_specific_extensions.h is for use with Pulpino Ri5cy\r
56  * devices, developed and tested using the Vega board RV32M1RM.\r
57  *\r
58  */\r
59 \r
60 #ifndef __FREERTOS_RISC_V_EXTENSIONS_H__\r
61 #define __FREERTOS_RISC_V_EXTENSIONS_H__\r
62 \r
63 #define portasmHAS_CLINT 0\r
64 \r
65 /* Constants to define the additional registers found on the Pulpino RI5KY. */\r
66 #define lpstart0        0x7b0\r
67 #define lpend0          0x7b1\r
68 #define lpcount0        0x7b2\r
69 #define lpstart1        0x7b4\r
70 #define lpend1          0x7b5\r
71 #define lpcount1        0x7b6\r
72 \r
73 /* Six additional registers to save and restore, as per the #defines above. */\r
74 #define portasmADDITIONAL_CONTEXT_SIZE 6 /* Must be even number on 32-bit cores. */\r
75 \r
76 /* Save additional registers found on the Pulpino. */\r
77 .macro portasmSAVE_ADDITIONAL_REGISTERS\r
78         addi sp, sp, -(portasmADDITIONAL_CONTEXT_SIZE * portWORD_SIZE) /* Make room for the additional registers. */\r
79         csrr t0, lpstart0                                                        /* Load additional registers into accessable temporary registers. */\r
80         csrr t1, lpend0\r
81         csrr t2, lpcount0\r
82         csrr t3, lpstart1\r
83         csrr t4, lpend1\r
84         csrr t5, lpcount1\r
85         sw t0, 1 * portWORD_SIZE( sp )\r
86         sw t1, 2 * portWORD_SIZE( sp )\r
87         sw t2, 3 * portWORD_SIZE( sp )\r
88         sw t3, 4 * portWORD_SIZE( sp )\r
89         sw t4, 5 * portWORD_SIZE( sp )\r
90         sw t5, 6 * portWORD_SIZE( sp )\r
91         .endm\r
92 \r
93 /* Restore the additional registers found on the Pulpino. */\r
94 .macro portasmRESTORE_ADDITIONAL_REGISTERS\r
95         lw t0, 1 * portWORD_SIZE( sp )                  /* Load additional registers into accessable temporary registers. */\r
96         lw t1, 2 * portWORD_SIZE( sp )\r
97         lw t2, 3 * portWORD_SIZE( sp )\r
98         lw t3, 4 * portWORD_SIZE( sp )\r
99         lw t4, 5 * portWORD_SIZE( sp )\r
100         lw t5, 6 * portWORD_SIZE( sp )\r
101         csrw lpstart0, t0\r
102         csrw lpend0, t1\r
103         csrw lpcount0, t2\r
104         csrw lpstart1, t3\r
105         csrw lpend1, t4\r
106         csrw lpcount1, t5\r
107         addi sp, sp, (portasmADDITIONAL_CONTEXT_SIZE * portWORD_SIZE )/* Remove space added for additional registers. */\r
108         .endm\r
109 \r
110 #endif /* __FREERTOS_RISC_V_EXTENSIONS_H__ */\r