|
| 1 | +// Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC) |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | +// |
| 15 | +// Original Author: Shay Gal-on |
| 16 | + |
| 17 | +#include "regs/cheshire.h" |
| 18 | +#include "dif/clint.h" |
| 19 | +#include "dif/uart.h" |
| 20 | +#include "params.h" |
| 21 | +#include "util.h" |
| 22 | + |
| 23 | +/* Topic : Description |
| 24 | + This file contains configuration constants required to execute on |
| 25 | + different platforms |
| 26 | +*/ |
| 27 | +#ifndef CORE_PORTME_H |
| 28 | +#define CORE_PORTME_H |
| 29 | +/************************/ |
| 30 | +/* Data types and settings */ |
| 31 | +/************************/ |
| 32 | +/* Configuration : HAS_FLOAT |
| 33 | + Define to 1 if the platform supports floating point. |
| 34 | +*/ |
| 35 | +#ifndef HAS_FLOAT |
| 36 | +#define HAS_FLOAT 1 |
| 37 | +#endif |
| 38 | +/* Configuration : HAS_TIME_H |
| 39 | + Define to 1 if platform has the time.h header file, |
| 40 | + and implementation of functions thereof. |
| 41 | +*/ |
| 42 | +#ifndef HAS_TIME_H |
| 43 | +#define HAS_TIME_H 0 |
| 44 | +#endif |
| 45 | +/* Configuration : USE_CLOCK |
| 46 | + Define to 1 if platform has the time.h header file, |
| 47 | + and implementation of functions thereof. |
| 48 | +*/ |
| 49 | +#ifndef USE_CLOCK |
| 50 | +#define USE_CLOCK 0 |
| 51 | +#endif |
| 52 | +/* Configuration : HAS_STDIO |
| 53 | + Define to 1 if the platform has stdio.h. |
| 54 | +*/ |
| 55 | +#ifndef HAS_STDIO |
| 56 | +#define HAS_STDIO 0 |
| 57 | +#endif |
| 58 | +/* Configuration : HAS_PRINTF |
| 59 | + Define to 1 if the platform has stdio.h and implements the printf |
| 60 | + function. |
| 61 | +*/ |
| 62 | +#ifndef HAS_PRINTF |
| 63 | +#define HAS_PRINTF 0 |
| 64 | +#endif |
| 65 | + |
| 66 | +/* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION |
| 67 | + Initialize these strings per platform |
| 68 | +*/ |
| 69 | +#ifndef COMPILER_VERSION |
| 70 | +#ifdef __GNUC__ |
| 71 | +#define COMPILER_VERSION "GCC"__VERSION__ |
| 72 | +#else |
| 73 | +#define COMPILER_VERSION "Please put compiler version here (e.g. gcc 4.1)" |
| 74 | +#endif |
| 75 | +#endif |
| 76 | +#ifndef COMPILER_FLAGS |
| 77 | +#define COMPILER_FLAGS \ |
| 78 | + FLAGS_STR /* "Please put compiler flags here (e.g. -o3)" */ |
| 79 | +#endif |
| 80 | +#ifndef MEM_LOCATION |
| 81 | +#define MEM_LOCATION "STACK" |
| 82 | +#endif |
| 83 | + |
| 84 | +/* Data Types : |
| 85 | + To avoid compiler issues, define the data types that need ot be used for |
| 86 | + 8b, 16b and 32b in <core_portme.h>. |
| 87 | +
|
| 88 | + *Imprtant* : |
| 89 | + ee_ptr_int needs to be the data type used to hold pointers, otherwise |
| 90 | + coremark may fail!!! |
| 91 | +*/ |
| 92 | +typedef signed short ee_s16; |
| 93 | +typedef unsigned short ee_u16; |
| 94 | +typedef signed int ee_s32; |
| 95 | +typedef float ee_f32; |
| 96 | +typedef double ee_f64; |
| 97 | +typedef unsigned char ee_u8; |
| 98 | +typedef unsigned int ee_u32; |
| 99 | +typedef unsigned long ee_u64; |
| 100 | +typedef ee_u64 ee_ptr_int; |
| 101 | +typedef ee_u64 ee_size_t; |
| 102 | +#define NULL ((void *)0) |
| 103 | +/* align_mem : |
| 104 | + This macro is used to align an offset to point to a 32b value. It is |
| 105 | + used in the Matrix algorithm to initialize the input memory blocks. |
| 106 | +*/ |
| 107 | +#define align_mem(x) (void *)(4 + (((ee_ptr_int)(x)-1) & ~3)) |
| 108 | + |
| 109 | +/* Configuration : CORE_TICKS |
| 110 | + Define type of return from the timing functions. |
| 111 | + */ |
| 112 | +#define CORETIMETYPE ee_u32 |
| 113 | +typedef ee_u32 CORE_TICKS; |
| 114 | + |
| 115 | +/* Configuration : SEED_METHOD |
| 116 | + Defines method to get seed values that cannot be computed at compile |
| 117 | + time. |
| 118 | +
|
| 119 | + Valid values : |
| 120 | + SEED_ARG - from command line. |
| 121 | + SEED_FUNC - from a system function. |
| 122 | + SEED_VOLATILE - from volatile variables. |
| 123 | +*/ |
| 124 | +#ifndef SEED_METHOD |
| 125 | +#define SEED_METHOD SEED_VOLATILE |
| 126 | +#endif |
| 127 | + |
| 128 | +/* Configuration : MEM_METHOD |
| 129 | + Defines method to get a block of memry. |
| 130 | +
|
| 131 | + Valid values : |
| 132 | + MEM_MALLOC - for platforms that implement malloc and have malloc.h. |
| 133 | + MEM_STATIC - to use a static memory array. |
| 134 | + MEM_STACK - to allocate the data block on the stack (NYI). |
| 135 | +*/ |
| 136 | +#ifndef MEM_METHOD |
| 137 | +#define MEM_METHOD MEM_STATIC |
| 138 | +#endif |
| 139 | + |
| 140 | +/* Configuration : MULTITHREAD |
| 141 | + Define for parallel execution |
| 142 | +
|
| 143 | + Valid values : |
| 144 | + 1 - only one context (default). |
| 145 | + N>1 - will execute N copies in parallel. |
| 146 | +
|
| 147 | + Note : |
| 148 | + If this flag is defined to more then 1, an implementation for launching |
| 149 | + parallel contexts must be defined. |
| 150 | +
|
| 151 | + Two sample implementations are provided. Use <USE_PTHREAD> or <USE_FORK> |
| 152 | + to enable them. |
| 153 | +
|
| 154 | + It is valid to have a different implementation of <core_start_parallel> |
| 155 | + and <core_end_parallel> in <core_portme.c>, to fit a particular architecture. |
| 156 | +*/ |
| 157 | +#ifndef MULTITHREAD |
| 158 | +#define MULTITHREAD 1 |
| 159 | +#define USE_PTHREAD 0 |
| 160 | +#define USE_FORK 0 |
| 161 | +#define USE_SOCKET 0 |
| 162 | +#endif |
| 163 | + |
| 164 | +/* Configuration : MAIN_HAS_NOARGC |
| 165 | + Needed if platform does not support getting arguments to main. |
| 166 | +
|
| 167 | + Valid values : |
| 168 | + 0 - argc/argv to main is supported |
| 169 | + 1 - argc/argv to main is not supported |
| 170 | +
|
| 171 | + Note : |
| 172 | + This flag only matters if MULTITHREAD has been defined to a value |
| 173 | + greater then 1. |
| 174 | +*/ |
| 175 | +#ifndef MAIN_HAS_NOARGC |
| 176 | +#define MAIN_HAS_NOARGC 0 |
| 177 | +#endif |
| 178 | + |
| 179 | +/* Configuration : MAIN_HAS_NORETURN |
| 180 | + Needed if platform does not support returning a value from main. |
| 181 | +
|
| 182 | + Valid values : |
| 183 | + 0 - main returns an int, and return value will be 0. |
| 184 | + 1 - platform does not support returning a value from main |
| 185 | +*/ |
| 186 | +#ifndef MAIN_HAS_NORETURN |
| 187 | +#define MAIN_HAS_NORETURN 0 |
| 188 | +#endif |
| 189 | + |
| 190 | +/* Variable : default_num_contexts |
| 191 | + Not used for this simple port, must contain the value 1. |
| 192 | +*/ |
| 193 | +extern ee_u32 default_num_contexts; |
| 194 | + |
| 195 | +typedef struct CORE_PORTABLE_S |
| 196 | +{ |
| 197 | + ee_u8 portable_id; |
| 198 | +} core_portable; |
| 199 | + |
| 200 | +/* target specific init/fini */ |
| 201 | +void portable_init(core_portable *p, int *argc, char *argv[]); |
| 202 | +void portable_fini(core_portable *p); |
| 203 | + |
| 204 | +#if !defined(PROFILE_RUN) && !defined(PERFORMANCE_RUN) \ |
| 205 | + && !defined(VALIDATION_RUN) |
| 206 | +#if (TOTAL_DATA_SIZE == 1200) |
| 207 | +#define PROFILE_RUN 1 |
| 208 | +#elif (TOTAL_DATA_SIZE == 2000) |
| 209 | +#define PERFORMANCE_RUN 1 |
| 210 | +#else |
| 211 | +#define VALIDATION_RUN 1 |
| 212 | +#endif |
| 213 | +#endif |
| 214 | + |
| 215 | +int ee_printf(const char *fmt, ...); |
| 216 | + |
| 217 | +#endif /* CORE_PORTME_H */ |
0 commit comments