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

浏览源代码.

函数

static int PowerLockWrite (struct ProcFile *pf, const char *buf, size_t count, loff_t *ppos)
 
static int PowerLockRead (struct SeqBuf *m, void *v)
 读取电源锁信息 更多...
 
static int PowerUnlockWrite (struct ProcFile *pf, const char *buf, size_t count, loff_t *ppos)
 
static int PowerModeWrite (struct ProcFile *pf, const char *buf, size_t count, loff_t *ppos)
 
static int PowerModeRead (struct SeqBuf *m, void *v)
 
static int PowerCountRead (struct SeqBuf *m, void *v)
 
static int PowerCountWrite (struct ProcFile *pf, const char *buf, size_t count, loff_t *ppos)
 
void ProcPmInit (void)
 

变量

static const struct ProcFileOperations PowerLock
 proc 拿电源锁操作 更多...
 
static const struct ProcFileOperations PowerUnlock
 
static const struct ProcFileOperations PowerMode
 
static const struct ProcFileOperations PowerCount
 

函数说明

◆ PowerCountRead()

static int PowerCountRead ( struct SeqBuf m,
void v 
)
static

在文件 power_proc.c115 行定义.

116{
117 (void)v;
118 UINT32 count = LOS_PmReadLock();
119
120 LosBufPrintf(m, "%u\n", count);
121 return 0;
122}
UINT32 LOS_PmReadLock(VOID)
Gets the current PM lock status.
Definition: los_pm.c:664
int LosBufPrintf(struct SeqBuf *seqBuf, const char *fmt,...)
支持可变参数 写 buf
Definition: los_seq_buf.c:133
unsigned int UINT32
Definition: los_typedef.h:57
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
函数调用图:

◆ PowerCountWrite()

static int PowerCountWrite ( struct ProcFile pf,
const char *  buf,
size_t  count,
loff_t *  ppos 
)
static

在文件 power_proc.c124 行定义.

125{
126 (void)pf;
127 (void)count;
128 (void)ppos;
129
130 int weakCount;
131
132 if (buf == NULL) {
133 return 0;
134 }
135
136 weakCount = atoi(buf);
137 return -LOS_PmSuspend(weakCount);
138}
UINT32 LOS_PmSuspend(UINT32 wakeCount)
The system enters the low-power flow.
Definition: los_pm.c:674
函数调用图:

◆ PowerLockRead()

static int PowerLockRead ( struct SeqBuf m,
void v 
)
static

读取电源锁信息

在文件 power_proc.c48 行定义.

49{
50 (void)v;
51
53 return 0;
54}
VOID LOS_PmLockInfoShow(struct SeqBuf *m)
显示所有电源锁信息
Definition: los_pm.c:455
函数调用图:

◆ PowerLockWrite()

static int PowerLockWrite ( struct ProcFile pf,
const char *  buf,
size_t  count,
loff_t *  ppos 
)
static

在文件 power_proc.c40 行定义.

41{
42 (void)pf;
43 (void)count;
44 (void)ppos;
45 return -LOS_PmLockRequest(buf);
46}
UINT32 LOS_PmLockRequest(const CHAR *name)
Request to obtain the lock in current mode, so that the system will not enter this mode when it enter...
Definition: los_pm.c:543
函数调用图:

◆ PowerModeRead()

static int PowerModeRead ( struct SeqBuf m,
void v 
)
static

在文件 power_proc.c102 行定义.

103{
104 (void)v;
105
106 LosBufPrintf(m, "normal light deep shutdown\n");
107 return 0;
108}
函数调用图:

◆ PowerModeWrite()

static int PowerModeWrite ( struct ProcFile pf,
const char *  buf,
size_t  count,
loff_t *  ppos 
)
static

在文件 power_proc.c74 行定义.

75{
76 (void)pf;
77 (void)count;
78 (void)ppos;
79
81
82 if (buf == NULL) {
83 return 0;
84 }
85
86 if (strcmp(buf, "normal") == 0) {
88 } else if (strcmp(buf, "light") == 0) {
90 } else if (strcmp(buf, "deep") == 0) {
91 mode = LOS_SYS_DEEP_SLEEP;
92 } else if (strcmp(buf, "shutdown") == 0) {
93 mode = LOS_SYS_SHUTDOWN;
94 } else {
95 PRINT_ERR("Unsupported hibernation mode: %s\n", buf);
96 return -EINVAL;
97 }
98
99 return -LOS_PmModeSet(mode);
100}
UINT32 LOS_PmModeSet(LOS_SysSleepEnum mode)
Set low power mode.
Definition: los_pm.c:411
LOS_SysSleepEnum
Definition: los_pm.h:41
@ LOS_SYS_DEEP_SLEEP
Definition: los_pm.h:44
@ LOS_SYS_LIGHT_SLEEP
Definition: los_pm.h:43
@ LOS_SYS_SHUTDOWN
Definition: los_pm.h:45
@ LOS_SYS_NORMAL_SLEEP
Definition: los_pm.h:42
函数调用图:

◆ PowerUnlockWrite()

static int PowerUnlockWrite ( struct ProcFile pf,
const char *  buf,
size_t  count,
loff_t *  ppos 
)
static

在文件 power_proc.c61 行定义.

62{
63 (void)pf;
64 (void)count;
65 (void)ppos;
66 return -LOS_PmLockRelease(buf);
67}
UINT32 LOS_PmLockRelease(const CHAR *name)
Release the lock in current mode so that the next time the system enters the idle task,...
Definition: los_pm.c:552
函数调用图:

◆ ProcPmInit()

void ProcPmInit ( void  )

在文件 power_proc.c148 行定义.

