This commit is contained in:
huxi
2025-12-03 11:12:34 +08:00
parent c23ae4f24c
commit bc195654bf
8163 changed files with 3799544 additions and 92 deletions
+178
View File
@@ -0,0 +1,178 @@
#ifndef BANK_SWITCH_H
#define BANK_SWITCH_H
#ifdef CONFIG_CODE_BANK_ENABLE
#define _BANK_ENTRY(num) __attribute__((section(".bank.code."#num))) __attribute__((banknum(num)))
#define __BANK_ENTRY(num) _BANK_ENTRY(num)
#define _BANK_NUM(num) __attribute__((section(".bank.code."#num))) __attribute__((banknum(num)))
#define __BANK_NUM(num) _BANK_NUM(num)
#define __BANK_COMMON() __attribute__((section(".common")))
#else
#define __BANK_ENTRY(num)
#define __BANK_NUM(num)
#endif
#ifdef CONFIG_BANK_COMM
#define __BANK_EDR_RX __BANK_COMMON()
#define __BANK_EDR_TX __BANK_COMMON()
#define __BANK_TWS_LINK __BANK_COMMON()
#define __BANK_EDR_FRAME __BANK_COMMON()
#else
#define __BANK_EDR_RX
#define __BANK_EDR_TX
#define __BANK_TWS_LINK
#define __BANK_EDR_FRAME
#endif
#ifdef CONFIG_BANK_NUM_INIT
#define __BANK_INIT_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_INIT)
#define __BANK_INIT __BANK_NUM(CONFIG_BANK_NUM_INIT)
#else
#define __BANK_INIT_ENTRY
#define __BANK_INIT
#endif
#ifdef CONFIG_BANK_NUM_RF
#define __BANK_RF_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_RF)
#define __BANK_RF __BANK_NUM(CONFIG_BANK_NUM_RF)
#else
#define __BANK_RF_ENTRY
#define __BANK_RF
#endif
#ifdef CONFIG_BANK_NUM_RF_TRIM
#define __BANK_RF_TRIM __BANK_NUM(CONFIG_BANK_NUM_RF_TRIM)
#else
#define __BANK_RF_TRIM
#endif
#ifdef CONFIG_BANK_NUM_DUT
#define __BANK_DUT_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_DUT)
#define __BANK_DUT __BANK_NUM(CONFIG_BANK_NUM_DUT)
#else
#define __BANK_DUT_ENTRY
#define __BANK_DUT
#endif
#ifdef CONFIG_BANK_NUM_ECDH
#define __BANK_ECDH_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_ECDH)
#define __BANK_ECDH __BANK_NUM(CONFIG_BANK_NUM_ECDH)
#else
#define __BANK_ECDH_ENTRY
#define __BANK_ECDH
#endif
#ifdef CONFIG_BANK_NUM_ENC
#define __BANK_ENC_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_ENC)
#define __BANK_ENC __BANK_NUM(CONFIG_BANK_NUM_ENC)
#else
#define __BANK_ENC_ENTRY
#define __BANK_ENC
#endif
#ifdef CONFIG_BANK_NUM_A2DP
#define __BANK_A2DP_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_A2DP)
#define __BANK_A2DP __BANK_NUM(CONFIG_BANK_NUM_A2DP)
#else
#define __BANK_A2DP_ENTRY
#define __BANK_A2DP
#endif
#ifdef CONFIG_BANK_NUM_AVCTP
#define __BANK_AVCTP_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_AVCTP)
#define __BANK_AVCTP __BANK_NUM(CONFIG_BANK_NUM_AVCTP)
#else
#define __BANK_AVCTP_ENTRY
#define __BANK_AVCTP
#endif
#ifdef CONFIG_BANK_NUM_RFCOMM
#define __BANK_RFCOMM_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_RFCOMM)
#define __BANK_RFCOMM __BANK_NUM(CONFIG_BANK_NUM_RFCOMM)
#else
#define __BANK_RFCOMM_ENTRY
#define __BANK_RFCOMM
#endif
#ifdef CONFIG_BANK_NUM_SDP
#define __BANK_SDP_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_SDP)
#define __BANK_SDP __BANK_NUM(CONFIG_BANK_NUM_SDP)
#else
#define __BANK_SDP_ENTRY
#define __BANK_SDP
#endif
#ifdef CONFIG_BANK_NUM_BT_HID
#define __BANK_BT_HID_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_BT_HID)
#define __BANK_BT_HID __BANK_NUM(CONFIG_BANK_NUM_BT_HID)
#else
#define __BANK_BT_HID_ENTRY
#define __BANK_BT_HID
#endif
#ifdef CONFIG_BANK_NUM_BLE
#define __BANK_BLE_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_BLE)
#define __BANK_BLE __BANK_NUM(CONFIG_BANK_NUM_BLE)
#else
#define __BANK_BLE_ENTRY
#define __BANK_BLE
#endif
#ifdef CONFIG_BANK_NUM_TWS_BLE
#define __BANK_TWS_BLE_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_TWS_BLE)
#define __BANK_TWS_BLE __BANK_NUM(CONFIG_BANK_NUM_TWS_BLE)
#else
#define __BANK_TWS_BLE_ENTRY
#define __BANK_TWS_BLE
#endif
#ifdef CONFIG_BANK_NUM_TONE
#define __BANK_TONE_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_TONE)
#define __BANK_TONE __BANK_NUM(CONFIG_BANK_NUM_TONE)
#else
#define __BANK_TONE_ENTRY
#define __BANK_TONE
#endif
#ifdef CONFIG_BANK_NUM_LMP_SLAVE
#define __BANK_LMP_SLAVE_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_LMP_SLAVE)
#define __BANK_LMP_SLAVE __BANK_NUM(CONFIG_BANK_NUM_LMP_SLAVE)
#else
#define __BANK_LMP_SLAVE_ENTRY
#define __BANK_LMP_SLAVE
#endif
#ifdef CONFIG_BANK_NUM_LMP_MASTER
#define __BANK_LMP_MASTER_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_LMP_MASTER)
#define __BANK_LMP_MASTER __BANK_NUM(CONFIG_BANK_NUM_LMP_MASTER)
#else
#define __BANK_LMP_MASTER_ENTRY
#define __BANK_LMP_MASTER
#endif
#ifdef CONFIG_BANK_NUM_CLOCK
#define __BANK_CLOCK_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_CLOCK)
#define __BANK_CLOCK __BANK_NUM(CONFIG_BANK_NUM_CLOCK)
#else
#define __BANK_CLOCK_ENTRY
#define __BANK_CLOCK
#endif
void load_overlay_code(int num);
void bank_syscall_entry(void);
void load_common_code(void);
#endif
+57
View File
@@ -0,0 +1,57 @@
#ifndef __BOOT_H__
#define __BOOT_H__
struct vm_info {
u8 align; //from uboot, 按 n * 256 对齐
u32 vm_saddr; //from sdfile, flash addr
u32 vm_res; //reverse_bytes
u32 vm_size; //from sdfile
};
struct sfc_info {
u32 sfc_base_addr; //flash memory addr, from uboot
u32 app_addr; //cpu logic addr, from uboot
};
struct bt_mac_addr {
u8 value[6];
u16 value_crc;
};
typedef struct _boot_info {
struct vm_info vm;
struct sfc_info sfc;
u32 flash_size; //from uboot
u16 chip_id; //from uboot
u16 trim_value; //from uboot
struct bt_mac_addr mac;
} BOOT_INFO;
//=====================================
struct flash_head {
u16 crc;
u16 size4burner;
u8 vid[4]; //u32 vm_eaddr;
u32 FlashSize;
u8 FsVersion; //flash文件结构
u8 align; //对齐 n * 256
u8 res;
u8 SpecialOptFlag;
u8 pid[16];
};
typedef struct boot_device_info {
struct flash_head *fs_info;
struct sfc_info sfc;
u16 chip_id; //from uboot
u16 trim_value; //from uboot
u8 bt_mac_addr[8];
} BOOT_DEVICE_INFO;
extern BOOT_INFO boot_info;
#endif
+283
View File
@@ -0,0 +1,283 @@
#ifndef SYS_EVENT_H
#define SYS_EVENT_H
#include "generic/typedef.h"
#include "generic/list.h"
#include "generic/rect.h"
#define SYS_ALL_EVENT 0xffff
#define SYS_KEY_EVENT 0x0001
#define SYS_TOUCH_EVENT 0x0002
#define SYS_DEVICE_EVENT 0x0004
#define SYS_NET_EVENT 0x0008
#define SYS_BT_EVENT 0x0010
#define SYS_IR_EVENT 0x0020
#define SYS_PBG_EVENT 0x0040
#define SYS_BT_AI_EVENT 0x0080
#define SYS_AI_EVENT 0x0100
#define SYS_MATRIX_KEY_EVENT 0x0200
#define SYS_TOUCHPAD_EVENT 0x0400
#define SYS_ADT_EVENT 0x0800
#define SYS_AUD_EVENT 0x1000
#define DEVICE_EVENT_FROM_AT_UART (('A' << 24) | ('T' << 16) | ('U' << 8) | '\0')
#define DEVICE_EVENT_FROM_CHARGE (('C' << 24) | ('H' << 16) | ('G' << 8) | '\0')
#define DEVICE_EVENT_FROM_POWER (('P' << 24) | ('O' << 16) | ('W' << 8) | '\0')
#define DEVICE_EVENT_FROM_CI_UART (('C' << 24) | ('I' << 16) | ('U' << 8) | '\0')
#define DEVICE_EVENT_FROM_CI_TWS (('C' << 24) | ('I' << 16) | ('T' << 8) | '\0')
#define DEVICE_EVENT_CHARGE_STORE (('S' << 24) | ('T' << 16) | ('O' << 8) | '\0')
#define DEVICE_EVENT_UMIDIGI_CHARGE_STORE (('Q' << 24) | ('C' << 16) | ('Y' << 8) | '\0')
#define DEVICE_EVENT_TEST_BOX (('T' << 24) | ('S' << 16) | ('B' << 8) | '\0')
#define DEVICE_EVENT_FROM_FM (('F' << 24) | ('M' << 16) | ('\0'<< 8) | '\0')
#define KEY_EVENT_FROM_TWS (('T' << 24) | ('W' << 16) | ('S' << 8) | '\0')
#define SYS_BT_EVENT_FROM_TWS (('T' << 24) | ('W' << 16) | ('S' << 8) | '\0')
#define DEVICE_EVENT_FROM_LINEIN (('A' << 24) | ('U' << 16) | ('X' << 8) | '\0')
#define DRIVER_EVENT_FROM_SD0 (('S' << 24) | ('D' << 16) | ('0' << 8) | '\0')
#define DRIVER_EVENT_FROM_SD1 (('S' << 24) | ('D' << 16) | ('1' << 8) | '\0')
#define DRIVER_EVENT_FROM_SD2 (('S' << 24) | ('D' << 16) | ('2' << 8) | '\0')
#define DEVICE_EVENT_FROM_MUSIC (('M' << 24) | ('S' << 16) | ('C' << 8) | '\0')
#define DEVICE_EVENT_FROM_USB_HOST (('U' << 24) | ('H' << 16) | '\0' | '\0')
#define DEVICE_EVENT_FROM_OTG (('O' << 24) | ('T' << 16) | ('G' << 8) | '\0')
#define DEVICE_EVENT_FROM_PC (('P' << 24) | ('C' << 16) | '\0' | '\0')
#define DEVICE_EVENT_FROM_UAC (('U' << 24) | ('A' << 16) | ('C' << 8) | '\0')
#define DEVICE_EVENT_FROM_ALM (('A' << 24) | ('L' << 16) | ('M' << 8) | '\0')
#define SYS_BT_EVENT_TYPE_CON_STATUS (('C' << 24) | ('O' << 16) | ('N' << 8) | '\0')
#define SYS_BT_EVENT_TYPE_HCI_STATUS (('H' << 24) | ('C' << 16) | ('I' << 8) | '\0')
#define SYS_BT_OTA_EVENT_TYPE_STATUS (('O' << 24) | ('T' << 16) | ('A' << 8) | '\0')
#define SYS_BT_EVENT_BLE_STATUS (('B' << 24) | ('L' << 16) | ('E' << 8) | '\0')
#define SYS_BT_EVENT_FORM_COMMON (('C' << 24) | ('M' << 16) | ('M' << 8) | '\0')
#define DEVICE_EVENT_FROM_KEY (('K' << 24) | ('E' << 16) | ('Y' << 8) | '\0')
#define DEVICE_EVENT_FROM_CUSTOM (('C' << 24) | ('S' << 16) | ('T' << 8) | '\0')
#define SYS_BT_AI_EVENT_TYPE_STATUS (('B' << 24) | ('A' << 16) | ('I' << 8) | '\0')
#define DEVICE_EVENT_FROM_UART_RX_OVERFLOW (('U' << 24) | ('R' << 16) | ('F' << 8) | '\0')
#define DEVICE_EVENT_FROM_UART_RX_OUTTIME (('U' << 24) | ('R' << 16) | ('T' << 8) | '\0')
#define DEVICE_EVENT_FROM_DAC (('D' << 24) | ('A' << 16) | ('C' << 8) | '\0')
#define SYS_EVENT_FROM_CTRLER (('C' << 24) | ('T' << 16) | ('R' << 8) | '\0')
#define SYS_EVENT_FROM_RECORD (('R' << 24) | ('E' << 16) | ('C' << 8) | '\0')
#define DEVICE_EVENT_FROM_ENDLESS_LOOP_DEBUG (('E' << 24) | ('L' << 16) | ('D' << 8) | '\0')
#define DEVICE_EVENT_FROM_EARTCH (('E' << 24) | ('T' << 16) | ('H' << 8) | '\0')
#define DEVICE_EVENT_ONLINE_DATA (('O' << 24) | ('L' << 16) | ('D' << 8) | '\0')
#define SYS_BT_EVENT_FROM_KEY (('K' << 24) | ('E' << 16) | ('Y' << 8) | '\0')
#define SYS_BT_EVENT_FORM_SELF (('S' << 24) | ('E' << 16) | ('F' << 8) | '\0')
#define DEVICE_EVENT_FROM_ANC (('A' << 24) | ('N' << 16) | ('C' << 8) | '\0')
#define SYS_BT_EVENT_FORM_AT (('I' << 24) | ('A' << 16) | ('T' << 8) | '\0')
#define DEVICE_EVENT_FROM_ADAPTER (('A' << 24) | ('D' << 16) | ('A' << 8) | '\0')
#define DEVICE_EVENT_FROM_BOARD_UART (('B' << 24) | ('D' << 16) | ('U' << 8) | '\0')
#define AUDIO_EVENT_TRIM_IMU_START (('A' << 24) | ('T' << 16) | ('S' << 8) | '\0')
#define AUDIO_EVENT_TRIM_IMU_STOP (('A' << 24) | ('T' << 16) | ('E' << 8) | '\0')
enum {
DEVICE_EVENT_IN,
DEVICE_EVENT_OUT,
DEVICE_EVENT_ONLINE,
DEVICE_EVENT_OFFLINE,
DEVICE_EVENT_CHANGE,
};
enum {
TOUCH_EVENT_DOWN,
TOUCH_EVENT_MOVE,
TOUCH_EVENT_HOLD,
TOUCH_EVENT_UP,
TOUCH_EVENT_CLICK,
TOUCH_EVENT_DOUBLE_CLICK,
};
enum {
NET_EVENT_CMD,
NET_EVENT_DATA,
NET_EVENT_CONNECTED,
NET_EVENT_DISCONNECTED,
NET_EVENT_SMP_CFG_TIMEOUT,
};
struct ir_event {
u8 event;
};
struct msg_event {
u8 event;
u8 value;
};
#if EVENT_TOUCH_ENABLE_CONFIG
struct touch_event {
u8 event;
struct position pos;
};
#endif
struct device_event {
u8 event;
int value;
};
struct net_event {
u8 event;
u8 value;
};
struct axis_event {
u8 event;
s16 x;
s16 y;
};
struct codesw_event {
u8 event;
s8 value;
};
struct adt_event {
u8 event;
u8 args[3];
};
struct ai_event {
u32 value;
};
struct ear_event {
u8 value;
};
struct rcsp_event {
u8 event;
u8 args[6];
u8 size;
};
struct chargebox_event {
u8 event;
};
struct matrix_key_event {
u16 args[6]; //最多推6个按键出来,如果需要推多个按键需要自行修改,每个u16 低八位标识row 高八位标识col
u8 *map;
};
struct touchpad_event {
u8 gesture_event; //手势事件
s8 x;
s8 y;
};
struct sys_event {
u16 type;
u8 consumed;
void *arg;
union {
struct axis_event axis;
struct codesw_event codesw;
#if EVENT_TOUCH_ENABLE_CONFIG
struct touch_event touch;
#endif
struct device_event dev;
struct net_event net;
struct msg_event msg;
struct ir_event ir;
struct ai_event ai;
struct ear_event ear;
struct rcsp_event rcsp;
struct chargebox_event chargebox;
struct matrix_key_event matrix_key;
struct touchpad_event touchpad;
struct adt_event adt;
} u;
};
struct static_event_handler {
int event_type;
void (*handler)(struct sys_event *);
};
#define SYS_EVENT_HANDLER(type, fn, pri) \
const struct static_event_handler __event_handler_##fn sec(.sys_event.pri.handler) = { \
.event_type = type, \
.handler = fn, \
}
extern struct static_event_handler sys_event_handler_begin[];
extern struct static_event_handler sys_event_handler_end[];
#define list_for_each_static_event_handler(p) \
for (p = sys_event_handler_begin; p < sys_event_handler_end; p++)
int register_sys_event_handler(int event_type, int from, u8 priority,
void (*handler)(struct sys_event *));
void unregister_sys_event_handler(void (*handler)(struct sys_event *));
/*
* 事件通知函数,系统有事件发生时调用此函数
*/
void sys_event_notify(struct sys_event *e);
void sys_event_clear(struct sys_event *e);
void sys_key_event_disable();
void sys_key_event_enable();
void sys_key_event_filter_disable();
void sys_key_event_filter_enable();
void sys_touch_event_disable();
void sys_touch_event_enable();
/*
*下面四个为系统事件消耗函数,调用此函数后则对应的事件不在分发给其它任务
*
*/
void sys_event_consume(struct sys_event *e);
#if EVENT_TOUCH_ENABLE_CONFIG
void sys_touch_event_consume(struct touch_event *e);
#endif
void sys_device_event_consume(struct device_event *e);
/*
* 下面两个函数为按键和触摸事件接管函数,调用此函数后则对应的事件只发到当前任务
*
* on=true: 开始接管, on=false: 取消接管
*
* once: on = false 时有效,当前这次不接管, 事件可以继续发送到其它任务
*
*/
void sys_key_event_takeover(bool on, bool once);
void sys_touch_event_takeover(bool on, bool once);
#endif
+22
View File
@@ -0,0 +1,22 @@
#ifndef GENERIC_CPU_H
#define GENERIC_CPU_H
#include <asm/cpu.h>
#endif
+40
View File
@@ -0,0 +1,40 @@
#ifndef _ASM_GENERIC_ERRNO_BASE_H
#define _ASM_GENERIC_ERRNO_BASE_H
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Argument list too long */
#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file number */
#define ECHILD 10 /* No child processes */
#define EAGAIN 11 /* Try again */
#define ENOMEM 12 /* Out of memory */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
#define ENOTBLK 15 /* Block device required */
#define EBUSY 16 /* Device or resource busy */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */
#define ENODEV 19 /* No such device */
#define ENOTDIR 20 /* Not a directory */
#define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */
#define ENFILE 23 /* File table overflow */
#define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Not a typewriter */
#define ETXTBSY 26 /* Text file busy */
#define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Illegal seek */
#define EROFS 30 /* Read-only file system */
#define EMLINK 31 /* Too many links */
#define EPIPE 32 /* Broken pipe */
#define EDOM 33 /* Math argument out of domain of func */
#define ERANGE 34 /* Math result not representable */
#define ETIMEDOUT 35 /* Connection timed out */
#endif
+36
View File
@@ -0,0 +1,36 @@
#ifndef GENERIC_INCLUDES_H
#define GENERIC_INCLUDES_H
#include "errno-base.h"
#include "typedef.h"
// #include "ascii.h"
// #include "atomic.h"
#include "ioctl.h"
#include "cpu.h"
// #include "gpio.h"
// #include "irq.h"
#include "jiffies.h"
#include "list.h"
// #include "printf.h"
// #include "rect.h"
// #include "version.h"
// #include "lbuf.h"
// #include "lbuf_lite.h"
// #include "circular_buf.h"
#include "index.h"
// #include "debug_lite.h"
#endif
+22
View File
@@ -0,0 +1,22 @@
#ifndef INDEX_H
#define INDEX_H
#include "typedef.h"
#define TABLE(t) t, ARRAY_SIZE(t)
int index_of_table8(u8 value, const u8 *table, int table_size);
int index_of_table16(u16 value, const u16 *table, int table_size);
int index_of_table32(u32 value, const u32 *table, int table_size);
#endif
+106
View File
@@ -0,0 +1,106 @@
#ifndef _ASM_GENERIC_IOCTL_H
#define _ASM_GENERIC_IOCTL_H
/* ioctl command encoding: 32 bits total, command in lower 16 bits,
* size of the parameter structure in the lower 14 bits of the
* upper 16 bits.
* Encoding the size of the parameter structure in the ioctl request
* is useful for catching programs compiled with old versions
* and to avoid overwriting user space outside the user buffer area.
* The highest 2 bits are reserved for indicating the ``access mode''.
* NOTE: This limits the max parameter size to 16kB -1 !
*/
/*
* The following is for compatibility across the various Linux
* platforms. The generic ioctl numbering scheme doesn't really enforce
* a type field. De facto, however, the top 8 bits of the lower 16
* bits are indeed used as a type field, so we might just as well make
* this explicit here. Please be sure to use the decoding macros
* below from now on.
*/
#define _IOC_NRBITS 8
#define _IOC_TYPEBITS 8
/*
* Let any architecture override either of the following before
* including this file.
*/
#ifndef _IOC_SIZEBITS
# define _IOC_SIZEBITS 14
#endif
#ifndef _IOC_DIRBITS
# define _IOC_DIRBITS 2
#endif
#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
#define _IOC_NRSHIFT 0
#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
/*
* Direction bits, which any architecture can choose to override
* before including this file.
*/
#ifndef _IOC_NONE
# define _IOC_NONE 0U
#endif
#ifndef _IOC_WRITE
# define _IOC_WRITE 1U
#endif
#ifndef _IOC_READ
# define _IOC_READ 2U
#endif
#define _IOC(dir,type,nr,size) \
(((dir) << _IOC_DIRSHIFT) | \
((type) << _IOC_TYPESHIFT) | \
((nr) << _IOC_NRSHIFT) | \
((size) << _IOC_SIZESHIFT))
#ifdef __KERNEL__
/* provoke compile error for invalid uses of size argument */
extern unsigned int __invalid_size_argument_for_IOC;
#define _IOC_TYPECHECK(t) \
((sizeof(t) == sizeof(t[1]) && \
sizeof(t) < (1 << _IOC_SIZEBITS)) ? \
sizeof(t) : __invalid_size_argument_for_IOC)
#else
#define _IOC_TYPECHECK(t) (sizeof(t))
#endif
/* used to create numbers */
#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
#define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
#define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
/* used to decode ioctl numbers.. */
#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
/* ...and for the drivers/sound files... */
#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
#endif /* _ASM_GENERIC_IOCTL_H */
+9
View File
@@ -0,0 +1,9 @@
#ifndef __IRQ_H_
#define __IRQ_H_
#include "asm/irq.h"
#endif
+48
View File
@@ -0,0 +1,48 @@
#ifndef JIFFIES_H
#define JIFFIES_H
/* timer interface */
/* Parameters used to convert the timespec values: */
#define HZ 100L
#define MSEC_PER_SEC 1000L
#define USEC_PER_MSEC 1000L
#define NSEC_PER_USEC 1000L
#define NSEC_PER_MSEC 1000000L
#define USEC_PER_SEC 1000000L
#define NSEC_PER_SEC 1000000000L
#define FSEC_PER_SEC 1000000000000000LL
#ifndef __ASSEMBLY__
extern volatile unsigned long jiffies;
extern unsigned long jiffies_msec();
extern unsigned long jiffies_offset2msec(unsigned long begin_msec, int offset_msec);
extern int jiffies_msec2offset(unsigned long begin_msec, unsigned long end_msec);
extern unsigned long jiffies_usec();
extern unsigned long jiffies_offset2usec(unsigned long base_usec, int offset_usec);
extern int jiffies_usec2offset(unsigned long begin, unsigned long end);
extern unsigned long audio_jiffies_usec(void);
#endif
#define time_after(a,b) ((long)(b) - (long)(a) < 0)
#define time_before(a,b) time_after(b,a)
#define msecs_to_jiffies(msec) ((msec)/10)
#define jiffies_to_msecs(j) ((j)*10)
static inline int jiffies_offset_to_msec(unsigned long begin, unsigned long end)
{
int offset = end - begin;
if (offset < 0 && time_after(end, begin)) {
offset += 0xffffffff;
}
return jiffies_to_msecs(offset);
}
#endif
+291
View File
@@ -0,0 +1,291 @@
#ifndef LIST_H
#define LIST_H
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
*
*/
#ifdef list_offsetof
#undef list_offsetof
#endif
#ifdef container_of
#undef container_of
#endif
#define list_offsetof(type, memb) \
((unsigned long)(&((type *)0)->memb))
#define container_of(ptr, type, memb) \
((type *)((char *)(ptr) - list_offsetof(type, memb)))
struct list_head {
struct list_head *next, *prev;
};
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)
/**
* list_entry - get the struct for this entry
* @ptr: the &struct list_head pointer.
* @type: the type of the struct this is embedded in.
* @member: the name of the list_struct within the struct.
*/
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)
/**
* list_first_entry - get the first element from a list
* @ptr: the list head to take the element from.
* @type: the type of the struct this is embedded in.
* @member: the name of the list_struct within the struct.
*
* Note, that list is expected to be not empty.
*/
/* REF_LIST: spi.c */
#define list_first_entry(ptr, type, member) \
list_entry((ptr)->next, type, member)
/**
* list_for_each - iterate over a list
* @pos: the &struct list_head to use as a loop cursor.
* @head: the head for your list.
*/
#define list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); \
pos = pos->next)
/**
* list_for_each_safe - iterate over a list safe against removal of list entry
* @pos: the &struct list_head to use as a loop counter.
* @n: another &struct list_head to use as temporary storage
* @head: the head for your list.
*/
#define list_for_each_safe(pos, n, head) \
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
/**
* list_for_each_entry - iterate over list of given type
* @pos: the type * to use as a loop cursor.
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define list_for_each_entry(pos, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))
/**
* list_for_each_entry_reverse - iterate backwards over list of given type.
* @pos: the type * to use as a loop cursor.
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define list_for_each_entry_reverse(pos, head, member) \
for (pos = list_entry((head)->prev, typeof(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.prev, typeof(*pos), member))
/**
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
* @pos: the type * to use as a loop cursor.
* @n: another type * to use as temporary storage
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define list_for_each_entry_safe(pos, n, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member), \
n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.next, typeof(*n), member))
#define list_for_each_entry_reverse_safe(pos, n, head, member) \
for (pos = list_entry((head)->prev, typeof(*pos), member), \
n = list_entry(pos->member.prev, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.prev, typeof(*n), member))
/**
* list_empty - tests whether a list is empty
* @head: the list to test.
*/
/* REF_LIST: spi.c */
static inline int list_empty(const struct list_head *head)
{
return head->next == head;
}
/*
* Insert a new entry between two known consecutive entries.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
static inline void __list_add(struct list_head *_new,
struct list_head *prev,
struct list_head *next)
{
next->prev = _new;
_new->next = next;
_new->prev = prev;
prev->next = _new;
}
/**
* list_add_tail - add a new entry
* @new: new entry to be added
* @head: list head to add it before
*
* Insert a new entry before the specified head.
* This is useful for implementing queues.
*/
/* REF_LIST: spi.c */
static inline void list_add_tail(struct list_head *_new, struct list_head *head)
{
__list_add(_new, head->prev, head);
}
static inline void __list_del(struct list_head *prev, struct list_head *next)
{
next->prev = prev;
prev->next = next;
}
static inline void __list_del_entry(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
}
/* REF_LIST: spi.c */
static inline void list_del(struct list_head *entry) //修改过的list_del,这里与list_del_init一样
{
__list_del(entry->prev, entry->next);
entry->next = entry;
entry->prev = entry;
}
/*
* Simple doubly linked list implementation.
*
* Some of the internal functions ("__xxx") are useful when
* manipulating whole lists rather than single entries, as
* sometimes we already know the next/prev entries and we can
* generate better code by using them directly rather than
* using the generic single-entry routines.
*/
static inline void INIT_LIST_HEAD(struct list_head *list)
{
list->next = list;
list->prev = list;
}
static inline void list_del_init(struct list_head *entry)
{
__list_del_entry(entry);
INIT_LIST_HEAD(entry);
}
/**
* list_move_tail - delete from one list and add as another's tail
* @list: the entry to move
* @head: the head that will follow our entry
*/
static inline void list_move_tail(struct list_head *list,
struct list_head *head)
{
__list_del(list->prev, list->next);
list_add_tail(list, head);
}
/**
* list_add - add a new entry
* @new: new entry to be added
* @head: list head to add it after
*
* Insert a new entry after the specified head.
* This is good for implementing stacks.
*/
static inline void list_add(struct list_head *new, struct list_head *head)
{
__list_add(new, head, head->next);
}
static inline int list_is_head(struct list_head *head, struct list_head *member)
{
return head->next == member;
}
#if 0
static inline void __list_splice(const struct list_head *list,
struct list_head *prev,
struct list_head *next)
{
struct list_head *first = list->next;
struct list_head *last = list->prev;
first->prev = prev;
prev->next = first;
last->next = next;
next->prev = last;
}
/**
* list_splice_tail_init - join two lists and reinitialise the emptied list
* @list: the new list to add.
* @head: the place to add it in the first list.
*
* Each of the lists is a queue.
* The list at @list is reinitialised
*/
static inline void list_splice_tail_init(struct list_head *list,
struct list_head *head)
{
if (!list_empty(list)) {
__list_splice(list, head->prev, head);
INIT_LIST_HEAD(list);
}
}
/**
* list_is_singular - tests whether a list has just one entry.
* @head: the list to test.
*/
static inline int list_is_singular(const struct list_head *head)
{
return !list_empty(head) && (head->next == head->prev);
}
/**
* list_splice_tail - join two lists, each list being a queue
* @list: the new list to add.
* @head: the place to add it in the first list.
*/
static inline void list_splice_tail(struct list_head *list,
struct list_head *head)
{
if (!list_empty(list)) {
__list_splice(list, head->prev, head);
}
}
#endif
#define list_for_each_entry_from(pos, head, member) \
for (; &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))
#define list_for_each_entry_from_reverse(pos, head, member) \
for (; &pos->member != (head); \
pos = list_entry(pos->member.prev, typeof(*pos), member))
#endif
+226
View File
@@ -0,0 +1,226 @@
#ifndef RECT_H
#define RECT_H
#include "typedef.h"
#define RECT_LARGE_SIZE_ENABLE 1
#if (defined RECT_LARGE_SIZE_ENABLE && RECT_LARGE_SIZE_ENABLE)
typedef int rect_coord_t;
#else
typedef short rect_coord_t;
#endif
#ifndef AT_UI_RAM
#define AT_UI_RAM //AT(.ui_ram)
#endif
enum hori_align {
HORI_ALIGN_LEFT = 0,
HORI_ALIGN_CENTER,
HORI_ALIGN_RIGHT,
};
enum vert_align {
VERT_ALIGN_TOP = 0,
VERT_ALIGN_CENTER,
VERT_ALIGN_BOTTOM,
};
struct position {
rect_coord_t x;
rect_coord_t y;
};
struct rect {
rect_coord_t left;
rect_coord_t top;
rect_coord_t width;
rect_coord_t height;
};
#define rect_left(r) ((r)->left)
#define rect_top(r) ((r)->top)
#define rect_right(r) ((r)->left + (r)->width)
#define rect_bottom(r) ((r)->top + (r)->height)
//#define rect_height(v) ((v)->bottom - (v)->top)
//#define rect_width(v) ((v)->right - (v)->left)
AT_UI_RAM
static inline bool in_rect(const struct rect *rect, struct position *pos)
{
if (rect->left <= pos->x && rect_right(rect) > pos->x) {
if (rect->top <= pos->y && rect_bottom(rect) > pos->y) {
return true;
}
}
return false;
}
AT_UI_RAM
static inline bool get_rect_cover(const struct rect *a, const struct rect *b, struct rect *c)
{
int right, bottom;
c->top = MAX(a->top, b->top);
c->left = MAX(a->left, b->left);
right = MIN(rect_right(a), rect_right(b));
bottom = MIN(rect_bottom(a), rect_bottom(b));
c->width = right - c->left;
c->height = bottom - c->top;
if ((c->top < bottom) && (c->left < right)) {
return true;
}
return false;
}
AT_UI_RAM
static inline bool get_rect_nocover_l(const struct rect *a, const struct rect *b, struct rect *c)
{
int right, bottom;
c->left = MIN(rect_left(a), rect_left(b));
c->top = MIN(rect_top(a), rect_top(b));
right = MAX(rect_left(a), rect_left(b));
bottom = MAX(rect_bottom(a), rect_bottom(b));
if ((c->top < bottom) && (c->left < right)) {
c->width = right - c->left;
c->height = bottom - c->top;
return true;
}
return false;
}
AT_UI_RAM
static inline bool get_rect_nocover_r(const struct rect *a, const struct rect *b, struct rect *c)
{
int right, bottom;
c->left = MIN(rect_right(a), rect_right(b));
c->top = MIN(rect_top(a), rect_top(b));
right = MAX(rect_right(a), rect_right(b));
bottom = MAX(rect_bottom(a), rect_bottom(b));
if ((c->top < bottom) && (c->left < right)) {
c->width = right - c->left;
c->height = bottom - c->top;
return true;
}
return false;
}
AT_UI_RAM
static inline bool get_rect_nocover_t(const struct rect *a, const struct rect *b, struct rect *c)
{
int right, bottom;
c->left = MIN(rect_left(a), rect_left(b));
c->top = MIN(rect_top(a), rect_top(b));
right = MAX(rect_right(a), rect_right(b));
bottom = MAX(rect_top(a), rect_top(b));
if ((c->top < bottom) && (c->left < right)) {
c->width = right - c->left;
c->height = bottom - c->top;
return true;
}
return false;
}
AT_UI_RAM
static inline bool get_rect_nocover_b(const struct rect *a, const struct rect *b, struct rect *c)
{
int right, bottom;
c->left = MIN(rect_left(a), rect_left(b));
c->top = MIN(rect_bottom(a), rect_bottom(b));
right = MAX(rect_right(a), rect_right(b));
bottom = MAX(rect_bottom(a), rect_bottom(b));
if ((c->top < bottom) && (c->left < right)) {
c->width = right - c->left;
c->height = bottom - c->top;
return true;
}
return false;
}
AT_UI_RAM
static inline bool has_crop_area(struct rect *rect, struct rect *lcd, struct rect *draw)
{
struct rect r;
if (get_rect_cover(rect, lcd, &r) && memcmp(&r, draw, sizeof(struct rect))) {
return true;
}
return false;
}
AT_UI_RAM
static inline bool get_rect_align(struct rect *rect, struct rect *img, int hori_align, int vert_align)
{
if ((img->width <= 0) || (img->height <= 0)) {
return false;
}
if (hori_align == HORI_ALIGN_CENTER) {
img->left = rect->left + (rect->width - img->width) / 2;
} else if (hori_align == HORI_ALIGN_RIGHT) {
img->left = rect->left + (rect->width - img->width);
} else {
img->left = rect->left;
}
if (vert_align == VERT_ALIGN_CENTER) {
img->top = rect->top + (rect->height - img->height) / 2;
} else if (vert_align == VERT_ALIGN_BOTTOM) {
img->top = rect->top + (rect->height - img->height);
} else {
img->top = rect->top;
}
return true;
}
AT_UI_RAM
static inline bool get_rect_crop(struct rect *draw, struct rect *img, struct rect *crop)
{
// 如果图片在绘制区域内,不需要裁剪
if ((rect_left(img) >= rect_left(draw))
&& (rect_top(img) >= rect_top(draw))
&& (rect_right(img) <= rect_right(draw))
&& (rect_bottom(img) <= rect_bottom(draw))) {
return false;
}
// 如果图片和绘制区域没有交集,不需要裁剪
struct rect temp;
if (!get_rect_cover(draw, img, &temp)) {
return false;
}
crop->left = temp.left - img->left;
crop->top = temp.top - img->top;
crop->width = temp.width;
crop->height = temp.height;
return true;
#if 0
struct rect rect;
if (!(get_rect_cover(draw, img, &rect) && memcmp(&rect, img, sizeof(struct rect)))) {
return false;
}
crop->left = rect.left - img->left;
crop->top = rect.top - img->top;
crop->width = rect.width;
crop->height = rect.height;
return true;
#endif
}
#endif
+169
View File
@@ -0,0 +1,169 @@
/*************************************************************
File: typedef.h
Author:Juntham
Discriptor:
数据类型重定义
Version:
Date
*************************************************************/
#ifndef _typedef_h_
#define _typedef_h_
#include "asm/cpu.h"
#if defined(__GNUC__)
///<locate code to x segment ever exist
#define SEC_USED(x) __attribute__((section(#x),used))
///<locate code to x segment optimized by dependency
#define SEC(x) __attribute__((section(#x)))
#define sec(x) __attribute__((section(#x),used))
///<locate data to x segment
#define AT(x) __attribute__((section(#x)))
#define SET(x) __attribute__((x))
#define ALIGNED(x) __attribute__((aligned(x)))
#define _GNU_PACKED_ __attribute__((packed))
#define _NOINLINE_ __attribute__((noinline))
#define _INLINE_ __attribute__((always_inline))
#define _WEAK_ __attribute__((weak))
#define _WEAKREF_ __attribute__((weakref))
#define _NORETURN_ __attribute__((noreturn))
#define _NAKED_ __attribute__((naked))
#else
#define SEC_USED(x)
#define SEC(x)
#define AT(x)
#define SET(x)
#define ALIGNED(x)
#define _GNU_PACKED_
#define _NOINLINE_
#define _INLINE_
#define _WEAK_
#define _WEAKREF_
#define _NORETURN_
#define _NAKED_
#endif
#if CPU_ENDIAN == LITTLE_ENDIAN
//#define ntohl(x) (u32)((x>>24)|((x>>8)&0xff00)|(x<<24)|((x&0xff00)<<8))
//#define ntoh(x) (u16)((x>>8&0x00ff)|x<<8&0xff00)
//#define ntohl(x) (u32)((((u32)(x))>>24) | ((((u32)(x))>>8)&0xff00) | (((u32)(x))<<24) | ((((u32)(x))&0xff00)<<8))
//#define ntoh(x) (u16)((((u32)(x))>>8&0x00ff) | (((u32)(x))<<8&0xff00))
//#define NTOH(x) (x) = ntoh(x)
//#define NTOHL(x) (x) = ntohl(x)
#define LD_WORD(ptr) (u16)(*(u16*)(u8*)(ptr))
#define LD_DWORD(ptr) (u32)(*(u32*)(u8*)(ptr))
#define ST_WORD(ptr,val) *(u16*)(u8*)(ptr)=(u16)(val)
#define ST_DWORD(ptr,val) *(u32*)(u8*)(ptr)=(u32)(val)
#else
#define ntohl(x) (x)
#define ntoh(x) (x)
#define NTOH(x) (x) = ntoh(x)
#define NTOHL(x) (x) = ntohl(x)
#endif
#undef FALSE
#define FALSE 0
#undef TRUE
#define TRUE 1
#define false 0
#define true 1
#ifndef NULL
#define NULL (void *)0
#endif
#define BIT(n) (1UL << (n))
#define BitSET(REG,POS) ((REG) |= (1L << (POS)))
#define BitCLR(REG,POS) ((REG) &= (~(1L<< (POS))))
#define BitXOR(REG,POS) ((REG) ^= (~(1L << (POS))))
#define BitCHK_1(REG,POS) (((REG) & (1L << (POS))) == (1L << (POS)))
#define BitCHK_0(REG,POS) (((REG) & (1L << (POS))) == 0x00)
#define testBit(REG,POS) ((REG) & (1L << (POS)))
#define clrBit(x,y) (x) &= ~(1L << (y))
#define setBit(x,y) (x) |= (1L << (y))
#define readb(addr) *((volatile unsigned char*)(addr))
#define readw(addr) *((volatile unsigned short *)(addr))
#define readl(addr) *((volatile unsigned long*)(addr))
#define writeb(addr, val) *((volatile unsigned char*)(addr)) = (u8)(val)
#define writew(addr, val) *((volatile unsigned short *)(addr)) = (u16)(val)
#define writel(addr, val) *((volatile unsigned long*)(addr)) = (u32)(val)
#define ALIGN_4BYTE(size) ((size+3)&0xfffffffc)
#if CPU_ENDIAN == BIG_ENDIAN
#define __cpu_u16(lo, hi) ((lo)|((hi)<<8))
#elif CPU_ENDIAN == LITTLE_ENDIAN
#define __cpu_u16(lo, hi) ((hi)|((lo)<<8))
#else
#error "undefine cpu eadin"
#endif
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#define SFR(sfr, start, len, dat) \
(sfr = (sfr & ~((~(0xffffffff << (len))) << (start))) | \
(((dat) & (~(0xffffffff << (len)))) << (start)))
// 只适用32位以内数据比较
#define LOOP_OVERTAKE(a, b, n) \
((((a) - (b)) & ((1ULL << (n)) - 1)) < ((1UL << ((n) - 1))))
#include "generic/errno-base.h"
#include "string.h"
#include "strings.h"
#include "system/malloc.h"
#ifdef offsetof
#undef offsetof
#endif
#ifdef container_of
#undef container_of
#endif
#define offsetof(type, memb) \
((unsigned long)(&((type *)0)->memb))
#define container_of(ptr, type, memb) \
((type *)((char *)(ptr) - offsetof(type, memb)))
u32 JBHash(const void *data, int len);
#define AT_UI_RAM //AT(.ui_ram)
#endif
+25
View File
@@ -0,0 +1,25 @@
#ifndef SYS_INCLUDES_H
#define SYS_INCLUDES_H
#include "init.h"
#include "malloc.h"
#include "spinlock.h"
#include "task.h"
#include "timer.h"
#include "fs/fs.h"
#include "sdfile.h"
#include "bank_switch.h"
#include "movable.h"
#include "utils/syscfg_id.h"
#include "generic/includes.h"
#include "device/includes.h"
#include "cpu/includes.h"
#endif
+73
View File
@@ -0,0 +1,73 @@
#ifndef SYS_INIT_H
#define SYS_INIT_H
typedef int (*initcall_t)(void);
#define __initcall(fn) \
const initcall_t __initcall_##fn sec(.initcall) = fn
#define early_initcall(fn) \
const initcall_t __initcall_##fn sec(.early.initcall) = fn
#define late_initcall(fn) \
const initcall_t __initcall_##fn sec(.late.initcall) = fn
#define platform_initcall(fn) \
const initcall_t __initcall_##fn sec(.platform.initcall) = fn
#define module_initcall(fn) \
const initcall_t __initcall_##fn sec(.module.initcall) = fn
#define __do_initcall(prefix) \
do { \
initcall_t *init; \
extern initcall_t prefix##_begin[], prefix##_end[]; \
for (init=prefix##_begin; init<prefix##_end; init++) { \
(*init)(); \
} \
}while(0)
#define do_initcall() __do_initcall(initcall)
#define do_early_initcall() __do_initcall(early_initcall)
#define do_late_initcall() __do_initcall(late_initcall)
#define do_platform_initcall() __do_initcall(platform_initcall)
#define do_module_initcall() __do_initcall(module_initcall)
typedef void (*uninitcall_t)(void);
#define platform_uninitcall(fn) \
const uninitcall_t __uninitcall_##fn sec(.platform.uninitcall) = fn
#define __do_uninitcall(prefix) \
do { \
uninitcall_t *uninit; \
extern uninitcall_t prefix##_begin[], prefix##_end[]; \
for (uninit=prefix##_begin; uninit<prefix##_end; uninit++) { \
(*uninit)(); \
} \
}while(0)
#define do_platform_uninitcall() __do_uninitcall(platform_uninitcall)
#endif
+231
View File
@@ -0,0 +1,231 @@
#ifndef _MEM_HEAP_H_
#define _MEM_HEAP_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "typedef.h"
typedef enum {
P_MEMORY_TOTAL, // ram0
P_MEMORY_UNUSED, // ram0
P_MEMORY_USED, // ram0
P_VLT_MEMORY_TOTAL, // ram1
P_VLT_MEMORY_UNUSED, // ram1
P_VLT_MEMORY_USED, // ram1
P_HEAP_SIZE, // ram0 + ram1
} MEMORY_TYPE;
void memory_init(void);
void *malloc(size_t size);
void *zalloc(size_t size);
void free(void *mem);
void mem_stats(void);
/* ---------------------------------------------------------------------------- */
/**
* @brief :获取物理内存的大小
*
* @param type: 需要获取的内存类型;
*
* @return : 对应类型物理内存大小
*/
/* ---------------------------------------------------------------------------- */
size_t memory_get_size(MEMORY_TYPE type);
/* ---------------------------------------------------------------------------- */
/**
* @brief :申请连续空间的物理内存
*
* @param size: 申请内存大小, 单位byte;
*
* @return : 物理内存地址
*/
/* ---------------------------------------------------------------------------- */
void *phy_malloc(size_t size);
/* ---------------------------------------------------------------------------- */
/**
* @brief :释放连续空间的物理内存
*
* @param :物理内存地址
*/
/* ---------------------------------------------------------------------------- */
void phy_free(void *pv);
/* --------------------------------------------------------------------------*/
/**
* @brief dma_malloc
*
* @param size: 申请内存大小, 单位byte;
*
* @return : dma内存地址
*/
/* ----------------------------------------------------------------------------*/
void *dma_malloc(size_t size);
/* ---------------------------------------------------------------------------- */
/**
* @brief :释放连续空间的dma内存
*
* @param :dma内存地址
*/
/* ---------------------------------------------------------------------------- */
void dma_free(void *pv);
/* --------------------------------------------------------------------------*/
/**
* @brief :检查mem是否物理内存地址
*
* @param mem :检查对象
*
* @return :true - 物理内存,false - 非物理内存
*/
/* ----------------------------------------------------------------------------*/
int memory_in_phy(const void *mem);
/* --------------------------------------------------------------------------*/
/**
* @brief :检查mem是否虚拟内存地址
*
* @param mem :检查对象
*
* @return :true - 虚拟内存,false - 非虚拟内存
*/
/* ----------------------------------------------------------------------------*/
int memory_in_vtl(const void *mem);
/* --------------------------------------------------------------------------*/
/**
* @brief :检查mem是否psram地址
*
* @param mem :检查对象
*
* @return :true - psram地址,false - 非psram地址
*/
/* ----------------------------------------------------------------------------*/
int memory_in_psram(const void *pv);
/* --------------------------------------------------------------------------*/
/**
* @brief :检查mem是否flash cache地址
*
* @param mem :检查对象
*
* @return :true - flash cache地址,false - 非flash cache地址
*/
/* ----------------------------------------------------------------------------*/
int memory_in_flash_cache(const void *pv);
/* --------------------------------------------------------------------------*/
/**
* @brief :检查mem是否flash no cache地址
*
* @param mem :检查对象
*
* @return :true - flash no cache地址,false - 非flash no cache地址
*/
/* ----------------------------------------------------------------------------*/
int memory_in_flash_nocache(const void *pv);
#define memory_in_flash(addr) (memory_in_flash_cache((const void *)(addr)) || memory_in_flash_nocache((const void *)(addr)))
/* --------------------------------------------------------------------------*/
/**
* @brief :获取空闲可掉电内存
*
* @param mem :
*
* @return :
*/
/* ----------------------------------------------------------------------------*/
extern u16 addr_map_2_ram(u32 start);
/* --------------------------------------------------------------------------*/
/**
* @brief :启动内存整理
*
* @param mem :
*
* @return :
*/
/* ----------------------------------------------------------------------------*/
extern u8 memory_defrag(void);
/* --------------------------------------------------------------------------*/
/**
* @brief :获取空闲ram的起始地址
*
* @param mem :
*
* @return :
*/
/* ----------------------------------------------------------------------------*/
extern u32 pmalloc_get_unused_addr();
/* ------------------------------------------------------------------------------------*/
/**
* @brief psram_heap_stats psram使用情况
*/
/* ------------------------------------------------------------------------------------*/
extern void psram_heap_stats(void);
/* ------------------------------------------------------------------------------------*/
/**
* @brief malloc_psram 申请psram
*
* @param size 大小
*
* @return psram地址
*/
/* ------------------------------------------------------------------------------------*/
extern void *malloc_psram(size_t size);
/* ------------------------------------------------------------------------------------*/
/**
* @brief realloc_psram 申请psram
*
* @param pv 原内存地址
* @param size 大小
*
* @return psram地址
*/
/* ------------------------------------------------------------------------------------*/
extern void *realloc_psram(void *pv, size_t size);
/* ------------------------------------------------------------------------------------*/
/**
* @brief free_psram 释放psram
*
* @param pv 地址
*/
/* ------------------------------------------------------------------------------------*/
extern void free_psram(void *pv);
//******************************************************************************************
/*内存整理的锁申请
*/
struct memory_defrag_lock_request {
char *name;
u8(*wait_is_idle)(); //查询能否整理,返回0即本次不整理
void (*request_lock)();//注册内存整理的锁
void (*request_unlock)();
};
#define REGISTER_MEMORY_DEFRAG_REQUEST(target) \
const struct memory_defrag_lock_request target sec(.memory_defrag_lock)
extern const struct memory_defrag_lock_request memory_defrag_lock_begin[];
extern const struct memory_defrag_lock_request memory_defrag_lock_end[];
#define list_for_each_memory_defrag_request(p) \
for (p = memory_defrag_lock_begin; p < memory_defrag_lock_end; p++)
#define list_for_each_reverse_memory_defrag_request(p) \
for (p = memory_defrag_lock_end-1; p >= memory_defrag_lock_begin; p--)
#ifdef __cplusplus
}
#endif
#endif /* _MEM_HEAP_H_ */
+13
View File
@@ -0,0 +1,13 @@
#ifndef CODE_MOVABLE_H
#define CODE_MOVABLE_H
#include "generic/typedef.h"
void code_movable_init();
void code_movable_load(u8 *code_store_addr, u32 code_size, u8 *code_load_addr,
u32 *code_slot_addr, u32 *code_slot_end);
void code_movable_unload(u8 *code_store_addr, u32 *code_slot_addr, u32 *code_slot_end);
#endif
+445
View File
@@ -0,0 +1,445 @@
#ifndef OS_API_H
#define OS_API_H
#ifdef __cplusplus
extern "C"
{
#endif
#include "generic/typedef.h"
#include "os/os_cpu.h"
#include "os/os_error.h"
#include "os/os_type.h"
typedef void *TaskHandle_t;
/* --------------------------------------------------------------------------*/
/**
* @brief reserved
*/
/* ----------------------------------------------------------------------------*/
void os_init(void);
/* --------------------------------------------------------------------------*/
/**
* @brief reserved
*/
/* ----------------------------------------------------------------------------*/
void os_start(void);
/* --------------------------------------------------------------------------*/
/**
* @brief reserved
*/
/* ----------------------------------------------------------------------------*/
void os_init_tick(int);
/* --------------------------------------------------------------------------*/
/**
* @brief 创建任务
*
* @param task 任务回调函数
* @param p_arg 传递给任务回调函数的参数
* @param prio 任务的优先级
* @param stksize 任务的堆栈大小, 单位(u32)
* @param qsize 任务的queue大小,单位(byte)
* @param name 任务名 (名字长度不能超过configMAX_TASK_NAME_LEN字节)
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_task_create(void (*task)(void *p_arg),
void *p_arg,
u8 prio,
u32 stksize,
int qsize,
const char *name);
int os_task_create_affinity_core(void (*task)(void *p_arg),
void *p_arg,
u8 prio,
u32 stksize,
int qsize,
const char *name,
u8 core);
/* --------------------------------------------------------------------------*/
/**
* @brief 获取当前任务名
*
* @return 当前任务名
*/
/* ----------------------------------------------------------------------------*/
const char *os_current_task();
/* --------------------------------------------------------------------------*/
/**
* @brief 删除任务
*
* @param name 任务名
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_task_del_req(const char *name);
/* --------------------------------------------------------------------------*/
/**
* @brief 响应任务删除请求,标记资源已经释放,可以删除当前任
*
* @param name 任务名,任务自己可以用OS_TASK_SELF
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_task_del_res(const char *name);
/* --------------------------------------------------------------------------*/
/**
* @brief 删除任务
*
* @param name 任务名
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_task_del(const char *name);
/* --------------------------------------------------------------------------*/
/**
* @brief 延时。中断函数或者关闭系统总中断的情况下不能调用此函数
*
* @param time_tick 延时时间
*/
/* ----------------------------------------------------------------------------*/
void os_time_dly(int time_tick);
/* --------------------------------------------------------------------------*/
/**
* @brief 发送Q_USER类型taskq
*
* @param name 任务名
* @param argc 后面传入的参数的个数。发送的最大参数个数限制为8个int类型
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_post(const char *name, int argc, ...);
/* --------------------------------------------------------------------------*/
/**
* @brief 非阻塞方式查询taskq
*
* @param argc 最大可获取的queue长度,单位(int)
* @param argv 存放queue的buf
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_accept(int argc, int *argv);
/* --------------------------------------------------------------------------*/
/**
* @brief 阻塞方式获取taskq
*
* @param fmt 保留,传NULL
* @param argv 存放queue的buf
* @param argc 最大可获取的queue长度,单位(int)
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_pend(const char *fmt, int *argv, int argc);
// int os_task_pend(const char *fmt, int *argv, int argc);
// int __os_taskq_pend(int *argv, int argc, int tick);
/* --------------------------------------------------------------------------*/
/**
* @brief 超时方式获取taskq
*
* @param fmt 保留,传NULL
* @param argv 存放queue的buf
* @param argc 最大可获取的queue长度,单位(int)
* @param tick 超时时间, 单位: tick(10ms)
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_pend_timeout(const char *fmt, int *argv, int argc, int tick);
/* --------------------------------------------------------------------------*/
/**
* @brief 发送指定类型的taskq
*
* @param name 任务名
* @param type queue类型
* @param argc 后面传入的参数的个数
* @param argv
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_post_type(const char *name, int type, int argc, int *argv);
/* --------------------------------------------------------------------------*/
/**
* @brief 发送Q_MSG类型的taskq
*
* @param name 任务名
* @param argc 后面参数的个数
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_post_msg(const char *name, int argc, ...);
/* --------------------------------------------------------------------------*/
/**
* @brief 发送Q_EVENT类型的taskq
*
* @param name 任务名
* @param argc 后面参数的个数
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_post_event(const char *name, int argc, ...);
/* --------------------------------------------------------------------------*/
/**
* @brief 删除指定类型的taskq
*
* @param name 任务名
* @param type taskq的类型
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_del_type(const char *name, int type);
/* --------------------------------------------------------------------------*/
/**
* @brief 清除所有taskq
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_flush(void);
/* --------------------------------------------------------------------------*/
/**
* @brief 创建信号量
*
* @param sem 信号量
* @param int 初始计数值
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_sem_create(OS_SEM *, int);
/* --------------------------------------------------------------------------*/
/**
* @brief 非阻塞方式查询信号量
*
* @param sem 信号量
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_sem_accept(OS_SEM *);
/* --------------------------------------------------------------------------*/
/**
* @brief 阻塞方式获取信号量
*
* @param sem 信号量
* @param timeout 等待时长,0表示一直等待
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_sem_pend(OS_SEM *, int timeout);
/* --------------------------------------------------------------------------*/
/**
* @brief 发送信号量
*
* @param sem 信号量
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_sem_post(OS_SEM *);
/* --------------------------------------------------------------------------*/
/**
* @brief 信号量删除
*
* @param sem 信号量
* @param block 保留
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_sem_del(OS_SEM *, int block);
/* --------------------------------------------------------------------------*/
/**
* @brief 信号量设置
*
* @param sem 信号量
* @param cnt 计数值
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_sem_set(OS_SEM *, u16 cnt);
/* --------------------------------------------------------------------------*/
/**
* @brief 信号量类型是否queueQUEUE_TYPE_COUNTING_SEMAPHORE
*
* @param true:信号量匹配, fail:信号量不匹配
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_sem_valid(OS_SEM *);
/* --------------------------------------------------------------------------*/
/**
* @brief 判断信号量是否可用
*
* @param sem 信号量
*
* @reutrn 可用数量
*/
/* ----------------------------------------------------------------------------*/
int os_sem_query(OS_SEM *);
/* --------------------------------------------------------------------------*/
/**
* @brief 创建互斥量
*
* @param mutex 互斥量
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_mutex_create(OS_MUTEX *);
/* --------------------------------------------------------------------------*/
/**
* @brief 非阻塞方式查询互斥量
*
* @param mutex:互斥量
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_mutex_accept(OS_MUTEX *);
/* --------------------------------------------------------------------------*/
/**
* @brief 阻塞方式查询互斥量
*
* @param mutex 互斥量
* @param timeout 等待时间,0表示一直等待
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_mutex_pend(OS_MUTEX *, int timeout);
/* --------------------------------------------------------------------------*/
/**
* @brief 发送斥量
*
* @param mutex 互斥量
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_mutex_post(OS_MUTEX *);
/* --------------------------------------------------------------------------*/
/**
* @brief 删除斥量
*
* @param mutex 互斥量
* @param block 保留
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_mutex_del(OS_MUTEX *, int block);
/* --------------------------------------------------------------------------*/
/**
* @brief 互斥量类型是否queueQUEUE_TYPE_MUTEX
*
* @param true:互斥量匹配, fail:互斥量不匹配
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_mutex_valid(OS_MUTEX *);
/*struct os_msg *os_message_create(int size);
int os_message_receive(struct os_msg **msg, int block_time);
int os_message_send(const char *task_name, struct os_msg *msg, int msgflg);
int os_message_delete(struct os_msg *msg);*/
int os_q_create(OS_QUEUE *pevent, /*void **start, */QS size);
int os_q_del(OS_QUEUE *pevent, u8 opt);
int os_q_flush(OS_QUEUE *pevent);
int os_q_pend(OS_QUEUE *pevent, int timeout, void *msg);
int os_q_post(OS_QUEUE *pevent, void *msg);
int os_q_query(OS_QUEUE *pevent);
int os_q_valid(OS_QUEUE *pevent);
int task_queue_post_event(const char *name, void *data, int len);
void *os_task_get_handle(const char *name);
void os_suspend_other_core(void);
void os_resume_other_core(void);
void os_system_info_output(void);
u8 os_idle_percentage(void);
#ifdef __cplusplus
}
#endif
#endif
+46
View File
@@ -0,0 +1,46 @@
#ifndef _OS_COMPAT_H_
#define _OS_COMPAT_H_
#include "os/os_api.h"
enum kill_mode {
KILL_WAIT,
KILL_REQ,
KILL_FORCE,
};
int sem_init(int *sem, int cnt);
int sem_pend(int *sem, unsigned int timeout);
int sem_post(int *sem);
int sem_set(int *sem, int init_val);
int sem_del(int *sem);
int thread_fork_init(void);
int thread_fork(const char *thread_name, int prio, int stk_size, u32 q_size, int *pid, void (*func)(void *), void *parm);
void thread_kill(volatile int *pid, enum kill_mode mode);
int thread_kill_req(void);
u16 thread_put_msg_fifo(u32 msg, u8 type, int *pid);
u16 thread_put_msg_lifo(u32 msg, u8 type, int *pid);
int *get_cur_thread_pid(void);
int thread_rpc(bool wait_finish, void (*rpc_finish_cb)(void *priv), int prio, int stk_size, void (*thread_func)(void *priv), void *priv);
void udelay(unsigned int t);
void usleep(unsigned int t);
void mdelay(unsigned int ms);
void msleep(unsigned int ms);
int pthread_mutexattr_init(int *attr);
int pthread_mutex_init(int *mutex, const int *attr);
int pthread_mutex_lock(int *mutex);
int pthread_mutex_unlock(int *mutex);
int pthread_mutex_destroy(int *mutex);
#endif //_OS_COMPAT_H_
+114
View File
@@ -0,0 +1,114 @@
/***********************************Jieli tech************************************************
File : os_cpu.h
By : Juntham
date : 2014-07-03 09:06
********************************************************************************************/
#ifndef _OS_CPU_H
#define _OS_CPU_H
#include "asm/cpu.h"
#include "jiffies.h"
#ifndef __ASSEMBLY__
typedef unsigned short QS;
typedef unsigned int OS_STK; /* Each stack entry is 32-bit wide*/
typedef unsigned int OS_CPU_SR; /* Unsigned 32 bit quantity */
typedef unsigned int OS_CPU_DATA; /* Unsigned 32 bit quantity */
#endif
#define OS_CPU_EXT extern
#define OS_CPU_CORE CPU_CORE_NUM
#define OS_CPU_ID current_cpu_id()
#define OS_STK_GROWTH 1 /* Stack grows from HIGH to LOW memory*/
#define OS_CPU_VIRTUAL_MEM 1
#ifndef OS_CORE_AFFINITY_ENABLE
#define OS_CORE_AFFINITY_ENABLE 0
#endif
#define OS_TASK_CLR(a) CPU_TASK_CLR(a)
#define OS_TASK_SW(a) CPU_TASK_SW(a) /* 任务级任务切换函数*/
#define OS_INT_NESTING CPU_INT_NESTING
#define CPU_SR_ALLOC()
#define OS_SR_ALLOC()
#define OS_ENTER_CRITICAL() \
CPU_CRITICAL_ENTER(); \
#define OS_EXIT_CRITICAL() \
CPU_CRITICAL_EXIT()
#ifndef __ASSEMBLY__
/*#include "system/spinlock.h"
extern spinlock_t os_lock;
#define OS_ENTER_CRITICAL() \
spin_lock(&os_lock)
#define OS_EXIT_CRITICAL() \
spin_unlock(&os_lock)*/
void OSCtxSw(void);
extern void EnableOtherCpu(void) ;
void OSInitTick(u32 hz);
void InstallOSISR(void);
void os_task_dead(const char *task_name);
//=======================================================//
// 系统进临界区多核同步类型 //
//=======================================================//
enum CPU_SUSPEND_TYPE {
CPU_SUSPEND_TYPE_NONE = 0,
CPU_SUSPEND_TYPE_SFC = 0x55, //操作Flash
CPU_SUSPEND_TYPE_PDOWN, //系统进低功耗Pdown
CPU_SUSPEND_TYPE_POFF, //系统进低功耗Pdown
CPU_SUSPEND_TYPE_SOFF,
CPU_SUSPEND_TYPE_UPDATE,
};
/* ---------------------------------------------------------------------------- */
/**
* @brief 系统进入临界区用于多核同步
*/
/* ---------------------------------------------------------------------------- */
void cpu_suspend_other_core(enum CPU_SUSPEND_TYPE type);
/* ---------------------------------------------------------------------------- */
/**
* @brief 系统退出临界区用于多核同步
*/
/* ---------------------------------------------------------------------------- */
void cpu_resume_other_core(enum CPU_SUSPEND_TYPE type);
#endif
/*
*********************************************************************************************************
* DATA TYPES
* (Compiler Specific)
*********************************************************************************************************
*/
#define OS_CRITICAL_METHOD 3
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
//#define CPU_SR_ALLOC() OS_CPU_SR cpu_sr
#endif
#endif /*_OS_CPU_H */
+79
View File
@@ -0,0 +1,79 @@
#ifndef __OS_ERROR_H__
#define __OS_ERROR_H__
#define OS_ERR_NONE 0
enum {
OS_NO_ERR = 0,
OS_TRUE,
OS_ERR_EVENT_TYPE,
OS_ERR_PEND_ISR,
OS_ERR_POST_NULL_PTR,
OS_ERR_PEVENT_NULL,
OS_ERR_POST_ISR,
OS_ERR_QUERY_ISR,
OS_ERR_INVALID_OPT,
OS_ERR_TASK_WAITING,
OS_ERR_PDATA_NULL,
OS_TIMEOUT,
OS_TIMER,
OS_TASKQ,
OS_TASK_NOT_EXIST,
OS_ERR_EVENT_NAME_TOO_LONG,
OS_ERR_FLAG_NAME_TOO_LONG,
OS_ERR_TASK_NAME_TOO_LONG,
OS_ERR_PNAME_NULL,
OS_ERR_TASK_CREATE_ISR,
OS_MBOX_FULL,
OS_Q_FULL,
OS_Q_EMPTY,
OS_Q_ERR,
OS_ERR_NO_QBUF,
OS_PRIO_EXIST,
OS_PRIO_ERR,
OS_PRIO_INVALID,
OS_SEM_OVF,
OS_TASK_DEL_ERR,
OS_TASK_DEL_IDLE,
OS_TASK_DEL_ISR,
OS_NO_MORE_TCB,
OS_TIME_NOT_DLY,
OS_TIME_INVALID_MINUTES,
OS_TIME_INVALID_SECONDS,
OS_TIME_INVALID_MILLI,
OS_TIME_ZERO_DLY,
OS_TASK_SUSPEND_PRIO,
OS_TASK_SUSPEND_IDLE,
OS_TASK_RESUME_PRIO,
OS_TASK_NOT_SUSPENDED,
OS_MEM_INVALID_PART,
OS_MEM_INVALID_BLKS,
OS_MEM_INVALID_SIZE,
OS_MEM_NO_FREE_BLKS,
OS_MEM_FULL,
OS_MEM_INVALID_PBLK,
OS_MEM_INVALID_PMEM,
OS_MEM_INVALID_PDATA,
OS_MEM_INVALID_ADDR,
OS_MEM_NAME_TOO_LONG,
OS_ERR_MEM_NO_MEM,
OS_ERR_NOT_MUTEX_OWNER,
OS_TASK_OPT_ERR,
OS_ERR_DEL_ISR,
OS_ERR_CREATE_ISR,
OS_FLAG_INVALID_PGRP,
OS_FLAG_ERR_WAIT_TYPE,
OS_FLAG_ERR_NOT_RDY,
OS_FLAG_INVALID_OPT,
OS_FLAG_GRP_DEPLETED,
OS_ERR_PIP_LOWER,
OS_ERR_MSG_POOL_EMPTY,
OS_ERR_MSG_POOL_NULL_PTR,
OS_ERR_MSG_POOL_FULL,
};
#endif
+73
View File
@@ -0,0 +1,73 @@
#ifndef __OS_TYPE_H
#define __OS_TYPE_H
#define OS_TICKS_PER_SEC 100
#define Q_MSG 0x100000
#define Q_EVENT 0x200000
#define Q_CALLBACK 0x300000
#define Q_USER 0x400000
#define OS_DEL_NO_PEND 0u
#define OS_DEL_ALWAYS 1u
#define OS_TASK_DEL_REQ 0x01u
#define OS_TASK_DEL_RES 0x02u
#define OS_TASK_DEL_OK 0x03u
#define OS_TASK_SELF (char *)0x1
#define OS_TASK_FATHER (char *)0x2
#ifdef CONFIG_UCOS_ENABLE
typedef struct {
unsigned char OSEventType;
int aa;
void *bb;
unsigned char value;
unsigned char prio;
unsigned short cc;
} OS_SEM, OS_MUTEX, OS_QUEUE;
#elif defined CONFIG_FREE_RTOS_ENABLE
struct StaticMiniListItem {
uint32_t tick;
void *pvDummy2[2];
};
struct StaticList {
unsigned long uxDummy1;
void *pvDummy2;
struct StaticMiniListItem xDummy3;
};
typedef struct {
void *pvDummy1[3];
union {
void *pvDummy2;
unsigned long uxDummy2;
} u;
struct StaticList xDummy3[2];
unsigned long uxDummy4[3];
uint8_t ucDummy5[2];
uint8_t ucDummy6;
unsigned long uxDummy8;
uint8_t ucDummy9;
} OS_SEM, OS_MUTEX, OS_QUEUE;
#else
#error "no_os_defined"
#endif
#endif
@@ -0,0 +1,340 @@
SECTIONS
{
.data : ALIGN(4)
{
. = ALIGN(4);
system_data_start = .;
_video_subdev_begin = .;
PROVIDE(video_subdev_begin = .);
KEEP(*(.video_subdev.0))
KEEP(*(.video_subdev.1))
KEEP(*(.video_subdev.2))
KEEP(*(.video_subdev.3))
KEEP(*(.video_subdev.4))
KEEP(*(.video_subdev.5))
_video_subdev_end = .;
PROVIDE(video_subdev_end = .);
_audio_subdev_begin = .;
PROVIDE(audio_subdev_begin = .);
KEEP(*(.audio_subdev.0))
KEEP(*(.audio_subdev.1))
KEEP(*(.audio_subdev.2))
KEEP(*(.audio_subdev.3))
_audio_subdev_end = .;
PROVIDE(audio_subdev_end = .);
_iic_device_begin = .;
PROVIDE(iic_device_begin = .);
KEEP(*(.iic))
_iic_device_end = .;
PROVIDE(iic_device_end = .);
_avin_spi_device_begin = .;
PROVIDE(avin_spi_device_begin = .);
KEEP(*(.sw_spi))
_avin_spi_device_end = .;
PROVIDE(avin_spi_device_end = .);
_video_dev_begin = .;
PROVIDE(video_dev_begin = .);
KEEP(*(.video_device))
_video_dev_end = .;
PROVIDE(video_dev_end = .);
_key_driver_ops_begin = .;
PROVIDE(key_driver_ops_begin = .);
KEEP(*(.key_driver_ops))
_key_driver_ops_end = .;
PROVIDE(key_driver_ops_end = .);
_touch_driver_begin = .;
PROVIDE(touch_driver_begin = .);
KEEP(*(.touch_driver))
_touch_driver_end = .;
PROVIDE(touch_driver_end = .);
_static_hi_timer_begin = .;
PROVIDE(static_hi_timer_begin = .);
KEEP(*(.hi_timer))
_static_hi_timer_end = .;
PROVIDE(static_hi_timer_end = .);
_sys_cpu_timer_begin = .;
PROVIDE(sys_cpu_timer_begin = .);
KEEP(*(.sys_cpu_timer))
_sys_cpu_timer_end = .;
PROVIDE(sys_cpu_timer_end = .);
_sys_config_begin = .;
PROVIDE(sys_config_begin = .);
KEEP(*(.sys_cfg))
_sys_config_end = .;
PROVIDE(sys_config_end = .);
_sys_fat_begin = .;
PROVIDE(sys_fat_begin = .);
KEEP(*(.fs_fat))
_sys_fat_end = .;
PROVIDE(sys_fat_end = .);
_app_begin = .;
PROVIDE(app_begin = .);
KEEP(*(.app))
_app_end = .;
PROVIDE(app_end = .);
*(.crypto_ecdh_data)
*(.crypto_data)
*(.mem_data)
*(.os_port_data)
*(.os_str)
*(.os_data)
*(.uECC_data)
*(.ECDH_sample_data)
. = ALIGN(4);
__movable_slot_start = .;
*(movable.slot.*);
__movable_slot_end = .;
. = ALIGN(32);
system_data_end = .;
*(.data*)
*(.*.data)
. = ALIGN(32);
} > ram0
.bss (NOLOAD) :ALIGN(4)
{
system_bss_start = .;
. = ALIGN(4);
*(.os_bss)
*(.mem_heap)
*(.mem_bss)
*(.os_port_bss)
*(.uECC_bss)
*(.ECDH_sample_bss)
. = ALIGN(4);
system_bss_end = .;
*(.*.bss)
*(.bss.*)
*(.*.data.bss)
. = ALIGN(4);
*(.*.data.bss.nv)
. = ALIGN(32);
} > ram0
.text : ALIGN(4)
{
. = ALIGN(4);
system_text_start = .;
_device_node_begin = .;
PROVIDE(device_node_begin = .);
KEEP(*(.device))
_device_node_end = .;
PROVIDE(device_node_end = .);
config_target_begin = .;
PROVIDE(config_target_begin = .);
KEEP(*(.config_target))
config_target_end = .;
PROVIDE(config_target_end = .);
system_code_begin = .;
KEEP(*(.system.*.text))
system_code_end = .;
. = ALIGN(4);
system_code_size = system_code_end - system_code_begin;
_lib_version_begin = .;
PROVIDE(lib_version_begin = .);
KEEP(*(.lib_version))
_lib_version_end = .;
PROVIDE(lib_version_end = .);
_initcall_begin = .;
PROVIDE(initcall_begin = .);
KEEP(*(.initcall))
_initcall_end = .;
PROVIDE(initcall_end = .);
_early_initcall_begin = .;
PROVIDE(early_initcall_begin = .);
KEEP(*(.early.initcall))
_early_initcall_end = .;
PROVIDE(early_initcall_end = .);
_late_initcall_begin = .;
PROVIDE(late_initcall_begin = .);
KEEP(*(.late.initcall))
_late_initcall_end = .;
PROVIDE(late_initcall_end = .);
_platform_initcall_begin = .;
PROVIDE(platform_initcall_begin = .);
KEEP(*(.platform.initcall))
_platform_initcall_end = .;
PROVIDE(platform_initcall_end = .);
_module_initcall_begin = .;
PROVIDE(module_initcall_begin = .);
KEEP(*(.module.initcall))
_module_initcall_end = .;
PROVIDE(module_initcall_end = .);
platform_uninitcall_begin = .;
KEEP(*(.platform.uninitcall))
platform_uninitcall_end = .;
_sys_event_handler_begin = .;
PROVIDE(sys_event_handler_begin = .);
KEEP(*(.sys_event.4.handler))
KEEP(*(.sys_event.3.handler))
KEEP(*(.sys_event.2.handler))
KEEP(*(.sys_event.1.handler))
KEEP(*(.sys_event.0.handler))
_sys_event_handler_end = .;
PROVIDE(sys_event_handler_end = .);
_syscfg_arg_begin = .;
PROVIDE(syscfg_arg_begin = .);
KEEP(*(.syscfg.arg))
_syscfg_arg_end = .;
PROVIDE(syscfg_arg_end = .);
_syscfg_handler_begin = .;
PROVIDE(syscfg_handler_begin = .);
KEEP(*(.syscfg.handler))
_syscfg_handler_end = .;
PROVIDE(syscfg_handler_end = .);
_syscfg_ops_begin = .;
PROVIDE(syscfg_ops_begin = .);
KEEP(*(.syscfg.2.ops))
KEEP(*(.syscfg.1.ops))
KEEP(*(.syscfg.0.ops))
_syscfg_ops_end = .;
PROVIDE(syscfg_ops_end = .);
_server_info_begin = .;
PROVIDE(server_info_begin = .);
KEEP(*(.server_info))
_server_info_end = .;
PROVIDE(server_info_end = .);
_bus_device_begin = .;
PROVIDE(bus_device_begin = .);
KEEP(*(.bus_device))
_bus_device_end = .;
PROVIDE(bus_device_end = .);
_sys_power_hal_ops_begin = .;
PROVIDE(sys_power_hal_ops_begin = .);
KEEP(*(.sys_power_hal_ops))
_sys_power_hal_ops_end = .;
PROVIDE(sys_power_hal_ops_end = .);
memory_defrag_lock_begin = .;
KEEP(*(.memory_defrag_lock))
memory_defrag_lock_end = .;
crypto_begin = .;
*(.crypto_ecdh_code)
*(.crypto_ecdh_const)
*(.crypto_bigint_code)
*(.crypto_bigint_const)
*(.crypto_code)
*(.crypto_const)
*(.ECDH_sample_code)
*(.ECDH_sample_const)
*(.uECC_code)
*(.uECC_const)
*(.hmac_code)
*(.hmac_const)
*(.hash_sample_code)
*(.hash_sample_const)
*(.aes_cmac_sample_code)
*(.aes_cmac_sample_const)
crypto_end = .;
crypto_size = . - crypto_begin;
*(.mem_code)
*(.mem_const)
*(.os_port_code)
*(.os_port_const)
*(.os_const)
. = ALIGN(4);
*(.os_code)
. = ALIGN(4);
*(.math_fast_funtion_code)
__movable_function_start = .;
*(movable.text.*);
*(movable.stub.*);
*(movable.region.*);
/* *(.movable.code*) */
. = ALIGN(4);
__movable_function_end = .;
__movable_function_size = __movable_function_end - __movable_function_start;
system_text_end = .;
system_code_total_size = system_text_end - system_text_start;
*(.*.text)
*(.*.text.const)
*(.*.text.const.cache.L2)
*(.*.text.cache.L2*)
*(.*.text.cache.L1*)
. = ALIGN(4);
*(.LOG_TAG_CONST*)
*(.rodata*)
#if defined CONFIG_CXX_SUPPORT
. = ALIGN(4);
_ctors_begin = .;
PROVIDE(ctors_begin = .);
*(.ctors*)
_ctors_end = .;
PROVIDE(ctors_end = .);
#endif
. = ALIGN(32);
} > code0
.data_code ALIGN(32):
{
. = ALIGN(32);
} > ram0
}
+29
View File
@@ -0,0 +1,29 @@
#ifndef SYS_SPINLOCK_H
#define SYS_SPINLOCK_H
#include "typedef.h"
#include "cpu.h"
#include "irq.h"
struct __spinlock {
volatile u8 rwlock;
volatile u8 lock_cnt[CPU_CORE_NUM];
};
typedef struct __spinlock spinlock_t;
#define DEFINE_SPINLOCK(x) \
spinlock_t x = { .rwlock = 0 }
void spin_lock_init(spinlock_t *lock);
void spin_lock(spinlock_t *lock);
void spin_unlock(spinlock_t *lock);
#endif
+20
View File
@@ -0,0 +1,20 @@
#ifndef SYS_APP_MSG_H
#define SYS_APP_MSG_H
//app自定义消息发送接口
int app_task_put_usr_msg(int msg, int arg_num, ...);
//app消息获取接口(block参数为0表示内部pend,1直接返回)
void app_task_get_msg(int *msg, int msg_size, int block);
//app按键消息发送接口
int app_task_put_key_msg(int msg, int value);
//app清理按键消息接口
void app_task_clear_key_msg();
#endif
+95
View File
@@ -0,0 +1,95 @@
#ifndef TASK_PRIORITY_H
#define TASK_PRIORITY_H
#include "os/os_api.h"
struct task_info {
const char *name;
u8 prio;
u8 core;
u16 stack_size;
u16 qsize;
};
typedef OS_SEM sem_t;
typedef OS_MUTEX mutex_t;
/* --------------------------------------------------------------------------*/
/**
* @brief 创建任务
*
* @param task 服务函数
* @param p 服务函数传参
* @param name 任务名
*
* @return 0:成功,其他:错误码
*/
/* ----------------------------------------------------------------------------*/
int task_create(void (*task)(void *p), void *p, const char *name);
int __task_create(void (*task)(void *p), void *p, const char *name, u8 prio);
/* --------------------------------------------------------------------------*/
/**
* @brief 删除任务
*
* @param name 任务名
*
* @return 0:成功,其他:错误码
*/
/* ----------------------------------------------------------------------------*/
int task_kill(const char *name);
int task_delete(const char *name, OS_SEM *sem);
void task_info_init(void);
void task_info_add(TaskHandle_t task);
void task_info_del(const char *name);
void task_info_update_runtime(TaskHandle_t old_task, TaskHandle_t new_task);
void task_info_reset(void);
void task_info_output(int size);
void task_info_output_debug(void);
u32 task_info_idle_percentage(void);
void *task_info_list_head_get(void);
int os_task_priority(const char *name);
int os_cpu_usage(const char *task_name, int *usage);
int os_hw_sem_pend(OS_SEM *sem, int timeout, const char *hw_name);
int os_hw_sem_post(OS_SEM *sem, const char *hw_name);
int os_get_hw_usage(const char *hw_name);
int task_info_get_pc_addr(const char *task_name, u32 *pc_addr);
#define SIMPLE_TASK_INFO_NAME_MAX_LEN 16
typedef struct __simple_task_info {
char task_name[SIMPLE_TASK_INFO_NAME_MAX_LEN]; // 任务名
u32 stack_used; // 已使用栈大小
u32 stack_max; // 最大栈
u32 task_usage; // CPU占用
} SIMPLE_TASK_INFO;
/* --------------------------------------------------------------------------*/
/**
* @brief 获取记录的任务个数
*
* @result
*/
/* ----------------------------------------------------------------------------*/
u32 get_task_info_list_num(void);
/* --------------------------------------------------------------------------*/
/**
* @brief 获取简易的任务信息
*
* @param task_info_list
* @param task_info_list_len
*
* @result task_info_list的有效长度,小于等于task_info_list_len
*/
/* ----------------------------------------------------------------------------*/
u16 simple_task_info_list_get(SIMPLE_TASK_INFO *task_info_list, u32 task_info_list_len);
#endif
+301
View File
@@ -0,0 +1,301 @@
#ifndef SYS_TIMER_H
#define SYS_TIMER_H
#include "typedef.h"
#include "generic/list.h"
struct static_sys_timer {
void (*func)(void *priv);
void *priv;
u32 msec;
u32 jiffies;
};
struct sys_usec_timer {
void (*func)(void *priv);
void *priv;
const char *owner;
struct sys_cpu_timer *timer;
};
#define SYS_HI_TIMER_ADD(_func, _priv, _msec) \
static struct static_sys_timer hi_timer sec(.hi_timer) = { \
.func = _func, \
.priv = _priv, \
.msec = _msec, \
}
extern struct static_sys_timer static_hi_timer_begin[];
extern struct static_sys_timer static_hi_timer_end[];
#define list_for_each_static_hi_timer(p) \
for (p=static_hi_timer_begin; p<static_hi_timer_end; p++)
struct sys_cpu_timer {
u8 busy;
void *priv;
void (*set)(u32 usec);
void (*unset)();
};
#define DEFINE_SYS_CPU_TIMER(t) \
struct sys_cpu_timer t sec(.sys_cpu_timer);
#define REGISTER_SYS_CPU_TIMER(t) \
struct sys_cpu_timer t sec(.sys_cpu_timer)
extern struct sys_cpu_timer sys_cpu_timer_begin[];
extern struct sys_cpu_timer sys_cpu_timer_end[];
#define list_for_each_cpu_usec_timer(p) \
for (p = sys_cpu_timer_begin; p < sys_cpu_timer_end; p++)
/*
* System Timer
*/
/**
* @brief 添加ms级系统非timeout类型定时任务。
*
* @param [in] priv 定时任务处理函数的输入参数
* @param [in] func 定时任务处理函数
* @param [in] msec 定时时间
*
* @return 定时器分配的ID
*
* @note
* 1、系统会进入低功耗,节拍不会丢失,定时结束会唤醒系统;
* 2、sys_timer由systimer线程提供时基,属于同步接口,
* 也就是说在哪个线程add的sys_timer,当定时时基到了,
* systimer线程会发事件通知对应的add线程响应(回调函数被执行);
* 3、与sys_timer_del成对使用。
*/
u16 sys_timer_add(void *priv, void (*func)(void *priv), u32 msec);
/**
* @brief 删除ms级非timeout类型定时任务。
*
* @param [in] id 要删除的任务ID
*
* @note
* 1、与sys_timer_add成对使用。
*/
void sys_timer_del(u16);
/**
* @brief 添加ms级系统timeout类型定时任务。
*
* @param [in] priv 定时任务处理函数的输入参数
* @param [in] func 定时任务处理函数
* @param [in] msec 定时时间
*
* @return 定时器分配的id号
*
* @note
* 1、系统会进入低功耗,节拍不会丢失,定时结束会唤醒系统;
* 2、sys_timeout由systimer线程提供时基,属于同步接口,
* 也就是说在哪个线程add的sys_timeout,定时时基到了
* systimer线程会发事件通知对应的add线程响应(回调函数被执行);
* 3、timeout回调只会被执行一次;
* 4、与sys_timerout_del成对使用。
*/
u16 sys_timeout_add(void *priv, void (*func)(void *priv), u32 msec);
u16 sys_timeout_add_2_task(void *priv, void (*func)(void *priv), u32 msec, const char *task_name);
/**
* @brief 删除ms级timeout类型定时任务。
*
* @param [in] id 要删除的任务ID
*
* @note
* 1、与sys_timerout_add成对使用。
*/
void sys_timeout_del(u16);
/**
* @brief 重置ms级定时任务定时时间。
*
* @param [in] id 要修改的任务ID
*
* @note
* 1、重置之后重新计时。
*/
void sys_timer_re_run(u16 id);
/**
* @brief 修改ms级定时任务处理函数的输入参数。
*
* @param [in] id 要修改的任务ID
* @param [in] priv 处理函数的输入参数
*/
void sys_timer_set_user_data(u16 id, void *priv);
/**
* @brief 获取ms级定时任务处理函数的输入参数的值。
*
* @param [in] id 要获取处理函数的输入参数值的任务ID
*
* @return 返回add时的私有参数
*
* @note
* 1、如果有通过sys_timer_set_user_data重新设置私有参数,
* 则返回的是设置后的私有参数。
*/
void *sys_timer_get_user_data(u16 id);
/*-----------------------------------------------------------*/
/*
* System Usec Timer
*/
int sys_timer_modify(u16 id, u32 msec);
void sys_timer_dump_time(void);
u32 sys_timer_get_ms(void);
/*-----------------------------------------------------------*/
/*
* Usr Timer
*/
void usr_timer_schedule();
/**
* @brief usr_timer定时扫描增加接口
*
* @param [in] priv 私有参数
* @param [in] func 定时扫描回调函数
* @param [in] msec 定时时间, 单位:毫秒
* @param [in] priority 优先级,范围:0/1
*
* @return 定时器分配的id号
*
* @note
* 1、usr_timer的参数priority(优先级)为1,使用该类定时器,系统无法进入低功耗;
* 2、usr_timer的参数priority(优先级)为0,使用该类定时器,系统低功耗会忽略该节拍,节拍不会丢失,但是定时周期会变;
* 3、usr_timer属于异步接口, add的时候注册的扫描函数将在硬件定时器中时基到时候被调用;
* 4、对应释放接口usr_timer_del。
*/
u16 usr_timer_add(void *priv, void (*func)(void *priv), u32 msec, u8 priority);
/**
* @brief usr_timer超时增加接口
*
* @param [in] priv 私有参数
* @param [in] func 超时回调函数
* @param [in] msec 定时时间, 单位:毫秒
* @param [in] priority 优先级,范围:0/1
*
* @return 定时器分配的id号
*
* @note
* 1、usr_timerout的参数priority(优先级)为1,使用该类定时器,系统无法进入低功耗;
* 2、usr_timerout的参数priority(优先级)为0,使用该类定时器,系统低功耗会忽略该节拍,节拍不会丢失,但是定时周期会变;
* 3、usr_timerout属于异步接口, add的时候注册的扫描函数将在硬件定时器中时基到时候被调用;
* 4、对应释放接口usr_timerout_del
* 5、timeout回调只会被执行一次。
*/
u16 usr_timeout_add(void *priv, void (*func)(void *priv), u32 msec, u8 priority);
/**
* @brief usr_timer修改定时扫描时间接口
*
* @param [in] id usr_timer_add时分配的id号
* @param [in] msec 定时时间,单位:毫秒
*/
int usr_timer_modify(u16 id, u32 msec);
/**
* @brief usr_timerout修改超时时间接口
*
* @param [in] id usr_timerout_add时分配的id号
* @param [in] msec 定时时间,单位:毫秒
*/
int usr_timeout_modify(u16 id, u32 msec);
/**
* @brief usr_timer删除接口
*
* @param [in] id usr_timer_add时分配的id号
*
* @note
* 1、注意与usr_timer_add成对使用。
*/
void usr_timer_del(u16 id);
/**
* @brief usr_timeout删除接口
*
* @param [in] id usr_timerout_add时分配的id号
*
* @note
* 1、注意与usr_timerout_add成对使用。
*/
void usr_timeout_del(u16 id);
/**
* @brief usr_time输出调试信息
*
* @note
* 1.调试时可用;
* 2.将输出所有被add定时器的id及其时间(msec)。
*/
void usr_timer_dump(void);
/*-----------------------------------------------------------*/
/*
* For Compatible
*/
#define sys_hi_timer_schedule()\
usr_timer_schedule()
#define sys_hi_timer_add(a, b, c)\
usr_timer_add(a, b, c, 1)
#define sys_hi_timeout_add(a, b, c)\
usr_timeout_add(a, b, c, 1)
#define sys_hi_timer_modify(a, b)\
usr_timer_modify(a, b)
#define sys_hi_timeout_modify(a, b)\
usr_timeout_modify(a, b)
#define sys_hi_timer_del(a)\
usr_timer_del(a)
#define sys_hi_timeout_del(a)\
usr_timeout_del(a)
#define sys_s_hi_timer_add(a, b, c)\
usr_timer_add(a, b, c, 0)
#define sys_s_hi_timerout_add(a, b, c)\
usr_timeout_add(a, b, c, 0)
#define sys_s_hi_timer_modify(a, b)\
usr_timer_modify(a, b)
#define sys_s_hi_timeout_modify(a, b)\
usr_timeout_modify(a, b)
#define sys_s_hi_timer_del(a)\
usr_timer_del(a)
#define sys_s_hi_timeout_del(a)\
usr_timeout_del(a)
#endif
+118
View File
@@ -0,0 +1,118 @@
#ifndef __USER_CFG_H__
#define __USER_CFG_H__
#include "typedef.h"
#define LOCAL_NAME_LEN 32 /*BD_NAME_LEN_MAX*/
//bt bin结构
typedef struct __BT_CONFIG {
u8 edr_name[LOCAL_NAME_LEN]; //经典蓝牙名
u8 mac_addr[6]; //蓝牙MAC地址
u8 rf_power; //发射功率
u8 dac_analog_gain; //通话DAC模拟增益
u8 mic_analog_gain; //通话MIC增益
u16 tws_device_indicate; /*设置对箱搜索标识,inquiry时候用,搜索到相应的标识才允许连接*/
u8 tws_local_addr[6];
} _GNU_PACKED_ BT_CONFIG;
//audio bin结构
typedef struct __AUDIO_CONFIG {
u8 sw;
u8 max_sys_vol; //最大系统音量
u8 default_vol; //开机默认音量
u8 tone_vol; //提示音音量
} _GNU_PACKED_ AUDIO_CONFIG;
//status bin结构体
typedef struct __STATUS {
u8 charge_start; //开始充电
u8 charge_full; //充电完成
u8 power_on; //开机
u8 power_off; //关机
u8 lowpower; //低电
u8 max_vol; //最大音量
u8 phone_in; //来电
u8 phone_out; //去电
u8 phone_activ; //通话中
u8 bt_init_ok; //蓝牙初始化完成
u8 bt_connect_ok; //蓝牙连接成功
u8 bt_disconnect; //蓝牙断开
u8 tws_connect_ok; //TWS连接成功
u8 tws_disconnect; //TWS蓝牙断开
} _GNU_PACKED_ STATUS;
typedef struct __STATUS_CONFIG {
u8 sw;
STATUS led; //led status
STATUS tone; //tone status
} _GNU_PACKED_ STATUS_CONFIG;
//charge bin结构
typedef struct __CHARGE_CONFIG {
u8 sw; //开关
u8 poweron_en; //支持开机充电
u8 full_v; //充满电压
u8 full_c; //充满电流
u8 charge_c; //充电电流
} _GNU_PACKED_ CHARGE_CONFIG;
//key
typedef struct __KEY_OP {
u8 short_msg; //短按消息
u8 long_msg; //长按消息
u8 hold_msg; //hold 消息
u8 up_msg; //抬键消息
u8 double_msg; //双击消息
u8 triple_msg; //三击消息
} _GNU_PACKED_ KEY_OP;
//mic type
typedef struct __MIC_TYPE_CONFIG {
u8 type; //0:不省电容模式 1:省电容模式
//1:16K 2:7.5K 3:5.1K 4:6.8K 5:4.7K 6:3.5K 7:2.9K 8:3K 9:2.5K 10:2.1K 11:1.9K 12:2K 13:1.8K 14:1.6K 15:1.5K 16:1K 31:0.6K
u8 pull_up;
//00:2.3v 01:2.5v 10:2.7v 11:3.0v
u8 ldo_lev;
} _GNU_PACKED_ MIC_TYPE_CONFIG;
//自动关机时间配置
typedef struct __AUTO_OFF_TIME_CONFIG {
u8 auto_off_time;
} _GNU_PACKED_ AUTO_OFF_TIME_CONFIG;
//低电压提示配置
typedef struct __AUTO_LOWPOWER_V_CONFIG {
u16 warning_tone_v;
u16 poweroff_tone_v;
} _GNU_PACKED_ AUTO_LOWPOWER_V_CONFIG;
//LRC配置
typedef struct __LRC_CONFIG {
u16 lrc_ws_inc;
u16 lrc_ws_init;
u16 btosc_ws_inc;
u16 btosc_ws_init;
u8 lrc_change_mode;
} _GNU_PACKED_ LRC_CONFIG;
void cfg_file_parse(u8 idx);
const u8 *bt_get_mac_addr();
void bt_get_tws_local_addr(u8 *addr);
STATUS *get_led_config(void);
STATUS *get_tone_config(void);
void get_random_number(u8 *ptr, u8 len);
extern void bt_get_vm_mac_addr(u8 *addr);
extern const char *bt_get_local_name();
extern u16 bt_get_tws_device_indicate(u8 *tws_device_indicate);
const char *bt_get_local_name();
extern void bt_update_mac_addr(u8 *addr);
extern void bt_set_local_name(char *name, u8 len);
extern void bt_reset_and_get_mac_addr(u8 *addr);
extern void bt_set_pair_code_en(u8 en);
const char *sdk_version_info_get(void);
#endif