16#if XF_HAL_POSIX_IS_ENABLE
24#define DEV_STR_NUM (sizeof(dev_str) / sizeof(const char *))
25#define TAG "hal_posix"
36static const char *
is_prefix(
const char *substr,
const char *str);
37static bool _atoi(
const char *src, uint16_t *num);
43#define XF_HAL_TABLE_STR
44#include "../device/xf_hal_reg_table.inc"
49#define FD_TO_ID(fd) ((fd) & 0xffff)
50#define FD_TO_TYPE(fd) (((fd) >> 16) & 0xffff)
51#define TYPE_ID_TO_FD(type, id) (((type) << 16) | (id))
55int open(
const char *pathname,
int flags)
63 XF_LOGE(
TAG,
"pathname not paser to type and id");
106int ioctl(
int fd,
unsigned long request, ...)
121 va_start(args, request);
122 arg_in = va_arg(args,
void *);
133size_t write(
int fd,
const void *buf,
size_t count)
154size_t read(
int fd,
void *buf,
size_t count)
198static const char *
is_prefix(
const char *substr,
const char *str)
200 while (*substr !=
'\0') {
201 if (*substr != *str) {
210static bool _atoi(
const char *src, uint16_t *num)
214 while (*src >=
'0' && *src <=
'9') {
215 *num = *num * 10 + (*src++ -
'0');
#define BITS_CHECK(src, bits_mask)
检查变量 var 在 bits_mask 的位置上是否存在 1。
xf_err_t xf_hal_driver_close(xf_hal_dev_t *dev)
int xf_hal_driver_read(xf_hal_dev_t *dev, void *buf, size_t count)
xf_err_t xf_hal_driver_ioctl(xf_hal_dev_t *dev, uint32_t cmd, void *config)
int xf_hal_driver_write(xf_hal_dev_t *dev, const void *buf, size_t count)
uint32_t xf_hal_driver_get_flag(xf_hal_type_t type)
xf_hal_dev_t * xf_hal_device_find(xf_hal_type_t type, uint32_t id)
xf_hal_dev_t * xf_hal_driver_create(xf_hal_type_t type, uint32_t id)
enum _xf_hal_flag_t xf_hal_flag_t
xf_hal 内核配置(仅 xf_hal kernel 内部使用)。
int ioctl(int fd, unsigned long request,...)
static bool name_to_type_and_id(const char *pathname, uint16_t *type, uint16_t *id)
static bool _atoi(const char *src, uint16_t *num)
static const char * is_prefix(const char *substr, const char *str)
size_t read(int fd, void *buf, size_t count)
#define TYPE_ID_TO_FD(type, id)
size_t write(int fd, const void *buf, size_t count)
int open(const char *pathname, int flags)
static const char * dev_str[]
(暂未使用)基于 xf_hal_driver 的 posix 实现。
#define XF_LOGE(tag, format,...)