SAMV71 Xplained Ultra Software Package 1.3

core_portme.c

00001 /* 
00002     File : core_portme.c
00003 */
00004 /*
00005     Author : Shay Gal-On, EEMBC
00006     Legal : TODO!
00007 */ 
00008 #include "coremark.h"
00009 #include "core_portme.h"
00010 
00011 #if VALIDATION_RUN
00012     volatile ee_s32 seed1_volatile=0x3415;
00013     volatile ee_s32 seed2_volatile=0x3415;
00014     volatile ee_s32 seed3_volatile=0x66;
00015 #endif
00016 #if PERFORMANCE_RUN
00017     volatile ee_s32 seed1_volatile=0x0;
00018     volatile ee_s32 seed2_volatile=0x0;
00019     volatile ee_s32 seed3_volatile=0x66;
00020 #endif
00021 #if PROFILE_RUN
00022     volatile ee_s32 seed1_volatile=0x8;
00023     volatile ee_s32 seed2_volatile=0x8;
00024     volatile ee_s32 seed3_volatile=0x8;
00025 #endif
00026     volatile ee_s32 seed4_volatile=ITERATIONS;
00027     volatile ee_s32 seed5_volatile=0;
00028 /* Porting : Timing functions
00029     How to capture time and convert to seconds must be ported to whatever is supported by the platform.
00030     e.g. Read value from on board RTC, read value from cpu clock cycles performance counter etc. 
00031     Sample implementation for standard time.h and windows.h definitions included.
00032 */
00033 CORETIMETYPE barebones_clock() {
00034     #error "You must implement a method to measure time in barebones_clock()! This function should return current time.\n"
00035 }
00036 /* Define : TIMER_RES_DIVIDER
00037     Divider to trade off timer resolution and total time that can be measured.
00038 
00039     Use lower values to increase resolution, but make sure that overflow does not occur.
00040     If there are issues with the return value overflowing, increase this value.
00041     */
00042 #define GETMYTIME(_t) (*_t=barebones_clock())
00043 #define MYTIMEDIFF(fin,ini) ((fin)-(ini))
00044 #define TIMER_RES_DIVIDER 1
00045 #define SAMPLE_TIME_IMPLEMENTATION 1
00046 #define EE_TICKS_PER_SEC (CLOCKS_PER_SEC / TIMER_RES_DIVIDER)
00047 
00048 /** Define Host specific (POSIX), or target specific global time variables. */
00049 static CORETIMETYPE start_time_val, stop_time_val;
00050 
00051 /* Function : start_time
00052     This function will be called right before starting the timed portion of the benchmark.
00053 
00054     Implementation may be capturing a system timer (as implemented in the example code) 
00055     or zeroing some system parameters - e.g. setting the cpu clocks cycles to 0.
00056 */
00057 void start_time(void) {
00058     GETMYTIME(&start_time_val );      
00059 }
00060 /* Function : stop_time
00061     This function will be called right after ending the timed portion of the benchmark.
00062 
00063     Implementation may be capturing a system timer (as implemented in the example code) 
00064     or other system parameters - e.g. reading the current value of cpu cycles counter.
00065 */
00066 void stop_time(void) {
00067     GETMYTIME(&stop_time_val );      
00068 }
00069 /* Function : get_time
00070     Return an abstract "ticks" number that signifies time on the system.
00071     
00072     Actual value returned may be cpu cycles, milliseconds or any other value,
00073     as long as it can be converted to seconds by <time_in_secs>.
00074     This methodology is taken to accomodate any hardware or simulated platform.
00075     The sample implementation returns millisecs by default, 
00076     and the resolution is controlled by <TIMER_RES_DIVIDER>
00077 */
00078 CORE_TICKS get_time(void) {
00079     CORE_TICKS elapsed=(CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
00080     return elapsed;
00081 }
00082 /* Function : time_in_secs
00083     Convert the value returned by get_time to seconds.
00084 
00085     The <secs_ret> type is used to accomodate systems with no support for floating point.
00086     Default implementation implemented by the EE_TICKS_PER_SEC macro above.
00087 */
00088 secs_ret time_in_secs(CORE_TICKS ticks) {
00089     secs_ret retval=((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
00090     return retval;
00091 }
00092 
00093 ee_u32 default_num_contexts=1;
00094 
00095 /* Function : portable_init
00096     Target specific initialization code 
00097     Test for some common mistakes.
00098 */
00099 void portable_init(core_portable *p, int *argc, char *argv[])
00100 {
00101     #error "Call board initialization routines in portable init (if needed), in particular initialize UART!\n"
00102     if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
00103         ee_printf("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n");
00104     }
00105     if (sizeof(ee_u32) != 4) {
00106         ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
00107     }
00108     p->portable_id=1;
00109 }
00110 /* Function : portable_fini
00111     Target specific final code 
00112 */
00113 void portable_fini(core_portable *p)
00114 {
00115     p->portable_id=0;
00116 }
00117 
00118 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines