First commit XiUOS

This commit is contained in:
xuetest
2021-04-28 17:49:18 +08:00
commit 6001051eb7
1331 changed files with 433955 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
SRC_DIR :=
ifeq ($(CONFIG_POSIX_API),y)
SRC_DIR += posix_support
endif
ifeq ($(CONFIG_SEPARATE_COMPILE),y)
SRC_DIR += switch_api
SRC_DIR += general_functions
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -0,0 +1,3 @@
SRC_DIR := linklist
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -0,0 +1,3 @@
SRC_FILES := double_linklist.c single_linklist.c
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: double_link.c
* @brief: functions definition of double linklist for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/3/15
*
*/
#include "xs_klist.h"
void InitDoubleLinkList(DoubleLinklistType *linklist_head)
{
linklist_head->node_next = linklist_head;
linklist_head->node_prev = linklist_head;
}
void DoubleLinkListInsertNodeAfter(DoubleLinklistType *linklist, DoubleLinklistType *linklist_node)
{
linklist->node_next->node_prev = linklist_node;
linklist_node->node_next = linklist->node_next;
linklist->node_next = linklist_node;
linklist_node->node_prev = linklist;
}
void DoubleLinkListInsertNodeBefore(DoubleLinklistType *linklist, DoubleLinklistType *linklist_node)
{
linklist->node_prev->node_next = linklist_node;
linklist_node->node_prev = linklist->node_prev;
linklist->node_prev = linklist_node;
linklist_node->node_next = linklist;
}
void DoubleLinkListRmNode(DoubleLinklistType *linklist_node)
{
linklist_node->node_next->node_prev = linklist_node->node_prev;
linklist_node->node_prev->node_next = linklist_node->node_next;
linklist_node->node_next = linklist_node;
linklist_node->node_prev = linklist_node;
}
int IsDoubleLinkListEmpty(const DoubleLinklistType *linklist)
{
return linklist->node_next == linklist;
}
struct SysDoubleLinklistNode *DoubleLinkListGetHead(const DoubleLinklistType *linklist)
{
return IsDoubleLinkListEmpty(linklist) ? NULL : linklist->node_next;
}
struct SysDoubleLinklistNode *DoubleLinkListGetNext(const DoubleLinklistType *linklist,
const struct SysDoubleLinklistNode *linklist_node)
{
return linklist_node->node_next == linklist ? NULL : linklist_node->node_next;
}
unsigned int DoubleLinkListLenGet(const DoubleLinklistType *linklist)
{
unsigned int linklist_length = 0;
const DoubleLinklistType *tmp_node = linklist;
while (tmp_node->node_next != linklist)
{
tmp_node = tmp_node->node_next;
linklist_length ++;
}
return linklist_length;
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: double_link.c
* @brief: functions definition of single linklist for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/3/15
*
*/
#include "xs_klist.h"
void InitSingleLinkList(SysSingleLinklistType *linklist)
{
linklist->node_next = NONE;
}
void AppendSingleLinkList(SysSingleLinklistType *linklist, SysSingleLinklistType *linklist_node)
{
struct SingleLinklistNode *node;
node = linklist;
while (node->node_next) node = node->node_next;
node->node_next = linklist_node;
linklist_node->node_next = NONE;
}
void SingleLinkListNodeInsert(SysSingleLinklistType *linklist, SysSingleLinklistType *linklist_node)
{
linklist_node->node_next = linklist->node_next;
linklist->node_next = linklist_node;
}
unsigned int SingleLinkListGetLen(const SysSingleLinklistType *linklist)
{
unsigned int length = 0;
const SysSingleLinklistType *tmp_list = linklist->node_next;
while (tmp_list != NONE)
{
tmp_list = tmp_list->node_next;
length ++;
}
return length;
}
SysSingleLinklistType *SingleLinkListRmNode(SysSingleLinklistType *linklist, SysSingleLinklistType *linklist_node)
{
struct SingleLinklistNode *node = linklist;
while (node->node_next && node->node_next != linklist_node) node = node->node_next;
if (node->node_next != (SysSingleLinklistType *)0){
node->node_next = node->node_next->node_next;
}
return linklist;
}
SysSingleLinklistType *SingleLinkListGetFirstNode(SysSingleLinklistType *linklist)
{
return linklist->node_next;
}
SysSingleLinklistType *SingleLinkListGetTailNode(SysSingleLinklistType *linklist)
{
while (linklist->node_next) linklist = linklist->node_next;
return linklist;
}
SysSingleLinklistType *SingleLinkListGetNextNode(SysSingleLinklistType *linklist_node)
{
return linklist_node->node_next;
}
int IsSingleLinkListEmpty(SysSingleLinklistType *linklist)
{
return linklist->node_next == NONE;
}

View File

@@ -0,0 +1,129 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: xs_klist.h
* @brief: function declaration and structure defintion of linklist
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/3/2
*
*/
#ifndef __XS_KLIST_H__
#define __XS_KLIST_H__
#include "../../kernel/include/xs_base.h"
#include "libc.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LINKLIST_FLAG_FIFO 0x00
#define LINKLIST_FLAG_PRIO 0x01
typedef struct SysDoubleLinklistNode
{
struct SysDoubleLinklistNode *node_next;
struct SysDoubleLinklistNode *node_prev;
} DoubleLinklistType;
// Single List
typedef struct SingleLinklistNode
{
struct SingleLinklistNode *node_next;
} SysSingleLinklistType;
struct CommonMember
{
char name[NAME_NUM_MAX];
uint8 type;
uint8 flag;
DoubleLinklistType list;
};
#define CONTAINER_OF(item, type, member) \
((type *)((char *)(item) - (unsigned long)(&((type *)0)->member)))
#define DOUBLE_LINKLIST_OBJ_INIT(obj) { &(obj), &(obj) }
void InitDoubleLinkList(DoubleLinklistType *linklist_head);
void DoubleLinkListInsertNodeAfter(DoubleLinklistType *linklist, DoubleLinklistType *linklist_node);
void DoubleLinkListInsertNodeBefore(DoubleLinklistType *linklist, DoubleLinklistType *linklist_node);
void DoubleLinkListRmNode(DoubleLinklistType *linklist_node);
int IsDoubleLinkListEmpty(const DoubleLinklistType *linklist);
struct SysDoubleLinklistNode *DoubleLinkListGetHead(const DoubleLinklistType *linklist);
struct SysDoubleLinklistNode *DoubleLinkListGetNext(const DoubleLinklistType *linklist,
const struct SysDoubleLinklistNode *linklist_node);
unsigned int DoubleLinkListLenGet(const DoubleLinklistType *linklist);
#define SYS_DOUBLE_LINKLIST_ENTRY(item, type, member) \
CONTAINER_OF(item, type, member)
#define DOUBLE_LINKLIST_FOR_EACH(item, head) \
for (item = (head)->node_next; item != (head); item = item->node_next)
#define DOUBLE_LINKLIST_FOR_EACH_SAFE(item, node_next, head) \
for (item = (head)->node_next, node_next = item->node_next; item != (head); \
item = node_next, node_next = item->node_next)
#define DOUBLE_LINKLIST_FOR_EACH_ENTRY(item, head, member) \
for (item = SYS_DOUBLE_LINKLIST_ENTRY((head)->node_next, typeof(*item), member); \
&item->member != (head); \
item = SYS_DOUBLE_LINKLIST_ENTRY(item->member.node_next, typeof(*item), member))
#define DOUBLE_LINKLIST_FOR_EACH_ENTRY_SAFE(item, node_next, head, member) \
for (item = SYS_DOUBLE_LINKLIST_ENTRY((head)->node_next, typeof(*item), member), \
node_next = SYS_DOUBLE_LINKLIST_ENTRY(item->member.node_next, typeof(*item), member); \
&item->member != (head); \
item = node_next, node_next = SYS_DOUBLE_LINKLIST_ENTRY(node_next->member.node_next, typeof(*node_next), member))
#define DOUBLE_LINKLIST_FIRST_ENTRY(ptr, type, member) \
SYS_DOUBLE_LINKLIST_ENTRY((ptr)->node_next, type, member)
#define SYS_SINGLE_LINKLIST_OBJ_INIT(obj) { NONE }
void InitSingleLinkList(SysSingleLinklistType *linklist);
void AppendSingleLinkList(SysSingleLinklistType *linklist, SysSingleLinklistType *linklist_node);
void SingleLinkListNodeInsert(SysSingleLinklistType *linklist, SysSingleLinklistType *linklist_node);
unsigned int SingleLinkListGetLen(const SysSingleLinklistType *linklist);
SysSingleLinklistType *SingleLinkListRmNode(SysSingleLinklistType *linklist, SysSingleLinklistType *linklist_node);
SysSingleLinklistType *SingleLinkListGetFirstNode(SysSingleLinklistType *linklist);
SysSingleLinklistType *SingleLinkListGetTailNode(SysSingleLinklistType *linklist);
SysSingleLinklistType *SingleLinkListGetNextNode(SysSingleLinklistType *linklist_node);
int IsSingleLinkListEmpty(SysSingleLinklistType *linklist);
#define SYS_SINGLE_LINKLIST_ENTRY(node, type, member) \
CONTAINER_OF(node, type, member)
#define SINGLE_LINKLIST_FOR_EACH(item, head) \
for (item = (head)->node_next; item != NONE; item = item->node_next)
#define SINGLE_LINKLIST_FOR_EACH_ENTRY(item, head, member) \
for (item = SYS_SINGLE_LINKLIST_ENTRY((head)->node_next, typeof(*item), member); \
&item->member != (NONE); \
item = SYS_SINGLE_LINKLIST_ENTRY(item->member.node_next, typeof(*item), member))
#define SINGLE_LINKLIST_FIRST_ENTRY(ptr, type, member) \
SYS_SINGLE_LINKLIST_ENTRY((ptr)->node_next, type, member)
#define SINGLE_LINKLIST_TAIL_ENTRY(ptr, type, member) \
SYS_SINGLE_LINKLIST_ENTRY(SingleLinkListGetTailNode(ptr), type, member)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file bus.h
* @brief define bus driver framework function and common API
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-04-24
*/
#ifndef BUS_H
#define BUS_H
#ifdef __cplusplus
extern "C" {
#endif
#define OPE_INT 0x0000
#define OPE_CFG 0x0001
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file bus_serial.h
* @brief define serial bus and drv function using bus driver framework
* @version 1.0
* @author AIIT XUOS Lab
* @date
*/
#ifndef BUS_SERIAL_H
#define BUS_SERIAL_H
#include <xs_klist.h>
#ifdef __cplusplus
extern "C" {
#endif
enum ExtSerialPortConfigure
{
PORT_CFG_INIT = 0,
PORT_CFG_PARITY_CHECK,
PORT_CFG_DISABLE,
PORT_CFG_DIV,
};
struct SerialDataCfg
{
uint32 serial_baud_rate;
uint8 serial_data_bits;
uint8 serial_stop_bits;
uint8 serial_parity_mode;
uint8 serial_bit_order;
uint8 serial_invert_mode;
uint16 serial_buffer_size;
uint8 ext_uart_no;
enum ExtSerialPortConfigure port_configure;
};
struct SerialHwCfg
{
uint32 serial_register_base;
uint32 serial_irq_interrupt;
void *private_data;
};
struct SerialCfgParam
{
struct SerialDataCfg data_cfg;
struct SerialHwCfg hw_cfg;
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file dev_serial.h
* @brief define serial dev function using bus driver framework
* @version 1.0
* @author AIIT XUOS Lab
* @date
*/
#ifndef DEV_SERIAL_H
#define DEV_SERIAL_H
#ifdef __cplusplus
extern "C" {
#endif
#define BAUD_RATE_2400 2400
#define BAUD_RATE_4800 4800
#define BAUD_RATE_9600 9600
#define BAUD_RATE_19200 19200
#define BAUD_RATE_38400 38400
#define BAUD_RATE_57600 57600
#define BAUD_RATE_115200 115200
#define BAUD_RATE_230400 230400
#define BAUD_RATE_460800 460800
#define BAUD_RATE_921600 921600
#define BAUD_RATE_2000000 2000000
#define BAUD_RATE_3000000 3000000
#define DATA_BITS_5 5
#define DATA_BITS_6 6
#define DATA_BITS_7 7
#define DATA_BITS_8 8
#define DATA_BITS_9 9
#define STOP_BITS_1 1
#define STOP_BITS_2 2
#define STOP_BITS_3 3
#define STOP_BITS_4 4
#define PARITY_NONE 1
#define PARITY_ODD 2
#define PARITY_EVEN 3
#define BIT_ORDER_LSB 1
#define BIT_ORDER_MSB 2
#define NRZ_NORMAL 1
#define NRZ_INVERTED 2
#ifndef SERIAL_RB_BUFSZ
#define SERIAL_RB_BUFSZ 128
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,4 @@
config POSIX_API
bool "support posix api"
default n

View File

@@ -0,0 +1,19 @@
ifeq ($(CONFIG_POSIX_API),y)
SRC_FILES += pthread.c
ifeq ($(CONFIG_KERNEL_SEMAPHORE),y)
SRC_FILES += semaphore.c
endif
ifeq ($(CONFIG_KERNEL_MUTEX),y)
SRC_FILES += pthread_mutex.c
endif
ifeq ($(CONFIG_KERNEL_MESSAGEQUEUE),y)
SRC_FILES += mqueue.c
endif
else
SRC_FILES :=
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: fs.h
* @brief: the macor definition of posix fs
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#ifndef POSIX_FS_H
#define POSIX_FS_H
// #include "../../switch_api/user_api.h"
// #define open UserOpen
// #define read UserRead
// #define write UserWrite
// #define close UserClose
// #define lseek UserLseek
// #define rename UserRename
// #define unlink UserUnlink
// #define stat UserStat
// #define fstat UserFstat
// #define fsync UserFsync
// #define ftruncate UserFtruncate
// #define mkdir UserMkdir
// #define opendir UserOpendir
// #define closedir UserClosedir
// #define readdir UserReaddir
// #define rmdir UserRmdir
// #define chdir UserChdir
// #define getcwd UserGetcwd
// #define telldir UserTelldir
// #define seekdir UserSeekdir
// #define rewinddir UserRewinddir
// #define printf UserPrintf
// #ifdef FS_DFS
// #define statfs UserStatfs
// #endif
#endif

View File

@@ -0,0 +1,57 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: msgqueue.h
* @brief: the function definition of posix msg queue
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#ifndef MQUEUE_H
#define MQUEUE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../../switch_api/user_api.h"
#include <time.h>
#define DEFAULT_MQUEUE_SIZE (10 * 1024)
#define DEFAULT_MAX_MSG_SIZE (1024)
typedef int mqd_t;
struct mq_attr {
long mq_flags; /* message queue flags */
long mq_maxmsg; /* maximum number of messages */
long mq_msgsize; /* maximum message size */
long mq_curmsgs; /* number of messages currently queued */
};
mqd_t mq_open(const char *name, int oflag, ...);
int mq_close(mqd_t mqdes);
ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio);
int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio);
int mq_setattr(mqd_t mqdes, const struct mq_attr *mqstat, struct mq_attr *omqstat);
int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat);
ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio, const struct timespec *abs_timeout);
int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio, const struct timespec *abs_timeout);
int mq_unlink(const char *name);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: pthread_arm.h
* @brief: the attribute definition of posix pthread for arm
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#ifndef PTHREAD_ARM_H
#define PTHREAD_ARM_H
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#include <sys/time.h>
typedef int pid_t;
typedef unsigned long int pthread_t;
struct sched_param {
int sched_priority; /* process execution scheduling priority */
size_t slice; /* time slice in SCHED_RR mode (ms) */
};
typedef struct pthread_attr {
unsigned char is_initialized; /* if the attr is initialized set to 1, otherwise set to 0 */
void *stackaddr; /* the start addr of the stack of the pthead */
size_t stacksize; /* the size of the stack of the pthead */
unsigned char contentionscope; /* the scope of contention, only PTHREAD_SCOPE_SYSTEM is supported */
unsigned char inheritsched; /* when set to PTHREAD_INHERIT_SCHED, specifies that the thread scheduling attributes
shall be inherited from the creating thread, and the scheduling attributes in this
attr argument shall be ignored */
unsigned char schedpolicy; /* the sched policy of the thread */
struct sched_param schedparam; /* the parameter of the thread scheduling */
size_t guardsize; /* guardsize is set to protect the stack, not supported */
unsigned char detachstate; /* when set to PTHREAD_CREATE_JOINABLE, thread will not end untill the creating thread end */
} pthread_attr_t;
typedef struct pthread_mutexattr {
int is_initialized;
int type;
int protocol;
int prioceiling;
int pshared;
} pthread_mutexattr_t;
typedef int pthread_mutex_t ;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* PTHREAD_H */

