1 /*
2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 #ifndef __OAL_KERNEL_FILE_H__
19 #define __OAL_KERNEL_FILE_H__
20
21 /* ****************************************************************************
22 1 其他头文件包含
23 **************************************************************************** */
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/fs.h>
27 #include <linux/string.h>
28 #ifndef HAVE_PCLINT_CHECK
29
30 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
31 #include <linux/kobject.h>
32 #include <linux/mm.h>
33 #include <linux/init.h>
34 #include <linux/syscalls.h>
35 #include <asm/uaccess.h>
36 #endif
37 #endif
38 #include "hi_types_base.h"
39
40 #ifdef __cplusplus
41 #if __cplusplus
42 extern "C" {
43 #endif
44 #endif
45
46 /* ****************************************************************************
47 2 宏定义
48 **************************************************************************** */
49 #define OAL_KERNEL_DS KERNEL_DS
50
51 /* 文件属性 */
52 #define OAL_O_ACCMODE O_ACCMODE
53 #define OAL_O_RDONLY O_RDONLY
54 #define OAL_O_WRONLY O_WRONLY
55 #define OAL_O_RDWR O_RDWR
56 #define OAL_O_CREAT O_CREAT
57 #define OAL_O_TRUNC O_TRUNC
58 #define OAL_O_APPEND O_APPEND
59
60 #define OAL_PRINT_FORMAT_LENGTH 512 /* 打印格式字符串的最大长度 */
61
62 typedef struct file oal_file;
63 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
64 typedef mm_segment_t oal_mm_segment_t;
65 typedef struct device_attribute oal_device_attribute_stru;
66 typedef struct device oal_device_stru;
67 #endif
68 typedef struct kobject oal_kobject;
69
70 /* ****************************************************************************
71 9 OTHERS定义
72 **************************************************************************** */
73 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
oal_sysfs_create_group(oal_kobject * kobj,const struct attribute_group * grp)74 static inline hi_s32 oal_sysfs_create_group(oal_kobject *kobj, const struct attribute_group *grp)
75 {
76 return sysfs_create_group(kobj, grp);
77 }
78
oal_sysfs_remove_group(oal_kobject * kobj,const struct attribute_group * grp)79 static inline hi_void oal_sysfs_remove_group(oal_kobject *kobj, const struct attribute_group *grp)
80 {
81 sysfs_remove_group(kobj, grp);
82 }
83
oal_debug_sysfs_create_group(oal_kobject * kobj,const struct attribute_group * grp)84 static inline hi_s32 oal_debug_sysfs_create_group(oal_kobject *kobj, const struct attribute_group *grp)
85 {
86 return sysfs_create_group(kobj, grp);
87 }
88
oal_debug_sysfs_remove_group(oal_kobject * kobj,const struct attribute_group * grp)89 static inline hi_void oal_debug_sysfs_remove_group(oal_kobject *kobj, const struct attribute_group *grp)
90 {
91 sysfs_remove_group(kobj, grp);
92 }
93 #endif
94
95 /* ****************************************************************************
96 10 函数声明
97 **************************************************************************** */
98 #ifdef _PRE_CONFIG_CONN_HISI_SYSFS_SUPPORT
99 extern oal_kobject *oal_get_sysfs_root_object(hi_void);
100 extern oal_kobject *oal_get_sysfs_root_boot_object(hi_void);
101 extern oal_kobject *oal_conn_sysfs_root_obj_init(hi_void);
102 extern hi_void oal_conn_sysfs_root_obj_exit(hi_void);
103 extern hi_void oal_conn_sysfs_root_boot_obj_exit(hi_void);
104 #endif
105
106 #ifdef __cplusplus
107 #if __cplusplus
108 }
109 #endif
110 #endif
111
112 #endif /* end of oal_main */
113