GK SDK 源码库: XMIPCLinuxV100R005C00SPC030 (kernel/tools/open_source excluded)
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
|
||||
#ifndef _ASSERT_H_
|
||||
#define _ASSERT_H_
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#define assert(x) ASSERT(x)
|
||||
|
||||
#endif /* _ASSERT_H_ */
|
||||
@@ -0,0 +1,63 @@
|
||||
|
||||
#ifndef __COMMON_H_
|
||||
#define __COMMON_H_
|
||||
#include <config.h>
|
||||
#include <sys/types.h>
|
||||
#include <io.h>
|
||||
#include <serial.h>
|
||||
#include <stdio.h>
|
||||
#include <compile.h>
|
||||
#include <core.h>
|
||||
#include <debug.h>
|
||||
#include <assert.h>
|
||||
#include <timer.h>
|
||||
#include <string.h>
|
||||
#include <reserved_mem.h>
|
||||
|
||||
extern char g_base_irqstack[];
|
||||
extern char g_top_irqstack[];
|
||||
|
||||
extern u32 g_heap_start;
|
||||
extern u32 g_heap_end;
|
||||
|
||||
extern char _start[];
|
||||
extern char _end[];
|
||||
|
||||
extern char __text_start[];
|
||||
extern char __text_end[];
|
||||
|
||||
extern char __rodata_start[];
|
||||
extern char __rodata_end[];
|
||||
|
||||
extern char __data_start[];
|
||||
extern char __data_end[];
|
||||
|
||||
extern char __text2_start[];
|
||||
extern char __text2_end[];
|
||||
|
||||
extern char __rodata2_start[];
|
||||
extern char __rodata2_end[];
|
||||
|
||||
extern char __data2_start[];
|
||||
extern char __data2_end[];
|
||||
|
||||
extern char __bss_start[];
|
||||
extern char __bss_end[];
|
||||
|
||||
extern char __bin_end_pad[];
|
||||
extern char __bin_end[];
|
||||
|
||||
extern char __param_start[];
|
||||
extern char __param_end[];
|
||||
|
||||
u32 start_shell(void);
|
||||
|
||||
int run_stage2_func(int (*func)(void));
|
||||
|
||||
u64 get_ddr_size(void);
|
||||
|
||||
ulong get_reserved_ddr(u32 size);
|
||||
|
||||
void stopwatch_trigger(void);
|
||||
|
||||
#endif /*__COMMON_H_*/
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
#ifndef _COMPILE_H_
|
||||
#define _COMPILE_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define __FILENAME__ (__builtin_strrchr(__FILE__, '/')? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
|
||||
#define array_size(x) (sizeof(x) / sizeof(*(x)))
|
||||
|
||||
#define swap32(_x) ((uint32)( \
|
||||
((((uint32)(_x)) & 0x000000FF) << 24) | \
|
||||
((((uint32)(_x)) & 0x0000FF00) << 8) | \
|
||||
((((uint32)(_x)) & 0xFF000000) >> 24) | \
|
||||
((((uint32)(_x)) & 0x00FF0000) >> 8)))
|
||||
|
||||
#define swap16(_x) ((uint16)( \
|
||||
((((uint16)(_x)) & 0xFF00) >> 8) | \
|
||||
((((uint16)(_x)) & 0x00FF) << 8)))
|
||||
|
||||
#define around(size, align) (((size) + (align) - 1) & (~((align) - 1)))
|
||||
|
||||
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
|
||||
|
||||
#define STAGE1_FUNC __attribute__((section(".text.stage1")))
|
||||
#define STAGE1_GLOBAL __attribute__((section(".data.stage1")))
|
||||
#define STAGE1_CONST_GLOBAL __attribute__((section(".rodata.stage1"))) const
|
||||
#define STAGE1_STR(str) \
|
||||
({ \
|
||||
static const char _str_##__COUNTER__[] \
|
||||
__attribute__((section(".rodata.stage1"))) = str; \
|
||||
_str_##__COUNTER__; \
|
||||
})
|
||||
|
||||
#define STAGE2_FUNC __attribute__((section(".text.stage2")))
|
||||
#define STAGE2_GLOBAL __attribute__((section(".data.stage2")))
|
||||
#define STAGE2_CONST_GLOBAL __attribute__((section(".rodata.stage2"))) const
|
||||
#define STAGE2_STR(str) \
|
||||
({ \
|
||||
static const char _str_##__COUNTER__[] \
|
||||
__attribute__((section(".rodata.stage2"))) = str; \
|
||||
_str_##__COUNTER__; \
|
||||
})
|
||||
|
||||
#endif /* _COMPILE_H_ */
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#ifndef CONFIGH
|
||||
#define CONFIGH
|
||||
#include <autoconf.h>
|
||||
#include <platform.h>
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) XMEDIA. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_CTYPE_H_
|
||||
#define _SYS_CTYPE_H_
|
||||
|
||||
#define isspace(c) ((c) == ' ' || ((c) >= '\t' && (c) <= '\r'))
|
||||
#define isascii(c) (((c) & ~0x7f) == 0)
|
||||
#define isupper(c) ((c) >= 'A' && (c) <= 'Z')
|
||||
#define islower(c) ((c) >= 'a' && (c) <= 'z')
|
||||
#define isalpha(c) (isupper(c) || islower(c))
|
||||
#define isdigit(c) ((c) >= '0' && (c) <= '9')
|
||||
#define isxdigit(c) (isdigit(c) \
|
||||
|| ((c) >= 'A' && (c) <= 'F') \
|
||||
|| ((c) >= 'a' && (c) <= 'f'))
|
||||
#define isprint(c) ((c) >= ' ' && (c) <= '~')
|
||||
#define toupper(c) ((c) - 0x20 * (((c) >= 'a') && ((c) <= 'z')))
|
||||
#define tolower(c) ((c) + 0x20 * (((c) >= 'A') && ((c) <= 'Z')))
|
||||
|
||||
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||
#define min_t(t, x, y) ((t)((t)(x) < (t)(y) ? (x) : (y)))
|
||||
|
||||
#define tohex(c) (((c) >= '0' && (c) <= '9') ? ((c) - '0') : \
|
||||
(((c) >= 'a' && (c) <= 'f') ? ((c) - 'a' + 10) : \
|
||||
(((c) >= 'A' && (c) <= 'F') ? ((c) - 'A' + 10) : -1)))
|
||||
|
||||
#endif /* !_SYS_CTYPE_H_ */
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) XMEDIA 2021. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _DEBUG_H_
|
||||
#define _DEBUG_H_
|
||||
/******************************************************************************/
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <lib.h>
|
||||
|
||||
/* #define ASSERT(_p) if (!(_p)) { \
|
||||
* printf("%s(%s,%d):assert:(%s)\n", __FILE__, __FUNCTION__, __LINE__, #_p);
|
||||
*
|
||||
* #define ASSERT1(_p, _fmt, args...) if (!(_p)) { \
|
||||
* printf("%s(%s,%d):assert:(%s)\n" _fmt, __FILE__, __FUNCTION__, __LINE__, #_p, ##args); */
|
||||
|
||||
#define ASSERT(_condition) do { \
|
||||
if (!(_condition)) { \
|
||||
puts("ASSERT "); \
|
||||
putchar('['); \
|
||||
puts(__FILE__); \
|
||||
putchar(','); \
|
||||
putdec(__LINE__); \
|
||||
puts("]: "); \
|
||||
puts(#_condition); \
|
||||
puts("\n"); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define __PRINT_MACRO(x) #x
|
||||
#define PRINT_MARCO(x) #x"="__PRINT_MACRO(x)
|
||||
/* #pragma message(PRINT_MARCO(MACRO_NAME_XXX)) */
|
||||
|
||||
int dump_hex(u32 addr, char *buf, u32 sz_buf, u32 width);
|
||||
|
||||
/******************************************************************************/
|
||||
#endif /* _DEBUG_H_ */
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
#ifndef _DIV64_H_
|
||||
#define _DIV64_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
|
||||
|
||||
#define do_div(n, base) ({ \
|
||||
uint32_t __base = (base); \
|
||||
uint32_t __rem; \
|
||||
if (((n) >> 32) == 0) { \
|
||||
__rem = (uint32_t)(n) % __base; \
|
||||
(n) = (uint32_t)(n) / __base; \
|
||||
} else \
|
||||
__rem = __div64_32(&(n), __base); \
|
||||
__rem; \
|
||||
})
|
||||
|
||||
#endif /* _DIV64_H_ */
|
||||
@@ -0,0 +1,153 @@
|
||||
|
||||
#ifndef _ERRNO_H_
|
||||
#define _ERRNO_H_
|
||||
|
||||
/****************************************************************************
|
||||
* Error Number Definitions
|
||||
****************************************************************************/
|
||||
#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 EDEADLK 35 /* Resource deadlock would occur */
|
||||
#define ENAMETOOLONG 36 /* File name too long */
|
||||
#define ENOLCK 37 /* No record locks available */
|
||||
|
||||
#define ENOSYS 38 /* Invalid system call number */
|
||||
|
||||
#define ENOTEMPTY 39 /* Directory not empty */
|
||||
#define ELOOP 40 /* Too many symbolic links encountered */
|
||||
#define EWOULDBLOCK EAGAIN /* Operation would block */
|
||||
#define ENOMSG 42 /* No message of desired type */
|
||||
#define EIDRM 43 /* Identifier removed */
|
||||
#define ECHRNG 44 /* Channel number out of range */
|
||||
#define EL2NSYNC 45 /* Level 2 not synchronized */
|
||||
#define EL3HLT 46 /* Level 3 halted */
|
||||
#define EL3RST 47 /* Level 3 reset */
|
||||
#define ELNRNG 48 /* Link number out of range */
|
||||
#define EUNATCH 49 /* Protocol driver not attached */
|
||||
#define ENOCSI 50 /* No CSI structure available */
|
||||
#define EL2HLT 51 /* Level 2 halted */
|
||||
#define EBADE 52 /* Invalid exchange */
|
||||
#define EBADR 53 /* Invalid request descriptor */
|
||||
#define EXFULL 54 /* Exchange full */
|
||||
#define ENOANO 55 /* No anode */
|
||||
#define EBADRQC 56 /* Invalid request code */
|
||||
#define EBADSLT 57 /* Invalid slot */
|
||||
|
||||
#define EDEADLOCK EDEADLK
|
||||
|
||||
#define EBFONT 59 /* Bad font file format */
|
||||
#define ENOSTR 60 /* Device not a stream */
|
||||
#define ENODATA 61 /* No data available */
|
||||
#define ETIME 62 /* Timer expired */
|
||||
#define ENOSR 63 /* Out of streams resources */
|
||||
#define ENONET 64 /* Machine is not on the network */
|
||||
#define ENOPKG 65 /* Package not installed */
|
||||
#define EREMOTE 66 /* Object is remote */
|
||||
#define ENOLINK 67 /* Link has been severed */
|
||||
#define EADV 68 /* Advertise error */
|
||||
#define ESRMNT 69 /* Srmount error */
|
||||
#define ECOMM 70 /* Communication error on send */
|
||||
#define EPROTO 71 /* Protocol error */
|
||||
#define EMULTIHOP 72 /* Multihop attempted */
|
||||
#define EDOTDOT 73 /* RFS specific error */
|
||||
#define EBADMSG 74 /* Not a data message */
|
||||
#define EOVERFLOW 75 /* Value too large for defined data type */
|
||||
#define ENOTUNIQ 76 /* Name not unique on network */
|
||||
#define EBADFD 77 /* File descriptor in bad state */
|
||||
#define EREMCHG 78 /* Remote address changed */
|
||||
#define ELIBACC 79 /* Can not access a needed shared library */
|
||||
#define ELIBBAD 80 /* Accessing a corrupted shared library */
|
||||
#define ELIBSCN 81 /* .lib section in a.out corrupted */
|
||||
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
|
||||
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
|
||||
#define EILSEQ 84 /* Illegal byte sequence */
|
||||
#define ERESTART 85 /* Interrupted system call should be restarted */
|
||||
#define ESTRPIPE 86 /* Streams pipe error */
|
||||
#define EUSERS 87 /* Too many users */
|
||||
#define ENOTSOCK 88 /* Socket operation on non-socket */
|
||||
#define EDESTADDRREQ 89 /* Destination address required */
|
||||
#define EMSGSIZE 90 /* Message too long */
|
||||
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
|
||||
#define ENOPROTOOPT 92 /* Protocol not available */
|
||||
#define EPROTONOSUPPORT 93 /* Protocol not supported */
|
||||
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
|
||||
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||
#define EPFNOSUPPORT 96 /* Protocol family not supported */
|
||||
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||
#define EADDRINUSE 98 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
|
||||
#define ENETDOWN 100 /* Network is down */
|
||||
#define ENETUNREACH 101 /* Network is unreachable */
|
||||
#define ENETRESET 102 /* Network dropped connection because of reset */
|
||||
#define ECONNABORTED 103 /* Software caused connection abort */
|
||||
#define ECONNRESET 104 /* Connection reset by peer */
|
||||
#define ENOBUFS 105 /* No buffer space available */
|
||||
#define EISCONN 106 /* Transport endpoint is already connected */
|
||||
#define ENOTCONN 107 /* Transport endpoint is not connected */
|
||||
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
|
||||
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
|
||||
#define ETIMEDOUT 110 /* Connection timed out */
|
||||
#define ECONNREFUSED 111 /* Connection refused */
|
||||
#define EHOSTDOWN 112 /* Host is down */
|
||||
#define EHOSTUNREACH 113 /* No route to host */
|
||||
#define EALREADY 114 /* Operation already in progress */
|
||||
#define EINPROGRESS 115 /* Operation now in progress */
|
||||
#define ESTALE 116 /* Stale file handle */
|
||||
#define EUCLEAN 117 /* Structure needs cleaning */
|
||||
#define ENOTNAM 118 /* Not a XENIX named type file */
|
||||
#define ENAVAIL 119 /* No XENIX semaphores available */
|
||||
#define EISNAM 120 /* Is a named type file */
|
||||
#define EREMOTEIO 121 /* Remote I/O error */
|
||||
#define EDQUOT 122 /* Quota exceeded */
|
||||
|
||||
#define ENOMEDIUM 123 /* No medium found */
|
||||
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
||||
#define ECANCELED 125 /* Operation Canceled */
|
||||
#define ENOKEY 126 /* Required key not available */
|
||||
#define EKEYEXPIRED 127 /* Key has expired */
|
||||
#define EKEYREVOKED 128 /* Key has been revoked */
|
||||
#define EKEYREJECTED 129 /* Key was rejected by service */
|
||||
|
||||
/* for robust mutexes */
|
||||
#define EOWNERDEAD 130 /* Owner died */
|
||||
#define ENOTRECOVERABLE 131 /* State not recoverable */
|
||||
|
||||
#define ERFKILL 132 /* Operation not possible due to RF-kill */
|
||||
|
||||
#define EHWPOISON 133 /* Memory page has hardware error */
|
||||
|
||||
#define ENOTSUP 134 /* Not supported */
|
||||
|
||||
#endif /* _ERRNO_H_ */
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
#ifndef _FLOAT_H_
|
||||
#define _FLOAT_H_
|
||||
|
||||
#undef FLT_MAX
|
||||
#define FLT_MAX __FLT_MAX__
|
||||
|
||||
#undef DBL_MAX
|
||||
#define DBL_MAX __DBL_MAX__
|
||||
|
||||
#undef FLT_MIN
|
||||
#define FLT_MIN __FLT_MIN__
|
||||
|
||||
#undef DBL_MIN
|
||||
#define DBL_MIN __DBL_MIN__
|
||||
|
||||
#undef FLT_EPSILON
|
||||
#define FLT_EPSILON __FLT_EPSILON__
|
||||
|
||||
#undef DBL_EPSILON
|
||||
#define DBL_EPSILON __DBL_EPSILON__
|
||||
|
||||
#endif /* ifndef _FLOAT_H_ */
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
#ifndef _GPIO_H_
|
||||
#define _GPIO_H_
|
||||
|
||||
void gpio_set_dir(int group, int bit, int dir);
|
||||
void gpio_set_data(int group, int bit, int data);
|
||||
|
||||
#endif /* _GPIO_H_ */
|
||||
@@ -0,0 +1,147 @@
|
||||
|
||||
#ifndef _HLIST_H_
|
||||
#define _HLIST_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/*
|
||||
* 该结构体用于嵌入到业务数据结构体中(entry),用于实现链表
|
||||
* 例:
|
||||
* struct Entry { // 你的业务数据结构体
|
||||
* ...
|
||||
* struct node node; // 嵌入其中,位置任意
|
||||
* ...
|
||||
* };
|
||||
*/
|
||||
struct node {
|
||||
struct node *next, *prev;
|
||||
};
|
||||
|
||||
/*
|
||||
* 由成员变量 node 地址获取结构体 entry 地址
|
||||
* 例:
|
||||
* struct Entry entry;
|
||||
* struct node *n = &entry.node;
|
||||
* struct Entry *p = node_entry(n, struct Entry, node);
|
||||
* 此时 p 指向 entry
|
||||
*/
|
||||
#define node_entry(node, type, member) \
|
||||
((type*)((char*)(node) - (size_t)&((type*)0)->member))
|
||||
|
||||
/* 带哨兵节点的双向链表 */
|
||||
struct list {
|
||||
struct node base;
|
||||
};
|
||||
|
||||
static inline void list_init(struct list *list)
|
||||
{
|
||||
list->base.next = &list->base;
|
||||
list->base.prev = &list->base;
|
||||
}
|
||||
|
||||
static inline bool list_empty(const struct list *list)
|
||||
{
|
||||
return list->base.next == &list->base;
|
||||
}
|
||||
|
||||
static inline bool list_is_head(const struct list *list, const struct node *node)
|
||||
{
|
||||
return list->base.next == node;
|
||||
}
|
||||
|
||||
static inline bool list_is_tail(const struct list *list, const struct node *node)
|
||||
{
|
||||
return list->base.prev == node;
|
||||
}
|
||||
|
||||
/* node 插入到 pos 后面 */
|
||||
static inline void list_insert_backward(struct node *pos, struct node *node)
|
||||
{
|
||||
node->prev = pos;
|
||||
node->next = pos->next;
|
||||
node->prev->next = node;
|
||||
node->next->prev = node;
|
||||
}
|
||||
|
||||
/* node 插入到 pos 前面 */
|
||||
static inline void list_insert(struct node *pos, struct node *node)
|
||||
{
|
||||
node->prev = pos->prev;
|
||||
node->next = pos;
|
||||
node->prev->next = node;
|
||||
node->next->prev = node;
|
||||
}
|
||||
|
||||
static inline void list_add_tail(struct list *list, struct node *node)
|
||||
{
|
||||
list_insert(&list->base, node);
|
||||
}
|
||||
|
||||
static inline void list_add_head(struct list *list, struct node *node)
|
||||
{
|
||||
list_insert(list->base.next, node);
|
||||
}
|
||||
|
||||
static inline void list_remove(struct node *node)
|
||||
{
|
||||
node->prev->next = node->next;
|
||||
node->next->prev = node->prev;
|
||||
}
|
||||
|
||||
static inline void list_remove_tail(struct list *list)
|
||||
{
|
||||
list_remove(list->base.prev);
|
||||
}
|
||||
|
||||
static inline void list_remove_head(struct list *list)
|
||||
{
|
||||
list_remove(list->base.next);
|
||||
}
|
||||
|
||||
static inline void list_replace(struct node *old, struct node *node)
|
||||
{
|
||||
node->next = old->next;
|
||||
node->next->prev = node;
|
||||
node->prev = old->prev;
|
||||
node->prev->next = node;
|
||||
}
|
||||
|
||||
#define list_for_each(node, list) \
|
||||
for (node = (list)->base.next; node != &(list)->base; node = (node)->next)
|
||||
|
||||
#define list_for_each_safe(node, tmp, list) \
|
||||
for (node = (list)->base.next, tmp = (node)->next; node != &(list)->base; node = tmp, tmp = (node)->next)
|
||||
|
||||
/* 获取头结点,或空 */
|
||||
#define list_head_entry(list, type, member) \
|
||||
(list_empty(list) ? NULL : node_entry((list)->base.next, type, member))
|
||||
|
||||
/* 获取尾结点,或空 */
|
||||
#define list_tail_entry(list, type, member) \
|
||||
(list_empty(list) ? NULL : node_entry((list)->base.prev, type, member))
|
||||
|
||||
/* 获取下一结点,或空 */
|
||||
#define list_next_entry(entry, list, type, member) \
|
||||
(list_is_tail(list, &(entry)->member) ? \
|
||||
NULL : \
|
||||
node_entry((entry)->member.next, type, member))
|
||||
|
||||
/* 获取上一结点,或空 */
|
||||
#define list_prev_entry(entry, list, type, member) \
|
||||
(list_is_head(list, &(entry)->member) ? \
|
||||
NULL : \
|
||||
node_entry((entry)->member.prev, type, member))
|
||||
|
||||
/* 遍历链表;过程中如需操作链表,请使用 _SAFE 版本 */
|
||||
#define list_for_each_entry(entry, list, type, member) \
|
||||
for (entry = node_entry((list)->base.next, type, member); \
|
||||
&(entry)->member != &(list)->base; \
|
||||
entry = node_entry((entry)->member.next, type, member))
|
||||
|
||||
#define list_for_each_entry_safe(entry, tmp, list, type, member) \
|
||||
for (entry = node_entry((list)->base.next, type, member), \
|
||||
tmp = node_entry((entry)->member.next, type, member); \
|
||||
&(entry)->member != &(list)->base; \
|
||||
entry = tmp, tmp = node_entry((entry)->member.next, type, member))
|
||||
|
||||
#endif /* _HLIST_H_ */
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef _I2C_H_
|
||||
#define _I2C_H_
|
||||
|
||||
#include <platform.h>
|
||||
#include <sys/types.h>
|
||||
#include <io.h>
|
||||
#include <lib.h>
|
||||
|
||||
struct i2c_client {
|
||||
unsigned char i2c_num;
|
||||
unsigned short dev_addr;
|
||||
unsigned long int reg_addr;
|
||||
unsigned int reg_width;
|
||||
};
|
||||
|
||||
int i2c_init(unsigned char i2c_num);
|
||||
int i2c_recv(const struct i2c_client *client, unsigned char *buf, unsigned int count);
|
||||
int i2c_send(unsigned char i2c_num, unsigned short dev_addr, const char *buf,unsigned int count);
|
||||
|
||||
|
||||
#endif
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
|
||||
#ifndef _IMAGE_H_
|
||||
#define _IMAGE_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
struct mcu_fw_head {
|
||||
u32 j_instruction; /* Jump to real excutable entry */
|
||||
u32 fw_magic; /* MCU Firmware magic */
|
||||
u32 fw_ver; /* MCU Firmware version */
|
||||
u32 fw_total_size; /* MCU Firmware total size */
|
||||
u32 fw_stage1_size; /* MCU Stage1 size */
|
||||
u8 resv[CONFIG_MCU_HEAD_SIZE - 20]; /* Reserved */
|
||||
};
|
||||
|
||||
#endif /* _IMAGE_H_ */
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
#ifndef _INTERRUPT_H_
|
||||
#define _INTERRUPT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define ATTRIBUTE_ISR __attribute__ ((interrupt ("machine")))
|
||||
|
||||
void drv_irq_enable(uint32_t irq_num);
|
||||
void drv_irq_disable(uint32_t irq_num);
|
||||
int drv_irq_register(uint32_t irq_num, void *irq_handler);
|
||||
void drv_irq_unregister(uint32_t irq_num);
|
||||
int irq_init(void);
|
||||
|
||||
#endif /* ifndef _INTERRUPT_H_ */
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
#ifdef CONFIG_ARM_ARCH
|
||||
#include <arm/include/io.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RISCV_ARCH
|
||||
#include <riscv/include/io.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef __LIB_H__
|
||||
#define __LIB_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <config.h>
|
||||
|
||||
#define SECUREC_MEM_MAX_LEN (0x100000) //1MB
|
||||
|
||||
void reset_cpu(void);
|
||||
|
||||
int memset_s(void* dest, size_t destMax, unsigned char c, size_t count);
|
||||
int memcpy_s(void* dest, size_t destMax, const void* src, size_t count);
|
||||
unsigned short crc16(unsigned char *data, unsigned int length);
|
||||
#endif /*__LIB_H__*/
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
#ifndef _MALLOC_H_
|
||||
#define _MALLOC_H_
|
||||
|
||||
#include <config.h>
|
||||
#include <stddef.h>
|
||||
|
||||
void malloc_init(uint32 start, uint32 len);
|
||||
#ifdef CONFIG_MALLOC
|
||||
void *malloc(uint32 bytes); /* not thread safe */
|
||||
void *memalign(uint32 alignment, uint32 bytes);
|
||||
void free(void *ptr);
|
||||
void show_memnode(unsigned int);
|
||||
#else
|
||||
void *__malloc(uint32 bytes, const char *file, int line);
|
||||
void *__memalign(uint32 alignment, uint32 bytes, const char *file, int line);
|
||||
void __free(const void *mem, const char *file, int line);
|
||||
#define malloc(bytes) __malloc(bytes, __FILE__, __LINE__)
|
||||
#define memalign(alignment, bytes) __memalign(alignment, bytes, __FILE__, __LINE__)
|
||||
#define free(mem) __free(mem, __FILE__, __LINE__)
|
||||
#endif
|
||||
#endif /* _MALLOC_H_ */
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
|
||||
#ifndef _MATH_H_
|
||||
#define _MATH_H_
|
||||
|
||||
#define FP_NAN 0
|
||||
#define FP_INFINITE 1
|
||||
#define FP_ZERO 2
|
||||
#define FP_SUBNORMAL 3
|
||||
#define FP_NORMAL 4
|
||||
|
||||
# ifndef HUGE_VALF
|
||||
# define HUGE_VALF (__builtin_huge_valf())
|
||||
# endif
|
||||
|
||||
# ifndef INFINITY
|
||||
# define INFINITY (__builtin_inff())
|
||||
# endif
|
||||
|
||||
# ifndef NAN
|
||||
# define NAN (__builtin_nanf(""))
|
||||
# endif
|
||||
|
||||
#define fpclassify(__x) (__builtin_fpclassify (FP_NAN, FP_INFINITE, \
|
||||
FP_NORMAL, FP_SUBNORMAL, \
|
||||
FP_ZERO, __x))
|
||||
#ifndef isfinite
|
||||
#define isfinite(__x) (__builtin_isfinite (__x))
|
||||
#endif
|
||||
#ifndef isinf
|
||||
#define isinf(__x) (__builtin_isinf_sign (__x))
|
||||
#endif
|
||||
#ifndef isnan
|
||||
#define isnan(__x) (__builtin_isnan (__x))
|
||||
#endif
|
||||
#define isnormal(__x) (__builtin_isnormal (__x))
|
||||
|
||||
float logf(float x);
|
||||
float sqrtf(float x);
|
||||
float powf(float x, float y);
|
||||
float fabsf(float x);
|
||||
float sinf(float x);
|
||||
float cosf(float x);
|
||||
|
||||
#undef log
|
||||
#define log(x) logf(x)
|
||||
#undef pow
|
||||
#define pow(x, y) powf(x, y)
|
||||
#undef abs
|
||||
#define abs(x) fabsf(x)
|
||||
#undef fabs
|
||||
#define fabs(x) fabsf(x)
|
||||
#undef sqrt
|
||||
#define sqrt(x) sqrtf(x)
|
||||
#undef sin
|
||||
#define sin(x) sinf(x)
|
||||
#undef cos
|
||||
#define cos(x) cosf(x)
|
||||
|
||||
|
||||
#endif /* _MATH_H_ */
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef _PWM_H_
|
||||
#define _PWM_H_
|
||||
|
||||
#include <platform.h>
|
||||
#include <sys/types.h>
|
||||
#include <io.h>
|
||||
#include <lib.h>
|
||||
|
||||
int pwm_enable(int pwm_id);
|
||||
int pwm_disable(int pwm_id);
|
||||
int pwm_config(int pwm_id, int duty_cycle_us, int period_us);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
#ifndef _RESERVED_MEM_H_
|
||||
#define _RESERVED_MEM_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <compile.h>
|
||||
|
||||
void rsv_mem_init(uint32 start, uint32 len);
|
||||
void *__rsv_mem_alloc(uint32 bytes, const char *file, int line);
|
||||
#define reserved_mem_alloc(bytes) \
|
||||
__rsv_mem_alloc(bytes, __FILENAME__, __LINE__)
|
||||
void *__rsv_mem_align(uint32 alignment, uint32 bytes, const char *file, int line);
|
||||
#define reserved_mem_align(alignment, bytes) \
|
||||
__rsv_mem_align(alignment, bytes, __FILENAME__, __LINE__)
|
||||
|
||||
void dump_rsv_mem_info(void);
|
||||
|
||||
#endif /* ifndef _RESERVED_MEM_H_ */
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) XMEDIA. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __SERIAL_H__
|
||||
#define __SERIAL_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
* serial interface
|
||||
------------------------------------------------------------------*/
|
||||
void serial_init(void);
|
||||
void serial_putc(const char c);
|
||||
void serial_puts(const char *s);
|
||||
void serial_puts_always(const char *s);
|
||||
void serial_put_dec(u32 dec);
|
||||
void serial_put_hex(u32 hex);
|
||||
void serial_put_hex_always(u32 hex);
|
||||
char serial_getc(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
#ifndef _STDARG_H_
|
||||
#define _STDARG_H_
|
||||
/******************************************************************************/
|
||||
|
||||
typedef __builtin_va_list va_list;
|
||||
|
||||
#define va_start(v,l) __builtin_va_start(v,l)
|
||||
#define va_end(v) __builtin_va_end(v)
|
||||
#define va_arg(v,l) __builtin_va_arg(v,l)
|
||||
|
||||
/******************************************************************************/
|
||||
#endif /* _STDARG_H_ */
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
#ifndef _STDBOOL_H_
|
||||
#define _STDBOOL_H_
|
||||
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#endif /* ifndef _STDBOOL_H_ */
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) XMEDIA. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __STDDEFH__
|
||||
#define __STDDEFH__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define _1K (0x400)
|
||||
#define _2K (0x800)
|
||||
#define _4K (0x1000)
|
||||
#define _8K (0x2000)
|
||||
#define _16K (0x4000)
|
||||
#define _32K (0x8000)
|
||||
#define _64K (0x10000)
|
||||
#define _128K (0x20000)
|
||||
#define _256K (0x40000)
|
||||
#define _512K (0x80000)
|
||||
#define _1M (0x100000)
|
||||
#define _2M (0x200000)
|
||||
#define _4M (0x400000)
|
||||
#define _8M (0x800000)
|
||||
#define _16M (0x1000000)
|
||||
#define _32M (0x2000000)
|
||||
#define _64M (0x4000000)
|
||||
#define _128M (0x8000000)
|
||||
#define _256M (0x10000000)
|
||||
#define _512M (0x20000000)
|
||||
#define _1G (0x40000000)
|
||||
#define _2G (0x80000000)
|
||||
#define _3G (0xC0000000)
|
||||
#define _4G (0x100000000ULL)
|
||||
#define _8G (0x200000000ULL)
|
||||
#define _16G (0x400000000ULL)
|
||||
#define _32G (0x800000000ULL)
|
||||
#define _64G (0x1000000000ULL)
|
||||
|
||||
#endif /* __STDDEFH__ */
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
#ifndef _STDINT_H_
|
||||
#define _STDINT_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
|
||||
#ifndef _STDIO_H_
|
||||
#define _STDIO_H_
|
||||
/******************************************************************************/
|
||||
|
||||
#include <config.h>
|
||||
#include <stddef.h>
|
||||
|
||||
int sprintf(char *buf, const char *cfmt, ...);
|
||||
int snprintf(char *str, size_t size, const char *format, ...);
|
||||
|
||||
int getchar(void);
|
||||
void puts_always(const char *s);
|
||||
void puthex_always(unsigned int hex);
|
||||
|
||||
#ifdef CONFIG_PRINT
|
||||
#ifdef CONFIG_PRINTF
|
||||
int printf(const char *cfmt, ...);
|
||||
#else
|
||||
# define printf(_cfmt, ...)
|
||||
#endif
|
||||
int putchar(int c);
|
||||
int puts(const char *s);
|
||||
void puthex(unsigned int hex);
|
||||
void putdec(unsigned int dec);
|
||||
#else
|
||||
# define printf(_cfmt, ...)
|
||||
# define putchar(c)
|
||||
# define puts(_s)
|
||||
# define puthex(hex)
|
||||
# define putdec(dec)
|
||||
#endif
|
||||
|
||||
#ifndef MOULE_NAME
|
||||
#define MOULE_NAME ""
|
||||
#endif
|
||||
|
||||
#define pr_error(_fmt, args...) printf(MOULE_NAME _fmt, ##args)
|
||||
#define pr_warn(_fmt, args...) printf(MOULE_NAME _fmt, ##args)
|
||||
#define pr_info(_fmt, args...) printf(MOULE_NAME _fmt, ##args)
|
||||
|
||||
#ifdef PR_DEBUG
|
||||
# define pr_debug(_fmt, args...) printf(MOULE_NAME _fmt, ##args)
|
||||
#else
|
||||
# define pr_debug(_fmt, args...)
|
||||
#endif /* pr_debug */
|
||||
|
||||
#define bug(_fmt, args...) { \
|
||||
printf(MOULE_NAME "%s(%d): "_fmt, __FILE__, __LINE__, ##args); \
|
||||
while (1); }
|
||||
|
||||
/******************************************************************************/
|
||||
#endif /* _STDIO_H_ */
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
#ifndef _STDLIB_H_
|
||||
#define _STDLIB_H_
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
#endif /* _STDLIB_H_ */
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
#ifndef _STRING_H_
|
||||
#define _STRING_H_
|
||||
/******************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
extern char const hex2ascii_data[];
|
||||
|
||||
#define hex2ascii(hex) (hex2ascii_data[hex])
|
||||
|
||||
#define imax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
|
||||
|
||||
#define bcpy(src, dst, len) memcpy((dst), (src), (len))
|
||||
#define bzero(buf, size) memset((buf), 0, (size))
|
||||
#define bcmp(b1, b2, len) (memcmp((b1), (b2), (len)) != 0)
|
||||
|
||||
void *memmove(void *dest, const void *src, size_t size);
|
||||
void *memcpy(void *dst, const void *src, size_t len);
|
||||
void *memset(void *b, int c, size_t len);
|
||||
int memcmp(const void *b1, const void *b2, size_t len);
|
||||
int strncmp(const char *s1, const char *s2, size_t len);
|
||||
uint32_t strnlen(const char *s, uint32_t len);
|
||||
unsigned long strtoul(const char *nptr, char **endptr, int base);
|
||||
uint64_t strtoull(const char *nptr, char **endptr, int base);
|
||||
char *strncpy(char * dst, const char * src, size_t n);
|
||||
uint64_t memparse(const char *ptr, char **retptr);
|
||||
char *strndup(const char *str, size_t n);
|
||||
char *strtok(char *s, const char *delim);
|
||||
|
||||
int strcmp(const char *s1, const char *s2);
|
||||
void strcpy(char *dst, const char *src);
|
||||
void strcat(char *dst, const char *src);
|
||||
char *strncat(char *dst, const char *src, size_t n);
|
||||
char *strchr(const char *s, char ch);
|
||||
char *strdup(const char *s);
|
||||
size_t strlen(const char *s);
|
||||
char *strstr(const char *s1, const char *s2);
|
||||
|
||||
/******************************************************************************/
|
||||
#endif /* _STRING_H_ */
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) XMEDIA. All rights reserved.
|
||||
*/
|
||||
#ifndef __TYPES_H__
|
||||
#define __TYPES_H__
|
||||
|
||||
|
||||
typedef signed char s8;
|
||||
typedef unsigned char u8;
|
||||
typedef signed short s16;
|
||||
typedef unsigned short u16;
|
||||
typedef signed int s32;
|
||||
typedef unsigned int u32;
|
||||
typedef signed long long s64;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef long long intmax_t;
|
||||
typedef unsigned long long uintmax_t;
|
||||
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned long ulong;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned char uint8;
|
||||
typedef char int8;
|
||||
typedef unsigned short uint16;
|
||||
typedef short int16;
|
||||
typedef unsigned int uint32;
|
||||
typedef int int32;
|
||||
|
||||
typedef unsigned long uintptr_t;
|
||||
typedef unsigned int size_t;
|
||||
|
||||
#define BITS_PER_LONG 32
|
||||
|
||||
#undef NULL
|
||||
#define NULL ((void *)0)
|
||||
|
||||
typedef int bool;
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#define ERROR -1
|
||||
#define OK 0
|
||||
|
||||
#define SZ_4M 0x400000
|
||||
#define SZ_8M 0x800000
|
||||
#define SZ_16M 0x1000000
|
||||
#define SZ_128M 0x8000000
|
||||
#define SZ_256M 0x10000000
|
||||
#define SZ_512M 0x20000000
|
||||
#define SZ_750M 0x30000000
|
||||
#define SZ_1G 0x40000000
|
||||
#define SZ_2G 0x80000000
|
||||
#define SZ_3G 0xc0000000
|
||||
#define SZ_4G 0x100000000
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
#ifndef _TIME_H_
|
||||
#define _TIME_H_
|
||||
|
||||
#include <timer.h>
|
||||
|
||||
#endif /* _TIME_H_ */
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
#ifndef _TIMER_H_
|
||||
#define _TIMER_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <io.h>
|
||||
#include <lib.h>
|
||||
|
||||
void timer_init(void);
|
||||
void timer_start(void);
|
||||
ulong timer_get_val(void);
|
||||
|
||||
void udelay(ulong us);
|
||||
void mdelay(u32 msec);
|
||||
|
||||
#endif /* _TIMER_H_ */
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
#ifndef _UT_CASE_H_
|
||||
#define _UT_CASE_H_
|
||||
|
||||
void test_math(void);
|
||||
void test_libc(void);
|
||||
void test_time(void);
|
||||
void test_multi_stage_in_stage1(void);
|
||||
void test_multi_stage_in_stage2(void);
|
||||
void test_submakefile1(void);
|
||||
void test_reserved_mem(void);
|
||||
int run_ut_in_stage1(void);
|
||||
int run_ut_in_stage2(void);
|
||||
|
||||
#endif /* ifndef _UT_CASE_H_ */
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
#ifndef __VERSION_H__
|
||||
#define __VERSION_H__
|
||||
|
||||
#define MCU_VERSION "v1.00"
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user