1/* 2 * Copyright (c) 2009-2012 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24#ifndef __IOKIT_IO_IOUSBMASSTORAGECLASS_TIMESTAMPS__ 25#define __IOKIT_IO_IOUSBMASSTORAGECLASS_TIMESTAMPS__ 26 27#include <stdint.h> 28 29#include <sys/kdebug.h> 30 31#if KERNEL 32#include <IOKit/IOTimeStamp.h> 33#endif 34 35#include <IOKit/scsi/IOSCSIArchitectureModelFamilyTimestamps.h> 36 37#ifdef __cplusplus 38extern "C" { 39#endif 40 41extern UInt32 gUSBDebugFlags; 42 43#if KERNEL 44 45//-------------------------------------------------------------------------------------------------- 46// RecordUSBTimeStamp [STATIC] 47//-------------------------------------------------------------------------------------------------- 48 49static inline void 50RecordUSBTimeStamp ( 51 unsigned int code, 52 unsigned int a, unsigned int b, 53 unsigned int c, unsigned int d ) 54{ 55 56 if ( gUSBDebugFlags != 0 ) 57 { 58 IOTimeStampConstant ( code, a, b, c, d ); 59 } 60 61} 62 63#endif 64 65#define USBMASS_SYSCTL "debug.USBMassStorageClass" 66 67typedef struct USBSysctlArgs 68{ 69 uint32_t type; 70 uint32_t operation; 71 uint32_t debugFlags; 72} USBSysctlArgs; 73 74 75#define kUSBTypeDebug 'USBM' 76 77enum 78{ 79 kUSBOperationGetFlags = 0, 80 kUSBOperationSetFlags = 1 81}; 82 83 84/* The trace codes consist of the following: 85 * 86 * ---------------------------------------------------------------------- 87 *| | | | |Func | 88 *| Class (8) | SubClass (8) | SAM Class(6) | Code (8) |Qual(2)| 89 * ---------------------------------------------------------------------- 90 * 91 * DBG_IOKIT(05h) DBG_IOSAM(27h) 92 * 93 * See <sys/kdebug.h> and IOTimeStamp.h for more details. 94 * 95 */ 96 97 98// USB Mass Storage Class Tracepoints 0x05278800 - 0x05278BFC 99enum 100{ 101 102 // Generic UMC Tracepoints 0x05278800 - 0x052788FC 103 kAbortedTask = 0x00, 104 kCompleteSCSICommand = 0x01, 105 kNewCommandWhileTerminating = 0x02, 106 kLUNConfigurationComplete = 0x03, 107 kIOUMCStorageCharacDictFound = 0x04, 108 kNoProtocolForDevice = 0x05, 109 kIOUSBMassStorageClassStart = 0x06, 110 kIOUSBMassStorageClassStop = 0x07, 111 kAtUSBAddress = 0x08, 112 kMessagedCalled = 0x09, 113 kWillTerminateCalled = 0x0A, 114 kDidTerminateCalled = 0x0B, 115 kCDBLog1 = 0x0C, 116 kCDBLog2 = 0x0D, 117 kClearEndPointStall = 0x0E, 118 kGetEndPointStatus = 0x0F, 119 kHandlePowerOnUSBReset = 0x10, 120 kUSBDeviceResetWhileTerminating = 0x11, 121 kUSBDeviceResetAfterDisconnect = 0x12, 122 kUSBDeviceResetReturned = 0x13, 123 kAbortCurrentSCSITask = 0x14, 124 kCompletingCommandWithError = 0x15, 125 kDeviceInformation = 0x16, 126 kSuspendPort = 0x17, 127 kSubclassUse = 0x18, 128 129 // CBI Tracepoints 0x05278900 - 0x0527897C 130 kCBIProtocolDeviceDetected = 0x40, 131 kCBICommandAlreadyInProgress = 0x41, 132 kCBISendSCSICommandReturned = 0x42, 133 kCBICompletion = 0x43, 134 135 // UFI Tracepoints 0x05278980 - 0x052789FC 136 137 // Bulk-Only Tracepoints 0x05278A00 - 0x05278BFC 138 kBODeviceDetected = 0x80, 139 kBOPreferredMaxLUN = 0x81, 140 kBOGetMaxLUNReturned = 0x82, 141 kBOCommandAlreadyInProgress = 0x83, 142 kBOSendSCSICommandReturned = 0x84, 143 kBOCBWDescription = 0x85, 144 kBOCBWBulkOutWriteResult = 0x86, 145 kBODoubleCompleteion = 0x87, 146 kBOCompletionDuringTermination = 0x88, 147 kBOCompletion = 0x89 148 149}; 150 151// SubclassCodes 152enum 153{ 154 155 kSubclassCode_AppleUSBODD = 0x00, 156 kSubclassCode_AppleUSBCardReaderUMC = 0x01 157 158}; 159 160// SubclassCodes for AppleUSBODD 161enum 162{ 163 164 kAppleUSBODD_probe = 0x00, 165 kAppleUSBODD_start = 0x01, 166 kAppleUSBODD_requestedExtraPower = 0x02, 167 kAppleUSBODD_isMacModelSupported = 0x03, 168 kAppleUSBODD_FindACPIPlatformDevice = 0x04, 169 kAppleUSBODD_CheckForACPIFlags = 0x05 170 171}; 172 173// SubclassCodes for AppleUSBCardReaderUMC 174enum 175{ 176 177 kAppleUSBCardReaderUMC_start = 0x00, 178 kAppleUSBCardReaderUMC_stop = 0x01, 179 kAppleUSBCardReaderUMC_HandlePowerChange = 0x02, 180 kAppleUSBCardReaderUMC_message = 0x03, 181 kAppleUSBCardReaderUMC_setProperty = 0x04, 182 kAppleUSBCardReaderUMC_gpioMediaDetectFired = 0x05, 183 kAppleUSBCardReaderUMC_gpioMediaDetectEnable = 0x06, 184 kAppleUSBCardReaderUMC_controllerReset = 0x07, 185 kAppleUSBCardReaderUMC_powerControl = 0x08, 186 kAppleUSBCardReaderUMC_waitForReconnect = 0x09, 187 kAppleUSBCardReaderUMC_systemWillShutdown = 0x0A, 188 kAppleUSBCardReaderUMC_generalPurpose = 0x0B, 189 kAppleUSBCardReaderUMC_stop_2 = 0x0C 190 191}; 192 193// Tracepoint macros. 194#define UMC_TRACE( code ) ( ( ( DBG_IOKIT & 0xFF ) << 24 ) | ( ( DBG_IOSAM & 0xFF ) << 16 ) | ( ( kSAMClassUSB & 0x3F ) << 10 ) | ( ( code & 0xFF ) << 2 ) ) 195#define USBODD_TRACE( code ) ( ( ( kSubclassCode_AppleUSBODD & 0xFF ) << 24 ) | ( code & 0xFFFFFF ) ) 196#define USBCARDREADER_TRACE( code ) ( ( ( kSubclassCode_AppleUSBCardReaderUMC & 0xFF ) << 24 ) | ( code & 0xFFFFFF ) ) 197 198#ifdef __cplusplus 199} 200#endif 201 202 203#endif /* __IOKIT_IO_IOUSBMASSTORAGECLASS_TIMESTAMPS__ */ 204