View File

@@ -0,0 +1,107 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: pthread.h
* @brief: the attribute definition of posix pthread
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#ifndef PTHREAD_H
#define PTHREAD_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../../switch_api/user_api.h"
#include <time.h>
#include <sys/time.h>
#if defined(ARCH_ARM)
#include "pthread arm.h"
#endif
// enum {
// PTHREAD_BARRIER_SERIAL_THREAD,
// PTHREAD_CANCEL_ASYNCHRONOUS,
// PTHREAD_CANCEL_ENABLE,
// PTHREAD_CANCEL_DEFERRED,
// PTHREAD_CANCEL_DISABLE,
// PTHREAD_CANCELED,
// PTHREAD_CREATE_DETACHED,
// PTHREAD_CREATE_JOINABLE,
// PTHREAD_EXPLICIT_SCHED,
// PTHREAD_INHERIT_SCHED,
// PTHREAD_MUTEX_DEFAULT,
// PTHREAD_MUTEX_ERRORCHECK,
// PTHREAD_MUTEX_NORMAL,
// PTHREAD_MUTEX_RECURSIVE,
// PTHREAD_MUTEX_ROBUST,
// PTHREAD_MUTEX_STALLED,
// PTHREAD_ONCE_INIT,
// PTHREAD_PRIO_INHERIT,
// PTHREAD_PRIO_NONE,
// PTHREAD_PRIO_PROTECT,
// PTHREAD_PROCESS_SHARED,
// PTHREAD_PROCESS_PRIVATE,
// PTHREAD_SCOPE_PROCESS,
// PTHREAD_SCOPE_SYSTEM,
// };
typedef int pid_t;
/* function in pthread.c */
int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void));
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg);
void pthread_exit(void *value_ptr);
int pthread_detach(pthread_t thread);
int pthread_join(pthread_t thread, void **retval);
int pthread_cancel(pthread_t thread);
void pthread_testcancel(void);
int pthread_setcancelstate(int state, int *oldstate);
int pthread_setcanceltype(int type, int *oldtype);
int pthread_kill(pthread_t thread, int sig);
int pthread_equal(pthread_t t1, pthread_t t2);
int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *pParam);
void pthread_cleanup_pop(int execute);
void pthread_cleanup_push(void (*routine)(void *), void *arg);
pthread_t pthread_self(void);
int pthread_getcpuclockid(pthread_t thread_id, clockid_t *clock_id);
int pthread_setconcurrency(int new_level);
int pthread_getconcurrency(void);
int pthread_setschedprio(pthread_t thread, int prio);
int pthread_setname_np(pthread_t thread, const char *name);
int pthread_timedjoin_np(pthread_t thread, void **retval, const struct timespec *abstime);
/* function in pthread_mutex.c */
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr);
int pthread_mutex_destroy(pthread_mutex_t *mutex);
int pthread_mutex_lock(pthread_mutex_t *mutex);
int pthread_mutex_unlock(pthread_mutex_t *mutex);
int pthread_mutex_trylock(pthread_mutex_t *mutex);
int pthread_mutexattr_init(pthread_mutexattr_t *attr);
int pthread_mutexattr_destroy(pthread_mutexattr_t *attr);
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type);
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type);
int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared);
int pthread_mutexattr_getpshared(pthread_mutexattr_t *attr, int *pshared);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: semaphore.h
* @brief: the functions definition of posix semaphore
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#ifndef SEMAPHORE_H
#define SEMAPHORE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../../switch_api/user_api.h"
#include <time.h>
typedef int sem_t;
int sem_init(sem_t *sem, int pshared, unsigned int value);
sem_t *sem_open(const char *name, int oflag, ...);
int sem_post(sem_t *sem);
int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout);
int sem_trywait(sem_t *sem);
int sem_unlink(const char *name);
int sem_wait(sem_t *sem);
int sem_getvalue(sem_t *sem, int *sval);
int sem_close(sem_t *sem);
int sem_destroy(sem_t *sem);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* SEMAPHORE_H */

