finish nimble blehr porting and do some kernel improve

This commit is contained in:
SheldonDai
2019-10-09 12:15:59 +08:00
parent 45c18c896c
commit aad1564e09
663 changed files with 314162 additions and 68 deletions

View File

@@ -0,0 +1,14 @@
#ifndef _CONSOLE_H_
#define _CONSOLE_H_
#include "tos.h"
#define console_printf tos_kprintf
// we need a console
#define console_init(...) -1
#define console_write(...)
#define console_read(...) -1
#endif

View File

@@ -0,0 +1,309 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef _NIMBLE_NPL_OS_H_
#define _NIMBLE_NPL_OS_H_
#include <assert.h>
#include <stdint.h>
#include <string.h>
#include "tos.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _Static_assert
#define _Static_assert(...)
#endif
#define BLE_NPL_OS_ALIGNMENT 4
#define BLE_NPL_TIME_FOREVER TOS_TIME_FOREVER
/* This should be compatible with k_tick_t */
typedef uint32_t ble_npl_time_t;
typedef int32_t ble_npl_stime_t;
extern volatile int ble_npl_in_critical;
struct ble_npl_event {
bool queued;
ble_npl_event_fn *fn;
void *arg;
};
struct ble_npl_eventq {
k_queue_t q;
};
struct ble_npl_callout {
k_timer_t handle;
struct ble_npl_eventq *evq;
struct ble_npl_event ev;
};
struct ble_npl_mutex {
k_mutex_t handle;
};
struct ble_npl_sem {
k_sem_t handle;
};
/*
* Simple APIs are just defined as static inline below, but some are a bit more
* complex or require some global state variables and thus are defined in .c
* file instead and static inline wrapper just calls proper implementation.
* We need declarations of these functions and they are defined in header below.
*/
#include "npl_tencentos_tiny.h"
static inline bool
ble_npl_os_started(void)
{
return tos_knl_is_running();
}
static inline void *
ble_npl_get_current_task_id(void)
{
return (void *)k_curr_task;
}
static inline void
ble_npl_eventq_init(struct ble_npl_eventq *evq)
{
npl_tencentos_tiny_eventq_init(evq);
}
static inline struct ble_npl_event *
ble_npl_eventq_get(struct ble_npl_eventq *evq, ble_npl_time_t tmo)
{
return npl_tencentos_tiny_eventq_get(evq, tmo);
}
static inline void
ble_npl_eventq_put(struct ble_npl_eventq *evq, struct ble_npl_event *ev)
{
npl_tencentos_tiny_eventq_put(evq, ev);
}
static inline void
ble_npl_eventq_remove(struct ble_npl_eventq *evq, struct ble_npl_event *ev)
{
npl_tencentos_tiny_eventq_remove(evq, ev);
}
static inline void
ble_npl_event_run(struct ble_npl_event *ev)
{
ev->fn(ev);
}
static inline bool
ble_npl_eventq_is_empty(struct ble_npl_eventq *evq)
{
return npl_tencentos_tiny_eventq_is_empty(evq);
}
static inline void
ble_npl_event_init(struct ble_npl_event *ev, ble_npl_event_fn *fn,
void *arg)
{
memset(ev, 0, sizeof(*ev));
ev->fn = fn;
ev->arg = arg;
}
static inline bool
ble_npl_event_is_queued(struct ble_npl_event *ev)
{
return ev->queued;
}
static inline void *
ble_npl_event_get_arg(struct ble_npl_event *ev)
{
return ev->arg;
}
static inline void
ble_npl_event_set_arg(struct ble_npl_event *ev, void *arg)
{
ev->arg = arg;
}
static inline ble_npl_error_t
ble_npl_mutex_init(struct ble_npl_mutex *mu)
{
return npl_tencentos_tiny_mutex_init(mu);
}
static inline ble_npl_error_t
ble_npl_mutex_pend(struct ble_npl_mutex *mu, ble_npl_time_t timeout)
{
return npl_tencentos_tiny_mutex_pend(mu, timeout);
}
static inline ble_npl_error_t
ble_npl_mutex_release(struct ble_npl_mutex *mu)
{
return npl_tencentos_tiny_mutex_release(mu);
}
static inline ble_npl_error_t
ble_npl_sem_init(struct ble_npl_sem *sem, uint16_t tokens)
{
return npl_tencentos_tiny_sem_init(sem, tokens);
}
static inline ble_npl_error_t
ble_npl_sem_pend(struct ble_npl_sem *sem, ble_npl_time_t timeout)
{
return npl_tencentos_tiny_sem_pend(sem, timeout);
}
static inline ble_npl_error_t
ble_npl_sem_release(struct ble_npl_sem *sem)
{
return npl_tencentos_tiny_sem_release(sem);
}
static inline uint16_t
ble_npl_sem_get_count(struct ble_npl_sem *sem)
{
return npl_tencentos_tiny_sem_get_count(sem);
}
static inline void
ble_npl_callout_init(struct ble_npl_callout *co, struct ble_npl_eventq *evq,
ble_npl_event_fn *ev_cb, void *ev_arg)
{
npl_tencentos_tiny_callout_init(co, evq, ev_cb, ev_arg);
}
static inline ble_npl_error_t
ble_npl_callout_reset(struct ble_npl_callout *co, ble_npl_time_t ticks)
{
return npl_tencentos_tiny_callout_reset(co, ticks);
}
static inline void
ble_npl_callout_stop(struct ble_npl_callout *co)
{
npl_tencentos_tiny_callout_stop(co);
}
static inline bool
ble_npl_callout_is_active(struct ble_npl_callout *co)
{
return npl_tencentos_tiny_callout_is_active(co);
}
static inline ble_npl_time_t
ble_npl_callout_get_ticks(struct ble_npl_callout *co)
{
return npl_tencentos_tiny_callout_get_ticks(co);
}
static inline ble_npl_time_t
ble_npl_callout_remaining_ticks(struct ble_npl_callout *co,
ble_npl_time_t time)
{
return npl_tencentos_tiny_callout_remaining_ticks(co, time);
}
static inline void
ble_npl_callout_set_arg(struct ble_npl_callout *co, void *arg)
{
co->ev.arg = arg;
}
static inline ble_npl_time_t
ble_npl_time_get(void)
{
return tos_systick_get();
}
static inline ble_npl_error_t
ble_npl_time_ms_to_ticks(uint32_t ms, ble_npl_time_t *out_ticks)
{
return npl_tencentos_tiny_time_ms_to_ticks(ms, out_ticks);
}
static inline ble_npl_error_t
ble_npl_time_ticks_to_ms(ble_npl_time_t ticks, uint32_t *out_ms)
{
return npl_tencentos_tiny_time_ticks_to_ms(ticks, out_ms);
}
static inline ble_npl_time_t
ble_npl_time_ms_to_ticks32(uint32_t ms)
{
return tos_millisec2tick(ms);
}
static inline uint32_t
ble_npl_time_ticks_to_ms32(ble_npl_time_t ticks)
{
return tos_tick2millisec(ticks);
}
static inline void
ble_npl_time_delay(ble_npl_time_t ticks)
{
tos_task_delay(ticks);
}
static inline uint32_t
ble_npl_hw_enter_critical(void)
{
cpu_cpsr_t cpsr;
cpsr = tos_cpu_cpsr_save();
++ble_npl_in_critical;
return cpsr;
}
static inline void
ble_npl_hw_exit_critical(uint32_t ctx)
{
--ble_npl_in_critical;
tos_cpu_cpsr_restore(ctx);
}
static inline bool
ble_npl_hw_is_in_critical(void)
{
/*
* XXX Currently TencentOS tiny does not support an API for finding out if interrupts
* are currently disabled, hence in a critical section in this context.
* So for now, we use this global variable to keep this state for us.
-*/
return (ble_npl_in_critical > 0);
}
#ifdef __cplusplus
}
#endif
#endif /* _NPL_H_ */

