1 /*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /** \file
18 This file consists of implementation of class AndroidUsbDeviceFileObject
19 that encapsulates an extension for a KMDF file object that represent
20 opened device.
21 */
22 #pragma data_seg()
23 #pragma code_seg()
24
25 #include "precomp.h"
26 #include "android_usb_device_file_object.h"
27
28 #pragma data_seg()
29 #pragma code_seg("PAGE")
30
AndroidUsbDeviceFileObject(AndroidUsbDeviceObject * dev_obj,WDFFILEOBJECT wdf_fo)31 AndroidUsbDeviceFileObject::AndroidUsbDeviceFileObject(
32 AndroidUsbDeviceObject* dev_obj,
33 WDFFILEOBJECT wdf_fo)
34 : AndroidUsbFileObject(AndroidUsbFileObjectTypeDevice, dev_obj, wdf_fo) {
35 ASSERT_IRQL_PASSIVE();
36 }
37
38 #pragma code_seg()
39
~AndroidUsbDeviceFileObject()40 AndroidUsbDeviceFileObject::~AndroidUsbDeviceFileObject() {
41 ASSERT_IRQL_LOW_OR_DISPATCH();
42 }
43
OnEvtIoDeviceControl(WDFREQUEST request,size_t output_buf_len,size_t input_buf_len,ULONG ioctl_code)44 void AndroidUsbDeviceFileObject::OnEvtIoDeviceControl(WDFREQUEST request,
45 size_t output_buf_len,
46 size_t input_buf_len,
47 ULONG ioctl_code) {
48 ASSERT_IRQL_LOW_OR_DISPATCH();
49
50 switch (ioctl_code) {
51 case ADB_IOCTL_GET_USB_DEVICE_DESCRIPTOR:
52 device_object()->OnGetUsbDeviceDescriptorCtl(request, output_buf_len);
53 break;
54
55 case ADB_IOCTL_GET_USB_CONFIGURATION_DESCRIPTOR:
56 device_object()->OnGetUsbConfigDescriptorCtl(request, output_buf_len);
57 break;
58
59 case ADB_IOCTL_GET_USB_INTERFACE_DESCRIPTOR:
60 device_object()->OnGetUsbInterfaceDescriptorCtl(request, output_buf_len);
61 break;
62
63 case ADB_IOCTL_GET_ENDPOINT_INFORMATION:
64 device_object()->OnGetEndpointInformationCtl(request,
65 input_buf_len,
66 output_buf_len);
67 break;
68
69 case ADB_IOCTL_GET_SERIAL_NUMBER:
70 device_object()->OnGetSerialNumberCtl(request, output_buf_len);
71 break;
72
73 default:
74 AndroidUsbFileObject::OnEvtIoDeviceControl(request,
75 output_buf_len,
76 input_buf_len,
77 ioctl_code);
78 break;
79 }
80 }
81
82 #pragma data_seg()
83 #pragma code_seg()
84