]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/pdk.git/blob - packages/ti/drv/mmcsd/test/src/profiling.h
sd-mmc: add to PDK
[processor-sdk/pdk.git] / packages / ti / drv / mmcsd / test / src / profiling.h
1 /**
2  *  \file   MMCSD_log.h
3  *
4  *  \brief  This file contains the prototypes for the log print functions. By
5             default the prints will be directed to serial console using UART.
6  *
7  */
9 /*
10  * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  *
16  * Redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer.
18  *
19  * Redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in the
21  * documentation and/or other materials provided with the
22  * distribution.
23  *
24  * Neither the name of Texas Instruments Incorporated nor the names of
25  * its contributors may be used to endorse or promote products derived
26  * from this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  *
40  */
42 #ifndef _PROFILING_H
43 #define _PROFILING_H
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
49 #include <stdio.h>
51 #ifndef BARE_METAL
52 #include <xdc/std.h>
53 #include <xdc/runtime/System.h>
54 #endif
57 #include "MMCSD_log.h"
59 typedef struct {
60    char name[64];
61    uint32_t start_tick;
62    uint32_t end_tick;
63    uint32_t total_ticks;
64    uint32_t total_ticks_master;
65    uint32_t num_iterations;
66    uint32_t total_bytes_transferred;
67    
68    float total_time_ms;
69    float total_time_percentage;/* w.r.t master */
70    float time_per_iter_ms;
71    float bandwidth_mbytes_per_sec;
73 } profilePoint_t;
76 typedef enum {
77           PROFILE_MMCSD_WRITE=0,
78           PROFILE_MMCSD_READ=1,
79           PROFILE_MMCSD_WRITE_CMD_WAIT=2,
80           PROFILE_MMCSD_WRITE_DATA_WAIT=3,
81           PROFILE_MMCSD_WRITE_DATA_TRANSFER_SUBMIT=4,
82           PROFILE_MMCSD_WRITE_DATA_TRANSFER_COMPLETE=5,
83           PROFILE_MMCSD_READ_CMD_WAIT=6,
84           PROFILE_MMCSD_READ_DATA_WAIT=7,
85           PROFILE_MMCSD_READ_DATA_TRANSFER_SUBMIT=8,
86           PROFILE_MMCSD_READ_DATA_TRANSFER_COMPLETE=9,
87 } profile_ProfilePoint_e;
89 #define PROFILE_MAX_POINTS 10
90 typedef struct {
91    uint32_t ticks_per_ms;
92    profilePoint_t profile_Points[PROFILE_MAX_POINTS];
93 } profile_Context_t;
96 typedef struct {
97         float bandwidth_mbytes_per_sec;
98         uint64_t num_bytes_transferred;
99 } mmcsdTestBenchmarkMeasurements_t;
101 typedef struct {
102         bool valid;
103         mmcsdTestBenchmarkMeasurements_t read;
104         mmcsdTestBenchmarkMeasurements_t write;
105 } mmcsdTestBenchmarkElem_t;
108 #define MMCSD_TEST_MAX_NUM_BENCHMARKS (5U) /* 0.25 MB, 0.5 MB, 1 MB , 2MB, 5 MB*/
110 typedef struct {
111         mmcsdTestBenchmarkElem_t RAW_measurements[MMCSD_TEST_MAX_NUM_BENCHMARKS];
112         mmcsdTestBenchmarkElem_t FATFS_measurements[MMCSD_TEST_MAX_NUM_BENCHMARKS];
113 } mmcsdTestBenchmarks_t;
115 void profile_initPerfCounters();
116 void profile_calibrate();
117 void profile_start_point(uint32_t profile_id);
118 void profile_end_point(uint32_t profile_id);
119 void profile_calculate_time(uint32_t profile_id);
120 void profile_calculate_all_time();
121 void profile_display_all();
122 void profile_reset_results();
123 void profile_calculate_results(uint32_t total_bytes_transferred);
124 void profile_display_results(uint32_t total_bytes_transferred);
125 void profile_init();
126 void mmcsd_display_benchmarks(mmcsdTestBenchmarks_t *benchmarks_ptr);
127 void mmcsd_reset_benchmarks(mmcsdTestBenchmarkElem_t *benchmark_elem_ptr);
128 void mmcsd_store_benchmarks(mmcsdTestBenchmarkElem_t *benchmark_elem_ptr,uint32_t bytes_transferred);
129 extern profile_Context_t profile_Context;
131 #ifdef __cplusplus
133 #endif
135 #endif /* _PROFILING_H */