Index

images Numbers and Symbols

_MALLOC() function, 107

_MALLOC_ZONE() function, 107

<libkern/OSKextLib.h> header file, 424

images A

AbortPipe, 375

acknowledgePowerChange() method, 219

Active List, 104

activityTickle() method, 217

activityTickle(type, powerState) method, 216

addAudioStream() method, 267

addAvailableFormat(), 268

addEventSource(), 195

addressOfMappedBuffer argument, 119

Advanced Graphics Port (AGP), 177

Advanced kernel programming, 411

drivers notifications

arbitrary file system, 425

communication, 42627

custom user client method, 43031

daemon process, 426

IOConnectSetNotificationPort() function, 430

IOUSBFamily, 425

IOUserClient class, 426

IOUserClient subclass, 430

Kernel-User Notification Center, 425

mach_msg_header_t structure, 427

MyNotificationMessage structure, 428

registerNotificationPort() method, 430

structure definition, 42728

user space code, 42830

user space daemon process, 426

I/O Kit families, 41314

kernel control KPI

access, user space, 41921

C language, 414

client connections, 41718

getsockopt() system call function, 414

getting and setting options, 41819

HelloKernControl header file, 417

kern_ctl_reg structure, 41415

KEXT, 414

registration, 41517

send() and recv() system call functions, 414

setsockopt() system call function, 414

vs. ioctl() system call, 414

KEXT resources, 425

loading resources, 42325

multi-function drivers, 41213

process, 42123

SSE and floating point, 41112

app_descriptor structure, 286

Apple AHCI storage driver stack, 321

Apple USB serial driver, 226

AppleACPIPCI, 177

AppleRTL8139Ethernet, 305

AppleUSBCDC driver, 226

AppleUSBCDCEthernet, 305

arg0 parameter, 364, 377

atAddress argument, 116

attachMediaObjectToDeviceTree(), 350

Audio drivers, 249

additional audio engine functionality, 27576

audio engine implementation

header file, MyAudioEngine class, 26364

IOAudioEngine subclass, 262

buffering, 249

Core Audio, 249, 25153

digital audio and audio devices

analog audio wave, 250

PCM samples, 25051

sample buffer, 251

sample rate, 250

sound waves, analog, 249

hardware initialization

activateAudioEngine() method, 259, 260

addTimerEvent() function, 257

createAudioEngine() method, 259

event argument, 257

header file, MyAudioDevice class, 25759

I/O Kit lifecycle methods, 259

initHardware() method, 259

IOAudioDevice subclass, 257

IOAudioEngine, 256

IOWorkLoop and IOCommandGate, 256

target argument, 257

I/O engine initialization

audio streams creation and initialization, 26768

handling format changes, 26869

handling interrupts and timestamps, 27375

initHardware() method, 26466

IOAudioStream, 267

IODMACommand class, 267

IOMalloc(), 267

IOTimerEventSource, 266

sample buffer, 266, 267

sample rate, 266

samples clipping and conversion, 26971

setDescription() method, 266

setInputSampleLatency function(), 266

setOutputSampleLatency() function, 266

starting and stopping audio engine, 27273

I/O kit audio support, 25354

IOAudioControl, 256

IOAudioDevice, 255

IOAudioEngine, 256

IOAudioFamily, 255

IOAudioStream, 256

MyAudioDevice architecture, 256

MyAudioDevice source code, 254

MyAudioEngine class, 256

programming drivers, 249

registering audio controls

addDefaultAudioControl(), 262

attributes, 260

callback function, 261

channel ID, 261

createMuteControl() factory method, 262

createVolumeControl() method, 260

dB value, 261

IOAudioLevelControl, 260

IOAudioStream, 262

System Preferences, 255

System Prefernces, 255

Audio HAL, 269

Audio Toolbox, 252

Audio Units, 252

audioStream parameter, 271

images B

bAlternateSetting, 374

Base Address 0-5, 176

Base Address Register (BAR), 176

bConfigurationValue, 369, 374

bDescriptorType, 374

bDeviceClass, 365

bDeviceProtocol, 365

bDeviceSubClass, 365

Berkeley Packet Filter (BPF), 276, 301

bInterfaceClass, 374

bInterfaceNumber, 374

bInterfaceProtocol, 374

bInterfaceSubClass, 374

bInterval, 374

Bit depth, 250

BSD data-link layer (BDIL), 304

BSD sockets, 105

bzero functions, 107

images C

capabilities argument, 218

capabilityFlags, 209

capabilityFlags bitmask, 218

CFMachPortCreate() function, 426

changePowerStateTo() method, 215, 216, 217

changePowerStateTo(powerStateOrdinal) method, 215

changePowerStateToPriv() method, 215, 216, 217

changePowerStateToPriv(powerStateOrdinal) method, 215

Class Code, 176

ClearPipeStall, 375

ClearPipeStallBothEnds, 375

clientMemoryForType method, 118

clipOutputSamples() method, 270

Cocoa framework, 6

Cocoa Touch API, 20

com.apple.iokit.IOAudioFamily, 413

com.apple.iokit.IOStorageFamily kernel module, 335

com.apple.kpi.private, 422

com_osxkernel_MyEthernetHwAbstraction class, 311

commandSleep() method, 141

Condition variables

definition, 133

functions, 13435

interruptType values, 13536

IOLockSleep(), 133, 134

m_readEvent parameter, 134

read() method, 133

sample code, 133

SIGHUP or SIGKILL signals, 135

user space application, 133

Configuration space registers

capability registers, 18586

device ID and vendor ID, 183

extended configuration space, 185

IOPCIDevice.h file, 184

offset parameter, 183

offsets constants, 184

PCI controller firmware, 184

PowerPC-based systems, 185

setConfigBits() method, 184

setMemoryEnable() method, 185

Connect and disconnect callbacks, 41718

connect() system, 289

constants callback function, 101

constants IOAsyncCallback0 function, 101

constants IOConnectCallAsyncScalarMethod() function, 101

contentHint parameter, 349, 351

Control get function, 418

ControlRequest, 377

ControlRequestAsync, 377

ControlRequestAsyncTO, 377

ControlRequestTO, 377

convertInputSamples() method, 271

cookie argument, 300

Copy-on-write (COW) optimization, 112

Core Audio, 249, 25153

Core Audio Kit, 252

Core MIDI / MIDI Server, 253

CreateDeviceAsyncEventSource method, 364

CreateInterfaceIterator, 369

createMappingInTask() method, 115, 116

createMedium() method, 31213

createNewAudioStream() method, 267

images D

Darwin distribution, 17

Darwin source code repository, 226

Data-link interface layer (DLIL), 303

Debugging

boot parameter, 386, 387

boot-args argument, 387

crashes, 387

deadlocks, 382

FireWire, remote tracing, 390, 392

GNU debugger

backtrace command, 404

cmp instruction, 407

disassemble command, 406

FireWire core dump mechanism, 403

FireWireKDP mechanism, 397, 398

fVariable1 and fVariable2, 408

host machine, 395, 396

kernel macros, 400, 401

kernel panic logs, 408, 410, 411

Mac OS X, 394

