WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
los_driverbase.h
浏览该文件的文档.
1/* ---------------------------------------------------------------------------
2 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
3 * Description: Driver Framework Header File
4 * Author: Huawei LiteOS Team
5 * Create: 2020-08-15
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 * to endorse or promote products derived from this software without specific prior written
15 * permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * --------------------------------------------------------------------------- */
28
36#ifndef _LOS_DRIVER_BASE_H
37#define _LOS_DRIVER_BASE_H
38
39#include "los_mux.h"
40
41struct LosDriver;
43
53
64
82
89 INT32 (*suspend)(struct LosDevice *device);
90 INT32 (*resume)(struct LosDevice *device);
91 INT32 (*prepare)(struct LosDevice *device);
92 INT32 (*complete)(struct LosDevice *device);
93};
94
101 INT32 (*probe)(struct LosDevice *device);
102 INT32 (*remove)(struct LosDevice *device);
103 VOID (*shutdown)(struct LosDevice *device);
104};
105
120
121/* errno */
130#define LOS_ERRNO_DRIVER_INPUT_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_DRIVER, 0x10)
131
140#define LOS_ERRNO_DRIVER_MUX_FAIL LOS_ERRNO_OS_ERROR(LOS_MOD_DRIVER, 0x11)
141
150#define LOS_ERRNO_DRIVER_DRIVER_MATCH_FAIL LOS_ERRNO_OS_ERROR(LOS_MOD_DRIVER, 0x20)
151
160#define LOS_ERRNO_DRIVER_DRIVER_PROBE_FAIL LOS_ERRNO_OS_ERROR(LOS_MOD_DRIVER, 0x21)
161
170#define LOS_ERRNO_DRIVER_DRIVER_REGISTERED LOS_ERRNO_OS_ERROR(LOS_MOD_DRIVER, 0x22)
171
180#define LOS_ERRNO_DRIVER_DRIVER_NOTFOUND LOS_ERRNO_OS_ERROR(LOS_MOD_DRIVER, 0x23)
181
190#define LOS_ERRNO_DRIVER_DEVICE_BOUNDED LOS_ERRNO_OS_ERROR(LOS_MOD_DRIVER, 0x30)
191
200#define LOS_ERRNO_DRIVER_DEVICE_INITIALFAIL LOS_ERRNO_OS_ERROR(LOS_MOD_DRIVER, 0x31)
201
210#define LOS_ERRNO_DRIVER_DEVICE_REGISTERED LOS_ERRNO_OS_ERROR(LOS_MOD_DRIVER, 0x32)
211
220#define LOS_ERRNO_DRIVER_DEVICE_BUSY LOS_ERRNO_OS_ERROR(LOS_MOD_DRIVER, 0x33)
221
222/* driver api */
248
270
271/* device api */
295
311
327VOID *LOS_DeviceDataGet(const struct LosDevice *dev);
328
347
366
383
400
417
439#define LOS_FOREACH_DEVICE_LIST_HOOK(device, list, hook) \
440 LOS_DL_LIST_FOR_EACH_ENTRY_HOOK(device, list, struct LosDevice, driverNode, hook)
441
462#define LOS_FOREACH_DEVICE_HOOK(device, hook) \
463 LOS_DL_LIST_FOR_EACH_ENTRY_HOOK(device, &g_deviceList, struct LosDevice, deviceItem, hook)
464
485#define LOS_FOREACH_DEVICE_BY_DRIVER(device, driver) \
486 LOS_FOREACH_DEVICE_LIST_HOOK(device, &(driver)->deviceList, NULL)
487
507#define LOS_FOREACH_DEVICE(device) \
508 LOS_FOREACH_DEVICE_HOOK(device, NULL)
509
510#endif
UINTPTR LOS_DeviceRegBaseGet(const struct LosDevice *dev, UINT32 index)
get register base address form a device.
UINTPTR LOS_DeviceRegSizeGet(const struct LosDevice *dev, UINT32 index)
get register size form a device.
UINT32 LOS_DriverUnregister(struct LosDriver *drv)
unregister a driver from the system.
UINTPTR LOS_DeviceIrqNumGet(const struct LosDevice *dev)
get interrupt number form a device.
VOID LOS_PmResume(VOID)
resume all devices in suspendedList.
void LOS_DeviceUnregister(struct LosDevice *dev)
unregister a device from the system.
UINT32 LOS_DriverRegister(struct LosDriver *drv)
register a new driver to the system.
UINT32 LOS_DeviceRegister(struct LosDevice *dev)
register a new device to the system.
VOID * LOS_DeviceDataGet(const struct LosDevice *dev)
get data form a device.
INT32 LOS_PmSuspend(VOID)
suspend all devices in preparedList.
LOS_DL_LIST g_deviceList
signed int INT32
Definition los_typedef.h:55
#define VOID
Definition los_typedef.h:88
unsigned int UINTPTR
Definition los_typedef.h:74
unsigned int UINT32
Definition los_typedef.h:52
char CHAR
Definition los_typedef.h:58
size_t BOOL
Definition los_typedef.h:83
Definition los_list.h:47
Definition los_driverbase.h:59
UINT32 numRegs
Definition los_driverbase.h:61
struct LosDeviceRegs * regs
Definition los_driverbase.h:62
UINTPTR irqNum
Definition los_driverbase.h:60
Definition los_driverbase.h:49
UINTPTR size
Definition los_driverbase.h:51
UINTPTR base
Definition los_driverbase.h:50
Definition los_driverbase.h:70
UINT32 mutex
Definition los_driverbase.h:76
const CHAR * name
Definition los_driverbase.h:71
BOOL isRegistered
Definition los_driverbase.h:77
LOS_DL_LIST deviceItem
Definition los_driverbase.h:74
LOS_DL_LIST pmNode
Definition los_driverbase.h:75
VOID * data
Definition los_driverbase.h:80
INT32 id
Definition los_driverbase.h:72
struct LosDriver * driver
Definition los_driverbase.h:78
struct LosDeviceConfig cfg
Definition los_driverbase.h:79
LOS_DL_LIST driverNode
Definition los_driverbase.h:73
Definition los_driverbase.h:100
VOID(* shutdown)(struct LosDevice *device)
Definition los_driverbase.h:103
INT32(* remove)(struct LosDevice *device)
Definition los_driverbase.h:102
INT32(* probe)(struct LosDevice *device)
Definition los_driverbase.h:101
Definition los_driverbase.h:111
BOOL isRegistered
Definition los_driverbase.h:116
LOS_DL_LIST deviceList
Definition los_driverbase.h:113
UINT32 mutex
Definition los_driverbase.h:115
LOS_DL_LIST driverItem
Definition los_driverbase.h:114
struct LosPowerMgrOps pmOps
Definition los_driverbase.h:118
struct LosDriverOps ops
Definition los_driverbase.h:117
const CHAR * name
Definition los_driverbase.h:112
Definition los_driverbase.h:88
INT32(* complete)(struct LosDevice *device)
Definition los_driverbase.h:92
INT32(* resume)(struct LosDevice *device)
Definition los_driverbase.h:90
INT32(* prepare)(struct LosDevice *device)
Definition los_driverbase.h:91
INT32(* suspend)(struct LosDevice *device)
Definition los_driverbase.h:89