diff options
| author | ousugo <[email protected]> | 2021-12-14 10:42:18 +0800 |
|---|---|---|
| committer | ousugo <[email protected]> | 2021-12-14 10:42:18 +0800 |
| commit | 4820dbb0b3a15a62f4cd5f3e20fb4e02e4bfbb20 (patch) | |
| tree | 27698aa9180b0c25dd9c4d9ced3320da10360b1d /components | |
| parent | a237f805b940db16ef0d0009e56eb183f5713c07 (diff) | |
| parent | c5208a7d19871573dcb719358d34d3effa0682e9 (diff) | |
Merge branch 'master' into addAnnotation
Diffstat (limited to 'components')
35 files changed, 848 insertions, 129 deletions
diff --git a/components/drivers/Kconfig b/components/drivers/Kconfig index 159a6cbda3..d197bd246e 100755 --- a/components/drivers/Kconfig +++ b/components/drivers/Kconfig @@ -5,10 +5,6 @@ config RT_USING_DEVICE_IPC default y if RT_USING_DEVICE_IPC - config RT_PIPE_BUFSZ - int "Set pipe buffer size" - default 512 - config RT_USING_SYSTEM_WORKQUEUE bool "Using system default workqueue" default n @@ -18,7 +14,7 @@ if RT_USING_DEVICE_IPC int "The stack size for system workqueue thread" default 2048 - config RT_SYSTEM_WORKQUEUE_PRIORITY + config RT_SYSTEM_WORKQUEUE_PRIORITY int "The priority level of system workqueue thread" default 23 endif @@ -149,6 +145,42 @@ config RT_USING_PM bool "Using Power Management device drivers" default n + if RT_USING_PM + config PM_TICKLESS_THRESHOLD_TIME + int "PM tickless threashold time" + default 2 + + config PM_USING_CUSTOM_CONFIG + bool "PM using custom pm config" + default n + + config PM_ENABLE_DEBUG + bool "PM Enable Debug" + default n + + config PM_ENABLE_SUSPEND_SLEEP_MODE + bool "PM Device suspend change sleep mode" + default n + + config PM_ENABLE_THRESHOLD_SLEEP_MODE + bool "PM using threshold time change sleep mode" + default n + + if PM_ENABLE_THRESHOLD_SLEEP_MODE + config PM_LIGHT_THRESHOLD_TIME + int "PM light mode threashold time" + default 5 + + config PM_DEEP_THRESHOLD_TIME + int "PM deep mode threashold time" + default 20 + + config PM_STANDBY_THRESHOLD_TIME + int "PM standby mode threashold time" + default 100 + endif + endif + config RT_USING_RTC bool "Using RTC device drivers" default n diff --git a/components/drivers/include/drivers/lptimer.h b/components/drivers/include/drivers/lptimer.h new file mode 100644 index 0000000000..e59ce61d22 --- /dev/null +++ b/components/drivers/include/drivers/lptimer.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-10-11 zhangsz the first version + */ + +#ifndef __LPTIMER_H__ +#define __LPTIMER_H__ + +#include <rtthread.h> + +struct rt_lptimer +{ + struct rt_timer timer; + rt_list_t list; +}; +typedef struct rt_lptimer *rt_lptimer_t; + +void rt_lptimer_init(rt_lptimer_t timer, + const char *name, + void (*timeout)(void *parameter), + void *parameter, + rt_tick_t time, + rt_uint8_t flag); + +rt_err_t rt_lptimer_detach(rt_lptimer_t timer); +rt_err_t rt_lptimer_start(rt_lptimer_t timer); +rt_err_t rt_lptimer_stop(rt_lptimer_t timer); + +rt_err_t rt_lptimer_control(rt_lptimer_t timer, int cmd, void *arg); + +rt_tick_t rt_lptimer_next_timeout_tick(void); + +#endif diff --git a/components/drivers/include/drivers/pm.h b/components/drivers/include/drivers/pm.h index d38c0a4e2a..2deee83692 100644 --- a/components/drivers/include/drivers/pm.h +++ b/components/drivers/include/drivers/pm.h @@ -17,8 +17,7 @@ #include <stdint.h> #include <rtthread.h> - -#ifndef PM_HAS_CUSTOM_CONFIG +#include <drivers/lptimer.h> /* All modes used for rt_pm_request() and rt_pm_release() */ enum @@ -48,10 +47,6 @@ enum RT_PM_FREQUENCY_PENDING = 0x01, }; -#define RT_PM_DEFAULT_SLEEP_MODE PM_SLEEP_MODE_NONE -#define RT_PM_DEFAULT_DEEPSLEEP_MODE PM_SLEEP_MODE_DEEP -#define RT_PM_DEFAULT_RUN_MODE PM_RUN_MODE_NORMAL_SPEED - /* The name of all modes used in the msh command "pm_dump" */ #define PM_SLEEP_MODE_NAMES \ { \ @@ -71,6 +66,7 @@ enum "Low Mode", \ } +#ifndef PM_USING_CUSTOM_CONFIG /** * Modules used for * pm_module_request(PM_BOARD_ID, PM_SLEEP_MODE_IDLE) @@ -98,11 +94,23 @@ enum pm_module_id { PM_MODULE_MAX_ID, /* enum must! */ }; -#else /* PM_HAS_CUSTOM_CONFIG */ +#else #include <pm_cfg.h> -#endif /* PM_HAS_CUSTOM_CONFIG */ +#endif /* PM_USING_CUSTOM_CONFIG */ + +#ifndef RT_PM_DEFAULT_SLEEP_MODE +#define RT_PM_DEFAULT_SLEEP_MODE PM_SLEEP_MODE_NONE +#endif + +#ifndef RT_PM_DEFAULT_DEEPSLEEP_MODE +#define RT_PM_DEFAULT_DEEPSLEEP_MODE PM_SLEEP_MODE_DEEP +#endif + +#ifndef RT_PM_DEFAULT_RUN_MODE +#define RT_PM_DEFAULT_RUN_MODE PM_RUN_MODE_NORMAL_SPEED +#endif /** * device control flag to request or release power @@ -160,6 +168,9 @@ struct rt_pm /* modules request status*/ struct rt_pm_module module_status[PM_MODULE_MAX_ID]; + /* sleep request table */ + rt_uint32_t sleep_status[PM_SLEEP_MODE_MAX - 1][(PM_MODULE_MAX_ID + 31) / 32]; + /* the list of device, which has PM feature */ rt_uint8_t device_pm_number; struct rt_device_pm *device_pm; @@ -203,5 +214,16 @@ void rt_pm_module_release_all(uint8_t module_id, rt_uint8_t sleep_mode); void rt_pm_module_delay_sleep(rt_uint8_t module_id, rt_tick_t timeout); rt_uint32_t rt_pm_module_get_status(void); rt_uint8_t rt_pm_get_sleep_mode(void); +struct rt_pm *rt_pm_get_handle(void); + +/* sleep : request or release */ +void rt_pm_sleep_request(rt_uint16_t module_id, rt_uint8_t mode); +void rt_pm_sleep_release(rt_uint16_t module_id, rt_uint8_t mode); +void rt_pm_sleep_none_request(rt_uint16_t module_id); +void rt_pm_sleep_none_release(rt_uint16_t module_id); +void rt_pm_sleep_idle_request(rt_uint16_t module_id); +void rt_pm_sleep_idle_release(rt_uint16_t module_id); +void rt_pm_sleep_light_request(rt_uint16_t module_id); +void rt_pm_sleep_light_release(rt_uint16_t module_id); #endif /* __PM_H__ */ diff --git a/components/drivers/include/ipc/pipe.h b/components/drivers/include/ipc/pipe.h index a45e8ae002..7d271c3a04 100644 --- a/components/drivers/include/ipc/pipe.h +++ b/components/drivers/include/ipc/pipe.h @@ -15,12 +15,6 @@ #include <rtthread.h> #include <rtdevice.h> -#ifndef RT_PIPE_BUFSZ -#define PIPE_BUFSZ 512 -#else -#define PIPE_BUFSZ RT_PIPE_BUFSZ -#endif - struct rt_pipe_device { struct rt_device parent; diff --git a/components/drivers/pm/SConscript b/components/drivers/pm/SConscript index a94fc11f57..fd23e8293c 100644 --- a/components/drivers/pm/SConscript +++ b/components/drivers/pm/SConscript @@ -7,6 +7,7 @@ group = [] if GetDepend(['RT_USING_PM']): src = src + ['pm.c'] + src = src + ['lptimer.c'] if len(src): group = DefineGroup('DeviceDrivers', src, depend = [''], CPPPATH = CPPPATH) diff --git a/components/drivers/pm/lptimer.c b/components/drivers/pm/lptimer.c new file mode 100644 index 0000000000..144270cf7f --- /dev/null +++ b/components/drivers/pm/lptimer.c @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-10-11 zhangsz the first version + */ + +#include <rtthread.h> +#include <rthw.h> +#include <drivers/lptimer.h> + +static rt_list_t rt_soft_lptimer_list = RT_LIST_OBJECT_INIT(rt_soft_lptimer_list); + +/* lptimer init */ +void rt_lptimer_init(rt_lptimer_t timer, + const char *name, + void (*timeout)(void *parameter), + void *parameter, + rt_tick_t time, + rt_uint8_t flag) +{ + rt_timer_init(&timer->timer, name, timeout, parameter, time, flag); + rt_list_init(&timer->list); +} + +/* lptimer detach */ +rt_err_t rt_lptimer_detach(rt_lptimer_t timer) +{ + rt_base_t level; + rt_err_t ret = RT_EOK; + RT_ASSERT(timer != RT_NULL); + + /* disable interrupt */ + level = rt_hw_interrupt_disable(); + + ret = rt_timer_detach(&timer->timer); + rt_list_remove(&timer->list); + + /* enable interrupt */ + rt_hw_interrupt_enable(level); + return ret; +} + +/* lptimer start */ +rt_err_t rt_lptimer_start(rt_lptimer_t timer) +{ + rt_base_t level; + + RT_ASSERT(timer != RT_NULL); + + /* disable interrupt */ + level = rt_hw_interrupt_disable(); + rt_list_remove(&timer->list); /* remove first */ + if (rt_timer_start(&timer->timer) == RT_EOK) + { + /* insert to lptimer list */ + rt_list_insert_after(&rt_soft_lptimer_list, &(timer->list)); + } + else + { + /* enable interrupt */ + rt_hw_interrupt_enable(level); + return -RT_ERROR; + } + + /* enable interrupt */ + rt_hw_interrupt_enable(level); + return RT_EOK; +} + +/* lptimer stop */ +rt_err_t rt_lptimer_stop(rt_lptimer_t timer) +{ + rt_base_t level; + RT_ASSERT(timer != RT_NULL); + + /* disable interrupt */ + level = rt_hw_interrupt_disable(); + rt_list_remove(&timer->list); + if (rt_timer_stop(&timer->timer) == RT_EOK) + { + /* enable interrupt */ + rt_hw_interrupt_enable(level); + return RT_EOK; + } + else + { + /* enable interrupt */ + rt_hw_interrupt_enable(level); + return -RT_ERROR; + } +} + +rt_err_t rt_lptimer_control(rt_lptimer_t timer, int cmd, void *arg) +{ + RT_ASSERT(timer != RT_NULL); + + return rt_timer_control(&timer->timer, cmd, arg); +} + +/* get the next soft lptimer timeout */ +rt_tick_t rt_lptimer_next_timeout_tick(void) +{ + struct rt_lptimer *timer; + rt_base_t level; + rt_tick_t timeout_tick = RT_TICK_MAX; + struct rt_list_node *node = RT_NULL; + rt_tick_t temp_tick = 0; + rt_tick_t min_tick = RT_TICK_MAX; + rt_tick_t cur_tick = rt_tick_get(); + + /* disable interrupt */ + level = rt_hw_interrupt_disable(); + + if (!rt_list_isempty(&rt_soft_lptimer_list)) + { + /* find the first active timer's timeout */ + rt_list_for_each(node, &rt_soft_lptimer_list) + { + timer = rt_list_entry(node, struct rt_lptimer, list); + if (timer->timer.parent.flag & RT_TIMER_FLAG_ACTIVATED) + { + temp_tick = timer->timer.timeout_tick - cur_tick; + + /* find the least timeout_tick */ + if (min_tick > temp_tick) + { + min_tick = temp_tick; + timeout_tick = timer->timer.timeout_tick; + } + } + } + } + + /* enable interrupt */ + rt_hw_interrupt_enable(level); + + return timeout_tick; +} + +void lptimer_dump(void) +{ + struct rt_lptimer *timer; + rt_base_t level; + struct rt_list_node *node = RT_NULL; + + /* disable interrupt */ + level = rt_hw_interrupt_disable(); + + rt_kprintf("| lptimer | periodic | timeout | flag |\n"); + rt_kprintf("+---------------+------------+------------+-------------+\n"); + + if (!rt_list_isempty(&rt_soft_lptimer_list)) + { + rt_list_for_each(node, &rt_soft_lptimer_list) + { + timer = rt_list_entry(node, struct rt_lptimer, list); + rt_kprintf("| %-13s | 0x%08x | 0x%08x |", + timer->timer.parent.name, timer->timer.init_tick, + timer->timer.timeout_tick); + if (timer->timer.parent.flag & RT_TIMER_FLAG_ACTIVATED) + rt_kprintf(" activated |\n"); + else + rt_kprintf(" deactivated |\n"); + } + } + + /* enable interrupt */ + rt_hw_interrupt_enable(level); + rt_kprintf("+---------------+------------+------------+-------------+\n"); +} + +MSH_CMD_EXPORT(lptimer_dump, soft lptimer dump); diff --git a/components/drivers/pm/pm.c b/components/drivers/pm/pm.c index cf488a9ce1..b3ebbeb078 100644 --- a/components/drivers/pm/pm.c +++ b/components/drivers/pm/pm.c @@ -15,9 +15,44 @@ #include <rthw.h> #include <rtthread.h> #include <drivers/pm.h> +#include <stdlib.h> #ifdef RT_USING_PM +/* tickless threshold time */ +#ifndef PM_TICKLESS_THRESHOLD_TIME +#define PM_TICKLESS_THRESHOLD_TIME 2 +#endif + +/* tickless threshold : sleep mode */ +#ifndef PM_TICKLESS_THRESHOLD_MODE +#define PM_TICKLESS_THRESHOLD_MODE PM_SLEEP_MODE_IDLE +#endif + +/* busy : sleep mode */ +#ifndef PM_BUSY_SLEEP_MODE +#define PM_BUSY_SLEEP_MODE PM_SLEEP_MODE_IDLE +#endif + +/* suspend : suspend sleep mode */ +#ifndef PM_SUSPEND_SLEEP_MODE +#define PM_SUSPEND_SLEEP_MODE PM_SLEEP_MODE_IDLE +#endif + +#ifdef PM_ENABLE_THRESHOLD_SLEEP_MODE +#ifndef PM_LIGHT_THRESHOLD_TIME +#define PM_LIGHT_THRESHOLD_TIME 5 +#endif + +#ifndef PM_DEEP_THRESHOLD_TIME +#define PM_DEEP_THRESHOLD_TIME 20 +#endif + +#ifndef PM_STANDBY_THRESHOLD_TIME +#define PM_STANDBY_THRESHOLD_TIME 100 +#endif +#endif + static struct rt_pm _pm; /* default mode : system power on */ @@ -29,8 +64,6 @@ static rt_uint8_t _pm_default_deepsleep = RT_PM_DEFAULT_DEEPSLEEP_MODE; static struct rt_pm_notify _pm_notify; static rt_uint8_t _pm_init_flag = 0; -#define RT_PM_TICKLESS_THRESH (2) - RT_WEAK rt_uint32_t rt_pm_enter_critical(rt_uint8_t sleep_mode) { return rt_hw_interrupt_disable(); @@ -41,6 +74,48 @@ RT_WEAK void rt_pm_exit_critical(rt_uint32_t ctx, rt_uint8_t sleep_mode) rt_hw_interrupt_enable(ctx); } +/* lptimer start */ +static void pm_lptimer_start(struct rt_pm *pm, uint32_t timeout) +{ + if (_pm.ops == RT_NULL) + return; + + if (_pm.ops->timer_start != RT_NULL) + _pm.ops->timer_start(pm, timeout); +} + +/* lptimer stop */ +static void pm_lptimer_stop(struct rt_pm *pm) +{ + if (_pm.ops == RT_NULL) + return; + + if (_pm.ops->timer_stop != RT_NULL) + _pm.ops->timer_stop(pm); +} + +/* lptimer get timeout tick */ +static rt_tick_t pm_lptimer_get_timeout(struct rt_pm *pm) +{ + if (_pm.ops == RT_NULL) + return RT_TICK_MAX; + + if (_pm.ops->timer_get_tick != RT_NULL) + return _pm.ops->timer_get_tick(pm); + + return RT_TICK_MAX; +} + +/* enter sleep mode */ +static void pm_sleep(struct rt_pm *pm, uint8_t sleep_mode) +{ + if (_pm.ops == RT_NULL) + return; + + if (_pm.ops->sleep != RT_NULL) + _pm.ops->sleep(pm, sleep_mode); +} + /** * This function will suspend all registered devices */ @@ -112,6 +187,30 @@ static void _pm_frequency_scaling(struct rt_pm *pm) } /** + * judge sleep mode from sleep request + * + * @param none + * + * @return sleep mode + */ +static rt_uint8_t _judge_sleep_mode(void) +{ + rt_uint16_t index; + rt_uint16_t len; + + for (index = 0; index < PM_SLEEP_MODE_MAX -1; index++) + { + for (len = 0; len < ((PM_MODULE_MAX_ID + 31) / 32); len++) + { + if (_pm.sleep_status[index][len] != 0x00) + return index; + } + } + + return PM_SLEEP_MODE_MAX; /* default sleep mode */ +} + +/** * This function selects the sleep mode according to the rt_pm_request/rt_pm_release count. */ static rt_uint8_t _pm_select_sleep_mode(struct rt_pm *pm) @@ -120,6 +219,7 @@ static rt_uint8_t _pm_select_sleep_mode(struct rt_pm *pm) rt_uint8_t mode; mode = _pm_default_deepsleep; + rt_uint8_t request_mode = _judge_sleep_mode(); for (index = PM_SLEEP_MODE_NONE; index < PM_SLEEP_MODE_MAX; index ++) { if (pm->modes[index]) @@ -128,7 +228,10 @@ static rt_uint8_t _pm_select_sleep_mode(struct rt_pm *pm) break; } } - pm->sleep_mode = mode; + + /* select the high power mode */ + if (request_mode < mode) + mode = request_mode; return mode; } @@ -185,6 +288,72 @@ static rt_bool_t _pm_device_check_idle(void) return RT_TRUE; } +RT_WEAK rt_tick_t pm_timer_next_timeout_tick(rt_uint8_t mode) +{ + switch (mode) + { + case PM_SLEEP_MODE_LIGHT: + return rt_timer_next_timeout_tick(); + case PM_SLEEP_MODE_DEEP: + case PM_SLEEP_MODE_STANDBY: + return rt_lptimer_next_timeout_tick(); + } + + return RT_TICK_MAX; +} + +/** + * This function will judge sleep mode from threshold timeout. + * + * @param cur_mode the current pm sleep mode + * @param timeout_tick the threshold timeout + * + * @return none + */ +RT_WEAK rt_uint8_t pm_get_sleep_threshold_mode(rt_uint8_t cur_mode, rt_tick_t timeout_tick) +{ + rt_uint8_t sleep_mode = cur_mode; + + if (_pm_init_flag == 0) + return sleep_mode; + + if (cur_mode >= PM_SLEEP_MODE_MAX) + return sleep_mode; + +#ifdef PM_ENABLE_THRESHOLD_SLEEP_MODE + switch (cur_mode) + { + case PM_SLEEP_MODE_NONE: + case PM_SLEEP_MODE_IDLE: + break; + case PM_SLEEP_MODE_LIGHT: + if (timeout_tick < PM_LIGHT_THRESHOLD_TIME) + sleep_mode = PM_SLEEP_MODE_IDLE; + break; + case PM_SLEEP_MODE_DEEP: + if (timeout_tick < PM_LIGHT_THRESHOLD_TIME) + sleep_mode = PM_SLEEP_MODE_IDLE; + else if (timeout_tick < PM_DEEP_THRESHOLD_TIME) + sleep_mode = PM_SLEEP_MODE_LIGHT; + break; + case PM_SLEEP_MODE_STANDBY: + if (timeout_tick < PM_LIGHT_THRESHOLD_TIME) + sleep_mode = PM_SLEEP_MODE_IDLE; + else if (timeout_tick < PM_DEEP_THRESHOLD_TIME) + sleep_mode = PM_SLEEP_MODE_LIGHT; + else if (timeout_tick < PM_STANDBY_THRESHOLD_TIME) + sleep_mode = PM_SLEEP_MODE_DEEP; + } +#else + if (timeout_tick < PM_TICKLESS_THRESHOLD_TIME) + { + cur_mode = PM_SLEEP_MODE_IDLE; + } +#endif + + return cur_mode; +} + /** * This function changes the power sleep mode base on the result of selection */ @@ -192,16 +361,21 @@ static void _pm_change_sleep_mode(struct rt_pm *pm) { rt_tick_t timeout_tick, delta_tick; rt_base_t level; - int ret = RT_EOK; + uint8_t sleep_mode = PM_SLEEP_MODE_DEEP; level = rt_pm_enter_critical(pm->sleep_mode); - /* module busy request */ + /* judge sleep mode from module request */ + pm->sleep_mode = _pm_select_sleep_mode(pm); + + /* module busy request check */ if (_pm_device_check_idle() == RT_FALSE) { - pm->ops->sleep(pm, PM_SLEEP_MODE_NONE); - rt_pm_exit_critical(level, pm->sleep_mode); - return; + sleep_mode = PM_BUSY_SLEEP_MODE; + if (sleep_mode < pm->sleep_mode) + { + pm->sleep_mode = sleep_mode; /* judge the highest sleep mode */ + } } if (_pm.sleep_mode == PM_SLEEP_MODE_NONE) @@ -216,50 +390,54 @@ static void _pm_change_sleep_mode(struct rt_pm *pm) _pm_notify.notify(RT_PM_ENTER_SLEEP, pm->sleep_mode, _pm_notify.data); /* Suspend all peripheral device */ - ret = _pm_device_suspend(pm->sleep_mode); +#ifdef PM_ENABLE_SUSPEND_SLEEP_MODE + int ret = _pm_device_suspend(pm->sleep_mode); if (ret != RT_EOK) { _pm_device_resume(pm->sleep_mode); if (_pm_notify.notify) _pm_notify.notify(RT_PM_EXIT_SLEEP, pm->sleep_mode, _pm_notify.data); + if (pm->sleep_mode > PM_SUSPEND_SLEEP_MODE) + { + pm->sleep_mode = PM_SUSPEND_SLEEP_MODE; + } + pm->ops->sleep(pm, pm->sleep_mode); /* suspend failed */ rt_pm_exit_critical(level, pm->sleep_mode); - return; } - +#else + _pm_device_suspend(pm->sleep_mode); +#endif /* Tickless*/ if (pm->timer_mask & (0x01 << pm->sleep_mode)) { - timeout_tick = rt_timer_next_timeout_tick(); - if (timeout_tick == RT_TICK_MAX) - { - if (pm->ops->timer_start) - { - pm->ops->timer_start(pm, RT_TICK_MAX); - } - } - else + timeout_tick = pm_timer_next_timeout_tick(pm->sleep_mode); + timeout_tick = timeout_tick - rt_tick_get(); + + /* Judge sleep_mode from threshold time */ + pm->sleep_mode = pm_get_sleep_threshold_mode(pm->sleep_mode, timeout_tick); + + if (pm->timer_mask & (0x01 << pm->sleep_mode)) { - timeout_tick = timeout_tick - rt_tick_get(); - if (timeout_tick < RT_PM_TICKLESS_THRESH) + if (timeout_tick == RT_TICK_MAX) { - pm->sleep_mode = PM_SLEEP_MODE_IDLE; + pm_lptimer_start(pm, RT_TICK_MAX); } else { - pm->ops->timer_start(pm, timeout_tick); + pm_lptimer_start(pm, timeout_tick); } } } /* enter lower power state */ - pm->ops->sleep(pm, pm->sleep_mode); + pm_sleep(pm, pm->sleep_mode); /* wake up from lower power state*/ if (pm->timer_mask & (0x01 << pm->sleep_mode)) { - delta_tick = pm->ops->timer_get_tick(pm); - pm->ops->timer_stop(pm); + delta_tick = pm_lptimer_get_timeout(pm); + pm_lptimer_stop(pm); if (delta_tick) { rt_tick_set(rt_tick_get() + delta_tick); @@ -320,7 +498,6 @@ void rt_pm_request(rt_uint8_t mode) pm = &_pm; if (pm->modes[mode] < 255) pm->modes[mode] ++; - _pm_select_sleep_mode(pm); rt_hw_interrupt_enable(level); } @@ -346,7 +523,6 @@ void rt_pm_release(rt_uint8_t mode) pm = &_pm; if (pm->modes[mode] > 0) pm->modes[mode] --; - _pm_select_sleep_mode(pm); rt_hw_interrupt_enable(level); } @@ -371,7 +547,6 @@ void rt_pm_release_all(rt_uint8_t mode) level = rt_hw_interrupt_disable(); pm = &_pm; pm->modes[mode] = 0; - _pm_select_sleep_mode(pm); rt_hw_interrupt_enable(level); } @@ -401,7 +576,6 @@ void rt_pm_module_request(uint8_t module_id, rt_uint8_t mode) pm->module_status[module_id].req_status = 0x01; if (pm->modes[mode] < 255) pm->modes[mode] ++; - _pm_select_sleep_mode(pm); rt_hw_interrupt_enable(level); } @@ -433,7 +607,6 @@ void rt_pm_module_release(uint8_t module_id, rt_uint8_t mode) pm->modes[mode] --; if (pm->modes[mode] == 0) pm->module_status[module_id].req_status = 0x00; - _pm_select_sleep_mode(pm); rt_hw_interrupt_enable(level); } @@ -460,11 +633,136 @@ void rt_pm_module_release_all(uint8_t module_id, rt_uint8_t mode) pm = &_pm; pm->modes[mode] = 0; pm->module_status[module_id].req_status = 0x00; - _pm_select_sleep_mode(pm); rt_hw_interrupt_enable(level); } /** + * This function will let current module work with specified sleep mode. + * + * @param module_id the pm module id + * @param mode the pm sleep mode + * + * @return none + */ +void rt_pm_sleep_request(rt_uint16_t module_id, rt_uint8_t mode) +{ + rt_uint32_t level; + + if (module_id >= PM_MODULE_MAX_ID) + { + return; + } + + if (mode >= (PM_SLEEP_MODE_MAX - 1)) + { + return; + } + + level = rt_hw_interrupt_disable(); + _pm.sleep_status[mode][module_id / 32] |= 1 << (module_id % 32); + rt_hw_interrupt_enable(level); +} + +/** + * This function will let current module work with PM_SLEEP_MODE_NONE mode. + * + * @param module_id the pm module id + * + * @return NULL + */ +void rt_pm_sleep_none_request(rt_uint16_t module_id) +{ + rt_pm_sleep_request(module_id, PM_SLEEP_MODE_NONE); +} + +/** + * This function will let current module work with PM_SLEEP_MODE_IDLE mode. + * + * @param module_id the pm module id + * + * @return NULL + */ +void rt_pm_sleep_idle_request(rt_uint16_t module_id) +{ + rt_pm_sleep_request(module_id, PM_SLEEP_MODE_IDLE); +} + +/** + * This function will let current module work with PM_SLEEP_MODE_LIGHT mode. + * + * @param module_id the pm module id + * + * @return NULL + */ +void rt_pm_sleep_light_request(rt_uint16_t module_id) +{ + rt_pm_sleep_request(module_id, PM_SLEEP_MODE_LIGHT); +} + +/** + * When current module don't work, release requested sleep mode. + * + * @param module_id the pm module id + * @param mode the pm sleep mode + * + * @return NULL + */ +void rt_pm_sleep_release(rt_uint16_t module_id, rt_uint8_t mode) +{ + rt_uint32_t level; + + if (module_id >= PM_MODULE_MAX_ID) + { + return; + } + + if (mode >= (PM_SLEEP_MODE_MAX - 1)) + { + return; + } + + level = rt_hw_interrupt_disable(); + _pm.sleep_status[mode][module_id / 32] &= ~(1 << (module_id % 32)); + rt_hw_interrupt_enable(level); +} + +/** + * The specified module release the requested PM_SLEEP_MODE_NONE mode + * + * @param module_id the pm module id + * + * @return none + */ +void rt_pm_sleep_none_release(rt_uint16_t module_id) +{ + rt_pm_sleep_release(module_id, PM_SLEEP_MODE_NONE); +} + +/** + * The specified module release the requested PM_SLEEP_MODE_IDLE mode + * + * @param module_id the pm module id + * + * @return none + */ +void rt_pm_sleep_idle_release(rt_uint16_t module_id) +{ + rt_pm_sleep_release(module_id, PM_SLEEP_MODE_IDLE); +} + +/** + * The specified module release the requested PM_SLEEP_MODE_LIGHT mode + * + * @param module_id the pm module id + * + * @return none + */ +void rt_pm_sleep_light_release(rt_uint16_t module_id) +{ + rt_pm_sleep_release(module_id, PM_SLEEP_MODE_LIGHT); +} + +/** * Register a device with PM feature * * @param device the device with PM feature @@ -853,6 +1151,69 @@ rt_uint8_t rt_pm_get_sleep_mode(void) return pm->sleep_mode; } +/* get pm entity pointer */ +struct rt_pm *rt_pm_get_handle(void) +{ + return &_pm; +} + +#ifdef PM_ENABLE_DEBUG +/** + * print current module sleep request list + * + * @param none + * + * @return none + */ +void pm_sleep_dump(void) +{ + uint8_t index; + uint16_t len; + + rt_kprintf("+-------------+--------------+\n"); + rt_kprintf("| Sleep Mode | Request List |\n"); + rt_kprintf("+-------------+--------------+\n"); + for (index = 0; index < PM_SLEEP_MODE_MAX -1; index++) + { + for (len = 0; len < ((PM_MODULE_MAX_ID + 31) / 32); len++) + { + rt_kprintf("| Mode[%d] : %d | 0x%08x |\n", index, len, + _pm.sleep_status[index][len]); + } + } + rt_kprintf("+-------------+--------------+\n"); +} +MSH_CMD_EXPORT(pm_sleep_dump, dump pm request list); + +static void pm_sleep_request(int argc, char **argv) +{ + int module = 0; + int mode = 0; + + if (argc >= 3) + { + module = atoi(argv[1]); + mode = atoi(argv[2]); + rt_pm_sleep_request(module, mode); + } +} +MSH_CMD_EXPORT(pm_sleep_request, pm_sleep_request module sleep_mode); + +static void pm_sleep_release(int argc, char **argv) +{ + int module = 0; + int mode = 0; + + if (argc >= 3) + { + module = atoi(argv[1]); + mode = atoi(argv[2]); + rt_pm_sleep_release(module, mode); + } +} +MSH_CMD_EXPORT(pm_sleep_release, pm_sleep_release module sleep_mode); +#endif + static void rt_pm_dump_status(void) { rt_uint32_t index; diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 0e944b5e95..6f7e7d5b2b 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -42,7 +42,7 @@ #include <sys/ioctl.h> #ifdef RT_USING_POSIX_TERMIOS -#include <posix_termios.h> +#include <termios.h> #endif /* it's possible the 'getc/putc' is defined by stdio.h in gcc/newlib. */ diff --git a/components/drivers/src/pipe.c b/components/drivers/src/pipe.c index 62047e46d6..993f6f7616 100644 --- a/components/drivers/src/pipe.c +++ b/components/drivers/src/pipe.c @@ -13,7 +13,7 @@ #include <stdint.h> #include <sys/errno.h> -#ifdef RT_USING_POSIX_DEVIO +#if defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_POSIX_PIPE) #include <dfs_file.h> #include <dfs_posix.h> #include <poll.h> @@ -392,7 +392,7 @@ static const struct dfs_file_ops pipe_fops = RT_NULL, pipe_fops_poll, }; -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_POSIX_PIPE) */ /** * @brief This function will open the pipe and actually creates the pipe buffer. @@ -406,7 +406,7 @@ static const struct dfs_file_ops pipe_fops = * When the return value is -RT_EINVAL, it means the device handle is empty. * When the return value is -RT_ENOMEM, it means insufficient memory allocation failed. */ -rt_err_t rt_pipe_open(rt_device_t device, rt_uint16_t oflag) +static rt_err_t rt_pipe_open(rt_device_t device, rt_uint16_t oflag) { rt_pipe_t *pipe = (rt_pipe_t *)device; rt_err_t ret = RT_EOK; @@ -443,7 +443,7 @@ __exit: * When the return value is RT_EOK, the operation is successful. * When the return value is -RT_EINVAL, it means the device handle is empty. */ -rt_err_t rt_pipe_close(rt_device_t device) +static rt_err_t rt_pipe_close(rt_device_t device) { rt_pipe_t *pipe = (rt_pipe_t *)device; @@ -475,7 +475,7 @@ rt_err_t rt_pipe_close(rt_device_t device) * @return Return the length of data read. * When the return value is 0, it means the pipe device handle is empty or the count is 0. */ -rt_size_t rt_pipe_read(rt_device_t device, rt_off_t pos, void *buffer, rt_size_t count) +static rt_size_t rt_pipe_read(rt_device_t device, rt_off_t pos, void *buffer, rt_size_t count) { uint8_t *pbuf; rt_size_t read_bytes = 0; @@ -517,7 +517,7 @@ rt_size_t rt_pipe_read(rt_device_t device, rt_off_t pos, void *buffer, rt_size_t * @return Return the length of data written. * When the return value is 0, it means the pipe device handle is empty or the count is 0. */ -rt_size_t rt_pipe_write(rt_device_t device, rt_off_t pos, const void *buffer, rt_size_t count) +static rt_size_t rt_pipe_write(rt_device_t device, rt_off_t pos, const void *buffer, rt_size_t count) { uint8_t *pbuf; rt_size_t write_bytes = 0; @@ -556,7 +556,7 @@ rt_size_t rt_pipe_write(rt_device_t device, rt_off_t pos, const void *buffer, rt * * @return Always return RT_EOK yet. */ -rt_err_t rt_pipe_control(rt_device_t dev, int cmd, void *args) +static rt_err_t rt_pipe_control(rt_device_t dev, int cmd, void *args) { return RT_EOK; } @@ -623,9 +623,9 @@ rt_pipe_t *rt_pipe_create(const char *name, int bufsz) rt_free(pipe); return RT_NULL; } -#ifdef RT_USING_POSIX_DEVIO +#if defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_POSIX_PIPE) dev->fops = (void*)&pipe_fops; -#endif /* RT_USING_POSIX_DEVIO */ +#endif return pipe; } @@ -683,7 +683,7 @@ int rt_pipe_delete(const char *name) return result; } -#ifdef RT_USING_POSIX_DEVIO +#if defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_POSIX_PIPE) /** * @brief This function will creat a anonymous pipe. * @@ -701,7 +701,7 @@ int pipe(int fildes[2]) rt_snprintf(dname, sizeof(dname), "pipe%d", pipeno++); - pipe = rt_pipe_create(dname, PIPE_BUFSZ); + pipe = rt_pipe_create(dname, RT_USING_POSIX_PIPE_SIZE); if (pipe == RT_NULL) { return -1; @@ -738,7 +738,7 @@ int mkfifo(const char *path, mode_t mode) { rt_pipe_t *pipe; - pipe = rt_pipe_create(path, PIPE_BUFSZ); + pipe = rt_pipe_create(path, RT_USING_POSIX_PIPE_SIZE); if (pipe == RT_NULL) { return -1; @@ -746,4 +746,4 @@ int mkfifo(const char *path, mode_t mode) return 0; } -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_POSIX_PIPE) */ diff --git a/components/libc/compilers/common/sys/ioctl.h b/components/libc/compilers/common/sys/ioctl.h index 29ed3a8b84..a1642199b1 100644 --- a/components/libc/compilers/common/sys/ioctl.h +++ b/components/libc/compilers/common/sys/ioctl.h @@ -7,8 +7,8 @@ * Date Author Notes * 2020-09-01 Meco Man First Version */ -#ifndef _SYS_IOCTL_H -#define _SYS_IOCTL_H +#ifndef __SYS_IOCTL_H__ +#define __SYS_IOCTL_H__ #include <rtconfig.h> #include <dfs_posix.h> diff --git a/components/libc/posix/Kconfig b/components/libc/posix/Kconfig index 0afff161ff..4534da7118 100644 --- a/components/libc/posix/Kconfig +++ b/components/libc/posix/Kconfig @@ -1,7 +1,7 @@ menu "POSIX (Portable Operating System Interface) layer" config RT_USING_POSIX_FS - bool "Enable POSIX file system, open()/read()/write()/close() etc" + bool "Enable POSIX file system and I/O" select RT_USING_DFS select DFS_USING_POSIX default n @@ -13,13 +13,26 @@ if RT_USING_POSIX_FS default n config RT_USING_POSIX_POLL - bool "Enable poll()" + bool "Enable I/O Multiplexing poll() <poll.h>" default n config RT_USING_POSIX_SELECT - bool "Enable select()" + bool "Enable I/O Multiplexing select() <sys/select.h>" select RT_USING_POSIX_POLL default n + + config RT_USING_POSIX_TERMIOS + bool "Enable Terminal I/O <termios.h>" + select RT_USING_POSIX_DEVIO + default n + + config RT_USING_POSIX_AIO + bool "Enable Asynchronous I/O <aio.h>" + default n + + config RT_USING_POSIX_MMAN + bool "Enable Memory-Mapped I/O <sys/mman.h>" + default n endif config RT_USING_POSIX_DELAY @@ -32,19 +45,6 @@ config RT_USING_POSIX_GETLINE select RT_LIBC_USING_FILEIO default n -config RT_USING_POSIX_MMAP - bool "Enable mmap()" - select RT_USING_POSIX_FS - default n - -config RT_USING_POSIX_TERMIOS - bool "Enable termios APIs" - default n - -config RT_USING_POSIX_AIO - bool "Enable AIO APIs" - default n - config RT_USING_PTHREADS bool "Enable pthreads APIs" default n @@ -55,4 +55,6 @@ if RT_USING_PTHREADS default 8 endif +source "$RTT_DIR/components/libc/posix/ipc/Kconfig" + endmenu diff --git a/components/libc/posix/io/SConscript b/components/libc/posix/io/SConscript new file mode 100644 index 0000000000..32654674e8 --- /dev/null +++ b/components/libc/posix/io/SConscript @@ -0,0 +1,30 @@ +# RT-Thread building script for component + +import os +from building import * + +src = [] +cwd = GetCurrentDir() +CPPPATH = [cwd] +group = [] + +flag = False + +if GetDepend('RT_USING_POSIX_DEVIO'): + src += ['libc.c'] + flag = True + +if GetDepend('RT_USING_POSIX_SELECT'): + src += ['select.c'] + flag = True + +if flag == True: + group = DefineGroup('POSIX', src, depend = [], CPPPATH = CPPPATH) + +list = os.listdir(cwd) +for d in list: + path = os.path.join(cwd, d) + if os.path.isfile(os.path.join(path, 'SConscript')): + group = group + SConscript(os.path.join(d, 'SConscript')) + +Return('group') diff --git a/components/libc/posix/aio/SConscript b/components/libc/posix/io/aio/SConscript index 139bc45749..6d4014311c 100644 --- a/components/libc/posix/aio/SConscript +++ b/components/libc/posix/io/aio/SConscript @@ -3,7 +3,7 @@ from building import * cwd = GetCurrentDir() -src = Glob('*.c') +src = ['aio.c'] CPPPATH = [cwd] group = DefineGroup('POSIX', src, depend = ['RT_USING_POSIX_AIO'], CPPPATH = CPPPATH) diff --git a/components/libc/posix/aio/posix_aio.c b/components/libc/posix/io/aio/aio.c index 66cced8687..08ef4c634a 100644 --- a/components/libc/posix/aio/posix_aio.c +++ b/components/libc/posix/io/aio/aio.c @@ -11,7 +11,7 @@ #include <stdint.h> #include <rthw.h> #include <dfs_posix.h> -#include "posix_aio.h" +#include "aio.h" struct rt_workqueue* aio_queue = NULL; diff --git a/components/libc/posix/aio/posix_aio.h b/components/libc/posix/io/aio/aio.h index 4e25e1d15b..35a5c194db 100644 --- a/components/libc/posix/aio/posix_aio.h +++ b/components/libc/posix/io/aio/aio.h @@ -8,8 +8,8 @@ * 2017/12/30 Bernard The first version. */ -#ifndef POSIX_AIO_H__ -#define POSIX_AIO_H__ +#ifndef __AIO_H__ +#define __AIO_H__ #include <stdio.h> #include <sys/signal.h> diff --git a/components/libc/posix/src/libc.c b/components/libc/posix/io/libc.c index c324d84ef8..c324d84ef8 100644 --- a/components/libc/posix/src/libc.c +++ b/components/libc/posix/io/libc.c diff --git a/components/libc/posix/src/libc.h b/components/libc/posix/io/libc.h index b019267926..b019267926 100644 --- a/components/libc/posix/src/libc.h +++ b/components/libc/posix/io/libc.h diff --git a/components/libc/posix/io/mman/SConscript b/components/libc/posix/io/mman/SConscript new file mode 100644 index 0000000000..7dd096c998 --- /dev/null +++ b/components/libc/posix/io/mman/SConscript @@ -0,0 +1,11 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = ['mman.c'] +CPPPATH = [cwd] + +group = DefineGroup('POSIX', src, depend = ['RT_USING_POSIX_MMAN'], CPPPATH = CPPPATH) + +Return('group') diff --git a/components/libc/posix/src/mmap.c b/components/libc/posix/io/mman/mman.c index e68b82e640..827f2cbb14 100644 --- a/components/libc/posix/src/mmap.c +++ b/components/libc/posix/io/mman/mman.c @@ -14,7 +14,7 @@ #include <rtthread.h> #include <dfs_posix.h> -#include <sys/mman.h> +#include "sys/mman.h" void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) diff --git a/components/libc/compilers/common/sys/mman.h b/components/libc/posix/io/mman/sys/mman.h index 2da2ddf716..a730f33b6b 100644 --- a/components/libc/compilers/common/sys/mman.h +++ b/components/libc/posix/io/mman/sys/mman.h @@ -8,8 +8,8 @@ * 2017/11/30 Bernard The first version. */ -#ifndef _SYS_MMAN_H -#define _SYS_MMAN_H +#ifndef __SYS_MMAN_H__ +#define __SYS_MMAN_H__ #ifdef __cplusplus extern "C" { diff --git a/components/libc/posix/io/poll/SConscript b/components/libc/posix/io/poll/SConscript new file mode 100644 index 0000000000..7d82ade035 --- /dev/null +++ b/components/libc/posix/io/poll/SConscript @@ -0,0 +1,14 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = [] +CPPPATH = [cwd] + +if GetDepend('RT_USING_POSIX_POLL'): + src += ['poll.c'] + +group = DefineGroup('POSIX', src, depend = [], CPPPATH = CPPPATH) + +Return('group') diff --git a/components/libc/posix/src/poll.c b/components/libc/posix/io/poll/poll.c index 0c773b306c..a1500ba109 100644 --- a/components/libc/posix/src/poll.c +++ b/components/libc/posix/io/poll/poll.c @@ -12,7 +12,7 @@ #include <rthw.h> #include <rtthread.h> #include <dfs_file.h> -#include <poll.h> +#include "poll.h" struct rt_poll_node; diff --git a/components/libc/compilers/common/poll.h b/components/libc/posix/io/poll/poll.h index aea73d6eaf..aea73d6eaf 100644 --- a/components/libc/compilers/common/poll.h +++ b/components/libc/posix/io/poll/poll.h diff --git a/components/libc/posix/src/select.c b/components/libc/posix/io/select.c index 55d320e921..55d320e921 100644 --- a/components/libc/posix/src/select.c +++ b/components/libc/posix/io/select.c diff --git a/components/libc/posix/io/termios/SConscript b/components/libc/posix/io/termios/SConscript new file mode 100644 index 0000000000..68bd9d81c9 --- /dev/null +++ b/components/libc/posix/io/termios/SConscript @@ -0,0 +1,11 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = ['termios.c'] +CPPPATH = [cwd] + +group = DefineGroup('POSIX', src, depend = ['RT_USING_POSIX_TERMIOS'], CPPPATH = CPPPATH) + +Return('group') diff --git a/components/libc/posix/termios/posix_termios.c b/components/libc/posix/io/termios/termios.c index 9f33c857e6..d7d869d67f 100644 --- a/components/libc/posix/termios/posix_termios.c +++ b/components/libc/posix/io/termios/termios.c @@ -11,7 +11,7 @@ #include <string.h> #include <dfs_posix.h> #include <sys/errno.h> -#include <termios.h> +#include "termios.h" int tcgetattr(int fd, struct termios *tio) { diff --git a/components/libc/posix/termios/posix_termios.h b/components/libc/posix/io/termios/termios.h index 6dc5531955..b647fa0728 100644 --- a/components/libc/posix/termios/posix_termios.h +++ b/components/libc/posix/io/termios/termios.h @@ -7,8 +7,8 @@ * Date Author Notes * 2017/08/30 Bernard The first version */ -#ifndef TERMIOS_H__ -#define TERMIOS_H__ +#ifndef __TERMIOS_H__ +#define __TERMIOS_H__ #include <sys/types.h> #include <sys/ioctl.h> diff --git a/components/libc/posix/ipc/Kconfig b/components/libc/posix/ipc/Kconfig new file mode 100644 index 0000000000..f5ec6ad040 --- /dev/null +++ b/components/libc/posix/ipc/Kconfig @@ -0,0 +1,17 @@ +menu "Interprocess Communication (IPC)" + +config RT_USING_POSIX_PIPE + bool "Enable pipe and FIFO" + select RT_USING_POSIX_FS + select RT_USING_POSIX_DEVIO + select RT_USING_POSIX_POLL + default n + +config RT_USING_POSIX_PIPE_SIZE + int "Set pipe buffer size" + depends on RT_USING_POSIX_PIPE + default 512 + +comment "Socket is in the 'Network' category" + +endmenu diff --git a/components/libc/compilers/common/sys/termios.h b/components/libc/posix/ipc/sys/ipc.h index c4b42083c4..03b5458d51 100644 --- a/components/libc/compilers/common/sys/termios.h +++ b/components/libc/posix/ipc/sys/ipc.h @@ -5,4 +5,11 @@ * * Change Logs: * Date Author Notes + * 2021-12-07 Meco Man First version */ +#ifndef __SYS_IPC_H__ +#define __SYS_IPC_H__ + + + +#endif diff --git a/components/libc/compilers/common/termios.h b/components/libc/posix/ipc/sys/msg.h index 2960d52c58..c030c9e8cb 100644 --- a/components/libc/compilers/common/termios.h +++ b/components/libc/posix/ipc/sys/msg.h @@ -5,15 +5,11 @@ * * Change Logs: * Date Author Notes + * 2021-12-07 Meco Man First version */ -#ifndef _TERMIOS_H__ -#define _TERMIOS_H__ +#ifndef __SYS_MSG_H__ +#define __SYS_MSG_H__ -#include <rtconfig.h> -#ifdef RT_USING_POSIX_TERMIOS -#include <sys/types.h> -#include <posix_termios.h> -#endif #endif diff --git a/components/libc/posix/ipc/sys/sem.h b/components/libc/posix/ipc/sys/sem.h new file mode 100644 index 0000000000..b849bd687d --- /dev/null +++ b/components/libc/posix/ipc/sys/sem.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-12-07 Meco Man First version + */ +#ifndef __SYS_SEM_H__ +#define __SYS_SEM_H__ + + + +#endif diff --git a/components/libc/posix/ipc/sys/shm.h b/components/libc/posix/ipc/sys/shm.h new file mode 100644 index 0000000000..762d68891a --- /dev/null +++ b/components/libc/posix/ipc/sys/shm.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-12-07 Meco Man First version + */ +#ifndef __SYS_SHM_H__ +#define __SYS_SHM_H__ + + + +#endif diff --git a/components/libc/posix/src/SConscript b/components/libc/posix/src/SConscript index 4be5ac83cc..87be6b6a06 100644 --- a/components/libc/posix/src/SConscript +++ b/components/libc/posix/src/SConscript @@ -10,26 +10,10 @@ group = [] flag = False src += ['unistd.c'] #TODO -if GetDepend('RT_USING_POSIX_DEVIO'): - src += ['libc.c'] - flag = True - if GetDepend('RT_USING_POSIX_DELAY'): src += ['delay.c'] flag = True -if GetDepend('RT_USING_POSIX_POLL'): - src += ['poll.c'] - flag = True - -if GetDepend('RT_USING_POSIX_SELECT'): - src += ['select.c'] - flag = True - -if GetDepend('RT_USING_POSIX_MMAP'): - src += ['mmap.c'] - flag = True - if flag == True: group = DefineGroup('POSIX', src, depend = [], CPPPATH = CPPPATH) diff --git a/components/libc/posix/termios/SConscript b/components/libc/posix/termios/SConscript deleted file mode 100644 index 3615926251..0000000000 --- a/components/libc/posix/termios/SConscript +++ /dev/null @@ -1,11 +0,0 @@ -# RT-Thread building script for component - -from building import * - -cwd = GetCurrentDir() -src = Glob('*.c') + Glob('*.cpp') -CPPPATH = [cwd] - -group = DefineGroup('POSIX', src, depend = ['RT_USING_LIBC', 'RT_USING_POSIX_TERMIOS'], CPPPATH = CPPPATH) - -Return('group') diff --git a/components/net/at/src/at_cli.c b/components/net/at/src/at_cli.c index c589bb68a0..d51358d863 100644 --- a/components/net/at/src/at_cli.c +++ b/components/net/at/src/at_cli.c @@ -264,6 +264,10 @@ static void client_cli_parser(at_client_t client) } else { + if(cur_line_len >= FINSH_CMD_SIZE) + { + continue; + } rt_kprintf("%c", ch); cur_line[cur_line_len++] = ch; } |