View File

@@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef _NIMBLE_PORT_TENCENT_OS_TINY_H
#define _NIMBLE_PORT_TENCENT_OS_TINY_H
#include "nimble/nimble_npl.h"
#ifdef __cplusplus
extern "C" {
#endif
void
nimble_port_tencentos_tiny_init(k_task_entry_t host_task_fn);
#ifdef __cplusplus
}
#endif
#endif /* _NIMBLE_PORT_FREERTOS_H */

View File

@@ -0,0 +1,91 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef _NPL_TENCENTOS_TINY_H_
#define _NPL_TENCENTOS_TINY_H_
#ifdef __cplusplus
extern "C" {
#endif
void npl_tencentos_tiny_eventq_init(struct ble_npl_eventq *evq);
struct ble_npl_eventq *npl_tencentos_tiny_eventq_dflt_get(void);
struct ble_npl_event *npl_tencentos_tiny_eventq_get(struct ble_npl_eventq *evq,
ble_npl_time_t tmo);
void npl_tencentos_tiny_eventq_put(struct ble_npl_eventq *evq,
struct ble_npl_event *ev);
void npl_tencentos_tiny_eventq_remove(struct ble_npl_eventq *evq,
struct ble_npl_event *ev);
bool npl_tencentos_tiny_eventq_is_empty(struct ble_npl_eventq *evq);
ble_npl_error_t npl_tencentos_tiny_mutex_init(struct ble_npl_mutex *mu);
ble_npl_error_t npl_tencentos_tiny_mutex_pend(struct ble_npl_mutex *mu,
ble_npl_time_t timeout);
ble_npl_error_t npl_tencentos_tiny_mutex_release(struct ble_npl_mutex *mu);
ble_npl_error_t npl_tencentos_tiny_sem_init(struct ble_npl_sem *sem, uint16_t tokens);
ble_npl_error_t npl_tencentos_tiny_sem_pend(struct ble_npl_sem *sem,
ble_npl_time_t timeout);
ble_npl_error_t npl_tencentos_tiny_sem_release(struct ble_npl_sem *sem);
uint16_t npl_tencentos_tiny_sem_get_count(struct ble_npl_sem *sem);
void npl_tencentos_tiny_callout_init(struct ble_npl_callout *co,
struct ble_npl_eventq *evq,
ble_npl_event_fn *ev_cb, void *ev_arg);
ble_npl_error_t npl_tencentos_tiny_callout_reset(struct ble_npl_callout *co,
ble_npl_time_t ticks);
void npl_tencentos_tiny_callout_stop(struct ble_npl_callout *co);
bool npl_tencentos_tiny_callout_is_active(struct ble_npl_callout *co);
ble_npl_time_t npl_tencentos_tiny_callout_get_ticks(struct ble_npl_callout *co);
ble_npl_time_t npl_tencentos_tiny_callout_remaining_ticks(struct ble_npl_callout *co,
ble_npl_time_t now);
ble_npl_error_t npl_tencentos_tiny_time_ms_to_ticks(uint32_t ms,
ble_npl_time_t *out_ticks);
ble_npl_error_t npl_tencentos_tiny_time_ticks_to_ms(ble_npl_time_t ticks,
uint32_t *out_ms);
void npl_tencentos_tiny_hw_set_isr(int irqn, void (*addr)(void));
uint32_t npl_tencentos_tiny_hw_enter_critical(void);
void npl_tencentos_tiny_hw_exit_critical(uint32_t ctx);
#ifdef __cplusplus
}
#endif
#endif /* _NPL_TENCENTOS_TINY_H_ */