MyDebugDriver Header File, 403, 404

pointer, 407, 408

remote debugging setup, 400

remote target, 396, 397

running kernel, 399

symbol information, 401, 403

symlink, 405

UNIX and Linux systems, 395

verbose flag, 395

x86-64 calling conventions, 411, 412

Xcode, 394

Hung processes, 412, 413

illegal instruction/operand, 382

invalid memory access, 382

IOLog() tracing, 388, 389

KDB, 394

kernel panics, 383

kernel problems, 384

lock contention, 382

memory and resource leaks, 382, 413, 414

nvram command, 385, 387

primary interrupt context, 383

race conditions, 382

remote kernel core dumps, 392, 393, 394

stack traces, 389

virtual machine, 399

volunteered panics, 383

deRegisterInterestedDriver(IOService* driver) method, 218

detach() method, 191

Device Address Resolution Table (DART), 100

Device ID, 175

DeviceRequest, 367

DeviceRequest method, 367

DeviceRequestAsync, 367

DeviceRequestTO, 367

didChange notification, 219

didTerminate() method, 191

Direct memory access (DMA), 251

Direct Memory Access (DMA)

64-bit platforms, 201

buffer, 200, 201

data structure, 202

definition, 199

inbound DMA, 199

IODMACommand class

32-bit addressing, 206

alignment parameter, 208

code output, 209

esoteric hardware device, 206

generation, 2089

inTaskWithPhysicalMask() factory method, 207

IOBufferMemoryDescriptor, 207

IOMemoryCursor class, 206

IOMMU, 206

mappingOptions parameter, 207

maxSegmentSize parameter, 207

maxTransferSize, 208

memory caching, 200

memory preparation, 2034

NULL pointer, 202

outbound DMA, 199

outbound DMA transfer, 199200

page-out operation, 201

physical-bus address translation, 2023

scatter/gather list, 201, 2046

setBusMasterEnable(), 199

user space memory, 201

zero-copy, 199

DKIOCEJECT, 326

DKIOCGETFORMATCAPACITIES, 325

DKIOCISWRITABLE, 325

DKIOCREQUESTIDLE, 326

DKIOCSYNCHRONIZECACHE, 327

DKIOCUNMAP, 326

do_block field, 286

doDiscard method, 326

doFormatMedia, 337

domain structure, 276

Driver class, Info.plist file

"IOKitTest.cpp" tutorial, 5960

"IOKitTest.h" tutorial, 58

com.osxkernel, 58

IOKitPersonalities dictionary, 60

IOKitTest dictionary, 60

IOKitTest.cpp, 58

IOMatchCategory key, 61

IOResourceMatch, 61

IOResources nub, 61

IOResources provider class, 61

IOService class, 58

kernel.log file, 62

methods calling order, 6263

object initialization, 63

OSBundleLibraries dictionary, 6061

OSDeclareDefaultStructors macro, 58

project's property list, 61

super macro, 60

Drivers, 69

chain of control requests, 13

device removal

callback function, 77

callback function installation, 7879

DeviceAdded() function, 77

driver object, 77

IONotificationPortCreate() function, 77

IOServiceAddInterestNotification() function, 77

driver properties

connection-based approach, 79

Core Foundation, 82

Core Foundation dictionary, 80

custom string value, 83

CustomMessage, 81

debugging information, 81

IOUSBDevice class, 80

key/value pairs, 79

manufacturer string, 81

setProperties() Method, 82

StopMessage, 81, 83

table, 79

i/o control, 14

I/O Kit framework, 7071

IO registry, 71

kernel/user space boundary, 69

lower-level USB driver, 13

matching dictionary

callback function, 73

CFRunLoopRun() function, 75

code structure, 71

Command Line Tool, 71

Core Foundation, 71

DeviceAdded, 75

DriverIterator, 71

event loop, 74

IOIteratorNext() function, 75

IOMasterPort() function, 73

IONotificationPortCreate() function, 75

IOServiceAddMatchingNotification() function, 75

IOServiceGetMatchingServices() function, 75

IOServiceMatching() function, 76

kernel driver's property list, 71

kIOMasterPortDefault macro, 73

NSApplicationMain() function, 75

run loop, 74

USB devices, 71

USB devices arrival, 7475, 76

USB hardware devices, 7273

notifications

asynchronous operations, 99

asyncReference buffer, 102

blocking operations, 99

DelayForMs() method, 99

DelayForTime() function, 99

InstallTimer() function, 99, 100101, 1023

IOConnectCallAsyncXXX() function, 100

IOConnectCallXXX() functions, 100

IOExternalMethodArguments structure, 1012

IONotificationPortCreate() function, 99

kIOAsyncCalloutFuncIndex and kIOAsyncCalloutRefconIndex constants, 101

port allocation, 99100

sendAsyncResult64(), 103

timerCallback and context arguments, 101

operating system kernel, 12

printer, 14

serial port driver, 69, 70

state-based interaction

asynchronous operations, 83

background operation, 83, 84

connection-based approach, 83

driverConnection parameter, 84

IOServiceClose() function, 85

IOServiceOpen() function, 84, 85

user client. See User client methods

user space application, 69, 70

images E

Embedded C++, 3940

emmintrin.h header file, 412

Enhanced host controller interface (ECHI), 145

EPERM, 291

ExpressCard, 175

Extensible host controller interface (xHCI), 145

images F

fAudioInputInteruptPending, 199

fAudioOutputInterruptPending, 199

fCurrentLoopCount, 273

File descriptors, 105

Filter scheme driver. See Media filter drivers

filterInterruptEventSource() method, 195

Firmware, 12

firstSampleFrame, 271

flush(), 317

flushInputQueue(), 319

frActCount value, 383

frame_ptr argument, 300

frameStart parameter, 380, 381

Free List, 104

free() method, 14243, 191

frStatus value, 383

frTimeStamp field, 384

images G

g_string_buf variable, 419

GCC compiler, 41

GetAlternateSetting, 374

getBufferMemoryDescriptor() method, 119

GetBusFrameNumber, 366, 372

GetBusFrameNumber method, 380, 381

GetBusFrameNumber() method, 366

GetBusFrameNumberWithTime, 366, 372

GetBusMicroFrameNumber, 366, 372

GetConfiguration, 369

GetConfigurationDescriptionPtr, 369

GetConfigurationValue, 374

getCurrentSampleFrame() method, 274

GetDevice, 372

GetDeviceAddress, 366

GetDeviceAsyncEventSource method, 364

GetDeviceClass, 365

getDeviceMemoryWithIndex() method, 188, 189

GetDeviceProduct, 365, 372

GetDeviceProtocol, 365

GetDeviceReleaseNumber, 365, 372

GetDeviceSpeed, 366, 373

GetDeviceSubClass, 365

GetDeviceVendor, 365, 372

getDirection() method, 327

GetEndpointProperties, 374, 375

GetFrameListTime, 373

getHardwareAddress() function, 314

getHardwareAddress() method, 314

GetInterfaceClass, 374

GetInterfaceNumber, 374

GetInterfaceProtocol, 374

GetInterfaceSubClass, 374

