初版
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
#ifndef CHRDEV_H
|
||||
#define CHRDEV_H
|
||||
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/list.h"
|
||||
//#include "generic/ioctl.h"
|
||||
#include "generic/atomic.h"
|
||||
//#include "sys/task.h"
|
||||
#include "device/ioctl_cmds.h"
|
||||
|
||||
|
||||
struct dev_node;
|
||||
struct device;
|
||||
|
||||
|
||||
/**@struct device_operations
|
||||
* @brief device_operations结构体 \n
|
||||
* otg设备执行哪种类型的操作
|
||||
*/
|
||||
struct device_operations {
|
||||
bool (*online)(const struct dev_node *node); ///<设备在线状态查询
|
||||
int (*init)(const struct dev_node *node, void *); ///<设备初始化
|
||||
int (*open)(const char *name, struct device **device, void *arg); ///<设备开启
|
||||
int (*read)(struct device *device, void *buf, u32 len, u32); ///<读操作
|
||||
int (*write)(struct device *device, void *buf, u32 len, u32); ///<写操作
|
||||
int (*seek)(struct device *device, u32 offset, int orig); ///<设备搜索
|
||||
int (*ioctl)(struct device *device, u32 cmd, u32 arg); ///<I/O控制
|
||||
int (*close)(struct device *device); ///<设备关闭
|
||||
};
|
||||
|
||||
struct dev_node {
|
||||
const char *name;
|
||||
const struct device_operations *ops;
|
||||
void *priv_data;
|
||||
};
|
||||
|
||||
|
||||
struct device {
|
||||
atomic_t ref;
|
||||
void *private_data;
|
||||
const struct device_operations *ops;
|
||||
void *platform_data;
|
||||
void *driver_data;
|
||||
};
|
||||
|
||||
|
||||
#define REGISTER_DEVICE(node) \
|
||||
const struct dev_node node sec(.device)
|
||||
|
||||
#define REGISTER_DEVICES(node) \
|
||||
const struct dev_node node[] sec(.device)
|
||||
|
||||
|
||||
int devices_init();
|
||||
|
||||
bool dev_online(const char *name);
|
||||
|
||||
void *dev_open(const char *name, void *arg);
|
||||
|
||||
|
||||
int dev_read(void *device, void *buf, u32 len);
|
||||
|
||||
|
||||
int dev_write(void *device, void *buf, u32 len);
|
||||
|
||||
|
||||
int dev_seek(void *device, u32 offset, int orig);
|
||||
|
||||
|
||||
int dev_ioctl(void *device, int cmd, u32 arg);
|
||||
|
||||
|
||||
int dev_close(void *device);
|
||||
|
||||
|
||||
int dev_bulk_read(void *_device, void *buf, u32 offset, u32 len);
|
||||
|
||||
int dev_bulk_write(void *_device, void *buf, u32 offset, u32 len);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
#ifndef IOCTL_INF_H
|
||||
#define IOCTL_INF_H
|
||||
|
||||
|
||||
|
||||
|
||||
#define IOCTL_SET_IRQ_NUM 1
|
||||
#define IOCTL_SET_PRIORITY 2
|
||||
#define IOCTL_SET_DATA_WIDTH 3
|
||||
#define IOCTL_SET_SPEED 4
|
||||
#define IOCTL_SET_DETECT_MODE 5
|
||||
#define IOCTL_SET_DETECT_FUNC 6
|
||||
#define IOCTL_SET_DETECT_TIME_INTERVAL 7
|
||||
#define IOCTL_SET_PORT 8
|
||||
#define IOCTL_SET_PORT_FUNC 9
|
||||
#define IOCTL_SET_CS_PORT_FUNC 10
|
||||
#define IOCTL_SET_READ_MODE 11
|
||||
#define IOCTL_SET_WRITE_MODE 12
|
||||
#define IOCTL_SET_WRITE_PROTECT 13
|
||||
#define IOCTL_SET_START_BIT 14
|
||||
#define IOCTL_SET_STOP_BIT 15
|
||||
#define IOCTL_FLUSH 16
|
||||
#define IOCTL_REGISTER_IRQ_HANDLER 17
|
||||
#define IOCTL_UNREGISTER_IRQ_HANDLER 18
|
||||
#define IOCTL_GET_SYS_TIME 19
|
||||
#define IOCTL_SET_SYS_TIME 20
|
||||
#define IOCTL_GET_ALARM 21
|
||||
#define IOCTL_SET_ALARM 22
|
||||
#define IOCTL_SET_CAP_LOWSPEED_CARD 23
|
||||
#define IOCTL_SET_VDD50_EN 30
|
||||
#define IOCTL_GET_WEEKDAY 32
|
||||
#define IOCTL_CLR_READ_MODE 33
|
||||
#define IOCTL_SET_READ_CRC 34
|
||||
#define IOCTL_GET_READ_CRC 35
|
||||
#define IOCTL_GET_VOLUME 36
|
||||
#define IOCTL_SET_VOLUME 37
|
||||
#define IOCTL_SET_ALARM_ENABLE 38
|
||||
#define IOCTL_CMD_RESUME 39
|
||||
#define IOCTL_CMD_SUSPEND 40
|
||||
#define IOCTL_SET_BASE_ADDR 41
|
||||
#define IOCTL_SET_ASYNC_MODE 42
|
||||
#define IOCTL_GET_SPEED 43
|
||||
#define IOCTL_SET_ACTIVE_STATUS 44
|
||||
#define IOCTL_POWER_RESUME 45
|
||||
#define IOCTL_POWER_SUSPEND 46
|
||||
|
||||
|
||||
#define IOCTL_GET_ID 100
|
||||
#define IOCTL_GET_SECTOR_SIZE 101
|
||||
#define IOCTL_GET_BLOCK_SIZE 102
|
||||
#define IOCTL_GET_CAPACITY 103
|
||||
#define IOCTL_GET_WIDTH 104
|
||||
#define IOCTL_GET_HEIGHT 105
|
||||
#define IOCTL_GET_BLOCK_NUMBER 106
|
||||
#define IOCTL_CHECK_WRITE_PROTECT 107
|
||||
#define IOCTL_GET_STATUS 108
|
||||
#define IOCTL_GET_TYPE 109
|
||||
#define IOCTL_GET_MAX_LUN 110
|
||||
#define IOCTL_GET_CUR_LUN 111
|
||||
#define IOCTL_SET_CUR_LUN 112
|
||||
#define IOCTL_SET_FORCE_RESET 113
|
||||
#define IOCTL_SET_CAPACITY 114
|
||||
#define IOCTL_ENTER_4BYTE_ADDR_MODE 115
|
||||
#define IOCTL_EXIT_4BYTE_ADDR_MODE 116
|
||||
|
||||
|
||||
#define IOCTL_ERASE_SECTOR 200
|
||||
#define IOCTL_ERASE_BLOCK 201
|
||||
#define IOCTL_ERASE_CHIP 202
|
||||
#define IOCTL_SET_ENC_END 203
|
||||
#define IOCTL_ERASE_PAGE 204
|
||||
|
||||
|
||||
#define IOCTL_SET_DATA_CALLBACK 301
|
||||
|
||||
#define IOCTL_GET_PART_INFO 320
|
||||
|
||||
struct ioctl_irq_handler {
|
||||
void *priv;
|
||||
void *handler;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user