View File

@@ -0,0 +1,75 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include <stddef.h>
#include <tos.h>
#include "syscfg/syscfg.h"
#include "nimble/nimble_port.h"
#if NIMBLE_CFG_CONTROLLER
static k_task_t ll_task_h;
static k_stack_t ll_task_stack[MYNEWT_VAL(BLE_LL_TASK_STACK_SIZE)];
#endif
static k_task_t host_task_h;
static k_stack_t host_task_stack[MYNEWT_VAL(BLE_HOST_TASK_STACK_SIZE)];
__WEAK__ void __aeabi_assert(const char *expr, const char *file, int line)
{
while (1)
;
}
void
nimble_port_tencentos_tiny_init(k_task_entry_t host_task_fn)
{
k_err_t err;
#if NIMBLE_CFG_CONTROLLER
/*
* Create task where NimBLE LL will run. This one is required as LL has its
* own event queue and should have highest priority. The task function is
* provided by NimBLE and in case of TencentOS tiny it does not need to be wrapped
* since it has compatible prototype.
*/
err = tos_task_create(&ll_task_h, "ll", nimble_port_ll_task_func, NULL,
MYNEWT_VAL(BLE_LL_TASK_PRIORITY),
ll_task_stack, MYNEWT_VAL(BLE_LL_TASK_STACK_SIZE),
0);
if (err != K_ERR_NONE) {
return;
}
#endif
/*
* Create task where NimBLE host will run. It is not strictly necessary to
* have separate task for NimBLE host, but since something needs to handle
* default queue it is just easier to make separate task which does this.
*/
err = tos_task_create(&host_task_h, "ble", host_task_fn, NULL,
MYNEWT_VAL(BLE_HOST_TASK_PRIORITY),
host_task_stack, MYNEWT_VAL(BLE_HOST_TASK_STACK_SIZE),
0);
if (err != K_ERR_NONE) {
return;
}
tos_knl_start();
}

