1 // Copyright (C) 2022 Beken Corporation 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 #include <common/bk_typedef.h> 22 #include "drv_model_pub.h" 23 24 #define DRV_FAILURE ((UINT32)-5) 25 #define DRV_SUCCESS (0) 26 27 #define DD_HANDLE_UNVALID ((UINT32)-1) 28 #define DD_ID_UNVALID ((UINT32)-1) 29 30 #define sddev_register_dev(handle, ops) ddev_register_dev(handle, ops) 31 #define sddev_unregister_dev(handle) ddev_unregister_dev(handle) 32 33 typedef struct _dd_operations_ 34 { 35 UINT32 (*open) (UINT32 op_flag); 36 UINT32 (*close) (void); 37 UINT32 (*read) (char *user_buf, UINT32 count, UINT32 op_flag); 38 UINT32 (*write) (char *user_buf, UINT32 count, UINT32 op_flag); 39 UINT32 (*control) (UINT32 cmd, void *parm); 40 } DD_OPERATIONS; 41 42 typedef enum _DD_OPEN_METHOD_ 43 { 44 DD_OPEN_METHOD_ONE_TIME = 0, // open one time only 45 DD_OPEN_METHOD_MUTI_TIME // open multi times 46 } DD_OPEN_METHOD; 47 48 49 /******************************************************************************* 50 * Function Declarations 51 *******************************************************************************/ 52 UINT32 drv_model_init(void); 53 UINT32 drv_model_uninit(void); 54 DD_HANDLE ddev_open(dd_device_type dev, UINT32 *status, UINT32 op_flag); 55 UINT32 ddev_close(DD_HANDLE handle); 56 UINT32 ddev_read(DD_HANDLE handle, char *user_buf , UINT32 count, UINT32 op_flag); 57 UINT32 ddev_write(DD_HANDLE handle, char *user_buf , UINT32 count, UINT32 op_flag); 58 UINT32 ddev_register_dev(DD_HANDLE handle, DD_OPERATIONS *optr); 59 UINT32 ddev_unregister_dev(DD_HANDLE handle); 60 61 #ifdef __cplusplus 62 } 63 #endif 64