1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * Description: calculate mips. 15 * 16 * Create: 2018-10-15 17 */ 18 #include "hal_mips.h" 19 #include "stdlib.h" 20 21 hal_exception_dump_mips_callback g_exception_mips_start_callback = NULL; 22 hal_exception_dump_mips_callback g_exception_mips_stop_callback = NULL; 23 24 /* register mips callback function */ hal_register_mips_start_callback(hal_exception_dump_mips_callback callback)25void hal_register_mips_start_callback(hal_exception_dump_mips_callback callback) 26 { 27 if (callback != NULL) { 28 g_exception_mips_start_callback = callback; 29 } 30 } 31 32 /* register mips callback function */ hal_register_mips_stop_callback(hal_exception_dump_mips_callback callback)33void hal_register_mips_stop_callback(hal_exception_dump_mips_callback callback) 34 { 35 if (callback != NULL) { 36 g_exception_mips_stop_callback = callback; 37 } 38 } 39 40 /* start calculating ticks */ hal_calculate_mips_start(void)41void hal_calculate_mips_start(void) 42 { 43 if (g_exception_mips_start_callback != NULL) { 44 g_exception_mips_start_callback(); 45 } 46 } 47 48 /* stop calculating ticks */ hal_calculate_mips_stop(void)49void hal_calculate_mips_stop(void) 50 { 51 if (g_exception_mips_stop_callback != NULL) { 52 g_exception_mips_stop_callback(); 53 } 54 } 55