commit
8d419bb029
|
@ -49,21 +49,19 @@ typedef enum {
|
||||||
} QuickstartStage;
|
} QuickstartStage;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
QS_UNREGISTER = QS_STAGE_LIMIT, /* quickstart dev unregister */
|
QS_NOTIFY = QS_STAGE_LIMIT, /* quickstart notify */
|
||||||
QS_NOTIFY, /* quickstart notify */
|
QS_LISTEN, /* quickstart listen */
|
||||||
QS_LISTEN, /* quickstart listen */
|
|
||||||
QS_CTL_LIMIT
|
QS_CTL_LIMIT
|
||||||
} QuickstartConctrl;
|
} QuickstartConctrl;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int pid;
|
|
||||||
unsigned int events;
|
unsigned int events;
|
||||||
} QuickstartMask;
|
unsigned int wait;
|
||||||
|
} QuickstartListenArgs;
|
||||||
|
|
||||||
#define QUICKSTART_IOC_MAGIC 'T'
|
#define QUICKSTART_IOC_MAGIC 'T'
|
||||||
#define QUICKSTART_UNREGISTER _IO(QUICKSTART_IOC_MAGIC, QS_UNREGISTER)
|
|
||||||
#define QUICKSTART_NOTIFY _IO(QUICKSTART_IOC_MAGIC, QS_NOTIFY)
|
#define QUICKSTART_NOTIFY _IO(QUICKSTART_IOC_MAGIC, QS_NOTIFY)
|
||||||
#define QUICKSTART_LISTEN _IOR(QUICKSTART_IOC_MAGIC, QS_LISTEN, QuickstartMask)
|
#define QUICKSTART_LISTEN _IOR(QUICKSTART_IOC_MAGIC, QS_LISTEN, QuickstartListenArgs)
|
||||||
#define QUICKSTART_STAGE(x) _IO(QUICKSTART_IOC_MAGIC, (x))
|
#define QUICKSTART_STAGE(x) _IO(QUICKSTART_IOC_MAGIC, (x))
|
||||||
|
|
||||||
#define QUICKSTART_NODE "/dev/quickstart"
|
#define QUICKSTART_NODE "/dev/quickstart"
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include "fcntl.h"
|
#include "fcntl.h"
|
||||||
#include "linux/kernel.h"
|
#include "linux/kernel.h"
|
||||||
#include "los_process_pri.h"
|
#include "los_process_pri.h"
|
||||||
|
#include "fs/fs.h"
|
||||||
|
|
||||||
EVENT_CB_S g_qsEvent;
|
EVENT_CB_S g_qsEvent;
|
||||||
static SysteminitHook g_systemInitFunc[QS_STAGE_CNT] = {0};
|
static SysteminitHook g_systemInitFunc[QS_STAGE_CNT] = {0};
|
||||||
|
@ -51,10 +51,7 @@ static int QuickstartClose(struct file *filep)
|
||||||
|
|
||||||
static int QuickstartNotify(unsigned int events)
|
static int QuickstartNotify(unsigned int events)
|
||||||
{
|
{
|
||||||
unsigned int pid = LOS_GetCurrProcessID();
|
int ret = LOS_EventWrite((PEVENT_CB_S)&g_qsEvent, events);
|
||||||
/* 16:low 16 bits for eventMask, high 16 bits for pid */
|
|
||||||
unsigned int notifyEvent = (pid << 16) | events;
|
|
||||||
int ret = LOS_EventWrite((PEVENT_CB_S)&g_qsEvent, notifyEvent);
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
PRINT_ERR("%s,%d:0x%x\n", __FUNCTION__, __LINE__, ret);
|
PRINT_ERR("%s,%d:0x%x\n", __FUNCTION__, __LINE__, ret);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
@ -62,17 +59,21 @@ static int QuickstartNotify(unsigned int events)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define WAITLIMIT 300000 /* 5min = 5*60*1000*1tick(1ms) */
|
||||||
|
|
||||||
static int QuickstartListen(unsigned long arg)
|
static int QuickstartListen(unsigned long arg)
|
||||||
{
|
{
|
||||||
QuickstartMask listenMask;
|
QuickstartListenArgs args;
|
||||||
if (copy_from_user(&listenMask, (struct QuickstartMask __user *)arg, sizeof(QuickstartMask)) != LOS_OK) {
|
if (copy_from_user(&args, (QuickstartListenArgs __user *)arg, sizeof(QuickstartListenArgs)) != LOS_OK) {
|
||||||
PRINT_ERR("%s,%d\n", __FUNCTION__, __LINE__);
|
PRINT_ERR("%s,%d,failed!\n", __FUNCTION__, __LINE__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
/* 16:low 16 bits for eventMask, high 16 bits for pid */
|
if (args.wait > WAITLIMIT) {
|
||||||
unsigned int mask = (listenMask.pid << 16) | listenMask.events;
|
args.wait = WAITLIMIT;
|
||||||
int ret = LOS_EventRead((PEVENT_CB_S)&g_qsEvent, mask, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
|
PRINT_ERR("%s wait arg is too longer, set to WAITLIMIT!\n", __FUNCTION__);
|
||||||
if (ret != mask) {
|
}
|
||||||
|
int ret = LOS_EventRead((PEVENT_CB_S)&g_qsEvent, args.events, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, args.wait);
|
||||||
|
if (ret != args.events && ret != 0) { /* 0: nowait is normal case */
|
||||||
PRINT_ERR("%s,%d:0x%x\n", __FUNCTION__, __LINE__, ret);
|
PRINT_ERR("%s,%d:0x%x\n", __FUNCTION__, __LINE__, ret);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -97,8 +98,9 @@ static int QuickstartStageWorking(unsigned int level)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int QuickstartDevUnregister(void)
|
static int QuickstartDevUnlink(struct Vnode *node)
|
||||||
{
|
{
|
||||||
|
(void)node;
|
||||||
return unregister_driver(QUICKSTART_NODE);
|
return unregister_driver(QUICKSTART_NODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,9 +116,6 @@ static ssize_t QuickstartIoctl(struct file *filep, int cmd, unsigned long arg)
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case QUICKSTART_UNREGISTER:
|
|
||||||
ret = QuickstartDevUnregister();
|
|
||||||
break;
|
|
||||||
case QUICKSTART_LISTEN:
|
case QUICKSTART_LISTEN:
|
||||||
ret = QuickstartListen(arg);
|
ret = QuickstartListen(arg);
|
||||||
break;
|
break;
|
||||||
|
@ -128,17 +127,10 @@ static ssize_t QuickstartIoctl(struct file *filep, int cmd, unsigned long arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct file_operations_vfs g_quickstartDevOps = {
|
static const struct file_operations_vfs g_quickstartDevOps = {
|
||||||
QuickstartOpen, /* open */
|
.open = QuickstartOpen, /* open */
|
||||||
QuickstartClose, /* close */
|
.close = QuickstartClose, /* close */
|
||||||
NULL, /* read */
|
.ioctl = QuickstartIoctl, /* ioctl */
|
||||||
NULL, /* write */
|
.unlink = QuickstartDevUnlink, /* unlink */
|
||||||
NULL, /* seek */
|
|
||||||
QuickstartIoctl, /* ioctl */
|
|
||||||
NULL, /* mmap */
|
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
|
||||||
NULL, /* poll */
|
|
||||||
#endif
|
|
||||||
NULL, /* unlink */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int QuickstartDevRegister(void)
|
int QuickstartDevRegister(void)
|
||||||
|
|
Loading…
Reference in New Issue