• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:  LOG MEMORY SECTION MODULE.
15  * Author:
16  * Create:  2018-10-15
17  */
18 
19 #include "log_memory_section.h"
20 
21 /*
22  * Public function definitions
23  */
log_memory_section_get(log_memory_region_section_t section,log_memory_section_params_t * section_data)24 void log_memory_section_get(log_memory_region_section_t section, log_memory_section_params_t *section_data)
25 {
26     const log_memory_region_control_t *log_region_control =
27         (const log_memory_region_control_t *)(uintptr_t)LOG_MEMORY_REGION_CONTROL_BLOCK_POINTER;
28     section_data->start = (uint8_t *)(uintptr_t)(LOGGING_REGION_START + log_region_control->offset[section]);
29 #if CORE_NUMS > 1
30     // section_data has been previously initialized by the security core.
31     if (section == LOG_MEMORY_REGION_MAX_NUMBER - 1) {  // If it is the last section use the length in stead
32         section_data->length = log_region_control->length - log_region_control->offset[section];
33     } else {
34         section_data->length = log_region_control->offset[(uint8_t)section + 1] -
35                                log_region_control->offset[(uint8_t)section];
36     }
37 #else
38     if (section == LOG_MEMORY_REGION_MAX_NUMBER - 1) {  // If it is the last section use the length in stead
39         section_data->length = log_region_control->length - log_region_control->offset[section];
40     }
41 #endif
42 }
43 
log_memory_section_get_control(log_memory_region_section_t section)44 log_memory_section_control_t *log_memory_section_get_control(log_memory_region_section_t section)
45 {
46     log_memory_region_control_t *log_region_control =
47         (log_memory_region_control_t *)LOG_MEMORY_REGION_CONTROL_BLOCK_POINTER;
48     return &log_region_control->section_control[section];
49 }
50