Goodix
GR551x API Reference  V1_6_06_B5676
gr55xx_fpb.h
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  *
4  * @file gr55xx_fpb.h
5  *
6  ******************************************************************************
7  * @attention
8  #####Copyright (c) 2019 GOODIX
9  All rights reserved.
10 
11  Redistribution and use in source and binary forms, with or without
12  modification, are permitted provided that the following conditions are met:
13  * Redistributions of source code must retain the above copyright
14  notice, this list of conditions and the following disclaimer.
15  * Redistributions in binary form must reproduce the above copyright
16  notice, this list of conditions and the following disclaimer in the
17  documentation and/or other materials provided with the distribution.
18  * Neither the name of GOODIX nor the names of its contributors may be used
19  to endorse or promote products derived from this software without
20  specific prior written permission.
21 
22  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
26  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  POSSIBILITY OF SUCH DAMAGE.
33  *****************************************************************************************
34  */
35 
36  /**
37  * @addtogroup SYSTEM
38  * @{
39  */
40 
41 /**
42  * @addtogroup FPB
43  * @{
44  * @brief Definitions and prototypes for FPB interface.
45  */
46 
47 #ifndef __GR55XX_FPB_H_
48 #define __GR55XX_FPB_H_
49 
50 #include <stdint.h>
51 #include <stdio.h>
52 #include <stdbool.h>
53 
54 /**
55  *@addtogroup GR55XX_FPB_ENUMERATIONS Enumerations
56  * @{
57  */
58 /**@brief FPB mode. */
59 typedef enum
60 {
61  FPB_MODE_PATCH_ONLY = 0, /**< FPB MODE ENABLE FOR PATCH ONLY*/
62  FPB_MODE_DEBUG_ONLY, /**< FPB MODE ENABLE FOR DEBUG ONLY*/
63  FPB_MODE_PATCH_AND_DEBUG, /**< FPB MODE ENABLE FOR PATCH AND DEBUG*/
64 } fpb_mode_t ;
65 
66 /**@brief FPB register. */
67 typedef struct
68 {
69  volatile uint32_t CTRL; /**< Offset: 0x000 (R/W) Data */
70  volatile uint32_t REMAP; /**< Offset: 0x004 (R/W) Data */
71  volatile uint32_t COMP[8]; /**< Offset: 0x008 (R) Data */
73 /** @} */
74 
75 /** @addtogroup GR55XX_FPB_DEFINES Defines
76  * @{
77  */
78 #define FPB ((FPB_REG_TypeDef *) 0xE0002000UL) /**< FPB Register Address. */
79 /** @} */
80 
81 
82 /**
83  * @defgroup GR55XX_FPB_TYPEDEF Typedefs
84  * @{
85  */
86 /**@brief FPB function.*/
87 typedef void(*fun_t)(void);
88 /** @} */
89 
90 /**
91  * @defgroup GR55XX_FPB_FUNCTION Functions
92  * @{
93  */
94  /**
95  ****************************************************************************************
96  * @brief Enabling patch function
97  * @param[in] index_start : Start Index Number
98  * @param[in] index_end : End Index Number
99  * @retval : void
100  ****************************************************************************************
101  */
102 void fpb_enable(uint8_t index_start ,uint8_t index_end);
103 
104 /**
105  ****************************************************************************************
106  * @brief Replace old and new functions
107  * @param[in] ori_func : primitive function address
108  * @param[in] rep_func : replacement function address
109  * @param[in] patch_table_num : group number
110  * @retval : void
111  ****************************************************************************************
112  */
113 int fun_replace_by_svc(uint32_t ori_func, uint32_t rep_func, uint8_t patch_table_num);
114 
115  /**
116  ****************************************************************************************
117  * @brief SVC handler process function
118  * @retval : void
119  ****************************************************************************************
120  */
121 uint32_t SVC_handler_proc(uint32_t *svc_args);
122 
123  /**
124  ****************************************************************************************
125  * @brief Register FPB patch enable function
126  * @param[in] patch_enable_func : pointer of function
127  * @retval : void
128  ****************************************************************************************
129  */
130 void fpb_register_patch_init_func(fun_t patch_enable_func);
131 
132  /**
133  ****************************************************************************************
134  * @brief FPB init function
135  * @param[in] fpb_mode : the mode of FPB
136  * @retval : void
137  ****************************************************************************************
138  */
139 void fpb_init(fpb_mode_t fpb_mode);
140 
141  /**
142  ****************************************************************************************
143  * @brief svc sub-function register
144  * @param[in] svc_num : the number of svc
145  * @param[in] func : sub-function callback
146  * @retval : void
147  ****************************************************************************************
148  */
149 void svc_func_register(uint8_t svc_num, uint32_t func);
150 
151  /**
152  ****************************************************************************************
153  * @brief register sve table function
154  * @param[in] p_svc_table : the pointer of sve table
155  * @retval : void
156  ****************************************************************************************
157  */
158 void svc_table_register(uint32_t *p_svc_table);
159 /** @} */
160 #endif
161 /** @} */
162 /** @} */
163 
fun_t
void(* fun_t)(void)
FPB function.
Definition: gr55xx_fpb.h:87
fpb_init
void fpb_init(fpb_mode_t fpb_mode)
FPB init function.
FPB_REG_TypeDef::REMAP
volatile uint32_t REMAP
Offset: 0x004 (R/W) Data.
Definition: gr55xx_fpb.h:70
fun_replace_by_svc
int fun_replace_by_svc(uint32_t ori_func, uint32_t rep_func, uint8_t patch_table_num)
Replace old and new functions.
FPB_REG_TypeDef::CTRL
volatile uint32_t CTRL
Offset: 0x000 (R/W) Data.
Definition: gr55xx_fpb.h:69
FPB_REG_TypeDef
FPB register.
Definition: gr55xx_fpb.h:68
FPB_MODE_PATCH_ONLY
@ FPB_MODE_PATCH_ONLY
FPB MODE ENABLE FOR PATCH ONLY.
Definition: gr55xx_fpb.h:61
FPB_MODE_DEBUG_ONLY
@ FPB_MODE_DEBUG_ONLY
FPB MODE ENABLE FOR DEBUG ONLY.
Definition: gr55xx_fpb.h:62
FPB_MODE_PATCH_AND_DEBUG
@ FPB_MODE_PATCH_AND_DEBUG
FPB MODE ENABLE FOR PATCH AND DEBUG.
Definition: gr55xx_fpb.h:63
svc_table_register
void svc_table_register(uint32_t *p_svc_table)
register sve table function
fpb_enable
void fpb_enable(uint8_t index_start, uint8_t index_end)
Enabling patch function.
fpb_register_patch_init_func
void fpb_register_patch_init_func(fun_t patch_enable_func)
Register FPB patch enable function.
svc_func_register
void svc_func_register(uint8_t svc_num, uint32_t func)
svc sub-function register
fpb_mode_t
fpb_mode_t
FPB mode.
Definition: gr55xx_fpb.h:60
SVC_handler_proc
uint32_t SVC_handler_proc(uint32_t *svc_args)
SVC handler process function.