View File

@@ -0,0 +1,290 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include <assert.h>
#include <stddef.h>
#include <string.h>
#include "nimble/nimble_npl.h"
volatile int ble_npl_in_critical = 0;
void
npl_tencentos_tiny_eventq_init(struct ble_npl_eventq *evq)
{
tos_queue_create(&evq->q);
}
struct ble_npl_event *
npl_tencentos_tiny_eventq_get(struct ble_npl_eventq *evq, ble_npl_time_t tmo)
{
k_err_t err;
size_t msg_size;
struct ble_npl_event *ev = NULL;
err = tos_queue_pend(&evq->q, (void **)&ev, &msg_size, tmo);
if (err != K_ERR_NONE) {
return NULL;
}
if (ev) {
ev->queued = false;
}
return ev;
}
void
npl_tencentos_tiny_eventq_put(struct ble_npl_eventq *evq, struct ble_npl_event *ev)
{
k_err_t err;
if (ev->queued) {
return;
}
ev->queued = true;
err = tos_queue_post(&evq->q, ev, sizeof(struct ble_npl_event));
assert(err == K_ERR_NONE);
}
void
npl_tencentos_tiny_eventq_remove(struct ble_npl_eventq *evq,
struct ble_npl_event *ev)
{
if (!ev->queued) {
return;
}
tos_queue_remove(&evq->q, ev);
ev->queued = false;
}
bool
npl_tencentos_tiny_eventq_is_empty(struct ble_npl_eventq *evq)
{
return tos_list_empty(&evq->q.msg_queue.queue_head);
}
ble_npl_error_t
npl_tencentos_tiny_mutex_init(struct ble_npl_mutex *mu)
{
k_err_t err;
if (!mu) {
return BLE_NPL_INVALID_PARAM;
}
err = tos_mutex_create(&mu->handle);
return err == K_ERR_NONE ? BLE_NPL_OK : BLE_NPL_ERROR;
}
ble_npl_error_t
npl_tencentos_tiny_mutex_pend(struct ble_npl_mutex *mu, ble_npl_time_t timeout)
{
k_err_t err;
if (!mu) {
return BLE_NPL_INVALID_PARAM;
}
err = tos_mutex_pend_timed(&mu->handle, timeout);
return err == K_ERR_NONE ? BLE_NPL_OK : BLE_NPL_TIMEOUT;
}
ble_npl_error_t
npl_tencentos_tiny_mutex_release(struct ble_npl_mutex *mu)
{
k_err_t err;
if (!mu) {
return BLE_NPL_INVALID_PARAM;
}
err = tos_mutex_post(&mu->handle);
return err == BLE_NPL_OK ? BLE_NPL_OK : BLE_NPL_ERROR;
}
ble_npl_error_t
npl_tencentos_tiny_sem_init(struct ble_npl_sem *sem, uint16_t tokens)
{
k_err_t err;
if (!sem) {
return BLE_NPL_INVALID_PARAM;
}
err = tos_sem_create(&sem->handle, tokens);
return err == K_ERR_NONE ? BLE_NPL_OK : BLE_NPL_ERROR;
}
ble_npl_error_t
npl_tencentos_tiny_sem_pend(struct ble_npl_sem *sem, ble_npl_time_t timeout)
{
k_err_t err;
if (!sem) {
return BLE_NPL_INVALID_PARAM;
}
err = tos_sem_pend(&sem->handle, timeout);
return err == K_ERR_NONE ? BLE_NPL_OK : BLE_NPL_TIMEOUT;
}
ble_npl_error_t
npl_tencentos_tiny_sem_release(struct ble_npl_sem *sem)
{
k_err_t err;
if (!sem) {
return BLE_NPL_INVALID_PARAM;
}
err = tos_sem_post(&sem->handle);
return err == K_ERR_NONE ? BLE_NPL_OK : BLE_NPL_ERROR;
}
uint16_t
npl_tencentos_tiny_sem_get_count(struct ble_npl_sem *sem)
{
TOS_CPU_CPSR_ALLOC();
k_sem_cnt_t sem_cnt;
TOS_CPU_INT_DISABLE();
sem_cnt = sem->handle.count;
TOS_CPU_INT_ENABLE();
return sem_cnt;
}
static void
os_callout_timer_cb(void *arg)
{
struct ble_npl_callout *co;
co = (struct ble_npl_callout *)arg;
assert(co);
if (co->evq) {
ble_npl_eventq_put(co->evq, &co->ev);
} else {
co->ev.fn(&co->ev);
}
}
void
npl_tencentos_tiny_callout_init(struct ble_npl_callout *co, struct ble_npl_eventq *evq,
ble_npl_event_fn *ev_cb, void *ev_arg)
{
k_err_t err;
memset(co, 0, sizeof(*co));
err = tos_timer_create(&co->handle, 1, 0, os_callout_timer_cb, co, TOS_OPT_TIMER_ONESHOT);
assert(err == K_ERR_NONE);
co->evq = evq;
ble_npl_event_init(&co->ev, ev_cb, ev_arg);
}
ble_npl_error_t
npl_tencentos_tiny_callout_reset(struct ble_npl_callout *co, ble_npl_time_t ticks)
{
if (ticks == 0) {
ticks = 1;
}
tos_timer_stop(&co->handle);
tos_timer_delay_change(&co->handle, ticks);
tos_timer_start(&co->handle);
return BLE_NPL_OK;
}
void
npl_tencentos_tiny_callout_stop(struct ble_npl_callout *co)
{
tos_timer_stop(&co->handle);
}
bool
npl_tencentos_tiny_callout_is_active(struct ble_npl_callout *co)
{
return co->handle.state == TIMER_STATE_RUNNING;
}
ble_npl_time_t
npl_tencentos_tiny_callout_get_ticks(struct ble_npl_callout *co)
{
return co->handle.expires;
}
ble_npl_time_t
npl_tencentos_tiny_callout_remaining_ticks(struct ble_npl_callout *co,
ble_npl_time_t now)
{
k_tick_t expires;
expires = co->handle.expires;
if (expires > now) {
return expires - now;
} else {
return 0;
}
}
ble_npl_error_t
npl_tencentos_tiny_time_ms_to_ticks(uint32_t ms, ble_npl_time_t *out_ticks)
{
ble_npl_time_t ticks;
ticks = tos_millisec2tick(ms);
if (ticks > UINT32_MAX) {
return BLE_NPL_EINVAL;
}
*out_ticks = ticks;
return BLE_NPL_OK;
}
ble_npl_error_t
npl_tencentos_tiny_time_ticks_to_ms(ble_npl_time_t ticks, uint32_t *out_ms)
{
uint64_t ms;
ms = ((uint64_t)ticks * K_TIME_MILLISEC_PER_SEC / TOS_CFG_CPU_TICK_PER_SECOND);
if (ms > UINT32_MAX) {
return BLE_NPL_EINVAL;
}
*out_ms = (uint32_t)ms;
return BLE_NPL_OK;
}