GetLocationID, 366, 372

GetNumberOfConfigurations, 366

GetNumEndpoints, 374, 375

getPhysicalAddress() function, 203

getPhysicalAddress() method, 120

getPhysicalSegment() method, 120

GetPipeProperties, 375

GetPipeStatus, 375

getVirtualAddress() method, 188, 189

images H

Hardware abstraction layer (HAL), 252

HELLO_CONTROL_GET_STRING, 419

hello_ctl_connect() function, 418

HelloWorld distribution, 437

Hot-pluggable devices, 434

images I, J

I/O Kit framework, 51

“nub”, 52

boilerplate code, 52

C++ language, 51

driver's provider, 52

Info.plist file

active matching, 55

com_mycompany_driver_MyExternalDiskDriver class, 57

com_mycompany_driver_MyExternalDiskDriverUSB class, 57

driver class. See Driver class, Info.plist file

driver personalities, 57

IOPCIDevice, 55

IOProviderClass, 54

IORegistryExplorer, 6365

IOUSBDevice, 5556

kernel extension, 54

match category, 55

matching dictionary, 54, 55, 57

MyUSBDevice, 56

property list, 54

USB device connection, 54

user client, 56

IOAudioDevice class, 52

IOSerialStreamSync class, 52

IOService class, 53

IOUSBDevice class, 52

Kernel framework, 51

libkern. See libkern

object relationship, 5354

object-oriented programming abstraction, 51

role of driver, 52

user space application, 51

I/O memory management unit (IOMMU), 100, 2023

I/O memory regions

control and status registers, 186

enumeration

frame buffer, 188

graphics card, 188

kernel.log, 188

setMemoryEnable(), 18788

frame buffer, 186

I/O ports, 186

I/O space access, 189

IDE controllers, 186

mapping and accessing, 188

size, 186

standardized interfaces, 186

ifconfig tool, 312

iff_input filter function, 300

iff_protocol field, 300

ifnet structure, 276

ifnet_hdrlen(ifnet_t) function, 300

ifnet_t argument, 300

iInterface field, 374

Inactive List, 104

Info.plist file, 413

inputPacket(), 319

inputPowerRequirement, 209

inputStructSize argument, 90

Installation Destination, 437

inTask argument, 111

inTaskWithOptions() method, 111

inTaskWithPhysicalMask(), 112

inTaskWithPhysicalMask() method, 111

intCount parameter, 199

Intel 64 Architecture, 103

Interface filters

AF_INET, 298

callback arguments, 300

iff_filter structure, 298

ifnet_find_by_name() KPI function, 300

ifnet_output_raw() function, 301

ioctl() messages, 297

MyInterfaceFilter, 298300

output filter function, 300301

physical interface, 297

Internet Protocol (IP) filters

EJUSTRETURN, 296

encrypted IP packet, 295

Ethernet, 297

ipf_addv4() function, 295

ipf_input and ipf_output callbacks, 295

ipf_output filter function, 296

IPv4 and IPv6, 292

MyIPFilter implementation, 29295

NAT, 297

ping command line utility, 296

structure, 292

TCP and UDP checksums, 296

UDP and TCP checksums, 296

Interrupt event source filtering, 19596

Interrupt handler code, 27374

Interrupt Service Routine (ISR), 192

interruptFilter() function, 197

interruptOccurred() method, 195

intoTask argument, 116

ioalloccount tool, 433

IOAudioControl, 254

IOAudioControlUserClient, 254

IOAudioDevice, 253

IOAudioDevice superclass, 53

IOAudioEngine, 253, 254

IOAudioEngineUserClient, 254

IOAudioFamily, 249, 253, 412

IOAudioLevelControl, 254

IOAudioPort, 254

IOAudioSelectorControl, 254

IOAudioStream, 254

IOAudioStreamFormat structure, 268

IOAudioToggleControl, 254

IOBasicOutptuQueue class, 304

IOBlockStorageDevice class, 320, 321, 339

IOBlockStorageDriver class, 339

IOBufferMemoryDescriptor, 109, 203, 205, 267, 318

IOCFPlugInInterface class, 362

ioclasscount tool, 192, 433

IOConnectCall*() functions, 432

IOConnectSetNotificationPort() function, 427

IODeviceMemory, 188

IODeviceTree, 64

IODMACommand class, 120, 203

IOEthernetController class, 303, 304

IOEthernetInterface, 310, 312

IOEthernetInterface class, 303, 311

IOEventSource base class, 139

IOExternalMethodArguments structure, 9293, 97, 1012

IOExternalMethodDispatch structure, 94

IOFilterInterruptEventSource, 194, 196, 198, 312

IOFilterInterruptEventSource instance, 197

IOFireWireIP, 305

IOGatedOutputQueue class, 304

IOGraphicsFamily, 413

IOInterruptEventSource, 194, 196, 198, 310, 312

IOInterruptEventSource class, 139

IOInterruptEventSource::interruptEventSource(), 196

IOIteratorNext() function, 72

IOKernelDebugger class, 303

IOKitPersonalities dictionary, 60

IOLock, 127, 131

IOLockSleep() function, 141

IOLockSleepDeadline() function, 141

IOLockWakeup() function, 141

IOLog(), 198

IOMalloc() family, 112

IOMalloc() function, 108

IOMallocAligned(), 112

IOMallocAligned() function, 108, 109

IOMallocContiguous() function, 109

IOMallocPageable() function, 109

IOMatchCategory, 342

IOMBufBigMemoryCursor subclass, 304

IOMbufDBMAMemoryCursor subclass, 304

IOMbufLittleMemoryCursor subclass, 304

IOMbufMemoryCursor, 318

IOMbufMemoryCursor class, 304

IOMbufMemoryCursor subclass, 319

IOMbufNaturalMemoryCursor subclass, 304

IOMedia class, 339

IOMediaBSDClient class, 339, 340

IOMemoryDescriptor, 115, 188, 203, 359

IOMemoryDescriptor class, 113, 203

IOMemoryDescriptor object, 327

IOMemoryDescriptor::getPhysicalSegment(), 204, 208

IOMemoryDescriptor::map() method, 115

IOMemoryDescriptor::prepare(), 100

IOMemoryMap class, 113

IOMemoryMap member function, 117

IOMemoryMap::getVirtualAddress() method, 116

IOMemoryMap::unmap() function, 117

IONetworkController class, 304

IONetworkController::selectMedium() method, 313

IONetworkData class, 304

IONetworkInterface class, 304, 311, 319

IONetworkMedium class, 312

IONetworkUserClient class, 304

IOObjectCopyClass() function, 72

IOObjectRelease() function, 72

IOOutputQueue class, 304

IOPacketQueue, 321

IOPacketQueue class, 304

IOPCI2PCIBridge class, 177

IOPCIDevice method, 188

IOPCIDevice provider class, 53, 54

IOPhysicalAddress, 100

IOPMAckImplied value, 218

IOPower, 64

IOPropertyMatch, 342

IOPropertyMatch item, 351

IOProviderClass key, 71

IORecursiveLock, 141

IORegistryEntry class, 82

IORegistryEntryCreateCFProperties() function, 79

