1/* 2 * 3 * @APPLE_LICENSE_HEADER_START@ 4 * 5 * Copyright (c) 1998-2003 Apple Computer, Inc. All Rights Reserved. 6 * 7 * This file contains Original Code and/or Modifications of Original Code 8 * as defined in and that are subject to the Apple Public Source License 9 * Version 2.0 (the 'License'). You may not use this file except in 10 * compliance with the License. Please obtain a copy of the License at 11 * http://www.opensource.apple.com/apsl/ and read it before using this 12 * file. 13 * 14 * The Original Code and all software distributed under the License are 15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 19 * Please see the License for the specific language governing rights and 20 * limitations under the License. 21 * 22 * @APPLE_LICENSE_HEADER_END@ 23 */ 24 25#ifndef __APPLEUSBCDCACM__ 26#define __APPLEUSBCDCACM__ 27 28#include "AppleUSBCDCCommon.h" 29 30 // Common Defintions 31 32#define LDEBUG 0 // for debugging 33#if LDEBUG 34#define USE_ELG 0 // to Event LoG (via kprintf) - LDEBUG must also be set 35#define USE_IOL 0 // to IOLog - LDEBUG must also be set 36#define USE_XTRACE 0 // use xtrace kext 37#define LOG_DATA 0 // logs data to the appropriate log - LDEBUG must also be set 38#define DUMPALL 0 // Dumps all the data to the log - LOG_DATA must also be set 39#endif 40 41#define Log IOLog 42#if USE_ELG 43#undef Log 44#define Log kprintf 45#endif 46 47#if LDEBUG 48 #if USE_ELG 49 #define XTRACE(ID,A,B,STRING) {Log("%8x %8x %8x " DEBUG_NAME ": " STRING "\n",(uintptr_t)(ID),(unsigned int)(A),(unsigned int)(B));} 50 #define XTRACEP(ID,A,B,STRING) {Log("%8x %p %p " DEBUG_NAME ": " STRING "\n",(uintptr_t)(ID),(void *)(A),(void *)(B));} 51#else /* not USE_ELG */ 52 #if USE_IOL 53 #define XTRACE(ID,A,B,STRING) {Log("%8x %8x %8x " DEBUG_NAME ": " STRING "\n",(unsigned int)(ID),(unsigned int)(A),(unsigned int)(B)); IOSleep(kSleepTime);} 54 #define XTRACEP(ID,A,B,STRING) {Log("%8x %p %p " DEBUG_NAME ": " STRING "\n",(unsigned int)(ID),(void *)(A),(void *)(B)); IOSleep(kSleepTime);} 55#else 56 #if USE_XTRACE 57 #include <XTrace/XTrace.h> 58 #define XTRACE(ID,A,B,STRING) {XTRACE_HELPER(gXTrace, ID, A, B, DEBUG_NAME ": " STRING, true);} 59 #define XTRACEP(ID,A,B,STRING) {XTRACE_HELPER(gXTrace, ID, A, B, DEBUG_NAME ": " STRING, true);} //XTRACE(ID,A,B,STRING) 60 #else 61 #define XTRACE(id, x, y, msg) 62 #define XTRACEP(id, x, y, msg) 63 #endif /* USE_XTRACE */ 64 #endif /* USE_IOL */ 65 #endif /* USE_ELG */ 66#if LOG_DATA 67 #if DUMPALL 68 #define LogData(D, C, b) dumpData((UInt8)D, (char *)b, (SInt32)C) 69#else 70 #define LogData(D, C, b) USBLogData((UInt8)D, (SInt32)C, (char *)b) 71#endif 72 #define DumpData(D, C, b) dumpData((UInt8)D, (char *)b, (SInt32)C) 73 #else /* not LOG_DATA */ 74 #define LogData(D, C, b) 75 #define DumpData(D, C, b) 76#endif /* LOG_DATA */ 77#else /* not LDEBUG */ 78 #define XTRACE(id, x, y, msg) 79 #define XTRACEP(id, x, y, msg) 80 #define LogData(D, C, b) 81 #define DumpData(D, C, b) 82 #undef USE_ELG 83 #undef USE_IOL 84 #undef LOG_DATA 85#undef DUMPALL 86#endif /* LDEBUG */ 87 88#define ALERT(A,B,STRING) Log("%8x %8x " DEBUG_NAME ": " STRING "\n", (unsigned int)(A), (unsigned int)(B)) 89#define ALERTP(A,B,STRING) Log("%p %p " DEBUG_NAME ": " STRING "\n", (void *)(A), (void *)(B)) 90 91//#define ALERTSPECIAL(A,B,STRING) Log("%8x %8x " DEBUG_NAME ": " STRING "\n", (unsigned int)(A), (unsigned int)(B)) 92 93enum 94{ 95 kDataIn = 0, 96 kDataOut, 97 kDataOther, 98 kDataNone 99}; 100 101 // USB CDC ACM Defintions 102 103#define kUSBbRxCarrier 0x01 // Carrier Detect 104#define kUSBDCD kUSBbRxCarrier 105#define kUSBbTxCarrier 0x02 // Data Set Ready 106#define kUSBDSR kUSBbTxCarrier 107#define kUSBbBreak 0x04 108#define kUSBbRingSignal 0x08 109#define kUSBbFraming 0x10 110#define kUSBbParity 0x20 111#define kUSBbOverRun 0x40 112 113#define kDTROff 0 114#define kRTSOff 0 115#define kDTROn 1 116#define kRTSOn 2 117 118typedef struct 119{ 120 UInt32 dwDTERate; 121 UInt8 bCharFormat; 122 UInt8 bParityType; 123 UInt8 bDataBits; 124} LineCoding; 125 126#define dwDTERateOffset 0 127 128#define wValueOffset 2 129#define wIndexOffset 4 130#define wLengthOffset 6 131 132#endif