struct / union in initializer, RFE #901.
[sdcc.git] / sdcc-extra / historygraphs / coremark-1.0-stm8.patch
blobbd16e4cbb838362d61a6e4c2185a229159a24c81
1 diff -u coremark_v1.0/core_main.c coremark-stm8/core_main.c
2 --- coremark_v1.0/core_main.c 2009-08-25 20:11:26.000000000 +0200
3 +++ coremark-stm8/core_main.c 2018-01-31 15:06:33.249348900 +0100
4 @@ -210,7 +210,7 @@
5 if (divisor==0) /* some machines cast float to int as 0 since this conversion is not defined by ANSI, but we know at least one second passed */
6 divisor=1;
7 results[0].iterations*=1+10/divisor;
8 - }
9 + }results[0].iterations = 60;
10 /* perform actual benchmark */
11 start_time();
12 #if (MULTITHREAD>1)
13 @@ -291,9 +291,9 @@
14 if (time_in_secs(total_time) > 0)
15 ee_printf("Iterations/Sec : %f\n",default_num_contexts*results[0].iterations/time_in_secs(total_time));
16 #else
17 - ee_printf("Total time (secs): %d\n",time_in_secs(total_time));
18 + ee_printf("Total time (secs): %lu\n",time_in_secs(total_time));
19 if (time_in_secs(total_time) > 0)
20 - ee_printf("Iterations/Sec : %d\n",default_num_contexts*results[0].iterations/time_in_secs(total_time));
21 + ee_printf("Iterations/Sec : %lu\n",default_num_contexts*results[0].iterations/time_in_secs(total_time));
22 #endif
23 if (time_in_secs(total_time) < 10) {
24 ee_printf("ERROR! Must execute for at least 10 secs for a valid result!\n");
25 diff -u coremark_v1.0/core_portme.c coremark-stm8/core_portme.c
26 --- coremark_v1.0/core_portme.c 2018-01-31 15:14:02.207818287 +0100
27 +++ coremark-stm8/core_portme.c 2018-01-31 15:12:39.884267347 +0100
28 @@ -5,8 +5,11 @@
29 Author : Shay Gal-On, EEMBC
30 Legal : TODO!
31 */
32 +#include <stdio.h>
33 +#include <stdlib.h>
34 #include "coremark.h"
35 -#include "core_portme.h"
37 +#define ITERATIONS 100
39 #if VALIDATION_RUN
40 volatile ee_s32 seed1_volatile=0x3415;
41 @@ -30,20 +33,22 @@
42 e.g. Read value from on board RTC, read value from cpu clock cycles performance counter etc.
43 Sample implementation for standard time.h and windows.h definitions included.
45 -CORETIMETYPE barebones_clock() {
46 - #error "You must implement a method to measure time in barebones_clock()! This function should return current time.\n"
48 /* Define : TIMER_RES_DIVIDER
49 Divider to trade off timer resolution and total time that can be measured.
51 Use lower values to increase resolution, but make sure that overflow does not occur.
52 If there are issues with the return value overflowing, increase this value.
54 -#define GETMYTIME(_t) (*_t=barebones_clock())
55 +#define CLOCKS_PER_SEC 1000
56 +#define NSECS_PER_SEC CLOCKS_PER_SEC
57 +unsigned int clock(void);
58 +//#define CORETIMETYPE clock_t
59 +#define CORETIMETYPE unsigned
60 +#define GETMYTIME(_t) (*_t=clock())
61 #define MYTIMEDIFF(fin,ini) ((fin)-(ini))
62 #define TIMER_RES_DIVIDER 1
63 #define SAMPLE_TIME_IMPLEMENTATION 1
64 -#define EE_TICKS_PER_SEC (CLOCKS_PER_SEC / TIMER_RES_DIVIDER)
65 +#define EE_TICKS_PER_SEC (NSECS_PER_SEC / TIMER_RES_DIVIDER)
67 /** Define Host specific (POSIX), or target specific global time variables. */
68 static CORETIMETYPE start_time_val, stop_time_val;
69 @@ -92,13 +97,16 @@
71 ee_u32 default_num_contexts=1;
73 +void init(void);
75 /* Function : portable_init
76 Target specific initialization code
77 Test for some common mistakes.
79 void portable_init(core_portable *p, int *argc, char *argv[])
81 - #error "Call board initialization routines in portable init (if needed), in particular initialize UART!\n"
82 + init();
84 if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
85 ee_printf("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n");
87 @@ -115,4 +123,96 @@
88 p->portable_id=0;
91 +#include <stdio.h>
92 +#include <stdint.h>
94 +#define PA_DDR (*(volatile uint8_t *)0x5002)
95 +#define PA_CR1 (*(volatile uint8_t *)0x5003)
97 +#define CLK_DIVR (*(volatile uint8_t *)0x50c6)
98 +#define CLK_PCKENR1 (*(volatile uint8_t *)0x50c7)
99 +#define CLK_PCKENR2 (*(volatile uint8_t *)0x50ca)
101 +#define USART3_SR (*(volatile uint8_t *)0x5240)
102 +#define USART3_DR (*(volatile uint8_t *)0x5241)
103 +#define USART3_BRR1 (*(volatile uint8_t *)0x5242)
104 +#define USART3_BRR2 (*(volatile uint8_t *)0x5243)
105 +#define USART3_CR2 (*(volatile uint8_t *)0x5245)
106 +#define USART3_CR3 (*(volatile uint8_t *)0x5246)
108 +#define TIM1_CR1 (*(volatile uint8_t *)0x5250)
109 +#define TIM1_CNTRH (*(volatile uint8_t *)0x525e)
110 +#define TIM1_CNTRL (*(volatile uint8_t *)0x525f)
111 +#define TIM1_PSCRH (*(volatile uint8_t *)0x5260)
112 +#define TIM1_PSCRL (*(volatile uint8_t *)0x5261)
114 +#define USART_CR2_TEN (1 << 3)
115 +#define USART_CR3_STOP2 (1 << 5)
116 +#define USART_CR3_STOP1 (1 << 4)
117 +#define USART_SR_TXE (1 << 7)
119 +void init(void)
121 + CLK_DIVR = 0x00; // Set the frequency to 16 MHz
122 + CLK_PCKENR2 |= 0x02; // Enable clock to timer
124 + // Configure timer
125 + // 1000 ticks per second
126 + TIM1_PSCRH = 0x3e;
127 + TIM1_PSCRL = 0x80;
128 + // Enable timer
129 + TIM1_CR1 = 0x01;
131 + CLK_PCKENR1 = 0xFF; // Enable peripherals
133 + PA_DDR = 0x08; // Put TX line on
134 + PA_CR1 = 0x08;
136 + USART3_CR2 = USART_CR2_TEN; // Allow TX & RX
137 + USART3_CR3 &= ~(USART_CR3_STOP1 | USART_CR3_STOP2); // 1 stop bit
138 + USART3_BRR2 = 0x03; USART3_BRR1 = 0x68; // 9600 baud
141 +unsigned int clock(void)
143 + unsigned char h = TIM1_CNTRH;
144 + unsigned char l = TIM1_CNTRL;
145 + return((unsigned int)(h) << 8 | l);
148 +#if defined(__CSMC__) // Cosmic weirdness
149 +char putchar(char c)
151 + while(!(USART3_SR & USART_SR_TXE));
153 + USART3_DR = c;
155 + return c;
157 +#elif defined(__RCSTM8__) // Raisonance weirdness
158 +int putchar(char c)
160 + while(!(USART3_SR & USART_SR_TXE));
162 + USART3_DR = c;
164 + return(c);
166 +#elif defined(__SDCC) && __SDCC_REVISION < 9624 // Old SDCC weirdness
167 +void putchar(char c)
169 + while(!(USART3_SR & USART_SR_TXE));
171 + USART3_DR = c;
173 +#else // Standard C
174 +int putchar(int c)
176 + while(!(USART3_SR & USART_SR_TXE));
178 + USART3_DR = c;
180 + return(c);
182 +#endif
184 diff -u coremark_v1.0/core_portme.h coremark-stm8/core_portme.h
185 --- coremark_v1.0/core_portme.h 2018-01-31 15:14:02.207818287 +0100
186 +++ coremark-stm8/core_portme.h 2018-01-31 15:06:33.249348900 +0100
187 @@ -16,21 +16,21 @@
188 Define to 1 if the platform supports floating point.
190 #ifndef HAS_FLOAT
191 -#define HAS_FLOAT 1
192 +#define HAS_FLOAT 0
193 #endif
194 /* Configuration : HAS_TIME_H
195 Define to 1 if platform has the time.h header file,
196 and implementation of functions thereof.
198 #ifndef HAS_TIME_H
199 -#define HAS_TIME_H 1
200 +#define HAS_TIME_H 0
201 #endif
202 /* Configuration : USE_CLOCK
203 Define to 1 if platform has the time.h header file,
204 and implementation of functions thereof.
206 #ifndef USE_CLOCK
207 -#define USE_CLOCK 1
208 +#define USE_CLOCK 0
209 #endif
210 /* Configuration : HAS_STDIO
211 Define to 1 if the platform has stdio.h.
212 @@ -42,10 +42,16 @@
213 Define to 1 if the platform has stdio.h and implements the printf function.
215 #ifndef HAS_PRINTF
216 -#define HAS_PRINTF 0
217 +#define HAS_PRINTF 1
218 #endif
221 +/* Configuration : CORE_TICKS
222 + Define type of return from the timing functions.
223 + */
224 +//#include <time.h>
225 +//typedef clock_t CORE_TICKS;
226 +unsigned int clock(void);
227 +typedef unsigned int CORE_TICKS;
228 /* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION
229 Initialize these strings per platform
231 @@ -57,7 +63,7 @@
232 #endif
233 #endif
234 #ifndef COMPILER_FLAGS
235 - #define COMPILER_FLAGS FLAGS_STR /* "Please put compiler flags here (e.g. -o3)" */
236 + #define COMPILER_FLAGS "Please put compiler flags here (e.g. -o3)"
237 #endif
238 #ifndef MEM_LOCATION
239 #define MEM_LOCATION "STACK"
240 @@ -69,26 +75,23 @@
241 *Imprtant* :
242 ee_ptr_int needs to be the data type used to hold pointers, otherwise coremark may fail!!!
244 -typedef signed short ee_s16;
245 -typedef unsigned short ee_u16;
246 -typedef signed int ee_s32;
247 -typedef double ee_f32;
248 -typedef unsigned char ee_u8;
249 -typedef unsigned int ee_u32;
250 -typedef ee_u32 ee_ptr_int;
251 +#include <stdio.h>
252 +#include <stddef.h>
253 +#include <stdint.h>
255 +typedef int16_t ee_s16;
256 +typedef uint16_t ee_u16;
257 +typedef int32_t ee_s32;
258 +typedef float ee_f32;
259 +typedef uint8_t ee_u8;
260 +typedef uint32_t ee_u32;
261 +typedef uintptr_t ee_ptr_int;
262 typedef size_t ee_size_t;
263 -#define NULL ((void *)0)
264 /* align_mem :
265 This macro is used to align an offset to point to a 32b value. It is used in the Matrix algorithm to initialize the input memory blocks.
267 #define align_mem(x) (void *)(4 + (((ee_ptr_int)(x) - 1) & ~3))
269 -/* Configuration : CORE_TICKS
270 - Define type of return from the timing functions.
271 - */
272 -#define CORETIMETYPE ee_u32
273 -typedef ee_u32 CORE_TICKS;
275 /* Configuration : SEED_METHOD
276 Defines method to get seed values that cannot be computed at compile time.
278 @@ -146,7 +149,7 @@
279 This flag only matters if MULTITHREAD has been defined to a value greater then 1.
281 #ifndef MAIN_HAS_NOARGC
282 -#define MAIN_HAS_NOARGC 0
283 +#define MAIN_HAS_NOARGC 1
284 #endif
286 /* Configuration : MAIN_HAS_NORETURN
287 @@ -157,7 +160,7 @@
288 1 - platform does not support returning a value from main
290 #ifndef MAIN_HAS_NORETURN
291 -#define MAIN_HAS_NORETURN 0
292 +#define MAIN_HAS_NORETURN 1
293 #endif
295 /* Variable : default_num_contexts
296 @@ -183,6 +186,4 @@
297 #endif
298 #endif
300 -int ee_printf(const char *fmt, ...);
302 #endif /* CORE_PORTME_H */
303 diff -u coremark_v1.0/Makefile coremark-stm8/Makefile
304 --- coremark_v1.0/Makefile 2009-07-10 19:48:43.000000000 +0200
305 +++ coremark-stm8/Makefile 2018-01-31 15:10:27.276856198 +0100
306 @@ -1,141 +1,15 @@
307 -#Author : Shay Gal-On, EEMBC
309 -#This file is part of EEMBC(R) and CoreMark(TM), which are Copyright (C) 2009
310 -#All rights reserved.
312 -#EEMBC CoreMark Software is a product of EEMBC and is provided under the terms of the
313 -#CoreMark License that is distributed with the official EEMBC COREMARK Software release.
314 -#If you received this EEMBC CoreMark Software without the accompanying CoreMark License,
315 -#you must discontinue use and download the official release from www.coremark.org.
317 -#Also, if you are publicly displaying scores generated from the EEMBC CoreMark software,
318 -#make sure that you are in compliance with Run and Reporting rules specified in the accompanying readme.txt file.
320 -#EEMBC
321 -#4354 Town Center Blvd. Suite 114-200
322 -#El Dorado Hills, CA, 95762
323 +SOURCES = core_list_join.c core_main.c core_matrix.c core_state.c core_util.c core_portme.c
324 +OBJ = $(SOURCES:.c=.rel)
325 +SDCC = sdcc
327 +all: coremark
329 -# Make sure the default target is to simply build and run the benchmark.
330 -RSTAMP = v1.0
332 -.PHONY: run score
333 -run: $(OUTFILE) rerun score
335 -score:
336 - @echo "Check run1.log and run2.log for results."
337 - @echo "See readme.txt for run and reporting rules."
339 -ifndef PORT_DIR
340 -# Ports for a couple of common self hosted platforms
341 -UNAME=$(shell if [[ `uname 2> /dev/null` ]] ; then uname ; fi)
342 -ifneq (,$(findstring CYGWIN,$(UNAME)))
343 -PORT_DIR=cygwin
344 -endif
345 -ifneq (,$(findstring Linux,$(UNAME)))
346 -MACHINE=$(shell uname -m)
347 -ifneq (,$(findstring 64,$(MACHINE)))
348 -PORT_DIR=linux64
349 -else
350 -PORT_DIR=linux
351 -endif
352 -endif
353 -endif
354 -ifndef PORT_DIR
355 -$(error PLEASE define PORT_DIR! (e.g. make PORT_DIR=simple))
356 -endif
357 -vpath %.c $(PORT_DIR)
358 -vpath %.h $(PORT_DIR)
359 -vpath %.mak $(PORT_DIR)
360 -include $(PORT_DIR)/core_portme.mak
362 -ifndef $(ITERATIONS)
363 -ITERATIONS=0
364 -endif
365 -ifdef REBUILD
366 -FORCE_REBUILD=force_rebuild
367 -endif
369 -CFLAGS += -DITERATIONS=$(ITERATIONS)
371 -CORE_FILES = core_list_join core_main core_matrix core_state core_util
372 -ORIG_SRCS = $(addsuffix .c,$(CORE_FILES))
373 -SRCS = $(ORIG_SRCS) $(PORT_SRCS)
374 -OBJS = $(addprefix $(OPATH),$(addsuffix $(OEXT),$(CORE_FILES)) $(PORT_OBJS))
375 -OUTNAME = coremark$(EXE)
376 -OUTFILE = $(OPATH)$(OUTNAME)
377 -LOUTCMD = $(OFLAG) $(OUTFILE) $(LFLAGS_END)
378 -OUTCMD = $(OUTFLAG) $(OUTFILE) $(LFLAGS_END)
380 -HEADERS = coremark.h
381 -CHECK_FILES = $(ORIG_SRCS) $(HEADERS)
383 -$(OPATH):
384 - $(MKDIR) $(OPATH)
386 -.PHONY: compile link
387 -ifdef SEPARATE_COMPILE
388 -$(OPATH)$(PORT_DIR):
389 - $(MKDIR) $(OPATH)$(PORT_DIR)
391 -compile: $(OPATH) $(OPATH)$(PORT_DIR) $(OBJS) $(HEADERS)
392 -link: compile
393 - $(LD) $(LFLAGS) $(XLFLAGS) $(OBJS) $(LOUTCMD)
395 -else
397 -compile: $(OPATH) $(SRCS) $(HEADERS)
398 - $(CC) $(CFLAGS) $(XCFLAGS) $(SRCS) $(OUTCMD)
399 -link: compile
400 - @echo "Link performed along with compile"
402 -endif
404 -$(OUTFILE): $(SRCS) $(HEADERS) Makefile core_portme.mak $(FORCE_REBUILD)
405 - $(MAKE) port_prebuild
406 - $(MAKE) link
407 - $(MAKE) port_postbuild
409 -.PHONY: rerun
410 -rerun:
411 - $(MAKE) XCFLAGS="$(XCFLAGS) -DPERFORMANCE_RUN=1" load run1.log
412 - $(MAKE) XCFLAGS="$(XCFLAGS) -DVALIDATION_RUN=1" load run2.log
414 -PARAM1=$(PORT_PARAMS) 0x0 0x0 0x66 $(ITERATIONS)
415 -PARAM2=$(PORT_PARAMS) 0x3415 0x3415 0x66 $(ITERATIONS)
416 -PARAM3=$(PORT_PARAMS) 8 8 8 $(ITERATIONS)
418 -run1.log-PARAM=$(PARAM1) 7 1 2000
419 -run2.log-PARAM=$(PARAM2) 7 1 2000
420 -run3.log-PARAM=$(PARAM3) 7 1 1200
422 -run1.log run2.log run3.log: load
423 - $(MAKE) port_prerun
424 - $(RUN) $(OUTFILE) $($(@)-PARAM) > $(OPATH)$@
425 - $(MAKE) port_postrun
427 -.PHONY: gen_pgo_data
428 -gen_pgo_data: run3.log
430 -.PHONY: load
431 -load: $(OUTFILE)
432 - $(MAKE) port_preload
433 - $(LOAD) $(OUTFILE)
434 - $(MAKE) port_postload
436 -.PHONY: clean
437 clean:
438 - rm -f $(OUTFILE) $(OPATH)*.log *.info $(OPATH)index.html $(PORT_CLEAN)
439 + rm -f *.ihx *.lnk *.lst *.noi *.rel *.sym *.size *.dot *.lk *.rst *.asm
441 +%.rel: %.c
442 + $(SDCC) -c --std-c99 --fverbose-asm $(SDCCFLAGS) --fverbose-asm $< ||:
444 -.PHONY: force_rebuild
445 -force_rebuild:
446 - echo "Forcing Rebuild"
448 -.PHONY: check
449 -check:
450 - md5sum -c coremark.md5
451 +coremark: $(OBJ)
452 + $(SDCC) $(SDCCFLAGS) *.rel -o Coremark.ihx
454 -ifdef ETC
455 -# Targets related to testing and releasing CoreMark. Not part of the general release!
456 -include Makefile.internal
457 -endif