View File

@@ -0,0 +1,94 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: mqueue.c
* @brief: posix api of mqueue
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#include "include/mqueue.h"
mqd_t mq_open(const char *name, int oflag, ...)
{
mqd_t mq;
mq = UserMsgQueueCreate( DEFAULT_MQUEUE_SIZE, DEFAULT_MAX_MSG_SIZE);
if (mq < 0) {
return -1;
}
return mq;
}
int mq_close(mqd_t mqdes)
{
return UserMsgQueueDelete(mqdes);
}
ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio)
{
ssize_t ret;
*msg_prio = 0;
ret = UserMsgQueueRecv(mqdes, msg_ptr, (unsigned long)&msg_len, 0);
return ret;
}
int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio)
{
int ret;
ret = UserMsgQueueSend(mqdes, (void *)msg_ptr, msg_len);
return ret;
}
int mq_setattr(mqd_t mqdes, const struct mq_attr *mqstat, struct mq_attr *omqstat)
{
return 0;
}
int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat)
{
return 0;
}
ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
unsigned *msg_prio, const struct timespec *abstime)
{
ssize_t ret;
int ticks;
*msg_prio = 0;
ticks = abstime->tv_sec * 1000 +
(abstime->tv_nsec / 1000000 ) ;
ret = UserMsgQueueRecv(mqdes, msg_ptr, msg_len, ticks);
return ret;
}
int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
unsigned msg_prio, const struct timespec *abstime)
{
int ret;
int ticks;
ticks = abstime->tv_sec * 1000 +
(abstime->tv_nsec / 1000000 ) ;
ret = UserMsgQueueSendwait(mqdes, (void *)msg_ptr, msg_len, ticks);
return ret;
}

