更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
quickstart.c 文件参考

浏览源代码.

函数

static int QuickstartOpen (struct file *filep)
 
static int QuickstartClose (struct file *filep)
 
static int QuickstartNotify (unsigned int events)
 
static int QuickstartListen (unsigned long arg)
 
void QuickstartHookRegister (LosSysteminitHook hooks)
 
static int QuickstartStageWorking (unsigned int level)
 
static int QuickstartDevUnlink (struct Vnode *node)
 
static ssize_t QuickstartIoctl (struct file *filep, int cmd, unsigned long arg)
 快速开始控制器 更多...
 
int QuickstartDevRegister (void)
 

变量

EVENT_CB_S g_qsEvent
 
static SysteminitHook g_systemInitFunc [QS_STAGE_CNT] = {0}
 
static char g_callOnce [QS_STAGE_CNT] = {0}
 
static const struct file_operations_vfs g_quickstartDevOps
 

函数说明

◆ QuickstartClose()

static int QuickstartClose ( struct file filep)
static

在文件 quickstart.c48 行定义.

49{
50 return 0;
51}

◆ QuickstartDevRegister()

int QuickstartDevRegister ( void  )

在文件 quickstart.c137 行定义.

138{
139 LOS_EventInit(&g_qsEvent);//初始化 g_qsEvent
140 return register_driver(QUICKSTART_NODE, &g_quickstartDevOps, 0644, 0); /* 0644: file mode */
141}
LITE_OS_SEC_TEXT_INIT UINT32 LOS_EventInit(PEVENT_CB_S eventCB)
初始化一个事件控制块
Definition: los_event.c:95
static const struct file_operations_vfs g_quickstartDevOps
Definition: quickstart.c:130
EVENT_CB_S g_qsEvent
Definition: quickstart.c:39
函数调用图:

◆ QuickstartDevUnlink()

static int QuickstartDevUnlink ( struct Vnode node)
static

在文件 quickstart.c102 行定义.

103{
104 (void)node;
105 return unregister_driver(QUICKSTART_NODE);
106}
ARG_NUM_3 ARG_NUM_1 ARG_NUM_2 ARG_NUM_2 ARG_NUM_3 ARG_NUM_1 ARG_NUM_4 ARG_NUM_2 ARG_NUM_2 ARG_NUM_5 ARG_NUM_2 void

◆ QuickstartHookRegister()

void QuickstartHookRegister ( LosSysteminitHook  hooks)

在文件 quickstart.c84 行定义.

85{
86 for (int i = 0; i < QS_STAGE_CNT; i++) {
87 g_systemInitFunc[i] = hooks.func[i];
88 }
89}
static SysteminitHook g_systemInitFunc[QS_STAGE_CNT]
Definition: quickstart.c:40
SysteminitHook func[QS_STAGE_CNT]

◆ QuickstartIoctl()

static ssize_t QuickstartIoctl ( struct file filep,
int  cmd,
unsigned long  arg 
)
static

快速开始控制器

在文件 quickstart.c108 行定义.

109{
110 ssize_t ret;
111 if (cmd == QUICKSTART_NOTIFY) {//通知模式
112 return QuickstartNotify(arg);
113 }
114
116 PRINT_ERR("Permission denios!\n");
117 return -EACCES;
118 }
119 switch (cmd) {
120 case QUICKSTART_LISTEN://监听模式
121 ret = QuickstartListen(arg);
122 break;
123 default:
124 ret = QuickstartStageWorking(cmd - QUICKSTART_STAGE(QS_STAGE1)); /* ioctl cmd converted to stage level */
125 break;
126 }
127 return ret;
128}
@ QS_STAGE1
LITE_OS_SEC_TEXT UINT32 OsGetUserInitProcessID(VOID)
获取用户态进程的根进程,所有用户进程都是g_processCBArray[g_userInitProcess] fork来的
Definition: los_process.c:2244
LITE_OS_SEC_TEXT UINT32 LOS_GetCurrProcessID(VOID)
获取当前进程的进程ID
Definition: los_process.c:2161
INT64 ssize_t
Definition: los_typedef.h:79
static int QuickstartNotify(unsigned int events)
Definition: quickstart.c:53
static int QuickstartStageWorking(unsigned int level)
Definition: quickstart.c:91
static int QuickstartListen(unsigned long arg)
Definition: quickstart.c:65
函数调用图:

