forked from xuos/xiuos
commit
b97a54dbed
|
@ -0,0 +1,5 @@
|
||||||
|
SRC_FILES := main.c
|
||||||
|
|
||||||
|
SRC_DIR := general_functions
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_DIR := linklist
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := double_linklist.c single_linklist.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -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 "list.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;
|
||||||
|
}
|
|
@ -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 <errno.h>
|
||||||
|
#include <stdint.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[32];
|
||||||
|
uint8_t type;
|
||||||
|
uint8_t 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
|
|
@ -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 "list.h"
|
||||||
|
|
||||||
|
void InitSingleLinkList(SysSingleLinklistType *linklist)
|
||||||
|
{
|
||||||
|
linklist->node_next = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 != NULL)
|
||||||
|
{
|
||||||
|
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 == NULL;
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
SRC_DIR := sensor transform_layer
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := sensor.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,393 @@
|
||||||
|
/*
|
||||||
|
* 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 sensor.c
|
||||||
|
* @brief Implement the sensor framework management, registration and done
|
||||||
|
* @version 1.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.03.24
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sensor.h>
|
||||||
|
|
||||||
|
/* Sensor quantity list table */
|
||||||
|
static DoubleLinklistType quant_table[SENSOR_QUANTITY_END];
|
||||||
|
|
||||||
|
/* Sensor device list */
|
||||||
|
static DoubleLinklistType sensor_device_list;
|
||||||
|
|
||||||
|
/* Sensor quantity list lock */
|
||||||
|
static int quant_table_lock;
|
||||||
|
|
||||||
|
/* Sensor device list lock */
|
||||||
|
static int sensor_device_list_lock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Init perception framework
|
||||||
|
* @return 0
|
||||||
|
*/
|
||||||
|
int SensorFrameworkInit(void)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < SENSOR_QUANTITY_END; i++)
|
||||||
|
InitDoubleLinkList(&quant_table[i]);
|
||||||
|
InitDoubleLinkList(&sensor_device_list);
|
||||||
|
|
||||||
|
quant_table_lock = PrivMutexCreate();
|
||||||
|
sensor_device_list_lock = PrivMutexCreate();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================= Sensor device interface operations ============================= */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Find sensor device by name
|
||||||
|
* @param name - name string
|
||||||
|
* @return sensor device pointer
|
||||||
|
*/
|
||||||
|
static struct SensorDevice *SensorDeviceFindByName(const char *name)
|
||||||
|
{
|
||||||
|
struct SensorDevice *ret = NULL;
|
||||||
|
struct SysDoubleLinklistNode *node;
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
PrivMutexObtain(sensor_device_list_lock, -1);
|
||||||
|
DOUBLE_LINKLIST_FOR_EACH(node, &sensor_device_list) {
|
||||||
|
struct SensorDevice *sdev =CONTAINER_OF(node,
|
||||||
|
struct SensorDevice, link);
|
||||||
|
if (strncmp(sdev->name, name, NAME_NUM_MAX) == 0) {
|
||||||
|
ret = sdev;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PrivMutexAbandon(sensor_device_list_lock);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Check whether the sensor is capable
|
||||||
|
* @param sdev - sensor device pointer
|
||||||
|
* @param ability - the ability to detect certain data
|
||||||
|
* @return success: true , failure: false
|
||||||
|
*/
|
||||||
|
inline int SensorDeviceCheckAbility(struct SensorDevice *sdev, uint32_t ability)
|
||||||
|
{
|
||||||
|
return (sdev->info->ability & ability) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Register the sensor to the linked list
|
||||||
|
* @param sdev - sensor device pointer
|
||||||
|
* @return success: 0 , failure: -1
|
||||||
|
*/
|
||||||
|
int SensorDeviceRegister(struct SensorDevice *sdev)
|
||||||
|
{
|
||||||
|
if (sdev == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (SensorDeviceFindByName(sdev->name) != NULL) {
|
||||||
|
printf("%s: sensor with the same name already registered\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sdev->ref_cnt = 0;
|
||||||
|
InitDoubleLinkList(&sdev->quant_list);
|
||||||
|
|
||||||
|
PrivMutexObtain(sensor_device_list_lock, -1);
|
||||||
|
DoubleLinkListInsertNodeAfter(&sensor_device_list, &sdev->link);
|
||||||
|
PrivMutexAbandon(sensor_device_list_lock);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Unregister the sensor from the linked list
|
||||||
|
* @param sdev - sensor device pointer
|
||||||
|
* @return 0
|
||||||
|
*/
|
||||||
|
int SensorDeviceUnregister(struct SensorDevice *sdev)
|
||||||
|
{
|
||||||
|
if (!sdev)
|
||||||
|
return -1;
|
||||||
|
PrivMutexObtain(sensor_device_list_lock, -1);
|
||||||
|
DoubleLinkListRmNode(&sdev->link);
|
||||||
|
PrivMutexAbandon(sensor_device_list_lock);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Open sensor device
|
||||||
|
* @param sdev - sensor device pointer
|
||||||
|
* @return success: 0 , failure: other
|
||||||
|
*/
|
||||||
|
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||||
|
{
|
||||||
|
if (!sdev)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
if (sdev->done->open != NULL)
|
||||||
|
result = sdev->done->open(sdev);
|
||||||
|
|
||||||
|
if (result == 0) {
|
||||||
|
printf("Device %s open success.\n", sdev->name);
|
||||||
|
}else{
|
||||||
|
if (sdev->fd)
|
||||||
|
PrivClose(sdev->fd);
|
||||||
|
|
||||||
|
printf("Device %s open failed(%d).\n", sdev->name, result);
|
||||||
|
memset(sdev, 0, sizeof(struct SensorDevice));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Close sensor device
|
||||||
|
* @param sdev - sensor device pointer
|
||||||
|
* @return success: 0 , failure: other
|
||||||
|
*/
|
||||||
|
static int SensorDeviceClose(struct SensorDevice *sdev)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
if (sdev->fd)
|
||||||
|
PrivClose(sdev->fd);
|
||||||
|
|
||||||
|
if (sdev->done->close != NULL)
|
||||||
|
result = sdev->done->close(sdev);
|
||||||
|
|
||||||
|
if (result == 0)
|
||||||
|
printf("%s successfully closed.\n", sdev->name);
|
||||||
|
else
|
||||||
|
printf("Closed %s failure.\n", sdev->name);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============================= Sensor quantity interface operations ============================= */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Find sensor quantity by name
|
||||||
|
* @param name - name string
|
||||||
|
* @param type - the quantity required
|
||||||
|
* @return sensor quantity pointer
|
||||||
|
*/
|
||||||
|
struct SensorQuantity *SensorQuantityFind(const char *name,
|
||||||
|
enum SensorQuantityType type)
|
||||||
|
{
|
||||||
|
struct SensorQuantity *ret = NULL;
|
||||||
|
struct SysDoubleLinklistNode *node;
|
||||||
|
|
||||||
|
if (name == NULL || type < 0 || type >= SENSOR_QUANTITY_END)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
PrivMutexObtain(quant_table_lock, -1);
|
||||||
|
DOUBLE_LINKLIST_FOR_EACH(node, &quant_table[type]) {
|
||||||
|
struct SensorQuantity *quant =CONTAINER_OF(node,
|
||||||
|
struct SensorQuantity, link);
|
||||||
|
if (strncmp(quant->name, name, NAME_NUM_MAX) == 0) {
|
||||||
|
ret = quant;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PrivMutexAbandon(quant_table_lock);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Register the quantity to the linked list
|
||||||
|
* @param quant - sensor quantity pointer
|
||||||
|
* @return success: 0 , failure: -1
|
||||||
|
*/
|
||||||
|
int SensorQuantityRegister(struct SensorQuantity *quant)
|
||||||
|
{
|
||||||
|
if (quant == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (SensorDeviceFindByName(quant->sdev->name) == NULL) {
|
||||||
|
if(SensorDeviceRegister(quant->sdev) != 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrivMutexObtain(quant_table_lock, -1);
|
||||||
|
DoubleLinkListInsertNodeAfter(&quant->sdev->quant_list, &quant->quant_link);
|
||||||
|
DoubleLinkListInsertNodeAfter(&quant_table[quant->type], &quant->link);
|
||||||
|
PrivMutexAbandon(quant_table_lock);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Unregister the quantity from the linked list
|
||||||
|
* @param quant - sensor quantity pointer
|
||||||
|
* @return 0
|
||||||
|
*/
|
||||||
|
int SensorQuantityUnregister(struct SensorQuantity *quant)
|
||||||
|
{
|
||||||
|
if (!quant)
|
||||||
|
return -1;
|
||||||
|
PrivMutexObtain(quant_table_lock, -1);
|
||||||
|
DoubleLinkListRmNode(&quant->quant_link);
|
||||||
|
DoubleLinkListRmNode(&quant->link);
|
||||||
|
PrivMutexAbandon(quant_table_lock);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Open the sensor quantity
|
||||||
|
* @param quant - sensor quantity pointer
|
||||||
|
* @return success: 0 , failure: other
|
||||||
|
*/
|
||||||
|
int SensorQuantityOpen(struct SensorQuantity *quant)
|
||||||
|
{
|
||||||
|
if (!quant)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
struct SensorDevice *sdev = quant->sdev;
|
||||||
|
|
||||||
|
if (!sdev)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (sdev->ref_cnt == 0) {
|
||||||
|
ret = SensorDeviceOpen(sdev);
|
||||||
|
if (ret != 0) {
|
||||||
|
printf("%s: open sensor device failed\n", __func__);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sdev->ref_cnt++;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Close sensor quantity
|
||||||
|
* @param quant - sensor quantity pointer
|
||||||
|
* @return success: 0 , failure: other
|
||||||
|
*/
|
||||||
|
int SensorQuantityClose(struct SensorQuantity *quant)
|
||||||
|
{
|
||||||
|
if (!quant)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
struct SensorDevice *sdev = quant->sdev;
|
||||||
|
|
||||||
|
if (!sdev)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (sdev->ref_cnt == 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
sdev->ref_cnt--;
|
||||||
|
if (sdev->ref_cnt == 0)
|
||||||
|
ret = SensorDeviceClose(sdev);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Read quantity current value
|
||||||
|
* @param quant - sensor quantity pointer
|
||||||
|
* @return quantity value
|
||||||
|
*/
|
||||||
|
int SensorQuantityRead(struct SensorQuantity *quant)
|
||||||
|
{
|
||||||
|
if (!quant)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
int result = 0;
|
||||||
|
struct SensorDevice *sdev = quant->sdev;
|
||||||
|
|
||||||
|
if (!sdev)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (quant->ReadValue != NULL) {
|
||||||
|
result = quant->ReadValue(quant);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Configure quantity mode
|
||||||
|
* @param quant - sensor quantity pointer
|
||||||
|
* @param cmd - mode command
|
||||||
|
* @return success: 0 , failure: other
|
||||||
|
*/
|
||||||
|
int SensorQuantityControl(struct SensorQuantity *quant, int cmd)
|
||||||
|
{
|
||||||
|
if (!quant)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (quant->sdev->done->ioctl != NULL) {
|
||||||
|
return quant->sdev->done->ioctl(quant->sdev, cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ============================= Check function ============================= */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: CRC16 check
|
||||||
|
* @param data sensor receive buffer
|
||||||
|
* @param length sensor receive buffer minus check code
|
||||||
|
* @return check code
|
||||||
|
*/
|
||||||
|
uint32_t Crc16(uint8_t * data, uint8_t length)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
unsigned int reg_crc=0xFFFF;
|
||||||
|
|
||||||
|
while (length--) {
|
||||||
|
reg_crc ^= *data++;
|
||||||
|
for (j=0;j<8;j++) {
|
||||||
|
if(reg_crc & 0x01)
|
||||||
|
reg_crc=reg_crc >>1 ^ 0xA001;
|
||||||
|
else
|
||||||
|
reg_crc=reg_crc >>1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return reg_crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: The checksum
|
||||||
|
* @param data sensor receive buffer
|
||||||
|
* @param head not check head length
|
||||||
|
* @param length sensor receive buffer minus check code
|
||||||
|
* @return check code
|
||||||
|
*/
|
||||||
|
uint8_t GetCheckSum(uint8_t *data, uint8_t head, uint8_t length)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
uint8_t checksum = 0;
|
||||||
|
for (i = head; i < length; i++) {
|
||||||
|
checksum += data[i];
|
||||||
|
}
|
||||||
|
checksum = ~checksum + 1;
|
||||||
|
|
||||||
|
return checksum;
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
/*
|
||||||
|
* 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 sensor.h
|
||||||
|
* @brief Structure and function declarations of the sensor framework
|
||||||
|
* @version 1.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.03.24
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SENSOR_H
|
||||||
|
#define SENSOR_H
|
||||||
|
|
||||||
|
#include <list.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <transform.h>
|
||||||
|
|
||||||
|
#define SENSOR_QUANTITY_VALUE_ERROR ((uint32_t)0xffffffff)
|
||||||
|
|
||||||
|
/* Sensor quantity report mode */
|
||||||
|
#define SENSOR_DEVICE_PASSIVE 0x00
|
||||||
|
#define SENSOR_DEVICE_ACTIVE 0x01
|
||||||
|
|
||||||
|
#define SENSOR_RECEIVE_BUFFSIZE 32
|
||||||
|
|
||||||
|
|
||||||
|
#if SENSOR_TYPE_END > 32
|
||||||
|
#error "Too many sensor types"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Sensor ability */
|
||||||
|
#define SENSOR_ABILITY_CO2 ((uint32_t)(1 << SENSOR_QUANTITY_CO2))
|
||||||
|
#define SENSOR_ABILITY_TEMP ((uint32_t)(1 << SENSOR_QUANTITY_TEMP))
|
||||||
|
#define SENSOR_ABILITY_HUMI ((uint32_t)(1 << SENSOR_QUANTITY_HUMI))
|
||||||
|
#define SENSOR_ABILITY_HCHO ((uint32_t)(1 << SENSOR_QUANTITY_HCHO))
|
||||||
|
#define SENSOR_ABILITY_CO ((uint32_t)(1 << SENSOR_QUANTITY_CO))
|
||||||
|
#define SENSOR_ABILITY_PM ((uint32_t)(1 << SENSOR_QUANTITY_PM))
|
||||||
|
#define SENSOR_ABILITY_VOICE ((uint32_t)(1 << SENSOR_QUANTITY_VOICE))
|
||||||
|
|
||||||
|
struct SensorProductInfo {
|
||||||
|
uint32_t ability; /* Bitwise OR of sensor ability */
|
||||||
|
const char *vendor_name;
|
||||||
|
const char *model_name;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SensorDevice;
|
||||||
|
|
||||||
|
struct SensorDone {
|
||||||
|
int (*open)(struct SensorDevice *sdev);
|
||||||
|
int (*close)(struct SensorDevice *sdev);
|
||||||
|
int (*read)(struct SensorDevice *sdev, size_t len);
|
||||||
|
int (*write)(struct SensorDevice *sdev, const void *buf, size_t len);
|
||||||
|
int (*ioctl)(struct SensorDevice *sdev, int cmd);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SensorDevice {
|
||||||
|
char *name; /* Name of sensor */
|
||||||
|
struct SensorProductInfo *info; /* Sensor model info */
|
||||||
|
struct SensorDone *done;
|
||||||
|
int fd; /* File descriptor */
|
||||||
|
int status; /* Sensor work mode */
|
||||||
|
uint8_t buffer[SENSOR_RECEIVE_BUFFSIZE]; /* Buffer for read data */
|
||||||
|
|
||||||
|
int ref_cnt; /* Reference count */
|
||||||
|
DoubleLinklistType quant_list; /* Sensor quantity link */
|
||||||
|
struct SysDoubleLinklistNode link; /* Sensors link node */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum SensorQuantityType {
|
||||||
|
SENSOR_QUANTITY_CO2 = 0,
|
||||||
|
SENSOR_QUANTITY_TEMP,
|
||||||
|
SENSOR_QUANTITY_HUMI,
|
||||||
|
SENSOR_QUANTITY_HCHO,
|
||||||
|
SENSOR_QUANTITY_CO,
|
||||||
|
SENSOR_QUANTITY_PM,
|
||||||
|
SENSOR_QUANTITY_VOICE,
|
||||||
|
/* ...... */
|
||||||
|
SENSOR_QUANTITY_END,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SensorQuantityValue {
|
||||||
|
uint8_t decimal_places; /* The decimal place of the result */
|
||||||
|
uint32_t last_value; /* The last read value, if it does not exist, is SENSOR_QUANTITY_VALUE_ERROR */
|
||||||
|
uint32_t min_value; /* The minimum read value, if it does not exist, is SENSOR_QUANTITY_VALUE_ERROR */
|
||||||
|
uint32_t max_value; /* The maximum read value, if it does not exist, is SENSOR_QUANTITY_VALUE_ERROR */
|
||||||
|
uint32_t min_std; /* The minimum standard value, if it does not exist, is SENSOR_QUANTITY_VALUE_ERROR */
|
||||||
|
uint32_t max_std; /* The maximum standard value, if it does not exist, is SENSOR_QUANTITY_VALUE_ERROR */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SensorQuantity {
|
||||||
|
char *name;
|
||||||
|
enum SensorQuantityType type;
|
||||||
|
struct SensorQuantityValue value;
|
||||||
|
struct SensorDevice *sdev;
|
||||||
|
|
||||||
|
int32_t (*ReadValue)(struct SensorQuantity *quant);
|
||||||
|
|
||||||
|
struct SysDoubleLinklistNode quant_link;
|
||||||
|
struct SysDoubleLinklistNode link;
|
||||||
|
};
|
||||||
|
|
||||||
|
int SensorDeviceRegister(struct SensorDevice *sdev);
|
||||||
|
int SensorDeviceUnregister(struct SensorDevice *sdev);
|
||||||
|
|
||||||
|
struct SensorQuantity *SensorQuantityFind(const char *name, enum SensorQuantityType type);
|
||||||
|
int SensorQuantityRegister(struct SensorQuantity *quant);
|
||||||
|
int SensorQuantityUnregister(struct SensorQuantity *quant);
|
||||||
|
int SensorQuantityOpen(struct SensorQuantity *quant);
|
||||||
|
int SensorQuantityClose(struct SensorQuantity *quant);
|
||||||
|
int32_t SensorQuantityRead(struct SensorQuantity *quant);
|
||||||
|
int SensorQuantityControl(struct SensorQuantity *quant, int cmd);
|
||||||
|
|
||||||
|
uint32_t Crc16(uint8_t * data, uint8_t length);
|
||||||
|
uint8_t GetCheckSum(uint8_t *data, uint8_t head, uint8_t length);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,149 @@
|
||||||
|
/*
|
||||||
|
* 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 transform.c
|
||||||
|
* @brief support to transform the application interface from private api to posix api
|
||||||
|
* @version 1.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.06.07
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <semaphore.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "transform.h"
|
||||||
|
|
||||||
|
//for test
|
||||||
|
#define XIUOS_OS
|
||||||
|
|
||||||
|
#ifdef XIUOS_OS
|
||||||
|
/************************Kernel Posix Transform***********************/
|
||||||
|
|
||||||
|
|
||||||
|
/************************Driver Posix Transform***********************/
|
||||||
|
int PrivOpen(const char *path, int flags, ...)
|
||||||
|
{
|
||||||
|
return open(path, flags, ...);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivClose(int fd, void *buf, size_t len)
|
||||||
|
{
|
||||||
|
return close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivRead(int fd, void *buf, size_t len)
|
||||||
|
{
|
||||||
|
return read(fd, buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivWrite(int fd, const void *buf, size_t len)
|
||||||
|
{
|
||||||
|
return write(fd, buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int PrivSerialIoctl(int fd, void *args)
|
||||||
|
{
|
||||||
|
struct SerialDataCfg *serial_cfg = (struct SerialDataCfg *)args;
|
||||||
|
|
||||||
|
return ioctl(fd, OPE_INT, &serial_cfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivIoctl(int fd, int cmd, void *args)
|
||||||
|
{
|
||||||
|
struct PrivIoctlCfg *ioctl_cfg = (struct PrivIoctlCfg *)args;
|
||||||
|
|
||||||
|
switch (ioctl_cfg->ioctl_driver_type)
|
||||||
|
{
|
||||||
|
case SERIAL_TYPE:
|
||||||
|
PrivSerialIoctl(fd, ioctl_cfg->args);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* private mutex API */
|
||||||
|
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr)
|
||||||
|
{
|
||||||
|
return pthread_mutex_init(p_mutex, attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivMutexDelete(pthread_mutex_t *p_mutex)
|
||||||
|
{
|
||||||
|
return pthread_mutex_destroy(p_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivMutexObtain(pthread_mutex_t *p_mutex)
|
||||||
|
{
|
||||||
|
return pthread_mutex_lock(p_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivMutexAbandon(pthread_mutex_t *p_mutex)
|
||||||
|
{
|
||||||
|
return pthread_mutex_lock(p_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* private sem API */
|
||||||
|
int PrivSemaphoreCreate(sem_t *sem, int pshared, unsigned int value)
|
||||||
|
{
|
||||||
|
return sem_init(sem, pshared, value);
|
||||||
|
}
|
||||||
|
int PrivSemaphoreDelete(sem_t *sem)
|
||||||
|
{
|
||||||
|
return sem_destroy(sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivSemaphoreObtainWait(sem_t *sem, const struct timespec *abstime)
|
||||||
|
{
|
||||||
|
return sem_timedwait(sem, abstime);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivSemaphoreObtainNoWait(sem_t *sem)
|
||||||
|
{
|
||||||
|
return sem_trywait(sem);
|
||||||
|
}
|
||||||
|
int PrivSemaphoreAbandon(sem_t *sem)
|
||||||
|
{
|
||||||
|
return sem_post(sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* private task API */
|
||||||
|
|
||||||
|
int PrivTaskCreate(pthread_t *thread, const pthread_attr_t *attr,
|
||||||
|
void *(*start_routine)(void *), void *arg)
|
||||||
|
{
|
||||||
|
return pthread_create(thread, attr, start_routine, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivTaskStartup(pthread_t *thread)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivTaskDelete(pthread_t thread, int sig)
|
||||||
|
{
|
||||||
|
return pthread_kill(thread, sig);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrivTaskQuit(void *value_ptr)
|
||||||
|
{
|
||||||
|
pthread_exit(value_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivTaskDelay(const struct timespec *rqtp, struct timespec *rmtp)
|
||||||
|
{
|
||||||
|
nanosleep(rqtp,rmtp);
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,127 @@
|
||||||
|
/*
|
||||||
|
* 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 transform.h
|
||||||
|
* @brief define the struct and transform function
|
||||||
|
* @version 1.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.06.07
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <xiuos.h>
|
||||||
|
#include <iot-vfs.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <semaphore.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
//for test
|
||||||
|
#define XIUOS_OS
|
||||||
|
|
||||||
|
#define OPE_INT 0x0000
|
||||||
|
#define OPE_CFG 0x0001
|
||||||
|
|
||||||
|
#ifdef XIUOS_OS
|
||||||
|
|
||||||
|
/************************Serial Configure define***********************/
|
||||||
|
#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
|
||||||
|
|
||||||
|
struct SerialDataCfg
|
||||||
|
{
|
||||||
|
uint32_t serial_baud_rate;
|
||||||
|
uint8_t serial_data_bits;
|
||||||
|
uint8_t serial_stop_bits;
|
||||||
|
uint8_t serial_parity_mode;
|
||||||
|
uint8_t serial_bit_order;
|
||||||
|
uint8_t serial_invert_mode;
|
||||||
|
uint16_t serial_buffer_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
/************************Driver Posix Transform***********************/
|
||||||
|
enum IoctlDriverType
|
||||||
|
{
|
||||||
|
SERIAL_TYPE = 0,
|
||||||
|
SPI_TYPE,
|
||||||
|
I2C_TYPE,
|
||||||
|
DEFAULT_TYPE,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct PrivIoctlCfg
|
||||||
|
{
|
||||||
|
enum IoctlDriverType ioctl_driver_type;
|
||||||
|
void *args;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivOpen(const char *path, int flags, ...);
|
||||||
|
|
||||||
|
int PrivClose(int fd, void *buf, size_t len);
|
||||||
|
|
||||||
|
int PrivRead(int fd, void *buf, size_t len);
|
||||||
|
|
||||||
|
int PrivWrite(int fd, const void *buf, size_t len);
|
||||||
|
|
||||||
|
int PrivIoctl(int fd, int cmd, void *args);
|
||||||
|
|
||||||
|
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr);
|
||||||
|
int PrivMutexDelete(pthread_mutex_t *p_mutex);
|
||||||
|
int PrivMutexObtain(pthread_mutex_t *p_mutex);
|
||||||
|
int PrivMutexAbandon(pthread_mutex_t *p_mutex);
|
||||||
|
int PrivSemaphoreCreate(sem_t *sem, int pshared, unsigned int value);
|
||||||
|
int PrivSemaphoreDelete(sem_t *sem);
|
||||||
|
int PrivSemaphoreObtainWait(sem_t *sem, const struct timespec *abstime);
|
||||||
|
int PrivSemaphoreObtainNoWait(sem_t *sem);
|
||||||
|
int PrivSemaphoreAbandon(sem_t *sem);
|
||||||
|
int PrivTaskCreate(pthread_t *thread, const pthread_attr_t *attr,
|
||||||
|
void *(*start_routine)(void *), void *arg);
|
||||||
|
int PrivTaskStartup(pthread_t *thread);
|
||||||
|
int PrivTaskDelete(pthread_t thread, int sig);
|
||||||
|
void PrivTaskQuit(void *value_ptr);
|
||||||
|
int PrivTaskDelay(const struct timespec *rqtp, struct timespec *rmtp);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := xiuos/xiuos.c xiuos/userspace.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,131 @@
|
||||||
|
/*
|
||||||
|
* 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 transform.h
|
||||||
|
* @brief Interface function declarations required by the framework
|
||||||
|
* @version 1.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.06.04
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TRANSFORM_H
|
||||||
|
#define TRANSFORM_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define NAME_NUM_MAX 32
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
struct SerialDataCfg
|
||||||
|
{
|
||||||
|
uint32_t serial_baud_rate;
|
||||||
|
uint8_t serial_data_bits;
|
||||||
|
uint8_t serial_stop_bits;
|
||||||
|
uint8_t serial_parity_mode;
|
||||||
|
uint8_t serial_bit_order;
|
||||||
|
uint8_t serial_invert_mode;
|
||||||
|
uint16_t serial_buffer_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum IoctlCmd
|
||||||
|
{
|
||||||
|
SERIAL_CFG_SETS = 0,
|
||||||
|
SERIAL_CFG_GETS,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**********************mutex**************************/
|
||||||
|
|
||||||
|
int32_t PrivMutexCreate(void);
|
||||||
|
void PrivMutexDelete(int32_t mutex);
|
||||||
|
int32_t PrivMutexObtain(int32_t mutex, int32_t wait_time);
|
||||||
|
int32_t PrivMutexAbandon(int32_t mutex);
|
||||||
|
|
||||||
|
/*********************semaphore**********************/
|
||||||
|
|
||||||
|
int32_t PrivSemaphoreCreate(uint16_t val);
|
||||||
|
int32_t PrivSemaphoreDelete(int32_t sem);
|
||||||
|
int32_t PrivSemaphoreObtain(int32_t sem, int32_t wait_time);
|
||||||
|
int32_t PrivSemaphoreAbandon(int32_t sem);
|
||||||
|
int32_t PrivSemaphoreSetValue(int32_t sem, uint16_t val);
|
||||||
|
|
||||||
|
/*********************task**************************/
|
||||||
|
|
||||||
|
struct utask
|
||||||
|
{
|
||||||
|
char name[NAME_NUM_MAX];
|
||||||
|
void *func_entry;
|
||||||
|
void *func_param;
|
||||||
|
int32_t stack_size;
|
||||||
|
uint8_t prio;
|
||||||
|
};
|
||||||
|
typedef struct utask UtaskType;
|
||||||
|
|
||||||
|
int32_t PrivTaskCreate(UtaskType utask);
|
||||||
|
int32_t PrivTaskStartup(int32_t id);
|
||||||
|
int32_t PrivTaskDelete(int32_t id);
|
||||||
|
void PrivTaskQuit(void);
|
||||||
|
int32_t PrivTaskDelay(int32_t ms);
|
||||||
|
|
||||||
|
int PrivOpen(const char *path, int flags, ...);
|
||||||
|
int PrivRead(int fd, void *buf, size_t len);
|
||||||
|
int PrivWrite(int fd, const void *buf, size_t len);
|
||||||
|
int PrivClose(int fd);
|
||||||
|
int PrivIoctl(int fd, int cmd, void *args);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,43 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
extern int main(void);
|
||||||
|
//extern void UserTaskQuit(void);
|
||||||
|
extern uintptr_t _ustext;
|
||||||
|
extern uintptr_t _uetext;
|
||||||
|
extern uintptr_t _ueronly;
|
||||||
|
extern uintptr_t _usdata;
|
||||||
|
extern uintptr_t _uedata;
|
||||||
|
extern uintptr_t _usbss;
|
||||||
|
extern uintptr_t _uebss;
|
||||||
|
typedef int (*main_t)(int argc, char *argv[]);
|
||||||
|
typedef void (*exit_t)(void);
|
||||||
|
struct userspace_s
|
||||||
|
{
|
||||||
|
main_t us_entrypoint;
|
||||||
|
exit_t us_taskquit;
|
||||||
|
uintptr_t us_textstart;
|
||||||
|
uintptr_t us_textend;
|
||||||
|
uintptr_t us_datasource;
|
||||||
|
uintptr_t us_datastart;
|
||||||
|
uintptr_t us_dataend;
|
||||||
|
uintptr_t us_bssstart;
|
||||||
|
uintptr_t us_bssend;
|
||||||
|
uintptr_t us_heapend;
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct userspace_s userspace __attribute__ ((section (".userspace"))) =
|
||||||
|
{
|
||||||
|
/* General memory map */
|
||||||
|
|
||||||
|
.us_entrypoint = (main_t)main,
|
||||||
|
//.us_taskquit = (exit_t)UserTaskQuit,
|
||||||
|
.us_textstart = (uintptr_t)&_ustext,
|
||||||
|
.us_textend = (uintptr_t)&_uetext,
|
||||||
|
.us_datasource = (uintptr_t)&_ueronly,
|
||||||
|
.us_datastart = (uintptr_t)&_usdata,
|
||||||
|
.us_dataend = (uintptr_t)&_uedata,
|
||||||
|
.us_bssstart = (uintptr_t)&_usbss,
|
||||||
|
.us_bssend = (uintptr_t)&_uebss,
|
||||||
|
|
||||||
|
};
|
|
@ -0,0 +1,124 @@
|
||||||
|
/*
|
||||||
|
* 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 xiuos.c
|
||||||
|
* @brief Converts the framework interface to an operating system interface
|
||||||
|
* @version 1.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021.06.07
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "transform.h"
|
||||||
|
|
||||||
|
/**************************mutex***************************/
|
||||||
|
|
||||||
|
int32_t PrivMutexCreate(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrivMutexDelete(int32_t mutex)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t PrivMutexObtain(int32_t mutex, int32_t wait_time)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t PrivMutexAbandon(int32_t mutex)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************semaphore****************************/
|
||||||
|
|
||||||
|
int32_t PrivSemaphoreCreate(uint16_t val)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t PrivSemaphoreDelete(int32_t sem)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t PrivSemaphoreObtain(int32_t sem, int32_t wait_time)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t PrivSemaphoreAbandon(int32_t sem)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t PrivSemaphoreSetValue(int32_t sem, uint16_t val)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************task*************************/
|
||||||
|
|
||||||
|
int32_t PrivTaskCreate(UtaskType utask)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t PrivTaskStartup(int32_t id)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t PrivTaskDelete(int32_t id)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrivTaskQuit(void)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t PrivTaskDelay(int32_t ms)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************fs**************************/
|
||||||
|
|
||||||
|
int PrivOpen(const char *path, int flags, ...)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivRead(int fd, void *buf, size_t len)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivWrite(int fd, const void *buf, size_t len)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivClose(int fd)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrivIoctl(int fd, int cmd, void *args)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
menu "APP_Framework"
|
||||||
|
|
||||||
|
config APP_DIR
|
||||||
|
string
|
||||||
|
option env="SRC_APP_DIR"
|
||||||
|
default "."
|
||||||
|
|
||||||
|
source "$APP_DIR/Applications/Kconfig"
|
||||||
|
|
||||||
|
endmenu
|
|
@ -0,0 +1,4 @@
|
||||||
|
SRC_DIR := Applications Framework lib
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_DIR := app_newlib
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := stdio.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file fs_syscalls.c
|
||||||
|
* @brief support newlib file system
|
||||||
|
* @version 1.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021-04-25
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
File name: fs_syscalls.c
|
||||||
|
Description: support newlib file system
|
||||||
|
Others: take RT-Thread v4.0.2/components/libc/compilers/newlib/syscalls.c for references
|
||||||
|
https://github.com/RT-Thread/rt-thread/tree/v4.0.2
|
||||||
|
History:
|
||||||
|
1. Date: 2021-04-25
|
||||||
|
Author: AIIT XUOS Lab
|
||||||
|
Modification: Use file system functions
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
#include <sys/errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int _close_r(struct _reent *ptr, int fd)
|
||||||
|
{
|
||||||
|
return close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _fstat_r(struct _reent *ptr, int fd, struct stat *pstat)
|
||||||
|
{
|
||||||
|
ptr->_errno = ENOTSUP;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _isatty_r(struct _reent *ptr, int fd)
|
||||||
|
{
|
||||||
|
if (fd >=0 && fd < 3)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
ptr->_errno = ENOTSUP;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _link_r(struct _reent *ptr, const char *old, const char *new)
|
||||||
|
{
|
||||||
|
ptr->_errno = ENOTSUP;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_off_t _lseek_r(struct _reent *ptr, int fd, _off_t pos, int whence)
|
||||||
|
{
|
||||||
|
return lseek(fd, pos, whence);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _open_r(struct _reent *ptr, const char *file, int flags, int mode)
|
||||||
|
{
|
||||||
|
return open(file, flags, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
_ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
|
||||||
|
{
|
||||||
|
return read(fd, buf, nbytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void * _sbrk_r(struct _reent *ptr, ptrdiff_t incr)
|
||||||
|
{
|
||||||
|
return NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _stat_r(struct _reent *ptr, const char *file, struct stat *pstat)
|
||||||
|
{
|
||||||
|
return stat(file, pstat);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _unlink_r(struct _reent *ptr, const char *file)
|
||||||
|
{
|
||||||
|
return unlink(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _wait_r(struct _reent *ptr, int *status)
|
||||||
|
{
|
||||||
|
ptr->_errno = ENOTSUP;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
|
||||||
|
{
|
||||||
|
return write(fd, buf, nbytes);
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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 libc.h
|
||||||
|
* @brief using newlib need include
|
||||||
|
* @version 1.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021-04-25
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LIBC_H__
|
||||||
|
#define _LIBC_H__
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file mem_syscalls.c
|
||||||
|
* @brief support newlib memory
|
||||||
|
* @version 1.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021-04-25
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
File name: mem_syscalls.c
|
||||||
|
Description: support newlib memory
|
||||||
|
Others: take RT-Thread v4.0.2/components/libc/compilers/newlib/syscalls.c for references
|
||||||
|
https://github.com/RT-Thread/rt-thread/tree/v4.0.2
|
||||||
|
History:
|
||||||
|
1. Date: 2021-04-25
|
||||||
|
Author: AIIT XUOS Lab
|
||||||
|
Modification: Use malloc, realloc, calloc and free functions
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
void *_malloc_r (struct _reent *ptr, size_t size)
|
||||||
|
{
|
||||||
|
void* result = (void*)UserMalloc(size);
|
||||||
|
|
||||||
|
if (result == NULL)
|
||||||
|
{
|
||||||
|
ptr->_errno = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *_realloc_r (struct _reent *ptr, void *old, size_t newlen)
|
||||||
|
{
|
||||||
|
void* result = (void*)UserRealloc(old, newlen);
|
||||||
|
|
||||||
|
if (result == NULL)
|
||||||
|
{
|
||||||
|
ptr->_errno = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *_calloc_r (struct _reent *ptr, size_t size, size_t len)
|
||||||
|
{
|
||||||
|
void* result = (void*)UserCalloc(size, len);
|
||||||
|
|
||||||
|
if (result == NULL)
|
||||||
|
{
|
||||||
|
ptr->_errno = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _free_r (struct _reent *ptr, void *address)
|
||||||
|
{
|
||||||
|
UserFree (address);
|
||||||
|
}
|
|
@ -0,0 +1,155 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2017/10/15 bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file stdio.c
|
||||||
|
* @brief support newlib stdio
|
||||||
|
* @version 1.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021-04-25
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
File name: stdio.c
|
||||||
|
Description: support newlib stdio
|
||||||
|
Others: take RT-Thread v4.0.2/components/libc/compilers/newlib/stdio.c for references
|
||||||
|
https://github.com/RT-Thread/rt-thread/tree/v4.0.2
|
||||||
|
History:
|
||||||
|
1. Date: 2021-04-25
|
||||||
|
Author: AIIT XUOS Lab
|
||||||
|
Modification: Use set and get console functions
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
#include <libc.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define STDIO_DEVICE_NAME_MAX 32
|
||||||
|
|
||||||
|
static FILE* std_console = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will set system console device.
|
||||||
|
*
|
||||||
|
* @param device_name the name of device
|
||||||
|
* @param mode the mode
|
||||||
|
*
|
||||||
|
* @return file number on success; or -1 on failure
|
||||||
|
*/
|
||||||
|
int LibcStdioSetConsole(const char* device_name, int mode)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
char name[STDIO_DEVICE_NAME_MAX];
|
||||||
|
char *file_mode;
|
||||||
|
|
||||||
|
snprintf(name, sizeof(name) - 1, "/dev/%s", device_name);
|
||||||
|
name[STDIO_DEVICE_NAME_MAX - 1] = '\0';
|
||||||
|
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case O_RDWR:
|
||||||
|
file_mode = "r+";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case O_WRONLY:
|
||||||
|
file_mode = "wb";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
file_mode = "rb";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* try to open file */
|
||||||
|
fp = fopen(name, file_mode);
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
|
/* set the fp buffer */
|
||||||
|
setvbuf(fp, NULL, _IONBF, 0);
|
||||||
|
|
||||||
|
if (std_console)
|
||||||
|
/* try to close console device */
|
||||||
|
fclose(std_console);
|
||||||
|
std_console = fp;
|
||||||
|
|
||||||
|
if (mode == O_RDWR)
|
||||||
|
{
|
||||||
|
/* set _stdin as std_console */
|
||||||
|
_GLOBAL_REENT->_stdin = std_console;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* set NULL */
|
||||||
|
_GLOBAL_REENT->_stdin = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == O_RDONLY)
|
||||||
|
{
|
||||||
|
/* set the _stdout as NULL */
|
||||||
|
_GLOBAL_REENT->_stdout = NULL;
|
||||||
|
/* set the _stderr as NULL */
|
||||||
|
_GLOBAL_REENT->_stderr = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* set the _stdout as std_console */
|
||||||
|
_GLOBAL_REENT->_stdout = std_console;
|
||||||
|
/* set the _stderr as std_console */
|
||||||
|
_GLOBAL_REENT->_stderr = std_console;
|
||||||
|
}
|
||||||
|
/* set the __sdidinit as 1 */
|
||||||
|
_GLOBAL_REENT->__sdidinit = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std_console)
|
||||||
|
/* return the file number */
|
||||||
|
return fileno(std_console);
|
||||||
|
/* failure and return -1 */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will get system console device.
|
||||||
|
*
|
||||||
|
* @return file number on success; or -1 on failure
|
||||||
|
*/
|
||||||
|
int LibcStdioGetConsole(void) {
|
||||||
|
if (std_console)
|
||||||
|
/* return the file number */
|
||||||
|
return fileno(std_console);
|
||||||
|
else
|
||||||
|
/* failure and return -1 */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will initialize the c library system.
|
||||||
|
*
|
||||||
|
* @return 0
|
||||||
|
*/
|
||||||
|
int LibcSystemInit(void)
|
||||||
|
{
|
||||||
|
#if defined(KERNEL_CONSOLE)
|
||||||
|
HardwareDevType console;
|
||||||
|
/* try to get console device */
|
||||||
|
console = ObtainConsole();
|
||||||
|
if (console)
|
||||||
|
{
|
||||||
|
#if defined(LIB_POSIX)
|
||||||
|
/* set console device mode */
|
||||||
|
LibcStdioSetConsole(console->dev_name, O_RDWR);
|
||||||
|
#else
|
||||||
|
/* set console device mode */
|
||||||
|
LibcStdioSetConsole(console->dev_name, O_WRONLY);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file task_syscalls.c
|
||||||
|
* @brief support newlib abort
|
||||||
|
* @version 1.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2021-04-25
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
File name: task_syscalls.c
|
||||||
|
Description: support newlib abort
|
||||||
|
Others: take RT-Thread v4.0.2/components/libc/compilers/newlib/syscalls.c for references
|
||||||
|
https://github.com/RT-Thread/rt-thread/tree/v4.0.2
|
||||||
|
History:
|
||||||
|
1. Date: 2021-04-25
|
||||||
|
Author: AIIT XUOS Lab
|
||||||
|
Modification: Use abort function
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
void abort(void)
|
||||||
|
{
|
||||||
|
KTaskDescriptorType current = GetKTaskDescriptor();
|
||||||
|
if (current)
|
||||||
|
{
|
||||||
|
KPrintf("Task:%-8.*s will be aborted!\n", NAME_NUM_MAX, current->task_base_info.name);
|
||||||
|
/* pend current task */
|
||||||
|
SuspendKTask(current->id.id);
|
||||||
|
/* schedule */
|
||||||
|
DO_KTASK_ASSIGN;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1);
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
time_t time(time_t *t)
|
||||||
|
{
|
||||||
|
NULL_PARAM_CHECK(t);
|
||||||
|
time_t current = 0;
|
||||||
|
|
||||||
|
#ifdef RESOURCES_RTC
|
||||||
|
struct RtcSetParam rtc_set_param;
|
||||||
|
rtc_set_param.rtc_set_cmd = OPER_RTC_GET_TIME;
|
||||||
|
rtc_set_param.time = ¤t;
|
||||||
|
|
||||||
|
RtcDrvSetFunction(RTC_DRV_NAME, &rtc_set_param);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
*t = current;
|
||||||
|
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
|
@ -7,4 +7,6 @@ source "$KERNEL_DIR/fs/Kconfig"
|
||||||
|
|
||||||
source "$KERNEL_DIR/framework/Kconfig"
|
source "$KERNEL_DIR/framework/Kconfig"
|
||||||
|
|
||||||
source "$KERNEL_DIR/applications/Kconfig"
|
source "$KERNEL_DIR/applications/Kconfig"
|
||||||
|
|
||||||
|
source "$KERNEL_DIR/../../APP_Framework/Kconfig"
|
||||||
|
|
|
@ -31,7 +31,7 @@ export HOSTTOOLS_DIR ?= $(KERNEL_ROOT)/tool/hosttools
|
||||||
export CONFIG2H_EXE ?= $(HOSTTOOLS_DIR)/xsconfig.sh
|
export CONFIG2H_EXE ?= $(HOSTTOOLS_DIR)/xsconfig.sh
|
||||||
|
|
||||||
export CPPPATHS
|
export CPPPATHS
|
||||||
export SRC_APP_DIR := applications framework
|
export SRC_APP_DIR := ../../APP_Framework
|
||||||
export SRC_KERNEL_DIR := arch board lib fs kernel resources tool
|
export SRC_KERNEL_DIR := arch board lib fs kernel resources tool
|
||||||
export SRC_DIR:= $(SRC_APP_DIR) $(SRC_KERNEL_DIR)
|
export SRC_DIR:= $(SRC_APP_DIR) $(SRC_KERNEL_DIR)
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ CFLAGS += $(DEFINES)
|
||||||
AFLAGS += $(DEFINES)
|
AFLAGS += $(DEFINES)
|
||||||
CXXFLAGS += $(DEFINES)
|
CXXFLAGS += $(DEFINES)
|
||||||
BUILD_DIR := $(KERNEL_ROOT)/build
|
BUILD_DIR := $(KERNEL_ROOT)/build
|
||||||
|
APP_DIR := Ubiquitous/XiUOS
|
||||||
|
|
||||||
|
|
||||||
.PHONY:COMPILER
|
.PHONY:COMPILER
|
||||||
|
@ -26,7 +27,7 @@ COMPILER:
|
||||||
################################################
|
################################################
|
||||||
define add_c_file
|
define add_c_file
|
||||||
$(eval COBJ := $(1:%.c=%.o)) \
|
$(eval COBJ := $(1:%.c=%.o)) \
|
||||||
$(eval COBJ := $(COBJ:$(KERNEL_ROOT)/%=%)) \
|
$(eval COBJ := $(subst $(subst $(APP_DIR),,$(KERNEL_ROOT)),,$(COBJ))) \
|
||||||
$(eval LOCALC := $(addprefix $(BUILD_DIR)/,$(COBJ))) \
|
$(eval LOCALC := $(addprefix $(BUILD_DIR)/,$(COBJ))) \
|
||||||
$(eval OBJS += $(LOCALC)) \
|
$(eval OBJS += $(LOCALC)) \
|
||||||
$(if $(strip $(LOCALC)),$(eval $(LOCALC): $(1)
|
$(if $(strip $(LOCALC)),$(eval $(LOCALC): $(1)
|
||||||
|
@ -39,7 +40,7 @@ endef
|
||||||
|
|
||||||
define add_cpp_file
|
define add_cpp_file
|
||||||
$(eval COBJ := $(1:%.cpp=%.o)) \
|
$(eval COBJ := $(1:%.cpp=%.o)) \
|
||||||
$(eval COBJ := $(COBJ:$(KERNEL_ROOT)/%=%)) \
|
$(eval COBJ := $(subst $(subst $(APP_DIR),,$(KERNEL_ROOT)),,$(COBJ))) \
|
||||||
$(eval LOCALCPP := $(addprefix $(BUILD_DIR)/,$(COBJ))) \
|
$(eval LOCALCPP := $(addprefix $(BUILD_DIR)/,$(COBJ))) \
|
||||||
$(eval OBJS += $(LOCALCPP)) \
|
$(eval OBJS += $(LOCALCPP)) \
|
||||||
$(if $(strip $(LOCALCPP)),$(eval $(LOCALCPP): $(1)
|
$(if $(strip $(LOCALCPP)),$(eval $(LOCALCPP): $(1)
|
||||||
|
@ -52,7 +53,7 @@ endef
|
||||||
|
|
||||||
define add_cc_file
|
define add_cc_file
|
||||||
$(eval COBJ := $(1:%.cc=%.o)) \
|
$(eval COBJ := $(1:%.cc=%.o)) \
|
||||||
$(eval COBJ := $(COBJ:$(KERNEL_ROOT)/%=%)) \
|
$(eval COBJ := $(subst $(subst $(APP_DIR),,$(KERNEL_ROOT)),,$(COBJ))) \
|
||||||
$(eval LOCALCPP := $(addprefix $(BUILD_DIR)/,$(COBJ))) \
|
$(eval LOCALCPP := $(addprefix $(BUILD_DIR)/,$(COBJ))) \
|
||||||
$(eval OBJS += $(LOCALCPP)) \
|
$(eval OBJS += $(LOCALCPP)) \
|
||||||
$(if $(strip $(LOCALCPP)),$(eval $(LOCALCPP): $(1)
|
$(if $(strip $(LOCALCPP)),$(eval $(LOCALCPP): $(1)
|
||||||
|
@ -65,7 +66,7 @@ endef
|
||||||
|
|
||||||
define add_S_file
|
define add_S_file
|
||||||
$(eval SOBJ := $(1:%.S=%.o)) \
|
$(eval SOBJ := $(1:%.S=%.o)) \
|
||||||
$(eval SOBJ := $(SOBJ:$(KERNEL_ROOT)/%=%)) \
|
$(eval SOBJ := $(subst $(subst $(APP_DIR),,$(KERNEL_ROOT)),,$(SOBJ))) \
|
||||||
$(eval LOCALS := $(addprefix $(BUILD_DIR)/,$(SOBJ))) \
|
$(eval LOCALS := $(addprefix $(BUILD_DIR)/,$(SOBJ))) \
|
||||||
$(eval OBJS += $(LOCALS)) \
|
$(eval OBJS += $(LOCALS)) \
|
||||||
$(if $(strip $(LOCALS)),$(eval $(LOCALS): $(1)
|
$(if $(strip $(LOCALS)),$(eval $(LOCALS): $(1)
|
||||||
|
|
|
@ -953,7 +953,7 @@ void *x_umalloc(x_size_t size)
|
||||||
lock = CriticalAreaLock();
|
lock = CriticalAreaLock();
|
||||||
/* alignment */
|
/* alignment */
|
||||||
size = ALIGN_MEN_UP(size, MEM_ALIGN_SIZE);
|
size = ALIGN_MEN_UP(size, MEM_ALIGN_SIZE);
|
||||||
ret = UserByteManager.dynamic_buddy_manager.done->malloc(&UserByteManager.dynamic_buddy_manager,size);
|
ret = UserByteManager.dynamic_buddy_manager.done->malloc(&UserByteManager.dynamic_buddy_manager,size, DYNAMIC_BLOCK_NO_EXTMEM_MASK);
|
||||||
if(ret != NONE)
|
if(ret != NONE)
|
||||||
CHECK(UserByteManager.dynamic_buddy_manager.done->JudgeLegal(&UserByteManager.dynamic_buddy_manager, ret - SIZEOF_DYNAMICALLOCNODE_MEM));
|
CHECK(UserByteManager.dynamic_buddy_manager.done->JudgeLegal(&UserByteManager.dynamic_buddy_manager, ret - SIZEOF_DYNAMICALLOCNODE_MEM));
|
||||||
|
|
||||||
|
|
|
@ -2,69 +2,10 @@
|
||||||
|
|
||||||
export APPPATHS :=-I$(BSP_ROOT) \
|
export APPPATHS :=-I$(BSP_ROOT) \
|
||||||
|
|
||||||
|
APPPATHS +=-I$(KERNEL_ROOT)/../../APP_Framework/Applications/general_functions/linklist \
|
||||||
APPPATHS +=-I$(KERNEL_ROOT)/applications/user_api/switch_api \
|
-I$(KERNEL_ROOT)/../../APP_Framework/lib/app_newlib/include \
|
||||||
-I$(KERNEL_ROOT)/applications/user_api/general_functions/linklist \
|
-I$(KERNEL_ROOT)/../../APP_Framework/Framework/sensor \
|
||||||
-I$(KERNEL_ROOT)/applications/user_api/include #
|
-I$(KERNEL_ROOT)/../../APP_Framework/Framework/transform_layer #
|
||||||
|
|
||||||
ifeq ($(CONFIG_CONNECTION_AT), y)
|
|
||||||
APPPATHS +=-I$(KERNEL_ROOT)/framework/connection/AT/at_device/inc \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/communication/wifi/esp8266 \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/communication/4G/air720 \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/communication/4G/ec20 \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/communication/4G/ec200x \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/communication/nbiot/bc26 \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/communication/nbiot/me3616 #
|
|
||||||
|
|
||||||
APPPATHS +=-I$(KERNEL_ROOT)/framework/connection/AT/at_protocol/include \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/AT/at_protocol/at_socket #
|
|
||||||
|
|
||||||
APPPATHS +=-I$(KERNEL_ROOT)/framework/connection/AT/sal_socket/include \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/AT/sal_socket/include/vfs_net \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/AT/sal_socket/include/socket \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/AT/sal_socket/include/socket/sys_socket \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/AT/sal_socket/impl #
|
|
||||||
|
|
||||||
APPPATHS +=-I$(KERNEL_ROOT)/framework/connection/AT/netdev/include #
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_CONNECTION_MQTT), y)
|
|
||||||
APPPATHS +=-I$(KERNEL_ROOT)/framework/connection/MQTT/MQTTClient-C \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/MQTT/MQTTPacket/src #
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_LORA), y)
|
|
||||||
APPPATHS +=-I$(KERNEL_ROOT)/framework/connection/Adapter/lora/inc \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/Adapter/lora/src/radio #
|
|
||||||
endif
|
|
||||||
|
|
||||||
APPPATHS +=-I$(KERNEL_ROOT)/framework/connection/Adapter/include \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/Adapter/4G \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/Adapter/5G \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/Adapter/bluetooth \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/Adapter/can \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/Adapter/ethernet \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/Adapter/lora \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/Adapter/nbiot \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/Adapter/rs485 \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/Adapter/wifi \
|
|
||||||
-I$(KERNEL_ROOT)/framework/connection/Adapter/zigbee #
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_PERCEPTION_SENSORDEVICE), y)
|
|
||||||
APPPATHS +=-I$(KERNEL_ROOT)/framework/perception
|
|
||||||
endif
|
|
||||||
|
|
||||||
APPPATHS +=-I$(KERNEL_ROOT)/lib/libcpp #
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_INTELLIGENT_TFLITE),y)
|
|
||||||
APPPATHS += \
|
|
||||||
-I$(KERNEL_ROOT)/framework/intelligent/tflite-mcu/source \
|
|
||||||
-I$(KERNEL_ROOT)/framework/intelligent/tflite-mcu/source/third_party/gemmlowp \
|
|
||||||
-I$(KERNEL_ROOT)/framework/intelligent/tflite-mcu/source/third_party/flatbuffers/include \
|
|
||||||
-I$(KERNEL_ROOT)/framework/intelligent/tflite-mcu/source/third_party/ruy
|
|
||||||
endif
|
|
||||||
|
|
||||||
APPPATHS += -I$(KERNEL_ROOT)/applications/app_newlib/include #
|
|
||||||
|
|
||||||
|
|
||||||
COMPILE_APP:
|
COMPILE_APP:
|
||||||
|
@ -74,6 +15,6 @@ COMPILE_APP:
|
||||||
$(MAKE) -C $$dir; \
|
$(MAKE) -C $$dir; \
|
||||||
done
|
done
|
||||||
@cp link.mk build/Makefile
|
@cp link.mk build/Makefile
|
||||||
@$(MAKE) -C build COMPILE_TYPE="_app" TARGET=XiaoShanOS_$(BOARD)_app.elf LINK_FLAGS=APPLFLAGS
|
@$(MAKE) -C build COMPILE_TYPE="_app" TARGET=XiUOS_$(BOARD)_app.elf LINK_FLAGS=APPLFLAGS
|
||||||
@rm build/Makefile build/make.obj
|
@rm build/Makefile build/make.obj
|
||||||
|
|
||||||
|
|
|
@ -217,6 +217,6 @@ COMPILE_KERNEL:
|
||||||
$(MAKE) -C $$dir; \
|
$(MAKE) -C $$dir; \
|
||||||
done
|
done
|
||||||
@cp link.mk build/Makefile
|
@cp link.mk build/Makefile
|
||||||
@$(MAKE) -C build COMPILE_TYPE="_kernel" TARGET=XiaoShanOS_$(BOARD)_kernel.elf LINK_FLAGS=LFLAGS
|
@$(MAKE) -C build COMPILE_TYPE="_kernel" TARGET=XiUOS_$(BOARD)_kernel.elf LINK_FLAGS=LFLAGS
|
||||||
@rm build/Makefile build/make.obj
|
@rm build/Makefile build/make.obj
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue