• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __PATCH_TAB_H_
2 #define __PATCH_TAB_H_
3 
4 // WEAK Functions for platform init & code size optimization
ble_con_env_init(void)5 __WEAK void  ble_con_env_init(void) {};
ble_adv_env_init(void)6 __WEAK void  ble_adv_env_init(void) {};
ble_per_adv_env_init(void)7 __WEAK void  ble_per_adv_env_init(void) {};
ble_scan_env_init(void)8 __WEAK void  ble_scan_env_init(void) {};
ble_sync_env_init(void)9 __WEAK void  ble_sync_env_init(void) {};
10 
11 typedef int (*ke_msg_func_t)(uint16_t const msgid, uint16_t const *param,
12                              uint16_t const dest_id, uint16_t const src_id);
13 
14 typedef int (*llm_hci_cmd_hdl_func_t)(uint16_t const *param, uint16_t opcode);
15 
16 typedef struct {
17     ke_msg_func_t ori_func_addr;
18     ke_msg_func_t new_func_addr;
19 } msg_tab_item_t;
20 
21 typedef struct {
22     llm_hci_cmd_hdl_func_t ori_func_addr;
23     llm_hci_cmd_hdl_func_t new_func_addr;
24 } hci_cmd_tab_item_t;
25 
26 // ble sdk task
27 extern int host_to_sdk_msg_handler_patch(uint16_t const msgid, uint16_t *param,
28                                          uint16_t const dest_id, uint16_t const src_id);
29 // ble sdk gapm for common
30 extern int gap_activity_stopped_ind_handler_patch(uint16_t const msgid, uint16_t const *p_param,
31                                                   uint16_t const dest_id, uint16_t const src_id);
32 extern int gapm_cmp_evt_handler_patch(uint16_t const msgid, uint16_t const *param,
33                                       uint16_t const dest_id, uint16_t const src_id);
34 extern int gap_dev_bdaddr_ind_handler_patch(uint16_t const msgid, uint16_t const *param,
35                                             uint16_t const dest_id, uint16_t const src_id);
36 // llm task for common
37 extern int llm_hci_command_handler_patch(uint16_t const msgid, uint16_t const *param,
38                                          uint16_t const dest_id, uint16_t const src_id);
39 // hci cmd for common
40 extern int hci_le_add_dev_to_wlst_cmd_handler_patch(uint16_t const *param, uint16_t opcode);
41 extern int hci_le_rmv_dev_from_wlst_cmd_handler_patch(uint16_t const *param, uint16_t opcode);
42 extern int hci_le_clear_wlst_cmd_handler_patch(uint16_t const *param, uint16_t opcode);
43 
44 extern int hci_dbg_ble_reg_wr_cmd_handler_patch(uint16_t const *param, uint16_t opcode);
45 extern int hci_dbg_ble_reg_rd_cmd_handler_patch(uint16_t const *param, uint16_t opcode);
46 
47 #if CFG_MAX_CONNECTIONS
48 // gattc task
49 extern int l2cc_pdu_recv_ind_handler_patch(uint16_t const msgid, struct l2cc_pdu_recv_ind *param,
50                                            uint16_t const dest_id, uint16_t const src_id);
51 // llc task
52 extern int llc_loc_llcp_rsp_to_handler_patch(uint16_t const msgid, uint16_t const *param,
53                                              uint16_t const dest_id, uint16_t const src_id);
54 extern int llc_rem_llcp_rsp_to_handler_patch(uint16_t const msgid, uint16_t const *param,
55                                              uint16_t const dest_id, uint16_t const src_id);
56 extern int lld_acl_rx_ind_handler_patch(uint16_t const msgid, uint16_t const *param,
57                                         uint16_t const dest_id, uint16_t const src_id);
58 extern int lld_con_offset_upd_ind_handler_patch(uint16_t const msgid, uint16_t const *param,
59                                                 uint16_t const dest_id, uint16_t const src_id);
60 extern int lld_con_param_upd_cfm_handler_patch(uint16_t const msgid, uint16_t const *param,
61                                                uint16_t const dest_id, uint16_t const src_id);
62 extern int lld_llcp_rx_ind_handler_patch(uint16_t const msgid, uint16_t const *param,
63                                          uint16_t const dest_id, uint16_t const src_id);
64 extern int lld_llcp_tx_cfm_handler_patch(uint16_t const msgid, uint16_t const *param,
65                                          uint16_t const dest_id, uint16_t const src_id);
66 extern int lld_ch_map_upd_cfm_handler_patch(uint16_t const msgid, uint16_t const *param,
67                                             uint16_t const dest_id, uint16_t const src_id);
68 extern int lld_phy_upd_cfm_handler_patch(uint16_t const msgid, uint16_t const *param,
69                                          uint16_t const dest_id, uint16_t const src_id);
70 extern int llc_auth_payl_nearly_to_handler_patch(uint16_t const msgid, uint16_t const *param,
71                                                  uint16_t const dest_id, uint16_t const src_id);
72 extern int llc_auth_payl_real_to_handler_patch(uint16_t const msgid, uint16_t const *param,
73                                                uint16_t const dest_id, uint16_t const src_id);
74 // l2cc task
75 extern int hci_nb_cmp_pkts_evt_handler_patch(uint16_t const msgid, struct hci_nb_cmp_pkts_evt const *event,
76                                              uint16_t const dest_id, uint16_t const src_id);
77 // gapc task
78 extern int gapc_hci_handler_patch(uint16_t const msgid, uint16_t const *event,
79                                   uint16_t dest_id, uint16_t src_id);
80 // ble sdk task for gapc
81 extern int gap_connection_req_ind_handler_patch(uint16_t const msgid, struct gapc_connection_req_ind const *param,
82                                                 uint16_t const dest_id, uint16_t const src_id);
83 extern int gap_disconnect_ind_handler_patch(uint16_t const msgid, struct gapc_disconnect_ind const *param,
84                                             uint16_t const dest_id, uint16_t const src_id);
85 extern int gap_cmp_evt_handler_patch(uint16_t const msgid, struct gapc_cmp_evt const *param,
86                                      uint16_t const dest_id, uint16_t const src_id);
87 extern int sec_rcv_sec_req_ind_handler_patch(uint16_t const msgid, struct gapc_security_ind const *param,
88                                              uint16_t const dest_id, uint16_t const src_id);
89 extern int sec_rcv_encrypt_req_ind_handler_patch(uint16_t const msgid, struct gapc_encrypt_req_ind const *param,
90                                                  uint16_t const dest_id, uint16_t const src_id);
91 // ble sdk task for gatt
92 extern int ble_sdk_gatts_svc_changed_cfg_ind_handler_patch(uint16_t const msgid,
93                                                            struct gattc_svc_changed_cfg const *param,
94                                                            uint16_t const dest_id, uint16_t const src_id);
95 extern int ble_sdk_gattc_event_ind_handler_patch(uint16_t const msgid, struct gattc_event_ind const *param,
96                                                  uint16_t const dest_id, uint16_t const src_id);
97 #endif
98 
99 #if CFG_MAX_SCAN
100 // gapm task for scan
101 extern int gapm_activity_create_cmd_handler_patch(uint16_t const msgid, struct gapm_activity_create_cmd const *param,
102                                                   uint16_t const dest_id, uint16_t const src_id);
103 extern int gapm_hci_handler_patch(uint16_t const msgid, uint16_t const *event,
104                                   uint16_t dest_id, uint16_t opcode);
105 
106 // hci cmd for scan
107 extern int hci_le_ext_create_con_cmd_handler_patch(struct hci_le_ext_create_con_cmd *param, uint16_t opcode);
108 extern int hci_le_set_ext_scan_param_cmd_handler_patch(struct hci_le_set_ext_scan_param_cmd const *param,
109                                                        uint16_t opcode);
110 extern int hci_le_set_ext_scan_en_cmd_handler_patch(struct hci_le_set_ext_scan_en_cmd const *param, uint16_t opcode);
111 #endif
112 
113 msg_tab_item_t msg_tab[] = {
114     // ble sdk gapm for common
115     {(ke_msg_func_t)0x00074235, (ke_msg_func_t)gapm_cmp_evt_handler_patch},
116     {(ke_msg_func_t)0x000709e1, (ke_msg_func_t)gap_activity_stopped_ind_handler_patch},
117     {(ke_msg_func_t)0x00071f6d, (ke_msg_func_t)gap_dev_bdaddr_ind_handler_patch},
118     // llm task for common
119     {(ke_msg_func_t)0x00051d09, (ke_msg_func_t)llm_hci_command_handler_patch},
120     // ble sdk task for common
121     {(ke_msg_func_t)0x000761a9, (ke_msg_func_t)host_to_sdk_msg_handler_patch},
122 
123 #if CFG_MAX_CONNECTIONS
124     // gattc task for conn
125     {(ke_msg_func_t)0x00032e7d, (ke_msg_func_t)l2cc_pdu_recv_ind_handler_patch},
126     // llc task for conn
127     {(ke_msg_func_t)0x000391b5, (ke_msg_func_t)llc_loc_llcp_rsp_to_handler_patch},
128     {(ke_msg_func_t)0x0003a795, (ke_msg_func_t)llc_rem_llcp_rsp_to_handler_patch},
129     {(ke_msg_func_t)0x00049a6d, (ke_msg_func_t)lld_llcp_rx_ind_handler_patch},
130     {(ke_msg_func_t)0x00049c95, (ke_msg_func_t)lld_llcp_tx_cfm_handler_patch},
131     {(ke_msg_func_t)0x0003aed9, (ke_msg_func_t)lld_acl_rx_ind_handler_patch},
132     {(ke_msg_func_t)0x00045e6d, (ke_msg_func_t)lld_con_param_upd_cfm_handler_patch},
133     {(ke_msg_func_t)0x000418c9, (ke_msg_func_t)lld_ch_map_upd_cfm_handler_patch},
134     {(ke_msg_func_t)0x0004b67d, (ke_msg_func_t)lld_phy_upd_cfm_handler_patch},
135     {(ke_msg_func_t)0x00045da1, (ke_msg_func_t)lld_con_offset_upd_ind_handler_patch},
136     {(ke_msg_func_t)0x0003679d, (ke_msg_func_t)llc_auth_payl_nearly_to_handler_patch},
137     {(ke_msg_func_t)0x00036801, (ke_msg_func_t)llc_auth_payl_real_to_handler_patch},
138     // l2cc task for conn
139     {(ke_msg_func_t)0x0002b281, (ke_msg_func_t)hci_nb_cmp_pkts_evt_handler_patch},
140     // gapc task for conn
141     {(ke_msg_func_t)0x0000f751, (ke_msg_func_t)gapc_hci_handler_patch},
142     // ble sdk gapc for conn
143     {(ke_msg_func_t)0x00071781, (ke_msg_func_t)gap_connection_req_ind_handler_patch},
144     {(ke_msg_func_t)0x00072229, (ke_msg_func_t)gap_disconnect_ind_handler_patch},
145     {(ke_msg_func_t)0x0007ac89, (ke_msg_func_t)sec_rcv_sec_req_ind_handler_patch},
146     {(ke_msg_func_t)0x00071519, (ke_msg_func_t)gap_cmp_evt_handler_patch},
147     {(ke_msg_func_t)0x0007ab15, (ke_msg_func_t)sec_rcv_encrypt_req_ind_handler_patch},
148     // ble sdk gatt for conn
149     {(ke_msg_func_t)0x0006d0d5, (ke_msg_func_t)ble_sdk_gattc_event_ind_handler_patch},
150     {(ke_msg_func_t)0x0006db75, (ke_msg_func_t)ble_sdk_gatts_svc_changed_cfg_ind_handler_patch},
151 #endif
152 
153 #if CFG_MAX_SCAN
154     // gapm task for scan
155     {(ke_msg_func_t)0x00010d2d, (ke_msg_func_t)gapm_activity_create_cmd_handler_patch},
156     {(ke_msg_func_t)0x00012751, (ke_msg_func_t)gapm_hci_handler_patch},
157 #endif
158 };
159 
160 extern void reg_hci_cmd_patch_tab(hci_cmd_tab_item_t *hci_cmd_tab, uint16_t hci_cmd_cnt);
161 extern void reg_msg_patch_tab(msg_tab_item_t *msg_tab, uint16_t msg_cnt);
162 
163 #endif
164