alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2021 Arm Limited. All rights reserved. |
| 3 | * SPDX-License-Identifier: Apache-2.0 |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | #include "timer_fvp.h" |
| 18 | |
| 19 | #include "irqs.h" |
| 20 | #include "bsp_core_log.h" |
| 21 | |
| 22 | fvp_time_counter get_time_counter(void) |
| 23 | { |
| 24 | fvp_time_counter t = { |
| 25 | .counter_systick = Get_SysTick_Cycle_Count() |
| 26 | }; |
| 27 | debug("counter_systick: %llu\n", t.counter_systick); |
| 28 | return t; |
| 29 | } |
| 30 | |
| 31 | void timer_reset(void) |
| 32 | { |
| 33 | if (0 != Init_SysTick()) { |
| 34 | printf_err("Failed to initialise system tick config\n"); |
| 35 | } |
| 36 | debug("system tick config ready\n"); |
| 37 | } |
| 38 | |
| 39 | uint64_t get_cycle_count_diff(fvp_time_counter *start, |
| 40 | fvp_time_counter *end) |
| 41 | { |
| 42 | if (start->counter_systick > end->counter_systick) { |
| 43 | warn("start > end; counter might have overflown\n"); |
| 44 | } |
| 45 | return end->counter_systick - start->counter_systick; |
| 46 | } |
| 47 | |
| 48 | void start_cycle_counter(void) |
| 49 | { |
| 50 | /* Add any custom requirement for this platform here */ |
| 51 | } |
| 52 | |
| 53 | void stop_cycle_counter(void) |
| 54 | { |
| 55 | /* Add any custom requirement for this platform here */ |
| 56 | } |