View File

@@ -0,0 +1,62 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include "nrfx.h"
#if NIMBLE_CFG_CONTROLLER
static void (*radio_isr_addr)(void);
static void (*rng_isr_addr)(void);
static void (*rtc0_isr_addr)(void);
void RADIO_IRQHandler(void)
{
radio_isr_addr();
}
void RNG_IRQHandler(void)
{
rng_isr_addr();
}
void RTC0_IRQHandler(void)
{
rtc0_isr_addr();
}
void
ble_npl_hw_set_isr(int irqn, void (*addr)(void))
{
switch (irqn) {
case RADIO_IRQn:
radio_isr_addr = addr;
break;
case RNG_IRQn:
rng_isr_addr = addr;
break;
case RTC0_IRQn:
rtc0_isr_addr = addr;
break;
}
}
#endif

View File

@@ -0,0 +1,27 @@
#include "tos.h"
#ifdef __CC_ARM
/* avoid the heap and heap-using library functions supplied by arm */
#pragma import(__use_no_heap)
#endif
void *malloc(size_t n)
{
return tos_mmheap_alloc(n);
}
void *realloc(void *rmem, size_t newsize)
{
return tos_mmheap_realloc(rmem, newsize);
}
void *calloc(size_t nelem, size_t elsize)
{
return tos_mmheap_calloc(nelem, elsize);
}
void free(void *rmem)
{
tos_mmheap_free(rmem);
}