View File

@@ -0,0 +1,94 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: pthread.c
* @brief: posix api of pthread
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#include "include/pthread.h"
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg)
{
int ret ;
int pid ;
utask_x task ;
task.func_entry = start_routine ;
task.func_param = arg ;
memcpy(task.name , "utask", 6);
task.prio = 20 ;
task.stack_size = 1024 ;
pid = UserTaskCreate(task);
if (pid < 0)
return -1 ;
ret = UserTaskStartup(pid);
return ret;
}
void pthread_exit(void *value_ptr){
//todo add exit value
UserTaskQuit();
}
pthread_t pthread_self(void){
pthread_t pthread ;
pthread = UserGetTaskID();
return pthread;
}
int pthread_setschedprio(pthread_t thread, int prio)
{
//add syscall
return 0;
}
int pthread_equal(pthread_t t1, pthread_t t2)
{
return (int)(t1 == t2);
}
int pthread_cancel(pthread_t thread)
{
return -1;
}
void pthread_testcancel(void)
{
return;
}
int pthread_setcancelstate(int state, int *oldstate)
{
return -1;
}
int pthread_setcanceltype(int type, int *oldtype)
{
return -1;
}
int pthread_kill(pthread_t thread, int sig)
{
/* This api should not be used, and will not be supported */
return -1;
}

View File

@@ -0,0 +1,125 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: pthread_mutex.c
* @brief: posix api of mutex
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#include <time.h>
#include "include/pthread.h"
int pthread_mutex_init(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr)
{
*p_mutex = UserMutexCreate();
if (*p_mutex < 0) {
return -1;
}
return 0;
}
int pthread_mutex_destroy(pthread_mutex_t *p_mutex)
{
UserMutexDelete(*p_mutex);
return 0;
}
int pthread_mutex_lock(pthread_mutex_t *p_mutex)
{
int ret = -1;
ret = UserMutexObtain(*p_mutex, WAITING_FOREVER);
return ret;
}
int pthread_mutex_unlock(pthread_mutex_t *p_mutex)
{
int ret = -1;
ret = UserMutexAbandon( *p_mutex );
return ret;
}
int pthread_mutex_trylock(pthread_mutex_t *p_mutex)
{
int ret = -1;
ret = UserMutexObtain( *p_mutex , 0);
return ret;
}
int pthread_mutexattr_init(pthread_mutexattr_t *attr)
{
return 0;
}
int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
{
return 0;
}
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type)
{
return 0;
}
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
{
return 0;
}
int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrict attr, int *restrict protocol)
{
return 0;
}
int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol)
{
return 0;
}
int pthread_mutex_getprioceiling(const pthread_mutex_t *restrict mutex, int *restrict prioceiling)
{
return 0;
}
int pthread_mutex_setprioceiling(pthread_mutex_t *restrict mutex, int prioceiling, int *restrict old_ceiling)
{
return 0;
}
int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *restrict attr, int *restrict prioceiling)
{
return 0;
}
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling)
{
return 0;
}
int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared)
{
return 0;
}
int pthread_mutexattr_getpshared(pthread_mutexattr_t *attr, int *pshared)
{
return 0;
}

View File

@@ -0,0 +1,97 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: semaphore.c
* @brief: posix api of semphore
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#include "include/semaphore.h"
#include <time.h>
int sem_init(sem_t *sem, int pshared, unsigned int value)
{
int32 ret = 0;
ret = UserSemaphoreCreate(value);
if (ret < 0) {
return -1;
}
return 0;
}
sem_t *sem_open(const char *name, int oflag, ...)
{
return 0;
}
int sem_post(sem_t *sem)
{
int ret;
ret = UserSemaphoreAbandon(*sem);
return ret;
}
int sem_timedwait(sem_t *sem, const struct timespec *abstime)
{
int ret ;
int ticks = -1 ;
if (abstime != NULL) {
ticks = abstime->tv_sec * 1000 +
(abstime->tv_nsec / 1000000 ) ;
}
ret = UserSemaphoreObtain(*sem, ticks);
return ret;
}
int sem_trywait(sem_t *sem)
{
int ret ;
ret = KSemaphoreObtain(*sem, 0);
return ret;
}
int sem_unlink(const char *name)
{
return 0;
}
int sem_wait(sem_t *sem)
{
int ret ;
ret = KSemaphoreObtain(*sem, -1);
return ret;
}
int sem_getvalue(sem_t *sem, int *sval)
{
return 0;
}
int sem_close(sem_t *sem)
{
return 0;
}
int sem_destroy(sem_t *sem)
{
UserSemaphoreDelete(*sem);
return 0;
}