IORegistryEntryCreateCFProperty() function, 80

IORegistryExplorer, 203, 206

IORWLock, 127, 136

IOSerialDriverSync class, 69

IOSerialStreamSync class, 53

IOService class, 207, 320

IOService lifecycle methods, 272

IOService::registerInterrupt(), 194

IOServiceGetMatchingServices() function, 72, 73

IOServiceMatching() function, 71

IOServiceOpen() function, 426

IOSimpleLock. See Spin locks:

IOStorage stack, 342

IOStorageCompletion, 359

IOTimerEventSource, 312

IOTimerEventSource class, 139, 14142

IOTimerEventSources, 310

IOUSB, 65

IOUSBConfigurationDescriptorPtr structure, 369

IOUSBController subclass, 414

IOUSBDevice, 72

IOUSBDevice class, 320

IOUSBDevice provider class, 53, 54

IOUSBDeviceInterface class

bmRequestType field, 367

CFStringRef, 368

control requests, 367

device configuration, 36970

device request function, 36869

IOUSBDevice class, 361, 364

IOUSBDeviceInterface300 class, 36566

kIOReturnExclusiveAccess error code, 365

kIOReturnSuccess error code, 365

kUSBIn, 367

kUSBRqGetDescriptor request, 367

loop source, 364

QueryInterface method, 362

read dynamic properties, 366

reset USB device, 36667

USBDeviceClose(), 365

USBDeviceOpen(), 365

USBGetManufacturerStringIndex, 367

wValue field, 367

IOUSBFindInterfaceRequest structure, 369

IOUSBHubDevice, 72

IOUSBInterface class, 320

IOUSBInterfaceInterface class, 37273

endpoint data transfer methods

Async, 376

bulk endpoint, 377

callback function, 376

control request, 377

endpoints determination, 37475

interrupt endpoint, 37778

isochronous data transfers. See Isochronous data transfers

pipe index, 375, 376

pipe reference, 37576

ReadPipeAsyncTO, 37879

endpoint types, 371

getting and setting properties, 37374

io_service_t, 36162

io_service_t object, 371

IOUSBInterface class, 361, 371

IOUSBInterfaceInterface300 class, 372

kIOUSBInterfaceClassName, 371

matching dictionary, 371

QueryInterface method, 362

USBInterfaceClose(), 372

USBInterfaceOpen(), 371

IOUSBIsocFrame array, 380, 381

IOUSBIsocFrame structure, 384

IOUSBLowLatencyIsocFrame array, 384

IOUSBLowLatencyIsocFrame structure, 384

IOUserClient class, 53, 85, 118

IOUserClient method, 432, 433

IOVirtualAddress, 101, 116

IOWorkLoop, 195

ipf_detach function, 292

ipf_remove() function, 292

iPhone OS, 16

Isochronous data transfers

bandwidth, USB bus, 380

GetBandwidthAvailable, 381

IOUSBIsocFrame structure, 380

low-latency isochronous transfers, 38384

read operation function, 38183

ReadIsochPipeAsync, 380

SetPipePolicy, 381

WriteIsochPipeAsync, 381

isWhole, 349

images K

kAudioBufferSampleFrames, 266

kAudioSampleRate, 266

Kernel address space management, 29

Kernel Control KPI, 281

Kernel development

C++ language, 3940

Console untility, 5051

kernel extension. See Kernel extension

Xcode, 4041

Kernel extension

"Hello World" application

"System Plug-in" category, 41

<libkern/libkern.h> header file, 42, 43

com.apple.kpi.libkern, 44

HelloWorld.c, 4243, 44

HelloWorld-Info.plist file, 43

I/O Kit driver, 42

Info.plist file, 46

Kernel.framework, 44

KEXT bundle, 46

Mac OS X kernel, 44

printf() function, 43

project settings, 44, 46

property list, 4344, 4344

reverse DNS convention, 42

reverse DNS prefix, 44

loading and unloading

compiled binary, 47

HelloWorld.kext, 47

HelloWorld_stop() function, 50

KEXT bundle, 48

kextload command, 48

kextstat command, 4850

kextunload command, 48

kextutil command, 48

path location, 47

security, 47

Kernel extension:, 43

Kernel extensions (KEXT), 429

loading and installation

AuthorizationExecuteWithPrivileges(), 431

I/O Registry, 429

Info.plist files, 429

IOResources, 429

iOS App Store, 431

kextd, 429

LaunchDaemon, 430

Mac App Store, 431

plist file, 431

preferences and settings, 43132

root user, 429

UNIX shell script, 43031

VPN application, 431

packaging:. See PackageMaker, KEXT

software distribution, 429

testing and quality assurance, 43334

versioning system, 43233

Kernel library. See libkern

Kernel private, 422

KernelUserClientAPIVersion, 433

kextd daemon, 413

kextload, 433

kextunload, 433

kfree() function, 106, 108

kIOAudioStreamAlignmentHighByte, 268

kIOAudioStreamAlignmentLowByte, 268

kIODirectionIn, 203

kIODirectionIn value, 327

kIODirectionInOut, 203

kIODirectionOut, 203

kIODirectionOut value, 327

kIOMapAnywhere, 116, 119

kIOMapCopybackCache, 116

kIOMapDefaultCache, 116

kIOMapInhibitCache, 116

kIOMapReadOnly, 116

kIOMapReference, 116

kIOMapUnique, 116

kIOMapWriteThruCache, 116

kIOMemoryKernelUserShared, 112

kIOMemoryMapperNone, 120

kIOMemoryPageable, 111

kIOMemoryPhysicallyContiguous, 111, 318

kIOMemoryPhysicallyContiguous flag, 205

kIOMemoryPurgeable, 112

kIONetworkLinkActive flag, 313

kIONetworkLinkValid flag, 313

kIOPCIConfigDeviceID, 184

kIOPCIConfigVendorID, 184

kIOPCIExpressCapability, 186

kIOPMDeviceUsable, 209

kIOPMInitialDeviceState, 209

kIOPMLowPower, 209

kIOPMPowerOn, 209

kIOPMPowerStateVersion1, 208

kIOPMPreventIdleSleep, 209

kIOPMSubclassPolicy parameter, 217

kIOPMSuperclassPolicy1 parameter, 217

kIOPropertyExternalKey, 189

kIOPropertyPhysicalInterconnectLocationKey, 189

kIOReturnSuccess, 144, 314, 367, 375

kIOReturnSuccess value, 364

kIOReturnUnsupported, 313, 314, 325

kIOServicesIsTerminated message, 191

kIOUSBPipeStalled, 375

kIOUSBUnknownPipeErr, 375

kmem_alloc() function, 107

kmem_alloc*() family, 105

kmem_alloc_pageable() function, 105

kUSBFullSpeedMicrosecondsInFrame, 373

kUSBHighSpeedMicrosecondsInFrame, 373

images L

Launch Daemon, 430, 432

Legacy mode, 103

len argument, 419

libkern, 51

OSObject class

adoption procedure, 6567

command ioclasscount, 68

container classes, 6870

free() method, 67

functionality, 65

init() method, 67