149{
150 struct ProcDirEntry *power = CreateProcEntry("power", S_IFDIR | S_IRWXU | S_IRWXG | S_IROTH, NULL);
151 if (power == NULL) {//创建 文件夹 /proc/power
152 PRINT_ERR("create /proc/power error!\n");
153 return;
154 }
155 power->uid = OS_POWER_PRIVILEGE;
156 power->gid = OS_POWER_PRIVILEGE;
157
158 struct ProcDirEntry *mode = CreateProcEntry("power/power_mode", POWER_FILE_MODE, NULL);
159 if (mode == NULL) {//创建 文件夹 /proc/power/power_mode
160 PRINT_ERR("create /proc/power/power_mode error!\n");
161 goto FREE_POWER;
162 }
163 mode->procFileOps = &PowerMode;
164 mode->uid = OS_POWER_PRIVILEGE;
165 mode->gid = OS_POWER_PRIVILEGE;
166
167 struct ProcDirEntry *lock = CreateProcEntry("power/power_lock", POWER_FILE_MODE, NULL);
168 if (lock == NULL) {//创建 文件夹 /proc/power/power_lock
169 PRINT_ERR("create /proc/power/power_lock error!\n");
170 goto FREE_MODE;
171 }
172 lock->procFileOps = &PowerLock;
173 lock->uid = OS_POWER_PRIVILEGE;
174 lock->gid = OS_POWER_PRIVILEGE;
175
176 struct ProcDirEntry *unlock = CreateProcEntry("power/power_unlock", POWER_FILE_MODE, NULL);
177 if (unlock == NULL) {//创建 文件夹 /proc/power/power_unlock
178 PRINT_ERR("create /proc/power/power_unlock error!\n");
179 goto FREE_LOCK;
180 }
181 unlock->procFileOps = &PowerUnlock;
182 unlock->uid = OS_POWER_PRIVILEGE;
183 unlock->gid = OS_POWER_PRIVILEGE;
184
185 struct ProcDirEntry *count = CreateProcEntry("power/power_count", S_IRUSR | S_IRGRP | S_IROTH, NULL);
186 if (count == NULL) {//创建 文件夹 /proc/power/power_count
187 PRINT_ERR("create /proc/power/power_count error!\n");
188 goto FREE_UNLOCK;
189 }
190 count->procFileOps = &PowerCount;
191 count->uid = OS_POWER_PRIVILEGE;
192 count->gid = OS_POWER_PRIVILEGE;
193
194 return;
195
196FREE_UNLOCK:
197 ProcFreeEntry(unlock);
198FREE_LOCK:
199 ProcFreeEntry(lock);
200FREE_MODE:
202FREE_POWER:
203 ProcFreeEntry(power);
204 return;
205}
void ProcFreeEntry(struct ProcDirEntry *pde)
释放
Definition: proc_file.c:388
static const struct ProcFileOperations PowerLock
proc 拿电源锁操作
Definition: power_proc.c:56
static const struct ProcFileOperations PowerUnlock
Definition: power_proc.c:69
static const struct ProcFileOperations PowerMode
Definition: power_proc.c:110
static const struct ProcFileOperations PowerCount
Definition: power_proc.c:140
struct ProcDirEntry * CreateProcEntry(const char *name, mode_t mode, struct ProcDirEntry *parent)
create a proc node
Definition: proc_file.c:364
proc 目录/文件项, @notethinking 直接叫 ProcEntry不香吗 ? 操作 /proc的 真正结构体
Definition: proc_fs.h:101
uint uid
Definition: proc_fs.h:102
atomic_t count
Definition: proc_fs.h:110
const struct ProcFileOperations * procFileOps
驱动程序,每个 /proc 下目录的驱动程序都不一样
Definition: proc_fs.h:106
mode_t mode
模式(读|写...)
Definition: proc_fs.h:104
uint gid
Definition: proc_fs.h:103
函数调用图:
这是这个函数的调用关系图:

变量说明

◆ PowerCount

const struct ProcFileOperations PowerCount
static
初始值:
= {
.write = PowerCountWrite,
.read = PowerCountRead,
}
static int PowerCountWrite(struct ProcFile *pf, const char *buf, size_t count, loff_t *ppos)
Definition: power_proc.c:124
static int PowerCountRead(struct SeqBuf *m, void *v)
Definition: power_proc.c:115

在文件 power_proc.c140 行定义.

◆ PowerLock

const struct ProcFileOperations PowerLock
static
初始值:
= {
.write = PowerLockWrite,
.read = PowerLockRead,
}
static int PowerLockWrite(struct ProcFile *pf, const char *buf, size_t count, loff_t *ppos)
Definition: power_proc.c:40
static int PowerLockRead(struct SeqBuf *m, void *v)
读取电源锁信息
Definition: power_proc.c:48

proc 拿电源锁操作

在文件 power_proc.c56 行定义.

◆ PowerMode

const struct ProcFileOperations PowerMode
static
初始值:
= {
.write = PowerModeWrite,
.read = PowerModeRead,
}
static int PowerModeRead(struct SeqBuf *m, void *v)
Definition: power_proc.c:102
static int PowerModeWrite(struct ProcFile *pf, const char *buf, size_t count, loff_t *ppos)
Definition: power_proc.c:74

在文件 power_proc.c110 行定义.

◆ PowerUnlock

const struct ProcFileOperations PowerUnlock
static
初始值:
= {
.write = PowerUnlockWrite,
.read = PowerLockRead,
}
static int PowerUnlockWrite(struct ProcFile *pf, const char *buf, size_t count, loff_t *ppos)
Definition: power_proc.c:61

在文件 power_proc.c69 行定义.