View File

@@ -0,0 +1,27 @@
ifeq ($(CONFIG_SEPARATE_COMPILE),y)
SRC_FILES :=user_print_info.c user_task.c user_mem.c
ifeq ($(CONFIG_KERNEL_SEMAPHORE),y)
SRC_FILES += user_semaphore.c
endif
ifeq ($(CONFIG_KERNEL_MUTEX),y)
SRC_FILES += user_mutex.c
endif
ifeq ($(CONFIG_KERNEL_EVENT),y)
SRC_FILES += user_event.c
endif
ifeq ($(CONFIG_KERNEL_MESSAGEQUEUE),y)
SRC_FILES += user_msg.c
endif
ifeq ($(CONFIG_FS_VFS),y)
SRC_FILES += user_fs.c
endif
else
SRC_FILES :=
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -0,0 +1,247 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: user_api.h
* @brief: the priviate user api for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#ifndef XS_USER_API_H
#define XS_USER_API_H
// #include <xiuos.h>
#include <xsconfig.h>
#include "../../../kernel/include/xs_service.h"
#include "../../../kernel/include/xs_base.h"
#include <stddef.h>
#include <stdint.h>
#include "../../../arch/kswitch.h"
#include <libc.h>
#ifdef SEPARATE_COMPILE
#define TASK_INFO 1
#define MEM_INFO 2
#define SEM_INFO 3
#define EVENT_INFO 4
#define MUTEX_INFO 5
#define MEMPOOL_INFO 6
#define MSGQUEUE_INFO 7
#define DEVICE_INFO 8
#define TIMER_INFO 9
int UserPrintInfo(unsigned long i);
struct utask
{
char name[NAME_NUM_MAX];
void *func_entry;
void *func_param;
int32_t stack_size;
uint8_t prio;
};
typedef struct utask utask_x;
typedef void DIR;
int32_t UserTaskCreate(utask_x utask);
x_err_t UserTaskStartup(int32_t id);
x_err_t UserTaskDelete(int32_t id);
void UserTaskQuit(void);
x_err_t UserTaskDelay(int32_t ms);
x_err_t UserGetTaskName(int32_t id ,char *name);
int32_t UserGetTaskID(void);
uint8_t UserGetTaskStat(int32_t id);
#ifdef ARCH_SMP
x_err_t UserTaskCoreCombine(int32_t id,uint8_t core_id);
x_err_t UserTaskCoreUnCombine(int32_t id);
uint8_t UserGetTaskCombinedCore(int32_t id);
uint8_t UserGetTaskRunningCore(int32_t id);
#endif
x_err_t UserGetTaskErrorstatus(int32_t id);
uint8_t UserGetTaskPriority(int32_t id);
void *UserMalloc(size_t size);
void *UserRealloc(void *pointer, size_t size);
void *UserCalloc(size_t count, size_t size);
void UserFree(void *pointer);
#ifdef KERNEL_MUTEX
int32_t UserMutexCreate();
void UserMutexDelete(int32_t mutex);
int32_t UserMutexObtain(int32_t mutex, int32_t wait_time);
int32_t UserMutexAbandon(int32_t mutex);
#endif
#ifdef KERNEL_SEMAPHORE
typedef int32 sem_t;
sem_t UserSemaphoreCreate(uint16_t val);
x_err_t UserSemaphoreDelete(sem_t sem);
x_err_t UserSemaphoreObtain(sem_t sem, int32_t wait_time);
x_err_t UserSemaphoreAbandon(sem_t sem);
x_err_t UserSemaphoreSetValue(sem_t sem, uint16_t val);
#endif
#ifdef KERNEL_EVENT
typedef int32 EventIdType;
EventIdType UserEventCreate(uint8_t flag);
void UserEventDelete(EventIdType event);
x_err_t UserEventTrigger(EventIdType event, uint32_t set);
x_err_t UserEventProcess(EventIdType event, uint32_t set, uint8_t option,
int32_t wait_time, uint32_t *Recved);
x_err_t UserEventReinit(EventIdType event);
#endif
#ifdef KERNEL_MESSAGEQUEUE
int32_t UserMsgQueueCreate(size_t msg_size, size_t max_msgs);
x_err_t UserMsgQueueDelete(int32_t mq );
x_err_t UserMsgQueueSendwait(int32_t mq, const void *buffer,
size_t size, int32_t wait_time);
x_err_t UserMsgQueueSend(int32_t mq, const void *buffer, size_t size);
x_err_t UserMsgQueueUrgentSend(int32_t mq, const void *buffer, size_t size);
x_err_t UserMsgQueueRecv(int32_t mq, void *buffer, size_t size,int32_t wait_time);
x_err_t UserMsgQueueReinit(int32_t mq);
#endif
int open(const char *path, int flags, ...);
int read(int fd, void *buf, size_t len);
int write(int fd, const void *buf, size_t len);
int close(int fd);
int ioctl(int fd, int cmd, void *args);
off_t lseek(int fd, off_t offset, int whence);
int rename(const char *from, const char *to);
int unlink(const char *path);
int stat(const char *path, struct stat *buf);
int fstat(int fd, struct stat *buf);
int fsync(int fd);
int ftruncate(int fd, off_t length);
int mkdir(const char *path, mode_t mode);
DIR *opendir(const char *path);
int closedir(DIR *dirp);
struct dirent *readdir(DIR *dirp);
int rmdir(const char *path);
int chdir(const char *path);
char *getcwd(char *buf, size_t size);
long telldir(DIR *dirp);
void seekdir(DIR *dirp, off_t offset);
void rewinddir(DIR *dirp);
#ifdef FS_VFS
struct statfs {
size_t f_bsize;
size_t f_blocks;
size_t f_bfree;
};
int statfs(const char *path, struct statfs *buf);
#endif
void Userprintf(const char *fmt, ...);
#define printf Userprintf
#else
#ifdef FS_VFS
#include <iot-vfs_posix.h>
#endif
struct utask
{
char name[NAME_NUM_MAX];
void *func_entry;
void *func_param;
int32_t stack_size;
uint8_t prio;
};
typedef struct utask utask_x;
int32_t UserTaskCreate(utask_x utask);
#define UserTaskStartup StartupKTask
#define UserTaskDelete KTaskDelete
#define UserTaskQuit KTaskQuit
#define UserTaskDelay MdelayKTask
x_err_t UserGetTaskName(int32_t id ,char *name);
int32_t UserGetTaskID(void);
uint8_t UserGetTaskStat(int32_t id);
#ifdef ARCH_SMP
#define UserTaskCoreCombine KTaskCoreCombine
#define UserTaskCoreUnCombine KTaskCoreUnCombine
uint8_t UserGetTaskCombinedCore(int32_t id);
uint8_t UserGetTaskRunningCore(int32_t id);
#endif
x_err_t UserGetTaskErrorstatus(int32_t id);
uint8_t UserGetTaskPriority(int32_t id);
#define UserMalloc x_malloc
#define UserRealloc x_realloc
#define UserCalloc x_calloc
#define UserFree x_free
#ifdef KERNEL_MUTEX
#define UserMutexCreate KMutexCreate
#define UserMutexDelete KMutexDelete
#define UserMutexObtain KMutexObtain
#define UserMutexAbandon KMutexAbandon
#endif
#ifdef KERNEL_SEMAPHORE
#define UserSemaphoreCreate KSemaphoreCreate
#define UserSemaphoreDelete KSemaphoreDelete
#define UserSemaphoreObtain KSemaphoreObtain
#define UserSemaphoreAbandon KSemaphoreAbandon
#define UserSemaphoreSetValue KSemaphoreSetValue
#endif
#ifdef KERNEL_EVENT
#define UserEventCreate KEventCreate
#define UserEventDelete KEventDelete
#define UserEventTrigger KEventTrigger
#define UserEventProcess KEventProcess
#endif
#ifdef KERNEL_MESSAGEQUEUE
#define UserMsgQueueCreate KCreateMsgQueue
#define UserMsgQueueDelete KDeleteMsgQueue
#define UserMsgQueueSendwait KMsgQueueSendwait
#define UserMsgQueueSend KMsgQueueSend
#define UserMsgQueueUrgentSend KMsgQueueUrgentSend
#define UserMsgQueueRecv KMsgQueueRecv
#define UserMsgQueueReinit KMsgQueueReinit
#endif
#define UserPrintf KPrintf
#define printf KPrintf
#endif
#endif

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: user_event.c
* @brief: the priviate user api of event for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#include "user_api.h"
/**
* This function will create a event.
*
* @param flag the trigger way of event.
*
* @return id
*/
EventIdType UserEventCreate(uint8_t flag){
return (EventIdType)KSwitch1(KS_USER_EVENT_CREATE,(uintptr_t)flag );
}
/**
* This function will delete a event.
*
* @param event the id number of event.
*
* @return
*/
void UserEventDelete(EventIdType event){
KSwitch1(KS_USER_EVENT_DELETE,(uintptr_t)event);
}
/**
* This function will trigger the event
*
* @param event the id number of event
* @param set trigger way & events flag
*
* @return EOK on success.
*/
x_err_t UserEventTrigger(EventIdType event, uint32_t set){
return (x_err_t)KSwitch2(KS_USER_EVENT_TRIGGER,(uintptr_t)event, (uintptr_t)set );
}
/**
* This function will get the event and process this event
*
* @param event the id number of event
* @param set events flag
* @param option trigger way
* @param wait_time timeout
* @param Recved event processed flag
*
* @return EOK on success.
*/
x_err_t UserEventProcess(EventIdType event, uint32_t set, uint8_t option,
int32_t wait_time, uint32_t *Recved){
return (x_err_t)KSwitch5(KS_USER_EVENT_PROCESS,(uintptr_t)event, (uintptr_t)set, (uintptr_t)option, (uintptr_t)wait_time, (uintptr_t)Recved);
}