◆ QuickstartListen()

static int QuickstartListen ( unsigned long  arg)
static

在文件 quickstart.c65 行定义.

66{
68 if (copy_from_user(&args, (QuickstartListenArgs __user *)arg, sizeof(QuickstartListenArgs)) != LOS_OK) {
69 PRINT_ERR("%s,%d,failed!\n", __FUNCTION__, __LINE__);
70 return -EINVAL;
71 }
72 if (args.wait > WAITLIMIT) {
73 args.wait = WAITLIMIT;
74 PRINT_ERR("%s wait arg is too longer, set to WAITLIMIT!\n", __FUNCTION__);
75 }
76 int ret = LOS_EventRead((PEVENT_CB_S)&g_qsEvent, args.events, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, args.wait);
77 if (ret != args.events && ret != 0) { /* 0: nowait is normal case */
78 PRINT_ERR("%s,%d:0x%x\n", __FUNCTION__, __LINE__, ret);
79 ret = -EINVAL;
80 }
81 return ret;
82}
LITE_OS_SEC_TEXT UINT32 LOS_EventRead(PEVENT_CB_S eventCB, UINT32 eventMask, UINT32 mode, UINT32 timeout)
读取指定事件类型,超时时间为相对时间:单位为Tick
Definition: los_event.c:313
函数调用图:
这是这个函数的调用关系图:

◆ QuickstartNotify()

static int QuickstartNotify ( unsigned int  events)
static

在文件 quickstart.c53 行定义.

54{
55 int ret = LOS_EventWrite((PEVENT_CB_S)&g_qsEvent, events);
56 if (ret != 0) {
57 PRINT_ERR("%s,%d:0x%x\n", __FUNCTION__, __LINE__, ret);
58 ret = -EINVAL;
59 }
60 return ret;
61}
LITE_OS_SEC_TEXT UINT32 LOS_EventWrite(PEVENT_CB_S eventCB, UINT32 events)
写指定的事件类型
Definition: los_event.c:318
函数调用图:
这是这个函数的调用关系图:

◆ QuickstartOpen()

static int QuickstartOpen ( struct file filep)
static

在文件 quickstart.c43 行定义.

44{
45 return 0;
46}

◆ QuickstartStageWorking()

static int QuickstartStageWorking ( unsigned int  level)
static

在文件 quickstart.c91 行定义.

92{
93 if ((level < QS_STAGE_CNT) && (g_callOnce[level] == 0) && (g_systemInitFunc[level] != NULL)) {
94 g_callOnce[level] = 1; /* 1: Already called */
95 g_systemInitFunc[level]();
96 } else {
97 PRINT_WARN("Trigger quickstart,but doing nothing!!\n");
98 }
99 return 0;
100}
static char g_callOnce[QS_STAGE_CNT]
Definition: quickstart.c:41
这是这个函数的调用关系图:

变量说明

◆ g_callOnce

char g_callOnce[QS_STAGE_CNT] = {0}
static

在文件 quickstart.c41 行定义.

◆ g_qsEvent

EVENT_CB_S g_qsEvent

在文件 quickstart.c39 行定义.

◆ g_quickstartDevOps

const struct file_operations_vfs g_quickstartDevOps
static
初始值:
= {
.open = QuickstartOpen,
.close = QuickstartClose,
.ioctl = QuickstartIoctl,
.unlink = QuickstartDevUnlink,
}
static int QuickstartClose(struct file *filep)
Definition: quickstart.c:48
static ssize_t QuickstartIoctl(struct file *filep, int cmd, unsigned long arg)
快速开始控制器
Definition: quickstart.c:108
static int QuickstartDevUnlink(struct Vnode *node)
Definition: quickstart.c:102
static int QuickstartOpen(struct file *filep)
Definition: quickstart.c:43

在文件 quickstart.c130 行定义.

◆ g_systemInitFunc

SysteminitHook g_systemInitFunc[QS_STAGE_CNT] = {0}
static

在文件 quickstart.c40 行定义.