ZedBoard用Coremarkのソースで、ZedBoard用に書き換えたファイルのみ公開す。 具体的には、移植用のディレクトリ core_portme.c と core_portme.h だ。これらは、coremark_v1.0/linux をコピーして、coremark_v1.0/zynq として編集している。
具体的に変更したのは、本当にタイマーの部分だけだ。タイマー読み込み、書き込み、そして時間計算のための定数を変更しているだけなので、 オリジナルのソースと比較しても簡単に意味が分かると思う。ついでだが、オリジナルとの差分は以下だ。
- core_portme.c
15,36d14
< #define TIMER_DEVICE_ID XPAR_XSCUTIMER_0_DEVICE_ID
< #define TIMER_LOAD_VALUE 0xFFFFFFE
< #define START_COUNTER 0
< #define STOP_COUNTER 1
<
< #define NSECS_PER_SEC 667000000/2
< #define CORETIMETYPE ee_u32
< #define TIMER_RES_DIVIDER 40
< #define EE_TICKS_PER_SEC (NSECS_PER_SEC / TIMER_RES_DIVIDER)
<
< typedef ee_u32 CORE_TICKS;
<
< #include "xil_printf.h"
< #include "xscutimer.h"
< #include "xscugic.h"
< #include "xparameters.h"
<
< ee_u32 GetTimerValue(ee_u32 TimerIntrId, ee_u16 Mode);
< static XScuTimer Timer;//timer
<
<
<
60d37
<
113,114c90
< // #define CORETIMETYPE struct timespec
< #define CORETIMETYPE ee_u32
---
> #define CORETIMETYPE struct timespec
123,126c99
< // #define CORETIMETYPE ee_u32
< // #define GETMYTIME(_t) clock_gettime(CLOCK_REALTIME,_t)
< #define SAMPLE_TIME_IMPLEMENTATION 1
< // #define SAMPLE_TIME_IMPLEMENTATION 0
---
> #define SAMPLE_TIME_IMPLEMENTATION 0
141,143c114
< // GETMYTIME(&start_time_val );
< start_time_val = GetTimerValue (TIMER_DEVICE_ID, START_COUNTER);
<
---
> GETMYTIME(&start_time_val );
164,165c135
< // GETMYTIME(&stop_time_val );
< stop_time_val = GetTimerValue (TIMER_DEVICE_ID, STOP_COUNTER);
---
> GETMYTIME(&stop_time_val );
177,178c147
< // CORE_TICKS elapsed=(CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
< CORE_TICKS elapsed = start_time_val - stop_time_val;
---
> CORE_TICKS elapsed=(CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
359,394d327
<
<
< ee_u32 GetTimerValue(ee_u32 TimerIntrId,ee_u16 Mode)
<
< {
<
< int Status;
< XScuTimer_Config *ConfigPtr;
< volatile ee_u32 CntValue = 0;
< XScuTimer *TimerInstancePtr = &Timer;
<
< if (Mode == 0) {
< // Initialize the Private Timer so that it is ready to use
< ConfigPtr = XScuTimer_LookupConfig(TimerIntrId);
< Status = XScuTimer_CfgInitialize (TimerInstancePtr, ConfigPtr,
< ConfigPtr->BaseAddr);
< if (Status != XST_SUCCESS) {
< print ("XST_FAILURE\n");
< return XST_FAILURE;
< }
<
< // Load the timer prescaler register.
< XScuTimer_SetPrescaler (TimerInstancePtr, TIMER_RES_DIVIDER);
< // Load the timer counter register.
< XScuTimer_LoadTimer (TimerInstancePtr, TIMER_LOAD_VALUE);
< // Start the timer counter and read start value
< XScuTimer_Start(TimerInstancePtr);
< CntValue = XScuTimer_GetCounterValue (TimerInstancePtr);
< } else {
< // Read stop value and stop the timer counter
< CntValue = XScuTimer_GetCounterValue (TimerInstancePtr);
< XScuTimer_Stop(TimerInstancePtr);
< }
<
< return CntValue;
< }
- core_portme.h
10,12d9 < < #include <stdio.h> < 29c26 < #define HAS_TIME_H 0 --- > #define HAS_TIME_H 1 61c58 < // #error "Please define type of CORE_TICKS and implement start_time, end_time get_time and time_in_secs functions!" --- > #error "Please define type of CORE_TICKS and implement start_time, end_time get_time and time_in_secs functions!" 96,97d92 < typedef ee_u32 CORE_TICKS; < 111,115c106,108 < #define SEED_METHOD SEED_VOLATILE < < // #ifndef SEED_METHOD < // #define SEED_METHOD SEED_ARG < // #endif --- > #ifndef SEED_METHOD > #define SEED_METHOD SEED_ARG > #endif 125,128c118,120 < #define MEM_METHOD MEM_STACK < // #ifndef MEM_METHOD < // #define MEM_METHOD MEM_MALLOC < // #endif --- > #ifndef MEM_METHOD > #define MEM_METHOD MEM_MALLOC > #endif 201,203c193,195 < // #ifndef MAIN_HAS_NOARGC < // #define MAIN_HAS_NOARGC 0 < // #endif --- > #ifndef MAIN_HAS_NOARGC > #define MAIN_HAS_NOARGC 0 > #endif