View File

@@ -0,0 +1,144 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: user_fs.c
* @brief: the priviate user api of fs for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#include "user_api.h"
#include <stdarg.h>
#define stdio 1
#define CONSOLEBUF_SIZE 128
int open(const char *path, int flags, ...){
va_list ap;
mode_t mode;
va_start(ap, flags);
mode = va_arg(ap, mode_t);
va_end(ap);
return (int)(KSwitch3(KS_USER_OPEN,(uintptr_t)path,(uintptr_t)flags,(uintptr_t)mode));
}
int read(int fd, void *buf, size_t len){
return (int)(KSwitch3(KS_USER_READ,(uintptr_t)fd,(uintptr_t)buf,(uintptr_t)len));
}
int write(int fd, const void *buf, size_t len){
return (int)(KSwitch3(KS_USER_WRITE,(uintptr_t)fd,(uintptr_t)buf,(uintptr_t)len));
}
int close(int fd){
return (int)(KSwitch1(KS_USER_CLOSE,(uintptr_t)fd));
}
int ioctl(int fd, int cmd, void *args){
return (int)(KSwitch3(KS_USER_IOCTL,(uintptr_t)fd,(uintptr_t)cmd,(uintptr_t)args));
}
off_t lseek(int fd, off_t offset, int whence){
return (off_t)(KSwitch3(KS_USER_LSEEK,(uintptr_t)fd,(uintptr_t)offset,(uintptr_t)whence));
}
int rename(const char *from, const char *to){
return (int)(KSwitch2(KS_USER_RENAME,(uintptr_t)from,(uintptr_t)to));
}
int unlink(const char *path){
return (int)(KSwitch1(KS_USER_UNLINK,(uintptr_t)path));
}
int stat(const char *path, struct stat *buf){
return (int)(KSwitch2(KS_USER_STAT,(uintptr_t)path,(uintptr_t)buf));
}
int fstat(int fd, struct stat *buf){
return (int)(KSwitch2(KS_USER_FS_STAT,(uintptr_t)fd,(uintptr_t)buf));
}
int fsync(int fd){
return (int)(KSwitch1(KS_USER_FS_SYNC,(uintptr_t)fd));
}
int ftruncate(int fd, off_t length){
return (int)(KSwitch2(KS_USER_FTRUNCATE,(uintptr_t)fd,(uintptr_t)length));
}
int mkdir(const char *path, mode_t mode){
return (int)(KSwitch2(KS_USER_MKDIR,(uintptr_t)path,(uintptr_t)mode));
}
DIR *opendir(const char *path){
return (DIR *)(KSwitch1(KS_USER_OPENDIR,(uintptr_t)path));
}
int closedir(DIR *dirp){
return (int)(KSwitch1(KS_USER_CLOSEDIR,(uintptr_t)dirp));
}
struct dirent *readdir(DIR *dirp){
return (struct dirent *)(KSwitch1(KS_USER_READDIR,(uintptr_t)dirp));
}
int rmdir(const char *path){
return (int)(KSwitch1(KS_USER_RMDIR,(uintptr_t)path));
}
int chdir(const char *path){
return (int)(KSwitch1(KS_USER_CHDIR,(uintptr_t)path));
}
char *getcwd(char *buf, size_t size){
return (char *)(KSwitch2(KS_USER_GETCWD,(uintptr_t)buf,(uintptr_t)size ));
}
long telldir(DIR *dirp){
return (long)(KSwitch1(KS_USER_TELLDIR,(uintptr_t)dirp));
}
void seekdir(DIR *dirp, off_t offset){
return (void)(KSwitch2(KS_USER_SEEKDIR,(uintptr_t)dirp,(uintptr_t)offset));
}
void rewinddir(DIR *dirp){
return (void)(KSwitch1(KS_USER_REWIND_DIR,(uintptr_t)dirp));
}
int statfs(const char *path, struct statfs *buf){
return (int)(KSwitch2(KS_USER_STAT_FS,(uintptr_t)path,(uintptr_t)buf));
}
void Userprintf(const char *fmt, ...)
{
if(stdio != NONE)
{
va_list args;
size_t length;
static char logbuf[CONSOLEBUF_SIZE];
va_start(args, fmt);
length = vsnprintf(logbuf, sizeof(logbuf) - 1, fmt, args);
if (length > CONSOLEBUF_SIZE - 1)
length = CONSOLEBUF_SIZE - 1;
write(stdio, logbuf, length);
va_end(args);
}
}