ioclasscount command, 68

kernel extension, 68

NSObject class, 65

OSDeclareDefaultStructors macros, 67

retain() method, 67

start() method, 68

static helper method, 67

libkern kernel library, 105

libkern library, 109

libpcap library, 301

LLVM compiler, 41

Long mode, 103

LowLatencyCreateBuffer, 384

LowLatencyCreateBuffer method, 384

LowLatencyDestroyBuffer, 384

LowLatencyReadIsochPipeAsync, 384

LowLatencyWriteIsochPipeAsync, 384

images M

m_devicePowerState, 220

m_outstandingIO variable, 220

Mac OS 9, 5

Mac OS X, 224, 225, 226

Mac OS X and iOS

64-bit operating system, 20

architecture, 16, 17

Darwin distribution, 17

desktop, 17, 18

iLife suite, 16

Intel x86-platform, 20

NeXTSTEP OS, 16

objective-C, 18, 19

POSIX, 17

powerPC platform, 17, 20

programming API, 18, 19

release date, 15, 20

Unix 03 Certification, 17

XNU kernel. See XNU kernel

Mac OS X and iOS audio architecture, 252

mach_msg_send_from_kernel() function, 427

mach_vm_address_t, 101

makeUsable() method, 215, 216

malloc() function, 105

map() method, 188

mapDeviceMemoryWithRegister() method, 188, 189

Matching and loading drivers

32-bit hexadecimal string, 179

Info.plist, 179

Info.plist file, 180

IONameMatch, 180

IOPCIClassMatch, 179

IOPCISecondaryMatch, 179

IOProvider* service method, 178

IOProviderClass, 179

keys, 178

matching dictionary, 17879

name property, 180

Thunderbolt devices, 18081

maxNumSegments, 318

maxSegmentSize, 318

mbuf_pkthdr_rcvif() function, 290

mbuf_t buffer, 300

Media Access Control (MAC) address, 31314

Media filter drivers

block-level disk encryption, 352

Content Hint property, 353

encryption

Encrypted_HFS_GUID, 353

HFS file system, 353

instantiateMediaObject() method, 356

IOPropertyMatch, 353

matching dictionary, property list, 35354

probe() method, 354

read() method, 35759

SampleEncryptionFilter class, 356

start() method implementation, 35456

uuidgen command line tool, 353

write() method, 36061

write() methods, 356

XOR encryption scheme, 353

GUID partition table

.dmg file, 363

"gpt add" command, 362

"hdiutil attach" command, 362

Apple_HFS, 363

Content Hint property, 361, 363

disk image, 361, 362

disk2, 363

disk2s1, 363

EncryptedImage.dmg file, 362

gpt command, 362

hdiutil command line utility, 362

HFS file system, 361, 363, 364

IOBlockStorageDevice superclass, 362

IOGUIDPartitionScheme driver, 363

IOMediaBSDClient object, 362

MyVolumeName, 363

setLocation() method, 363

IOFilterScheme class, 352

RAID driver, 352, 353

Media independent interface (MII) bus, 310

memcpy() function, 113

Memory management, 99

IOMemoryDescriptor

complete() method, 111

IOBufferMemoryDescriptor, 11112

IODeviceMemory, 112

IOMultiMemoryDescriptor, 112

prepare() method, 11011

release() method, 111

virtual and physical memory, 110

withAddressRange() method, 110

withPhysicalAddress() method, 111

kernel memory allocation

BSD, 107

C++ new operator, 109

I/O Kit, 1079

kalloc family, 1057

low-level allocation mechanisms, 1045

Mach zone allocator, 105

malloc()/free() interface, 104

VM page cache and file system cache, 104

vm_page structure, 104

xnu kernel, 104

mapping memory

COW optimization, 112

definition, 112

IOBufferMemoryDescriptor, 119

IOMalloc() and IOMallocAligned() functions, 119

IOMemoryDescriptor::createMappingInTask(), 119, 120

IOMemoryMap class, 11618

Memory management, mapping memory (cont.)

IOMemoryMap::getVirtualAddress(), 120

kernel to user space task, 11819

kIOMemoryKernelUserShared, 119

physical address mapping, 120

user space task into kernel space, 1012

types

32-bit vs. 64-bit memory addressing, 1034

big vs. little endian, 102

bus physical addresses, 100

CPU physical sddress, 100

user and kernel virtual addresses, 1012

memory management unit (MMU), 202

Memory Management Unit (MMU), 100, 101

Memory mapped I/O (MMIO), 190

Memory Mapped I/O (MMIO), 186

Message signaled interrupts (MSI), 19697

Message Signaled Interrupts (MSI), 195

message() method, 191

Message-signaled interrupts (MSI). See

Mutexes

advantages, 131

deadlock, 131

functions, 13132

IOLock, 127, 131

ListEnqueue() function, 131

POSIX mutex lock functions, 131

recursive mutex, 131

MyEthernetDriver, 301

BSD layer, 306

configureInterface() method, 31112

DHCP server, 323

en5, 323

enable() method, 31415

header file, 3079

ifconfig command line tool, 323

interaction, 305

interrupt handler, 31819

IOEthernetController, 306

IOEthernetInterface, 306

IONetworkController, 305, 306

IORegisterExplorer, 321

IORegisteryExplorer, 322

IOResources, 321

IOResources nub, 305

IOUSBFamily source distribution, 305

kextload, 321

MAC address, 314

Mac's Thunderbolt port, 306

MyEthernetHwAbstraction class, 307

MyEthernetHwAbstraction.cpp, 321

network stack, 306

outputPacket() function, 316

packets and data transfer, 324

physical network switch, 306

ping utility, 324

start() method, 31011

System Preferences, network pane, 322, 323

test setup, 306

virtual Ethernet bridge/switch, 307

MyFirstPCIDriver class

declaration, 18182

implementation, 182

Info.plist, 182

IOProviderClass key, 182

IORegistryExplorer, 183

kextload utility, 183

modifications, 181

probe() method, 182

registerService() function, 182

start() method, 182

myReadDataFromDevice() method, 224

myReadDataFromDevice() operation, 219

images N

netcat, 302

Network Address Translation (NAT), 297

Network Kernel Extension (NKE), 414

Network kernel extensions (NKE)

architecture, 276

interface filter. See Interface filter

interface KPI, 281

IP filter. See Internet Protocol filter

kernel control interface, 281

protocol plumber, 281

socket filter. See Socket filter

Network memory buffers (mbufs)

cluster, 278

data structure, 27778

KPI, 279

linked list, 278

mbuf_allocpacket() function, 280

mbuf_allocpacket_list function, 280

mbuf_copyback() function, 279

mbuf_copydata() function, 279

MBUF_DONTWAIT, 280

mbuf_tag_allocate() function, 280

MBUF_WAITOK, 280

MH_ext field, 279

the mbuf_next() macro, 280

Networking, 275

BSD layer, 275

BSD network stack, 276

data structures, 276

debugging and testing, 301

I/O Kit

AirPort drivers, 304

disable() method, 31516

driver initialization and startup

attachInterface() method, 311

configureInterface() method, 31112

createMedium() function, 311

