1 /*
2  * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #include <stdio.h>
7 #include <string.h>
8 #include "common/hci_driver_mem.h"
9 #include "common/hci_driver_h4.h"
10 #include "esp_hci_internal.h"
11 
12 void *
hci_driver_mem_cmd_alloc(void)13 hci_driver_mem_cmd_alloc(void)
14 {
15     return r_ble_hci_trans_buf_alloc(ESP_HCI_INTERNAL_BUF_CMD);
16 }
17 
18 void *
hci_driver_mem_evt_alloc(int discardable)19 hci_driver_mem_evt_alloc(int discardable)
20 {
21     /* The controller shouldn't invoke this. */
22     assert(0);
23     return NULL;
24 }
25 
26 struct os_mbuf *
hci_driver_mem_acl_alloc(void)27 hci_driver_mem_acl_alloc(void)
28 {
29     return os_msys_get_pkthdr(0, ESP_HCI_INTERNAL_ACL_MBUF_LEADINGSPCAE);
30 }
31 
32 struct os_mbuf *
hci_driver_mem_acl_len_alloc(uint32_t len)33 hci_driver_mem_acl_len_alloc(uint32_t len)
34 {
35     return os_msys_get_pkthdr(len, ESP_HCI_INTERNAL_ACL_MBUF_LEADINGSPCAE);
36 }
37 
38 struct os_mbuf *
hci_driver_mem_iso_alloc(void)39 hci_driver_mem_iso_alloc(void)
40 {
41      return os_msys_get_pkthdr(0, ESP_HCI_INTERNAL_ACL_MBUF_LEADINGSPCAE);
42 }
43 
44 struct os_mbuf *
hci_driver_mem_iso_len_alloc(uint32_t len)45 hci_driver_mem_iso_len_alloc(uint32_t len)
46 {
47      return os_msys_get_pkthdr(len, ESP_HCI_INTERNAL_ACL_MBUF_LEADINGSPCAE);
48 }
49 
50 const struct hci_h4_allocators s_hci_driver_mem_alloc = {
51     .cmd = hci_driver_mem_cmd_alloc,
52     .evt = hci_driver_mem_evt_alloc,
53     .acl = hci_driver_mem_acl_alloc,
54     .iso = hci_driver_mem_iso_alloc,
55 };
56