sync branch rt-smart. (#6641)

* Synchronize the code of the rt mart branch to the master branch.
  * TTY device
  * Add lwP code from rt-smart
  * Add vnode in DFS, but DFS will be re-write for rt-smart
  * There are three libcpu for rt-smart:
    * arm/cortex-a, arm/aarch64
    * riscv64

Co-authored-by: Rbb666 <zhangbingru@rt-thread.com>
Co-authored-by: zhkag <zhkag@foxmail.com>
This commit is contained in:
guo
2022-12-03 12:07:44 +08:00
committed by GitHub
parent aaf5462c6d
commit ecf2d82159
1693 changed files with 389530 additions and 9680 deletions

View File

@@ -153,6 +153,11 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#define RT_MB_ENTRY_MAX RT_UINT16_MAX /**< Maximum number of mailbox .entry */
#define RT_MQ_ENTRY_MAX RT_UINT16_MAX /**< Maximum number of message queue .entry */
/* Common Utilities */
#define _RT_STRINGIFY(x...) #x
#define RT_STRINGIFY(x...) _RT_STRINGIFY(x)
#define RT_UNUSED(x) ((void)x)
/* Compiler Related Definitions */
@@ -351,6 +356,7 @@ typedef int (*init_fn_t)(void);
#define RT_EIO 8 /**< IO error */
#define RT_EINTR 9 /**< Interrupted system call */
#define RT_EINVAL 10 /**< Invalid argument */
#define RT_ETRAP 11 /**< trap event */
/**@}*/
@@ -414,6 +420,11 @@ struct rt_object
#ifdef RT_USING_MODULE
void *module_id; /**< id of application module */
#endif /* RT_USING_MODULE */
#ifdef RT_USING_LWP
int lwp_ref_count; /**< ref count for lwp */
#endif /* RT_USING_LWP */
rt_list_t list; /**< list node of kernel object */
};
typedef struct rt_object *rt_object_t; /**< Type for kernel objects. */
@@ -450,7 +461,9 @@ enum rt_object_class_type
RT_Object_Class_Timer = 0x0a, /**< The object is a timer. */
RT_Object_Class_Module = 0x0b, /**< The object is a module. */
RT_Object_Class_Memory = 0x0c, /**< The object is a memory. */
RT_Object_Class_Unknown = 0x0e, /**< The object is unknown. */
RT_Object_Class_Channel = 0x0d, /**< The object is a channel */
RT_Object_Class_Custom = 0x0e, /**< The object is a custom object */
RT_Object_Class_Unknown = 0x0f, /**< The object is unknown. */
RT_Object_Class_Static = 0x80 /**< The object is a static object. */
};
@@ -515,6 +528,10 @@ struct rt_object_information
#define RT_TIMER_CTRL_SET_PERIODIC 0x3 /**< change timer to periodic */
#define RT_TIMER_CTRL_GET_STATE 0x4 /**< get timer run state active or deactive*/
#define RT_TIMER_CTRL_GET_REMAIN_TIME 0x5 /**< get the remaining hang time */
#define RT_TIMER_CTRL_GET_FUNC 0x6 /**< get timer timeout func */
#define RT_TIMER_CTRL_SET_FUNC 0x7 /**< set timer timeout func */
#define RT_TIMER_CTRL_GET_PARM 0x8 /**< get timer parameter */
#define RT_TIMER_CTRL_SET_PARM 0x9 /**< get timer parameter */
#ifndef RT_TIMER_SKIP_LIST_LEVEL
#define RT_TIMER_SKIP_LIST_LEVEL 1
@@ -553,8 +570,14 @@ typedef unsigned long rt_sigset_t;
typedef siginfo_t rt_siginfo_t;
typedef void (*rt_sighandler_t)(int signo);
#define RT_SIG_MAX 32
#else
#ifdef RT_USING_LWP
#include <sys/signal.h>
#endif
#endif /* RT_USING_SIGNALS */
/**@}*/
@@ -571,12 +594,30 @@ typedef void (*rt_sighandler_t)(int signo);
/*
* thread state definitions
*/
#define RT_THREAD_INIT 0x00 /**< Initialized status */
#define RT_THREAD_READY 0x01 /**< Ready status */
#define RT_THREAD_SUSPEND 0x02 /**< Suspend status */
#define RT_THREAD_RUNNING 0x03 /**< Running status */
#define RT_THREAD_CLOSE 0x04 /**< Closed status */
#define RT_THREAD_STAT_MASK 0x07
#define RT_THREAD_INIT 0x00 /**< Initialized status */
#define RT_THREAD_CLOSE 0x01 /**< Closed status */
#define RT_THREAD_READY 0x02 /**< Ready status */
#define RT_THREAD_RUNNING 0x03 /**< Running status */
/*
* for rt_thread_suspend_with_flag()
*/
enum
{
RT_INTERRUPTIBLE = 0,
RT_KILLABLE,
RT_UNINTERRUPTIBLE,
};
#define RT_THREAD_SUSPEND_MASK 0x04
#define RT_SIGNAL_COMMON_WAKEUP_MASK 0x02
#define RT_SIGNAL_KILL_WAKEUP_MASK 0x01
#define RT_THREAD_SUSPEND_INTERRUPTIBLE (RT_THREAD_SUSPEND_MASK) /**< Suspend interruptable 0x4 */
#define RT_THREAD_SUSPEND RT_THREAD_SUSPEND_INTERRUPTIBLE
#define RT_THREAD_SUSPEND_KILLABLE (RT_THREAD_SUSPEND_MASK | RT_SIGNAL_COMMON_WAKEUP_MASK) /**< Suspend with killable 0x6 */
#define RT_THREAD_SUSPEND_UNINTERRUPTIBLE (RT_THREAD_SUSPEND_MASK | RT_SIGNAL_COMMON_WAKEUP_MASK | RT_SIGNAL_KILL_WAKEUP_MASK) /**< Suspend with uninterruptable 0x7 */
#define RT_THREAD_STAT_MASK 0x07
#define RT_THREAD_STAT_YIELD 0x08 /**< indicate whether remaining_tick has been reloaded since last schedule */
#define RT_THREAD_STAT_YIELD_MASK RT_THREAD_STAT_YIELD
@@ -634,6 +675,51 @@ struct rt_cpu
#endif /* RT_USING_SMP */
struct rt_thread;
#ifdef RT_USING_LWP
typedef rt_err_t (*rt_wakeup_func_t)(void *object, struct rt_thread *thread);
struct rt_wakeup
{
rt_wakeup_func_t func;
void *user_data;
};
#define _LWP_NSIG 64
#ifdef ARCH_CPU_64BIT
#define _LWP_NSIG_BPW 64
#else
#define _LWP_NSIG_BPW 32
#endif
#define _LWP_NSIG_WORDS (_LWP_NSIG / _LWP_NSIG_BPW)
typedef void (*lwp_sighandler_t)(int);
typedef struct {
unsigned long sig[_LWP_NSIG_WORDS];
} lwp_sigset_t;
struct lwp_sigaction {
union {
void (*_sa_handler)(int);
void (*_sa_sigaction)(int, siginfo_t *, void *);
} __sa_handler;
lwp_sigset_t sa_mask;
int sa_flags;
void (*sa_restorer)(void);
};
struct rt_user_context
{
void *sp;
void *pc;
void *flag;
};
#endif
/**
* Thread structure
*/
@@ -648,6 +734,10 @@ struct rt_thread
void *module_id; /**< id of application module */
#endif /* RT_USING_MODULE */
#ifdef RT_USING_LWP
int lwp_ref_count; /**< ref count for lwp */
#endif /* RT_USING_LWP */
rt_list_t list; /**< the object list */
rt_list_t tlist; /**< the thread list */
@@ -704,6 +794,10 @@ struct rt_thread
void *si_list; /**< the signal infor list */
#endif /* RT_USING_SIGNALS */
#if defined(RT_USING_LWP)
void *msg_ret; /**< the return msg */
#endif
rt_ubase_t init_tick; /**< thread's initialized tick */
rt_ubase_t remaining_tick; /**< remaining tick */
@@ -722,7 +816,35 @@ struct rt_thread
/* light weight process if present */
#ifdef RT_USING_LWP
void *lwp;
#endif /* RT_USING_LWP */
/* for user create */
void *user_entry;
void *user_stack;
rt_uint32_t user_stack_size;
rt_uint32_t *kernel_sp; /**< kernel stack point */
rt_list_t sibling; /**< next thread of same process */
lwp_sigset_t signal;
lwp_sigset_t signal_mask;
int signal_mask_bak;
rt_uint32_t signal_in_process;
#ifndef ARCH_MM_MMU
lwp_sighandler_t signal_handler[32];
#endif
struct rt_user_context user_ctx;
struct rt_wakeup wakeup; /**< wakeup data */
int exit_request;
#ifdef RT_USING_USERSPACE
int step_exec;
int debug_attach_req;
int debug_ret_user;
int debug_suspend;
struct rt_hw_exp_stack *regs;
void * thread_idr; /** lwp thread indicator */
int *clear_child_tid;
#endif
int tid;
#endif
rt_ubase_t user_data; /**< private user data beyond this thread */
};
@@ -744,6 +866,7 @@ typedef struct rt_thread *rt_thread_t;
#define RT_IPC_CMD_UNKNOWN 0x00 /**< unknown IPC command */
#define RT_IPC_CMD_RESET 0x01 /**< reset IPC object */
#define RT_IPC_CMD_GET_STATE 0x02 /**< get the state of IPC object */
#define RT_WAITING_FOREVER -1 /**< Block forever until get resource. */
#define RT_WAITING_NO 0 /**< Non-block. */
@@ -1001,6 +1124,7 @@ enum rt_device_class_type
RT_Device_Class_DAC, /**< DAC device */
RT_Device_Class_WDT, /**< WDT device */
RT_Device_Class_PWM, /**< PWM device */
RT_Device_Class_Bus, /**< Bus device */
RT_Device_Class_Unknown /**< unknown device */
};
@@ -1033,15 +1157,20 @@ enum rt_device_class_type
/**
* general device commands
* 0x01 - 0x1F general device control commands
* 0x20 - 0x3F udevice control commands
* 0x40 - special device control commands
*/
#define RT_DEVICE_CTRL_RESUME 0x01 /**< resume device */
#define RT_DEVICE_CTRL_SUSPEND 0x02 /**< suspend device */
#define RT_DEVICE_CTRL_CONFIG 0x03 /**< configure device */
#define RT_DEVICE_CTRL_CLOSE 0x04 /**< close device */
#define RT_DEVICE_CTRL_SET_INT 0x10 /**< set interrupt */
#define RT_DEVICE_CTRL_CLR_INT 0x11 /**< clear interrupt */
#define RT_DEVICE_CTRL_GET_INT 0x12 /**< get interrupt status */
#define RT_DEVICE_CTRL_NOTIFY_SET 0x05 /**< set notify func */
#define RT_DEVICE_CTRL_SET_INT 0x06 /**< set interrupt */
#define RT_DEVICE_CTRL_CLR_INT 0x07 /**< clear interrupt */
#define RT_DEVICE_CTRL_GET_INT 0x08 /**< get interrupt status */
#define RT_DEVICE_CTRL_CONSOLE_OFLAG 0x09 /**< get console open flag */
#define RT_DEVICE_CTRL_MASK 0x1f /**< mask for contrl commands */
/**
* device control
@@ -1051,12 +1180,17 @@ enum rt_device_class_type
/**
* special device commands
*/
/* character device */
#define RT_DEVICE_CTRL_CHAR_STREAM (RT_DEVICE_CTRL_BASE(Char) + 1) /**< stream mode on char device */
/* block device */
#define RT_DEVICE_CTRL_BLK_GETGEOME (RT_DEVICE_CTRL_BASE(Block) + 1) /**< get geometry information */
#define RT_DEVICE_CTRL_BLK_SYNC (RT_DEVICE_CTRL_BASE(Block) + 2) /**< flush data to block device */
#define RT_DEVICE_CTRL_BLK_ERASE (RT_DEVICE_CTRL_BASE(Block) + 3) /**< erase block on block device */
#define RT_DEVICE_CTRL_BLK_AUTOREFRESH (RT_DEVICE_CTRL_BASE(Block) + 4) /**< block device : enter/exit auto refresh mode */
#define RT_DEVICE_CTRL_BLK_PARTITION (RT_DEVICE_CTRL_BASE(Block) + 5) /**< get block device partition */
/* net interface device*/
#define RT_DEVICE_CTRL_NETIF_GETMAC (RT_DEVICE_CTRL_BASE(NetIf) + 1) /**< get mac address */
/* mtd interface device*/
#define RT_DEVICE_CTRL_MTD_FORMAT (RT_DEVICE_CTRL_BASE(MTD) + 1) /**< format a MTD device */
typedef struct rt_device *rt_device_t;
@@ -1093,7 +1227,10 @@ typedef struct rt_wqueue rt_wqueue_t;
struct rt_device
{
struct rt_object parent; /**< inherit from rt_object */
#ifdef RT_USING_DM
struct rt_driver *drv;
void *dtb_node;
#endif
enum rt_device_class_type type; /**< device type */
rt_uint16_t flag; /**< device flag */
rt_uint16_t open_flag; /**< device open flag */
@@ -1125,12 +1262,69 @@ struct rt_device
void *user_data; /**< device private data */
};
#define RT_DRIVER_MATCH_DTS (1<<0)
struct rt_device_id
{
const char *compatible;
void *data;
};
struct rt_driver
{
#ifdef RT_USING_DEVICE_OPS
const struct rt_device_ops *dev_ops;
#else
/* common device interface */
rt_err_t (*init) (rt_device_t dev);
rt_err_t (*open) (rt_device_t dev, rt_uint16_t oflag);
rt_err_t (*close) (rt_device_t dev);
rt_size_t (*read) (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size);
rt_size_t (*write) (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
rt_err_t (*control)(rt_device_t dev, int cmd, void *args);
#endif
const struct filesystem_ops *fops;
const char *name;
enum rt_device_class_type dev_type;
int device_size;
int flag;
const struct rt_device_id *dev_match;
int (*probe)(struct rt_device *dev);
int (*probe_init)(struct rt_device *dev);
int (*remove)(struct rt_device *dev);
const void *ops; /* driver-specific operations */
void *drv_priv_data;
};
typedef struct rt_driver *rt_driver_t;
/**
* Notify structure
*/
struct rt_device_notify
{
void (*notify)(rt_device_t dev);
struct rt_device *dev;
};
#ifdef RT_USING_LWP
struct rt_channel
{
struct rt_ipc_object parent; /**< inherit from object */
struct rt_thread *reply; /**< the thread will be reply */
rt_list_t wait_msg; /**< the wait queue of sender msg */
rt_list_t wait_thread; /**< the wait queue of sender thread */
rt_wqueue_t reader_queue; /**< channel poll queue */
rt_uint8_t stat; /**< the status of this channel */
rt_ubase_t ref;
};
typedef struct rt_channel *rt_channel_t;
#endif
/**
* block device geometry structure
*/
struct rt_device_blk_geometry
{
rt_uint32_t sector_count; /**< count of sectors */
rt_uint64_t sector_count; /**< count of sectors */
rt_uint32_t bytes_per_sector; /**< number of bytes per sector */
rt_uint32_t block_size; /**< number of bytes to erase one block */
};
@@ -1140,8 +1334,8 @@ struct rt_device_blk_geometry
*/
struct rt_device_blk_sectors
{
rt_uint32_t sector_begin; /**< begin sector */
rt_uint32_t sector_end; /**< end sector */
rt_uint64_t sector_begin; /**< begin sector */
rt_uint64_t sector_end; /**< end sector */
};
/**