WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
oal_kernel_file.h
浏览该文件的文档.
1/*
2 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2012-2023. All rights reserved.
3 * Description: oal_kernel_file.h 的头文件
4 */
5
6#ifndef OAL_LINUX_KERNEL_FILE_H
7#define OAL_LINUX_KERNEL_FILE_H
8
9#include <linux/kernel.h>
10#include <linux/init.h>
11#include <linux/module.h>
12#include <linux/fs.h>
13#include <linux/string.h>
14#include <linux/mm.h>
15#include <linux/syscalls.h>
16#include <asm/unistd.h>
17#include <asm/uaccess.h>
18
19#ifdef __cplusplus
20#if __cplusplus
21extern "C" {
22#endif
23#endif
24
25#define OAL_KERNEL_DS KERNEL_DS
26
27/* 文件属性 */
28#define OAL_O_ACCMODE O_ACCMODE
29#define OAL_O_RDONLY O_RDONLY
30#define OAL_O_WRONLY O_WRONLY
31#define OAL_O_RDWR O_RDWR
32#define OAL_O_CREAT O_CREAT
33#define OAL_O_TRUNC O_TRUNC
34#define OAL_O_APPEND O_APPEND
35
36#define OAL_PRINT_FORMAT_LENGTH 200 /* 打印格式字符串的最大长度 */
37
38typedef struct file oal_file;
39typedef mm_segment_t oal_mm_segment_t;
40
42{
43#if defined(LINUX_VERSION_CODE) && (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
44 return get_fs();
45#else
46#ifdef CONFIG_SET_FS
47 return get_fs();
48#else
49 return force_uaccess_begin();
50#endif
51#endif
52}
53
55{
56#if defined(LINUX_VERSION_CODE) && (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
57 set_fs(fs);
58#else
59#ifdef CONFIG_SET_FS
60 set_fs(fs);
61#else
62 force_uaccess_end(fs);
63#endif
64#endif
65}
66
68{
69#if defined(LINUX_VERSION_CODE) && (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
70 oal_set_fs(get_ds());
71#else
72#ifdef CONFIG_SET_FS
73 oal_set_fs(KERNEL_DS);
74#else
75 force_uaccess_begin();
76#endif
77#endif
78}
79
81 const struct attribute_group *grp)
82{
83 return sysfs_create_group(kobj, grp);
84}
85
87 const struct attribute_group *grp)
88{
89 sysfs_remove_group(kobj, grp);
90}
91#ifdef _PRE_CONFIG_CONN_EXT_SYSFS_SUPPORT
92extern oal_kobject *oal_get_sysfs_root_object_etc(osal_void);
93extern osal_void oal_put_sysfs_root_object_etc(osal_void);
94extern oal_kobject *oal_get_sysfs_root_boot_object_etc(osal_void);
95extern oal_kobject *oal_conn_sysfs_root_obj_init_etc(osal_void);
96extern osal_void oal_conn_sysfs_root_obj_exit_etc(osal_void);
97extern osal_void oal_conn_sysfs_root_boot_obj_exit_etc(osal_void);
98#endif
99extern oal_file *oal_kernel_file_open_etc(osal_u8 *file_path, osal_s32 attribute);
101extern ssize_t oal_kernel_file_read_etc(oal_file *file, osal_u8 *buff, loff_t fsize);
102extern osal_slong oal_kernel_file_write_etc(oal_file *file, osal_u8 *buf, loff_t fsize);
103extern osal_slong oal_kernel_file_print_etc(oal_file *file, const osal_s8 *pc_fmt, ...);
104
105#ifdef __cplusplus
106#if __cplusplus
107}
108#endif
109#endif
110
111#endif /* end of oal_main */
#define OAL_INLINE
Definition driver_soc_common.h:47
INT32 ssize_t
Definition los_typedef.h:77
OAL_STATIC OAL_INLINE int oal_debug_sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp)
Definition oal_kernel_file.h:80
OAL_STATIC OAL_INLINE osal_void oal_set_ds(osal_void)
Definition oal_kernel_file.h:67
OAL_STATIC OAL_INLINE osal_void oal_debug_sysfs_remove_group(struct kobject *kobj, const struct attribute_group *grp)
Definition oal_kernel_file.h:86
oal_file * oal_kernel_file_open_etc(osal_u8 *file_path, osal_s32 attribute)
mm_segment_t oal_mm_segment_t
Definition oal_kernel_file.h:39
OAL_STATIC OAL_INLINE osal_void oal_set_fs(oal_mm_segment_t fs)
Definition oal_kernel_file.h:54
osal_slong oal_kernel_file_write_etc(oal_file *file, osal_u8 *buf, loff_t fsize)
loff_t oal_kernel_file_size_etc(oal_file *file)
ssize_t oal_kernel_file_read_etc(oal_file *file, osal_u8 *buff, loff_t fsize)
osal_slong oal_kernel_file_print_etc(oal_file *file, const osal_s8 *pc_fmt,...)
OAL_STATIC OAL_INLINE oal_mm_segment_t oal_get_fs(osal_void)
Definition oal_kernel_file.h:41
struct file oal_file
Definition oal_kernel_file.h:38
int osal_s32
Definition osal_types.h:19
long osal_slong
Definition osal_types.h:21
unsigned char osal_u8
Definition osal_types.h:11
signed char osal_s8
Definition osal_types.h:17
void osal_void
Definition osal_types.h:29
#define OAL_STATIC
Definition soc_wifi_service_api.c:30