registerService() method, 312

start() method, 30911

enable() method, 31415

enableHardware() method, 315

Ethernet controller driver. See MyEthernetDriver

fRxPacketQueue, 315

IO80211Controller, 304

IO802Family.kext, 304

IONetworkController class, 303

IONetworkingFamily class hierachy, 302, 303

IONetworkInterface class, 303

IOUserClient, 304

MAC address configuration, 31314

medium and status selection, 31213

packets transmission, 31618

receiving packets, 31821

kernel network architecture, 275

KPI, 276

mbufs. See Network memory buffers

NKE. See Network kernel extensions

socket API, 276

numSampleFrames, 271

images O

Objective-C, 18

Open host controller interface (OHCI), 145

OpenAL, 253

Operating system fundamentals, 1

boot sequence, 4

driver, 2

hardware and drivers, 1214

hardware configuration, 2

kernel extension, 1, 2

kernel space code, 3

network interfaces, 1, 2

process address spaces, 56

process management, 45

scheduling, 1112

services, 67

sound card, 3

user space code, 3

virtual memory

buffer, 11

page fault, 10

page frames, 89

page table, 9

paging, 8, 10, 11

physical address translation, 9, 10

RAM, 78

opt argument, 418

options argument, 116

OSArray, 69, 70

OSBoolean class, 69

OSBundleLibraries, 44, 180, 413

OSBundleLibraries dictionary, 43, 6061

OSDeclareDefaultDestructors() macro, 66

OSDefineMetaClassAndStructors() macro, 66

OSDictionary, 69, 313

OSDictionary object, 63

OSKextRequestResource function, 42425

OSNumber class, 69

OSOBject, 192

OSOrderedSet, 69

OSSet, 69

OSString class, 69

OSSwapLittleToHostInt64(), 349

OSSymbol class, 69

outputPacket() method, 31617

outputPowerCharacter, 209

outputStructSize argument, 90

outputStructSize arguments, 91

images P, Q

PackageMaker, 429

PackageMaker, KEXT

.user interface, 434

"Volume selected by user" option, 435

binary compressed package file, 435

contents addition, 43637

file command, 435

FireWire, PCI, and USB, 435

GUI-based wizard, 435

Hello World Kernel Extension, 436

Installer.app program, 435

Launch Agents/Daemons, 434

package building, 44142

package configuration

“Actions” editor, 441

“Actions” tab, 438

“Allow custom location” option, 439

“Apply Recommendations” button, 440

“Contents” tab, 440

“Destination” field, 439

“Edit Interface” option, 437

“Install” field, 439

“Package Location” field, 440

“Patch” field, 439

“Require admin authentication”, 440

“Requirements” tab, 438

“Restart Action”, 439

“rm” command, 441

“Scripts” tab, 439, 441

action editor, 438

bundle/individual file, 440

HelloWorld.kext, 438

Installer.app, 437

Launch Agents/Daemons, 440

meta data files, 441

meta-data and version information, 439

root user, 441

test subset, 438

wheel group, 441

software distributions, 434

uninstallation, 442

UNIX scripts, 435

user interface, 435

Xcode, 435

PCI Express (PCIe), 174

performAudioEngineStart() method, 272, 273

performAudioEngineStop() method, 27273

performRead() and performWrite() methods, 329

Peripheral component interconnect (PCI), 173

configuration space registers, 17576

DMA. See Direct Memory Access

ExpressCard, 175

I/O Kit

Configuration space registers. See Configuration space registers

display controller, 181

handling device removal, 18992

IOAGPDevice, 177

IOMatchCategory, 181

IOPCIBridge, 177

IOPCIDevice object, 177

IOPCIFamily class hierarchy, 176, 177

matching and loading drivers, 17880

memory regions. See I/O memory regions

MyFirstPCIDriver class. See MyFirstPCIDriver class

interrupts

direct interrupt, 193

handling primary interrupts, 19798

handling secondary interrupts, 198- 99

I/O Kit mechanisms, 19394

indirect interrupts, 193

ISR, 19293

MSI, 192, 19697

OS X and iOS, 193

primary interrupt context, 192

registration, 19596

secondary interrupt context, 192

PCI Express, 174

PCI-X and PCI-X 2.0 standards, 173

Thunderbolt, 174

Physical Address Extensions (PAE), 100

Power management, 205

doze state, PCI card, 205

I/O Kit, 2067

I/O registry power plane, 2056

power state changes

acknowledgeSetPowerState(), 214

driver registration, 21112

driver removal, 212

for driver, 211

gPowerStates array, 211

handling device idle, 21617

header file, 22021

implementation file, 22124

IOPMPowerState structure, 208

IOPMPowerState structures, 210

IOService class, 210

joinPMtree() method, 212

kIOPMAckImplied code, 214

myReadDataFromDevice() method, 224

notifications, 208

observation, 21819

off and on states, 208, 219

PMinit() method, 212

powerStateOrdinal parameter, 214

registerPowerDriver() method, 212, 214

request response, 21214

requesting, 21416

setPowerState() method, 212, 214

structure fields, 20810

sleep mode, 205

powerChangeDone() method, 219

powerDomainBudget, 210

PowerPC architecture, 102

powerStateDidChangeTo() notification, 218

powerStateWillChangeTo() notification, 218

powerToAttain, 210

pre-Lion operating systems, 434

prepare() method, 203

Primary interrupt filter method, 197

proc_selfname() function, 422

proc_selfpid() function, 422

protosw, 276

publishMediumDictionary() method, 313

Pulse Code Modulation (PCM), 250

images R

RAM, 78

RAMDiskStorageDevice nub class header file, 33132

ReadIsochPipeAsync method, 384

ReadPipe, 377

ReadPipeAsync, 378

ReadPipeAsyncTO, 378

ReadPipeTO, 378

receivePacketFromHardware(), 321

registerInterestedDriver(IOService* driver) method, 218

registerNotificationPort() method, 427

ResetDevice, 366

ResetPipe, 375

Rosetta, 20, 102

runAction(), 140

images S

Sample depth, 250

Sample frame, 250

Sample rate, 250

sampleBuf parameter, 271

scheduleSecondaryInterrupt variable, 198

sDelayForTime(), 98

Secondary interrupt handler function, 199

Serial port drivers

Apple USB serial driver, 226

AppleUSBCDC driver, 226

AppleUSBCDCDMM class, 227

attach() method, 228

C++ new operator, 228

Communications Device Class, 226

createSerialStream() method, 227, 229

Darwin source code repository, 226

data transmission, 223

executeEvent() and requestEvent() method, 239, 241, 242

I/O Kit, 226

init() method, 228

IOModemSerialStreamSync class, 229

IOSerialDriverSync Class, 226

AppleUSBCDCDMM driver, 232, 233

dequeueData() method, 232

IOSerialDriverSync interface, 230, 231, 232

refCon value, 231

watchState() method, 232

IOSerialFamily kernel module, 229

IOSerialStreamSync class, 227

IOSerialStreamSync Object, 228

IOUSBDevice object, 226

kernel serial driver stack, 226

kIOTTYBaseNameKey and kIOTTYSuffixKey properties, 230

