optimize code standard

This commit is contained in:
Liu_Weichao
2021-04-30 16:01:38 +08:00
parent 3ba05d0a71
commit adcfd5e7f6
70 changed files with 1596 additions and 1773 deletions

View File

@@ -31,8 +31,8 @@
extern "C" {
#endif
#define MERGE_FLAG(src, flag) *(src) |= flag
#define CLEAR_FLAG(src, flag) *(src) &= ~flag
#define MERGE_FLAG(src, flag) (*(src) |= flag)
#define CLEAR_FLAG(src, flag) (*(src) &= ~flag)
extern struct Assign Assign;

View File

@@ -30,13 +30,14 @@
#define TASK_DELAY_INACTIVE 0
#define TASK_DELAY_ACTIVE 1
struct Delay {
struct Delay
{
struct TaskDescriptor *task;
x_ticks_t ticks;
uint8 status;
DoubleLinklistType link;
};
typedef struct Delay *delay_t;
typedef struct Delay *DelayType;
x_err_t KTaskSetDelay(struct TaskDescriptor *task, x_ticks_t ticks);
x_err_t KTaskUnSetDelay(struct TaskDescriptor *task);

View File

@@ -36,54 +36,54 @@
extern "C" {
#endif
#define OSIGN_OPER_CLOSE (0U << 0)
#define OSIGN_OPER_RDONLY (1U << 0)
#define OSIGN_OPER_WRONLY (1U << 1)
#define OSIGN_OPER_RDWR (OSIGN_OPER_WRONLY| OSIGN_OPER_RDONLY )
#define OSIGN_OPER_OPEN (1U << 3)
#define OSIGN_OPER_MASK 0xf0f
#define OSIGN_OPER_CLOSE (0U << 0)
#define OSIGN_OPER_RDONLY (1U << 0)
#define OSIGN_OPER_WRONLY (1U << 1)
#define OSIGN_OPER_RDWR (OSIGN_OPER_WRONLY| OSIGN_OPER_RDONLY )
#define OSIGN_OPER_OPEN (1U << 3)
#define OSIGN_OPER_MASK 0xf0f
#define SIGN_OPER_DEACTIVATE (0U << 0)
#define SIGN_OPER_RDONLY (1U << 0)
#define SIGN_OPER_WRONLY (1U << 1)
#define SIGN_OPER_RDWR (SIGN_OPER_RDONLY|SIGN_OPER_WRONLY)
#define SIGN_OPER_REMOVABLE (1U << 2)
#define SIGN_OPER_STANDALONE (1U << 3)
#define SIGN_OPER_ACTIVATED (1U << 4)
#define SIGN_OPER_SUSPENDED (1U << 5)
#define SIGN_OPER_STREAM (1U << 6)
#define SIGN_OPER_INT_RX (1U << 8)
#define SIGN_OPER_DMA_RX (1U << 9)
#define SIGN_OPER_INT_TX (1U << 10)
#define SIGN_OPER_DMA_TX (1U << 11)
#define SIGN_OPER_DEACTIVATE (0U << 0)
#define SIGN_OPER_RDONLY (1U << 0)
#define SIGN_OPER_WRONLY (1U << 1)
#define SIGN_OPER_RDWR (SIGN_OPER_RDONLY|SIGN_OPER_WRONLY)
#define SIGN_OPER_REMOVABLE (1U << 2)
#define SIGN_OPER_STANDALONE (1U << 3)
#define SIGN_OPER_ACTIVATED (1U << 4)
#define SIGN_OPER_SUSPENDED (1U << 5)
#define SIGN_OPER_STREAM (1U << 6)
#define SIGN_OPER_INT_RX (1U << 8)
#define SIGN_OPER_DMA_RX (1U << 9)
#define SIGN_OPER_INT_TX (1U << 10)
#define SIGN_OPER_DMA_TX (1U << 11)
enum SIGN_OPER
enum SIGN_OPER
{
OPER_RESUME = 0x01,
OPER_SUSPEND = 0x02,
OPER_CONFIG = 0x03,
OPER_SET_INT = 0x10,
OPER_CLR_INT = 0x11,
OPER_GET_INT = 0x12,
OPER_CHAR_STREAM = 0x10,
OPER_BLK_GETGEOME = 0x10,
OPER_BLK_SYNC = 0x11,
OPER_BLK_ERASE = 0x12,
OPER_BLK_AUTOREFRESH = 0x13,
OPER_NETIF_GETMAC = 0x10,
OPER_MTD_FORMAT = 0x10,
OPER_RTC_GET_TIME = 0x10,
OPER_RTC_SET_TIME = 0x11,
OPER_RTC_GET_ALARM = 0x12,
OPER_RTC_SET_ALARM = 0x13,
OPER_RESUME = 0x01,
OPER_SUSPEND = 0x02,
OPER_CONFIG = 0x03,
OPER_SET_INT = 0x10,
OPER_CLR_INT = 0x11,
OPER_GET_INT = 0x12,
OPER_CHAR_STREAM = 0x10,
OPER_BLK_GETGEOME = 0x10,
OPER_BLK_SYNC = 0x11,
OPER_BLK_ERASE = 0x12,
OPER_BLK_AUTOREFRESH = 0x13,
OPER_NETIF_GETMAC = 0x10,
OPER_MTD_FORMAT = 0x10,
OPER_RTC_GET_TIME = 0x10,
OPER_RTC_SET_TIME = 0x11,
OPER_RTC_GET_ALARM = 0x12,
OPER_RTC_SET_ALARM = 0x13,
};
struct DeviceBlockArrange
{
uint32 bank_num;
uint32 size_perbank;
uint32 block_size;
uint16 bank_start;
uint32 size_perbank;
uint32 block_size;
uint16 bank_start;
uint16 bank_end;
};

View File

@@ -86,7 +86,7 @@ struct TaskDyncSchedMember {
uint8 bitmap_row;
#endif
uint32 bitmap_column;
delay_t delay;
DelayType delay;
};
typedef struct TaskDyncSchedMember TaskDyncSchedMembeType;

View File

@@ -100,16 +100,16 @@ enum KernelService
KS_USER_END
};
#define SERVICETABLE ((struct Kernel_Service*)SERVICE_TABLE_ADDRESS)
#define SERVICETABLE ((struct KernelService*)SERVICE_TABLE_ADDRESS)
#endif
typedef uintptr_t (*kservice)(uint32_t knum,uintptr_t *param,uint8_t param_num);
struct Kernel_Service
struct KernelService
{
const kservice fun;
const uint8_t param_num;
};
extern struct Kernel_Service g_service_table[] ;
extern struct KernelService g_service_table[] ;
#endif

View File

@@ -45,16 +45,16 @@ struct SpinLock
HwSpinlock lock;
};
struct Spin_Lockfileops
{ //定义自旋锁
struct SpinLock node_lock; //原有的自旋锁结构体
void (*SPinLock)(struct Spin_Lockfileops *spinlock);
void (*UnlockSpinLock)(struct Spin_Lockfileops *spinlock);
void (*UnlockSpinLockIrqRestore)(struct Spin_Lockfileops *spinlock, x_base level);
x_base (*SpinLockIrqSave)(struct Spin_Lockfileops *spinlock);
struct SpinLockfileOps
{ //define spin lock
struct SpinLock node_lock; //last spin lock node struct
void (*SPinLock)(struct SpinLockfileOps *spinlock);
void (*UnlockSpinLock)(struct SpinLockfileOps *spinlock);
void (*UnlockSpinLockIrqRestore)(struct SpinLockfileOps *spinlock, x_base level);
x_base (*SpinLockIrqSave)(struct SpinLockfileOps *spinlock);
};
extern struct Spin_Lockfileops spinlock;
extern struct SpinLockfileOps spinlock;
extern HwSpinlock _CriticalLock;
void InitHwSpinlock(HwSpinlock *lock);
@@ -82,11 +82,11 @@ void ExecSecondaryCpuIdleKtask(void);
#ifdef ARCH_SMP
struct SpinLock;
void InitSpinLock(struct Spin_Lockfileops * spinlock);
void _SpinLock(struct Spin_Lockfileops * spinlock);
void _UnlockSpinLock(struct Spin_Lockfileops * spinlock);
x_base _SpinLockIrqSave(struct Spin_Lockfileops * spinlock);
void _UnlockSpinLockIrqRestore(struct Spin_Lockfileops * spinlock, x_base level);
void InitSpinLock(struct SpinLockfileOps * spinlock);
void _SpinLock(struct SpinLockfileOps * spinlock);
void _UnlockSpinLock(struct SpinLockfileOps * spinlock);
x_base _SpinLockIrqSave(struct SpinLockfileOps * spinlock);
void _UnlockSpinLockIrqRestore(struct SpinLockfileOps * spinlock, x_base level);
#else
#define InitSpinLock(lock) /* nothing */

View File

@@ -554,7 +554,7 @@ uintptr_t KsStatfs(uint32_t knum,uintptr_t *param, uint8_t num )
}
#endif
struct Kernel_Service g_service_table[256] __attribute__ ((section (".g_service_table"))) =
struct KernelService g_service_table[256] __attribute__ ((section (".g_service_table"))) =
{
[KS_USER_PRINT_INFO] = { KsPrintInfo, 1 },

View File

@@ -30,9 +30,9 @@ static uint8 mempool[2048];
static struct MemGather gm;
static GatherMemType gm_d;
#define TASK_PRIORITY 25
#define TASK_STACK_SIZE 2048
#define TASK_TIMESLICE 5
#define TASK_PRIORITY 25
#define TASK_STACK_SIZE 2048
#define TASK_TIMESLICE 5
/* thread control pointer */
static int32 tid1;
@@ -284,9 +284,9 @@ void GatherblockLimitTest(char *name, int count, int blocksize){
}
#ifdef ARCH_ARM
#define CACHE_COUNT 1024
#define CACHE_COUNT 1024
#else
#define CACHE_COUNT 8000
#define CACHE_COUNT 8000
#endif
struct MemGather *pools[CACHE_COUNT];

View File

@@ -59,7 +59,7 @@ void TimeoutCb(void* param){
hwtimer_dev->hwtimer_param.repeat = 1;
hwtimer_dev->hwtimer_param.period_millisecond = 3000;
hwtimer_dev->hwtimer_param.cb_info.param = NULL;
hwtimer_dev->hwtimer_param.cb_info.TimeoutCb = TimeoutCb;
hwtimer_dev->hwtimer_param.cb_info.timeout_callback = timeout_callback;
BusDevOpen(dev);

View File

@@ -29,10 +29,10 @@
* shell cmd parami2c device name,if null means default i2c device name
*/
#define HS_I2C_BUS_NAME I2C_BUS_NAME_1 /* I2C bus name */
#define HS_I2C_DEV_NAME I2C_1_DEVICE_NAME_0/* I2C device name */
#define HS_I2C_DRV_NAME I2C_DRV_NAME_1 /* I2C driver name */
#define ADDR 0x44 /* slave address */
#define HS_I2C_BUS_NAME I2C_BUS_NAME_1 /* I2C bus name */
#define HS_I2C_DEV_NAME I2C_1_DEVICE_NAME_0/* I2C device name */
#define HS_I2C_DRV_NAME I2C_DRV_NAME_1 /* I2C driver name */
#define ADDR 0x44 /* slave address */
static struct Bus *i2c_bus = NONE; /* I2C bus handle */

View File

@@ -42,8 +42,8 @@ DoubleLinklistType xiaoshan_task_head ={&xiaoshan_task_head, &xiaoshan_task_head
#define BITMAP_CACULATE_COLUMN_OFFSET(offset,n) (offset = n / 8)
#endif
#define BITMAP_SETCOLUMN(column,offset) (column = 1 << offset)
#define BITMAP_SETROW(row,offset) (row = 1 << offset)
#define BITMAP_SETCOLUMN(column,offset) (column = (1 << offset))
#define BITMAP_SETROW(row,offset) (row = (1 << offset))
#define BITLOWMASK_3BIT (0x7)

View File

@@ -24,7 +24,7 @@
#include <xs_assign.h>
#ifdef ARCH_SMP
struct Spin_Lockfileops spinlock;
struct SpinLockfileOps spinlock;
/*
* lock scheduler
*/
@@ -50,7 +50,7 @@ static void EnablePreempt(void)
EnableLocalInterrupt(lock);
}
void InitSpinLock( struct Spin_Lockfileops * spinlock)
void InitSpinLock( struct SpinLockfileOps * spinlock)
{
InitHwSpinlock(&spinlock->node_lock.lock);
spinlock->SPinLock = _SpinLock;
@@ -60,19 +60,19 @@ static void EnablePreempt(void)
}
void _SpinLock(struct Spin_Lockfileops * spinlock)
void _SpinLock(struct SpinLockfileOps * spinlock)
{
DisablePreempt();
HwLockSpinlock(&spinlock->node_lock.lock);
}
void _UnlockSpinLock(struct Spin_Lockfileops * spinlock)
void _UnlockSpinLock(struct SpinLockfileOps * spinlock)
{
HwUnlockSpinlock(&spinlock->node_lock.lock);
EnablePreempt();
}
x_base _SpinLockIrqSave(struct Spin_Lockfileops * spinlock)
x_base _SpinLockIrqSave(struct SpinLockfileOps * spinlock)
{
x_base lock = 0;
@@ -84,7 +84,7 @@ x_base _SpinLockIrqSave(struct Spin_Lockfileops * spinlock)
return lock;
}
void _UnlockSpinLockIrqRestore(struct Spin_Lockfileops * spinlock, x_base lock)
void _UnlockSpinLockIrqRestore(struct SpinLockfileOps * spinlock, x_base lock)
{
HwUnlockSpinlock(&spinlock->node_lock.lock);
EnableLocalInterrupt(lock);

View File

@@ -25,9 +25,9 @@
DECLARE_ID_MANAGER(k_mq_id_manager, ID_NUM_MAX);
DoubleLinklistType k_mq_list = {&k_mq_list, &k_mq_list};
struct mq_message
struct MqMessage
{
struct mq_message *next;
struct MqMessage *next;
};
static struct MsgQueue *GetMsgQueueById(int32 id)
@@ -195,7 +195,7 @@ static x_err_t _MsgQueueRecv(struct MsgQueue *mq,
x_ubase lock = 0;
uint32 tick_delta = 0;
int32 timeout = 0;
struct mq_message *msg = NONE;
struct MqMessage *msg = NONE;
struct TaskDescriptor *task = NONE;
NULL_PARAM_CHECK(mq);