Initial commit: TXW82x FPV v2.7.0.7-42229 SDK + project sources
This commit is contained in:
68
csky/csi_kernel/rhino/core/include/k_api.h
Normal file
68
csky/csi_kernel/rhino/core/include/k_api.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_API_H
|
||||
#define K_API_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <k_config.h>
|
||||
#include <k_default_config.h>
|
||||
#include <k_types.h>
|
||||
#include <k_err.h>
|
||||
#include <k_critical.h>
|
||||
#include <k_sys.h>
|
||||
#include <k_bitmap.h>
|
||||
#include <k_list.h>
|
||||
#include <k_obj.h>
|
||||
#include <k_sched.h>
|
||||
#include <k_task.h>
|
||||
#include <k_ringbuf.h>
|
||||
#include <k_queue.h>
|
||||
#include <k_buf_queue.h>
|
||||
#include <k_sem.h>
|
||||
#include <k_task_sem.h>
|
||||
#include <k_mutex.h>
|
||||
#include <k_timer.h>
|
||||
#include <k_time.h>
|
||||
#include <k_event.h>
|
||||
#include <k_stats.h>
|
||||
#include <k_mm_debug.h>
|
||||
#include <k_mm_blk.h>
|
||||
#include <k_mm_region.h>
|
||||
#include <k_mm.h>
|
||||
#include <k_workqueue.h>
|
||||
#include <k_internal.h>
|
||||
#include <k_trace.h>
|
||||
#include <k_soc.h>
|
||||
#include <k_hook.h>
|
||||
#include <port.h>
|
||||
#include <k_endian.h>
|
||||
#include <k_fifo.h>
|
||||
|
||||
#ifndef __at_section
|
||||
#define __at_section(sec) __attribute__((section(sec)))
|
||||
#endif
|
||||
|
||||
#ifndef __bobj
|
||||
#define __bobj
|
||||
#endif
|
||||
|
||||
#ifndef __init
|
||||
#define __init
|
||||
#endif
|
||||
|
||||
extern void assert_internal(const char *__function, unsigned int __line, const char *__assertion, void *lr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* K_API_H */
|
||||
|
||||
108
csky/csi_kernel/rhino/core/include/k_bitmap.h
Normal file
108
csky/csi_kernel/rhino/core/include/k_bitmap.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_BITMAP_H
|
||||
#define K_BITMAP_H
|
||||
|
||||
#define BITMAP_UNIT_SIZE 32U
|
||||
#define BITMAP_UNIT_MASK 0X0000001F
|
||||
#define BITMAP_UNIT_BITS 5U
|
||||
|
||||
#define BITMAP_MASK(nr) (1UL << (BITMAP_UNIT_SIZE - 1U - ((nr) & BITMAP_UNIT_MASK)))
|
||||
#define BITMAP_WORD(nr) ((nr) >> BITMAP_UNIT_BITS)
|
||||
|
||||
|
||||
#define LITTLE_TO_BIG_ENDIAN(x) ((uint32_t)(((x) & 0x000000ffUL) << 24u) | \
|
||||
(((x) & 0x0000ff00UL) << 8u) | \
|
||||
(((x) & 0x00ff0000UL) >> 8u) | \
|
||||
(((x) & 0xff000000UL) >> 24u))
|
||||
|
||||
/**
|
||||
** This MACRO will declare a bitmap
|
||||
** @param[in] name the name of the bitmap to declare
|
||||
** @param[in] bits the bits of the bitmap
|
||||
** @return no return
|
||||
**/
|
||||
#define BITMAP_DECLARE(name, bits) uint32_t name[((bits) + (BITMAP_UNIT_SIZE - 1U)) >> BITMAP_UNIT_BITS]
|
||||
|
||||
#if (RHINO_CONFIG_BITMAP_HW != 0)
|
||||
extern int32_t cpu_bitmap_clz(uint32_t val);
|
||||
#endif
|
||||
|
||||
/**
|
||||
** This function will set a bit of the bitmap
|
||||
** @param[in] bitmap pointer to the bitmap
|
||||
** @param[in] nr position of the bitmap to set
|
||||
** @return no return
|
||||
**/
|
||||
RHINO_INLINE void krhino_bitmap_set(uint32_t *bitmap, int32_t nr)
|
||||
{
|
||||
bitmap[BITMAP_WORD(nr)] |= BITMAP_MASK(nr);
|
||||
}
|
||||
|
||||
/**
|
||||
** This function will clear a bit of the bitmap
|
||||
** @param[in] bitmap pointer to the bitmap
|
||||
** @param[in] nr position of the bitmap to clear
|
||||
** @return no return
|
||||
**/
|
||||
RHINO_INLINE void krhino_bitmap_clear(uint32_t *bitmap, int32_t nr)
|
||||
{
|
||||
bitmap[BITMAP_WORD(nr)] &= ~BITMAP_MASK(nr);
|
||||
}
|
||||
|
||||
/**
|
||||
** This function will find the first bit(1) of the bitmap
|
||||
** @param[in] bitmap pointer to the bitmap
|
||||
** @return the first bit position
|
||||
**/
|
||||
RHINO_INLINE int krhino_find_first_bit(uint32_t *bitmap)
|
||||
{
|
||||
int32_t nr = 0;
|
||||
uint32_t tmp = 0;
|
||||
|
||||
while (*bitmap == 0UL) {
|
||||
nr += BITMAP_UNIT_SIZE;
|
||||
bitmap++;
|
||||
}
|
||||
|
||||
tmp = *bitmap;
|
||||
|
||||
#if (RHINO_CONFIG_LITTLE_ENDIAN == 0)
|
||||
tmp = LITTLE_TO_BIG_ENDIAN(tmp);
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_BITMAP_HW == 0)
|
||||
if (!(tmp & 0XFFFF0000)) {
|
||||
tmp <<= 16;
|
||||
nr += 16;
|
||||
}
|
||||
|
||||
if (!(tmp & 0XFF000000)) {
|
||||
tmp <<= 8;
|
||||
nr += 8;
|
||||
}
|
||||
|
||||
if (!(tmp & 0XF0000000)) {
|
||||
tmp <<= 4;
|
||||
nr += 4;
|
||||
}
|
||||
|
||||
if (!(tmp & 0XC0000000)) {
|
||||
tmp <<= 2;
|
||||
nr += 2;
|
||||
}
|
||||
|
||||
if (!(tmp & 0X80000000)) {
|
||||
nr += 1;
|
||||
}
|
||||
#else
|
||||
nr += cpu_bitmap_clz(tmp);
|
||||
#endif
|
||||
|
||||
return nr;
|
||||
}
|
||||
|
||||
#endif /* K_BITMAP_H */
|
||||
|
||||
122
csky/csi_kernel/rhino/core/include/k_buf_queue.h
Normal file
122
csky/csi_kernel/rhino/core/include/k_buf_queue.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_BUF_QUEUE_H
|
||||
#define K_BUF_QUEUE_H
|
||||
|
||||
typedef struct {
|
||||
blk_obj_t blk_obj;
|
||||
blk_obj_t sblk_obj;
|
||||
void *buf;
|
||||
k_ringbuf_t ringbuf;
|
||||
size_t max_msg_size;
|
||||
size_t cur_num;
|
||||
size_t peak_num;
|
||||
size_t min_free_buf_size;
|
||||
#if (RHINO_CONFIG_SYSTEM_STATS > 0)
|
||||
klist_t buf_queue_item;
|
||||
#endif
|
||||
uint8_t mm_alloc_flag;
|
||||
} kbuf_queue_t;
|
||||
|
||||
typedef struct {
|
||||
size_t buf_size;
|
||||
size_t max_msg_size;
|
||||
size_t cur_num;
|
||||
size_t peak_num;
|
||||
size_t free_buf_size;
|
||||
size_t min_free_buf_size;
|
||||
} kbuf_queue_info_t;
|
||||
|
||||
/**
|
||||
* This function will create a buf-queue
|
||||
* @param[in] queue pointer to the queue(the space is provided by user)
|
||||
* @param[in] name name of the queue
|
||||
* @param[in] buf pointer to the buf
|
||||
* @param[in] size size of the buf
|
||||
* @param[in] max_msg max size of one msg
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_buf_queue_create(kbuf_queue_t *queue, const name_t *name,
|
||||
void *buf,
|
||||
size_t size, size_t max_msg);
|
||||
|
||||
/**
|
||||
* This function will create a fix buf-queue
|
||||
* @param[in] queue pointer to the queue(the space is provided by user)
|
||||
* @param[in] name name of the queue
|
||||
* @param[in] buf pointer to the buf
|
||||
* @param[in] msg_size size of the msg
|
||||
* @param[in] msg_num number of msg
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_fix_buf_queue_create(kbuf_queue_t *queue, const name_t *name,
|
||||
void *buf, size_t msg_size, size_t msg_num);
|
||||
|
||||
/**
|
||||
* This function will delete a queue
|
||||
* @param[in] queue pointer to the queue
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_buf_queue_del(kbuf_queue_t *queue);
|
||||
|
||||
#if (RHINO_CONFIG_KOBJ_DYN_ALLOC > 0)
|
||||
/**
|
||||
* This function will create a dyn-queue
|
||||
* @param[out] queue pointer to the queue(The space is provided by kernel)
|
||||
* @param[in] name pointer to the nam
|
||||
* @param[in] size size of the buf
|
||||
* @param[in] max_msg max size of one msg
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_buf_queue_dyn_create(kbuf_queue_t **queue, const name_t *name,
|
||||
size_t size, size_t max_msg);
|
||||
|
||||
/**
|
||||
* This function will delete a dyn-queue
|
||||
* @param[in] queue pointer to the queue
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_buf_queue_dyn_del(kbuf_queue_t *queue);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function will send a msg at the end of queue
|
||||
* @param[in] queue pointer to the queue
|
||||
* @param[in] msg pointer to msg to be send
|
||||
* @param[in] size size of the msg
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_buf_queue_send(kbuf_queue_t *queue, void *msg, size_t size, tick_t ticks);
|
||||
|
||||
|
||||
/**
|
||||
* This function will receive msg form aqueue
|
||||
* @param[in] queue pointer to the queue
|
||||
* @param[in] ticks ticks to wait before receiving msg
|
||||
* @param[out] msg pointer to the buf to save msg
|
||||
* @param[out] size size of received msg
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_buf_queue_recv(kbuf_queue_t *queue, tick_t ticks, void *msg,
|
||||
size_t *size);
|
||||
|
||||
/**
|
||||
* This function will reset queue
|
||||
* @param[in] queue pointer to the queue
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_buf_queue_flush(kbuf_queue_t *queue);
|
||||
|
||||
/**
|
||||
* This function will get information of a queue
|
||||
* @param[in] queue pointer to the queue
|
||||
* @param[out] free free size of the queue buf
|
||||
* @param[out] total total size of the queue buf
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_buf_queue_info_get(kbuf_queue_t *queue, kbuf_queue_info_t *info);
|
||||
|
||||
#endif /* K_BUF_QUEUE_H */
|
||||
|
||||
132
csky/csi_kernel/rhino/core/include/k_critical.h
Normal file
132
csky/csi_kernel/rhino/core/include/k_critical.h
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_CRITICAL_H
|
||||
#define K_CRITICAL_H
|
||||
|
||||
typedef struct {
|
||||
#if (RHINO_CONFIG_CPU_NUM > 1)
|
||||
uint32_t owner; /* cpu index of owner */
|
||||
#endif
|
||||
uint32_t cnt;
|
||||
cpu_cpsr_t cpsr; /* the int key for this lock */
|
||||
} kspinlock_t;
|
||||
|
||||
#if (RHINO_CONFIG_CPU_NUM > 1)
|
||||
/* SMP spin lock */
|
||||
#define krhino_spin_lock(lock) do { \
|
||||
kspinlock_t *s = (kspinlock_t*)(lock); \
|
||||
cpu_spin_lock((lock)); \
|
||||
s->cnt++; \
|
||||
} while (0) \
|
||||
|
||||
#define krhino_spin_unlock(lock) do { \
|
||||
kspinlock_t *s = (kspinlock_t*)(lock); \
|
||||
s->cnt--; \
|
||||
if (s->cnt == 0u) { \
|
||||
cpu_spin_unlock((lock)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define krhino_spin_lock_irq_save(lock) do { \
|
||||
kspinlock_t *s = (kspinlock_t*)(lock); \
|
||||
s->cpsr = cpu_intrpt_save(); \
|
||||
cpu_spin_lock((lock)); \
|
||||
s->cnt++; \
|
||||
} while (0)
|
||||
|
||||
#define krhino_spin_unlock_irq_restore(lock) do { \
|
||||
kspinlock_t *s = (kspinlock_t*)(lock); \
|
||||
s->cnt--; \
|
||||
if (s->cnt == 0u) { \
|
||||
cpu_spin_unlock((lock)); \
|
||||
cpu_intrpt_restore(s->cpsr); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define krhino_spin_init(lock) do{ \
|
||||
kspinlock_t *s = (kspinlock_t*)(lock); \
|
||||
s->owner = (uint32_t)-1; \
|
||||
s->cnt = 0u; \
|
||||
} while(0)
|
||||
#else
|
||||
/* UP spin lock */
|
||||
#define krhino_spin_lock(lock) krhino_sched_disable();
|
||||
#define krhino_spin_unlock(lock) krhino_sched_enable();
|
||||
|
||||
#define krhino_spin_lock_irq_save(lock) do { \
|
||||
kspinlock_t *s = (kspinlock_t*)(lock); \
|
||||
s->cpsr = cpu_intrpt_save(); \
|
||||
s->cnt++; \
|
||||
} while (0)
|
||||
|
||||
#define krhino_spin_unlock_irq_restore(lock) do { \
|
||||
kspinlock_t *s = (kspinlock_t*)(lock); \
|
||||
s->cnt--; \
|
||||
if (s->cnt == 0u) { \
|
||||
cpu_intrpt_restore(s->cpsr); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define krhino_spin_init(lock)
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_DISABLE_INTRPT_STATS > 0)
|
||||
#define RHINO_CRITICAL_ENTER() \
|
||||
do { \
|
||||
RHINO_CPU_INTRPT_DISABLE(); \
|
||||
intrpt_disable_measure_start(); \
|
||||
} while (0)
|
||||
|
||||
#define RHINO_CRITICAL_EXIT() \
|
||||
do { \
|
||||
intrpt_disable_measure_stop(); \
|
||||
RHINO_CPU_INTRPT_ENABLE(); \
|
||||
} while (0)
|
||||
|
||||
#if (RHINO_CONFIG_CPU_NUM > 1)
|
||||
#define RHINO_CRITICAL_EXIT_SCHED() \
|
||||
do { \
|
||||
intrpt_disable_measure_stop(); \
|
||||
core_sched(); \
|
||||
RHINO_CPU_INTRPT_ENABLE(); \
|
||||
} while (0)
|
||||
#else
|
||||
#define RHINO_CRITICAL_EXIT_SCHED() \
|
||||
do { \
|
||||
intrpt_disable_measure_stop(); \
|
||||
RHINO_CPU_INTRPT_ENABLE(); \
|
||||
core_sched(); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#else /* RHINO_CONFIG_DISABLE_INTRPT_STATS */
|
||||
#define RHINO_CRITICAL_ENTER() \
|
||||
do { \
|
||||
RHINO_CPU_INTRPT_DISABLE(); \
|
||||
} while (0)
|
||||
|
||||
#define RHINO_CRITICAL_EXIT() \
|
||||
do { \
|
||||
RHINO_CPU_INTRPT_ENABLE(); \
|
||||
} while (0)
|
||||
|
||||
#if (RHINO_CONFIG_CPU_NUM > 1)
|
||||
#define RHINO_CRITICAL_EXIT_SCHED() \
|
||||
do { \
|
||||
core_sched(); \
|
||||
RHINO_CPU_INTRPT_ENABLE(); \
|
||||
} while (0)
|
||||
#else
|
||||
#define RHINO_CRITICAL_EXIT_SCHED() \
|
||||
do { \
|
||||
RHINO_CPU_INTRPT_ENABLE(); \
|
||||
core_sched(); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif /* RHINO_CONFIG_DISABLE_INTRPT_STATS */
|
||||
|
||||
#endif /* K_CRITICAL_H */
|
||||
|
||||
314
csky/csi_kernel/rhino/core/include/k_default_config.h
Normal file
314
csky/csi_kernel/rhino/core/include/k_default_config.h
Normal file
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_DEFAULT_CONFIG_H
|
||||
#define K_DEFAULT_CONFIG_H
|
||||
|
||||
#ifndef RHINO_CONFIG_CPU_PWR_MGMT
|
||||
#define RHINO_CONFIG_CPU_PWR_MGMT 0
|
||||
#endif
|
||||
|
||||
/* leave this option as default unless your compiler does not support 64 bit data such as uint64_t */
|
||||
#ifndef RHINO_CONFIG_64_BIT_TYPE
|
||||
#define RHINO_CONFIG_64_BIT_TYPE 1
|
||||
#endif
|
||||
|
||||
/* chip level conf */
|
||||
#ifndef RHINO_CONFIG_LITTLE_ENDIAN
|
||||
#define RHINO_CONFIG_LITTLE_ENDIAN 1
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_CPU_STACK_DOWN
|
||||
#define RHINO_CONFIG_CPU_STACK_DOWN 1
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_BITMAP_HW
|
||||
#define RHINO_CONFIG_BITMAP_HW 0
|
||||
#endif
|
||||
|
||||
/* kernel feature conf */
|
||||
#ifndef RHINO_CONFIG_SEM
|
||||
#define RHINO_CONFIG_SEM 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_QUEUE
|
||||
#define RHINO_CONFIG_QUEUE 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TASK_SEM
|
||||
#define RHINO_CONFIG_TASK_SEM 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_WORKQUEUE
|
||||
#define RHINO_CONFIG_WORKQUEUE 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_WORKQUEUE_STACK_SIZE
|
||||
#define RHINO_CONFIG_WORKQUEUE_STACK_SIZE 512
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_WORKQUEUE_TASK_PRIO
|
||||
#define RHINO_CONFIG_WORKQUEUE_TASK_PRIO 9
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_EVENT_FLAG
|
||||
#define RHINO_CONFIG_EVENT_FLAG 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TIMER
|
||||
#define RHINO_CONFIG_TIMER 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_BUF_QUEUE
|
||||
#define RHINO_CONFIG_BUF_QUEUE 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_MM_BLK
|
||||
#define RHINO_CONFIG_MM_BLK 1
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_MM_TLF
|
||||
#define RHINO_CONFIG_MM_TLF 1
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_MM_MAXMSIZEBIT
|
||||
#define RHINO_CONFIG_MM_MAXMSIZEBIT 20
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_MM_TLF_BLK_SIZE
|
||||
#define RHINO_CONFIG_MM_TLF_BLK_SIZE 8192
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_MM_DEBUG
|
||||
#define RHINO_CONFIG_MM_DEBUG 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_GCC_RETADDR
|
||||
#define RHINO_CONFIG_GCC_RETADDR 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_MM_LEAKCHECK
|
||||
#define RHINO_CONFIG_MM_LEAKCHECK 0
|
||||
#endif
|
||||
|
||||
#ifndef K_MM_STATISTIC
|
||||
#define K_MM_STATISTIC 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TASK_SEM
|
||||
#define RHINO_CONFIG_TASK_SEM 0
|
||||
#endif
|
||||
|
||||
/* kernel task conf */
|
||||
#ifndef RHINO_CONFIG_TASK_PRI_CHG
|
||||
#define RHINO_CONFIG_TASK_PRI_CHG 1
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TASK_INFO
|
||||
#define RHINO_CONFIG_TASK_INFO 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TASK_INFO_NUM
|
||||
#define RHINO_CONFIG_TASK_INFO_NUM 2
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TASK_DEL
|
||||
#define RHINO_CONFIG_TASK_DEL 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TASK_STACK_CUR_CHECK
|
||||
#define RHINO_CONFIG_TASK_STACK_CUR_CHECK 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TASK_WAIT_ABORT
|
||||
#define RHINO_CONFIG_TASK_WAIT_ABORT 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_SCHED_RR
|
||||
#define RHINO_CONFIG_SCHED_RR 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TIME_SLICE_DEFAULT
|
||||
#define RHINO_CONFIG_TIME_SLICE_DEFAULT 50
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_PRI_MAX
|
||||
#define RHINO_CONFIG_PRI_MAX 62
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_USER_PRI_MAX
|
||||
#define RHINO_CONFIG_USER_PRI_MAX (RHINO_CONFIG_PRI_MAX - 2)
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_RINGBUF_VENDOR
|
||||
#define RHINO_CONFIG_RINGBUF_VENDOR 0
|
||||
#endif
|
||||
|
||||
/* kernel mm_region conf */
|
||||
#ifndef RHINO_CONFIG_MM_REGION_MUTEX
|
||||
#define RHINO_CONFIG_MM_REGION_MUTEX 1
|
||||
#endif
|
||||
|
||||
/* kernel timer&tick conf */
|
||||
#ifndef RHINO_CONFIG_HW_COUNT
|
||||
#define RHINO_CONFIG_HW_COUNT 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TICKS_PER_SECOND
|
||||
#define RHINO_CONFIG_TICKS_PER_SECOND 100
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TIMER_TASK_STACK_SIZE
|
||||
#define RHINO_CONFIG_TIMER_TASK_STACK_SIZE 200
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TIMER_RATE
|
||||
#define RHINO_CONFIG_TIMER_RATE 1
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TIMER_TASK_PRI
|
||||
#define RHINO_CONFIG_TIMER_TASK_PRI 5
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TIMER_MSG_NUM
|
||||
#define RHINO_CONFIG_TIMER_MSG_NUM 20
|
||||
#endif
|
||||
|
||||
/* kernel intrpt conf */
|
||||
#ifndef RHINO_CONFIG_INTRPT_STACK_REMAIN_GET
|
||||
#define RHINO_CONFIG_INTRPT_STACK_REMAIN_GET 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_INTRPT_MAX_NESTED_LEVEL
|
||||
#define RHINO_CONFIG_INTRPT_MAX_NESTED_LEVEL 188u
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_INTRPT_GUARD
|
||||
#define RHINO_CONFIG_INTRPT_GUARD 0
|
||||
#endif
|
||||
|
||||
/* kernel stack ovf check */
|
||||
#ifndef RHINO_CONFIG_INTRPT_STACK_OVF_CHECK
|
||||
#define RHINO_CONFIG_INTRPT_STACK_OVF_CHECK 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TASK_STACK_OVF_CHECK
|
||||
#define RHINO_CONFIG_TASK_STACK_OVF_CHECK 0
|
||||
#endif
|
||||
|
||||
/* kernel dyn alloc conf */
|
||||
#ifndef RHINO_CONFIG_KOBJ_DYN_ALLOC
|
||||
#define RHINO_CONFIG_KOBJ_DYN_ALLOC 0
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_KOBJ_DYN_ALLOC > 0)
|
||||
|
||||
#ifndef RHINO_CONFIG_K_DYN_QUEUE_MSG
|
||||
#define RHINO_CONFIG_K_DYN_QUEUE_MSG 30
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_K_DYN_TASK_STACK
|
||||
#define RHINO_CONFIG_K_DYN_TASK_STACK 256
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_K_DYN_MEM_TASK_PRI
|
||||
#define RHINO_CONFIG_K_DYN_MEM_TASK_PRI RHINO_CONFIG_USER_PRI_MAX
|
||||
#endif
|
||||
|
||||
#endif /* RHINO_CONFIG_KOBJ_DYN_ALLOC */
|
||||
|
||||
/* kernel idle conf */
|
||||
#ifndef RHINO_CONFIG_IDLE_TASK_STACK_SIZE
|
||||
#define RHINO_CONFIG_IDLE_TASK_STACK_SIZE 100
|
||||
#endif
|
||||
|
||||
/* kernel hook conf */
|
||||
#ifndef RHINO_CONFIG_USER_HOOK
|
||||
#define RHINO_CONFIG_USER_HOOK 1
|
||||
#endif
|
||||
|
||||
/* kernel stats conf */
|
||||
#ifndef RHINO_CONFIG_SYSTEM_STATS
|
||||
#define RHINO_CONFIG_SYSTEM_STATS 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_DISABLE_SCHED_STATS
|
||||
#define RHINO_CONFIG_DISABLE_SCHED_STATS 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_DISABLE_INTRPT_STATS
|
||||
#define RHINO_CONFIG_DISABLE_INTRPT_STATS 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_CPU_USAGE_STATS
|
||||
#define RHINO_CONFIG_CPU_USAGE_STATS 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_CPU_USAGE_TASK_PRI
|
||||
#define RHINO_CONFIG_CPU_USAGE_TASK_PRI (RHINO_CONFIG_PRI_MAX - 2)
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_TASK_SCHED_STATS
|
||||
#define RHINO_CONFIG_TASK_SCHED_STATS 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_CPU_USAGE_TASK_STACK
|
||||
#define RHINO_CONFIG_CPU_USAGE_TASK_STACK 256
|
||||
#endif
|
||||
|
||||
/* kernel trace conf */
|
||||
#ifndef RHINO_CONFIG_TRACE
|
||||
#define RHINO_CONFIG_TRACE 0
|
||||
#endif
|
||||
|
||||
#ifndef RHINO_CONFIG_CPU_NUM
|
||||
#define RHINO_CONFIG_CPU_NUM 1
|
||||
#endif
|
||||
|
||||
#ifdef RHINO_CONFIG_ISR_TASK
|
||||
#ifndef RHINO_CONFIG_ISR_BUFF_SIZE
|
||||
#define RHINO_CONFIG_ISR_BUFF_SIZE (16)
|
||||
#endif
|
||||
#ifndef RHINO_CONFIG_ISR_TASK_PRI
|
||||
#define RHINO_CONFIG_ISR_TASK_PRI (1)
|
||||
#endif
|
||||
#ifndef RHINO_CONFIG_ISR_TASK_STACK_SIZE
|
||||
#define RHINO_CONFIG_ISR_TASK_STACK_SIZE (1024)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ((RHINO_CONFIG_TIMER >= 1) && (RHINO_CONFIG_BUF_QUEUE == 0))
|
||||
#error "RHINO_CONFIG_BUF_QUEUE should be 1 when RHINO_CONFIG_TIMER is enabled."
|
||||
#endif
|
||||
|
||||
#if ((RHINO_CONFIG_MM_TLF >= 1) && (RHINO_CONFIG_MM_BLK == 0))
|
||||
#error "RHINO_CONFIG_MM_BLK should be 1 when RHINO_CONFIG_MM_TLF is enabled."
|
||||
#endif
|
||||
|
||||
#if ((RHINO_CONFIG_KOBJ_DYN_ALLOC >= 1) && (RHINO_CONFIG_MM_TLF == 0))
|
||||
#error "RHINO_CONFIG_MM_TLF should be 1 when RHINO_CONFIG_KOBJ_DYN_ALLOC is enabled."
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_PRI_MAX >= 256)
|
||||
#error "RHINO_CONFIG_PRI_MAX must be <= 255."
|
||||
#endif
|
||||
|
||||
#if ((RHINO_CONFIG_SEM == 0) && (RHINO_CONFIG_TASK_SEM >= 1))
|
||||
#error "you need enable RHINO_CONFIG_SEM as well."
|
||||
#endif
|
||||
|
||||
#if ((RHINO_CONFIG_HW_COUNT == 0) && (RHINO_CONFIG_TASK_SCHED_STATS >= 1))
|
||||
#error "you need enable RHINO_CONFIG_HW_COUNT as well."
|
||||
#endif
|
||||
|
||||
#if ((RHINO_CONFIG_HW_COUNT == 0) && (RHINO_CONFIG_DISABLE_SCHED_STATS >= 1))
|
||||
#error "you need enable RHINO_CONFIG_HW_COUNT as well."
|
||||
#endif
|
||||
|
||||
#if ((RHINO_CONFIG_HW_COUNT == 0) && (RHINO_CONFIG_DISABLE_INTRPT_STATS >= 1))
|
||||
#error "you need enable RHINO_CONFIG_HW_COUNT as well."
|
||||
#endif
|
||||
|
||||
#endif /* K_DEFAULT_CONFIG_H */
|
||||
|
||||
46
csky/csi_kernel/rhino/core/include/k_endian.h
Normal file
46
csky/csi_kernel/rhino/core/include/k_endian.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_ENDIAN_H
|
||||
#define K_ENDIAN_H
|
||||
|
||||
#if (RHINO_CONFIG_LITTLE_ENDIAN != 1)
|
||||
|
||||
#define krhino_htons(x) x
|
||||
#define krhino_htonl(x) x
|
||||
#define krhino_ntohl(x) x
|
||||
#define krhino_ntohs(x) x
|
||||
|
||||
#else
|
||||
|
||||
#ifndef krhino_htons
|
||||
#define krhino_htons(x) ((uint16_t)(((x) & 0x00ffU) << 8)| \
|
||||
(((x) & 0xff00U) >> 8))
|
||||
#endif
|
||||
|
||||
#ifndef krhino_htonl
|
||||
#define krhino_htonl(x) ((uint32_t)(((x) & 0x000000ffUL) << 24) | \
|
||||
(((x) & 0x0000ff00UL) << 8) | \
|
||||
(((x) & 0x00ff0000UL) >> 8) | \
|
||||
(((x) & 0xff000000UL) >> 24))
|
||||
#endif
|
||||
|
||||
#ifndef krhino_ntohs
|
||||
#define krhino_ntohs(x) ((uint16_t)((x & 0x00ffU) << 8) | \
|
||||
((x & 0xff00U) >> 8))
|
||||
#endif
|
||||
|
||||
#ifndef krhino_ntohl
|
||||
#define krhino_ntohl(x) ((uint32_t)(((x) & 0x000000ffUL) << 24) | \
|
||||
(((x) & 0x0000ff00UL) << 8) | \
|
||||
(((x) & 0x00ff0000UL) >> 8) | \
|
||||
(((x) & 0xff000000UL) >> 24))
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*RHINO_CONFIG_LITTLE_ENDIAN*/
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
95
csky/csi_kernel/rhino/core/include/k_err.h
Normal file
95
csky/csi_kernel/rhino/core/include/k_err.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_ERR_H
|
||||
#define K_ERR_H
|
||||
|
||||
typedef enum {
|
||||
RHINO_SUCCESS = 0u,
|
||||
RHINO_SYS_FATAL_ERR,
|
||||
RHINO_SYS_SP_ERR,
|
||||
RHINO_RUNNING,
|
||||
RHINO_STOPPED,
|
||||
RHINO_INV_PARAM,
|
||||
RHINO_NULL_PTR,
|
||||
RHINO_INV_ALIGN,
|
||||
RHINO_KOBJ_TYPE_ERR,
|
||||
RHINO_KOBJ_DEL_ERR,
|
||||
RHINO_KOBJ_DOCKER_EXIST,
|
||||
RHINO_KOBJ_BLK,
|
||||
RHINO_KOBJ_SET_FULL,
|
||||
RHINO_NOTIFY_FUNC_EXIST,
|
||||
|
||||
RHINO_MM_POOL_SIZE_ERR = 100u,
|
||||
RHINO_MM_ALLOC_SIZE_ERR,
|
||||
RHINO_MM_FREE_ADDR_ERR,
|
||||
RHINO_MM_CORRUPT_ERR,
|
||||
RHINO_DYN_MEM_PROC_ERR,
|
||||
RHINO_NO_MEM,
|
||||
RHINO_RINGBUF_FULL,
|
||||
RHINO_RINGBUF_EMPTY,
|
||||
|
||||
RHINO_SCHED_DISABLE = 200u,
|
||||
RHINO_SCHED_ALREADY_ENABLED,
|
||||
RHINO_SCHED_LOCK_COUNT_OVF,
|
||||
RHINO_INV_SCHED_WAY,
|
||||
|
||||
RHINO_TASK_INV_STACK_SIZE = 300u,
|
||||
RHINO_TASK_NOT_SUSPENDED,
|
||||
RHINO_TASK_DEL_NOT_ALLOWED,
|
||||
RHINO_TASK_SUSPEND_NOT_ALLOWED,
|
||||
RHINO_SUSPENDED_COUNT_OVF,
|
||||
RHINO_BEYOND_MAX_PRI,
|
||||
RHINO_PRI_CHG_NOT_ALLOWED,
|
||||
RHINO_INV_TASK_STATE,
|
||||
RHINO_IDLE_TASK_EXIST,
|
||||
|
||||
RHINO_NO_PEND_WAIT = 400u,
|
||||
RHINO_BLK_ABORT,
|
||||
RHINO_BLK_TIMEOUT,
|
||||
RHINO_BLK_DEL,
|
||||
RHINO_BLK_INV_STATE,
|
||||
RHINO_BLK_POOL_SIZE_ERR,
|
||||
|
||||
RHINO_TIMER_STATE_INV = 500u,
|
||||
|
||||
RHINO_NO_THIS_EVENT_OPT = 600u,
|
||||
|
||||
RHINO_BUF_QUEUE_INV_SIZE = 700u,
|
||||
RHINO_BUF_QUEUE_SIZE_ZERO,
|
||||
RHINO_BUF_QUEUE_FULL,
|
||||
RHINO_BUF_QUEUE_MSG_SIZE_OVERFLOW,
|
||||
RHINO_QUEUE_FULL,
|
||||
RHINO_QUEUE_NOT_FULL,
|
||||
|
||||
RHINO_SEM_OVF = 800u,
|
||||
RHINO_SEM_TASK_WAITING,
|
||||
|
||||
RHINO_MUTEX_NOT_RELEASED_BY_OWNER = 900u,
|
||||
RHINO_MUTEX_OWNER_NESTED,
|
||||
RHINO_MUTEX_NESTED_OVF,
|
||||
|
||||
RHINO_INTRPT_NESTED_LEVEL_OVERFLOW = 1000u,
|
||||
RHINO_INV_INTRPT_NESTED_LEVEL,
|
||||
RHINO_NOT_CALLED_BY_INTRPT,
|
||||
RHINO_TRY_AGAIN,
|
||||
|
||||
RHINO_WORKQUEUE_EXIST = 1100u,
|
||||
RHINO_WORKQUEUE_NOT_EXIST,
|
||||
RHINO_WORKQUEUE_WORK_EXIST,
|
||||
RHINO_WORKQUEUE_BUSY,
|
||||
RHINO_WORKQUEUE_WORK_RUNNING,
|
||||
|
||||
RHINO_TASK_STACK_OVF = 1200u,
|
||||
RHINO_INTRPT_STACK_OVF,
|
||||
RHINO_INTRPT_ISR_OVF,
|
||||
|
||||
} kstat_t;
|
||||
|
||||
typedef void (*krhino_err_proc_t)(kstat_t err);
|
||||
|
||||
extern krhino_err_proc_t g_err_proc;
|
||||
|
||||
#endif /* K_ERR_H */
|
||||
|
||||
84
csky/csi_kernel/rhino/core/include/k_event.h
Normal file
84
csky/csi_kernel/rhino/core/include/k_event.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_EVENT_H
|
||||
#define K_EVENT_H
|
||||
|
||||
typedef struct {
|
||||
blk_obj_t blk_obj;
|
||||
uint32_t flags;
|
||||
|
||||
#if (RHINO_CONFIG_SYSTEM_STATS > 0)
|
||||
klist_t event_item;
|
||||
#endif
|
||||
|
||||
uint8_t mm_alloc_flag;
|
||||
} kevent_t;
|
||||
|
||||
#define RHINO_FLAGS_AND_MASK 0x2u
|
||||
#define RHINO_FLAGS_CLEAR_MASK 0x1u
|
||||
|
||||
#define RHINO_AND 0x02u
|
||||
#define RHINO_AND_CLEAR 0x03u
|
||||
#define RHINO_OR 0x00u
|
||||
#define RHINO_OR_CLEAR 0x01u
|
||||
|
||||
/**
|
||||
* This function will create a event
|
||||
* @param[in] event pointer to the event
|
||||
* @param[in] name name of the event
|
||||
* @param[in] flags flags to be init
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_event_create(kevent_t *event, const name_t *name, uint32_t flags);
|
||||
|
||||
/**
|
||||
* This function will delete a event
|
||||
* @param[in] event pointer to a event
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_event_del(kevent_t *event);
|
||||
|
||||
#if (RHINO_CONFIG_KOBJ_DYN_ALLOC > 0)
|
||||
/**
|
||||
* This function will create a dyn-event
|
||||
* @param[out] event pointer to the event
|
||||
* @param[in] name name of the semaphore
|
||||
* @param[in] flags flags to be init
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_event_dyn_create(kevent_t **event, const name_t *name,
|
||||
uint32_t flags);
|
||||
|
||||
/**
|
||||
* This function will delete a dyn created event
|
||||
* @param[in] event pointer to a event
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_event_dyn_del(kevent_t *event);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function will get event
|
||||
* @param[in] event pointer to the event
|
||||
* @param[in] flags which is provided by users
|
||||
* @param[in] opt could be RHINO_AND, RHINO_AND_CLEAR, RHINO_OR, RHINO_OR_CLEAR
|
||||
* @param[out] actl_flags the actually flag where flags is satisfied
|
||||
* @param[in] ticks ticks to wait
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_event_get(kevent_t *event, uint32_t flags, uint8_t opt,
|
||||
uint32_t *actl_flags, tick_t ticks);
|
||||
|
||||
/**
|
||||
* This function will set a event
|
||||
* @param[in] event pointer to a event
|
||||
* @param[in] flags which users want to be set
|
||||
* @param[in] opt could be RHINO_AND, RHINO_OR
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_event_set(kevent_t *event, uint32_t flags, uint8_t opt);
|
||||
|
||||
#endif /* K_EVENT_H */
|
||||
|
||||
76
csky/csi_kernel/rhino/core/include/k_fifo.h
Normal file
76
csky/csi_kernel/rhino/core/include/k_fifo.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef FIFO_H
|
||||
#define FIFO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct k_fifo {
|
||||
|
||||
uint32_t in;
|
||||
uint32_t out;
|
||||
uint32_t mask;
|
||||
void *data;
|
||||
uint32_t free_bytes;
|
||||
uint32_t size;
|
||||
|
||||
};
|
||||
|
||||
#define fifo_min(x, y) ((x) > (y)?(y):(x))
|
||||
#define fifo_max(x, y) ((x) > (y)?(x):(y))
|
||||
|
||||
/**
|
||||
* This function will init the fifo.
|
||||
* @param[in] fifo pointer to fifo
|
||||
* @param[in] buffer pointer to fifo buffer
|
||||
* @param[in] size size of fifo buffer
|
||||
* @return the operation status, 0 is OK, others is error
|
||||
*/
|
||||
int8_t fifo_init(struct k_fifo *fifo, void *buffer, uint32_t size);
|
||||
|
||||
/**
|
||||
* This function will write buf to fifo.
|
||||
* @param[in] fifo pointer to fifo
|
||||
* @param[in] buf pointer to buffer write
|
||||
* @param[in] size size of buffer
|
||||
* @return the size has been written to the fifo
|
||||
*/
|
||||
uint32_t fifo_in(struct k_fifo *fifo, const void *buf, uint32_t len);
|
||||
|
||||
/**
|
||||
* This function will read fifo data to buf
|
||||
* @param[in] fifo pointer to fifo
|
||||
* @param[in] buf pointer to buffer read
|
||||
* @param[in] len len of buffer
|
||||
* @return the size has read
|
||||
*/
|
||||
uint32_t fifo_out(struct k_fifo *fifo, void *buf, uint32_t len);
|
||||
|
||||
/**
|
||||
* This function will read fifo data to buf,but data remain in fifo
|
||||
* @param[in] fifo pointer to fifo
|
||||
* @param[in] buf pointer to buffer read
|
||||
* @param[in] len len of buffer
|
||||
* @return the size has read
|
||||
*/
|
||||
uint32_t fifo_out_peek(struct k_fifo *fifo,
|
||||
void *buf, uint32_t len);
|
||||
|
||||
/**
|
||||
* This function will read fifo all data
|
||||
* @param[in] fifo pointer to fifo
|
||||
* @param[in] buf pointer to buffer read
|
||||
* @return the size has read
|
||||
*/
|
||||
uint32_t fifo_out_all(struct k_fifo *fifo, void *buf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
64
csky/csi_kernel/rhino/core/include/k_hook.h
Normal file
64
csky/csi_kernel/rhino/core/include/k_hook.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_HOOK_H
|
||||
#define K_HOOK_H
|
||||
|
||||
#if (RHINO_CONFIG_USER_HOOK > 0)
|
||||
/**
|
||||
* This function will provide init hook
|
||||
*/
|
||||
void krhino_init_hook(void);
|
||||
|
||||
/**
|
||||
* This function will provide system start hook
|
||||
*/
|
||||
void krhino_start_hook(void);
|
||||
|
||||
/**
|
||||
* This function will provide task create hook
|
||||
* @param[in] task pointer to the task
|
||||
*/
|
||||
void krhino_task_create_hook(ktask_t *task);
|
||||
|
||||
/**
|
||||
* This function will provide task delete hook
|
||||
* @param[in] task pointer to the task
|
||||
*/
|
||||
void krhino_task_del_hook(ktask_t *task, res_free_t *arg);
|
||||
|
||||
/**
|
||||
* This function will provide task abort hook
|
||||
* @param[in] task pointer to the task
|
||||
*/
|
||||
void krhino_task_abort_hook(ktask_t *task);
|
||||
|
||||
/**
|
||||
* This function will provide task switch hook
|
||||
*/
|
||||
void krhino_task_switch_hook(ktask_t *orgin, ktask_t *dest);
|
||||
|
||||
/**
|
||||
* This function will provide system tick hook
|
||||
*/
|
||||
void krhino_tick_hook(void);
|
||||
|
||||
/**
|
||||
* This function will provide idle hook
|
||||
*/
|
||||
void krhino_idle_hook(void);
|
||||
|
||||
/**
|
||||
* This function will provide idle pre hook
|
||||
*/
|
||||
void krhino_idle_pre_hook(void);
|
||||
|
||||
/**
|
||||
* This function will provide krhino_mm_alloc hook
|
||||
*/
|
||||
void krhino_mm_alloc_hook(void *mem, size_t size);
|
||||
#endif
|
||||
|
||||
#endif /* K_HOOK_H */
|
||||
|
||||
193
csky/csi_kernel/rhino/core/include/k_internal.h
Normal file
193
csky/csi_kernel/rhino/core/include/k_internal.h
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_INTERNAL_H
|
||||
#define K_INTERNAL_H
|
||||
|
||||
extern kstat_t g_sys_stat;
|
||||
extern uint8_t g_idle_task_spawned[RHINO_CONFIG_CPU_NUM];
|
||||
|
||||
extern runqueue_t g_ready_queue;
|
||||
|
||||
/* System lock */
|
||||
extern uint8_t g_sched_lock[RHINO_CONFIG_CPU_NUM];
|
||||
extern uint8_t g_intrpt_nested_level[RHINO_CONFIG_CPU_NUM];
|
||||
|
||||
/* highest pri ready task object */
|
||||
extern ktask_t *g_preferred_ready_task[RHINO_CONFIG_CPU_NUM];
|
||||
|
||||
/* current active task */
|
||||
extern ktask_t *g_active_task[RHINO_CONFIG_CPU_NUM];
|
||||
|
||||
/* idle attribute */
|
||||
extern ktask_t g_idle_task[RHINO_CONFIG_CPU_NUM];
|
||||
extern idle_count_t g_idle_count[RHINO_CONFIG_CPU_NUM];
|
||||
extern cpu_stack_t g_idle_task_stack[RHINO_CONFIG_CPU_NUM][RHINO_CONFIG_IDLE_TASK_STACK_SIZE];
|
||||
|
||||
/* tick attribute */
|
||||
extern tick_t g_tick_count;
|
||||
extern klist_t g_tick_head;
|
||||
|
||||
#if (RHINO_CONFIG_SYSTEM_STATS > 0)
|
||||
extern kobj_list_t g_kobj_list;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_TIMER > 0)
|
||||
extern klist_t g_timer_head;
|
||||
extern sys_time_t g_timer_count;
|
||||
extern ktask_t g_timer_task;
|
||||
extern cpu_stack_t g_timer_task_stack[RHINO_CONFIG_TIMER_TASK_STACK_SIZE];
|
||||
extern kbuf_queue_t g_timer_queue;
|
||||
extern k_timer_queue_cb timer_queue_cb[RHINO_CONFIG_TIMER_MSG_NUM];
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_DISABLE_SCHED_STATS > 0)
|
||||
extern hr_timer_t g_sched_disable_time_start;
|
||||
extern hr_timer_t g_sched_disable_max_time;
|
||||
extern hr_timer_t g_cur_sched_disable_max_time;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_DISABLE_INTRPT_STATS > 0)
|
||||
extern uint16_t g_intrpt_disable_times;
|
||||
extern hr_timer_t g_intrpt_disable_time_start;
|
||||
extern hr_timer_t g_intrpt_disable_max_time;
|
||||
extern hr_timer_t g_cur_intrpt_disable_max_time;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_HW_COUNT > 0)
|
||||
extern hr_timer_t g_sys_measure_waste;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_CPU_USAGE_STATS > 0)
|
||||
extern ktask_t g_cpu_usage_task;
|
||||
extern cpu_stack_t g_cpu_task_stack[RHINO_CONFIG_CPU_USAGE_TASK_STACK];
|
||||
extern idle_count_t g_idle_count_max;
|
||||
extern uint32_t g_cpu_usage;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_TASK_SCHED_STATS > 0)
|
||||
extern ctx_switch_t g_sys_ctx_switch_times;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_KOBJ_DYN_ALLOC > 0)
|
||||
extern ksem_t g_res_sem;
|
||||
extern klist_t g_res_list;
|
||||
extern ktask_t g_dyn_task;
|
||||
extern cpu_stack_t g_dyn_task_stack[RHINO_CONFIG_K_DYN_TASK_STACK];
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_WORKQUEUE > 0)
|
||||
extern klist_t g_workqueue_list_head;
|
||||
extern kmutex_t g_workqueue_mutex;
|
||||
extern kworkqueue_t g_workqueue_default;
|
||||
extern cpu_stack_t g_workqueue_stack[RHINO_CONFIG_WORKQUEUE_STACK_SIZE];
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_MM_TLF > 0)
|
||||
extern k_mm_head *g_kmm_head;
|
||||
#endif
|
||||
|
||||
#ifdef RHINO_CONFIG_ISR_TASK
|
||||
extern ktask_t g_isr_task;
|
||||
extern ksem_t g_isr_sem;
|
||||
extern uint32_t g_isr_buff[4+2*RHINO_CONFIG_ISR_BUFF_SIZE];
|
||||
extern cpu_stack_t g_isr_task_stack[RHINO_CONFIG_ISR_TASK_STACK_SIZE];
|
||||
#endif
|
||||
|
||||
extern kspinlock_t g_sys_lock;
|
||||
extern uint8_t g_in_interrupt;
|
||||
|
||||
#define K_OBJ_STATIC_ALLOC 1u
|
||||
#define K_OBJ_DYN_ALLOC 2u
|
||||
|
||||
#define NULL_PARA_CHK(para) \
|
||||
do { \
|
||||
if (para == NULL) { \
|
||||
return RHINO_NULL_PTR; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define INTRPT_NESTED_LEVEL_CHK()\
|
||||
do { \
|
||||
if (g_intrpt_nested_level[cpu_cur_get()] > 0u) { \
|
||||
RHINO_CRITICAL_EXIT(); \
|
||||
return RHINO_NOT_CALLED_BY_INTRPT; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RES_FREE_NUM 4
|
||||
|
||||
typedef struct {
|
||||
uint8_t cnt;
|
||||
void *res[RES_FREE_NUM];
|
||||
klist_t res_list;
|
||||
} res_free_t;
|
||||
|
||||
void preferred_cpu_ready_task_get(runqueue_t *rq, uint8_t cpu_num);
|
||||
|
||||
void core_sched(void);
|
||||
void runqueue_init(runqueue_t *rq);
|
||||
|
||||
void ready_list_add(runqueue_t *rq, ktask_t *task);
|
||||
void ready_list_add_head(runqueue_t *rq, ktask_t *task);
|
||||
void ready_list_add_tail(runqueue_t *rq, ktask_t *task);
|
||||
void ready_list_rm(runqueue_t *rq, ktask_t *task);
|
||||
void ready_list_head_to_tail(runqueue_t *rq, ktask_t *task);
|
||||
|
||||
void time_slice_update(void);
|
||||
void timer_task_sched(void);
|
||||
|
||||
void pend_list_reorder(ktask_t *task);
|
||||
void pend_task_wakeup(ktask_t *task);
|
||||
void pend_to_blk_obj(blk_obj_t *blk_obj, ktask_t *task, tick_t timeout, uint32_t psr);
|
||||
void pend_task_rm(ktask_t *task);
|
||||
|
||||
kstat_t pend_state_end_proc(ktask_t *task);
|
||||
|
||||
void idle_task(void *p_arg);
|
||||
void idle_count_set(idle_count_t value);
|
||||
idle_count_t idle_count_get(void);
|
||||
|
||||
void tick_list_init(void);
|
||||
void tick_task_start(void);
|
||||
void tick_list_rm(ktask_t *task);
|
||||
void tick_list_insert(ktask_t *task, tick_t time);
|
||||
void tick_list_update(tick_i_t ticks);
|
||||
|
||||
uint8_t mutex_pri_limit(ktask_t *tcb, uint8_t pri);
|
||||
void mutex_task_pri_reset(ktask_t *tcb);
|
||||
uint8_t mutex_pri_look(ktask_t *tcb, kmutex_t *mutex_rel);
|
||||
|
||||
kstat_t task_pri_change(ktask_t *task, uint8_t new_pri);
|
||||
|
||||
void k_err_proc(kstat_t err);
|
||||
|
||||
void ktimer_init(void);
|
||||
void kisr_init(void);
|
||||
|
||||
|
||||
void intrpt_disable_measure_start(void);
|
||||
void intrpt_disable_measure_stop(void);
|
||||
void dyn_mem_proc_task_start(void);
|
||||
void cpu_usage_stats_start(void);
|
||||
void dym_mem_proc_hdl(void);
|
||||
|
||||
kstat_t ringbuf_init(k_ringbuf_t *p_ringbuf, void *buf, size_t len, size_t type,
|
||||
size_t block_size);
|
||||
kstat_t ringbuf_reset(k_ringbuf_t *p_ringbuf);
|
||||
kstat_t ringbuf_push(k_ringbuf_t *p_ringbuf, void *data, size_t len);
|
||||
kstat_t ringbuf_head_push(k_ringbuf_t *p_ringbuf, void *data, size_t len);
|
||||
kstat_t ringbuf_pop(k_ringbuf_t *p_ringbuf, void *pdata, size_t *plen);
|
||||
uint8_t ringbuf_is_full(k_ringbuf_t *p_ringbuf);
|
||||
uint8_t ringbuf_is_empty(k_ringbuf_t *p_ringbuf);
|
||||
void workqueue_init(void);
|
||||
//void k_mm_init(void);
|
||||
|
||||
#if (RHINO_CONFIG_CPU_PWR_MGMT > 0)
|
||||
void cpu_pwr_down(void);
|
||||
void cpu_pwr_up(void);
|
||||
#endif
|
||||
|
||||
#endif /* K_INTERNAL_H */
|
||||
|
||||
60
csky/csi_kernel/rhino/core/include/k_list.h
Normal file
60
csky/csi_kernel/rhino/core/include/k_list.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_LIST_H
|
||||
#define K_LIST_H
|
||||
|
||||
typedef struct klist_s {
|
||||
struct klist_s *next;
|
||||
struct klist_s *prev;
|
||||
} klist_t;
|
||||
|
||||
#define krhino_list_entry(node, type, member) ((type *)((uint8_t *)(node) - (size_t)(&((type *)0)->member)))
|
||||
|
||||
RHINO_INLINE void klist_init(klist_t *list_head)
|
||||
{
|
||||
list_head->next = list_head;
|
||||
list_head->prev = list_head;
|
||||
}
|
||||
|
||||
RHINO_INLINE uint8_t is_klist_empty(klist_t *list)
|
||||
{
|
||||
return (list->next == list);
|
||||
}
|
||||
|
||||
RHINO_INLINE void klist_insert(klist_t *head, klist_t *element)
|
||||
{
|
||||
element->prev = head->prev;
|
||||
element->next = head;
|
||||
|
||||
head->prev->next = element;
|
||||
head->prev = element;
|
||||
}
|
||||
|
||||
RHINO_INLINE void klist_add(klist_t *head, klist_t *element)
|
||||
{
|
||||
element->prev = head;
|
||||
element->next = head->next;
|
||||
|
||||
head->next->prev = element;
|
||||
head->next = element;
|
||||
}
|
||||
|
||||
RHINO_INLINE void klist_rm(klist_t *element)
|
||||
{
|
||||
element->prev->next = element->next;
|
||||
element->next->prev = element->prev;
|
||||
}
|
||||
|
||||
RHINO_INLINE void klist_rm_init(klist_t *element)
|
||||
{
|
||||
element->prev->next = element->next;
|
||||
element->next->prev = element->prev;
|
||||
|
||||
element->next = element->prev = element;
|
||||
}
|
||||
|
||||
|
||||
#endif /* K_LIST_H */
|
||||
|
||||
153
csky/csi_kernel/rhino/core/include/k_mm.h
Normal file
153
csky/csi_kernel/rhino/core/include/k_mm.h
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_MM_H
|
||||
#define K_MM_H
|
||||
|
||||
#ifdef HAVE_VALGRIND_H
|
||||
#include <valgrind.h>
|
||||
#include <memcheck.h>
|
||||
#define VGF(X) X
|
||||
#elif defined(HAVE_VALGRIND_VALGRIND_H)
|
||||
#include <valgrind/valgrind.h>
|
||||
#include <valgrind/memcheck.h>
|
||||
#define VGF(X) X
|
||||
#else
|
||||
#define VGF(X)
|
||||
#endif
|
||||
|
||||
|
||||
/*use two level bit map to find free memory block*/
|
||||
|
||||
#if (RHINO_CONFIG_MM_TLF > 0)
|
||||
#define MAX_MM_BIT RHINO_CONFIG_MM_MAXMSIZEBIT
|
||||
|
||||
#define MAX_MM_SIZE (1<<MAX_MM_BIT)
|
||||
#define FIX_BLK_BIT 5 /*32 bytes*/
|
||||
#define DEF_FIX_BLK_SIZE (1<<FIX_BLK_BIT) /*32 bytes*/
|
||||
#define MIN_FLT_BIT 7 /*<2^7 only need one level mapping */
|
||||
#define MIN_FLT_SIZE (1<<MIN_FLT_BIT)
|
||||
#define MAX_LOG2_SLT 5
|
||||
#define SLT_SIZE (1<<MAX_LOG2_SLT)
|
||||
#define FLT_SIZE (MAX_MM_BIT - MIN_FLT_BIT + 1)
|
||||
#define MM_ALIGIN_SIZE (1<<(MIN_FLT_BIT - MAX_LOG2_SLT))
|
||||
#define MM_ALIGN_MASK (sizeof(void*)-1)
|
||||
|
||||
#define MM_ALIGN_UP(a) (((a) + MM_ALIGN_MASK) & ~MM_ALIGN_MASK)
|
||||
#define MM_ALIGN_DOWN(a) ((a) & ~MM_ALIGN_MASK)
|
||||
|
||||
|
||||
#define RHINO_MM_BLKSIZE_MASK (0xFFFFFFFF - MM_ALIGN_MASK)
|
||||
|
||||
#define DEF_TOTAL_FIXEDBLK_SIZE 8192 /*by default, total 2k momory fo fix size block */
|
||||
#define MIN_FREE_MEMORY_SIZE 1024 /*at least need 1k for user alloced*/
|
||||
|
||||
|
||||
|
||||
/*bit 0 and bit 1 mask*/
|
||||
#define RHINO_MM_CURSTAT_MASK 0x1
|
||||
#define RHINO_MM_PRESTAT_MASK 0x2
|
||||
|
||||
/*bit 0*/
|
||||
#define RHINO_MM_FREE 1
|
||||
#define RHINO_MM_ALLOCED 0
|
||||
|
||||
/*bit 1*/
|
||||
#define RHINO_MM_PREVFREE 2
|
||||
#define RHINO_MM_PREVALLOCED 0
|
||||
|
||||
#define NEXT_MM_BLK(_addr, _r) ((k_mm_list_t *) ((uint8_t *) (_addr) + (_r)))
|
||||
|
||||
#define MMLIST_HEAD_SIZE (sizeof(k_mm_list_t) - sizeof(free_ptr_t))
|
||||
/*
|
||||
-------------------------------------------------------------------
|
||||
| k_mm_list_t |k_mm_region_info_t|k_mm_list_t|free space |k_mm_list_t|
|
||||
-------------------------------------------------------------------
|
||||
*/
|
||||
#define MMREGION_USED_SIZE (MM_ALIGN_UP(sizeof(k_mm_region_info_t)) + 3 * MMLIST_HEAD_SIZE )
|
||||
|
||||
/*struct of memory list ,every memory block include this information*/
|
||||
typedef struct free_ptr_struct {
|
||||
struct k_mm_list_struct *prev;
|
||||
struct k_mm_list_struct *next;
|
||||
} free_ptr_t;
|
||||
|
||||
typedef struct k_mm_list_struct {
|
||||
#if (RHINO_CONFIG_MM_DEBUG > 0)
|
||||
size_t dye;
|
||||
size_t owner;
|
||||
#endif
|
||||
struct k_mm_list_struct *prev;
|
||||
size_t size;
|
||||
/* bit 0 indicates whether the block is used and */
|
||||
/* bit 1 allows to know whether the previous block is free */
|
||||
union {
|
||||
struct free_ptr_struct free_ptr;
|
||||
uint8_t buffer[1];
|
||||
} mbinfo;
|
||||
} k_mm_list_t;
|
||||
|
||||
typedef struct k_mm_region_info_struct {
|
||||
k_mm_list_t *end;
|
||||
struct k_mm_region_info_struct *next;
|
||||
} k_mm_region_info_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
#if (RHINO_CONFIG_MM_REGION_MUTEX == 1)
|
||||
kmutex_t mm_mutex;
|
||||
#endif
|
||||
k_mm_region_info_t *regioninfo;
|
||||
k_mm_list_t *fixedmblk;
|
||||
|
||||
#if (K_MM_STATISTIC > 0)
|
||||
size_t used_size;
|
||||
size_t maxused_size;
|
||||
size_t free_size;
|
||||
size_t mm_size_stats[MAX_MM_BIT];
|
||||
#endif
|
||||
|
||||
uint32_t fl_bitmap;
|
||||
uint32_t sl_bitmap[FLT_SIZE]; /* the second-level bitmap */
|
||||
k_mm_list_t *mm_tbl[FLT_SIZE][SLT_SIZE];
|
||||
} k_mm_head;
|
||||
|
||||
|
||||
kstat_t krhino_init_mm_head(k_mm_head **ppmmhead, void *addr, size_t len );
|
||||
kstat_t krhino_deinit_mm_head(k_mm_head *mmhead);
|
||||
|
||||
kstat_t krhino_add_mm_region(k_mm_head *mmhead, void *addr, size_t len);
|
||||
|
||||
|
||||
void *k_mm_alloc(k_mm_head *mmhead, size_t size);
|
||||
void k_mm_free(k_mm_head *mmhead, void *ptr);
|
||||
void *k_mm_realloc(k_mm_head *mmhead, void *oldmem, size_t new_size);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function is wrapper of mm allocation
|
||||
* @param[in] size size of the mem to malloc
|
||||
* @return the operation status, NULL is error, others is memory address
|
||||
*/
|
||||
void *krhino_mm_alloc(size_t size, void *caller);
|
||||
|
||||
/**
|
||||
* This function is wrapper of mm free
|
||||
* @param[in] ptr address point of the mem
|
||||
*/
|
||||
void krhino_mm_free(void *ptr);
|
||||
|
||||
|
||||
/**
|
||||
* This function is wrapper of mm rallocation
|
||||
* @param[in] oldmem oldmem address
|
||||
* @param[in] size size of the mem to malloc
|
||||
* @return the operation status, NULL is error, others is realloced memory address
|
||||
*/
|
||||
void *krhino_mm_realloc(void *oldmem, size_t newsize, void *caller);
|
||||
|
||||
|
||||
|
||||
#endif /* K_MM_BESTFIT_H */
|
||||
|
||||
50
csky/csi_kernel/rhino/core/include/k_mm_blk.h
Normal file
50
csky/csi_kernel/rhino/core/include/k_mm_blk.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_MM_BLK_H
|
||||
#define K_MM_BLK_H
|
||||
|
||||
typedef struct {
|
||||
kobj_type_t obj_type;
|
||||
const name_t *pool_name;
|
||||
size_t blk_size;
|
||||
size_t blk_avail;
|
||||
size_t blk_whole;
|
||||
uint8_t *avail_list;
|
||||
#if (RHINO_CONFIG_SYSTEM_STATS > 0)
|
||||
klist_t mblkpool_stats_item;
|
||||
#endif
|
||||
} mblk_pool_t;
|
||||
|
||||
/**
|
||||
* This function will init a blk-pool
|
||||
* @param[in] pool pointer to the pool
|
||||
* @param[in] name name of the pool
|
||||
* @param[in] pool_start start addr of the pool
|
||||
* @param[in] blk_size size of the blk
|
||||
* @param[in] pool_size size of the pool
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_mblk_pool_init(mblk_pool_t *pool, const name_t *name,
|
||||
void *pool_start,
|
||||
size_t blk_size, size_t pool_size);
|
||||
|
||||
/**
|
||||
* This function will alloc a blk-pool
|
||||
* @param[in] pool pointer to a pool
|
||||
* @param[in] blk pointer to a blk
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_mblk_alloc(mblk_pool_t *pool, void **blk);
|
||||
|
||||
/**
|
||||
* This function will free a blk-pool
|
||||
* @param[in] pool pointer to the pool
|
||||
* @param[in] blk pointer to the blk
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_mblk_free(mblk_pool_t *pool, void *blk);
|
||||
|
||||
#endif /* K_MM_BLK_H */
|
||||
|
||||
40
csky/csi_kernel/rhino/core/include/k_mm_debug.h
Normal file
40
csky/csi_kernel/rhino/core/include/k_mm_debug.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef RHINO_MM_DEBUG_H
|
||||
#define RHINO_MM_DEBUG_H
|
||||
|
||||
#if (RHINO_CONFIG_MM_DEBUG > 0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AOS_MM_SCAN_REGION_MAX 10
|
||||
typedef struct {
|
||||
void *start;
|
||||
void *end;
|
||||
} mm_scan_region_t;
|
||||
|
||||
#if (RHINO_CONFIG_GCC_RETADDR > 0u)
|
||||
#include <k_mm.h>
|
||||
#define AOS_UNSIGNED_INT_MSB (1u << (sizeof(unsigned int) * 8 - 1))
|
||||
void krhino_owner_attach(k_mm_head *mmhead, void *addr, size_t allocator);
|
||||
#endif
|
||||
|
||||
uint32_t krhino_mm_leak_region_init(void *start, void *end);
|
||||
|
||||
uint32_t dumpsys_mm_info_func(char *buf, uint32_t len);
|
||||
|
||||
uint32_t dump_mmleak(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RHINO_CONFIG_MM_DEBUG */
|
||||
|
||||
#endif /* YSH_H */
|
||||
|
||||
|
||||
14
csky/csi_kernel/rhino/core/include/k_mm_region.h
Normal file
14
csky/csi_kernel/rhino/core/include/k_mm_region.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_MM_REGION_H
|
||||
#define K_MM_REGION_H
|
||||
|
||||
typedef struct {
|
||||
uint8_t *start;
|
||||
size_t len;
|
||||
} k_mm_region_t;
|
||||
|
||||
#endif /* K_MM_REGION_H */
|
||||
|
||||
69
csky/csi_kernel/rhino/core/include/k_mutex.h
Normal file
69
csky/csi_kernel/rhino/core/include/k_mutex.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_MUTEX_H
|
||||
#define K_MUTEX_H
|
||||
|
||||
typedef struct mutex_s {
|
||||
blk_obj_t blk_obj;
|
||||
ktask_t *mutex_task; /* mutex owner task */
|
||||
struct mutex_s *mutex_list; /* task mutex list */
|
||||
mutex_nested_t owner_nested;
|
||||
|
||||
#if (RHINO_CONFIG_SYSTEM_STATS > 0)
|
||||
klist_t mutex_item;
|
||||
#endif
|
||||
|
||||
uint8_t mm_alloc_flag;
|
||||
} kmutex_t;
|
||||
|
||||
/**
|
||||
* This function will create a mutex
|
||||
* @param[in] mutex pointer to the mutex(the space is provided by user)
|
||||
* @param[in] name name of the mutex
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_mutex_create(kmutex_t *mutex, const name_t *name);
|
||||
|
||||
/**
|
||||
* This function will delete a mutex
|
||||
* @param[in] mutex pointer to the mutex
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_mutex_del(kmutex_t *mutex);
|
||||
|
||||
#if (RHINO_CONFIG_KOBJ_DYN_ALLOC > 0)
|
||||
/**
|
||||
* This function will create a dyn mutex
|
||||
* @param[in] mutex pointer to the mutex(the space is provided by user)
|
||||
* @param[in] name name of the mutex
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_mutex_dyn_create(kmutex_t **mutex, const name_t *name);
|
||||
|
||||
/**
|
||||
* This function will delete a dyn mutex
|
||||
* @param[in] mutex pointer to the mutex
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_mutex_dyn_del(kmutex_t *mutex);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function will lock mutex
|
||||
* @param[in] mutex pointer to the mutex
|
||||
* @param[in] ticks ticks to be wait for before lock
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_mutex_lock(kmutex_t *mutex, tick_t ticks, uint32_t lr);
|
||||
|
||||
/**
|
||||
* This function will unlock a mutex
|
||||
* @param[in] mutex pointer to the mutex
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_mutex_unlock(kmutex_t *mutex);
|
||||
|
||||
#endif /* K_MUTEX_H */
|
||||
|
||||
67
csky/csi_kernel/rhino/core/include/k_obj.h
Normal file
67
csky/csi_kernel/rhino/core/include/k_obj.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_OBJ_H
|
||||
#define K_OBJ_H
|
||||
|
||||
typedef enum {
|
||||
BLK_POLICY_PRI = 0u,
|
||||
BLK_POLICY_FIFO
|
||||
} blk_policy_t;
|
||||
|
||||
typedef enum {
|
||||
BLK_FINISH = 0,
|
||||
BLK_ABORT,
|
||||
BLK_TIMEOUT,
|
||||
BLK_DEL,
|
||||
BLK_INVALID
|
||||
} blk_state_t;
|
||||
|
||||
typedef enum {
|
||||
RHINO_OBJ_TYPE_NONE = 0,
|
||||
RHINO_SEM_OBJ_TYPE,
|
||||
RHINO_MUTEX_OBJ_TYPE,
|
||||
RHINO_QUEUE_OBJ_TYPE,
|
||||
RHINO_BUF_QUEUE_OBJ_TYPE,
|
||||
RHINO_TIMER_OBJ_TYPE,
|
||||
RHINO_EVENT_OBJ_TYPE,
|
||||
RHINO_MM_BLK_OBJ_TYPE,
|
||||
RHINO_MM_OBJ_TYPE,
|
||||
RHINO_BLKLIST_OBJ_TYPE,
|
||||
} kobj_type_t;
|
||||
|
||||
typedef struct blk_obj {
|
||||
klist_t blk_list;
|
||||
const name_t *name;
|
||||
uint8_t blk_policy; // blk_policy_t
|
||||
uint8_t obj_type; // blk_state_t
|
||||
} blk_obj_t;
|
||||
|
||||
typedef struct {
|
||||
klist_t task_head;
|
||||
klist_t mutex_head;
|
||||
|
||||
#if (RHINO_CONFIG_MM_BLK > 0)
|
||||
klist_t mblkpool_head;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_SEM > 0)
|
||||
klist_t sem_head;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_QUEUE > 0)
|
||||
klist_t queue_head;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_EVENT_FLAG > 0)
|
||||
klist_t event_head;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_BUF_QUEUE > 0)
|
||||
klist_t buf_queue_head;
|
||||
#endif
|
||||
} kobj_list_t;
|
||||
|
||||
#endif /* K_OBJ_H */
|
||||
|
||||
118
csky/csi_kernel/rhino/core/include/k_queue.h
Normal file
118
csky/csi_kernel/rhino/core/include/k_queue.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_QUEUE_H
|
||||
#define K_QUEUE_H
|
||||
|
||||
#define WAKE_ONE_TASK 0u
|
||||
#define WAKE_ALL_TASK 1u
|
||||
|
||||
typedef struct {
|
||||
void **queue_start;
|
||||
size_t size;
|
||||
size_t cur_num;
|
||||
size_t peak_num;
|
||||
} msg_q_t;
|
||||
|
||||
typedef struct {
|
||||
msg_q_t msg_q;
|
||||
klist_t *pend_entry;
|
||||
} msg_info_t;
|
||||
|
||||
typedef struct queue_s {
|
||||
blk_obj_t blk_obj;
|
||||
k_ringbuf_t ringbuf;
|
||||
msg_q_t msg_q;
|
||||
#if (RHINO_CONFIG_SYSTEM_STATS > 0)
|
||||
klist_t queue_item;
|
||||
#endif
|
||||
uint8_t mm_alloc_flag;
|
||||
} kqueue_t;
|
||||
|
||||
/**
|
||||
* This function will create a queue
|
||||
* @param[in] queue pointer to the queue(the space is provided by user)
|
||||
* @param[in] name name of the queue
|
||||
* @param[in] start start address of the queue internal space
|
||||
* @param[in] msg_num num of the msg
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_queue_create(kqueue_t *queue, const name_t *name, void **start,
|
||||
size_t msg_num);
|
||||
|
||||
/**
|
||||
* This function will delete a queue
|
||||
* @param[in] queue pointer to the queue
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_queue_del(kqueue_t *queue);
|
||||
|
||||
#if (RHINO_CONFIG_KOBJ_DYN_ALLOC > 0)
|
||||
/**
|
||||
* This function will create a dyn queue
|
||||
* @param[in] queue pointer to the queue
|
||||
* @param[in] name name of the queue
|
||||
* @param[in] msg_num num of the msg
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_queue_dyn_create(kqueue_t **queue, const name_t *name,
|
||||
size_t msg_num);
|
||||
|
||||
/**
|
||||
* This function will delete a dyn created queue
|
||||
* @param[in] queue pointer to the queue
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_queue_dyn_del(kqueue_t *queue);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function will send a msg to the back of a queue
|
||||
* @param[in] queue pointer to the queue
|
||||
* @param[in] msg msg to send
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_queue_back_send(kqueue_t *queue, void *msg);
|
||||
|
||||
/**
|
||||
* This function will send a msg to a queue and wake all tasks
|
||||
* @param[in] queue pointer to the queue
|
||||
* @param[in] msg msg to send
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_queue_all_send(kqueue_t *queue, void *msg);
|
||||
|
||||
/**
|
||||
* This function will receive msg from a queue
|
||||
* @param[in] queue pointer to the queue
|
||||
* @param[in] ticks ticks to wait before receive
|
||||
* @param[out] msg buf to save msg
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_queue_recv(kqueue_t *queue, tick_t ticks, void **msg);
|
||||
|
||||
/**
|
||||
* This function will detect a queue full or not
|
||||
* @param[in] queue pointer to the queue
|
||||
* @return the operation status, RHINO_QUEUE_FULL/RHINO_QUEUE_NOT_FULL
|
||||
*/
|
||||
kstat_t krhino_queue_is_full(kqueue_t *queue);
|
||||
|
||||
/**
|
||||
* This function will reset a queue
|
||||
* @param[in] queue pointer to the queue
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_queue_flush(kqueue_t *queue);
|
||||
|
||||
/**
|
||||
* This function will get information of a queue
|
||||
* @param[in] queue pointer to the queue
|
||||
* @param[out] info buf to save msg-info
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_queue_info_get(kqueue_t *queue, msg_info_t *info);
|
||||
|
||||
#endif /* K_QUEUE_H */
|
||||
|
||||
101
csky/csi_kernel/rhino/core/include/k_ringbuf.h
Normal file
101
csky/csi_kernel/rhino/core/include/k_ringbuf.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_MM_RINGBUF_H
|
||||
#define K_MM_RINGBUF_H
|
||||
|
||||
#define RINGBUF_TYPE_FIX 0
|
||||
#define RINGBUF_TYPE_DYN 1
|
||||
|
||||
#define RINGBUF_LEN_MAX_SIZE 3
|
||||
#define RINGBUF_LEN_MASK_ONEBIT 0x80 //1000 0000
|
||||
#define RINGBUF_LEN_MASK_TWOBIT 0xC0 //1100 0000
|
||||
#define RINGBUF_LEN_MASK_CLEAN_TWOBIT 0x3f //0011 1111
|
||||
|
||||
|
||||
#define RINGBUF_LEN_VLE_2BYTES 0x80 //1000 0000
|
||||
#define RINGBUF_LEN_VLE_3BYTES 0xC0 //1100 0000
|
||||
|
||||
#define RINGBUF_LEN_1BYTE_MAXVALUE 0x7f //0111 1111; 127
|
||||
#define RINGBUF_LEN_2BYTES_MAXVALUE 0x3fff // 16383
|
||||
#define RINGBUF_LEN_3BYTES_MAXVALUE 0x3fffff //4194303
|
||||
|
||||
|
||||
#ifndef true
|
||||
#define true 1
|
||||
#endif
|
||||
|
||||
#ifndef false
|
||||
#define false 0
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint8_t *buf;
|
||||
uint8_t *end;
|
||||
uint8_t *head;
|
||||
uint8_t *tail;
|
||||
size_t freesize;
|
||||
size_t type;
|
||||
size_t blk_size;
|
||||
} k_ringbuf_t;
|
||||
|
||||
#define COMPRESS_LEN(x) ((x) <= RINGBUF_LEN_1BYTE_MAXVALUE ? 1: (x) <= RINGBUF_LEN_2BYTES_MAXVALUE ? 2: \
|
||||
(x) <= RINGBUF_LEN_3BYTES_MAXVALUE ? 3 : RHINO_INV_PARAM)
|
||||
|
||||
|
||||
#if (RHINO_CONFIG_RINGBUF_VENDOR > 0)
|
||||
/**
|
||||
* This function will init the mm ring buffer.
|
||||
* @param[in] p_ringbuf pointer to ring buffer
|
||||
* @param[in] buf pointer to memory buffer
|
||||
* @param[in] len length of memory buffer
|
||||
* @param[in] type type of ring buffer, fix length or dynamic length
|
||||
* @param[in] block_size block size of fix length ringbuf, if dynamic ringbuffer, ignore this parameter
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_ringbuf_init (k_ringbuf_t *p_ringbuf, void *buf, size_t len,
|
||||
size_t type, size_t block_size);
|
||||
|
||||
/**
|
||||
* This function will clean all data in mm ring buffer.
|
||||
* @param[in] p_ringbuf pointer to ring buffer
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_ringbuf_reset(k_ringbuf_t *p_ringbuf);
|
||||
|
||||
/**
|
||||
* This function will push the data to ring buffer end.
|
||||
* @param[in] p_ringbuf pointer to ring buffer
|
||||
* @param[in] data pointer to data
|
||||
* @param[in] len length of data
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_ringbuf_push(k_ringbuf_t *p_ringbuf, void *data, size_t len);
|
||||
|
||||
/**
|
||||
* This function will pop the data from ring buffer head.
|
||||
* @param[in] p_ringbuf pointer to ring buffer
|
||||
* @param[out] pdata pointer to data
|
||||
* @param[out] plen length of data
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_ringbuf_pop(k_ringbuf_t *p_ringbuf, void *pdata, size_t *plen);
|
||||
|
||||
|
||||
/**
|
||||
* This function will check if the ring buffer is full.
|
||||
* @param[in] p_ringbuf pointer to ring buffer
|
||||
* @return the ringbuf status, true is full. else is not.
|
||||
*/
|
||||
uint8_t krhino_ringbuf_is_full(k_ringbuf_t *p_ringbuf);
|
||||
|
||||
/**
|
||||
* This function will check if the ring buffer is empty.
|
||||
* @param[in] p_ringbuf pointer to ring buffer
|
||||
* @return the ringbuf status, true is empty. else is not.
|
||||
*/
|
||||
uint8_t krhino_ringbuf_is_empty(k_ringbuf_t *p_ringbuf);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
32
csky/csi_kernel/rhino/core/include/k_sched.h
Normal file
32
csky/csi_kernel/rhino/core/include/k_sched.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_SCHED_H
|
||||
#define K_SCHED_H
|
||||
|
||||
#define KSCHED_FIFO 0u
|
||||
#define KSCHED_RR 1u
|
||||
#define SCHED_MAX_LOCK_COUNT 200u
|
||||
#define NUM_WORDS ((RHINO_CONFIG_PRI_MAX + 31) / 32)
|
||||
|
||||
typedef struct {
|
||||
klist_t *cur_list_item[RHINO_CONFIG_PRI_MAX];
|
||||
uint32_t task_bit_map[NUM_WORDS];
|
||||
uint8_t highest_pri;
|
||||
} runqueue_t;
|
||||
|
||||
/**
|
||||
* This function will disable schedule
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_sched_disable(void);
|
||||
|
||||
/**
|
||||
* This function will enable schedule
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_sched_enable(void);
|
||||
|
||||
#endif /* K_SCHED_H */
|
||||
|
||||
95
csky/csi_kernel/rhino/core/include/k_sem.h
Normal file
95
csky/csi_kernel/rhino/core/include/k_sem.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_SEM_H
|
||||
#define K_SEM_H
|
||||
|
||||
#define WAKE_ONE_SEM 0u
|
||||
#define WAKE_ALL_SEM 1u
|
||||
|
||||
typedef struct sem_s {
|
||||
blk_obj_t blk_obj;
|
||||
sem_count_t count;
|
||||
sem_count_t peak_count;
|
||||
#if (RHINO_CONFIG_SYSTEM_STATS > 0)
|
||||
klist_t sem_item;
|
||||
#endif
|
||||
uint8_t mm_alloc_flag;
|
||||
} ksem_t;
|
||||
|
||||
/**
|
||||
* This function will create a semaphore
|
||||
* @param[in] sem pointer to the semaphore(the space is provided by user)
|
||||
* @param[in] name name of the semaphore
|
||||
* @param[in] count the init count of the semaphore
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_sem_create(ksem_t *sem, const name_t *name, sem_count_t count);
|
||||
|
||||
/**
|
||||
* This function will delete a semaphore
|
||||
* @param[in] sem pointer to the semaphore
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_sem_del(ksem_t *sem);
|
||||
|
||||
#if (RHINO_CONFIG_KOBJ_DYN_ALLOC > 0)
|
||||
/**
|
||||
* This function will create a dyn-semaphore
|
||||
* @param[out] sem pointer to the semaphore(the space is provided by kernel)
|
||||
* @param[in] name name of the semaphore
|
||||
* @param[in] count the init count of the semaphore
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_sem_dyn_create(ksem_t **sem, const name_t *name,
|
||||
sem_count_t count);
|
||||
|
||||
/**
|
||||
* This function will delete a dyn-semaphore
|
||||
* @param[in] sem pointer to the semaphore
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_sem_dyn_del(ksem_t *sem);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function will give a semaphore
|
||||
* @param[in] sem pointer to the semphore
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_sem_give(ksem_t *sem);
|
||||
|
||||
/**
|
||||
* This function will give a semaphore and wakeup all thee waiting task
|
||||
* @param[in] sem pointer to the semaphore
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_sem_give_all(ksem_t *sem);
|
||||
|
||||
/**
|
||||
* This function will take a semaphore
|
||||
* @param[in] sem pointer to the semaphore
|
||||
* @param[in] ticks ticks to wait before take
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_sem_take(ksem_t *sem, tick_t ticks);
|
||||
|
||||
/**
|
||||
* This function will set the count of a semaphore
|
||||
* @param[in] sem pointer to the semaphore
|
||||
* @param[in] sem_count count of the semaphore
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_sem_count_set(ksem_t *sem, sem_count_t count);
|
||||
|
||||
/**
|
||||
* This function will get count of a semaphore
|
||||
* @param[in] sem pointer to the semaphore
|
||||
* @param[out] count count of the semaphore
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_sem_count_get(ksem_t *sem, sem_count_t *count);
|
||||
|
||||
#endif /* K_SEM_H */
|
||||
|
||||
40
csky/csi_kernel/rhino/core/include/k_soc.h
Normal file
40
csky/csi_kernel/rhino/core/include/k_soc.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_SOC_H
|
||||
#define K_SOC_H
|
||||
|
||||
#if (RHINO_CONFIG_HW_COUNT > 0)
|
||||
void soc_hw_timer_init(void);
|
||||
hr_timer_t soc_hr_hw_cnt_get(void);
|
||||
lr_timer_t soc_lr_hw_cnt_get(void);
|
||||
#define HR_COUNT_GET() soc_hr_hw_cnt_get()
|
||||
#else /* RHINO_CONFIG_HW_COUNT */
|
||||
#define HR_COUNT_GET() 0u
|
||||
#endif /* RHINO_CONFIG_HW_COUNT */
|
||||
|
||||
#if (RHINO_CONFIG_TASK_SCHED_STATS > 0)
|
||||
#define LR_COUNT_GET() soc_lr_hw_cnt_get()
|
||||
#else /* RHINO_CONFIG_TASK_SCHED_STATS */
|
||||
#define LR_COUNT_GET() 0u
|
||||
#endif /* RHINO_CONFIG_TASK_SCHED_STATS */
|
||||
|
||||
#if (RHINO_CONFIG_INTRPT_GUARD > 0)
|
||||
void soc_intrpt_guard(void);
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_INTRPT_STACK_REMAIN_GET > 0)
|
||||
size_t soc_intrpt_stack_remain_get(void);
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_INTRPT_STACK_OVF_CHECK > 0)
|
||||
void soc_intrpt_stack_ovf_check(void);
|
||||
#endif
|
||||
|
||||
void soc_err_proc(kstat_t err);
|
||||
|
||||
size_t soc_get_cur_sp(void);
|
||||
|
||||
#endif /* K_SOC_H */
|
||||
|
||||
39
csky/csi_kernel/rhino/core/include/k_stats.h
Normal file
39
csky/csi_kernel/rhino/core/include/k_stats.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_STATS_H
|
||||
#define K_STATS_H
|
||||
|
||||
#if (RHINO_CONFIG_SYSTEM_STATS > 0)
|
||||
void kobj_list_init(void);
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_TASK_STACK_OVF_CHECK > 0)
|
||||
/**
|
||||
* This function will check task stack overflow
|
||||
*/
|
||||
void krhino_stack_ovf_check(void);
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_TASK_SCHED_STATS > 0)
|
||||
/**
|
||||
* This function will reset task schedule stats
|
||||
*/
|
||||
void krhino_task_sched_stats_reset(void);
|
||||
/**
|
||||
* This function will get task statistic data
|
||||
*/
|
||||
void krhino_task_sched_stats_get(void);
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_HW_COUNT > 0)
|
||||
void krhino_overhead_measure(void);
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_CPU_USAGE_STATS > 0)
|
||||
uint32_t krhino_get_cpu_usage(void);
|
||||
#endif
|
||||
|
||||
#endif /* K_STATS_H */
|
||||
|
||||
84
csky/csi_kernel/rhino/core/include/k_sys.h
Normal file
84
csky/csi_kernel/rhino/core/include/k_sys.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_SYS_H
|
||||
#define K_SYS_H
|
||||
|
||||
#define RHINO_VERSION 10000
|
||||
#define RHINO_IDLE_PRI (RHINO_CONFIG_PRI_MAX - 1)
|
||||
#define RHINO_FALSE 0u
|
||||
#define RHINO_TRUE 1u
|
||||
|
||||
#define RHINO_NO_WAIT 0u
|
||||
|
||||
#define MAX_TIMER_TICKS ((tick_t)-1 >> 1)
|
||||
|
||||
#if (RHINO_CONFIG_64_BIT_TYPE > 0)
|
||||
#define RHINO_WAIT_FOREVER ((uint64_t)-1)
|
||||
typedef uint64_t sys_time_t;
|
||||
typedef int64_t sys_time_i_t;
|
||||
typedef uint64_t idle_count_t;
|
||||
typedef uint64_t tick_t;
|
||||
typedef int64_t tick_i_t;
|
||||
#else
|
||||
#define RHINO_WAIT_FOREVER ((uint32_t)-1)
|
||||
typedef uint32_t sys_time_t;
|
||||
typedef int32_t sys_time_i_t;
|
||||
typedef uint32_t idle_count_t;
|
||||
typedef uint32_t tick_t;
|
||||
typedef int32_t tick_i_t;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_INTRPT_STACK_OVF_CHECK > 0)
|
||||
#if (RHINO_CONFIG_CPU_STACK_DOWN > 0)
|
||||
extern cpu_stack_t *g_intrpt_stack_bottom;
|
||||
#else
|
||||
extern cpu_stack_t *g_intrpt_stack_top;
|
||||
#endif
|
||||
#endif /* RHINO_CONFIG_INTRPT_STACK_OVF_CHECK */
|
||||
|
||||
/**
|
||||
* This function will init AliOS
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_init(void);
|
||||
|
||||
/**
|
||||
* This function will start AliOS
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_start(void);
|
||||
|
||||
/**
|
||||
* This function will enter interrupt
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_intrpt_enter(void);
|
||||
|
||||
/**
|
||||
* This function will exit interrupt
|
||||
*/
|
||||
void krhino_intrpt_exit(void);
|
||||
|
||||
/**
|
||||
* This function will check intrpt-stack overflow
|
||||
*/
|
||||
void krhino_intrpt_stack_ovf_check(void);
|
||||
|
||||
/**
|
||||
* This function will get the whole ram space used by kernel
|
||||
* @return the whole ram space used by kernel
|
||||
*/
|
||||
size_t krhino_global_space_get(void);
|
||||
|
||||
/**
|
||||
* This function will get kernel version
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
uint32_t krhino_version_get(void);
|
||||
|
||||
void krhino_check_fatal_call(const char *func);
|
||||
|
||||
#endif /* K_SYS_H */
|
||||
|
||||
312
csky/csi_kernel/rhino/core/include/k_task.h
Normal file
312
csky/csi_kernel/rhino/core/include/k_task.h
Normal file
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_TASK_H
|
||||
#define K_TASK_H
|
||||
|
||||
typedef enum {
|
||||
K_SEED,
|
||||
K_RDY,
|
||||
K_PEND,
|
||||
K_SUSPENDED,
|
||||
K_PEND_SUSPENDED,
|
||||
K_SLEEP,
|
||||
K_SLEEP_SUSPENDED,
|
||||
K_DELETED,
|
||||
} task_stat_t;
|
||||
|
||||
typedef struct {
|
||||
void *task_stack;
|
||||
|
||||
#if (RHINO_CONFIG_TASK_INFO > 0)
|
||||
/* for user data extension do not move the position! */
|
||||
void *user_info[RHINO_CONFIG_TASK_INFO_NUM];
|
||||
#endif
|
||||
|
||||
cpu_stack_t *task_stack_base;
|
||||
uint32_t stack_size;
|
||||
klist_t task_list;
|
||||
|
||||
#if (RHINO_CONFIG_TASK_SUSPEND > 0)
|
||||
suspend_nested_t suspend_count;
|
||||
#endif
|
||||
|
||||
struct mutex_s *mutex_list;
|
||||
|
||||
#if (RHINO_CONFIG_SYSTEM_STATS > 0)
|
||||
klist_t task_stats_item;
|
||||
#endif
|
||||
|
||||
klist_t tick_list;
|
||||
tick_t tick_match;
|
||||
tick_t tick_remain;
|
||||
klist_t *tick_head;
|
||||
|
||||
void *msg;
|
||||
|
||||
#if (RHINO_CONFIG_BUF_QUEUE > 0)
|
||||
size_t bq_msg_size;
|
||||
#endif
|
||||
|
||||
const name_t *task_name;
|
||||
|
||||
task_stat_t task_state;
|
||||
blk_state_t blk_state;
|
||||
|
||||
/* Task block on mutex, queue, semphore, event */
|
||||
blk_obj_t *blk_obj;
|
||||
|
||||
#if (RHINO_CONFIG_TASK_SEM > 0)
|
||||
struct sem_s *task_sem_obj;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_TASK_SCHED_STATS > 0)
|
||||
size_t task_free_stack_size;
|
||||
ctx_switch_t task_ctx_switch_times;
|
||||
sys_time_t task_time_total_run;
|
||||
sys_time_t task_time_total_run_prev;
|
||||
lr_timer_t task_exec_time;
|
||||
lr_timer_t task_time_start;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_DISABLE_INTRPT_STATS > 0)
|
||||
hr_timer_t task_intrpt_disable_time_max;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_DISABLE_SCHED_STATS > 0)
|
||||
hr_timer_t task_sched_disable_time_max;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_SCHED_RR > 0)
|
||||
/* for task time slice*/
|
||||
uint32_t time_slice;
|
||||
uint32_t time_total;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_EVENT_FLAG > 0)
|
||||
uint32_t pend_flags;
|
||||
void *pend_info;
|
||||
uint8_t pend_option;
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_SCHED_RR > 0)
|
||||
uint8_t sched_policy;
|
||||
#endif
|
||||
|
||||
uint8_t cpu_num;
|
||||
|
||||
#if (RHINO_CONFIG_CPU_NUM > 1)
|
||||
uint8_t cpu_binded;
|
||||
uint8_t cur_exc;
|
||||
#endif
|
||||
|
||||
/* current prio */
|
||||
uint8_t prio;
|
||||
/* base prio */
|
||||
uint8_t b_prio;
|
||||
uint8_t mm_alloc_flag:2, lprun:1, rev: 5;
|
||||
|
||||
void *arg;
|
||||
uint32_t runtime;
|
||||
int32_t task_errno;
|
||||
} ktask_t;
|
||||
|
||||
typedef void (*task_entry_t)(void *arg);
|
||||
|
||||
/**
|
||||
* This function will initialize a task
|
||||
* @param[in] task the task to be created
|
||||
* @param[in] name the name of task, which shall be unique
|
||||
* @param[in] arg the parameter of task enter function
|
||||
* @param[in] pri the prio of task
|
||||
* @param[in] ticks the time slice if there are same prio task
|
||||
* @param[in] stack_buf the start address of task stack
|
||||
* @param[in] stack the size of thread stack
|
||||
* @param[in] entry the entry function of task
|
||||
* @param[in] autorun the autorunning flag of task
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_create(ktask_t *task, const name_t *name, void *arg,
|
||||
uint8_t prio, tick_t ticks, cpu_stack_t *stack_buf,
|
||||
size_t stack_size, task_entry_t entry, uint8_t autorun);
|
||||
|
||||
#if (RHINO_CONFIG_CPU_NUM > 1)
|
||||
kstat_t krhino_task_cpu_create(ktask_t *task, const name_t *name, void *arg,
|
||||
uint8_t prio, tick_t ticks, cpu_stack_t *stack_buf,
|
||||
size_t stack_size, task_entry_t entry, uint8_t cpu_num,
|
||||
uint8_t autorun);
|
||||
|
||||
kstat_t krhino_task_cpu_bind(ktask_t *task, uint8_t cpu_num);
|
||||
kstat_t krhino_task_cpu_unbind(ktask_t *task);
|
||||
#endif
|
||||
|
||||
|
||||
#if (RHINO_CONFIG_KOBJ_DYN_ALLOC > 0)
|
||||
/**
|
||||
* This function will initialize a task
|
||||
* @param[in] task the task to be created
|
||||
* @param[in] name the name of task, which shall be unique
|
||||
* @param[in] arg the parameter of task enter function
|
||||
* @param[in] pri the prio of task
|
||||
* @param[in] ticks the time slice if there are same prio task
|
||||
* @param[in] stack the size of thread stack
|
||||
* @param[in] entry the entry function of task
|
||||
* @param[in] autorun the autorunning flag of task
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_dyn_create(ktask_t **task, const name_t *name, void *arg,
|
||||
uint8_t pri,
|
||||
tick_t ticks, void *stack, size_t stack_size,
|
||||
task_entry_t entry, uint8_t autorun);
|
||||
|
||||
#if (RHINO_CONFIG_CPU_NUM > 1)
|
||||
kstat_t krhino_task_cpu_dyn_create(ktask_t **task, const name_t *name, void *arg,
|
||||
uint8_t pri, tick_t ticks, size_t stack,
|
||||
task_entry_t entry, uint8_t cpu_num, uint8_t autorun);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_TASK_DEL > 0)
|
||||
/**
|
||||
* This function will delete a task
|
||||
* @param[in] task the task to be deleted.
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_del(ktask_t *task);
|
||||
#if (RHINO_CONFIG_KOBJ_DYN_ALLOC > 0)
|
||||
/**
|
||||
* This function will delete a dyn-task
|
||||
* @param[in] task the task to be deleted.
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_dyn_del(ktask_t *task);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function will cause a task to sleep for some ticks
|
||||
* @param[in] ticks the ticks to sleep
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
|
||||
kstat_t krhino_task_sleep(tick_t dly);
|
||||
|
||||
/**
|
||||
* This function will yield a task
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_yield(void);
|
||||
|
||||
/**
|
||||
* This function will get the current task for this cpu
|
||||
* @return the current task
|
||||
*/
|
||||
ktask_t *krhino_cur_task_get(void);
|
||||
|
||||
#if (RHINO_CONFIG_TASK_SUSPEND > 0)
|
||||
/**
|
||||
* This function will suspend a task
|
||||
* @param[in] task the task to be suspended
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_suspend(ktask_t *task);
|
||||
|
||||
/**
|
||||
* This function will resume a task
|
||||
* @param[in] task the task to be resumed
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_resume(ktask_t *task);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function will get min free stack size in the total runtime
|
||||
* @param[in] task the task where get free stack size.
|
||||
* @param[in] free the free task stack size to be filled with.
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_stack_min_free(ktask_t *task, size_t *free);
|
||||
|
||||
|
||||
/**
|
||||
* This function will get current free stack size
|
||||
* @param[in] task the task where get free stack size.
|
||||
* @param[in] free the free task stack size to be filled with.
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_stack_cur_free(ktask_t *task, size_t *free);
|
||||
|
||||
/**
|
||||
* This function will change the prio of task
|
||||
* @param[in] task the task to be changed prio
|
||||
* @param[in] pri the prio to be changed.
|
||||
* @param[out] old_pri the old task prio to be filled with
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_pri_change(ktask_t *task, uint8_t pri, uint8_t *old_pri);
|
||||
|
||||
#if (RHINO_CONFIG_TASK_WAIT_ABORT > 0)
|
||||
/**
|
||||
* This function will abort a task and wakup the task
|
||||
* @param[in] task the task to be aborted
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_wait_abort(ktask_t *task);
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_SCHED_RR > 0)
|
||||
/**
|
||||
* This function will set task timeslice
|
||||
* @param[in] task the task to be set timeslice
|
||||
* @param[in] slice the task time slice
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_time_slice_set(ktask_t *task, size_t slice);
|
||||
|
||||
/**
|
||||
* This function will set task sched policy
|
||||
* @param[in] task the task to be set timeslice
|
||||
* @param[in] policy the policy to be set, pllicy option can be either KSCHED_FIFO or KSCHED_RR
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_sched_policy_set(ktask_t *task, uint8_t policy);
|
||||
|
||||
/**
|
||||
* This function will get task sched policy
|
||||
* @param[in] task the task to be get timeslice
|
||||
* @param[out] policy the policy to be get
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_sched_policy_get(ktask_t *task, uint8_t *policy);
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_TASK_INFO > 0)
|
||||
/**
|
||||
* This function will set task private infomation
|
||||
* @param[in] task the task to be set private infomation
|
||||
* @param[out] info the private information
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_info_set(ktask_t *task, size_t idx, void *info);
|
||||
|
||||
/**
|
||||
* This function will get task private infomation
|
||||
* @param[in] task the task to be get private infomation
|
||||
* @param[out] info to save private infomation
|
||||
* @return the task private information
|
||||
*/
|
||||
kstat_t krhino_task_info_get(ktask_t *task, size_t idx, void **info);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function will be set in cpu_task_stack_init,set LR reg with
|
||||
* this funtion pointer
|
||||
*/
|
||||
void krhino_task_deathbed(void);
|
||||
|
||||
void krhino_task_set_lprun(ktask_t *task, uint8_t run);
|
||||
void krhino_lpower_mode(uint8_t enable);
|
||||
|
||||
#endif /* K_TASK_H */
|
||||
|
||||
57
csky/csi_kernel/rhino/core/include/k_task_sem.h
Normal file
57
csky/csi_kernel/rhino/core/include/k_task_sem.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_TASK_SEM_H
|
||||
#define K_TASK_SEM_H
|
||||
|
||||
/**
|
||||
* This function will create a task-semaphore
|
||||
* @param[in] task pointer to the task
|
||||
* @param[in] sem pointer to the semaphore
|
||||
* @param[in] name name of the task-semaphore
|
||||
* @param[in] count count of the semaphore
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_sem_create(ktask_t *task, ksem_t *sem, const name_t *name,
|
||||
size_t count);
|
||||
|
||||
/**
|
||||
* This function will delete a task-semaphore
|
||||
* @param[in] task pointer to the semaphore
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_sem_del(ktask_t *task);
|
||||
|
||||
/**
|
||||
* This function will give up a task-semaphore
|
||||
* @param[in] task pointer to the task
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_sem_give(ktask_t *task);
|
||||
|
||||
/**
|
||||
* This function will take a task-semaphore
|
||||
* @param[in] ticks ticks to wait before take the semaphore
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_sem_take(tick_t ticks);
|
||||
|
||||
/**
|
||||
* This function will set the count of a task-semaphore
|
||||
* @param[in] task pointer to the task
|
||||
* @param[in] count count of the semaphre to set
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_sem_count_set(ktask_t *task, sem_count_t count);
|
||||
|
||||
/**
|
||||
* This function will get task-semaphore count
|
||||
* @param[in] task pointer to the semphore
|
||||
* @param[out] count count of the semaphore
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_task_sem_count_get(ktask_t *task, sem_count_t *count);
|
||||
|
||||
#endif /* K_TASK_SEM_H */
|
||||
|
||||
41
csky/csi_kernel/rhino/core/include/k_time.h
Normal file
41
csky/csi_kernel/rhino/core/include/k_time.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_TIME_H
|
||||
#define K_TIME_H
|
||||
|
||||
/**
|
||||
* This function will handle systick routine
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
void krhino_tick_proc(void);
|
||||
|
||||
/**
|
||||
* This function will get time of the system in ms
|
||||
* @return system time
|
||||
*/
|
||||
sys_time_t krhino_sys_time_get(void);
|
||||
|
||||
/**
|
||||
* This function will get ticks of the system
|
||||
* @return the system ticks
|
||||
*/
|
||||
sys_time_t krhino_sys_tick_get(void);
|
||||
|
||||
/**
|
||||
* This function will convert ms to ticks
|
||||
* @param[in] ms ms which will be converted to ticks
|
||||
* @return the ticks of the ms
|
||||
*/
|
||||
tick_t krhino_ms_to_ticks(sys_time_t ms);
|
||||
|
||||
/**
|
||||
* This function will convert ticks to ms
|
||||
* @param[in] ticks ticks which will be converted to ms
|
||||
* @return the ms of the ticks
|
||||
*/
|
||||
sys_time_t krhino_ticks_to_ms(tick_t ticks);
|
||||
|
||||
#endif /* K_TIME_H */
|
||||
|
||||
137
csky/csi_kernel/rhino/core/include/k_timer.h
Normal file
137
csky/csi_kernel/rhino/core/include/k_timer.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_TIMER_H
|
||||
#define K_TIMER_H
|
||||
|
||||
enum {
|
||||
TIMER_CMD_CB = 0u,
|
||||
TIMER_CMD_START,
|
||||
TIMER_CMD_STOP,
|
||||
TIMER_CMD_CHG,
|
||||
TIMER_ARG_CHG,
|
||||
TIMER_ARG_CHG_AUTO,
|
||||
TIMER_CMD_DEL,
|
||||
TIMER_CMD_DYN_DEL
|
||||
};
|
||||
|
||||
typedef void (*timer_cb_t)(void *timer, void *arg);
|
||||
|
||||
typedef struct {
|
||||
klist_t timer_list;
|
||||
klist_t *to_head;
|
||||
const name_t *name;
|
||||
timer_cb_t cb;
|
||||
void *timer_cb_arg;
|
||||
sys_time_t match;
|
||||
sys_time_t remain;
|
||||
sys_time_t init_count;
|
||||
sys_time_t round_ticks;
|
||||
void *priv;
|
||||
kobj_type_t obj_type;
|
||||
uint8_t timer_state;
|
||||
uint8_t mm_alloc_flag;
|
||||
} ktimer_t;
|
||||
|
||||
typedef struct {
|
||||
ktimer_t *timer;
|
||||
uint8_t cb_num;
|
||||
sys_time_t first;
|
||||
union {
|
||||
sys_time_t round;
|
||||
void *arg;
|
||||
} u;
|
||||
} k_timer_queue_cb;
|
||||
|
||||
typedef enum {
|
||||
TIMER_DEACTIVE = 0u,
|
||||
TIMER_ACTIVE
|
||||
} k_timer_state_t;
|
||||
|
||||
/**
|
||||
* This function will create a timer
|
||||
* @param[in] timer pointer to the timer(the space is provided by user)
|
||||
* @param[in] name name of the timer
|
||||
* @param[in] cb callbak of the timer
|
||||
* @param[in] first ticks of the first timer triger
|
||||
* @param[in] round ticks of the normal timer triger
|
||||
* @param[in] arg the argument of the callback
|
||||
* @param[in] auto_run auto run or not when the timer is created
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_timer_create(ktimer_t *timer, const name_t *name, timer_cb_t cb,
|
||||
sys_time_t first, sys_time_t round, void *arg, uint8_t auto_run);
|
||||
|
||||
/**
|
||||
* This function will delete a timer
|
||||
* @param[in] timer pointer to a timer
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_timer_del(ktimer_t *timer);
|
||||
|
||||
#if (RHINO_CONFIG_KOBJ_DYN_ALLOC > 0)
|
||||
/**
|
||||
* This function will create a dyn-timer
|
||||
* @param[in] timer pointer to the timer
|
||||
* @param[in] name name of the timer
|
||||
* @param[in] cb callbak of the timer
|
||||
* @param[in] first ticks of the first timer triger
|
||||
* @param[in] round ticks of the normal timer triger
|
||||
* @param[in] arg the argument of the callback
|
||||
* @param[in] auto_run auto run or not when the timer is created
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_timer_dyn_create(ktimer_t **timer, const name_t *name,
|
||||
timer_cb_t cb,
|
||||
sys_time_t first, sys_time_t round, void *arg, uint8_t auto_run);
|
||||
/**
|
||||
* This function will delete a dyn-timer
|
||||
* @param[in] timer pointer to a timer
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_timer_dyn_del(ktimer_t *timer);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function will start a timer
|
||||
* @param[in] timer pointer to the timer
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_timer_start(ktimer_t *timer);
|
||||
|
||||
/**
|
||||
* This function will stop a timer
|
||||
* @param[in] timer pointer to the timer
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_timer_stop(ktimer_t *timer);
|
||||
|
||||
/**
|
||||
* This function will change attributes of a timer
|
||||
* @param[in] timer pointer to the timer
|
||||
* @param[in] first ticks of the first timer triger
|
||||
* @param[in] round ticks of the normal timer triger
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_timer_change(ktimer_t *timer, sys_time_t first, sys_time_t round);
|
||||
|
||||
/**
|
||||
* This function will change attributes of a timer without stop and start
|
||||
* @param[in] timer pointer to the timer
|
||||
* @param[in] first ticks of the first timer triger
|
||||
* @param[in] round ticks of the normal timer triger
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_timer_arg_change_auto(ktimer_t *timer, void *arg);
|
||||
|
||||
/**
|
||||
* This function will change callback arg attributes of a timer
|
||||
* @param[in] timer pointer to the timer
|
||||
* @param[in] arg timer callback arg
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_timer_arg_change(ktimer_t *timer, void *arg);
|
||||
|
||||
#endif /* K_TIMER_H */
|
||||
|
||||
207
csky/csi_kernel/rhino/core/include/k_trace.h
Normal file
207
csky/csi_kernel/rhino/core/include/k_trace.h
Normal file
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_TRACE_H
|
||||
#define K_TRACE_H
|
||||
|
||||
|
||||
#if (RHINO_CONFIG_TRACE > 0)
|
||||
/* task trace function */
|
||||
void _trace_init(void);
|
||||
void _trace_task_switch(ktask_t *from, ktask_t *to);
|
||||
void _trace_intrpt_task_switch(ktask_t *from, ktask_t *to);
|
||||
void _trace_task_create(ktask_t *task);
|
||||
void _trace_task_sleep(ktask_t *task, tick_t ticks);
|
||||
void _trace_task_pri_change(ktask_t *task, ktask_t *task_pri_chg, uint8_t pri);
|
||||
void _trace_task_suspend(ktask_t *task, ktask_t *task_suspended);
|
||||
void _trace_task_resume(ktask_t *task, ktask_t *task_resumed);
|
||||
void _trace_task_del(ktask_t *task, ktask_t *task_del);
|
||||
void _trace_task_abort(ktask_t *task, ktask_t *task_abort);
|
||||
|
||||
/* semaphore trace function */
|
||||
void _trace_sem_create(ktask_t *task, ksem_t *sem);
|
||||
void _trace_sem_overflow(ktask_t *task, ksem_t *sem);
|
||||
void _trace_sem_del(ktask_t *task, ksem_t *sem);
|
||||
void _trace_sem_get_success(ktask_t *task, ksem_t *sem);
|
||||
void _trace_sem_get_blk(ktask_t *task, ksem_t *sem, tick_t wait_option);
|
||||
void _trace_sem_task_wake(ktask_t *task, ktask_t *task_waked_up, ksem_t *sem,
|
||||
uint8_t opt_wake_all);
|
||||
void _trace_sem_cnt_increase(ktask_t *task, ksem_t *sem);
|
||||
|
||||
/* mutex trace function */
|
||||
void _trace_mutex_create(ktask_t *task, kmutex_t *mutex, const name_t *name);
|
||||
void _trace_mutex_release(ktask_t *task, ktask_t *task_release,
|
||||
uint8_t new_pri);
|
||||
void _trace_mutex_get(ktask_t *task, kmutex_t *mutex, tick_t wait_option);
|
||||
void _trace_task_pri_inv(ktask_t *task, ktask_t *mtxtsk);
|
||||
void _trace_mutex_get_blk(ktask_t *task, kmutex_t *mutex, tick_t wait_option);
|
||||
void _trace_mutex_release_success(ktask_t *task, kmutex_t *mutex);
|
||||
void _trace_mutex_task_wake(ktask_t *task, ktask_t *task_waked_up,
|
||||
kmutex_t *mutex);
|
||||
void _trace_mutex_del(ktask_t *task, kmutex_t *mutex);
|
||||
|
||||
/* event trace function */
|
||||
void _trace_event_create(ktask_t *task, kevent_t *event, const name_t *name,
|
||||
uint32_t flags_init);
|
||||
void _trace_event_get(ktask_t *task, kevent_t *event);
|
||||
void _trace_event_get_blk(ktask_t *task, kevent_t *event, tick_t wait_option);
|
||||
void _trace_event_task_wake(ktask_t *task, ktask_t *task_waked_up,
|
||||
kevent_t *event);
|
||||
void _trace_event_del(ktask_t *task, kevent_t *event);
|
||||
|
||||
/* buf_queue trace function */
|
||||
void _trace_buf_queue_create(ktask_t *task, kbuf_queue_t *buf_queue);
|
||||
void _trace_buf_max(ktask_t *task, kbuf_queue_t *buf_queue, void *p_void,
|
||||
size_t msg_size);
|
||||
void _trace_buf_post(ktask_t *task, kbuf_queue_t *buf_queue, void *p_void,
|
||||
size_t msg_size);
|
||||
void _trace_buf_queue_task_wake(ktask_t *task, ktask_t *task_waked_up,
|
||||
kbuf_queue_t *buf_queue);
|
||||
void _trace_buf_queue_get_blk(ktask_t *task, kbuf_queue_t *buf_queue,
|
||||
tick_t wait_option);
|
||||
|
||||
/* timer trace function */
|
||||
void _trace_timer_create(ktask_t *task, ktimer_t *timer);
|
||||
void _trace_timer_del(ktask_t *task, ktimer_t *timer);
|
||||
|
||||
/* mblk trace function */
|
||||
void _trace_mblk_pool_create(ktask_t *task, mblk_pool_t *pool);
|
||||
|
||||
/* mm trace function */
|
||||
//void _trace_mm_pool_create(ktask_t *task, mm_pool_t *pool);
|
||||
|
||||
/* work queue trace */
|
||||
void _trace_work_init(ktask_t *task, kwork_t *work);
|
||||
void _trace_workqueue_create(ktask_t *task, kworkqueue_t *workqueue);
|
||||
void _trace_workqueue_del(ktask_t *task, kworkqueue_t *workqueue);
|
||||
|
||||
/* task trace */
|
||||
#define TRACE_INIT() _trace_init()
|
||||
#define TRACE_TASK_SWITCH(from, to) _trace_task_switch(from, to)
|
||||
#define TRACE_TASK_CREATE(task) _trace_task_create(task)
|
||||
#define TRACE_TASK_SLEEP(task, ticks) _trace_task_sleep(task, ticks)
|
||||
#define TRACE_INTRPT_TASK_SWITCH(from, to) _trace_intrpt_task_switch(from, to)
|
||||
#define TRACE_TASK_PRI_CHANGE(task, task_pri_chg, pri) _trace_task_pri_change(task, task_pri_chg, pri)
|
||||
#define TRACE_TASK_SUSPEND(task, task_suspended) _trace_task_suspend(task, task_suspended)
|
||||
#define TRACE_TASK_RESUME(task, task_resumed) _trace_task_resume(task, task_resumed)
|
||||
#define TRACE_TASK_DEL(task, task_del) _trace_task_del(task, task_del)
|
||||
#define TRACE_TASK_WAIT_ABORT(task, task_abort) _trace_task_abort(task, task_abort)
|
||||
|
||||
/* semaphore trace */
|
||||
#define TRACE_SEM_CREATE(task, sem) _trace_sem_create(task, sem)
|
||||
#define TRACE_SEM_OVERFLOW(task, sem) _trace_sem_overflow(task, sem)
|
||||
#define TRACE_SEM_CNT_INCREASE(task, sem) _trace_sem_cnt_increase(task, sem)
|
||||
#define TRACE_SEM_GET_SUCCESS(task, sem) _trace_sem_get_success(task, sem)
|
||||
#define TRACE_SEM_GET_BLK(task, sem, wait_option) _trace_sem_get_blk(task, sem, wait_option)
|
||||
#define TRACE_SEM_TASK_WAKE(task, task_waked_up, sem, opt_wake_all) _trace_sem_task_wake(task, task_waked_up, sem, opt_wake_all)
|
||||
#define TRACE_SEM_DEL(task, sem) _trace_sem_del(task, sem);
|
||||
|
||||
/* mutex trace */
|
||||
#define TRACE_MUTEX_CREATE(task, mutex, name) _trace_mutex_create(task, mutex, name)
|
||||
#define TRACE_MUTEX_RELEASE(task, task_release, new_pri) _trace_mutex_release(task, task_release, new_pri)
|
||||
#define TRACE_MUTEX_GET(task, mutex, wait_option) _trace_mutex_get(task, mutex, wait_option)
|
||||
#define TRACE_TASK_PRI_INV(task, mtxtsk) _trace_task_pri_inv(task, mtxtsk)
|
||||
#define TRACE_MUTEX_GET_BLK(task, mutex, wait_option) _trace_mutex_get_blk(task, mutex, wait_option)
|
||||
#define TRACE_MUTEX_RELEASE_SUCCESS(task, mutex) _trace_mutex_release_success(task, mutex)
|
||||
#define TRACE_MUTEX_TASK_WAKE(task, task_waked_up, mutex) _trace_mutex_task_wake(task, task_waked_up, mutex)
|
||||
#define TRACE_MUTEX_DEL(task, mutex) _trace_mutex_del(task, mutex)
|
||||
|
||||
/* event trace */
|
||||
#define TRACE_EVENT_CREATE(task, event, name, flags_init) _trace_event_create(task, event, name, flags_init)
|
||||
#define TRACE_EVENT_GET(task, event) _trace_event_get(task, event)
|
||||
#define TRACE_EVENT_GET_BLK(task, event, wait_option) _trace_event_get_blk(task, event, wait_option)
|
||||
#define TRACE_EVENT_TASK_WAKE(task, task_waked_up, event) _trace_event_task_wake(task, task_waked_up, event)
|
||||
#define TRACE_EVENT_DEL(task, event) _trace_event_del(task, event)
|
||||
|
||||
/* buf_queue trace */
|
||||
#define TRACE_BUF_QUEUE_CREATE(task, buf_queue) _trace_buf_queue_create(task, buf_queue)
|
||||
#define TRACE_BUF_QUEUE_MAX(task, buf_queue, msg, msg_size) _trace_buf_max(task, buf_queue, msg, msg_size)
|
||||
#define TRACE_BUF_QUEUE_POST(task, buf_queue, msg, msg_size) _trace_buf_post(task, buf_queue, msg, msg_size)
|
||||
#define TRACE_BUF_QUEUE_TASK_WAKE(task, task_waked_up, queue) _trace_buf_queue_task_wake(task, task_waked_up, queue)
|
||||
#define TRACE_BUF_QUEUE_GET_BLK(task, buf_queue, wait_option) _trace_buf_queue_get_blk(task, buf_queue, wait_option)
|
||||
|
||||
/* timer trace */
|
||||
#define TRACE_TIMER_CREATE(task, timer) _trace_timer_create(task, timer)
|
||||
#define TRACE_TIMER_DEL(task, timer) _trace_timer_del(task, timer)
|
||||
|
||||
/* mblk trace */
|
||||
#define TRACE_MBLK_POOL_CREATE(task, pool) _trace_mblk_pool_create(task, pool)
|
||||
|
||||
/* mm trace */
|
||||
#define TRACE_MM_POOL_CREATE(task, pool) _trace_mm_pool_create(task, pool)
|
||||
|
||||
/* mm region */
|
||||
#define TRACE_MM_REGION_CREATE(task, regions) _trace_mm_region_create(task, regions)
|
||||
|
||||
/* work queue trace */
|
||||
#define TRACE_WORK_INIT(task, work) _trace_work_init(task, work)
|
||||
#define TRACE_WORKQUEUE_CREATE(task, workqueue) _trace_workqueue_create(task, workqueue)
|
||||
#define TRACE_WORKQUEUE_DEL(task, workqueue) _trace_workqueue_del(task, workqueue)
|
||||
|
||||
#else
|
||||
/* task trace */
|
||||
#define TRACE_INIT()
|
||||
#define TRACE_TASK_SWITCH(from, to)
|
||||
#define TRACE_TASK_CREATE(task)
|
||||
#define TRACE_TASK_SLEEP(task, ticks)
|
||||
#define TRACE_INTRPT_TASK_SWITCH(from, to)
|
||||
#define TRACE_TASK_PRI_CHANGE(task, task_pri_chg, pri)
|
||||
#define TRACE_TASK_SUSPEND(task, task_suspended)
|
||||
#define TRACE_TASK_RESUME(task, task_resumed)
|
||||
#define TRACE_TASK_DEL(task, task_del)
|
||||
#define TRACE_TASK_WAIT_ABORT(task, task_abort)
|
||||
|
||||
/* semaphore trace */
|
||||
#define TRACE_SEM_CREATE(task, sem)
|
||||
#define TRACE_SEM_OVERFLOW(task, sem)
|
||||
#define TRACE_SEM_CNT_INCREASE(task, sem)
|
||||
#define TRACE_SEM_GET_SUCCESS(task, sem)
|
||||
#define TRACE_SEM_GET_BLK(task, sem, wait_option)
|
||||
#define TRACE_SEM_TASK_WAKE(task, task_waked_up, sem, opt_wake_all)
|
||||
#define TRACE_SEM_DEL(task, sem)
|
||||
|
||||
/* mutex trace */
|
||||
#define TRACE_MUTEX_CREATE(task, mutex, name)
|
||||
#define TRACE_MUTEX_RELEASE(task, task_release, new_pri)
|
||||
#define TRACE_MUTEX_GET(task, mutex, wait_option)
|
||||
#define TRACE_TASK_PRI_INV(task, mtxtsk)
|
||||
#define TRACE_MUTEX_GET_BLK(task, mutex, wait_option)
|
||||
#define TRACE_MUTEX_RELEASE_SUCCESS(task, mutex)
|
||||
#define TRACE_MUTEX_TASK_WAKE(task, task_waked_up, mutex)
|
||||
#define TRACE_MUTEX_DEL(task, mutex)
|
||||
|
||||
/* event trace */
|
||||
#define TRACE_EVENT_CREATE(task, event, name, flags_init)
|
||||
#define TRACE_EVENT_GET(task, event)
|
||||
#define TRACE_EVENT_GET_BLK(task, event, wait_option)
|
||||
#define TRACE_EVENT_TASK_WAKE(task, task_waked_up, event)
|
||||
#define TRACE_EVENT_DEL(task, event)
|
||||
|
||||
/* buf_queue trace */
|
||||
#define TRACE_BUF_QUEUE_CREATE(task, buf_queue)
|
||||
#define TRACE_BUF_QUEUE_MAX(task, buf_queue, msg, msg_size)
|
||||
#define TRACE_BUF_QUEUE_POST(task, buf_queue, msg, msg_size)
|
||||
#define TRACE_BUF_QUEUE_TASK_WAKE(task, task_waked_up, queue)
|
||||
#define TRACE_BUF_QUEUE_GET_BLK(task, buf_queue, wait_option)
|
||||
|
||||
/* timer trace */
|
||||
#define TRACE_TIMER_CREATE(task, timer)
|
||||
#define TRACE_TIMER_DEL(task, timer)
|
||||
|
||||
/* MBLK trace */
|
||||
#define TRACE_MBLK_POOL_CREATE(task, pool)
|
||||
|
||||
/* MM trace */
|
||||
#define TRACE_MM_POOL_CREATE(task, pool)
|
||||
|
||||
/* MM region trace*/
|
||||
#define TRACE_MM_REGION_CREATE(task, regions)
|
||||
|
||||
/* work queue trace */
|
||||
#define TRACE_WORK_INIT(task, work)
|
||||
#define TRACE_WORKQUEUE_CREATE(task, workqueue)
|
||||
#define TRACE_WORKQUEUE_DEL(task, workqueue)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
86
csky/csi_kernel/rhino/core/include/k_workqueue.h
Normal file
86
csky/csi_kernel/rhino/core/include/k_workqueue.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef K_WORKQUEUE_H
|
||||
#define K_WORKQUEUE_H
|
||||
|
||||
#if (RHINO_CONFIG_WORKQUEUE > 0)
|
||||
#define WORKQUEUE_WORK_MAX 32
|
||||
|
||||
typedef void (*work_handle_t)(void *arg);
|
||||
|
||||
typedef struct {
|
||||
klist_t work_node;
|
||||
work_handle_t handle;
|
||||
void *arg;
|
||||
tick_t dly;
|
||||
ktimer_t *timer;
|
||||
void *wq;
|
||||
uint8_t work_exit;
|
||||
} kwork_t;
|
||||
|
||||
typedef struct {
|
||||
klist_t workqueue_node;
|
||||
klist_t work_list;
|
||||
kwork_t *work_current; /* current work */
|
||||
const name_t *name;
|
||||
ktask_t worker;
|
||||
ksem_t sem;
|
||||
} kworkqueue_t;
|
||||
|
||||
/**
|
||||
* This function will creat a workqueue
|
||||
* @param[in] workqueue the workqueue to be created
|
||||
* @param[in] name the name of workqueue/worker, which should be unique
|
||||
* @param[in] pri the priority of the worker
|
||||
* @param[in] stack_buf the stack of the worker(task)
|
||||
* @param[in] stack_size the size of the worker-stack
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_workqueue_create(kworkqueue_t *workqueue, const name_t *name,
|
||||
uint8_t pri, cpu_stack_t *stack_buf, size_t stack_size);
|
||||
|
||||
/**
|
||||
* This function will delete a workqueue
|
||||
* @param[in] workqueue the workqueue to be deleted
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_workqueue_del(kworkqueue_t *workqueue);
|
||||
|
||||
/**
|
||||
* This function will initialize a work
|
||||
* @param[in] work the work to be initialized
|
||||
* @param[in] handle the call back function to run
|
||||
* @param[in] arg the paraments of the function
|
||||
* @param[in] dly the ticks to delay before run
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_work_init(kwork_t *work, work_handle_t handle, void *arg,
|
||||
tick_t dly);
|
||||
|
||||
/**
|
||||
* This function will run a work on a workqueue
|
||||
* @param[in] workqueue the workqueue to run work
|
||||
* @param[in] work the work to run
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_work_run(kworkqueue_t *workqueue, kwork_t *work);
|
||||
|
||||
/**
|
||||
* This function will run a work on the default workqueue
|
||||
* @param[in] work the work to run
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_work_sched(kwork_t *work);
|
||||
|
||||
/**
|
||||
* This function will cancel a work
|
||||
* @param[in] work the work to cancel
|
||||
* @return the operation status, RHINO_SUCCESS is OK, others is error
|
||||
*/
|
||||
kstat_t krhino_work_cancel(kwork_t *work);
|
||||
#endif
|
||||
|
||||
#endif /* K_WORKQUEUE_H */
|
||||
|
||||
Reference in New Issue
Block a user