Mac OS X, 224, 225, 226

PD_E_FRAMING_ERROR, 242

PD_E_HW_OVERRUN_ERROR and PD_E_SW_OVERRUN_ERROR, 242

PD_E_INTEGRITY_ERROR, 242

PD_RS232_E_RX_LINE_BREAK, 242

registerService() method, 229

serial data transfer

CheckQueues() function, 246

dequeueData() method, 243, 245, 246

driver internal transmit buffer, 246, 247

enqueueData() method, 243, 244

IOSerialBSDClient, 243

requestEvent() method, 243

StartHardwareTransmit() function, 244

transmit buffer, 243

serial port settings, 239

tcsetattr() and tcgetattr() functions, 239

user space application, 223

/dev directory, 248

character device, 249, 250

I/O Registry, 248

IOSerialBSDClient objects, 248

kIOCalloutDeviceKey, 249

Serial port drivers, user space application (cont.)

kIODialinDeviceKey, 249

kIOTTYDeviceKey, 248

matching dictionary, 248

Set option function, 419

SetAlternateInterface, 374

SetConfiguration, 369

setHardwareAddress() method, 314

setIdleTimerPeriod(period) method, 216

setIOEnable() method, 189

setLinkStatus() method, 313

setNumSampleFramesPerBuffer() method, 266

setPowerState() method, 216, 217, 218, 220

setProperties() method, 82

setProperty, 189

setSelectedMedium(), 313

settleDownTime, 210

settleUpTime, 210

sf_connect_in filter function, 28990

sf_connect_in function, 289

sf_connect_out filter function, 289

sf_data_out function, 29091

sf_handle structure, 283

sflt_register() function, 284, 285

sflt_register() function add_entry() function, 285

sft_name, 284

sGetElapsedTimerTime(), 98

SleepX tool, 433

sock_data_filt_flag_oob flag, 291

sock_data_filt_flag_record flag, 291

sockaddr structure, 289, 291

Socket filters

AppWall

ALF.kext, 284

IP version 4, 284

operation and data structures, 286

registration, 28485

unabridged source, 284

attachment and detachment

attach callback, 287

cookie parameter, 287

detach callback, 28889

ENOPOLICY, 288

IP address retrieval, 287

proc_selfname(), 288

sf_attach function, 286

sf_attach() function, 288

sf_detach function, 286

sflt_unregister(), 288

auxiliary protocols, 282

bind() and listen(), 282

connections handling, 28990

data input and output, 29092

definition, 284

filter IP-based traffic, 281

sf_attach and sf_detach, 283

sf_flags field, 283

sflt_filter structure, 28283

SFLT_GLOBAL, 283

SFLT_PROG, 283

socket structure, 276

Spin locks

Boolean flag, 128

CPU cycles spinning, 128

deadlock, 128

interrupt handler, 129

IOSimpleLock functions, 12930

multiprocessor system, 128

unsigned 32-bit integer, 128

startFrame parameter, 381

stateNumber argument, 218

staticPower, 209

stop() method, 191

Storage systems, 319

driver stack, 320

external USB flash drive vs. internal hard disk, 319

I/O Kit, 319

IOBlockStorageDevice interface

Disk Utility, 324

doAsyncReadWrite, 327

doDiscard method, 325

doEjectMedia, 326

doFormatMedia, 325

doGetFormatCapacities, 325

doLockUnlockMedia, 326

doSynchronizeCache, 327

doUnmap method, 326

getAdditionalDeviceInfoString, 324

getProductString, 324

getRevisionString, 324

getVendorString, 324

getWriteCacheState, 327

logical blocks, 321

reportBlockSize, 325

reportLockability, 324

reportMaxValidBlock, 325

reportMediaState, 324

reportPollRequirements, 324

reportRemovability and reportEjectability, 324

reportWriteProtection, 325

requestIdle, 326

setWriteCacheState, 327

subclass implementation methods, 32223

System Information, 324

layered stack, 319

media filter drivers. See Media filter drivers

multiple drivers, 319

partition schemes

attachMediaObjectToDeviceTree() method, 345

hypothetical partition scheme, 347

instantiateMediaObject() method implementation, 34850

IOBufferMemoryDescriptor, 347

IOGUIDPartitionTableScheme, 341

IOMemoryDescriptor, 347

IOPartitionScheme class, 340, 341

IOService method, 344

kIODirectionIn, 347

Mac OS X, 340

matching dictionary, property list, 34142

media content hint property, 351

OSSet, 347

partition entry verification, 348

probe() method, 34244

read() method, 347

scan() method, 34546

start() method, 34244

stop() and free() methods, 35051

strcmp() function, 347

RAM disk device

block and character device interface, 340

block and character device interfaces, 340

buffer cache, 340

com_osxkernel_driver_RAMDiskStorageDevice class, 330

com_osxkernel_driver_RAMDiskStorageDevice class implementation, 33235

createBlockStorageDevice() method, 330

Disk Utility application, 33638

diskutil list command, 340

driver stack, 337

GUID partition table, 338, 339

I/O Kit, 327

IOBlockStorageDevice class, 339

IOBlockStorageDevice nub, 33031

IOBlockStorageDriver class, 339

IOMedia class, 339

IOMediaBSDClient class, 339

IOMediaBSDClient object, 339

IORegisterExplorer utility, 336

IOResources class, 327

IOService class, 327

IOStorageFamily, 339

IOStorageFamily framework, 335

kernel extension, 335, 336

Mac OS X implementation, 327

matching dictionary, 335

memory allocation, 327

OSBundleLibraries, 335

property list, 335, 336

RAMDisk class, 329

RAMDiskStorageDevice, 330

registerService() method, 331

standard Mac OS X dialog, 336

transport driver header file, 328

transport driver implementation, 32829

transport layer drivers, 32021

VFS layer, 319

streamFormat parameter, 271

Streaming SIMD Extensions (SSE), 41112

Struct task, 105

Subsytem vendor/device ID, 176

Synchronization and threading, 119

arbitration, 119

asynchronous events. See Work loops

atomic operations

ARM instruction set, 123

bitwise AND and OR, 12526

definition, 123

functions, 12324

LOCK prefix, 123

object reference counting implementation, 12425

OSBitAndAtomic() function, 125

OSBitOrAtomic() function, 125

OSCompareAndSwap() function, 125, 126

OSDecrementAtomic(), 125

race condition, 123

release() method, 125

retain() and release() implementation, 124

retainCount value, 125

interrupt service routine, 119

Synchronization and threading (cont.)

kernel threads

<IOKit/IOLib.h> header file, 143

<kern/thread.h> header file, 143

continuation argument, 144

delay operation, 143

interrupt handler, 143

kernel_thread_start() function, 144

new_thread argument, 144

parameter function, 144

pthread_create() function, 144

sleep operation, 143

thread_terminate() function, 144

time-consuming operation, 143

user space process, 143

waitResult function, 144

locks

condition variables. See Condition variables

I/O Kit, 127

mutexes. See Mutexes

race conditions, 127

read/write mutexes, 13637

shared resource, 127

spin. See Spin locks