View File

@@ -0,0 +1,103 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: user_mem.c
* @brief: the priviate user api of mem for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#include "user_api.h"
#include <string.h>
/**
* This function is provided to allocate memory block.
*
* @param size the memory size to be allocated
*
* @return pointer on success; NULL on failure
*/
void *UserMalloc(size_t size){
return (void *)(KSwitch1(KS_USER_MALLOC,(uintptr_t)size));
}
/**
* This function is provided to release memory block.
*
* @param pointer the memory to be released
*/
void UserFree(void *pointer){
KSwitch1(KS_USER_FREE,(uintptr_t)pointer);
return;
}
/**
* This function is provided to re-allocate memory block.
*
* @param pointer the old memory pointer
* @param size the memory size to be re-allocated
*
* @return pointer on success; NULL on failure
*/
void *UserRealloc(void *pointer, size_t size){
x_size_t newsize = 0;
x_size_t oldsize = 0;
void *newmem = NONE;
/* the given pointer is NULL */
if (pointer == NONE)
return UserMalloc(size);
/* parameter detection */
if (size == 0) {
UserFree(pointer);
return NONE;
}
/* allocate new memory */
newmem = UserMalloc(size);
if(newmem == NONE) {
return NONE;
}
/* copy the old memory and then release old memory pointer */
memcpy((char*)newmem, (char*) pointer,size > oldsize ? oldsize : size);
UserFree(pointer);
return newmem;
}
/**
* This function will allocate memory blocks and then clear the memory.
*
* @param count the number of memory blocks
* @param size the size of a memory block
*
* @return pointer on success; NULL on failure
*/
void *UserCalloc(size_t count, size_t size){
void *p = NONE;
/* calls x_malloc to allocate count * size memory */
p = UserMalloc(count * size);
/* zero the memory */
if (p)
memset((char*)p, 0, count * size);
return p;
}

View File

