1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 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 16#ifndef OHOS_HDI_USB_V1_0_USBTYPES_H 17#define OHOS_HDI_USB_V1_0_USBTYPES_H 18 19#include <cstdbool> 20#include <cstdint> 21 22#ifndef HDI_BUFF_MAX_SIZE 23#define HDI_BUFF_MAX_SIZE (1024 * 200) 24#endif 25 26#ifndef HDI_CHECK_VALUE_RETURN 27#define HDI_CHECK_VALUE_RETURN(lv, compare, rv, ret) do { \ 28 if ((lv) compare (rv)) { \ 29 return ret; \ 30 } \ 31} while (false) 32#endif 33 34#ifndef HDI_CHECK_VALUE_RET_GOTO 35#define HDI_CHECK_VALUE_RET_GOTO(lv, compare, rv, ret, value, table) do { \ 36 if ((lv) compare (rv)) { \ 37 ret = value; \ 38 goto table; \ 39 } \ 40} while (false) 41#endif 42 43namespace OHOS { 44class MessageParcel; 45} 46 47namespace OHOS { 48namespace HDI { 49namespace Usb { 50namespace V1_0 { 51 52using namespace OHOS; 53 54struct PortInfo { 55 int32_t portId; 56 int32_t powerRole; 57 int32_t dataRole; 58 int32_t mode; 59} __attribute__ ((aligned(8))); 60 61struct UsbDev { 62 uint8_t busNum; 63 uint8_t devAddr; 64} __attribute__ ((aligned(8))); 65 66struct UsbPipe { 67 uint8_t intfId; 68 uint8_t endpointId; 69} __attribute__ ((aligned(8))); 70 71struct UsbCtrlTransfer { 72 int32_t requestType; 73 int32_t requestCmd; 74 int32_t value; 75 int32_t index; 76 int32_t timeout; 77} __attribute__ ((aligned(8))); 78 79struct USBDeviceInfo { 80 int32_t status; 81 int32_t busNum; 82 int32_t devNum; 83} __attribute__ ((aligned(8))); 84 85bool PortInfoBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Usb::V1_0::PortInfo& dataBlock); 86 87bool PortInfoBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Usb::V1_0::PortInfo& dataBlock); 88 89bool UsbDevBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Usb::V1_0::UsbDev& dataBlock); 90 91bool UsbDevBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Usb::V1_0::UsbDev& dataBlock); 92 93bool UsbPipeBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Usb::V1_0::UsbPipe& dataBlock); 94 95bool UsbPipeBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Usb::V1_0::UsbPipe& dataBlock); 96 97bool UsbCtrlTransferBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Usb::V1_0::UsbCtrlTransfer& dataBlock); 98 99bool UsbCtrlTransferBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Usb::V1_0::UsbCtrlTransfer& dataBlock); 100 101bool USBDeviceInfoBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Usb::V1_0::USBDeviceInfo& dataBlock); 102 103bool USBDeviceInfoBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Usb::V1_0::USBDeviceInfo& dataBlock); 104 105} // V1_0 106} // Usb 107} // HDI 108} // OHOS 109 110#endif // OHOS_HDI_USB_V1_0_USBTYPES_H 111 112