multiple CPU cores, 119

primitives

EAX register, 122

mov instruction, 121

OSObject class, 120

OSObject implementation, 120

race condition, 122

release() function, 120

retain() function, 12021

retainCount, 122

images T

takeTimeStamp(), 273

takeTimeStamp() function, 272

takeTimeStamp() method, 273

tcpdump, 3012

tcplognke, 292

terminate() method, 191

Thread, 1112

Thunderbolt, 174

timeToAttain, 210

timeToLower, 210

transaction argument, 140

transmitPacketToHardware() method, 31718

images U

unbudgetedPower, 210

Unified buffer cache (UBC), 37, 38

unique identifier (UID), 432

unitinfo parameter, 418

Universal Buffer Cache (UBC), 104

Universal host controller interface (UHCI), 145

Universal serial bus (USB)

bulk endpoints, 149

configuration descriptor, 150

control endpoints, 149

control requests, 171

device and driver handling, 153, 154

device classes, 151

device descriptor, 150

device removals, 164, 165

device requests, 168, 170, 171

driver loading, 154, 156

driver startup, 163, 164

endpoint descriptor, 150

endpoint enumeration, 166, 167, 168

host controller, 142, 144, 145

I/O bulk and interrupt

asynchronous requests, 175, 176

completion parameter, 172

completionTimeout, 172

endpoints, 173

errors and pipe stalls, 174

IOMemoryDescriptor, 172

IOUSBPipe class, 171

isochronous I/O, 174, 175

Read() and Write() method, 171, 172

reqCount, 172

I/O kit, 152

implementers forum, 141

interface descriptor, 150

interface enumeration, 165, 166

interrupt endpoints, 149

interrupt transfer, 143

iSight camera, 143

isochronous endpoints, 149

key characteristics, 143

MacBook, 142

mass storage device driver

attach() method, 162

bInterfaceClass, 161

IOMatchCategory key, 161

IOUSBInterface, 163

IOUSBMassStorageClass, 161

kernel.log, 162

kextlibs tools, 162

matching dictionary, 161

MyFirstUSBDriver.cpp, 158, 159, 160

MyFirstUSBDriver.h, 158

OSBundleLibraries dictionary, 162

start() method, 161

thumb/flash drive, 158

virtual driver, 157

master-slave system, 141

message pipe, 149

On-The-Go (OTG), 145

prober, 156, 157

protocol, 146

communication protocol, 146

cyclic redundancy check field, 148

data packet, 146

data packets, 148

end of packet (EOP) field, 148

endpoint field, 148

frame packet, 146

handshake packet, 146

isochronous transfer modes, 149

little-endian format (LSB), 146

packet identifier values, 147, 148

packet type layout, 147

token packet, 146

transaction, 148

stream pipe, 149

topology, 142

transfer speeds, 144

version 3.0, 141

unmap() method, 189

updateFrequency parameter, 384

USBDeviceAbortPipeZero, 367

USBDeviceReEnumerate, 366

USBGetManufacturerStringIndex, 365

USBGetProductStringIndex, 365

USBGetSerialNumberStringIndex, 365

USBInterfaceGetStringIndex, 374

User client methods

callback function, 94

clientClose() method, 86, 88

clientDied() method, 86

DelayForTime(), 97

DelayForTime() function, 92

dispatch table, 9597

driver object and user client objects, 84

externalMethod(), 93, 95, 98

externalMethod() implementation, 92, 97

getElapsedTimerTime(), 98

GetElapsedTimerTime() and DelayForTime() methods, 98

GetElapsedTimerTime() implementation, 91

GetElapsedTimerTimer(), 97

header file, 8586

implementation, 8687

initWithTask() method, 87

inputStruct argument, 90

IOConnectCallMethod() function, 91

IOConnectCallScalarMethod() function, 89, 91

IOConnectCallStructMethod() function, 90, 91

IOExternalMethodArguments structure, 9293, 97

IOExternalMethodDispatch, 95

IOExternalMethodDispatch structure, 93

IOMemoryDescriptor class, 93

IOService, 84

IOService class, 85

IOServiceClose() function, 86

IOUserClient class, 84

library functions, 88

MyUserClient class, 85

newUserClient() method, 85

outputCount argument, 90

outputStruct buffer, 90

outputValues array, 90

pseudocode, 9495

scalarOutput array, 98

start() method, 88

StartTimer() and StopTimer() functions, 91

structureInput buffer, 98

structureInputDescriptor and structureOutputDescriptor, 93

TestDriverInterface.h, 89

TimerRequestCode enumeration, 90, 97

user space interface, 88

User-space USB drivers, 357

asynchronous operations, 36364

extensions directory, 357

IOUSBDevice class, 358

IOUSBDeviceInterface class. See IOUSBDeviceInterface class

IOUSBInterface class, 358

IOUSBInterfaceInterface class. See IOUSBInterfaceInterface class

IOUSBLib, 358

User-space USB drivers (cont.)

IOUSBLib framework

AddRef() method, 363

IOCFPlugInInterface class, 363

IOCreatePlugInInterfaceForService, 362

IOCreatePlugInInterfaceForService() function, 362

IODestroyPlugInInterface(), 362

IOUSBLib.h header file, 362

IUnknown class, 363

matching dictionary, 35962

notification callback, 358

plugin variable, 363

QueryInterface, 362

QueryInterface() method, 362, 363

Release() method, 363

layers, 358

PCI and Thunderbolt devices, 357

primary interrupt level, 357

images V

Vendor ID, 175

Virtual File System layer (VFS layer), 319

Virtual memory addresses, 120

Virtual memory structure, 105

Virtual Private Network (VPN), 431

vm_page_alloc() function, 105

vm_page_grab function, 104

images W

whatDevice argument, 218

willChange notification, 219

willTerminate() method, 191

Windows Registry, 63

withSpecification() factory method, 318

wMaxPacketSize, 374

Work loops

advantages, 138

callback function, 139

getWorkLoop() method, 138, 139

hardware interrupts/timers, 137

interrupt handler, 139

IOCommandGate, 13941

IOEventSource function, 139

IOWorkLoop object, 137, 13839

OSObject class, 139

release, 14243

timers, 14142

WriteIsochPipeAsync method, 384

WritePipe, 377

WritePipeAsync, 378

WritePipeAsyncTO, 378

WritePipeTO, 378

images X, Y

Xcode, 433

Xcode 4 user interface, 40, 41

XNU kernel

architecture, 22

BSD layer, 22

file systems, 36

FreeBSD 5 operating system, 34

networking, 36

services overview, 34

system calls, 35

UBC, 37, 38

virtual file system, 37

I/O kit, 38, 40

I/O Kit, 22

KEXT, 22

Mach layer, 21

exceptions, 26, 27

hardware abstraction, 23

interprocess communication, 25, 26

memory allocation, 34

memory management, 28

pagers, 33, 34

physical map, 30

scheduling, 24, 25

task address space, 28, 31, 32, 33

tasks and threads, 23

time management, 27, 28

virtual memory map, 29, 30

virtual memory objects, 30, 31

images Z

zinit() function, 105

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.12.124