@@ -0,0 +1,120 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: user_msg.c
* @brief: the priviate user api of msg queue for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#include "user_api.h"
/**
* This function will create a msg queue.
*
* @param msg_size the length of the msg queue.
* @param max_msgs the max length of the msg queue.
*
* @return id on success;ENOMEMORY/ERROR on failure
*/
int32_t UserMsgQueueCreate( size_t msg_size,
size_t max_msgs){
return (int32_t)KSwitch2(KS_USER_MSGQUEUE_CREATE, (uintptr_t)msg_size, (uintptr_t)max_msgs);
}
/**
* a dynamic messagequeue will be deleted from the manage list
*
* @param id the message id
*
* @return EOK on success;EINVALED on failure
*
*/
x_err_t UserMsgQueueDelete(int32_t mq ){
return (x_err_t)KSwitch1(KS_USER_MSGQUEUE_DELETE, (uintptr_t)mq);
}
/**
* send message with waiting time,current suspend task will be resumed
*
* @param id the message id
* @param buffer message info
* @param size the size of buffer
* @param timeout waiting time
*
* @return EOK on success;EINVALED on failure
*
*/
x_err_t UserMsgQueueSendwait(int32_t mq, const void *buffer,
size_t size, int32_t wait_time){
return (x_err_t)KSwitch3(KS_USER_MSGQUEUE_SEND , (uintptr_t)mq, (uintptr_t)buffer, (uintptr_t)size );
}
/**
* send message without waiting time,current suspend task will be resumed
*
* @param id the message id
* @param buffer message info
* @param size the size of buffer
*
* @return EOK on success;EINVALED on failure
*
*/
x_err_t UserMsgQueueSend(int32_t mq, const void *buffer, size_t size){
return (x_err_t)KSwitch3(KS_USER_MSGQUEUE_SEND , (uintptr_t)mq, (uintptr_t)buffer, (uintptr_t)size );
}
/**
* send urgent message without waiting time, this message will be inserted to the head of the queue
*
* @param id the message id
* @param buffer message info
* @param size the size of buffer
*
* @return EOK on success;EINVALED on failure
*
*/
x_err_t UserMsgQueueUrgentSend(int32_t mq, const void *buffer, size_t size){
return (x_err_t)KSwitch3(KS_USER_MSGQUEUE_URGENTSEND , (uintptr_t)mq, (uintptr_t)buffer, (uintptr_t)size );
}
/**
* receive message with some waiting time
*
* @param id the message id
* @param buffer message info
* @param size the size of buffer
* @param timeout time needed waiting
*
* @return EOK on success;EINVALED on failure
*
*/
x_err_t UserMsgQueueRecv(int32_t mq, void *buffer,
size_t size,int32_t wait_time){
return (x_err_t)KSwitch4(KS_USER_MSGQUEUE_RECV ,(uintptr_t)mq, (uintptr_t)buffer, (uintptr_t)size, (uintptr_t)wait_time );
}
/**
* This function will reset a event.
*
* @param id the id number of event.
*
* @return EOK on success;EINVALED on failure
*/
x_err_t UserMsgQueueReinit(int32_t mq){
return (x_err_t)KSwitch1(KS_USER_MSGQUEUE_REINIT ,(uintptr_t)mq );
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: user_mutex.c
* @brief: the priviate user api of mutex for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#include "user_api.h"
/**
* a mutex will be inited in static way,then this mutex will be inserted to the manage list
*
* @param mutex the mutex descriptor
* @param name mutex name
* @param flag mutex flag
*
* @return EOK on success
*
*/
int32_t UserMutexCreate(){
return (int32_t)KSwitch0(KS_USER_MUTEX_CREATE);
}
/**
* a dynamic mutex will be deleted from the manage list
*
* @param mutex mutex descriptor
*
*/
void UserMutexDelete(int32_t mutex){
KSwitch1(KS_USER_MUTEX_DELETE,(uintptr_t)mutex);
}
/**
* a mutex will be taken when mutex is available
*
* @param mutex mutex descriptor
* @param msec the time needed waiting
*
* @return EOK on success;ERROR on failure
*
*/
int32_t UserMutexObtain(int32_t mutex, int32_t wait_time){
return (int32_t)KSwitch2(KS_USER_MUTEX_OBTAIN,(uintptr_t)mutex, (uintptr_t)wait_time);
}
/**
* release the mutex and resume corresponding suspended task
*
* @param mutex mutex descriptor
*
* @return EOK on success;ERROR on failure
*/
int32_t UserMutexAbandon(int32_t mutex){
return (int32_t)KSwitch1(KS_USER_MUTEX_ABANDON,(uintptr_t)mutex);
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: user_print_info.c
* @brief: the priviate user api of user info print for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#include "user_api.h"
/* for debug */
int UserPrintInfo(unsigned long i){
return (int)KSwitch1(KS_USER_PRINT_INFO,i);
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: user_semaphore.c
* @brief: the priviate user api of semphore for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#include "user_api.h"
/**
* Create a new semaphore with specified initial value.
*
* @param val initial value
* @return id of the semaphore
*/
sem_t UserSemaphoreCreate(uint16_t val){
return (sem_t)KSwitch1(KS_USER_SEMAPHORE_CREATE,(uintptr_t)val);
}
/**
* Delete a semaphore and wakeup all pending tasks on it.
*
* @param id id of the semaphore to be deleted
*/
x_err_t UserSemaphoreDelete(sem_t sem){
return (x_err_t)KSwitch1(KS_USER_SEMAPHORE_DELETE,(uintptr_t)sem);
}
/**
* Obtain a semaphore when its value is greater than 0; pend on it otherwise.
*
* @param id id of the semaphore to be obtained
* @param msec wait time in millisecond
* @return EOK on success, error code on failure
*/
x_err_t UserSemaphoreObtain(sem_t sem, int32_t wait_time){
return (x_err_t)KSwitch2(KS_USER_SEMAPHORE_OBTAIN,(uintptr_t)sem,(uintptr_t)wait_time);
}
/**
* Abandon a semaphore and wakeup a pending task if any.
*
* @param id id of the semaphore to be abandoned
* @return EOK on success, error code on failure
*/
x_err_t UserSemaphoreAbandon(sem_t sem){
return (x_err_t)KSwitch1(KS_USER_SEMAPHORE_ABANDON,(uintptr_t)sem);
}
/**
* Set the value of a semaphore, wakeup all pending tasks if new value is positive.
*
* @param id id of the semaphore for which to set value
* @param val new value
* @return EOK on success, error code on failure
*/
x_err_t UserSemaphoreSetValue(sem_t sem, uint16_t val){
return (x_err_t)KSwitch2(KS_USER_SEMAPHORE_SETVALUE,(uintptr_t)sem,(uintptr_t)val);
}

View File

@@ -0,0 +1,128 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: user_task.c
* @brief: the priviate user api of task for application
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2020/4/20
*
*/
#include "user_api.h"
/**
*
* This function init a user task in dynamic way .
*
* @param name task name
* @param parameter task process function
* @param parameter task arg
* @param stack_size task stack size
* @param priority task priority
* @param tick task time slice
*
* @return EOK on success; ENOMEMORY/EEMPTY on failure
*/
int32_t UserTaskCreate(utask_x utask){
return (int32_t) KSwitch5(KS_USER_TASK_CREATE,(uintptr_t)utask.name,(uintptr_t)utask.func_entry,(uintptr_t)utask.func_param,(uintptr_t)utask.stack_size,(uintptr_t)utask.prio);
}
/**
* This function will insert task to ready queue then schedule
*
* @param id task id
*
* @return EOK on success; EINVALED on failure
*/
x_err_t UserTaskStartup(int32_t id){
return (x_err_t)KSwitch1(KS_USER_TASK_STARTUP,(uintptr_t)id);
}
/**
* This function will remove a dynamic task out of the task manage list.
*
* @param id task id
*
* @return EOK on success; EINVALED on failure
*/
x_err_t UserTaskDelete(int32_t id){
return (x_err_t)KSwitch1(KS_USER_TASK_DELETE,(uintptr_t)id);
}
void UserTaskQuit(void){
KSwitch0(KS_USER_TASK_EXECEXIT);
return ;
}
/**
* This function will delay current task running with some ticks.
*
* @param tick delay ticks
* @return EOK on success; EINVALED/EEMPTY on failure
*/
x_err_t UserTaskDelay(int32_t ms){
return (x_err_t)KSwitch1(KS_USER_TASK_DELAY,(uintptr_t)ms);
}
x_err_t UserGetTaskName( int32_t id, char *name){
return (x_err_t)KSwitch2(KS_USER_GET_TASK_NAME,(uintptr_t)id, (uintptr_t)name);
}
int32_t UserGetTaskID(void){
return (int32_t)KSwitch0(KS_USER_GET_TASK_ID);
}
uint8_t UserGetTaskStat(int32_t id){
return (uint8_t)KSwitch1(KS_USER_GET_TASK_STAT,(uintptr_t)id );
}
#ifdef ARCH_SMP
/**
* This function binds a task to cpu core.
*
* @param id task id
* @param coreid cpu core id
*
* @return EOK
*/
x_err_t UserTaskCoreCombine(int32_t id,uint8_t core_id){
return (x_err_t)KSwitch2(KS_USER_TASK_CORE_COMBINE,(uintptr_t)id,core_id);
}
/**
* This function unbinds a task with cpu core.
*
* @param id task id
*
* @return EOK
*/
x_err_t UserTaskCoreUnCombine(int32_t id){
return (x_err_t)KSwitch1(KS_USER_TASK_CORE_UNCOMBINE,(uintptr_t)id);
}
uint8_t UserGetTaskCombinedCore(int32_t id){
return (uint8_t)KSwitch1(KS_USER_GET_TASK_COMBINEED_CORE,(uintptr_t)id );
}
uint8 UserGetTaskRunningCore(int32_t id){
return (uint8_t)KSwitch1(KS_USER_GET_TASK_RUNNING_CORE,(uintptr_t)id );
}
#endif
x_err_t UserGetTaskErrorstatus(int32_t id){
return (x_err_t)KSwitch1(KS_USER_GET_TASK_ERROR_STATUS,(uintptr_t)id );
}
uint8_t UserGetTaskPriority(int32_t id){
return (uint8_t)KSwitch1(KS_USER_GET_TASK_PRIORITY,(uintptr_t)id );
}