premier push
This commit is contained in:
commit
b03b6c8197
405 files changed
+152754
No files matched your search
@@ -0,0 +1,348 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 77;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
AE7E20C7307F7D1E000AD02F /* QualcommWireless.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QualcommWireless.kext; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||
AE7E20CF307F7D1E000AD02F /* Exceptions for "QualcommWireless" folder in "QualcommWireless" target */ = {
|
||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||
membershipExceptions = (
|
||||
Info.plist,
|
||||
);
|
||||
target = AE7E20C6307F7D1E000AD02F /* QualcommWireless */;
|
||||
};
|
||||
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||
|
||||
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||
AE7E20C9307F7D1E000AD02F /* QualcommWireless */ = {
|
||||
isa = PBXFileSystemSynchronizedRootGroup;
|
||||
exceptions = (
|
||||
AE7E20CF307F7D1E000AD02F /* Exceptions for "QualcommWireless" folder in "QualcommWireless" target */,
|
||||
);
|
||||
path = QualcommWireless;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXFileSystemSynchronizedRootGroup section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
AE7E20C4307F7D1E000AD02F /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
AE7E20BD307F7D1E000AD02F = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
AE7E20C9307F7D1E000AD02F /* QualcommWireless */,
|
||||
AE7E20C8307F7D1E000AD02F /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
AE7E20C8307F7D1E000AD02F /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
AE7E20C7307F7D1E000AD02F /* QualcommWireless.kext */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
AE7E20C2307F7D1E000AD02F /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
AE7E20C6307F7D1E000AD02F /* QualcommWireless */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = AE7E20D0307F7D1E000AD02F /* Build configuration list for PBXNativeTarget "QualcommWireless" */;
|
||||
buildPhases = (
|
||||
AE7E20C2307F7D1E000AD02F /* Headers */,
|
||||
AE7E20C3307F7D1E000AD02F /* Sources */,
|
||||
AE7E20C4307F7D1E000AD02F /* Frameworks */,
|
||||
AE7E20C5307F7D1E000AD02F /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
fileSystemSynchronizedGroups = (
|
||||
AE7E20C9307F7D1E000AD02F /* QualcommWireless */,
|
||||
);
|
||||
name = QualcommWireless;
|
||||
packageProductDependencies = (
|
||||
);
|
||||
productName = QualcommWireless;
|
||||
productReference = AE7E20C7307F7D1E000AD02F /* QualcommWireless.kext */;
|
||||
productType = "com.apple.product-type.kernel-extension";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
AE7E20BE307F7D1E000AD02F /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = 1;
|
||||
LastUpgradeCheck = 1640;
|
||||
TargetAttributes = {
|
||||
AE7E20C6307F7D1E000AD02F = {
|
||||
CreatedOnToolsVersion = 16.4;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = AE7E20C1307F7D1E000AD02F /* Build configuration list for PBXProject "QualcommWireless" */;
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = AE7E20BD307F7D1E000AD02F;
|
||||
minimizedProjectReferenceProxies = 1;
|
||||
preferredProjectObjectVersion = 77;
|
||||
productRefGroup = AE7E20C8307F7D1E000AD02F /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
AE7E20C6307F7D1E000AD02F /* QualcommWireless */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
AE7E20C5307F7D1E000AD02F /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
AE7E20C3307F7D1E000AD02F /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
AE7E20D1307F7D1E000AD02F /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1.0.2;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"__IO80211_TARGET=150000",
|
||||
"$(inherited)",
|
||||
);
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/QualcommWireless/include",
|
||||
);
|
||||
INFOPLIST_FILE = QualcommWireless/Info.plist;
|
||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.5;
|
||||
MARKETING_VERSION = 1.0.2;
|
||||
MODULE_NAME = com.nawrhehe.QualcommWireless;
|
||||
MODULE_VERSION = 1.0.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nawrhehe.QualcommWireless;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
RUN_CLANG_STATIC_ANALYZER = YES;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
WRAPPER_EXTENSION = kext;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
AE7E20D2307F7D1E000AD02F /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1.0.2;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"__IO80211_TARGET=150000",
|
||||
"$(inherited)",
|
||||
);
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/QualcommWireless/include",
|
||||
);
|
||||
INFOPLIST_FILE = QualcommWireless/Info.plist;
|
||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.5;
|
||||
MARKETING_VERSION = 1.0.2;
|
||||
MODULE_NAME = com.nawrhehe.QualcommWireless;
|
||||
MODULE_VERSION = 1.0.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nawrhehe.QualcommWireless;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
RUN_CLANG_STATIC_ANALYZER = YES;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
WRAPPER_EXTENSION = kext;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
AE7E20D3307F7D1E000AD02F /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.5;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
AE7E20D4307F7D1E000AD02F /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.5;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
AE7E20C1307F7D1E000AD02F /* Build configuration list for PBXProject "QualcommWireless" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
AE7E20D3307F7D1E000AD02F /* Debug */,
|
||||
AE7E20D4307F7D1E000AD02F /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
AE7E20D0307F7D1E000AD02F /* Build configuration list for PBXNativeTarget "QualcommWireless" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
AE7E20D1307F7D1E000AD02F /* Debug */,
|
||||
AE7E20D2307F7D1E000AD02F /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = AE7E20BE307F7D1E000AD02F /* Project object */;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,36 @@
|
||||
#ifndef _FIRMWARE_WCN7850_WIFI_H
|
||||
#define _FIRMWARE_WCN7850_WIFI_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const uint8_t wcn7850_amss_bin[];
|
||||
extern const uint8_t wcn7850_amss_bin_end[];
|
||||
|
||||
extern const uint8_t wcn7850_board2_bin[];
|
||||
extern const uint8_t wcn7850_board2_bin_end[];
|
||||
|
||||
extern const uint8_t wcn7850_m3_bin[];
|
||||
extern const uint8_t wcn7850_m3_bin_end[];
|
||||
|
||||
static inline size_t get_wcn7850_amss_size(void) {
|
||||
return (size_t)(wcn7850_amss_bin_end - wcn7850_amss_bin);
|
||||
}
|
||||
|
||||
static inline size_t get_wcn7850_board2_size(void) {
|
||||
return (size_t)(wcn7850_board2_bin_end - wcn7850_board2_bin);
|
||||
}
|
||||
|
||||
static inline size_t get_wcn7850_m3_size(void) {
|
||||
return (size_t)(wcn7850_m3_bin_end - wcn7850_m3_bin);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
.section __TEXT,__const
|
||||
.globl _wcn7850_amss_bin
|
||||
.globl _wcn7850_amss_bin_end
|
||||
_wcn7850_amss_bin:
|
||||
.incbin "/Users/erwan/Documents/QualcommWireless/firmware/amss.bin"
|
||||
_wcn7850_amss_bin_end:
|
||||
|
||||
.globl _wcn7850_board2_bin
|
||||
.globl _wcn7850_board2_bin_end
|
||||
_wcn7850_board2_bin:
|
||||
.incbin "/Users/erwan/Documents/QualcommWireless/firmware/board-2.bin"
|
||||
_wcn7850_board2_bin_end:
|
||||
|
||||
.globl _wcn7850_m3_bin
|
||||
.globl _wcn7850_m3_bin_end
|
||||
_wcn7850_m3_bin:
|
||||
.incbin "/Users/erwan/Documents/QualcommWireless/firmware/m3.bin"
|
||||
_wcn7850_m3_bin_end:
|
||||
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>KEXT</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.2</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0.2</string>
|
||||
<key>IOKitPersonalities</key>
|
||||
<dict>
|
||||
<key>QualcommWireless_BT</key>
|
||||
<dict>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.nawrhehe.QualcommWireless</string>
|
||||
<key>IOClass</key>
|
||||
<string>QualcommWireless</string>
|
||||
<key>IOMatchCategory</key>
|
||||
<string>QualcommWireless</string>
|
||||
<key>IOProviderClass</key>
|
||||
<string>IOUSBHostDevice</string>
|
||||
<key>idVendor</key>
|
||||
<integer>1161</integer>
|
||||
<key>idProduct</key>
|
||||
<integer>57613</integer>
|
||||
<key>IOProbeScore</key>
|
||||
<integer>5000</integer>
|
||||
</dict>
|
||||
<key>QualcommWireless_WiFi</key>
|
||||
<dict>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.nawrhehe.QualcommWireless</string>
|
||||
<key>IOClass</key>
|
||||
<string>QualcommWifi</string>
|
||||
<key>IOMatchCategory</key>
|
||||
<string>IODefaultMatchCategory</string>
|
||||
<key>IONameMatch</key>
|
||||
<string>pci17cb,1107</string>
|
||||
<key>IOPCIPrimaryMatch</key>
|
||||
<string>0x110717cb</string>
|
||||
<key>IOProbeScore</key>
|
||||
<integer>20000</integer>
|
||||
<key>IOProviderClass</key>
|
||||
<string>IOPCIDevice</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>OSBundleLibraries</key>
|
||||
<dict>
|
||||
<key>com.apple.kpi.libkern</key>
|
||||
<string>15.0</string>
|
||||
<key>com.apple.kpi.iokit</key>
|
||||
<string>15.0</string>
|
||||
<key>com.apple.kpi.mach</key>
|
||||
<string>15.0</string>
|
||||
<key>com.apple.iokit.IOUSBHostFamily</key>
|
||||
<string>1.2</string>
|
||||
<key>com.apple.iokit.IOPCIFamily</key>
|
||||
<string>2.9</string>
|
||||
<key>com.apple.iokit.IONetworkingFamily</key>
|
||||
<string>3.2</string>
|
||||
<key>com.apple.iokit.IO80211Family</key>
|
||||
<string>1200.12.2b1</string>
|
||||
<key>com.apple.iokit.IOSkywalkFamily</key>
|
||||
<string>1.0</string>
|
||||
<key>com.apple.driver.corecapture</key>
|
||||
<string>1.0.0</string>
|
||||
<key>com.apple.kpi.bsd</key>
|
||||
<string>15.0</string>
|
||||
</dict>
|
||||
<key>OSBundleRequired</key>
|
||||
<string>Root</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,918 @@
|
||||
#include "QualcommWifi.hpp"
|
||||
#include <IOKit/IOLib.h>
|
||||
#include <libkern/OSByteOrder.h>
|
||||
#include <kern/task.h>
|
||||
#include <string.h>
|
||||
|
||||
#define super IO80211Controller
|
||||
OSDefineMetaClassAndStructors(QualcommWifi, IO80211Controller)
|
||||
|
||||
bool QualcommWifi::init(OSDictionary *dictionary) {
|
||||
if (!super::init(dictionary)) {
|
||||
return false;
|
||||
}
|
||||
fPciDevice = nullptr;
|
||||
fBar0Map = nullptr;
|
||||
fBar0Virt = nullptr;
|
||||
fCurrWindow = 0xFFFFFFFF;
|
||||
fInterruptSource = nullptr;
|
||||
fNetif = nullptr;
|
||||
bzero(&fMacAddress, sizeof(fMacAddress));
|
||||
fLinkActive = false;
|
||||
fCurrentChannel = 1;
|
||||
fLastRssi = -50;
|
||||
fSsidLen = 0;
|
||||
bzero(fSsid, sizeof(fSsid));
|
||||
bzero(fBssid, sizeof(fBssid));
|
||||
fScanInProgress = false;
|
||||
fDmaBuf = nullptr;
|
||||
fDmaPhysAddr = 0;
|
||||
fDmaVirtAddr = nullptr;
|
||||
fDmaPrepared = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void QualcommWifi::free(void) {
|
||||
super::free();
|
||||
}
|
||||
|
||||
IOService *QualcommWifi::probe(IOService *provider, SInt32 *score) {
|
||||
return super::probe(provider, score);
|
||||
}
|
||||
|
||||
UInt32 QualcommWifi::read32(UInt32 offset) {
|
||||
if (!fBar0Virt || offset >= 0x200000) {
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
return OSReadLittleInt32(fBar0Virt, offset);
|
||||
}
|
||||
|
||||
void QualcommWifi::write32(UInt32 offset, UInt32 value) {
|
||||
if (!fBar0Virt || offset >= 0x200000) {
|
||||
return;
|
||||
}
|
||||
OSWriteLittleInt32(fBar0Virt, offset, value);
|
||||
}
|
||||
|
||||
void QualcommWifi::selectWindow(UInt32 offset) {
|
||||
UInt32 window = (offset >> ATH12K_PCI_WINDOW_SHIFT) & ATH12K_PCI_WINDOW_VALUE_MASK;
|
||||
if (window != fCurrWindow) {
|
||||
write32(ATH12K_PCI_WINDOW_REG_ADDRESS, ATH12K_PCI_WINDOW_ENABLE_BIT | window);
|
||||
(void)read32(ATH12K_PCI_WINDOW_REG_ADDRESS);
|
||||
fCurrWindow = window;
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 QualcommWifi::socRead32(UInt32 offset) {
|
||||
if (offset < ATH12K_PCI_WINDOW_START) {
|
||||
return read32(offset);
|
||||
}
|
||||
selectWindow(offset);
|
||||
return read32(ATH12K_PCI_WINDOW_START + (offset & ATH12K_PCI_WINDOW_RANGE_MASK));
|
||||
}
|
||||
|
||||
void QualcommWifi::socWrite32(UInt32 offset, UInt32 value) {
|
||||
if (offset < ATH12K_PCI_WINDOW_START) {
|
||||
write32(offset, value);
|
||||
return;
|
||||
}
|
||||
selectWindow(offset);
|
||||
write32(ATH12K_PCI_WINDOW_START + (offset & ATH12K_PCI_WINDOW_RANGE_MASK), value);
|
||||
}
|
||||
|
||||
// Équivalent de dma_alloc_coherent() avec DMA_BIT_MASK(36) sous Linux
|
||||
bool QualcommWifi::allocDmaContext(IOByteCount size) {
|
||||
fDmaBuf = IOBufferMemoryDescriptor::inTaskWithPhysicalMask(
|
||||
kernel_task,
|
||||
static_cast<IOOptionBits>(kIODirectionInOut) | static_cast<IOOptionBits>(kIOMemoryPhysicallyContiguous),
|
||||
size,
|
||||
ATH12K_DMA_MASK_36BIT_PAGE
|
||||
);
|
||||
|
||||
if (!fDmaBuf) {
|
||||
IOLog("QualcommWifi: Erreur - Impossible d'allouer le descripteur DMA 36-bit.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fDmaBuf->prepare(kIODirectionInOut) != kIOReturnSuccess) {
|
||||
IOLog("QualcommWifi: Erreur - Impossible de verrouiller (prepare) les pages DMA.\n");
|
||||
OSSafeReleaseNULL(fDmaBuf);
|
||||
return false;
|
||||
}
|
||||
fDmaPrepared = true;
|
||||
|
||||
fDmaVirtAddr = fDmaBuf->getBytesNoCopy();
|
||||
IOByteCount segLen = 0;
|
||||
fDmaPhysAddr = fDmaBuf->getPhysicalSegment(0, &segLen);
|
||||
|
||||
if (!fDmaVirtAddr || !fDmaPhysAddr || segLen < size) {
|
||||
IOLog("QualcommWifi: Erreur - Segment physique DMA invalide (segLen=%llu).\n", (uint64_t)segLen);
|
||||
freeDmaContext();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remise à zéro de la zone DMA (comme kzalloc / dma_alloc_coherent)
|
||||
bzero(fDmaVirtAddr, size);
|
||||
|
||||
IOLog("QualcommWifi: Tampon DMA 36-bit pret ! Phys: 0x%llx, Taille: %llu octets (Contigu: %llu)\n",
|
||||
(uint64_t)fDmaPhysAddr, (uint64_t)size, (uint64_t)segLen);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QualcommWifi::freeDmaContext(void) {
|
||||
if (fDmaBuf) {
|
||||
if (fDmaPrepared) {
|
||||
fDmaBuf->complete(kIODirectionInOut);
|
||||
fDmaPrepared = false;
|
||||
}
|
||||
OSSafeReleaseNULL(fDmaBuf);
|
||||
}
|
||||
fDmaVirtAddr = nullptr;
|
||||
fDmaPhysAddr = 0;
|
||||
}
|
||||
|
||||
void QualcommWifi::interruptOccurred(OSObject *owner, IOInterruptEventSource *src, int count) {
|
||||
IOLog("QualcommWifi: Interruption materielle MSI recue (count=%d) !\n", count);
|
||||
}
|
||||
|
||||
bool QualcommWifi::loadBhiFirmware(void) {
|
||||
if (!fBar0Virt || !fPciDevice) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UInt32 bhiOff = read32(ATH12K_MHI_BHIOFF);
|
||||
UInt32 bhieOff = read32(ATH12K_MHI_BHIEOFF);
|
||||
if (bhiOff == 0xFFFFFFFF || bhiOff >= 0x200000 || bhieOff == 0xFFFFFFFF || bhieOff >= 0x200000) {
|
||||
IOLog("QualcommWifi: Erreur - BHI/BHIe Offsets invalides (BHI: 0x%08x, BHIe: 0x%08x)\n", bhiOff, bhieOff);
|
||||
setProperty("BHI_Load_Error", "Invalid_Offsets");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Désactivation d'ASPM PCIe pour stabiliser le transfert firmware (recommandation ath12k)
|
||||
UInt8 pciCapOffset = 0;
|
||||
if (fPciDevice->findPCICapability(kIOPCIPCIExpressCapability, &pciCapOffset) && pciCapOffset != 0) {
|
||||
UInt16 linkCtrl = fPciDevice->configRead16(pciCapOffset + 0x10);
|
||||
linkCtrl &= ~0x3; // Désactive ASPM L0s / L1
|
||||
fPciDevice->configWrite16(pciCapOffset + 0x10, linkCtrl);
|
||||
IOLog("QualcommWifi: ASPM PCIe désactivé pour stabilité du transfert firmware (LinkCtrl: 0x%04x)\n", linkCtrl);
|
||||
}
|
||||
|
||||
// Étape 1 : Réinitialisation MHI et effacement des vecteurs BHIe (ath12k_mhi_clear_vector)
|
||||
write32(bhieOff + ATH12K_BHIE_TXVECDB, 0);
|
||||
write32(bhieOff + ATH12K_BHIE_TXVECSTATUS, 0);
|
||||
write32(bhieOff + ATH12K_BHIE_RXVECDB, 0);
|
||||
write32(bhieOff + ATH12K_BHIE_RXVECSTATUS, 0);
|
||||
|
||||
write32(ATH12K_MHI_MHICTRL, ATH12K_MHICTRL_RESET_MASK); // MHICTRL_RESET
|
||||
IODelay(10000); // 10 ms
|
||||
|
||||
size_t fwSize = get_wcn7850_amss_size();
|
||||
size_t sblSize = 0x80000; // 512 Ko pour le Secondary Boot Loader (SBL)
|
||||
if (fwSize < sblSize) {
|
||||
IOLog("QualcommWifi: Erreur - Taille AMSS trop petite (%lu < 512 Ko)\n", fwSize);
|
||||
return false;
|
||||
}
|
||||
|
||||
IOLog("QualcommWifi: Initialisation du chargeur FBC 2-étapes (SBL: 512 Ko, Image totale: %lu octets)...\n", fwSize);
|
||||
|
||||
// Étape 2 : Allocation DMA contigu pour l'image AMSS complète
|
||||
IOBufferMemoryDescriptor *fwDma = IOBufferMemoryDescriptor::inTaskWithPhysicalMask(
|
||||
kernel_task,
|
||||
static_cast<IOOptionBits>(kIODirectionInOut) | static_cast<IOOptionBits>(kIOMemoryPhysicallyContiguous),
|
||||
fwSize,
|
||||
ATH12K_DMA_MASK_36BIT_PAGE
|
||||
);
|
||||
|
||||
if (!fwDma || fwDma->prepare(kIODirectionInOut) != kIOReturnSuccess) {
|
||||
IOLog("QualcommWifi: Erreur - Echec allocation/prepare DMA AMSS\n");
|
||||
setProperty("BHI_Load_Error", "DMA_Alloc_Failed");
|
||||
if (fwDma) OSSafeReleaseNULL(fwDma);
|
||||
return false;
|
||||
}
|
||||
|
||||
void *virt = fwDma->getBytesNoCopy();
|
||||
IOByteCount segLen = 0;
|
||||
IOPhysicalAddress phys = fwDma->getPhysicalSegment(0, &segLen);
|
||||
|
||||
if (!virt || !phys || segLen < fwSize) {
|
||||
IOLog("QualcommWifi: Erreur - Segment DMA AMSS incomplet\n");
|
||||
fwDma->complete(kIODirectionInOut);
|
||||
OSSafeReleaseNULL(fwDma);
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(virt, wcn7850_amss_bin, fwSize);
|
||||
setProperty("AMSS_DMA_Phys", (uint64_t)phys, 64);
|
||||
|
||||
// Étape 3 : Chargement du SBL (512 Ko) via BHI en mode PBL
|
||||
write32(bhiOff + ATH12K_BHI_STATUS, 0);
|
||||
write32(bhiOff + ATH12K_BHI_IMGADDR_LOW, (UInt32)(phys & 0xFFFFFFFF));
|
||||
write32(bhiOff + ATH12K_BHI_IMGADDR_HIGH, (UInt32)((phys >> 32) & 0xFFFFFFFF));
|
||||
write32(bhiOff + ATH12K_BHI_IMGSIZE, (UInt32)sblSize);
|
||||
|
||||
// Déclenchement de la sonnette PBL avec Session ID = 1 (NON-NUL exigé par PBL)
|
||||
write32(bhiOff + ATH12K_BHI_IMGTXDB, 0x1);
|
||||
IOLog("QualcommWifi: Sonnette BHI_IMGTXDB déclenchée (Session ID = 1, SBL 512 Ko)...\n");
|
||||
|
||||
UInt32 bhiStatus = 0;
|
||||
UInt32 timeoutMs = 3000;
|
||||
bool sblSuccess = false;
|
||||
|
||||
while (timeoutMs > 0) {
|
||||
bhiStatus = read32(bhiOff + ATH12K_BHI_STATUS);
|
||||
UInt32 state = (bhiStatus & ATH12K_BHI_STATUS_MASK) >> ATH12K_BHI_STATUS_SHIFT;
|
||||
if (state == ATH12K_BHI_STATUS_SUCCESS) {
|
||||
sblSuccess = true;
|
||||
break;
|
||||
} else if (state == ATH12K_BHI_STATUS_ERROR) {
|
||||
UInt32 err = read32(bhiOff + ATH12K_BHI_ERRCODE);
|
||||
IOLog("QualcommWifi: Erreur BHI SBL (code=0x%08x)\n", err);
|
||||
setProperty("BHI_ErrorCode", err, 32);
|
||||
break;
|
||||
}
|
||||
IODelay(1000); // 1 ms
|
||||
timeoutMs--;
|
||||
}
|
||||
|
||||
setProperty("BHI_FinalStatus", bhiStatus, 32);
|
||||
setProperty("BHI_Status_Raw", bhiStatus, 32);
|
||||
setProperty("BHI_Status_State", (bhiStatus & ATH12K_BHI_STATUS_MASK) >> ATH12K_BHI_STATUS_SHIFT, 32);
|
||||
|
||||
// Attente de l'exécution du SBL (BHI_EXECENV == 1) et de la disponibilité MHI (READY)
|
||||
timeoutMs = 2000;
|
||||
UInt32 ee = 0;
|
||||
while (timeoutMs > 0) {
|
||||
ee = read32(bhiOff + ATH12K_BHI_EXECENV);
|
||||
UInt32 mhiStat = read32(ATH12K_MHI_MHISTATUS);
|
||||
if (ee == ATH12K_MHI_EE_SBL || ee == ATH12K_MHI_EE_AMSS || (mhiStat & ATH12K_MHISTATUS_READY_MASK)) {
|
||||
break;
|
||||
}
|
||||
IODelay(1000);
|
||||
timeoutMs--;
|
||||
}
|
||||
|
||||
setProperty("BHI_ExecEnv_AfterLoad", ee, 32);
|
||||
setProperty("MHI_Status_After_SBL", read32(ATH12K_MHI_MHISTATUS), 32);
|
||||
setProperty("MHI_Ctrl_After_SBL", read32(ATH12K_MHI_MHICTRL), 32);
|
||||
IOLog("QualcommWifi: SBL BHI terminé (Status=0x%08x, State=%u, ExecEnv=0x%x, SBL_Succes=%d)\n",
|
||||
bhiStatus, (bhiStatus & ATH12K_BHI_STATUS_MASK) >> ATH12K_BHI_STATUS_SHIFT, ee, sblSuccess);
|
||||
|
||||
// Étape 4 : Configuration des contextes MHI MMIO et transition vers M0 (mhi_ready_state_transition selon Linux ath12k)
|
||||
bool inM0 = false;
|
||||
bool amssSuccess = false;
|
||||
uint32_t processedEvents = 0;
|
||||
|
||||
if (sblSuccess && fDmaPhysAddr != 0) {
|
||||
// Attente de la confirmation READY dans MHISTATUS
|
||||
timeoutMs = 3000;
|
||||
while (timeoutMs > 0) {
|
||||
UInt32 mstat = read32(ATH12K_MHI_MHISTATUS);
|
||||
if (mstat & ATH12K_MHISTATUS_READY_MASK) {
|
||||
break;
|
||||
}
|
||||
IODelay(1000);
|
||||
timeoutMs--;
|
||||
}
|
||||
|
||||
uint64_t chan_ctxt_phys = fDmaPhysAddr + 0x0000;
|
||||
uint64_t er_ctxt_phys = fDmaPhysAddr + 0x1000;
|
||||
uint64_t cmd_ctxt_phys = fDmaPhysAddr + 0x2000;
|
||||
uint64_t cmd_ring_phys = fDmaPhysAddr + 0x3000;
|
||||
uint64_t er0_ring_phys = fDmaPhysAddr + 0x4000;
|
||||
uint64_t er1_ring_phys = fDmaPhysAddr + 0x5000;
|
||||
|
||||
uint32_t cmd_ring_len = 64 * sizeof(struct mhi_ring_element); // 1024 octets (64 TREs)
|
||||
uint32_t er0_ring_len = 32 * sizeof(struct mhi_ring_element); // 512 octets (32 TREs) selon ath12k WCN7850
|
||||
uint32_t er1_ring_len = 256 * sizeof(struct mhi_ring_element); // 4096 octets (256 TREs)
|
||||
|
||||
// 1. Initialisation des 64 contextes de canaux (désactivés au départ)
|
||||
struct mhi_chan_ctxt *chan_ctxt = (struct mhi_chan_ctxt *)((uint8_t *)fDmaVirtAddr + 0x0000);
|
||||
bzero(chan_ctxt, 64 * sizeof(struct mhi_chan_ctxt));
|
||||
|
||||
// 2. Initialisation du contexte d'anneau de commandes
|
||||
struct mhi_cmd_ctxt *cmd_ctxt = (struct mhi_cmd_ctxt *)((uint8_t *)fDmaVirtAddr + 0x2000);
|
||||
bzero(cmd_ctxt, sizeof(struct mhi_cmd_ctxt));
|
||||
cmd_ctxt[0].rbase = OSSwapHostToLittleInt64(cmd_ring_phys);
|
||||
cmd_ctxt[0].rlen = OSSwapHostToLittleInt64(cmd_ring_len);
|
||||
cmd_ctxt[0].rp = OSSwapHostToLittleInt64(cmd_ring_phys);
|
||||
cmd_ctxt[0].wp = OSSwapHostToLittleInt64(cmd_ring_phys);
|
||||
|
||||
// 3. Initialisation des contextes d'anneau d'événements (2 anneaux selon WCN7850 ath12k)
|
||||
struct mhi_event_ctxt *evCtxt = (struct mhi_event_ctxt *)((uint8_t *)fDmaVirtAddr + 0x1000);
|
||||
bzero(evCtxt, 2 * sizeof(struct mhi_event_ctxt));
|
||||
|
||||
// Event Ring 0: CTRL ring, 32 TREs
|
||||
evCtxt[0].intmod = 0;
|
||||
evCtxt[0].ertype = OSSwapHostToLittleInt32(1); // MHI_ER_TYPE_VALID
|
||||
evCtxt[0].msivec = 0;
|
||||
evCtxt[0].rbase = OSSwapHostToLittleInt64(er0_ring_phys);
|
||||
evCtxt[0].rlen = OSSwapHostToLittleInt64(er0_ring_len);
|
||||
evCtxt[0].rp = OSSwapHostToLittleInt64(er0_ring_phys);
|
||||
evCtxt[0].wp = OSSwapHostToLittleInt64(er0_ring_phys);
|
||||
|
||||
// Event Ring 1: DATA ring, 256 TREs
|
||||
evCtxt[1].intmod = OSSwapHostToLittleInt32(1);
|
||||
evCtxt[1].ertype = OSSwapHostToLittleInt32(1); // MHI_ER_TYPE_VALID
|
||||
evCtxt[1].msivec = 0;
|
||||
evCtxt[1].rbase = OSSwapHostToLittleInt64(er1_ring_phys);
|
||||
evCtxt[1].rlen = OSSwapHostToLittleInt64(er1_ring_len);
|
||||
evCtxt[1].rp = OSSwapHostToLittleInt64(er1_ring_phys);
|
||||
evCtxt[1].wp = OSSwapHostToLittleInt64(er1_ring_phys);
|
||||
|
||||
bzero((uint8_t *)fDmaVirtAddr + 0x3000, cmd_ring_len);
|
||||
bzero((uint8_t *)fDmaVirtAddr + 0x4000, er0_ring_len);
|
||||
bzero((uint8_t *)fDmaVirtAddr + 0x5000, er1_ring_len);
|
||||
|
||||
// 4. Programmation des registres MMIO MHI
|
||||
write32(ATH12K_MHI_CCABAP_HIGHER, (UInt32)((chan_ctxt_phys >> 32) & 0xFFFFFFFF));
|
||||
write32(ATH12K_MHI_CCABAP_LOWER, (UInt32)(chan_ctxt_phys & 0xFFFFFFFF));
|
||||
write32(ATH12K_MHI_ECABAP_HIGHER, (UInt32)((er_ctxt_phys >> 32) & 0xFFFFFFFF));
|
||||
write32(ATH12K_MHI_ECABAP_LOWER, (UInt32)(er_ctxt_phys & 0xFFFFFFFF));
|
||||
write32(ATH12K_MHI_CRCBAP_HIGHER, (UInt32)((cmd_ctxt_phys >> 32) & 0xFFFFFFFF));
|
||||
write32(ATH12K_MHI_CRCBAP_LOWER, (UInt32)(cmd_ctxt_phys & 0xFFFFFFFF));
|
||||
|
||||
// MHICFG (0x10): total_ev_rings = 2, hw_ev_rings = 0 (tous logiciels pour WCN7850)
|
||||
write32(ATH12K_MHI_MHICFG, (2 << 16) | (0 << 24));
|
||||
|
||||
write32(ATH12K_MHI_MHICTRLBASE_HIGHER, 0);
|
||||
write32(ATH12K_MHI_MHICTRLBASE_LOWER, 0);
|
||||
write32(ATH12K_MHI_MHIDATABASE_HIGHER, 0);
|
||||
write32(ATH12K_MHI_MHIDATABASE_LOWER, 0);
|
||||
|
||||
write32(ATH12K_MHI_MHICTRLLIMIT_HIGHER, 0x0F);
|
||||
write32(ATH12K_MHI_MHICTRLLIMIT_LOWER, 0xFFFFFFFF);
|
||||
write32(ATH12K_MHI_MHIDATALIMIT_HIGHER, 0x0F);
|
||||
write32(ATH12K_MHI_MHIDATALIMIT_LOWER, 0xFFFFFFFF);
|
||||
|
||||
// 5. Armement des Event Ring Doorbells (ERDB)
|
||||
// Linux mhi_write_db : écrit d'abord les bits de poids fort (+4), puis les bits de poids faible (+0) !
|
||||
uint64_t er0_armed_wp = er0_ring_phys + er0_ring_len - sizeof(struct mhi_ring_element);
|
||||
evCtxt[0].wp = OSSwapHostToLittleInt64(er0_armed_wp);
|
||||
|
||||
uint64_t er1_armed_wp = er1_ring_phys + er1_ring_len - sizeof(struct mhi_ring_element);
|
||||
evCtxt[1].wp = OSSwapHostToLittleInt64(er1_armed_wp);
|
||||
|
||||
UInt32 erdbOff = read32(ATH12K_MHI_ERDBOFF);
|
||||
if (erdbOff != 0 && erdbOff < 0x200000) {
|
||||
// Sonnette ER0 (erdbOff + 0)
|
||||
write32(erdbOff + 4, (UInt32)((er0_armed_wp >> 32) & 0xFFFFFFFF));
|
||||
write32(erdbOff + 0, (UInt32)(er0_armed_wp & 0xFFFFFFFF));
|
||||
|
||||
// Sonnette ER1 (erdbOff + 8)
|
||||
write32(erdbOff + 8 + 4, (UInt32)((er1_armed_wp >> 32) & 0xFFFFFFFF));
|
||||
write32(erdbOff + 8 + 0, (UInt32)(er1_armed_wp & 0xFFFFFFFF));
|
||||
|
||||
IOLog("QualcommWifi: Event Ring Doorbells armées (ER0 @ 0x%08x WP=0x%llx, ER1 @ 0x%08x WP=0x%llx) !\n",
|
||||
erdbOff, er0_armed_wp, erdbOff + 8, er1_armed_wp);
|
||||
setProperty("ERDB_Offset", erdbOff, 32);
|
||||
}
|
||||
|
||||
// 6. Bascule vers l'état M0
|
||||
UInt32 mhiCtrlVal = read32(ATH12K_MHI_MHICTRL);
|
||||
mhiCtrlVal &= ~ATH12K_MHICTRL_MHISTATE_MASK;
|
||||
mhiCtrlVal |= (ATH12K_MHI_STATE_M0 << ATH12K_MHICTRL_MHISTATE_SHIFT);
|
||||
write32(ATH12K_MHI_MHICTRL, mhiCtrlVal);
|
||||
IOLog("QualcommWifi: Transition MHI vers M0 demandée (MHICTRL: 0x%08x)...\n", mhiCtrlVal);
|
||||
}
|
||||
|
||||
// Étape 5 : Téléversement FBC complet du firmware via BHIe (mhi_download_amss_image sous SBL actif)
|
||||
const size_t segSize = 0x80000; // Segments de 512 Ko (SZ_512K exigé par ath12k)
|
||||
int numVecEntries = (int)((fwSize + segSize - 1) / segSize); // 12 segments pour l'image complète
|
||||
|
||||
IOBufferMemoryDescriptor *vecDma = IOBufferMemoryDescriptor::inTaskWithPhysicalMask(
|
||||
kernel_task,
|
||||
static_cast<IOOptionBits>(kIODirectionInOut) | static_cast<IOOptionBits>(kIOMemoryPhysicallyContiguous),
|
||||
numVecEntries * sizeof(struct bhi_vec_entry),
|
||||
ATH12K_DMA_MASK_36BIT_PAGE
|
||||
);
|
||||
|
||||
if (vecDma) {
|
||||
if (vecDma->prepare(kIODirectionInOut) == kIOReturnSuccess) {
|
||||
struct bhi_vec_entry *vecTable = (struct bhi_vec_entry *)vecDma->getBytesNoCopy();
|
||||
IOByteCount vecLen = 0;
|
||||
IOPhysicalAddress vecPhys = vecDma->getPhysicalSegment(0, &vecLen);
|
||||
|
||||
if (vecTable && vecPhys) {
|
||||
size_t curRem = fwSize;
|
||||
|
||||
for (int i = 0; i < numVecEntries; i++) {
|
||||
size_t chunk = (curRem > segSize) ? segSize : curRem;
|
||||
vecTable[i].dma_addr = OSSwapHostToLittleInt64((uint64_t)phys + (uint64_t)i * segSize);
|
||||
vecTable[i].size = OSSwapHostToLittleInt64(chunk);
|
||||
curRem -= chunk;
|
||||
}
|
||||
|
||||
IOLog("QualcommWifi: Table vectorielle BHIe FBC prête (%d segments, Phys: 0x%llx). Programmation BHIe...\n",
|
||||
numVecEntries, (uint64_t)vecPhys);
|
||||
|
||||
write32(bhieOff + ATH12K_BHIE_TXVECADDR_LOW, (UInt32)(vecPhys & 0xFFFFFFFF));
|
||||
write32(bhieOff + ATH12K_BHIE_TXVECADDR_HIGH, (UInt32)((vecPhys >> 32) & 0xFFFFFFFF));
|
||||
write32(bhieOff + ATH12K_BHIE_TXVECSIZE, (UInt32)(numVecEntries * sizeof(struct bhi_vec_entry)));
|
||||
write32(bhieOff + ATH12K_BHIE_TXVECSTATUS, 0);
|
||||
|
||||
// Sonnette BHIe avec Sequence ID = 1
|
||||
write32(bhieOff + ATH12K_BHIE_TXVECDB, 0x1);
|
||||
|
||||
UInt32 bhieStatus = 0;
|
||||
timeoutMs = 10000; // 10 secondes pour le transfert DMA complet de 6 Mo
|
||||
while (timeoutMs > 0) {
|
||||
bhieStatus = read32(bhieOff + ATH12K_BHIE_TXVECSTATUS);
|
||||
UInt32 bhieState = (bhieStatus & ATH12K_BHIE_TXVECSTATUS_STATUS_MASK) >> ATH12K_BHIE_TXVECSTATUS_STATUS_SHIFT;
|
||||
if (bhieState == ATH12K_BHIE_TXVECSTATUS_XFER_COMPL) {
|
||||
amssSuccess = true;
|
||||
break;
|
||||
}
|
||||
IODelay(1000);
|
||||
timeoutMs--;
|
||||
}
|
||||
|
||||
setProperty("BHIE_FinalStatus", bhieStatus, 32);
|
||||
setProperty("BHIE_Status_Raw", bhieStatus, 32);
|
||||
setProperty("BHIE_Status_State", (bhieStatus & ATH12K_BHIE_TXVECSTATUS_STATUS_MASK) >> ATH12K_BHIE_TXVECSTATUS_STATUS_SHIFT, 32);
|
||||
IOLog("QualcommWifi: BHIe DMA terminé (Status=0x%08x) ! Dépouillement des événements MHI...\n", bhieStatus);
|
||||
|
||||
// Étape 6 : Dépouillement des événements MHI émis par SBL / AMSS sur l'anneau 0
|
||||
struct mhi_ring_element *erElements = (struct mhi_ring_element *)((uint8_t *)fDmaVirtAddr + 0x4000);
|
||||
|
||||
timeoutMs = 5000;
|
||||
while (timeoutMs > 0) {
|
||||
UInt32 mstat = read32(ATH12K_MHI_MHISTATUS);
|
||||
UInt32 mstate = (mstat & ATH12K_MHISTATUS_MHISTATE_MASK) >> ATH12K_MHISTATUS_MHISTATE_SHIFT;
|
||||
|
||||
while (processedEvents < 32) {
|
||||
struct mhi_ring_element *el = &erElements[processedEvents];
|
||||
UInt32 dw1 = OSSwapLittleToHostInt32(el->dword[1]);
|
||||
UInt32 dw0 = OSSwapLittleToHostInt32(el->dword[0]);
|
||||
if (dw1 == 0 && dw0 == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
UInt8 evType = (dw1 >> 16) & 0xFF;
|
||||
UInt8 evCode = (dw0 >> 24) & 0xFF;
|
||||
IOLog("QualcommWifi: Événement MHI reçu #%u: Type=0x%02x, Code=0x%02x, PTR=0x%llx\n",
|
||||
processedEvents, evType, evCode, OSSwapLittleToHostInt64(el->ptr));
|
||||
|
||||
char evKey[32];
|
||||
snprintf(evKey, sizeof(evKey), "MHI_Event_%u_Type", processedEvents);
|
||||
setProperty(evKey, evType, 8);
|
||||
snprintf(evKey, sizeof(evKey), "MHI_Event_%u_Code", processedEvents);
|
||||
setProperty(evKey, evCode, 8);
|
||||
snprintf(evKey, sizeof(evKey), "MHI_Event_%u_PTR", processedEvents);
|
||||
setProperty(evKey, OSSwapLittleToHostInt64(el->ptr), 64);
|
||||
|
||||
if (evType == ATH12K_MHI_PKT_TYPE_STATE_CHANGE_EVENT) {
|
||||
IOLog("QualcommWifi: -> Notification changement d'état MHI: State=%u\n", evCode);
|
||||
if (evCode == ATH12K_MHI_STATE_M0) {
|
||||
inM0 = true;
|
||||
}
|
||||
} else if (evType == ATH12K_MHI_PKT_TYPE_EE_EVENT) {
|
||||
IOLog("QualcommWifi: -> Notification environnement d'exécution (EE): 0x%x\n", evCode);
|
||||
ee = evCode;
|
||||
if (ee == ATH12K_MHI_EE_AMSS || ee == ATH12K_MHI_EE_WFW) {
|
||||
amssSuccess = true;
|
||||
}
|
||||
}
|
||||
processedEvents++;
|
||||
}
|
||||
|
||||
if (mstate == ATH12K_MHI_STATE_M0 || inM0 || ee == ATH12K_MHI_EE_AMSS || ee == ATH12K_MHI_EE_WFW) {
|
||||
inM0 = true;
|
||||
IOLog("QualcommWifi: MHI en mode Mission M0 (MHISTATUS: 0x%08x, EE: 0x%x) !\n", mstat, ee);
|
||||
break;
|
||||
}
|
||||
|
||||
IODelay(1000);
|
||||
timeoutMs--;
|
||||
}
|
||||
|
||||
setProperty("MHI_Events_Processed", processedEvents, 32);
|
||||
setProperty("MHI_Status_In_M0", read32(ATH12K_MHI_MHISTATUS), 32);
|
||||
setProperty("MHI_In_M0", inM0);
|
||||
setProperty("BHI_ExecEnv_Final", ee, 32);
|
||||
}
|
||||
|
||||
vecDma->complete(kIODirectionInOut);
|
||||
}
|
||||
OSSafeReleaseNULL(vecDma);
|
||||
}
|
||||
|
||||
if (inM0 || ee == ATH12K_MHI_EE_AMSS || ee == ATH12K_MHI_EE_WFW) {
|
||||
IOLog("QualcommWifi: SUCCÈS MAJEUR ! Firmware WCN7850 actif en mode Mission (ExecEnv=0x%x, M0=%d) !\n", ee, inM0);
|
||||
setProperty("Driver_Status", "AMSS_Loaded_Success");
|
||||
} else if (sblSuccess) {
|
||||
IOLog("QualcommWifi: SBL actif (ExecEnv=0x%x, BHIe=0x%x)\n", ee, read32(bhieOff + ATH12K_BHIE_TXVECSTATUS));
|
||||
setProperty("Driver_Status", "SBL_Loaded_Success");
|
||||
} else {
|
||||
IOLog("QualcommWifi: Échec chargement complet (BHI=0x%x, ExecEnv=0x%x)\n", bhiStatus, ee);
|
||||
setProperty("Driver_Status", "AMSS_Load_Timeout_Or_Error");
|
||||
}
|
||||
|
||||
fwDma->complete(kIODirectionInOut);
|
||||
OSSafeReleaseNULL(fwDma);
|
||||
|
||||
return (sblSuccess || amssSuccess);
|
||||
}
|
||||
|
||||
bool QualcommWifi::start(IOService *provider) {
|
||||
if (!super::start(provider)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
fPciDevice = OSDynamicCast(IOPCIDevice, provider);
|
||||
if (!fPciDevice) {
|
||||
return false;
|
||||
}
|
||||
fPciDevice->retain();
|
||||
|
||||
if (!fPciDevice->open(this)) {
|
||||
OSSafeReleaseNULL(fPciDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
UInt16 pciCommand = fPciDevice->configRead16(kIOPCIConfigCommand);
|
||||
pciCommand |= (kIOPCICommandMemorySpace | kIOPCICommandBusMaster);
|
||||
fPciDevice->configWrite16(kIOPCIConfigCommand, pciCommand);
|
||||
|
||||
fBar0Map = fPciDevice->mapDeviceMemoryWithRegister(kIOPCIConfigBaseAddress0);
|
||||
if (!fBar0Map) {
|
||||
fPciDevice->close(this);
|
||||
OSSafeReleaseNULL(fPciDevice);
|
||||
return false;
|
||||
}
|
||||
fBar0Virt = (volatile void *)fBar0Map->getVirtualAddress();
|
||||
|
||||
UInt32 socHwVer = socRead32(TCSR_SOC_HW_VERSION);
|
||||
UInt32 major = (socHwVer & TCSR_SOC_HW_VERSION_MAJOR_MASK) >> TCSR_SOC_HW_VERSION_MAJOR_SHIFT;
|
||||
UInt32 minor = (socHwVer & TCSR_SOC_HW_VERSION_MINOR_MASK);
|
||||
IOLog("QualcommWifi: WCN7850 HW v%u.%u detecte (0x%08x)\n", major, minor, socHwVer);
|
||||
|
||||
setProperty("SoC_Version", socHwVer, 32);
|
||||
setProperty("SoC_Major", major, 32);
|
||||
setProperty("SoC_Minor", minor, 32);
|
||||
|
||||
// Lecture des registres de contrôle MHI et pointeurs BHI
|
||||
UInt32 mhiStatus = read32(ATH12K_MHI_MHISTATUS);
|
||||
UInt32 mhiCtrl = read32(ATH12K_MHI_MHICTRL);
|
||||
UInt32 bhiOff = read32(ATH12K_MHI_BHIOFF);
|
||||
UInt32 bhieOff = read32(ATH12K_MHI_BHIEOFF);
|
||||
IOLog("QualcommWifi: MHI STATUS=0x%08x, CTRL=0x%08x, BHIOFF=0x%08x, BHIEOFF=0x%08x\n",
|
||||
mhiStatus, mhiCtrl, bhiOff, bhieOff);
|
||||
|
||||
setProperty("MHI_Status", mhiStatus, 32);
|
||||
setProperty("MHI_Ctrl", mhiCtrl, 32);
|
||||
setProperty("BHI_Offset", bhiOff, 32);
|
||||
setProperty("BHIE_Offset", bhieOff, 32);
|
||||
|
||||
if (bhiOff != 0xFFFFFFFF && bhiOff < 0x200000) {
|
||||
UInt32 bhiMajor = read32(bhiOff + ATH12K_BHI_BHIVERSION_MAJOR);
|
||||
UInt32 bhiMinor = read32(bhiOff + ATH12K_BHI_BHIVERSION_MINOR);
|
||||
UInt32 bhiEe = read32(bhiOff + ATH12K_BHI_EXECENV);
|
||||
UInt32 bhiStat = read32(bhiOff + ATH12K_BHI_STATUS);
|
||||
UInt32 bhiSerial = read32(bhiOff + ATH12K_BHI_SERIALNU);
|
||||
IOLog("QualcommWifi: BHI v%u.%u: ExecEnv=0x%x, Status=0x%x, Serial=0x%08x\n",
|
||||
bhiMajor, bhiMinor, bhiEe, bhiStat, bhiSerial);
|
||||
|
||||
setProperty("BHI_Major", bhiMajor, 32);
|
||||
setProperty("BHI_Minor", bhiMinor, 32);
|
||||
setProperty("BHI_ExecEnv", bhiEe, 32);
|
||||
setProperty("BHI_Status", bhiStat, 32);
|
||||
setProperty("BHI_Serial", bhiSerial, 32);
|
||||
}
|
||||
|
||||
// Allocation du tampon DMA 36-bit pour les anneaux MHI / BHI
|
||||
if (!allocDmaContext(ATH12K_DMA_TEST_RING_SIZE)) {
|
||||
OSSafeReleaseNULL(fBar0Map);
|
||||
fPciDevice->close(this);
|
||||
OSSafeReleaseNULL(fPciDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
setProperty("DMA_PhysAddr", (uint64_t)fDmaPhysAddr, 64);
|
||||
setProperty("Driver_Status", "Hardware_Initialized");
|
||||
|
||||
int msiIndex = -1;
|
||||
for (int i = 0; ; i++) {
|
||||
int intrType = 0;
|
||||
if (fPciDevice->getInterruptType(i, &intrType) != kIOReturnSuccess) {
|
||||
break;
|
||||
}
|
||||
if (intrType & kIOInterruptTypePCIMessaged) {
|
||||
msiIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IOWorkLoop *workLoop = getWorkLoop();
|
||||
if (msiIndex >= 0 && workLoop) {
|
||||
fInterruptSource = IOInterruptEventSource::interruptEventSource(
|
||||
this, &QualcommWifi::interruptOccurred, fPciDevice, msiIndex);
|
||||
if (fInterruptSource && workLoop->addEventSource(fInterruptSource) == kIOReturnSuccess) {
|
||||
fInterruptSource->enable();
|
||||
IOLog("QualcommWifi: MSI index %d actif.\n", msiIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// Chargement du firmware radio AMSS via le protocole BHI
|
||||
(void)loadBhiFirmware();
|
||||
|
||||
// Configuration de l'adresse MAC (OUI Qualcomm 00:03:7F + BHI serial)
|
||||
UInt32 bhiSerial = read32(bhiOff + ATH12K_BHI_SERIALNU);
|
||||
fMacAddress.bytes[0] = 0x00;
|
||||
fMacAddress.bytes[1] = 0x03;
|
||||
fMacAddress.bytes[2] = 0x7F;
|
||||
fMacAddress.bytes[3] = (bhiSerial >> 16) & 0xFF;
|
||||
fMacAddress.bytes[4] = (bhiSerial >> 8) & 0xFF;
|
||||
fMacAddress.bytes[5] = (bhiSerial) & 0xFF;
|
||||
|
||||
IOLog("QualcommWifi: Adresse MAC physique : %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
fMacAddress.bytes[0], fMacAddress.bytes[1], fMacAddress.bytes[2],
|
||||
fMacAddress.bytes[3], fMacAddress.bytes[4], fMacAddress.bytes[5]);
|
||||
|
||||
// Configuration des propriétés Wi-Fi AirPort pour macOS et airportd
|
||||
setProperty("IO80211AirPort", true);
|
||||
setProperty("AirPort", true);
|
||||
setProperty("IO80211Locale", "ETSI");
|
||||
setProperty("IO80211CountryCode", "FR");
|
||||
setProperty("IO80211ScanCache", true);
|
||||
setProperty("IO80211RadioState", (UInt64)1, 32);
|
||||
|
||||
// Configuration et publication des médias supportés (Auto / 1Gbps)
|
||||
OSDictionary *mediumDict = OSDictionary::withCapacity(1);
|
||||
if (mediumDict) {
|
||||
IONetworkMedium *medium = IONetworkMedium::medium(kIOMediumEthernetAuto, 1000000000ULL);
|
||||
if (medium) {
|
||||
IONetworkMedium::addMedium(mediumDict, medium);
|
||||
publishMediumDictionary(mediumDict);
|
||||
setSelectedMedium(medium);
|
||||
medium->release();
|
||||
}
|
||||
mediumDict->release();
|
||||
}
|
||||
|
||||
// Attachement de l'interface Wi-Fi native (IO80211Interface)
|
||||
if (attachInterface((IONetworkInterface **)&fNetif, true)) {
|
||||
IOLog("QualcommWifi: Interface Wi-Fi native (IO80211Interface) attachee avec succes !\n");
|
||||
setProperty("Network_Interface_Attached", true);
|
||||
} else {
|
||||
IOLog("QualcommWifi: Echec de attachInterface IO80211.\n");
|
||||
setProperty("Network_Interface_Attached", false);
|
||||
}
|
||||
|
||||
registerService();
|
||||
return true;
|
||||
}
|
||||
|
||||
void QualcommWifi::stop(IOService *provider) {
|
||||
IOLog("QualcommWifi: Arret du pilote, liberation interface reseau, MSI, DMA et BAR0.\n");
|
||||
|
||||
if (fNetif) {
|
||||
detachInterface(fNetif);
|
||||
OSSafeReleaseNULL(fNetif);
|
||||
}
|
||||
|
||||
IOWorkLoop *workLoop = getWorkLoop();
|
||||
if (fInterruptSource) {
|
||||
fInterruptSource->disable();
|
||||
if (workLoop) {
|
||||
workLoop->removeEventSource(fInterruptSource);
|
||||
}
|
||||
OSSafeReleaseNULL(fInterruptSource);
|
||||
}
|
||||
|
||||
// Déverrouillage et libération du tampon DMA avant la fermeture PCIe
|
||||
freeDmaContext();
|
||||
|
||||
fBar0Virt = nullptr;
|
||||
if (fBar0Map) {
|
||||
OSSafeReleaseNULL(fBar0Map);
|
||||
}
|
||||
|
||||
if (fPciDevice) {
|
||||
fPciDevice->close(this);
|
||||
OSSafeReleaseNULL(fPciDevice);
|
||||
}
|
||||
|
||||
super::stop(provider);
|
||||
}
|
||||
|
||||
IOReturn QualcommWifi::getHardwareAddress(IOEthernetAddress *addrP) {
|
||||
if (!addrP) return kIOReturnBadArgument;
|
||||
bcopy(&fMacAddress, addrP, sizeof(IOEthernetAddress));
|
||||
return kIOReturnSuccess;
|
||||
}
|
||||
|
||||
IOReturn QualcommWifi::enable(IONetworkInterface *netif) {
|
||||
IOLog("QualcommWifi: Interface reseau activee par macOS.\n");
|
||||
const IONetworkMedium *medium = getSelectedMedium();
|
||||
setLinkStatus(kIONetworkLinkValid | kIONetworkLinkActive, medium);
|
||||
return kIOReturnSuccess;
|
||||
}
|
||||
|
||||
IOReturn QualcommWifi::disable(IONetworkInterface *netif) {
|
||||
IOLog("QualcommWifi: Interface reseau desactivee par macOS.\n");
|
||||
setLinkStatus(kIONetworkLinkValid, nullptr);
|
||||
return kIOReturnSuccess;
|
||||
}
|
||||
|
||||
UInt32 QualcommWifi::outputPacket(mbuf_t m, void *param) {
|
||||
if (m) {
|
||||
freePacket(m);
|
||||
}
|
||||
return kIOReturnOutputDropped;
|
||||
}
|
||||
|
||||
SInt32 QualcommWifi::apple80211Request(unsigned int req_type, int req_val, IO80211Interface* iface, void* req_data) {
|
||||
switch (req_type) {
|
||||
case APPLE80211_IOC_CARD_CAPABILITIES: {
|
||||
apple80211_capability_data *cap = (apple80211_capability_data *)req_data;
|
||||
if (cap) {
|
||||
bzero(cap, sizeof(*cap));
|
||||
cap->version = APPLE80211_VERSION;
|
||||
#define SET_CAP(c) (cap->capabilities[(c) / 8] |= (1 << ((c) % 8)))
|
||||
SET_CAP(APPLE80211_CAP_WEP);
|
||||
SET_CAP(APPLE80211_CAP_TKIP);
|
||||
SET_CAP(APPLE80211_CAP_AES_CCM);
|
||||
SET_CAP(APPLE80211_CAP_WPA1);
|
||||
SET_CAP(APPLE80211_CAP_WPA2);
|
||||
SET_CAP(APPLE80211_CAP_WPA);
|
||||
SET_CAP(APPLE80211_CAP_SHORT_GI_20MHZ);
|
||||
SET_CAP(APPLE80211_CAP_SHORT_GI_40MHZ);
|
||||
#undef SET_CAP
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APPLE80211_IOC_STATE: {
|
||||
apple80211_state_data *state = (apple80211_state_data *)req_data;
|
||||
if (state) {
|
||||
state->version = APPLE80211_VERSION;
|
||||
state->state = fLinkActive ? APPLE80211_S_RUN : APPLE80211_S_INIT;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APPLE80211_IOC_PHY_MODE: {
|
||||
apple80211_phymode_data *pm = (apple80211_phymode_data *)req_data;
|
||||
if (pm) {
|
||||
pm->version = APPLE80211_VERSION;
|
||||
pm->phy_mode = APPLE80211_MODE_11AX;
|
||||
pm->active_phy_mode = APPLE80211_MODE_11AX;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APPLE80211_IOC_OP_MODE: {
|
||||
apple80211_opmode_data *om = (apple80211_opmode_data *)req_data;
|
||||
if (om) {
|
||||
om->version = APPLE80211_VERSION;
|
||||
om->op_mode = APPLE80211_M_STA;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APPLE80211_IOC_CHANNEL: {
|
||||
apple80211_channel_data *cd = (apple80211_channel_data *)req_data;
|
||||
if (cd) {
|
||||
cd->version = APPLE80211_VERSION;
|
||||
cd->channel.version = APPLE80211_VERSION;
|
||||
cd->channel.channel = fCurrentChannel > 0 ? fCurrentChannel : 1;
|
||||
cd->channel.flags = APPLE80211_C_FLAG_2GHZ | APPLE80211_C_FLAG_20MHZ;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APPLE80211_IOC_RSSI: {
|
||||
apple80211_rssi_data *rd = (apple80211_rssi_data *)req_data;
|
||||
if (rd) {
|
||||
rd->version = APPLE80211_VERSION;
|
||||
rd->num_radios = 1;
|
||||
rd->rssi_unit = APPLE80211_UNIT_DBM;
|
||||
rd->rssi[0] = fLastRssi ? fLastRssi : -50;
|
||||
rd->aggregate_rssi = rd->rssi[0];
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APPLE80211_IOC_NOISE: {
|
||||
apple80211_noise_data *nd = (apple80211_noise_data *)req_data;
|
||||
if (nd) {
|
||||
nd->version = APPLE80211_VERSION;
|
||||
nd->num_radios = 1;
|
||||
nd->noise_unit = APPLE80211_UNIT_DBM;
|
||||
nd->noise[0] = -95;
|
||||
nd->aggregate_noise = -95;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APPLE80211_IOC_SSID: {
|
||||
apple80211_ssid_data *sd = (apple80211_ssid_data *)req_data;
|
||||
if (sd) {
|
||||
sd->version = APPLE80211_VERSION;
|
||||
sd->ssid_len = fSsidLen;
|
||||
memcpy(sd->ssid_bytes, fSsid, fSsidLen);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APPLE80211_IOC_BSSID: {
|
||||
apple80211_bssid_data *bd = (apple80211_bssid_data *)req_data;
|
||||
if (bd) {
|
||||
bd->version = APPLE80211_VERSION;
|
||||
memcpy(bd->bssid.octet, fBssid, 6);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APPLE80211_IOC_RATE: {
|
||||
apple80211_rate_data *rate = (apple80211_rate_data *)req_data;
|
||||
if (rate) {
|
||||
rate->version = APPLE80211_VERSION;
|
||||
rate->num_radios = 1;
|
||||
rate->rate[0] = 1200;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APPLE80211_IOC_SUPPORTED_CHANNELS: {
|
||||
apple80211_sup_channel_data *sc = (apple80211_sup_channel_data *)req_data;
|
||||
if (sc) {
|
||||
sc->version = APPLE80211_VERSION;
|
||||
static const UInt16 chs[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
||||
36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 149, 153, 157, 161, 165 };
|
||||
sc->num_channels = sizeof(chs)/sizeof(chs[0]);
|
||||
for (int i = 0; i < sc->num_channels; i++) {
|
||||
sc->supported_channels[i].version = APPLE80211_VERSION;
|
||||
sc->supported_channels[i].channel = chs[i];
|
||||
sc->supported_channels[i].flags = (chs[i] <= 14) ? (APPLE80211_C_FLAG_2GHZ | APPLE80211_C_FLAG_20MHZ) : (APPLE80211_C_FLAG_5GHZ | APPLE80211_C_FLAG_80MHZ);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APPLE80211_IOC_SCAN_REQ: {
|
||||
IOLog("QualcommWifi: Requete de scan Wi-Fi recue depuis airportd !\n");
|
||||
fScanInProgress = true;
|
||||
return 0;
|
||||
}
|
||||
case APPLE80211_IOC_SCAN_RESULT: {
|
||||
return 0;
|
||||
}
|
||||
case APPLE80211_IOC_ASSOCIATE: {
|
||||
apple80211_assoc_data *assoc = (apple80211_assoc_data *)req_data;
|
||||
if (assoc) {
|
||||
IOLog("QualcommWifi: Demande d'association au reseau Wi-Fi : %.*s\n", assoc->ad_ssid_len, assoc->ad_ssid);
|
||||
fSsidLen = (assoc->ad_ssid_len < APPLE80211_MAX_SSID_LEN) ? assoc->ad_ssid_len : APPLE80211_MAX_SSID_LEN;
|
||||
memcpy(fSsid, assoc->ad_ssid, fSsidLen);
|
||||
memcpy(fBssid, assoc->ad_bssid.octet, 6);
|
||||
fLinkActive = true;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APPLE80211_IOC_DISASSOCIATE: {
|
||||
IOLog("QualcommWifi: Deconnexion Wi-Fi demandee par macOS.\n");
|
||||
fLinkActive = false;
|
||||
fSsidLen = 0;
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SInt32 QualcommWifi::apple80211SkywalkRequest(UInt req_type, int req_val, IO80211SkywalkInterface *iface, void *req_data) {
|
||||
return apple80211Request(req_type, req_val, nullptr, req_data);
|
||||
}
|
||||
|
||||
SInt32 QualcommWifi::stopDMA() {
|
||||
IOLog("QualcommWifi: stopDMA appele.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
UInt32 QualcommWifi::hardwareOutputQueueDepth(IO80211Interface *iface) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SInt32 QualcommWifi::performCountryCodeOperation(IO80211Interface *iface, IO80211CountryCodeOp op) {
|
||||
IOLog("QualcommWifi: performCountryCodeOperation op=%d.\n", op);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SInt32 QualcommWifi::enableFeature(IO80211FeatureCode code, void *arg) {
|
||||
IOLog("QualcommWifi: enableFeature code=%d.\n", code);
|
||||
return 0;
|
||||
}
|
||||
|
||||
IOReturn QualcommWifi::enable(IO80211SkywalkInterface *netif) {
|
||||
IOLog("QualcommWifi: Skywalk Interface activee par macOS.\n");
|
||||
fLinkActive = true;
|
||||
return kIOReturnSuccess;
|
||||
}
|
||||
|
||||
IOReturn QualcommWifi::disable(IO80211SkywalkInterface *netif) {
|
||||
IOLog("QualcommWifi: Skywalk Interface desactivee par macOS.\n");
|
||||
fLinkActive = false;
|
||||
return kIOReturnSuccess;
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
#ifndef _QUALCOMMWIFI_HPP
|
||||
#define _QUALCOMMWIFI_HPP
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/pci/IOPCIDevice.h>
|
||||
#include <IOKit/IOWorkLoop.h>
|
||||
#include <IOKit/IOInterruptEventSource.h>
|
||||
#include <IOKit/IOBufferMemoryDescriptor.h>
|
||||
|
||||
// Registres PCIe et constantes de fenêtrage (ath12k/pci.h)
|
||||
#define ATH12K_PCI_SOC_GLOBAL_RESET 0x3008
|
||||
#define ATH12K_PCI_WINDOW_REG_ADDRESS 0x310c
|
||||
#define ATH12K_PCI_WINDOW_ENABLE_BIT 0x40000000
|
||||
#define ATH12K_PCI_WINDOW_START 0x80000
|
||||
#define ATH12K_PCI_WINDOW_RANGE_MASK 0x7FFFF
|
||||
#define ATH12K_PCI_WINDOW_SHIFT 19
|
||||
#define ATH12K_PCI_WINDOW_VALUE_MASK 0x3F
|
||||
|
||||
// Registre de révision matérielle du SoC Qualcomm WCN7850
|
||||
#define TCSR_SOC_HW_VERSION 0x1B00000
|
||||
#define TCSR_SOC_HW_VERSION_MAJOR_MASK 0x0F00
|
||||
#define TCSR_SOC_HW_VERSION_MAJOR_SHIFT 8
|
||||
#define TCSR_SOC_HW_VERSION_MINOR_MASK 0x00FF
|
||||
|
||||
// Masque DMA 36-bit aligné sur 4 Ko (4096 octets) exigé par WCN7850
|
||||
#define ATH12K_DMA_MASK_36BIT_PAGE 0x0000000FFFFFF000ULL
|
||||
#define ATH12K_DMA_TEST_RING_SIZE 65536 // 64 Ko pour le contexte MHI
|
||||
|
||||
// Registres MHI MMIO (bar0 direct)
|
||||
#define ATH12K_MHI_MHIREGLEN 0x00
|
||||
#define ATH12K_MHI_MHIVER 0x08
|
||||
#define ATH12K_MHI_MHICFG 0x10
|
||||
#define ATH12K_MHI_CHDBOFF 0x18
|
||||
#define ATH12K_MHI_ERDBOFF 0x20
|
||||
#define ATH12K_MHI_BHIOFF 0x28
|
||||
#define ATH12K_MHI_BHIEOFF 0x2c
|
||||
#define ATH12K_MHI_DEBUGOFF 0x30
|
||||
#define ATH12K_MHI_MHICTRL 0x38
|
||||
#define ATH12K_MHI_MHISTATUS 0x48
|
||||
#define ATH12K_MHI_CCABAP_LOWER 0x58
|
||||
#define ATH12K_MHI_CCABAP_HIGHER 0x5c
|
||||
#define ATH12K_MHI_ECABAP_LOWER 0x60
|
||||
#define ATH12K_MHI_ECABAP_HIGHER 0x64
|
||||
#define ATH12K_MHI_CRCBAP_LOWER 0x68
|
||||
#define ATH12K_MHI_CRCBAP_HIGHER 0x6c
|
||||
#define ATH12K_MHI_CRDB_LOWER 0x70
|
||||
#define ATH12K_MHI_CRDB_HIGHER 0x74
|
||||
#define ATH12K_MHI_MHICTRLBASE_LOWER 0x80
|
||||
#define ATH12K_MHI_MHICTRLBASE_HIGHER 0x84
|
||||
#define ATH12K_MHI_MHICTRLLIMIT_LOWER 0x88
|
||||
#define ATH12K_MHI_MHICTRLLIMIT_HIGHER 0x8c
|
||||
#define ATH12K_MHI_MHIDATABASE_LOWER 0x98
|
||||
#define ATH12K_MHI_MHIDATABASE_HIGHER 0x9c
|
||||
#define ATH12K_MHI_MHIDATALIMIT_LOWER 0xa0
|
||||
#define ATH12K_MHI_MHIDATALIMIT_HIGHER 0xa4
|
||||
|
||||
// États MHI
|
||||
#define ATH12K_MHI_STATE_RESET 0x0
|
||||
#define ATH12K_MHI_STATE_READY 0x1
|
||||
#define ATH12K_MHI_STATE_M0 0x2
|
||||
#define ATH12K_MHI_STATE_M1 0x3
|
||||
#define ATH12K_MHI_STATE_M2 0x4
|
||||
#define ATH12K_MHI_STATE_M3 0x5
|
||||
|
||||
// Environnements d'exécution MHI (EE)
|
||||
#define ATH12K_MHI_EE_PBL 0x00
|
||||
#define ATH12K_MHI_EE_SBL 0x01
|
||||
#define ATH12K_MHI_EE_AMSS 0x02
|
||||
#define ATH12K_MHI_EE_RDDM 0x03
|
||||
#define ATH12K_MHI_EE_WFW 0x04
|
||||
|
||||
#define ATH12K_MHISTATUS_READY_MASK 0x00000001
|
||||
#define ATH12K_MHICTRL_RESET_MASK 0x00000002
|
||||
#define ATH12K_MHICTRL_MHISTATE_SHIFT 8
|
||||
#define ATH12K_MHICTRL_MHISTATE_MASK 0x0000FF00
|
||||
#define ATH12K_MHISTATUS_MHISTATE_SHIFT 8
|
||||
#define ATH12K_MHISTATUS_MHISTATE_MASK 0x0000FF00
|
||||
#define ATH12K_MHICFG_NER_MASK 0x00FF0000
|
||||
#define ATH12K_MHICFG_NHWER_MASK 0xFF000000
|
||||
|
||||
// Types de paquets d'événements MHI
|
||||
#define ATH12K_MHI_PKT_TYPE_STATE_CHANGE_EVENT 0x20
|
||||
#define ATH12K_MHI_PKT_TYPE_EE_EVENT 0x40
|
||||
|
||||
// Registres BHI (Boot Host Interface)
|
||||
#define ATH12K_BHI_BHIVERSION_MINOR 0x00
|
||||
#define ATH12K_BHI_BHIVERSION_MAJOR 0x04
|
||||
#define ATH12K_BHI_IMGADDR_LOW 0x08
|
||||
#define ATH12K_BHI_IMGADDR_HIGH 0x0c
|
||||
#define ATH12K_BHI_IMGSIZE 0x10
|
||||
#define ATH12K_BHI_IMGTXDB 0x18
|
||||
#define ATH12K_BHI_EXECENV 0x28
|
||||
#define ATH12K_BHI_STATUS 0x2c
|
||||
#define ATH12K_BHI_ERRCODE 0x30
|
||||
#define ATH12K_BHI_SERIALNU 0x40
|
||||
|
||||
#define ATH12K_BHI_STATUS_RESET 0x00
|
||||
#define ATH12K_BHI_STATUS_MASK 0xC0000000
|
||||
#define ATH12K_BHI_STATUS_SHIFT 30
|
||||
#define ATH12K_BHI_STATUS_SUCCESS 0x02
|
||||
#define ATH12K_BHI_STATUS_ERROR 0x03
|
||||
|
||||
// Registres BHIe (Boot Host Interface extension) - offsets relatifs à bhieOff (0x224 sur WCN7850)
|
||||
#define ATH12K_BHIE_MSMSOCID 0x00
|
||||
#define ATH12K_BHIE_TXVECADDR_LOW 0x2c
|
||||
#define ATH12K_BHIE_TXVECADDR_HIGH 0x30
|
||||
#define ATH12K_BHIE_TXVECSIZE 0x34
|
||||
#define ATH12K_BHIE_TXVECDB 0x3c
|
||||
#define ATH12K_BHIE_TXVECSTATUS 0x44
|
||||
#define ATH12K_BHIE_RXVECADDR_LOW 0x60
|
||||
#define ATH12K_BHIE_RXVECADDR_HIGH 0x64
|
||||
#define ATH12K_BHIE_RXVECSIZE 0x68
|
||||
#define ATH12K_BHIE_RXVECDB 0x70
|
||||
#define ATH12K_BHIE_RXVECSTATUS 0x78
|
||||
|
||||
#define ATH12K_BHIE_TXVECSTATUS_STATUS_MASK 0xC0000000
|
||||
#define ATH12K_BHIE_TXVECSTATUS_STATUS_SHIFT 30
|
||||
#define ATH12K_BHIE_TXVECSTATUS_XFER_COMPL 0x02
|
||||
|
||||
struct bhi_vec_entry {
|
||||
uint64_t dma_addr;
|
||||
uint64_t size;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct mhi_chan_ctxt {
|
||||
UInt32 chcfg;
|
||||
UInt32 chtype;
|
||||
UInt32 erindex;
|
||||
UInt64 rbase __attribute__((packed, aligned(4)));
|
||||
UInt64 rlen __attribute__((packed, aligned(4)));
|
||||
UInt64 rp __attribute__((packed, aligned(4)));
|
||||
UInt64 wp __attribute__((packed, aligned(4)));
|
||||
} __attribute__((packed));
|
||||
|
||||
struct mhi_event_ctxt {
|
||||
UInt32 intmod;
|
||||
UInt32 ertype;
|
||||
UInt32 msivec;
|
||||
UInt64 rbase __attribute__((packed, aligned(4)));
|
||||
UInt64 rlen __attribute__((packed, aligned(4)));
|
||||
UInt64 rp __attribute__((packed, aligned(4)));
|
||||
UInt64 wp __attribute__((packed, aligned(4)));
|
||||
} __attribute__((packed));
|
||||
|
||||
struct mhi_cmd_ctxt {
|
||||
UInt32 reserved0;
|
||||
UInt32 reserved1;
|
||||
UInt32 reserved2;
|
||||
UInt64 rbase __attribute__((packed, aligned(4)));
|
||||
UInt64 rlen __attribute__((packed, aligned(4)));
|
||||
UInt64 rp __attribute__((packed, aligned(4)));
|
||||
UInt64 wp __attribute__((packed, aligned(4)));
|
||||
} __attribute__((packed));
|
||||
|
||||
struct mhi_ring_element {
|
||||
UInt64 ptr;
|
||||
UInt32 dword[2];
|
||||
} __attribute__((packed));
|
||||
|
||||
#define MHI_TRE_GET_EV_TYPE(tre) (((tre)->dword[1] >> 16) & 0xFF)
|
||||
#define MHI_TRE_GET_EV_STATE(tre) (((tre)->dword[0] >> 24) & 0xFF)
|
||||
#define MHI_TRE_GET_EV_EXECENV(tre) (((tre)->dword[0] >> 24) & 0xFF)
|
||||
|
||||
#include <IOKit/network/IOEthernetController.h>
|
||||
#include <IOKit/network/IOEthernetInterface.h>
|
||||
#include <IOKit/network/IOOutputQueue.h>
|
||||
#include <IOKit/network/IONetworkMedium.h>
|
||||
|
||||
#include <IOKit/80211/apple80211_var.h>
|
||||
#include <IOKit/80211/apple80211_ioctl.h>
|
||||
#include <IOKit/80211/IO80211Controller.h>
|
||||
#include <IOKit/80211/IO80211Interface.h>
|
||||
#include <IOKit/80211/IO80211SkywalkInterface.h>
|
||||
#include "Firmware_WCN7850_Wifi.h"
|
||||
|
||||
class QualcommWifi : public IO80211Controller {
|
||||
OSDeclareDefaultStructors(QualcommWifi)
|
||||
|
||||
private:
|
||||
IOPCIDevice *fPciDevice;
|
||||
IOMemoryMap *fBar0Map;
|
||||
volatile void *fBar0Virt;
|
||||
UInt32 fCurrWindow;
|
||||
|
||||
IOInterruptEventSource *fInterruptSource;
|
||||
IO80211Interface *fNetif;
|
||||
IOEthernetAddress fMacAddress;
|
||||
|
||||
// État réseau Wi-Fi
|
||||
bool fLinkActive;
|
||||
UInt16 fCurrentChannel;
|
||||
SInt32 fLastRssi;
|
||||
UInt8 fSsid[APPLE80211_MAX_SSID_LEN];
|
||||
UInt32 fSsidLen;
|
||||
UInt8 fBssid[6];
|
||||
bool fScanInProgress;
|
||||
|
||||
// Tampon DMA physiquement contigu
|
||||
IOBufferMemoryDescriptor *fDmaBuf;
|
||||
IOPhysicalAddress fDmaPhysAddr;
|
||||
void *fDmaVirtAddr;
|
||||
bool fDmaPrepared;
|
||||
|
||||
UInt32 read32(UInt32 offset);
|
||||
void write32(UInt32 offset, UInt32 value);
|
||||
|
||||
void selectWindow(UInt32 offset);
|
||||
UInt32 socRead32(UInt32 offset);
|
||||
void socWrite32(UInt32 offset, UInt32 value);
|
||||
|
||||
bool allocDmaContext(IOByteCount size);
|
||||
void freeDmaContext(void);
|
||||
|
||||
bool loadBhiFirmware(void);
|
||||
|
||||
static void interruptOccurred(OSObject *owner, IOInterruptEventSource *src, int count);
|
||||
|
||||
public:
|
||||
virtual bool init(OSDictionary *dictionary = 0) override;
|
||||
virtual void free(void) override;
|
||||
virtual IOService *probe(IOService *provider, SInt32 *score) override;
|
||||
virtual bool start(IOService *provider) override;
|
||||
virtual void stop(IOService *provider) override;
|
||||
|
||||
// IOEthernetController / IONetworkController interface
|
||||
virtual IOReturn getHardwareAddress(IOEthernetAddress *addrP) override;
|
||||
virtual IOReturn enable(IONetworkInterface *netif) override;
|
||||
virtual IOReturn disable(IONetworkInterface *netif) override;
|
||||
virtual UInt32 outputPacket(mbuf_t m, void *param) override;
|
||||
|
||||
// IO80211Controller interface
|
||||
virtual SInt32 apple80211Request(unsigned int req_type, int req_val, IO80211Interface* iface, void* req_data) override;
|
||||
virtual SInt32 apple80211SkywalkRequest(UInt req_type, int req_val, IO80211SkywalkInterface *iface, void *req_data) override;
|
||||
virtual SInt32 stopDMA() override;
|
||||
virtual UInt32 hardwareOutputQueueDepth(IO80211Interface* iface) override;
|
||||
virtual SInt32 performCountryCodeOperation(IO80211Interface* iface, IO80211CountryCodeOp op) override;
|
||||
virtual SInt32 enableFeature(IO80211FeatureCode code, void* arg) override;
|
||||
|
||||
// Skywalk interface
|
||||
virtual IOReturn enable(IO80211SkywalkInterface *netif) override;
|
||||
virtual IOReturn disable(IO80211SkywalkInterface *netif) override;
|
||||
|
||||
// Compatibilité symboles virtuels IONetworkController sous macOS 15
|
||||
virtual void _RESERVEDIONetworkController2() override {}
|
||||
virtual void _RESERVEDIONetworkController3() override {}
|
||||
virtual void _RESERVEDIONetworkController4() override {}
|
||||
virtual void _RESERVEDIONetworkController5() override {}
|
||||
virtual void _RESERVEDIONetworkController6() override {}
|
||||
virtual void _RESERVEDIONetworkController7() override {}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,375 @@
|
||||
#include "QualcommWireless.hpp"
|
||||
#include "Firmware_WCN7850.h"
|
||||
|
||||
#include <IOKit/IOLib.h>
|
||||
#include <libkern/OSByteOrder.h>
|
||||
#include <IOKit/usb/IOUSBHostFamily.h>
|
||||
|
||||
#define super IOService
|
||||
OSDefineMetaClassAndStructors(QualcommWireless, IOService)
|
||||
|
||||
bool QualcommWireless::init(OSDictionary *dictionary) {
|
||||
if (!super::init(dictionary)) return false;
|
||||
fDevice = nullptr;
|
||||
fInterface = nullptr;
|
||||
fBulkOutPipe = nullptr;
|
||||
fIntrInPipe = nullptr;
|
||||
fBulkBuffer = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
void QualcommWireless::free(void) {
|
||||
super::free();
|
||||
}
|
||||
|
||||
IOService *QualcommWireless::probe(IOService *provider, SInt32 *score) {
|
||||
if (!super::probe(provider, score)) return nullptr;
|
||||
|
||||
IOUSBHostDevice *dev = OSDynamicCast(IOUSBHostDevice, provider);
|
||||
if (!dev) return nullptr;
|
||||
|
||||
const StandardUSB::DeviceDescriptor *desc = dev->getDeviceDescriptor();
|
||||
if (!desc) return nullptr;
|
||||
|
||||
UInt16 vid = OSSwapLittleToHostInt16(desc->idVendor);
|
||||
UInt16 pid = OSSwapLittleToHostInt16(desc->idProduct);
|
||||
|
||||
if (vid == 0x0489 && pid == 0xe10d) {
|
||||
IOLog("QualcommWireless: Detecte controleur Bluetooth Foxconn/Qualcomm (0x%04x:0x%04x) !\n", vid, pid);
|
||||
*score += 10000;
|
||||
return this;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint8_t QualcommWireless::checkStatus(void) {
|
||||
uint8_t status = 0;
|
||||
uint32_t transferred = 0;
|
||||
|
||||
StandardUSB::DeviceRequest req;
|
||||
req.bmRequestType = makeDeviceRequestbmRequestType(kRequestDirectionIn,
|
||||
kRequestTypeVendor,
|
||||
kRequestRecipientDevice);
|
||||
req.bRequest = QCA_CHECK_STATUS;
|
||||
req.wValue = 0;
|
||||
req.wIndex = 0;
|
||||
req.wLength = sizeof(status);
|
||||
|
||||
IOReturn kr = fDevice->deviceRequest(this, req, &status, transferred, 2000);
|
||||
if (kr != kIOReturnSuccess) {
|
||||
IOLog("QualcommWireless: Erreur checkStatus (0x%08x)\n", kr);
|
||||
return 0;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
bool QualcommWireless::queryTargetVersion(struct qca_version *verOut) {
|
||||
uint32_t transferred = 0;
|
||||
|
||||
StandardUSB::DeviceRequest req;
|
||||
req.bmRequestType = makeDeviceRequestbmRequestType(kRequestDirectionIn,
|
||||
kRequestTypeVendor,
|
||||
kRequestRecipientDevice);
|
||||
req.bRequest = QCA_GET_TARGET_VERSION;
|
||||
req.wValue = 0;
|
||||
req.wIndex = 0;
|
||||
req.wLength = sizeof(struct qca_version);
|
||||
|
||||
IOReturn kr = fDevice->deviceRequest(this, req, verOut, transferred, 2000);
|
||||
if (kr != kIOReturnSuccess || transferred < sizeof(struct qca_version)) {
|
||||
IOLog("QualcommWireless: Erreur queryTargetVersion (0x%08x, transferred=%u)\n", kr, transferred);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QualcommWireless::downloadFirmware(const uint8_t *data, size_t size, size_t hdrSize) {
|
||||
if (!fDevice || !fBulkOutPipe || !fBulkBuffer || size < hdrSize) return false;
|
||||
|
||||
// 1. Envoi du header via requête de contrôle vendeur DFU
|
||||
uint32_t transferred = 0;
|
||||
StandardUSB::DeviceRequest req;
|
||||
req.bmRequestType = makeDeviceRequestbmRequestType(kRequestDirectionOut,
|
||||
kRequestTypeVendor,
|
||||
kRequestRecipientDevice);
|
||||
req.bRequest = QCA_DFU_DOWNLOAD;
|
||||
req.wValue = 0;
|
||||
req.wIndex = 0;
|
||||
req.wLength = (uint16_t)hdrSize;
|
||||
|
||||
IOReturn kr = fDevice->deviceRequest(this, req, (void *)data, transferred, 2000);
|
||||
if (kr != kIOReturnSuccess) {
|
||||
IOLog("QualcommWireless: Erreur envoi header DFU (0x%08x)\n", kr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Délai de 20ms pour permettre au contrôleur d'activer le mode DFU sur ep2
|
||||
IOSleep(20);
|
||||
|
||||
// 2. Envoi du corps par paquets de 4096 octets max sur le pipe Bulk OUT
|
||||
size_t sent = hdrSize;
|
||||
size_t remaining = size - hdrSize;
|
||||
void *bufPtr = fBulkBuffer->getBytesNoCopy();
|
||||
|
||||
while (remaining > 0) {
|
||||
uint32_t chunk = (remaining > QCA_DFU_PACKET_LEN) ? QCA_DFU_PACKET_LEN : (uint32_t)remaining;
|
||||
memcpy(bufPtr, data + sent, chunk);
|
||||
|
||||
uint32_t bytesWritten = 0;
|
||||
kr = fBulkOutPipe->io(fBulkBuffer, chunk, bytesWritten, 3000);
|
||||
if (kr != kIOReturnSuccess || bytesWritten != chunk) {
|
||||
IOLog("QualcommWireless: Erreur io pipe bulk (offset %zu/%zu, kr=0x%08x)\n", sent, size, kr);
|
||||
return false;
|
||||
}
|
||||
|
||||
sent += chunk;
|
||||
remaining -= chunk;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QualcommWireless::sendHciReset(void) {
|
||||
uint8_t cmd[3] = {0x03, 0x0c, 0x00}; // HCI Reset
|
||||
uint32_t transferred = 0;
|
||||
|
||||
StandardUSB::DeviceRequest req;
|
||||
req.bmRequestType = makeDeviceRequestbmRequestType(kRequestDirectionOut,
|
||||
kRequestTypeClass,
|
||||
kRequestRecipientInterface);
|
||||
req.bRequest = 0;
|
||||
req.wValue = 0;
|
||||
req.wIndex = 0;
|
||||
req.wLength = sizeof(cmd);
|
||||
|
||||
IOReturn kr = fDevice->deviceRequest(this, req, cmd, transferred, 2000);
|
||||
if (kr != kIOReturnSuccess) {
|
||||
IOLog("QualcommWireless: Erreur envoi HCI Reset (0x%08x)\n", kr);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fIntrInPipe && fBulkBuffer) {
|
||||
uint32_t bytesRead = 0;
|
||||
kr = fIntrInPipe->io(fBulkBuffer, 256, bytesRead, 2000);
|
||||
if (kr == kIOReturnSuccess && bytesRead > 0) {
|
||||
uint8_t *evt = (uint8_t *)fBulkBuffer->getBytesNoCopy();
|
||||
if (evt[0] == 0x0E && evt[5] == 0) {
|
||||
IOLog("QualcommWireless: HCI Reset acquitte avec succes par le controleur !\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QualcommWireless::start(IOService *provider) {
|
||||
if (!super::start(provider)) return false;
|
||||
|
||||
fDevice = OSDynamicCast(IOUSBHostDevice, provider);
|
||||
if (!fDevice) return false;
|
||||
fDevice->retain();
|
||||
|
||||
if (!fDevice->open(this)) {
|
||||
IOLog("QualcommWireless: Impossible d'ouvrir le peripherique USB.\n");
|
||||
OSSafeReleaseNULL(fDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Configuration 1
|
||||
IOReturn kr = fDevice->setConfiguration(1);
|
||||
if (kr != kIOReturnSuccess) {
|
||||
IOLog("QualcommWireless: Erreur setConfiguration(1) -> 0x%08x\n", kr);
|
||||
fDevice->close(this);
|
||||
OSSafeReleaseNULL(fDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
struct qca_version ver;
|
||||
memset(&ver, 0, sizeof(ver));
|
||||
if (queryTargetVersion(&ver)) {
|
||||
IOLog("QualcommWireless: QCA Version ROM=0x%08x Patch=0x%08x RAM=0x%08x\n",
|
||||
OSSwapLittleToHostInt32(ver.rom_version),
|
||||
OSSwapLittleToHostInt32(ver.patch_version),
|
||||
OSSwapLittleToHostInt32(ver.ram_version));
|
||||
}
|
||||
|
||||
uint8_t status = checkStatus();
|
||||
IOLog("QualcommWireless: Statut initial QCA: 0x%02x (Patch: %s, Syscfg: %s)\n",
|
||||
status, (status & 0x80) ? "OUI" : "NON", (status & 0x40) ? "OUI" : "NON");
|
||||
|
||||
bool needPatch = !(status & 0x80);
|
||||
bool needNvm = !(status & 0x40);
|
||||
|
||||
if (needPatch || needNvm) {
|
||||
// Recherche de l'interface 0 (avec réessais si l'énumération est en cours)
|
||||
for (int retry = 0; retry < 10 && !fInterface; retry++) {
|
||||
OSIterator *iterator = fDevice->getChildIterator(gIOServicePlane);
|
||||
if (iterator) {
|
||||
OSObject *candidate;
|
||||
while ((candidate = iterator->getNextObject())) {
|
||||
IOUSBHostInterface *intf = OSDynamicCast(IOUSBHostInterface, candidate);
|
||||
if (intf && intf->getInterfaceDescriptor() && intf->getInterfaceDescriptor()->bInterfaceNumber == 0) {
|
||||
fInterface = intf;
|
||||
fInterface->retain();
|
||||
break;
|
||||
}
|
||||
}
|
||||
OSSafeReleaseNULL(iterator);
|
||||
}
|
||||
if (!fInterface) {
|
||||
IOSleep(30);
|
||||
}
|
||||
}
|
||||
|
||||
if (!fInterface) {
|
||||
IOLog("QualcommWireless: Erreur - Interface 0 non trouvee.\n");
|
||||
fDevice->close(this);
|
||||
OSSafeReleaseNULL(fDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!fInterface->open(this)) {
|
||||
IOLog("QualcommWireless: Impossible d'ouvrir l'interface 0.\n");
|
||||
OSSafeReleaseNULL(fInterface);
|
||||
fDevice->close(this);
|
||||
OSSafeReleaseNULL(fDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Recherche des pipes (Bulk OUT 0x02 et Interrupt IN 0x81)
|
||||
const StandardUSB::ConfigurationDescriptor *configDescriptor = fInterface->getConfigurationDescriptor();
|
||||
const StandardUSB::InterfaceDescriptor *interfaceDescriptor = fInterface->getInterfaceDescriptor();
|
||||
const EndpointDescriptor *endpointDescriptor = nullptr;
|
||||
|
||||
while ((endpointDescriptor = StandardUSB::getNextEndpointDescriptor(configDescriptor, interfaceDescriptor, endpointDescriptor))) {
|
||||
uint8_t epDirection = StandardUSB::getEndpointDirection(endpointDescriptor);
|
||||
uint8_t epType = StandardUSB::getEndpointType(endpointDescriptor);
|
||||
uint8_t epAddress = StandardUSB::getEndpointAddress(endpointDescriptor);
|
||||
|
||||
if (epDirection == kEndpointDirectionOut && epType == kEndpointTypeBulk) {
|
||||
fBulkOutPipe = fInterface->copyPipe(epAddress);
|
||||
} else if (epDirection == kEndpointDirectionIn && epType == kEndpointTypeInterrupt) {
|
||||
fIntrInPipe = fInterface->copyPipe(epAddress);
|
||||
}
|
||||
}
|
||||
|
||||
fBulkBuffer = fInterface->createIOBuffer(kIODirectionOut, QCA_DFU_PACKET_LEN);
|
||||
|
||||
if (fBulkOutPipe && fBulkBuffer) {
|
||||
if (needPatch) {
|
||||
IOLog("QualcommWireless: Televersement du RAMPATCH WCN7850 (%u octets)...\n", rampatch_usb_00190200_bin_len);
|
||||
if (downloadFirmware(rampatch_usb_00190200_bin, rampatch_usb_00190200_bin_len, 40)) {
|
||||
IOLog("QualcommWireless: RAMPATCH televerse avec succes !\n");
|
||||
} else {
|
||||
IOLog("QualcommWireless: Echec du televersement RAMPATCH !\n");
|
||||
}
|
||||
}
|
||||
|
||||
status = checkStatus();
|
||||
if (needNvm) {
|
||||
IOLog("QualcommWireless: Televersement du NVM WCN7850 (%u octets)...\n", nvm_usb_00190200_bin_len);
|
||||
if (downloadFirmware(nvm_usb_00190200_bin, nvm_usb_00190200_bin_len, 4)) {
|
||||
IOLog("QualcommWireless: NVM televerse avec succes !\n");
|
||||
} else {
|
||||
IOLog("QualcommWireless: Echec du televersement NVM !\n");
|
||||
}
|
||||
IOSleep(100);
|
||||
}
|
||||
|
||||
sendHciReset();
|
||||
|
||||
// Délai de stabilisation post-reset (150 ms) pour permettre au processeur Bluetooth
|
||||
// et aux tampons FIFO USB de re-calibrer leur état avant que bluetoothd n'initialise la pile.
|
||||
IOSleep(150);
|
||||
} else {
|
||||
IOLog("QualcommWireless: Erreur initialisation pipes ou buffer.\n");
|
||||
}
|
||||
|
||||
if (fIntrInPipe) {
|
||||
fIntrInPipe->clearStall(false);
|
||||
}
|
||||
if (fBulkOutPipe) {
|
||||
fBulkOutPipe->clearStall(false);
|
||||
}
|
||||
|
||||
OSSafeReleaseNULL(fBulkBuffer);
|
||||
OSSafeReleaseNULL(fBulkOutPipe);
|
||||
OSSafeReleaseNULL(fIntrInPipe);
|
||||
|
||||
if (fInterface->isOpen(this)) {
|
||||
fInterface->close(this);
|
||||
}
|
||||
OSSafeReleaseNULL(fInterface);
|
||||
}
|
||||
|
||||
uint8_t finalStatus = checkStatus();
|
||||
IOLog("QualcommWireless: Statut FINAL: 0x%02x (Patch: %s, Syscfg: %s) -> Pret pour macOS !\n",
|
||||
finalStatus, (finalStatus & 0x80) ? "OUI" : "NON", (finalStatus & 0x40) ? "OUI" : "NON");
|
||||
|
||||
// 1. Propriétés sur le périphérique USB pour bluetoothd (macOS Monterey / Ventura / Sonoma / Sequoia)
|
||||
// IMPORTANT: Ne JAMAIS nommer "Bluetooth USB Host Controller" sinon Found_USB_Dongle ignore le périphérique.
|
||||
fDevice->setProperty("USB Product Name", "Qualcomm WCN7850 Bluetooth");
|
||||
fDevice->setProperty("USB Vendor Name", "Qualcomm");
|
||||
fDevice->setProperty("FirmwareLoaded", true);
|
||||
fDevice->setProperty("kUSBHostPortType", (uint32_t)255, 32);
|
||||
fDevice->setProperty("builtin", (uint32_t)1, 32);
|
||||
|
||||
// Spoof idVendor à 0x0a12 (CSR) dans IORegistry pour que bluetoothd le valide dans sa liste
|
||||
// blanche de dongles tiers et active le chipset générique THIRD_PARTY_DONGLE (HCI Transport: USB).
|
||||
fDevice->setProperty("idVendor", (uint32_t)0x0a12, 32);
|
||||
fDevice->setName("Qualcomm WCN7850 Bluetooth");
|
||||
|
||||
// 2. Propriétés sur le port parent
|
||||
IOService *hubPort = fDevice->getProvider();
|
||||
if (hubPort) {
|
||||
hubPort->setProperty("USBPortType", (uint32_t)255, 32);
|
||||
hubPort->setProperty("port-type", (uint32_t)255, 32);
|
||||
}
|
||||
|
||||
// 3. Injection sur toutes les interfaces enfants (HCI & SCO)
|
||||
OSIterator *intfIter = fDevice->getChildIterator(gIOServicePlane);
|
||||
if (intfIter) {
|
||||
OSObject *candidate;
|
||||
while ((candidate = intfIter->getNextObject())) {
|
||||
IOUSBHostInterface *intf = OSDynamicCast(IOUSBHostInterface, candidate);
|
||||
if (intf) {
|
||||
intf->setProperty("USB Product Name", "Qualcomm WCN7850 Bluetooth");
|
||||
intf->setProperty("USB Vendor Name", "Qualcomm");
|
||||
intf->setProperty("idVendor", (uint32_t)0x0a12, 32);
|
||||
}
|
||||
}
|
||||
OSSafeReleaseNULL(intfIter);
|
||||
}
|
||||
|
||||
// Délai de 100ms avant de relâcher l'accès exclusif pour garantir que bluetoothd
|
||||
// trouve le contrôleur dans un état parfaitement calme et stabilisé au démarrage.
|
||||
IOSleep(100);
|
||||
|
||||
// Libération de l'accès exclusif afin que bluetoothd puisse ouvrir le contrôleur
|
||||
fDevice->close(this);
|
||||
|
||||
registerService();
|
||||
return true;
|
||||
}
|
||||
|
||||
void QualcommWireless::stop(IOService *provider) {
|
||||
IOLog("QualcommWireless: Arret du service.\n");
|
||||
|
||||
if (fInterface) {
|
||||
if (fInterface->isOpen(this)) {
|
||||
fInterface->close(this);
|
||||
}
|
||||
OSSafeReleaseNULL(fInterface);
|
||||
}
|
||||
|
||||
if (fDevice) {
|
||||
if (fDevice->isOpen(this)) {
|
||||
fDevice->close(this);
|
||||
}
|
||||
OSSafeReleaseNULL(fDevice);
|
||||
}
|
||||
|
||||
super::stop(provider);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef _QUALCOMMWIRELESS_HPP
|
||||
#define _QUALCOMMWIRELESS_HPP
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/usb/IOUSBHostDevice.h>
|
||||
#include <IOKit/usb/IOUSBHostInterface.h>
|
||||
#include <IOKit/usb/IOUSBHostPipe.h>
|
||||
#include <IOKit/IOBufferMemoryDescriptor.h>
|
||||
|
||||
#define QCA_GET_TARGET_VERSION 0x09
|
||||
#define QCA_CHECK_STATUS 0x05
|
||||
#define QCA_DFU_DOWNLOAD 0x01
|
||||
#define QCA_DFU_PACKET_LEN 4096
|
||||
|
||||
struct qca_version {
|
||||
uint32_t rom_version;
|
||||
uint32_t patch_version;
|
||||
uint32_t ram_version;
|
||||
uint8_t chip_id;
|
||||
uint8_t platform_id;
|
||||
uint16_t flag;
|
||||
uint8_t reserved[4];
|
||||
} __attribute__((packed));
|
||||
|
||||
class QualcommWireless : public IOService {
|
||||
OSDeclareDefaultStructors(QualcommWireless)
|
||||
|
||||
private:
|
||||
IOUSBHostDevice *fDevice;
|
||||
IOUSBHostInterface *fInterface;
|
||||
IOUSBHostPipe *fBulkOutPipe;
|
||||
IOUSBHostPipe *fIntrInPipe;
|
||||
IOBufferMemoryDescriptor *fBulkBuffer;
|
||||
|
||||
uint8_t checkStatus(void);
|
||||
bool queryTargetVersion(struct qca_version *verOut);
|
||||
bool downloadFirmware(const uint8_t *data, size_t size, size_t hdrSize);
|
||||
bool sendHciReset(void);
|
||||
|
||||
public:
|
||||
virtual bool init(OSDictionary *dictionary = 0) override;
|
||||
virtual void free(void) override;
|
||||
virtual IOService *probe(IOService *provider, SInt32 *score) override;
|
||||
virtual bool start(IOService *provider) override;
|
||||
virtual void stop(IOService *provider) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Apple80211.h
|
||||
// itlwm
|
||||
//
|
||||
// Created by qcwap on 2020/9/4.
|
||||
// Copyright © 2020 钟先耀. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef Apple80211_h
|
||||
#define Apple80211_h
|
||||
|
||||
#include <IOKit/80211/apple_private_spi.h>
|
||||
#include <IOKit/80211/debug.h>
|
||||
#include <IOKit/80211/IO80211WorkLoop.h>
|
||||
#include <IOKit/80211/IO80211Controller.h>
|
||||
#include <IOKit/80211/IO80211Interface.h>
|
||||
#include <IOKit/80211/IO80211VirtualInterface.h>
|
||||
#include <IOKit/80211/IO80211P2PInterface.h>
|
||||
#if __IO80211_TARGET >= __MAC_10_15
|
||||
#include <IOKit/80211/IO80211SkywalkInterface.h>
|
||||
#endif
|
||||
|
||||
#endif /* Apple80211_h */
|
||||
@@ -0,0 +1,358 @@
|
||||
//
|
||||
// IO80211Controller.h
|
||||
// IO80211Family
|
||||
//
|
||||
|
||||
#ifndef _IO80211CONTROLLER_H
|
||||
#define _IO80211CONTROLLER_H
|
||||
|
||||
#if defined(KERNEL) && defined(__cplusplus)
|
||||
|
||||
#include <Availability.h>
|
||||
#include <libkern/version.h>
|
||||
|
||||
// This is necessary, because even the latest Xcode does not support properly targeting 11.0.
|
||||
#ifndef __IO80211_TARGET
|
||||
#error "Please define __IO80211_TARGET to the requested version"
|
||||
#endif
|
||||
|
||||
#if VERSION_MAJOR > 8
|
||||
#define _MODERN_BPF
|
||||
#endif
|
||||
|
||||
#include <sys/kpi_mbuf.h>
|
||||
|
||||
#include <IOKit/network/IOEthernetController.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <net/bpf.h>
|
||||
|
||||
#include "apple80211_ioctl.h"
|
||||
#include "IO80211SkywalkInterface.h"
|
||||
#include "IO80211WorkLoop.h"
|
||||
|
||||
#define AUTH_TIMEOUT 15 // seconds
|
||||
|
||||
/*! @enum LinkSpeed.
|
||||
@abstract ???.
|
||||
@discussion ???.
|
||||
@constant LINK_SPEED_80211A 54 Mbps
|
||||
@constant LINK_SPEED_80211B 11 Mbps.
|
||||
@constant LINK_SPEED_80211G 54 Mbps.
|
||||
*/
|
||||
enum {
|
||||
LINK_SPEED_80211A = 54000000ul, // 54 Mbps
|
||||
LINK_SPEED_80211B = 11000000ul, // 11 Mbps
|
||||
LINK_SPEED_80211G = 54000000ul, // 54 Mbps
|
||||
LINK_SPEED_80211N = 300000000ul, // 300 Mbps (MCS index 15, 400ns GI, 40 MHz channel)
|
||||
};
|
||||
|
||||
enum IO80211CountryCodeOp
|
||||
{
|
||||
kIO80211CountryCodeReset, // Reset country code to world wide default, and start
|
||||
// searching for 802.11d beacon
|
||||
};
|
||||
typedef enum IO80211CountryCodeOp IO80211CountryCodeOp;
|
||||
|
||||
enum IO80211SystemPowerState
|
||||
{
|
||||
kIO80211SystemPowerStateUnknown,
|
||||
kIO80211SystemPowerStateAwake,
|
||||
kIO80211SystemPowerStateSleeping,
|
||||
};
|
||||
typedef enum IO80211SystemPowerState IO80211SystemPowerState;
|
||||
|
||||
enum IO80211FeatureCode
|
||||
{
|
||||
kIO80211Feature80211n = 1,
|
||||
};
|
||||
typedef enum IO80211FeatureCode IO80211FeatureCode;
|
||||
|
||||
|
||||
class IOSkywalkInterface;
|
||||
class IO80211ScanManager;
|
||||
enum CCStreamLogLevel
|
||||
{
|
||||
LEVEL_1,
|
||||
};
|
||||
|
||||
enum scanSource
|
||||
{
|
||||
SOURCE_1,
|
||||
};
|
||||
|
||||
enum joinStatus
|
||||
{
|
||||
STATUS_1,
|
||||
};
|
||||
|
||||
class IO80211Controller;
|
||||
class IO80211Interface;
|
||||
class IO82110WorkLoop;
|
||||
class IO80211VirtualInterface;
|
||||
class IO80211ControllerMonitor;
|
||||
class CCLogPipe;
|
||||
class CCIOReporterLogStream;
|
||||
class CCLogStream;
|
||||
class IO80211VirtualInterface;
|
||||
class IO80211RangingManager;
|
||||
class IO80211FlowQueue;
|
||||
class IO80211FlowQueueLegacy;
|
||||
class FlowIdMetadata;
|
||||
class IOReporter;
|
||||
extern void IO80211VirtualInterfaceNamerRetain();
|
||||
|
||||
|
||||
struct apple80211_hostap_state;
|
||||
|
||||
struct apple80211_awdl_sync_channel_sequence;
|
||||
struct ieee80211_ht_capability_ie;
|
||||
struct apple80211_channel_switch_announcement;
|
||||
struct apple80211_beacon_period_data;
|
||||
struct apple80211_power_debug_sub_info;
|
||||
struct apple80211_stat_report;
|
||||
struct apple80211_frame_counters;
|
||||
struct apple80211_leaky_ap_event;
|
||||
struct apple80211_chip_stats;
|
||||
struct apple80211_extended_stats;
|
||||
struct apple80211_ampdu_stat_report;
|
||||
struct apple80211_btCoex_report;
|
||||
struct apple80211_cca_report;
|
||||
class CCPipe;
|
||||
struct apple80211_lteCoex_report;
|
||||
|
||||
//typedef int scanSource;
|
||||
//typedef int joinStatus;
|
||||
//typedef int CCStreamLogLevel;
|
||||
typedef IOReturn (*IOCTL_FUNC)(IO80211Controller*, IO80211Interface*, IO80211VirtualInterface*, apple80211req*, bool);
|
||||
extern IOCTL_FUNC gGetHandlerTable[];
|
||||
extern IOCTL_FUNC gSetHandlerTable[];
|
||||
|
||||
class IO80211Controller : public IOEthernetController {
|
||||
OSDeclareAbstractStructors(IO80211Controller)
|
||||
|
||||
public:
|
||||
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
#if __IO80211_TARGET <= __MAC_10_15
|
||||
virtual bool terminate(unsigned int) APPLE_KEXT_OVERRIDE;
|
||||
#endif
|
||||
virtual bool init(OSDictionary *) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn configureReport(IOReportChannelList *,UInt,void *,void *) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn updateReport(IOReportChannelList *,UInt,void *,void *) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool start(IOService *) APPLE_KEXT_OVERRIDE;
|
||||
virtual void stop(IOService *) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOService* getProvider(void) const APPLE_KEXT_OVERRIDE { return IOEthernetController::getProvider(); }
|
||||
virtual IOWorkLoop* getWorkLoop(void) const APPLE_KEXT_OVERRIDE;
|
||||
virtual const char* stringFromReturn(int) APPLE_KEXT_OVERRIDE;
|
||||
virtual int errnoFromReturn(int) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOOutputQueue* getOutputQueue(void) const APPLE_KEXT_OVERRIDE { return NULL; }
|
||||
virtual bool createWorkLoop(void) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn enable(IONetworkInterface *) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn disable(IONetworkInterface *) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool attachInterface(IONetworkInterface **iface, bool attach = true) APPLE_KEXT_OVERRIDE { return IOEthernetController::attachInterface(iface, attach); }
|
||||
#if __IO80211_TARGET >= __MAC_10_15
|
||||
virtual void detachInterface(IONetworkInterface *iface, bool sync = false) APPLE_KEXT_OVERRIDE { IOEthernetController::detachInterface(iface, sync); }
|
||||
#endif
|
||||
virtual IONetworkInterface* createInterface(void) APPLE_KEXT_OVERRIDE { return IOEthernetController::createInterface(); }
|
||||
virtual bool configureInterface(IONetworkInterface *iface) APPLE_KEXT_OVERRIDE { return IOEthernetController::configureInterface(iface); }
|
||||
#ifdef __PRIVATE_SPI__
|
||||
virtual IOReturn outputStart(IONetworkInterface *,UInt) APPLE_KEXT_OVERRIDE;
|
||||
#endif
|
||||
virtual IOReturn getHardwareAddress(IOEthernetAddress *) APPLE_KEXT_OVERRIDE;
|
||||
virtual void requestPacketTx(void*, UInt) {}
|
||||
virtual IOReturn getHardwareAddressForInterface(IO80211Interface *,IOEthernetAddress *) { return kIOReturnSuccess; }
|
||||
virtual void inputMonitorPacket(mbuf_t,UInt,void *,unsigned long) {}
|
||||
virtual int outputRaw80211Packet(IO80211Interface *,mbuf_t) { return 0; }
|
||||
virtual int outputActionFrame(IO80211Interface *,mbuf_t) { return 0; }
|
||||
virtual int bpfOutputPacket(OSObject *,UInt,mbuf_t m) { return 0; }
|
||||
virtual SInt32 monitorModeSetEnabled(IO80211Interface*, bool, UInt) { return 0; }
|
||||
virtual IO80211Interface* getNetworkInterface(void) { return NULL; }
|
||||
#if __IO80211_TARGET >= __MAC_10_15
|
||||
virtual IO80211SkywalkInterface* getPrimarySkywalkInterface(void) { return NULL; }
|
||||
#endif
|
||||
virtual SInt32 apple80211_ioctl(IO80211Interface *, IO80211VirtualInterface*, ifnet_t,unsigned long,void *) { return 0; }
|
||||
#if __IO80211_TARGET >= __MAC_10_15
|
||||
virtual SInt32 apple80211_ioctl(IO80211SkywalkInterface *,unsigned long,void *) { return 0; }
|
||||
#endif
|
||||
virtual SInt32 apple80211_ioctl(IO80211Interface *interface, ifnet_t net,unsigned long id,void *data) {
|
||||
return apple80211_ioctl(interface, NULL, net, id, data);
|
||||
}
|
||||
virtual SInt32 apple80211Request(unsigned int, int, IO80211Interface*, void*) = 0;
|
||||
virtual SInt32 apple80211VirtualRequest(UInt,int,IO80211VirtualInterface *,void *) { return 0; }
|
||||
#if __IO80211_TARGET >= __MAC_10_15
|
||||
virtual SInt32 apple80211SkywalkRequest(UInt,int,IO80211SkywalkInterface *,void *) { return 0; }
|
||||
#endif
|
||||
virtual SInt32 stopDMA() = 0;
|
||||
virtual UInt32 hardwareOutputQueueDepth(IO80211Interface*) = 0;
|
||||
virtual SInt32 performCountryCodeOperation(IO80211Interface*, IO80211CountryCodeOp) = 0;
|
||||
virtual bool useAppleRSNSupplicant(IO80211Interface *) { return false; }
|
||||
virtual bool useAppleRSNSupplicant(IO80211VirtualInterface *) { return false; }
|
||||
virtual void dataLinkLayerAttachComplete(IO80211Interface *) {}
|
||||
virtual SInt32 enableFeature(IO80211FeatureCode, void*) = 0;
|
||||
virtual SInt32 setVirtualHardwareAddress(IO80211VirtualInterface *,ether_addr *) { return 0; }
|
||||
virtual SInt32 enableVirtualInterface(IO80211VirtualInterface *) { return 0; }
|
||||
virtual SInt32 disableVirtualInterface(IO80211VirtualInterface *) { return 0; }
|
||||
virtual bool requiresExplicitMBufRelease() {
|
||||
return false;
|
||||
}
|
||||
virtual bool flowIdSupported() {
|
||||
return false;
|
||||
}
|
||||
virtual IO80211FlowQueueLegacy* requestFlowQueue(FlowIdMetadata const*) { return NULL; }
|
||||
virtual void releaseFlowQueue(IO80211FlowQueue *) {}
|
||||
#if __IO80211_TARGET >= __MAC_10_15
|
||||
virtual void getLogPipes(CCPipe**, CCPipe**, CCPipe**) {};
|
||||
#endif
|
||||
virtual IOReturn enablePacketTimestamping(void) {
|
||||
return kIOReturnUnsupported;
|
||||
}
|
||||
virtual IOReturn disablePacketTimestamping(void) {
|
||||
return kIOReturnUnsupported;
|
||||
}
|
||||
virtual UInt32 selfDiagnosticsReport(int,char const*,UInt);
|
||||
virtual UInt32 getDataQueueDepth(OSObject *);
|
||||
#if __IO80211_TARGET >= __MAC_11_0
|
||||
virtual bool isAssociatedToMovingNetwork(void) { return false; }
|
||||
#endif
|
||||
virtual mbuf_flags_t inputPacket(mbuf_t) { return 0; }
|
||||
virtual SInt32 apple80211_ioctl_get(IO80211Interface *,IO80211VirtualInterface *,ifnet_t,void *) { return 0; }
|
||||
|
||||
|
||||
#if __IO80211_TARGET >= __MAC_10_15
|
||||
virtual SInt32 apple80211_ioctl_get(IO80211SkywalkInterface *,void *) { return 0; }
|
||||
virtual SInt32 apple80211_ioctl_set(IO80211Interface *,IO80211VirtualInterface *,IO80211SkywalkInterface *,void *) { return 0; }
|
||||
virtual SInt32 apple80211_ioctl_set(IO80211SkywalkInterface *,void*) { return 0; }
|
||||
virtual bool attachInterface(IOSkywalkInterface *,IOService *) { return false; }
|
||||
#else
|
||||
virtual SInt32 apple80211_ioctl_set(IO80211Interface *,IO80211VirtualInterface *,ifnet_t,void *) { return 0; }
|
||||
#endif
|
||||
|
||||
|
||||
#if __IO80211_TARGET >= __MAC_11_0
|
||||
virtual bool detachInterface(IOSkywalkInterface *, bool) { return false; }
|
||||
#endif
|
||||
virtual IO80211VirtualInterface* createVirtualInterface(ether_addr *,UInt) { return NULL; }
|
||||
virtual bool attachVirtualInterface(IO80211VirtualInterface **,ether_addr *,UInt,bool) { return false; }
|
||||
virtual bool detachVirtualInterface(IO80211VirtualInterface *,bool) { return false; }
|
||||
#if __IO80211_TARGET >= __MAC_10_15
|
||||
virtual IOReturn enable(IO80211SkywalkInterface *) { return kIOReturnSuccess; }
|
||||
virtual IOReturn disable(IO80211SkywalkInterface *) { return kIOReturnSuccess; }
|
||||
#endif
|
||||
|
||||
//public:
|
||||
// IO80211SkywalkInterface* getInfraInterface(void);
|
||||
// IO80211ScanManager* getPrimaryInterfaceScanManager(void);
|
||||
// IO80211ControllerMonitor* getInterfaceMonitor(void);
|
||||
// IOReturn addReporterLegend(IOService *,IOReporter *,char const*,char const*);
|
||||
// IOReturn removeReporterFromLegend(IOService *,IOReporter *,char const*,char const*);
|
||||
// IOReturn unlockIOReporterLegend(void);
|
||||
// void lockIOReporterLegend(void);// Suspected return type - int
|
||||
// IOReturn logIOReportLogStreamSubscription(unsigned long long);
|
||||
// IOReturn addIOReportLogStreamForProvider(IOService *,unsigned long long *);
|
||||
// IOReturn addSubscriptionForThisReporterFetchedOnTimer(IOReporter *,char const*,char const*,IOService *) ;
|
||||
// IOReturn addSubscriptionForProviderFetchedOnTimer(IOService *);
|
||||
// void handleIOReporterTimer(IOTimerEventSource *);
|
||||
// void setIOReportersStreamFlags(unsigned long long);
|
||||
// void updateIOReportersStreamFrequency(void); // Suspected return type - int
|
||||
// void setIOReportersStreamLevel(CCStreamLogLevel);
|
||||
// void powerChangeGated(OSObject *,void *,void *,void *,void *);
|
||||
// int copyOut(void const*,unsigned long long,unsigned long);
|
||||
// SInt32 getASSOCIATE_RESULT(IO80211Interface *,IO80211VirtualInterface *,IO80211SkywalkInterface *,apple80211_assoc_result_data *);
|
||||
// IOReturn copyIn(unsigned long long,void *,unsigned long);
|
||||
// void logIOCTL(apple80211req *);
|
||||
// bool isIOCTLLoggingRestricted(apple80211req *);
|
||||
// IOReturn setChanNoiseFloorLTE(apple80211_stat_report *,int);
|
||||
// IOReturn setChanNoiseFloor(apple80211_stat_report *,int);
|
||||
// IOReturn setChanCCA(apple80211_stat_report *,int);
|
||||
// IOReturn setChanExtendedCCA(apple80211_stat_report *,apple80211_cca_report *);
|
||||
// bool setLTECoexstat(apple80211_stat_report *,apple80211_lteCoex_report *);
|
||||
// bool setBTCoexstat(apple80211_stat_report *,apple80211_btCoex_report *);
|
||||
// bool setAMPDUstat(apple80211_stat_report *,apple80211_ampdu_stat_report *,apple80211_channel *);
|
||||
// UInt32 getCountryCode(apple80211_country_code_data *);
|
||||
// IOReturn setCountryCode(apple80211_country_code_data *);
|
||||
// bool getInfraExtendedStats(apple80211_extended_stats *);
|
||||
// bool getChipCounterStats(apple80211_chip_stats *);
|
||||
// bool setExtendedChipCounterStats(apple80211_stat_report *,void *);
|
||||
// bool setChipCounterStats(apple80211_stat_report *,apple80211_chip_stats *,apple80211_channel *);
|
||||
// virtual bool setLeakyAPStats(apple80211_leaky_ap_event *);
|
||||
// bool setFrameStats(apple80211_stat_report *,apple80211_frame_counters *,apple80211_channel *);
|
||||
// bool setPowerStats(apple80211_stat_report *,apple80211_power_debug_sub_info *);
|
||||
// bool getBeaconPeriod(apple80211_beacon_period_data *);
|
||||
SInt32 apple80211VirtualRequestIoctl(unsigned int,int,IO80211VirtualInterface *,void *);
|
||||
// bool getBSSIDData(OSObject *,apple80211_bssid_data *);
|
||||
// bool getSSIDData(apple80211_ssid_data *);
|
||||
// bool inputInfraPacket(mbuf_t);
|
||||
// void notifyHostapState(apple80211_hostap_state *);
|
||||
// bool isAwdlAssistedDiscoveryEnabled(void);
|
||||
// void joinDone(scanSource,joinStatus);
|
||||
// void joinStarted(scanSource,joinStatus);
|
||||
// void handleChannelSwitchAnnouncement(apple80211_channel_switch_announcement *);
|
||||
// void scanDone(scanSource,int);
|
||||
// void scanStarted(scanSource,apple80211_scan_data *);
|
||||
// void printChannels(void);
|
||||
// void updateInterfaceCoexRiskPct(unsigned long long);
|
||||
// SInt32 getInfraChannel(apple80211_channel_data *);
|
||||
// void calculateInterfacesAvaiability(void); // Suspected return type - int
|
||||
// void setChannelSequenceList(apple80211_awdl_sync_channel_sequence *); // Suspected return type - int
|
||||
// void setPrimaryInterfaceDatapathState(bool);
|
||||
// UInt32 getPrimaryInterfaceLinkState(void);
|
||||
// void setCurrentChannel(apple80211_channel *); // Suspected return type - int
|
||||
// void setHtCapability(ieee80211_ht_capability_ie *);
|
||||
// UInt32 getHtCapability(void);
|
||||
// UInt32 getHtCapabilityLength(void);
|
||||
// bool io80211isDebuggable(bool* enable);
|
||||
// void logDebug(unsigned long long,char const*,...); // Suspected return type - int
|
||||
// void vlogDebug(unsigned long long,char const*,va_list); // Suspected return type - char
|
||||
// void logDebug(char const*,...); // Suspected return type - int
|
||||
// bool calculateInterfacesCoex(void);
|
||||
// void setInfraChannel(apple80211_channel *);
|
||||
// void configureAntennae(void);
|
||||
SInt32 apple80211RequestIoctl(unsigned int,int,IO80211Interface *,void *);
|
||||
UInt32 radioCountForInterface(IO80211Interface *);
|
||||
// void releaseIOReporters(void);
|
||||
// bool findAndAttachToFaultReporter(void);
|
||||
// UInt32 setupControlPathLogging(void);
|
||||
// IOReturn createIOReporters(IOService *);
|
||||
// IOReturn powerChangeHandler(void *,void *,unsigned int,IOService *,void *,unsigned long);
|
||||
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 0);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 1);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 2);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 3);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 4);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 5);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 6);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 7);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 8);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 9);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 10);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 11);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 12);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 13);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 14);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Controller, 15);
|
||||
|
||||
protected:
|
||||
uint8_t filler[0x500];
|
||||
};
|
||||
|
||||
// 0x215: 1 byte, length of channel sequence, should be 16
|
||||
// 0x21c: channel sequence, should contain 16 elements of length 12, possibly apple80211_channel (but why 16?)
|
||||
// struct of three ints, last looks like flags, first unused
|
||||
|
||||
/*
|
||||
void __thiscall
|
||||
setChannelSequenceList(IO80211Controller *this,apple80211_awdl_sync_channel_sequence *param_1)
|
||||
|
||||
{
|
||||
_memcpy(this + 0x210,param_1,400);
|
||||
calculateInterfacesAvaiability(this);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
#endif /* defined(KERNEL) && defined(__cplusplus) */
|
||||
|
||||
#endif /* !_IO80211CONTROLLER_H */
|
||||
@@ -0,0 +1,144 @@
|
||||
//
|
||||
// IO80211SkywalkInterface.h
|
||||
// IO80211Family
|
||||
//
|
||||
|
||||
#ifndef _IO80211INTERFACE_H
|
||||
#define _IO80211INTERFACE_H
|
||||
|
||||
/*
|
||||
* Kernel
|
||||
*/
|
||||
#if defined(KERNEL) && defined(__cplusplus)
|
||||
|
||||
#include <Availability.h>
|
||||
#include <libkern/version.h>
|
||||
|
||||
// This is necessary, because even the latest Xcode does not support properly targeting 11.0.
|
||||
#ifndef __IO80211_TARGET
|
||||
#error "Please define __IO80211_TARGET to the requested version"
|
||||
#endif
|
||||
|
||||
#if VERSION_MAJOR > 8
|
||||
#define _MODERN_BPF
|
||||
#endif
|
||||
|
||||
#include <IOKit/network/IOEthernetInterface.h>
|
||||
#include <net/if_var.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
enum IO80211LinkState
|
||||
{
|
||||
kIO80211NetworkLinkUndefined, // Starting link state when an interface is created
|
||||
kIO80211NetworkLinkDown, // Interface not capable of transmitting packets
|
||||
kIO80211NetworkLinkUp, // Interface capable of transmitting packets
|
||||
};
|
||||
typedef enum IO80211LinkState IO80211LinkState;
|
||||
|
||||
/*! @defined kIO80211InterfaceClass
|
||||
@abstract The name of the IO80211Interface class.
|
||||
*/
|
||||
#define kIO80211InterfaceClass "IO80211Interface"
|
||||
|
||||
typedef UInt64 IO80211FlowQueueHash;
|
||||
class RSNSupplicant;
|
||||
class IOTimerEventSource;
|
||||
class IOGatedOutputQueue;
|
||||
class IO80211Controller;
|
||||
class IO80211Workloop;
|
||||
class IO80211ScanManager;
|
||||
class IO80211PeerManager;
|
||||
class IO80211FlowQueueDatabase;
|
||||
class IO80211InterfaceMonitor;
|
||||
class IO80211AssociationJoinSnapshot;
|
||||
|
||||
struct apple80211_debug_command;
|
||||
struct apple80211_txstats;
|
||||
struct apple80211_chip_counters_tx;
|
||||
struct apple80211_chip_error_counters_tx;
|
||||
struct apple80211_chip_counters_rx;
|
||||
struct apple80211_ManagementInformationBasedot11_counters;
|
||||
struct apple80211_leaky_ap_stats;
|
||||
struct apple80211_leaky_ap_ssid_metrics;
|
||||
struct apple80211_interface_availability;
|
||||
struct apple80211_pmk_cache_data;
|
||||
struct apple80211_ap_cmp_data;
|
||||
struct TxPacketRequest;
|
||||
struct AWSRequest;
|
||||
struct packet_info_tx;
|
||||
struct userPrintCtx;
|
||||
|
||||
typedef int apple80211_postMessage_tlv_types;
|
||||
|
||||
class IO80211Interface : public IOEthernetInterface
|
||||
{
|
||||
OSDeclareDefaultStructors( IO80211Interface );
|
||||
|
||||
public:
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn configureReport(IOReportChannelList *,uint,void *,void *) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn updateReport(IOReportChannelList *,uint,void *,void *) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool terminate(unsigned int) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool attach(IOService*) APPLE_KEXT_OVERRIDE;
|
||||
virtual void detach(IOService*) APPLE_KEXT_OVERRIDE;
|
||||
#if __IO80211_TARGET >= __MAC_10_15
|
||||
virtual IOReturn newUserClient(task_t, void*, UInt32 type, OSDictionary*, IOUserClient**) APPLE_KEXT_OVERRIDE;
|
||||
#endif
|
||||
virtual const char* stringFromReturn(int) APPLE_KEXT_OVERRIDE;
|
||||
virtual int errnoFromReturn(int) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool init(IONetworkController*) APPLE_KEXT_OVERRIDE;
|
||||
virtual UInt32 inputPacket(mbuf_t packet,
|
||||
UInt32 length = 0,
|
||||
IOOptionBits options = 0,
|
||||
void * param = 0) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool inputEvent(unsigned int, void*) APPLE_KEXT_OVERRIDE;
|
||||
virtual SInt32 performCommand(IONetworkController*, unsigned long, void*, void*) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn attachToDataLinkLayer(IOOptionBits, void*) APPLE_KEXT_OVERRIDE;
|
||||
virtual void detachFromDataLinkLayer(unsigned int, void*) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual void setPoweredOnByUser(bool);
|
||||
virtual void setEnabledBySystem(bool);
|
||||
|
||||
virtual bool setLinkState(IO80211LinkState, unsigned int);
|
||||
virtual bool setLinkState(IO80211LinkState, int, unsigned int);
|
||||
virtual UInt32 outputPacket(mbuf_t, void*);
|
||||
|
||||
virtual bool setLinkQualityMetric(int);
|
||||
virtual void handleDebugCmd(apple80211_debug_command*);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 0);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 1);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 2);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 3);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 4);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 5);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 6);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 7);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 8);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 9);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 10);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 11);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 12);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 13);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 14);
|
||||
OSMetaClassDeclareReservedUnused( IO80211Interface, 15);
|
||||
public:
|
||||
IO80211FlowQueue * findOrCreateFlowQueue(IO80211FlowQueueHash);
|
||||
void dropTxPacket(mbuf_t);
|
||||
void logDebug(unsigned long long, char const*, ...);
|
||||
void vlogDebug(unsigned long long, char const*, va_list);
|
||||
const char * getBSDName();
|
||||
bool setLeakyAPStatsMode(unsigned int);
|
||||
void stopOutputQueues();
|
||||
void startOutputQueues();
|
||||
bool updateLinkSpeed();
|
||||
bool reportDataTransferRatesStatic(void*);
|
||||
void logDebug(char const*, ...);
|
||||
void postMessage(unsigned int, void* data = NULL, unsigned long dataLen = 0);
|
||||
protected:
|
||||
u_int8_t dat[0x500];
|
||||
};
|
||||
|
||||
#endif /* defined(KERNEL) && defined(__cplusplus) */
|
||||
|
||||
#endif /* ! _IO80211INTERFACE_H */
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
#ifndef IO80211P2PInterface_h
|
||||
#define IO80211P2PInterface_h
|
||||
|
||||
#include "IO80211VirtualInterface.h"
|
||||
|
||||
class IO80211P2PInterface : public IO80211VirtualInterface {
|
||||
OSDeclareDefaultStructors(IO80211P2PInterface)
|
||||
|
||||
public:
|
||||
virtual void free(void) APPLE_KEXT_OVERRIDE;
|
||||
#if __IO80211_TARGET >= __MAC_11_0
|
||||
virtual bool willTerminate(IOService *,uint) APPLE_KEXT_OVERRIDE;
|
||||
#endif
|
||||
virtual IOReturn configureReport(IOReportChannelList *channels,
|
||||
IOReportConfigureAction action,
|
||||
void *result,
|
||||
void *destination) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn updateReport(IOReportChannelList *channels,
|
||||
IOReportUpdateAction action,
|
||||
void *result,
|
||||
void *destination) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual bool terminate( IOOptionBits options = 0 ) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool attach(IOService *) APPLE_KEXT_OVERRIDE;
|
||||
virtual void detach(IOService *) APPLE_KEXT_OVERRIDE;
|
||||
#if __IO80211_TARGET >= __MAC_10_15
|
||||
virtual IOReturn newUserClient(task_t,void *,UInt,OSDictionary *,IOUserClient **) APPLE_KEXT_OVERRIDE;
|
||||
#endif
|
||||
virtual const char * stringFromReturn( IOReturn rtn ) APPLE_KEXT_OVERRIDE;
|
||||
virtual int errnoFromReturn( IOReturn rtn ) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn powerStateWillChangeTo(
|
||||
IOPMPowerFlags capabilities,
|
||||
unsigned long stateNumber,
|
||||
IOService * whatDevice ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOReturn powerStateDidChangeTo(
|
||||
IOPMPowerFlags capabilities,
|
||||
unsigned long stateNumber,
|
||||
IOService * whatDevice ) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool init(IO80211Controller *,ether_addr *,uint,char const*) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool createPeerManager(ether_addr *,IO80211PeerManager **) APPLE_KEXT_OVERRIDE;
|
||||
virtual UInt getMediumType() APPLE_KEXT_OVERRIDE;
|
||||
virtual void setLinkState(IO80211LinkState,uint) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool dequeueOutputPacketsWithServiceClass(uint,IOMbufServiceClass,mbuf_t*,mbuf_t*,UInt *,unsigned long long *) APPLE_KEXT_OVERRIDE;
|
||||
virtual UInt32 outputPacket (mbuf_t m, void* param) APPLE_KEXT_OVERRIDE;
|
||||
virtual void setEnabledBySystem(bool) APPLE_KEXT_OVERRIDE;
|
||||
virtual void handleIoctl(unsigned long,void *) APPLE_KEXT_OVERRIDE;
|
||||
virtual UInt32 inputPacket(mbuf_t,packet_info_tag *) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn controllerWillChangePowerState(IO80211Controller *,unsigned long,UInt,IOService *) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn controllerDidChangePowerState(IO80211Controller *,unsigned long,UInt,IOService *) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool handleDebugCmd(apple80211_debug_command *) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn postPeerPresence(ether_addr *,int,int,int,char *) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn postPeerAbsence(ether_addr *) APPLE_KEXT_OVERRIDE;
|
||||
#if __IO80211_TARGET >= __MAC_10_15
|
||||
virtual IOReturn postPeerPresenceIPv6(ether_addr *,int,int,int,char *,unsigned char *) APPLE_KEXT_OVERRIDE;
|
||||
#endif
|
||||
virtual void signalOutputThread() APPLE_KEXT_OVERRIDE;
|
||||
virtual bool isOutputFlowControlled() APPLE_KEXT_OVERRIDE;
|
||||
virtual void setOutputFlowControlled() APPLE_KEXT_OVERRIDE;
|
||||
virtual void clearOutputFlowControlled() APPLE_KEXT_OVERRIDE;
|
||||
virtual void outputStart(uint) APPLE_KEXT_OVERRIDE;
|
||||
virtual UInt32 configureAQMOutput() APPLE_KEXT_OVERRIDE;
|
||||
virtual void setUnitNumber(char const*) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool initIfnetEparams(ifnet_init_eparams *) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool attachToBpf() APPLE_KEXT_OVERRIDE;
|
||||
virtual bool configureIfnet() APPLE_KEXT_OVERRIDE;
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 0);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 1);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 2);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 3);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 4);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 5);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 6);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 7);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 8);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 9);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 10);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 11);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 12);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 13);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 14);
|
||||
OSMetaClassDeclareReservedUnused( IO80211P2PInterface, 15);
|
||||
public:
|
||||
char buf[0x300];
|
||||
};
|
||||
|
||||
#endif /* IO80211P2PInterface_h */
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// IO80211SkywalkInterface.h
|
||||
// IO80211Family
|
||||
//
|
||||
// Created by 钟先耀 on 2019/10/18.
|
||||
// Copyright © 2019 钟先耀. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef _IO80211SKYWALK_H
|
||||
#define _IO80211SKYWALK_H
|
||||
|
||||
#include <Availability.h>
|
||||
#include <IOKit/network/IOSkywalkEthernetInterface.h>
|
||||
|
||||
// This is necessary, because even the latest Xcode does not support properly targeting 11.0.
|
||||
#ifndef __IO80211_TARGET
|
||||
#error "Please define __IO80211_TARGET to the requested version"
|
||||
#endif
|
||||
|
||||
class IO80211SkywalkInterface : IOSkywalkEthernetInterface {
|
||||
OSDeclareAbstractStructors(IO80211SkywalkInterface)
|
||||
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
#endif /* _IO80211SKYWALK_H */
|
||||
@@ -0,0 +1,101 @@
|
||||
#ifndef IO80211VirtualInterface_h
|
||||
#define IO80211VirtualInterface_h
|
||||
|
||||
#include "IO80211Interface.h"
|
||||
#include "apple_private_spi.h"
|
||||
|
||||
class IO80211PeerManager;
|
||||
|
||||
class IO80211VirtualInterface : public IOService {
|
||||
OSDeclareDefaultStructors(IO80211VirtualInterface)
|
||||
|
||||
public:
|
||||
virtual void free(void) APPLE_KEXT_OVERRIDE;
|
||||
#if __IO80211_TARGET >= __MAC_11_0
|
||||
virtual bool willTerminate( IOService * provider, IOOptionBits options ) APPLE_KEXT_OVERRIDE;
|
||||
#endif
|
||||
virtual IOReturn configureReport(IOReportChannelList *channels,
|
||||
IOReportConfigureAction action,
|
||||
void *result,
|
||||
void *destination) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn updateReport(IOReportChannelList *channels,
|
||||
IOReportUpdateAction action,
|
||||
void *result,
|
||||
void *destination) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool terminate( IOOptionBits options = 0 ) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool attach(IOService *) APPLE_KEXT_OVERRIDE;
|
||||
virtual void detach(IOService *) APPLE_KEXT_OVERRIDE;
|
||||
#if __IO80211_TARGET >= __MAC_10_15
|
||||
virtual IOReturn newUserClient(task_t,void *,UInt,OSDictionary *,IOUserClient **) APPLE_KEXT_OVERRIDE;
|
||||
#endif
|
||||
virtual const char * stringFromReturn( IOReturn rtn ) APPLE_KEXT_OVERRIDE;
|
||||
virtual int errnoFromReturn( IOReturn rtn ) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn powerStateWillChangeTo(
|
||||
IOPMPowerFlags capabilities,
|
||||
unsigned long stateNumber,
|
||||
IOService * whatDevice ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOReturn powerStateDidChangeTo(
|
||||
IOPMPowerFlags capabilities,
|
||||
unsigned long stateNumber,
|
||||
IOService * whatDevice ) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool init(IO80211Controller *,ether_addr *,uint,char const*);
|
||||
virtual bool createPeerManager(ether_addr *,IO80211PeerManager **);
|
||||
virtual UInt getMediumType();
|
||||
virtual void setLinkState(IO80211LinkState,uint);
|
||||
virtual bool dequeueOutputPacketsWithServiceClass(uint,IOMbufServiceClass,mbuf_t*,mbuf_t*,UInt *,unsigned long long *);
|
||||
virtual UInt32 outputPacket (mbuf_t m, void* param);
|
||||
virtual void setEnabledBySystem(bool);
|
||||
virtual void handleIoctl(unsigned long,void *);
|
||||
virtual UInt32 inputPacket(mbuf_t,packet_info_tag *);
|
||||
virtual IOReturn controllerWillChangePowerState(IO80211Controller *,unsigned long,UInt,IOService *);
|
||||
virtual IOReturn controllerDidChangePowerState(IO80211Controller *,unsigned long,UInt,IOService *);
|
||||
virtual bool handleDebugCmd(apple80211_debug_command *);
|
||||
virtual IOReturn postPeerPresence(ether_addr *,int,int,int,char *);
|
||||
virtual IOReturn postPeerAbsence(ether_addr *);
|
||||
#if __IO80211_TARGET >= __MAC_10_15
|
||||
virtual IOReturn postPeerPresenceIPv6(ether_addr *,int,int,int,char *,unsigned char *);
|
||||
#endif
|
||||
virtual void signalOutputThread();
|
||||
virtual bool isOutputFlowControlled();
|
||||
virtual void setOutputFlowControlled();
|
||||
virtual void clearOutputFlowControlled();
|
||||
virtual void outputStart(uint);
|
||||
virtual UInt32 configureAQMOutput();
|
||||
virtual void setUnitNumber(char const*);
|
||||
virtual bool initIfnetEparams(ifnet_init_eparams *);
|
||||
virtual bool attachToBpf();
|
||||
virtual bool configureIfnet();
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 0);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 1);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 2);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 3);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 4);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 5);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 6);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 7);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 8);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 9);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 10);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 11);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 12);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 13);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 14);
|
||||
OSMetaClassDeclareReservedUnused( IO80211VirtualInterface, 15);
|
||||
public:
|
||||
|
||||
static void startOutputQueues();
|
||||
|
||||
static void stopOutputQueues();
|
||||
|
||||
static void postMessage(unsigned int, void* data = NULL, unsigned long dataLen = 0);
|
||||
|
||||
static int getInterfaceRole();
|
||||
|
||||
const char *getBSDName();
|
||||
public:
|
||||
char buf[0x300];
|
||||
};
|
||||
|
||||
|
||||
#endif /* IO80211VirtualInterface_h */
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Released under "The BSD 3-Clause License"
|
||||
*
|
||||
* Copyright (c) 2021 cjiang. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The names of its contributors may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IO80211VIRTUALINTERFACENAMER_H
|
||||
#define _IO80211VIRTUALINTERFACENAMER_H
|
||||
|
||||
#include <IOKit/IOService.h>
|
||||
|
||||
class IO80211VirtualInterfaceNamer : public IOService
|
||||
{
|
||||
OSDeclareDefaultStructors(IO80211VirtualInterfaceNamer)
|
||||
|
||||
public:
|
||||
virtual bool init() APPLE_KEXT_OVERRIDE;
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
bool arrayContainsUnitNumber( OSArray * array, OSNumber * unitNumber );
|
||||
bool markInterfaceUnitUsed( char const * name, UInt32 unitNumber );
|
||||
void markInterfaceUnitUnused( char const * name, UInt32 unitNumber );
|
||||
UInt32 nextAvailableUnitNumberForName( char const * name, bool markUsed );
|
||||
|
||||
IORecursiveLock * _lock;
|
||||
OSDictionary * _interfaceUnits; // all OSArrays
|
||||
};
|
||||
|
||||
static IO80211VirtualInterfaceNamer * _interfaceNamer;
|
||||
|
||||
bool IO80211VirtualInterfaceNamerRetain();
|
||||
void IO80211VirtualInterfaceNamerRelease();
|
||||
bool IO80211VirtualInterfaceNamerMarkInterfaceUnitUsed( char const * name, UInt32 unitNumber );
|
||||
void IO80211VirtualInterfaceNamerMarkInterfaceUnitUnused( char const * name, UInt32 unitNumber );
|
||||
UInt32 IO80211VirtualInterfaceNamerNextAvailableUnitNumberForName( char const * name, bool markUsed );
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* IO80211WorkLoop.h
|
||||
* IO80211Family
|
||||
*
|
||||
* Created by Pete on 5/31/06.
|
||||
* Copyright 2006 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IO80211WORKLOOP_H
|
||||
#define _IO80211WORKLOOP_H
|
||||
|
||||
#include <Availability.h>
|
||||
#include <IOKit/IOWorkLoop.h>
|
||||
|
||||
// This is necessary, because even the latest Xcode does not support properly targeting 11.0.
|
||||
#ifndef __IO80211_TARGET
|
||||
#error "Please define __IO80211_TARGET to the requested version"
|
||||
#endif
|
||||
|
||||
class IO80211WorkLoop : public IOWorkLoop
|
||||
{
|
||||
OSDeclareDefaultStructors( IO80211WorkLoop )
|
||||
|
||||
public:
|
||||
|
||||
static IO80211WorkLoop * workLoop();
|
||||
|
||||
virtual void openGate() APPLE_KEXT_OVERRIDE;
|
||||
virtual void closeGate() APPLE_KEXT_OVERRIDE;
|
||||
virtual int sleepGate( void * event, UInt32 interuptibleType ) APPLE_KEXT_OVERRIDE;
|
||||
virtual int sleepGateDeadline( void * event, UInt32 interuptibleType, AbsoluteTime deadline );
|
||||
virtual void wakeupGate( void * event, bool oneThread ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef IOSkywalkEthernetInterface_h
|
||||
#define IOSkywalkEthernetInterface_h
|
||||
|
||||
#include <IOKit/network/IOEthernetController.h>
|
||||
|
||||
class IOSkywalkEthernetInterface : public IOEthernetController {
|
||||
OSDeclareAbstractStructors( IOSkywalkEthernetInterface )
|
||||
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
#endif /* IOSkywalkEthernetInterface_h */
|
||||
@@ -0,0 +1,850 @@
|
||||
/*
|
||||
* Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
#ifndef _APPLE80211_IOCTL_H_
|
||||
#define _APPLE80211_IOCTL_H_
|
||||
|
||||
#include <Availability.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
// This is necessary, because even the latest Xcode does not support properly targeting 11.0.
|
||||
#ifndef __IO80211_TARGET
|
||||
#error "Please define __IO80211_TARGET to the requested version"
|
||||
#endif
|
||||
|
||||
#include <IOKit/80211/apple80211_var.h>
|
||||
|
||||
struct apple80211req
|
||||
{
|
||||
char req_if_name[IFNAMSIZ]; // 16 bytes
|
||||
int req_type; // 4 bytes
|
||||
int req_val; // 4 bytes
|
||||
u_int32_t req_len; // 4 bytes
|
||||
void *req_data; // 4 bytes
|
||||
};
|
||||
|
||||
#define SIOCSA80211 2150656456
|
||||
#define SIOCGA80211 3224398281
|
||||
|
||||
// req_type
|
||||
|
||||
#define APPLE80211_IOC_SSID 1 // req_type
|
||||
|
||||
#define APPLE80211_IOC_AUTH_TYPE 2 // req_type
|
||||
#define APPLE80211_AUTH_TYPE_UNICAST 1 // req_val, SIOCGA80211 only
|
||||
#define APPLE80211_AUTH_TYPE_MULTICAST 2 // req_val, SIOCGA80211 only
|
||||
|
||||
#define APPLE80211_IOC_CIPHER_KEY 3 // req_type
|
||||
#define APPLE80211_CIPHER_KEY_UNICAST 1 // req_val
|
||||
#define APPLE80211_CIPHER_KEY_MULICAST 2 // req_val
|
||||
|
||||
#define APPLE80211_IOC_CHANNEL 4 // req_type
|
||||
|
||||
#define APPLE80211_IOC_POWERSAVE 5 // req_type
|
||||
|
||||
#define APPLE80211_IOC_PROTMODE 6 // req_type
|
||||
|
||||
#define APPLE80211_IOC_TXPOWER 7 // req_type
|
||||
#define APPLE80211_IOC_RATE 8 // req_type
|
||||
#define APPLE80211_IOC_BSSID 9 // req_type
|
||||
|
||||
#define APPLE80211_IOC_SCAN_REQ 10 // req_type
|
||||
|
||||
#define APPLE80211_IOC_SCAN_RESULT 11 // req_type
|
||||
|
||||
#define APPLE80211_IOC_CARD_CAPABILITIES 12 // req_type
|
||||
|
||||
#define APPLE80211_IOC_STATE 13 // req_type (apple80211_state)
|
||||
#define APPLE80211_IOC_PHY_MODE 14 // req_type (apple80211_phymode)
|
||||
|
||||
#define APPLE80211_IOC_OP_MODE 15 // req_type (apple80211_opmode)
|
||||
#define APPLE80211_IOC_RSSI 16 // req_type
|
||||
#define APPLE80211_IOC_NOISE 17 // req_type
|
||||
|
||||
#define APPLE80211_IOC_INT_MIT 18
|
||||
#define APPLE80211_IOC_INT_MIT_OFF 1 // req_val
|
||||
#define APPLE80211_IOC_INT_MIT_ON 2 // req_val
|
||||
|
||||
// card power
|
||||
#define APPLE80211_IOC_POWER 19 // req_type
|
||||
|
||||
#define APPLE80211_IOC_ASSOCIATE 20 // req_type
|
||||
#define APPLE80211_IOC_ASSOCIATE_RESULT 21 // req_type
|
||||
#define APPLE80211_IOC_DISASSOCIATE 22 // req_type
|
||||
#define APPLE80211_IOC_STATUS_DEV_NAME 23 // req_type
|
||||
|
||||
#define APPLE80211_IOC_IBSS_MODE 24 // req_type
|
||||
#define APPLE80211_IOC_IBSS_MODE_START 1 // req_val
|
||||
#define APPLE80211_IOC_IBSS_MODE_STOP 2 // req_val
|
||||
|
||||
#define APPLE80211_IOC_HOST_AP_MODE 25 // req_type
|
||||
#define APPLE80211_IOC_HOST_AP_MODE_START 1 // req_val
|
||||
#define APPLE80211_IOC_HOST_AP_MODE_STOP 2 // req_val
|
||||
|
||||
#define APPLE80211_IOC_AP_MODE 26 // req_type (apple80211_apmode)
|
||||
#define APPLE80211_IOC_SUPPORTED_CHANNELS 27 // req_type
|
||||
#define APPLE80211_IOC_LOCALE 28 // req_type
|
||||
#define APPLE80211_IOC_DEAUTH 29 // req_type
|
||||
#define APPLE80211_IOC_COUNTERMEASURES 30 // req_type
|
||||
#define APPLE80211_IOC_FRAG_THRESHOLD 31 // req_type
|
||||
#define APPLE80211_IOC_RATE_SET 32 // req_type
|
||||
#define APPLE80211_IOC_SHORT_SLOT 33 // req_type
|
||||
#define APPLE80211_IOC_MULTICAST_RATE 34 // req_type
|
||||
#define APPLE80211_IOC_SHORT_RETRY_LIMIT 35 // req_type
|
||||
#define APPLE80211_IOC_LONG_RETRY_LIMIT 36 // req_type
|
||||
#define APPLE80211_IOC_TX_ANTENNA 37 // req_type
|
||||
#define APPLE80211_IOC_RX_ANTENNA 38 // req_type
|
||||
#define APPLE80211_IOC_ANTENNA_DIVERSITY 39 // req_type
|
||||
#define APPLE80211_IOC_ROM 40 // req_type
|
||||
#define APPLE80211_IOC_DTIM_INT 41 // req_type
|
||||
#define APPLE80211_IOC_STATION_LIST 42 // req_type
|
||||
#define APPLE80211_IOC_DRIVER_VERSION 43 // req_type
|
||||
#define APPLE80211_IOC_HARDWARE_VERSION 44 // req_type
|
||||
#define APPLE80211_IOC_RAND 45 // req_type
|
||||
#define APPLE80211_IOC_RSN_IE 46 // req_type
|
||||
#define APPLE80211_IOC_BACKGROUND_SCAN 47 // req_type
|
||||
#define APPLE80211_IOC_AP_IE_LIST 48 // req_type
|
||||
#define APPLE80211_IOC_STATS 49 // req_type
|
||||
#define APPLE80211_IOC_ASSOCIATION_STATUS 50 // req_type
|
||||
#define APPLE80211_IOC_COUNTRY_CODE 51 // req_type
|
||||
#define APPLE80211_IOC_DEBUG_FLAGS 52 // req_type
|
||||
#define APPLE80211_IOC_LAST_RX_PKT_DATA 53 // req_type
|
||||
#define APPLE80211_IOC_RADIO_INFO 54 // req_type
|
||||
#define APPLE80211_IOC_GUARD_INTERVAL 55 // req_type
|
||||
#define APPLE80211_IOC_MIMO_POWERSAVE 56 // req_type
|
||||
#define APPLE80211_IOC_MCS 57 // req_type
|
||||
#define APPLE80211_IOC_RIFS 58 // req_type
|
||||
#define APPLE80211_IOC_LDPC 59 // req_type
|
||||
#define APPLE80211_IOC_MSDU 60 // req_type
|
||||
#define APPLE80211_IOC_MPDU 61 // req_type
|
||||
#define APPLE80211_IOC_BLOCK_ACK 62 // req_type
|
||||
#define APPLE80211_IOC_PLS 63 // req_type
|
||||
#define APPLE80211_IOC_PSMP 64 // req_type
|
||||
#define APPLE80211_IOC_PHY_SUB_MODE 65 // req_type
|
||||
#define APPLE80211_IOC_MCS_INDEX_SET 66 // req_type
|
||||
#define APPLE80211_IOC_CACHE_THRESH_BCAST 67 // req_type
|
||||
#define APPLE80211_IOC_CACHE_THRESH_DIRECT 68 // req_type
|
||||
#define APPLE80211_IOC_WOW_PARAMETERS 69 // req_type
|
||||
#define APPLE80211_IOC_WOW_ENABLED 70 // req_type
|
||||
#define APPLE80211_IOC_40MHZ_INTOLERANT 71 // req_type
|
||||
#define APPLE80211_IOC_PID_LOCK 72
|
||||
#define APPLE80211_IOC_STA_IE_LIST 73
|
||||
#define APPLE80211_IOC_STA_AUTHORIZE 74
|
||||
#define APPLE80211_IOC_STA_DISASSOCIATE 75
|
||||
#define APPLE80211_IOC_STA_DEAUTH 76
|
||||
#define APPLE80211_IOC_RSN_CONF 77
|
||||
#define APPLE80211_IOC_KEY_RSC 78
|
||||
#define APPLE80211_IOC_STA_STATS 79
|
||||
#define APPLE80211_IOC_ROAM_THRESH 80
|
||||
#define APPLE80211_IOC_VENDOR_DBG_FLAGS 81
|
||||
#define APPLE80211_IOC_CACHE_AGE_THRESH 82
|
||||
#define APPLE80211_IOC_PMK_CACHE 83
|
||||
#define APPLE80211_IOC_LINK_QUAL_EVENT_PARAMS 84
|
||||
#define APPLE80211_IOC_IE 85
|
||||
#define APPLE80211_IOC_SCAN_REQ_MULTIPLE 86
|
||||
#define APPLE80211_IOC_BTCOEX_MODE 87
|
||||
#define APPLE80211_IOC_WOW_TEST 88
|
||||
#define APPLE80211_IOC_CLEAR_PMK_CACHE 89
|
||||
#define APPLE80211_IOC_SCANCACHE_CLEAR 90
|
||||
#define APPLE80211_IOC_P2P_ENABLE 91
|
||||
#define APPLE80211_IOC_P2P_LISTEN 92
|
||||
#define APPLE80211_IOC_P2P_SCAN 93
|
||||
#define APPLE80211_IOC_VIRTUAL_IF_CREATE 94
|
||||
#define APPLE80211_IOC_VIRTUAL_IF_DELETE 95
|
||||
#define APPLE80211_IOC_VIRTUAL_IF_ROLE 96
|
||||
#define APPLE80211_IOC_VIRTUAL_IF_PARENT 97
|
||||
#define APPLE80211_IOC_P2P_GO_CONF 98
|
||||
#define APPLE80211_IOC_P2P_NOA_LIST 99
|
||||
#define APPLE80211_IOC_P2P_OPP_PS 100
|
||||
#define APPLE80211_IOC_P2P_CT_WINDOW 101
|
||||
#define APPLE80211_IOC_BT_COEX_FLAGS 102
|
||||
#define APPLE80211_IOC_CURRENT_NETWORK 103
|
||||
#define APPLE80211_IOC_BT_POWER 104
|
||||
#define APPLE80211_IOC_AVAILABILITY 105
|
||||
#define APPLE80211_IOC_RSSI_BOUNDS 106
|
||||
#define APPLE80211_IOC_ROAM 107
|
||||
#define APPLE80211_IOC_TX_CHAIN_POWER 108
|
||||
#define APPLE80211_IOC_CDD_MODE 109
|
||||
#define APPLE80211_IOC_LAST_BCAST_SCAN_TIME 110
|
||||
#define APPLE80211_IOC_THERMAL_THROTTLING 111
|
||||
#define APPLE80211_IOC_FACTORY_MODE 112
|
||||
#define APPLE80211_IOC_REASSOCIATE 113
|
||||
|
||||
#define APPLE80211_IOC_POWER_DEBUG_INFO 115
|
||||
#define APPLE80211_IOC_AWDL_SYNC_PARAMS 116
|
||||
#define APPLE80211_IOC_AWDL_SYNC_ENABLED 117
|
||||
#define APPLE80211_IOC_AWDL_EXTENSION_STATE_MACHINE_PARAMETERS 118
|
||||
#define APPLE80211_IOC_AWDL_SERVICE_PARAMS 119
|
||||
#define APPLE80211_IOC_AWDL_PEER_SERVICE_REQUEST 120
|
||||
#define APPLE80211_IOC_AWDL_ELECTION_ALGORITHM_ENABLED 121
|
||||
#define APPLE80211_IOC_AWDL_ELECTION_ID 122
|
||||
#define APPLE80211_IOC_AWDL_MAX_TREE_DEPTH 123
|
||||
#define APPLE80211_IOC_AWDL_GUARD_TIME 124
|
||||
#define APPLE80211_IOC_AWDL_BSSID 125
|
||||
#define APPLE80211_IOC_AWDL_ELECTION_METRIC 126
|
||||
#define APPLE80211_IOC_AWDL_AVAILABILITY_WINDOW_AP_ALIGNMENT 127
|
||||
#define APPLE80211_IOC_AWDL_SYNC_FRAME_AP_BEACON_ALIGNMENT 128
|
||||
#define APPLE80211_IOC_AWDL_SYNCHRONIZATION_CHANNEL_SEQUENCE 129
|
||||
#define APPLE80211_IOC_PEER_CACHE_MAXIMUM_SIZE 130
|
||||
#define APPLE80211_IOC_AWDL_OUI 131
|
||||
#define APPLE80211_IOC_AWDL_MASTER_CHANNEL 132
|
||||
#define APPLE80211_IOC_AWDL_TOP_MASTER 133
|
||||
#define APPLE80211_IOC_AWDL_SYNC_STATE 134
|
||||
#define APPLE80211_IOC_AWDL_ELECTION_RSSI_THRESHOLDS 135
|
||||
#define APPLE80211_IOC_AWDL_PRESENCE_MODE 136
|
||||
#define APPLE80211_IOC_AWDL_ELECTION_MASTER_COUNTS 137
|
||||
#define APPLE80211_IOC_AWDL_PERIODIC_SYNC_FRAME_PACKET_LIFETIME 138
|
||||
#define APPLE80211_IOC_AWDL_MASTER_MODE_SYNC_FRAME_PERIOD 139
|
||||
#define APPLE80211_IOC_AWDL_NON_ELECTION_MASTER_MODE_SYNC_FRAME_PERIOD 140
|
||||
#define APPLE80211_IOC_AWDL_EXPLICIT_AVAILABILITY_WINDOW_EXTENSION_OPT_OUT 141
|
||||
#define APPLE80211_IOC_AWDL_GET_AWDL_MASTER_DATABASE 142
|
||||
#define APPLE80211_IOC_PEER_CACHE_CONTROL 143
|
||||
#define APPLE80211_IOC_AWDL_BATTERY_LEVEL 144
|
||||
#define APPLE80211_IOC_AWDL_BT_COEX_AW_PROTECTED_PERIOD_LENGTH 145
|
||||
#define APPLE80211_IOC_AWDL_BT_COEX_AGREEMENT 146
|
||||
#define APPLE80211_IOC_AWDL_BT_COEX_AGREEMENT_ENABLED 147
|
||||
#define APPLE80211_IOC_AWDL_STRATEGY 148
|
||||
#define APPLE80211_IOC_AWDL_OOB_REQUEST 149
|
||||
#define APPLE80211_IOC_AWDL_MAX_NO_MASTER_PERIODS 150
|
||||
#define APPLE80211_IOC_AWDL_SYNC_FRAME_TEMPLATE 151
|
||||
#define APPLE80211_IOC_LOG_FLAGS 152
|
||||
#define APPLE80211_IOC_PEER_STATS 153
|
||||
#define APPLE80211_IOC_HT_CAPABILITY 154
|
||||
#define APPLE80211_IOC_AWDL_ELECTION_PARAMS 155
|
||||
#define APPLE80211_IOC_LINK_CHANGED_EVENT_DATA 156
|
||||
#define APPLE80211_IOC_GET_DEBUG_INFO 157
|
||||
#define APPLE80211_IOC_AWDL_DEVICE_CAPABILITIES 158
|
||||
#define APPLE80211_IOC_AWDL_RSSI_MEASUREMENT_REQUEST 159
|
||||
#define APPLE80211_IOC_AWDL_AES_KEY 160
|
||||
#define APPLE80211_IOC_AWDL_SCAN_RESERVED_TIME 161
|
||||
#define APPLE80211_IOC_AWDL_CTL 162
|
||||
#define APPLE80211_IOC_AWDL_SOCIAL_TIME_SLOTS 163
|
||||
#define APPLE80211_IOC_AWDL_PEER_TRAFFIC_REGISTRATION 164
|
||||
#define APPLE80211_IOC_EXTENDED_STATS 165
|
||||
#define APPLE80211_IOC_BEACON_PERIOD 166
|
||||
#define APPLE80211_IOC_AWDL_FORCED_ROAM_CONFIG 167
|
||||
#define APPLE80211_IOC_AWDL_QUIET 168
|
||||
#define APPLE80211_IOC_ACL_POLICY 169
|
||||
#define APPLE80211_IOC_ACL_ADD 170
|
||||
#define APPLE80211_IOC_ACL_REMOVE 171
|
||||
#define APPLE80211_IOC_ACL_FLUSH 172
|
||||
#define APPLE80211_IOC_ACL_LIST 173
|
||||
#define APPLE80211_IOC_CHAIN_ACK 174
|
||||
#define APPLE80211_IOC_DESENSE 175
|
||||
#define APPLE80211_IOC_OFFLOAD_SCANNING 176
|
||||
#define APPLE80211_IOC_OFFLOAD_RSN 177
|
||||
#define APPLE80211_IOC_OFFLOAD_COUNTRY_CODE 178
|
||||
#define APPLE80211_IOC_OFFLOAD_KEEPALIVE_L2 179
|
||||
#define APPLE80211_IOC_OFFLOAD_ARP_NDP 180
|
||||
#define APPLE80211_IOC_VHT_MCS_INDEX_SET 181
|
||||
#define APPLE80211_IOC_DWDS 182
|
||||
#define APPLE80211_IOC_INTERRUPT_STATS 183
|
||||
#define APPLE80211_IOC_INTERRUPT_STATS_RESET 184
|
||||
#define APPLE80211_IOC_TIMER_STATS 185
|
||||
#define APPLE80211_IOC_TIMER_STATS_RESET 186
|
||||
#define APPLE80211_IOC_OFFLOAD_STATS 187
|
||||
#define APPLE80211_IOC_OFFLOAD_STATS_RESET 188
|
||||
#define APPLE80211_IOC_OFFLOAD_BEACONS 189
|
||||
#define APPLE80211_IOC_ROAMING 190
|
||||
#define APPLE80211_IOC_OFFLOAD_ARP 191
|
||||
#define APPLE80211_IOC_OFFLOAD_NDP 192
|
||||
#define APPLE80211_IOC_OFFLOAD_SCAN 193
|
||||
#define APPLE80211_IOC_DESENSE_LEVEL 194
|
||||
#define APPLE80211_IOC_MCS_VHT 195
|
||||
#define APPLE80211_IOC_TX_NSS 196
|
||||
#define APPLE80211_IOC_GAS_REQ 197
|
||||
#define APPLE80211_IOC_GAS_START 198
|
||||
#define APPLE80211_IOC_GAS_SET_PEER 199
|
||||
#define APPLE80211_IOC_GAS_RESULTS 200
|
||||
#define APPLE80211_IOC_AWDL_BTLE_PEER_INDICATION 201
|
||||
#define APPLE80211_IOC_AWDL_BTLE_STATE_PARAMS 202
|
||||
#define APPLE80211_IOC_AWDL_PEER_DATABASE 203
|
||||
#define APPLE80211_IOC_AWDL_BTLE_ENABLE_SYNC_WITH_PARAMS 204
|
||||
#define APPLE80211_IOC_AWDL_SECONDARY_MASTER_CHANNEL 205
|
||||
#define APPLE80211_IOC_PHY_STATS 206
|
||||
#define APPLE80211_IOC_CHANNELS_INFO 207
|
||||
#define APPLE80211_IOC_AWDL_AF_TX_MODE 208
|
||||
#define APPLE80211_IOC_ERROR_STRING 209
|
||||
#define APPLE80211_IOC_ERROR_NO 210
|
||||
#define APPLE80211_IOC_AWDL_PIGGYBACK_SCAN_REQ 211
|
||||
#define APPLE80211_IOC_AWDL_PRIVATE_ELECTION_ID 212
|
||||
#define APPLE80211_IOC_AWDL_MIN_RATE 213
|
||||
#define APPLE80211_IOC_VHT_CAPABILITY 214
|
||||
#define APPLE80211_IOC_BGSCAN_CACHE_RESULTS 215
|
||||
#define APPLE80211_IOC_ROAM_PROFILE 216
|
||||
#define APPLE80211_IOC_AWDL_OPER_MODE 217
|
||||
#define APPLE80211_IOC_RESTORE_DEFAULTS 218
|
||||
#define APPLE80211_IOC_AWDL_ENCRYPTION_KEYS 219
|
||||
#define APPLE80211_IOC_AWDL_ENCRYPTION_TYPE 220
|
||||
#define APPLE80211_IOC_BTCOEX_PROFILES 221
|
||||
#define APPLE80211_IOC_BTCOEX_CONFIG 222
|
||||
#define APPLE80211_IOC_AWDL_STATISTICS 223
|
||||
#define APPLE80211_IOC_AWDL_ENABLE_ROAMING 224
|
||||
#define APPLE80211_IOC_AWDL_OOB_AUTO_REQUEST 225
|
||||
#define APPLE80211_IOC_AWDL_TXCAL_PERIOD 226
|
||||
#define APPLE80211_IOC_CHIP_COUNTER_STATS 227
|
||||
#define APPLE80211_IOC_DBG_GUARD_TIME_PARAMS 228
|
||||
#define APPLE80211_IOC_AWDL_AWDL_ADVERTISERS 229
|
||||
#define APPLE80211_IOC_LEAKY_AP_STATS_MODE 230
|
||||
#define APPLE80211_IOC_CAPTURE 231
|
||||
#define APPLE80211_IOC_LEAKY_AP_STATS 232
|
||||
#define APPLE80211_IOC_AWDL_BLOCK_SET_COMMANDS 233
|
||||
#define APPLE80211_IOC_LEAKY_AP_AWD_MODE 234
|
||||
#define APPLE80211_IOC_BTCOEX_OPTIONS 235
|
||||
#define APPLE80211_IOC_FORCE_SYNC_TO_PEER 236
|
||||
#define APPLE80211_IOC_COUNTRY_CHANNELS 237
|
||||
#define APPLE80211_IOC_PRIVATE_MAC 238
|
||||
#define APPLE80211_IOC_RESET_CHIP 239
|
||||
#define APPLE80211_IOC_CRASH 240
|
||||
#define APPLE80211_IOC_RANGING_ENABLE 241
|
||||
#define APPLE80211_IOC_RANGING_START 242
|
||||
#define APPLE80211_IOC_RANGING_AUTHENTICATE 243
|
||||
#define APPLE80211_IOC_AWDL_PREFERRED_CHANNELS 244
|
||||
#define APPLE80211_IOC_LEAKY_AP_SSID_STATS 245
|
||||
#define APPLE80211_IOC_AWDL_RSDB_CAPS 246
|
||||
#define APPLE80211_IOC_AWDL_DEV_STATS 247
|
||||
#define APPLE80211_IOC_LAST_ASSOC_HISTORY 248
|
||||
#define APPLE80211_IOC_AWDL_COMMON_CHANNEL 249
|
||||
#define APPLE80211_IOC_AWDL_PEERS_INFO 250
|
||||
#define APPLE80211_IOC_TKO_PARAMS 251
|
||||
#define APPLE80211_IOC_TKO_DUMP 252
|
||||
#define APPLE80211_IOC_AWDL_NEARBY_LOG_TRIGGER 253
|
||||
#define APPLE80211_IOC_HW_SUPPORTED_CHANNELS 254
|
||||
#define APPLE80211_IOC_BTCOEX_PROFILE 255
|
||||
#define APPLE80211_IOC_BTCOEX_PROFILE_ACTIVE 256
|
||||
#define APPLE80211_IOC_TRAP_INFO 257
|
||||
#define APPLE80211_IOC_THERMAL_INDEX 258
|
||||
#define APPLE80211_IOC_MAX_NSS_FOR_AP 259
|
||||
#define APPLE80211_IOC_BTCOEX_2G_CHAIN_DISABLE 260
|
||||
#define APPLE80211_IOC_POWER_BUDGET 261
|
||||
#define APPLE80211_IOC_AWDL_DFSP_CONFIG 262
|
||||
#define APPLE80211_IOC_AWDL_DFSP_UCSA_CONFIG 263
|
||||
#define APPLE80211_IOC_SCAN_BACKOFF_REPORT 264
|
||||
#define APPLE80211_IOC_OFFLOAD_TCPKA_ENABLE 265
|
||||
#define APPLE80211_IOC_RANGING_CAPS 266
|
||||
#define APPLE80211_IOC_PER_CORE_RSSI_REPORT 267
|
||||
#define APPLE80211_IOC_NSS 353
|
||||
|
||||
#define APPLE80211_IOC_CARD_SPECIFIC 0xffffffff // req_type
|
||||
|
||||
// Kernel interface
|
||||
|
||||
// Bump this value when structures change
|
||||
#define APPLE80211_VERSION 1
|
||||
|
||||
struct apple80211_ssid_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t ssid_len;
|
||||
u_int8_t ssid_bytes[APPLE80211_MAX_SSID_LEN];
|
||||
};
|
||||
|
||||
struct apple80211_virt_if_create_data {
|
||||
uint32_t version;
|
||||
uint8_t mac[APPLE80211_ADDR_LEN];
|
||||
uint16_t unk1;
|
||||
uint32_t role;
|
||||
uint8_t bsd_name[15];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct apple80211_virt_if_delete_data {
|
||||
uint32_t version;
|
||||
uint8_t bsd_name[15];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct apple80211_ht_capability {
|
||||
uint32_t version;
|
||||
uint8_t unk1;
|
||||
uint8_t unk2;
|
||||
uint16_t unk3;
|
||||
uint8_t unk4;
|
||||
uint8_t unk5[16];
|
||||
uint16_t unk6;
|
||||
uint unk7;
|
||||
uint8_t unk8;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct apple80211_channel_data
|
||||
{
|
||||
u_int32_t version;
|
||||
struct apple80211_channel channel;
|
||||
};
|
||||
|
||||
struct apple80211_bssid_data
|
||||
{
|
||||
u_int32_t version;
|
||||
struct ether_addr bssid;
|
||||
};
|
||||
|
||||
struct apple80211_capability_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int8_t capabilities[11];
|
||||
};
|
||||
|
||||
struct apple80211_state_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t state;
|
||||
};
|
||||
|
||||
struct apple80211_rssi_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t num_radios;
|
||||
u_int32_t rssi_unit;
|
||||
int32_t rssi[APPLE80211_MAX_RADIO]; // control channel
|
||||
int32_t aggregate_rssi; // aggregate control channel rssi
|
||||
int32_t rssi_ext[APPLE80211_MAX_RADIO]; // extension channel rssi
|
||||
int32_t aggregate_rssi_ext; // aggregate extension channel rssi
|
||||
};
|
||||
|
||||
struct apple80211_power_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t num_radios;
|
||||
u_int32_t power_state[APPLE80211_MAX_RADIO];
|
||||
};
|
||||
|
||||
struct apple80211_assoc_result_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t result;
|
||||
};
|
||||
|
||||
struct apple80211_assoc_status_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t status;
|
||||
};
|
||||
|
||||
struct apple80211_rate_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t num_radios;
|
||||
u_int32_t rate[APPLE80211_MAX_RADIO];
|
||||
};
|
||||
|
||||
struct apple80211_status_dev_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int8_t dev_name[MAXPATHLEN];
|
||||
};
|
||||
|
||||
struct apple80211_powersave_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t powersave_level;
|
||||
};
|
||||
|
||||
struct apple80211_protmode_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t protmode;
|
||||
u_int32_t threshold; // bytes
|
||||
};
|
||||
|
||||
struct apple80211_txpower_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t txpower_unit;
|
||||
int32_t txpower;
|
||||
};
|
||||
|
||||
struct apple80211_phymode_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t phy_mode; // vector of supported phy modes
|
||||
u_int32_t active_phy_mode; // current active phy mode
|
||||
};
|
||||
|
||||
struct apple80211_opmode_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t op_mode;
|
||||
};
|
||||
|
||||
struct apple80211_noise_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t num_radios;
|
||||
u_int32_t noise_unit;
|
||||
int32_t noise[APPLE80211_MAX_RADIO]; // control channel
|
||||
int32_t aggregate_noise; // aggregate control channel noise
|
||||
int32_t noise_ext[APPLE80211_MAX_RADIO]; // extension channel noise
|
||||
int32_t aggregate_noise_ext; // aggregate extension channel noise
|
||||
};
|
||||
|
||||
struct apple80211_intmit_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t int_mit;
|
||||
};
|
||||
|
||||
struct apple80211_authtype_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t authtype_lower; // apple80211_authtype_lower
|
||||
u_int32_t authtype_upper; // apple80211_authtype_upper
|
||||
};
|
||||
|
||||
struct apple80211_sup_channel_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t num_channels;
|
||||
struct apple80211_channel supported_channels[APPLE80211_MAX_CHANNELS];
|
||||
};
|
||||
|
||||
|
||||
struct apple80211_roam_threshold_data
|
||||
{
|
||||
u_int32_t threshold;
|
||||
u_int32_t count;
|
||||
};
|
||||
|
||||
struct apple80211_locale_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t locale;
|
||||
};
|
||||
|
||||
struct apple80211_scan_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t bss_type; // apple80211_apmode
|
||||
struct ether_addr bssid; // target BSSID
|
||||
u_int32_t ssid_len; // length of the SSID
|
||||
u_int8_t ssid[APPLE80211_MAX_SSID_LEN]; // direct scan ssid or AirDrop scan ssid like "Air-xxxx"
|
||||
u_int32_t scan_type; // apple80211_scan_type
|
||||
u_int32_t phy_mode; // apple80211_phymode vector
|
||||
u_int16_t dwell_time; // time to spend on each channel (ms)
|
||||
u_int32_t rest_time; // time between scanning each channel (ms)
|
||||
u_int32_t num_channels; // 0 if not passing in channels
|
||||
struct apple80211_channel channels[APPLE80211_MAX_CHANNELS]; // channel list
|
||||
};
|
||||
|
||||
struct apple80211_scan_multiple_data
|
||||
{
|
||||
uint32_t version;
|
||||
uint32_t ap_mode; // apple80211_apmode
|
||||
uint32_t ssid_count;
|
||||
apple80211_ssid_data ssids[16];
|
||||
uint32_t bssid_count;
|
||||
ether_addr bssids[16];
|
||||
uint32_t scan_type;
|
||||
uint32_t phy_mode;
|
||||
uint32_t dwell_time;
|
||||
uint32_t rest_time;
|
||||
uint32_t num_channels;
|
||||
struct apple80211_channel channels[128];
|
||||
uint16_t unk_2;
|
||||
};
|
||||
|
||||
struct apple80211_link_changed_event_data
|
||||
{
|
||||
bool isLinkDown; // 0
|
||||
uint32_t rssi; // 4
|
||||
uint16_t snr; // 8
|
||||
uint16_t nf; // 10
|
||||
char cca; // 12
|
||||
bool voluntary; // 16
|
||||
uint32_t reason; // 20
|
||||
};
|
||||
|
||||
struct apple80211_apmode_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t apmode;
|
||||
};
|
||||
|
||||
struct apple80211_assoc_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int16_t ad_mode; // apple80211_apmode
|
||||
u_int16_t ad_auth_lower; // apple80211_authtype_lower
|
||||
u_int16_t ad_auth_upper; // apple80211_authtype_upper
|
||||
u_int32_t ad_ssid_len;
|
||||
u_int8_t ad_ssid[ APPLE80211_MAX_SSID_LEN ];
|
||||
struct ether_addr ad_bssid; // prefer over ssid if not zeroed
|
||||
struct apple80211_key ad_key;
|
||||
uint16_t pad;
|
||||
u_int8_t ad_rsn_ie[ APPLE80211_MAX_RSN_IE_LEN ];
|
||||
u_int32_t ad_flags; // apple80211_assoc_flags
|
||||
};
|
||||
|
||||
static_assert(offsetof(apple80211_assoc_data, ad_rsn_ie) == 206, "offsetof(apple80211_assoc_data, ad_rsn_ie)");
|
||||
|
||||
struct apple80211_deauth_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t deauth_reason; // reason code
|
||||
struct ether_addr deauth_ea; // BSSID of AP
|
||||
};
|
||||
|
||||
struct apple80211_countermeasures_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t enabled;
|
||||
};
|
||||
|
||||
struct apple80211_frag_threshold_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t threshold; // bytes
|
||||
};
|
||||
|
||||
struct apple80211_rate_set_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int16_t num_rates;
|
||||
struct apple80211_rate rates[APPLE80211_MAX_RATES];
|
||||
};
|
||||
|
||||
struct apple80211_short_slot_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int8_t mode;
|
||||
};
|
||||
|
||||
struct apple80211_retry_limit_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t limit;
|
||||
};
|
||||
|
||||
struct apple80211_antenna_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t num_radios;
|
||||
int32_t antenna_index[APPLE80211_MAX_RADIO];
|
||||
};
|
||||
|
||||
struct apple80211_dtim_int_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t interval;
|
||||
};
|
||||
|
||||
struct apple80211_sta_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t num_stations;
|
||||
struct apple80211_station station_list[APPLE80211_MAX_STATIONS];
|
||||
};
|
||||
|
||||
struct apple80211_version_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int16_t string_len;
|
||||
char string[APPLE80211_MAX_VERSION_LEN];
|
||||
};
|
||||
|
||||
struct apple80211_rom_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t rom_len;
|
||||
u_int8_t rom[1]; // variable length
|
||||
};
|
||||
|
||||
struct apple80211_rand_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t rand;
|
||||
};
|
||||
|
||||
struct apple80211_rsn_ie_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int16_t len;
|
||||
u_int8_t ie[ APPLE80211_MAX_RSN_IE_LEN ];
|
||||
};
|
||||
|
||||
struct apple80211_ap_ie_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t len;
|
||||
u_int8_t *ie_data;
|
||||
};
|
||||
|
||||
struct apple80211_stats_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t tx_frame_count;
|
||||
u_int32_t tx_errors;
|
||||
u_int32_t rx_frame_count;
|
||||
u_int32_t rx_errors;
|
||||
};
|
||||
|
||||
struct apple80211_country_code_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int8_t cc[APPLE80211_MAX_CC_LEN];
|
||||
};
|
||||
|
||||
struct apple80211_last_rx_pkt_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t rate;
|
||||
int32_t rssi;
|
||||
u_int32_t num_streams; // number of spatial streams
|
||||
struct ether_addr sa; // source address
|
||||
};
|
||||
|
||||
struct apple80211_radio_info_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t count; // number of rf chains
|
||||
};
|
||||
|
||||
struct apple80211_guard_interval_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t interval; // apple80211_guard_interval
|
||||
};
|
||||
|
||||
struct apple80211_mcs_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t index; // 0 to APPLE80211_MAX_MCS_INDEX
|
||||
};
|
||||
|
||||
struct apple80211_rifs_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t enabled;
|
||||
};
|
||||
|
||||
struct apple80211_ldpc_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t enabled;
|
||||
};
|
||||
|
||||
struct apple80211_msdu_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t max_length; // 3839 or 7935 bytes
|
||||
};
|
||||
|
||||
struct apple80211_mpdu_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t max_factor; // 0 - APPLE80211_MAX_MPDU_FACTOR
|
||||
u_int32_t max_density; // 0 - APPLE80211_MAX_MPDU_DENSITY
|
||||
};
|
||||
|
||||
struct apple80211_block_ack_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int8_t ba_enabled; // block ack enabled
|
||||
u_int8_t immediate_ba_enabled; // immediate block ack enabled
|
||||
u_int8_t cbba_enabled; // compressed bitmap block ack enabled
|
||||
u_int8_t implicit_ba_enabled; // implicit block ack enabled
|
||||
};
|
||||
|
||||
struct apple80211_pls_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t enabled; // phy level spoofing enabled
|
||||
};
|
||||
|
||||
struct apple80211_psmp_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t enabled;
|
||||
};
|
||||
|
||||
struct apple80211_physubmode_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t phy_mode; // one apple80211_phymode
|
||||
u_int32_t phy_submode; // one apple80211_physubmode
|
||||
u_int32_t flags; // apple80211_channel_flag vector
|
||||
};
|
||||
|
||||
struct apple80211_mcs_index_set_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int8_t mcs_set_map[APPLE80211_MAP_SIZE( APPLE80211_MAX_MCS_INDEX + 1 )];
|
||||
};
|
||||
|
||||
struct apple80211_wow_parameter_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int8_t wake_cond_map[APPLE80211_MAP_SIZE( APPLE80211_MAX_WAKE_COND + 1 )];
|
||||
u_int32_t beacon_loss_time;
|
||||
u_int32_t pattern_count;
|
||||
struct apple80211_wow_pattern patterns[APPLE80211_MAX_WOW_PATTERNS];
|
||||
};
|
||||
|
||||
struct apple80211_40mhz_intolerant_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t enabled; // bit enabled or not
|
||||
};
|
||||
|
||||
struct apple80211_tx_nss_data
|
||||
{
|
||||
uint32_t version;
|
||||
uint8_t nss;
|
||||
};
|
||||
|
||||
struct apple80211_nss_data
|
||||
{
|
||||
uint32_t version;
|
||||
uint8_t nss;
|
||||
};
|
||||
|
||||
struct apple80211_awdl_peer_traffic_registration
|
||||
{
|
||||
uint32_t version;
|
||||
void *addr;
|
||||
uint32_t name_len;
|
||||
char name[152];
|
||||
uint32_t active;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct apple80211_awdl_election_metric
|
||||
{
|
||||
uint32_t version;
|
||||
uint32_t metric;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct apple80211_awdl_sync_enabled
|
||||
{
|
||||
uint32_t version;
|
||||
uint32_t unk1;
|
||||
uint32_t enabled;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct apple80211_awdl_sync_frame_template
|
||||
{
|
||||
uint32_t version;
|
||||
uint32_t payload_len;
|
||||
void *payload;
|
||||
} __attribute__((packed));
|
||||
|
||||
#endif // _APPLE80211_IOCTL_H_
|
||||
|
||||
@@ -0,0 +1,645 @@
|
||||
/*
|
||||
* Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _APPLE80211_VAR_H_
|
||||
#define _APPLE80211_VAR_H_
|
||||
|
||||
#include <Availability.h>
|
||||
#include <sys/types.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
// This is necessary, because even the latest Xcode does not support properly targeting 11.0.
|
||||
#ifndef __IO80211_TARGET
|
||||
#error "Please define __IO80211_TARGET to the requested version"
|
||||
#endif
|
||||
|
||||
// Sizes and limits
|
||||
#define APPLE80211_ADDR_LEN 6
|
||||
#define APPLE80211_MAX_RATES 15
|
||||
#define APPLE80211_MAX_SSID_LEN 32
|
||||
#define APPLE80211_MAX_ANTENNAE 4
|
||||
#define APPLE80211_MAX_RADIO 4
|
||||
#define APPLE80211_MAX_CHANNELS 64
|
||||
#define APPLE80211_MAX_STATIONS 128
|
||||
#define APPLE80211_MAX_VERSION_LEN 256
|
||||
#define APPLE80211_MAX_ROM_SIZE 32768 // 32 KB
|
||||
#define APPLE80211_MAX_RSN_IE_LEN 257 // 255 + type and length bytes
|
||||
#define APPLE80211_MAX_CC_LEN 3
|
||||
#define APPLE80211_MAX_MCS_INDEX 76
|
||||
#define APPLE80211_MAX_MPDU_FACTOR 3
|
||||
#define APPLE80211_MAX_MPDU_DENSITY 7
|
||||
#define APPLE80211_MAX_WOW_PAT_LEN 1500 // Max wake on wireless pattern length
|
||||
#define APPLE80211_MAX_WOW_PATTERNS 12 // Arbitrary..this can change
|
||||
|
||||
#define APPLE80211_MAP_SIZE( _bits ) (roundup( _bits, NBBY )/NBBY)
|
||||
|
||||
enum apple80211_phymode {
|
||||
APPLE80211_MODE_UNKNOWN = 0,
|
||||
APPLE80211_MODE_AUTO = 1, // autoselect
|
||||
APPLE80211_MODE_11A = 2 << (1 - 1), // 5GHz, OFDM
|
||||
APPLE80211_MODE_11B = 2 << (2 - 1), // 2GHz, CCK
|
||||
APPLE80211_MODE_11G = 2 << (3 - 1), // 2GHz, OFDM
|
||||
APPLE80211_MODE_11N = 2 << (4 - 1), // 2GHz/5GHz, OFDM
|
||||
APPLE80211_MODE_TURBO_A = 2 << (5 - 1), // 5GHz, OFDM, 2x clock
|
||||
APPLE80211_MODE_TURBO_G = 2 << (6 - 1), // 2GHz, OFDM, 2x clock
|
||||
APPLE80211_MODE_11AC = 2 << (7 - 1),
|
||||
APPLE80211_MODE_11AX = 2 << (8 - 1),
|
||||
};
|
||||
|
||||
enum apple80211_physubmode {
|
||||
APPLE80211_SUBMODE_UNKNOWN = 0x0,
|
||||
APPLE80211_SUBMODE_11N_AUTO = 0x1, // 11n mode determined by AP capabilities
|
||||
APPLE80211_SUBMODE_11N_LEGACY = 0x2, // legacy
|
||||
APPLE80211_SUBMODE_11N_LEGACY_DUP = 0x4, // legacy duplicate
|
||||
APPLE80211_SUBMODE_11N_HT = 0x8, // high throughput
|
||||
APPLE80211_SUBMODE_11N_HT_DUP = 0x10, // high throughput duplicate
|
||||
APPLE80211_SUBMODE_11N_GF = 0x20, // green field
|
||||
};
|
||||
|
||||
// flags
|
||||
enum apple80211_opmode {
|
||||
APPLE80211_M_NONE = 0x0,
|
||||
APPLE80211_M_STA = 0x1, // infrastructure station
|
||||
APPLE80211_M_IBSS = 0x2, // IBSS (adhoc) station
|
||||
APPLE80211_M_AHDEMO = 0x4, // Old lucent compatible adhoc demo
|
||||
APPLE80211_M_HOSTAP = 0x8, // Software Access Point
|
||||
APPLE80211_M_MONITOR = 0x10 // Monitor mode
|
||||
};
|
||||
|
||||
enum apple80211_apmode {
|
||||
APPLE80211_AP_MODE_UNKNOWN = 0,
|
||||
APPLE80211_AP_MODE_IBSS = 1, // IBSS (adhoc) station
|
||||
APPLE80211_AP_MODE_INFRA = 2, // Access Point
|
||||
APPLE80211_AP_MODE_ANY = 3, // Any supported mode
|
||||
};
|
||||
|
||||
enum apple80211_state {
|
||||
APPLE80211_S_INIT = 0, // default state
|
||||
APPLE80211_S_SCAN = 1, // scanning
|
||||
APPLE80211_S_AUTH = 2, // try to authenticate
|
||||
APPLE80211_S_ASSOC = 3, // try to assoc
|
||||
APPLE80211_S_RUN = 4, // associated
|
||||
};
|
||||
|
||||
enum apple80211_protmode {
|
||||
APPLE80211_PROTMODE_OFF = 0, // no protection
|
||||
APPLE80211_PROTMODE_AUTO = 1, // auto
|
||||
APPLE80211_PROTMODE_CTS = 2, // CTS to self
|
||||
APPLE80211_PROTMODE_RTSCTS = 3, // RTS-CTS
|
||||
APPLE80211_PROTMODE_DUAL_CTS = 4, // dual CTS
|
||||
};
|
||||
|
||||
enum apple80211_cipher_type {
|
||||
APPLE80211_CIPHER_NONE = 0, // open network
|
||||
APPLE80211_CIPHER_WEP_40 = 1, // 40 bit WEP
|
||||
APPLE80211_CIPHER_WEP_104 = 2, // 104 bit WEP
|
||||
APPLE80211_CIPHER_TKIP = 3, // TKIP (WPA)
|
||||
APPLE80211_CIPHER_AES_OCB = 4, // AES (OCB)
|
||||
APPLE80211_CIPHER_AES_CCM = 5, // AES (CCM)
|
||||
APPLE80211_CIPHER_PMK = 6, // PMK
|
||||
APPLE80211_CIPHER_PMKSA = 7, // PMK obtained from pre-authentication
|
||||
};
|
||||
|
||||
enum apple80211_cipher_key_type
|
||||
{
|
||||
APPLE80211_CIPHER_KEY_TYPE_UNICAST = 0, // unicast cipher key
|
||||
APPLE80211_CIPHER_KEY_TYPE_MULTICAST = 1 // multicast cipher key
|
||||
};
|
||||
|
||||
// Low level 802.11 authentication types
|
||||
|
||||
enum apple80211_authtype_lower
|
||||
{
|
||||
APPLE80211_AUTHTYPE_OPEN = 1, // open
|
||||
APPLE80211_AUTHTYPE_SHARED = 2, // shared key
|
||||
APPLE80211_AUTHTYPE_CISCO = 3, // cisco net eap
|
||||
};
|
||||
|
||||
// Higher level authentication used after 802.11 association complete
|
||||
|
||||
enum apple80211_authtype_upper
|
||||
{
|
||||
APPLE80211_AUTHTYPE_NONE = 0, // No upper auth
|
||||
APPLE80211_AUTHTYPE_WPA = 1 << 0, // WPA
|
||||
APPLE80211_AUTHTYPE_WPA_PSK = 1 << 1, // WPA PSK
|
||||
APPLE80211_AUTHTYPE_WPA2 = 1 << 2, // WPA2
|
||||
APPLE80211_AUTHTYPE_WPA2_PSK = 1 << 3, // WPA2 PSK
|
||||
APPLE80211_AUTHTYPE_LEAP = 1 << 4, // LEAP
|
||||
APPLE80211_AUTHTYPE_8021X = 1 << 5, // 802.1x
|
||||
APPLE80211_AUTHTYPE_WPS = 1 << 6, // WiFi Protected Setup
|
||||
APPLE80211_AUTHTYPE_SHA256_PSK = 1 << 7,
|
||||
APPLE80211_AUTHTYPE_SHA256_8021X = 1 << 8,
|
||||
APPLE80211_AUTHTYPE_WPA3_SAE = 1 << 9
|
||||
};
|
||||
|
||||
// Unify association status code and deauth reason codes into a single enum describing
|
||||
// common error conditions
|
||||
enum apple80211_associate_result
|
||||
{
|
||||
APPLE80211_RESULT_UNAVAILABLE = 0, // No association/authentication result ready
|
||||
APPLE80211_RESULT_SUCCESS = 1, // APPLE80211_STATUS_SUCCESS and no deauth
|
||||
APPLE80211_RESULT_UNSPECIFIED_FAILURE = 2, // APPLE80211_STATUS_UNSPECIFIED_FAILURE
|
||||
APPLE80211_RESULT_UNSUPPORTED_CAPAPBILITIES = 3, // APPLE80211_STATUS_UNSUPPORTED_CAPABILITIES
|
||||
APPLE80211_RESULT_REASSOCIATION_DENIED = 4, // APPLE80211_STATUS_REASSOCIATION_DENIED
|
||||
APPLE80211_RESULT_ASSOCIATION_DENIED = 5, // APPLE80211_STATUS_ASSOCIATION_DENIED
|
||||
APPLE80211_RESULT_AUTH_ALG_UNSUPPORTED = 6, // APPLE80211_STATUS_AUTH_ALG_UNSUPPORTED
|
||||
APPLE80211_RESULT_INVALID_AUTH_SEQ_NUM = 7, // APPLE80211_STATUS_INVALID_AUTH_SEQ_NUM
|
||||
APPLE80211_RESULT_CHALLENGE_FAILURE = 8, // APPLE80211_STATUS_CHALLENGE_FAILURE
|
||||
APPLE80211_RESULT_TIMEOUT = 9, // APPLE80211_STATUS_TIMEOUT
|
||||
APPLE80211_RESULT_AP_FULL = 10, // APPLE80211_STATUS_AP_FULL
|
||||
APPLE80211_RESULT_UNSUPPORTED_RATE_SET = 11, // APPLE80211_STATUS_UNSUPPORTED_RATE_SET
|
||||
APPLE80211_RESULT_SHORT_SLOT_UNSUPPORTED = 12, // APPLE80211_STATUS_SHORT_SLOT_UNSUPPORTED
|
||||
APPLE80211_RESULT_DSSS_OFDM_UNSUPPORTED = 13, // APPLE80211_STATUS_DSSS_OFDM_UNSUPPORTED
|
||||
APPLE80211_RESULT_INVALID_IE = 14, // APPLE80211_STATUS_INVALID_IE
|
||||
APPLE80211_RESULT_INVALID_GROUP_CIPHER = 15, // APPLE80211_STATUS_INVALID_GROUP_CIPHER
|
||||
APPLE80211_RESULT_INVALID_PAIRWISE_CIPHER = 16, // APPLE80211_STATUS_INVALID_PAIRWISE_CIPHER
|
||||
APPLE80211_RESULT_INVALID_AKMP = 17, // APPLE80211_STATUS_INVALID_AKMP
|
||||
APPLE80211_RESULT_UNSUPPORTED_RSN_VERSION = 18, // APPLE80211_STATUS_UNSUPPORTED_RSN_VERSION
|
||||
APPLE80211_RESULT_INVALID_RSN_CAPABILITIES = 19, // APPLE80211_STATUS_INVALID_RSN_CAPABILITIES
|
||||
APPLE80211_RESULT_CIPHER_SUITE_REJECTED = 20, // APPLE80211_STATUS_CIPHER_SUIT_REJECTED
|
||||
APPLE80211_RESULT_INVALID_PMK = 21, // APPLE80211_REASON_PREV_AUTH_EXPIRED received
|
||||
APPLE80211_RESULT_SUPPLICANT_TIMEOUT = 22, // RSNSupplicant did not finish handshake
|
||||
APPLE80211_RESULT_UNKNOWN = 0xffff // Unrecognized error condition
|
||||
};
|
||||
|
||||
enum apple80211_link_down_reason
|
||||
{
|
||||
APPLE80211_LINK_DOWN_REASON_INTERNAL_ERROR = 0,
|
||||
APPLE80211_LINK_DOWN_REASON_BEACONLOST = 1,
|
||||
APPLE80211_LINK_DOWN_REASON_DEAUTH = 2,
|
||||
APPLE80211_LINK_DOWN_REASON_INTERNAL_ERROR_2 = 3
|
||||
};
|
||||
|
||||
enum apple80211_unit
|
||||
{
|
||||
APPLE80211_UNIT_DBM = 0, // dBm
|
||||
APPLE80211_UNIT_MW = 1, // milliwatts
|
||||
APPLE80211_UNIT_PERCENT = 2, // value expressed as a percentage
|
||||
};
|
||||
|
||||
enum apple80211_power_state
|
||||
{
|
||||
APPLE80211_POWER_OFF = 0, // Chain disabled
|
||||
APPLE80211_POWER_ON = 1, // Chain powered on for tx and rx
|
||||
APPLE80211_POWER_TX = 2, // Chain powered on for tx only
|
||||
APPLE80211_POWER_RX = 3, // Chain powered on for rx only
|
||||
};
|
||||
|
||||
enum apple80211_locale
|
||||
{
|
||||
APPLE80211_LOCALE_UNKNOWN = 0,
|
||||
APPLE80211_LOCALE_FCC = 1,
|
||||
APPLE80211_LOCALE_ETSI = 2,
|
||||
APPLE80211_LOCALE_JAPAN = 3,
|
||||
APPLE80211_LOCALE_KOREA = 4,
|
||||
APPLE80211_LOCALE_APAC = 5,
|
||||
APPLE80211_LOCALE_ROW = 6,
|
||||
APPLE80211_LOCALE_INDONESIA = 7
|
||||
};
|
||||
|
||||
enum apple80211_scan_type
|
||||
{
|
||||
APPLE80211_SCAN_TYPE_NONE = 0,
|
||||
APPLE80211_SCAN_TYPE_ACTIVE = 1,
|
||||
APPLE80211_SCAN_TYPE_PASSIVE = 2,
|
||||
APPLE80211_SCAN_TYPE_FAST = 3, // Ok to return cached scan results
|
||||
APPLE80211_SCAN_TYPE_BACKGROUND = 4, // Initiate background scanning
|
||||
};
|
||||
|
||||
enum apple80211_int_mit {
|
||||
APPLE80211_INT_MIT_OFF = 0,
|
||||
APPLE80211_INT_MIT_AUTO = 1,
|
||||
};
|
||||
|
||||
enum apple80211_channel_flag
|
||||
{
|
||||
APPLE80211_C_FLAG_NONE = 0x0, // no flags
|
||||
APPLE80211_C_FLAG_10MHZ = 0x1, // 10 MHz wide
|
||||
APPLE80211_C_FLAG_20MHZ = 0x2, // 20 MHz wide
|
||||
APPLE80211_C_FLAG_40MHZ = 0x4, // 40 MHz wide
|
||||
APPLE80211_C_FLAG_2GHZ = 0x8, // 2.4 GHz
|
||||
APPLE80211_C_FLAG_5GHZ = 0x10, // 5 GHz
|
||||
APPLE80211_C_FLAG_IBSS = 0x20, // IBSS supported
|
||||
APPLE80211_C_FLAG_HOST_AP = 0x40, // HOST AP mode supported
|
||||
APPLE80211_C_FLAG_ACTIVE = 0x80, // active scanning supported
|
||||
APPLE80211_C_FLAG_DFS = 0x100, // DFS required
|
||||
APPLE80211_C_FLAG_EXT_ABV = 0x200, // If 40 Mhz, extension channel above.
|
||||
// If this flag is not set, then the
|
||||
// extension channel is below.
|
||||
APPLE80211_C_FLAG_80MHZ = 0x400 // name made up - set if channelWidth == 80 && 5ghz && AC
|
||||
};
|
||||
|
||||
enum apple80211_rate_flag
|
||||
{
|
||||
APPLE80211_RATE_FLAG_NONE = 0x0, // no flags
|
||||
APPLE80211_RATE_FLAG_BASIC = 0x1, // basic rate
|
||||
APPLE80211_RATE_FLAG_HT = 0x2, // HT rate computed from MCS index
|
||||
};
|
||||
|
||||
enum apple80211_short_slot_mode
|
||||
{
|
||||
APPLE80211_SHORT_SLOT_MODE_AUTO = 1, // Default behavior
|
||||
APPLE80211_SHORT_SLOT_MODE_LONG = 2, // long - short slot timing mode
|
||||
APPLE80211_SHORT_SLOT_MODE_SHORT = 3, // short - short slot timing mode
|
||||
};
|
||||
|
||||
enum apple80211_powersave_mode
|
||||
{
|
||||
// Standard modes
|
||||
APPLE80211_POWERSAVE_MODE_DISABLED = 0,
|
||||
APPLE80211_POWERSAVE_MODE_80211 = 1,
|
||||
APPLE80211_POWERSAVE_MODE_VENDOR = 2, // Vendor specific mode, there should be
|
||||
// more general apple modes in the future.
|
||||
// Vendor modes also likely require more info.
|
||||
// Mimo modes
|
||||
APPLE80211_POWERSAVE_MODE_MIMO_STATIC = 3,
|
||||
APPLE80211_POWERSAVE_MODE_MIMO_DYNAMIC = 4,
|
||||
APPLE80211_POWERSAVE_MODE_MIMO_MIMO = 5,
|
||||
|
||||
// WOW
|
||||
APPLE80211_POWERSAVE_MODE_WOW = 6,
|
||||
|
||||
// Vendor specific powersave mode, throughput is maximized
|
||||
APPLE80211_POWERSAVE_MODE_MAX_THROUGHPUT = 7,
|
||||
|
||||
// Vendor specific powersave mode, power savings are maximized, possibly
|
||||
// at the expense of throughput/latency.
|
||||
APPLE80211_POWERSAVE_MODE_MAX_POWERSAVE = 8,
|
||||
};
|
||||
|
||||
enum apple80211_debug_flag
|
||||
{
|
||||
APPLE80211_DEBUG_FLAG_NONE = 0x0, // No logging
|
||||
APPLE80211_DEBUG_FLAG_INFORMATIVE = 0x1, // Log "interesting" events
|
||||
APPLE80211_DEBUG_FLAG_ERROR = 0x2, // Log errors
|
||||
APPLE80211_DEBUG_FLAG_RSN = 0x4, // Full RSN supplicant logging
|
||||
APPLE80211_DEBUG_FLAG_SCAN = 0x8, // Scan events and information
|
||||
};
|
||||
|
||||
enum apple80211_guard_interval
|
||||
{
|
||||
APPLE80211_GI_SHORT = 400, // ns
|
||||
APPLE80211_GI_LONG = 800, // ns
|
||||
};
|
||||
|
||||
#define APPLE80211_RSC_LEN 8
|
||||
#define APPLE80211_KEY_BUFF_LEN 32
|
||||
|
||||
#define APPLE80211_KEY_FLAG_UNICAST 0x1
|
||||
#define APPLE80211_KEY_FLAG_MULTICAST 0x2
|
||||
#define APPLE80211_KEY_FLAG_TX 0x4
|
||||
#define APPLE80211_KEY_FLAG_RX 0x8
|
||||
|
||||
struct apple80211_key
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t key_len;
|
||||
u_int32_t key_cipher_type; // apple80211_cipher_type
|
||||
u_int16_t key_flags;
|
||||
u_int16_t key_index;
|
||||
u_int8_t key[ APPLE80211_KEY_BUFF_LEN ];
|
||||
u_int8_t pad[30];
|
||||
u_int32_t key_rsc_len;
|
||||
u_int8_t key_rsc[ APPLE80211_RSC_LEN ]; // receive sequence counter
|
||||
struct ether_addr key_ea; // key applies to this bssid
|
||||
uint wowl_kck_len;
|
||||
uint8_t wowl_kck_key[16];
|
||||
uint wowl_kek_len;
|
||||
u_int8_t wowl_kek_key[24];
|
||||
};
|
||||
|
||||
// Changing this affects any structure that contains a channel
|
||||
struct apple80211_channel
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t channel; // channel number
|
||||
u_int32_t flags; // apple80211_channel_flag vector
|
||||
};
|
||||
|
||||
struct apple80211_rate
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int32_t rate; // rate mbps
|
||||
u_int32_t flags; // apple80211_rate_flag vector
|
||||
};
|
||||
|
||||
// Probe response capability flags, IEEE 7.3.1.4
|
||||
#define APPLE80211_CAPINFO_ESS 0x0001
|
||||
#define APPLE80211_CAPINFO_IBSS 0x0002
|
||||
#define APPLE80211_CAPINFO_CF_POLLABLE 0x0004
|
||||
#define APPLE80211_CAPINFO_CF_POLLREQ 0x0008
|
||||
#define APPLE80211_CAPINFO_PRIVACY 0x0010
|
||||
#define APPLE80211_CAPINFO_SHORT_PREAMBLE 0x0020
|
||||
#define APPLE80211_CAPINFO_PBCC 0x0040
|
||||
#define APPLE80211_CAPINFO_AGILITY 0x0080
|
||||
// 0x0100, 0x0200 reserved
|
||||
#define APPLE80211_CAPINFO_SHORT_SLOT_TIME 0x0400
|
||||
// 0x0800, 0x1000 reserved
|
||||
#define APPLE80211_CAPINFO_DSSS_OFDM 0x2000
|
||||
// 0x4000, 0x8000 reserved
|
||||
|
||||
// Reason codes IEEE 7.3.1.7
|
||||
#define APPLE80211_REASON_UNSPECIFIED 1
|
||||
#define APPLE80211_REASON_PREV_AUTH_EXPIRED 2
|
||||
#define APPLE80211_REASON_AUTH_LEAVING 3
|
||||
#define APPLE80211_REASON_INACTIVE 4
|
||||
#define APPLE80211_REASON_AP_OVERLOAD 5
|
||||
#define APPLE80211_REASON_NOT_AUTHED 6
|
||||
#define APPLE80211_REASON_NOT_ASSOCED 7
|
||||
#define APPLE80211_REASON_ASSOC_LEAVING 8
|
||||
#define APPLE80211_REASON_ASSOC_NOT_AUTHED 9
|
||||
#define APPLE80211_REASON_POWER_CAP 10
|
||||
#define APPLE80211_REASON_SUPPORTED_CHANS 11
|
||||
|
||||
#define APPLE80211_REASON_INVALID_IE 13
|
||||
#define APPLE80211_REASON_MIC_FAILURE 14
|
||||
#define APPLE80211_REASON_4_WAY_TIMEOUT 15
|
||||
#define APPLE80211_REASON_GROUP_KEY_TIMEOUT 16
|
||||
#define APPLE80211_REASON_DIFF_IE 17
|
||||
#define APPLE80211_REASON_INVALID_GROUP_KEY 18
|
||||
#define APPLE80211_REASON_INVALID_PAIR_KEY 19
|
||||
#define APPLE80211_REASON_INVALID_AKMP 20
|
||||
#define APPLE80211_REASON_UNSUPP_RSN_VER 21
|
||||
#define APPLE80211_REASON_INVALID_RSN_CAPS 22
|
||||
#define APPLE80211_REASON_8021X_AUTH_FAILED 23
|
||||
|
||||
// Status codes IEEE 7.3.1.9
|
||||
#define APPLE80211_STATUS_SUCCESS 0
|
||||
#define APPLE80211_STATUS_UNSPECIFIED_FAILURE 1
|
||||
// 2-9 reserved
|
||||
#define APPLE80211_STATUS_UNSUPPORTED_CAPABILITIES 10
|
||||
#define APPLE80211_STATUS_REASSOCIATION_DENIED 11
|
||||
#define APPLE80211_STATUS_ASSOCIATION_DENIED 12
|
||||
#define APPLE80211_STATUS_AUTH_ALG_UNSUPPORTED 13
|
||||
#define APPLE80211_STATUS_INVALID_AUTH_SEQ_NUM 14
|
||||
#define APPLE80211_STATUS_CHALLENGE_FAILURE 15
|
||||
#define APPLE80211_STATUS_TIMEOUT 16
|
||||
#define APPLE80211_STATUS_AP_FULL 17
|
||||
#define APPLE80211_STATUS_UNSUPPORTED_RATE_SET 18
|
||||
// 22-24 reserved
|
||||
#define APPLE80211_STATUS_SHORT_SLOT_UNSUPPORTED 25
|
||||
#define APPLE80211_STATUS_DSSS_OFDM_UNSUPPORTED 26
|
||||
// 27-39 reserved
|
||||
#define APPLE80211_STATUS_INVALID_IE 40
|
||||
#define APPLE80211_STATUS_INVALID_GROUP_CIPHER 41
|
||||
#define APPLE80211_STATUS_INVALID_PAIRWISE_CIPHER 42
|
||||
#define APPLE80211_STATUS_INVALID_AKMP 43
|
||||
#define APPLE80211_STATUS_UNSUPPORTED_RSN_VERSION 44
|
||||
#define APPLE80211_STATUS_INVALID_RSN_CAPABILITIES 45
|
||||
#define APPLE80211_STATUS_CIPHER_SUITE_REJECTED 46
|
||||
// 47 - 65535 reserved
|
||||
#define APPLE80211_STATUS_UNAVAILABLE 0xffff
|
||||
|
||||
// If mcs index is set to APPLE80211_MCS_INDEX_AUTO, the interface
|
||||
// should go to auto rate selection, and abandon any previously
|
||||
// configured static MCS indices
|
||||
#define APPLE80211_MCS_INDEX_AUTO 0xffffffff
|
||||
|
||||
/*
|
||||
DSCP TOS/Traffic class values for WME access categories taken from
|
||||
WiFi WMM Test Plan v 1.3.1 Appendix C.
|
||||
|
||||
TOS/Traffic class field looks like:
|
||||
|
||||
0 1 2 3 4 5 6 7
|
||||
+---+---+---+---+---+---+---+---+
|
||||
| DSCP | ECN |
|
||||
+---+---+---+---+---+---+---+---+
|
||||
|
||||
These bits are numbered according to rfc 2474, but might be misleading.
|
||||
It looks like bit 0 is actually the high order bit.
|
||||
*/
|
||||
|
||||
#define APPLE80211_DSCP_WME_BE 0x00
|
||||
#define APPLE80211_DSCP_WME_BK 0x08
|
||||
#define APPLE80211_DSCP_WME_VI 0x28
|
||||
#define APPLE80211_DSCP_WME_VO 0x38
|
||||
|
||||
// Access category values set in the mbuf
|
||||
#define APPLE80211_WME_AC_BE 0
|
||||
#define APPLE80211_WME_AC_BK 1
|
||||
#define APPLE80211_WME_AC_VI 2
|
||||
#define APPLE80211_WME_AC_VO 3
|
||||
|
||||
// Working within the limitations of the kpi mbuf routines, the receive interface pointer
|
||||
// is the best place to put this for now since it is not used on the output path. The mbuf
|
||||
// kpi doesn't allow us to access unused flags, or I would put the WME AC in there like
|
||||
// everyone else.
|
||||
|
||||
#define APPLE80211_MBUF_SET_WME_AC( m, ac ) mbuf_pkthdr_setrcvif( m, (ifnet_t)ac )
|
||||
#define APPLE80211_MBUF_WME_AC( m ) (int)mbuf_pkthdr_rcvif( m )
|
||||
|
||||
// FIXME: seems that rates array starts at 0x24, immediately after
|
||||
struct apple80211_scan_result
|
||||
{
|
||||
u_int32_t version; // 0x00 - 0x03
|
||||
apple80211_channel asr_channel; // 0x04 - 0x0f
|
||||
|
||||
int16_t asr_unk; // 0x10 - 0x11
|
||||
|
||||
int16_t asr_noise; // 0x12 - 0x13
|
||||
int16_t asr_snr; // 0x14 - 0x15
|
||||
int16_t asr_rssi; // 0x16 - 0x17
|
||||
int16_t asr_beacon_int; // 0x18 - 0x19
|
||||
|
||||
int16_t asr_cap; // 0x1a - 0x1b (capabilities)
|
||||
|
||||
u_int8_t asr_bssid[ APPLE80211_ADDR_LEN ]; // 0x1c 0x1d 0x1e 0x1f 0x20 0x21
|
||||
u_int8_t asr_nrates; // 0x22
|
||||
u_int8_t asr_nr_unk; // 0x23
|
||||
u_int32_t asr_rates[ APPLE80211_MAX_RATES ]; // 0x24 - 0x5f
|
||||
u_int8_t asr_ssid_len; // 0x60
|
||||
u_int8_t asr_ssid[ APPLE80211_MAX_SSID_LEN ]; // 0x61 - 0x80
|
||||
__attribute__((packed)) __attribute__((aligned(1))) int16_t unk;
|
||||
uint8_t unk2;
|
||||
u_int32_t asr_age; // (ms) non-zero for cached scan result // 0x84
|
||||
|
||||
u_int16_t unk3;
|
||||
int16_t asr_ie_len;
|
||||
uint32_t asr_unk3;
|
||||
void* asr_ie_data;
|
||||
};
|
||||
|
||||
struct apple80211_network_data
|
||||
{
|
||||
u_int32_t version;
|
||||
u_int16_t nd_mode; // apple80211_apmode
|
||||
u_int16_t nd_auth_lower; // apple80211_authtype_lower
|
||||
u_int16_t nd_auth_upper; // apple80211_authtype_upper
|
||||
struct apple80211_channel nd_channel;
|
||||
u_int32_t nd_ssid_len;
|
||||
u_int8_t nd_ssid[ APPLE80211_MAX_SSID_LEN ];
|
||||
struct apple80211_key nd_key;
|
||||
u_int32_t nd_ie_len;
|
||||
void *nd_ie_data;
|
||||
};
|
||||
|
||||
#define APPLE80211_NETWORK_DATA_MAX_IE_LEN 1024
|
||||
|
||||
// As hostap support improves, this will grow
|
||||
struct apple80211_station
|
||||
{
|
||||
u_int32_t version;
|
||||
struct ether_addr sta_mac;
|
||||
int32_t sta_rssi;
|
||||
};
|
||||
|
||||
// WOW structures and defines
|
||||
|
||||
struct apple80211_wow_pattern
|
||||
{
|
||||
size_t len;
|
||||
u_int8_t *pattern;
|
||||
};
|
||||
|
||||
enum apple80211_wake_condition
|
||||
{
|
||||
APPLE80211_WAKE_COND_MAGIC_PATTERN = 0,
|
||||
APPLE80211_WAKE_COND_NET_PATTERN = 1,
|
||||
APPLE80211_WAKE_COND_DISASSOCIATED = 2,
|
||||
APPLE80211_WAKE_COND_DEAUTHED = 3,
|
||||
APPLE80211_WAKE_COND_RETROGRADE_TSF = 4,
|
||||
APPLE80211_WAKE_COND_BEACON_LOSS = 5,
|
||||
};
|
||||
|
||||
#define APPLE80211_MAX_WAKE_COND 5
|
||||
|
||||
enum apple80211_card_capability
|
||||
{
|
||||
APPLE80211_CAP_WEP = 0, // CAPABILITY: WEP available
|
||||
APPLE80211_CAP_TKIP = 1, // CAPABILITY: TKIP available
|
||||
APPLE80211_CAP_AES = 2, // CAPABILITY: AES OCB avail
|
||||
APPLE80211_CAP_AES_CCM = 3, // CAPABILITY: AES CCM avail
|
||||
APPLE80211_CAP_CKIP = 4, // CAPABILITY: CKIP available
|
||||
APPLE80211_CAP_IBSS = 5, // CAPABILITY: IBSS available
|
||||
APPLE80211_CAP_PMGT = 6, // CAPABILITY: Power mgmt
|
||||
APPLE80211_CAP_HOSTAP = 7, // CAPABILITY: HOSTAP avail
|
||||
APPLE80211_CAP_TXPMGT = 8, // CAPABILITY: tx power mgmt
|
||||
APPLE80211_CAP_SHSLOT = 9, // CAPABILITY: short slottime
|
||||
APPLE80211_CAP_SHPREAMBLE = 10, // CAPABILITY: short preamble
|
||||
APPLE80211_CAP_MONITOR = 11, // CAPABILITY: monitor mode
|
||||
APPLE80211_CAP_TKIPMIC = 12, // CAPABILITY: TKIP MIC avail
|
||||
APPLE80211_CAP_WPA1 = 13, // CAPABILITY: WPA1 avail
|
||||
APPLE80211_CAP_WPA2 = 14, // CAPABILITY: WPA2 avail
|
||||
APPLE80211_CAP_WPA = 15, // CAPABILITY: WPA1+WPA2 avail
|
||||
APPLE80211_CAP_BURST = 16, // CAPABILITY: frame bursting
|
||||
APPLE80211_CAP_WME = 17, // CAPABILITY: WME avail
|
||||
APPLE80211_CAP_SHORT_GI_40MHZ = 18, // CAPABILITY: Short guard interval in 40 MHz
|
||||
APPLE80211_CAP_SHORT_GI_20MHZ = 19, // CAPABILITY: Short guard interval in 20 MHz
|
||||
APPLE80211_CAP_WOW = 20, // CAPABILITY: Wake on wireless
|
||||
APPLE80211_CAP_TSN = 21, // CAPABILITY: WPA with WEP group key
|
||||
};
|
||||
#define APPLE80211_CAP_MAX 63
|
||||
|
||||
enum apple80211_virtual_interface_type
|
||||
{
|
||||
APPLE80211_VIF_P2P_DEVICE = 1,
|
||||
APPLE80211_VIF_P2P_CLIENT = 2,
|
||||
APPLE80211_VIF_P2P_GO = 3,
|
||||
APPLE80211_VIF_AWDL = 4,
|
||||
APPLE80211_VIF_SOFT_AP = 5,
|
||||
|
||||
APPLE80211_VIF_MAX
|
||||
};
|
||||
|
||||
enum apple80211_assoc_flags {
|
||||
APPLE80211_ASSOC_F_CLOSED = 1, // flag: scan was directed, needed to remember closed networks
|
||||
};
|
||||
|
||||
// Kernel messages
|
||||
|
||||
struct apple80211_status_msg_hdr
|
||||
{
|
||||
u_int32_t msg_type; // type of message
|
||||
u_int32_t msg_len; // length of data (not including msg_type and msg_len)
|
||||
|
||||
// data follows
|
||||
};
|
||||
|
||||
#define APPLE80211_M_MAX_LEN 2048
|
||||
|
||||
#define APPLE80211_M_POWER_CHANGED 1
|
||||
#define APPLE80211_M_SSID_CHANGED 2
|
||||
#define APPLE80211_M_BSSID_CHANGED 3
|
||||
#define APPLE80211_M_LINK_CHANGED 4
|
||||
#define APPLE80211_M_MIC_ERROR_UCAST 5
|
||||
#define APPLE80211_M_MIC_ERROR_MCAST 6
|
||||
#define APPLE80211_M_INT_MIT_CHANGED 7
|
||||
#define APPLE80211_M_MODE_CHANGED 8
|
||||
#define APPLE80211_M_ASSOC_DONE 9
|
||||
#define APPLE80211_M_SCAN_DONE 10
|
||||
#define APPLE80211_M_COUNTRY_CODE_CHANGED 11
|
||||
#define APPLE80211_M_STA_ARRIVE 12
|
||||
#define APPLE80211_M_STA_LEAVE 13
|
||||
#define APPLE80211_M_DECRYPTION_FAILURE 14
|
||||
#define APPLE80211_M_SCAN_CACHE_UPDATED 15
|
||||
#define APPLE80211_M_INTERNAL_SCAN_DONE 16
|
||||
#define APPLE80211_M_LINK_QUALITY 17
|
||||
#define APPLE80211_M_IBSS_PEER_ARRIVED 18
|
||||
#define APPLE80211_M_IBSS_PEER_LEFT 19
|
||||
#define APPLE80211_M_RSN_HANDSHAKE_DONE 20
|
||||
#define APPLE80211_M_BT_COEX_CHANGED 21
|
||||
#define APPLE80211_M_P2P_PEER_DETECTED 22
|
||||
#define APPLE80211_M_P2P_LISTEN_COMPLETE 23
|
||||
#define APPLE80211_M_P2P_SCAN_COMPLETE 24
|
||||
#define APPLE80211_M_P2P_LISTEN_STARTED 25
|
||||
#define APPLE80211_M_P2P_SCAN_STARTED 26
|
||||
#define APPLE80211_M_P2P_INTERFACE_CREATED 27
|
||||
#define APPLE80211_M_P2P_GROUP_STARTED 28
|
||||
#define APPLE80211_M_BGSCAN_NET_DISCOVERED 29
|
||||
#define APPLE80211_M_ROAMED 30
|
||||
#define APPLE80211_M_ACT_FRM_TX_COMPLETE 31
|
||||
#define APPLE80211_M_DEAUTH_RECEIVED 32
|
||||
#define APPLE80211_M_DRIVER_AVAILABLE 0x37
|
||||
#define APPLE80211_M_LINK_ADDRESS_CHANGED 0x3B
|
||||
#define APPLE80211_M_ROAM_START 0x46
|
||||
#define APPLE80211_M_ROAM_END 0x47
|
||||
#define APPLE80211_M_INTERFACE_STATE 0x3A
|
||||
|
||||
#define APPLE80211_M_MAX 0x3A
|
||||
#define APPLE80211_M_BUFF_SIZE APPLE80211_MAP_SIZE( APPLE80211_M_MAX )
|
||||
|
||||
// Registry Information
|
||||
#define APPLE80211_REGKEY_HARDWARE_VERSION "IO80211HardwareVersion"
|
||||
// #define APPLE80211_REG_FIRMWARE_VERSION "IO80211FirmwareVersion"
|
||||
#define APPLE80211_REGKEY_DRIVER_VERSION "IO80211DriverVersion"
|
||||
#define APPLE80211_REGKEY_LOCALE "IO80211Locale"
|
||||
#define APPLE80211_REGKEY_SSID "IO80211SSID"
|
||||
#define APPLE80211_REGKEY_CHANNEL "IO80211Channel"
|
||||
#define APPLE80211_REGKEY_EXT_CHANNEL "IO80211ExtensionChannel"
|
||||
#define APPLE80211_REGKEY_BAND "IO80211Band"
|
||||
#define APPLE80211_BAND_2GHZ "2 GHz"
|
||||
#define APPLE80211_BAND_5GHZ "5 GHz"
|
||||
#define APPLE80211_REGKEY_COUNTRY_CODE "IO80211CountryCode"
|
||||
|
||||
// Userland messages
|
||||
#define APPLE80211_M_RSN_AUTH_SUCCESS 254
|
||||
#define APPLE80211_M_RSN_AUTH_SUCCESS_TEMPLATE "com.apple.rsn.%s.auth.success" // string is interface name
|
||||
|
||||
#define APPLE80211_M_RSN_AUTH_TIMEOUT 255
|
||||
#define APPLE80211_M_RSN_AUTH_TIMEOUT_TEMPLATE "com.apple.rsn.%s.auth.timeout" // string is interface name
|
||||
|
||||
#define APPLE80211_M_RSN_MSG_MAX 2
|
||||
|
||||
#endif // _APPLE80211_VAR_H_
|
||||
|
||||
@@ -0,0 +1,537 @@
|
||||
//
|
||||
// wps_eap.h
|
||||
// IO80211Family
|
||||
//
|
||||
// Created by Pete on 6/20/06.
|
||||
// Copyright 2006 Apple Computer, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef _APPLE80211_WPS_H_
|
||||
#define _APPLE80211_WPS_H_
|
||||
|
||||
#include <Availability.h>
|
||||
#include <sys/types.h>
|
||||
#include <net/ethernet.h>
|
||||
|
||||
// This is necessary, because even the latest Xcode does not support properly targeting 11.0.
|
||||
#ifndef __IO80211_TARGET
|
||||
#error "Please define __IO80211_TARGET to the requested version"
|
||||
#endif
|
||||
|
||||
#define WPS_HANDSHAKE_TIMEOUT 120 /* seconds */
|
||||
#define WPS_RETRANSMIT_TIMEOUT 5
|
||||
#define WPS_MAX_RETRIES 3
|
||||
|
||||
#define WPS_IDENTITY_STR "WFA-SimpleConfig-Enrollee-1-0"
|
||||
#define WPS_IDENTITY_STR_LEN 29
|
||||
#define WPS_PERSONALIZATION_STRING "Wi-Fi Easy and Secure Key Derivation"
|
||||
#define WPS_PERSONALIZATION_STRING_LEN ( sizeof( WPS_PERSONALIZATION_STRING ) - 1 )
|
||||
#define WPS_KDF_KEY_BITS 640
|
||||
|
||||
#define WPS_DISPLAY_PIN_LEN 8
|
||||
|
||||
#define EAP_TYPE_ID 1
|
||||
#define WPS_EAP_METHOD_TYPE 254
|
||||
|
||||
#define WPS_VENDOR_ID_BYTES 0x00, 0x37, 0x2A
|
||||
#define WPS_VENDOR_TYPE 0x00000001
|
||||
|
||||
#define WPS_OP_START 0x01
|
||||
#define WPS_OP_ACK 0x02
|
||||
#define WPS_OP_NACK 0x03
|
||||
#define WPS_OP_MSG 0x04
|
||||
#define WPS_OP_DONE 0x05
|
||||
|
||||
#define WPS_FLAG_MF 0x01 /* more fragments */
|
||||
#define WPS_FLAG_LF 0x02 /* length field in use */
|
||||
|
||||
#define WPS_MAX_MSG_LEN UINT16_MAX /* max frag len, my limit */
|
||||
|
||||
#define PACKED __attribute__((packed))
|
||||
|
||||
struct wps_eap_hdr
|
||||
{
|
||||
u_int8_t code;
|
||||
u_int8_t identifier;
|
||||
u_int16_t length;
|
||||
u_int8_t type;
|
||||
u_int8_t vendor_id[3];
|
||||
u_int32_t vendor_type;
|
||||
u_int8_t op_code;
|
||||
u_int8_t flags;
|
||||
u_int16_t msg_length;
|
||||
// u_int8_t msg[1]; /* data follows */
|
||||
} PACKED;
|
||||
|
||||
#define WPS_EAP_HDR_LEN( _whdr ) ( ( _whdr->flags & WPS_FLAG_LF ) ? sizeof( struct wps_eap_hdr ) : sizeof( struct wps_eap_hdr ) - sizeof( u_int16_t ) )
|
||||
|
||||
// Messages elements
|
||||
|
||||
#define BUF_SIZE_64_BITS 8
|
||||
#define BUF_SIZE_128_BITS 16
|
||||
#define BUF_SIZE_160_BITS 20
|
||||
#define BUF_SIZE_256_BITS 32
|
||||
#define BUF_SIZE_512_BITS 64
|
||||
#define BUF_SIZE_1024_BITS 128
|
||||
#define BUF_SIZE_1536_BITS 192
|
||||
|
||||
struct wps_msg_elem_hdr
|
||||
{
|
||||
u_int16_t elem_id;
|
||||
u_int16_t elem_len;
|
||||
} PACKED;
|
||||
|
||||
#define WPS_ELEM_SET_HEADER( elem, id, len ) (elem)->hdr.elem_id = htons( id ); (elem)->hdr.elem_len = htons( len )
|
||||
|
||||
struct wps_dev_type
|
||||
{
|
||||
u_int16_t category;
|
||||
u_int8_t oui[4];
|
||||
u_int16_t sub_category;
|
||||
} PACKED;
|
||||
|
||||
#define WIFI_DEV_TYPE_OUI_BYTES 0x00, 0x50, 0xf2, 0x04
|
||||
|
||||
#define DEFINE_WPS_ELEMENT( name, param ) \
|
||||
typedef struct { \
|
||||
struct wps_msg_elem_hdr hdr; \
|
||||
param; \
|
||||
} PACKED name
|
||||
|
||||
|
||||
#define WPS_VERSION 0x10
|
||||
DEFINE_WPS_ELEMENT( wps_elem_ap_channel_t, u_int16_t channel );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_assoc_state_t, u_int16_t assoc_state );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_auth_type_t, u_int16_t auth_type );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_auth_type_flags_t, u_int16_t auth_flags );
|
||||
#define AUTHENTICATOR_MSG_SIZE ( sizeof( struct wps_msg_elem_hdr ) + 8 )
|
||||
DEFINE_WPS_ELEMENT( wps_elem_authenticator_t, u_int8_t authenticator[8] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_config_methods_t, u_int16_t config_methods );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_config_error_t, u_int16_t error );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_confirm_url4_t, u_int16_t url4[1] ); // <= 64B
|
||||
DEFINE_WPS_ELEMENT( wps_elem_confirm_url6_t, u_int16_t url6[1] ); // <= 76B
|
||||
DEFINE_WPS_ELEMENT( wps_elem_conn_type_t, u_int8_t conn_type );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_conn_type_flags_t, u_int8_t conn_type_flags );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_credential_t, u_int8_t cred[1] ); // <= ???
|
||||
DEFINE_WPS_ELEMENT( wps_elem_dev_name_t, u_int8_t dev_name[1] ); // <= 32B
|
||||
DEFINE_WPS_ELEMENT( wps_elem_dev_pw_id_t, u_int16_t dev_pw_id );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_e_hash1_t, u_int8_t e_hash1[BUF_SIZE_256_BITS] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_e_hash2_t, u_int8_t e_hash2[BUF_SIZE_256_BITS] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_e_snonce1_t, u_int8_t e_snonce1[BUF_SIZE_128_BITS] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_e_snonce2_t, u_int8_t e_snonce2[BUF_SIZE_128_BITS] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_ecrypt_settings_t, u_int8_t settings[1] ); // no limit defined
|
||||
DEFINE_WPS_ELEMENT( wps_elem_encrypt_type_t, u_int16_t encrypt_type );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_encrypt_type_flags_t, u_int16_t encrypt_type_flags );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_enrl_nonce_t, u_int8_t nonce[BUF_SIZE_128_BITS] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_feature_id_t, u_int32_t feature_id );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_identity_t, u_int8_t identity[1] ); // <= 80
|
||||
// identity proof?
|
||||
DEFINE_WPS_ELEMENT( wps_elem_iv_t, u_int8_t iv[BUF_SIZE_256_BITS] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_key_wrap_authenticator_t, u_int8_t key_wrap_authenticator[8] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_key_id_t, u_int8_t key_id[16] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_mac_addr_t, u_int8_t mac[ETHER_ADDR_LEN] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_manufacturer_t, u_int8_t manufacturer[1] ); // <= 64
|
||||
DEFINE_WPS_ELEMENT( wps_elem_msg_type_t, u_int8_t msg_type );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_model_name_t, u_int8_t model_name[1] ); // <= 32B
|
||||
DEFINE_WPS_ELEMENT( wps_elem_model_number_t, u_int8_t model_number[1] ); // <= 32B
|
||||
DEFINE_WPS_ELEMENT( wps_elem_network_index_t, u_int8_t network_index );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_network_key_t, u_int8_t network_key[1] ); // <= 64B
|
||||
DEFINE_WPS_ELEMENT( wps_elem_network_key_index_t, u_int8_t network_key_index );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_new_dev_name_t, u_int8_t new_dev_name[1] ); // <= 32B
|
||||
DEFINE_WPS_ELEMENT( wps_elem_new_pw_t, u_int8_t new_pw[1] ); // <= 64
|
||||
// oob device password?
|
||||
DEFINE_WPS_ELEMENT( wps_elem_os_version_t, u_int32_t os_version );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_power_level_t, u_int8_t power_level );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_psk_current_t, u_int8_t psk_current );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_psk_max_t, u_int8_t psk_max );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_public_key_t, u_int8_t key[BUF_SIZE_1536_BITS] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_radio_enabled_t, u_int8_t radio_enabled ); // bool?
|
||||
DEFINE_WPS_ELEMENT( wps_elem_reboot_t, u_int8_t reboot ); // bool?
|
||||
DEFINE_WPS_ELEMENT( wps_elem_reg_current_t, u_int8_t reg_current );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_reg_established_t, u_int8_t reg_established ); // bool?
|
||||
DEFINE_WPS_ELEMENT( wps_elem_reg_list_t, u_int8_t reg_list[1] ); // <= 512B
|
||||
DEFINE_WPS_ELEMENT( wps_elem_reg_max_t, u_int8_t reg_max );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_reg_nonce_t, u_int8_t nonce[BUF_SIZE_128_BITS] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_req_type_t, u_int8_t req_type );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_resp_type_t, u_int8_t resp_type );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_rf_band_t, u_int8_t rf_band );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_r_hash1, u_int8_t r_hash1[BUF_SIZE_256_BITS] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_r_hash2, u_int8_t r_hash2[BUF_SIZE_256_BITS] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_r_snonce1, u_int8_t r_snonce1[BUF_SIZE_128_BITS] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_r_snonce2, u_int8_t r_snonce2[BUF_SIZE_128_BITS] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_selected_reg_t, u_int8_t selected_reg ); // bool?
|
||||
DEFINE_WPS_ELEMENT( wps_elem_serial_number_t, u_int8_t serial_number[1] ); // <= 32B
|
||||
DEFINE_WPS_ELEMENT( wps_elem_simple_config_state_t, u_int8_t simple_config_state );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_ssid_t, u_int8_t ssid[32] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_total_networks_t, u_int8_t total_networks );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_uuid_e_t, u_int8_t uuid_e[16] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_uuid_r_t, u_int8_t uuid_r[16] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_vendor_ext_t, u_int8_t vendor_ext[1] ); // <= 1024
|
||||
DEFINE_WPS_ELEMENT( wps_elem_version_t, u_int8_t version ); // int?
|
||||
DEFINE_WPS_ELEMENT( wps_elem_x_509_cert_req_t, u_int8_t cert_req[1] ); // limit?
|
||||
DEFINE_WPS_ELEMENT( wps_elem_x_509_cert_t, u_int8_t cert[1] ); // limit?
|
||||
DEFINE_WPS_ELEMENT( wps_elem_eap_id_t, u_int8_t eap_id[1] ); // <= 64
|
||||
DEFINE_WPS_ELEMENT( wps_elem_msg_counter_t, u_int8_t msg_counter[8] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_public_key_hash_t, u_int8_t public_key_hash[BUF_SIZE_160_BITS] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_rekey_key_t, u_int8_t rekey_key[32] );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_key_lifetime_t, u_int32_t key_lifetime );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_permitted_config_methods_t, u_int16_t permitted_config_methods );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_sel_reg_config_methods_t, u_int8_t sel_reg_config_methods );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_primary_dev_type_t, struct wps_dev_type prime_dev_type );
|
||||
DEFINE_WPS_ELEMENT( wps_elem_secondary_dev_type_list_t, u_int8_t secondary_dev_type_list[1] ); // <= 128B
|
||||
DEFINE_WPS_ELEMENT( wps_elem_portable_dev_t, u_int8_t portable_dev ); // bool?
|
||||
DEFINE_WPS_ELEMENT( wps_elem_ap_setup_locked_t, u_int8_t ap_setup_locked ); // bool?
|
||||
DEFINE_WPS_ELEMENT( wps_elem_app_list_t, u_int8_t app_list[1] ); // <= 512B
|
||||
DEFINE_WPS_ELEMENT( wps_elem_eap_type_t, u_int8_t eap_type[1] ); // <= 8B
|
||||
|
||||
#define WPS_NEXT_ELEMENT( cast, cur_elm, len ) (cast)( (UInt8 *)(cur_elm) + sizeof( struct wps_msg_elem_hdr ) + ntohs( cur_elm->hdr.elem_len ) ); \
|
||||
len+=( sizeof( struct wps_msg_elem_hdr ) + ntohs( cur_elm->hdr.elem_len ) )
|
||||
#define WPS_NEXT_ELEMENT_IE( cast, cur_elm, len ) (cast)( (UInt8 *)(cur_elm) + sizeof( struct wps_msg_elem_hdr ) + ntohs( cur_elm->hdr.elem_len ) ); \
|
||||
len-=( sizeof( struct wps_msg_elem_hdr ) + ntohs( cur_elm->hdr.elem_len ) );
|
||||
#define WPS_ELEMENT_IS( elem, id ) ( ntohs( elem->hdr.elem_id ) == id )
|
||||
#define WPS_ELEMENT_LEN_VAR( elem ) ( sizeof( struct wps_msg_elem_hdr ) + ntohs( elem->hdr.elem_len ) )
|
||||
#define WPS_ELEMENT_LEN_FIXED( fixed ) ( sizeof( struct wps_msg_elem_hdr ) + sizeof( fixed ) )
|
||||
#define WPS_ELEMENT_PARAM_LEN( elem ) ( ntohs( elem->hdr.elem_len ) )
|
||||
|
||||
// Messages
|
||||
#define WPS_MBUF_GET_MSG_PTR( m, type ) (type *)( (UInt8 *)mbuf_data( m ) + sizeof( struct ether_header ) + sizeof( struct wps_eap_hdr ) )
|
||||
|
||||
struct wps_msg_nack
|
||||
{
|
||||
wps_elem_version_t version;
|
||||
wps_elem_msg_type_t msg_type;
|
||||
wps_elem_enrl_nonce_t enrl_nonce;
|
||||
wps_elem_reg_nonce_t reg_nonce;
|
||||
wps_elem_config_error_t error;
|
||||
}PACKED;
|
||||
|
||||
struct wps_msg_ack
|
||||
{
|
||||
wps_elem_version_t version;
|
||||
wps_elem_msg_type_t msg_type;
|
||||
wps_elem_enrl_nonce_t enrl_nonce;
|
||||
wps_elem_reg_nonce_t reg_nonce;
|
||||
}PACKED;
|
||||
|
||||
struct wps_msg_done
|
||||
{
|
||||
wps_elem_version_t version;
|
||||
wps_elem_msg_type_t msg_type;
|
||||
};
|
||||
|
||||
// From RFC 3748 section 4.1 for identity
|
||||
struct wps_identity_msg
|
||||
{
|
||||
u_int8_t code;
|
||||
u_int8_t id;
|
||||
u_int16_t length;
|
||||
u_int8_t type;
|
||||
// u_int8_t type_data[1]; /* data follows */
|
||||
} PACKED;
|
||||
|
||||
#define WPS_EAP_TYPE_IDENTITY 1
|
||||
|
||||
// Data Element Definitions
|
||||
#define WPS_ID_AP_CHANNEL 0x1001
|
||||
#define WPS_ID_ASSOC_STATE 0x1002
|
||||
#define WPS_ID_AUTH_TYPE 0x1003
|
||||
#define WPS_ID_AUTH_TYPE_FLAGS 0x1004
|
||||
#define WPS_ID_AUTHENTICATOR 0x1005
|
||||
#define WPS_ID_CONFIG_METHODS 0x1008
|
||||
#define WPS_ID_CONFIG_ERROR 0x1009
|
||||
#define WPS_ID_CONF_URL4 0x100A
|
||||
#define WPS_ID_CONF_URL6 0x100B
|
||||
#define WPS_ID_CONN_TYPE 0x100C
|
||||
#define WPS_ID_CONN_TYPE_FLAGS 0x100D
|
||||
#define WPS_ID_CREDENTIAL 0x100E
|
||||
#define WPS_ID_DEVICE_NAME 0x1011
|
||||
#define WPS_ID_DEVICE_PWD_ID 0x1012
|
||||
#define WPS_ID_E_HASH1 0x1014
|
||||
#define WPS_ID_E_HASH2 0x1015
|
||||
#define WPS_ID_E_SNONCE1 0x1016
|
||||
#define WPS_ID_E_SNONCE2 0x1017
|
||||
#define WPS_ID_ENCR_SETTINGS 0x1018
|
||||
#define WPS_ID_ENCR_TYPE 0x100F
|
||||
#define WPS_ID_ENCR_TYPE_FLAGS 0x1010
|
||||
#define WPS_ID_ENROLLEE_NONCE 0x101A
|
||||
#define WPS_ID_FEATURE_ID 0x101B
|
||||
#define WPS_ID_IDENTITY 0x101C
|
||||
#define WPS_ID_IDENTITY_PROOF 0x101D
|
||||
#define WPS_ID_INIT_VECTOR 0x104B //this becomes 0x1060 later
|
||||
//#define WPS_ID_KEY_WRAP_AUTH WPS_ID_AUTHENTICATOR //this becomes 0x101E later
|
||||
#define WPS_ID_KEY_WRAP_AUTH 0x101E // HH changed for MS beta 2 testing
|
||||
#define WPS_ID_KEY_IDENTIFIER 0x101F
|
||||
#define WPS_ID_MAC_ADDR 0x1020
|
||||
#define WPS_ID_MANUFACTURER 0x1021
|
||||
#define WPS_ID_MSG_TYPE 0x1022
|
||||
#define WPS_ID_MODEL_NAME 0x1023
|
||||
#define WPS_ID_MODEL_NUMBER 0x1024
|
||||
#define WPS_ID_NW_INDEX 0x1026
|
||||
#define WPS_ID_NW_KEY 0x1027
|
||||
#define WPS_ID_NW_KEY_INDEX 0x1028
|
||||
#define WPS_ID_NEW_DEVICE_NAME 0x1029
|
||||
#define WPS_ID_NEW_PWD 0x102A
|
||||
#define WPS_ID_OOB_DEV_PWD 0x102C
|
||||
#define WPS_ID_OS_VERSION 0x102D
|
||||
#define WPS_ID_POWER_LEVEL 0x102F
|
||||
#define WPS_ID_PSK_CURRENT 0x1030
|
||||
#define WPS_ID_PSK_MAX 0x1031
|
||||
#define WPS_ID_PUBLIC_KEY 0x1032
|
||||
#define WPS_ID_RADIO_ENABLED 0x1033
|
||||
#define WPS_ID_REBOOT 0x1034
|
||||
#define WPS_ID_REGISTRAR_CURRENT 0x1035
|
||||
#define WPS_ID_REGISTRAR_ESTBLSHD 0x1036
|
||||
#define WPS_ID_REGISTRAR_LIST 0x1037
|
||||
#define WPS_ID_REGISTRAR_MAX 0x1038
|
||||
#define WPS_ID_REGISTRAR_NONCE 0x1039
|
||||
#define WPS_ID_REQ_TYPE 0x103A
|
||||
#define WPS_ID_RESP_TYPE 0x103B
|
||||
#define WPS_ID_RF_BAND 0x103C
|
||||
#define WPS_ID_R_HASH1 0x103D
|
||||
#define WPS_ID_R_HASH2 0x103E
|
||||
#define WPS_ID_R_SNONCE1 0x103F
|
||||
#define WPS_ID_R_SNONCE2 0x1040
|
||||
#define WPS_ID_SEL_REGISTRAR 0x1041
|
||||
#define WPS_ID_SERIAL_NUM 0x1042
|
||||
#define WPS_ID_SC_STATE 0x1044
|
||||
#define WPS_ID_SSID 0x1045
|
||||
#define WPS_ID_TOT_NETWORKS 0x1046
|
||||
#define WPS_ID_UUID_E 0x1047
|
||||
#define WPS_ID_UUID_R 0x1048
|
||||
#define WPS_ID_VENDOR_EXT 0x1049
|
||||
#define WPS_ID_VERSION 0x104A
|
||||
#define WPS_ID_X509_CERT_REQ 0x104B
|
||||
#define WPS_ID_X509_CERT 0x104C
|
||||
#define WPS_ID_EAP_IDENTITY 0x104D
|
||||
#define WPS_ID_MSG_COUNTER 0x104E
|
||||
#define WPS_ID_PUBKEY_HASH 0x104F
|
||||
#define WPS_ID_REKEY_KEY 0x1050
|
||||
#define WPS_ID_KEY_LIFETIME 0x1051
|
||||
#define WPS_ID_PERM_CFG_METHODS 0x1052
|
||||
#define WPS_ID_SEL_REG_CFG_METHODS_ORIGINAL 0x0153 // This was the original val in the spec, we must support both
|
||||
#define WPS_ID_SEL_REG_CFG_METHODS 0x1053
|
||||
#define WPS_ID_PRIM_DEV_TYPE 0x1054
|
||||
#define WPS_ID_SEC_DEV_TYPE_LIST 0x1055
|
||||
#define WPS_ID_PORTABLE_DEVICE 0x1056
|
||||
#define WPS_ID_AP_SETUP_LOCKED 0x1057
|
||||
#define WPS_ID_APP_LIST 0x1058
|
||||
#define WPS_ID_EAP_TYPE 0x1059
|
||||
|
||||
// Association states
|
||||
#define WPS_ASSOC_NOT_ASSOCIATED 0
|
||||
#define WPS_ASSOC_CONN_SUCCESS 1
|
||||
#define WPS_ASSOC_CONFIG_FAIL 2
|
||||
#define WPS_ASSOC_ASSOC_FAIL 3
|
||||
#define WPS_ASSOC_IP_FAIL 4
|
||||
|
||||
// Authentication types
|
||||
#define WPS_AUTHTYPE_OPEN 0x0001
|
||||
#define WPS_AUTHTYPE_WPAPSK 0x0002
|
||||
#define WPS_AUTHTYPE_SHARED 0x0004
|
||||
#define WPS_AUTHTYPE_WPA 0x0008
|
||||
#define WPS_AUTHTYPE_WPA2 0x0010
|
||||
#define WPS_AUTHTYPE_WPA2PSK 0x0020
|
||||
|
||||
// Config methods
|
||||
#define WPS_CONFMET_USBA 0x0001
|
||||
#define WPS_CONFMET_ETHERNET 0x0002
|
||||
#define WPS_CONFMET_LABEL 0x0004
|
||||
#define WPS_CONFMET_DISPLAY 0x0008
|
||||
#define WPS_CONFMET_EXT_NFC_TOK 0x0010
|
||||
#define WPS_CONFMET_INT_NFC_TOK 0x0020
|
||||
#define WPS_CONFMET_NFC_INTF 0x0040
|
||||
#define WPS_CONFMET_PBC 0x0080
|
||||
#define WPS_CONFMET_KEYPAD 0x0100
|
||||
|
||||
// WPS error messages
|
||||
#define WPS_ERROR_NO_ERROR 0
|
||||
#define WPS_ERROR_OOB_INT_READ_ERR 1
|
||||
#define WPS_ERROR_DECRYPT_CRC_FAIL 2
|
||||
#define WPS_ERROR_CHAN24_NOT_SUPP 3
|
||||
#define WPS_ERROR_CHAN50_NOT_SUPP 4
|
||||
#define WPS_ERROR_SIGNAL_WEAK 5
|
||||
#define WPS_ERROR_NW_AUTH_FAIL 6
|
||||
#define WPS_ERROR_NW_ASSOC_FAIL 7
|
||||
#define WPS_ERROR_NO_DHCP_RESP 8
|
||||
#define WPS_ERROR_FAILED_DHCP_CONF 9
|
||||
#define WPS_ERROR_IP_ADDR_CONFLICT 10
|
||||
#define WPS_ERROR_FAIL_CONN_REGISTRAR 11
|
||||
#define WPS_ERROR_MULTI_PBC_DETECTED 12
|
||||
#define WPS_ERROR_ROGUE_SUSPECTED 13
|
||||
#define WPS_ERROR_DEVICE_BUSY 14
|
||||
#define WPS_ERROR_SETUP_LOCKED 15
|
||||
#define WPS_ERROR_MSG_TIMEOUT 16
|
||||
#define WPS_ERROR_REG_SESSION_TIMEOUT 17
|
||||
#define WPS_ERROR_DEV_PWD_AUTH_FAIL 18
|
||||
|
||||
#define WPS_ERROR_MAX WPS_ERROR_DEV_PWD_AUTH_FAIL
|
||||
|
||||
// Connection types
|
||||
#define WPS_CONNTYPE_ESS 0x01
|
||||
#define WPS_CONNTYPE_IBSS 0x02
|
||||
|
||||
// Device password ID
|
||||
#define WPS_DEVICEPWDID_DEFAULT 0x0000
|
||||
#define WPS_DEVICEPWDID_USER_SPEC 0x0001
|
||||
#define WPS_DEVICEPWDID_MACHINE_SPEC 0x0002
|
||||
#define WPS_DEVICEPWDID_REKEY 0x0003
|
||||
#define WPS_DEVICEPWDID_PUSH_BTN 0x0004
|
||||
#define WPS_DEVICEPWDID_REG_SPEC 0x0005
|
||||
|
||||
/*
|
||||
// Device type
|
||||
#define WPS_DEVICETYPE_COMPUTER "Computer"
|
||||
#define WPS_DEVICETYPE_AP "Access_Point"
|
||||
#define WPS_DEVICETYPE_ROUTER_AP "Router_AP"
|
||||
#define WPS_DEVICETYPE_PRINTER "Printer"
|
||||
#define WPS_DEVICETYPE_PRINTER_BRIDGE "Printer_Brigde"
|
||||
#define WPS_DEVICETYPE_ELECT_PIC_FRAME "Electronic_Picture_Frame"
|
||||
#define WPS_DEVICETYPE_DIG_AUDIO_RECV "Digital_Audio_Receiver"
|
||||
#define WPS_DEVICETYPE_WIN_MCE "Windows_Media_Center_Extender"
|
||||
#define WPS_DEVICETYPE_WIN_MOBILE "Windows_Mobile"
|
||||
#define WPS_DEVICETYPE_PVR "Personal_Video_Recorder"
|
||||
#define WPS_DEVICETYPE_VIDEO_STB "Video_STB"
|
||||
#define WPS_DEVICETYPE_PROJECTOR "Projector"
|
||||
#define WPS_DEVICETYPE_IP_TV "IP_TV"
|
||||
#define WPS_DEVICETYPE_DIG_STILL_CAM "Digital_Still_Camera"
|
||||
#define WPS_DEVICETYPE_PHONE "Phone"
|
||||
#define WPS_DEVICETYPE_VOID_PHONE "VoIP_Phone"
|
||||
#define WPS_DEVICETYPE_GAME_CONSOLE "Game_console"
|
||||
#define WPS_DEVICETYPE_OTHER "Other"
|
||||
*/
|
||||
|
||||
// Encryption type
|
||||
#define WPS_ENCRTYPE_NONE 0x0001
|
||||
#define WPS_ENCRTYPE_WEP 0x0002
|
||||
#define WPS_ENCRTYPE_TKIP 0x0004
|
||||
#define WPS_ENCRTYPE_AES 0x0008
|
||||
|
||||
|
||||
// WPS Message Types
|
||||
#define WPS_ID_BEACON 0x01
|
||||
#define WPS_ID_PROBE_REQ 0x02
|
||||
#define WPS_ID_PROBE_RESP 0x03
|
||||
#define WPS_ID_MESSAGE_M1 0x04
|
||||
#define WPS_ID_MESSAGE_M2 0x05
|
||||
#define WPS_ID_MESSAGE_M2D 0x06
|
||||
#define WPS_ID_MESSAGE_M3 0x07
|
||||
#define WPS_ID_MESSAGE_M4 0x08
|
||||
#define WPS_ID_MESSAGE_M5 0x09
|
||||
#define WPS_ID_MESSAGE_M6 0x0A
|
||||
#define WPS_ID_MESSAGE_M7 0x0B
|
||||
#define WPS_ID_MESSAGE_M8 0x0C
|
||||
#define WPS_ID_MESSAGE_ACK 0x0D
|
||||
#define WPS_ID_MESSAGE_NACK 0x0E
|
||||
#define WPS_ID_MESSAGE_DONE 0x0F
|
||||
|
||||
//Device Type categories for primary and secondary device types
|
||||
#define WPS_DEVICE_TYPE_CAT_COMPUTER 1
|
||||
#define WPS_DEVICE_TYPE_CAT_INPUT_DEVICE 2
|
||||
#define WPS_DEVICE_TYPE_CAT_PRINTER 3
|
||||
#define WPS_DEVICE_TYPE_CAT_CAMERA 4
|
||||
#define WPS_DEVICE_TYPE_CAT_STORAGE 5
|
||||
#define WPS_DEVICE_TYPE_CAT_NW_INFRA 6
|
||||
#define WPS_DEVICE_TYPE_CAT_DISPLAYS 7
|
||||
#define WPS_DEVICE_TYPE_CAT_MM_DEVICES 8
|
||||
#define WPS_DEVICE_TYPE_CAT_GAME_DEVICES 9
|
||||
#define WPS_DEVICE_TYPE_CAT_TELEPHONE 10
|
||||
|
||||
//Device Type sub categories for primary and secondary device types
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_COMP_PC 1
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_COMP_SERVER 2
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_COMP_MEDIA_CTR 3
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_PRTR_PRINTER 1
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_PRTR_SCANNER 2
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_CAM_DGTL_STILL 1
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_STOR_NAS 1
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_NW_AP 1
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_NW_ROUTER 2
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_NW_SWITCH 3
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_DISP_TV 1
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_DISP_PIC_FRAME 2
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_DISP_PROJECTOR 3
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_MM_DAR 1
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_MM_PVR 2
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_MM_MCX 3
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_GAM_XBOX 1
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_GAM_XBOX_360 2
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_GAM_PS 3
|
||||
#define WPS_DEVICE_TYPE_SUB_CAT_PHONE_WM 1
|
||||
|
||||
// Device request/response type
|
||||
#define WPS_MSGTYPE_ENROLLEE_INFO_ONLY 0x00
|
||||
#define WPS_MSGTYPE_ENROLLEE_OPEN_8021X 0x01
|
||||
#define WPS_MSGTYPE_REGISTRAR 0x02
|
||||
#define WPS_MSGTYPE_AP_WLAN_MGR 0x03
|
||||
|
||||
// RF Band
|
||||
#define WPS_RFBAND_24GHZ 0x01
|
||||
#define WPS_RFBAND_50GHZ 0x02
|
||||
|
||||
// Simple Config state
|
||||
#define WPS_SCSTATE_UNCONFIGURED 0x01
|
||||
#define WPS_SCSTATE_CONFIGURED 0x02
|
||||
|
||||
// State business
|
||||
#define WPS_RETRY_INTERVAL 5 /* seconds */
|
||||
#define WPS_PACKET_TIMEOUT 15 /* seconds */
|
||||
|
||||
#define WPS_TIMEOUT_SECS 1
|
||||
|
||||
enum WPSSupplicantState
|
||||
{
|
||||
WPS_S_INIT,
|
||||
WPS_S_EAPOL_START_TX,
|
||||
WPS_S_EAPOL_START_RX,
|
||||
WPS_S_IDENT_REQ_TX,
|
||||
WPS_S_IDENT_REQ_RX,
|
||||
WPS_S_IDENT_RESP_TX,
|
||||
WPS_S_IDENT_RESP_RX,
|
||||
WPS_S_START_TX,
|
||||
WPS_S_START_RX,
|
||||
WPS_S_M1_TX,
|
||||
WPS_S_M1_RX,
|
||||
WPS_S_M2_TX,
|
||||
WPS_S_M2_RX,
|
||||
WPS_S_M3_TX,
|
||||
WPS_S_M3_RX,
|
||||
WPS_S_M4_TX,
|
||||
WPS_S_M4_RX,
|
||||
WPS_S_M5_TX,
|
||||
WPS_S_M5_RX,
|
||||
WPS_S_M6_TX,
|
||||
WPS_S_M6_RX,
|
||||
WPS_S_M7_TX,
|
||||
WPS_S_M7_RX,
|
||||
WPS_S_M8_TX,
|
||||
WPS_S_M8_RX,
|
||||
WPS_S_DONE_TX,
|
||||
WPS_S_DONE_RX,
|
||||
WPS_S_FAIL_TX,
|
||||
WPS_S_FAIL_RX,
|
||||
WPS_S_MSG_TIMEOUT,
|
||||
WPS_S_SESSION_TIMEOUT,
|
||||
};
|
||||
typedef enum WPSSupplicantState WPSSupplicantState;
|
||||
|
||||
// Apple specific error codes
|
||||
|
||||
#define WPSE_NOERR 0 // no error
|
||||
#define WPSE_ERR -1 // general error code
|
||||
#define WPSE_PROTO_ERR -2 // Problem with EAPOL handshake
|
||||
#define WPSE_IE_NOT_PRESENT -3 // No WPS IE present in IE list for ssid
|
||||
#define WPSE_IE_MALFORMED -4 // WPS IS missing required (for Apple) fields
|
||||
#define WPSE_SCAN_ERR -5 // Scan failed
|
||||
#define WPSE_NO_PIN_AT_REG -6 // No PIN configured at registrar
|
||||
#define WPSE_NO_PIN_AT_CLIENT -7 // No PIN configured at client
|
||||
#define WPSE_SSID_NOT_FOUND -8 // Scan did not find SSID
|
||||
#define WPSE_UNSUPPORTED_PW_ID -9 // Registrar reports that it is using an unsupported PW ID
|
||||
#define WPSE_ASSOC_FAILED -10 // Association attempt failed
|
||||
#define WPSE_API_REQ -11 // An apple80211 ioctl request failed
|
||||
#define WPSE_NOMEM -12 // memory error
|
||||
#define WPSE_WPA_RSN_NOT_SUP -13 // WPA/RSN not supported
|
||||
#define WPSE_TIMEOUT -14 // EAPOL timed out
|
||||
#define WPSE_NACKED -15 // NACKED by registrar
|
||||
#define WPSE_FAIL -16 // unexpected EAP-FAIL received
|
||||
|
||||
#endif /* _APPLE80211_WPS_H_ */
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2016 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef apple_private_spi_h
|
||||
#define apple_private_spi_h
|
||||
|
||||
#ifndef __PRIVATE_SPI__
|
||||
|
||||
/*! @enum IOMbufServiceClass
|
||||
@discussion Service class of a mbuf packet.
|
||||
@constant kIOMbufServiceClassBKSYS Background System-Initiated.
|
||||
@constant kIOMbufServiceClassBK Background.
|
||||
@constant kIOMbufServiceClassBE Best Effort.
|
||||
@constant kIOMbufServiceClassRD Responsive Data.
|
||||
@constant kIOMbufServiceClassOAM Operations, Administration, and Management.
|
||||
@constant kIOMbufServiceClassAV Multimedia Audio/Video Streaming.
|
||||
@constant kIOMbufServiceClassRV Responsive Multimedia Audio/Video.
|
||||
@constant kIOMbufServiceClassVI Interactive Video.
|
||||
@constant kIOMbufServiceClassVO Interactive Voice.
|
||||
@constant kIOMbufServiceClassCTL Network Control.
|
||||
*/
|
||||
enum IOMbufServiceClass {
|
||||
kIOMbufServiceClassBKSYS = 100,
|
||||
kIOMbufServiceClassBK = 200,
|
||||
kIOMbufServiceClassBE = 0,
|
||||
kIOMbufServiceClassRD = 300,
|
||||
kIOMbufServiceClassOAM = 400,
|
||||
kIOMbufServiceClassAV = 500,
|
||||
kIOMbufServiceClassRV = 600,
|
||||
kIOMbufServiceClassVI = 700,
|
||||
kIOMbufServiceClassVO = 800,
|
||||
kIOMbufServiceClassCTL = 900
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
struct packet_info_tag {
|
||||
|
||||
};
|
||||
|
||||
struct apple80211_debug_command {
|
||||
|
||||
};
|
||||
|
||||
struct ifnet_init_eparams {
|
||||
|
||||
};
|
||||
|
||||
#endif /* apple_private_spi_h */
|
||||
@@ -0,0 +1,283 @@
|
||||
//
|
||||
// debug.h
|
||||
// Black80211_HighSierra
|
||||
//
|
||||
// Created by Roman Peshkov on 05/07/2018.
|
||||
// Copyright © 2018 Roman Peshkov. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef debug_h
|
||||
#define debug_h
|
||||
|
||||
static const char* IOCTL_NAMES[] = {
|
||||
"UNKNOWN",
|
||||
"SSID",
|
||||
"AUTH_TYPE",
|
||||
"CIPHER_KEY",
|
||||
"CHANNEL",
|
||||
"POWERSAVE",
|
||||
"PROTMODE",
|
||||
"TXPOWER",
|
||||
"RATE",
|
||||
"BSSID",
|
||||
"SCAN_REQ",
|
||||
"SCAN_RESULT",
|
||||
"CARD_CAPABILITIES",
|
||||
"STATE",
|
||||
"PHY_MODE",
|
||||
"OP_MODE",
|
||||
"RSSI",
|
||||
"NOISE",
|
||||
"INT_MIT",
|
||||
"POWER",
|
||||
"ASSOCIATE",
|
||||
"ASSOCIATE_RESULT",
|
||||
"DISASSOCIATE",
|
||||
"STATUS_DEV_NAME",
|
||||
"IBSS_MODE",
|
||||
"HOST_AP_MODE",
|
||||
"AP_MODE",
|
||||
"SUPPORTED_CHANNELS",
|
||||
"LOCALE",
|
||||
"DEAUTH",
|
||||
"COUNTERMEASURES",
|
||||
"FRAG_THRESHOLD",
|
||||
"RATE_SET",
|
||||
"SHORT_SLOT",
|
||||
"MULTICAST_RATE",
|
||||
"SHORT_RETRY_LIMIT",
|
||||
"LONG_RETRY_LIMIT",
|
||||
"TX_ANTENNA",
|
||||
"RX_ANTENNA",
|
||||
"ANTENNA_DIVERSITY",
|
||||
"ROM",
|
||||
"DTIM_INT",
|
||||
"STATION_LIST",
|
||||
"DRIVER_VERSION",
|
||||
"HARDWARE_VERSION",
|
||||
"RAND",
|
||||
"RSN_IE",
|
||||
"BACKGROUND_SCAN",
|
||||
"AP_IE_LIST",
|
||||
"STATS",
|
||||
"ASSOCIATION_STATUS",
|
||||
"COUNTRY_CODE",
|
||||
"DEBUG_FLAGS",
|
||||
"LAST_RX_PKT_DATA",
|
||||
"RADIO_INFO",
|
||||
"GUARD_INTERVAL",
|
||||
"MIMO_POWERSAVE",
|
||||
"MCS",
|
||||
"RIFS",
|
||||
"LDPC",
|
||||
"MSDU",
|
||||
"MPDU",
|
||||
"BLOCK_ACK",
|
||||
"PLS",
|
||||
"PSMP",
|
||||
"PHY_SUB_MODE",
|
||||
"MCS_INDEX_SET",
|
||||
"CACHE_THRESH_BCAST",
|
||||
"CACHE_THRESH_DIRECT",
|
||||
"WOW_PARAMETERS",
|
||||
"WOW_ENABLED",
|
||||
"40MHZ_INTOLERANT",
|
||||
"PID_LOCK",
|
||||
"STA_IE_LIST",
|
||||
"STA_AUTHORIZE",
|
||||
"STA_DISASSOCIATE",
|
||||
"STA_DEAUTH",
|
||||
"RSN_CONF",
|
||||
"KEY_RSC",
|
||||
"STA_STATS",
|
||||
"ROAM_THRESH",
|
||||
"VENDOR_DBG_FLAGS",
|
||||
"CACHE_AGE_THRESH",
|
||||
"PMK_CACHE",
|
||||
"LINK_QUAL_EVENT_PARAMS",
|
||||
"IE",
|
||||
"SCAN_REQ_MULTIPLE",
|
||||
"BTCOEX_MODE",
|
||||
"WOW_TEST",
|
||||
"CLEAR_PMK_CACHE",
|
||||
"SCANCACHE_CLEAR",
|
||||
"P2P_ENABLE",
|
||||
"P2P_LISTEN",
|
||||
"P2P_SCAN",
|
||||
"VIRTUAL_IF_CREATE",
|
||||
"VIRTUAL_IF_DELETE",
|
||||
"VIRTUAL_IF_ROLE",
|
||||
"VIRTUAL_IF_PARENT",
|
||||
"P2P_GO_CONF",
|
||||
"P2P_NOA_LIST",
|
||||
"P2P_OPP_PS",
|
||||
"P2P_CT_WINDOW",
|
||||
"BT_COEX_FLAGS",
|
||||
"CURRENT_NETWORK",
|
||||
"BT_POWER",
|
||||
"AVAILABILITY",
|
||||
"RSSI_BOUNDS",
|
||||
"ROAM",
|
||||
"TX_CHAIN_POWER",
|
||||
"CDD_MODE",
|
||||
"LAST_BCAST_SCAN_TIME",
|
||||
"THERMAL_THROTTLING",
|
||||
"FACTORY_MODE",
|
||||
"REASSOCIATE",
|
||||
"???MISSING???",
|
||||
"POWER_DEBUG_INFO",
|
||||
"AWDL_SYNC_PARAMS",
|
||||
"AWDL_SYNC_ENABLED",
|
||||
"AWDL_EXTENSION_STATE_MACHINE_PARAMETERS",
|
||||
"AWDL_SERVICE_PARAMS",
|
||||
"AWDL_PEER_SERVICE_REQUEST",
|
||||
"AWDL_ELECTION_ALGORITHM_ENABLED",
|
||||
"AWDL_ELECTION_ID",
|
||||
"AWDL_MAX_TREE_DEPTH",
|
||||
"AWDL_GUARD_TIME",
|
||||
"AWDL_BSSID",
|
||||
"AWDL_ELECTION_METRIC",
|
||||
"AWDL_AVAILABILITY_WINDOW_AP_ALIGNMENT",
|
||||
"AWDL_SYNC_FRAME_AP_BEACON_ALIGNMENT",
|
||||
"AWDL_SYNCHRONIZATION_CHANNEL_SEQUENCE",
|
||||
"PEER_CACHE_MAXIMUM_SIZE",
|
||||
"AWDL_OUI",
|
||||
"AWDL_MASTER_CHANNEL",
|
||||
"AWDL_TOP_MASTER",
|
||||
"AWDL_SYNC_STATE",
|
||||
"AWDL_ELECTION_RSSI_THRESHOLDS",
|
||||
"AWDL_PRESENCE_MODE",
|
||||
"AWDL_ELECTION_MASTER_COUNTS",
|
||||
"AWDL_PERIODIC_SYNC_FRAME_PACKET_LIFETIME",
|
||||
"AWDL_MASTER_MODE_SYNC_FRAME_PERIOD",
|
||||
"AWDL_NON_ELECTION_MASTER_MODE_SYNC_FRAME_PERIOD",
|
||||
"AWDL_EXPLICIT_AVAILABILITY_WINDOW_EXTENSION_OPT_OUT",
|
||||
"AWDL_GET_AWDL_MASTER_DATABASE",
|
||||
"PEER_CACHE_CONTROL",
|
||||
"AWDL_BATTERY_LEVEL",
|
||||
"AWDL_BT_COEX_AW_PROTECTED_PERIOD_LENGTH",
|
||||
"AWDL_BT_COEX_AGREEMENT",
|
||||
"AWDL_BT_COEX_AGREEMENT_ENABLED",
|
||||
"AWDL_STRATEGY",
|
||||
"AWDL_OOB_REQUEST",
|
||||
"AWDL_MAX_NO_MASTER_PERIODS",
|
||||
"AWDL_SYNC_FRAME_TEMPLATE",
|
||||
"LOG_FLAGS",
|
||||
"PEER_STATS",
|
||||
"HT_CAPABILITY",
|
||||
"AWDL_ELECTION_PARAMS",
|
||||
"LINK_CHANGED_EVENT_DATA",
|
||||
"GET_DEBUG_INFO",
|
||||
"AWDL_DEVICE_CAPABILITIES",
|
||||
"AWDL_RSSI_MEASUREMENT_REQUEST",
|
||||
"AWDL_AES_KEY",
|
||||
"AWDL_SCAN_RESERVED_TIME",
|
||||
"AWDL_CTL",
|
||||
"AWDL_SOCIAL_TIME_SLOTS",
|
||||
"AWDL_PEER_TRAFFIC_REGISTRATION",
|
||||
"EXTENDED_STATS",
|
||||
"BEACON_PERIOD",
|
||||
"AWDL_FORCED_ROAM_CONFIG",
|
||||
"AWDL_QUIET",
|
||||
"ACL_POLICY",
|
||||
"ACL_ADD",
|
||||
"ACL_REMOVE",
|
||||
"ACL_FLUSH",
|
||||
"ACL_LIST",
|
||||
"CHAIN_ACK",
|
||||
"DESENSE",
|
||||
"OFFLOAD_SCANNING",
|
||||
"OFFLOAD_RSN",
|
||||
"OFFLOAD_COUNTRY_CODE",
|
||||
"OFFLOAD_KEEPALIVE_L2",
|
||||
"OFFLOAD_ARP_NDP",
|
||||
"VHT_MCS_INDEX_SET",
|
||||
"DWDS",
|
||||
"INTERRUPT_STATS",
|
||||
"INTERRUPT_STATS_RESET",
|
||||
"TIMER_STATS",
|
||||
"TIMER_STATS_RESET",
|
||||
"OFFLOAD_STATS",
|
||||
"OFFLOAD_STATS_RESET",
|
||||
"OFFLOAD_BEACONS",
|
||||
"ROAMING",
|
||||
"OFFLOAD_ARP",
|
||||
"OFFLOAD_NDP",
|
||||
"OFFLOAD_SCAN",
|
||||
"DESENSE_LEVEL",
|
||||
"MCS_VHT",
|
||||
"TX_NSS",
|
||||
"GAS_REQ",
|
||||
"GAS_START",
|
||||
"GAS_SET_PEER",
|
||||
"GAS_RESULTS",
|
||||
"AWDL_BTLE_PEER_INDICATION",
|
||||
"AWDL_BTLE_STATE_PARAMS",
|
||||
"AWDL_PEER_DATABASE",
|
||||
"AWDL_BTLE_ENABLE_SYNC_WITH_PARAMS",
|
||||
"AWDL_SECONDARY_MASTER_CHANNEL",
|
||||
"PHY_STATS",
|
||||
"CHANNELS_INFO",
|
||||
"AWDL_AF_TX_MODE",
|
||||
"ERROR_STRING",
|
||||
"ERROR_NO",
|
||||
"AWDL_PIGGYBACK_SCAN_REQ",
|
||||
"AWDL_PRIVATE_ELECTION_ID",
|
||||
"AWDL_MIN_RATE",
|
||||
"VHT_CAPABILITY",
|
||||
"BGSCAN_CACHE_RESULTS",
|
||||
"ROAM_PROFILE",
|
||||
"AWDL_OPER_MODE",
|
||||
"RESTORE_DEFAULTS",
|
||||
"AWDL_ENCRYPTION_KEYS",
|
||||
"AWDL_ENCRYPTION_TYPE",
|
||||
"BTCOEX_PROFILES",
|
||||
"BTCOEX_CONFIG",
|
||||
"AWDL_STATISTICS",
|
||||
"AWDL_ENABLE_ROAMING",
|
||||
"AWDL_OOB_AUTO_REQUEST",
|
||||
"AWDL_TXCAL_PERIOD",
|
||||
"CHIP_COUNTER_STATS",
|
||||
"DBG_GUARD_TIME_PARAMS",
|
||||
"AWDL_AWDL_ADVERTISERS",
|
||||
"LEAKY_AP_STATS_MODE",
|
||||
"CAPTURE",
|
||||
"LEAKY_AP_STATS",
|
||||
"AWDL_BLOCK_SET_COMMANDS",
|
||||
"LEAKY_AP_AWD_MODE",
|
||||
"BTCOEX_OPTIONS",
|
||||
"FORCE_SYNC_TO_PEER",
|
||||
"COUNTRY_CHANNELS",
|
||||
"PRIVATE_MAC",
|
||||
"RESET_CHIP",
|
||||
"CRASH",
|
||||
"RANGING_ENABLE",
|
||||
"RANGING_START",
|
||||
"RANGING_AUTHENTICATE",
|
||||
"AWDL_PREFERRED_CHANNELS",
|
||||
"LEAKY_AP_SSID_STATS",
|
||||
"AWDL_RSDB_CAPS",
|
||||
"AWDL_DEV_STATS",
|
||||
"LAST_ASSOC_HISTORY",
|
||||
"AWDL_COMMON_CHANNEL",
|
||||
"AWDL_PEERS_INFO",
|
||||
"TKO_PARAMS",
|
||||
"TKO_DUMP",
|
||||
"AWDL_NEARBY_LOG_TRIGGER",
|
||||
"HW_SUPPORTED_CHANNELS",
|
||||
"BTCOEX_PROFILE",
|
||||
"BTCOEX_PROFILE_ACTIVE",
|
||||
"TRAP_INFO",
|
||||
"THERMAL_INDEX",
|
||||
"MAX_NSS_FOR_AP",
|
||||
"BTCOEX_2G_CHAIN_DISABLE",
|
||||
"POWER_BUDGET",
|
||||
"AWDL_DFSP_CONFIG",
|
||||
"AWDL_DFSP_UCSA_CONFIG",
|
||||
"SCAN_BACKOFF_REPORT",
|
||||
"OFFLOAD_TCPKA_ENABLE",
|
||||
"RANGING_CAPS",
|
||||
"PER_CORE_RSSI_REPORT",
|
||||
};
|
||||
|
||||
#endif /* debug_h */
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
#ifndef _IOBSD_H
|
||||
#define _IOBSD_H
|
||||
|
||||
/*
|
||||
* bsd-related registry properties
|
||||
*/
|
||||
|
||||
#define kIOBSDKey "IOBSD" // (BSD subsystem resource)
|
||||
#define kIOBSDNameKey "BSD Name" // (an OSString)
|
||||
#define kIOBSDNamesKey "BSD Names" // (an OSDictionary of OSString's, for links)
|
||||
#define kIOBSDMajorKey "BSD Major" // (an OSNumber)
|
||||
#define kIOBSDMinorKey "BSD Minor" // (an OSNumber)
|
||||
#define kIOBSDUnitKey "BSD Unit" // (an OSNumber)
|
||||
|
||||
|
||||
|
||||
#endif /* !_IOBSD_H */
|
||||
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2016 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
#ifndef _IOBUFFERMEMORYDESCRIPTOR_H
|
||||
#define _IOBUFFERMEMORYDESCRIPTOR_H
|
||||
|
||||
#include <IOKit/IOMemoryDescriptor.h>
|
||||
#include <DriverKit/IOBufferMemoryDescriptor.h>
|
||||
|
||||
enum {
|
||||
kIOMemoryPhysicallyContiguous = 0x00000010,
|
||||
kIOMemoryPageable = 0x00000020,
|
||||
kIOMemoryPurgeable = 0x00000040,
|
||||
kIOMemoryHostPhysicallyContiguous = 0x00000080,
|
||||
kIOMemorySharingTypeMask = 0x000f0000,
|
||||
kIOMemoryUnshared = 0x00000000,
|
||||
kIOMemoryKernelUserShared = 0x00010000,
|
||||
// shared IOMemoryDescriptor options for IOBufferMemoryDescriptor:
|
||||
kIOBufferDescriptorMemoryFlags = kIOMemoryDirectionMask
|
||||
| kIOMemoryThreadSafe
|
||||
| kIOMemoryClearEncrypt
|
||||
| kIOMemoryMapperNone
|
||||
| kIOMemoryUseReserve
|
||||
};
|
||||
|
||||
#define _IOBUFFERMEMORYDESCRIPTOR_INTASKWITHOPTIONS_ 1
|
||||
#define _IOBUFFERMEMORYDESCRIPTOR_HOSTPHYSICALLYCONTIGUOUS_ 1
|
||||
#define IOBUFFERMEMORYDESCRIPTOR_SUPPORTS_INTASKWITHOPTIONS_TAGS 1
|
||||
/*!
|
||||
* @class IOBufferMemoryDescriptor
|
||||
* @abstract Provides a simple memory descriptor that allocates its own buffer memory.
|
||||
*/
|
||||
|
||||
class IOBufferMemoryDescriptor : public IOGeneralMemoryDescriptor
|
||||
{
|
||||
OSDeclareDefaultStructorsWithDispatch(IOBufferMemoryDescriptor);
|
||||
|
||||
private:
|
||||
/*! @struct ExpansionData
|
||||
* @discussion This structure will be used to expand the capablilties of this class in the future.
|
||||
*/
|
||||
struct ExpansionData {
|
||||
IOMemoryMap * map;
|
||||
};
|
||||
|
||||
/*! @var reserved
|
||||
* Reserved for future use. (Internal use only) */
|
||||
APPLE_KEXT_WSHADOW_PUSH;
|
||||
ExpansionData * reserved;
|
||||
|
||||
protected:
|
||||
void * _buffer;
|
||||
vm_size_t _capacity;
|
||||
vm_offset_t _alignment;
|
||||
IOOptionBits _options;
|
||||
private:
|
||||
uintptr_t _internalReserved;
|
||||
unsigned _internalFlags;
|
||||
APPLE_KEXT_WSHADOW_POP;
|
||||
|
||||
private:
|
||||
#ifndef __LP64__
|
||||
virtual bool initWithOptions(
|
||||
IOOptionBits options,
|
||||
vm_size_t capacity,
|
||||
vm_offset_t alignment,
|
||||
task_t inTask) APPLE_KEXT_DEPRECATED; /* use withOptions() instead */
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
public:
|
||||
virtual bool initWithPhysicalMask(
|
||||
task_t inTask,
|
||||
IOOptionBits options,
|
||||
mach_vm_size_t capacity,
|
||||
mach_vm_address_t alignment,
|
||||
mach_vm_address_t physicalMask);
|
||||
|
||||
#ifdef __LP64__
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 1);
|
||||
#else /* !__LP64__ */
|
||||
OSMetaClassDeclareReservedUsed(IOBufferMemoryDescriptor, 0);
|
||||
OSMetaClassDeclareReservedUsed(IOBufferMemoryDescriptor, 1);
|
||||
#endif /* !__LP64__ */
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 10);
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 11);
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 12);
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 13);
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 14);
|
||||
OSMetaClassDeclareReservedUnused(IOBufferMemoryDescriptor, 15);
|
||||
|
||||
protected:
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
* withOptions:
|
||||
*
|
||||
* Returns a new IOBufferMemoryDescriptor with a buffer large enough to
|
||||
* hold capacity bytes. The descriptor's length is initially set to the
|
||||
* capacity.
|
||||
*/
|
||||
#ifndef __LP64__
|
||||
virtual bool initWithOptions( IOOptionBits options,
|
||||
vm_size_t capacity,
|
||||
vm_offset_t alignment) APPLE_KEXT_DEPRECATED; /* use withOptions() instead */
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
static IOBufferMemoryDescriptor * withCopy(
|
||||
task_t inTask,
|
||||
IOOptionBits options,
|
||||
vm_map_t sourceMap,
|
||||
mach_vm_address_t source,
|
||||
mach_vm_size_t size);
|
||||
|
||||
static IOBufferMemoryDescriptor * withOptions( IOOptionBits options,
|
||||
vm_size_t capacity,
|
||||
vm_offset_t alignment = 1);
|
||||
|
||||
/*! @function inTaskWithOptions
|
||||
* @abstract Creates a memory buffer with memory descriptor for that buffer.
|
||||
* @discussion Added in Mac OS X 10.2, this method allocates a memory buffer with a given size and alignment in the task's address space specified, and returns a memory descriptor instance representing the memory. It is recommended that memory allocated for I/O or sharing via mapping be created via IOBufferMemoryDescriptor. Options passed with the request specify the kind of memory to be allocated - pageablity and sharing are specified with option bits. This function may block and so should not be called from interrupt level or while a simple lock is held.
|
||||
* @param inTask The task the buffer will be allocated in.
|
||||
* @param options Options for the allocation:<br>
|
||||
* kIODirectionOut, kIODirectionIn - set the direction of the I/O transfer.<br>
|
||||
* kIOMemoryPhysicallyContiguous - pass to request memory be physically contiguous. This option is heavily discouraged. The request may fail if memory is fragmented, may cause large amounts of paging activity, and may take a very long time to execute.<br>
|
||||
* kIOMemoryPageable - pass to request memory be non-wired - the default for kernel allocated memory is wired.<br>
|
||||
* kIOMemoryPurgeable - pass to request memory that may later have its purgeable state set with IOMemoryDescriptor::setPurgeable. Only supported for kIOMemoryPageable allocations.<br>
|
||||
* kIOMemoryKernelUserShared - pass to request memory that will be mapped into both the kernel and client applications.<br>
|
||||
* kIOMapInhibitCache - allocate memory with inhibited cache setting. <br>
|
||||
* kIOMapWriteThruCache - allocate memory with writethru cache setting. <br>
|
||||
* kIOMapCopybackCache - allocate memory with copyback cache setting. <br>
|
||||
* kIOMapWriteCombineCache - allocate memory with writecombined cache setting.
|
||||
* @param capacity The number of bytes to allocate.
|
||||
* @param alignment The minimum required alignment of the buffer in bytes - 1 is the default for no required alignment. For example, pass 256 to get memory allocated at an address with bits 0-7 zero.
|
||||
* @result Returns an instance of class IOBufferMemoryDescriptor to be released by the caller, which will free the memory desriptor and associated buffer. */
|
||||
|
||||
static IOBufferMemoryDescriptor * inTaskWithOptions(
|
||||
task_t inTask,
|
||||
IOOptionBits options,
|
||||
vm_size_t capacity,
|
||||
vm_offset_t alignment = 1);
|
||||
|
||||
/*! @function inTaskWithOptions
|
||||
* @abstract Creates a memory buffer with memory descriptor for that buffer.
|
||||
* @discussion Added in Mac OS X 10.2, this method allocates a memory buffer with a given size and alignment in the task's address space specified, and returns a memory descriptor instance representing the memory. It is recommended that memory allocated for I/O or sharing via mapping be created via IOBufferMemoryDescriptor. Options passed with the request specify the kind of memory to be allocated - pageablity and sharing are specified with option bits. This function may block and so should not be called from interrupt level or while a simple lock is held.
|
||||
* @param inTask The task the buffer will be allocated in.
|
||||
* @param options Options for the allocation:<br>
|
||||
* kIODirectionOut, kIODirectionIn - set the direction of the I/O transfer.<br>
|
||||
* kIOMemoryPhysicallyContiguous - pass to request memory be physically contiguous. This option is heavily discouraged. The request may fail if memory is fragmented, may cause large amounts of paging activity, and may take a very long time to execute.<br>
|
||||
* kIOMemoryPageable - pass to request memory be non-wired - the default for kernel allocated memory is wired.<br>
|
||||
* kIOMemoryPurgeable - pass to request memory that may later have its purgeable state set with IOMemoryDescriptor::setPurgeable. Only supported for kIOMemoryPageable allocations.<br>
|
||||
* kIOMemoryKernelUserShared - pass to request memory that will be mapped into both the kernel and client applications.<br>
|
||||
* kIOMapInhibitCache - allocate memory with inhibited cache setting. <br>
|
||||
* kIOMapWriteThruCache - allocate memory with writethru cache setting. <br>
|
||||
* kIOMapCopybackCache - allocate memory with copyback cache setting. <br>
|
||||
* kIOMapWriteCombineCache - allocate memory with writecombined cache setting.
|
||||
* @param capacity The number of bytes to allocate.
|
||||
* @param alignment The minimum required alignment of the buffer in bytes - 1 is the default for no required alignment. For example, pass 256 to get memory allocated at an address with bits 0-7 zero.
|
||||
* @param kernTag The kernel memory tag
|
||||
* @param userTag The user memory tag
|
||||
* @result Returns an instance of class IOBufferMemoryDescriptor to be released by the caller, which will free the memory desriptor and associated buffer. */
|
||||
|
||||
static IOBufferMemoryDescriptor * inTaskWithOptions(
|
||||
task_t inTask,
|
||||
IOOptionBits options,
|
||||
vm_size_t capacity,
|
||||
vm_offset_t alignment,
|
||||
uint32_t kernTag,
|
||||
uint32_t userTag);
|
||||
|
||||
/*! @function inTaskWithPhysicalMask
|
||||
* @abstract Creates a memory buffer with memory descriptor for that buffer.
|
||||
* @discussion Added in Mac OS X 10.5, this method allocates a memory buffer with a given size and alignment in the task's address space specified, and returns a memory descriptor instance representing the memory. It is recommended that memory allocated for I/O or sharing via mapping be created via IOBufferMemoryDescriptor. Options passed with the request specify the kind of memory to be allocated - pageablity and sharing are specified with option bits. This function may block and so should not be called from interrupt level or while a simple lock is held.
|
||||
* @param inTask The task the buffer will be mapped in. Pass NULL to create memory unmapped in any task (eg. for use as a DMA buffer).
|
||||
* @param options Options for the allocation:<br>
|
||||
* kIODirectionOut, kIODirectionIn - set the direction of the I/O transfer.<br>
|
||||
* kIOMemoryPhysicallyContiguous - pass to request memory be physically contiguous. This option is heavily discouraged. The request may fail if memory is fragmented, may cause large amounts of paging activity, and may take a very long time to execute.<br>
|
||||
* kIOMemoryKernelUserShared - pass to request memory that will be mapped into both the kernel and client applications.<br>
|
||||
* kIOMapInhibitCache - allocate memory with inhibited cache setting. <br>
|
||||
* kIOMapWriteThruCache - allocate memory with writethru cache setting. <br>
|
||||
* kIOMapCopybackCache - allocate memory with copyback cache setting. <br>
|
||||
* kIOMapWriteCombineCache - allocate memory with writecombined cache setting.
|
||||
* @param capacity The number of bytes to allocate.
|
||||
* @param physicalMask The buffer will be allocated with pages such that physical addresses will only have bits set present in physicalMask. For example, pass 0x00000000FFFFFFFFULL for a buffer to be accessed by hardware that has 32 address bits.
|
||||
* @result Returns an instance of class IOBufferMemoryDescriptor to be released by the caller, which will free the memory desriptor and associated buffer. */
|
||||
|
||||
static IOBufferMemoryDescriptor * inTaskWithPhysicalMask(
|
||||
task_t inTask,
|
||||
IOOptionBits options,
|
||||
mach_vm_size_t capacity,
|
||||
mach_vm_address_t physicalMask);
|
||||
|
||||
/*
|
||||
* withCapacity:
|
||||
*
|
||||
* Returns a new IOBufferMemoryDescriptor with a buffer large enough to
|
||||
* hold capacity bytes. The descriptor's length is initially set to the
|
||||
* capacity.
|
||||
*/
|
||||
static IOBufferMemoryDescriptor * withCapacity(
|
||||
vm_size_t capacity,
|
||||
IODirection withDirection,
|
||||
bool withContiguousMemory = false);
|
||||
#ifndef __LP64__
|
||||
virtual bool initWithBytes(const void * bytes,
|
||||
vm_size_t withLength,
|
||||
IODirection withDirection,
|
||||
bool withContiguousMemory = false) APPLE_KEXT_DEPRECATED; /* use withBytes() instead */
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/*
|
||||
* withBytes:
|
||||
*
|
||||
* Returns a new IOBufferMemoryDescriptor preloaded with bytes (copied).
|
||||
* The descriptor's length and capacity are set to the input buffer's size.
|
||||
*/
|
||||
static IOBufferMemoryDescriptor * withBytes(
|
||||
const void * bytes,
|
||||
vm_size_t withLength,
|
||||
IODirection withDirection,
|
||||
bool withContiguousMemory = false);
|
||||
|
||||
/*
|
||||
* setLength:
|
||||
*
|
||||
* Change the buffer length of the memory descriptor. When a new buffer
|
||||
* is created, the initial length of the buffer is set to be the same as
|
||||
* the capacity. The length can be adjusted via setLength for a shorter
|
||||
* transfer (there is no need to create more buffer descriptors when you
|
||||
* can reuse an existing one, even for different transfer sizes). Note
|
||||
* that the specified length must not exceed the capacity of the buffer.
|
||||
*/
|
||||
virtual void setLength(vm_size_t length);
|
||||
|
||||
/*
|
||||
* setDirection:
|
||||
*
|
||||
* Change the direction of the transfer. This method allows one to redirect
|
||||
* the descriptor's transfer direction. This eliminates the need to destroy
|
||||
* and create new buffers when different transfer directions are needed.
|
||||
*/
|
||||
virtual void setDirection(IODirection direction);
|
||||
|
||||
/*
|
||||
* getCapacity:
|
||||
*
|
||||
* Get the buffer capacity
|
||||
*/
|
||||
virtual vm_size_t getCapacity() const;
|
||||
|
||||
/*
|
||||
* getBytesNoCopy:
|
||||
*
|
||||
* Return the virtual address of the beginning of the buffer
|
||||
*/
|
||||
virtual void *getBytesNoCopy();
|
||||
|
||||
/*
|
||||
* getBytesNoCopy:
|
||||
*
|
||||
* Return the virtual address of an offset from the beginning of the buffer
|
||||
*/
|
||||
virtual void *getBytesNoCopy(vm_size_t start, vm_size_t withLength);
|
||||
|
||||
/*
|
||||
* appendBytes:
|
||||
*
|
||||
* Add some data to the end of the buffer. This method automatically
|
||||
* maintains the memory descriptor buffer length. Note that appendBytes
|
||||
* will not copy past the end of the memory descriptor's current capacity.
|
||||
*/
|
||||
virtual bool appendBytes(const void *bytes, vm_size_t withLength);
|
||||
|
||||
#ifndef __LP64__
|
||||
virtual void * getVirtualSegment(IOByteCount offset,
|
||||
IOByteCount * length) APPLE_KEXT_OVERRIDE APPLE_KEXT_DEPRECATED; /* use getBytesNoCopy() instead */
|
||||
#endif /* !__LP64__ */
|
||||
};
|
||||
|
||||
#endif /* !_IOBUFFERMEMORYDESCRIPTOR_H */
|
||||
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1998 Apple Inc. All rights reserved.
|
||||
*
|
||||
* HISTORY
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _IOKIT_IOCATALOGUE_H
|
||||
#define _IOKIT_IOCATALOGUE_H
|
||||
|
||||
#include <libkern/c++/OSObject.h>
|
||||
#include <libkern/c++/OSCollectionIterator.h>
|
||||
#include <libkern/c++/OSArray.h>
|
||||
#include <libkern/c++/OSDictionary.h>
|
||||
#include <IOKit/IOLocks.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <IOKit/IOKitServer.h>
|
||||
|
||||
class IOService;
|
||||
|
||||
extern const OSSymbol * gIOModuleIdentifierKey;
|
||||
extern const OSSymbol * gIOModuleIdentifierKernelKey;
|
||||
|
||||
|
||||
/*!
|
||||
* @class IOCatalogue
|
||||
* @abstract In-kernel database for IOKit driver personalities.
|
||||
* @discussion The IOCatalogue is a database which contains all IOKit driver personalities. IOService uses this resource when matching devices to their associated drivers.
|
||||
*/
|
||||
class IOCatalogue : public OSObject
|
||||
{
|
||||
OSDeclareDefaultStructors(IOCatalogue);
|
||||
|
||||
private:
|
||||
IORWLock * lock;
|
||||
SInt32 generation;
|
||||
OSDictionary * personalities;
|
||||
OSArray * arrayForPersonality(OSDictionary * dict);
|
||||
void addPersonality(OSDictionary * dict);
|
||||
|
||||
public:
|
||||
/*!
|
||||
* @function initialize
|
||||
* @abstract Creates and initializes the database object and poputates it with in-kernel driver personalities.
|
||||
*/
|
||||
static void initialize( void );
|
||||
|
||||
/*!
|
||||
* @function init
|
||||
* @abstract Initializes the database object.
|
||||
* @param initArray The initial array of driver personalities to populate the database.
|
||||
*/
|
||||
bool init( OSArray * initArray );
|
||||
|
||||
/*!
|
||||
* @function free
|
||||
* @abstract Cleans up the database and deallocates memory allocated at initialization. This is never called in normal operation of the system.
|
||||
*/
|
||||
void free( void ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*!
|
||||
* @function findDrivers
|
||||
* @abstract This is the primary entry point for IOService.
|
||||
* @param service The service
|
||||
* @param generationCount Returns a reference to the generation count of the database. The generation count increases only when personalities are added to the database *and* IOService matching has been initiated.
|
||||
* @result Returns an ordered set of driver personalities ranked on probe-scores. The ordered set must be released by the receiver.
|
||||
*/
|
||||
OSOrderedSet * findDrivers( IOService * service, SInt32 * generationCount );
|
||||
|
||||
/*!
|
||||
* @function findDrivers
|
||||
* @abstract A more general purpose interface which allows one to retreive driver personalities based the intersection of the 'matching' dictionary and the personality's own property list.
|
||||
* @param matching A dictionary containing only keys and values which are to be used for matching. For example, a matching dictionary containing 'IOProviderClass'='IOPCIDevice' will return all personalities with an IOProviderClass key and a value of IOPCIDevice.
|
||||
* @param generationCount Returns a reference to the current generation of the database. The generation count increases only when personalities are added to the database *and* IOService matching has been initiated.
|
||||
* @result Returns an ordered set of driver personalities ranked on probe-scores. The ordered set must be released by the receiver.
|
||||
*/
|
||||
OSOrderedSet * findDrivers( OSDictionary * matching, SInt32 * generationCount );
|
||||
|
||||
/*!
|
||||
* @function addDrivers
|
||||
* @abstract Adds an array of driver personalities to the database.
|
||||
* @param array Array of driver personalities to be added to the database.
|
||||
* @param doNubMatching Start matching process after personalities have been added.
|
||||
* @result Returns true if driver personality was added to the database successfully. Failure is due to a memory allocation failure.
|
||||
*/
|
||||
bool addDrivers( OSArray * array, bool doNubMatching = true );
|
||||
|
||||
/*!
|
||||
* @function removeDrivers
|
||||
* @abstract Remove driver personalities from the database based on matching information provided.
|
||||
* @param matching A dictionary whose keys and values are used for matching personalities in the database. For example, a matching dictionary containing a 'IOProviderClass' key with the value 'IOPCIDevice' will remove all personalities which have the key 'IOProviderClass' equal to 'IOPCIDevice'.
|
||||
* @param doNubMatching Start matching process after personalities have been removed. Matching criteria is based on IOProviderClass of those personalities which were removed. This is to allow drivers which haven't been matched to match against NUB's which were blocked by the previous personalities.
|
||||
* @result Returns true if personality was removed successfully. Failure is due to a memory allocation failure.
|
||||
*/
|
||||
bool removeDrivers( OSDictionary * matching, bool doNubMatching = true );
|
||||
|
||||
/*!
|
||||
* @function getGenerationCount
|
||||
* @abstract Get the current generation count of the database.
|
||||
*/
|
||||
SInt32 getGenerationCount( void ) const;
|
||||
|
||||
/*!
|
||||
* @function isModuleLoaded
|
||||
* @abstract Reports if a kernel module has been loaded for a particular personality.
|
||||
* @param driver A driver personality's property list.
|
||||
* @param kextRef A reference to the kext getting loaded.
|
||||
* @result Returns true if the associated kernel module has been loaded into the kernel for a particular driver personality on which it depends.
|
||||
*/
|
||||
bool isModuleLoaded( OSDictionary * driver, OSObject ** kextRef ) const;
|
||||
|
||||
/*!
|
||||
* @function moduleHasLoaded
|
||||
* @abstract Callback function called after a IOKit dependent kernel module is loaded.
|
||||
* @param name Name of the kernel module.
|
||||
*/
|
||||
void moduleHasLoaded( const OSSymbol * name );
|
||||
|
||||
/*!
|
||||
* @function moduleHasLoaded
|
||||
* @abstract Callback function called after a IOKit dependent kernel module is loaded.
|
||||
* @param name Name of the kernel module.
|
||||
*/
|
||||
void moduleHasLoaded( const char * name );
|
||||
|
||||
/*!
|
||||
* @function terminateDrivers
|
||||
* @abstract Terminates all instances of a driver which match the contents of the matching dictionary. Does not unload module.
|
||||
* @param matching A dictionary whose keys and values are used for matching personalities in the database. For example, a matching dictionary containing a 'IOProviderClass' key with the value 'IOPCIDevice' will cause termination for all instances whose personalities have the key 'IOProviderClass' equal to 'IOPCIDevice'.
|
||||
*/
|
||||
IOReturn terminateDrivers( OSDictionary * matching );
|
||||
|
||||
/*!
|
||||
* @function terminateDriversForModule
|
||||
* @abstract Terminates all instances of a driver which depends on a particular module and unloads the module.
|
||||
* @param moduleName Name of the module which is used to determine which driver instances to terminate and unload.
|
||||
* @param unload Flag to cause the actual unloading of the module.
|
||||
*/
|
||||
IOReturn terminateDriversForModule( OSString * moduleName, bool unload = true);
|
||||
|
||||
/*!
|
||||
* @function terminateDriversForModule
|
||||
* @abstract Terminates all instances of a driver which depends on a particular module and unloads the module.
|
||||
* @param moduleName Name of the module which is used to determine which driver instances to terminate and unload.
|
||||
* @param unload Flag to cause the actual unloading of the module.
|
||||
*/
|
||||
IOReturn terminateDriversForModule( const char * moduleName, bool unload = true);
|
||||
|
||||
/*!
|
||||
* @function startMatching
|
||||
* @abstract Restarts IOService matching.
|
||||
* @param identifier All IOService objects with this bundle indentifier are rematched.
|
||||
*/
|
||||
bool startMatching( const OSSymbol * identifier );
|
||||
|
||||
// deprecated, for bin compat
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
bool startMatching( OSDictionary * matching );
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @function reset
|
||||
* @abstract Return the Catalogue to its initial state.
|
||||
* @discussion
|
||||
* Should only be used by kextd just before it sends all kext personalities down during a rescan.
|
||||
*/
|
||||
void reset(void);
|
||||
|
||||
/*!
|
||||
* @function resetAndAddDrivers
|
||||
* @abstract Replace personalities in IOCatalog with those provided.
|
||||
* @discussion
|
||||
* Resets the catalogue with a new set of drivers, preserving matching originals to keep wired memory usage down.
|
||||
*/
|
||||
bool resetAndAddDrivers(OSArray * drivers, bool doNubMatching = true);
|
||||
|
||||
/*!
|
||||
* @function serialize
|
||||
* @abstract Serializes the catalog for transport to the user.
|
||||
* @param s The serializer object.
|
||||
* @result Returns false if unable to serialize database, most likely due to memory shortage.
|
||||
*/
|
||||
virtual bool serialize(OSSerialize * s) const APPLE_KEXT_OVERRIDE;
|
||||
|
||||
bool serializeData(IOOptionBits kind, OSSerialize * s) const;
|
||||
|
||||
/* This stuff is no longer used at all we keep it around for i386
|
||||
* binary compatibility only. Symbols are no longer exported.
|
||||
*/
|
||||
|
||||
private:
|
||||
|
||||
/*!
|
||||
* @function unloadModule
|
||||
* @abstract Unloads the reqested module if no driver instances are currently depending on it.
|
||||
* @param moduleName An OSString containing the name of the module to unload.
|
||||
*/
|
||||
IOReturn unloadModule( OSString * moduleName ) const;
|
||||
|
||||
IOReturn _removeDrivers(OSDictionary * matching);
|
||||
};
|
||||
|
||||
extern const OSSymbol * gIOClassKey;
|
||||
extern const OSSymbol * gIOProbeScoreKey;
|
||||
extern IOCatalogue * gIOCatalogue;
|
||||
|
||||
#endif /* ! _IOKIT_IOCATALOGUE_H */
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* HISTORY
|
||||
*
|
||||
* 2001-01-18 gvdl Made the primary queue pointer public, to be used when
|
||||
* Ownership is clear.
|
||||
* 11/13/2000 CJS Created IOCommand class and implementation
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @header IOCommand
|
||||
* @abstract
|
||||
* This header contains the IOCommand class definition.
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IO_COMMAND_H_
|
||||
#define _IOKIT_IO_COMMAND_H_
|
||||
|
||||
/*
|
||||
* Kernel
|
||||
*/
|
||||
|
||||
#if defined(KERNEL) && defined(__cplusplus)
|
||||
|
||||
#include <kern/queue.h>
|
||||
#include <libkern/c++/OSObject.h>
|
||||
|
||||
/*!
|
||||
* @class IOCommand
|
||||
* @abstract
|
||||
* This class is an abstract class which represents an I/O command.
|
||||
* @discussion
|
||||
* This class is an abstract class which represents an I/O command passed
|
||||
* from a device driver to a controller. All controller commands (e.g. IOATACommand)
|
||||
* should inherit from this class.
|
||||
*/
|
||||
|
||||
class IOCommand : public OSObject
|
||||
{
|
||||
OSDeclareDefaultStructors(IOCommand);
|
||||
|
||||
public:
|
||||
virtual bool init(void) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @var fCommandChain
|
||||
* This variable is used by the current 'owner' to queue the command. During the life cycle of a command it moves through a series of queues. This is the queue pointer for it. Only valid while 'ownership' is clear. For instance a IOCommandPool uses this pointer to maintain its list of free commands. May be manipulated using the kern/queue.h macros */
|
||||
queue_chain_t fCommandChain; /* used to queue commands */
|
||||
};
|
||||
|
||||
#endif /* defined(KERNEL) && defined(__cplusplus) */
|
||||
|
||||
#endif /* _IOKIT_IO_COMMAND_H_ */
|
||||
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*[
|
||||
* 1999-8-10 Godfrey van der Linden(gvdl)
|
||||
* Created.
|
||||
* ]*/
|
||||
/*! @language embedded-c++ */
|
||||
|
||||
#ifndef _IOKIT_IOCOMMANDGATE_H
|
||||
#define _IOKIT_IOCOMMANDGATE_H
|
||||
|
||||
#include <IOKit/IOEventSource.h>
|
||||
|
||||
/*!
|
||||
* @class IOCommandGate : public IOEventSource
|
||||
* @abstract Single-threaded work loop client request mechanism.
|
||||
* @discussion An IOCommandGate instance is an extremely lightweight mechanism
|
||||
* that executes an action on the driver's work loop. Although the code does not
|
||||
* technically execute on the work loop itself, a single-threaded work loop semantic
|
||||
* is maintained for this event source using the work loop gate. The command gate
|
||||
* tests for a potential self dead lock by checking if the runCommand request is
|
||||
* made from the work loop's thread, it doesn't check for a mutual dead lock though
|
||||
* where a pair of work loop's dead lock each other.
|
||||
* <br><br>
|
||||
* The IOCommandGate is a lighter weight version of the IOCommandQueue and
|
||||
* should be used in preference. Generally use a command queue whenever you need a
|
||||
* client to submit a request to a work loop. A typical command gate action would
|
||||
* check if the hardware is active, if so it will add the request to a pending
|
||||
* queue internal to the device or the device's family. Otherwise if the hardware
|
||||
* is inactive then this request can be acted upon immediately.
|
||||
* <br><br>
|
||||
* CAUTION: The runAction, runCommand, and attemptCommand functions cannot be called from an interrupt context.
|
||||
*
|
||||
*/
|
||||
class IOCommandGate : public IOEventSource
|
||||
{
|
||||
OSDeclareDefaultStructors(IOCommandGate);
|
||||
|
||||
public:
|
||||
/*!
|
||||
* @typedef Action
|
||||
* @discussion Type and arguments of callout C function that is used when
|
||||
* a runCommand is executed by a client. Cast to this type when you want a C++
|
||||
* member function to be used. Note the arg1 - arg3 parameters are straight pass
|
||||
* through from the runCommand to the action callout.
|
||||
* @param owner
|
||||
* Target of the function, can be used as a refcon. The owner is set
|
||||
* during initialisation of the IOCommandGate instance. Note if a C++ function
|
||||
* was specified this parameter is implicitly the first paramter in the target
|
||||
* member function's parameter list.
|
||||
* @param arg0 Argument to action from run operation.
|
||||
* @param arg1 Argument to action from run operation.
|
||||
* @param arg2 Argument to action from run operation.
|
||||
* @param arg3 Argument to action from run operation.
|
||||
*/
|
||||
typedef IOReturn (*Action)(OSObject *owner,
|
||||
void *arg0, void *arg1,
|
||||
void *arg2, void *arg3);
|
||||
|
||||
protected:
|
||||
|
||||
/*! @struct ExpansionData
|
||||
* @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
|
||||
*/
|
||||
struct ExpansionData { };
|
||||
|
||||
/*! @var reserved
|
||||
* Reserved for future use. (Internal use only) */
|
||||
APPLE_KEXT_WSHADOW_PUSH;
|
||||
ExpansionData *reserved;
|
||||
APPLE_KEXT_WSHADOW_POP;
|
||||
|
||||
public:
|
||||
/*! @function commandGate
|
||||
* @abstract Factory method to create and initialise an IOCommandGate, See $link init.
|
||||
* @result Returns a pointer to the new command gate if sucessful, 0 otherwise. */
|
||||
static IOCommandGate *commandGate(OSObject *owner, Action action = NULL);
|
||||
|
||||
/*! @function init
|
||||
* @abstract Class initialiser.
|
||||
* @discussion Initialiser for IOCommandGate operates only on newly 'newed'
|
||||
* objects. Shouldn't be used to re-init an existing instance.
|
||||
* @param owner Owner of this, newly created, instance of the IOCommandGate. This argument will be used as the first parameter in the action callout.
|
||||
* @param action
|
||||
* Pointer to a C function that is called whenever a client of the
|
||||
* IOCommandGate calls runCommand. NB Can be a C++ member function but caller
|
||||
* must cast the member function to $link IOCommandGate::Action and they will get a
|
||||
* compiler warning. Defaults to zero, see $link IOEventSource::setAction.
|
||||
* @result True if inherited classes initialise successfully. */
|
||||
virtual bool init(OSObject *owner, Action action = NULL);
|
||||
|
||||
// Superclass overrides
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
virtual void setWorkLoop(IOWorkLoop *inWorkLoop) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function runCommand
|
||||
* @abstract Single thread a command with the target work loop.
|
||||
* @discussion Client function that causes the current action to be called in
|
||||
* a single threaded manner. Beware the work loop's gate is recursive and command
|
||||
* gates can cause direct or indirect re-entrancy. When the executing on a
|
||||
* client's thread runCommand will sleep until the work loop's gate opens for
|
||||
* execution of client actions, the action is single threaded against all other
|
||||
* work loop event sources. If the command is disabled the attempt to run a command will be stalled until enable is called.
|
||||
* @param arg0 Parameter for action of command gate, defaults to 0.
|
||||
* @param arg1 Parameter for action of command gate, defaults to 0.
|
||||
* @param arg2 Parameter for action of command gate, defaults to 0.
|
||||
* @param arg3 Parameter for action of command gate, defaults to 0.
|
||||
* @result kIOReturnSuccess if successful. kIOReturnAborted if a disabled command gate is free()ed before being reenabled, kIOReturnNoResources if no action available.
|
||||
*/
|
||||
virtual IOReturn runCommand(void *arg0 = NULL, void *arg1 = NULL,
|
||||
void *arg2 = NULL, void *arg3 = NULL);
|
||||
|
||||
/*! @function runAction
|
||||
* @abstract Single thread a call to an action with the target work loop.
|
||||
* @discussion Client function that causes the given action to be called in
|
||||
* a single threaded manner. Beware the work loop's gate is recursive and command
|
||||
* gates can cause direct or indirect re-entrancy. When the executing on a
|
||||
* client's thread runAction will sleep until the work loop's gate opens for
|
||||
* execution of client actions, the action is single threaded against all other
|
||||
* work loop event sources. If the command is disabled the attempt to run a command will be stalled until enable is called.
|
||||
* @param action Pointer to function to be executed in the context of the work loop.
|
||||
* @param arg0 Parameter for action parameter, defaults to 0.
|
||||
* @param arg1 Parameter for action parameter, defaults to 0.
|
||||
* @param arg2 Parameter for action parameter, defaults to 0.
|
||||
* @param arg3 Parameter for action parameter, defaults to 0.
|
||||
* @result The return value of action if it was called, kIOReturnBadArgument if action is not defined, kIOReturnAborted if a disabled command gate is free()ed before being reenabled.
|
||||
*/
|
||||
virtual IOReturn runAction(Action action,
|
||||
void *arg0 = NULL, void *arg1 = NULL,
|
||||
void *arg2 = NULL, void *arg3 = NULL);
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
/*! @function runActionBlock
|
||||
* @abstract Single thread a call to an action with the target work loop.
|
||||
* @discussion Client function that causes the given action to be called in
|
||||
* a single threaded manner. Beware the work loop's gate is recursive and command
|
||||
* gates can cause direct or indirect re-entrancy. When the executing on a
|
||||
* client's thread runAction will sleep until the work loop's gate opens for
|
||||
* execution of client actions, the action is single threaded against all other
|
||||
* work loop event sources. If the command is disabled the attempt to run a command will be stalled until enable is called.
|
||||
* @param action Block to be executed in the context of the work loop.
|
||||
* @result The return value of action if it was called, kIOReturnBadArgument if action is not defined, kIOReturnAborted if a disabled command gate is free()ed before being reenabled.
|
||||
*/
|
||||
IOReturn runActionBlock(ActionBlock action);
|
||||
#endif /* __BLOCKS__ */
|
||||
|
||||
/*! @function attemptCommand
|
||||
* @abstract Single thread a command with the target work loop.
|
||||
* @discussion Client function that causes the current action to be called in
|
||||
* a single threaded manner. When the executing on a client's thread attemptCommand will fail if the work loop's gate is closed.
|
||||
* @param arg0 Parameter for action of command gate, defaults to 0.
|
||||
* @param arg1 Parameter for action of command gate, defaults to 0.
|
||||
* @param arg2 Parameter for action of command gate, defaults to 0.
|
||||
* @param arg3 Parameter for action of command gate, defaults to 0.
|
||||
* @result kIOReturnSuccess if successful. kIOReturnNotPermitted if this event source is currently disabled, kIOReturnNoResources if no action available, kIOReturnCannotLock if lock attempt fails.
|
||||
*/
|
||||
virtual IOReturn attemptCommand(void *arg0 = NULL, void *arg1 = NULL,
|
||||
void *arg2 = NULL, void *arg3 = NULL);
|
||||
|
||||
/*! @function attemptAction
|
||||
* @abstract Single thread a call to an action with the target work loop.
|
||||
* @discussion Client function that causes the given action to be called in
|
||||
* a single threaded manner. Beware the work loop's gate is recursive and command
|
||||
* gates can cause direct or indirect re-entrancy. When the executing on a
|
||||
* client's thread attemptCommand will fail if the work loop's gate is closed.
|
||||
* @param action Pointer to function to be executed in context of the work loop.
|
||||
* @param arg0 Parameter for action parameter, defaults to 0.
|
||||
* @param arg1 Parameter for action parameter, defaults to 0.
|
||||
* @param arg2 Parameter for action parameter, defaults to 0.
|
||||
* @param arg3 Parameter for action parameter, defaults to 0.
|
||||
* @result kIOReturnSuccess if successful. kIOReturnBadArgument if action is not defined, kIOReturnNotPermitted if this event source is currently disabled, kIOReturnCannotLock if lock attempt fails.
|
||||
*
|
||||
*/
|
||||
virtual IOReturn attemptAction(Action action,
|
||||
void *arg0 = NULL, void *arg1 = NULL,
|
||||
void *arg2 = NULL, void *arg3 = NULL);
|
||||
|
||||
/*! @function commandSleep
|
||||
* @abstract Put a thread that is currently holding the command gate to sleep.
|
||||
* @discussion Put a thread to sleep waiting for an event but release the gate first. If the event occurs then the commandGate is closed before the function returns. If the thread does not hold the gate, panic.
|
||||
* @param event Pointer to an address.
|
||||
* @param interruptible THREAD_UNINT, THREAD_INTERRUPTIBLE or THREAD_ABORTSAFE. THREAD_UNINT specifies that the sleep cannot be interrupted by a signal. THREAD_INTERRUPTIBLE specifies that the sleep may be interrupted by a "kill -9" signal. THREAD_ABORTSAFE (the default value) specifies that the sleep may be interrupted by any user signal.
|
||||
* @result THREAD_AWAKENED - normal wakeup, THREAD_TIMED_OUT - timeout expired, THREAD_INTERRUPTED - interrupted, THREAD_RESTART - restart operation entirely. */
|
||||
virtual IOReturn commandSleep(void *event,
|
||||
UInt32 interruptible = THREAD_ABORTSAFE);
|
||||
|
||||
/*! @function commandWakeup
|
||||
* @abstract Wakeup one or more threads that are asleep on an event.
|
||||
* @param event Pointer to an address.
|
||||
* @param oneThread true to only wake up at most one thread, false otherwise. */
|
||||
virtual void commandWakeup(void *event, bool oneThread = false);
|
||||
|
||||
/*! @function disable
|
||||
* @abstract Disable the command gate
|
||||
* @discussion When a command gate is disabled all future calls to runAction and runCommand will stall until the gate is enable()d later. This can be used to block client threads when a system sleep is requested. The IOWorkLoop thread itself will never stall, even when making runAction/runCommand calls. This call must be made from a gated context, to clear potential race conditions. */
|
||||
virtual void disable() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function enable
|
||||
* @abstract Enable command gate, this will unblock any blocked Commands and Actions.
|
||||
* @discussion Enable the command gate. The attemptAction/attemptCommand calls will now be enabled and can succeeed. Stalled runCommand/runAction calls will be woken up. */
|
||||
virtual void enable() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function commandSleep
|
||||
* @abstract Put a thread that is currently holding the command gate to sleep.
|
||||
* @discussion Put a thread to sleep waiting for an event but release the gate first. If the event occurs or timeout occurs then the commandGate is closed before the function returns. If the thread does not hold the gate, panic.
|
||||
* @param event Pointer to an address.
|
||||
* @param deadline Clock deadline to timeout the sleep.
|
||||
* @param interruptible THREAD_UNINT, THREAD_INTERRUPTIBLE or THREAD_ABORTSAFE. THREAD_UNINT specifies that the sleep cannot be interrupted by a signal. THREAD_INTERRUPTIBLE specifies that the sleep may be interrupted by a "kill -9" signal. THREAD_ABORTSAFE specifies that the sleep may be interrupted by any user signal.
|
||||
* @result THREAD_AWAKENED - normal wakeup, THREAD_TIMED_OUT - timeout expired, THREAD_INTERRUPTED - interrupted, THREAD_RESTART - restart operation entirely. */
|
||||
virtual IOReturn commandSleep(void *event,
|
||||
AbsoluteTime deadline,
|
||||
UInt32 interruptible);
|
||||
|
||||
private:
|
||||
#if __LP64__
|
||||
OSMetaClassDeclareReservedUnused(IOCommandGate, 0);
|
||||
#else
|
||||
OSMetaClassDeclareReservedUsed(IOCommandGate, 0);
|
||||
#endif
|
||||
OSMetaClassDeclareReservedUnused(IOCommandGate, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOCommandGate, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOCommandGate, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOCommandGate, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOCommandGate, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOCommandGate, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOCommandGate, 7);
|
||||
};
|
||||
|
||||
#endif /* !_IOKIT_IOCOMMANDGATE_H */
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* HISTORY
|
||||
*
|
||||
* 2001-01-17 gvdl Re-implement on IOCommandGate::commandSleep
|
||||
* 11/13/2000 CJS Created IOCommandPool class and implementation
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @header IOCommandPool
|
||||
* @abstract
|
||||
* This header contains the IOCommandPool class definition.
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IO_COMMAND_POOL_H_
|
||||
#define _IOKIT_IO_COMMAND_POOL_H_
|
||||
|
||||
/*
|
||||
* Kernel
|
||||
*/
|
||||
|
||||
#if defined(KERNEL) && defined(__cplusplus)
|
||||
|
||||
#include <kern/kern_types.h>
|
||||
#include <kern/queue.h>
|
||||
#include <IOKit/IOCommand.h>
|
||||
#include <IOKit/IOCommandGate.h>
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/IOWorkLoop.h>
|
||||
|
||||
/*!
|
||||
* @class IOCommandPool
|
||||
* @abstract Manipulates a pool of commands which inherit from IOCommand.
|
||||
* @discussion
|
||||
* The IOCommandPool class is used to manipulate a pool of commands which
|
||||
* inherit from IOCommand. It includes a factory method to create a pool
|
||||
* of a certain size. Once the factory method is invoked, the semaphore
|
||||
* is set to zero. The caller must then put commands in the pool by creating
|
||||
* the command (via the controller's factory method or a memory allocation)
|
||||
* and calling the returnCommand method with the newly created command as its
|
||||
* argument.
|
||||
*/
|
||||
|
||||
class IOCommandPool : public OSObject
|
||||
{
|
||||
OSDeclareDefaultStructors(IOCommandPool);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
queue_head_t fQueueHead; /* head of the queue of elements available */
|
||||
UInt32 fSleepers; /* Count of threads sleeping on this pool */
|
||||
IOCommandGate *fSerializer; /* command gate used for serializing pool access */
|
||||
|
||||
/*! @struct ExpansionData
|
||||
* @discussion This structure will be used to expand the capablilties of the IOEventSource in the future.
|
||||
*/
|
||||
struct ExpansionData { };
|
||||
|
||||
/*! @var reserved
|
||||
* Reserved for future use. (Internal use only) */
|
||||
ExpansionData *reserved;
|
||||
|
||||
/*!
|
||||
* @const kIOCommandPoolDefaultSize
|
||||
* @abstract The default size of any command pool.
|
||||
* @discussion
|
||||
* kIOCommandPoolDefaultSize is the default size of any command pool.
|
||||
* The default size was determined to be the smallest size for which
|
||||
* a pool makes sense.
|
||||
*/
|
||||
|
||||
static const UInt32 kIOCommandPoolDefaultSize = 2;
|
||||
|
||||
/*
|
||||
* Free all of this object's outstanding resources.
|
||||
*/
|
||||
|
||||
virtual void free(void) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* @function initWithWorkLoop
|
||||
* @abstract Primary initializer for an IOCommandPool object.
|
||||
* @discussion Primary initializer for an IOCommandPool.
|
||||
* Should probably use IOCommandPool::withWorkLoop() as it is easier to use.
|
||||
* @param workLoop
|
||||
* The workloop that this command pool should synchronize with.
|
||||
* @result Returns true if command pool was successfully initialized.
|
||||
*/
|
||||
virtual bool initWithWorkLoop(IOWorkLoop *workLoop);
|
||||
|
||||
/*!
|
||||
* @function withWorkLoop
|
||||
* @abstract Primary factory method for the IOCommandPool class
|
||||
* @discussion
|
||||
* The withWorkLoop method is what is known as a factory method. It creates
|
||||
* a new instance of an IOCommandPool and returns a pointer to that object.
|
||||
* @param inWorkLoop
|
||||
* The workloop that this command pool should synchronize with.
|
||||
* @result
|
||||
* Returns a pointer to an instance of IOCommandPool if successful,
|
||||
* otherwise NULL.
|
||||
*/
|
||||
|
||||
static IOCommandPool *withWorkLoop(IOWorkLoop *inWorkLoop);
|
||||
|
||||
/*!
|
||||
* @function init
|
||||
* @abstract Should never be used, obsolete. See initWithWorkLoop.
|
||||
*/
|
||||
virtual bool init(IOService *inOwner,
|
||||
IOWorkLoop *inWorkLoop,
|
||||
UInt32 inSize = kIOCommandPoolDefaultSize);
|
||||
|
||||
/*!
|
||||
* @function withWorkLoop
|
||||
* @abstract Should never be used, obsolete. See IOCommandPool::withWorkLoop.
|
||||
*/
|
||||
static IOCommandPool *commandPool(IOService *inOwner,
|
||||
IOWorkLoop *inWorkLoop,
|
||||
UInt32 inSize = kIOCommandPoolDefaultSize);
|
||||
|
||||
|
||||
/*!
|
||||
* @function getCommand
|
||||
* @discussion The getCommand method is used to get a pointer to an object of type IOCommand from the pool.
|
||||
* @param blockForCommand
|
||||
* If the caller would like to have its thread slept until a command is
|
||||
* available, it should pass true, else false.
|
||||
* @result
|
||||
* If the caller passes true in blockForCommand, getCommand guarantees that
|
||||
* the result will be a pointer to an IOCommand object from the pool. If
|
||||
* the caller passes false, s/he is responsible for checking whether a non-NULL
|
||||
* pointer was returned.
|
||||
*/
|
||||
|
||||
virtual IOCommand *getCommand(bool blockForCommand = true);
|
||||
|
||||
/*!
|
||||
* @function returnCommand
|
||||
* @discussion
|
||||
* The returnCommand method is used to place an object of type IOCommand
|
||||
* into the pool, whether it be the first time, or the 1000th time.
|
||||
* @param command
|
||||
* The command to place in the pool.
|
||||
*/
|
||||
|
||||
virtual void returnCommand(IOCommand *command);
|
||||
|
||||
protected:
|
||||
|
||||
/*!
|
||||
* @function gatedGetCommand
|
||||
* @discussion
|
||||
* The gatedGetCommand method is used to serialize the extraction of a
|
||||
* command from the pool behind a command gate, runAction-ed by getCommand.
|
||||
* @param command
|
||||
* A pointer to a pointer to an IOCommand object where the returned
|
||||
* command will be stored.
|
||||
* @param blockForCommand
|
||||
* A bool that indicates whether to block the request until a command
|
||||
* becomes available.
|
||||
* @result
|
||||
* Returns kIOReturnNoResources if no command is available and the client
|
||||
* doesn't wish to block until one does become available.
|
||||
* kIOReturnSuccess if the vCommand argument is valid.
|
||||
*/
|
||||
virtual IOReturn gatedGetCommand(
|
||||
LIBKERN_RETURNS_NOT_RETAINED IOCommand **command, bool blockForCommand);
|
||||
|
||||
/*!
|
||||
* @function gatedReturnCommand
|
||||
* @discussion
|
||||
* The gatedReturnCommand method is used to serialize the return of a
|
||||
* command to the pool behind a command gate, runAction-ed by returnCommand.
|
||||
* @param command
|
||||
* A pointer to the IOCommand object to be returned to the pool.
|
||||
* @result
|
||||
* Always returns kIOReturnSuccess if the vCommand argument is valid.
|
||||
*/
|
||||
virtual IOReturn gatedReturnCommand(IOCommand *command);
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUnused(IOCommandPool, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOCommandPool, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOCommandPool, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOCommandPool, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOCommandPool, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOCommandPool, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOCommandPool, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOCommandPool, 7);
|
||||
};
|
||||
|
||||
#endif /* defined(KERNEL) && defined(__cplusplus) */
|
||||
|
||||
#endif /* _IOKIT_IO_COMMAND_POOL_H_ */
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
|
||||
* Copyright (c) 1994-1996 NeXT Software, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IOCONDITIONLOCK_H
|
||||
#define _IOKIT_IOCONDITIONLOCK_H
|
||||
|
||||
#include <libkern/c++/OSObject.h>
|
||||
#include <IOKit/IOLib.h>
|
||||
#include <IOKit/system.h>
|
||||
|
||||
#include <IOKit/IOLocks.h>
|
||||
|
||||
class IOConditionLock : public OSObject
|
||||
{
|
||||
OSDeclareDefaultStructors(IOConditionLock);
|
||||
|
||||
private:
|
||||
IOLock * cond_interlock; // condition var Simple lock
|
||||
volatile int condition;
|
||||
|
||||
IOLock * sleep_interlock; // sleep lock Simple lock
|
||||
unsigned char interruptible;
|
||||
volatile bool want_lock;
|
||||
volatile bool waiting;
|
||||
|
||||
public:
|
||||
static IOConditionLock *withCondition(int condition, bool inIntr = true);
|
||||
virtual bool initWithCondition(int condition, bool inIntr = true);
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual bool tryLock(); // acquire lock, no waiting
|
||||
virtual int lock(); // acquire lock (enter critical section)
|
||||
virtual void unlock(); // release lock (leave critical section)
|
||||
|
||||
virtual bool getInterruptible() const;
|
||||
virtual int getCondition() const;
|
||||
virtual int setCondition(int condition);
|
||||
|
||||
virtual int lockWhen(int condition);// acquire lock when condition
|
||||
virtual void unlockWith(int condition); // set condition & release lock
|
||||
};
|
||||
|
||||
#endif /* _IOKIT_IOCONDITIONLOCK_H */
|
||||
@@ -0,0 +1,649 @@
|
||||
/*
|
||||
* Copyright (c) 2005-2016 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
#ifndef _IODMACOMMAND_H
|
||||
#define _IODMACOMMAND_H
|
||||
|
||||
#include <IOKit/IOCommand.h>
|
||||
#include <IOKit/IOMemoryDescriptor.h>
|
||||
#include <DriverKit/IODMACommand.h>
|
||||
class IOMapper;
|
||||
class IOBufferMemoryDescriptor;
|
||||
|
||||
enum{
|
||||
kIODMAMapOptionMapped = 0x00000000,
|
||||
kIODMAMapOptionBypassed = 0x00000001,
|
||||
kIODMAMapOptionNonCoherent = 0x00000002,
|
||||
kIODMAMapOptionUnmapped = 0x00000003,
|
||||
kIODMAMapOptionTypeMask = 0x0000000f,
|
||||
|
||||
kIODMAMapOptionNoCacheStore = 0x00000010, // Memory in descriptor
|
||||
kIODMAMapOptionOnChip = 0x00000020,// Indicates DMA is on South Bridge
|
||||
kIODMAMapOptionIterateOnly = 0x00000040// DMACommand will be used as a cursor only
|
||||
};
|
||||
|
||||
/**************************** class IODMACommand ***************************/
|
||||
|
||||
/*!
|
||||
* @class IODMACommand
|
||||
* @abstract A mechanism to convert memory references to I/O bus addresses.
|
||||
* @discussion The IODMACommand is supersedes the IOMemoryCursor and greatly enhances the functionality and power of it. The command can be specified to output 64 bit physical addresses and also allows driver writers bypass mapping hardware or get addresses suitable for non-snooped DMA.
|
||||
* <br><br>
|
||||
* The command is designed to be very easily subclassable. Most driver writers need to associate some DMA operations with their memory descriptor and usually use a C structure for that purpose. This structure is often kept in a linked list. This IODMACommand has built it <kern/queue.h> linkage and can be derived and 'public:' variables added, giving the developer a structure that can associate a memory descriptor with a particular dma command but will also allow the developer to generate that command and keep the state necessary for tracking it.
|
||||
* <br><br>
|
||||
* It is envisaged that a pool of IODMACommands will be created at driver initialisation and each command will be kept in an IOCommandPool while not in use. However if developers wishes to maintain their own free lists that is certainly possible. See the <kern/queue.h> and <xnu/iokit/Kernel/IOCommandPool> for sample code on manipulating the command's doubly linked list entries.
|
||||
* <br><br>
|
||||
* The IODMACommand can be used in a 'weak-linked' manner. To do this you must avoid using any static member functions. Use the, much slower but safe, weakWithSpecification function. On success a dma command instance will be returned. This instance can then be used to clone as many commands as is needed. Remember deriving from this class can not be done weakly, that is no weak subclassing!
|
||||
*/
|
||||
|
||||
class IODMACommand : public IOCommand
|
||||
{
|
||||
OSDeclareDefaultStructorsWithDispatch(IODMACommand);
|
||||
|
||||
friend class IODMAEventSource;
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* @typedef Segment32
|
||||
* @discussion A 32 bit I/O bus address/length pair
|
||||
*/
|
||||
struct Segment32 {
|
||||
UInt32 fIOVMAddr, fLength;
|
||||
};
|
||||
|
||||
/*!
|
||||
* @typedef Segment64
|
||||
* @discussion A 64 bit I/O bus address/length pair
|
||||
*/
|
||||
struct Segment64 {
|
||||
UInt64 fIOVMAddr, fLength;
|
||||
};
|
||||
|
||||
/*! @enum MappingOptions
|
||||
* @abstract Mapping types to indicate the desired mapper type for translating memory descriptors into I/O DMA Bus addresses.
|
||||
* @constant kNonCoherent Used by drivers for non-coherent transfers, implies unmapped memmory
|
||||
* @constant kMapped Allow a driver to define addressing size
|
||||
* @constant kBypassed Allow drivers to bypass any mapper
|
||||
* @constant kMaxMappingOptions Internal use only
|
||||
*/
|
||||
enum MappingOptions {
|
||||
kMapped = kIODMAMapOptionMapped,
|
||||
kBypassed = kIODMAMapOptionBypassed,
|
||||
kNonCoherent = kIODMAMapOptionNonCoherent,
|
||||
kUnmapped = kIODMAMapOptionUnmapped,
|
||||
kTypeMask = kIODMAMapOptionTypeMask,
|
||||
|
||||
kNoCacheStore = kIODMAMapOptionNoCacheStore, // Memory in descriptor
|
||||
kOnChip = kIODMAMapOptionOnChip, // Indicates DMA is on South Bridge
|
||||
kIterateOnly = kIODMAMapOptionIterateOnly// DMACommand will be used as a cursor only
|
||||
};
|
||||
|
||||
struct SegmentOptions {
|
||||
uint8_t fStructSize;
|
||||
uint8_t fNumAddressBits;
|
||||
uint64_t fMaxSegmentSize;
|
||||
uint64_t fMaxTransferSize;
|
||||
uint32_t fAlignment;
|
||||
uint32_t fAlignmentLength;
|
||||
uint32_t fAlignmentInternalSegments;
|
||||
};
|
||||
|
||||
/*! @enum SynchronizeOptions
|
||||
* @abstract Options for the synchronize method.
|
||||
* @constant kForceDoubleBuffer Copy the entire prepared range to a new page aligned buffer.
|
||||
*/
|
||||
enum SynchronizeOptions {
|
||||
kForceDoubleBuffer = 0x01000000
|
||||
};
|
||||
|
||||
/*!
|
||||
* @typedef SegmentFunction
|
||||
* @discussion Pointer to a C function that translates a 64 segment and outputs a single desired segment to the array at the requested index. There are a group of pre-implemented SegmentFunctions that may be usefull to the developer below.
|
||||
* @param segment The 64Bit I/O bus address and length.
|
||||
* @param segments Base of the output vector of DMA address length pairs.
|
||||
* @param segmentIndex Index to output 'segment' in the 'segments' array.
|
||||
* @result Returns true if segment encoding succeeded. false may be returned if the current segment does not fit in an output segment, i.e. a 38bit address wont fit into a 32 encoding.
|
||||
*/
|
||||
typedef bool (*SegmentFunction)(IODMACommand *target,
|
||||
Segment64 segment,
|
||||
void *segments,
|
||||
UInt32 segmentIndex);
|
||||
|
||||
// -------------- Preimplemented output functions ----------------
|
||||
|
||||
/*! @function OutputHost32
|
||||
* @abstract Output host natural Segment32 output segment function.
|
||||
*/
|
||||
static bool OutputHost32(IODMACommand *target,
|
||||
Segment64 seg, void *segs, UInt32 ind);
|
||||
|
||||
/*! @defined kIODMACommandOutputHost32
|
||||
* @abstract Output host natural Segment32 output segment function.
|
||||
*/
|
||||
#define kIODMACommandOutputHost32 (IODMACommand::OutputHost32)
|
||||
|
||||
/*! @function OutputBig32
|
||||
* @abstract Output big-endian Segment32 output segment function.
|
||||
*/
|
||||
static bool OutputBig32(IODMACommand *target,
|
||||
Segment64 seg, void *segs, UInt32 ind);
|
||||
|
||||
/*! @defined kIODMACommandOutputBig32
|
||||
* @abstract Output big-endian Segment32 output segment function.
|
||||
*/
|
||||
#define kIODMACommandOutputBig32 (IODMACommand::OutputBig32)
|
||||
|
||||
/*! @function OutputLittle32
|
||||
* @abstract Output little-endian Segment32 output segment function.
|
||||
*/
|
||||
static bool OutputLittle32(IODMACommand *target,
|
||||
Segment64 seg, void *segs, UInt32 ind);
|
||||
|
||||
/*! @defined kIODMACommandOutputLittle32
|
||||
* @abstract Output little-endian Segment32 output segment function.
|
||||
*/
|
||||
#define kIODMACommandOutputLittle32 (IODMACommand::OutputLittle32)
|
||||
|
||||
/*! @function OutputHost64
|
||||
* @abstract Output host natural Segment64 output segment function.
|
||||
*/
|
||||
static bool OutputHost64(IODMACommand *target,
|
||||
Segment64 seg, void *segs, UInt32 ind);
|
||||
|
||||
/*! @defined kIODMACommandOutputHost64
|
||||
* @abstract Output host natural Segment64 output segment function.
|
||||
*/
|
||||
#define kIODMACommandOutputHost64 (IODMACommand::OutputHost64)
|
||||
|
||||
/*! @function OutputBig64
|
||||
* @abstract Output big-endian Segment64 output segment function.
|
||||
*/
|
||||
static bool OutputBig64(IODMACommand *target,
|
||||
Segment64 seg, void *segs, UInt32 ind);
|
||||
|
||||
/*! @defined kIODMACommandOutputBig64
|
||||
* @abstract Output big-endian Segment64 output segment function.
|
||||
*/
|
||||
#define kIODMACommandOutputBig64 (IODMACommand::OutputBig64)
|
||||
|
||||
/*! @function OutputLittle64
|
||||
* @abstract Output little-endian Segment64 output segment function.
|
||||
*/
|
||||
static bool OutputLittle64(IODMACommand *target,
|
||||
Segment64 seg, void *segs, UInt32 ind);
|
||||
|
||||
/*! @defined kIODMACommandOutputLittle64
|
||||
* @abstract Output little-endian Segment64 output segment function.
|
||||
*/
|
||||
#define kIODMACommandOutputLittle64 (IODMACommand::OutputLittle64)
|
||||
|
||||
/*! @function withSpecification
|
||||
* @abstract Creates and initializes an IODMACommand in one operation.
|
||||
* @discussion Factory function to create and initialize an IODMACommand in one operation.
|
||||
* @param outSegFunc SegmentFunction to call to output one physical segment. A set of nine commonly required segment functions are provided.
|
||||
* @param numAddressBits Number of bits that the hardware uses on its internal address bus. Typically 32 but may be more on modern hardware. A 0 implies no-restriction other than that implied by the output segment function.
|
||||
* @param maxSegmentSize Maximum allowable size for one segment. If 0 is passed the maximum segment size is unlimited.
|
||||
* @param mappingOptions is the type of mapping that is required to translate an IOMemoryDescriptor into the desired number of bits. For instance if your hardware only supports 32 bits but must run on machines with > 4G of RAM some mapping will be required. Number of bits will be specified in numAddressBits, see below.This parameter can take 3 values:- kNonCoherent - used for non-coherent hardware transfers, Mapped - Validate that all I/O bus generated addresses are within the number of addressing bits specified, Bypassed indicates that bypassed addressing is required, this is used when the hardware transferes are into coherent memory but no mapping is required. See also prepare() for failure cases.
|
||||
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
|
||||
* @param alignment Alignment restriction, in bytes, on I/O bus addresses. Defaults to single byte alignment.
|
||||
* @param mapper For mapping types kMapped & kBypassed mapper is used to define the hardware that will perform the mapping, defaults to the system mapper.
|
||||
* @param refCon Reference Constant
|
||||
* @result Returns a new IODMACommand if successfully created and initialized, 0 otherwise.
|
||||
*/
|
||||
static IODMACommand *
|
||||
withSpecification(SegmentFunction outSegFunc,
|
||||
UInt8 numAddressBits,
|
||||
UInt64 maxSegmentSize,
|
||||
MappingOptions mappingOptions = kMapped,
|
||||
UInt64 maxTransferSize = 0,
|
||||
UInt32 alignment = 1,
|
||||
IOMapper *mapper = NULL,
|
||||
void *refCon = NULL);
|
||||
|
||||
/*! @function weakWithSpecification
|
||||
* @abstract Creates and initialises an IODMACommand in one operation if this version of the operating system supports it.
|
||||
* @discussion Factory function to create and initialise an IODMACommand in one operation. The function allows a developer to 'weak' link with IODMACommand. This function will return kIOReturnUnsupported if the IODMACommand is unavailable. This function is actually fairly slow so it will be better to call it once then clone the successfully create command using cloneCommand (q.v.).
|
||||
* @param newCommand Output reference variable of the newly created IODMACommand.
|
||||
* @param outSegFunc SegmentFunction to call to output one physical segment. A set of nine commonly required segment functions are provided.
|
||||
* @param numAddressBits Number of bits that the hardware uses on its internal address bus. Typically 32 but may be more on modern hardware. A 0 implies no-restriction other than that implied by the output segment function.
|
||||
* @param maxSegmentSize Maximum allowable size for one segment. Zero is treated as an unlimited segment size.
|
||||
* @param mapType is the type of mapping that is required to translate an IOMemoryDescriptor into the desired number of bits. For instance if your hardware only supports 32 bits but must run on machines with > 4G of RAM some mapping will be required. Number of bits will be specified in numAddressBits, see below. This parameter can take 3 values:- kNonCoherent - used for non-coherent hardware transfers, Mapped - Validate that all I/O bus generated addresses are within the number of addressing bits specified, Bypassed indicates that bypassed addressing is required, this is used when the hardware transfers are into coherent memory but no mapping is required. See also prepare() for failure cases.
|
||||
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
|
||||
* @param alignment Alignment restriction, in bytes, on I/O bus addresses. Defaults to single byte alignment.
|
||||
* @param mapper For mapping types kMapped & kBypassed mapper is used to define the hardware that will perform the mapping, defaults to the system mapper.
|
||||
* @param refCon Reference Constant
|
||||
* @result kIOReturnSuccess if everything is OK, otherwise kIOReturnBadArgument if newCommand is NULL, kIOReturnUnsupported if the kernel doesn't export IODMACommand or IOReturnError if the new command fails to init, q.v. initWithSpecification.
|
||||
*/
|
||||
// Note that the function has the attribute always_inline.
|
||||
// The point of this function is to make a call into the kernel
|
||||
// without generating an undefined symbol. If the client could call
|
||||
// the code as a function then the goal of no undefined symbols
|
||||
// would be lost thus defeating the purpose.
|
||||
static inline IOReturn weakWithSpecification
|
||||
(IODMACommand **newCommand,
|
||||
SegmentFunction outSegFunc,
|
||||
UInt8 numAddressBits,
|
||||
UInt64 maxSegmentSize,
|
||||
MappingOptions mapType = kMapped,
|
||||
UInt64 maxTransferSize = 0,
|
||||
UInt32 alignment = 1,
|
||||
IOMapper *mapper = NULL,
|
||||
void *refCon = NULL) __attribute__((always_inline));
|
||||
|
||||
static IODMACommand *
|
||||
withSpecification(SegmentFunction outSegFunc,
|
||||
const SegmentOptions * segmentOptions,
|
||||
uint32_t mappingOptions,
|
||||
IOMapper * mapper,
|
||||
void * refCon);
|
||||
|
||||
|
||||
/*! @function withRefCon
|
||||
* @abstract Creates and initializes an unspecified IODMACommand.
|
||||
* @discussion Factory function to create and initialize an unspecified IODMACommand. prepareWithSpecification() must be used to prepare the IODMACommand before use.
|
||||
* @param refCon Reference Constant
|
||||
* @result Returns a new IODMACommand if successfully created and initialized, 0 otherwise.
|
||||
*/
|
||||
static IODMACommand * withRefCon(void * refCon);
|
||||
|
||||
/*!
|
||||
* @function cloneCommand
|
||||
* @abstract Creates a new command based on the specification of the current one.
|
||||
* @discussion Factory function to create and initialise an IODMACommand in one operation. The current command's specification will be duplicated in the new object, but however none of its state will be duplicated. This means that it is safe to clone a command even if it is currently active and running, however you must be certain that the command to be duplicated does have a valid reference for the duration.
|
||||
* @result Returns a new IODMACommand if successfully created and initialised, 0 otherwise.
|
||||
*/
|
||||
virtual IODMACommand *cloneCommand(void *refCon = NULL);
|
||||
|
||||
/*! @function initWithSpecification
|
||||
* @abstract Primary initializer for the IODMACommand class.
|
||||
* @param outSegFunc SegmentFunction to call to output one physical segment. A set of nine commonly required segment functions are provided.
|
||||
* @param numAddressBits Number of bits that the hardware uses on its internal address bus. Typically 32 but may be more on modern hardware. A 0 implies no-restriction other than that implied by the output segment function.
|
||||
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0 which means any size.
|
||||
* @param mappingOptions is the type of mapping that is required to translate an IOMemoryDescriptor into the desired number of bits. For instance if your hardware only supports 32 bits but must run on machines with > 4G of RAM some mapping will be required. Number of bits will be specified in numAddressBits, see below.This parameter can take 3 values:- kNonCoherent - used for non-coherent hardware transfers, Mapped - Validate that all I/O bus generated addresses are within the number of addressing bits specified, Bypassed indicates that bypassed addressing is required, this is used when the hardware transferes are into coherent memory but no mapping is required. See also prepare() for failure cases.
|
||||
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
|
||||
* @param alignment Alignment restriction, in bytes, on I/O bus addresses. Defaults to single byte alignment.
|
||||
* @param mapper For mapping types kMapped & kBypassed mapper is used to define the hardware that will perform the mapping, defaults to the system mapper.
|
||||
* @param refCon Reference Constant
|
||||
* @result Can fail if the mapping type is not recognised, if one of the 3 mandatory parameters are set to 0, if a 32 bit output function is selected when more than 32 bits of address is required or, if kBypassed is requested on a machine that doesn't support bypassing. Returns true otherwise.
|
||||
*/
|
||||
virtual bool initWithSpecification( SegmentFunction outSegFunc,
|
||||
UInt8 numAddressBits,
|
||||
UInt64 maxSegmentSize,
|
||||
MappingOptions mappingOptions = kMapped,
|
||||
UInt64 maxTransferSize = 0,
|
||||
UInt32 alignment = 1,
|
||||
IOMapper *mapper = NULL,
|
||||
void *refCon = NULL);
|
||||
|
||||
/*! @function setMemoryDescriptor
|
||||
* @abstract Sets and resets the DMACommand's current memory descriptor
|
||||
* @discussion The DMA command will configure itself based on the information that it finds in the memory descriptor. It looks for things like the direction of the memory descriptor and whether the current memory descriptor is already mapped into some IOMMU. As a programmer convenience it can also prepare the DMA command immediately. See prepare(). Note the IODMACommand is designed to used multiple times with a succession of memory descriptors, making the pooling of commands possible. It is an error though to attempt to reset a currently prepared() DMA command. Warning: This routine may block so never try to autoprepare an IODMACommand while in a gated context, i.e. one of the WorkLoops action call outs.
|
||||
* @param mem A pointer to the current I/Os memory descriptor.
|
||||
* @param autoPrepare An optional boolean variable that will call the prepare() function automatically after the memory descriptor is processed. Defaults to true.
|
||||
* @result Returns kIOReturnSuccess, kIOReturnBusy if currently prepared, kIOReturnNoSpace if the length(mem) >= Maximum Transfer Size or the error codes returned by prepare() (qv).
|
||||
*/
|
||||
virtual IOReturn setMemoryDescriptor(const IOMemoryDescriptor *mem,
|
||||
bool autoPrepare = true);
|
||||
|
||||
/*! @function clearMemoryDescriptor
|
||||
* @abstract Clears the DMACommand's current memory descriptor
|
||||
* @discussion completes and invalidates the cache if the DMA command is currently active, copies all data from bounce buffers if necessary and releases all resources acquired during setMemoryDescriptor.
|
||||
* @param autoComplete An optional boolean variable that will call the complete() function automatically before the memory descriptor is processed. Defaults to true.
|
||||
*/
|
||||
virtual IOReturn clearMemoryDescriptor(bool autoComplete = true);
|
||||
|
||||
/*! @function getMemoryDescriptor
|
||||
* @abstract Get the current memory descriptor
|
||||
*/
|
||||
virtual const IOMemoryDescriptor *getMemoryDescriptor() const;
|
||||
|
||||
/*! @function getIOMemoryDescriptor
|
||||
* @abstract Get the memory descriptor to be used for DMA
|
||||
*/
|
||||
IOMemoryDescriptor * getIOMemoryDescriptor() const;
|
||||
|
||||
/*! @function prepare
|
||||
* @abstract Prepare the memory for an I/O transfer.
|
||||
* @discussion Allocate the mapping resources neccessary for this transfer, specifying a sub range of the IOMemoryDescriptor that will be the target of the I/O. The complete() method frees these resources. Data may be copied to buffers for kIODirectionOut memory descriptors, depending on hardware mapping resource availabilty or alignment restrictions. It should be noted that the this function may block and should only be called on the clients context, i.e never call this routine while gated; also the call itself is not thread safe though this should be an issue as each IODMACommand is independant.
|
||||
* @param offset defines the starting offset in the memory descriptor the DMA command will operate on. genIOVMSegments will produce its results based on the offset and length passed to the prepare method.
|
||||
* @param length defines the ending position in the memory descriptor the DMA command will operate on. genIOVMSegments will produce its results based on the offset and length passed to the prepare method.
|
||||
* @param flushCache Flush the caches for the memory descriptor and make certain that the memory cycles are complete. Defaults to true for kNonCoherent and is ignored by the other types.
|
||||
* @param synchronize Copy any buffered data back from the target IOMemoryDescriptor. Defaults to true, if synchronize() is being used to explicitly copy data, passing false may avoid an unneeded copy.
|
||||
* @result An IOReturn code. */
|
||||
|
||||
virtual IOReturn prepare(UInt64 offset = 0, UInt64 length = 0, bool flushCache = true, bool synchronize = true);
|
||||
|
||||
/*! @function complete
|
||||
* @abstract Complete processing of DMA mappings after an I/O transfer is finished.
|
||||
* @discussion This method should not be called unless a prepare was previously issued; the prepare() and complete() must occur in pairs, before and after an I/O transfer
|
||||
* @param invalidateCache Invalidate the caches for the memory descriptor. Defaults to true for kNonCoherent and is ignored by the other types.
|
||||
* @param synchronize Copy any buffered data back to the target IOMemoryDescriptor. Defaults to true, if synchronize() is being used to explicitly copy data, passing false may avoid an unneeded copy.
|
||||
* @result kIOReturnNotReady if not prepared, kIOReturnSuccess otherwise. */
|
||||
|
||||
virtual IOReturn complete(bool invalidateCache = true, bool synchronize = true);
|
||||
|
||||
/*! @function synchronize
|
||||
* @abstract Bring IOMemoryDescriptor and IODMACommand buffers into sync.
|
||||
* @discussion This method should not be called unless a prepare was previously issued. If needed a caller may synchronize any IODMACommand buffers with the original IOMemoryDescriptor buffers.
|
||||
* @param options Specifies the direction of the copy:
|
||||
* kIODirectionOut copy IOMemoryDesciptor memory to any IODMACommand buffers. By default this action takes place automatically at prepare().
|
||||
* kIODirectionIn copy any IODMACommand buffers back to the IOMemoryDescriptor. By default this action takes place automatically at complete().
|
||||
* kForceDoubleBuffer copy the entire prepared range to a new page aligned buffer.
|
||||
* @result kIOReturnNotReady if not prepared, kIOReturnBadArgument if invalid options are passed, kIOReturnSuccess otherwise. */
|
||||
|
||||
virtual IOReturn synchronize(IOOptionBits options);
|
||||
|
||||
/*! @function genIOVMSegments
|
||||
* @abstract Generates a physical scatter/gather for the current DMA command
|
||||
* @discussion Generates a list of physical segments from the given memory descriptor, relative to the current position of the descriptor. The constraints that are set during initialisation will be respected. This function maintains the state across multiple calls for efficiency. However the state is discarded if the new offset is not the expected one.
|
||||
* @param offset input/output parameter, defines the starting and ending offset in the memory descriptor, relative to any offset passed to the prepare() method.
|
||||
* @param segments Void pointer to base of output physical scatter/gather list. Always passed directly onto the SegmentFunction.
|
||||
* @param numSegments Input/output parameter Number of segments that can fit in the segment array and returns number of segments generated.
|
||||
* @result kIOReturnSuccess on success, kIOReturnOverrun if the memory descriptor is exhausted, kIOReturnMessageTooLarge if the output segment function's address bits has insufficient resolution for a segment, kIOReturnNotReady if the DMA command has not be prepared, kIOReturnBadArgument if the DMA command doesn't have a memory descriptor yet or some of the parameters are NULL and kIOReturnNotReady if the DMA command is not prepared.
|
||||
*/
|
||||
virtual IOReturn genIOVMSegments(UInt64 *offset,
|
||||
void *segments,
|
||||
UInt32 *numSegments);
|
||||
|
||||
private:
|
||||
virtual UInt64 transfer( IOOptionBits transferOp, UInt64 offset, void * buffer, UInt64 length );
|
||||
|
||||
public:
|
||||
|
||||
/*! @function writeBytes
|
||||
* @abstract Copy data to the IODMACommand's buffer from the specified buffer.
|
||||
* @discussion This method copies data to the IODMACommand's memory at the given offset, from the caller's buffer. The IODMACommand must be prepared, and the offset is relative to the prepared offset.
|
||||
* @param offset A byte offset into the IODMACommand's memory, relative to the prepared offset.
|
||||
* @param bytes The caller supplied buffer to copy the data from.
|
||||
* @param length The length of the data to copy.
|
||||
* @result The number of bytes copied, zero will be returned if the specified offset is beyond the prepared length of the IODMACommand. */
|
||||
|
||||
UInt64 writeBytes(UInt64 offset, const void *bytes, UInt64 length);
|
||||
|
||||
/*! @function readBytes
|
||||
* @abstract Copy data from the IODMACommand's buffer to the specified buffer.
|
||||
* @discussion This method copies data from the IODMACommand's memory at the given offset, to the caller's buffer. The IODMACommand must be prepared, and the offset is relative to the prepared offset.
|
||||
* @param offset A byte offset into the IODMACommand's memory, relative to the prepared offset.
|
||||
* @param bytes The caller supplied buffer to copy the data to.
|
||||
* @param length The length of the data to copy.
|
||||
* @result The number of bytes copied, zero will be returned if the specified offset is beyond the prepared length of the IODMACommand. */
|
||||
|
||||
UInt64 readBytes(UInt64 offset, void *bytes, UInt64 length);
|
||||
|
||||
/*! @function gen32IOVMSegments
|
||||
* @abstract Helper function for a type checked call to genIOVMSegments(qv), for use with an IODMACommand set up with the output function kIODMACommandOutputHost32, kIODMACommandOutputBig32, or kIODMACommandOutputLittle32. If the output function of the IODMACommand is not a 32 bit function, results will be incorrect.
|
||||
*/
|
||||
inline IOReturn
|
||||
gen32IOVMSegments(UInt64 *offset,
|
||||
Segment32 *segments,
|
||||
UInt32 *numSegments)
|
||||
{
|
||||
return genIOVMSegments(offset, segments, numSegments);
|
||||
}
|
||||
|
||||
/*! @function gen64IOVMSegments
|
||||
* @abstract Helper function for a type checked call to genIOVMSegments(qv), for use with an IODMACommand set up with the output function kIODMACommandOutputHost64, kIODMACommandOutputBig64, or kIODMACommandOutputLittle64. If the output function of the IODMACommand is not a 64 bit function, results will be incorrect.
|
||||
*/
|
||||
inline IOReturn
|
||||
gen64IOVMSegments(UInt64 *offset,
|
||||
Segment64 *segments,
|
||||
UInt32 *numSegments)
|
||||
{
|
||||
return genIOVMSegments(offset, segments, numSegments);
|
||||
}
|
||||
|
||||
IOReturn
|
||||
genIOVMSegments(SegmentFunction segmentFunction,
|
||||
UInt64 *offsetP,
|
||||
void *segmentsP,
|
||||
UInt32 *numSegmentsP);
|
||||
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
private:
|
||||
IOReturn setSpecification(SegmentFunction outSegFunc,
|
||||
const SegmentOptions * segmentOptions,
|
||||
uint32_t mappingOptions,
|
||||
IOMapper * mapper);
|
||||
|
||||
typedef IOReturn (*InternalSegmentFunction)(
|
||||
void *reference,
|
||||
IODMACommand *target,
|
||||
Segment64 segment,
|
||||
void *segments,
|
||||
UInt32 segmentIndex);
|
||||
|
||||
IOReturn genIOVMSegments(uint32_t op,
|
||||
InternalSegmentFunction outSegFunc,
|
||||
void *reference,
|
||||
UInt64 *offsetP,
|
||||
void *segmentsP,
|
||||
UInt32 *numSegmentsP);
|
||||
|
||||
static IOReturn clientOutputSegment(
|
||||
void *reference, IODMACommand *target,
|
||||
Segment64 segment, void *vSegList, UInt32 outSegIndex);
|
||||
|
||||
static IOReturn segmentOp(
|
||||
void *reference,
|
||||
IODMACommand *target,
|
||||
Segment64 segment,
|
||||
void *segments,
|
||||
UInt32 segmentIndex);
|
||||
IOReturn walkAll(UInt8 op);
|
||||
|
||||
public:
|
||||
|
||||
/*! @function prepareWithSpecification
|
||||
* @abstract Prepare the memory for an I/O transfer with a new specification.
|
||||
* @discussion Allocate the mapping resources neccessary for this transfer, specifying a sub range of the IOMemoryDescriptor that will be the target of the I/O. The complete() method frees these resources. Data may be copied to buffers for kIODirectionOut memory descriptors, depending on hardware mapping resource availabilty or alignment restrictions. It should be noted that the this function may block and should only be called on the clients context, i.e never call this routine while gated; also the call itself is not thread safe though this should be an issue as each IODMACommand is independant.
|
||||
* @param outSegFunc SegmentFunction to call to output one physical segment. A set of nine commonly required segment functions are provided.
|
||||
* @param numAddressBits Number of bits that the hardware uses on its internal address bus. Typically 32 but may be more on modern hardware. A 0 implies no-restriction other than that implied by the output segment function.
|
||||
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0 which means any size.
|
||||
* @param mappingOptions is the type of mapping that is required to translate an IOMemoryDescriptor into the desired number of bits. For instance if your hardware only supports 32 bits but must run on machines with > 4G of RAM some mapping will be required. Number of bits will be specified in numAddressBits, see below.This parameter can take 3 values:- kNonCoherent - used for non-coherent hardware transfers, Mapped - Validate that all I/O bus generated addresses are within the number of addressing bits specified, Bypassed indicates that bypassed addressing is required, this is used when the hardware transferes are into coherent memory but no mapping is required. See also prepare() for failure cases.
|
||||
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
|
||||
* @param alignment Alignment restriction, in bytes, on I/O bus addresses. Defaults to single byte alignment.
|
||||
* @param mapper For mapping types kMapped & kBypassed mapper is used to define the hardware that will perform the mapping, defaults to the system mapper.
|
||||
* @param offset defines the starting offset in the memory descriptor the DMA command will operate on. genIOVMSegments will produce its results based on the offset and length passed to the prepare method.
|
||||
* @param length defines the ending position in the memory descriptor the DMA command will operate on. genIOVMSegments will produce its results based on the offset and length passed to the prepare method.
|
||||
* @param flushCache Flush the caches for the memory descriptor and make certain that the memory cycles are complete. Defaults to true for kNonCoherent and is ignored by the other types.
|
||||
* @param synchronize Copy any buffered data back from the target IOMemoryDescriptor. Defaults to true, if synchronize() is being used to explicitly copy data, passing false may avoid an unneeded copy.
|
||||
* @result An IOReturn code. Can fail if the mapping type is not recognised, if one of the 3 mandatory parameters are set to 0, if a 32 bit output function is selected when more than 32 bits of address is required or, if kBypassed is requested on a machine that doesn't support bypassing.
|
||||
*/
|
||||
|
||||
virtual IOReturn prepareWithSpecification(SegmentFunction outSegFunc,
|
||||
UInt8 numAddressBits,
|
||||
UInt64 maxSegmentSize,
|
||||
MappingOptions mappingOptions = kMapped,
|
||||
UInt64 maxTransferSize = 0,
|
||||
UInt32 alignment = 1,
|
||||
IOMapper *mapper = NULL,
|
||||
UInt64 offset = 0,
|
||||
UInt64 length = 0,
|
||||
bool flushCache = true,
|
||||
bool synchronize = true);
|
||||
|
||||
static IOReturn transferSegment(void *reference,
|
||||
IODMACommand *target,
|
||||
Segment64 segment,
|
||||
void *segments,
|
||||
UInt32 segmentIndex);
|
||||
|
||||
/*! @function getPreparedOffsetAndLength
|
||||
* @abstract Returns the offset and length into the target IOMemoryDescriptor of a prepared IODDMACommand.
|
||||
* @discussion If successfully prepared, returns the offset and length into the IOMemoryDescriptor. Will fail for an unprepared IODMACommand.
|
||||
* @param offset returns the starting offset in the memory descriptor the DMA command was prepared with. Pass NULL for don't care.
|
||||
* @param length returns the length in the memory descriptor the DMA command was prepared with. Pass NULL for don't care.
|
||||
* @result An IOReturn code. kIOReturnNotReady if the IODMACommand is not prepared. */
|
||||
|
||||
virtual IOReturn getPreparedOffsetAndLength(UInt64 * offset, UInt64 * length);
|
||||
|
||||
UInt8 getNumAddressBits(void);
|
||||
UInt32 getAlignment(void);
|
||||
uint32_t getAlignmentLength(void);
|
||||
uint32_t getAlignmentInternalSegments(void);
|
||||
|
||||
|
||||
/*! @function initWithRefCon
|
||||
* @abstract Secondary initializer for the IODMACommand class.
|
||||
* @param refCon Reference Constant
|
||||
* @result Can fail if super init fails. Returns true otherwise.
|
||||
*/
|
||||
|
||||
virtual
|
||||
bool initWithRefCon(void * refCon = NULL);
|
||||
|
||||
virtual
|
||||
bool initWithSpecification(SegmentFunction outSegFunc,
|
||||
const SegmentOptions * segmentOptions,
|
||||
uint32_t mappingOptions,
|
||||
IOMapper * mapper,
|
||||
void * refCon);
|
||||
|
||||
virtual
|
||||
IOReturn prepareWithSpecification(SegmentFunction outSegFunc,
|
||||
const SegmentOptions * segmentOptions,
|
||||
uint32_t mappingOptions,
|
||||
IOMapper * mapper,
|
||||
uint64_t offset,
|
||||
uint64_t length,
|
||||
bool flushCache = true,
|
||||
bool synchronize = true);
|
||||
|
||||
virtual
|
||||
IOBufferMemoryDescriptor * createCopyBuffer(IODirection direction, UInt64 length);
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUsed(IODMACommand, 0);
|
||||
OSMetaClassDeclareReservedUsed(IODMACommand, 1);
|
||||
OSMetaClassDeclareReservedUsed(IODMACommand, 2);
|
||||
OSMetaClassDeclareReservedUsed(IODMACommand, 3);
|
||||
OSMetaClassDeclareReservedUsed(IODMACommand, 4);
|
||||
OSMetaClassDeclareReservedUsed(IODMACommand, 5);
|
||||
OSMetaClassDeclareReservedUsed(IODMACommand, 6);
|
||||
OSMetaClassDeclareReservedUnused(IODMACommand, 7);
|
||||
OSMetaClassDeclareReservedUnused(IODMACommand, 8);
|
||||
OSMetaClassDeclareReservedUnused(IODMACommand, 9);
|
||||
OSMetaClassDeclareReservedUnused(IODMACommand, 10);
|
||||
OSMetaClassDeclareReservedUnused(IODMACommand, 11);
|
||||
OSMetaClassDeclareReservedUnused(IODMACommand, 12);
|
||||
OSMetaClassDeclareReservedUnused(IODMACommand, 13);
|
||||
OSMetaClassDeclareReservedUnused(IODMACommand, 14);
|
||||
OSMetaClassDeclareReservedUnused(IODMACommand, 15);
|
||||
|
||||
public:
|
||||
/*! @var fRefCon Reference Constant, client defined publicly avialable */
|
||||
void *fRefCon;
|
||||
|
||||
protected:
|
||||
|
||||
/*! @var fMaxSegmentSize Maximum size of one segment in a scatter/gather list */
|
||||
UInt64 fMaxSegmentSize;
|
||||
|
||||
/*! @var fMaxTransferSize
|
||||
* Maximum size of a transfer that this memory cursor is allowed to generate */
|
||||
UInt64 fMaxTransferSize;
|
||||
|
||||
UInt32 fAlignMaskLength;
|
||||
UInt32 fAlignMaskInternalSegments;
|
||||
|
||||
/*! @var fMapper
|
||||
* Client defined mapper. */
|
||||
IOMapper *fMapper;
|
||||
|
||||
/*! @var fMemory
|
||||
* memory descriptor for current I/O. */
|
||||
const IOMemoryDescriptor *fMemory;
|
||||
|
||||
/*! @var fOutSeg The action method called when an event has been delivered */
|
||||
SegmentFunction fOutSeg;
|
||||
|
||||
/*! @var fAlignMask
|
||||
* Alignment restriction mask. */
|
||||
UInt32 fAlignMask;
|
||||
|
||||
/*! @var fNumAddressBits
|
||||
* Number of bits that the hardware can address */
|
||||
UInt32 fNumAddressBits;
|
||||
|
||||
/*! @var fNumSegments
|
||||
* Number of contiguous segments required for the current memory descriptor and desired mapping */
|
||||
UInt32 fNumSegments;
|
||||
|
||||
/*! @var fMappingOptions
|
||||
* What type of I/O virtual address mapping is required for this command */
|
||||
uint32_t fMappingOptions;
|
||||
|
||||
/*! @var fActive
|
||||
* fActive indicates that this DMA command is currently prepared and ready to go */
|
||||
UInt32 fActive;
|
||||
|
||||
/*! @var reserved
|
||||
* Reserved for future use. (Internal use only) */
|
||||
struct IODMACommandInternal * reserved;
|
||||
};
|
||||
|
||||
IOReturn
|
||||
IODMACommand::
|
||||
weakWithSpecification(IODMACommand **newCommand,
|
||||
SegmentFunction outSegFunc,
|
||||
UInt8 numAddressBits,
|
||||
UInt64 maxSegmentSize,
|
||||
MappingOptions mapType,
|
||||
UInt64 maxTransferSize,
|
||||
UInt32 alignment,
|
||||
IOMapper *mapper,
|
||||
void *refCon)
|
||||
{
|
||||
if (!newCommand) {
|
||||
return kIOReturnBadArgument;
|
||||
}
|
||||
|
||||
IODMACommand *self = (IODMACommand *)
|
||||
OSMetaClass::allocClassWithName("IODMACommand");
|
||||
if (!self) {
|
||||
return kIOReturnUnsupported;
|
||||
}
|
||||
|
||||
IOReturn ret;
|
||||
bool inited = self->
|
||||
initWithSpecification(outSegFunc,
|
||||
numAddressBits, maxSegmentSize, mapType,
|
||||
maxTransferSize, alignment, mapper, refCon);
|
||||
if (inited) {
|
||||
ret = kIOReturnSuccess;
|
||||
} else {
|
||||
self->release();
|
||||
self = NULL;
|
||||
ret = kIOReturnError;
|
||||
}
|
||||
|
||||
*newCommand = self;
|
||||
return ret;
|
||||
};
|
||||
#endif /* !_IODMACOMMAND_H */
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IODMACONTROLLER_H
|
||||
#define _IOKIT_IODMACONTROLLER_H
|
||||
|
||||
#include <IOKit/IODMACommand.h>
|
||||
#include <IOKit/IODMAEventSource.h>
|
||||
#include <IOKit/IOService.h>
|
||||
|
||||
class IODMAEventSource;
|
||||
|
||||
class IODMAController : public IOService
|
||||
{
|
||||
OSDeclareAbstractStructors(IODMAController);
|
||||
|
||||
friend class IODMAEventSource;
|
||||
|
||||
private:
|
||||
IOService *_provider;
|
||||
const OSSymbol *_dmaControllerName;
|
||||
|
||||
protected:
|
||||
virtual void registerDMAController(IOOptionBits options = 0);
|
||||
virtual IOReturn initDMAChannel(IOService *provider, IODMAEventSource *dmaES, UInt32 *dmaIndex, UInt32 reqIndex) = 0;
|
||||
virtual IOReturn startDMACommand(UInt32 dmaIndex, IODMACommand *dmaCommand, IODirection direction,
|
||||
IOByteCount byteCount = 0, IOByteCount byteOffset = 0) = 0;
|
||||
virtual IOReturn stopDMACommand(UInt32 dmaIndex, bool flush = false, uint64_t timeout = UINT64_MAX) = 0;
|
||||
virtual void completeDMACommand(IODMAEventSource *dmaES, IODMACommand *dmaCommand);
|
||||
virtual void notifyDMACommand(IODMAEventSource *dmaES, IODMACommand *dmaCommand, IOReturn status, IOByteCount actualByteCount, AbsoluteTime timeStamp);
|
||||
virtual IOReturn queryDMACommand(UInt32 dmaIndex, IODMACommand **dmaCommand, IOByteCount *transferCount, bool waitForIdle = false) = 0;
|
||||
virtual IOByteCount getFIFODepth(UInt32 dmaIndex, IODirection direction) = 0;
|
||||
virtual IOReturn setFIFODepth(UInt32 dmaIndex, IOByteCount depth) = 0;
|
||||
virtual IOByteCount validFIFODepth(UInt32 dmaIndex, IOByteCount depth, IODirection direction) = 0;
|
||||
virtual IOReturn setFrameSize(UInt32 dmaIndex, UInt8 byteCount) = 0;
|
||||
virtual IOReturn setDMAConfig(UInt32 dmaIndex, IOService *provider, UInt32 reqIndex) = 0;
|
||||
virtual bool validDMAConfig(UInt32 dmaIndex, IOService *provider, UInt32 reqIndex) = 0;
|
||||
|
||||
public:
|
||||
static const OSSymbol *createControllerName(UInt32 phandle);
|
||||
static IODMAController *getController(IOService *provider, UInt32 dmaIndex);
|
||||
|
||||
virtual bool start(IOService *provider) APPLE_KEXT_OVERRIDE;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _IOKIT_IODMACONTROLLER_H */
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IODMAEVENTSOURCE_H
|
||||
#define _IOKIT_IODMAEVENTSOURCE_H
|
||||
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/IODMACommand.h>
|
||||
#include <IOKit/IODMAController.h>
|
||||
#include <IOKit/IOEventSource.h>
|
||||
|
||||
class IODMAController;
|
||||
|
||||
class IODMAEventSource : public IOEventSource
|
||||
{
|
||||
OSDeclareDefaultStructors(IODMAEventSource);
|
||||
|
||||
friend class IODMAController;
|
||||
|
||||
public:
|
||||
typedef void (*Action)(OSObject *owner, IODMAEventSource *dmaES, IODMACommand *dmaCommand, IOReturn status, IOByteCount actualByteCount, AbsoluteTime timeStamp);
|
||||
#define IODMAEventAction IODMAEventSource::Action
|
||||
|
||||
protected:
|
||||
virtual void completeDMACommand(IODMACommand *dmaCommand);
|
||||
virtual void notifyDMACommand(IODMACommand *dmaCommand, IOReturn status, IOByteCount actualByteCount, AbsoluteTime timeStamp);
|
||||
|
||||
public:
|
||||
static IODMAEventSource *dmaEventSource(OSObject *owner,
|
||||
IOService *provider,
|
||||
Action completion = NULL,
|
||||
Action notification = NULL,
|
||||
UInt32 dmaIndex = 0);
|
||||
|
||||
virtual IOReturn startDMACommand(IODMACommand *dmaCommand, IODirection direction, IOByteCount byteCount = 0, IOByteCount byteOffset = 0);
|
||||
virtual IOReturn stopDMACommand(bool flush = false, uint64_t timeout = UINT64_MAX);
|
||||
|
||||
virtual IOReturn queryDMACommand(IODMACommand **dmaCommand, IOByteCount *transferCount, bool waitForIdle = false);
|
||||
|
||||
virtual IOByteCount getFIFODepth(IODirection direction = kIODirectionNone);
|
||||
virtual IOReturn setFIFODepth(IOByteCount depth);
|
||||
virtual IOByteCount validFIFODepth(IOByteCount depth, IODirection direction);
|
||||
|
||||
virtual IOReturn setFrameSize(UInt8 byteCount);
|
||||
|
||||
virtual IOReturn setDMAConfig(UInt32 dmaIndex);
|
||||
virtual bool validDMAConfig(UInt32 dmaIndex);
|
||||
|
||||
private:
|
||||
IOService *dmaProvider;
|
||||
IODMAController *dmaController;
|
||||
UInt32 dmaIndex;
|
||||
queue_head_t dmaCommandsCompleted;
|
||||
IOSimpleLock *dmaCommandsCompletedLock;
|
||||
Action dmaCompletionAction;
|
||||
Action dmaNotificationAction;
|
||||
bool dmaSynchBusy;
|
||||
|
||||
virtual bool init(OSObject *owner,
|
||||
IOService *provider,
|
||||
Action completion = NULL,
|
||||
Action notification = NULL,
|
||||
UInt32 dmaIndex = 0);
|
||||
virtual bool checkForWork(void) APPLE_KEXT_OVERRIDE;
|
||||
virtual void free(void) APPLE_KEXT_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif /* _IOKIT_IODMAEVENTSOURCE_H */
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IODATAQUEUE_H
|
||||
#define _IOKIT_IODATAQUEUE_H
|
||||
|
||||
#ifndef DISABLE_DATAQUEUE_WARNING
|
||||
#warning "IODataQueue is deprecated due to security issues in its interfaces, please use IOSharedDataQueue instead"
|
||||
#endif
|
||||
|
||||
|
||||
#include <libkern/c++/OSObject.h>
|
||||
#include <libkern/OSTypes.h>
|
||||
#include <mach/port.h>
|
||||
#include <mach/message.h>
|
||||
|
||||
typedef struct _IODataQueueMemory IODataQueueMemory;
|
||||
class IOMemoryDescriptor;
|
||||
|
||||
struct _notifyMsg {
|
||||
mach_msg_header_t h;
|
||||
};
|
||||
|
||||
|
||||
#ifdef dequeue
|
||||
#undef dequeue
|
||||
#endif
|
||||
#ifdef enqueue
|
||||
#undef enqueue
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @class IODataQueue : public OSObject
|
||||
* @abstract A generic queue designed to pass data from the kernel to a user process.
|
||||
* @discussion The IODataQueue class is designed to allow kernel code to queue data to a user process. IODataQueue objects are designed to be used in a single producer / single consumer situation. As such, there are no locks on the data itself. Because the kernel enqueue and user-space dequeue methods follow a strict set of guidelines, no locks are necessary to maintain the integrity of the data struct.
|
||||
*
|
||||
* <br>Each data entry can be variable sized, but the entire size of the queue data region (including overhead for each entry) must be specified up front.
|
||||
*
|
||||
* <br>In order for the IODataQueue instance to notify the user process that data is available, a notification mach port must be set. When the queue is empty and a new entry is added, a message is sent to the specified port.
|
||||
*
|
||||
* <br>User client code exists in the IOKit framework that facilitates the creation of the receive notification port as well as the listen process for new data available notifications.
|
||||
*
|
||||
* <br>In order to make the data queue memory available to a user process, the method getMemoryDescriptor() must be used to get an IOMemoryDescriptor instance that can be mapped into a user process. Typically, the clientMemoryForType() method on an IOUserClient instance will be used to request the IOMemoryDescriptor and then return it to be mapped into the user process.
|
||||
*/
|
||||
#ifndef DISABLE_DATAQUEUE_WARNING
|
||||
class __attribute__((deprecated)) IODataQueue: public OSObject
|
||||
#else
|
||||
class IODataQueue : public OSObject
|
||||
#endif
|
||||
{
|
||||
OSDeclareDefaultStructors(IODataQueue);
|
||||
|
||||
protected:
|
||||
IODataQueueMemory * dataQueue;
|
||||
|
||||
void * notifyMsg;
|
||||
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*!
|
||||
* @function sendDataAvailableNotification
|
||||
* @abstract Sends a dataAvailableNotification message to the specified mach port.
|
||||
* @discussion This method sends a message to the mach port passed to setNotificationPort(). It is used to indicate that data is available in the queue.
|
||||
*/
|
||||
virtual void sendDataAvailableNotification();
|
||||
|
||||
public:
|
||||
/*!
|
||||
* @function withCapacity
|
||||
* @abstract Static method that creates a new IODataQueue instance with the capacity specified in the size parameter.
|
||||
* @discussion The actual size of the entire data queue memory region (to be shared into a user process) is equal to the capacity plus the IODataQueueMemory overhead. This overhead value can be determined from the DATA_QUEUE_MEMORY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>. The size of the data queue memory region must include space for the overhead of each IODataQueueEntry. This entry overhead can be determined from the DATA_QUEUE_ENTRY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>.<br> This method allocates a new IODataQueue instance and then calls initWithCapacity() with the given size parameter. If the initWithCapacity() fails, the new instance is released and zero is returned.
|
||||
* @param size The size of the data queue memory region.
|
||||
* @result Returns the newly allocated IODataQueue instance. Zero is returned on failure.
|
||||
*/
|
||||
static IODataQueue *withCapacity(UInt32 size);
|
||||
|
||||
/*!
|
||||
* @function withEntries
|
||||
* @abstract Static method that creates a new IODataQueue instance with the specified number of entries of the given size.
|
||||
* @discussion This method will create a new IODataQueue instance with enough capacity for numEntries of entrySize. It does account for the IODataQueueEntry overhead for each entry. Note that the numEntries and entrySize are simply used to determine the data region size. They do not actually restrict the size of number of entries that can be added to the queue.<br> This method allocates a new IODataQueue instance and then calls initWithEntries() with the given numEntries and entrySize parameters. If the initWithEntries() fails, the new instance is released and zero is returned.
|
||||
* @param numEntries Number of entries to allocate space for.
|
||||
* @param entrySize Size of each entry.
|
||||
* @result Reeturns the newly allocated IODataQueue instance. Zero is returned on failure.
|
||||
*/
|
||||
static IODataQueue *withEntries(UInt32 numEntries, UInt32 entrySize);
|
||||
|
||||
/*!
|
||||
* @function initWithCapacity
|
||||
* @abstract Initializes an IODataQueue instance with the capacity specified in the size parameter.
|
||||
* @discussion The actual size of the entire data queue memory region (to be shared into a user process) is equal to the capacity plus the IODataQueueMemory overhead. This overhead value can be determined from the DATA_QUEUE_MEMORY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>. The size of the data queue memory region must include space for the overhead of each IODataQueueEntry. This entry overhead can be determined from the DATA_QUEUE_ENTRY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>.
|
||||
* @param size The size of the data queue memory region.
|
||||
* @result Returns true on success and false on failure.
|
||||
*/
|
||||
virtual Boolean initWithCapacity(UInt32 size);
|
||||
|
||||
/*!
|
||||
* @function initWithEntries
|
||||
* @abstract Initializes an IODataQueue instance with the specified number of entries of the given size.
|
||||
* @discussion This method will initialize an IODataQueue instance with enough capacity for numEntries of entrySize. It does account for the IODataQueueEntry overhead for each entry. Note that the numEntries and entrySize are simply used to determine the data region size. They do not actually restrict the size of number of entries that can be added to the queue.<br> This method allocates a new IODataQueue instance and then calls initWithEntries() with the given numEntries and entrySize parameters.
|
||||
* @param numEntries Number of entries to allocate space for.
|
||||
* @param entrySize Size of each entry.
|
||||
* @result Reeturns true on success and false on failure.
|
||||
*/
|
||||
virtual Boolean initWithEntries(UInt32 numEntries, UInt32 entrySize);
|
||||
|
||||
/*!
|
||||
* @function enqueue
|
||||
* @abstract Enqueues a new entry on the queue.
|
||||
* @discussion This method adds a new data entry of dataSize to the queue. It sets the size parameter of the entry pointed to by the tail value and copies the memory pointed to by the data parameter in place in the queue. Once that is done, it moves the tail to the next available location. When attempting to add a new entry towards the end of the queue and there isn't enough space at the end, it wraps back to the beginning.<br> If the queue is empty when a new entry is added, sendDataAvailableNotification() is called to send a message to the user process that data is now available.
|
||||
* @param data Pointer to the data to be added to the queue.
|
||||
* @param dataSize Size of the data pointed to by data.
|
||||
* @result Returns true on success and false on failure. Typically failure means that the queue is full.
|
||||
*/
|
||||
virtual Boolean enqueue(void *data, UInt32 dataSize);
|
||||
|
||||
/*!
|
||||
* @function setNotificationPort
|
||||
* @abstract Creates a simple mach message targeting the mach port specified in port.
|
||||
* @discussion This message is sent when data is added to an empty queue. It is to notify a user process that new data has become available.
|
||||
* @param port The mach port to target with the notification message.
|
||||
*/
|
||||
virtual void setNotificationPort(mach_port_t port);
|
||||
|
||||
/*!
|
||||
* @function getMemoryDescriptor
|
||||
* @abstract Returns a memory descriptor covering the IODataQueueMemory region.
|
||||
* @discussion The IOMemoryDescriptor instance returned by this method is intended to be mapped into a user process. This is the memory region that the IODataQueueClient code operates on.
|
||||
* @result Returns a newly allocated IOMemoryDescriptor for the IODataQueueMemory region. Returns zero on failure.
|
||||
*/
|
||||
virtual IOMemoryDescriptor *getMemoryDescriptor();
|
||||
};
|
||||
|
||||
#endif /* _IOKIT_IODATAQUEUE_H */
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IODATAQUEUESHARED_H
|
||||
#define _IOKIT_IODATAQUEUESHARED_H
|
||||
|
||||
#include <libkern/OSTypes.h>
|
||||
#include <mach/port.h>
|
||||
#include <mach/message.h>
|
||||
|
||||
/*!
|
||||
* @typedef IODataQueueEntry
|
||||
* @abstract Represents an entry within the data queue
|
||||
* @discussion This is a variable sized struct. The data field simply represents the start of the data region. The size of the data region is stored in the size field. The whole size of the specific entry is the size of a UInt32 plus the size of the data region.
|
||||
* @field size The size of the following data region.
|
||||
* @field data Represents the beginning of the data region. The address of the data field is a pointer to the start of the data region.
|
||||
*/
|
||||
typedef struct _IODataQueueEntry {
|
||||
UInt32 size;
|
||||
UInt8 data[4];
|
||||
} IODataQueueEntry;
|
||||
|
||||
/*!
|
||||
* @typedef IODataQueueMemory
|
||||
* @abstract A struct mapping to the header region of a data queue.
|
||||
* @discussion This struct is variable sized. The struct represents the data queue header information plus a pointer to the actual data queue itself. The size of the struct is the combined size of the header fields (3 * sizeof(UInt32)) plus the actual size of the queue region. This size is stored in the queueSize field.
|
||||
* @field queueSize The size of the queue region pointed to by the queue field.
|
||||
* @field head The location of the queue head. This field is represented as a byte offset from the beginning of the queue memory region.
|
||||
* @field tail The location of the queue tail. This field is represented as a byte offset from the beginning of the queue memory region.
|
||||
* @field queue Represents the beginning of the queue memory region. The size of the region pointed to by queue is stored in the queueSize field.
|
||||
*/
|
||||
typedef struct _IODataQueueMemory {
|
||||
UInt32 queueSize;
|
||||
volatile UInt32 head;
|
||||
volatile UInt32 tail;
|
||||
IODataQueueEntry queue[1];
|
||||
} IODataQueueMemory;
|
||||
|
||||
/*!
|
||||
* @typedef IODataQueueAppendix
|
||||
* @abstract A struct mapping to the appendix region of a data queue.
|
||||
* @discussion This struct is variable sized dependent on the version. The struct represents the data queue appendix information.
|
||||
* @field version The version of the queue appendix.
|
||||
* @field msgh Mach message header containing the notification mach port associated with this queue.
|
||||
*/
|
||||
typedef struct _IODataQueueAppendix {
|
||||
UInt32 version;
|
||||
mach_msg_header_t msgh;
|
||||
} IODataQueueAppendix;
|
||||
|
||||
/*!
|
||||
* @defined DATA_QUEUE_ENTRY_HEADER_SIZE Represents the size of the data queue entry header independent of the actual size of the data in the entry. This is the overhead of each entry in the queue. The total size of an entry is equal to this value plus the size stored in the entry's size field (in IODataQueueEntry).
|
||||
*/
|
||||
#define DATA_QUEUE_ENTRY_HEADER_SIZE (sizeof(IODataQueueEntry) - 4)
|
||||
|
||||
/*!
|
||||
* @defined DATA_QUEUE_MEMORY_HEADER_SIZE Represents the size of the data queue memory header independent of the actual size of the queue data itself. The total size of the queue memory is equal to this value plus the size of the queue appendix and the size of the queue data region which is stored in the queueSize field of IODataQueueMeory.
|
||||
*/
|
||||
#define DATA_QUEUE_MEMORY_HEADER_SIZE (sizeof(IODataQueueMemory) - sizeof(IODataQueueEntry))
|
||||
|
||||
/*!
|
||||
* @defined DATA_QUEUE_MEMORY_APPENDIX_SIZE Represents the size of the data queue memory appendix independent of the actual size of the queue data itself. The total size of the queue memory is equal to this value plus the size of queue header and size of the queue data region which is stored in the queueSize field of IODataQueueMeory.
|
||||
*/
|
||||
#define DATA_QUEUE_MEMORY_APPENDIX_SIZE (sizeof(IODataQueueAppendix))
|
||||
|
||||
#endif /* _IOKIT_IODATAQUEUESHARED_H */
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* HISTORY
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IODEVICEMEMORY_H
|
||||
#define _IOKIT_IODEVICEMEMORY_H
|
||||
|
||||
#include <IOKit/IOMemoryDescriptor.h>
|
||||
|
||||
/*! @class IODeviceMemory
|
||||
* @abstract An IOMemoryDescriptor used for device physical memory ranges.
|
||||
* @discussion The IODeviceMemory class is a simple subclass of IOMemoryDescriptor that uses its methods to describe a single range of physical memory on a device. IODeviceMemory objects are usually looked up with IOService or IOPCIDevice accessors, and are created by memory-mapped bus families. IODeviceMemory implements only some factory methods in addition to the methods of IOMemoryDescriptor.
|
||||
*/
|
||||
|
||||
class IODeviceMemory : public IOMemoryDescriptor
|
||||
{
|
||||
OSDeclareDefaultStructors(IODeviceMemory);
|
||||
|
||||
public:
|
||||
|
||||
/*! @struct InitElement
|
||||
* @field start First physical address in the range.
|
||||
* @field length Length of the range.
|
||||
* @field tag 32-bit value not interpreted by IODeviceMemory or IOMemoryDescriptor, for use by the bus family. */
|
||||
|
||||
struct InitElement {
|
||||
IOPhysicalAddress start;
|
||||
IOPhysicalLength length;
|
||||
IOOptionBits tag;
|
||||
};
|
||||
|
||||
/*! @function arrayFromList
|
||||
* @abstract Constructs an OSArray of IODeviceMemory instances, each describing one physical range, and a tag value.
|
||||
* @discussion This method creates IODeviceMemory instances for each physical range passed in an IODeviceMemory::InitElement array. Each element consists of a physical address, length and tag value for the IODeviceMemory. The instances are returned as a created OSArray.
|
||||
* @param list An array of IODeviceMemory::InitElement structures.
|
||||
* @param count The number of elements in the list.
|
||||
* @result Returns a created OSArray of IODeviceMemory objects, to be released by the caller, or zero on failure. */
|
||||
|
||||
static OSArray * arrayFromList(
|
||||
InitElement list[],
|
||||
IOItemCount count );
|
||||
|
||||
/*! @function withRange
|
||||
* @abstract Constructs an IODeviceMemory instance, describing one physical range.
|
||||
* @discussion This method creates an IODeviceMemory instance for one physical range passed as a physical address and length. It just calls IOMemoryDescriptor::withPhysicalAddress.
|
||||
* @param start The physical address of the first byte in the memory.
|
||||
* @param length The length of memory.
|
||||
* @result Returns the created IODeviceMemory on success, to be released by the caller, or zero on failure. */
|
||||
|
||||
static IODeviceMemory * withRange(
|
||||
IOPhysicalAddress start,
|
||||
IOPhysicalLength length );
|
||||
|
||||
/*! @function withSubRange
|
||||
* @abstract Constructs an IODeviceMemory instance, describing a subset of an existing IODeviceMemory range.
|
||||
* @discussion This method creates an IODeviceMemory instance for a subset of an existing IODeviceMemory range, passed as a physical address offset and length. It just calls IOMemoryDescriptor::withSubRange.
|
||||
* @param of The parent IODeviceMemory of which a subrange is to be used for the new descriptor, which will be retained by the subrange IODeviceMemory.
|
||||
* @param offset A byte offset into the parent's memory.
|
||||
* @param length The length of the subrange.
|
||||
* @result Returns the created IODeviceMemory on success, to be released by the caller, or zero on failure. */
|
||||
|
||||
static IODeviceMemory * withSubRange(
|
||||
IODeviceMemory * of,
|
||||
IOPhysicalAddress offset,
|
||||
IOPhysicalLength length );
|
||||
};
|
||||
|
||||
#endif /* ! _IOKIT_IODEVICEMEMORY_H */
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* HISTORY
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IODEVICETREE_H
|
||||
#define _IOKIT_IODEVICETREE_H
|
||||
|
||||
#include <IOKit/IORegistryEntry.h>
|
||||
#include <libkern/c++/OSData.h>
|
||||
|
||||
class IODeviceMemory;
|
||||
class IOService;
|
||||
|
||||
extern const IORegistryPlane * gIODTPlane;
|
||||
|
||||
extern const OSSymbol * gIODTPHandleKey;
|
||||
|
||||
extern const OSSymbol * gIODTCompatibleKey;
|
||||
extern const OSSymbol * gIODTTypeKey;
|
||||
extern const OSSymbol * gIODTModelKey;
|
||||
extern const OSSymbol * gIODTTargetTypeKey;
|
||||
|
||||
extern const OSSymbol * gIODTAAPLInterruptsKey;
|
||||
extern const OSSymbol * gIODTDefaultInterruptController;
|
||||
extern const OSSymbol * gIODTNWInterruptMappingKey;
|
||||
|
||||
LIBKERN_RETURNS_NOT_RETAINED IORegistryEntry * IODeviceTreeAlloc( void * dtTop );
|
||||
|
||||
|
||||
bool IODTMatchNubWithKeys( IORegistryEntry * nub,
|
||||
const char * keys );
|
||||
|
||||
bool IODTCompareNubName( const IORegistryEntry * regEntry,
|
||||
OSString * name,
|
||||
LIBKERN_RETURNS_RETAINED_ON_NONZERO OSString ** matchingName );
|
||||
|
||||
enum {
|
||||
kIODTRecursive = 0x00000001,
|
||||
kIODTExclusive = 0x00000002
|
||||
};
|
||||
|
||||
OSCollectionIterator * IODTFindMatchingEntries( IORegistryEntry * from,
|
||||
IOOptionBits options, const char * keys );
|
||||
|
||||
typedef SInt32 (*IODTCompareAddressCellFunc)
|
||||
(UInt32 cellCount, UInt32 left[], UInt32 right[]);
|
||||
|
||||
typedef void (*IODTNVLocationFunc)
|
||||
(IORegistryEntry * entry,
|
||||
UInt8 * busNum, UInt8 * deviceNum, UInt8 * functionNum );
|
||||
|
||||
void IODTSetResolving( IORegistryEntry * regEntry,
|
||||
IODTCompareAddressCellFunc compareFunc,
|
||||
IODTNVLocationFunc locationFunc );
|
||||
|
||||
void IODTGetCellCounts( IORegistryEntry * regEntry,
|
||||
UInt32 * sizeCount, UInt32 * addressCount);
|
||||
|
||||
bool IODTResolveAddressCell( IORegistryEntry * regEntry,
|
||||
UInt32 cellsIn[],
|
||||
IOPhysicalAddress * phys, IOPhysicalLength * len );
|
||||
|
||||
LIBKERN_RETURNS_NOT_RETAINED OSArray *
|
||||
IODTResolveAddressing( IORegistryEntry * regEntry,
|
||||
const char * addressPropertyName,
|
||||
IODeviceMemory * parent );
|
||||
|
||||
struct IONVRAMDescriptor {
|
||||
unsigned int format:4;
|
||||
unsigned int marker:1;
|
||||
unsigned int bridgeCount:3;
|
||||
unsigned int busNum:2;
|
||||
unsigned int bridgeDevices:6 * 5;
|
||||
unsigned int functionNum:3;
|
||||
unsigned int deviceNum:5;
|
||||
} __attribute__((aligned(2), packed));
|
||||
|
||||
IOReturn IODTMakeNVDescriptor( IORegistryEntry * regEntry,
|
||||
IONVRAMDescriptor * hdr );
|
||||
|
||||
LIBKERN_RETURNS_NOT_RETAINED OSData *
|
||||
IODTFindSlotName( IORegistryEntry * regEntry, UInt32 deviceNumber );
|
||||
|
||||
const OSSymbol * IODTInterruptControllerName(
|
||||
IORegistryEntry * regEntry );
|
||||
|
||||
bool IODTMapInterrupts( IORegistryEntry * regEntry );
|
||||
|
||||
enum {
|
||||
kIODTInterruptShared = 0x00000001
|
||||
};
|
||||
IOReturn IODTGetInterruptOptions( IORegistryEntry * regEntry, int source, IOOptionBits * options );
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
IOReturn IONDRVLibrariesInitialize( IOService * provider );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _IOKIT_IODEVICETREE_H */
|
||||
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
|
||||
* HISTORY
|
||||
* 1998-7-13 Godfrey van der Linden(gvdl)
|
||||
* Created.
|
||||
* 1998-10-30 Godfrey van der Linden(gvdl)
|
||||
* Converted to C++
|
||||
*/
|
||||
#ifndef _IOKIT_IOEVENTSOURCE_H
|
||||
#define _IOKIT_IOEVENTSOURCE_H
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <libkern/c++/OSObject.h>
|
||||
|
||||
#include <IOKit/IOLib.h>
|
||||
#include <IOKit/system.h>
|
||||
#include <IOKit/IOWorkLoop.h>
|
||||
|
||||
#if IOKITSTATS
|
||||
#include <IOKit/IOStatisticsPrivate.h>
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
#include <mach/clock_types.h>
|
||||
#include <kern/clock.h>
|
||||
__END_DECLS
|
||||
|
||||
/*!
|
||||
* @class IOEventSource : public OSObject
|
||||
* @abstract Abstract class for all work-loop event sources.
|
||||
* @discussion The IOEventSource declares the abstract super class that all
|
||||
* event sources must inherit from if an IOWorkLoop is to receive events from them.
|
||||
* <br><br>
|
||||
* An event source can represent any event that should cause the work-loop of a
|
||||
* device to wake up and perform work. Two examples of event sources are the
|
||||
* IOInterruptEventSource which delivers interrupt notifications and IOCommandGate
|
||||
* which delivers command requests.
|
||||
* <br><br>
|
||||
* A kernel module can always use the work-loop model for serialising access to
|
||||
* anything at all. The IOEventSource is used for communicating events to the
|
||||
* work-loop, and the chain of event sources should be used to walk the possible
|
||||
* event sources and demultipex them. Note a particular instance of an event
|
||||
* source may only be a member of 1 linked list chain. If you need to move it
|
||||
* between chains than make sure it is removed from the original chain before
|
||||
* attempting to move it.
|
||||
* <br><br>
|
||||
* The IOEventSource makes no attempt to maintain the consistency of its internal data across multi-threading. It is assumed that the user of these basic tools will protect the data that these objects represent in some sort of device wide instance lock. For example the IOWorkLoop maintains the event chain by using an IOCommandGate and thus single threading access to its state.
|
||||
* <br><br>
|
||||
* All subclasses of IOEventSource that wish to perform work on the work-loop thread are expected to implement the checkForWork() member function. As of Mac OS X, 10.7 (Darwin 11), checkForWork is no longer pure virtual, and should not be overridden if there is no work to be done.
|
||||
*
|
||||
* <br><br>
|
||||
* checkForWork() is the key method in this class. It is called by some work-loop when convienient and is expected to evaluate its internal state and determine if an event has occurred since the last call. In the case of an event having occurred then the instance defined target(owner)/action will be called. The action is stored as an ordinary C function pointer but the first parameter is always the owner. This means that a C++ member function can be used as an action function though this depends on the ABI.
|
||||
* <br><br>
|
||||
* Although the eventChainNext variable contains a reference to the next event source in the chain this reference is not retained. The list 'owner' i.e. the client that creates the event, not the work-loop, is expected to retain the source.
|
||||
*/
|
||||
class IOEventSource : public OSObject
|
||||
{
|
||||
OSDeclareAbstractStructors(IOEventSource);
|
||||
friend class IOWorkLoop;
|
||||
#if IOKITSTATS
|
||||
friend class IOStatistics;
|
||||
#endif
|
||||
|
||||
public:
|
||||
/*!
|
||||
* @typedef Action
|
||||
* @discussion Placeholder type for C++ function overloading discrimination.
|
||||
* As the all event sources require an action and it has to be stored somewhere
|
||||
* and be of some type, this is that type.
|
||||
* @param owner
|
||||
* Target of the function, can be used as a refcon. The owner is set
|
||||
* during initialisation. Note if a C++ function was specified this parameter
|
||||
* is implicitly the first paramter in the target member function's parameter list.
|
||||
*/
|
||||
typedef void (*Action)(OSObject *owner, ...);
|
||||
|
||||
/*! @defined IOEventSourceAction
|
||||
* @discussion Backward compatibilty define for the old non-class scoped type definition. See $link IOEventSource::Action */
|
||||
#define IOEventSourceAction IOEventSource::Action
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
typedef IOReturn (^ActionBlock)();
|
||||
#endif /* __BLOCKS__ */
|
||||
|
||||
protected:
|
||||
/*! @var eventChainNext
|
||||
* The next event source in the event chain. nil at end of chain. */
|
||||
IOEventSource *eventChainNext;
|
||||
|
||||
/*! @var owner The owner object called when an event has been delivered. */
|
||||
OSObject *owner;
|
||||
|
||||
/*! @var action
|
||||
* The action method called when an event has been delivered */
|
||||
|
||||
Action action;
|
||||
|
||||
/*! @var enabled
|
||||
* Is this event source enabled to deliver requests to the work-loop. */
|
||||
bool enabled;
|
||||
|
||||
|
||||
/*! @var workLoop What is the work-loop for this event source. */
|
||||
IOWorkLoop *workLoop;
|
||||
|
||||
/*! @var refcon What ever the client wants to do, see $link setRefcon. */
|
||||
void *refcon;
|
||||
|
||||
/*! @struct ExpansionData
|
||||
* @discussion This structure will be used to expand the capablilties of the IOEventSource in the future.
|
||||
*/
|
||||
struct ExpansionData {
|
||||
#if IOKITSTATS
|
||||
struct IOEventSourceCounter *counter;
|
||||
#else
|
||||
void *iokitstatsReserved;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*! @var reserved
|
||||
* Reserved for future use. (Internal use only) */
|
||||
ExpansionData *reserved;
|
||||
|
||||
/*! @function init
|
||||
* @abstract Primary initialiser for the IOEventSource class.
|
||||
* @param owner
|
||||
* Owner of this instance of an event source. Used as the first parameter
|
||||
* of the action callout. Owner must be an OSObject.
|
||||
* @param action
|
||||
* Pointer to C call out function. Action is a pointer to a C function
|
||||
* that gets called when this event source has outstanding work. It will usually
|
||||
* be called by the checkForWork member function. The first parameter of the
|
||||
* action call out will always be the owner, this allows C++ member functions to
|
||||
* be used as actions. Defaults to 0.
|
||||
* @result true if the inherited classes and this instance initialise
|
||||
* successfully.
|
||||
*/
|
||||
virtual bool init(OSObject *owner, IOEventSource::Action action = NULL);
|
||||
|
||||
virtual void free( void ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function checkForWork
|
||||
* @abstract Virtual member function used by IOWorkLoop for work
|
||||
* scheduling.
|
||||
* @discussion This function will be called to request a subclass to check
|
||||
* its internal state for any work to do and then to call out the owner/action.
|
||||
* If this event source never performs any work (e.g. IOCommandGate), this
|
||||
* method should not be overridden. NOTE: This method is no longer declared pure
|
||||
* virtual. A default implementation is provided in IOEventSource.
|
||||
* @result Return true if this function needs to be called again before all its outstanding events have been processed.
|
||||
*/
|
||||
virtual bool checkForWork();
|
||||
|
||||
/*! @function setWorkLoop
|
||||
* @abstract Set'ter for $link workLoop variable.
|
||||
* @param workLoop
|
||||
* Target work-loop of this event source instance. A subclass of
|
||||
* IOWorkLoop that at least reacts to signalWorkAvailable() and onThread functions.
|
||||
*/
|
||||
virtual void setWorkLoop(IOWorkLoop *workLoop);
|
||||
|
||||
/*! @function setNext
|
||||
* @abstract Set'ter for $link eventChainNext variable.
|
||||
* @param next
|
||||
* Pointer to another IOEventSource instance.
|
||||
*/
|
||||
virtual void setNext(IOEventSource *next);
|
||||
|
||||
/*! @function getNext
|
||||
* @abstract Get'ter for $link eventChainNext variable.
|
||||
* @result value of eventChainNext.
|
||||
*/
|
||||
virtual IOEventSource *getNext() const;
|
||||
|
||||
|
||||
protected:
|
||||
// Methods to access the IOWorkLoop exported fields
|
||||
void signalWorkAvailable();
|
||||
void openGate();
|
||||
void closeGate();
|
||||
bool tryCloseGate();
|
||||
int sleepGate(void *event, UInt32 type);
|
||||
int sleepGate(void *event, AbsoluteTime deadline, UInt32 type);
|
||||
void wakeupGate(void *event, bool oneThread);
|
||||
|
||||
public:
|
||||
/*! @function setAction
|
||||
* @abstract Set'ter for $link action variable.
|
||||
* @param action Pointer to a C function of type IOEventSource::Action. */
|
||||
virtual void setAction(IOEventSource::Action action);
|
||||
|
||||
/*! @function getAction
|
||||
* @abstract Get'ter for $link action variable.
|
||||
* @result value of action. */
|
||||
virtual IOEventSource::Action getAction() const;
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
/*! @function setActionBlock
|
||||
* @abstract Setter for action ivar. The current block is released, & the new block is retained.
|
||||
* @param block Block pointer of type IOEventSource::ActionBlock. */
|
||||
void setActionBlock(ActionBlock block);
|
||||
/*! @function getActionBlock
|
||||
* @abstract Getter for action ivar.
|
||||
* @result Block pointer of type IOEventSource::ActionBlock, if set, or NULL. */
|
||||
ActionBlock getActionBlock(ActionBlock) const;
|
||||
#endif /* __BLOCKS__ */
|
||||
|
||||
/*! @function setRefcon
|
||||
* @abstract Setter for refcon ivar. This function will assert if a block action has been set.
|
||||
* @param refcon Refcon. */
|
||||
void setRefcon(void *refcon);
|
||||
/*! @function getRefcon
|
||||
* @abstract Getter for refcon ivar.
|
||||
* @result The refcon. This function will assert if a block action has been set. */
|
||||
void * getRefcon() const;
|
||||
|
||||
/*! @function enable
|
||||
* @abstract Enable event source.
|
||||
* @discussion A subclass implementation is expected to respect the enabled
|
||||
* state when checkForWork is called. Calling this function will cause the
|
||||
* work-loop to be signalled so that a checkForWork is performed. */
|
||||
virtual void enable();
|
||||
|
||||
/*! @function disable
|
||||
* @abstract Disable event source.
|
||||
* @discussion A subclass implementation is expected to respect the enabled
|
||||
* state when checkForWork is called. */
|
||||
virtual void disable();
|
||||
|
||||
/*! @function isEnabled
|
||||
* @abstract Get'ter for $link enable variable.
|
||||
* @result true if enabled. */
|
||||
virtual bool isEnabled() const;
|
||||
|
||||
/*! @function getWorkLoop
|
||||
* @abstract Get'ter for $link workLoop variable.
|
||||
* @result value of workLoop. */
|
||||
virtual IOWorkLoop *getWorkLoop() const;
|
||||
|
||||
/*! @function onThread
|
||||
* @abstract Convenience function for workLoop->onThread.
|
||||
* @result true if called on the work-loop thread.
|
||||
*/
|
||||
virtual bool onThread() const;
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUnused(IOEventSource, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOEventSource, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOEventSource, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOEventSource, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOEventSource, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOEventSource, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOEventSource, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOEventSource, 7);
|
||||
};
|
||||
|
||||
#endif /* !_IOKIT_IOEVENTSOURCE_H */
|
||||
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* HISTORY
|
||||
* 1999-4-15 Godfrey van der Linden(gvdl)
|
||||
* Created.
|
||||
*/
|
||||
#ifndef _IOKIT_IOFILTERINTERRUPTEVENTSOURCE_H
|
||||
#define _IOKIT_IOFILTERINTERRUPTEVENTSOURCE_H
|
||||
|
||||
#include <IOKit/IOInterruptEventSource.h>
|
||||
|
||||
class IOService;
|
||||
|
||||
/*! @class IOFilterInterruptEventSource : public IOInterruptEventSource
|
||||
* @abstract Filtering varient of the $link IOInterruptEventSource.
|
||||
* @discussion An interrupt event source that calls the client to determine if a interrupt event needs to be scheduled on the work loop. A filter interrupt event source call's the client in the primary interrupt context, the client can then interrogate its hardware and determine if the interrupt needs to be processed yet.
|
||||
* <br><br>
|
||||
* As the routine is called in the primary interrupt context great care must be taken in the writing of this routine. In general none of the generic IOKit environment is safe to call in this context. We intend this routine to be used by hardware that can interrogate its registers without destroying state. Primarily this variant of event sources will be used by drivers that share interrupts. The filter routine will determine if the interrupt is a real interrupt or a ghost and thus optimise the work thread context switch away.
|
||||
* <br><br>
|
||||
* If you are implementing 'SoftDMA' (or pseudo-DMA), you may not want the I/O Kit to automatically start your interrupt handler routine on your work loop when your filter routine returns true. In this case, you may choose to have your filter routine schedule the work on the work loop itself and then return false. If you do this, the interrupt will not be disabled in hardware and you could receive additional primary interrupts before your work loop–level service routine completes. Because this scheme has implications for synchronization between your filter routine and your interrupt service routine, you should avoid doing this unless your driver requires SoftDMA.
|
||||
* <br><br>
|
||||
* CAUTION: Called in primary interrupt context, if you need to disable interrupt to guard you registers against an unexpected call then it is better to use a straight IOInterruptEventSource and its secondary interrupt delivery mechanism.
|
||||
*/
|
||||
class IOFilterInterruptEventSource : public IOInterruptEventSource
|
||||
{
|
||||
OSDeclareDefaultStructors(IOFilterInterruptEventSource);
|
||||
|
||||
public:
|
||||
/*!
|
||||
* @typedef Filter
|
||||
* @discussion C Function pointer to a routine to call when an interrupt occurs.
|
||||
* @param owner Pointer to the owning/client instance.
|
||||
* @param sender Where is the interrupt comming from.
|
||||
* @result false if this interrupt can be ignored. */
|
||||
typedef bool (*Filter)(OSObject *owner, IOFilterInterruptEventSource *sender);
|
||||
|
||||
/*! @defined IOFilterInterruptAction
|
||||
* @discussion Backward compatibilty define for the old non-class scoped type definition. See $link IOFilterInterruptSource::Filter */
|
||||
#define IOFilterInterruptAction IOFilterInterruptEventSource::Filter
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
typedef bool (^FilterBlock)(IOFilterInterruptEventSource *sender);
|
||||
#endif /* __BLOCKS__ */
|
||||
|
||||
private:
|
||||
// Hide the superclass initializers
|
||||
virtual bool init(OSObject *inOwner,
|
||||
IOInterruptEventSource::Action inAction = NULL,
|
||||
IOService *inProvider = NULL,
|
||||
int inIntIndex = 0) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
static IOInterruptEventSource *
|
||||
interruptEventSource(OSObject *inOwner,
|
||||
IOInterruptEventSource::Action inAction = NULL,
|
||||
IOService *inProvider = NULL,
|
||||
int inIntIndex = 0);
|
||||
|
||||
protected:
|
||||
/*! @var filterAction Filter callout */
|
||||
|
||||
Filter filterAction;
|
||||
|
||||
/*! @struct ExpansionData
|
||||
* @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
|
||||
*/
|
||||
struct ExpansionData { };
|
||||
|
||||
/*! @var reserved
|
||||
* Reserved for future use. (Internal use only) */
|
||||
APPLE_KEXT_WSHADOW_PUSH;
|
||||
ExpansionData *reserved;
|
||||
APPLE_KEXT_WSHADOW_POP;
|
||||
|
||||
public:
|
||||
/*! @function filterInterruptEventSource
|
||||
* @abstract Factor method to create and initialise an IOFilterInterruptEventSource. See $link init.
|
||||
* @param owner Owner/client of this event source.
|
||||
* @param action 'C' Function to call when something happens.
|
||||
* @param filter 'C' Function to call when interrupt occurs.
|
||||
* @param provider Service that provides interrupts.
|
||||
* @param intIndex Defaults to 0.
|
||||
* @result a new event source if succesful, 0 otherwise. */
|
||||
static IOFilterInterruptEventSource *
|
||||
filterInterruptEventSource(OSObject *owner,
|
||||
IOInterruptEventSource::Action action,
|
||||
Filter filter,
|
||||
IOService *provider,
|
||||
int intIndex = 0);
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
/*! @function filterInterruptEventSource
|
||||
* @abstract Factor method to create and initialise an IOFilterInterruptEventSource. See $link init.
|
||||
* @param owner Owner/client of this event source.
|
||||
* @param provider Service that provides interrupts.
|
||||
* @param intIndex The index of the interrupt within the provider's interrupt sources.
|
||||
* @param action Block for the callout routine of this event source.
|
||||
* @param filter Block to invoke when HW interrupt occurs.
|
||||
* @result a new event source if succesful, 0 otherwise. */
|
||||
static IOFilterInterruptEventSource *
|
||||
filterInterruptEventSource(OSObject *owner,
|
||||
IOService *provider,
|
||||
int intIndex,
|
||||
IOInterruptEventSource::ActionBlock action,
|
||||
FilterBlock filter);
|
||||
#endif /* __BLOCKS__ */
|
||||
|
||||
|
||||
/*! @function init
|
||||
* @abstract Primary initialiser for the IOFilterInterruptEventSource class.
|
||||
* @param owner Owner/client of this event source.
|
||||
* @param action 'C' Function to call when something happens.
|
||||
* @param filter 'C' Function to call in primary interrupt context.
|
||||
* @param provider Service that provides interrupts.
|
||||
* @param intIndex Interrupt source within provider. Defaults to 0.
|
||||
* @result true if the inherited classes and this instance initialise
|
||||
* successfully. */
|
||||
virtual bool init(OSObject *owner,
|
||||
IOInterruptEventSource::Action action,
|
||||
Filter filter,
|
||||
IOService *provider,
|
||||
int intIndex = 0);
|
||||
|
||||
virtual void free( void ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function signalInterrupt
|
||||
* @abstract Cause the work loop to schedule the action.
|
||||
* @discussion Cause the work loop to schedule the interrupt action even if the filter routine returns 'false'. Note well the interrupting condition MUST be cleared from the hardware otherwise an infinite process interrupt loop will occur. Use this function when SoftDMA is desired. See $link IOFilterInterruptSource::Filter */
|
||||
virtual void signalInterrupt();
|
||||
|
||||
/*! @function getFilterAction
|
||||
* @abstract Get'ter for filterAction variable.
|
||||
* @result value of filterAction. */
|
||||
virtual Filter getFilterAction() const;
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
/*! @function getFilterActionBlock
|
||||
* @abstract Get'ter for filterAction variable.
|
||||
* @result value of filterAction. */
|
||||
FilterBlock getFilterActionBlock() const;
|
||||
#endif /* __BLOCKS__ */
|
||||
|
||||
/*! @function normalInterruptOccurred
|
||||
* @abstract Override $link IOInterruptEventSource::normalInterruptOccured to make a filter callout. */
|
||||
virtual void normalInterruptOccurred(void *self, IOService *prov, int ind) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function disableInterruptOccurred
|
||||
* @abstract Override $link IOInterruptEventSource::disableInterruptOccurred to make a filter callout. */
|
||||
virtual void disableInterruptOccurred(void *self, IOService *prov, int ind) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOFilterInterruptEventSource, 7);
|
||||
};
|
||||
|
||||
#endif /* !_IOKIT_IOFILTERINTERRUPTEVENTSOURCE_H */
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOINTERLEAVEDMEMORYDESCRIPTOR_H
|
||||
#define _IOINTERLEAVEDMEMORYDESCRIPTOR_H
|
||||
|
||||
#include <IOKit/IOMemoryDescriptor.h>
|
||||
|
||||
/*! @class IOInterleavedMemoryDescriptor : public IOMemoryDescriptor
|
||||
* @abstract The IOInterleavedMemoryDescriptor object describes a memory area made up of portions of several other IOMemoryDescriptors.
|
||||
* @discussion The IOInterleavedMemoryDescriptor object represents interleaved ranges of memory, specified as an ordered list of portions of individual IOMemoryDescriptors. The portions are chained end-to-end to make up a single contiguous buffer. */
|
||||
|
||||
class IOInterleavedMemoryDescriptor : public IOMemoryDescriptor
|
||||
{
|
||||
OSDeclareDefaultStructors(IOInterleavedMemoryDescriptor);
|
||||
|
||||
protected:
|
||||
|
||||
IOByteCount _descriptorCapacity;
|
||||
UInt32 _descriptorCount;
|
||||
IOMemoryDescriptor ** _descriptors;
|
||||
IOByteCount * _descriptorOffsets;
|
||||
IOByteCount * _descriptorLengths;
|
||||
bool _descriptorPrepared;
|
||||
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
/*! @function withCapacity
|
||||
* @abstract Create an IOInterleavedMemoryDescriptor to describe a memory area made up of several other IOMemoryDescriptors.
|
||||
* @discussion This method creates and initializes an IOInterleavedMemoryDescriptor for memory consisting of portions of a number of other IOMemoryDescriptors, chained end-to-end (in the order they appear in the array) to represent a single contiguous memory buffer.
|
||||
* @param capacity The maximum number of IOMemoryDescriptors that may be subsequently added to this IOInterleavedMemoryDescriptor.
|
||||
* @param direction An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
|
||||
* @result The created IOInterleavedMemoryDescriptor on success, to be released by the caller, or zero on failure. */
|
||||
|
||||
static IOInterleavedMemoryDescriptor * withCapacity( IOByteCount capacity,
|
||||
IODirection direction);
|
||||
|
||||
/*! @function initWithCapacity
|
||||
* @abstract Initialize an IOInterleavedMemoryDescriptor to describe a memory area made up of several other IOMemoryDescriptors.
|
||||
* @discussion This method initializes an IOInterleavedMemoryDescriptor for memory consisting of portions of a number of other IOMemoryDescriptors, chained end-to-end (in the order they appear in the array) to represent a single contiguous memory buffer.
|
||||
* @param capacity The maximum number of IOMemoryDescriptors that may be subsequently added to this IOInterleavedMemoryDescriptor.
|
||||
* @param direction An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
|
||||
* @result The created IOInterleavedMemoryDescriptor on success, to be released by the caller, or zero on failure. */
|
||||
|
||||
virtual bool initWithCapacity( IOByteCount capacity,
|
||||
IODirection direction );
|
||||
|
||||
/*! @function clearMemoryDescriptors
|
||||
* @abstract Clear all of the IOMemoryDescriptors currently contained in and reset the IOInterleavedMemoryDescriptor.
|
||||
* @discussion Clears each IOMemoryDescriptor by completing (if needed) and releasing. The IOInterleavedMemoryDescriptor is then reset and may accept new descriptors up to the capacity specified when it was created.
|
||||
* @param direction An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures. */
|
||||
|
||||
virtual void clearMemoryDescriptors( IODirection direction = kIODirectionNone );
|
||||
|
||||
/*! @function setMemoryDescriptor
|
||||
* @abstract Add a portion of an IOMemoryDescriptor to the IOInterleavedMemoryDescriptor.
|
||||
* @discussion This method adds the portion of an IOMemoryDescriptor described by the offset and length parameters to the end of the IOInterleavedMemoryDescriptor. A single IOMemoryDescriptor may be added as many times as there is room for it. The offset and length must describe a portion entirely within the IOMemoryDescriptor.
|
||||
* @param descriptor An IOMemoryDescriptor to be added to the IOInterleavedMemoryDescriptor. Its direction must be compatible with that of the IOInterleavedMemoryDescriptor.
|
||||
* @param offset The offset into the IOMemoryDescriptor of the portion that will be added to the virtualized buffer.
|
||||
* @param length The length of the portion of the IOMemoryDescriptor to be added to the virtualized buffer.
|
||||
* @result Returns true the portion was successfully added. */
|
||||
|
||||
virtual bool setMemoryDescriptor( IOMemoryDescriptor * descriptor,
|
||||
IOByteCount offset,
|
||||
IOByteCount length );
|
||||
|
||||
/*! @function getPhysicalSegment
|
||||
* @abstract Break a memory descriptor into its physically contiguous segments.
|
||||
* @discussion This method returns the physical address of the byte at the given offset into the memory, and optionally the length of the physically contiguous segment from that offset.
|
||||
* @param offset A byte offset into the memory whose physical address to return.
|
||||
* @param length If non-zero, getPhysicalSegment will store here the length of the physically contiguous segement at the given offset.
|
||||
* @result A physical address, or zero if the offset is beyond the length of the memory. */
|
||||
|
||||
virtual addr64_t getPhysicalSegment( IOByteCount offset,
|
||||
IOByteCount * length,
|
||||
IOOptionBits options = 0 ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function prepare
|
||||
* @abstract Prepare the memory for an I/O transfer.
|
||||
* @discussion This involves paging in the memory, if necessary, and wiring it down for the duration of the transfer. The complete() method completes the processing of the memory after the I/O transfer finishes. This method need not called for non-pageable memory.
|
||||
* @param forDirection The direction of the I/O to be performed, or kIODirectionNone for the direction specified by the memory descriptor.
|
||||
* @result An IOReturn code. */
|
||||
|
||||
virtual IOReturn prepare(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function complete
|
||||
* @abstract Complete processing of the memory after an I/O transfer finishes.
|
||||
* @discussion This method should not be called unless a prepare was previously issued; the prepare() and complete() must occur in pairs, before and after an I/O transfer involving pageable memory.
|
||||
* @param forDirection The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
|
||||
* @result An IOReturn code. */
|
||||
|
||||
virtual IOReturn complete(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif /* !_IOINTERLEAVEDMEMORYDESCRIPTOR_H */
|
||||
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* DRI: Josh de Cesare
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _IOKIT_IOINTERRUPTCONTROLLER_H
|
||||
#define _IOKIT_IOINTERRUPTCONTROLLER_H
|
||||
|
||||
#include <IOKit/IOLocks.h>
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/IOInterrupts.h>
|
||||
|
||||
|
||||
class IOSharedInterruptController;
|
||||
|
||||
struct IOInterruptVector {
|
||||
volatile char interruptActive;
|
||||
volatile char interruptDisabledSoft;
|
||||
volatile char interruptDisabledHard;
|
||||
volatile char interruptRegistered;
|
||||
IOLock * interruptLock;
|
||||
IOService * nub;
|
||||
int source;
|
||||
void * target;
|
||||
IOInterruptHandler handler;
|
||||
void * refCon;
|
||||
IOSharedInterruptController *sharedController;
|
||||
};
|
||||
|
||||
typedef struct IOInterruptVector IOInterruptVector;
|
||||
|
||||
#if __LP64__
|
||||
typedef int32_t IOInterruptVectorNumber;
|
||||
#else
|
||||
typedef long IOInterruptVectorNumber;
|
||||
#endif
|
||||
|
||||
class IOInterruptController : public IOService
|
||||
{
|
||||
OSDeclareAbstractStructors(IOInterruptController);
|
||||
|
||||
protected:
|
||||
IOInterruptVector *vectors;
|
||||
IOSimpleLock *controllerLock;
|
||||
|
||||
struct ExpansionData { };
|
||||
ExpansionData *ioic_reserved;
|
||||
|
||||
public:
|
||||
virtual IOReturn registerInterrupt(IOService *nub, int source,
|
||||
void *target,
|
||||
IOInterruptHandler handler,
|
||||
void *refCon);
|
||||
virtual IOReturn unregisterInterrupt(IOService *nub, int source);
|
||||
|
||||
virtual IOReturn getInterruptType(IOService *nub, int source,
|
||||
int *interruptType);
|
||||
|
||||
virtual IOReturn enableInterrupt(IOService *nub, int source);
|
||||
virtual IOReturn disableInterrupt(IOService *nub, int source);
|
||||
virtual IOReturn causeInterrupt(IOService *nub, int source);
|
||||
|
||||
virtual IOInterruptAction getInterruptHandlerAddress(void);
|
||||
virtual IOReturn handleInterrupt(void *refCon, IOService *nub,
|
||||
int source);
|
||||
|
||||
// Methods to be overridden for simplifed interrupt controller subclasses.
|
||||
|
||||
virtual bool vectorCanBeShared(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
|
||||
virtual void initVector(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
|
||||
virtual int getVectorType(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
|
||||
virtual void disableVectorHard(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
|
||||
virtual void enableVector(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
|
||||
virtual void causeVector(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
|
||||
|
||||
OSMetaClassDeclareReservedUnused(IOInterruptController, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOInterruptController, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOInterruptController, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOInterruptController, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOInterruptController, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOInterruptController, 5);
|
||||
|
||||
public:
|
||||
// Generic methods (not to be overriden).
|
||||
|
||||
void timeStampSpuriousInterrupt(void);
|
||||
void timeStampInterruptHandlerStart(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
|
||||
void timeStampInterruptHandlerEnd(IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
|
||||
|
||||
private:
|
||||
void timeStampInterruptHandlerInternal(bool isStart, IOInterruptVectorNumber vectorNumber, IOInterruptVector *vector);
|
||||
};
|
||||
|
||||
|
||||
class IOSharedInterruptController : public IOInterruptController
|
||||
{
|
||||
OSDeclareDefaultStructors(IOSharedInterruptController);
|
||||
|
||||
private:
|
||||
IOService *provider;
|
||||
int numVectors;
|
||||
int vectorsRegistered;
|
||||
int vectorsEnabled;
|
||||
volatile int controllerDisabled;
|
||||
bool sourceIsLevel;
|
||||
|
||||
struct ExpansionData { };
|
||||
ExpansionData *iosic_reserved __unused;
|
||||
|
||||
public:
|
||||
virtual IOReturn initInterruptController(IOInterruptController *parentController, OSData *parentSource);
|
||||
|
||||
virtual IOReturn registerInterrupt(IOService *nub, int source,
|
||||
void *target,
|
||||
IOInterruptHandler handler,
|
||||
void *refCon) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn unregisterInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOReturn getInterruptType(IOService *nub, int source,
|
||||
int *interruptType) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOReturn enableInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn disableInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOInterruptAction getInterruptHandlerAddress(void) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn handleInterrupt(void *refCon, IOService *nub, int source) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOSharedInterruptController, 3);
|
||||
};
|
||||
|
||||
|
||||
#endif /* ! _IOKIT_IOINTERRUPTCONTROLLER_H */
|
||||
@@ -0,0 +1,260 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* HISTORY
|
||||
* 1998-7-13 Godfrey van der Linden(gvdl)
|
||||
* Created.
|
||||
* 1998-10-30 Godfrey van der Linden(gvdl)
|
||||
* Converted to C++
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IOINTERRUPTEVENTSOURCE_H
|
||||
#define _IOKIT_IOINTERRUPTEVENTSOURCE_H
|
||||
|
||||
#include <IOKit/IOEventSource.h>
|
||||
|
||||
class IOService;
|
||||
|
||||
struct IOInterruptAccountingData;
|
||||
|
||||
/*! @class IOInterruptEventSource : public IOEventSource
|
||||
* @abstract Event source for interrupt delivery to work-loop based drivers.
|
||||
* @discussion The IOInterruptEventSource is a generic object that delivers calls interrupt routines in it's client in a guaranteed single-threaded manner. IOInterruptEventSource is part of the IOKit $link IOWorkLoop infrastructure where the semantic that one and only one action method is executing within a work-loops event chain.
|
||||
* <br><br>
|
||||
* When the action method is called in the client member function will receive 2 arguments, (IOEventSource *) sender and (int) count, See $link IOInterruptEventSource::Action. Where sender will be reference to the interrupt that occurred and the count will be computed by the difference between the $link producerCount and $link consumerCount. This number may not be reliable as no attempt is made to adjust for around the world type problems but is provided for general information and statistic gathering.
|
||||
* <br><br>
|
||||
* In general a client will use the factory member function to create and initialise the event source and then add it to their work-loop. It is the work loop's responsiblity to maintain the new event source in it's event chain. See $link IOWorkLoop.
|
||||
* <br><br>
|
||||
* An interrupt event source attaches itself to the given provider's interrupt source at initialisation time. At this time it determines if it is connected to a level or edge triggered interrupt. If the interrupt is an level triggered interrupt the event source automatically disables the interrupt source at primary interrupt time and after it call's the client it automatically reenables the interrupt. This action is fairly expensive but it is 100% safe and defaults sensibly so that the driver writer does not have to implement type dependant interrupt routines. So to repeat, the driver writer does not have to be concerned by the actual underlying interrupt mechanism as the event source hides the complexity.
|
||||
* <br><br>
|
||||
* Saying this if the hardware is a multi-device card, for instance a 4 port NIC, where all of the devices are sharing one level triggered interrupt AND it is possible to determine each port's interrupt state non-destructively then the $link IOFilterInterruptEventSource would be a better choice.
|
||||
* <br><br>
|
||||
* Warning: All IOInterruptEventSources are created in the disabled state. If you want to actually schedule interrupt delivery do not forget to enable the source.
|
||||
*/
|
||||
class IOInterruptEventSource : public IOEventSource
|
||||
{
|
||||
OSDeclareDefaultStructors(IOInterruptEventSource);
|
||||
|
||||
public:
|
||||
/*! @typedef Action
|
||||
* @discussion 'C' pointer prototype of functions that are called in a single threaded context when an interrupt occurs.
|
||||
* @param owner Pointer to client instance.
|
||||
* @param sender Pointer to generation interrupt event source.
|
||||
* @param count Number of interrupts seen before delivery. */
|
||||
typedef void (*Action)(OSObject *owner, IOInterruptEventSource *sender, int count);
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
typedef void (^ActionBlock)(IOInterruptEventSource *sender, int count);
|
||||
#endif /* __BLOCKS__ */
|
||||
|
||||
/*! @defined IOInterruptEventAction
|
||||
* @discussion Backward compatibilty define for the old non-class scoped type definition. See $link IOInterruptEventSource::Action */
|
||||
#define IOInterruptEventAction IOInterruptEventSource::Action
|
||||
|
||||
protected:
|
||||
/*! @var provider IOService that provides interrupts for delivery. */
|
||||
IOService *provider;
|
||||
|
||||
/*! @var intIndex */
|
||||
int intIndex;
|
||||
|
||||
/*! @var producerCount
|
||||
* Current count of produced interrupts that have been received. */
|
||||
volatile unsigned int producerCount;
|
||||
|
||||
/*! @var consumerCount
|
||||
* Current count of produced interrupts that the owner has been informed of. */
|
||||
unsigned int consumerCount;
|
||||
|
||||
/*! @var autoDisable Do we need to automatically disable the interrupt source when we take an interrupt, i.e. we are level triggered. */
|
||||
bool autoDisable;
|
||||
|
||||
/*! @var explicitDisable Has the user expicitly disabled this event source, if so then do not overide their request when returning from the callout */
|
||||
bool explicitDisable;
|
||||
|
||||
/*! @struct ExpansionData
|
||||
* @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
|
||||
*/
|
||||
struct ExpansionData {
|
||||
IOInterruptAccountingData * statistics;
|
||||
};
|
||||
|
||||
/*! @var reserved
|
||||
* Reserved for future use. (Internal use only) */
|
||||
APPLE_KEXT_WSHADOW_PUSH;
|
||||
ExpansionData *reserved;
|
||||
APPLE_KEXT_WSHADOW_POP;
|
||||
|
||||
/*! @function free
|
||||
* @abstract Sub-class implementation of free method, disconnects from the interrupt source. */
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function checkForWork
|
||||
* @abstract Pure Virtual member function used by IOWorkLoop for issueing a client calls.
|
||||
* @discussion This function called when the work-loop is ready to check for any work to do and then to call out the owner/action.
|
||||
* @result Return true if this function needs to be called again before all its outstanding events have been processed. */
|
||||
virtual bool checkForWork() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function setWorkLoop
|
||||
* @abstract Sub-class implementation of setWorkLoop method. */
|
||||
virtual void setWorkLoop(IOWorkLoop *inWorkLoop) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
/*! @function interruptEventSource
|
||||
* @abstract Factory function for IOInterruptEventSources creation and initialisation.
|
||||
* @param owner Owning client of the new event source.
|
||||
* @param action 'C' Function to call when something happens.
|
||||
* @param provider IOService that represents the interrupt source. Defaults to 0. When no provider is defined the event source assumes that the client will in some manner call the interruptOccured method explicitly. This will start the ball rolling for safe delivery of asynchronous event's into the driver.
|
||||
* @param intIndex The index of the interrupt within the provider's interrupt sources. Defaults to 0, i.e. the first interrupt in the provider.
|
||||
* @result A new interrupt event source if successfully created and initialised, 0 otherwise. */
|
||||
static IOInterruptEventSource *
|
||||
interruptEventSource(OSObject *owner,
|
||||
Action action,
|
||||
IOService *provider = NULL,
|
||||
int intIndex = 0);
|
||||
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
/*! @function interruptEventSource
|
||||
* @abstract Factory function for IOInterruptEventSources creation and initialisation.
|
||||
* @param owner Owning client of the new event source.
|
||||
* @param provider IOService that represents the interrupt source. When no provider is defined the event source assumes that the client will in some manner call the interruptOccured method explicitly. This will start the ball rolling for safe delivery of asynchronous event's into the driver.
|
||||
* @param intIndex The index of the interrupt within the provider's interrupt sources.
|
||||
* @param action Block for the callout routine of this event source..
|
||||
* @result A new interrupt event source if successfully created and initialised, 0 otherwise. */
|
||||
static IOInterruptEventSource *
|
||||
interruptEventSource(OSObject *owner,
|
||||
IOService *provider,
|
||||
int intIndex,
|
||||
ActionBlock action);
|
||||
#endif /* __BLOCKS__ */
|
||||
|
||||
|
||||
/*! @function init
|
||||
* @abstract Primary initialiser for the IOInterruptEventSource class.
|
||||
* @param owner Owning client of the new event source.
|
||||
* @param action 'C' Function to call when something happens.
|
||||
* @param provider IOService that represents the interrupt source. Defaults to 0. When no provider is defined the event source assumes that the client will in some manner call the interruptOccured method explicitly. This will start the ball rolling for safe delivery of asynchronous event's into the driver.
|
||||
* @param intIndex The index of the interrupt within the provider's interrupt sources. Defaults to 0, i.e. the first interrupt in the provider.
|
||||
* @result true if the inherited classes and this instance initialise
|
||||
* successfully. */
|
||||
virtual bool init(OSObject *owner,
|
||||
Action action,
|
||||
IOService *provider = NULL,
|
||||
int intIndex = 0);
|
||||
|
||||
/*! @function enable
|
||||
* @abstract Enable event source.
|
||||
* @discussion A subclass implementation is expected to respect the enabled
|
||||
* state when checkForWork is called. Calling this function will cause the
|
||||
* work-loop to be signalled so that a checkForWork is performed. */
|
||||
virtual void enable() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function disable
|
||||
* @abstract Disable event source.
|
||||
* @discussion A subclass implementation is expected to respect the enabled
|
||||
* state when checkForWork is called. */
|
||||
virtual void disable() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function getProvider
|
||||
* @abstract Get'ter for $link provider variable.
|
||||
* @result value of provider. */
|
||||
virtual const IOService *getProvider() const;
|
||||
|
||||
/*! @function getIntIndex
|
||||
* @abstract Get'ter for $link intIndex interrupt index variable.
|
||||
* @result value of intIndex. */
|
||||
virtual int getIntIndex() const;
|
||||
|
||||
/*! @function getAutoDisable
|
||||
* @abstract Get'ter for $link autoDisable variable.
|
||||
* @result value of autoDisable. */
|
||||
virtual bool getAutoDisable() const;
|
||||
|
||||
/*! @function interruptOccurred
|
||||
* @abstract Functions that get called by the interrupt controller. See $link IOService::registerInterrupt
|
||||
* @param nub Where did the interrupt originate from
|
||||
* @param ind What is this interrupts index within 'nub'. */
|
||||
virtual void interruptOccurred(void *, IOService *nub, int ind);
|
||||
|
||||
/*! @function normalInterruptOccurred
|
||||
* @abstract Functions that get called by the interrupt controller.See $link IOService::registerInterrupt
|
||||
* @param nub Where did the interrupt originate from
|
||||
* @param ind What is this interrupts index within 'nub'. */
|
||||
virtual void normalInterruptOccurred(void *, IOService *nub, int ind);
|
||||
|
||||
/*! @function disableInterruptOccurred
|
||||
* @abstract Functions that get called by the interrupt controller.See $link IOService::registerInterrupt
|
||||
* @param nub Where did the interrupt originate from
|
||||
* @param ind What is this interrupts index within 'nub'. */
|
||||
virtual void disableInterruptOccurred(void *, IOService *nub, int ind);
|
||||
|
||||
/*! @function warmCPU
|
||||
* @abstract Tries to reduce latency for an interrupt which will be received near a specified time.
|
||||
* @discussion Warms up a CPU in advance of an interrupt so that the interrupt may be serviced with predictable latency.
|
||||
* The warm-up is not periodic; callers should call warmCPU once in advance of each interrupt. It is recommended that
|
||||
* requests be issues in serial (i.e. each after the target for the previous call has elapsed), as there is a systemwide
|
||||
* cap on the number of outstanding requests. This routine may be disruptive to the system if used with very small intervals
|
||||
* between requests; it should be used only in cases where interrupt latency is absolutely critical, and tens or hundreds of
|
||||
* milliseconds between targets is the expected time scale. NOTE: it is not safe to call this method with interrupts disabled.
|
||||
* @param abstime Time at which interrupt is expected. */
|
||||
IOReturn warmCPU(uint64_t abstime);
|
||||
|
||||
/*! @function enablePrimaryInterruptTimestamp
|
||||
* @abstract Enables collection of mach_absolute_time at primary interrupt.
|
||||
* @discussion Enables collection of mach_absolute_time at primary interrupt.
|
||||
* @param enable True to enable timestamp. */
|
||||
|
||||
void enablePrimaryInterruptTimestamp(bool enable);
|
||||
|
||||
/*! @function getPimaryInterruptTimestamp
|
||||
* @abstract Returns mach_absolute_time timestamp of primary interrupt.
|
||||
* @discussion Returns mach_absolute_time timestamp of primary interrupt.
|
||||
* @result Value of the timestamp. Zero if never interrupted, or -1ULL if timestamp collection has not been enabled. */
|
||||
|
||||
uint64_t getPimaryInterruptTimestamp();
|
||||
|
||||
private:
|
||||
IOReturn registerInterruptHandler(IOService *inProvider, int inIntIndex);
|
||||
void unregisterInterruptHandler(IOService *inProvider, int inIntIndex);
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOInterruptEventSource, 7);
|
||||
};
|
||||
|
||||
#endif /* !_IOKIT_IOINTERRUPTEVENTSOURCE_H */
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* DRI: Josh de Cesare
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _IOKIT_IOINTERRUPTS_H
|
||||
#define _IOKIT_IOINTERRUPTS_H
|
||||
|
||||
#define kIOInterruptTypeEdge (0)
|
||||
#define kIOInterruptTypeLevel (1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class OSData;
|
||||
class IOInterruptController;
|
||||
|
||||
struct IOInterruptSource {
|
||||
IOInterruptController *interruptController;
|
||||
OSData *vectorData;
|
||||
};
|
||||
typedef struct IOInterruptSource IOInterruptSource;
|
||||
|
||||
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef void (*IOInterruptHandler)(void *target, void *refCon,
|
||||
void *nub, int source);
|
||||
|
||||
#endif /* ! _IOKIT_IOINTERRUPTS_H */
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2014 Apple Computer, Inc. All Rights Reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
// Internal data structures to be used by IOReporters and User Space Observers
|
||||
|
||||
|
||||
#ifndef _IOKERNELREPORTSTRUCTS_H_
|
||||
#define _IOKERNELREPORTSTRUCTS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <IOKit/IOReportTypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Drivers participating in IOReporting can advertise channels by
|
||||
// publishing properties in the I/O Kit registry. Various helper
|
||||
// mechanisms exist to produce correctly-formatted legends.
|
||||
// 12836893 tracks advertising channels in user space.
|
||||
#define kIOReportLegendPublicKey "IOReportLegendPublic" // bool
|
||||
#define kIOReportLegendKey "IOReportLegend" // arr
|
||||
#define kIOReportLegendChannelsKey "IOReportChannels" // arr
|
||||
#define kIOReportLegendGroupNameKey "IOReportGroupName" // str
|
||||
#define kIOReportLegendSubGroupNameKey "IOReportSubGroupName" // str
|
||||
#define kIOReportLegendInfoKey "IOReportChannelInfo" // dict
|
||||
#define kIOReportLegendUnitKey "IOReportChannelUnit" // num
|
||||
#define kIOReportLegendConfigKey "IOReportChannelConfig" // data
|
||||
#define kIOReportLegendStateNamesKey "IOReportChannelStateNames" // str[]
|
||||
|
||||
// in an I/O Kit registry legend, a small "array struct" represents a channel
|
||||
#define kIOReportChannelIDIdx 0 // required
|
||||
#define kIOReportChannelTypeIdx 1 // required
|
||||
#define kIOReportChannelNameIdx 2 // optional
|
||||
|
||||
/* Histogram Segment Configuration
|
||||
* Currently supports 2 types of scaling to compute bucket upper bounds,
|
||||
* linear or exponential.
|
||||
* scale_flag = 0 -> linear scale
|
||||
* 1 -> exponential scale
|
||||
* upper_bound[n] = (scale_flag) ? pow(base,(n+1)) : base * (n+1);
|
||||
*/
|
||||
#define kIOHistogramScaleLinear 0
|
||||
#define kIOHistogramScaleExponential 1
|
||||
typedef struct {
|
||||
uint32_t base_bucket_width;// segment[0].bucket[0] = [0, base_width]
|
||||
uint32_t scale_flag; // bit 0 only in current use (see #defs)
|
||||
uint32_t segment_idx; // for multiple segments histograms
|
||||
uint32_t segment_bucket_count;// number of buckets in this segment
|
||||
} __attribute((packed)) IOHistogramSegmentConfig;
|
||||
|
||||
// "normalized distribution"(FIXME?) internal format (unused?)
|
||||
typedef struct {
|
||||
uint64_t samples;
|
||||
uint64_t mean;
|
||||
uint64_t variance;
|
||||
uint64_t reserved;
|
||||
} __attribute((packed)) IONormDistReportValues;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _IOKERNELREPORTSTRUCTS_H_
|
||||
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IOKITDEBUG_H
|
||||
#define _IOKIT_IOKITDEBUG_H
|
||||
|
||||
#include <IOKit/IOTypes.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <libkern/c++/OSObject.h>
|
||||
#include <libkern/c++/OSDictionary.h>
|
||||
#include <libkern/c++/OSSerialize.h>
|
||||
|
||||
class IOKitDiagnostics : public OSObject
|
||||
{
|
||||
OSDeclareDefaultStructors(IOKitDiagnostics);
|
||||
|
||||
public:
|
||||
static OSObject * diagnostics( void );
|
||||
virtual bool serialize(OSSerialize *s) const APPLE_KEXT_OVERRIDE;
|
||||
private:
|
||||
static void updateOffset( OSDictionary * dict,
|
||||
UInt64 value, const char * name );
|
||||
};
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
enum {
|
||||
// loggage
|
||||
kIOLogAttach = 0x00000001ULL,
|
||||
kIOLogProbe = 0x00000002ULL,
|
||||
kIOLogStart = 0x00000004ULL,
|
||||
kIOLogRegister = 0x00000008ULL,
|
||||
kIOLogMatch = 0x00000010ULL,
|
||||
kIOLogConfig = 0x00000020ULL,
|
||||
kIOLogYield = 0x00000040ULL,
|
||||
kIOLogPower = 0x00000080ULL,
|
||||
kIOLogMapping = 0x00000100ULL,
|
||||
kIOLogCatalogue = 0x00000200ULL,
|
||||
kIOLogTracePower = 0x00000400ULL, // Obsolete: Use iotrace=0x00000400ULL to enable now
|
||||
kIOLogDebugPower = 0x00000800ULL,
|
||||
kIOLogServiceTree = 0x00001000ULL,
|
||||
kIOLogDTree = 0x00002000ULL,
|
||||
kIOLogMemory = 0x00004000ULL,
|
||||
kIOLogKextMemory = 0x00008000ULL,
|
||||
kOSLogRegistryMods = 0x00010000ULL,// Log attempts to modify registry collections
|
||||
kIOLogPMRootDomain = 0x00020000ULL,
|
||||
kOSRegistryModsMode = 0x00040000ULL,// Change default registry modification handling - panic vs. log
|
||||
// kIOTraceIOService = 0x00080000ULL, // Obsolete: Use iotrace=0x00080000ULL to enable now
|
||||
kIOLogHibernate = 0x00100000ULL,
|
||||
kIOStatistics = 0x04000000ULL,
|
||||
kIOSleepWakeWdogOff = 0x40000000ULL,
|
||||
kIOKextSpinDump = 0x80000000ULL,
|
||||
|
||||
// debug aids - change behaviour
|
||||
kIONoFreeObjects = 0x00100000ULL,
|
||||
// kIOLogSynchronous = 0x00200000ULL, // IOLog completes synchronously -- obsolete
|
||||
kIOTracking = 0x00400000ULL,
|
||||
kIOWaitQuietPanics = 0x00800000ULL,
|
||||
kIOWaitQuietBeforeRoot = 0x01000000ULL,
|
||||
kIOTrackingBoot = 0x02000000ULL,
|
||||
|
||||
_kIODebugTopFlag = 0x8000000000000000ULL// force enum to be 64 bits
|
||||
};
|
||||
|
||||
enum {
|
||||
kIOKitDebugUserOptions = 0
|
||||
| kIOLogAttach
|
||||
| kIOLogProbe
|
||||
| kIOLogStart
|
||||
| kIOLogRegister
|
||||
| kIOLogMatch
|
||||
| kIOLogConfig
|
||||
| kIOLogYield
|
||||
| kIOLogPower
|
||||
| kIOLogMapping
|
||||
| kIOLogCatalogue
|
||||
| kIOLogTracePower
|
||||
| kIOLogDebugPower
|
||||
| kOSLogRegistryMods
|
||||
| kIOLogPMRootDomain
|
||||
| kOSRegistryModsMode
|
||||
| kIOLogHibernate
|
||||
| kIOSleepWakeWdogOff
|
||||
| kIOKextSpinDump
|
||||
| kIOWaitQuietPanics
|
||||
};
|
||||
|
||||
enum {
|
||||
kIOTraceInterrupts = 0x00000001ULL, // Trace primary interrupts
|
||||
kIOTraceWorkLoops = 0x00000002ULL, // Trace workloop activity
|
||||
kIOTraceEventSources = 0x00000004ULL, // Trace non-passive event sources
|
||||
kIOTraceIntEventSource = 0x00000008ULL, // Trace IOIES and IOFIES sources
|
||||
kIOTraceCommandGates = 0x00000010ULL, // Trace command gate activity
|
||||
kIOTraceTimers = 0x00000020ULL, // Trace timer event source activity
|
||||
|
||||
kIOTracePowerMgmt = 0x00000400ULL, // Trace power management changes
|
||||
|
||||
kIOTraceIOService = 0x00080000ULL, // registerService/termination
|
||||
|
||||
kIOTraceCompatBootArgs = kIOTraceIOService | kIOTracePowerMgmt
|
||||
};
|
||||
|
||||
enum {
|
||||
kIODKEnable = 0x00000001ULL,
|
||||
kIODKLogSetup = 0x00000002ULL,
|
||||
kIODKLogIPC = 0x00000004ULL,
|
||||
kIODKLogPM = 0x00000008ULL,
|
||||
kIODKLogMessages = 0x00000010ULL,
|
||||
|
||||
kIODKDisablePM = 0x000000100ULL,
|
||||
kIODKDisableDextLaunch = 0x00001000ULL,
|
||||
kIODKDisableDextTag = 0x00002000ULL,
|
||||
kIODKDisableCDHashChecking = 0x00004000ULL,
|
||||
kIODKDisableEntitlementChecking = 0x00008000ULL,
|
||||
};
|
||||
|
||||
|
||||
extern SInt64 gIOKitDebug;
|
||||
extern SInt64 gIOKitTrace;
|
||||
extern SInt64 gIODKDebug;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
class IORegistryPlane;
|
||||
#endif
|
||||
|
||||
extern void IOPrintPlane(
|
||||
#ifdef __cplusplus
|
||||
const IORegistryPlane * plane
|
||||
#else
|
||||
const struct IORegistryPlane * plane
|
||||
#endif
|
||||
);
|
||||
#ifndef _OSCPPDEBUG_H
|
||||
extern void OSPrintMemory( void );
|
||||
#endif
|
||||
#define IOPrintMemory OSPrintMemory
|
||||
|
||||
|
||||
|
||||
#define kIOKitDiagnosticsClientClassName "IOKitDiagnosticsClient"
|
||||
|
||||
enum{
|
||||
kIOKitDiagnosticsClientType = 0x99000002
|
||||
};
|
||||
|
||||
|
||||
struct IOKitDiagnosticsParameters {
|
||||
size_t size;
|
||||
uint64_t value;
|
||||
uint32_t options;
|
||||
uint32_t tag;
|
||||
uint32_t zsize;
|
||||
uint32_t reserved[8];
|
||||
};
|
||||
typedef struct IOKitDiagnosticsParameters IOKitDiagnosticsParameters;
|
||||
|
||||
enum{
|
||||
kIOTrackingCallSiteBTs = 16,
|
||||
};
|
||||
|
||||
struct IOTrackingCallSiteInfo {
|
||||
uint32_t count;
|
||||
pid_t addressPID;
|
||||
mach_vm_address_t address;
|
||||
mach_vm_size_t size[2];
|
||||
pid_t btPID;
|
||||
mach_vm_address_t bt[2][kIOTrackingCallSiteBTs];
|
||||
};
|
||||
|
||||
#define kIOMallocTrackingName "IOMalloc"
|
||||
#define kIOWireTrackingName "IOWire"
|
||||
#define kIOMapTrackingName "IOMap"
|
||||
|
||||
|
||||
enum{
|
||||
kIOTrackingExcludeNames = 0x00000001,
|
||||
};
|
||||
|
||||
enum{
|
||||
kIOTrackingGetTracking = 0x00000001,
|
||||
kIOTrackingGetMappings = 0x00000002,
|
||||
kIOTrackingResetTracking = 0x00000003,
|
||||
kIOTrackingStartCapture = 0x00000004,
|
||||
kIOTrackingStopCapture = 0x00000005,
|
||||
kIOTrackingSetMinCaptureSize = 0x00000006,
|
||||
kIOTrackingLeaks = 0x00000007,
|
||||
kIOTrackingInvalid = 0xFFFFFFFE,
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* ! _IOKIT_IOKITDEBUG_H */
|
||||
@@ -0,0 +1,17 @@
|
||||
/* * Copyright (c) 2019 Apple Inc. All rights reserved. */
|
||||
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/IOUserClient.h>
|
||||
|
||||
|
||||
class IOKitDiagnosticsClient : public IOUserClient
|
||||
{
|
||||
OSDeclareDefaultStructors(IOKitDiagnosticsClient);
|
||||
|
||||
public:
|
||||
static IOUserClient * withTask(task_t owningTask);
|
||||
virtual IOReturn clientClose(void) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn setProperties(OSObject * properties) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn externalMethod(uint32_t selector, IOExternalMethodArguments * args,
|
||||
IOExternalMethodDispatch * dispatch, OSObject * target, void * reference) APPLE_KEXT_OVERRIDE;
|
||||
};
|
||||
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* Common symbol definitions for IOKit.
|
||||
*
|
||||
* HISTORY
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _IOKIT_IOKITKEYS_H
|
||||
#define _IOKIT_IOKITKEYS_H
|
||||
|
||||
// properties found in the registry root
|
||||
#define kIOKitBuildVersionKey "IOKitBuildVersion"
|
||||
#define kIOKitDiagnosticsKey "IOKitDiagnostics"
|
||||
// a dictionary keyed by plane name
|
||||
#define kIORegistryPlanesKey "IORegistryPlanes"
|
||||
#define kIOCatalogueKey "IOCatalogue"
|
||||
|
||||
// registry plane names
|
||||
#define kIOServicePlane "IOService"
|
||||
#define kIOPowerPlane "IOPower"
|
||||
#define kIODeviceTreePlane "IODeviceTree"
|
||||
#define kIOAudioPlane "IOAudio"
|
||||
#define kIOFireWirePlane "IOFireWire"
|
||||
#define kIOUSBPlane "IOUSB"
|
||||
|
||||
// registry ID number
|
||||
#define kIORegistryEntryIDKey "IORegistryEntryID"
|
||||
// property name to get array of property names
|
||||
#define kIORegistryEntryPropertyKeysKey "IORegistryEntryPropertyKeys"
|
||||
|
||||
// IOService class name
|
||||
#define kIOServiceClass "IOService"
|
||||
|
||||
// IOResources class name
|
||||
#define kIOResourcesClass "IOResources"
|
||||
|
||||
// IOService driver probing property names
|
||||
#define kIOClassKey "IOClass"
|
||||
#define kIOProbeScoreKey "IOProbeScore"
|
||||
#define kIOKitDebugKey "IOKitDebug"
|
||||
|
||||
// Properties to be supported as API
|
||||
#define kIOSupportedPropertiesKey "IOSupportedProperties"
|
||||
// Properties writable by dexts
|
||||
#define kIOUserServicePropertiesKey "IOUserServiceProperties"
|
||||
|
||||
|
||||
// IOService matching property names
|
||||
#define kIOProviderClassKey "IOProviderClass"
|
||||
#define kIONameMatchKey "IONameMatch"
|
||||
#define kIOPropertyMatchKey "IOPropertyMatch"
|
||||
#define kIOPropertyExistsMatchKey "IOPropertyExistsMatch"
|
||||
#define kIOPathMatchKey "IOPathMatch"
|
||||
#define kIOLocationMatchKey "IOLocationMatch"
|
||||
#define kIOParentMatchKey "IOParentMatch"
|
||||
#define kIOResourceMatchKey "IOResourceMatch"
|
||||
#define kIOResourceMatchedKey "IOResourceMatched"
|
||||
#define kIOMatchedServiceCountKey "IOMatchedServiceCountMatch"
|
||||
|
||||
#define kIONameMatchedKey "IONameMatched"
|
||||
|
||||
#define kIOMatchCategoryKey "IOMatchCategory"
|
||||
#define kIODefaultMatchCategoryKey "IODefaultMatchCategory"
|
||||
|
||||
#define kIOMatchedPersonalityKey "IOMatchedPersonality"
|
||||
#define kIORematchPersonalityKey "IORematchPersonality"
|
||||
#define kIORematchCountKey "IORematchCount"
|
||||
#define kIODEXTMatchCountKey "IODEXTMatchCount"
|
||||
|
||||
// Entitlements to check against dext process
|
||||
// Property is an array, one or more of which may match, of:
|
||||
// an array of entitlement strings, all must be present
|
||||
// Any array can be a single string.
|
||||
#define kIOServiceDEXTEntitlementsKey "IOServiceDEXTEntitlements"
|
||||
|
||||
// Entitlement required to open dext connection
|
||||
#define kIODriverKitEntitlementKey "com.apple.developer.driverkit"
|
||||
|
||||
// Entitlements required to open dext IOUserClient
|
||||
// Property is an array of strings containing CFBundleIdentifiers of service being opened
|
||||
#define kIODriverKitUserClientEntitlementsKey "com.apple.developer.driverkit.userclient-access"
|
||||
|
||||
// Entitlement of a dext that allows any task to open one of its IOUserClients
|
||||
#define kIODriverKitUserClientEntitlementAllowAnyKey "com.apple.developer.driverkit.allow-any-userclient-access"
|
||||
|
||||
// Other DriverKit entitlements
|
||||
#define kIODriverKitUSBTransportEntitlementKey "com.apple.developer.driverkit.transport.usb"
|
||||
#define kIODriverKitHIDTransportEntitlementKey "com.apple.developer.driverkit.transport.hid"
|
||||
#define kIODriverKitHIDFamilyDeviceEntitlementKey "com.apple.developer.driverkit.family.hid.device"
|
||||
#define kIODriverKitHIDFamilyEventServiceEntitlementKey "com.apple.developer.driverkit.family.hid.eventservice"
|
||||
#define kIODriverKitTransportBuiltinEntitlementKey "com.apple.developer.driverkit.builtin"
|
||||
|
||||
|
||||
// When possible, defer matching of this driver until kextd has started.
|
||||
#define kIOMatchDeferKey "IOMatchDefer"
|
||||
|
||||
// IOService default user client class, for loadable user clients
|
||||
#define kIOUserClientClassKey "IOUserClientClass"
|
||||
|
||||
// key to find IOMappers
|
||||
#define kIOMapperIDKey "IOMapperID"
|
||||
|
||||
#define kIOUserClientCrossEndianKey "IOUserClientCrossEndian"
|
||||
#define kIOUserClientCrossEndianCompatibleKey "IOUserClientCrossEndianCompatible"
|
||||
#define kIOUserClientSharedInstanceKey "IOUserClientSharedInstance"
|
||||
// diagnostic string describing the creating task
|
||||
#define kIOUserClientCreatorKey "IOUserClientCreator"
|
||||
// the expected cdhash value of the userspace driver executable
|
||||
#define kIOUserServerCDHashKey "IOUserServerCDHash"
|
||||
|
||||
#define kIOUserUserClientKey "IOUserUserClient"
|
||||
|
||||
|
||||
// IOService notification types
|
||||
#define kIOPublishNotification "IOServicePublish"
|
||||
#define kIOFirstPublishNotification "IOServiceFirstPublish"
|
||||
#define kIOMatchedNotification "IOServiceMatched"
|
||||
#define kIOFirstMatchNotification "IOServiceFirstMatch"
|
||||
#define kIOTerminatedNotification "IOServiceTerminate"
|
||||
#define kIOWillTerminateNotification "IOServiceWillTerminate"
|
||||
|
||||
// IOService interest notification types
|
||||
#define kIOGeneralInterest "IOGeneralInterest"
|
||||
#define kIOBusyInterest "IOBusyInterest"
|
||||
#define kIOAppPowerStateInterest "IOAppPowerStateInterest"
|
||||
#define kIOPriorityPowerStateInterest "IOPriorityPowerStateInterest"
|
||||
|
||||
#define kIOPlatformDeviceMessageKey "IOPlatformDeviceMessage"
|
||||
|
||||
// IOService interest notification types
|
||||
#define kIOCFPlugInTypesKey "IOCFPlugInTypes"
|
||||
|
||||
// properties found in services that implement command pooling
|
||||
#define kIOCommandPoolSizeKey "IOCommandPoolSize" // (OSNumber)
|
||||
|
||||
// properties found in services that implement priority
|
||||
#define kIOMaximumPriorityCountKey "IOMaximumPriorityCount" // (OSNumber)
|
||||
|
||||
// properties found in services that have transfer constraints
|
||||
#define kIOMaximumBlockCountReadKey "IOMaximumBlockCountRead" // (OSNumber)
|
||||
#define kIOMaximumBlockCountWriteKey "IOMaximumBlockCountWrite" // (OSNumber)
|
||||
#define kIOMaximumByteCountReadKey "IOMaximumByteCountRead" // (OSNumber)
|
||||
#define kIOMaximumByteCountWriteKey "IOMaximumByteCountWrite" // (OSNumber)
|
||||
#define kIOMaximumSegmentCountReadKey "IOMaximumSegmentCountRead" // (OSNumber)
|
||||
#define kIOMaximumSegmentCountWriteKey "IOMaximumSegmentCountWrite" // (OSNumber)
|
||||
#define kIOMaximumSegmentByteCountReadKey "IOMaximumSegmentByteCountRead" // (OSNumber)
|
||||
#define kIOMaximumSegmentByteCountWriteKey "IOMaximumSegmentByteCountWrite" // (OSNumber)
|
||||
#define kIOMinimumSegmentAlignmentByteCountKey "IOMinimumSegmentAlignmentByteCount" // (OSNumber)
|
||||
#define kIOMaximumSegmentAddressableBitCountKey "IOMaximumSegmentAddressableBitCount" // (OSNumber)
|
||||
#define kIOMinimumSaturationByteCountKey "IOMinimumSaturationByteCount" // (OSNumber)
|
||||
#define kIOMaximumSwapWriteKey "IOMaximumSwapWrite" // (OSNumber)
|
||||
|
||||
// properties found in services that wish to describe an icon
|
||||
//
|
||||
// IOIcon =
|
||||
// {
|
||||
// CFBundleIdentifier = "com.example.driver.example";
|
||||
// IOBundleResourceFile = "example.icns";
|
||||
// };
|
||||
//
|
||||
// where IOBundleResourceFile is the filename of the resource
|
||||
|
||||
#define kIOIconKey "IOIcon" // (OSDictionary)
|
||||
#define kIOBundleResourceFileKey "IOBundleResourceFile" // (OSString)
|
||||
|
||||
#define kIOBusBadgeKey "IOBusBadge" // (OSDictionary)
|
||||
#define kIODeviceIconKey "IODeviceIcon" // (OSDictionary)
|
||||
|
||||
// property of root that describes the machine's serial number as a string
|
||||
#define kIOPlatformSerialNumberKey "IOPlatformSerialNumber" // (OSString)
|
||||
|
||||
// property of root that describes the machine's UUID as a string
|
||||
#define kIOPlatformUUIDKey "IOPlatformUUID" // (OSString)
|
||||
|
||||
// IODTNVRAM property keys
|
||||
#define kIONVRAMBootArgsKey "boot-args"
|
||||
#define kIONVRAMDeletePropertyKey "IONVRAM-DELETE-PROPERTY"
|
||||
#define kIONVRAMSyncNowPropertyKey "IONVRAM-SYNCNOW-PROPERTY"
|
||||
#define kIONVRAMActivateCSRConfigPropertyKey "IONVRAM-ARMCSR-PROPERTY"
|
||||
#define kIODTNVRAMPanicInfoKey "aapl,panic-info"
|
||||
|
||||
// keys for complex boot information
|
||||
#define kIOBootDeviceKey "IOBootDevice" // dict | array of dicts
|
||||
#define kIOBootDevicePathKey "IOBootDevicePath" // arch-neutral OSString
|
||||
#define kIOBootDeviceSizeKey "IOBootDeviceSize" // OSNumber of bytes
|
||||
|
||||
// keys for OS Version information
|
||||
#define kOSBuildVersionKey "OS Build Version"
|
||||
|
||||
#endif /* ! _IOKIT_IOKITKEYS_H */
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2011 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* HISTORY
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Internal definitions used between the iokit user library and
|
||||
* server routines.
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IOKITSERVER_H
|
||||
#define _IOKIT_IOKITSERVER_H
|
||||
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include <IOKit/IOKitKeys.h>
|
||||
#include <IOKit/OSMessageNotification.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <mach/kmod.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// IOCatalogueSendData
|
||||
/*!
|
||||
* @enum IOCatalogueSendData user-client flags.
|
||||
* @constant kIOCatalogAddDrivers Signals a call to the addDrivers function in IOCatalogue.
|
||||
* @constant kIOCatalogAddDriversNoMatch Signals a call to the addDrivers function in IOCatalogue but does not start a matching thread.
|
||||
* @constant kIOCatalogRemoveDrivers Signals a call to the removeDrivers function in IOCatalogue.
|
||||
* @constant kIOCatalogRemoveDriversNoMatch Signals a call to the removedrivers function in IOCatalogue but does not start a matching thread.
|
||||
* @constant kIOCatalogStartMatching Signals the IOCatalogue to start an IOService matching thread.
|
||||
* @constant kIOCatalogRemoveKernelLinker Deprecated; does nothing.
|
||||
* @constant kIOCatalogKextdActive Signals the kernel that kextd is running.
|
||||
* @constant kIOCatalogKextdFinishedLaunching Signals the IOCatalogue that kextd has finished sending it information at startup.
|
||||
* @constant kIOCatalogResetDrivers Resets the IOCatalogue with a new set of personalities.
|
||||
* @constant kIOCatalogResetDriversNoMatch Resets the IOCatalogue with a new set of personalities but does not start a matching thread.
|
||||
*/
|
||||
enum {
|
||||
kIOCatalogAddDrivers = 1,
|
||||
kIOCatalogAddDriversNoMatch,
|
||||
kIOCatalogRemoveDrivers,
|
||||
kIOCatalogRemoveDriversNoMatch,
|
||||
kIOCatalogStartMatching__Removed,
|
||||
kIOCatalogRemoveKernelLinker__Removed,
|
||||
kIOCatalogKextdActive,
|
||||
kIOCatalogKextdFinishedLaunching,
|
||||
kIOCatalogResetDrivers,
|
||||
kIOCatalogResetDriversNoMatch
|
||||
};
|
||||
|
||||
// IOCatalogueGetData
|
||||
/*!
|
||||
* @enum IOCatalogueGetData user-client flags
|
||||
* @constant kIOCatalogGetContents Returns a snapshot of the database to the caller.
|
||||
*/
|
||||
enum {
|
||||
kIOCatalogGetContents = 1,
|
||||
kIOCatalogGetModuleDemandList = 2,
|
||||
kIOCatalogGetCacheMissList = 3,
|
||||
kIOCatalogGetROMMkextList = 4
|
||||
};
|
||||
|
||||
// IOCatalogueReset
|
||||
/*!
|
||||
* @enum IOCatalogueReset user-client flag
|
||||
* @constant kIOCatalogResetDefault Removes all entries from IOCatalogue except those used for booting the system.
|
||||
*/
|
||||
enum {
|
||||
kIOCatalogResetDefault = 1
|
||||
};
|
||||
|
||||
// IOCatalogueTerminate
|
||||
/*!
|
||||
* @enum IOCatalogueTerminate user-client flags.
|
||||
* @constant kIOCatalogModuleUnload Terminates all services which depend on a particular module and unloads the module.
|
||||
* @constant kIOCatalogModuleTerminate Terminates all services which depend on a particular module but does not unload the module.
|
||||
* @constant kIOCatalogServiceTerminate Terminates a particular service by name.
|
||||
*/
|
||||
enum {
|
||||
kIOCatalogModuleUnload = 1,
|
||||
kIOCatalogModuleTerminate,
|
||||
kIOCatalogServiceTerminate
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* ! _IOKIT_IOKITSERVER_H */
|
||||
@@ -0,0 +1,450 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2016 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* HISTORY
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __IOKIT_IOLIB_H
|
||||
#define __IOKIT_IOLIB_H
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <os/overflow.h>
|
||||
|
||||
#include <sys/appleapiopts.h>
|
||||
|
||||
#include <IOKit/system.h>
|
||||
|
||||
#include <IOKit/IOReturn.h>
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include <IOKit/IOLocks.h>
|
||||
|
||||
#include <libkern/OSAtomic.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <kern/thread_call.h>
|
||||
#include <kern/clock.h>
|
||||
|
||||
/*
|
||||
* min/max macros.
|
||||
*/
|
||||
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
/*
|
||||
* These are opaque to the user.
|
||||
*/
|
||||
typedef thread_t IOThread;
|
||||
typedef void (*IOThreadFunc)(void *argument);
|
||||
|
||||
/*
|
||||
* Memory allocation functions.
|
||||
*/
|
||||
|
||||
/*! @function IOMalloc
|
||||
* @abstract Allocates general purpose, wired memory in the kernel map.
|
||||
* @discussion This is a general purpose utility to allocate memory in the kernel. There are no alignment guarantees given on the returned memory, and alignment may vary depending on the kernel configuration. This function may block and so should not be called from interrupt level or while a simple lock is held.
|
||||
* @param size Size of the memory requested.
|
||||
* @result Pointer to the allocated memory, or zero on failure. */
|
||||
|
||||
void * IOMalloc(vm_size_t size) __attribute__((alloc_size(1)));
|
||||
void * IOMallocZero(vm_size_t size) __attribute__((alloc_size(1)));
|
||||
|
||||
/*! @function IOFree
|
||||
* @abstract Frees memory allocated with IOMalloc.
|
||||
* @discussion This function frees memory allocated with IOMalloc, it may block and so should not be called from interrupt level or while a simple lock is held.
|
||||
* @param address Pointer to the allocated memory. Must be identical to result
|
||||
* @of a prior IOMalloc.
|
||||
* @param size Size of the memory allocated. Must be identical to size of
|
||||
* @the corresponding IOMalloc */
|
||||
|
||||
void IOFree(void * address, vm_size_t size);
|
||||
|
||||
/*! @function IOMallocAligned
|
||||
* @abstract Allocates wired memory in the kernel map, with an alignment restriction.
|
||||
* @discussion This is a utility to allocate memory in the kernel, with an alignment restriction which is specified as a byte count. This function may block and so should not be called from interrupt level or while a simple lock is held.
|
||||
* @param size Size of the memory requested.
|
||||
* @param alignment Byte count of the alignment for the memory. For example, pass 256 to get memory allocated at an address with bit 0-7 zero.
|
||||
* @result Pointer to the allocated memory, or zero on failure. */
|
||||
|
||||
void * IOMallocAligned(vm_size_t size, vm_offset_t alignment) __attribute__((alloc_size(1)));
|
||||
|
||||
/*! @function IOFreeAligned
|
||||
* @abstract Frees memory allocated with IOMallocAligned.
|
||||
* @discussion This function frees memory allocated with IOMallocAligned, it may block and so should not be called from interrupt level or while a simple lock is held.
|
||||
* @param address Pointer to the allocated memory.
|
||||
* @param size Size of the memory allocated. */
|
||||
|
||||
void IOFreeAligned(void * address, vm_size_t size);
|
||||
|
||||
/*! @function IOMallocContiguous
|
||||
* @abstract Deprecated - use IOBufferMemoryDescriptor. Allocates wired memory in the kernel map, with an alignment restriction and physically contiguous.
|
||||
* @discussion This is a utility to allocate memory in the kernel, with an alignment restriction which is specified as a byte count, and will allocate only physically contiguous memory. The request may fail if memory is fragmented, and may cause large amounts of paging activity. This function may block and so should not be called from interrupt level or while a simple lock is held.
|
||||
* @param size Size of the memory requested.
|
||||
* @param alignment Byte count of the alignment for the memory. For example, pass 256 to get memory allocated at an address with bits 0-7 zero.
|
||||
* @param physicalAddress IOMallocContiguous returns the physical address of the allocated memory here, if physicalAddress is a non-zero pointer. The physicalAddress argument is deprecated and should be passed as NULL. To obtain the physical address for a memory buffer, use the IODMACommand class in conjunction with the IOMemoryDescriptor or IOBufferMemoryDescriptor classes.
|
||||
* @result Virtual address of the allocated memory, or zero on failure. */
|
||||
|
||||
void * IOMallocContiguous(vm_size_t size, vm_size_t alignment,
|
||||
IOPhysicalAddress * physicalAddress) __attribute__((deprecated)) __attribute__((alloc_size(1)));
|
||||
|
||||
/*! @function IOFreeContiguous
|
||||
* @abstract Deprecated - use IOBufferMemoryDescriptor. Frees memory allocated with IOMallocContiguous.
|
||||
* @discussion This function frees memory allocated with IOMallocContiguous, it may block and so should not be called from interrupt level or while a simple lock is held.
|
||||
* @param address Virtual address of the allocated memory.
|
||||
* @param size Size of the memory allocated. */
|
||||
|
||||
void IOFreeContiguous(void * address, vm_size_t size) __attribute__((deprecated));
|
||||
|
||||
|
||||
/*! @function IOMallocPageable
|
||||
* @abstract Allocates pageable memory in the kernel map.
|
||||
* @discussion This is a utility to allocate pageable memory in the kernel. This function may block and so should not be called from interrupt level or while a simple lock is held.
|
||||
* @param size Size of the memory requested.
|
||||
* @param alignment Byte count of the alignment for the memory. For example, pass 256 to get memory allocated at an address with bits 0-7 zero.
|
||||
* @result Pointer to the allocated memory, or zero on failure. */
|
||||
|
||||
void * IOMallocPageable(vm_size_t size, vm_size_t alignment) __attribute__((alloc_size(1)));
|
||||
|
||||
/*! @function IOFreePageable
|
||||
* @abstract Frees memory allocated with IOMallocPageable.
|
||||
* @discussion This function frees memory allocated with IOMallocPageable, it may block and so should not be called from interrupt level or while a simple lock is held.
|
||||
* @param address Virtual address of the allocated memory.
|
||||
* @param size Size of the memory allocated. */
|
||||
|
||||
void IOFreePageable(void * address, vm_size_t size);
|
||||
|
||||
/*
|
||||
* Typed memory allocation macros. All may block.
|
||||
*/
|
||||
|
||||
#define IONew(type, count) \
|
||||
({ \
|
||||
size_t __size; \
|
||||
(os_mul_overflow(sizeof(type), (count), &__size) \
|
||||
? ((type *) NULL) \
|
||||
: ((type *) IOMalloc(__size))); \
|
||||
})
|
||||
|
||||
#define IONewZero(type, count) \
|
||||
({ \
|
||||
size_t __size; \
|
||||
(os_mul_overflow(sizeof(type), (count), &__size) \
|
||||
? ((type *) NULL) \
|
||||
: ((type *) IOMallocZero(__size))); \
|
||||
})
|
||||
|
||||
#define IODelete(ptr, type, count) \
|
||||
({ \
|
||||
size_t __size; \
|
||||
if (!os_mul_overflow(sizeof(type), (count), &__size)) { \
|
||||
IOFree(ptr, __size); \
|
||||
} \
|
||||
})
|
||||
|
||||
#define IOSafeDeleteNULL(ptr, type, count) \
|
||||
do { \
|
||||
if (NULL != (ptr)) { \
|
||||
IODelete((ptr), type, count); \
|
||||
(ptr) = NULL; \
|
||||
} \
|
||||
} while (0) \
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// These functions are now implemented in IOMapper.cpp
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*! @function IOMappedRead8
|
||||
* @abstract Read one byte from the desired "Physical" IOSpace address.
|
||||
* @discussion Read one byte from the desired "Physical" IOSpace address. This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine. It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.
|
||||
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
|
||||
* @result Data contained at that location */
|
||||
|
||||
UInt8 IOMappedRead8(IOPhysicalAddress address);
|
||||
|
||||
/*! @function IOMappedRead16
|
||||
* @abstract Read two bytes from the desired "Physical" IOSpace address.
|
||||
* @discussion Read two bytes from the desired "Physical" IOSpace address. This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine. It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.
|
||||
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
|
||||
* @result Data contained at that location */
|
||||
|
||||
UInt16 IOMappedRead16(IOPhysicalAddress address);
|
||||
|
||||
/*! @function IOMappedRead32
|
||||
* @abstract Read four bytes from the desired "Physical" IOSpace address.
|
||||
* @discussion Read four bytes from the desired "Physical" IOSpace address. This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine. It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.
|
||||
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
|
||||
* @result Data contained at that location */
|
||||
|
||||
UInt32 IOMappedRead32(IOPhysicalAddress address);
|
||||
|
||||
/*! @function IOMappedRead64
|
||||
* @abstract Read eight bytes from the desired "Physical" IOSpace address.
|
||||
* @discussion Read eight bytes from the desired "Physical" IOSpace address. This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine. It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.
|
||||
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
|
||||
* @result Data contained at that location */
|
||||
|
||||
UInt64 IOMappedRead64(IOPhysicalAddress address);
|
||||
|
||||
/*! @function IOMappedWrite8
|
||||
* @abstract Write one byte to the desired "Physical" IOSpace address.
|
||||
* @discussion Write one byte to the desired "Physical" IOSpace address. This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
|
||||
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
|
||||
* @param value Data to be writen to the desired location */
|
||||
|
||||
void IOMappedWrite8(IOPhysicalAddress address, UInt8 value);
|
||||
|
||||
/*! @function IOMappedWrite16
|
||||
* @abstract Write two bytes to the desired "Physical" IOSpace address.
|
||||
* @discussion Write two bytes to the desired "Physical" IOSpace address. This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
|
||||
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
|
||||
* @param value Data to be writen to the desired location */
|
||||
|
||||
void IOMappedWrite16(IOPhysicalAddress address, UInt16 value);
|
||||
|
||||
/*! @function IOMappedWrite32
|
||||
* @abstract Write four bytes to the desired "Physical" IOSpace address.
|
||||
* @discussion Write four bytes to the desired "Physical" IOSpace address. This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
|
||||
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
|
||||
* @param value Data to be writen to the desired location */
|
||||
|
||||
void IOMappedWrite32(IOPhysicalAddress address, UInt32 value);
|
||||
|
||||
/*! @function IOMappedWrite64
|
||||
* @abstract Write eight bytes to the desired "Physical" IOSpace address.
|
||||
* @discussion Write eight bytes to the desired "Physical" IOSpace address. This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
|
||||
* @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
|
||||
* @param value Data to be writen to the desired location */
|
||||
|
||||
void IOMappedWrite64(IOPhysicalAddress address, UInt64 value);
|
||||
|
||||
/* This function is deprecated. Cache settings may be set for allocated memory with the IOBufferMemoryDescriptor api. */
|
||||
|
||||
IOReturn IOSetProcessorCacheMode( task_t task, IOVirtualAddress address,
|
||||
IOByteCount length, IOOptionBits cacheMode ) __attribute__((deprecated));
|
||||
|
||||
/*! @function IOFlushProcessorCache
|
||||
* @abstract Flushes the processor cache for mapped memory.
|
||||
* @discussion This function flushes the processor cache of an already mapped memory range. Note in most cases it is preferable to use IOMemoryDescriptor::prepare and complete to manage cache coherency since they are aware of the architecture's requirements. Flushing the processor cache is not required for coherency in most situations.
|
||||
* @param task Task the memory is mapped into.
|
||||
* @param address Virtual address of the memory.
|
||||
* @param length Length of the range to set.
|
||||
* @result An IOReturn code. */
|
||||
|
||||
IOReturn IOFlushProcessorCache( task_t task, IOVirtualAddress address,
|
||||
IOByteCount length );
|
||||
|
||||
/*! @function IOThreadSelf
|
||||
* @abstract Returns the osfmk identifier for the currently running thread.
|
||||
* @discussion This function returns the current thread (a pointer to the currently active osfmk thread_shuttle). */
|
||||
|
||||
#define IOThreadSelf() (current_thread())
|
||||
|
||||
/*! @function IOCreateThread
|
||||
* @abstract Deprecated function - use kernel_thread_start(). Create a kernel thread.
|
||||
* @discussion This function creates a kernel thread, and passes the caller supplied argument to the new thread. Warning: the value returned by this function is not 100% reliable. There is a race condition where it is possible that the new thread has already terminated before this call returns. Under that circumstance the IOThread returned will be invalid. In general there is little that can be done with this value except compare it against 0. The thread itself can call IOThreadSelf() 100% reliably and that is the prefered mechanism to manipulate the IOThreads state.
|
||||
* @param function A C-function pointer where the thread will begin execution.
|
||||
* @param argument Caller specified data to be passed to the new thread.
|
||||
* @result An IOThread identifier for the new thread, equivalent to an osfmk thread_t. */
|
||||
|
||||
IOThread IOCreateThread(IOThreadFunc function, void *argument) __attribute__((deprecated));
|
||||
|
||||
/*! @function IOExitThread
|
||||
* @abstract Deprecated function - use thread_terminate(). Terminate execution of current thread.
|
||||
* @discussion This function destroys the currently running thread, and does not return. */
|
||||
|
||||
void IOExitThread(void) __attribute__((deprecated));
|
||||
|
||||
/*! @function IOSleep
|
||||
* @abstract Sleep the calling thread for a number of milliseconds.
|
||||
* @discussion This function blocks the calling thread for at least the number of specified milliseconds, giving time to other processes.
|
||||
* @param milliseconds The integer number of milliseconds to wait. */
|
||||
|
||||
void IOSleep(unsigned milliseconds);
|
||||
|
||||
/*! @function IOSleepWithLeeway
|
||||
* @abstract Sleep the calling thread for a number of milliseconds, with a specified leeway the kernel may use for timer coalescing.
|
||||
* @discussion This function blocks the calling thread for at least the number of specified milliseconds, giving time to other processes. The kernel may also coalesce any timers involved in the delay, using the leeway given as a guideline.
|
||||
* @param intervalMilliseconds The integer number of milliseconds to wait.
|
||||
* @param leewayMilliseconds The integer number of milliseconds to use as a timer coalescing guideline. */
|
||||
|
||||
void IOSleepWithLeeway(unsigned intervalMilliseconds, unsigned leewayMilliseconds);
|
||||
|
||||
/*! @function IODelay
|
||||
* @abstract Spin delay for a number of microseconds.
|
||||
* @discussion This function spins to delay for at least the number of specified microseconds. Since the CPU is busy spinning no time is made available to other processes; this method of delay should be used only for short periods. Also, the AbsoluteTime based APIs of kern/clock.h provide finer grained and lower cost delays.
|
||||
* @param microseconds The integer number of microseconds to spin wait. */
|
||||
|
||||
void IODelay(unsigned microseconds);
|
||||
|
||||
/*! @function IOPause
|
||||
* @abstract Spin delay for a number of nanoseconds.
|
||||
* @discussion This function spins to delay for at least the number of specified nanoseconds. Since the CPU is busy spinning no time is made available to other processes; this method of delay should be used only for short periods.
|
||||
* @param nanoseconds The integer number of nanoseconds to spin wait. */
|
||||
|
||||
void IOPause(unsigned nanoseconds);
|
||||
|
||||
/*! @function IOLog
|
||||
* @abstract Log a message to console in text mode, and /var/log/system.log.
|
||||
* @discussion This function allows a driver to log diagnostic information to the screen during verbose boots, and to a log file found at /var/log/system.log. IOLog should not be called from interrupt context.
|
||||
* @param format A printf() style format string (see printf(3) documentation).
|
||||
*/
|
||||
|
||||
void IOLog(const char *format, ...)
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
|
||||
/*! @function IOLogv
|
||||
* @abstract Log a message to console in text mode, and /var/log/system.log.
|
||||
* @discussion This function allows a driver to log diagnostic information to the screen during verbose boots, and to a log file found at /var/log/system.log. IOLogv should not be called from interrupt context.
|
||||
* @param format A printf() style format string (see printf(3) documentation).
|
||||
* @param ap stdarg(3) style variable arguments. */
|
||||
|
||||
void IOLogv(const char *format, va_list ap)
|
||||
__attribute__((format(printf, 1, 0)));
|
||||
|
||||
#ifndef _FN_KPRINTF
|
||||
#define _FN_KPRINTF
|
||||
void kprintf(const char *format, ...);
|
||||
#endif
|
||||
#ifndef _FN_KPRINTF_DECLARED
|
||||
#define _FN_KPRINTF_DECLARED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Convert a integer constant (typically a #define or enum) to a string
|
||||
* via an array of IONamedValue.
|
||||
*/
|
||||
const char *IOFindNameForValue(int value,
|
||||
const IONamedValue *namedValueArray);
|
||||
|
||||
/*
|
||||
* Convert a string to an int via an array of IONamedValue. Returns
|
||||
* kIOReturnSuccess of string found, else returns kIOReturnBadArgument.
|
||||
*/
|
||||
IOReturn IOFindValueForName(const char *string,
|
||||
const IONamedValue *regValueArray,
|
||||
int *value); /* RETURNED */
|
||||
|
||||
/*! @function Debugger
|
||||
* @abstract Enter the kernel debugger.
|
||||
* @discussion This function freezes the kernel and enters the builtin debugger. It may not be possible to exit the debugger without a second machine.
|
||||
* @param reason A C-string to describe why the debugger is being entered. */
|
||||
|
||||
void Debugger(const char * reason);
|
||||
#if __LP64__
|
||||
#define IOPanic(reason) panic("%s", reason)
|
||||
#else
|
||||
void IOPanic(const char *reason) __attribute__((deprecated)) __abortlike;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
class OSDictionary;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
OSDictionary *
|
||||
#else
|
||||
struct OSDictionary *
|
||||
#endif
|
||||
IOBSDNameMatching( const char * name );
|
||||
|
||||
#ifdef __cplusplus
|
||||
OSDictionary *
|
||||
#else
|
||||
struct OSDictionary *
|
||||
#endif
|
||||
IOOFPathMatching( const char * path, char * buf, int maxLen ) __attribute__((deprecated));
|
||||
|
||||
/*
|
||||
* Convert between size and a power-of-two alignment.
|
||||
*/
|
||||
IOAlignment IOSizeToAlignment(unsigned int size);
|
||||
unsigned int IOAlignmentToSize(IOAlignment align);
|
||||
|
||||
/*
|
||||
* Multiply and divide routines for IOFixed datatype.
|
||||
*/
|
||||
|
||||
static inline IOFixed
|
||||
IOFixedMultiply(IOFixed a, IOFixed b)
|
||||
{
|
||||
return (IOFixed)((((SInt64) a) * ((SInt64) b)) >> 16);
|
||||
}
|
||||
|
||||
static inline IOFixed
|
||||
IOFixedDivide(IOFixed a, IOFixed b)
|
||||
{
|
||||
return (IOFixed)((((SInt64) a) << 16) / ((SInt64) b));
|
||||
}
|
||||
|
||||
/*
|
||||
* IORound and IOTrunc convenience functions, in the spirit
|
||||
* of vm's round_page() and trunc_page().
|
||||
*/
|
||||
#define IORound(value, multiple) \
|
||||
((((value) + (multiple) - 1) / (multiple)) * (multiple))
|
||||
|
||||
#define IOTrunc(value, multiple) \
|
||||
(((value) / (multiple)) * (multiple));
|
||||
|
||||
|
||||
#if defined(__APPLE_API_OBSOLETE)
|
||||
|
||||
/* The following API is deprecated */
|
||||
|
||||
/* The API exported by kern/clock.h
|
||||
* should be used for high resolution timing. */
|
||||
|
||||
void IOGetTime( mach_timespec_t * clock_time) __attribute__((deprecated));
|
||||
|
||||
#if !defined(__LP64__)
|
||||
|
||||
#undef eieio
|
||||
#define eieio() \
|
||||
OSSynchronizeIO()
|
||||
|
||||
extern mach_timespec_t IOZeroTvalspec;
|
||||
|
||||
#endif /* !defined(__LP64__) */
|
||||
|
||||
#endif /* __APPLE_API_OBSOLETE */
|
||||
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !__IOKIT_IOLIB_H */
|
||||
@@ -0,0 +1,440 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __IOKIT_IOLOCKS_H
|
||||
#define __IOKIT_IOLOCKS_H
|
||||
|
||||
|
||||
#include <sys/appleapiopts.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <IOKit/system.h>
|
||||
|
||||
#include <IOKit/IOReturn.h>
|
||||
#include <IOKit/IOTypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libkern/locks.h>
|
||||
#include <machine/machine_routines.h>
|
||||
|
||||
/*! @var IOLockGroup
|
||||
* Global lock group used by all IOKit locks. To simplify kext debugging and lock-heat analysis, consider using lck_* locks with a per-driver lock group, as defined in kern/locks.h.
|
||||
*/
|
||||
extern lck_grp_t *IOLockGroup;
|
||||
|
||||
|
||||
/*
|
||||
* Mutex lock operations
|
||||
*/
|
||||
|
||||
#ifdef IOLOCKS_INLINE
|
||||
typedef lck_mtx_t IOLock;
|
||||
#else
|
||||
typedef struct _IOLock IOLock;
|
||||
#endif /* IOLOCKS_INLINE */
|
||||
|
||||
|
||||
/*! @function IOLockAlloc
|
||||
* @abstract Allocates and initializes a mutex.
|
||||
* @discussion Allocates a mutex in general purpose memory, and initializes it. Mutexes are general purpose blocking mutual exclusion locks, supplied by libkern/locks.h. This function may block and so should not be called from interrupt level or while a spin lock is held. IOLocks use the global IOKit lock group, IOLockGroup. To simplify kext debugging and lock-heat analysis, consider using lck_* locks with a per-driver lock group, as defined in kern/locks.h.
|
||||
* @result Pointer to the allocated lock, or zero on failure. */
|
||||
|
||||
IOLock * IOLockAlloc( void );
|
||||
|
||||
/*! @function IOLockFree
|
||||
* @abstract Frees a mutex.
|
||||
* @discussion Frees a lock allocated with IOLockAlloc. Mutex should be unlocked with no waiters.
|
||||
* @param lock Pointer to the allocated lock. */
|
||||
|
||||
void IOLockFree( IOLock * lock);
|
||||
|
||||
/*! @function IOLockGetMachLock
|
||||
* @abstract Accessor to a Mach mutex.
|
||||
* @discussion Accessor to the Mach mutex.
|
||||
* @param lock Pointer to the allocated lock. */
|
||||
|
||||
lck_mtx_t * IOLockGetMachLock( IOLock * lock);
|
||||
|
||||
/*! @function IOLockLock
|
||||
* @abstract Lock a mutex.
|
||||
* @discussion Lock the mutex. If the lock is held by any thread, block waiting for its unlock. This function may block and so should not be called from interrupt level or while a spin lock is held. Locking the mutex recursively from one thread will result in deadlock.
|
||||
* @param lock Pointer to the allocated lock. */
|
||||
|
||||
#ifdef IOLOCKS_INLINE
|
||||
#define IOLockLock(l) lck_mtx_lock(l)
|
||||
#else
|
||||
void IOLockLock( IOLock * lock);
|
||||
#endif /* !IOLOCKS_INLINE */
|
||||
|
||||
/*! @function IOLockTryLock
|
||||
* @abstract Attempt to lock a mutex.
|
||||
* @discussion Lock the mutex if it is currently unlocked, and return true. If the lock is held by any thread, return false.
|
||||
* @param lock Pointer to the allocated lock.
|
||||
* @result True if the mutex was unlocked and is now locked by the caller, otherwise false. */
|
||||
|
||||
#ifdef IOLOCKS_INLINE
|
||||
#define IOLockTryLock(l) lck_mtx_try_lock(l)
|
||||
#else
|
||||
boolean_t IOLockTryLock( IOLock * lock);
|
||||
#endif /* !IOLOCKS_INLINE */
|
||||
|
||||
/*! @function IOLockUnlock
|
||||
* @abstract Unlock a mutex.
|
||||
* @discussion Unlock the mutex and wake any blocked waiters. Results are undefined if the caller has not locked the mutex. This function may block and so should not be called from interrupt level or while a spin lock is held.
|
||||
* @param lock Pointer to the allocated lock. */
|
||||
|
||||
#ifdef IOLOCKS_INLINE
|
||||
#define IOLockUnlock(l) lck_mtx_unlock(l)
|
||||
#else
|
||||
void IOLockUnlock( IOLock * lock);
|
||||
#endif /* !IOLOCKS_INLINE */
|
||||
|
||||
/*! @function IOLockSleep
|
||||
* @abstract Sleep with mutex unlock and relock
|
||||
* @discussion Prepare to sleep,unlock the mutex, and re-acquire it on wakeup. Results are undefined if the caller has not locked the mutex. This function may block and so should not be called from interrupt level or while a spin lock is held.
|
||||
* @param lock Pointer to the locked lock.
|
||||
* @param event The event to sleep on. Must be non-NULL.
|
||||
* @param interType How can the sleep be interrupted.
|
||||
* @result The wait-result value indicating how the thread was awakened.*/
|
||||
int IOLockSleep( IOLock * lock, void *event, UInt32 interType) __DARWIN14_ALIAS(IOLockSleep);
|
||||
|
||||
int IOLockSleepDeadline( IOLock * lock, void *event,
|
||||
AbsoluteTime deadline, UInt32 interType) __DARWIN14_ALIAS(IOLockSleepDeadline);
|
||||
|
||||
void IOLockWakeup(IOLock * lock, void *event, bool oneThread) __DARWIN14_ALIAS(IOLockWakeup);
|
||||
|
||||
|
||||
#ifdef __APPLE_API_OBSOLETE
|
||||
|
||||
/* The following API is deprecated */
|
||||
|
||||
typedef enum {
|
||||
kIOLockStateUnlocked = 0,
|
||||
kIOLockStateLocked = 1
|
||||
} IOLockState;
|
||||
|
||||
void IOLockInitWithState( IOLock * lock, IOLockState state);
|
||||
#define IOLockInit( l ) IOLockInitWithState( l, kIOLockStateUnlocked);
|
||||
|
||||
static __inline__ void
|
||||
IOTakeLock( IOLock * lock)
|
||||
{
|
||||
IOLockLock(lock);
|
||||
}
|
||||
static __inline__ boolean_t
|
||||
IOTryLock( IOLock * lock)
|
||||
{
|
||||
return IOLockTryLock(lock);
|
||||
}
|
||||
static __inline__ void
|
||||
IOUnlock( IOLock * lock)
|
||||
{
|
||||
IOLockUnlock(lock);
|
||||
}
|
||||
|
||||
#endif /* __APPLE_API_OBSOLETE */
|
||||
|
||||
/*
|
||||
* Recursive lock operations
|
||||
*/
|
||||
|
||||
typedef struct _IORecursiveLock IORecursiveLock;
|
||||
|
||||
/*! @function IORecursiveLockAlloc
|
||||
* @abstract Allocates and initializes an recursive lock.
|
||||
* @discussion Allocates a recursive lock in general purpose memory, and initializes it. Recursive locks function identically to mutexes but allow one thread to lock more than once, with balanced unlocks. IORecursiveLocks use the global IOKit lock group, IOLockGroup. To simplify kext debugging and lock-heat analysis, consider using lck_* locks with a per-driver lock group, as defined in kern/locks.h.
|
||||
* @result Pointer to the allocated lock, or zero on failure. */
|
||||
|
||||
IORecursiveLock * IORecursiveLockAlloc( void );
|
||||
|
||||
/*! @function IORecursiveLockFree
|
||||
* @abstract Frees a recursive lock.
|
||||
* @discussion Frees a lock allocated with IORecursiveLockAlloc. Lock should be unlocked with no waiters.
|
||||
* @param lock Pointer to the allocated lock. */
|
||||
|
||||
void IORecursiveLockFree( IORecursiveLock * lock);
|
||||
|
||||
/*! @function IORecursiveLockGetMachLock
|
||||
* @abstract Accessor to a Mach mutex.
|
||||
* @discussion Accessor to the Mach mutex.
|
||||
* @param lock Pointer to the allocated lock. */
|
||||
|
||||
lck_mtx_t * IORecursiveLockGetMachLock( IORecursiveLock * lock);
|
||||
|
||||
/*! @function IORecursiveLockLock
|
||||
* @abstract Lock a recursive lock.
|
||||
* @discussion Lock the recursive lock. If the lock is held by another thread, block waiting for its unlock. This function may block and so should not be called from interrupt level or while a spin lock is held. The lock may be taken recursively by the same thread, with a balanced number of calls to IORecursiveLockUnlock.
|
||||
* @param lock Pointer to the allocated lock. */
|
||||
|
||||
void IORecursiveLockLock( IORecursiveLock * lock);
|
||||
|
||||
/*! @function IORecursiveLockTryLock
|
||||
* @abstract Attempt to lock a recursive lock.
|
||||
* @discussion Lock the lock if it is currently unlocked, or held by the calling thread, and return true. If the lock is held by another thread, return false. Successful calls to IORecursiveLockTryLock should be balanced with calls to IORecursiveLockUnlock.
|
||||
* @param lock Pointer to the allocated lock.
|
||||
* @result True if the lock is now locked by the caller, otherwise false. */
|
||||
|
||||
boolean_t IORecursiveLockTryLock( IORecursiveLock * lock);
|
||||
|
||||
/*! @function IORecursiveLockUnlock
|
||||
* @abstract Unlock a recursive lock.
|
||||
* @discussion Undo one call to IORecursiveLockLock, if the lock is now unlocked wake any blocked waiters. Results are undefined if the caller does not balance calls to IORecursiveLockLock with IORecursiveLockUnlock. This function may block and so should not be called from interrupt level or while a spin lock is held.
|
||||
* @param lock Pointer to the allocated lock. */
|
||||
|
||||
void IORecursiveLockUnlock( IORecursiveLock * lock);
|
||||
|
||||
/*! @function IORecursiveLockHaveLock
|
||||
* @abstract Check if a recursive lock is held by the calling thread.
|
||||
* @discussion If the lock is held by the calling thread, return true, otherwise the lock is unlocked, or held by another thread and false is returned.
|
||||
* @param lock Pointer to the allocated lock.
|
||||
* @result True if the calling thread holds the lock otherwise false. */
|
||||
|
||||
boolean_t IORecursiveLockHaveLock( const IORecursiveLock * lock);
|
||||
|
||||
extern int IORecursiveLockSleep( IORecursiveLock *_lock,
|
||||
void *event, UInt32 interType);
|
||||
extern int IORecursiveLockSleepDeadline( IORecursiveLock * _lock, void *event,
|
||||
AbsoluteTime deadline, UInt32 interType);
|
||||
extern void IORecursiveLockWakeup( IORecursiveLock *_lock,
|
||||
void *event, bool oneThread);
|
||||
|
||||
/*
|
||||
* Complex (read/write) lock operations
|
||||
*/
|
||||
|
||||
#ifdef IOLOCKS_INLINE
|
||||
typedef lck_rw_t IORWLock;
|
||||
#else
|
||||
typedef struct _IORWLock IORWLock;
|
||||
#endif /* IOLOCKS_INLINE */
|
||||
|
||||
/*! @function IORWLockAlloc
|
||||
* @abstract Allocates and initializes a read/write lock.
|
||||
* @discussion Allocates and initializes a read/write lock in general purpose memory. Read/write locks provide for multiple readers, one exclusive writer, and are supplied by libkern/locks.h. This function may block and so should not be called from interrupt level or while a spin lock is held. IORWLocks use the global IOKit lock group, IOLockGroup. To simplify kext debugging and lock-heat analysis, consider using lck_* locks with a per-driver lock group, as defined in kern/locks.h.
|
||||
* @result Pointer to the allocated lock, or zero on failure. */
|
||||
|
||||
IORWLock * IORWLockAlloc( void );
|
||||
|
||||
/*! @function IORWLockFree
|
||||
* @abstract Frees a read/write lock.
|
||||
* @discussion Frees a lock allocated with IORWLockAlloc. Lock should be unlocked with no waiters.
|
||||
* @param lock Pointer to the allocated lock. */
|
||||
|
||||
void IORWLockFree( IORWLock * lock);
|
||||
|
||||
/*! @function IORWLockGetMachLock
|
||||
* @abstract Accessor to a Mach read/write lock.
|
||||
* @discussion Accessor to the Mach read/write lock.
|
||||
* @param lock Pointer to the allocated lock. */
|
||||
|
||||
lck_rw_t * IORWLockGetMachLock( IORWLock * lock);
|
||||
|
||||
/*! @function IORWLockRead
|
||||
* @abstract Lock a read/write lock for read.
|
||||
* @discussion Lock the lock for read, allowing multiple readers when there are no writers. If the lock is held for write, block waiting for its unlock. This function may block and so should not be called from interrupt level or while a spin lock is held. Locking the lock recursively from one thread, for read or write, can result in deadlock.
|
||||
* @param lock Pointer to the allocated lock. */
|
||||
|
||||
#ifdef IOLOCKS_INLINE
|
||||
#define IORWLockRead(l) lck_rw_lock_shared(l)
|
||||
#else
|
||||
void IORWLockRead(IORWLock * lock);
|
||||
#endif /* !IOLOCKS_INLINE */
|
||||
|
||||
/*! @function IORWLockWrite
|
||||
* @abstract Lock a read/write lock for write.
|
||||
* @discussion Lock the lock for write, allowing one writer exlusive access. If the lock is held for read or write, block waiting for its unlock. This function may block and so should not be called from interrupt level or while a spin lock is held. Locking the lock recursively from one thread, for read or write, can result in deadlock.
|
||||
* @param lock Pointer to the allocated lock. */
|
||||
|
||||
#ifdef IOLOCKS_INLINE
|
||||
#define IORWLockWrite(l) lck_rw_lock_exclusive(l)
|
||||
#else
|
||||
void IORWLockWrite( IORWLock * lock);
|
||||
#endif /* !IOLOCKS_INLINE */
|
||||
|
||||
/*! @function IORWLockUnlock
|
||||
* @abstract Unlock a read/write lock.
|
||||
* @discussion Undo one call to IORWLockRead or IORWLockWrite. Results are undefined if the caller has not locked the lock. This function may block and so should not be called from interrupt level or while a spin lock is held.
|
||||
* @param lock Pointer to the allocated lock. */
|
||||
|
||||
#ifdef IOLOCKS_INLINE
|
||||
#define IORWLockUnlock(l) lck_rw_done(l)
|
||||
#else
|
||||
void IORWLockUnlock( IORWLock * lock);
|
||||
#endif /* !IOLOCKS_INLINE */
|
||||
|
||||
|
||||
#ifdef __APPLE_API_OBSOLETE
|
||||
|
||||
/* The following API is deprecated */
|
||||
|
||||
static __inline__ void
|
||||
IOReadLock( IORWLock * lock)
|
||||
{
|
||||
IORWLockRead(lock);
|
||||
}
|
||||
static __inline__ void
|
||||
IOWriteLock( IORWLock * lock)
|
||||
{
|
||||
IORWLockWrite(lock);
|
||||
}
|
||||
static __inline__ void
|
||||
IORWUnlock( IORWLock * lock)
|
||||
{
|
||||
IORWLockUnlock(lock);
|
||||
}
|
||||
|
||||
#endif /* __APPLE_API_OBSOLETE */
|
||||
|
||||
|
||||
/*
|
||||
* Simple locks. Cannot block while holding a simple lock.
|
||||
*/
|
||||
|
||||
#ifdef IOLOCKS_INLINE
|
||||
typedef lck_spin_t IOSimpleLock;
|
||||
#else
|
||||
typedef struct _IOSimpleLock IOSimpleLock;
|
||||
#endif /* IOLOCKS_INLINE */
|
||||
|
||||
/*! @function IOSimpleLockAlloc
|
||||
* @abstract Allocates and initializes a spin lock.
|
||||
* @discussion Allocates and initializes a spin lock in general purpose memory. Spin locks provide non-blocking mutual exclusion for synchronization between thread context and interrupt context, or for multiprocessor synchronization, and are supplied by libkern/locks.h. This function may block and so should not be called from interrupt level or while a spin lock is held. IOSimpleLocks use the global IOKit lock group, IOLockGroup. To simplify kext debugging and lock-heat analysis, consider using lck_* locks with a per-driver lock group, as defined in kern/locks.h.
|
||||
* @result Pointer to the allocated lock, or zero on failure. */
|
||||
|
||||
IOSimpleLock * IOSimpleLockAlloc( void );
|
||||
|
||||
/*! @function IOSimpleLockFree
|
||||
* @abstract Frees a spin lock.
|
||||
* @discussion Frees a lock allocated with IOSimpleLockAlloc.
|
||||
* @param lock Pointer to the lock. */
|
||||
|
||||
void IOSimpleLockFree( IOSimpleLock * lock );
|
||||
|
||||
/*! @function IOSimpleLockGetMachLock
|
||||
* @abstract Accessor to a Mach spin lock.
|
||||
* @discussion Accessor to the Mach spin lock.
|
||||
* @param lock Pointer to the allocated lock. */
|
||||
|
||||
lck_spin_t * IOSimpleLockGetMachLock( IOSimpleLock * lock);
|
||||
|
||||
/*! @function IOSimpleLockInit
|
||||
* @abstract Initialize a spin lock.
|
||||
* @discussion Initialize a non heap allocated spin lock to the unlocked state. Use this function when your lock is, for example, a member variable. You will need to call IOSimpleLockDestroy when you are finished with the lock to avoid lock group refcount leaks.
|
||||
* @param lock Pointer to the lock. */
|
||||
|
||||
void IOSimpleLockInit( IOSimpleLock * lock );
|
||||
|
||||
/*! @function IOSimpleLockDestroy
|
||||
* @abstract De-initializes (destroys) a spin lock initialized with IOSimpleLockInit
|
||||
* @discussion Destroy / De-initialize a non heap allocated spin lock, releasing any system resources such as lock group refcounts.
|
||||
* @param lock Pointer to the lock. */
|
||||
|
||||
void IOSimpleLockDestroy( IOSimpleLock * lock );
|
||||
|
||||
/*! @function IOSimpleLockLock
|
||||
* @abstract Lock a spin lock.
|
||||
* @discussion Lock the spin lock. If the lock is held, spin waiting for its unlock. Spin locks disable preemption, cannot be held across any blocking operation, and should be held for very short periods. When used to synchronize between interrupt context and thread context they should be locked with interrupts disabled - IOSimpleLockLockDisableInterrupt() will do both. Locking the lock recursively from one thread will result in deadlock.
|
||||
* @param lock Pointer to the lock. */
|
||||
|
||||
#ifdef IOLOCKS_INLINE
|
||||
#define IOSimpleLockLock(l) lck_spin_lock(l)
|
||||
#else
|
||||
void IOSimpleLockLock( IOSimpleLock * lock );
|
||||
#endif /* !IOLOCKS_INLINE */
|
||||
|
||||
|
||||
/*! @function IOSimpleLockTryLock
|
||||
* @abstract Attempt to lock a spin lock.
|
||||
* @discussion Lock the spin lock if it is currently unlocked, and return true. If the lock is held, return false. Successful calls to IOSimpleLockTryLock should be balanced with calls to IOSimpleLockUnlock.
|
||||
* @param lock Pointer to the lock.
|
||||
* @result True if the lock was unlocked and is now locked by the caller, otherwise false. */
|
||||
|
||||
#ifdef IOLOCKS_INLINE
|
||||
#define IOSimpleLockTryLock(l) lck_spin_try_lock(l)
|
||||
#else
|
||||
boolean_t IOSimpleLockTryLock( IOSimpleLock * lock );
|
||||
#endif /* !IOLOCKS_INLINE */
|
||||
|
||||
/*! @function IOSimpleLockUnlock
|
||||
* @abstract Unlock a spin lock.
|
||||
* @discussion Unlock the lock, and restore preemption. Results are undefined if the caller has not locked the lock.
|
||||
* @param lock Pointer to the lock. */
|
||||
|
||||
#ifdef IOLOCKS_INLINE
|
||||
#define IOSimpleLockUnlock(l) lck_spin_unlock(l)
|
||||
#else
|
||||
void IOSimpleLockUnlock( IOSimpleLock * lock );
|
||||
#endif /* !IOLOCKS_INLINE */
|
||||
|
||||
|
||||
#if __LP64__
|
||||
typedef boolean_t IOInterruptState;
|
||||
#else
|
||||
typedef long int IOInterruptState;
|
||||
#endif
|
||||
|
||||
/*! @function IOSimpleLockLockDisableInterrupt
|
||||
* @abstract Lock a spin lock.
|
||||
* @discussion Lock the spin lock. If the lock is held, spin waiting for its unlock. Simple locks disable preemption, cannot be held across any blocking operation, and should be held for very short periods. When used to synchronize between interrupt context and thread context they should be locked with interrupts disabled - IOSimpleLockLockDisableInterrupt() will do both. Locking the lock recursively from one thread will result in deadlock.
|
||||
* @param lock Pointer to the lock. */
|
||||
|
||||
static __inline__
|
||||
IOInterruptState
|
||||
IOSimpleLockLockDisableInterrupt( IOSimpleLock * lock )
|
||||
{
|
||||
IOInterruptState state = ml_set_interrupts_enabled( false );
|
||||
IOSimpleLockLock( lock );
|
||||
return state;
|
||||
}
|
||||
|
||||
/*! @function IOSimpleLockUnlockEnableInterrupt
|
||||
* @abstract Unlock a spin lock, and restore interrupt state.
|
||||
* @discussion Unlock the lock, and restore preemption and interrupts to the state as they were when the lock was taken. Results are undefined if the caller has not locked the lock.
|
||||
* @param lock Pointer to the lock.
|
||||
* @param state The interrupt state returned by IOSimpleLockLockDisableInterrupt() */
|
||||
|
||||
static __inline__
|
||||
void
|
||||
IOSimpleLockUnlockEnableInterrupt( IOSimpleLock * lock,
|
||||
IOInterruptState state )
|
||||
{
|
||||
IOSimpleLockUnlock( lock );
|
||||
ml_set_interrupts_enabled( state );
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* !__IOKIT_IOLOCKS_H */
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2016 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __IOKIT_IOMAPPER_H
|
||||
#define __IOKIT_IOMAPPER_H
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include <mach/vm_types.h>
|
||||
|
||||
// These are C accessors to the system mapper for non-IOKit clients
|
||||
ppnum_t IOMapperIOVMAlloc(unsigned pages);
|
||||
void IOMapperIOVMFree(ppnum_t addr, unsigned pages);
|
||||
ppnum_t IOMapperInsertPage(ppnum_t addr, unsigned offset, ppnum_t page);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#if __cplusplus
|
||||
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/IOMemoryDescriptor.h>
|
||||
#include <IOKit/IODMACommand.h>
|
||||
|
||||
class OSData;
|
||||
|
||||
extern const OSSymbol * gIOMapperIDKey;
|
||||
|
||||
class IOMapper : public IOService
|
||||
{
|
||||
OSDeclareAbstractStructors(IOMapper);
|
||||
|
||||
// Give the platform expert access to setMapperRequired();
|
||||
friend class IOPlatformExpert;
|
||||
friend class IOMemoryDescriptor;
|
||||
friend class IOGeneralMemoryDescriptor;
|
||||
|
||||
private:
|
||||
enum SystemMapperState {
|
||||
kNoMapper = 0,
|
||||
kUnknown = 1,
|
||||
kHasMapper = 2, // Any other value is pointer to a live mapper
|
||||
kWaitMask = 3,
|
||||
};
|
||||
protected:
|
||||
uint64_t __reserved[8];
|
||||
bool fIsSystem;
|
||||
|
||||
static void setMapperRequired(bool hasMapper);
|
||||
static void waitForSystemMapper();
|
||||
|
||||
virtual bool initHardware(IOService *provider) = 0;
|
||||
|
||||
public:
|
||||
virtual bool start(IOService *provider) APPLE_KEXT_OVERRIDE;
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
// To get access to the system mapper IOMapper::gSystem
|
||||
static IOMapper *gSystem;
|
||||
|
||||
static void
|
||||
checkForSystemMapper()
|
||||
{
|
||||
if ((uintptr_t) gSystem & kWaitMask) {
|
||||
waitForSystemMapper();
|
||||
}
|
||||
}
|
||||
|
||||
static IOMapper * copyMapperForDevice(IOService * device);
|
||||
static IOMapper * copyMapperForDeviceWithIndex(IOService * device, unsigned int index);
|
||||
|
||||
// { subclasses
|
||||
|
||||
virtual uint64_t getPageSize(void) const = 0;
|
||||
|
||||
virtual IOReturn iovmMapMemory(IOMemoryDescriptor * memory,
|
||||
uint64_t descriptorOffset,
|
||||
uint64_t length,
|
||||
uint32_t mapOptions,
|
||||
const IODMAMapSpecification * mapSpecification,
|
||||
IODMACommand * dmaCommand,
|
||||
const IODMAMapPageList * pageList,
|
||||
uint64_t * mapAddress,
|
||||
uint64_t * mapLength) = 0;
|
||||
|
||||
virtual IOReturn iovmUnmapMemory(IOMemoryDescriptor * memory,
|
||||
IODMACommand * dmaCommand,
|
||||
uint64_t mapAddress,
|
||||
uint64_t mapLength) = 0;
|
||||
|
||||
virtual IOReturn iovmInsert(uint32_t options,
|
||||
uint64_t mapAddress,
|
||||
uint64_t offset,
|
||||
uint64_t physicalAddress,
|
||||
uint64_t length) = 0;
|
||||
|
||||
virtual uint64_t mapToPhysicalAddress(uint64_t mappedAddress) = 0;
|
||||
|
||||
// }
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 10);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 11);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 12);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 13);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 14);
|
||||
OSMetaClassDeclareReservedUnused(IOMapper, 15);
|
||||
};
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* !__IOKIT_IOMAPPER_H */
|
||||
@@ -0,0 +1,383 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
#ifndef _IOMEMORYCURSOR_H
|
||||
#define _IOMEMORYCURSOR_H
|
||||
|
||||
#include <libkern/c++/OSObject.h>
|
||||
#include <IOKit/IOTypes.h>
|
||||
|
||||
class IOMemoryDescriptor;
|
||||
|
||||
/**************************** class IOMemoryCursor ***************************/
|
||||
|
||||
/*!
|
||||
* @class IOMemoryCursor
|
||||
* @abstract A mechanism to convert memory references to physical addresses.
|
||||
* @discussion The IOMemoryCursor declares the super class that all
|
||||
* specific memory cursors must inherit from, but a memory cursor can be created without a specific format subclass by just providing a segment function to the initializers. This class does the difficult stuff of dividing a memory descriptor into a physical scatter/gather list appropriate for the target hardware.
|
||||
* <br><br>
|
||||
* A driver is expected to create a memory cursor and configure it to the limitations of its DMA hardware; for instance the memory cursor used by the FireWire SBP-2 protocol has a maximum physical segment size of 2^16 - 1 but the actual transfer size is unlimited. Thus it would create a cursor with a maxSegmentSize of 65535 and a maxTransfer size of UINT_MAX. It would also provide a SegmentFunction that can output a pagelist entry.
|
||||
* <br><br>
|
||||
* Below is the simplest example of a SegmentFunction:<br>
|
||||
* void IONaturalMemoryCursor::outputSegment(PhysicalSegment segment,<br>
|
||||
* void * outSegments,<br>
|
||||
* UInt32 outSegmentIndex)<br>
|
||||
* {<br>
|
||||
* ((PhysicalSegment *) outSegments)[outSegmentIndex] = segment;<br>
|
||||
* }
|
||||
*
|
||||
*/
|
||||
class IOMemoryCursor : public OSObject
|
||||
{
|
||||
OSDeclareDefaultStructors(IOMemoryCursor);
|
||||
|
||||
public:
|
||||
/*!
|
||||
* @typedef PhysicalSegment
|
||||
* @discussion A physical address/length pair.
|
||||
*/
|
||||
struct PhysicalSegment {
|
||||
IOPhysicalAddress location;
|
||||
IOPhysicalLength length;
|
||||
};
|
||||
|
||||
/*! @defined IOPhysicalSegment
|
||||
* @discussion Backward compatibility define for the old non-class scoped type definition. See IOMemoryCursor::PhysicalSegment
|
||||
*/
|
||||
#define IOPhysicalSegment IOMemoryCursor::PhysicalSegment
|
||||
|
||||
/*!
|
||||
* @typedef SegmentFunction
|
||||
* @discussion Pointer to a C function that outputs a single physical segment to an element in the array as defined by the segments and segmentIndex parameters.
|
||||
* @param segment The physical address and length that is next to be output.
|
||||
* @param segments Base of the output vector of DMA address length pairs.
|
||||
* @param segmentIndex Index to output 'segment' in the 'segments' array.
|
||||
*/
|
||||
typedef void (*SegmentFunction)(PhysicalSegment segment,
|
||||
void * segments,
|
||||
UInt32 segmentIndex);
|
||||
|
||||
/*! @defined OutputSegmentFunc
|
||||
* @discussion Backward compatibility define for the old non-class scoped type definition. See IOMemoryCursor::SegmentFunction */
|
||||
#define OutputSegmentFunc IOMemoryCursor::SegmentFunction
|
||||
|
||||
protected:
|
||||
/*! @var outSeg The action method called when an event has been delivered */
|
||||
SegmentFunction outSeg;
|
||||
|
||||
/*! @var maxSegmentSize Maximum size of one segment in a scatter/gather list */
|
||||
IOPhysicalLength maxSegmentSize;
|
||||
|
||||
/*! @var maxTransferSize
|
||||
* Maximum size of a transfer that this memory cursor is allowed to generate */
|
||||
IOPhysicalLength maxTransferSize;
|
||||
|
||||
/*! @var alignMask
|
||||
* Currently unused. Reserved for automated aligment restriction code. */
|
||||
IOPhysicalLength alignMask;
|
||||
|
||||
public:
|
||||
/*! @function withSpecification
|
||||
* @abstract Creates and initializes an IOMemoryCursor in one operation.
|
||||
* @discussion Factory function to create and initialize an IOMemoryCursor in one operation. For more information, see IOMemoryCursor::initWithSpecification.
|
||||
* @param outSegFunc SegmentFunction to call to output one physical segment.
|
||||
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
|
||||
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
|
||||
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
|
||||
* @result Returns a new memory cursor if successfully created and initialized, 0 otherwise.
|
||||
*/
|
||||
static IOMemoryCursor *
|
||||
withSpecification(SegmentFunction outSegFunc,
|
||||
IOPhysicalLength maxSegmentSize = 0,
|
||||
IOPhysicalLength maxTransferSize = 0,
|
||||
IOPhysicalLength alignment = 1);
|
||||
|
||||
/*! @function initWithSpecification
|
||||
* @abstract Primary initializer for the IOMemoryCursor class.
|
||||
* @param outSegFunc SegmentFunction to call to output one physical segment.
|
||||
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
|
||||
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
|
||||
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
|
||||
* @result Returns true if the inherited classes and this instance initialize
|
||||
* successfully.
|
||||
*/
|
||||
virtual bool initWithSpecification(SegmentFunction outSegFunc,
|
||||
IOPhysicalLength maxSegmentSize = 0,
|
||||
IOPhysicalLength maxTransferSize = 0,
|
||||
IOPhysicalLength alignment = 1);
|
||||
|
||||
/*! @function genPhysicalSegments
|
||||
* @abstract Generates a physical scatter/gather list given a memory descriptor.
|
||||
* @discussion Generates a list of physical segments from the given memory descriptor, relative to the current position of the descriptor.
|
||||
* @param descriptor IOMemoryDescriptor that describes the data associated with an I/O request.
|
||||
* @param fromPosition Starting location of the I/O within a memory descriptor.
|
||||
* @param segments Void pointer to base of output physical scatter/gather list. Always passed directly onto the SegmentFunction without interpretation by the cursor.
|
||||
* @param maxSegments Maximum number of segments that can be written to segments array.
|
||||
* @param maxTransferSize Maximum transfer size is limited to that many bytes, otherwise it defaults to the maximum transfer size specified when the memory cursor was initialized.
|
||||
* @param transferSize Pointer to an IOByteCount variable that can contain the total size of the transfer being described. Defaults to 0 indicating that no transfer size need be returned.
|
||||
* @result If the descriptor is exhausted of memory, a zero is returned, otherwise the number of segments that were filled in is returned.
|
||||
*/
|
||||
virtual UInt32 genPhysicalSegments(
|
||||
IOMemoryDescriptor *descriptor,
|
||||
IOByteCount fromPosition,
|
||||
void * segments,
|
||||
UInt32 maxSegments,
|
||||
UInt32 maxTransferSize = 0,
|
||||
IOByteCount *transferSize = NULL);
|
||||
};
|
||||
|
||||
/************************ class IONaturalMemoryCursor ************************/
|
||||
|
||||
|
||||
/*!
|
||||
* @class IONaturalMemoryCursor
|
||||
* @abstract An IOMemoryCursor subclass that outputs a vector of PhysicalSegments in the natural byte orientation for the CPU.
|
||||
* @discussion The IONaturalMemoryCursor would be used when it is too difficult to safely describe a SegmentFunction that is more appropriate for your hardware. This cursor just outputs an array of PhysicalSegments.
|
||||
*/
|
||||
class IONaturalMemoryCursor : public IOMemoryCursor
|
||||
{
|
||||
OSDeclareDefaultStructors(IONaturalMemoryCursor);
|
||||
|
||||
public:
|
||||
/*! @function outputSegment
|
||||
* @abstract Outputs the given segment into the output segments array in natural byte order.
|
||||
* @param segment The physical address and length that is next to be output.
|
||||
* @param segments Base of the output vector of DMA address length pairs.
|
||||
* @param segmentIndex Index to output 'segment' in the 'segments' array.
|
||||
*/
|
||||
static void outputSegment(PhysicalSegment segment,
|
||||
void * segments,
|
||||
UInt32 segmentIndex);
|
||||
|
||||
/*! @defined naturalOutputSegment
|
||||
* @discussion Backward compatibility define for the old global function definition. See IONaturalMemoryCursor::outputSegment.
|
||||
*/
|
||||
#define naturalOutputSegment IONaturalMemoryCursor::outputSegment
|
||||
|
||||
/*! @function withSpecification
|
||||
* @abstract Creates and initializes an IONaturalMemoryCursor in one operation.
|
||||
* @discussion Factory function to create and initialize an IONaturalMemoryCursor in one operation. For more information, see IONaturalMemoryCursor::initWithSpecification.
|
||||
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
|
||||
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
|
||||
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
|
||||
* @result Returns a new memory cursor if successfully created and initialized, 0 otherwise.
|
||||
*/
|
||||
static IONaturalMemoryCursor *
|
||||
withSpecification(IOPhysicalLength maxSegmentSize,
|
||||
IOPhysicalLength maxTransferSize,
|
||||
IOPhysicalLength alignment = 1);
|
||||
|
||||
/*! @function initWithSpecification
|
||||
* @abstract Primary initializer for the IONaturalMemoryCursor class.
|
||||
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
|
||||
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
|
||||
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
|
||||
* @result Returns true if the inherited classes and this instance initialize successfully.
|
||||
*/
|
||||
virtual bool initWithSpecification(IOPhysicalLength maxSegmentSize,
|
||||
IOPhysicalLength maxTransferSize,
|
||||
IOPhysicalLength alignment = 1);
|
||||
|
||||
|
||||
/*! @function getPhysicalSegments
|
||||
* @abstract Generates a CPU natural physical scatter/gather list given a memory descriptor.
|
||||
* @discussion Generates a list of physical segments from the given memory descriptor, relative to the current position of the descriptor. Wraps IOMemoryCursor::genPhysicalSegments.
|
||||
* @param descriptor IOMemoryDescriptor that describes the data associated with an I/O request.
|
||||
* @param fromPosition Starting location of the I/O within a memory descriptor.
|
||||
* @param segments Pointer to an array of IOMemoryCursor::PhysicalSegments for the output physical scatter/gather list.
|
||||
* @param maxSegments Maximum number of segments that can be written to segments array.
|
||||
* @param inMaxTransferSize Maximum transfer size is limited to that many bytes, otherwise it defaults to the maximum transfer size specified when the memory cursor was initialized.
|
||||
* @param transferSize Pointer to an IOByteCount variable that can contain the total size of the transfer being described. Defaults to 0 indicating that no transfer size need be returned.
|
||||
* @result If the descriptor is exhausted of memory, a zero is returned, otherwise the number of segments that were filled in is returned.
|
||||
*/
|
||||
virtual UInt32
|
||||
getPhysicalSegments(IOMemoryDescriptor *descriptor,
|
||||
IOByteCount fromPosition,
|
||||
PhysicalSegment *segments,
|
||||
UInt32 maxSegments,
|
||||
UInt32 inMaxTransferSize = 0,
|
||||
IOByteCount *transferSize = NULL)
|
||||
{
|
||||
return genPhysicalSegments(descriptor, fromPosition, segments,
|
||||
maxSegments, inMaxTransferSize, transferSize);
|
||||
}
|
||||
};
|
||||
|
||||
/************************** class IOBigMemoryCursor **************************/
|
||||
|
||||
/*!
|
||||
* @class IOBigMemoryCursor
|
||||
* @abstract An IOMemoryCursor subclass that outputs a vector of PhysicalSegments in the big endian byte order.
|
||||
* @discussion The IOBigMemoryCursor would be used when the DMA hardware requires a big endian address and length pair. This cursor outputs an array of PhysicalSegments that are encoded in big-endian format.
|
||||
*/
|
||||
class IOBigMemoryCursor : public IOMemoryCursor
|
||||
{
|
||||
OSDeclareDefaultStructors(IOBigMemoryCursor);
|
||||
|
||||
public:
|
||||
/*! @function outputSegment
|
||||
* @abstract Outputs the given segment into the output segments array in big endian byte order.
|
||||
* @param segment The physical address and length that is next to be output.
|
||||
* @param segments Base of the output vector of DMA address length pairs.
|
||||
* @param segmentIndex Index to output 'segment' in the 'segments' array.
|
||||
*/
|
||||
static void outputSegment(PhysicalSegment segment,
|
||||
void * segments,
|
||||
UInt32 segmentIndex);
|
||||
|
||||
/*! @defined bigOutputSegment
|
||||
* @discussion Backward compatibility define for the old global function definition. See IOBigMemoryCursor::outputSegment
|
||||
*/
|
||||
#define bigOutputSegment IOBigMemoryCursor::outputSegment
|
||||
|
||||
/*! @function withSpecification
|
||||
* @abstract Creates and initializes an IOBigMemoryCursor in one operation.
|
||||
* @discussion Factory function to create and initialize an IOBigMemoryCursor in one operation. See also IOBigMemoryCursor::initWithSpecification.
|
||||
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
|
||||
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
|
||||
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
|
||||
* @result Returns a new memory cursor if successfully created and initialized, 0 otherwise.
|
||||
*/
|
||||
static IOBigMemoryCursor *
|
||||
withSpecification(IOPhysicalLength maxSegmentSize,
|
||||
IOPhysicalLength maxTransferSize,
|
||||
IOPhysicalLength alignment = 1);
|
||||
|
||||
/*! @function initWithSpecification
|
||||
* @abstract Primary initializer for the IOBigMemoryCursor class.
|
||||
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
|
||||
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
|
||||
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
|
||||
* @result Returns true if the inherited classes and this instance initialize
|
||||
* successfully.
|
||||
*/
|
||||
virtual bool initWithSpecification(IOPhysicalLength maxSegmentSize,
|
||||
IOPhysicalLength maxTransferSize,
|
||||
IOPhysicalLength alignment = 1);
|
||||
|
||||
|
||||
/*! @function getPhysicalSegments
|
||||
* @abstract Generates a big endian physical scatter/gather list given a memory descriptor.
|
||||
* @discussion Generates a list of physical segments from the given memory descriptor, relative to the current position of the descriptor. Wraps IOMemoryCursor::genPhysicalSegments.
|
||||
* @param descriptor IOMemoryDescriptor that describes the data associated with an I/O request.
|
||||
* @param fromPosition Starting location of the I/O within a memory descriptor.
|
||||
* @param segments Pointer to an array of IOMemoryCursor::PhysicalSegments for the output physical scatter/gather list.
|
||||
* @param maxSegments Maximum number of segments that can be written to segments array.
|
||||
* @param inMaxTransferSize Maximum transfer size is limited to that many bytes, otherwise it defaults to the maximum transfer size specified when the memory cursor was initialized.
|
||||
* @param transferSize Pointer to an IOByteCount variable that can contain the total size of the transfer being described. Defaults to 0 indicating that no transfer size need be returned.
|
||||
* @result If the descriptor is exhausted of memory, a zero is returned, otherwise the number of segments that were filled in is returned.
|
||||
*/
|
||||
virtual UInt32
|
||||
getPhysicalSegments(IOMemoryDescriptor * descriptor,
|
||||
IOByteCount fromPosition,
|
||||
PhysicalSegment * segments,
|
||||
UInt32 maxSegments,
|
||||
UInt32 inMaxTransferSize = 0,
|
||||
IOByteCount * transferSize = NULL)
|
||||
{
|
||||
return genPhysicalSegments(descriptor, fromPosition, segments,
|
||||
maxSegments, inMaxTransferSize, transferSize);
|
||||
}
|
||||
};
|
||||
|
||||
/************************* class IOLittleMemoryCursor ************************/
|
||||
|
||||
/*!
|
||||
* @class IOLittleMemoryCursor
|
||||
* @abstract An IOMemoryCursor subclass that outputs a vector of PhysicalSegments in the little endian byte order.
|
||||
* @discussion The IOLittleMemoryCursor would be used when the DMA hardware requires a little endian address and length pair. This cursor outputs an array of PhysicalSegments that are encoded in little endian format.
|
||||
*/
|
||||
class IOLittleMemoryCursor : public IOMemoryCursor
|
||||
{
|
||||
OSDeclareDefaultStructors(IOLittleMemoryCursor);
|
||||
|
||||
public:
|
||||
/*! @function outputSegment
|
||||
* @abstract Outputs the given segment into the output segments array in little endian byte order.
|
||||
* @param segment The physical address and length that is next to be output.
|
||||
* @param segments Base of the output vector of DMA address length pairs.
|
||||
* @param segmentIndex Index to output 'segment' in the 'segments' array.
|
||||
*/
|
||||
static void outputSegment(PhysicalSegment segment,
|
||||
void * segments,
|
||||
UInt32 segmentIndex);
|
||||
|
||||
/*! @defined littleOutputSegment
|
||||
* @discussion Backward compatibility define for the old global function definition. See also IOLittleMemoryCursor::outputSegment. */
|
||||
#define littleOutputSegment IOLittleMemoryCursor::outputSegment
|
||||
|
||||
/*! @function withSpecification
|
||||
* @abstract Creates and initializes an IOLittleMemoryCursor in one operation.
|
||||
* @discussion Factory function to create and initialize an IOLittleMemoryCursor in one operation. See also IOLittleMemoryCursor::initWithSpecification.
|
||||
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
|
||||
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
|
||||
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
|
||||
* @result Returns a new memory cursor if successfully created and initialized, 0 otherwise.
|
||||
*/
|
||||
static IOLittleMemoryCursor *
|
||||
withSpecification(IOPhysicalLength maxSegmentSize,
|
||||
IOPhysicalLength maxTransferSize,
|
||||
IOPhysicalLength alignment = 1);
|
||||
|
||||
/*! @function initWithSpecification
|
||||
* @abstract Primary initializer for the IOLittleMemoryCursor class.
|
||||
* @param maxSegmentSize Maximum allowable size for one segment. Defaults to 0.
|
||||
* @param maxTransferSize Maximum size of an entire transfer. Defaults to 0 indicating no maximum.
|
||||
* @param alignment Alignment restrictions on output physical addresses. Not currently implemented. Defaults to single byte alignment.
|
||||
* @result Returns true if the inherited classes and this instance initialize successfully.
|
||||
*/
|
||||
virtual bool initWithSpecification(IOPhysicalLength maxSegmentSize,
|
||||
IOPhysicalLength maxTransferSize,
|
||||
IOPhysicalLength alignment = 1);
|
||||
|
||||
|
||||
/*! @function getPhysicalSegments
|
||||
* @abstract Generates a little endian physical scatter/gather list given a memory descriptor.
|
||||
* @discussion Generates a list of physical segments from the given memory descriptor, relative to the current position of the descriptor. Wraps IOMemoryCursor::genPhysicalSegments.
|
||||
* @param descriptor IOMemoryDescriptor that describes the data associated with an I/O request.
|
||||
* @param fromPosition Starting location of the I/O within a memory descriptor.
|
||||
* @param segments Pointer to an array of IOMemoryCursor::PhysicalSegments for the output physical scatter/gather list.
|
||||
* @param maxSegments Maximum number of segments that can be written to segments array.
|
||||
* @param inMaxTransferSize Maximum transfer size is limited to that many bytes, otherwise it defaults to the maximum transfer size specified when the memory cursor was initialized.
|
||||
* @param transferSize Pointer to an IOByteCount variable that can contain the total size of the transfer being described. Defaults to 0 indicating that no transfer size need be returned.
|
||||
* @result If the descriptor is exhausted of memory, a zero is returned, otherwise the number of segments that were filled in is returned.
|
||||
*/
|
||||
virtual UInt32
|
||||
getPhysicalSegments(IOMemoryDescriptor * descriptor,
|
||||
IOByteCount fromPosition,
|
||||
PhysicalSegment * segments,
|
||||
UInt32 maxSegments,
|
||||
UInt32 inMaxTransferSize = 0,
|
||||
IOByteCount * transferSize = NULL)
|
||||
{
|
||||
return genPhysicalSegments(descriptor, fromPosition, segments,
|
||||
maxSegments, inMaxTransferSize, transferSize);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* !_IOMEMORYCURSOR_H */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __IOKIT_IOMESSAGE_H
|
||||
#define __IOKIT_IOMESSAGE_H
|
||||
|
||||
#include <IOKit/IOReturn.h>
|
||||
#include <IOKit/IOTypes.h>
|
||||
|
||||
/*!
|
||||
* @header IOMessage.h
|
||||
*
|
||||
* Defines message type constants for several IOKit messaging API's.
|
||||
*
|
||||
*/
|
||||
|
||||
typedef UInt32 IOMessage;
|
||||
|
||||
#define iokit_common_msg(message) (UInt32)(sys_iokit|sub_iokit_common|message)
|
||||
#define iokit_family_msg(sub, message) (UInt32)(sys_iokit|sub|message)
|
||||
|
||||
/*!
|
||||
* @defined iokit_vendor_specific_msg
|
||||
* @discussion iokit_vendor_specific_msg passes messages in the sub_iokit_vendor_specific
|
||||
* subsystem. It can be used to generate messages that are used for private
|
||||
* communication between vendor specific code with the IOService::message() etc. APIs.
|
||||
*/
|
||||
#define iokit_vendor_specific_msg(message) (UInt32)(sys_iokit|sub_iokit_vendor_specific|message)
|
||||
|
||||
#define kIOMessageServiceIsTerminated iokit_common_msg(0x010)
|
||||
#define kIOMessageServiceIsSuspended iokit_common_msg(0x020)
|
||||
#define kIOMessageServiceIsResumed iokit_common_msg(0x030)
|
||||
|
||||
#define kIOMessageServiceIsRequestingClose iokit_common_msg(0x100)
|
||||
#define kIOMessageServiceIsAttemptingOpen iokit_common_msg(0x101)
|
||||
#define kIOMessageServiceWasClosed iokit_common_msg(0x110)
|
||||
|
||||
#define kIOMessageServiceBusyStateChange iokit_common_msg(0x120)
|
||||
|
||||
#define kIOMessageConsoleSecurityChange iokit_common_msg(0x128)
|
||||
|
||||
#define kIOMessageServicePropertyChange iokit_common_msg(0x130)
|
||||
|
||||
#define kIOMessageCopyClientID iokit_common_msg(0x330)
|
||||
|
||||
#define kIOMessageSystemCapabilityChange iokit_common_msg(0x340)
|
||||
#define kIOMessageDeviceSignaledWakeup iokit_common_msg(0x350)
|
||||
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageDeviceWillPowerOff
|
||||
* @discussion Indicates the device is about to move to a lower power state.
|
||||
* Sent to IOKit interest notification clients of type <code>kIOAppPowerStateInterest</code>
|
||||
* and <code>kIOGeneralInterest</code>.
|
||||
*/
|
||||
#define kIOMessageDeviceWillPowerOff iokit_common_msg(0x210)
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageDeviceHasPoweredOn
|
||||
* @discussion Indicates the device has just moved to a higher power state.
|
||||
* Sent to IOKit interest notification clients of type <code>kIOAppPowerStateInterest</code>
|
||||
* and <code>kIOGeneralInterest</code>.
|
||||
*/
|
||||
#define kIOMessageDeviceHasPoweredOn iokit_common_msg(0x230)
|
||||
|
||||
/*! @group In-kernel system shutdown and restart notifications
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageSystemWillPowerOff
|
||||
* @discussion Indicates an imminent system shutdown. Recipients have a limited
|
||||
* amount of time to respond, otherwise the system will timeout and
|
||||
* shutdown even without a response.
|
||||
* Delivered to in-kernel IOKit drivers via <code>IOService::systemWillShutdown()</code>,
|
||||
* and to clients of <code>registerPrioritySleepWakeInterest()</code>.
|
||||
* Never delivered to user space notification clients.
|
||||
*/
|
||||
#define kIOMessageSystemWillPowerOff iokit_common_msg(0x250)
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageSystemWillRestart
|
||||
* @discussion Indicates an imminent system restart. Recipients have a limited
|
||||
* amount of time to respond, otherwise the system will timeout and
|
||||
* restart even without a response.
|
||||
* Delivered to in-kernel IOKit drivers via <code>IOService::systemWillShutdown()</code>,
|
||||
* and to clients of <code>registerPrioritySleepWakeInterest()</code>.
|
||||
* Never delivered to user space notification clients.
|
||||
*/
|
||||
#define kIOMessageSystemWillRestart iokit_common_msg(0x310)
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageSystemPagingOff
|
||||
* @discussion Indicates an imminent system shutdown, paging device now unavailable.
|
||||
* Recipients have a limited amount of time to respond, otherwise the
|
||||
* system will timeout and shutdown even without a response.
|
||||
* Delivered to clients of <code>registerPrioritySleepWakeInterest()</code>.
|
||||
* Never delivered to user space notification clients.
|
||||
*/
|
||||
#define kIOMessageSystemPagingOff iokit_common_msg(0x255)
|
||||
|
||||
|
||||
/*! @group System sleep and wake notifications
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageCanSystemSleep
|
||||
* @discussion Announces/Requests permission to proceed to system sleep.
|
||||
* Delivered to in-kernel IOKit drivers via <code>kIOGeneralInterest</code>
|
||||
* and <code>kIOPriorityPowerStateInterest</code>.
|
||||
* Delivered to user clients of <code>IORegisterForSystemPower</code>.
|
||||
*/
|
||||
#define kIOMessageCanSystemSleep iokit_common_msg(0x270)
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageSystemWillNotSleep
|
||||
* @discussion Announces that the system has retracted a previous attempt to sleep;
|
||||
* it follows <code>kIOMessageCanSystemSleep</code>.
|
||||
* Delivered to in-kernel IOKit drivers via <code>kIOGeneralInterest</code>
|
||||
* and <code>kIOPriorityPowerStateInterest</code>.
|
||||
* Delivered to user clients of <code>IORegisterForSystemPower</code>.
|
||||
*/
|
||||
#define kIOMessageSystemWillNotSleep iokit_common_msg(0x290)
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageSystemWillSleep
|
||||
* @discussion Announces that sleep is beginning.
|
||||
* Delivered to in-kernel IOKit drivers via <code>kIOGeneralInterest</code>
|
||||
* and <code>kIOPriorityPowerStateInterest</code>.
|
||||
* Delivered to user clients of <code>IORegisterForSystemPower</code>.
|
||||
*/
|
||||
#define kIOMessageSystemWillSleep iokit_common_msg(0x280)
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageSystemWillPowerOn
|
||||
* @discussion Announces that the system is beginning to power the device tree; most
|
||||
* devices are unavailable at this point..
|
||||
* Delivered to in-kernel IOKit drivers via <code>kIOGeneralInterest</code>
|
||||
* and <code>kIOPriorityPowerStateInterest</code>.
|
||||
* Delivered to user clients of <code>IORegisterForSystemPower</code>.
|
||||
*/
|
||||
#define kIOMessageSystemWillPowerOn iokit_common_msg(0x320)
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageSystemHasPoweredOn
|
||||
* @discussion Announces that the system and its devices have woken up.
|
||||
* Delivered to in-kernel IOKit drivers via <code>kIOGeneralInterest</code>
|
||||
* and <code>kIOPriorityPowerStateInterest</code>.
|
||||
* Delivered to user clients of <code>IORegisterForSystemPower</code>.
|
||||
*/
|
||||
#define kIOMessageSystemHasPoweredOn iokit_common_msg(0x300)
|
||||
|
||||
/*! @group Unused and deprecated notifications
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageCanDevicePowerOff
|
||||
* @discussion Delivered to <code>kIOAppPowerStateInterest</code> clients of
|
||||
* devices that implement their own idle timeouts.
|
||||
* This message type is almost never used.
|
||||
*/
|
||||
#define kIOMessageCanDevicePowerOff iokit_common_msg(0x200)
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageDeviceWillNotPowerOff
|
||||
* @discussion This IOKit interest notification is largely unused;
|
||||
* it's not very interesting.
|
||||
*/
|
||||
#define kIOMessageDeviceWillNotPowerOff iokit_common_msg(0x220)
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageSystemWillNotPowerOff
|
||||
* @deprecated This IOKit message is unused.
|
||||
*/
|
||||
#define kIOMessageSystemWillNotPowerOff iokit_common_msg(0x260)
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageCanSystemPowerOff
|
||||
* @deprecated This IOKit message is unused.
|
||||
*/
|
||||
#define kIOMessageCanSystemPowerOff iokit_common_msg(0x240)
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageDeviceWillPowerOn
|
||||
* @discussion IOService power mgt does not send kIOMessageDeviceWillPowerOn.
|
||||
*/
|
||||
#define kIOMessageDeviceWillPowerOn iokit_common_msg(0x215)
|
||||
|
||||
/*!
|
||||
* @defined kIOMessageDeviceHasPoweredOff
|
||||
* @discussion IOService power mgt does not send kIOMessageDeviceHasPoweredOff.
|
||||
*/
|
||||
#define kIOMessageDeviceHasPoweredOff iokit_common_msg(0x225)
|
||||
|
||||
|
||||
#endif /* ! __IOKIT_IOMESSAGE_H */
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOMULTIMEMORYDESCRIPTOR_H
|
||||
#define _IOMULTIMEMORYDESCRIPTOR_H
|
||||
|
||||
#include <IOKit/IOMemoryDescriptor.h>
|
||||
|
||||
/*! @class IOMultiMemoryDescriptor : public IOMemoryDescriptor
|
||||
* @abstract The IOMultiMemoryDescriptor object describes a memory area made up of several other IOMemoryDescriptors.
|
||||
* @discussion The IOMultiMemoryDescriptor object represents multiple ranges of memory, specified as an ordered list of IOMemoryDescriptors. The descriptors are chained end-to-end to make up a single contiguous buffer. */
|
||||
|
||||
class IOMultiMemoryDescriptor : public IOMemoryDescriptor
|
||||
{
|
||||
OSDeclareDefaultStructors(IOMultiMemoryDescriptor);
|
||||
|
||||
protected:
|
||||
|
||||
IOMemoryDescriptor ** _descriptors;
|
||||
UInt32 _descriptorsCount;
|
||||
bool _descriptorsIsAllocated;
|
||||
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
/*! @function withDescriptors
|
||||
* @abstract Create an IOMultiMemoryDescriptor to describe a memory area made up of several other IOMemoryDescriptors.
|
||||
* @discussion This method creates and initializes an IOMultiMemoryDescriptor for memory consisting of a number of other IOMemoryDescriptors, chained end-to-end (in the order they appear in the array) to represent a single contiguous memory buffer. Passing the descriptor array as a reference will avoid an extra allocation.
|
||||
* @param descriptors An array of IOMemoryDescriptors which make up the memory to be described.
|
||||
* @param withCount The object count for the descriptors array.
|
||||
* @param withDirection An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
|
||||
* @param asReference If false, the IOMultiMemoryDescriptor object will make a copy of the descriptors array, otherwise, the array will be used in situ, avoiding an extra allocation.
|
||||
* @result The created IOMultiMemoryDescriptor on success, to be released by the caller, or zero on failure. */
|
||||
|
||||
static IOMultiMemoryDescriptor * withDescriptors(
|
||||
IOMemoryDescriptor ** descriptors,
|
||||
UInt32 withCount,
|
||||
IODirection withDirection,
|
||||
bool asReference = false );
|
||||
|
||||
/*! @function withDescriptors
|
||||
* @abstract Initialize an IOMultiMemoryDescriptor to describe a memory area made up of several other IOMemoryDescriptors.
|
||||
* @discussion This method initializes an IOMultiMemoryDescriptor for memory consisting of a number of other IOMemoryDescriptors, chained end-to-end (in the order they appear in the array) to represent a single contiguous memory buffer. Passing the descriptor array as a reference will avoid an extra allocation.
|
||||
* @param descriptors An array of IOMemoryDescriptors which make up the memory to be described.
|
||||
* @param withCount The object count for the descriptors array.
|
||||
* @param withDirection An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
|
||||
* @param asReference If false, the IOMultiMemoryDescriptor object will make a copy of the descriptors array, otherwise, the array will be used in situ, avoiding an extra allocation.
|
||||
* @result The created IOMultiMemoryDescriptor on success, to be released by the caller, or zero on failure. */
|
||||
|
||||
virtual bool initWithDescriptors(
|
||||
IOMemoryDescriptor ** descriptors,
|
||||
UInt32 withCount,
|
||||
IODirection withDirection,
|
||||
bool asReference = false );
|
||||
|
||||
/*! @function getPhysicalSegment
|
||||
* @abstract Break a memory descriptor into its physically contiguous segments.
|
||||
* @discussion This method returns the physical address of the byte at the given offset into the memory, and optionally the length of the physically contiguous segment from that offset.
|
||||
* @param offset A byte offset into the memory whose physical address to return.
|
||||
* @param length If non-zero, getPhysicalSegment will store here the length of the physically contiguous segement at the given offset.
|
||||
* @result A physical address, or zero if the offset is beyond the length of the memory. */
|
||||
|
||||
virtual addr64_t getPhysicalSegment( IOByteCount offset,
|
||||
IOByteCount * length,
|
||||
IOOptionBits options = 0 ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function prepare
|
||||
* @abstract Prepare the memory for an I/O transfer.
|
||||
* @discussion This involves paging in the memory, if necessary, and wiring it down for the duration of the transfer. The complete() method completes the processing of the memory after the I/O transfer finishes. This method needn't called for non-pageable memory.
|
||||
* @param forDirection The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
|
||||
* @result An IOReturn code. */
|
||||
|
||||
virtual IOReturn prepare(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function complete
|
||||
* @abstract Complete processing of the memory after an I/O transfer finishes.
|
||||
* @discussion This method should not be called unless a prepare was previously issued; the prepare() and complete() must occur in pairs, before and after an I/O transfer involving pageable memory.
|
||||
* @param forDirection The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
|
||||
* @result An IOReturn code. */
|
||||
|
||||
virtual IOReturn complete(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOReturn setPurgeable(IOOptionBits newState, IOOptionBits * oldState) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
IOReturn setOwnership(task_t newOwner, int newLedgerTag, IOOptionBits newOptions);
|
||||
|
||||
/*! @function getPageCounts
|
||||
* @abstract Retrieve the number of resident and/or dirty pages encompassed by an IOMemoryDescriptor.
|
||||
* @discussion This method returns the number of resident and/or dirty pages encompassed by an IOMemoryDescriptor.
|
||||
* @param residentPageCount - If non-null, a pointer to a byte count that will return the number of resident pages encompassed by this IOMemoryDescriptor.
|
||||
* @param dirtyPageCount - If non-null, a pointer to a byte count that will return the number of dirty pages encompassed by this IOMemoryDescriptor.
|
||||
* @result An IOReturn code. */
|
||||
|
||||
IOReturn getPageCounts(IOByteCount * residentPageCount,
|
||||
IOByteCount * dirtyPageCount);
|
||||
|
||||
virtual uint64_t getPreparationID( void ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
#define IOMULTIMEMORYDESCRIPTOR_SUPPORTS_GETPAGECOUNTS 1
|
||||
|
||||
private:
|
||||
virtual IOReturn doMap(vm_map_t addressMap,
|
||||
IOVirtualAddress * atAddress,
|
||||
IOOptionBits options,
|
||||
IOByteCount sourceOffset = 0,
|
||||
IOByteCount length = 0 ) APPLE_KEXT_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif /* !_IOMULTIMEMORYDESCRIPTOR_H */
|
||||
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2006 Apple Computer, Inc. All rights reserved.
|
||||
* Copyright (c) 2007-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IONVRAM_H
|
||||
#define _IOKIT_IONVRAM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <IOKit/IOKitKeys.h>
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/IODeviceTreeSupport.h>
|
||||
#include <IOKit/nvram/IONVRAMController.h>
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define kIODTNVRAMOFPartitionName "common"
|
||||
#define kIODTNVRAMXPRAMPartitionName "APL,MacOS75"
|
||||
#define kIODTNVRAMPanicInfoPartitonName "APL,OSXPanic"
|
||||
#define kIODTNVRAMFreePartitionName "wwwwwwwwwwww"
|
||||
|
||||
#define MIN_SYNC_NOW_INTERVAL 15*60 /* Minimum 15 Minutes interval mandated */
|
||||
|
||||
enum {
|
||||
kIODTNVRAMImageSize = 0x2000,
|
||||
kIODTNVRAMXPRAMSize = 0x0100,
|
||||
kIODTNVRAMNameRegistrySize = 0x0400
|
||||
};
|
||||
|
||||
enum {
|
||||
kOFVariableTypeBoolean = 1,
|
||||
kOFVariableTypeNumber,
|
||||
kOFVariableTypeString,
|
||||
kOFVariableTypeData
|
||||
};
|
||||
|
||||
enum {
|
||||
kOFVariablePermRootOnly = 0,
|
||||
kOFVariablePermUserRead,
|
||||
kOFVariablePermUserWrite,
|
||||
kOFVariablePermKernelOnly
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class IODTNVRAM : public IOService
|
||||
{
|
||||
OSDeclareDefaultStructors(IODTNVRAM);
|
||||
|
||||
private:
|
||||
IONVRAMController *_nvramController;
|
||||
const OSSymbol *_registryPropertiesKey;
|
||||
UInt8 *_nvramImage;
|
||||
__unused bool _nvramImageDirty;
|
||||
UInt32 _ofPartitionOffset;
|
||||
UInt32 _ofPartitionSize;
|
||||
UInt8 *_ofImage;
|
||||
__unused bool _ofImageDirty;
|
||||
OSDictionary *_ofDict;
|
||||
OSDictionary *_nvramPartitionOffsets;
|
||||
OSDictionary *_nvramPartitionLengths;
|
||||
UInt32 _resv0 __unused;
|
||||
UInt32 _resv1 __unused;
|
||||
IOLock *_ofLock;
|
||||
UInt32 _resv2 __unused;
|
||||
UInt32 _resv3 __unused;
|
||||
UInt8 *_resv4 __unused;
|
||||
UInt32 _piPartitionOffset;
|
||||
UInt32 _piPartitionSize;
|
||||
UInt8 *_piImage;
|
||||
bool _systemPaniced;
|
||||
SInt32 _lastDeviceSync;
|
||||
bool _freshInterval;
|
||||
bool _isProxied;
|
||||
|
||||
virtual UInt8 calculatePartitionChecksum(UInt8 *partitionHeader);
|
||||
virtual IOReturn initOFVariables(void);
|
||||
public:
|
||||
virtual IOReturn syncOFVariables(void);
|
||||
private:
|
||||
virtual UInt32 getOFVariableType(const OSSymbol *propSymbol) const;
|
||||
virtual UInt32 getOFVariablePerm(const OSSymbol *propSymbol) const;
|
||||
virtual bool getOWVariableInfo(UInt32 variableNumber, const OSSymbol **propSymbol,
|
||||
UInt32 *propType, UInt32 *propOffset);
|
||||
virtual bool convertPropToObject(UInt8 *propName, UInt32 propNameLength,
|
||||
UInt8 *propData, UInt32 propDataLength,
|
||||
LIBKERN_RETURNS_RETAINED const OSSymbol **propSymbol,
|
||||
LIBKERN_RETURNS_RETAINED OSObject **propObject);
|
||||
virtual bool convertObjectToProp(UInt8 *buffer, UInt32 *length,
|
||||
const OSSymbol *propSymbol, OSObject *propObject);
|
||||
virtual UInt16 generateOWChecksum(UInt8 *buffer);
|
||||
virtual bool validateOWChecksum(UInt8 *buffer);
|
||||
virtual void updateOWBootArgs(const OSSymbol *key, OSObject *value);
|
||||
virtual bool searchNVRAMProperty(struct IONVRAMDescriptor *hdr,
|
||||
UInt32 *where);
|
||||
|
||||
virtual IOReturn readNVRAMPropertyType0(IORegistryEntry *entry,
|
||||
const OSSymbol **name,
|
||||
OSData **value);
|
||||
virtual IOReturn writeNVRAMPropertyType0(IORegistryEntry *entry,
|
||||
const OSSymbol *name,
|
||||
OSData * value);
|
||||
|
||||
virtual OSData *unescapeBytesToData(const UInt8 *bytes, UInt32 length);
|
||||
virtual OSData *escapeDataToData(OSData * value);
|
||||
|
||||
virtual IOReturn readNVRAMPropertyType1(IORegistryEntry *entry,
|
||||
const OSSymbol **name,
|
||||
OSData **value);
|
||||
virtual IOReturn writeNVRAMPropertyType1(IORegistryEntry *entry,
|
||||
const OSSymbol *name,
|
||||
OSData *value);
|
||||
|
||||
void initNVRAMImage(void);
|
||||
void initProxyData(void);
|
||||
IOReturn syncVariables(void);
|
||||
IOReturn setPropertyInternal(const OSSymbol *aKey, OSObject *anObject);
|
||||
|
||||
|
||||
public:
|
||||
virtual bool init(IORegistryEntry *old, const IORegistryPlane *plane) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual void registerNVRAMController(IONVRAMController *nvram);
|
||||
|
||||
virtual void sync(void);
|
||||
|
||||
virtual bool serializeProperties(OSSerialize *s) const APPLE_KEXT_OVERRIDE;
|
||||
virtual OSObject *copyProperty(const OSSymbol *aKey) const APPLE_KEXT_OVERRIDE;
|
||||
virtual OSObject *copyProperty(const char *aKey) const APPLE_KEXT_OVERRIDE;
|
||||
virtual OSObject *getProperty(const OSSymbol *aKey) const APPLE_KEXT_OVERRIDE;
|
||||
virtual OSObject *getProperty(const char *aKey) const APPLE_KEXT_OVERRIDE;
|
||||
virtual bool setProperty(const OSSymbol *aKey, OSObject *anObject) APPLE_KEXT_OVERRIDE;
|
||||
virtual void removeProperty(const OSSymbol *aKey) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn setProperties(OSObject *properties) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOReturn readXPRAM(IOByteCount offset, UInt8 *buffer,
|
||||
IOByteCount length);
|
||||
virtual IOReturn writeXPRAM(IOByteCount offset, UInt8 *buffer,
|
||||
IOByteCount length);
|
||||
|
||||
virtual IOReturn readNVRAMProperty(IORegistryEntry *entry,
|
||||
const OSSymbol **name,
|
||||
OSData **value);
|
||||
virtual IOReturn writeNVRAMProperty(IORegistryEntry *entry,
|
||||
const OSSymbol *name,
|
||||
OSData *value);
|
||||
|
||||
virtual OSDictionary *getNVRAMPartitions(void);
|
||||
|
||||
virtual IOReturn readNVRAMPartition(const OSSymbol *partitionID,
|
||||
IOByteCount offset, UInt8 *buffer,
|
||||
IOByteCount length);
|
||||
|
||||
virtual IOReturn writeNVRAMPartition(const OSSymbol *partitionID,
|
||||
IOByteCount offset, UInt8 *buffer,
|
||||
IOByteCount length);
|
||||
|
||||
virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
|
||||
virtual bool safeToSync(void);
|
||||
void syncInternal(bool rateLimit);
|
||||
};
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* !_IOKIT_IONVRAM_H */
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* HISTORY
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IONOTIFIER_H
|
||||
#define _IOKIT_IONOTIFIER_H
|
||||
|
||||
#include <libkern/c++/OSObject.h>
|
||||
|
||||
/*! @class IONotifier : public OSObject
|
||||
* @abstract An abstract base class defining common methods for controlling a notification request.
|
||||
* @discussion IOService notification requests are represented as implementations of the IONotifier object. It defines methods to enable, disable and remove notification requests. These actions are synchronized with invocations of the notification handler, so removing a notification request will guarantee the handler is not being executed. */
|
||||
|
||||
class IONotifier : public OSObject
|
||||
{
|
||||
OSDeclareAbstractStructors(IONotifier);
|
||||
|
||||
public:
|
||||
|
||||
/*! @function remove
|
||||
* @abstract Removes the notification request and releases it.
|
||||
* @discussion Removes the notification request and release it. Since creating an IONotifier instance will leave it with a retain count of one, creating an IONotifier and then removing it will destroy it. This method is synchronous with any handler invocations, so when this method returns its guaranteed the handler will not be in entered. */
|
||||
|
||||
virtual void remove() = 0;
|
||||
|
||||
/*! @function disable
|
||||
* @abstract Disables the notification request.
|
||||
* @discussion Disables the notification request. This method is synchronous with any handler invocations, so when this method returns its guaranteed the handler will not be in entered.
|
||||
* @result Returns the previous enable state of the IONotifier. */
|
||||
|
||||
virtual bool disable() = 0;
|
||||
|
||||
/*! @function enable
|
||||
* @abstract Sets the enable state of the notification request.
|
||||
* @discussion Restores the enable state of the notification request, given the previous state passed in.
|
||||
* @param was The enable state of the notifier to restore. */
|
||||
|
||||
virtual void enable( bool was ) = 0;
|
||||
};
|
||||
|
||||
#endif /* ! _IOKIT_IONOTIFIER_H */
|
||||
@@ -0,0 +1,428 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* HISTORY
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _IOKIT_IOPLATFORMEXPERT_H
|
||||
#define _IOKIT_IOPLATFORMEXPERT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <IOKit/IOLib.h>
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/IOInterrupts.h>
|
||||
#include <IOKit/IOInterruptController.h>
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libkern/OSTypes.h>
|
||||
|
||||
typedef enum {
|
||||
kCoprocessorVersionNone = 0x00000000,
|
||||
kCoprocessorVersion1 = 0x00010000,
|
||||
kCoprocessorVersion2 = 0x00020000,
|
||||
} coprocessor_type_t;
|
||||
|
||||
|
||||
extern boolean_t PEGetMachineName( char * name, int maxLength );
|
||||
extern boolean_t PEGetModelName( char * name, int maxLength );
|
||||
extern int PEGetPlatformEpoch( void );
|
||||
|
||||
enum {
|
||||
kPEHaltCPU,
|
||||
kPERestartCPU,
|
||||
kPEHangCPU,
|
||||
kPEUPSDelayHaltCPU,
|
||||
kPEPanicRestartCPU,
|
||||
kPEPanicSync,
|
||||
kPEPagingOff,
|
||||
kPEPanicBegin,
|
||||
kPEPanicEnd,
|
||||
kPEPanicDiskShutdown,
|
||||
kPEPanicRestartCPUNoPanicEndCallouts,
|
||||
kPEPanicRestartCPUNoCallouts
|
||||
};
|
||||
extern int (*PE_halt_restart)(unsigned int type);
|
||||
extern int PEHaltRestart(unsigned int type);
|
||||
|
||||
|
||||
|
||||
// Save the Panic Info. Returns the number of bytes saved.
|
||||
extern UInt32 PESavePanicInfo(UInt8 *buffer, UInt32 length);
|
||||
extern void PESavePanicInfoAction(void *buffer, UInt32 offset, UInt32 length);
|
||||
|
||||
/*
|
||||
* SMC requires that all data is flushed in multiples of 16 bytes at 16 byte
|
||||
* boundaries.
|
||||
*/
|
||||
#define PANIC_FLUSH_BOUNDARY 16
|
||||
|
||||
extern long PEGetGMTTimeOfDay( void );
|
||||
extern void PESetGMTTimeOfDay( long secs );
|
||||
extern void PEGetUTCTimeOfDay( clock_sec_t * secs, clock_usec_t * usecs );
|
||||
extern void PESetUTCTimeOfDay( clock_sec_t secs, clock_usec_t usecs );
|
||||
|
||||
/* unless it's a "well-known" property, these will read/write out the value as raw data */
|
||||
|
||||
extern boolean_t PEWriteNVRAMBooleanProperty(const char *symbol, boolean_t value);
|
||||
extern boolean_t PEWriteNVRAMProperty(const char *symbol, const void *value, const unsigned int len);
|
||||
extern boolean_t PEWriteNVRAMPropertyWithCopy(const char *symbol, const void *value, const unsigned int len);
|
||||
|
||||
extern boolean_t PEReadNVRAMProperty(const char *symbol, void *value, unsigned int *len);
|
||||
|
||||
extern boolean_t PERemoveNVRAMProperty(const char *symbol);
|
||||
|
||||
extern coprocessor_type_t PEGetCoprocessorVersion( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
||||
#define kIOPlatformMapperPresentKey "IOPlatformMapperPresent"
|
||||
|
||||
|
||||
|
||||
|
||||
extern OSSymbol * gPlatformInterruptControllerName;
|
||||
|
||||
/*
|
||||
* IOPlatformSleepAction
|
||||
*
|
||||
* Sleep is called after power management has finished all of the power plane
|
||||
* driver power management notifications and state transitions and has
|
||||
* committed to sleep, but before the other CPUs are powered off.
|
||||
* The scheduler is still active.
|
||||
*/
|
||||
extern const OSSymbol *gIOPlatformSleepActionKey;
|
||||
|
||||
/*
|
||||
* IOPlatformWakeAction
|
||||
*
|
||||
* Wake is called with the scheduler enabled, but before
|
||||
* powering on other CPUs, so try to minimize work done in this path to speed
|
||||
* up wake time.
|
||||
*/
|
||||
extern const OSSymbol *gIOPlatformWakeActionKey;
|
||||
|
||||
/*
|
||||
* IOPlatformQuiesceAction
|
||||
*
|
||||
* Quiesce is called after all CPUs are off, scheduling is disabled,
|
||||
* and the boot CPU is about to pull the plug.
|
||||
* Mutexes and blocking are disallowed in this context and will panic.
|
||||
* Do not pass this action to super() (incl. IOService, IOPlatformExpert)
|
||||
*/
|
||||
extern const OSSymbol *gIOPlatformQuiesceActionKey;
|
||||
|
||||
/*
|
||||
* IOPlatformActiveAction
|
||||
*
|
||||
* Active is called very early in the wake path before enabling the scheduler
|
||||
* on the boot CPU.
|
||||
* Mutexes and blocking are disallowed in this context and will panic.
|
||||
* Do not pass this action to super() (incl. IOService, IOPlatformExpert)
|
||||
*/
|
||||
extern const OSSymbol *gIOPlatformActiveActionKey;
|
||||
|
||||
/*
|
||||
* IOPlatformHaltRestartAction
|
||||
*
|
||||
* Halt/Restart is called after the kernel finishes shutting down the
|
||||
* system and is ready to power off or reboot.
|
||||
*
|
||||
* It is not guaranteed to be called in non-graceful shutdown scenarios.
|
||||
*/
|
||||
extern const OSSymbol *gIOPlatformHaltRestartActionKey;
|
||||
|
||||
/*
|
||||
* IOPlatformPanicAction
|
||||
*
|
||||
* Panic is called when the system is panicking before it records a core file
|
||||
* (if it is configured to do so)
|
||||
*
|
||||
* It can be called at any time, in any context, in any state. Don't depend
|
||||
* on anything being powered on in a useful state.
|
||||
*
|
||||
* Mutexes and blocking are disallowed in this context and will fail.
|
||||
*
|
||||
* If you hang or panic again in this callout, the panic log may not be recorded,
|
||||
* leading to the loss of field reports about customer issues.
|
||||
*/
|
||||
extern const OSSymbol *gIOPlatformPanicActionKey;
|
||||
|
||||
class IORangeAllocator;
|
||||
class IONVRAMController;
|
||||
class IOPMrootDomain;
|
||||
|
||||
class IOPlatformExpert : public IOService
|
||||
{
|
||||
OSDeclareDefaultStructors(IOPlatformExpert);
|
||||
|
||||
private:
|
||||
long _peBootROMType;
|
||||
long _peChipSetType;
|
||||
long _peMachineType;
|
||||
|
||||
protected:
|
||||
IOPMrootDomain * root;
|
||||
int _pePMFeatures;
|
||||
int _pePrivPMFeatures;
|
||||
int _peNumBatteriesSupported;
|
||||
OSArray * thePowerTree;
|
||||
|
||||
bool searchingForAdditionalParents;
|
||||
OSNumber * multipleParentKeyValue;
|
||||
int numInstancesRegistered;
|
||||
|
||||
struct ExpansionData { };
|
||||
ExpansionData *iope_reserved __unused;
|
||||
|
||||
virtual void setBootROMType(long peBootROMType);
|
||||
virtual void setChipSetType(long peChipSetType);
|
||||
virtual void setMachineType(long peMachineType);
|
||||
|
||||
virtual bool CheckSubTree(OSArray * inSubTree, IOService * theNub, IOService * theDevice, OSDictionary * theParent);
|
||||
virtual bool RegisterServiceInTree(IOService * theService, OSDictionary * theTreeNode, OSDictionary * theTreeParentNode, IOService * theProvider);
|
||||
|
||||
virtual void PMInstantiatePowerDomains( void );
|
||||
|
||||
public:
|
||||
virtual bool attach( IOService * provider ) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool start( IOService * provider ) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool configure( IOService * provider );
|
||||
virtual IOService * createNub( OSDictionary * from );
|
||||
|
||||
virtual bool compareNubName( const IOService * nub, OSString * name,
|
||||
OSString ** matched = NULL ) const;
|
||||
virtual IOReturn getNubResources( IOService * nub );
|
||||
|
||||
virtual long getBootROMType(void);
|
||||
virtual long getChipSetType(void);
|
||||
virtual long getMachineType(void);
|
||||
|
||||
virtual bool getModelName( char * name, int maxLength );
|
||||
virtual bool getMachineName( char * name, int maxLength );
|
||||
|
||||
virtual int haltRestart(unsigned int type);
|
||||
virtual void sleepKernel(void);
|
||||
|
||||
virtual long getGMTTimeOfDay( void );
|
||||
virtual void setGMTTimeOfDay( long secs );
|
||||
|
||||
virtual IOReturn getConsoleInfo( PE_Video * consoleInfo );
|
||||
virtual IOReturn setConsoleInfo( PE_Video * consoleInfo, unsigned int op );
|
||||
|
||||
virtual void registerNVRAMController( IONVRAMController * nvram );
|
||||
|
||||
virtual IOReturn registerInterruptController(OSSymbol *name, IOInterruptController *interruptController);
|
||||
virtual LIBKERN_RETURNS_NOT_RETAINED IOInterruptController *
|
||||
lookUpInterruptController(OSSymbol *name);
|
||||
|
||||
virtual void setCPUInterruptProperties(IOService *service);
|
||||
virtual bool atInterruptLevel(void);
|
||||
|
||||
virtual IOReturn callPlatformFunction(const OSSymbol *functionName,
|
||||
bool waitForFunction,
|
||||
void *param1, void *param2,
|
||||
void *param3, void *param4) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IORangeAllocator * getPhysicalRangeAllocator(void);
|
||||
|
||||
virtual bool platformAdjustService(IOService *service);
|
||||
|
||||
virtual void PMRegisterDevice(IOService * theNub, IOService * theDevice);
|
||||
virtual void PMLog( const char *, unsigned long, unsigned long, unsigned long );
|
||||
|
||||
virtual bool hasPMFeature(unsigned long featureMask);
|
||||
virtual bool hasPrivPMFeature(unsigned long privFeatureMask);
|
||||
virtual int numBatteriesSupported(void);
|
||||
|
||||
virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
|
||||
|
||||
virtual OSString* createSystemSerialNumberString(OSData* myProperty);
|
||||
|
||||
virtual IOReturn deregisterInterruptController(OSSymbol *name);
|
||||
|
||||
virtual void getUTCTimeOfDay( clock_sec_t * secs, clock_nsec_t * nsecs );
|
||||
virtual void setUTCTimeOfDay( clock_sec_t secs, clock_nsec_t nsecs );
|
||||
|
||||
OSMetaClassDeclareReservedUsed(IOPlatformExpert, 0);
|
||||
OSMetaClassDeclareReservedUsed(IOPlatformExpert, 1);
|
||||
OSMetaClassDeclareReservedUsed(IOPlatformExpert, 2);
|
||||
OSMetaClassDeclareReservedUsed(IOPlatformExpert, 3);
|
||||
OSMetaClassDeclareReservedUsed(IOPlatformExpert, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformExpert, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformExpert, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformExpert, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformExpert, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformExpert, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformExpert, 10);
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformExpert, 11);
|
||||
};
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
class IODTNVRAM;
|
||||
|
||||
class IODTPlatformExpert : public IOPlatformExpert
|
||||
{
|
||||
OSDeclareAbstractStructors(IODTPlatformExpert);
|
||||
|
||||
private:
|
||||
IODTNVRAM *dtNVRAM;
|
||||
|
||||
struct ExpansionData { };
|
||||
ExpansionData *iodtpe_reserved;
|
||||
|
||||
public:
|
||||
virtual IOService * probe( IOService * provider,
|
||||
SInt32 * score ) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool configure( IOService * provider ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual void processTopLevel( IORegistryEntry * root );
|
||||
virtual const char * deleteList( void ) = 0;
|
||||
virtual const char * excludeList( void ) = 0;
|
||||
virtual IOService * createNub( IORegistryEntry * from );
|
||||
virtual bool createNubs( IOService * parent, LIBKERN_CONSUMED OSIterator * iter );
|
||||
|
||||
virtual bool compareNubName( const IOService * nub, OSString * name,
|
||||
OSString ** matched = NULL ) const APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOReturn getNubResources( IOService * nub ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual bool getModelName( char * name, int maxLength ) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool getMachineName( char * name, int maxLength ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual void registerNVRAMController( IONVRAMController * nvram ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual int haltRestart(unsigned int type) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/* virtual */ IOReturn readXPRAM(IOByteCount offset, UInt8 * buffer,
|
||||
IOByteCount length);
|
||||
|
||||
/* virtual */ IOReturn writeXPRAM(IOByteCount offset, UInt8 * buffer,
|
||||
IOByteCount length);
|
||||
|
||||
virtual IOReturn readNVRAMProperty(
|
||||
IORegistryEntry * entry,
|
||||
const OSSymbol ** name, OSData ** value );
|
||||
|
||||
virtual IOReturn writeNVRAMProperty(
|
||||
IORegistryEntry * entry,
|
||||
const OSSymbol * name, OSData * value );
|
||||
|
||||
// This returns a dictionary describing all the NVRAM partitions.
|
||||
// The keys will be the partitionIDs of the form "0x52,nvram".
|
||||
// The values will be OSNumbers of the partition's byte count.
|
||||
/* virtual */ OSDictionary *getNVRAMPartitions(void);
|
||||
|
||||
/* virtual */ IOReturn readNVRAMPartition(const OSSymbol * partitionID,
|
||||
IOByteCount offset, UInt8 * buffer,
|
||||
IOByteCount length);
|
||||
|
||||
/* virtual */ IOReturn writeNVRAMPartition(const OSSymbol * partitionID,
|
||||
IOByteCount offset, UInt8 * buffer,
|
||||
IOByteCount length);
|
||||
|
||||
virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length) APPLE_KEXT_OVERRIDE;
|
||||
virtual OSString* createSystemSerialNumberString(OSData* myProperty) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 0);
|
||||
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 1);
|
||||
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 2);
|
||||
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 3);
|
||||
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 4);
|
||||
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 5);
|
||||
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 6);
|
||||
OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 7);
|
||||
};
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/* generic root nub of service tree */
|
||||
|
||||
class IOPlatformExpertDevice : public IOService
|
||||
{
|
||||
OSDeclareDefaultStructors(IOPlatformExpertDevice);
|
||||
|
||||
private:
|
||||
IOWorkLoop *workLoop;
|
||||
|
||||
struct ExpansionData { };
|
||||
ExpansionData *ioped_reserved __unused;
|
||||
|
||||
public:
|
||||
virtual bool initWithArgs( void * p1, void * p2,
|
||||
void * p3, void *p4 );
|
||||
virtual bool compareName( OSString * name, OSString ** matched = NULL ) const APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOWorkLoop *getWorkLoop() const APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn setProperties( OSObject * properties ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOReturn newUserClient( task_t owningTask, void * securityID,
|
||||
UInt32 type, OSDictionary * properties,
|
||||
IOUserClient ** handler) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 3);
|
||||
};
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/* generic nub for motherboard devices */
|
||||
|
||||
class IOPlatformDevice : public IOService
|
||||
{
|
||||
OSDeclareDefaultStructors(IOPlatformDevice);
|
||||
|
||||
struct ExpansionData { };
|
||||
ExpansionData *iopd_reserved;
|
||||
|
||||
public:
|
||||
virtual bool compareName( OSString * name, OSString ** matched = NULL ) const APPLE_KEXT_OVERRIDE;
|
||||
virtual IOService * matchLocation( IOService * client ) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn getResources( void ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformDevice, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformDevice, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformDevice, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOPlatformDevice, 3);
|
||||
};
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* ! _IOKIT_IOPLATFORMEXPERT_H */
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _IORPC_H
|
||||
#define _IORPC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include <mach/message.h>
|
||||
|
||||
|
||||
class IOUserServer;
|
||||
|
||||
typedef uint64_t OSObjectRef;
|
||||
|
||||
enum {
|
||||
kIORPCVersion190615 = (mach_msg_id_t) 0x4da2b68c,
|
||||
kIORPCVersion190615Reply = (mach_msg_id_t) 0x4da2b68d,
|
||||
|
||||
#if DRIVERKIT_PRIVATE
|
||||
kIORPCVersion190501 = (mach_msg_id_t) 0xfe316a7a,
|
||||
kIORPCVersion190501Reply = (mach_msg_id_t) 0xfe316a7b,
|
||||
|
||||
kIORPCVersionCurrent = kIORPCVersion190615,
|
||||
kIORPCVersionCurrentReply = kIORPCVersion190615Reply
|
||||
#endif /* DRIVERKIT_PRIVATE */
|
||||
};
|
||||
|
||||
enum{
|
||||
kIORPCMessageRemote = 0x00000001,
|
||||
kIORPCMessageLocalHost = 0x00000002,
|
||||
kIORPCMessageKernel = 0x00000004,
|
||||
kIORPCMessageOneway = 0x00000008,
|
||||
kIORPCMessageObjectRefs = 0x00000010,
|
||||
kIORPCMessageOnqueue = 0x00000020,
|
||||
kIORPCMessageError = 0x00000040,
|
||||
kIORPCMessageSimpleReply = 0x00000080,
|
||||
};
|
||||
|
||||
enum{
|
||||
kIORPCMessageIDKernel = (1ULL << 63),
|
||||
};
|
||||
|
||||
struct IORPCMessageMach {
|
||||
mach_msg_header_t msgh;
|
||||
mach_msg_body_t msgh_body;
|
||||
mach_msg_port_descriptor_t objects[0];
|
||||
};
|
||||
typedef struct IORPCMessageMach IORPCMessageMach;
|
||||
|
||||
struct IORPCMessage {
|
||||
uint64_t msgid;
|
||||
uint64_t flags;
|
||||
uint64_t objectRefs;
|
||||
OSObjectRef objects[0];
|
||||
};
|
||||
typedef struct IORPCMessage IORPCMessage;
|
||||
|
||||
extern "C" IORPCMessage *
|
||||
IORPCMessageFromMach(IORPCMessageMach * msg, bool reply);
|
||||
|
||||
struct IORPCMessageErrorReturnContent {
|
||||
IORPCMessage hdr;
|
||||
kern_return_t result;
|
||||
uint32_t pad;
|
||||
};
|
||||
|
||||
#pragma pack(4)
|
||||
struct IORPCMessageErrorReturn {
|
||||
IORPCMessageMach mach;
|
||||
IORPCMessageErrorReturnContent content;
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
|
||||
class OSMetaClassBase;
|
||||
struct IORPC;
|
||||
typedef kern_return_t (*OSDispatchMethod)(OSMetaClassBase * self, const IORPC rpc);
|
||||
|
||||
struct IORPC {
|
||||
IORPCMessageMach * message;
|
||||
IORPCMessageMach * reply;
|
||||
uint32_t sendSize;
|
||||
uint32_t replySize;
|
||||
};
|
||||
typedef struct IORPC IORPC;
|
||||
|
||||
enum {
|
||||
kOSClassCanRemote = 0x00000001,
|
||||
};
|
||||
|
||||
struct OSClassDescription {
|
||||
uint32_t descriptionSize;
|
||||
|
||||
char name[96];
|
||||
char superName[96];
|
||||
|
||||
uint32_t methodOptionsSize;
|
||||
uint32_t methodOptionsOffset;
|
||||
uint32_t metaMethodOptionsSize;
|
||||
uint32_t metaMethodOptionsOffset;
|
||||
uint32_t queueNamesSize;
|
||||
uint32_t queueNamesOffset;
|
||||
uint32_t methodNamesSize;
|
||||
uint32_t methodNamesOffset;
|
||||
uint32_t metaMethodNamesSize;
|
||||
uint32_t metaMethodNamesOffset;
|
||||
|
||||
uint64_t flags;
|
||||
|
||||
uint64_t resv1[8];
|
||||
|
||||
uint64_t methodOptions[0];
|
||||
uint64_t metaMethodOptions[0];
|
||||
|
||||
char dispatchNames[0];
|
||||
char methodNames[0];
|
||||
char metaMethodNames[0];
|
||||
};
|
||||
|
||||
#endif /* _IORPC_H */
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1999 Apple Computer, Inc.
|
||||
*
|
||||
*
|
||||
* HISTORY
|
||||
*
|
||||
* sdouglas 05 Nov 99 - created.
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IORANGEALLOCATOR_H
|
||||
#define _IOKIT_IORANGEALLOCATOR_H
|
||||
|
||||
#include <libkern/c++/OSObject.h>
|
||||
#include <IOKit/IOTypes.h>
|
||||
|
||||
typedef IOByteCount IORangeScalar;
|
||||
|
||||
/*! @class IORangeAllocator
|
||||
* @abstract A utility class to manage allocations from a range.
|
||||
* @discussion The IORangeAllocator class provides functions for allocating ranges, at a fixed or any offset, and freeing them back to a free list. It is useful for describing ranges of memory or address space without requiring storage in the memory - information describing the free elements is kept elsewhere. Ranges are described by a start offset and a size. IORangeAllocator is optionally protected against multithreaded access.
|
||||
*/
|
||||
|
||||
class IORangeAllocator : public OSObject {
|
||||
OSDeclareDefaultStructors(IORangeAllocator);
|
||||
|
||||
protected:
|
||||
UInt32 numElements;
|
||||
UInt32 capacity;
|
||||
UInt32 capacityIncrement;
|
||||
IORangeScalar defaultAlignmentMask;
|
||||
IOOptionBits options;
|
||||
|
||||
struct IORangeAllocatorElement * elements;
|
||||
|
||||
private:
|
||||
virtual bool allocElement( UInt32 index );
|
||||
|
||||
virtual void deallocElement( UInt32 index );
|
||||
|
||||
public:
|
||||
enum {
|
||||
kLocking = 0x00000001
|
||||
};
|
||||
|
||||
/*! @function init
|
||||
* @abstract Standard initializer for IORangeAllocator.
|
||||
* @discussion This method initializes an IORangeAllocator and optionally sets the free list to contain one fragment, from zero to an endOfRange parameter. The capacity in terms of free fragments and locking options are set for the instance.
|
||||
* @param endOfRange If the free list is to contain an initial fragment, set endOfRange to the last offset in the range, ie. size - 1, to create a free fragment for the range zero to endOfRange inclusive. If zero is passed, the free list will be initialized empty, and can be populated with calls to the deallocate method.
|
||||
* @param defaultAlignment If this parameter is non-zero it specifies a required alignment for all allocations, for example pass 256 to align allocations on 256 byte boundaries. Zero or one specify unaligned allocations.
|
||||
* @param capacity Sets the initial size of the free list in number of noncontiguous fragments. This value is also used for the capacityIncrement.
|
||||
* @param options Pass kLocking if the instance can be used by multiple threads.
|
||||
* @result Returns true if the instance is successfully initialized, false on failure. */
|
||||
|
||||
virtual bool init( IORangeScalar endOfRange,
|
||||
IORangeScalar defaultAlignment,
|
||||
UInt32 capacity,
|
||||
IOOptionBits options );
|
||||
|
||||
/*! @function withRange
|
||||
* @abstract Standard factory method for IORangeAllocator.
|
||||
* @discussion This method allocates and initializes an IORangeAllocator and optionally sets the free list to contain one fragment, from zero to an endOfRange parameter. The capacity in terms of free fragments and locking options are set for the instance.
|
||||
* @param endOfRange If the free list is to contain an initial fragment, set endOfRange to the last offset in the range, ie. size - 1, to create a free fragment for the range zero to endOfRange inclusive. If zero is passed the free list will be initialized empty, and can be populated with calls to the deallocate method.
|
||||
* @param defaultAlignment If this parameter is non-zero it specifies a required alignment for all allocations, for example pass 256 to align allocations on 256 byte boundaries. Zero or one specify unaligned allocations.
|
||||
* @param capacity Sets the initial size of the free list in number of non-contiguous fragments. This value is also used for the capacityIncrement.
|
||||
* @param options Pass kLocking if the instance can be used by multiple threads.
|
||||
* @result Returns the new IORangeAllocator instance, to be released by the caller, or zero on failure. */
|
||||
|
||||
static IORangeAllocator * withRange( IORangeScalar endOfRange,
|
||||
IORangeScalar defaultAlignment = 0,
|
||||
UInt32 capacity = 0,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
virtual bool serialize(OSSerialize *s) const APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function getFragmentCount
|
||||
* @abstract Accessor to return the number of free fragments in the range.
|
||||
* @discussion This method returns a count of free fragments. Each fragment describes a non-contiguous free range - deallocations will merge contiguous fragments together.
|
||||
* @result Returns the count of free fragments.
|
||||
*/
|
||||
|
||||
virtual UInt32 getFragmentCount( void );
|
||||
|
||||
/*! @function getFragmentCapacity
|
||||
* @abstract Accessor to return the number of free fragments in the range.
|
||||
* @discussion This method returns the current capacity of the free fragment list.
|
||||
* @result Returns the current capacity of free fragment list.
|
||||
*/
|
||||
|
||||
virtual UInt32 getFragmentCapacity( void );
|
||||
|
||||
/*! @function setFragmentCapacityIncrement
|
||||
* @abstract Sets the count of fragments the free list will increase by when full.
|
||||
* @discussion This method sets the number of extra fragments the free list will expand to when full. It defaults to the initial capacity.
|
||||
* @param count The number of fragments to increment the capacity by when the free list is full.
|
||||
*/
|
||||
|
||||
virtual void setFragmentCapacityIncrement( UInt32 count );
|
||||
|
||||
/*! @function getFreeCount
|
||||
* @abstract Totals the sizes of the free fragments.
|
||||
* @discussion This method returns the total of the sizes of the fragments on the free list.
|
||||
* @result Returns the total of the free fragments sizes.
|
||||
*/
|
||||
|
||||
virtual IORangeScalar getFreeCount( void );
|
||||
|
||||
/*! @function allocate
|
||||
* @abstract Allocates from the free list, at any offset.
|
||||
* @discussion This method allocates a range from the free list. The alignment will default to the alignment set when the allocator was created or may be set here.
|
||||
* @param size The size of the range requested.
|
||||
* @param result The beginning of the range allocated is returned here on success.
|
||||
* @param alignment If zero is passed, default to the allocators alignment, otherwise pass an alignment required for the allocation, for example 4096 to page align.
|
||||
* @result Returns true if the allocation was successful, else false.
|
||||
*/
|
||||
|
||||
virtual bool allocate( IORangeScalar size,
|
||||
IORangeScalar * result,
|
||||
IORangeScalar alignment = 0 );
|
||||
|
||||
/*! @function allocateRange
|
||||
* @abstract Allocates from the free list, at a set offset.
|
||||
* @discussion This method allocates a range from the free list, given a set offset passed in.
|
||||
* @param start The beginning of the range requested.
|
||||
* @param size The size of the range requested.
|
||||
* @result Returns true if the allocation was successful, else false.
|
||||
*/
|
||||
|
||||
virtual bool allocateRange( IORangeScalar start,
|
||||
IORangeScalar size );
|
||||
|
||||
/*! @function deallocate
|
||||
* @abstract Deallocates a range to the free list.
|
||||
* @discussion This method deallocates a range to the free list, given a the start offset and length passed in.
|
||||
* @param start The beginning of the range requested.
|
||||
* @param size Returns the size of the range requested.
|
||||
*/
|
||||
|
||||
virtual void deallocate( IORangeScalar start,
|
||||
IORangeScalar size );
|
||||
};
|
||||
|
||||
#endif /* _IOKIT_IORANGEALLOCATOR_H */
|
||||
@@ -0,0 +1,955 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* HISTORY
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _IOKIT_IOREGISTRYENTRY_H
|
||||
#define _IOKIT_IOREGISTRYENTRY_H
|
||||
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include <libkern/c++/OSContainers.h>
|
||||
|
||||
|
||||
extern const OSSymbol * gIONameKey;
|
||||
extern const OSSymbol * gIOLocationKey;
|
||||
extern const OSSymbol * gIORegistryEntryIDKey;
|
||||
extern const OSSymbol * gIORegistryEntryPropertyKeysKey;
|
||||
|
||||
class IORegistryEntry;
|
||||
class IORegistryPlane;
|
||||
class IORegistryIterator;
|
||||
|
||||
typedef void (*IORegistryEntryApplierFunction)(IORegistryEntry * entry,
|
||||
void * context);
|
||||
|
||||
enum {
|
||||
kIORegistryIterateRecursively = 0x00000001,
|
||||
kIORegistryIterateParents = 0x00000002,
|
||||
};
|
||||
|
||||
|
||||
/*! @class IORegistryEntry : public OSObject
|
||||
* @abstract The base class for all objects in the registry.
|
||||
* @discussion The IORegistryEntry base class provides functions for describing graphs of connected registry entries, each with a dictionary-based property table. Entries may be connected in different planes, with differing topologies. Access to the registry is protected against multiple threads. Inside the kernel planes are specified with plane objects and are published by the creator - IOService exports the gIOServicePlane plane object for example. Non kernel clients specify planes by their name.
|
||||
*/
|
||||
|
||||
class IORegistryEntry : public OSObject
|
||||
{
|
||||
friend class IORegistryIterator;
|
||||
|
||||
OSDeclareDefaultStructors(IORegistryEntry);
|
||||
|
||||
protected:
|
||||
/*! @struct ExpansionData
|
||||
* @discussion This structure will be used to expand the capablilties of this class in the future.
|
||||
*/
|
||||
struct ExpansionData;
|
||||
|
||||
/*! @var reserved
|
||||
* Reserved for future use. (Internal use only) */
|
||||
ExpansionData * reserved;
|
||||
|
||||
private:
|
||||
|
||||
OSDictionary * fRegistryTable;
|
||||
OSDictionary * fPropertyTable;
|
||||
|
||||
public:
|
||||
/* methods available in Mac OS X 10.1 or later */
|
||||
|
||||
/*! @function copyProperty
|
||||
* @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy. Available in Mac OS X 10.1 or later.
|
||||
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
|
||||
* @param aKey The property's name as a C-string.
|
||||
* @param plane The plane to iterate over, eg. gIOServicePlane.
|
||||
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
|
||||
* @result The property value found, or zero. A reference on any found property is returned to caller, which should be released. */
|
||||
|
||||
virtual OSObject * copyProperty( const char * aKey,
|
||||
const IORegistryPlane * plane,
|
||||
IOOptionBits options =
|
||||
kIORegistryIterateRecursively |
|
||||
kIORegistryIterateParents) const;
|
||||
|
||||
/*! @function copyProperty
|
||||
* @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy. Available in Mac OS X 10.1 or later.
|
||||
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
|
||||
* @param aKey The property's name as an OSString.
|
||||
* @param plane The plane to iterate over, eg. gIOServicePlane.
|
||||
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
|
||||
* @result The property value found, or zero. A reference on any found property is returned to caller, which should be released. */
|
||||
|
||||
virtual OSObject * copyProperty( const OSString * aKey,
|
||||
const IORegistryPlane * plane,
|
||||
IOOptionBits options =
|
||||
kIORegistryIterateRecursively |
|
||||
kIORegistryIterateParents) const;
|
||||
|
||||
/*! @function copyProperty
|
||||
* @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy. Available in Mac OS X 10.1 or later.
|
||||
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
|
||||
* @param aKey The property's name as an OSSymbol.
|
||||
* @param plane The plane to iterate over, eg. gIOServicePlane.
|
||||
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
|
||||
* @result The property value found, or zero. A reference on any found property is returned to caller, which should be released. */
|
||||
|
||||
virtual OSObject * copyProperty( const OSSymbol * aKey,
|
||||
const IORegistryPlane * plane,
|
||||
IOOptionBits options =
|
||||
kIORegistryIterateRecursively |
|
||||
kIORegistryIterateParents) const;
|
||||
|
||||
/*! @function copyParentEntry
|
||||
* @abstract Returns an registry entry's first parent entry in a plane. Available in Mac OS X 10.1 or later.
|
||||
* @discussion This function will return the parent to which a registry entry was first attached. Since the majority of registry entrys have only one provider, this is a useful simplification.
|
||||
* @param plane The plane object.
|
||||
* @result Returns the first parent of the registry entry, or zero if the entry is not attached into the registry in that plane. A reference on the entry is returned to caller, which should be released. */
|
||||
|
||||
virtual IORegistryEntry * copyParentEntry( const IORegistryPlane * plane ) const;
|
||||
|
||||
/*! @function copyChildEntry
|
||||
* @abstract Returns an registry entry's first child entry in a plane. Available in Mac OS X 10.1 or later.
|
||||
* @discussion This function will return the child which first attached to a registry entry.
|
||||
* @param plane The plane object.
|
||||
* @result Returns the first child of the registry entry, or zero if the entry is not attached into the registry in that plane. A reference on the entry is returned to caller, which should be released. */
|
||||
|
||||
virtual IORegistryEntry * copyChildEntry( const IORegistryPlane * plane ) const;
|
||||
|
||||
/* method available in Mac OS X 10.4 or later */
|
||||
/*!
|
||||
* @typedef Action
|
||||
* @discussion Type and arguments of callout C function that is used when
|
||||
* a runCommand is executed by a client. Cast to this type when you want a C++
|
||||
* member function to be used. Note the arg1 - arg3 parameters are passed straight pass through to the action callout.
|
||||
* @param target
|
||||
* Target of the function, can be used as a refcon. Note if a C++ function
|
||||
* was specified, this parameter is implicitly the first parameter in the target
|
||||
* member function's parameter list.
|
||||
* @param arg0 Argument to action from run operation.
|
||||
* @param arg1 Argument to action from run operation.
|
||||
* @param arg2 Argument to action from run operation.
|
||||
* @param arg3 Argument to action from run operation.
|
||||
*/
|
||||
typedef IOReturn (*Action)(OSObject *target,
|
||||
void *arg0, void *arg1,
|
||||
void *arg2, void *arg3);
|
||||
|
||||
/*! @function runPropertyAction
|
||||
* @abstract Single thread a call to an action w.r.t. the property lock
|
||||
* @discussion Client function that causes the given action to be called in a manner that syncrhonises with the registry iterators and serialisers. This functin can be used to synchronously manipulate the property table of this nub
|
||||
* @param action Pointer to function to be executed in work-loop context.
|
||||
* @param arg0 Parameter for action parameter, defaults to 0.
|
||||
* @param arg1 Parameter for action parameter, defaults to 0.
|
||||
* @param arg2 Parameter for action parameter, defaults to 0.
|
||||
* @param arg3 Parameter for action parameter, defaults to 0.
|
||||
* @result Returns the value of the Action callout.
|
||||
*/
|
||||
virtual IOReturn runPropertyAction(Action action, OSObject *target,
|
||||
void *arg0 = NULL, void *arg1 = NULL,
|
||||
void *arg2 = NULL, void *arg3 = NULL);
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
typedef IOReturn (^ActionBlock)(void);
|
||||
IOReturn runPropertyActionBlock(ActionBlock block);
|
||||
#endif /* __BLOCKS__ */
|
||||
|
||||
private:
|
||||
#if __LP64__
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 0);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 1);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 2);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 3);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 4);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 5);
|
||||
#else
|
||||
OSMetaClassDeclareReservedUsed(IORegistryEntry, 0);
|
||||
OSMetaClassDeclareReservedUsed(IORegistryEntry, 1);
|
||||
OSMetaClassDeclareReservedUsed(IORegistryEntry, 2);
|
||||
OSMetaClassDeclareReservedUsed(IORegistryEntry, 3);
|
||||
OSMetaClassDeclareReservedUsed(IORegistryEntry, 4);
|
||||
OSMetaClassDeclareReservedUsed(IORegistryEntry, 5);
|
||||
#endif
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 6);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 7);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 8);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 9);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 10);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 11);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 12);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 13);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 14);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 15);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 16);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 17);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 18);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 19);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 20);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 21);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 22);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 23);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 24);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 25);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 26);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 27);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 28);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 29);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 30);
|
||||
OSMetaClassDeclareReservedUnused(IORegistryEntry, 31);
|
||||
|
||||
public:
|
||||
|
||||
/* Registry accessors */
|
||||
|
||||
/*! @function getRegistryRoot
|
||||
* @abstract Returns a pointer to the root instance of the registry.
|
||||
* @discussion This method provides an accessor to the root of the registry for the machine. The root may be passed to a registry iterator when iterating a plane, and contains properties that describe the available planes, and diagnostic information for IOKit. Keys for these properties are in IOKitKeys.h.
|
||||
* @result A pointer to the IORegistryEntry root instance. It should not be released by the caller. */
|
||||
|
||||
static IORegistryEntry * getRegistryRoot( void );
|
||||
|
||||
/*! @function getGenerationCount
|
||||
* @abstract Returns an generation count for all registry changing operations.
|
||||
* @discussion This method provides an accessor to the current generation count (or seed) of the registry which changes when any topology change occurs in the registry - this does not include property table changes. It may be used to invalidate any caching of the results from IORegistryEntry methods.
|
||||
* @result An integer generation count. */
|
||||
|
||||
static SInt32 getGenerationCount( void );
|
||||
|
||||
/*! @function getPlane
|
||||
* @abstract Looks up the plane object by a C-string name.
|
||||
* @discussion Planes are usually provided as globals by the creator, eg. gIOServicePlane, gIODeviceTreePlane, or gIOAudioPlane, however they may also be looked up by name with this method.
|
||||
* @result A pointer to the plane object, or zero if no such plane exists. The returned plane should not be released. */
|
||||
|
||||
static const IORegistryPlane * getPlane( const char * name );
|
||||
|
||||
/* Registry Entry allocation & init */
|
||||
|
||||
/*! @function init
|
||||
* @abstract Standard init method for all IORegistryEntry subclasses.
|
||||
* @discussion A registry entry must be initialized with this method before it can be used. A property dictionary may passed and will be retained by this method for use as the registry entry's property table, or an empty one will be created.
|
||||
* @param dictionary A dictionary that will become the registry entry's property table (retaining it), or zero which will cause an empty property table to be created.
|
||||
* @result true on success, or false on a resource failure. */
|
||||
|
||||
virtual bool init( OSDictionary * dictionary = NULL );
|
||||
|
||||
/*! @function free
|
||||
* @abstract Standard free method for all IORegistryEntry subclasses.
|
||||
* @discussion This method will release any resources of the entry, in particular its property table. Note that the registry entry must always be detached from the registry before free may be called, and subclasses (namely IOService) will have additional protocols for removing registry entries. free should never need be called directly. */
|
||||
|
||||
virtual void free( void ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function setPropertyTable
|
||||
* @abstract Replace a registry entry's property table.
|
||||
* @discussion This method will release the current property table of a the entry and replace it with another, retaining the new property table.
|
||||
* @param dict The new dictionary to be used as the entry's property table. */
|
||||
|
||||
virtual void setPropertyTable( OSDictionary * dict );
|
||||
|
||||
/* Synchronized property accessors; wrappers to OSDictionary
|
||||
* plus property creation helpers */
|
||||
|
||||
/*! @function setProperty
|
||||
* @abstract Synchronized method to add a property to a registry entry's property table.
|
||||
* @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
|
||||
* @param aKey The properties name as an OSSymbol.
|
||||
* @param anObject The property value.
|
||||
* @result true on success or false on a resource failure. */
|
||||
|
||||
virtual bool setProperty(const OSSymbol * aKey,
|
||||
OSObject * anObject);
|
||||
|
||||
|
||||
/*! @function setProperty
|
||||
* @abstract Synchronized method to add a property to a registry entry's property table.
|
||||
* @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
|
||||
* @param aKey The property's name as an OSString.
|
||||
* @param anObject The property value.
|
||||
* @result true on success or false on a resource failure. */
|
||||
|
||||
virtual bool setProperty(const OSString * aKey, OSObject * anObject);
|
||||
|
||||
/*! @function setProperty
|
||||
* @abstract Synchronized method to add a property to a registry entry's property table.
|
||||
* @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
|
||||
* @param aKey The property's name as a C-string.
|
||||
* @param anObject The property value.
|
||||
* @result true on success or false on a resource failure. */
|
||||
|
||||
virtual bool setProperty(const char * aKey, OSObject * anObject);
|
||||
|
||||
/*! @function setProperty
|
||||
* @abstract Synchronized method to construct and add a OSString property to a registry entry's property table.
|
||||
* @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. The property is created as an OSString from the supplied C-string, set in the property table with the given name, and released.
|
||||
* @param aKey The property's name as a C-string.
|
||||
* @param aString The property value as a C-string.
|
||||
* @result true on success or false on a resource failure. */
|
||||
|
||||
virtual bool setProperty(const char * aKey, const char * aString);
|
||||
|
||||
/*! @function setProperty
|
||||
* @abstract Synchronized method to construct and add an OSBoolean property to a registry entry's property table.
|
||||
* @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. The property is created as an OSBoolean from the supplied value, set in the property table with the given name, and released.
|
||||
* @param aKey The property's name as a C-string.
|
||||
* @param aBoolean The property's boolean value.
|
||||
* @result true on success or false on a resource failure. */
|
||||
|
||||
virtual bool setProperty(const char * aKey, bool aBoolean);
|
||||
|
||||
/*! @function setProperty
|
||||
* @abstract Synchronized method to construct and add an OSNumber property to a registry entry's property table.
|
||||
* @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. The property is created as an OSNumber from the supplied value and size, set in the property table with the given name, and released.
|
||||
* @param aKey The property's name as a C-string.
|
||||
* @param aValue The property's numeric value.
|
||||
* @param aNumberOfBits The property's size in bits, for OSNumber.
|
||||
* @result true on success or false on a resource failure. */
|
||||
|
||||
virtual bool setProperty( const char * aKey,
|
||||
unsigned long long aValue,
|
||||
unsigned int aNumberOfBits);
|
||||
|
||||
/*! @function setProperty
|
||||
* @abstract Synchronized method to construct and add an OSData property to a registry entry's property table.
|
||||
* @discussion This method will add or replace a property in a registry entry's property table, using the OSDictionary::setObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table. The property is created as an OSData copied from the supplied data and length, set in the property table with the given name, and released.
|
||||
* @param aKey The property's name as a C-string.
|
||||
* @param bytes The property's value as a pointer. OSData will copy this data.
|
||||
* @param length The property's size in bytes, for OSData.
|
||||
* @result true on success or false on a resource failure. */
|
||||
|
||||
virtual bool setProperty( const char * aKey,
|
||||
void * bytes,
|
||||
unsigned int length);
|
||||
|
||||
/*! @function removeProperty
|
||||
* @abstract Synchronized method to remove a property from a registry entry's property table.
|
||||
* @discussion This method will remove a property from a registry entry's property table, using the OSDictionary::removeObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
|
||||
* @param aKey The property's name as an OSSymbol. */
|
||||
|
||||
virtual void removeProperty( const OSSymbol * aKey);
|
||||
|
||||
/*! @function removeProperty
|
||||
* @abstract Synchronized method to remove a property from a registry entry's property table.
|
||||
* @discussion This method will remove a property from a registry entry's property table, using the OSDictionary::removeObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
|
||||
* @param aKey The property's name as an OSString. */
|
||||
|
||||
virtual void removeProperty( const OSString * aKey);
|
||||
|
||||
/*! @function removeProperty
|
||||
* @abstract Synchronized method to remove a property from a registry entry's property table.
|
||||
* @discussion This method will remove a property from a registry entry's property table, using the OSDictionary::removeObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
|
||||
* @param aKey The property's name as a C-string. */
|
||||
|
||||
virtual void removeProperty( const char * aKey);
|
||||
|
||||
/*! @function getProperty
|
||||
* @abstract Synchronized method to obtain a property from a registry entry's property table.
|
||||
* @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
|
||||
* @param aKey The property's name as an OSSymbol.
|
||||
* @result The property value found, or zero. */
|
||||
|
||||
virtual OSObject * getProperty( const OSSymbol * aKey) const;
|
||||
|
||||
/*! @function getProperty
|
||||
* @abstract Synchronized method to obtain a property from a registry entry's property table.
|
||||
* @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
|
||||
* @param aKey The property's name as an OSString.
|
||||
* @result The property value found, or zero. */
|
||||
|
||||
virtual OSObject * getProperty( const OSString * aKey) const;
|
||||
|
||||
/*! @function getProperty
|
||||
* @abstract Synchronized method to obtain a property from a registry entry's property table.
|
||||
* @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics. This method is synchronized with other IORegistryEntry accesses to the property table.
|
||||
* @param aKey The property's name as a C-string.
|
||||
* @result The property value found, or zero. */
|
||||
|
||||
virtual OSObject * getProperty( const char * aKey) const;
|
||||
|
||||
/*! @function getProperty
|
||||
* @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy.
|
||||
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
|
||||
* @param aKey The property's name as an OSSymbol.
|
||||
* @param plane The plane to iterate over, eg. gIOServicePlane.
|
||||
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
|
||||
* @result The property value found, or zero. */
|
||||
|
||||
virtual OSObject * getProperty( const OSSymbol * aKey,
|
||||
const IORegistryPlane * plane,
|
||||
IOOptionBits options =
|
||||
kIORegistryIterateRecursively |
|
||||
kIORegistryIterateParents) const;
|
||||
|
||||
/*! @function getProperty
|
||||
* @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy.
|
||||
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
|
||||
* @param aKey The property's name as an OSString.
|
||||
* @param plane The plane to iterate over, eg. gIOServicePlane.
|
||||
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
|
||||
* @result The property value found, or zero. */
|
||||
|
||||
virtual OSObject * getProperty( const OSString * aKey,
|
||||
const IORegistryPlane * plane,
|
||||
IOOptionBits options =
|
||||
kIORegistryIterateRecursively |
|
||||
kIORegistryIterateParents) const;
|
||||
|
||||
/*! @function getProperty
|
||||
* @abstract Synchronized method to obtain a property from a registry entry or one of its parents (or children) in the hierarchy.
|
||||
* @discussion This method will search for a property, starting first with this registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the OSDictionary::getObject semantics. The iteration keeps track of entries that have been recursed into previously to avoid loops. This method is synchronized with other IORegistryEntry accesses to the property table(s).
|
||||
* @param aKey The property's name as a C-string.
|
||||
* @param plane The plane to iterate over, eg. gIOServicePlane.
|
||||
* @param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard getProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.
|
||||
* @result The property value found, or zero. */
|
||||
|
||||
virtual OSObject * getProperty( const char * aKey,
|
||||
const IORegistryPlane * plane,
|
||||
IOOptionBits options =
|
||||
kIORegistryIterateRecursively |
|
||||
kIORegistryIterateParents) const;
|
||||
|
||||
/*! @function copyProperty
|
||||
* @abstract Synchronized method to obtain a property from a registry entry's property table.
|
||||
* @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics, and return a reference to the caller. This method is synchronized with other IORegistryEntry accesses to the property table.
|
||||
* @param aKey The property's name as an OSSymbol.
|
||||
* @result The property value found, or zero. It should be released by the caller. */
|
||||
|
||||
virtual OSObject * copyProperty( const OSSymbol * aKey) const;
|
||||
|
||||
/*! @function copyProperty
|
||||
* @abstract Synchronized method to obtain a property from a registry entry's property table.
|
||||
* @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics, and return a reference to the caller. This method is synchronized with other IORegistryEntry accesses to the property table.
|
||||
* @param aKey The property's name as an OSString.
|
||||
* @result The property value found, or zero. It should be released by the caller. */
|
||||
|
||||
virtual OSObject * copyProperty( const OSString * aKey) const;
|
||||
|
||||
/*! @function copyProperty
|
||||
* @abstract Synchronized method to obtain a property from a registry entry's property table.
|
||||
* @discussion This method will lookup a property in a registry entry's property table, using the OSDictionary::getObject semantics, and return a reference to the caller. This method is synchronized with other IORegistryEntry accesses to the property table.
|
||||
* @param aKey The property's name as a C-string.
|
||||
* @result The property value found, or zero. It should be released by the caller. */
|
||||
|
||||
virtual OSObject * copyProperty( const char * aKey) const;
|
||||
|
||||
/*! @function dictionaryWithProperties
|
||||
* @abstract Synchronized method to obtain copy a registry entry's property table.
|
||||
* @discussion This method will copy a registry entry's property table, using the OSDictionary::withDictionary semantics. This method is synchronized with other IORegistryEntry accesses to the property table. Since OSDictionary will only copy property values by reference, synchronization is not guaranteed to any collection values.
|
||||
* @result The created dictionary, or zero on a resource value. It should be released by the caller. */
|
||||
|
||||
virtual OSDictionary * dictionaryWithProperties( void ) const;
|
||||
|
||||
/*! @function serializeProperties
|
||||
* @abstract Synchronized method to serialize a registry entry's property table.
|
||||
* @discussion This method will serialize a registry entry's property table, using the OSDictionary::serialize semantics. This method is synchronized with other IORegistryEntry accesses to the property table. Many non-kernel clients of IOKit read information from the registry via properties, and will invoke this method in a registry entry to create a serialization of all the entry's properties, which is then reconstructed in the client's task as a CFDictionary. This method may be intercepted by subclasses to update their properties or implement a different serialization method, though it is usually better to implement such functionality by creating objects in the property table and implementing their serialize methods, avoiding any need to implement serializeProperties.
|
||||
* @param serialize The OSSerialize instance representing the serialization request.
|
||||
* @result True on success, false otherwise. */
|
||||
|
||||
virtual bool serializeProperties( OSSerialize * serialize ) const;
|
||||
|
||||
/* Unsynchronized(!) property table access */
|
||||
|
||||
/*! @function getPropertyTable
|
||||
* @abstract Unsynchronized accessor to a registry entry's property table.
|
||||
* @discussion This method will return a pointer to the live property table as an OSDictionery. Its use is not recommended in most cases, instead use the synchronized accessors and helper functions of IORegistryEntry to access properties. It can only safely be used by one thread, which usually means it can only be used before a registry entry is entered into the registry.
|
||||
* @result A pointer to the property table as an OSDictionary. The pointer is valid while the registry entry is retained, and should not be released by the caller. */
|
||||
|
||||
/* inline */ OSDictionary * getPropertyTable( void ) const;
|
||||
/* { return(fPropertyTable); } */
|
||||
|
||||
/* Set properties from user level, to be overridden if supported */
|
||||
|
||||
/*! @function setProperties
|
||||
* @abstract Optionally supported external method to set properties in a registry entry.
|
||||
* @discussion This method is not implemented by IORegistryEntry, but is available to kernel and non-kernel clients to set properties in a registry entry. IOUserClient provides connection based, more controlled access to this functionality and may be more appropriate for many uses, since there is no differentiation between clients available to this method.
|
||||
* @param properties Any OSObject subclass, to be interpreted by the implementing method - for example an OSDictionary, OSData etc. may all be appropriate.
|
||||
* @result An IOReturn code to be returned to the caller. */
|
||||
|
||||
virtual IOReturn setProperties( OSObject * properties );
|
||||
|
||||
/* Topology */
|
||||
|
||||
/*! @function getParentIterator
|
||||
* @abstract Returns an iterator over an registry entry's parent entries in a specified plane.
|
||||
* @param plane The plane object.
|
||||
* @result Returns an iterator over the parents of the registry entry, or zero if there is a resource failure. The iterator must be released when the iteration is finished. All objects returned by the iteration are retained while the iterator is valid, though they may no longer be attached during the iteration. */
|
||||
|
||||
virtual OSIterator * getParentIterator( const IORegistryPlane * plane )
|
||||
const;
|
||||
virtual void applyToParents( IORegistryEntryApplierFunction applier,
|
||||
void * context,
|
||||
const IORegistryPlane * plane ) const;
|
||||
|
||||
/*! @function getParentEntry
|
||||
* @abstract Returns an registry entry's first parent entry in a plane.
|
||||
* @discussion This function will return the parent to which a registry entry was first attached. Since the majority of registry entrys have only one provider, this is a useful simplification.
|
||||
* @param plane The plane object.
|
||||
* @result Returns the first parent of the registry entry, or zero if the entry is not attached into the registry in that plane. The parent is retained while the entry is attached, and should not be released by the caller. */
|
||||
|
||||
virtual IORegistryEntry * getParentEntry( const IORegistryPlane * plane ) const;
|
||||
|
||||
/*! @function getChildIterator
|
||||
* @abstract Returns an iterator over an registry entry's child entries in a plane.
|
||||
* @discussion This method creates an iterator which will return each of a registry entry's child entries in a specified plane.
|
||||
* @param plane The plane object.
|
||||
* @result Returns an iterator over the children of the entry, or zero if there is a resource failure. The iterator must be released when the iteration is finished. All objects returned by the iteration are retained while the iterator is valid, though they may no longer be attached during the iteration. */
|
||||
|
||||
virtual OSIterator * getChildIterator( const IORegistryPlane * plane )
|
||||
const;
|
||||
|
||||
|
||||
virtual void applyToChildren( IORegistryEntryApplierFunction applier,
|
||||
void * context,
|
||||
const IORegistryPlane * plane ) const;
|
||||
|
||||
/*! @function getChildEntry
|
||||
* @abstract Returns an registry entry's first child entry in a plane.
|
||||
* @discussion This function will return the child which first attached to a registry entry.
|
||||
* @param plane The plane object.
|
||||
* @result Returns the first child of the registry entry, or zero if the entry is not attached into the registry in that plane. The child is retained while the entry is attached, and should not be released by the caller. */
|
||||
|
||||
virtual IORegistryEntry * getChildEntry( const IORegistryPlane * plane ) const;
|
||||
|
||||
/*! @function isChild
|
||||
* @abstract Determines whether a registry entry is the child of another in a plane.
|
||||
* @discussion This method called in the parent entry determines if the specified entry is a child, in a plane. Additionally, it can check if the child is the only child of the parent entry.
|
||||
* @param child The possible child registry entry.
|
||||
* @param plane The plane object.
|
||||
* @param onlyChild If true, check also if the child is the only child.
|
||||
* @result If the child argument is not a child of the registry entry, false is returned. If onlyChild is true and the child is not the only child of the entry, false is returned, otherwise true is returned. */
|
||||
|
||||
virtual bool isChild( IORegistryEntry * child,
|
||||
const IORegistryPlane * plane,
|
||||
bool onlyChild = false ) const;
|
||||
|
||||
/*! @function isParent
|
||||
* @abstract Determines whether a registry entry is the parent of another in a plane.
|
||||
* @discussion This method called in the child entry determines if the specified entry is a parent, in a plane. Additionally, it can check if the parent is the only parent of the child entry.
|
||||
* @param parent The possible parent registry entry.
|
||||
* @param plane The plane object.
|
||||
* @param onlyParent If true, check also if the parent is the only parent.
|
||||
* @result If the parent argument is not a parent of the registry entry, false is returned. If onlyParent is true and the parent is not the only parent of the entry, false is returned, otherwise true is returned. */
|
||||
|
||||
virtual bool isParent( IORegistryEntry * parent,
|
||||
const IORegistryPlane * plane,
|
||||
bool onlyParent = false ) const;
|
||||
|
||||
/*! @function inPlane
|
||||
* @abstract Determines whether a registry entry is attached in a plane.
|
||||
* @discussion This method determines if the entry is attached in a plane to any other entry. It can also be used to determine if the entry is a member of any plane.
|
||||
* @param plane The plane object, 0 indicates any plane.
|
||||
* @result If the entry has a parent in the given plane or if plane = 0 then if entry has any parent; return true, otherwise false. */
|
||||
|
||||
virtual bool inPlane( const IORegistryPlane * plane = NULL) const;
|
||||
|
||||
/*! @function getDepth
|
||||
* @abstract Counts the maximum number of entries between an entry and the registry root, in a plane.
|
||||
* @discussion This method counts the number of entries between and entry and the registry root, in a plane, for each parent of the entry and returns the maximum value.
|
||||
* @param plane The plane object.
|
||||
* @result The maximum number of entries between the entry and the root. Zero is returned if the entry is not attached in the plane. */
|
||||
|
||||
virtual unsigned int getDepth( const IORegistryPlane * plane ) const;
|
||||
|
||||
/* Attach / detach */
|
||||
|
||||
/*! @function attachToParent
|
||||
* @abstract Attaches a entry to a parent entry in a plane.
|
||||
* @discussion This is the usual method of entering an entry into the registry. It is a no-op and success if the entry is already attached to the parent. Attaching the entry into the registry retains both the child and parent while they are attached. This method will call attachToChild in the parent entry if it is not being called from attachToChild.
|
||||
* @param parent The registry entry to attach to.
|
||||
* @param plane The plane object.
|
||||
* @result true on success, or false on a resource failure, or if the parent is the same as the child. */
|
||||
|
||||
virtual bool attachToParent( IORegistryEntry * parent,
|
||||
const IORegistryPlane * plane );
|
||||
|
||||
/*! @function detachFromParent
|
||||
* @abstract Detaches an entry from a parent entry in a plane.
|
||||
* @discussion This is the usual method of removing an entry from the registry. It is a no-op if the entry is not attached to the parent. Detaching the entry will release both the child and parent. This method will call detachFromChild in the parent entry if it is not being called from detachFromChild.
|
||||
* @param parent The registry entry to detach from.
|
||||
* @param plane The plane object. */
|
||||
|
||||
virtual void detachFromParent( IORegistryEntry * parent,
|
||||
const IORegistryPlane * plane );
|
||||
|
||||
/*! @function attachToChild
|
||||
* @abstract Method called in the parent entry when a child attaches.
|
||||
* @discussion This method is called in the parent entry when a child attaches, to make overrides possible. This method will also call attachToParent in the child entry if it is not being called from attachToParent. It is a no-op and success if the entry is already a child. Attaching the entry into the registry retains both the child and parent while they are attached.
|
||||
* @param child The registry entry being attached.
|
||||
* @param plane The plane object.
|
||||
* @result true on success, or false on a resource failure, or if the parent is the same as the child. */
|
||||
|
||||
virtual bool attachToChild( IORegistryEntry * child,
|
||||
const IORegistryPlane * plane );
|
||||
|
||||
/*! @function detachFromChild
|
||||
* @abstract Detaches a child entry from its parent in a plane.
|
||||
* @discussion This method is called in the parent entry when a child detaches, to make overrides possible. It is a no-op if the entry is not a child of the parent. Detaching the entry will release both the child and parent. This method will call detachFromParent in the child entry if it is not being called from detachFromParent.
|
||||
* @param child The registry entry to detach.
|
||||
* @param plane The plane object. */
|
||||
|
||||
virtual void detachFromChild( IORegistryEntry * child,
|
||||
const IORegistryPlane * plane );
|
||||
|
||||
/*! @function detachAbove
|
||||
* @abstract Detaches an entry from all its parent entries in a plane.
|
||||
* @discussion This method calls detachFromParent in the entry for each of its parent entries in the plane.
|
||||
* @param plane The plane object. */
|
||||
|
||||
virtual void detachAbove( const IORegistryPlane * plane );
|
||||
|
||||
/*! @function detachAll
|
||||
* @abstract Detaches an entry and all its children recursively in a plane.
|
||||
* @discussion This method breaks the registry connections for a subtree. detachAbove is called in the entry, and all child entries and their children in the plane.
|
||||
* @param plane The plane object. */
|
||||
|
||||
virtual void detachAll( const IORegistryPlane * plane );
|
||||
|
||||
/* Name, location and path accessors */
|
||||
|
||||
/*! @function getName
|
||||
* @abstract Returns the name assigned to the registry entry as a C-string.
|
||||
* @discussion Entries can be named in a particular plane, or globally. If the entry is named in plane and the plane is specified that name will be returned, otherwise the global name is returned. The global name defaults to the entry's meta class name if it has not been named.
|
||||
* @param plane The plane object, or zero for the global name.
|
||||
* @result A C-string name, valid while the entry is retained. */
|
||||
|
||||
virtual const char * getName( const IORegistryPlane * plane = NULL ) const;
|
||||
|
||||
/*! @function copyName
|
||||
* @abstract Returns the name assigned to the registry entry as an OSSymbol.
|
||||
* @discussion Entries can be named in a particular plane, or globally. If the entry is named in plane and the plane is specified that name will be returned, otherwise the global name is returned. The global name defaults to the entry's meta class name if it has not been named.
|
||||
* @param plane The plane object, or zero for the global name.
|
||||
* @result A reference to an OSSymbol for the name, which should be released by the caller. */
|
||||
|
||||
virtual const OSSymbol * copyName(
|
||||
const IORegistryPlane * plane = NULL ) const;
|
||||
|
||||
/*! @function compareNames
|
||||
* @abstract Compares the name of the entry with one or more names, and optionally returns the matching name.
|
||||
* @discussion This method is called during IOService name matching and elsewhere to compare the entry's global name with a list of names, or a single name. A list of names may be passed as any OSCollection of OSStrings, while a single name may be passed an OSString, in the name parameter. compareNames will call the compareName method for each name, for overrides.
|
||||
* @param name The name or names to compare with as any OSCollection (eg. OSArray, OSSet, OSDictionary) of OSStrings, or a single name may be passed an OSString.
|
||||
* @param matched If the caller wants the successfully matched name returned, pass a non-zero pointer for the matched parameter and an OSString will be returned here. It should be released by the caller.
|
||||
* @result True if one of the names compared true with the entry's global name. */
|
||||
|
||||
virtual bool compareNames( OSObject * name, OSString ** matched = NULL ) const;
|
||||
|
||||
/*! @function compareName
|
||||
* @abstract Compares the name of the entry with one name, and optionally returns the matching name.
|
||||
* @discussion This method is called during IOService name matching and elsewhere from the compareNames method. It should be overridden to provide non-standard name matching.
|
||||
* @param name The name to compare with as an OSString.
|
||||
* @param matched If the caller wants the successfully matched name returned, pass a non-zero pointer for the matched parameter and an OSString will be returned here. It should be released by the caller. Generally, this will be the same as the name parameter, but may not be if wildcards are used.
|
||||
* @result True if the name compared true with the entry's global name. */
|
||||
|
||||
virtual bool compareName( OSString * name, OSString ** matched = NULL ) const;
|
||||
|
||||
/*! @function setName
|
||||
* @abstract Sets a name for the registry entry, in a particular plane, or globally.
|
||||
* @discussion Entries can be named in a particular plane, or globally. If the plane is specified the name applies only to that plane, otherwise the global name is set. The global name defaults to the entry's meta class name if it has not been named.
|
||||
* @param name An OSSymbol which will be retained.
|
||||
* @param plane The plane object, or zero to set the global name. */
|
||||
|
||||
virtual void setName( const OSSymbol * name,
|
||||
const IORegistryPlane * plane = NULL );
|
||||
|
||||
/*! @function setName
|
||||
* @abstract Sets a name for the registry entry, in a particular plane, or globally.
|
||||
* @discussion Entries can be named in a particular plane, or globally. If the plane is specified the name applies only to that plane, otherwise the global name is set. The global name defaults to the entry's meta class name if it has not been named.
|
||||
* @param name A const C-string name which will be copied.
|
||||
* @param plane The plane object, or zero to set the global name. */
|
||||
|
||||
virtual void setName( const char * name,
|
||||
const IORegistryPlane * plane = NULL );
|
||||
|
||||
/*! @function getLocation
|
||||
* @abstract Returns the location string assigned to the registry entry as a C-string.
|
||||
* @discussion Entries can given a location string in a particular plane, or globally. If the entry has had a location set in a plane and the plane is specified that location string will be returned, otherwise the global location string is returned. If no global location string has been set, zero is returned.
|
||||
* @param plane The plane object, or zero for the global name.
|
||||
* @result A C-string location string, valid while the entry is retained, or zero. */
|
||||
|
||||
virtual const char * getLocation( const IORegistryPlane * plane = NULL ) const;
|
||||
|
||||
/*! @function copyLocation
|
||||
* @abstract Returns the location string assigned to the registry entry as an OSSymbol.
|
||||
* @discussion Entries can given a location string in a particular plane, or globally. If the entry has had a location set in a plane and the plane is specified that location string will be returned, otherwise the global location string is returned. If no global location string has been set, zero is returned.
|
||||
* @param plane The plane object, or zero for the global name.
|
||||
* @result A reference to an OSSymbol for the location if one exists, which should be released by the caller, or zero. */
|
||||
|
||||
virtual const OSSymbol * copyLocation(
|
||||
const IORegistryPlane * plane = NULL ) const;
|
||||
|
||||
/*! @function setLocation
|
||||
* @abstract Sets a location string for the registry entry, in a particular plane, or globally.
|
||||
* @discussion Entries can be given a location string in a particular plane, or globally. If the plane is specified the location applies only to that plane, otherwise the global location is set. The location string may be used during path lookups of registry entries, to distinguish between sibling entries with the same name. The default IORegistryEntry parsing of location strings expects a list of hex numbers separated by commas, though subclasses of IORegistryEntry might do their own parsing.
|
||||
* @param location A C-string location string which will be copied, or an OSSymbol which will be retained.
|
||||
* @param plane The plane object, or zero to set the global location string. */
|
||||
|
||||
virtual void setLocation( const OSSymbol * location,
|
||||
const IORegistryPlane * plane = NULL );
|
||||
virtual void setLocation( const char * location,
|
||||
const IORegistryPlane * plane = NULL );
|
||||
|
||||
/*! @function getPath
|
||||
* @abstract Create a path for a registry entry.
|
||||
* @discussion The path for a registry entry is copied to the caller's buffer. The path describes the entry's attachment in a particular plane, which must be specified. The path begins with the plane name followed by a colon, and then followed by '/' separated path components for each of the entries between the root and the registry entry. Each component is constructed with the getPathComponent method called in each entry. An alias may also exist for the entry, which are described as properties in a registry entry found at /aliases in the plane. If a property value interpreted as a path in a call to IORegistryEntry::fromPath yields the entry, then the property name is used as the entry's path.
|
||||
* @param path A char buffer allocated by the caller.
|
||||
* @param length An in/out parameter - the caller sets the length of the buffer available, and getPath returns the total length of the path copied to the buffer.
|
||||
* @param plane The plane object.
|
||||
* @result getPath will fail if the entry is not attached in the plane, or if the buffer is not large enough to contain the path. */
|
||||
|
||||
virtual bool getPath( char * path, int * length,
|
||||
const IORegistryPlane * plane) const;
|
||||
|
||||
/*! @function getPathComponent
|
||||
* @abstract Create a path component for a registry entry.
|
||||
* @discussion Each component of a path created with getPath is created with getPathComponent. The default implementation concatenates the entry's name in the the plane, with the "at" symbol and the location string of the entry in the plane if it has been set.
|
||||
* @param path A char buffer allocated by the caller.
|
||||
* @param length An in/out parameter - the caller sets the length of the buffer available, and getPathComponent returns the total length of the path component copied to the buffer.
|
||||
* @param plane The plane object.
|
||||
* @result true if the path fits into the supplied buffer or false on a overflow. */
|
||||
|
||||
virtual bool getPathComponent( char * path, int * length,
|
||||
const IORegistryPlane * plane ) const;
|
||||
|
||||
/*! @function fromPath
|
||||
* @abstract Looks up a registry entry by path.
|
||||
* @discussion This function parses paths to lookup registry entries. The path may begin with the <plane name>: created by getPath, or the plane may be set by the caller. If there are characters remaining unparsed after an entry has been looked up, this may be considered an invalid lookup, or those characters may be passed back to the caller and the lookup successful.
|
||||
* @param path A C-string path.
|
||||
* @param plane The plane to lookup up the path, or zero, in which case the path must begin with the plane name.
|
||||
* @param residualPath If the path may contain residual characters after the last path component, the residual will be copied back to the caller's residualPath buffer. If there are residual characters and no residual buffer is specified, fromPath will fail.
|
||||
* @param residualLength An in/out parameter - the caller sets the length of the residual buffer available, and fromPath returns the total length of the residual path copied to the buffer. If there is no residualBuffer (residualPath = 0) then residualLength may be zero also.
|
||||
* @param fromEntry The lookup will proceed rooted at this entry if non-zero, otherwise it proceeds from the root of the plane.
|
||||
* @result A retained registry entry is returned on success, or zero on failure. The caller should release the entry. */
|
||||
|
||||
static IORegistryEntry * fromPath( const char * path,
|
||||
const IORegistryPlane * plane = NULL,
|
||||
char * residualPath = NULL,
|
||||
int * residualLength = NULL,
|
||||
IORegistryEntry * fromEntry = NULL );
|
||||
|
||||
/*! @function fromPath
|
||||
* @abstract Looks up a registry entry by relative path.
|
||||
* @discussion This function looks up a entry below the called entry by a relative path. It is just a convenience that calls IORegistryEntry::fromPath with this as the fromEntry parameter.
|
||||
* @param path See IORegistryEntry::fromPath.
|
||||
* @param plane See IORegistryEntry::fromPath.
|
||||
* @param residualPath See IORegistryEntry::fromPath.
|
||||
* @param residualLength See IORegistryEntry::fromPath.
|
||||
* @result See IORegistryEntry::fromPath. */
|
||||
|
||||
virtual IORegistryEntry * childFromPath( const char * path,
|
||||
const IORegistryPlane * plane = NULL,
|
||||
char * residualPath = NULL,
|
||||
int * residualLength = NULL );
|
||||
|
||||
/*! @function dealiasPath
|
||||
* @abstract Strips any aliases from the head of path and returns the full path.
|
||||
* @discussion If the path specified begins with an alias found in the /aliases entry, the value of the alias is returned, and a pointer into the passed in path after the alias is passed back to the caller. If an alias is not found, zero is returned and the path parameter is unchanged.
|
||||
* @param opath An in/out paramter - the caller passes in a pointer to a C-string pointer to a path. If an alias is found, dealiasPath returns a pointer into the path just beyond the end of the alias.
|
||||
* @param plane A plane object must be specified.
|
||||
* @result A C-string pointer to the value of the alias if one is found, or zero if not. */
|
||||
|
||||
static const char * dealiasPath( const char ** opath,
|
||||
const IORegistryPlane * plane );
|
||||
|
||||
/*! @function makePlane
|
||||
* @abstract Constructs an IORegistryPlane object.
|
||||
* @discussion Most planes in IOKit are created by the OS, although other planes may be created.
|
||||
* @param name A C-string name for the new plane, to be copied.
|
||||
* @result A new instance of an IORegistryPlane, or zero on failure. */
|
||||
|
||||
static const IORegistryPlane * makePlane( const char * name );
|
||||
|
||||
/*! @abstract Returns an ID for the registry entry that is global to all tasks.
|
||||
* @discussion The entry ID returned by getRegistryEntryID can be used to identify a registry entry across all tasks. A registry entry may be looked up by its entry ID by creating a matching dictionary with IORegistryEntryIDMatching() in user space, or <code>IOService::registryEntryIDMatching()</code> in the kernel, to be used with the IOKit matching functions. The ID is valid only until the machine reboots.
|
||||
* @result An ID for the registry entry, assigned when the entry is first attached in the registry. */
|
||||
|
||||
uint64_t getRegistryEntryID( void );
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* * * * * * * * * * * * internals * * * * * * * * * * * */
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
virtual bool init( IORegistryEntry * from,
|
||||
const IORegistryPlane * inPlane );
|
||||
|
||||
private:
|
||||
static LIBKERN_RETURNS_NOT_RETAINED IORegistryEntry * initialize( void );
|
||||
|
||||
|
||||
private:
|
||||
inline bool arrayMember( OSArray * set,
|
||||
const IORegistryEntry * member,
|
||||
unsigned int * index = NULL ) const;
|
||||
|
||||
bool makeLink( IORegistryEntry * to,
|
||||
unsigned int relation,
|
||||
const IORegistryPlane * plane ) const;
|
||||
void breakLink( IORegistryEntry * to,
|
||||
unsigned int relation,
|
||||
const IORegistryPlane * plane ) const;
|
||||
|
||||
APPLE_KEXT_COMPATIBILITY_VIRTUAL
|
||||
OSArray * getParentSetReference( const IORegistryPlane * plane )
|
||||
const;
|
||||
|
||||
APPLE_KEXT_COMPATIBILITY_VIRTUAL
|
||||
OSArray * getChildSetReference( const IORegistryPlane * plane )
|
||||
const;
|
||||
|
||||
APPLE_KEXT_COMPATIBILITY_VIRTUAL
|
||||
IORegistryEntry * getChildFromComponent( const char ** path,
|
||||
const IORegistryPlane * plane );
|
||||
|
||||
APPLE_KEXT_COMPATIBILITY_VIRTUAL
|
||||
LIBKERN_RETURNS_NOT_RETAINED const OSSymbol * hasAlias(
|
||||
const IORegistryPlane * plane,
|
||||
char * opath = NULL, int * length = NULL ) const;
|
||||
|
||||
APPLE_KEXT_COMPATIBILITY_VIRTUAL
|
||||
const char * matchPathLocation( const char * cmp,
|
||||
const IORegistryPlane * plane );
|
||||
};
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*! @class IORegistryIterator : public OSIterator
|
||||
* @abstract An iterator over the registry.
|
||||
* @discussion An iterator that can traverse the children or parents of a registry entry in a plane, and recurse. Access to the registry is protected against multiple threads, but an IORegistryIterator instance is for use by one thread only. */
|
||||
|
||||
class IORegistryIterator : public OSIterator
|
||||
{
|
||||
OSDeclareAbstractStructors(IORegistryIterator);
|
||||
|
||||
private:
|
||||
struct IORegCursor {
|
||||
IORegCursor * next;
|
||||
IORegistryEntry * current;
|
||||
OSIterator * iter;
|
||||
};
|
||||
IORegCursor start;
|
||||
IORegCursor * where;
|
||||
IORegistryEntry * root;
|
||||
OSOrderedSet * done;
|
||||
const IORegistryPlane * plane;
|
||||
IOOptionBits options;
|
||||
|
||||
virtual void free( void ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
public:
|
||||
/*! @function iterateOver
|
||||
* @abstract Create an iterator rooted at a given registry entry.
|
||||
* @discussion This method creates an IORegistryIterator that is set up with options to iterate children or parents of a root entry, and to recurse automatically into entries as they are returned, or only when instructed. The iterator object keeps track of entries that have been recursed into previously to avoid loops.
|
||||
* @param start The root entry to begin the iteration at.
|
||||
* @param plane A plane object must be specified.
|
||||
* @param options kIORegistryIterateRecursively may be set to recurse automatically into each entry as it is returned. This option affects the behaviour of the getNextObject method, which is defined in the OSIterator superclass. Other methods will override this behaviour. kIORegistryIterateParents may be set to iterate the parents of each entry, by default the children are iterated.
|
||||
* @result A created IORegistryIterator instance, to be released by the caller when it has finished with it. */
|
||||
|
||||
static IORegistryIterator * iterateOver( IORegistryEntry * start,
|
||||
const IORegistryPlane * plane,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
/*! @function iterateOver
|
||||
* @abstract Create an iterator rooted at the registry root.
|
||||
* @discussion This method creates an IORegistryIterator that is set up with options to iterate children of the registry root entry, and to recurse automatically into entries as they are returned, or only when instructed. The iterator object keeps track of entries that have been recursed into previously to avoid loops.
|
||||
* @param plane A plane object must be specified.
|
||||
* @param options kIORegistryIterateRecursively may be set to recurse automatically into each entry as it is returned. This option affects the behaviour of the getNextObject method, which is defined in the OSIterator superclass. Other methods will override this behaviour. kIORegistryIterateParents may be set to iterate the parents of each entry, by default the children are iterated.
|
||||
* @result A created IORegistryIterator instance, to be released by the caller when it has finished with it. */
|
||||
|
||||
static IORegistryIterator * iterateOver( const IORegistryPlane * plane,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
/*! @function getNextObject
|
||||
* @abstract Return the next object in the registry iteration.
|
||||
* @discussion This method calls either getNextObjectFlat or getNextObjectRecursive depending on the options the iterator was created with. This implements the OSIterator defined getNextObject method. The object returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it.
|
||||
* @result The next registry entry in the iteration (the current entry), or zero if the iteration has finished at this level of recursion. The entry returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. */
|
||||
|
||||
virtual IORegistryEntry * getNextObject( void ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function getNextObjectFlat
|
||||
* @abstract Return the next object in the registry iteration, ignoring the kIORegistryIterateRecursively option.
|
||||
* @discussion This method returns the next child, or parent if the kIORegistryIterateParents option was used to create the iterator, of the current root entry. The object returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it.
|
||||
* @result The next registry entry in the iteration (the current entry), or zero if the iteration has finished at this level of recursion, or the iteration is invalid (see isValid). The entry returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. */
|
||||
|
||||
virtual IORegistryEntry * getNextObjectFlat( void );
|
||||
|
||||
/*! @function getNextObjectRecursive
|
||||
* @abstract Return the next object in the registry iteration, and enter it.
|
||||
* @discussion If the iterator has a current entry, and the iterator has not already entered previously, enterEntry is called to recurse into it, ie. make it the new root, and the next child, or parent if the kIORegistryIterateParents option was used to create the iterator, at this new level of recursion is returned. If there is no current entry at this level of recursion, exitEntry is called and the process repeats, until the iteration returns to the entry the iterator was created with and zero is returned. The object returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it.
|
||||
* @result The next registry entry in the iteration (the current entry), or zero if its finished, or the iteration is invalid (see isValid). The entry returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. */
|
||||
|
||||
virtual IORegistryEntry * getNextObjectRecursive( void );
|
||||
|
||||
/*! @function getCurrentEntry
|
||||
* @abstract Return the current entry in the registry iteration.
|
||||
* @discussion This method returns the current entry, last returned by getNextObject et al. The object returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. If the iteration is no longer valid (see isValid), the current entry is zero.
|
||||
* @result The current registry entry in the iteration, or zero if the last iteration returned zero, or the iteration is invalid (see isValid). The entry returned is retained while the iterator is pointing at it (its the current entry), or recursing into it. The caller should not release it. */
|
||||
|
||||
virtual IORegistryEntry * getCurrentEntry( void );
|
||||
|
||||
/*! @function enterEntry
|
||||
* @abstract Recurse into the current entry in the registry iteration.
|
||||
* @discussion This method makes the current entry, ie. the last entry returned by getNextObject et al., the root in a new level of recursion. */
|
||||
|
||||
virtual void enterEntry( void );
|
||||
|
||||
/*! @function enterEntry
|
||||
* @abstract Recurse into the current entry in the registry iteration.
|
||||
* @discussion This method recurses into an entry as with enterEntry, but also switches from the current plane to a new one set by the caller.
|
||||
* @param plane The new plane to switch into. */
|
||||
|
||||
virtual void enterEntry( const IORegistryPlane * plane );
|
||||
|
||||
/*! @function exitEntry
|
||||
* @abstract Exits a level of recursion, restoring the current entry.
|
||||
* @discussion This method undoes an enterEntry, restoring the current entry. If there are no more levels of recursion to exit false is returned, otherwise true is returned.
|
||||
* @result true if a level of recursion was undone, false if no recursive levels are left in the iteration. */
|
||||
|
||||
virtual bool exitEntry( void );
|
||||
|
||||
/*! @function reset
|
||||
* @abstract Exits all levels of recursion, restoring the iterator to its state at creation.
|
||||
* @discussion This method exits all levels of recursion, and restores the iterator to its state at creation. */
|
||||
|
||||
virtual void reset( void ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function isValid
|
||||
* @abstract Checks that no registry changes have invalidated the iteration.
|
||||
* @discussion If a registry iteration is invalidated by changes to the registry, it will be made invalid, the currentEntry will be considered zero, and further calls to getNextObject et al. will return zero. The iterator should be reset to restart the iteration when this happens.
|
||||
* @result false if the iterator has been invalidated by changes to the registry, true otherwise. */
|
||||
|
||||
virtual bool isValid( void ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function iterateAll
|
||||
* @abstract Iterates all entries (with getNextObject) and returns a set of all returned entries.
|
||||
* @discussion This method will reset, then iterate all entries in the iteration (with getNextObject).
|
||||
* @result A set of entries returned by the iteration. The caller should release the set when it has finished with it. Zero is returned on a resource failure. */
|
||||
|
||||
virtual OSOrderedSet * iterateAll( void );
|
||||
};
|
||||
|
||||
#endif /* _IOKIT_IOREGISTRYENTRY_H */
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Released under "The BSD 3-Clause License"
|
||||
*
|
||||
* Copyright (c) 2021 cjiang. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The names of its contributors may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IOREPORTHUB_H
|
||||
#define _IOKIT_IOREPORTHUB_H
|
||||
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/IOBufferMemoryDescriptor.h>
|
||||
|
||||
extern IOReturn _getInterests(OSDictionary *, OSArray **, OSArray **, OSArray **);
|
||||
extern IOReturn _copyServiceGetChannels(OSArray *, OSArray *, OSArray *, UInt32, IOService **, IOReportChannelList **, OSNumber **);
|
||||
|
||||
class IOReportHub : public IOService
|
||||
{
|
||||
OSDeclareDefaultStructors(IOReportHub)
|
||||
|
||||
public:
|
||||
virtual bool start( IOService * provider ) APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn getReportBufferSize( OSDictionary * dict, int * size );
|
||||
virtual IOReturn getValues( OSDictionary * dict, IOBufferMemoryDescriptor * buffer );
|
||||
IOReturn callConfigureReport(OSDictionary *, UInt32, int *);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,705 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2014 Apple Computer, Inc. All Rights Reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOREPORT_MACROS_H_
|
||||
#define _IOREPORT_MACROS_H_
|
||||
|
||||
#include "IOReportTypes.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef IOREPORT_ABORT
|
||||
#define IOREPORT_ABORT panic
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Background
|
||||
*
|
||||
* These macros allow non-I/O Kit software to generate IOReporting
|
||||
* reports. Clients must prevent concurrent access to any given
|
||||
* report buffer from multiple threads.
|
||||
*
|
||||
* While these macros allow non-I/O Kit software to participate
|
||||
* in IOReporting, an IOService instance must lend its driver ID,
|
||||
* respond to the appropriate IOService overrides, and shuttle
|
||||
* data back and forth. In some cases, it may be useful to have
|
||||
* the I/O Kit driver initialize the report buffer with the
|
||||
* appropriate macro.
|
||||
*/
|
||||
|
||||
|
||||
/* ----- Reporting Single Integers (SimpleReport) ----- */
|
||||
|
||||
/*
|
||||
* The buffer size required for a SimpleReport.
|
||||
*/
|
||||
|
||||
#define SIMPLEREPORT_BUFSIZE (sizeof(IOReportElement))
|
||||
|
||||
|
||||
/*
|
||||
* Initialize a buffer to hold a SimpleReport.
|
||||
*
|
||||
* void* buffer - ptr to SIMPLEREPORT_BUFSIZE bytes
|
||||
* size_t bufSize - sanity check of buffer's size
|
||||
* uint64_t providerID - registry Entry ID of the reporting service
|
||||
* uint64_t channelID - the report's channel ID
|
||||
* IOReportCategories categories - categories of this channel
|
||||
*
|
||||
* If the buffer is not of sufficient size, the macro calls IOREPORT_ABORT().
|
||||
* If that returns, the buffer is left full of '&'.
|
||||
*/
|
||||
|
||||
#define SIMPLEREPORT_INIT(buf, bufSize, providerID, channelID, cats) \
|
||||
do { \
|
||||
memset((buf), '&', (bufSize)); \
|
||||
IOReportElement *__elem = (IOReportElement *)(buf); \
|
||||
IOSimpleReportValues *__vals; \
|
||||
if ((bufSize) >= SIMPLEREPORT_BUFSIZE) { \
|
||||
__elem->provider_id = (providerID); \
|
||||
__elem->channel_id = (channelID); \
|
||||
__elem->channel_type.report_format = kIOReportFormatSimple; \
|
||||
__elem->channel_type.reserved = 0; \
|
||||
__elem->channel_type.categories = (cats); \
|
||||
__elem->channel_type.nelements = 1; \
|
||||
__elem->channel_type.element_idx = 0; \
|
||||
__elem->timestamp = 0; \
|
||||
__vals = (IOSimpleReportValues*)&__elem->values; \
|
||||
__vals->simple_value = kIOReportInvalidIntValue; \
|
||||
} \
|
||||
else { \
|
||||
IOREPORT_ABORT("bufSize is smaller than the required size\n"); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
/*
|
||||
* Set a SimpleReport to a new value.
|
||||
*
|
||||
* void* simp_buf - ptr to memory initialized by SIMPLEREPORT_INIT()
|
||||
* int64_t new_value - new value for the report
|
||||
*/
|
||||
|
||||
#define SIMPLEREPORT_SETVALUE(simp_buf, new_value) \
|
||||
do { \
|
||||
IOReportElement *__elem = (IOReportElement *)(simp_buf); \
|
||||
IOSimpleReportValues *__vals; \
|
||||
__vals = (IOSimpleReportValues*)&__elem->values; \
|
||||
__vals->simple_value = (new_value); \
|
||||
} while(0)
|
||||
|
||||
|
||||
/*
|
||||
* Increment the value of a SimpleReport.
|
||||
*
|
||||
* void* simp_buf - ptr to memory initialized by SIMPLEREPORT_INIT()
|
||||
* int64_t increment - amount by which to increment the value
|
||||
*/
|
||||
#define SIMPLEREPORT_INCREMENTVALUE(simp_buf, new_value) \
|
||||
do { \
|
||||
IOReportElement *__elem = (IOReportElement *)(simp_buf); \
|
||||
IOSimpleReportValues *__vals; \
|
||||
__vals = (IOSimpleReportValues*)&__elem->values; \
|
||||
__vals->simple_value += (new_value); \
|
||||
} while(0)
|
||||
|
||||
|
||||
/*
|
||||
* Prepare a SimpleReport for
|
||||
* IOService::updateReport(kIOReportCopyChannelData...)
|
||||
*
|
||||
* void* simp_buf - Ptr to memory updated by SIMPLEREPORT_SETVALUE()
|
||||
* void* ptr2cpy - On return, 'ptr2cpy' points to the memory that needs to be
|
||||
* copied for kIOReportCopyChannelData.
|
||||
* size_t size2cpy - On return, 'size2cpy' is set to the size of the report
|
||||
* data that needs to be copied for kIOReportCopyChannelData.
|
||||
*/
|
||||
|
||||
#define SIMPLEREPORT_UPDATEPREP(simp_buf, ptr2cpy, size2cpy) \
|
||||
do { \
|
||||
(ptr2cpy) = (simp_buf); \
|
||||
(size2cpy) = sizeof(IOReportElement); \
|
||||
} while(0)
|
||||
|
||||
|
||||
/*
|
||||
* Update the result field received as a parameter for
|
||||
* kIOReportGetDimensions & kIOReportCopyChannelData actions.
|
||||
*
|
||||
* IOReportConfigureAction action - configure/updateReport() 'action' param
|
||||
* void* result - configure/updateReport() 'result' param
|
||||
*/
|
||||
|
||||
#define SIMPLEREPORT_UPDATERES(action, result) \
|
||||
do { \
|
||||
if (((action) == kIOReportGetDimensions) || ((action) == kIOReportCopyChannelData)) { \
|
||||
int *__nElements = (int *)(result); \
|
||||
*__nElements += 1; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
* Get the 64-bit channel ID of a SimpleReport.
|
||||
*
|
||||
* void* simp_buf - ptr to memory initialized by SIMPLEREPORT_INIT()
|
||||
*/
|
||||
|
||||
#define SIMPLEREPORT_GETCHID(simp_buf) \
|
||||
(((IOReportElement *)(simp_buf))->channel_id)
|
||||
|
||||
/*
|
||||
* Get the IOReportChannelType of a SimpleReport.
|
||||
*
|
||||
* void* simp_buf - ptr to memory initialized by SIMPLEREPORT_INIT()
|
||||
*/
|
||||
|
||||
#define SIMPLEREPORT_GETCHTYPE(simp_buf) \
|
||||
(*(uint64_t*)&(((IOReportElement *)(simp_buf))->channel_type))
|
||||
|
||||
|
||||
/*
|
||||
* Get the integer value of a SimpleReport.
|
||||
*
|
||||
* void* simp_buf - memory initialized by SIMPLEREPORT_INIT()
|
||||
*/
|
||||
|
||||
#define SIMPLEREPORT_GETVALUE(simp_buf) \
|
||||
(((IOSimpleReportValues*)&(((IOReportElement*)(simp_buf))->values)) \
|
||||
->simple_value)
|
||||
|
||||
|
||||
/* ----- State Machine Reporting (StateReport) ----- */
|
||||
|
||||
// Internal struct for StateReport
|
||||
typedef struct {
|
||||
uint16_t curr_state;
|
||||
uint64_t update_ts;
|
||||
IOReportElement elem[]; // Array of elements
|
||||
} IOStateReportInfo;
|
||||
|
||||
/*
|
||||
* Determine the size required for a StateReport buffer.
|
||||
*
|
||||
* int nstates - number of states to be reported
|
||||
*/
|
||||
#define STATEREPORT_BUFSIZE(nstates) \
|
||||
(sizeof(IOStateReportInfo) + (nstates) * sizeof(IOReportElement))
|
||||
|
||||
|
||||
/*
|
||||
* Initialize a StateReport buffer.
|
||||
*
|
||||
* int nstates - number of states to be reported
|
||||
* void* buffer - ptr to STATEREPORT_BUFSIZE(nstates) bytes
|
||||
* size_t bufSize - sanity check of buffer's size
|
||||
* uint64_t providerID - registry Entry ID of the reporting service
|
||||
* uint64_t channelID - ID of this channel, see IOREPORT_MAKEID()
|
||||
* IOReportCategories categories - categories of this channel
|
||||
*
|
||||
* If the buffer is not of sufficient size, the macro invokes IOREPORT_ABORT.
|
||||
* If that returns, the buffer is left full of '&'.
|
||||
*/
|
||||
#define STATEREPORT_INIT(nstates, buf, bufSize, providerID, channelID, cats) \
|
||||
do { \
|
||||
memset((buf), '&', (bufSize)); \
|
||||
IOStateReportInfo *__info = (IOStateReportInfo *)(buf); \
|
||||
IOStateReportValues *__rep; \
|
||||
IOReportElement *__elem; \
|
||||
if ((bufSize) >= STATEREPORT_BUFSIZE(nstates)) { \
|
||||
for (unsigned __no = 0; __no < (nstates); __no++) { \
|
||||
__elem = &(__info->elem[__no]); \
|
||||
__rep = (IOStateReportValues *) &(__elem->values); \
|
||||
__elem->provider_id = (providerID); \
|
||||
__elem->channel_id = (channelID); \
|
||||
__elem->channel_type.report_format = kIOReportFormatState; \
|
||||
__elem->channel_type.reserved = 0; \
|
||||
__elem->channel_type.categories = (cats); \
|
||||
__elem->channel_type.nelements = (nstates); \
|
||||
__elem->channel_type.element_idx = __no; \
|
||||
__elem->timestamp = 0; \
|
||||
__rep->state_id = __no; \
|
||||
__rep->intransitions = 0; \
|
||||
__rep->upticks = 0; \
|
||||
__rep->last_intransition = 0; \
|
||||
} \
|
||||
__info->curr_state = 0; \
|
||||
__info->update_ts = 0; \
|
||||
} \
|
||||
else { \
|
||||
IOREPORT_ABORT("bufSize is smaller than the required size\n"); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
* Initialize the state id field of a state with the specified value. By
|
||||
* default, STATEREPORT_INIT() initializes the state IDs with the index of
|
||||
* that state. This macro can be used to provide a more descriptive state id.
|
||||
*
|
||||
* void* state_buf - ptr to memory initialized by STATEREPORT_INIT()
|
||||
* unsigned stateIdx - index of the state, out of bounds -> no-op
|
||||
* uint64_t stateID - new state id, see IOREPORT_MAKEID()
|
||||
*/
|
||||
#define STATEREPORT_SETSTATEID(state_buf, stateIdx, stateID) \
|
||||
do { \
|
||||
IOStateReportInfo *__info = (IOStateReportInfo *)(state_buf); \
|
||||
IOStateReportValues *__rep; \
|
||||
if ((stateIdx) < __info->elem[0].channel_type.nelements) { \
|
||||
__rep = (IOStateReportValues*) &(__info->elem[(stateIdx)].values); \
|
||||
__rep->state_id = (stateID); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
* Set the state of a StateReport.
|
||||
*
|
||||
* void* state_buf - pointer to memory initialized by STATEREPORT_INIT()
|
||||
* unsigned newStateIdx - index of new state, out of bounds -> no-op
|
||||
* uint64_t changeTime - time at which the transition occurred
|
||||
*/
|
||||
#define STATEREPORT_SETSTATE(state_buf, newStateIdx, changeTime) \
|
||||
do { \
|
||||
IOStateReportInfo *__info = (IOStateReportInfo *)(state_buf); \
|
||||
IOStateReportValues *__rep; \
|
||||
if ((newStateIdx) < __info->elem[0].channel_type.nelements ) { \
|
||||
__rep = (IOStateReportValues*) &(__info->elem[__info->curr_state].values); \
|
||||
if (__info->update_ts) \
|
||||
__rep->upticks += (changeTime) - __info->update_ts; \
|
||||
__info->elem[(newStateIdx)].timestamp = (changeTime); \
|
||||
__rep = (IOStateReportValues*) &(__info->elem[(newStateIdx)].values); \
|
||||
__rep->intransitions++; \
|
||||
__info->curr_state = (newStateIdx); \
|
||||
__info->update_ts = (changeTime); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
* Prepare a StateReport for
|
||||
* IOService::updateReport(kIOReportCopyChannelData...)
|
||||
*
|
||||
* void* state_buf - ptr to memory initialized by STATEREPORT_INIT()
|
||||
* uint64_t currentTime - current timestamp
|
||||
* void* ptr2cpy - filled in with pointer to buffer to be copied out
|
||||
* size_t size2cpy - filled in with the size of the buffer to copy out
|
||||
*/
|
||||
#define STATEREPORT_UPDATEPREP(state_buf, currentTime, ptr2cpy, size2cpy) \
|
||||
do { \
|
||||
IOStateReportInfo *__info = (IOStateReportInfo *)(state_buf); \
|
||||
IOReportElement *__elem; \
|
||||
IOStateReportValues *__state; \
|
||||
(size2cpy) = __info->elem[0].channel_type.nelements * sizeof(IOReportElement); \
|
||||
(ptr2cpy) = (void *) &__info->elem[0]; \
|
||||
if (__info->update_ts) { \
|
||||
__elem = &__info->elem[__info->curr_state]; \
|
||||
__state = (IOStateReportValues *)&__elem->values; \
|
||||
__elem->timestamp = (currentTime); \
|
||||
__state->upticks += (currentTime) - __info->update_ts; \
|
||||
__info->update_ts = (currentTime); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
* Update the result field received as a parameter for kIOReportGetDimensions &
|
||||
* kIOReportCopyChannelData actions.
|
||||
*
|
||||
* void* state_buf - memory initialized by STATEREPORT_INIT()
|
||||
* IOReportConfigureAction action - configure/updateReport() 'action'
|
||||
* void* result - configure/updateReport() 'result'
|
||||
*/
|
||||
|
||||
#define STATEREPORT_UPDATERES(state_buf, action, result) \
|
||||
do { \
|
||||
IOStateReportInfo *__info = (IOStateReportInfo *)(state_buf); \
|
||||
IOReportElement *__elem; \
|
||||
int *__nElements = (int *)(result); \
|
||||
if (((action) == kIOReportGetDimensions) || ((action) == kIOReportCopyChannelData)) { \
|
||||
__elem = &(__info->elem[0]); \
|
||||
*__nElements += __elem->channel_type.nelements; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
* Get the 64-bit channel ID of a StateReport.
|
||||
*
|
||||
* void* state_buf - ptr to memory initialized by STATEREPORT_INIT()
|
||||
*/
|
||||
#define STATEREPORT_GETCHID(state_buf) \
|
||||
(((IOStateReportInfo *)(state_buf))->elem[0].channel_id)
|
||||
|
||||
/*
|
||||
* Get the IOReportChannelType of a StateReport.
|
||||
*
|
||||
* void* state_buf - ptr to memory initialized by STATEREPORT_INIT()
|
||||
*/
|
||||
#define STATEREPORT_GETCHTYPE(state_buf) \
|
||||
(*(uint64_t*)&(((IOStateReportInfo *)(state_buf))->elem[0].channel_type))
|
||||
|
||||
/*
|
||||
* Get the number of transitions into a given state.
|
||||
*
|
||||
* void* state_buf - ptr to memory initialized by STATEREPORT_INIT()
|
||||
* unsigned stateIdx - index of state, out of bounds -> kIOReportInvalidValue
|
||||
*
|
||||
*/
|
||||
#define STATEREPORT_GETTRANSITIONS(state_buf, stateIdx) \
|
||||
(((stateIdx) < ((IOStateReportInfo *)(state_buf))->elem[0].channel_type.nelements) \
|
||||
? ((IOStateReportValues*)&(((IOStateReportInfo*)(state_buf))->elem[(stateIdx)].values))->intransitions \
|
||||
: kIOReportInvalidValue)
|
||||
|
||||
/*
|
||||
* Get the total number of ticks spent in a given state.
|
||||
*
|
||||
* void* state_buf - ptr to memory initialized by STATEREPORT_INIT()
|
||||
* unsigned stateIdx - index of state, out of bounds -> kIOReportInvalidValue
|
||||
*/
|
||||
#define STATEREPORT_GETTICKS(state_buf, stateIdx) \
|
||||
(((stateIdx) < ((IOStateReportInfo*)(state_buf))->elem[0].channel_type.nelements) \
|
||||
? ((IOStateReportValues*)&(((IOStateReportInfo*)(state_buf))->elem[(stateIdx)].values))->upticks \
|
||||
: kIOReportInvalidValue)
|
||||
|
||||
|
||||
/* ----- Reporting an Array of Integers (SimpleArrayReport) ----- */
|
||||
|
||||
/*
|
||||
* Determine the buffer size for a SimpleArrayReport.
|
||||
*
|
||||
* int nValues - number of values to be reported
|
||||
*/
|
||||
|
||||
#define SIMPLEARRAY_BUFSIZE(nValues) \
|
||||
((((nValues)/IOR_VALUES_PER_ELEMENT) + (((nValues) % IOR_VALUES_PER_ELEMENT) ? 1:0)) \
|
||||
* sizeof(IOReportElement))
|
||||
|
||||
/*
|
||||
* Initialize a buffer for use as a SimpleArrayReport.
|
||||
*
|
||||
* int nValues - number of elements to be reported
|
||||
* void* buf - ptr to SIMPLEARRAY_BUFSIZE(nValues) bytes
|
||||
* size_t bufSize - sanity check of buffer's size
|
||||
* uint64_t providerID - registry Entry ID of the reporting service
|
||||
* uint64_t channelID - ID of this channel, see IOREPORT_MAKEID()
|
||||
* IOReportCategories categories - categories of this channel
|
||||
*
|
||||
* If the buffer is not of sufficient size, the macro invokes IOREPORT_ABORT().
|
||||
* If that returns, the buffer is left full of '&'.
|
||||
*/
|
||||
|
||||
#define SIMPLEARRAY_INIT(nValues, buf, bufSize, providerID, channelID, cats) \
|
||||
do { \
|
||||
memset((buf), '&', (bufSize)); \
|
||||
IOSimpleArrayReportValues *__rep; \
|
||||
IOReportElement *__elem; \
|
||||
uint32_t __nElems = (((nValues) / IOR_VALUES_PER_ELEMENT) + \
|
||||
(((nValues) % IOR_VALUES_PER_ELEMENT) ? 1 : 0)); \
|
||||
if ((bufSize) >= SIMPLEARRAY_BUFSIZE(nValues)) { \
|
||||
for (unsigned __no = 0; __no < __nElems; __no++) { \
|
||||
__elem = &(((IOReportElement *)(buf))[__no]); \
|
||||
__rep = (IOSimpleArrayReportValues *) &(__elem->values); \
|
||||
__elem->provider_id = (providerID); \
|
||||
__elem->channel_id = (channelID); \
|
||||
__elem->channel_type.report_format = kIOReportFormatSimpleArray; \
|
||||
__elem->channel_type.reserved = 0; \
|
||||
__elem->channel_type.categories = (cats); \
|
||||
__elem->channel_type.nelements = (__nElems); \
|
||||
__elem->channel_type.element_idx = __no; \
|
||||
__elem->timestamp = 0; \
|
||||
__rep->simple_values[0] = kIOReportInvalidIntValue; \
|
||||
__rep->simple_values[1] = kIOReportInvalidIntValue; \
|
||||
__rep->simple_values[2] = kIOReportInvalidIntValue; \
|
||||
__rep->simple_values[3] = kIOReportInvalidIntValue; \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
IOREPORT_ABORT("bufSize is smaller than the required size\n"); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
/* SimpleArrayReport helpers */
|
||||
|
||||
#define __SA_FINDREP(array_buf, idx) \
|
||||
IOSimpleArrayReportValues *__rep; \
|
||||
IOReportElement *__elem; \
|
||||
unsigned __elemIdx = (idx) / IOR_VALUES_PER_ELEMENT; \
|
||||
unsigned __valueIdx = (idx) % IOR_VALUES_PER_ELEMENT; \
|
||||
__elem = &(((IOReportElement *)(array_buf))[0]); \
|
||||
if (__elemIdx < __elem->channel_type.nelements) { \
|
||||
__elem = &(((IOReportElement *)(array_buf))[__elemIdx]); \
|
||||
__rep = (IOSimpleArrayReportValues *) &(__elem->values); \
|
||||
|
||||
#define __SA_MAXINDEX(array_buf) \
|
||||
((((IOReportElement*)(array_buf))->channel_type.nelements) \
|
||||
* IOR_VALUES_PER_ELEMENT) - 1
|
||||
|
||||
/*
|
||||
* Set a value at a specified index in a SimpleArrayReport.
|
||||
*
|
||||
* void* array_bufbuf - ptr to memory initialized by SIMPLEARRAY_INIT()
|
||||
* unsigned idx - array index, out of bounds -> no-op
|
||||
* uint64_t newValue - new value to be stored at array[idx]
|
||||
*/
|
||||
#define SIMPLEARRAY_SETVALUE(array_buf, idx, newValue) \
|
||||
do { \
|
||||
__SA_FINDREP((array_buf), (idx)) \
|
||||
__rep->simple_values[__valueIdx] = (newValue); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
* Increment an array value within a SimpleArrayReport.
|
||||
*
|
||||
* void* array_buf - ptr to memory initialized by SIMPLEARRAY_INIT()
|
||||
* unsigned idx - array index to increment, out of bounds -> no-op
|
||||
* int64_t value - amount by which to increment array[idx]
|
||||
*/
|
||||
#define SIMPLEARRAY_INCREMENTVALUE(array_buf, idx, value) \
|
||||
do { \
|
||||
__SA_FINDREP((array_buf), (idx)) \
|
||||
__rep->simple_values[__valueIdx] += (value); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
/*
|
||||
* Prepare a SimpleArrayReport for
|
||||
* IOService::updateReport(kIOReportCopyChannelData...)
|
||||
*
|
||||
* void* array_buf - ptr to memory initialized by SIMPLEARRAY_INIT()
|
||||
* void* ptr2cpy - filled in with pointer to buffer to be copied out
|
||||
* size_t size2cpy - filled in with the size of the buffer to copy out
|
||||
*/
|
||||
|
||||
#define SIMPLEARRAY_UPDATEPREP(array_buf, ptr2cpy, size2cpy) \
|
||||
do { \
|
||||
IOReportElement *__elem; \
|
||||
__elem = &(((IOReportElement *)(array_buf))[0]); \
|
||||
(ptr2cpy) = (void *) (array_buf); \
|
||||
(size2cpy) = __elem->channel_type.nelements * sizeof(IOReportElement); \
|
||||
} while(0)
|
||||
|
||||
|
||||
/*
|
||||
* Update the result field received as a parameter for kIOReportGetDimensions &
|
||||
* kIOReportCopyChannelData actions.
|
||||
*
|
||||
* void* array_buf - memory initialized by SIMPLEARRAY_INIT()
|
||||
* IOReportConfigureAction action - configure/updateReport() 'action'
|
||||
* void* result - configure/updateReport() 'result'
|
||||
*/
|
||||
|
||||
#define SIMPLEARRAY_UPDATERES(array_buf, action, result) \
|
||||
do { \
|
||||
IOReportElement *__elem; \
|
||||
int *__nElements = (int *)(result); \
|
||||
__elem = &(((IOReportElement *)(array_buf))[0]); \
|
||||
if (((action) == kIOReportGetDimensions) || ((action) == kIOReportCopyChannelData)) { \
|
||||
*__nElements += __elem->channel_type.nelements; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
* Get the 64-bit channel ID of a SimpleArrayReport.
|
||||
*
|
||||
* void* array_buf - ptr to memory initialized by SIMPLEARRAY_INIT()
|
||||
*/
|
||||
#define SIMPLEARRAY_GETCHID(array_buf) \
|
||||
(((IOReportElement *)(array_buf))->channel_id)
|
||||
|
||||
|
||||
/*
|
||||
* Get the IOReportChannelType of a SimpleArrayReport.
|
||||
*
|
||||
* void* simp_buf - ptr to memory initialized by SIMPLEREPORT_INIT()
|
||||
*/
|
||||
#define SIMPLEARRAY_GETCHTYPE(array_buf) \
|
||||
(*(uint64_t*)&(((IOReportElement *)(array_buf))->channel_type))
|
||||
|
||||
/*
|
||||
* Get a value from a SimpleArrayReport.
|
||||
*
|
||||
* void* array_buf - ptr to memory initialized by SIMPLEARRAY_INIT()
|
||||
* unsigned idx - index of the value, out of bounds -> kIOReportInvalidValue
|
||||
*/
|
||||
#define SIMPLEARRAY_GETVALUE(array_buf, idx) \
|
||||
(((idx) > __SA_MAXINDEX(array_buf) || (idx) < 0) ? kIOReportInvalidIntValue : \
|
||||
((IOSimpleArrayReportValues*)&( \
|
||||
((IOReportElement*)(array_buf))[(idx) / IOR_VALUES_PER_ELEMENT].values)) \
|
||||
->simple_values[(idx) % IOR_VALUES_PER_ELEMENT])
|
||||
|
||||
|
||||
/* ----- Histogram Reporting (HistogramReport) ----- */
|
||||
|
||||
// Internal struct for HistogramReport
|
||||
typedef struct {
|
||||
int bucketWidth;
|
||||
IOReportElement elem[]; // Array of elements
|
||||
} IOHistReportInfo;
|
||||
|
||||
/*
|
||||
* Determine the size required for a HistogramReport buffer.
|
||||
*
|
||||
* int nbuckets - number of buckets in the histogram
|
||||
*/
|
||||
#define HISTREPORT_BUFSIZE(nbuckets) \
|
||||
(sizeof(IOHistReportInfo) + ((nbuckets) * sizeof(IOReportElement)))
|
||||
|
||||
/*
|
||||
* Initialize a HistogramReport buffer. Supports only linear scale histogram.
|
||||
*
|
||||
* int nbuckets - number of buckets data is combined into
|
||||
* uint32_t bucketWidth - size of each bucket
|
||||
* void* buffer - ptr to HISTREPORT_BUFSIZE(nbuckets) bytes
|
||||
* size_t bufSize - sanity check of buffer's size
|
||||
* uint64_t providerID - registry Entry ID of the reporting service
|
||||
* uint64_t channelID - ID of this channel, see IOREPORT_MAKEID()
|
||||
* IOReportCategories categories - categories of this channel
|
||||
*
|
||||
* If the buffer is not of sufficient size, the macro invokes IOREPORT_ABORT.
|
||||
* If that returns, the buffer is left full of '&'.
|
||||
*/
|
||||
#define HISTREPORT_INIT(nbuckets, bktSize, buf, bufSize, providerID, channelID, cats) \
|
||||
do { \
|
||||
memset((buf), '&', (bufSize)); \
|
||||
IOHistReportInfo *__info = (IOHistReportInfo *)(buf); \
|
||||
IOReportElement *__elem; \
|
||||
IOHistogramReportValues *__rep; \
|
||||
if ((bufSize) >= HISTREPORT_BUFSIZE(nbuckets)) { \
|
||||
__info->bucketWidth = (bktSize); \
|
||||
for (unsigned __no = 0; __no < (nbuckets); __no++) { \
|
||||
__elem = &(__info->elem[__no]); \
|
||||
__rep = (IOHistogramReportValues *) &(__elem->values); \
|
||||
__elem->provider_id = (providerID); \
|
||||
__elem->channel_id = (channelID); \
|
||||
__elem->channel_type.report_format = kIOReportFormatHistogram; \
|
||||
__elem->channel_type.reserved = 0; \
|
||||
__elem->channel_type.categories = (cats); \
|
||||
__elem->channel_type.nelements = (nbuckets); \
|
||||
__elem->channel_type.element_idx = __no; \
|
||||
__elem->timestamp = 0; \
|
||||
memset(__rep, '\0', sizeof(IOHistogramReportValues)); \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
IOREPORT_ABORT("bufSize is smaller than the required size\n"); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Update histogram with a new value.
|
||||
*
|
||||
*
|
||||
* void* hist_buf - pointer to memory initialized by HISTREPORT_INIT()
|
||||
* int64_t value - new value to add to the histogram
|
||||
*/
|
||||
#define HISTREPORT_TALLYVALUE(hist_buf, value) \
|
||||
do { \
|
||||
IOHistReportInfo *__info = (IOHistReportInfo *)(hist_buf); \
|
||||
IOReportElement *__elem; \
|
||||
IOHistogramReportValues *__rep; \
|
||||
for (unsigned __no = 0; __no < __info->elem[0].channel_type.nelements; __no++) { \
|
||||
if ((value) <= __info->bucketWidth * (__no+1)) { \
|
||||
__elem = &(__info->elem[__no]); \
|
||||
__rep = (IOHistogramReportValues *) &(__elem->values); \
|
||||
if (__rep->bucket_hits == 0) { \
|
||||
__rep->bucket_min = __rep->bucket_max = (value); \
|
||||
} \
|
||||
else if ((value) < __rep->bucket_min) { \
|
||||
__rep->bucket_min = (value); \
|
||||
} \
|
||||
else if ((value) > __rep->bucket_max) { \
|
||||
__rep->bucket_max = (value); \
|
||||
} \
|
||||
__rep->bucket_sum += (value); \
|
||||
__rep->bucket_hits++; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Prepare a HistogramReport for
|
||||
* IOService::updateReport(kIOReportCopyChannelData...)
|
||||
*
|
||||
* void* array_buf - ptr to memory initialized by HISTREPORT_INIT()
|
||||
* void* ptr2cpy - filled in with pointer to buffer to be copied out
|
||||
* size_t size2cpy - filled in with the size of the buffer to copy out
|
||||
*/
|
||||
|
||||
#define HISTREPORT_UPDATEPREP(hist_buf, ptr2cpy, size2cpy) \
|
||||
do { \
|
||||
IOHistReportInfo *__info = (IOHistReportInfo *)(hist_buf); \
|
||||
(size2cpy) = __info->elem[0].channel_type.nelements * sizeof(IOReportElement); \
|
||||
(ptr2cpy) = (void *) &__info->elem[0]; \
|
||||
} while(0)
|
||||
|
||||
|
||||
/*
|
||||
* Update the result field received as a parameter for kIOReportGetDimensions &
|
||||
* kIOReportCopyChannelData actions.
|
||||
*
|
||||
* void* array_buf - memory initialized by HISTREPORT_INIT()
|
||||
* IOReportConfigureAction action - configure/updateReport() 'action'
|
||||
* void* result - configure/updateReport() 'result'
|
||||
*/
|
||||
|
||||
#define HISTREPORT_UPDATERES(hist_buf, action, result) \
|
||||
do { \
|
||||
IOHistReportInfo *__info = (IOHistReportInfo *)(hist_buf); \
|
||||
int *__nElements = (int *)(result); \
|
||||
if (((action) == kIOReportGetDimensions) || ((action) == kIOReportCopyChannelData)) { \
|
||||
*__nElements += __info->elem[0].channel_type.nelements; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Get the 64-bit channel ID of a HistogramReport.
|
||||
*
|
||||
* void* hist_buf - ptr to memory initialized by HISTREPORT_INIT()
|
||||
*/
|
||||
#define HISTREPORT_GETCHID(hist_buf) \
|
||||
(((IOHistReportInfo *)(hist_buf))->elem[0].channel_id)
|
||||
|
||||
/*
|
||||
* Get the IOReportChannelType of a HistogramReport.
|
||||
*
|
||||
* void* hist_buf - ptr to memory initialized by HISTREPORT_INIT()
|
||||
*/
|
||||
#define HISTREPORT_GETCHTYPE(hist_buf) \
|
||||
(*(uint64_t*)&(((IOHistReportInfo *)(hist_buf))->elem[0].channel_type))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _IOREPORT_MACROS_H_
|
||||
@@ -0,0 +1,411 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2014 Apple Computer, Inc. All Rights Reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOREPORT_TYPES_H_
|
||||
#define _IOREPORT_TYPES_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IOR_VALUES_PER_ELEMENT 4
|
||||
|
||||
/*! @const kIOReportInvalidValue
|
||||
* @const kIOReportInvalidIntValue
|
||||
* @abstract cardinal value used to indicate data errors
|
||||
*
|
||||
* @discussion
|
||||
* kIOReportInvalidValue and kIOReportInvalidIntValue have the
|
||||
* same bit pattern so that clients checking for one or the other
|
||||
* don't have to worry about getting the signedness right.
|
||||
*/
|
||||
#define kIOReportInvalidIntValue INT64_MIN
|
||||
#define kIOReportInvalidValue (uint64_t)kIOReportInvalidIntValue
|
||||
|
||||
/*! @typedef IOReportCategories
|
||||
* @abstract encapsulate important, multi-purpose "tags" for channels
|
||||
*
|
||||
* @discussion
|
||||
* IOReportCategories is the type for the .categories field of
|
||||
* IOReportChanelType. These categories are inteded to empower a
|
||||
* limited number of clients to retrieve a broad range of channels
|
||||
* without knowing much about them. They can be OR'd together as
|
||||
* needed. Groups and subgroups are a more extensible mechanism
|
||||
* for aggregating channels produced by different drivers.
|
||||
*/
|
||||
typedef uint16_t IOReportCategories;
|
||||
#define kIOReportCategoryPower (1 << 1) // and energy
|
||||
#define kIOReportCategoryTraffic (1 << 2) // I/O at any level
|
||||
#define kIOReportCategoryPerformance (1 << 3) // e.g. cycles/byte
|
||||
#define kIOReportCategoryPeripheral (1 << 4) // not built-in
|
||||
|
||||
#define kIOReportCategoryField (1 << 8) // consider logging
|
||||
|
||||
// future categories TBD
|
||||
#define kIOReportCategoryDebug (1 << 15)
|
||||
#define kIOReportInvalidCategory UINT16_MAX
|
||||
|
||||
|
||||
// IOReportChannelType.report_format
|
||||
typedef uint8_t IOReportFormat;
|
||||
enum {
|
||||
kIOReportInvalidFormat = 0,
|
||||
kIOReportFormatSimple = 1,
|
||||
kIOReportFormatState = 2,
|
||||
kIOReportFormatHistogram = 3,
|
||||
kIOReportFormatSimpleArray = 4
|
||||
};
|
||||
|
||||
// simple report values
|
||||
typedef struct {
|
||||
int64_t simple_value;
|
||||
uint64_t reserved1;
|
||||
uint64_t reserved2;
|
||||
uint64_t reserved3;
|
||||
} __attribute((packed)) IOSimpleReportValues;
|
||||
|
||||
// simple value array
|
||||
typedef struct {
|
||||
int64_t simple_values[IOR_VALUES_PER_ELEMENT];
|
||||
} __attribute((packed)) IOSimpleArrayReportValues;
|
||||
|
||||
// state report values
|
||||
typedef struct {
|
||||
uint64_t state_id; // 0..N-1 or 8-char code (see MAKEID())
|
||||
uint64_t intransitions; // number of transitions into this state
|
||||
uint64_t upticks; // ticks spent in state (local timebase)
|
||||
uint64_t last_intransition;// ticks at last in-transition
|
||||
} __attribute((packed)) IOStateReportValues;
|
||||
|
||||
// histogram report values
|
||||
typedef struct {
|
||||
uint64_t bucket_hits;
|
||||
int64_t bucket_min;
|
||||
int64_t bucket_max;
|
||||
int64_t bucket_sum;
|
||||
} __attribute((packed)) IOHistogramReportValues;
|
||||
|
||||
|
||||
|
||||
// configuration actions generally change future behavior
|
||||
typedef uint32_t IOReportConfigureAction;
|
||||
enum {
|
||||
// basics (in common operational order)
|
||||
kIOReportEnable = 0x01,
|
||||
kIOReportGetDimensions = 0x02,
|
||||
kIOReportDisable = 0x00,
|
||||
|
||||
// Enable/disable modifiers
|
||||
kIOReportNotifyHubOnChange = 0x10, // triggered polling
|
||||
|
||||
kIOReportTraceOnChange = 0x20 // kdebug.h tracing
|
||||
};
|
||||
|
||||
// update actions should not have observable side effects
|
||||
typedef uint32_t IOReportUpdateAction;
|
||||
enum {
|
||||
kIOReportCopyChannelData = 1,
|
||||
kIOReportTraceChannelData = 2
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint8_t report_format; // Histogram, StateResidency, etc.
|
||||
uint8_t reserved; // must be zero
|
||||
uint16_t categories; // power, traffic, etc (omnibus obs.)
|
||||
uint16_t nelements; // internal size of channel
|
||||
|
||||
// only meaningful in the data pipeline
|
||||
int16_t element_idx; // 0..nelements-1
|
||||
// -1..-(nelements) = invalid (13127884)
|
||||
} __attribute((packed)) IOReportChannelType;
|
||||
|
||||
/*!
|
||||
* @define IOREPORT_MAKECHID
|
||||
* @abstract convert up to 8 printable characters into a 64-bit channel ID
|
||||
* @param <char0..char7> - printable chars to be packed into a channel ID
|
||||
* @result a 64-bit channel ID with an implicit ASCII name
|
||||
* @discussion A simple example:
|
||||
* IOREPORT_MAKECHID('H', 'i', ' ', 'w', 'o', 'r', 'l', 'd');
|
||||
* will evaluate to 0x686920776f726c64. Any NUL bytes are
|
||||
* ignored (by libIOReport) for naming purposes, but will
|
||||
* appear in the channel ID. Using a non-NUL non-printable
|
||||
* character will disable the implicit name. Putting NUL
|
||||
* bytes first eliminates trailing zeros when the channel
|
||||
* ID is printed as hex. For example:
|
||||
* IORERPORT_MAKECHID('\0','\0','n','x','f','e','r','s');
|
||||
* To see the text, use xxd -r -p # not -rp; see 12976241
|
||||
*/
|
||||
#define __IOR_lshiftchr(c, chshift) ((uint64_t)(c) << (8*(chshift)))
|
||||
#define IOREPORT_MAKEID(A, B, C, D, E, F, G, H) \
|
||||
(__IOR_lshiftchr(A, 7) | __IOR_lshiftchr(B, 6) | __IOR_lshiftchr(C, 5) \
|
||||
| __IOR_lshiftchr(D, 4) | __IOR_lshiftchr(E, 3) | __IOR_lshiftchr(F, 2) \
|
||||
| __IOR_lshiftchr(G, 1) | __IOR_lshiftchr(H, 0))
|
||||
|
||||
typedef struct {
|
||||
uint64_t channel_id;
|
||||
IOReportChannelType channel_type;
|
||||
} IOReportChannel;
|
||||
|
||||
typedef struct {
|
||||
uint32_t nchannels;
|
||||
IOReportChannel channels[];
|
||||
} IOReportChannelList;
|
||||
|
||||
typedef struct {
|
||||
uint64_t provider_id;
|
||||
IOReportChannel channel;
|
||||
} IOReportInterest;
|
||||
|
||||
typedef struct {
|
||||
uint32_t ninterests;
|
||||
IOReportInterest interests[];
|
||||
} IOReportInterestList;
|
||||
|
||||
typedef struct {
|
||||
uint64_t v[IOR_VALUES_PER_ELEMENT];
|
||||
} __attribute((packed)) IOReportElementValues;
|
||||
|
||||
typedef struct {
|
||||
uint64_t provider_id;
|
||||
uint64_t channel_id;
|
||||
IOReportChannelType channel_type;
|
||||
uint64_t timestamp;// mach_absolute_time()
|
||||
IOReportElementValues values;
|
||||
} __attribute((packed)) IOReportElement;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* IOReporting unit type and constants
|
||||
*/
|
||||
|
||||
// 1. Mechanism
|
||||
|
||||
// Assume encoded units could be stored in binary format: don't
|
||||
// change existing values.
|
||||
|
||||
typedef uint64_t IOReportUnit;
|
||||
typedef uint64_t IOReportUnits; // deprecated typo, please switch
|
||||
#define __IOR_MAKEUNIT(quantity, scale) \
|
||||
(((IOReportUnit)quantity << 56) | (uint64_t)scale)
|
||||
#define IOREPORT_GETUNIT_QUANTITY(unit) \
|
||||
((IOReportQuantity)((uint64_t)unit >> 56) & 0xff)
|
||||
#define IOREPORT_GETUNIT_SCALE(unit) \
|
||||
((IOReportScaleFactor)unit & 0x00ffffffffffffff)
|
||||
|
||||
// 8b quantity ID | 32b const val + 8b*2^10 + 8b*2^n | 8b cardinal | 8b unused
|
||||
typedef uint8_t IOReportQuantity; // SI "quantity" is what's measured
|
||||
typedef uint64_t IOReportScaleFactor;
|
||||
|
||||
// See <http://en.wikipedia.org/wiki/SI_base_unit> for a list
|
||||
// of quantities and their symbols.
|
||||
enum {
|
||||
// used by state reports, etc
|
||||
kIOReportQuantityUndefined = 0,
|
||||
|
||||
kIOReportQuantityTime = 1,// Seconds
|
||||
kIOReportQuantityPower = 2,// Watts
|
||||
kIOReportQuantityEnergy = 3,// Joules
|
||||
kIOReportQuantityCurrent = 4,// Amperes
|
||||
kIOReportQuantityVoltage = 5,// Volts
|
||||
kIOReportQuantityCapacitance = 6,// Farad
|
||||
kIOReportQuantityInductance = 7,// Henry
|
||||
kIOReportQuantityFrequency = 8,// Hertz
|
||||
kIOReportQuantityData = 9,// bits/bytes (see scale)
|
||||
kIOReportQuantityTemperature = 10,// Celsius (not Kelvin :)
|
||||
|
||||
kIOReportQuantityEventCount = 100,
|
||||
kIOReportQuantityPacketCount = 101,
|
||||
kIOReportQuantityCPUInstrs = 102
|
||||
};
|
||||
|
||||
|
||||
/* A number of units end up with both IEC (2^n) and SI (10^n) scale factors.
|
||||
* For example, the "MB" of a 1.44 MB floppy or a 1024MHz clock. We
|
||||
* thus support separate 2^n and 10^n factors. The exponent encoding
|
||||
* scheme is modeled loosely on single-precision IEEE 754.
|
||||
*/
|
||||
#define kIOReportScaleConstMask 0x000000007fffffff // constant ("uint31")
|
||||
#define kIOReportScaleOneOver (1LL << 31) // 1/constant
|
||||
#define kIOReportExpBase (-127) // support base^(-n)
|
||||
#define kIOReportExpZeroOffset -(kIOReportExpBase) // max exponent = 128
|
||||
#define kIOReportScaleSIShift 32 // * 10^n
|
||||
#define kIOReportScaleSIMask 0x000000ff00000000
|
||||
#define kIOReportScaleIECShift 40 // * 2^n
|
||||
#define kIOReportScaleIECMask 0x0000ff0000000000
|
||||
#define kIOReportCardinalShift 48 // placeholders
|
||||
#define kIOReportCardinalMask 0x00ff000000000000
|
||||
|
||||
|
||||
/*
|
||||
* Scales are described as a factor times unity:
|
||||
* 1ms = kIOReportScaleMilli * s
|
||||
*
|
||||
* A value expressed in a scaled unit can be scaled to unity via
|
||||
* multiplication by the constant:
|
||||
* 100ms * kIOReportScaleMilli [1e-3] = 0.1s.
|
||||
*/
|
||||
|
||||
// SI / decimal
|
||||
#define kIOReportScalePico ((-12LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleSIShift)
|
||||
#define kIOReportScaleNano ((-9LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleSIShift)
|
||||
#define kIOReportScaleMicro ((-6LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleSIShift)
|
||||
#define kIOReportScaleMilli ((-3LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleSIShift)
|
||||
#define kIOReportScaleUnity 0 // 10^0 = 2^0 = 1
|
||||
// unity = 0 is a special case for which we give up exp = -127
|
||||
#define kIOReportScaleKilo ((3LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleSIShift)
|
||||
#define kIOReportScaleMega ((6LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleSIShift)
|
||||
#define kIOReportScaleGiga ((9LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleSIShift)
|
||||
#define kIOReportScaleTera ((12LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleSIShift)
|
||||
|
||||
// IEC / computer / binary
|
||||
// It's not clear we'll ever use 2^(-n), but 1..2^~120 should suffice.
|
||||
#define kIOReportScaleBits kIOReportScaleUnity
|
||||
#define kIOReportScaleBytes ((3LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleIECShift)
|
||||
// (bytes have to be added to the exponents up front, can't just OR in)
|
||||
#define kIOReportScaleKibi ((10LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleIECShift)
|
||||
#define kIOReportScaleKiBytes ((13LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleIECShift)
|
||||
#define kIOReportScaleMebi ((20LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleIECShift)
|
||||
#define kIOReportScaleMiBytes ((23LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleIECShift)
|
||||
#define kIOReportScaleGibi ((30LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleIECShift)
|
||||
#define kIOReportScaleGiBytes ((33LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleIECShift)
|
||||
#define kIOReportScaleTebi ((40LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleIECShift)
|
||||
#define kIOReportScaleTiBytes ((43LL + kIOReportExpZeroOffset) \
|
||||
<< kIOReportScaleIECShift)
|
||||
// can't encode more than 2^125 (keeping bits & bytes inside -126..128)
|
||||
// Also, IOReportScaleValue() is currently limited internally by uint64_t.
|
||||
|
||||
|
||||
// Cardinal values, to be filled in appropriately.
|
||||
// Add values in increasing order.
|
||||
#define kIOReportScaleMachHWTicks (1LL << kIOReportCardinalShift)
|
||||
#define kIOReportScaleHWPageSize (2LL << kIOReportCardinalShift)
|
||||
|
||||
// page scales: 2 pages * 4ikB/page = 8096 bytes
|
||||
#define kIOReportScale4KiB (4 | kIOReportScaleKiBytes)
|
||||
#define kIOReportScale8KiB (8 | kIOReportScaleKiBytes)
|
||||
#define kIOReportScale16KiB (16 | kIOReportScaleKiBytes)
|
||||
|
||||
// Clock frequency scales (units add seconds).
|
||||
// 1 GHz ticks are 1 ns: 1000 ticks * 1e-6 = 1e-3s
|
||||
// This '1' is a no-op for scaling, but allows a custom label.
|
||||
#define kIOReportScale1GHz (1 | kIOReportScaleNano)
|
||||
// 24MHz ticks are 1/24 of a microsecond: (1/24 * kIOReportScaleMicro [1e-6])s
|
||||
// So for example, 240 24Mticks * 1/24 * 1e-6 = .00001s [1e-5]s
|
||||
#define kIOReportScale24MHz (kIOReportScaleOneOver|24 |kIOReportScaleMicro)
|
||||
|
||||
// --- END: units mechanism
|
||||
|
||||
|
||||
// 2. Unit constants
|
||||
#define kIOReportUnitNone __IOR_MAKEUNIT(kIOReportQuantityUndefined, \
|
||||
kIOReportScaleUnity)
|
||||
|
||||
#define kIOReportUnit_s __IOR_MAKEUNIT(kIOReportQuantityTime, \
|
||||
kIOReportScaleUnity)
|
||||
#define kIOReportUnit_ms __IOR_MAKEUNIT(kIOReportQuantityTime, \
|
||||
kIOReportScaleMilli)
|
||||
#define kIOReportUnit_us __IOR_MAKEUNIT(kIOReportQuantityTime, \
|
||||
kIOReportScaleMicro)
|
||||
#define kIOReportUnit_ns __IOR_MAKEUNIT(kIOReportQuantityTime, \
|
||||
kIOReportScaleNano)
|
||||
|
||||
#define kIOReportUnit_J __IOR_MAKEUNIT(kIOReportQuantityEnergy, \
|
||||
kIOReportScaleUnity)
|
||||
#define kIOReportUnit_mJ __IOR_MAKEUNIT(kIOReportQuantityEnergy, \
|
||||
kIOReportScaleMilli)
|
||||
#define kIOReportUnit_uJ __IOR_MAKEUNIT(kIOReportQuantityEnergy, \
|
||||
kIOReportScaleMicro)
|
||||
#define kIOReportUnit_nJ __IOR_MAKEUNIT(kIOReportQuantityEnergy, \
|
||||
kIOReportScaleNano)
|
||||
#define kIOReportUnit_pJ __IOR_MAKEUNIT(kIOReportQuantityEnergy, \
|
||||
kIOReportScalePico)
|
||||
|
||||
#define kIOReportUnitHWTicks __IOR_MAKEUNIT(kIOReportQuantityTime, \
|
||||
kIOReportScaleMachHWTicks)
|
||||
#define kIOReportUnit24MHzTicks __IOR_MAKEUNIT(kIOReportQuantityTime, \
|
||||
kIOReportScale24MHz)
|
||||
#define kIOReportUnit1GHzTicks __IOR_MAKEUNIT(kIOReportQuantityTime, \
|
||||
kIOReportScale1GHz)
|
||||
|
||||
#define kIOReportUnitBits __IOR_MAKEUNIT(kIOReportQuantityData, \
|
||||
kIOReportScaleBits)
|
||||
#define kIOReportUnitBytes __IOR_MAKEUNIT(kIOReportQuantityData, \
|
||||
kIOReportScaleBytes)
|
||||
#define kIOReportUnit_KiB __IOR_MAKEUNIT(kIOReportQuantityData, \
|
||||
kIOReportScaleKiBytes)
|
||||
#define kIOReportUnit_MiB __IOR_MAKEUNIT(kIOReportQuantityData, \
|
||||
kIOReportScaleMiBytes)
|
||||
#define kIOReportUnit_GiB __IOR_MAKEUNIT(kIOReportQuantityData, \
|
||||
kIOReportScaleGiBytes)
|
||||
#define kIOReportUnit_TiB __IOR_MAKEUNIT(kIOReportQuantityData, \
|
||||
kIOReportScaleTiBytes)
|
||||
|
||||
#define kIOReportUnitEvents __IOR_MAKEUNIT(kIOReportQuantityEventCount, \
|
||||
kIOReportScaleUnity)
|
||||
|
||||
#define kIOReportUnitPackets __IOR_MAKEUNIT(kIOReportQuantityPacketCount, \
|
||||
kIOReportScaleUnity)
|
||||
|
||||
#define kIOReportUnitInstrs __IOR_MAKEUNIT(kIOReportQuantityCPUInstrs, \
|
||||
kIOReportScaleUnity)
|
||||
#define kIOReportUnit_KI __IOR_MAKEUNIT(kIOReportQuantityCPUInstrs, \
|
||||
kIOReportScaleKilo)
|
||||
#define kIOReportUnit_MI __IOR_MAKEUNIT(kIOReportQuantityCPUInstrs, \
|
||||
kIOReportScaleMega)
|
||||
#define kIOReportUnit_GI __IOR_MAKEUNIT(kIOReportQuantityCPUInstrs, \
|
||||
kIOReportScaleGiga)
|
||||
|
||||
// Please file bugs (xnu | IOReporting) for additional units.
|
||||
|
||||
// --- END: unit constants
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _IOREPORT_TYPES_H_
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Released under "The BSD 3-Clause License"
|
||||
*
|
||||
* Copyright (c) 2021 cjiang. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The names of its contributors may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IOREPORTUSERCLIENT_H
|
||||
#define _IOKIT_IOREPORTUSERCLIENT_H
|
||||
|
||||
#include <IOKit/IOUserClient.h>
|
||||
#include <IOKit/IOReportHub.h>
|
||||
|
||||
class IOReportUserClient : public IOUserClient
|
||||
{
|
||||
OSDeclareDefaultStructors(IOReportUserClient)
|
||||
|
||||
public:
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_5
|
||||
virtual IOReturn externalMethod(uint32_t selector, IOExternalMethodArguments * arguments, IOExternalMethodDispatch * dispatch = NULL, OSObject * target = NULL, void * reference = NULL) APPLE_KEXT_OVERRIDE;
|
||||
#endif
|
||||
|
||||
virtual bool init( OSDictionary * dictionary ) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool initWithTask( task_t owningTask, void * securityToken, UInt32 type ) APPLE_KEXT_OVERRIDE;
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
virtual bool start( IOService * provider ) APPLE_KEXT_OVERRIDE;
|
||||
virtual bool stop( IOService * provider ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOReturn clientClose() APPLE_KEXT_OVERRIDE;
|
||||
virtual IOService * getService() APPLE_KEXT_OVERRIDE;
|
||||
virtual IOReturn clientMemoryForType( UInt32 type, IOOptionBits * options, IOMemoryDescriptor ** memory ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOReturn open( IOOptionBits options );
|
||||
virtual IOReturn close();
|
||||
|
||||
static IOReturn _open( IOReportUserClient *, void *, IOExternalMethodArguments * );
|
||||
static IOReturn _close( IOReportUserClient *, void *, IOExternalMethodArguments * );
|
||||
static IOReturn goto_configureInterests( IOReportUserClient *, void *, IOExternalMethodArguments * );
|
||||
static IOReturn goto_getValues( IOReportUserClient *, void *, IOExternalMethodArguments * );
|
||||
IOReturn _configureInterests( IOReportInterestList *, IOByteCount * );
|
||||
IOReturn _getInterests( IOByteCount, OSDictionary **, IOBufferMemoryDescriptor ** );
|
||||
IOReturn _getValues( IOByteCount );
|
||||
|
||||
protected:
|
||||
IOOptionBits mHubOptions;
|
||||
task_t mOwningTask;
|
||||
IOReportHub * mHub;
|
||||
IOLock * mHubLock;
|
||||
OSArray * mReportDictionaryArray;
|
||||
OSArray * mSubscriptionBufferArray;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2002 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
*/
|
||||
|
||||
/*
|
||||
* Core IOReturn values. Others may be family defined.
|
||||
*/
|
||||
|
||||
#ifndef __IOKIT_IORETURN_H
|
||||
#define __IOKIT_IORETURN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include <mach/error.h>
|
||||
|
||||
|
||||
typedef kern_return_t IOReturn;
|
||||
|
||||
#ifndef sys_iokit
|
||||
#define sys_iokit err_system(0x38)
|
||||
#endif /* sys_iokit */
|
||||
#define sub_iokit_common err_sub(0)
|
||||
#define sub_iokit_usb err_sub(1)
|
||||
#define sub_iokit_firewire err_sub(2)
|
||||
#define sub_iokit_block_storage err_sub(4)
|
||||
#define sub_iokit_graphics err_sub(5)
|
||||
#define sub_iokit_networking err_sub(6)
|
||||
#define sub_iokit_bluetooth err_sub(8)
|
||||
#define sub_iokit_pmu err_sub(9)
|
||||
#define sub_iokit_acpi err_sub(10)
|
||||
#define sub_iokit_smbus err_sub(11)
|
||||
#define sub_iokit_ahci err_sub(12)
|
||||
#define sub_iokit_powermanagement err_sub(13)
|
||||
#define sub_iokit_hidsystem err_sub(14)
|
||||
#define sub_iokit_scsi err_sub(16)
|
||||
#define sub_iokit_usbaudio err_sub(17)
|
||||
#define sub_iokit_wirelesscharging err_sub(18)
|
||||
//#define sub_iokit_pccard err_sub(21)
|
||||
#define sub_iokit_thunderbolt err_sub(29)
|
||||
#define sub_iokit_graphics_acceleration err_sub(30)
|
||||
#define sub_iokit_keystore err_sub(31)
|
||||
#define sub_iokit_apfs err_sub(33)
|
||||
#define sub_iokit_acpiec err_sub(34)
|
||||
#define sub_iokit_timesync_avb err_sub(35)
|
||||
|
||||
#define sub_iokit_platform err_sub(0x2A)
|
||||
#define sub_iokit_audio_video err_sub(0x45)
|
||||
#define sub_iokit_cec err_sub(0x46)
|
||||
#define sub_iokit_baseband err_sub(0x80)
|
||||
#define sub_iokit_HDA err_sub(0xFE)
|
||||
#define sub_iokit_hsic err_sub(0x147)
|
||||
#define sub_iokit_sdio err_sub(0x174)
|
||||
#define sub_iokit_wlan err_sub(0x208)
|
||||
#define sub_iokit_appleembeddedsleepwakehandler err_sub(0x209)
|
||||
#define sub_iokit_appleppm err_sub(0x20A)
|
||||
|
||||
#define sub_iokit_vendor_specific err_sub(-2)
|
||||
#define sub_iokit_reserved err_sub(-1)
|
||||
|
||||
#define iokit_common_err(return ) (sys_iokit|sub_iokit_common|return)
|
||||
#define iokit_family_err(sub, return ) (sys_iokit|sub|return)
|
||||
#define iokit_vendor_specific_err(return ) (sys_iokit|sub_iokit_vendor_specific|return)
|
||||
|
||||
#define kIOReturnSuccess KERN_SUCCESS // OK
|
||||
#define kIOReturnError iokit_common_err(0x2bc) // general error
|
||||
#define kIOReturnNoMemory iokit_common_err(0x2bd) // can't allocate memory
|
||||
#define kIOReturnNoResources iokit_common_err(0x2be) // resource shortage
|
||||
#define kIOReturnIPCError iokit_common_err(0x2bf) // error during IPC
|
||||
#define kIOReturnNoDevice iokit_common_err(0x2c0) // no such device
|
||||
#define kIOReturnNotPrivileged iokit_common_err(0x2c1) // privilege violation
|
||||
#define kIOReturnBadArgument iokit_common_err(0x2c2) // invalid argument
|
||||
#define kIOReturnLockedRead iokit_common_err(0x2c3) // device read locked
|
||||
#define kIOReturnLockedWrite iokit_common_err(0x2c4) // device write locked
|
||||
#define kIOReturnExclusiveAccess iokit_common_err(0x2c5) // exclusive access and
|
||||
// device already open
|
||||
#define kIOReturnBadMessageID iokit_common_err(0x2c6) // sent/received messages
|
||||
// had different msg_id
|
||||
#define kIOReturnUnsupported iokit_common_err(0x2c7) // unsupported function
|
||||
#define kIOReturnVMError iokit_common_err(0x2c8) // misc. VM failure
|
||||
#define kIOReturnInternalError iokit_common_err(0x2c9) // internal error
|
||||
#define kIOReturnIOError iokit_common_err(0x2ca) // General I/O error
|
||||
//#define kIOReturn???Error iokit_common_err(0x2cb) // ???
|
||||
#define kIOReturnCannotLock iokit_common_err(0x2cc) // can't acquire lock
|
||||
#define kIOReturnNotOpen iokit_common_err(0x2cd) // device not open
|
||||
#define kIOReturnNotReadable iokit_common_err(0x2ce) // read not supported
|
||||
#define kIOReturnNotWritable iokit_common_err(0x2cf) // write not supported
|
||||
#define kIOReturnNotAligned iokit_common_err(0x2d0) // alignment error
|
||||
#define kIOReturnBadMedia iokit_common_err(0x2d1) // Media Error
|
||||
#define kIOReturnStillOpen iokit_common_err(0x2d2) // device(s) still open
|
||||
#define kIOReturnRLDError iokit_common_err(0x2d3) // rld failure
|
||||
#define kIOReturnDMAError iokit_common_err(0x2d4) // DMA failure
|
||||
#define kIOReturnBusy iokit_common_err(0x2d5) // Device Busy
|
||||
#define kIOReturnTimeout iokit_common_err(0x2d6) // I/O Timeout
|
||||
#define kIOReturnOffline iokit_common_err(0x2d7) // device offline
|
||||
#define kIOReturnNotReady iokit_common_err(0x2d8) // not ready
|
||||
#define kIOReturnNotAttached iokit_common_err(0x2d9) // device not attached
|
||||
#define kIOReturnNoChannels iokit_common_err(0x2da) // no DMA channels left
|
||||
#define kIOReturnNoSpace iokit_common_err(0x2db) // no space for data
|
||||
//#define kIOReturn???Error iokit_common_err(0x2dc) // ???
|
||||
#define kIOReturnPortExists iokit_common_err(0x2dd) // port already exists
|
||||
#define kIOReturnCannotWire iokit_common_err(0x2de) // can't wire down
|
||||
// physical memory
|
||||
#define kIOReturnNoInterrupt iokit_common_err(0x2df) // no interrupt attached
|
||||
#define kIOReturnNoFrames iokit_common_err(0x2e0) // no DMA frames enqueued
|
||||
#define kIOReturnMessageTooLarge iokit_common_err(0x2e1) // oversized msg received
|
||||
// on interrupt port
|
||||
#define kIOReturnNotPermitted iokit_common_err(0x2e2) // not permitted
|
||||
#define kIOReturnNoPower iokit_common_err(0x2e3) // no power to device
|
||||
#define kIOReturnNoMedia iokit_common_err(0x2e4) // media not present
|
||||
#define kIOReturnUnformattedMedia iokit_common_err(0x2e5)// media not formatted
|
||||
#define kIOReturnUnsupportedMode iokit_common_err(0x2e6) // no such mode
|
||||
#define kIOReturnUnderrun iokit_common_err(0x2e7) // data underrun
|
||||
#define kIOReturnOverrun iokit_common_err(0x2e8) // data overrun
|
||||
#define kIOReturnDeviceError iokit_common_err(0x2e9) // the device is not working properly!
|
||||
#define kIOReturnNoCompletion iokit_common_err(0x2ea) // a completion routine is required
|
||||
#define kIOReturnAborted iokit_common_err(0x2eb) // operation aborted
|
||||
#define kIOReturnNoBandwidth iokit_common_err(0x2ec) // bus bandwidth would be exceeded
|
||||
#define kIOReturnNotResponding iokit_common_err(0x2ed) // device not responding
|
||||
#define kIOReturnIsoTooOld iokit_common_err(0x2ee) // isochronous I/O request for distant past!
|
||||
#define kIOReturnIsoTooNew iokit_common_err(0x2ef) // isochronous I/O request for distant future
|
||||
#define kIOReturnNotFound iokit_common_err(0x2f0) // data was not found
|
||||
#define kIOReturnInvalid iokit_common_err(0x1) // should never be seen
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ! __IOKIT_IORETURN_H */
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef RE_APPLE_IOSMBUSCONTROLLER_H
|
||||
#define RE_APPLE_IOSMBUSCONTROLLER_H
|
||||
|
||||
// This header represents a mostly valid IOSMBusController class implementation useful for our needs.
|
||||
// Compatible with macOS 10.13.5. Based on PureDarwin header:
|
||||
// https://raw.githubusercontent.com/PureDarwin/PureDarwin/master/patches/PowerManagement-158.10.9.IOSmbusController.p1.patch
|
||||
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/IOCommand.h>
|
||||
#include <IOKit/IOCommandGate.h>
|
||||
|
||||
// SMBus Status register type
|
||||
typedef uint8_t IOSMBusStatus;
|
||||
|
||||
// Status Register (SMB_STS) Codes
|
||||
// See section 12.9.1.1 of ACPI 4.0a specification
|
||||
enum : IOSMBusStatus {
|
||||
kIOSMBusStatusOK = 0x00,
|
||||
kIOSMBusStatusUnknownFailure = 0x07,
|
||||
kIOSMBusStatusDeviceAddressNotAcknowledged = 0x10,
|
||||
kIOSMBusStatusDeviceError = 0x11,
|
||||
kIOSMBusStatusDeviceCommandAccessDenied = 0x12,
|
||||
kIOSMBusStatusUnknownHostError = 0x13,
|
||||
kIOSMBusStatusDeviceAccessDenied = 0x17,
|
||||
kIOSMBusStatusTimeout = 0x18,
|
||||
kIOSMBusStatusHostUnsupportedProtocol = 0x19,
|
||||
kIOSMBusStatusBusy = 0x1A,
|
||||
kIOSMBusStatusPECError = 0x1F,
|
||||
};
|
||||
|
||||
// Protocol Register (SMB_PRTCL) Types
|
||||
// See section 12.9.1.2 of ACPI 4.0a specification
|
||||
enum {
|
||||
kIOSMBusProtocolControllerNotInUse = 0x00,
|
||||
kIOSMBusProtocolReserved = 0x01,
|
||||
kIOSMBusProtocolWriteQuickCommand = 0x02,
|
||||
kIOSMBusProtocolReadQuickCommand = 0x03,
|
||||
kIOSMBusProtocolSendByte = 0x04,
|
||||
kIOSMBusProtocolReceiveByte = 0x05,
|
||||
kIOSMBusProtocolWriteByte = 0x06,
|
||||
kIOSMBusProtocolReadByte = 0x07,
|
||||
kIOSMBusProtocolWriteWord = 0x08,
|
||||
kIOSMBusProtocolReadWord = 0x09,
|
||||
kIOSMBusProtocolWriteBlock = 0x0A,
|
||||
kIOSMBusProtocolReadBlock = 0x0B,
|
||||
kIOSMBusProtocolProcessCall = 0x0C,
|
||||
kIOSMBusProtocolBlockWriteBlockReadProcessCall = 0x0D,
|
||||
|
||||
// Same as above but with (P)acket (E)rror (C)hecking enabled
|
||||
kIOSMBusProtocolPECControllerNotInUse = 0x80,
|
||||
kIOSMBusProtocolPECReserved = 0x81,
|
||||
kIOSMBusProtocolPECWriteQuickCommand = 0x82,
|
||||
kIOSMBusProtocolPECReadQuickCommand = 0x83,
|
||||
kIOSMBusProtocolPECSendByte = 0x84,
|
||||
kIOSMBusProtocolPECReceiveByte = 0x85,
|
||||
kIOSMBusProtocolPECWriteByte = 0x86,
|
||||
kIOSMBusProtocolPECReadByte = 0x87,
|
||||
kIOSMBusProtocolPECWriteWord = 0x88,
|
||||
kIOSMBusProtocolPECReadWord = 0x89,
|
||||
kIOSMBusProtocolPECWriteBlock = 0x8A,
|
||||
kIOSMBusProtocolPECReadBlock = 0x8B,
|
||||
kIOSMBusProtocolPECProcessCall = 0x8C,
|
||||
kIOSMBusProtocolPECBlockWriteBlockReadProcessCall = 0x8D,
|
||||
};
|
||||
|
||||
// SMBus alarm message type
|
||||
enum {
|
||||
kIOMessageSMBusAlarm = iokit_family_msg(sub_iokit_smbus, 0x10),
|
||||
};
|
||||
|
||||
static_assert(kIOMessageSMBusAlarm == 0xE002C010, "Invalid kIOMessageSMBusAlarm value");
|
||||
|
||||
// See section 12.9.1.7 of ACPI 4.0a specification
|
||||
static constexpr size_t kSMBusAlarmDataSize = 2;
|
||||
|
||||
struct IOSMBusAlarmMessage {
|
||||
uint8_t fromAddress;
|
||||
uint8_t data[kSMBusAlarmDataSize];
|
||||
};
|
||||
|
||||
// Maximum size of SMBus Data Register Array (SMB_DATA)
|
||||
// See section 12.9.1.5 of ACPI 4.0a specification
|
||||
static constexpr size_t kSMBusMaximumDataSize = 32;
|
||||
|
||||
// Holds data related to a SMBus transaction
|
||||
// Padding required for 32-bit as 64-bit integers are normally not aligned to 8 bytes
|
||||
struct IOSMBusTransaction {
|
||||
uint8_t address;
|
||||
uint8_t command;
|
||||
uint8_t protocol;
|
||||
uint8_t pad1[5];
|
||||
uint64_t timeout;
|
||||
uint32_t sendDataCount;
|
||||
uint8_t sendData[kSMBusMaximumDataSize];
|
||||
IOSMBusStatus status;
|
||||
uint32_t receiveDataCount;
|
||||
uint8_t receiveData[kSMBusMaximumDataSize];
|
||||
uint32_t pad2;
|
||||
};
|
||||
|
||||
static_assert(sizeof(IOSMBusTransaction) == 0x60, "Invalid IOSMBusTransaction size");
|
||||
#if defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 5 || __GNUC__ > 3)
|
||||
static_assert(offsetof(IOSMBusTransaction, timeout) == 0x08, "Invalid IOSMBusTransaction::timeout offset");
|
||||
static_assert(offsetof(IOSMBusTransaction, sendDataCount) == 0x10, "Invalid IOSMBusTransaction::sendDataCount offset");
|
||||
static_assert(offsetof(IOSMBusTransaction, sendData) == 0x14, "Invalid IOSMBusTransaction::sendData offset");
|
||||
static_assert(offsetof(IOSMBusTransaction, receiveDataCount) == 0x38, "Invalid IOSMBusTransaction::receiveDataCount offset");
|
||||
static_assert(offsetof(IOSMBusTransaction, receiveData) == 0x3C, "Invalid IOSMBusTransaction::receiveData offset");
|
||||
#endif
|
||||
|
||||
// Transaction completion callback
|
||||
typedef void (*IOSMBusTransactionCompletion)(OSObject *target, void *reference, IOSMBusTransaction *transaction);
|
||||
|
||||
// Transaction request for later execution.
|
||||
//TODO: complete the fields.
|
||||
class IOSMBusRequest : public IOCommand {
|
||||
OSDeclareDefaultStructors(IOSMBusRequest)
|
||||
public:
|
||||
queue_chain_t requestChain;
|
||||
IOSMBusTransaction *transaction;
|
||||
IOSMBusTransactionCompletion completionHandler;
|
||||
OSObject *completionHandlerInstance;
|
||||
void *completionHandlerArgument;
|
||||
void *unknown[6];
|
||||
};
|
||||
|
||||
static_assert(sizeof(IOSMBusRequest) == (0x10 * sizeof(uintptr_t)), "Invalid IOSMBusRequest size"); // 0x80 on 64-bit
|
||||
|
||||
// Main SMBus controller base class.
|
||||
class IOACPIPlatformDevice;
|
||||
class IOSMBusController : public IOService {
|
||||
OSDeclareDefaultStructors(IOSMBusController)
|
||||
public:
|
||||
virtual IOReturn performTransaction(IOSMBusTransaction *transaction, IOSMBusTransactionCompletion completion = 0,
|
||||
OSObject *target = 0, void *reference = 0);
|
||||
virtual IOSMBusRequest *createRequest();
|
||||
virtual IOSMBusStatus startRequest(IOSMBusRequest *request);
|
||||
virtual IOSMBusStatus completeRequest(IOSMBusRequest *request);
|
||||
virtual IOSMBusStatus sendAlarm(IOSMBusAlarmMessage *alarmMessage);
|
||||
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 10);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 11);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 12);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 13);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 14);
|
||||
OSMetaClassDeclareReservedUnused(IOSMBusController, 15);
|
||||
|
||||
public:
|
||||
//FIXME: This is roughly unknown and incomplete.
|
||||
void *fPrivateUnknown;
|
||||
IOCommandGate *fPrivateCommandGate;
|
||||
queue_chain_t fPrivateCommandQueue;
|
||||
void *fPrivateUnknown2[5];
|
||||
};
|
||||
|
||||
#if defined(__i386__)
|
||||
static_assert(sizeof(IOSMBusController) == 0x74, "Invalid 32-bit IOSMBusController size");
|
||||
#if defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 5 || __GNUC__ > 3)
|
||||
static_assert(offsetof(IOSMBusController, fPrivateCommandGate) == 0x54, "Invalid 32-bit IOSMBusController::fCommandGate offset");
|
||||
static_assert(offsetof(IOSMBusController, fPrivateCommandQueue) == 0x58, "Invalid 32-bit IOSMBusController::fCommandQueue offset");
|
||||
#endif
|
||||
|
||||
#elif defined(__x86_64__)
|
||||
static_assert(sizeof(IOSMBusController) == 0xD0, "Invalid 64-bit IOSMBusController size");
|
||||
#if defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 5 || __GNUC__ > 3)
|
||||
static_assert(offsetof(IOSMBusController, fPrivateCommandGate) == 0x90, "Invalid 64-bit IOSMBusController::fCommandGate offset");
|
||||
static_assert(offsetof(IOSMBusController, fPrivateCommandQueue) == 0x98, "Invalid 64-bit IOSMBusController::fCommandQueue offset");
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error Unsupported arch
|
||||
#endif
|
||||
|
||||
#endif /* RE_APPLE_IOSMBUSCONTROLLER_H */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IOSERVICEPM_H
|
||||
#define _IOKIT_IOSERVICEPM_H
|
||||
|
||||
#include <IOKit/pwr_mgt/IOPM.h>
|
||||
|
||||
class IOService;
|
||||
class IOServicePM;
|
||||
class IOPowerConnection;
|
||||
class IOWorkLoop;
|
||||
class IOCommandGate;
|
||||
class IOTimerEventSource;
|
||||
class IOPlatformExpert;
|
||||
|
||||
#endif /* !_IOKIT_IOSERVICEPM_H */
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IOSHAREDDATAQUEUE_H
|
||||
#define _IOKIT_IOSHAREDDATAQUEUE_H
|
||||
|
||||
#define DISABLE_DATAQUEUE_WARNING /* IODataQueue is deprecated, please use IOSharedDataQueue instead */
|
||||
|
||||
#include <IOKit/IODataQueue.h>
|
||||
|
||||
#undef DISABLE_DATAQUEUE_WARNING
|
||||
|
||||
typedef struct _IODataQueueEntry IODataQueueEntry;
|
||||
|
||||
/*!
|
||||
* @class IOSharedDataQueue : public IODataQueue
|
||||
* @abstract A generic queue designed to pass data both from the kernel to a user process and from a user process to the kernel.
|
||||
* @discussion The IOSharedDataQueue class is designed to also allow a user process to queue data to kernel code. IOSharedDataQueue objects are designed to be used in a single producer / single consumer situation. As such, there are no locks on the data itself. Because the kernel enqueue and user-space dequeue methods follow a strict set of guidelines, no locks are necessary to maintain the integrity of the data struct.
|
||||
*
|
||||
* <br>Each data entry can be variable sized, but the entire size of the queue data region (including overhead for each entry) must be specified up front.
|
||||
*
|
||||
* <br>In order for the IODataQueue instance to notify the user process that data is available, a notification mach port must be set. When the queue is empty and a new entry is added, a message is sent to the specified port.
|
||||
*
|
||||
* <br>In order to make the data queue memory available to a user process, the method getMemoryDescriptor() must be used to get an IOMemoryDescriptor instance that can be mapped into a user process. Typically, the clientMemoryForType() method on an IOUserClient instance will be used to request the IOMemoryDescriptor and then return it to be mapped into the user process.
|
||||
*/
|
||||
class IOSharedDataQueue : public IODataQueue
|
||||
{
|
||||
OSDeclareDefaultStructors(IOSharedDataQueue);
|
||||
|
||||
struct ExpansionData {
|
||||
UInt32 queueSize;
|
||||
};
|
||||
/*! @var reserved
|
||||
* Reserved for future use. (Internal use only) */
|
||||
ExpansionData * _reserved;
|
||||
|
||||
protected:
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*!
|
||||
* @function getQueueSize
|
||||
* @abstract Returns the size of the data queue.
|
||||
* @discussion Use this method to access the size of the data queue. Do not access the value of size directly, as it can get modified from userspace and is not reliable.
|
||||
* @result Returns the size of the data queue, or zero in case of failure.
|
||||
*/
|
||||
UInt32 getQueueSize();
|
||||
|
||||
/*!
|
||||
* @function setQueueSize
|
||||
* @abstract Stores the value of the size of the data queue.
|
||||
* @discussion Use this method to store the value of the size of the data queue. Do not access the value of size directly, as it can get modified from userspace and is not reliable.
|
||||
* @param size The size of the data queue.
|
||||
* @result Returns true in case of success, false otherwise.
|
||||
*/
|
||||
Boolean setQueueSize(UInt32 size);
|
||||
|
||||
public:
|
||||
/*!
|
||||
* @function withCapacity
|
||||
* @abstract Static method that creates a new IOSharedDataQueue instance with the capacity specified in the size parameter.
|
||||
* @discussion The actual size of the entire data queue memory region (to be shared into a user process) is equal to the capacity plus the IODataQueueMemory overhead. This overhead value can be determined from the DATA_QUEUE_MEMORY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>. The size of the data queue memory region must include space for the overhead of each IODataQueueEntry. This entry overhead can be determined from the DATA_QUEUE_ENTRY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>.<br> This method allocates a new IODataQueue instance and then calls initWithCapacity() with the given size parameter. If the initWithCapacity() fails, the new instance is released and zero is returned.
|
||||
* @param size The size of the data queue memory region.
|
||||
* @result Returns the newly allocated IOSharedDataQueue instance. Zero is returned on failure.
|
||||
*/
|
||||
static IOSharedDataQueue *withCapacity(UInt32 size);
|
||||
|
||||
/*!
|
||||
* @function withEntries
|
||||
* @abstract Static method that creates a new IOSharedDataQueue instance with the specified number of entries of the given size.
|
||||
* @discussion This method will create a new IOSharedDataQueue instance with enough capacity for numEntries of entrySize. It does account for the IODataQueueEntry overhead for each entry. Note that the numEntries and entrySize are simply used to determine the data region size. They do not actually restrict the size of number of entries that can be added to the queue.<br> This method allocates a new IODataQueue instance and then calls initWithEntries() with the given numEntries and entrySize parameters. If the initWithEntries() fails, the new instance is released and zero is returned.
|
||||
* @param numEntries Number of entries to allocate space for.
|
||||
* @param entrySize Size of each entry.
|
||||
* @result Reeturns the newly allocated IOSharedDataQueue instance. Zero is returned on failure.
|
||||
*/
|
||||
static IOSharedDataQueue *withEntries(UInt32 numEntries, UInt32 entrySize);
|
||||
|
||||
/*!
|
||||
* @function initWithCapacity
|
||||
* @abstract Initializes an IOSharedDataQueue instance with the capacity specified in the size parameter.
|
||||
* @discussion The actual size of the entire data queue memory region (to be shared into a user process) is equal to the capacity plus the IODataQueueMemory overhead. This overhead value can be determined from the DATA_QUEUE_MEMORY_HEADER_SIZE and DATA_QUEUE_MEMORY_APPENDIX_SIZE macro in <IOKit/IODataQueueShared.h>. The size of the data queue memory region must include space for the overhead of each IODataQueueEntry. This entry overhead can be determined from the DATA_QUEUE_ENTRY_HEADER_SIZE macro in <IOKit/IODataQueueShared.h>.
|
||||
* @param size The size of the data queue memory region.
|
||||
* @result Returns true on success and false on failure.
|
||||
*/
|
||||
virtual Boolean initWithCapacity(UInt32 size) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*!
|
||||
* @function getMemoryDescriptor
|
||||
* @abstract Returns a memory descriptor covering the IODataQueueMemory region.
|
||||
* @discussion The IOMemoryDescriptor instance returned by this method is intended to be mapped into a user process. This is the memory region that the IODataQueueClient code operates on.
|
||||
* @result Returns a newly allocated IOMemoryDescriptor for the IODataQueueMemory region. Returns zero on failure.
|
||||
*/
|
||||
virtual IOMemoryDescriptor *getMemoryDescriptor() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*!
|
||||
* @function peek
|
||||
* @abstract Used to peek at the next entry on the queue.
|
||||
* @discussion This function can be used to look at the next entry which allows the entry to be received without having to copy it with dequeue. In order to do this, call peek to get the entry. Then call dequeue with a NULL data pointer. That will cause the head to be moved to the next entry, but no memory to be copied.
|
||||
* @result Returns a pointer to the next IODataQueueEntry if one is available. 0 (NULL) is returned if the queue is empty.
|
||||
*/
|
||||
virtual IODataQueueEntry * peek();
|
||||
|
||||
/*!
|
||||
* @function dequeue
|
||||
* @abstract Dequeues the next available entry on the queue and copies it into the given data pointer.
|
||||
* @discussion This function will dequeue the next available entry on the queue. If a data pointer is provided, it will copy the data into the memory region if there is enough space available as specified in the dataSize parameter. If no data pointer is provided, it will simply move the head value past the current entry.
|
||||
* @param data A pointer to the data memory region in which to copy the next entry data on the queue. If this parameter is 0 (NULL), it will simply move to the next entry.
|
||||
* @param dataSize A pointer to the size of the data parameter. On return, this contains the size of the actual entry data - even if the original size was not large enough.
|
||||
* @result Returns true on success and false on failure. Typically failure means that the queue is empty.
|
||||
*/
|
||||
virtual Boolean dequeue(void *data, UInt32 *dataSize);
|
||||
|
||||
/*!
|
||||
* @function enqueue
|
||||
* @abstract Enqueues a new entry on the queue.
|
||||
* @discussion This method adds a new data entry of dataSize to the queue. It sets the size parameter of the entry pointed to by the tail value and copies the memory pointed to by the data parameter in place in the queue. Once that is done, it moves the tail to the next available location. When attempting to add a new entry towards the end of the queue and there isn't enough space at the end, it wraps back to the beginning.<br> If the queue is empty when a new entry is added, sendDataAvailableNotification() is called to send a message to the user process that data is now available.
|
||||
* @param data Pointer to the data to be added to the queue.
|
||||
* @param dataSize Size of the data pointed to by data.
|
||||
* @result Returns true on success and false on failure. Typically failure means that the queue is full.
|
||||
*/
|
||||
virtual Boolean enqueue(void *data, UInt32 dataSize) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
|
||||
#if APPLE_KEXT_VTABLE_PADDING
|
||||
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOSharedDataQueue, 7);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* _IOKIT_IOSHAREDDATAQUEUE_H */
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2010 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IOSHAREDLOCK_H
|
||||
#define _IOKIT_IOSHAREDLOCK_H
|
||||
|
||||
#include <libkern/OSAtomic.h>
|
||||
|
||||
#define IOSharedLockData OSSpinLock
|
||||
#define ev_lock_data_t OSSpinLock
|
||||
|
||||
#define ev_unlock(l) OSSpinLockUnlock(l)
|
||||
#define ev_try_lock(l) OSSpinLockTry(l)
|
||||
|
||||
#endif /* ! _IOKIT_IOSHAREDLOCK_H */
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOSUBMEMORYDESCRIPTOR_H
|
||||
#define _IOSUBMEMORYDESCRIPTOR_H
|
||||
|
||||
#include <IOKit/IOMemoryDescriptor.h>
|
||||
|
||||
/*! @class IOSubMemoryDescriptor : public IOMemoryDescriptor
|
||||
* @abstract The IOSubMemoryDescriptor object describes a memory area made up of a portion of another IOMemoryDescriptor.
|
||||
* @discussion The IOSubMemoryDescriptor object represents a subrange of memory, specified as a portion of another IOMemoryDescriptor. */
|
||||
|
||||
class IOSubMemoryDescriptor : public IOMemoryDescriptor
|
||||
{
|
||||
OSDeclareDefaultStructors(IOSubMemoryDescriptor);
|
||||
|
||||
protected:
|
||||
IOMemoryDescriptor * _parent;
|
||||
IOByteCount _start;
|
||||
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
public:
|
||||
/*! @function withSubRange
|
||||
* @abstract Create an IOMemoryDescriptor to describe a subrange of an existing descriptor.
|
||||
* @discussion This method creates and initializes an IOMemoryDescriptor for memory consisting of a subrange of the specified memory descriptor. The parent memory descriptor is retained by the new descriptor.
|
||||
* @param of The parent IOMemoryDescriptor of which a subrange is to be used for the new descriptor, which will be retained by the subrange IOMemoryDescriptor.
|
||||
* @param offset A byte offset into the parent memory descriptor's memory.
|
||||
* @param length The length of the subrange.
|
||||
* @param options
|
||||
* kIOMemoryDirectionMask (options:direction) This nibble indicates the I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
|
||||
* @result The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure. */
|
||||
|
||||
static IOSubMemoryDescriptor * withSubRange(IOMemoryDescriptor *of,
|
||||
IOByteCount offset,
|
||||
IOByteCount length,
|
||||
IOOptionBits options);
|
||||
|
||||
/*
|
||||
* Initialize or reinitialize an IOSubMemoryDescriptor to describe
|
||||
* a subrange of an existing descriptor.
|
||||
*
|
||||
* An IOSubMemoryDescriptor can be re-used by calling initSubRange
|
||||
* again on an existing instance -- note that this behavior is not
|
||||
* commonly supported in other IOKit classes, although it is here.
|
||||
*/
|
||||
virtual bool initSubRange( IOMemoryDescriptor * parent,
|
||||
IOByteCount offset, IOByteCount length,
|
||||
IODirection withDirection );
|
||||
|
||||
/*
|
||||
* IOMemoryDescriptor required methods
|
||||
*/
|
||||
|
||||
virtual addr64_t getPhysicalSegment( IOByteCount offset,
|
||||
IOByteCount * length,
|
||||
IOOptionBits options = 0 ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOReturn prepare(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOReturn complete(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
#ifdef __LP64__
|
||||
virtual IOReturn redirect( task_t safeTask, bool redirect ) APPLE_KEXT_OVERRIDE;
|
||||
#else
|
||||
IOReturn redirect( task_t safeTask, bool redirect );
|
||||
#endif /* __LP64__ */
|
||||
|
||||
virtual IOReturn setPurgeable( IOOptionBits newState,
|
||||
IOOptionBits * oldState ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
IOReturn setOwnership( task_t newOwner,
|
||||
int newLedgerTag,
|
||||
IOOptionBits newLedgerOptions );
|
||||
|
||||
// support map() on kIOMemoryTypeVirtual without prepare()
|
||||
virtual IOMemoryMap * makeMapping(
|
||||
IOMemoryDescriptor * owner,
|
||||
task_t intoTask,
|
||||
IOVirtualAddress atAddress,
|
||||
IOOptionBits options,
|
||||
IOByteCount offset,
|
||||
IOByteCount length ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual uint64_t getPreparationID( void ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function getPageCounts
|
||||
* @abstract Retrieve the number of resident and/or dirty pages encompassed by an IOMemoryDescriptor.
|
||||
* @discussion This method returns the number of resident and/or dirty pages encompassed by an IOMemoryDescriptor.
|
||||
* @param residentPageCount - If non-null, a pointer to a byte count that will return the number of resident pages encompassed by this IOMemoryDescriptor.
|
||||
* @param dirtyPageCount - If non-null, a pointer to a byte count that will return the number of dirty pages encompassed by this IOMemoryDescriptor.
|
||||
* @result An IOReturn code. */
|
||||
|
||||
IOReturn getPageCounts(IOByteCount * residentPageCount,
|
||||
IOByteCount * dirtyPageCount);
|
||||
};
|
||||
|
||||
#endif /* !_IOSUBMEMORYDESCRIPTOR_H */
|
||||
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2010 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
#ifndef IOKIT_IOTIMESTAMP_H
|
||||
#define IOKIT_IOTIMESTAMP_H
|
||||
|
||||
#include <sys/kdebug.h>
|
||||
|
||||
static inline void
|
||||
IOTimeStampStartConstant(unsigned int csc,
|
||||
uintptr_t a = 0, uintptr_t b = 0,
|
||||
uintptr_t c = 0, uintptr_t d = 0)
|
||||
{
|
||||
KERNEL_DEBUG_CONSTANT(((uint32_t)csc) | DBG_FUNC_START, a, b, c, d, 0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
IOTimeStampEndConstant(uintptr_t csc,
|
||||
uintptr_t a = 0, uintptr_t b = 0,
|
||||
uintptr_t c = 0, uintptr_t d = 0)
|
||||
{
|
||||
KERNEL_DEBUG_CONSTANT(((uint32_t)csc) | DBG_FUNC_END, a, b, c, d, 0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
IOTimeStampConstant(uintptr_t csc,
|
||||
uintptr_t a = 0, uintptr_t b = 0,
|
||||
uintptr_t c = 0, uintptr_t d = 0)
|
||||
{
|
||||
KERNEL_DEBUG_CONSTANT(((uint32_t)csc) | DBG_FUNC_NONE, a, b, c, d, 0);
|
||||
}
|
||||
|
||||
#if KDEBUG
|
||||
|
||||
static inline void
|
||||
IOTimeStampStart(uintptr_t csc,
|
||||
uintptr_t a = 0, uintptr_t b = 0,
|
||||
uintptr_t c = 0, uintptr_t d = 0)
|
||||
{
|
||||
KERNEL_DEBUG(((uint32_t)csc) | DBG_FUNC_START, a, b, c, d, 0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
IOTimeStampEnd(uintptr_t csc,
|
||||
uintptr_t a = 0, uintptr_t b = 0,
|
||||
uintptr_t c = 0, uintptr_t d = 0)
|
||||
{
|
||||
KERNEL_DEBUG(((uint32_t)csc) | DBG_FUNC_END, a, b, c, d, 0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
IOTimeStamp(uintptr_t csc,
|
||||
uintptr_t a = 0, uintptr_t b = 0,
|
||||
uintptr_t c = 0, uintptr_t d = 0)
|
||||
{
|
||||
KERNEL_DEBUG(((uint32_t)csc) | DBG_FUNC_NONE, a, b, c, d, 0);
|
||||
}
|
||||
|
||||
#endif /* KDEBUG */
|
||||
|
||||
#define IODBG_STORAGE(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSTORAGE, code))
|
||||
#define IODBG_NETWORK(code) (KDBG_CODE(DBG_IOKIT, DBG_IONETWORK, code))
|
||||
#define IODBG_KEYBOARD(code) (KDBG_CODE(DBG_IOKIT, DBG_IOKEYBOARD, code))
|
||||
#define IODBG_HID(code) (KDBG_CODE(DBG_IOKIT, DBG_IOHID, code))
|
||||
#define IODBG_AUDIO(code) (KDBG_CODE(DBG_IOKIT, DBG_IOAUDIO, code))
|
||||
#define IODBG_SERIAL(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSERIAL, code))
|
||||
#define IODBG_TTY(code) (KDBG_CODE(DBG_IOKIT, DBG_IOTTY, code))
|
||||
#define IODBG_SAM(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSAM, code))
|
||||
#define IODBG_PARALLELATA(code) (KDBG_CODE(DBG_IOKIT, DBG_IOPARALLELATA, code))
|
||||
#define IODBG_PARALLELSCSI(code) (KDBG_CODE(DBG_IOKIT, DBG_IOPARALLELSCSI, code))
|
||||
#define IODBG_SATA(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSATA, code))
|
||||
#define IODBG_SAS(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSAS, code))
|
||||
#define IODBG_FIBRECHANNEL(code) (KDBG_CODE(DBG_IOKIT, DBG_IOFIBRECHANNEL, code))
|
||||
#define IODBG_USB(code) (KDBG_CODE(DBG_IOKIT, DBG_IOUSB, code))
|
||||
#define IODBG_BLUETOOTH(code) (KDBG_CODE(DBG_IOKIT, DBG_IOBLUETOOTH, code))
|
||||
#define IODBG_FIREWIRE(code) (KDBG_CODE(DBG_IOKIT, DBG_IOFIREWIRE, code))
|
||||
#define IODBG_INFINIBAND(code) (KDBG_CODE(DBG_IOKIT, DBG_IOINFINIBAND, code))
|
||||
|
||||
|
||||
/* Backwards compatibility */
|
||||
#define IODBG_DISK(code) IODBG_STORAGE(code)
|
||||
#define IODBG_POINTING(code) IODBG_HID(code)
|
||||
|
||||
|
||||
/* IOKit infrastructure subclasses */
|
||||
#define IODBG_INTC(code) (KDBG_CODE(DBG_IOKIT, DBG_IOINTC, code))
|
||||
#define IODBG_WORKLOOP(code) (KDBG_CODE(DBG_IOKIT, DBG_IOWORKLOOP, code))
|
||||
#define IODBG_INTES(code) (KDBG_CODE(DBG_IOKIT, DBG_IOINTES, code))
|
||||
#define IODBG_TIMES(code) (KDBG_CODE(DBG_IOKIT, DBG_IOCLKES, code))
|
||||
#define IODBG_CMDQ(code) (KDBG_CODE(DBG_IOKIT, DBG_IOCMDQ, code))
|
||||
#define IODBG_MCURS(code) (KDBG_CODE(DBG_IOKIT, DBG_IOMCURS, code))
|
||||
#define IODBG_MDESC(code) (KDBG_CODE(DBG_IOKIT, DBG_IOMDESC, code))
|
||||
#define IODBG_POWER(code) (KDBG_CODE(DBG_IOKIT, DBG_IOPOWER, code))
|
||||
#define IODBG_IOSERVICE(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSERVICE, code))
|
||||
#define IODBG_IOREGISTRY(code) (KDBG_CODE(DBG_IOKIT, DBG_IOREGISTRY, code))
|
||||
|
||||
/* IOKit specific codes - within each subclass */
|
||||
|
||||
/* DBG_IOKIT/DBG_IODISK codes */
|
||||
|
||||
/* DBG_IOKIT/DBG_IONETWORK codes */
|
||||
|
||||
/* DBG_IOKIT/DBG_IOKEYBOARD codes */
|
||||
|
||||
/* DBG_IOKIT/DBG_IOHID codes */
|
||||
|
||||
/* DBG_IOKIT/DBG_IOAUDIO codes */
|
||||
|
||||
/* DBG_IOKIT/DBG_IOSERIAL codes */
|
||||
|
||||
/* DBG_IOKIT/DBG_IOTTY codes */
|
||||
|
||||
/* DBG_IOKIT/DBG_IOINTC codes */
|
||||
#define IOINTC_HANDLER 1 /* 0x05000004 */
|
||||
#define IOINTC_SPURIOUS 2 /* 0x05000008 */
|
||||
|
||||
/* DBG_IOKIT/DBG_IOWORKLOOP codes */
|
||||
#define IOWL_CLIENT 1 /* 0x05010004 */
|
||||
#define IOWL_WORK 2 /* 0x05010008 */
|
||||
|
||||
/* DBG_IOKIT/DBG_IOINTES codes */
|
||||
#define IOINTES_CLIENT 1 /* 0x05020004 */
|
||||
#define IOINTES_LAT 2 /* 0x05020008 */
|
||||
#define IOINTES_SEMA 3 /* 0x0502000c */
|
||||
#define IOINTES_INTCTXT 4 /* 0x05020010 */
|
||||
#define IOINTES_INTFLTR 5 /* 0x05020014 */
|
||||
#define IOINTES_ACTION 6 /* 0x05020018 */
|
||||
#define IOINTES_FILTER 7 /* 0x0502001c */
|
||||
|
||||
/* DBG_IOKIT/DBG_IOTIMES codes */
|
||||
#define IOTIMES_CLIENT 1 /* 0x05030004 */
|
||||
#define IOTIMES_LAT 2 /* 0x05030008 */
|
||||
#define IOTIMES_SEMA 3 /* 0x0503000c */
|
||||
#define IOTIMES_ACTION 4 /* 0x05030010 */
|
||||
|
||||
/* DBG_IOKIT/DBG_IOCMDQ codes */
|
||||
#define IOCMDQ_CLIENT 1 /* 0x05040004 */
|
||||
#define IOCMDQ_LAT 2 /* 0x05040008 */
|
||||
#define IOCMDQ_SEMA 3 /* 0x0504000c */
|
||||
#define IOCMDQ_PSEMA 4 /* 0x05040010 */
|
||||
#define IOCMDQ_PLOCK 5 /* 0x05040014 */
|
||||
#define IOCMDQ_ACTION 6 /* 0x05040018 */
|
||||
|
||||
/* DBG_IOKIT/DBG_IOMCURS codes */
|
||||
|
||||
/* DBG_IOKIT/DBG_IOMDESC codes */
|
||||
|
||||
/* DBG_IOKIT/DBG_IOPOWER codes */
|
||||
// See IOKit/pwr_mgt/IOPMlog.h for the power management codes
|
||||
|
||||
/* DBG_IOKIT/DBG_IOSERVICE codes */
|
||||
#define IOSERVICE_BUSY 1 /* 0x05080004 */
|
||||
#define IOSERVICE_NONBUSY 2 /* 0x05080008 */
|
||||
#define IOSERVICE_MODULESTALL 3 /* 0x0508000C */
|
||||
#define IOSERVICE_MODULEUNSTALL 4 /* 0x05080010 */
|
||||
|
||||
#define IOSERVICE_TERMINATE_PHASE1 5 /* 0x05080014 */
|
||||
#define IOSERVICE_TERMINATE_REQUEST_OK 6 /* 0x05080018 */
|
||||
#define IOSERVICE_TERMINATE_REQUEST_FAIL 7 /* 0x0508001C */
|
||||
#define IOSERVICE_TERMINATE_SCHEDULE_STOP 8 /* 0x05080020 */
|
||||
#define IOSERVICE_TERMINATE_SCHEDULE_FINALIZE 9 /* 0x05080024 */
|
||||
#define IOSERVICE_TERMINATE_WILL 10 /* 0x05080028 */
|
||||
#define IOSERVICE_TERMINATE_DID 11 /* 0x0508002C */
|
||||
#define IOSERVICE_TERMINATE_DID_DEFER 12 /* 0x05080030 */
|
||||
#define IOSERVICE_TERMINATE_FINALIZE 13 /* 0x05080034 */
|
||||
#define IOSERVICE_TERMINATE_STOP 14 /* 0x05080038 */
|
||||
#define IOSERVICE_TERMINATE_STOP_NOP 15 /* 0x0508003C */
|
||||
#define IOSERVICE_TERMINATE_STOP_DEFER 16 /* 0x05080040 */
|
||||
#define IOSERVICE_TERMINATE_DONE 17 /* 0x05080044 */
|
||||
|
||||
#define IOSERVICE_KEXTD_ALIVE 18 /* 0x05080048 */
|
||||
#define IOSERVICE_KEXTD_READY 19 /* 0x0508004C */
|
||||
#define IOSERVICE_REGISTRY_QUIET 20 /* 0x05080050 */
|
||||
|
||||
#define IOSERVICE_TERM_SET_INACTIVE 21 /* 0x05080054 */
|
||||
#define IOSERVICE_TERM_SCHED_PHASE2 22 /* 0x05080058 */
|
||||
#define IOSERVICE_TERM_START_PHASE2 23 /* 0x0508005C */
|
||||
#define IOSERVICE_TERM_TRY_PHASE2 24 /* 0x05080060 */
|
||||
#define IOSERVICE_TERM_UC_DEFER 25 /* 0x05080064 */
|
||||
#define IOSERVICE_DETACH 26 /* 0x05080068 */
|
||||
|
||||
/* DBG_IOKIT/DBG_IOREGISTRY codes */
|
||||
#define IOREGISTRYENTRY_NAME_STRING 1 /* 0x05090004 */
|
||||
#define IOREGISTRYENTRY_NAME 2 /* 0x05090008 */
|
||||
|
||||
#endif /* ! IOKIT_IOTIMESTAMP_H */
|
||||
@@ -0,0 +1,325 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* IOTimerEventSource.h
|
||||
*
|
||||
* HISTORY
|
||||
* 2-Feb-1999 Joe Liu (jliu) created.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IOTIMEREVENTSOURCE
|
||||
#define _IOTIMEREVENTSOURCE
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
#include <kern/clock.h>
|
||||
__END_DECLS
|
||||
|
||||
#include <IOKit/IOEventSource.h>
|
||||
#include <IOKit/IOTypes.h>
|
||||
|
||||
/*!
|
||||
* @enum IOTimerEventSource constructor options
|
||||
* @abstract Constants defining behavior of the IOTimerEventSource.
|
||||
* @constant kIOTimerEventSourceOptionsPriorityHigh Importance above everything but realtime.
|
||||
* Thread calls allocated with this priority execute at extremely high priority,
|
||||
* above everything but realtime threads. They are generally executed in serial.
|
||||
* Though they may execute concurrently under some circumstances, no fan-out is implied.
|
||||
* These work items should do very small amounts of work or risk disrupting system
|
||||
* responsiveness.
|
||||
* @constant kIOTimerEventSourceOptionsPriorityKernelHigh Importance higher than most kernel
|
||||
* threads.
|
||||
* @constant kIOTimerEventSourceOptionsPriorityKernel Importance similar to that of normal kernel
|
||||
* threads.
|
||||
* @constant kIOTimerEventSourceOptionsPriorityUser Importance similar to that of normal user threads.
|
||||
* @constant kIOTimerEventSourceOptionsPriorityLow Very low importance.
|
||||
* @constant kIOTimerEventSourceOptionsPriorityWorkLoop Run the callout on the thread of the IOWorkLoop
|
||||
* the event source has been added to.
|
||||
* @constant kIOTimerEventSourceOptionsAllowReenter Allow the callout to be rescheduled and potentially
|
||||
* re-entered, if the IOWorkLoop lock has been released (eg. with commandSleep) during its invocation.
|
||||
* @constant kIOTimerEventSourceOptionsDefault Recommended default options.
|
||||
*/
|
||||
enum{
|
||||
kIOTimerEventSourceOptionsPriorityMask = 0x000000ff,
|
||||
kIOTimerEventSourceOptionsPriorityHigh = 0x00000000,
|
||||
kIOTimerEventSourceOptionsPriorityKernelHigh = 0x00000001,
|
||||
kIOTimerEventSourceOptionsPriorityKernel = 0x00000002,
|
||||
kIOTimerEventSourceOptionsPriorityUser = 0x00000003,
|
||||
kIOTimerEventSourceOptionsPriorityLow = 0x00000004,
|
||||
kIOTimerEventSourceOptionsPriorityWorkLoop = 0x000000ff,
|
||||
|
||||
kIOTimerEventSourceOptionsAllowReenter = 0x00000100,
|
||||
|
||||
kIOTimerEventSourceOptionsDefault = kIOTimerEventSourceOptionsPriorityKernelHigh
|
||||
};
|
||||
|
||||
#define IOTIMEREVENTSOURCEOPTIONS_DEFINED 1
|
||||
|
||||
/*!
|
||||
* @enum IOTimerEventSource setTimeout/wakeAtTime options
|
||||
* @abstract Constants defining behavior of a scheduled call from IOTimerEventSource.
|
||||
* @constant kIOTimeOptionsWithLeeway Use the leeway parameter to the call.
|
||||
* @constant kIOTimeOptionsContinuous Use mach_continuous_time() to generate the callback.
|
||||
*/
|
||||
enum{
|
||||
kIOTimeOptionsWithLeeway = 0x00000020,
|
||||
kIOTimeOptionsContinuous = 0x00000100,
|
||||
};
|
||||
|
||||
/*!
|
||||
* @class IOTimerEventSource : public IOEventSource
|
||||
* @abstract Time based event source mechanism.
|
||||
* @discussion An event source that implements a simple timer. A timeout handler is called once the timeout period expires. This timeout handler will be called by the work-loop that this event source is attached to.
|
||||
* <br><br>
|
||||
* Usually a timer event source will be used to implement a timeout. In general when a driver makes a request it will need to setup a call to keep track of when the I/O doesn't complete. This class is designed to make that somewhat easier.
|
||||
* <br><br>
|
||||
* Remember the system doesn't guarantee the accuracy of the callout. It is possible that a higher priority thread is running which will delay the execution of the action routine. In fact the thread will be made runable at the exact requested time, within the accuracy of the CPU's decrementer based interrupt, but the scheduler will then control execution.
|
||||
*/
|
||||
|
||||
class IOTimerEventSource : public IOEventSource
|
||||
{
|
||||
OSDeclareDefaultStructors(IOTimerEventSource);
|
||||
|
||||
protected:
|
||||
/*! @var calloutEntry thread_call entry for preregistered thread callouts */
|
||||
void *calloutEntry;
|
||||
|
||||
/*! @var abstime time to wake up next, see enable. */
|
||||
AbsoluteTime abstime;
|
||||
|
||||
/*! @struct ExpansionData
|
||||
* @discussion This structure is private to the IOTimerEventSource implementation.
|
||||
*/
|
||||
struct ExpansionData {
|
||||
SInt32 calloutGeneration;
|
||||
SInt32 calloutGenerationSignaled;
|
||||
IOWorkLoop * workLoop;
|
||||
};
|
||||
|
||||
/*! @var reserved
|
||||
* Reserved for future use. (Internal use only) */
|
||||
APPLE_KEXT_WSHADOW_PUSH;
|
||||
ExpansionData *reserved;
|
||||
APPLE_KEXT_WSHADOW_POP;
|
||||
|
||||
/*! @function timeout
|
||||
* @abstract Function that routes the call from the OS' timeout mechanism into a work-loop context.
|
||||
* @discussion timeout will normally not be called nor overridden by a subclass. If the event source is enabled then close the work-loop's gate and call the action routine.
|
||||
* @param self This argument will be cast to an IOTimerEventSource. */
|
||||
static void timeout(void *self);
|
||||
|
||||
/*! @function setTimeoutFunc
|
||||
* @abstract Set's timeout as the function of calloutEntry.
|
||||
* @discussion IOTimerEventSource is based upon the kern/thread_call.h APIs currently. This function allocates the calloutEntry member variable by using thread_call_allocate(timeout, this). If you need to write your own subclass of IOTimerEventSource you probably should override this method to allocate an entry that points to your own timeout routine. */
|
||||
virtual void setTimeoutFunc();
|
||||
|
||||
/*! @function free
|
||||
* @abstract Sub-class implementation of free method, frees calloutEntry */
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual void setWorkLoop(IOWorkLoop *workLoop) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
/*! @typedef Action
|
||||
* @discussion 'C' Function pointer defining the callout routine of this event source.
|
||||
* @param owner Owning target object. Note by a startling coincidence the first parameter in a C callout is currently used to define the target of a C++ member function.
|
||||
* @param sender The object that timed out. */
|
||||
typedef void (*Action)(OSObject *owner, IOTimerEventSource *sender);
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
typedef void (^ActionBlock)(IOTimerEventSource *sender);
|
||||
#endif /* __BLOCKS__ */
|
||||
|
||||
static IOTimerEventSource *
|
||||
timerEventSource(OSObject *owner, Action action = NULL);
|
||||
|
||||
/*! @function timerEventSource
|
||||
* @abstract Allocates and returns an initialized timer instance.
|
||||
* @param options Mask of kIOTimerEventSourceOptions* options.
|
||||
* @param owner The object that that will be passed to the Action callback.
|
||||
* @param action 'C' Function pointer for the callout routine of this event source.
|
||||
*/
|
||||
static IOTimerEventSource *
|
||||
timerEventSource(uint32_t options, OSObject *owner, Action action = NULL);
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
/*! @function timerEventSource
|
||||
* @abstract Allocates and returns an initialized timer instance.
|
||||
* @param options Mask of kIOTimerEventSourceOptions* options.
|
||||
* @param inOwner The object that that will be passed to the Action callback.
|
||||
* @param action Block for the callout routine of this event source.
|
||||
*/
|
||||
static IOTimerEventSource *
|
||||
timerEventSource(uint32_t options, OSObject *inOwner, ActionBlock action);
|
||||
#endif /* __BLOCKS__ */
|
||||
|
||||
|
||||
/*! @function init
|
||||
* @abstract Initializes the timer with an owner, and a handler to call when the timeout expires.
|
||||
*/
|
||||
virtual bool init(OSObject *owner, Action action = NULL);
|
||||
|
||||
/*! @function enable
|
||||
* @abstract Enables a call to the action.
|
||||
* @discussion Allows the action function to be called. If the timer event source was disabled while a call was outstanding and the call wasn't cancelled then it will be rescheduled. So a disable/enable pair will disable calls from this event source. */
|
||||
virtual void enable() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function disable
|
||||
* @abstract Disable a timed callout.
|
||||
* @discussion When disable returns the action will not be called until the next time enable(qv) is called. */
|
||||
virtual void disable() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function checkForWork
|
||||
* @abstract Pure Virtual member function used by IOWorkLoop for issuing a client calls.
|
||||
* @discussion This function called when the work-loop is ready to check for any work to do and then to call out the owner/action.
|
||||
* @result Return true if this function needs to be called again before all its outstanding events have been processed. */
|
||||
virtual bool checkForWork() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function setTimeoutTicks
|
||||
* @abstract Setup a callback at after the delay in scheduler ticks. See wakeAtTime(AbsoluteTime).
|
||||
* @param ticks Delay from now to wake up, in scheduler ticks, whatever that may be.
|
||||
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
|
||||
virtual IOReturn setTimeoutTicks(UInt32 ticks);
|
||||
|
||||
/*! @function setTimeoutMS
|
||||
* @abstract Setup a callback at after the delay in milliseconds. See wakeAtTime(AbsoluteTime).
|
||||
* @param ms Delay from now to wake up, time in milliseconds.
|
||||
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
|
||||
virtual IOReturn setTimeoutMS(UInt32 ms);
|
||||
|
||||
/*! @function setTimeoutUS
|
||||
* @abstract Setup a callback at after the delay in microseconds. See wakeAtTime(AbsoluteTime).
|
||||
* @param us Delay from now to wake up, time in microseconds.
|
||||
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
|
||||
virtual IOReturn setTimeoutUS(UInt32 us);
|
||||
|
||||
/*! @function setTimeout
|
||||
* @abstract Setup a callback at after the delay in some unit. See wakeAtTime(AbsoluteTime).
|
||||
* @param interval Delay from now to wake up in some defined unit.
|
||||
* @param scale_factor Define the unit of interval, default to nanoseconds.
|
||||
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
|
||||
virtual IOReturn setTimeout(UInt32 interval,
|
||||
UInt32 scale_factor = kNanosecondScale);
|
||||
|
||||
#if !defined(__LP64__)
|
||||
virtual IOReturn setTimeout(mach_timespec_t interval)
|
||||
APPLE_KEXT_DEPRECATED;
|
||||
#endif
|
||||
|
||||
/*! @function setTimeout
|
||||
* @abstract Setup a callback at after the delay in decrementer ticks. See wakeAtTime(AbsoluteTime).
|
||||
* @param interval Delay from now to wake up in decrementer ticks.
|
||||
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
|
||||
virtual IOReturn setTimeout(AbsoluteTime interval);
|
||||
|
||||
/*! @function wakeAtTimeTicks
|
||||
* @abstract Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
|
||||
* @param ticks Time to wake up in scheduler quantums, whatever that is?
|
||||
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
|
||||
virtual IOReturn wakeAtTimeTicks(UInt32 ticks);
|
||||
|
||||
/*! @function wakeAtTimeMS
|
||||
* @abstract Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
|
||||
* @param ms Time to wake up in milliseconds.
|
||||
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
|
||||
virtual IOReturn wakeAtTimeMS(UInt32 ms);
|
||||
|
||||
/*! @function wakeAtTimeUS
|
||||
* @abstract Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
|
||||
* @param us Time to wake up in microseconds.
|
||||
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
|
||||
virtual IOReturn wakeAtTimeUS(UInt32 us);
|
||||
|
||||
/*! @function wakeAtTime
|
||||
* @abstract Setup a callback at this absolute time. See wakeAtTime(AbsoluteTime).
|
||||
* @param abstime Time to wake up in some unit.
|
||||
* @param scale_factor Define the unit of abstime, default to nanoseconds.
|
||||
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
|
||||
virtual IOReturn wakeAtTime(UInt32 abstime,
|
||||
UInt32 scale_factor = kNanosecondScale);
|
||||
|
||||
#if !defined(__LP64__)
|
||||
virtual IOReturn wakeAtTime(mach_timespec_t abstime)
|
||||
APPLE_KEXT_DEPRECATED;
|
||||
#endif
|
||||
|
||||
/*! @function wakeAtTime
|
||||
* @abstract Setup a callback at this absolute time.
|
||||
* @discussion Starts the timer, which will expire at abstime. After it expires, the timer will call the 'action' registered in the init() function. This timer is not periodic, a further call is needed to reset and restart the timer after it expires.
|
||||
* @param abstime Absolute Time when to wake up, counted in 'decrementer' units and starts at zero when system boots.
|
||||
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared by init or IOEventSource::setAction (qqv). */
|
||||
virtual IOReturn wakeAtTime(AbsoluteTime abstime);
|
||||
|
||||
/*! @function cancelTimeout
|
||||
* @abstract Disable any outstanding calls to this event source.
|
||||
* @discussion Clear down any oustanding calls. By the time this function completes it is guaranteed that the action will not be called again. */
|
||||
virtual void cancelTimeout();
|
||||
|
||||
/*! @function init
|
||||
* @abstract Initializes the timer with an owner, and a handler to call when the timeout expires.
|
||||
*/
|
||||
virtual bool init(uint32_t options, OSObject *inOwner, Action inAction);
|
||||
|
||||
/*! @function setTimeout
|
||||
* @abstract Setup a callback at after the delay in decrementer ticks. See wakeAtTime(AbsoluteTime).
|
||||
* @param options see kIOTimeOptionsWithLeeway and kIOTimeOptionsContinuous
|
||||
* @param interval Delay from now to wake up in decrementer ticks.
|
||||
* @param leeway Allowable leeway to wake time, if the kIOTimeOptionsWithLeeway option is set
|
||||
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared. */
|
||||
virtual IOReturn setTimeout(uint32_t options, AbsoluteTime interval, AbsoluteTime leeway);
|
||||
|
||||
/*! @function wakeAtTime
|
||||
* @abstract Setup a callback at this absolute time.
|
||||
* @discussion Starts the timer, which will expire at abstime. After it expires, the timer will call the 'action' registered in the init() function. This timer is not periodic, a further call is needed to reset and restart the timer after it expires.
|
||||
* @param options see kIOTimeOptionsWithLeeway and kIOTimeOptionsContinuous
|
||||
* @param abstime Absolute Time when to wake up, counted in 'decrementer' units and starts at zero when system boots.
|
||||
* @param leeway Allowable leeway to wake time, if the kIOTimeOptionsWithLeeway option is set
|
||||
* @result kIOReturnSuccess if everything is fine, kIOReturnNoResources if action hasn't been declared by init or IOEventSource::setAction (qqv). */
|
||||
virtual IOReturn wakeAtTime(uint32_t options, AbsoluteTime abstime, AbsoluteTime leeway);
|
||||
|
||||
private:
|
||||
static void timeoutAndRelease(void *self, void *c);
|
||||
static void timeoutSignaled(void *self, void *c);
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUsed(IOTimerEventSource, 0);
|
||||
OSMetaClassDeclareReservedUsed(IOTimerEventSource, 1);
|
||||
OSMetaClassDeclareReservedUsed(IOTimerEventSource, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOTimerEventSource, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOTimerEventSource, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOTimerEventSource, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOTimerEventSource, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOTimerEventSource, 7);
|
||||
};
|
||||
|
||||
#endif /* !_IOTIMEREVENTSOURCE */
|
||||
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2012 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
#ifndef __IOKIT_IOTYPES_H
|
||||
#define __IOKIT_IOTYPES_H
|
||||
|
||||
|
||||
#ifndef IOKIT
|
||||
#define IOKIT 1
|
||||
#endif /* !IOKIT */
|
||||
|
||||
#include <IOKit/system.h>
|
||||
|
||||
#include <IOKit/IOReturn.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#if defined (__cplusplus)
|
||||
#if __cplusplus >= 201103L
|
||||
#define NULL nullptr
|
||||
#else
|
||||
#define NULL 0
|
||||
#endif
|
||||
#else
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Simple data types.
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include <libkern/OSTypes.h>
|
||||
|
||||
#include <libkern/OSBase.h>
|
||||
|
||||
typedef UInt32 IOOptionBits;
|
||||
typedef SInt32 IOFixed;
|
||||
typedef UInt32 IOVersion;
|
||||
typedef UInt32 IOItemCount;
|
||||
typedef UInt32 IOCacheMode;
|
||||
|
||||
typedef UInt32 IOByteCount32;
|
||||
typedef UInt64 IOByteCount64;
|
||||
|
||||
typedef UInt32 IOPhysicalAddress32;
|
||||
typedef UInt64 IOPhysicalAddress64;
|
||||
typedef UInt32 IOPhysicalLength32;
|
||||
typedef UInt64 IOPhysicalLength64;
|
||||
|
||||
#if !defined(__arm__) && !defined(__i386__)
|
||||
typedef mach_vm_address_t IOVirtualAddress;
|
||||
#else
|
||||
typedef vm_address_t IOVirtualAddress;
|
||||
#endif
|
||||
|
||||
#if !defined(__arm__) && !defined(__i386__) && !(defined(__x86_64__) && !defined(KERNEL)) && !(defined(__arm64__) && !defined(__LP64__))
|
||||
typedef IOByteCount64 IOByteCount;
|
||||
#else
|
||||
typedef IOByteCount32 IOByteCount;
|
||||
#endif
|
||||
|
||||
typedef IOVirtualAddress IOLogicalAddress;
|
||||
|
||||
#if !defined(__arm__) && !defined(__i386__) && !(defined(__x86_64__) && !defined(KERNEL))
|
||||
|
||||
typedef IOPhysicalAddress64 IOPhysicalAddress;
|
||||
typedef IOPhysicalLength64 IOPhysicalLength;
|
||||
#define IOPhysical32( hi, lo ) ((UInt64) lo + ((UInt64)(hi) << 32))
|
||||
#define IOPhysSize 64
|
||||
|
||||
#else
|
||||
|
||||
typedef IOPhysicalAddress32 IOPhysicalAddress;
|
||||
typedef IOPhysicalLength32 IOPhysicalLength;
|
||||
#define IOPhysical32( hi, lo ) (lo)
|
||||
#define IOPhysSize 32
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct{
|
||||
IOPhysicalAddress address;
|
||||
IOByteCount length;
|
||||
} IOPhysicalRange;
|
||||
|
||||
typedef struct{
|
||||
IOVirtualAddress address;
|
||||
IOByteCount length;
|
||||
} IOVirtualRange;
|
||||
|
||||
#if !defined(__arm__) && !defined(__i386__)
|
||||
typedef IOVirtualRange IOAddressRange;
|
||||
#else
|
||||
typedef struct{
|
||||
mach_vm_address_t address;
|
||||
mach_vm_size_t length;
|
||||
} IOAddressRange;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Map between #defined or enum'd constants and text description.
|
||||
*/
|
||||
typedef struct {
|
||||
int value;
|
||||
const char *name;
|
||||
} IONamedValue;
|
||||
|
||||
|
||||
/*
|
||||
* Memory alignment -- specified as a power of two.
|
||||
*/
|
||||
typedef unsigned int IOAlignment;
|
||||
|
||||
#define IO_NULL_VM_TASK ((vm_task_t)0)
|
||||
|
||||
|
||||
/*
|
||||
* Pull in machine specific stuff.
|
||||
*/
|
||||
|
||||
//#include <IOKit/machine/IOTypes.h>
|
||||
|
||||
#ifndef MACH_KERNEL
|
||||
|
||||
#ifndef __IOKIT_PORTS_DEFINED__
|
||||
#define __IOKIT_PORTS_DEFINED__
|
||||
#ifdef __cplusplus
|
||||
class OSObject;
|
||||
typedef OSObject * io_object_t;
|
||||
#else
|
||||
typedef struct OSObject * io_object_t;
|
||||
#endif
|
||||
#endif /* __IOKIT_PORTS_DEFINED__ */
|
||||
|
||||
#include <device/device_types.h>
|
||||
|
||||
typedef io_object_t io_connect_t;
|
||||
typedef io_object_t io_enumerator_t;
|
||||
typedef io_object_t io_iterator_t;
|
||||
typedef io_object_t io_registry_entry_t;
|
||||
typedef io_object_t io_service_t;
|
||||
typedef io_object_t uext_object_t;
|
||||
|
||||
#define IO_OBJECT_NULL ((io_object_t) 0)
|
||||
|
||||
#endif /* MACH_KERNEL */
|
||||
|
||||
// IOConnectMapMemory memoryTypes
|
||||
enum {
|
||||
kIODefaultMemoryType = 0
|
||||
};
|
||||
|
||||
enum {
|
||||
kIODefaultCache = 0,
|
||||
kIOInhibitCache = 1,
|
||||
kIOWriteThruCache = 2,
|
||||
kIOCopybackCache = 3,
|
||||
kIOWriteCombineCache = 4,
|
||||
kIOCopybackInnerCache = 5,
|
||||
kIOPostedWrite = 6,
|
||||
kIORealTimeCache = 7,
|
||||
kIOPostedReordered = 8,
|
||||
kIOPostedCombinedReordered = 9,
|
||||
};
|
||||
|
||||
// IOMemory mapping options
|
||||
enum {
|
||||
kIOMapAnywhere = 0x00000001,
|
||||
|
||||
kIOMapCacheMask = 0x00000f00,
|
||||
kIOMapCacheShift = 8,
|
||||
kIOMapDefaultCache = kIODefaultCache << kIOMapCacheShift,
|
||||
kIOMapInhibitCache = kIOInhibitCache << kIOMapCacheShift,
|
||||
kIOMapWriteThruCache = kIOWriteThruCache << kIOMapCacheShift,
|
||||
kIOMapCopybackCache = kIOCopybackCache << kIOMapCacheShift,
|
||||
kIOMapWriteCombineCache = kIOWriteCombineCache << kIOMapCacheShift,
|
||||
kIOMapCopybackInnerCache = kIOCopybackInnerCache << kIOMapCacheShift,
|
||||
kIOMapPostedWrite = kIOPostedWrite << kIOMapCacheShift,
|
||||
kIOMapRealTimeCache = kIORealTimeCache << kIOMapCacheShift,
|
||||
kIOMapPostedReordered = kIOPostedReordered << kIOMapCacheShift,
|
||||
kIOMapPostedCombinedReordered = kIOPostedCombinedReordered << kIOMapCacheShift,
|
||||
|
||||
kIOMapUserOptionsMask = 0x00000fff,
|
||||
|
||||
kIOMapReadOnly = 0x00001000,
|
||||
|
||||
kIOMapStatic = 0x01000000,
|
||||
kIOMapReference = 0x02000000,
|
||||
kIOMapUnique = 0x04000000,
|
||||
kIOMapPrefault = 0x10000000,
|
||||
kIOMapOverwrite = 0x20000000
|
||||
};
|
||||
|
||||
/*! @enum Scale Factors
|
||||
* @discussion Used when a scale_factor parameter is required to define a unit of time.
|
||||
* @constant kNanosecondScale Scale factor for nanosecond based times.
|
||||
* @constant kMicrosecondScale Scale factor for microsecond based times.
|
||||
* @constant kMillisecondScale Scale factor for millisecond based times.
|
||||
* @constant kTickScale Scale factor for the standard (100Hz) tick.
|
||||
* @constant kSecondScale Scale factor for second based times. */
|
||||
|
||||
enum {
|
||||
kNanosecondScale = 1,
|
||||
kMicrosecondScale = 1000,
|
||||
kMillisecondScale = 1000 * 1000,
|
||||
kSecondScale = 1000 * 1000 * 1000,
|
||||
kTickScale = (kSecondScale / 100)
|
||||
};
|
||||
|
||||
enum {
|
||||
kIOConnectMethodVarOutputSize = -3
|
||||
};
|
||||
|
||||
/* compatibility types */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* ! __IOKIT_IOTYPES_H */
|
||||
@@ -0,0 +1,440 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Changes to this API are expected.
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IOUSERCLIENT_H
|
||||
#define _IOKIT_IOUSERCLIENT_H
|
||||
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/OSMessageNotification.h>
|
||||
#include <DriverKit/IOUserClient.h>
|
||||
|
||||
#if IOKITSTATS
|
||||
#include <IOKit/IOStatisticsPrivate.h>
|
||||
#endif
|
||||
|
||||
#define _IOUSERCLIENT_SENDASYNCRESULT64WITHOPTIONS_ 1
|
||||
|
||||
enum {
|
||||
kIOUCTypeMask = 0x0000000f,
|
||||
kIOUCScalarIScalarO = 0,
|
||||
kIOUCScalarIStructO = 2,
|
||||
kIOUCStructIStructO = 3,
|
||||
kIOUCScalarIStructI = 4,
|
||||
|
||||
kIOUCForegroundOnly = 0x00000010,
|
||||
};
|
||||
|
||||
/*! @enum
|
||||
* @abstract Constant to denote a variable length structure argument to IOUserClient.
|
||||
* @constant kIOUCVariableStructureSize Use in the structures IOExternalMethod, IOExternalAsyncMethod, IOExternalMethodDispatch to specify the size of the structure is variable.
|
||||
*/
|
||||
enum {
|
||||
kIOUCVariableStructureSize = 0xffffffff
|
||||
};
|
||||
|
||||
|
||||
typedef IOReturn (IOService::*IOMethod)(void * p1, void * p2, void * p3,
|
||||
void * p4, void * p5, void * p6 );
|
||||
|
||||
typedef IOReturn (IOService::*IOAsyncMethod)(OSAsyncReference asyncRef,
|
||||
void * p1, void * p2, void * p3,
|
||||
void * p4, void * p5, void * p6 );
|
||||
|
||||
typedef IOReturn (IOService::*IOTrap)(void * p1, void * p2, void * p3,
|
||||
void * p4, void * p5, void * p6 );
|
||||
|
||||
typedef IOReturn (*IOMethodACID32)(IOService * svc, void * p1, void * p2, void * p3,
|
||||
void * p4, void * p5, void * p6 );
|
||||
|
||||
typedef IOReturn (*IOAsyncMethodACID32)(IOService * svc, OSAsyncReference asyncRef,
|
||||
void * p1, void * p2, void * p3,
|
||||
void * p4, void * p5, void * p6 );
|
||||
|
||||
typedef IOReturn (*IOTrapACID32)(IOService * svc, void * p1, void * p2, void * p3,
|
||||
void * p4, void * p5, void * p6 );
|
||||
|
||||
//
|
||||
// When building for i386, clang does not emit code that is compatible with GCC-built code for the below structs.
|
||||
// The below struct modifications are workarounds to have the correct positioning of the function pointer.
|
||||
//
|
||||
// padding must be set to kIOExternalMethodACIDClangPadding
|
||||
//
|
||||
#if (defined(__i386__) && defined(__clang__))
|
||||
#define kIOExternalMethodACID32Padding 0xFFFF0000
|
||||
#endif
|
||||
|
||||
struct IOExternalMethod {
|
||||
IOService * object;
|
||||
#if (defined(__i386__) && defined(__clang__))
|
||||
uint32_t padding;
|
||||
IOMethodACID32 func;
|
||||
#else
|
||||
IOMethod func;
|
||||
#endif
|
||||
IOOptionBits flags;
|
||||
IOByteCount count0;
|
||||
IOByteCount count1;
|
||||
};
|
||||
|
||||
struct IOExternalAsyncMethod {
|
||||
IOService * object;
|
||||
#if (defined(__i386__) && defined(__clang__))
|
||||
uint32_t padding;
|
||||
IOAsyncMethodACID32 func;
|
||||
#else
|
||||
IOAsyncMethod func;
|
||||
#endif
|
||||
IOOptionBits flags;
|
||||
IOByteCount count0;
|
||||
IOByteCount count1;
|
||||
};
|
||||
|
||||
struct IOExternalTrap {
|
||||
IOService * object;
|
||||
#if (defined(__i386__) && defined(__clang__))
|
||||
uint32_t padding;
|
||||
IOTrapACID32 func;
|
||||
#else
|
||||
IOTrap func;
|
||||
#endif
|
||||
};
|
||||
|
||||
enum {
|
||||
kIOUserNotifyMaxMessageSize = 64
|
||||
};
|
||||
|
||||
enum {
|
||||
kIOUserNotifyOptionCanDrop = 0x1 /* Fail if queue is full, rather than infinitely queuing. */
|
||||
};
|
||||
|
||||
// keys for clientHasPrivilege
|
||||
#define kIOClientPrivilegeAdministrator "root"
|
||||
#define kIOClientPrivilegeLocalUser "local"
|
||||
#define kIOClientPrivilegeForeground "foreground"
|
||||
|
||||
/*! @enum
|
||||
* @abstract Constants to specify the maximum number of scalar arguments in the IOExternalMethodArguments structure. These constants are documentary since the scalarInputCount, scalarOutputCount fields reflect the actual number passed.
|
||||
* @constant kIOExternalMethodScalarInputCountMax The maximum number of scalars able to passed on input.
|
||||
* @constant kIOExternalMethodScalarOutputCountMax The maximum number of scalars able to passed on output.
|
||||
*/
|
||||
enum {
|
||||
kIOExternalMethodScalarInputCountMax = 16,
|
||||
kIOExternalMethodScalarOutputCountMax = 16,
|
||||
};
|
||||
|
||||
|
||||
struct IOExternalMethodArguments {
|
||||
uint32_t version;
|
||||
|
||||
uint32_t selector;
|
||||
|
||||
mach_port_t asyncWakePort;
|
||||
io_user_reference_t * asyncReference;
|
||||
uint32_t asyncReferenceCount;
|
||||
|
||||
const uint64_t * scalarInput;
|
||||
uint32_t scalarInputCount;
|
||||
|
||||
const void * structureInput;
|
||||
uint32_t structureInputSize;
|
||||
|
||||
IOMemoryDescriptor * structureInputDescriptor;
|
||||
|
||||
uint64_t * scalarOutput;
|
||||
uint32_t scalarOutputCount;
|
||||
|
||||
void * structureOutput;
|
||||
uint32_t structureOutputSize;
|
||||
|
||||
IOMemoryDescriptor * structureOutputDescriptor;
|
||||
uint32_t structureOutputDescriptorSize;
|
||||
|
||||
uint32_t __reservedA;
|
||||
|
||||
OSObject ** structureVariableOutputData;
|
||||
|
||||
uint32_t __reserved[30];
|
||||
};
|
||||
|
||||
typedef IOReturn (*IOExternalMethodAction)(OSObject * target, void * reference,
|
||||
IOExternalMethodArguments * arguments);
|
||||
struct IOExternalMethodDispatch {
|
||||
IOExternalMethodAction function;
|
||||
uint32_t checkScalarInputCount;
|
||||
uint32_t checkStructureInputSize;
|
||||
uint32_t checkScalarOutputCount;
|
||||
uint32_t checkStructureOutputSize;
|
||||
};
|
||||
|
||||
enum {
|
||||
#define IO_EXTERNAL_METHOD_ARGUMENTS_CURRENT_VERSION 2
|
||||
kIOExternalMethodArgumentsCurrentVersion = IO_EXTERNAL_METHOD_ARGUMENTS_CURRENT_VERSION
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* @class IOUserClient
|
||||
* @abstract Provides a basis for communication between client applications and I/O Kit objects.
|
||||
*/
|
||||
|
||||
class IOUserClient : public IOService
|
||||
{
|
||||
OSDeclareAbstractStructorsWithDispatch(IOUserClient);
|
||||
#if IOKITSTATS
|
||||
friend class IOStatistics;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
/*! @struct ExpansionData
|
||||
* @discussion This structure will be used to expand the capablilties of this class in the future.
|
||||
*/
|
||||
struct ExpansionData {
|
||||
#if IOKITSTATS
|
||||
IOUserClientCounter *counter;
|
||||
#else
|
||||
void *iokitstatsReserved;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*! @var reserved
|
||||
* Reserved for future use. (Internal use only)
|
||||
*/
|
||||
APPLE_KEXT_WSHADOW_PUSH;
|
||||
ExpansionData * reserved;
|
||||
APPLE_KEXT_WSHADOW_POP;
|
||||
|
||||
bool reserve();
|
||||
|
||||
private:
|
||||
void * __reserved[9];
|
||||
|
||||
public:
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_5
|
||||
MIG_SERVER_ROUTINE virtual IOReturn
|
||||
externalMethod(uint32_t selector, IOExternalMethodArguments *arguments,
|
||||
IOExternalMethodDispatch *dispatch = NULL,
|
||||
OSObject *target = NULL, void *reference = NULL);
|
||||
#endif
|
||||
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6
|
||||
MIG_SERVER_ROUTINE virtual IOReturn registerNotificationPort(
|
||||
mach_port_t port, UInt32 type, io_user_reference_t refCon);
|
||||
#endif
|
||||
|
||||
private:
|
||||
#if __LP64__
|
||||
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 1);
|
||||
|
||||
#else
|
||||
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_5
|
||||
OSMetaClassDeclareReservedUsed(IOUserClient, 0);
|
||||
#else
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 0);
|
||||
#endif
|
||||
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6
|
||||
OSMetaClassDeclareReservedUsed(IOUserClient, 1);
|
||||
#else
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 1);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 10);
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 11);
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 12);
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 13);
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 14);
|
||||
OSMetaClassDeclareReservedUnused(IOUserClient, 15);
|
||||
|
||||
|
||||
protected:
|
||||
static IOReturn sendAsyncResult(OSAsyncReference reference,
|
||||
IOReturn result, void *args[], UInt32 numArgs);
|
||||
static void setAsyncReference(OSAsyncReference asyncRef,
|
||||
mach_port_t wakePort,
|
||||
void *callback, void *refcon);
|
||||
|
||||
static IOReturn sendAsyncResult64(OSAsyncReference64 reference,
|
||||
IOReturn result, io_user_reference_t args[], UInt32 numArgs);
|
||||
|
||||
/*!
|
||||
* @function sendAsyncResult64WithOptions
|
||||
* @abstract Send a notification as with sendAsyncResult, but with finite queueing.
|
||||
* @discussion IOUserClient::sendAsyncResult64() will infitely queue messages if the client
|
||||
* is not processing them in a timely fashion. This variant will not, for simple
|
||||
* handling of situations where clients may be expected to stop processing messages.
|
||||
*/
|
||||
static IOReturn sendAsyncResult64WithOptions(OSAsyncReference64 reference,
|
||||
IOReturn result, io_user_reference_t args[], UInt32 numArgs,
|
||||
IOOptionBits options);
|
||||
|
||||
static void setAsyncReference64(OSAsyncReference64 asyncRef,
|
||||
mach_port_t wakePort,
|
||||
mach_vm_address_t callback, io_user_reference_t refcon);
|
||||
|
||||
static void setAsyncReference64(OSAsyncReference64 asyncRef,
|
||||
mach_port_t wakePort,
|
||||
mach_vm_address_t callback, io_user_reference_t refcon,
|
||||
task_t task);
|
||||
|
||||
public:
|
||||
|
||||
static IOReturn clientHasAuthorization( task_t task,
|
||||
IOService * service );
|
||||
|
||||
static IOReturn clientHasPrivilege( void * securityToken,
|
||||
const char * privilegeName );
|
||||
|
||||
static OSObject * copyClientEntitlement( task_t task,
|
||||
const char * entitlement );
|
||||
|
||||
static OSDictionary * copyClientEntitlements(task_t task);
|
||||
|
||||
/*!
|
||||
* @function releaseAsyncReference64
|
||||
* @abstract Release the mach_port_t reference held within the OSAsyncReference64 structure.
|
||||
* @discussion The OSAsyncReference64 structure passed to async methods holds a reference to the wakeup mach port, which should be released to balance each async method call. Behavior is undefined if these calls are not correctly balanced.
|
||||
* @param reference The reference passed to the subclass IOAsyncMethod, or externalMethod() in the IOExternalMethodArguments.asyncReference field.
|
||||
* @result A return code.
|
||||
*/
|
||||
static IOReturn releaseAsyncReference64(OSAsyncReference64 reference);
|
||||
/*!
|
||||
* @function releaseNotificationPort
|
||||
* @abstract Release the mach_port_t passed to registerNotificationPort().
|
||||
* @discussion The mach_port_t passed to the registerNotificationPort() methods should be released to balance each call to registerNotificationPort(). Behavior is undefined if these calls are not correctly balanced.
|
||||
* @param port The mach_port_t argument previously passed to the subclass implementation of registerNotificationPort().
|
||||
* @result A return code.
|
||||
*/
|
||||
static IOReturn releaseNotificationPort(mach_port_t port);
|
||||
|
||||
virtual bool init() APPLE_KEXT_OVERRIDE;
|
||||
virtual bool init( OSDictionary * dictionary ) APPLE_KEXT_OVERRIDE;
|
||||
// Currently ignores the all args, just passes up to IOService::init()
|
||||
virtual bool initWithTask(
|
||||
task_t owningTask, void * securityToken, UInt32 type,
|
||||
OSDictionary * properties);
|
||||
|
||||
virtual bool initWithTask(
|
||||
task_t owningTask, void * securityToken, UInt32 type);
|
||||
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOReturn clientClose( void );
|
||||
virtual IOReturn clientDied( void );
|
||||
|
||||
virtual IOService * getService( void );
|
||||
|
||||
MIG_SERVER_ROUTINE virtual IOReturn registerNotificationPort(
|
||||
mach_port_t port, UInt32 type, UInt32 refCon );
|
||||
|
||||
MIG_SERVER_ROUTINE virtual IOReturn getNotificationSemaphore( UInt32 notification_type,
|
||||
semaphore_t * semaphore );
|
||||
|
||||
virtual IOReturn connectClient( IOUserClient * client );
|
||||
|
||||
// memory will be released by user client when last map is destroyed
|
||||
virtual IOReturn clientMemoryForType( UInt32 type,
|
||||
IOOptionBits * options,
|
||||
IOMemoryDescriptor ** memory );
|
||||
|
||||
#if !__LP64__
|
||||
private:
|
||||
APPLE_KEXT_COMPATIBILITY_VIRTUAL
|
||||
IOMemoryMap * mapClientMemory( IOOptionBits type,
|
||||
task_t task,
|
||||
IOOptionBits mapFlags = kIOMapAnywhere,
|
||||
IOVirtualAddress atAddress = 0 );
|
||||
#endif
|
||||
|
||||
static IOReturn _sendAsyncResult64(OSAsyncReference64 reference,
|
||||
IOReturn result, io_user_reference_t args[], UInt32 numArgs, IOOptionBits options);
|
||||
public:
|
||||
|
||||
/*!
|
||||
* @function removeMappingForDescriptor
|
||||
* Remove the first mapping created from the memory descriptor returned by clientMemoryForType() from IOUserClient's list of mappings. If such a mapping exists, it is retained and the reference currently held by IOUserClient is returned to the caller.
|
||||
* @param memory The memory descriptor instance previously returned by the implementation of clientMemoryForType().
|
||||
* @result A reference to the first IOMemoryMap instance found in the list of mappings created by IOUserClient from that passed memory descriptor is returned, or zero if none exist. The caller should release this reference.
|
||||
*/
|
||||
IOMemoryMap * removeMappingForDescriptor(IOMemoryDescriptor * memory);
|
||||
|
||||
/*!
|
||||
* @function exportObjectToClient
|
||||
* Make an arbitrary OSObject available to the client task.
|
||||
* @param task The task.
|
||||
* @param obj The object we want to export to the client.
|
||||
* @param clientObj Returned value is the client's port name.
|
||||
*/
|
||||
virtual IOReturn exportObjectToClient(task_t task,
|
||||
OSObject *obj, io_object_t *clientObj);
|
||||
|
||||
|
||||
// Old methods for accessing method vector backward compatiblility only
|
||||
virtual IOExternalMethod *
|
||||
getExternalMethodForIndex( UInt32 index )
|
||||
APPLE_KEXT_DEPRECATED;
|
||||
virtual IOExternalAsyncMethod *
|
||||
getExternalAsyncMethodForIndex( UInt32 index )
|
||||
APPLE_KEXT_DEPRECATED;
|
||||
|
||||
// Methods for accessing method vector.
|
||||
virtual IOExternalMethod *
|
||||
getTargetAndMethodForIndex(
|
||||
LIBKERN_RETURNS_NOT_RETAINED IOService ** targetP, UInt32 index );
|
||||
virtual IOExternalAsyncMethod *
|
||||
getAsyncTargetAndMethodForIndex(
|
||||
LIBKERN_RETURNS_NOT_RETAINED IOService ** targetP, UInt32 index );
|
||||
|
||||
// Methods for accessing trap vector - old and new style
|
||||
virtual IOExternalTrap *
|
||||
getExternalTrapForIndex( UInt32 index )
|
||||
APPLE_KEXT_DEPRECATED;
|
||||
|
||||
virtual IOExternalTrap *
|
||||
getTargetAndTrapForIndex(
|
||||
LIBKERN_RETURNS_NOT_RETAINED IOService **targetP, UInt32 index );
|
||||
};
|
||||
|
||||
|
||||
#endif /* ! _IOKIT_IOUSERCLIENT_H */
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _IOUSERSERVER_H
|
||||
#define _IOUSERSERVER_H
|
||||
|
||||
#include <IOKit/IORPC.h>
|
||||
|
||||
#define kIOUserClassKey "IOUserClass"
|
||||
#define kIOUserServerClassKey "IOUserServer"
|
||||
#define kIOUserServerNameKey "IOUserServerName"
|
||||
#define kIOUserServerTagKey "IOUserServerTag"
|
||||
// the expected cdhash value of the userspace driver executable
|
||||
#define kIOUserServerCDHashKey "IOUserServerCDHash"
|
||||
|
||||
#if DRIVERKIT_PRIVATE
|
||||
|
||||
enum{
|
||||
kIOKitUserServerClientType = 0x99000003,
|
||||
};
|
||||
|
||||
enum{
|
||||
kIOUserServerMethodRegisterClass = 0x0001000,
|
||||
kIOUserServerMethodStart = 0x0001001,
|
||||
kIOUserServerMethodRegister = 0x0001002,
|
||||
};
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
class OSObject;
|
||||
|
||||
#define OSObject_Instantiate_ID 0x0000000100000001ULL
|
||||
|
||||
enum {
|
||||
kOSObjectRPCRemote = 0x00000001,
|
||||
kOSObjectRPCKernel = 0x00000002,
|
||||
};
|
||||
|
||||
struct OSObject_Instantiate_Msg_Content {
|
||||
IORPCMessage __hdr;
|
||||
OSObjectRef __object;
|
||||
};
|
||||
|
||||
struct OSObject_Instantiate_Rpl_Content {
|
||||
IORPCMessage __hdr;
|
||||
kern_return_t __result;
|
||||
uint32_t __pad;
|
||||
uint64_t flags;
|
||||
char classname[64];
|
||||
uint64_t methods[0];
|
||||
};
|
||||
|
||||
#pragma pack(4)
|
||||
struct OSObject_Instantiate_Msg {
|
||||
IORPCMessageMach mach;
|
||||
mach_msg_port_descriptor_t __object__descriptor;
|
||||
OSObject_Instantiate_Msg_Content content;
|
||||
};
|
||||
struct OSObject_Instantiate_Rpl {
|
||||
IORPCMessageMach mach;
|
||||
OSObject_Instantiate_Rpl_Content content;
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
typedef uint64_t IOTrapMessageBuffer[256];
|
||||
|
||||
#endif /* DRIVERKIT_PRIVATE */
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#endif /* _IOUSERSERVER_H */
|
||||
@@ -0,0 +1,361 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2019 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __IOKIT_IOWORKLOOP_H
|
||||
#define __IOKIT_IOWORKLOOP_H
|
||||
|
||||
#include <libkern/c++/OSObject.h>
|
||||
#include <IOKit/IOReturn.h>
|
||||
#include <IOKit/IOLib.h>
|
||||
#include <IOKit/IOLocks.h>
|
||||
|
||||
#include <IOKit/system.h>
|
||||
|
||||
#if IOKITSTATS
|
||||
#include <IOKit/IOStatisticsPrivate.h>
|
||||
#endif
|
||||
|
||||
class IOEventSource;
|
||||
class IOTimerEventSource;
|
||||
class IOCommandGate;
|
||||
|
||||
/*! @class IOWorkLoop
|
||||
* @discussion An IOWorkLoop is a thread of control that is intended to be used to provide single threaded access to hardware. This class has no knowledge of the nature and type of the events that it marshals and forwards. When a device driver successfully starts (see IOService::start), it is expected to create the event sources it will need to receive events. Then a work loop is initialized and the events are added to the work loop for monitoring. In general this set up will be automated by the family superclass of the specific device.
|
||||
* <br><br>
|
||||
* The thread main method walks the event source linked list and messages each one requesting a work check. At this point each event source is expected to notify its registered owner that the event has occurred. After each event has been walked and each indicates that another loop isn't required (by setting the 'more' flag to false) the thread will go to sleep on a signaling semaphore.
|
||||
* <br><br>
|
||||
* When an event source is registered with a work loop it is informed of the semaphore to use to wake up the loop.
|
||||
*/
|
||||
|
||||
class IOWorkLoop : public OSObject
|
||||
{
|
||||
OSDeclareDefaultStructors(IOWorkLoop);
|
||||
|
||||
public:
|
||||
/*!
|
||||
* @typedef Action
|
||||
* @discussion Type and arguments of callout C function that is used when
|
||||
* a runCommand is executed by a client. Cast to this type when you want a C++
|
||||
* member function to be used. Note the arg1 - arg3 parameters are straight pass
|
||||
* through from the runCommand to the action callout.
|
||||
* @param target
|
||||
* Target of the function, can be used as a refcon. Note if a C++ function
|
||||
* was specified, this parameter is implicitly the first parameter in the target
|
||||
* member function's parameter list.
|
||||
* @param arg0 Argument to action from run operation.
|
||||
* @param arg1 Argument to action from run operation.
|
||||
* @param arg2 Argument to action from run operation.
|
||||
* @param arg3 Argument to action from run operation.
|
||||
*/
|
||||
typedef IOReturn (*Action)(OSObject *target,
|
||||
void *arg0, void *arg1,
|
||||
void *arg2, void *arg3);
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
typedef IOReturn (^ActionBlock)();
|
||||
#endif /* __BLOCKS__ */
|
||||
|
||||
enum {
|
||||
kPreciousStack = 0x00000001,
|
||||
kTimeLockPanics = 0x00000002,
|
||||
};
|
||||
|
||||
private:
|
||||
/*! @function threadMainContinuation
|
||||
* @abstract Static function that calls the threadMain function.
|
||||
*/
|
||||
static void threadMainContinuation(IOWorkLoop *self);
|
||||
|
||||
/*! @function eventSourcePerformsWork
|
||||
* @abstract Checks if the event source passed in overrides checkForWork() to perform any work.
|
||||
* IOWorkLoop uses this to determine if the event source should be polled in runEventSources() or not.
|
||||
* @param inEventSource The event source to check.
|
||||
*/
|
||||
bool eventSourcePerformsWork(IOEventSource *inEventSource);
|
||||
|
||||
protected:
|
||||
|
||||
/*! @typedef maintCommandEnum
|
||||
* @discussion Enumeration of commands that _maintCommand can deal with.
|
||||
* @constant mAddEvent Used to tag a Remove event source command.
|
||||
* @constant mRemoveEvent Used to tag a Remove event source command.
|
||||
*/
|
||||
typedef enum { mAddEvent, mRemoveEvent } maintCommandEnum;
|
||||
|
||||
/*! @var gateLock
|
||||
* Mutual exclusion lock that is used by close and open Gate functions.
|
||||
* This is a recursive lock, which allows multiple layers of code to share a single IOWorkLoop without deadlock. This is common in IOKit since threads of execution tend to follow the service plane in the IORegistry, and multiple objects along the call path may acquire the gate for the same (shared) workloop.
|
||||
*/
|
||||
IORecursiveLock *gateLock;
|
||||
|
||||
/*! @var eventChain
|
||||
* Pointer to first event source in linked list.
|
||||
*/
|
||||
IOEventSource *eventChain;
|
||||
|
||||
/*! @var controlG
|
||||
* Internal control gate to maintain event system.
|
||||
*/
|
||||
IOCommandGate *controlG;
|
||||
|
||||
/*! @var workToDoLock
|
||||
* The spin lock that is used to guard the 'workToDo' variable.
|
||||
*/
|
||||
IOSimpleLock *workToDoLock;
|
||||
|
||||
/*! @var workThread
|
||||
* Work loop thread.
|
||||
*/
|
||||
IOThread workThread;
|
||||
|
||||
/*! @var workToDo
|
||||
* Used to to indicate that an interrupt has fired and needs to be processed.
|
||||
*/
|
||||
volatile bool workToDo;
|
||||
|
||||
/*! @var loopRestart
|
||||
* Set if an event chain has been changed and the system has to be rechecked from start. (Internal use only)
|
||||
*/
|
||||
bool loopRestart;
|
||||
|
||||
/*! @struct ExpansionData
|
||||
* @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
|
||||
*/
|
||||
struct ExpansionData {
|
||||
IOOptionBits options;
|
||||
IOEventSource *passiveEventChain;
|
||||
#if IOKITSTATS
|
||||
struct IOWorkLoopCounter *counter;
|
||||
#else
|
||||
void *iokitstatsReserved;
|
||||
#endif
|
||||
uint64_t lockInterval;
|
||||
uint64_t lockTime;
|
||||
};
|
||||
|
||||
/*! @var reserved
|
||||
* Reserved for future use. (Internal use only)
|
||||
*/
|
||||
ExpansionData *reserved;
|
||||
|
||||
/*! @function _maintRequest
|
||||
* @abstract Synchronous implementation of addEventSource and removeEventSource functions.
|
||||
* @discussion This function implements the commands as defined in the maintCommandEnum. It can be subclassed but it isn't an external API in the usual sense. A subclass implementation of _maintRequest would be called synchronously with respect to the work loop and it should be implemented in the usual way that an ioctl would be.
|
||||
* @return kIOReturnUnsupported if the command given is not implemented, kIOReturnSuccess otherwise.
|
||||
*/
|
||||
virtual IOReturn _maintRequest(void *command, void *data, void *, void *);
|
||||
|
||||
/*! @function free
|
||||
* @discussion Mandatory free of the object independent of the current retain count. If the work loop is running, this method will not return until the thread has successfully terminated. Each event source in the chain will be released and the working semaphore will be destroyed.
|
||||
* <br><br>
|
||||
* If the client has some outstanding requests on an event they will never be informed of completion. If an external thread is blocked on any of the event sources they will be awakened with a KERN_INTERUPTED status.
|
||||
*/
|
||||
virtual void free() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function threadMain
|
||||
* @discussion Work loop threads main function. This function consists of 3
|
||||
* loops: the outermost loop is the semaphore clear and wait loop, the middle
|
||||
* loop terminates when there is no more work, and the inside loop walks the
|
||||
* event list calling the checkForWork method in each event source. If an
|
||||
* event source has more work to do, it can set the more flag and the middle
|
||||
* loop will repeat. When no more work is outstanding the outermost will
|
||||
* sleep until an event is signalled.
|
||||
*/
|
||||
virtual void threadMain();
|
||||
|
||||
public:
|
||||
|
||||
/*! @function workLoop
|
||||
* @abstract Factory member function to construct and intialize a work loop.
|
||||
* @result Returns a workLoop instance if constructed successfully, 0 otherwise.
|
||||
*/
|
||||
static IOWorkLoop *workLoop();
|
||||
|
||||
/*! @function workLoopWithOptions(IOOptionBits options)
|
||||
* @abstract Factory member function to constuct and intialize a work loop.
|
||||
* @param options Options - kPreciousStack to avoid stack deallocation on paging path.
|
||||
* @result Returns a workLoop instance if constructed successfully, 0 otherwise.
|
||||
*/
|
||||
static IOWorkLoop *workLoopWithOptions(IOOptionBits options);
|
||||
|
||||
/*! @function init
|
||||
* @discussion Initializes an instance of the workloop. This method creates and initializes the signaling semaphore, the controller gate lock, and spawns the thread that will continue executing.
|
||||
* @result Returns true if initialized successfully, false otherwise.
|
||||
*/
|
||||
virtual bool init() APPLE_KEXT_OVERRIDE;
|
||||
|
||||
/*! @function getThread
|
||||
* @abstract Gets the workThread.
|
||||
* @result Returns workThread.
|
||||
*/
|
||||
virtual IOThread getThread() const;
|
||||
|
||||
/*! @function onThread
|
||||
* @abstract Is the current execution context on the work thread?
|
||||
* @result Returns true if IOThreadSelf() == workThread.
|
||||
*/
|
||||
virtual bool onThread() const;
|
||||
|
||||
/*! @function inGate
|
||||
* @abstract Is the current execution context holding the work-loop's gate?
|
||||
* @result Returns true if IOThreadSelf() is gate holder.
|
||||
*/
|
||||
virtual bool inGate() const;
|
||||
|
||||
/*! @function addEventSource
|
||||
* @discussion Add an event source to be monitored by the work loop. This function does not return until the work loop has acknowledged the arrival of the new event source. When a new event has been added the threadMain will always restart its loop and check all outstanding events. The event source is retained by the work loop.
|
||||
* @param newEvent Pointer to IOEventSource subclass to add.
|
||||
* @result Always returns kIOReturnSuccess.
|
||||
*/
|
||||
virtual IOReturn addEventSource(IOEventSource *newEvent);
|
||||
|
||||
/*! @function removeEventSource
|
||||
* @discussion Remove an event source from the work loop. This function does not return until the work loop has acknowledged the removal of the event source. When an event has been removed the threadMain will always restart its loop and check all outstanding events. The event source will be released before return.
|
||||
* @param toRemove Pointer to IOEventSource subclass to remove.
|
||||
* @result Returns kIOReturnSuccess if successful, kIOReturnBadArgument if toRemove couldn't be found.
|
||||
*/
|
||||
virtual IOReturn removeEventSource(IOEventSource *toRemove);
|
||||
|
||||
/*! @function enableAllEventSources
|
||||
* @abstract Calls enable() in all event sources.
|
||||
* @discussion For all event sources in eventChain, call enable() function. See IOEventSource::enable().
|
||||
*/
|
||||
virtual void enableAllEventSources() const;
|
||||
|
||||
/*! @function disableAllEventSources
|
||||
* @abstract Calls disable() in all event sources.
|
||||
* @discussion For all event sources in eventChain, call disable() function. See IOEventSource::disable().
|
||||
*/
|
||||
virtual void disableAllEventSources() const;
|
||||
|
||||
/*! @function enableAllInterrupts
|
||||
* @abstract Calls enable() in all interrupt event sources.
|
||||
* @discussion For all event sources (ES) for which OSDynamicCast(IOInterruptEventSource, ES) is valid, in eventChain call enable() function. See IOEventSource::enable().
|
||||
*/
|
||||
virtual void enableAllInterrupts() const;
|
||||
|
||||
/*! @function disableAllInterrupts
|
||||
* @abstract Calls disable() in all interrupt event sources.
|
||||
* @discussion For all event sources (ES) for which OSDynamicCast(IOInterruptEventSource, ES) is valid, in eventChain call disable() function. See IOEventSource::disable().
|
||||
*/
|
||||
virtual void disableAllInterrupts() const;
|
||||
|
||||
|
||||
protected:
|
||||
// Internal APIs used by event sources to control the thread
|
||||
friend class IOEventSource;
|
||||
friend class IOTimerEventSource;
|
||||
friend class IOCommandGate;
|
||||
#if IOKITSTATS
|
||||
friend class IOStatistics;
|
||||
#endif
|
||||
virtual void signalWorkAvailable();
|
||||
virtual void openGate();
|
||||
virtual void closeGate();
|
||||
virtual bool tryCloseGate();
|
||||
virtual int sleepGate(void *event, UInt32 interuptibleType);
|
||||
virtual void wakeupGate(void *event, bool oneThread);
|
||||
|
||||
public:
|
||||
/* methods available in Mac OS X 10.1 or later */
|
||||
|
||||
/*! @function runAction
|
||||
* @abstract Single thread a call to an action with the work-loop.
|
||||
* @discussion Client function that causes the given action to be called in a single threaded manner. Beware: the work-loop's gate is recursive and runAction can cause direct or indirect re-entrancy. When executing on a client's thread, runAction will sleep until the work-loop's gate opens for execution of client actions, the action is single threaded against all other work-loop event sources.
|
||||
* @param action Pointer to function to be executed in work-loop context.
|
||||
* @param arg0 Parameter for action parameter, defaults to 0.
|
||||
* @param arg1 Parameter for action parameter, defaults to 0.
|
||||
* @param arg2 Parameter for action parameter, defaults to 0.
|
||||
* @param arg3 Parameter for action parameter, defaults to 0.
|
||||
* @result Returns the value of the Action callout.
|
||||
*/
|
||||
virtual IOReturn runAction(Action action, OSObject *target,
|
||||
void *arg0 = NULL, void *arg1 = NULL,
|
||||
void *arg2 = NULL, void *arg3 = NULL);
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
/*! @function runAction
|
||||
* @abstract Single thread a call to an action with the work-loop.
|
||||
* @discussion Client function that causes the given action to be called in a single threaded manner. Beware: the work-loop's gate is recursive and runAction can cause direct or indirect re-entrancy. When executing on a client's thread, runAction will sleep until the work-loop's gate opens for execution of client actions, the action is single threaded against all other work-loop event sources.
|
||||
* @param action Block to be executed in work-loop context.
|
||||
* @result Returns the result of the action block.
|
||||
*/
|
||||
IOReturn runActionBlock(ActionBlock action);
|
||||
#endif /* __BLOCKS__ */
|
||||
|
||||
/*! @function runEventSources
|
||||
* @discussion Consists of the inner 2 loops of the threadMain function(qv).
|
||||
* The outer loop terminates when there is no more work, and the inside loop
|
||||
* walks the event list calling the checkForWork method in each event source.
|
||||
* If an event source has more work to do, it can set the more flag and the
|
||||
* outer loop will repeat.
|
||||
* <br><br>
|
||||
* This function can be used to clear a priority inversion between the normal
|
||||
* workloop thread and multimedia's real time threads. The problem is that
|
||||
* the interrupt action routine is often held off by high priority threads.
|
||||
* So if they want to get their data now they will have to call us and ask if
|
||||
* any data is available. The multi-media user client will arrange for this
|
||||
* function to be called, which causes any pending interrupts to be processed
|
||||
* and the completion routines called. By the time the function returns all
|
||||
* outstanding work will have been completed at the real time threads
|
||||
* priority.
|
||||
*
|
||||
* @result Return false if the work loop is shutting down, true otherwise.
|
||||
*/
|
||||
virtual bool runEventSources();
|
||||
|
||||
/*! @function setMaximumLockTime
|
||||
* @discussion For diagnostics use in DEVELOPMENT kernels, set a time interval which if the work loop lock is held for this time or greater, IOWorkLoop will panic or log a backtrace.
|
||||
* @param interval An absolute time interval, eg. created with clock_interval_to_absolutetime_interval().
|
||||
* @param options Pass IOWorkLoop::kTimeLockPanics to panic when the time is exceeded, otherwise a log will be generated with OSReportWithBacktrace().
|
||||
*/
|
||||
void setMaximumLockTime(uint64_t interval, uint32_t options);
|
||||
|
||||
protected:
|
||||
// Internal APIs used by event sources to control the thread
|
||||
virtual int sleepGate(void *event, AbsoluteTime deadline, UInt32 interuptibleType);
|
||||
|
||||
|
||||
protected:
|
||||
#if __LP64__
|
||||
OSMetaClassDeclareReservedUnused(IOWorkLoop, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOWorkLoop, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOWorkLoop, 2);
|
||||
#else
|
||||
OSMetaClassDeclareReservedUsed(IOWorkLoop, 0);
|
||||
OSMetaClassDeclareReservedUsed(IOWorkLoop, 1);
|
||||
OSMetaClassDeclareReservedUsed(IOWorkLoop, 2);
|
||||
#endif
|
||||
OSMetaClassDeclareReservedUnused(IOWorkLoop, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOWorkLoop, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOWorkLoop, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOWorkLoop, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOWorkLoop, 7);
|
||||
};
|
||||
|
||||
#endif /* !__IOKIT_IOWORKLOOP_H */
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* HISTORY
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __OS_OSMESSAGENOTIFICATION_H
|
||||
#define __OS_OSMESSAGENOTIFICATION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <mach/mach_types.h>
|
||||
#include <device/device_types.h>
|
||||
#include <IOKit/IOReturn.h>
|
||||
|
||||
enum {
|
||||
kFirstIOKitNotificationType = 100,
|
||||
kIOServicePublishNotificationType = 100,
|
||||
kIOServiceMatchedNotificationType = 101,
|
||||
kIOServiceTerminatedNotificationType = 102,
|
||||
kIOAsyncCompletionNotificationType = 150,
|
||||
kIOServiceMessageNotificationType = 160,
|
||||
kLastIOKitNotificationType = 199,
|
||||
|
||||
// reserved bits
|
||||
kIOKitNoticationTypeMask = 0x00000FFF,
|
||||
kIOKitNoticationTypeSizeAdjShift = 30,
|
||||
kIOKitNoticationMsgSizeMask = 3,
|
||||
};
|
||||
|
||||
enum {
|
||||
kOSNotificationMessageID = 53,
|
||||
kOSAsyncCompleteMessageID = 57,
|
||||
kMaxAsyncArgs = 16
|
||||
};
|
||||
|
||||
enum {
|
||||
kIOAsyncReservedIndex = 0,
|
||||
kIOAsyncReservedCount,
|
||||
|
||||
kIOAsyncCalloutFuncIndex = kIOAsyncReservedCount,
|
||||
kIOAsyncCalloutRefconIndex,
|
||||
kIOAsyncCalloutCount,
|
||||
|
||||
kIOMatchingCalloutFuncIndex = kIOAsyncReservedCount,
|
||||
kIOMatchingCalloutRefconIndex,
|
||||
kIOMatchingCalloutCount,
|
||||
|
||||
kIOInterestCalloutFuncIndex = kIOAsyncReservedCount,
|
||||
kIOInterestCalloutRefconIndex,
|
||||
kIOInterestCalloutServiceIndex,
|
||||
kIOInterestCalloutCount
|
||||
};
|
||||
|
||||
|
||||
|
||||
// --------------
|
||||
enum {
|
||||
kOSAsyncRef64Count = 8,
|
||||
kOSAsyncRef64Size = kOSAsyncRef64Count * ((int) sizeof(io_user_reference_t))
|
||||
};
|
||||
typedef io_user_reference_t OSAsyncReference64[kOSAsyncRef64Count];
|
||||
|
||||
struct OSNotificationHeader64 {
|
||||
mach_msg_size_t size; /* content size */
|
||||
natural_t type;
|
||||
OSAsyncReference64 reference;
|
||||
|
||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
||||
unsigned char content[];
|
||||
#else
|
||||
unsigned char content[0];
|
||||
#endif
|
||||
};
|
||||
|
||||
#pragma pack(4)
|
||||
struct IOServiceInterestContent64 {
|
||||
natural_t messageType;
|
||||
io_user_reference_t messageArgument[1];
|
||||
};
|
||||
#pragma pack()
|
||||
// --------------
|
||||
|
||||
#if !KERNEL_USER32
|
||||
|
||||
enum {
|
||||
kOSAsyncRefCount = 8,
|
||||
kOSAsyncRefSize = 32
|
||||
};
|
||||
typedef natural_t OSAsyncReference[kOSAsyncRefCount];
|
||||
|
||||
struct OSNotificationHeader {
|
||||
mach_msg_size_t size; /* content size */
|
||||
natural_t type;
|
||||
OSAsyncReference reference;
|
||||
|
||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
||||
unsigned char content[];
|
||||
#else
|
||||
unsigned char content[0];
|
||||
#endif
|
||||
};
|
||||
|
||||
#pragma pack(4)
|
||||
struct IOServiceInterestContent {
|
||||
natural_t messageType;
|
||||
void * messageArgument[1];
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
#endif /* KERNEL_USER32 */
|
||||
|
||||
struct IOAsyncCompletionContent {
|
||||
IOReturn result;
|
||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
||||
void * args[] __attribute__ ((packed));
|
||||
#else
|
||||
void * args[0] __attribute__ ((packed));
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef struct OSNotificationHeader OSNotificationHeader;
|
||||
typedef struct IOServiceInterestContent IOServiceInterestContent;
|
||||
typedef struct IOAsyncCompletionContent IOAsyncCompletionContent;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __OS_OSMESSAGENOTIFICATION_H */
|
||||
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2005 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IOACPIPLATFORMDEVICE_H
|
||||
#define _IOKIT_IOACPIPLATFORMDEVICE_H
|
||||
|
||||
#include <libkern/c++/OSContainers.h>
|
||||
#include <IOKit/IOPlatformExpert.h>
|
||||
#include <IOKit/acpi/IOACPITypes.h>
|
||||
|
||||
class IOACPIPlatformExpert;
|
||||
|
||||
class IOACPIPlatformDevice : public IOPlatformDevice
|
||||
{
|
||||
OSDeclareDefaultStructors( IOACPIPlatformDevice )
|
||||
|
||||
protected:
|
||||
void * _deviceHandle;
|
||||
UInt32 _deviceType;
|
||||
UInt32 _powerFlags;
|
||||
UInt32 * _powerStateFlags;
|
||||
UInt32 _sleepPowerState;
|
||||
IOService * _acpiParent;
|
||||
IOACPIPlatformExpert * _platform;
|
||||
|
||||
/*
|
||||
* This structure will be used to expand the capablilties
|
||||
* of the class in the future.
|
||||
*/
|
||||
struct ExpansionData { };
|
||||
|
||||
/*
|
||||
* Reserved for future use. (Internal use only)
|
||||
*/
|
||||
ExpansionData * reserved;
|
||||
|
||||
virtual bool initACPIPowerManagement( IOService * powerParent );
|
||||
virtual void stopACPIPowerManagement( IOService * powerParent );
|
||||
|
||||
public:
|
||||
virtual bool init( IOService * platform,
|
||||
void * handle,
|
||||
OSDictionary * properties );
|
||||
|
||||
virtual void free( void ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual bool attachToParent( IORegistryEntry * parent,
|
||||
const IORegistryPlane * plane ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual void detachFromParent( IORegistryEntry * parent,
|
||||
const IORegistryPlane * plane ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual bool getPathComponent( char * path, int * length,
|
||||
const IORegistryPlane * plane ) const APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual bool compareName( OSString * name,
|
||||
OSString ** matched ) const APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual IOReturn getResources( void ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
virtual void * getDeviceHandle( void ) const;
|
||||
|
||||
virtual UInt32 getDeviceStatus( void ) const;
|
||||
|
||||
enum {
|
||||
kTypeDevice = 0,
|
||||
kTypeProcessor = 1,
|
||||
kTypePowerResource = 2
|
||||
};
|
||||
|
||||
virtual UInt32 getDeviceType( void ) const;
|
||||
|
||||
virtual void setDeviceType( UInt32 deviceType );
|
||||
|
||||
// Method (object) evaluation
|
||||
|
||||
virtual IOReturn validateObject( const OSSymbol * objectName );
|
||||
|
||||
virtual IOReturn validateObject( const char * objectName );
|
||||
|
||||
virtual IOReturn evaluateObject( const OSSymbol * objectName,
|
||||
OSObject ** result = 0,
|
||||
OSObject * params[] = 0,
|
||||
IOItemCount paramCount = 0,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
virtual IOReturn evaluateObject( const char * objectName,
|
||||
OSObject ** result = 0,
|
||||
OSObject * params[] = 0,
|
||||
IOItemCount paramCount = 0,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
virtual IOReturn evaluateInteger( const OSSymbol * objectName,
|
||||
UInt32 * resultInt32,
|
||||
OSObject * params[] = 0,
|
||||
IOItemCount paramCount = 0,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
virtual IOReturn evaluateInteger( const char * objectName,
|
||||
UInt32 * resultInt32,
|
||||
OSObject * params[] = 0,
|
||||
IOItemCount paramCount = 0,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
virtual IOReturn evaluateInteger( const OSSymbol * objectName,
|
||||
UInt64 * resultInt64,
|
||||
OSObject * params[] = 0,
|
||||
IOItemCount paramCount = 0,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
virtual IOReturn evaluateInteger( const char * objectName,
|
||||
UInt64 * resultInt64,
|
||||
OSObject * params[] = 0,
|
||||
IOItemCount paramCount = 0,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
// ACPI table access
|
||||
|
||||
virtual const OSData * getACPITableData( const char * tableName,
|
||||
UInt32 tableInstance = 0 ) const;
|
||||
|
||||
// Map ACPI event to interrupt event source index
|
||||
|
||||
virtual SInt32 installInterruptForFixedEvent( UInt32 fixedEvent );
|
||||
|
||||
virtual SInt32 installInterruptForGPE( UInt32 gpeNumber,
|
||||
void * gpeBlockDevice = 0,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
// ACPI global lock acquire/release
|
||||
|
||||
virtual IOReturn acquireGlobalLock( UInt32 * lockToken,
|
||||
const mach_timespec_t * timeout = 0 );
|
||||
|
||||
virtual void releaseGlobalLock( UInt32 lockToken );
|
||||
|
||||
// Address space handler registration
|
||||
|
||||
virtual IOReturn registerAddressSpaceHandler(
|
||||
IOACPIAddressSpaceID spaceID,
|
||||
IOACPIAddressSpaceHandler handler,
|
||||
void * context,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
virtual void unregisterAddressSpaceHandler(
|
||||
IOACPIAddressSpaceID spaceID,
|
||||
IOACPIAddressSpaceHandler handler,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
// Address space access
|
||||
|
||||
virtual IOReturn readAddressSpace( UInt64 * value,
|
||||
IOACPIAddressSpaceID spaceID,
|
||||
IOACPIAddress address,
|
||||
UInt32 bitWidth,
|
||||
UInt32 bitOffset = 0,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
virtual IOReturn writeAddressSpace( UInt64 value,
|
||||
IOACPIAddressSpaceID spaceID,
|
||||
IOACPIAddress address,
|
||||
UInt32 bitWidth,
|
||||
UInt32 bitOffset = 0,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
// Power management
|
||||
|
||||
virtual bool hasSystemWakeCapability( void ) const;
|
||||
|
||||
virtual IOReturn setSystemWakeCapabilityEnable( bool enable );
|
||||
|
||||
virtual bool hasACPIPowerStateSupport( UInt32 powerState ) const;
|
||||
|
||||
virtual IOReturn setACPIPowerManagementEnable(
|
||||
bool enable,
|
||||
UInt32 powerState = kIOACPIDevicePowerStateD3,
|
||||
IOOptionBits options = 0 );
|
||||
|
||||
virtual IOReturn setPowerState( unsigned long powerState,
|
||||
IOService * whatDevice ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
// I/O space helpers
|
||||
|
||||
virtual void ioWrite32( UInt16 offset, UInt32 value,
|
||||
IOMemoryMap * map = 0 );
|
||||
|
||||
virtual void ioWrite16( UInt16 offset, UInt16 value,
|
||||
IOMemoryMap * map = 0 );
|
||||
|
||||
virtual void ioWrite8( UInt16 offset, UInt8 value,
|
||||
IOMemoryMap * map = 0 );
|
||||
|
||||
virtual UInt32 ioRead32( UInt16 offset, IOMemoryMap * map = 0 );
|
||||
|
||||
virtual UInt16 ioRead16( UInt16 offset, IOMemoryMap * map = 0 );
|
||||
|
||||
virtual UInt8 ioRead8( UInt16 offset, IOMemoryMap * map = 0 );
|
||||
|
||||
// vtable padding
|
||||
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 0 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 1 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 2 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 3 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 4 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 5 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 6 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 7 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 8 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 9 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 10 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 11 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 12 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 13 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 14 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 15 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 16 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 17 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 18 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 19 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 20 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 21 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 22 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 23 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 24 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 25 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 26 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 27 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 28 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 29 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 30 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformDevice, 31 );
|
||||
};
|
||||
|
||||
#endif /* !_IOKIT_IOACPIPLATFORMDEVICE_H */
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2005 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IOACPIPLATFORMEXPERT_H
|
||||
#define _IOKIT_IOACPIPLATFORMEXPERT_H
|
||||
|
||||
#include <IOKit/IOPlatformExpert.h> // superclass
|
||||
#include <IOKit/acpi/IOACPIPlatformDevice.h> // children
|
||||
|
||||
class IOACPIPlatformExpert : public IODTPlatformExpert
|
||||
{
|
||||
OSDeclareAbstractStructors( IOACPIPlatformExpert )
|
||||
|
||||
friend class IOACPIPlatformDevice;
|
||||
|
||||
protected:
|
||||
/*! @struct ExpansionData
|
||||
@discussion This structure will be used to expand the capablilties
|
||||
of the class in the future.
|
||||
*/
|
||||
struct ExpansionData { };
|
||||
|
||||
/*! @var reserved
|
||||
Reserved for future use. (Internal use only)
|
||||
*/
|
||||
ExpansionData * reserved;
|
||||
|
||||
public:
|
||||
virtual bool start( IOService * provider ) APPLE_KEXT_OVERRIDE;
|
||||
|
||||
protected:
|
||||
// Map ACPI event to interrupt event source index
|
||||
|
||||
virtual SInt32 installDeviceInterruptForFixedEvent(
|
||||
IOService * device,
|
||||
UInt32 fixedEvent ) = 0;
|
||||
|
||||
virtual SInt32 installDeviceInterruptForGPE(
|
||||
IOService * device,
|
||||
UInt32 gpeNumber,
|
||||
void * gpeBlockDevice,
|
||||
IOOptionBits options ) = 0;
|
||||
|
||||
// ACPI global lock acquisition
|
||||
|
||||
virtual IOReturn acquireGlobalLock( IOService * client,
|
||||
UInt32 * lockToken,
|
||||
const mach_timespec_t * timeout ) = 0;
|
||||
|
||||
virtual void releaseGlobalLock( IOService * client,
|
||||
UInt32 lockToken ) = 0;
|
||||
|
||||
// ACPI method and object evaluation
|
||||
|
||||
virtual IOReturn validateObject( IOACPIPlatformDevice * device,
|
||||
const OSSymbol * objectName ) = 0;
|
||||
|
||||
virtual IOReturn validateObject( IOACPIPlatformDevice * device,
|
||||
const char * objectName );
|
||||
|
||||
virtual IOReturn evaluateObject( IOACPIPlatformDevice * device,
|
||||
const OSSymbol * objectName,
|
||||
OSObject ** result,
|
||||
OSObject * params[],
|
||||
IOItemCount paramCount,
|
||||
IOOptionBits options ) = 0;
|
||||
|
||||
virtual IOReturn evaluateObject( IOACPIPlatformDevice * device,
|
||||
const char * objectName,
|
||||
OSObject ** result,
|
||||
OSObject * params[],
|
||||
IOItemCount paramCount,
|
||||
IOOptionBits options );
|
||||
|
||||
// ACPI table
|
||||
|
||||
virtual const OSData * getACPITableData(
|
||||
const char * tableName,
|
||||
UInt32 tableInstance ) = 0;
|
||||
|
||||
// Address space handler
|
||||
|
||||
virtual IOReturn registerAddressSpaceHandler(
|
||||
IOACPIPlatformDevice * device,
|
||||
IOACPIAddressSpaceID spaceID,
|
||||
IOACPIAddressSpaceHandler handler,
|
||||
void * context,
|
||||
IOOptionBits options ) = 0;
|
||||
|
||||
virtual void unregisterAddressSpaceHandler(
|
||||
IOACPIPlatformDevice * device,
|
||||
IOACPIAddressSpaceID spaceID,
|
||||
IOACPIAddressSpaceHandler handler,
|
||||
IOOptionBits options ) = 0;
|
||||
|
||||
// Address space read/write
|
||||
|
||||
virtual IOReturn readAddressSpace( UInt64 * value,
|
||||
IOACPIAddressSpaceID spaceID,
|
||||
IOACPIAddress address,
|
||||
UInt32 bitWidth,
|
||||
UInt32 bitOffset,
|
||||
IOOptionBits options ) = 0;
|
||||
|
||||
virtual IOReturn writeAddressSpace( UInt64 value,
|
||||
IOACPIAddressSpaceID spaceID,
|
||||
IOACPIAddress address,
|
||||
UInt32 bitWidth,
|
||||
UInt32 bitOffset,
|
||||
IOOptionBits options ) = 0;
|
||||
|
||||
// Device power management
|
||||
|
||||
virtual IOReturn setDevicePowerState( IOACPIPlatformDevice * device,
|
||||
UInt32 powerState ) = 0;
|
||||
|
||||
virtual IOReturn getDevicePowerState( IOACPIPlatformDevice * device,
|
||||
UInt32 * powerState ) = 0;
|
||||
|
||||
virtual IOReturn setDeviceWakeEnable( IOACPIPlatformDevice * device,
|
||||
bool enable ) = 0;
|
||||
|
||||
// vtable padding
|
||||
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 0 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 1 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 2 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 3 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 4 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 5 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 6 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 7 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 8 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 9 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 10 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 11 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 12 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 13 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 14 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 15 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 16 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 17 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 18 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 19 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 20 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 21 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 22 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 23 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 24 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 25 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 26 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 27 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 28 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 29 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 30 );
|
||||
OSMetaClassDeclareReservedUnused( IOACPIPlatformExpert, 31 );
|
||||
};
|
||||
|
||||
#endif /* !_IOKIT_IOACPIPLATFORMEXPERT_H */
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2005 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __IOKIT_IOACPITYPES_H
|
||||
#define __IOKIT_IOACPITYPES_H
|
||||
|
||||
#include <IOKit/IOMessage.h>
|
||||
|
||||
extern const IORegistryPlane * gIOACPIPlane;
|
||||
extern const OSSymbol * gIOACPIHardwareIDKey;
|
||||
extern const OSSymbol * gIOACPIUniqueIDKey;
|
||||
extern const OSSymbol * gIOACPIAddressKey;
|
||||
extern const OSSymbol * gIOACPIDeviceStatusKey;
|
||||
|
||||
#define kIOACPIInterruptTypeValid (1 << 1)
|
||||
#pragma pack(1)
|
||||
|
||||
struct IOACPIAddressSpaceDescriptor {
|
||||
UInt32 resourceType;
|
||||
UInt32 generalFlags;
|
||||
UInt32 typeSpecificFlags;
|
||||
UInt32 reserved1;
|
||||
UInt64 granularity;
|
||||
UInt64 minAddressRange;
|
||||
UInt64 maxAddressRange;
|
||||
UInt64 translationOffset;
|
||||
UInt64 addressLength;
|
||||
UInt64 reserved2;
|
||||
UInt64 reserved3;
|
||||
UInt64 reserved4;
|
||||
};
|
||||
|
||||
enum {
|
||||
kIOACPIMemoryRange = 0,
|
||||
kIOACPIIORange = 1,
|
||||
kIOACPIBusNumberRange = 2
|
||||
};
|
||||
|
||||
typedef UInt32 IOACPIAddressSpaceID;
|
||||
|
||||
enum {
|
||||
kIOACPIAddressSpaceIDSystemMemory = 0,
|
||||
kIOACPIAddressSpaceIDSystemIO = 1,
|
||||
kIOACPIAddressSpaceIDPCIConfiguration = 2,
|
||||
kIOACPIAddressSpaceIDEmbeddedController = 3,
|
||||
kIOACPIAddressSpaceIDSMBus = 4
|
||||
};
|
||||
|
||||
/*
|
||||
* Address space operation
|
||||
*/
|
||||
enum {
|
||||
kIOACPIAddressSpaceOpRead = 0,
|
||||
kIOACPIAddressSpaceOpWrite = 1
|
||||
};
|
||||
|
||||
/*
|
||||
* 64-bit ACPI address
|
||||
*/
|
||||
union IOACPIAddress {
|
||||
UInt64 addr64;
|
||||
struct {
|
||||
unsigned int offset :16;
|
||||
unsigned int function :3;
|
||||
unsigned int device :5;
|
||||
unsigned int bus :8;
|
||||
unsigned int segment :16;
|
||||
unsigned int reserved :16;
|
||||
} pci;
|
||||
};
|
||||
|
||||
/*
|
||||
* Address space handler
|
||||
*/
|
||||
typedef IOReturn (*IOACPIAddressSpaceHandler)( UInt32 operation,
|
||||
IOACPIAddress address,
|
||||
UInt64 * value,
|
||||
UInt32 bitWidth,
|
||||
UInt32 bitOffset,
|
||||
void * context );
|
||||
|
||||
/*
|
||||
* ACPI fixed event types
|
||||
*/
|
||||
enum {
|
||||
kIOACPIFixedEventPMTimer = 0,
|
||||
kIOACPIFixedEventPowerButton = 2,
|
||||
kIOACPIFixedEventSleepButton = 3,
|
||||
kIOACPIFixedEventRealTimeClock = 4
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*
|
||||
* FIXME: Move to xnu/iokit to reserve the ACPI family code.
|
||||
*/
|
||||
#ifndef sub_iokit_acpi
|
||||
#define sub_iokit_acpi err_sub(10)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ACPI notify message sent to all clients and interested parties.
|
||||
* The notify code can be read from the argument as an UInt32.
|
||||
*/
|
||||
#define kIOACPIMessageDeviceNotification iokit_family_msg(sub_iokit_acpi, 0x10)
|
||||
|
||||
/*
|
||||
* ACPI device power states
|
||||
*/
|
||||
enum {
|
||||
kIOACPIDevicePowerStateD0 = 0,
|
||||
kIOACPIDevicePowerStateD1 = 1,
|
||||
kIOACPIDevicePowerStateD2 = 2,
|
||||
kIOACPIDevicePowerStateD3 = 3,
|
||||
kIOACPIDevicePowerStateCount = 4
|
||||
};
|
||||
|
||||
#endif /* !__IOKIT_IOACPITYPES_H */
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IO_ASSERT_H_
|
||||
#define _IO_ASSERT_H_
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if IOASSERT
|
||||
#undef MACH_ASSERT
|
||||
#define MACH_ASSERT 1
|
||||
#endif
|
||||
#include <kern/assert.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if(!defined(OSCompileAssert))
|
||||
# define OSCompileAssert( TEST ) \
|
||||
extern int OSCompileAssertFailed[ ( TEST ) ? 1 : -1 ] __unused;
|
||||
#endif
|
||||
|
||||
#endif /* _IO_ASSERT_H_ */
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*!
|
||||
@header ATADeviceNub.h
|
||||
@abstract A concrete implementation of IOATADevice.
|
||||
*/
|
||||
|
||||
#ifndef _ATADEVICENUB_H
|
||||
#define _ATADEVICENUB_H
|
||||
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include "IOATATypes.h"
|
||||
#include "IOATADevice.h"
|
||||
#include "IOATAController.h"
|
||||
|
||||
#include "IOATABusCommand.h"
|
||||
|
||||
|
||||
/*!
|
||||
@class ATADeviceNub
|
||||
@abstract ATADeviceNub is a concrete implementation of IOATADevice.
|
||||
@discussion clients of IOATA (disk drivers) should use the interface presented
|
||||
by IOATADevice. Concrete nubs are private to the IOATA family and
|
||||
specific subclasses of IOATADevice are instantiated by controller
|
||||
drivers to provide the abstract interface to clients.
|
||||
|
||||
*/
|
||||
class ATADeviceNub : public IOATADevice
|
||||
{
|
||||
OSDeclareDefaultStructors(ATADeviceNub);
|
||||
|
||||
public:
|
||||
|
||||
/*!@function ataDeviceNub
|
||||
@abstract static creator function - used by IOATAControllers to create nubs.
|
||||
*/
|
||||
static ATADeviceNub* ataDeviceNub( IOATAController* provider, ataUnitID unit, ataDeviceType devType);
|
||||
|
||||
/*!@function attach
|
||||
@abstract override of IOService method.
|
||||
*/
|
||||
virtual bool attach(IOService* provider );
|
||||
|
||||
|
||||
// overrides from IOATADevice to provide actual client interface
|
||||
|
||||
|
||||
/*!@function executeCommand
|
||||
@abstract Submit IO requests
|
||||
*/
|
||||
virtual IOReturn executeCommand(IOATACommand* command);
|
||||
|
||||
// create and destroy IOATACommands
|
||||
/*!@function allocCommand
|
||||
@abstract create command objects for clients.
|
||||
*/
|
||||
virtual IOATACommand* allocCommand( void );
|
||||
|
||||
/*!@function freeCommand
|
||||
@abstract Clients use this method to dispose of command objects.
|
||||
*/
|
||||
virtual void freeCommand( IOATACommand* inCommand);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/*!@function init
|
||||
@abstract used after creating the nub.
|
||||
*/
|
||||
virtual bool init(IOATAController* provider, ataUnitID unit, ataDeviceType devType);
|
||||
|
||||
/*!@function publishProperties
|
||||
@abstract publish the nub's properties in the device tree.
|
||||
*/
|
||||
virtual void publishProperties( void );
|
||||
|
||||
/*!@function publishBusProperties
|
||||
@abstract puts info about this device's bus capability in the device tree.
|
||||
*/
|
||||
virtual void publishBusProperties(void);
|
||||
|
||||
/*!@function publishVendorProperties
|
||||
@abstract will be deprecated.
|
||||
*/
|
||||
virtual void publishVendorProperties( void );
|
||||
|
||||
/*!@function getDeviceID
|
||||
@abstract get the unit id of this drive (0 or 1)
|
||||
*/
|
||||
virtual IOReturn getDeviceID(void);
|
||||
|
||||
/*!@function MyATACallback
|
||||
@abstract to be deprecated.
|
||||
*/
|
||||
static void MyATACallback(IOATACommand* command );
|
||||
|
||||
/*!@function processCallback
|
||||
@abstract to be deprecated.
|
||||
*/
|
||||
void processCallback(IOATACommand* command );
|
||||
|
||||
/*!@function swapBytes16
|
||||
@abstract to be deprecated.
|
||||
*/
|
||||
void swapBytes16( UInt8* dataBuffer, IOByteCount length);
|
||||
|
||||
UInt8* buffer;
|
||||
|
||||
protected:
|
||||
/*! @struct ExpansionData
|
||||
@discussion This structure will be used to expand the capablilties of the ATADeviceNub in the future.
|
||||
*/
|
||||
struct ExpansionData { };
|
||||
|
||||
/*! @var reserved
|
||||
Reserved for future use. (Internal use only) */
|
||||
ExpansionData *reserved;
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 0);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 1);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 2);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 3);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 4);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 5);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 6);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 7);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 8);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 9);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 10);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 11);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 12);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 13);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 14);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 15);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 16);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 17);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 18);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 19);
|
||||
OSMetaClassDeclareReservedUnused(ATADeviceNub, 20);
|
||||
|
||||
};
|
||||
|
||||
#endif /* !_IOATABUSNUB_H */
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2008 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _ATATIMEREVENTSOURCE_H
|
||||
#define _ATATIMEREVENTSOURCE_H
|
||||
|
||||
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include <IOKit/IOCommandGate.h>
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/IOWorkLoop.h>
|
||||
#include <IOKit/IOTimerEventSource.h>
|
||||
#include <IOKit/ndrvsupport/IOMacOSTypes.h>
|
||||
|
||||
|
||||
/*!
|
||||
@class ATATimerEventSource
|
||||
|
||||
@discussion
|
||||
Extend the timer event source to allow checking for timer expiration
|
||||
from behind the workloop.
|
||||
*/
|
||||
|
||||
class ATATimerEventSource : public IOTimerEventSource
|
||||
{
|
||||
OSDeclareDefaultStructors(ATATimerEventSource);
|
||||
|
||||
public:
|
||||
|
||||
/*!@function ataTimerEventSource
|
||||
@abstract allocate an instance of this type.
|
||||
*/
|
||||
static ATATimerEventSource *
|
||||
ataTimerEventSource(OSObject *owner, Action action = 0);
|
||||
|
||||
/*!@function hasTimedOut
|
||||
@abstract returns true if the timer has expired since the last enable/disable or setTimeout() or wakeAtTime() call.
|
||||
*/
|
||||
virtual bool hasTimedOut( void );
|
||||
|
||||
// override to initialize the time out flag.
|
||||
/*!@function
|
||||
@abstract
|
||||
*/
|
||||
virtual bool init(OSObject *owner, Action action = 0);
|
||||
|
||||
/*!@function enable
|
||||
@abstract overrides in order to set/clear the timed out flag
|
||||
*/
|
||||
virtual void enable();
|
||||
|
||||
/*!@function disable
|
||||
@abstract overrides in order to set/clear the timed out flag
|
||||
*/
|
||||
virtual void disable();
|
||||
|
||||
/*!@function wakeAtTime
|
||||
@abstract overrides in order to set/clear the timed out flag
|
||||
*/
|
||||
virtual IOReturn wakeAtTime(UnsignedWide abstime);
|
||||
|
||||
/*!@function cancelTimeout
|
||||
@abstract overrides in order to set/clear the timed out flag
|
||||
*/
|
||||
virtual void cancelTimeout();
|
||||
|
||||
protected:
|
||||
|
||||
enum{ kTimedOutTrue = 'true',
|
||||
kTimedOutFalse = 'fals'
|
||||
};
|
||||
|
||||
UInt32 hasExpired;
|
||||
|
||||
|
||||
/*!@function myTimeout
|
||||
@abstract my timeout function which sets the timedOut flag atomically.
|
||||
*/
|
||||
static void myTimeout(void *self);
|
||||
|
||||
/*!@function setTimeoutFunc
|
||||
@abstract override to install my timeout function instead of the super's.
|
||||
*/
|
||||
virtual void setTimeoutFunc();
|
||||
|
||||
/*! @struct ExpansionData
|
||||
@discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
|
||||
*/
|
||||
struct ExpansionData { };
|
||||
|
||||
/*! @var reserved
|
||||
Reserved for future use. (Internal use only) */
|
||||
ExpansionData *reserved;
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUnused(ATATimerEventSource, 0);
|
||||
OSMetaClassDeclareReservedUnused(ATATimerEventSource, 1);
|
||||
OSMetaClassDeclareReservedUnused(ATATimerEventSource, 2);
|
||||
OSMetaClassDeclareReservedUnused(ATATimerEventSource, 3);
|
||||
OSMetaClassDeclareReservedUnused(ATATimerEventSource, 4);
|
||||
OSMetaClassDeclareReservedUnused(ATATimerEventSource, 5);
|
||||
OSMetaClassDeclareReservedUnused(ATATimerEventSource, 6);
|
||||
OSMetaClassDeclareReservedUnused(ATATimerEventSource, 7);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /*_ATATIMEREVENTSOURCE_H*/
|
||||
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* IOATABusCommand.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IOATABUSCOMMAND_H
|
||||
#define _IOATABUSCOMMAND_H
|
||||
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include "IOATATypes.h"
|
||||
#include "IOATACommand.h"
|
||||
|
||||
|
||||
class IOSyncer;
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
@class IOATABusCommand
|
||||
|
||||
@discussion ATA Device (disk) drivers should use the superclass, IOATACommand
|
||||
and may not derive or use any subclass of IOATACommand.
|
||||
|
||||
IOATABusCommand is the subclass of IOATACommand used by
|
||||
IOATAControllers. Controller classes may override this class to
|
||||
provide additional fields as their needs dictate or may use this
|
||||
as a concrete class if it is sufficient.
|
||||
|
||||
IOATAControllers are always paired with specific IOATADevices
|
||||
and each specific subclass of IOATADevice is in turn the factory method
|
||||
for IOATACommands for use by disk drivers.
|
||||
|
||||
In this manner, mass-storage device drivers (disk drivers, clients of
|
||||
ATA bus controllers) see only the generalized interface of IOATADevice
|
||||
and the generalized interface of IOATACommand. This provides isolation
|
||||
from specific bus details for disk drivers and offers flexibility to
|
||||
controllers to add per-command fields and state variables for their own
|
||||
internal use.
|
||||
|
||||
*/
|
||||
|
||||
class IOATABusCommand : public IOATACommand {
|
||||
|
||||
OSDeclareDefaultStructors( IOATABusCommand );
|
||||
|
||||
public:
|
||||
|
||||
// data items for use by IOATAController
|
||||
|
||||
/*! @var queueChain queue header for use by IOATAController. */
|
||||
queue_chain_t queueChain;
|
||||
|
||||
/*! @var state state-semaphore for use by IOATAController */
|
||||
UInt32 state;
|
||||
|
||||
/*! @var syncer IOSyncer for use by IOATAController */
|
||||
IOSyncer* syncer;
|
||||
|
||||
|
||||
|
||||
/*!@function allocateCmd
|
||||
@abstract factory method to create an instance of this class used by subclasses of IOATADevice
|
||||
*/
|
||||
static IOATABusCommand* allocateCmd(void);
|
||||
|
||||
/*!@function zeroCommand
|
||||
@abstract set to blank state, call prior to re-use of this object
|
||||
*/
|
||||
virtual void zeroCommand(void);
|
||||
|
||||
/*!@function getOpcode
|
||||
@abstract return the command opcode
|
||||
*/
|
||||
virtual ataOpcode getOpcode( void );
|
||||
|
||||
/*!@function getFlags
|
||||
@abstract return the flags for this command.
|
||||
*/
|
||||
virtual ataFlags getFlags ( void );
|
||||
|
||||
/*!@function getRegMask
|
||||
@abstract get the register mask for desired regs
|
||||
*/
|
||||
virtual ataRegMask getRegMask( void );
|
||||
|
||||
/*!@function getUnit
|
||||
@abstract return the unit id (0 master, 1 slave)
|
||||
*/
|
||||
virtual ataUnitID getUnit( void );
|
||||
|
||||
/*!@function getTimeoutMS
|
||||
@abstract return the timeout value for this command
|
||||
*/
|
||||
virtual UInt32 getTimeoutMS (void );
|
||||
|
||||
/*!@function setResult
|
||||
@abstract set the result code
|
||||
*/
|
||||
virtual void setResult( IOReturn );
|
||||
|
||||
/*!@function getCallbackPtr
|
||||
@abstract return the callback pointer
|
||||
*/
|
||||
virtual IOATACompletionFunction* getCallbackPtr (void );
|
||||
|
||||
|
||||
/*!@function executeCallback
|
||||
@abstract call the completion callback function
|
||||
*/
|
||||
virtual void executeCallback(void);
|
||||
|
||||
/*!@function getTaskFilePtr
|
||||
@abstract return the taskfile structure pointer.
|
||||
*/
|
||||
virtual ataTaskFile* getTaskFilePtr(void);
|
||||
|
||||
/*!@function getPacketSize
|
||||
@abstract return the size of atapi packet if any.
|
||||
*/
|
||||
virtual UInt16 getPacketSize(void);
|
||||
|
||||
/*!@function getPacketData
|
||||
@abstract return pointer to the array of packet data.
|
||||
*/
|
||||
virtual UInt16* getPacketData(void);
|
||||
|
||||
/*!@function getTransferChunkSize
|
||||
@abstract number of bytes between interrupts.
|
||||
*/
|
||||
virtual IOByteCount getTransferChunkSize(void);
|
||||
|
||||
/*!@function setActualTransfer
|
||||
@abstract set the byte count of bytes actually transferred.
|
||||
*/
|
||||
virtual void setActualTransfer ( IOByteCount bytesTransferred );
|
||||
|
||||
/*!@function getBuffer
|
||||
@abstract get pointer to the memory descriptor for this transaction
|
||||
*/
|
||||
virtual IOMemoryDescriptor* getBuffer ( void);
|
||||
|
||||
/*!@function getPosition
|
||||
@abstract the position within the memory buffer for the transaction.
|
||||
*/
|
||||
virtual IOByteCount getPosition (void);
|
||||
|
||||
/*!@function getByteCount
|
||||
@abstract return the byte count for this transaction to transfer.
|
||||
*/
|
||||
virtual IOByteCount getByteCount (void);
|
||||
|
||||
/*!@function setCommandInUse
|
||||
@abstract mark the command as being in progress.
|
||||
*/
|
||||
virtual void setCommandInUse( bool inUse = true);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
//
|
||||
/*!@function init
|
||||
@abstract Zeroes all data, returns false if allocation fails. protected.
|
||||
*/
|
||||
virtual bool init();
|
||||
|
||||
/*! @struct ExpansionData
|
||||
@discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
|
||||
*/
|
||||
struct ExpansionData { };
|
||||
|
||||
/*! @var reserved
|
||||
Reserved for future use. (Internal use only) */
|
||||
ExpansionData *reserved;
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 10);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 11);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 12);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 13);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 14);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 15);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 16);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 17);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 18);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 19);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusCommand, 20);
|
||||
};
|
||||
|
||||
#include <IOKit/IODMACommand.h>
|
||||
|
||||
class IOATABusCommand64 : public IOATABusCommand
|
||||
{
|
||||
|
||||
OSDeclareDefaultStructors( IOATABusCommand64 );
|
||||
|
||||
public:
|
||||
|
||||
// new features
|
||||
static IOATABusCommand64* allocateCmd32(void);
|
||||
virtual IODMACommand* GetDMACommand( void );
|
||||
|
||||
|
||||
|
||||
// overrides for IODMACommand setup
|
||||
virtual void zeroCommand(void);
|
||||
virtual void setBuffer ( IOMemoryDescriptor* inDesc);
|
||||
virtual void setCommandInUse( bool inUse = true);
|
||||
virtual void executeCallback(void);
|
||||
|
||||
|
||||
protected:
|
||||
IODMACommand* _dmaCmd;
|
||||
virtual bool init();
|
||||
virtual void free();
|
||||
};
|
||||
|
||||
#endif /*_IOATABUSCOMMAND_H*/
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2008 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _IOATABUSINFO_H
|
||||
#define _IOATABUSINFO_H
|
||||
|
||||
#include <libkern/c++/OSObject.h>
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include "IOATATypes.h"
|
||||
|
||||
/*!
|
||||
@class IOATABusInfo
|
||||
@discussion used to indicate the capabilities of the bus the device is connected to, PIO and DMA modes supported, etc.
|
||||
*/
|
||||
|
||||
class IOATABusInfo : public OSObject
|
||||
{
|
||||
OSDeclareDefaultStructors( IOATABusInfo );
|
||||
|
||||
public:
|
||||
|
||||
/*!@function atabusinfo
|
||||
@abstract factory method
|
||||
*/
|
||||
static IOATABusInfo* atabusinfo(void);
|
||||
|
||||
/*!@function zeroData
|
||||
@abstract set this object to a blank state.
|
||||
*/
|
||||
virtual void zeroData(void);
|
||||
|
||||
// Used by clients of ATAControllers to find out about the bus
|
||||
// capability.
|
||||
|
||||
/*!@function getSocketType
|
||||
@abstract returns the socket type, internal fixed, media-bay, PC-Card
|
||||
Used by clients of ATAControllers to find out about the bus
|
||||
*/
|
||||
ataSocketType getSocketType( void );
|
||||
|
||||
/*!@function getPIOModes
|
||||
@abstract returns the bit-significant map of PIO mode(s) supported on the bus.
|
||||
Used by clients of ATAControllers to find out about the bus.
|
||||
*/
|
||||
UInt8 getPIOModes( void );
|
||||
|
||||
/*!@function getDMAModes
|
||||
@abstract bit-significant map of DMA mode(s) supported on the bus.
|
||||
Used by clients of ATAControllers to find out about the bus.
|
||||
*/
|
||||
UInt8 getDMAModes( void );
|
||||
|
||||
/*!@function getUltraModes
|
||||
@abstract bit-significant map of Ultra mode(s) supported on the bus.
|
||||
Used by clients of ATAControllers to find out about the bus.
|
||||
*/
|
||||
UInt8 getUltraModes( void );
|
||||
|
||||
/*!@function getUnits
|
||||
@abstract How many devices are present on bus.
|
||||
Used by clients of ATAControllers to find out about the bus.
|
||||
*/
|
||||
UInt8 getUnits( void );
|
||||
|
||||
/*!@function supportsDMA
|
||||
@abstract True = DMA supported on bus - inferred by looking at the DMA mode bits.
|
||||
Used by clients of ATAControllers to find out about the bus.
|
||||
*/
|
||||
bool supportsDMA( void );
|
||||
|
||||
/*!@function supportsExtendedLBA
|
||||
@abstract Supports 48-bit LBA if true.
|
||||
Used by clients of ATAControllers to find out about the bus.
|
||||
*/
|
||||
bool supportsExtendedLBA( void );
|
||||
|
||||
/*!@function maxBlocksExtended
|
||||
@abstract The maximum number of 512-byte blocks this controller supports
|
||||
in a single Extended LBA transfer. Some controllers may be limited to less than
|
||||
the maximum sector count allowed under extended LBA protocol.
|
||||
*/
|
||||
UInt16 maxBlocksExtended(void);
|
||||
|
||||
/*!@function supportsOverlapped
|
||||
@abstract Supports overlapped packet feature set if true.
|
||||
Used by clients of ATAControllers to find out about the bus.
|
||||
*/
|
||||
bool supportsOverlapped( void );
|
||||
|
||||
/*!@function supportsDMAQueued
|
||||
@abstract Supports DMA Queued Feature set if true.
|
||||
Used by clients of ATAControllers to find out about the bus.
|
||||
*/
|
||||
bool supportsDMAQueued( void );
|
||||
|
||||
|
||||
// Used by ATAControllers to generate an information object.
|
||||
// Would not be used by disk device drivers normally.
|
||||
// Bus controllers should set these items everytime.
|
||||
|
||||
/*!@function setSocketType
|
||||
@abstract internal fixed, media-bay, PC-Card. Set by ATAControllers.
|
||||
*/
|
||||
void setSocketType( ataSocketType inSocketType );
|
||||
|
||||
/*!@function setPIOModes
|
||||
@abstract Bit significant map of supported transfer modes. Set by ATAControllers.
|
||||
*/
|
||||
void setPIOModes( UInt8 inModeBitMap);
|
||||
|
||||
/*!@function setDMAModes
|
||||
@abstract Bit significant map of supported transfer modes. Set by ATAControllers.
|
||||
*/
|
||||
void setDMAModes( UInt8 inModeBitMap );
|
||||
|
||||
/*!@function setUltraModes
|
||||
@abstract Bit significant map of supported transfer modes. Set by ATAControllers.
|
||||
*/
|
||||
void setUltraModes( UInt8 inModeBitMap );
|
||||
|
||||
/*!@function setUnits
|
||||
@abstract set to indicate how many devices are on this bus. Set by ATAControllers.
|
||||
*/
|
||||
void setUnits( UInt8 inNumUnits );
|
||||
|
||||
// Optional bus protocols some busses may support
|
||||
/*!@function setExtendedLBA
|
||||
@abstract Set true for supports 48-bit LBA. Set by ATAControllers.
|
||||
*/
|
||||
void setExtendedLBA( bool inState );
|
||||
|
||||
/*!function setMaxBlocksExtended
|
||||
@abstract value set by controllers to indicate the maximum number of blocks
|
||||
allowed in a single transfer of data. Some dma engines may not be capable of supporting the full
|
||||
16-bit worth of sector count allowed under 48 bit extended LBA. Default is 256 blocks, same as
|
||||
standard ATA.
|
||||
*/
|
||||
void setMaxBlocksExtended( UInt16 inMaxBlocks);
|
||||
|
||||
/*!@function setOverlapped
|
||||
@abstract Set true for supports overlapped packet feature set. Set by ATAControllers.
|
||||
*/
|
||||
void setOverlapped( bool inState);
|
||||
|
||||
/*!@function setDMAQueued
|
||||
@abstract Set true if supports DMA Queued Feature. Set by ATAControllers.
|
||||
*/
|
||||
void setDMAQueued( bool inState); //
|
||||
|
||||
protected:
|
||||
|
||||
UInt8 _PIOModes; /* PIO modes supported (bit-significant) */
|
||||
UInt8 _MultiDMAModes; /* <--: Multiword DMA modes supported (b-sig) */
|
||||
UInt8 _UltraDMAModes; /* <--: Ultra DMA modes supported (b-sig) */
|
||||
bool _ExtendedLBA; /* <--: Suppports 48-bit LBA protocol */
|
||||
bool _Overlapped; /* <--: Supports overlapped packet feature set */
|
||||
bool _DMAQueued; /* <--: Supports DMA Queued Feature set */
|
||||
ataSocketType _SocketType; /* <--: Indicates bus is fixed internal, removable media-bay, removable PC-Card or unknown type */
|
||||
UInt8 _numUnits; /* <--: How many devices on this bus */
|
||||
UInt16 _maxBlocksExtended;
|
||||
|
||||
protected:
|
||||
/*! @struct ExpansionData
|
||||
@discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
|
||||
*/
|
||||
struct ExpansionData { };
|
||||
|
||||
/*! @var reserved
|
||||
Reserved for future use. (Internal use only) */
|
||||
ExpansionData *reserved;
|
||||
|
||||
virtual bool init();
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 10);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 11);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 12);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 13);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 14);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 15);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 16);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 17);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 18);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 19);
|
||||
OSMetaClassDeclareReservedUnused(IOATABusInfo, 20);
|
||||
};
|
||||
|
||||
|
||||
#endif /* !_IOATABUSINFO_H */
|
||||
@@ -0,0 +1,478 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* IOATACommand.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IOATACOMMAND_H
|
||||
#define _IOATACOMMAND_H
|
||||
|
||||
#include <libkern/c++/OSObject.h>
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include <IOKit/IOMemoryDescriptor.h>
|
||||
#include <IOKit/IOCommand.h>
|
||||
#include "IOATATypes.h"
|
||||
|
||||
|
||||
class IOExtendedLBA;
|
||||
class IOATACommand;
|
||||
|
||||
|
||||
/*! @typedef IOATACompletionFunction callback function for ATA disk devices.
|
||||
*/
|
||||
typedef void (IOATACompletionFunction)(IOATACommand* command );
|
||||
|
||||
|
||||
/*!
|
||||
@class IOATACommand
|
||||
|
||||
@discussion
|
||||
Command structure superclass, created and freed only by IOATADevice objects
|
||||
populated by disk device drivers with command parameters
|
||||
then submitted for operation to their IOATADevice provider for execution.
|
||||
|
||||
IOATACommand is a virtual class, a concrete subclass contains the methods and fields needed
|
||||
by IOATAControllers. Subclasses may be specific to particular controller hardware.
|
||||
Disk device drivers will only have visibility to this interface and may not subclass this object.
|
||||
Disk device drivers should instead make use of the void* refcon field which the controllers will not
|
||||
touch
|
||||
*/
|
||||
|
||||
class IOATACommand : public IOCommand {
|
||||
|
||||
OSDeclareAbstractStructors( IOATACommand );
|
||||
|
||||
public:
|
||||
|
||||
/*!@function zeroCommand
|
||||
@abstract set to blank state, MUST call prior to re-use of this object
|
||||
*/
|
||||
virtual void zeroCommand(void);
|
||||
|
||||
/*!@function setOpcode
|
||||
@abstract command opcode as defined in IOATATypes.
|
||||
*/
|
||||
virtual void setOpcode( ataOpcode inCode);
|
||||
|
||||
/*!@function setFlags
|
||||
@abstract set the flags for this command, as defined in IOATATypes.
|
||||
*/
|
||||
virtual void setFlags( UInt32 inFlags);
|
||||
|
||||
/*!@function setUnit
|
||||
@abstract set the unit number for this command.
|
||||
*/
|
||||
virtual void setUnit( ataUnitID inUnit);
|
||||
|
||||
/*!@function setTimeoutMS
|
||||
@abstract how long to allow this command to complete, in milliseconds, once issued to
|
||||
the hardware. if the time period expires, this command will return with a timeout error.
|
||||
*/
|
||||
virtual void setTimeoutMS( UInt32 inMs);
|
||||
|
||||
/*!@function setCallbackPtr
|
||||
@abstract set the function pointer to call when this command completes.
|
||||
*/
|
||||
virtual void setCallbackPtr (IOATACompletionFunction* inCompletion);
|
||||
|
||||
/*!@function setRegMask
|
||||
@abstract used when accessing registers or reading registers on an error result. Mask is defined
|
||||
in IOATATypes.h
|
||||
*/
|
||||
virtual void setRegMask( ataRegMask mask);
|
||||
|
||||
// memory information
|
||||
// Since ATA hardware is limited in the amount of bytes
|
||||
// that can be transfered in a command, the disk driver shall supply
|
||||
// a seperate offset and byte count per transfer.
|
||||
// the offset may be any amount. The byte count must be a multiple of the
|
||||
// sector size of the device, ie, N * 512 bytes for ata hard drives.
|
||||
/*!@function setBuffer
|
||||
@abstract set the IIOMemoryDescriptor for this transaction.
|
||||
*/
|
||||
virtual void setBuffer ( IOMemoryDescriptor* inDesc);
|
||||
|
||||
/*!@function setPosition
|
||||
@abstract used to set an offset into the memory descriptor for this transfer.
|
||||
*/
|
||||
virtual void setPosition (IOByteCount fromPosition);
|
||||
|
||||
/*!@function setByteCount
|
||||
@abstract set the byte count for this transaction. Should agree with the device command and the
|
||||
memory descriptor in use.
|
||||
*/
|
||||
virtual void setByteCount (IOByteCount numBytes);
|
||||
|
||||
/*!@function setTransferChunkSize
|
||||
@abstract set the size of transfer between intervening interrupts. necessary when doing PIO Read/Write Multiple, etc. so the controller knows when to expect an interrupt during multi-sector data transfers.
|
||||
*/
|
||||
virtual void setTransferChunkSize( IOByteCount chunk = kATADefaultSectorSize);
|
||||
|
||||
/*!@function setFeatures
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual void setFeatures( UInt8 in);
|
||||
|
||||
/*!@function getErrorReg
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual UInt8 getErrorReg (void );
|
||||
|
||||
/*!@function setSectorCount
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual void setSectorCount( UInt8 in);
|
||||
|
||||
/*!@function getSectorCount
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual UInt8 getSectorCount (void );
|
||||
|
||||
/*!@function setSectorNumber
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual void setSectorNumber( UInt8 in);
|
||||
|
||||
/*!@function getSectorNumber
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual UInt8 getSectorNumber (void );
|
||||
|
||||
/*!@function setCylLo
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual void setCylLo ( UInt8 in);
|
||||
|
||||
/*!@function getCylLo
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual UInt8 getCylLo (void );
|
||||
|
||||
/*!@function setCylHi
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual void setCylHi( UInt8 in);
|
||||
|
||||
/*!@function getCylHi
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual UInt8 getCylHi (void );
|
||||
|
||||
/*!@function setDevice_Head
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual void setDevice_Head( UInt8 in);
|
||||
|
||||
/*!@function getDevice_Head
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual UInt8 getDevice_Head (void );
|
||||
|
||||
/*!@function setCommand
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual void setCommand ( UInt8 in);
|
||||
|
||||
/*!@function getStatus
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual UInt8 getStatus (void );
|
||||
|
||||
/*!@function setLBA28
|
||||
@abstract convenience method that sets the taskfile registers into a 28-bit LBA address, with unit selected and LBA bit set. return err if param out of range, return kIOSuccess (kATANoErr) = 0 on return if successful
|
||||
*/
|
||||
virtual IOReturn setLBA28( UInt32 lba, ataUnitID inUnit);
|
||||
|
||||
/*!@function setPacketCommand
|
||||
@abstract ATAPI command packet max size is 16 bytes. Makes deep copy of data.
|
||||
*/
|
||||
virtual IOReturn setPacketCommand( UInt16 packetSizeBytes, UInt8* command);
|
||||
|
||||
// the following registers are only accessed by register access
|
||||
// commands. Not by normal command dispatch where they are handled
|
||||
// by the controller.
|
||||
|
||||
// not part of task file params. not written to device when sending commands.
|
||||
virtual void setDataReg ( UInt16 in);
|
||||
virtual UInt16 getDataReg (void );
|
||||
|
||||
// not part of taskfile. Not usually used except by controller.
|
||||
virtual void setControl ( UInt8 in);
|
||||
virtual UInt8 getAltStatus (void );
|
||||
|
||||
// return values
|
||||
/*!@function getResult
|
||||
@abstract IOReturn value of the result of this command. ATA family errors are defined in IOATATypes.h
|
||||
*/
|
||||
virtual IOReturn getResult (void);
|
||||
|
||||
/*!@function getBuffer
|
||||
@abstract the IOMemoryDescriptor used in this transaction.
|
||||
*/
|
||||
virtual IOMemoryDescriptor* getBuffer ( void );
|
||||
|
||||
/*!@function getActualTransfer
|
||||
@abstract The byte count on the ending result, as best as can be determined by the controller. May be zero, but partial transfer may have occurred on error in some cases.
|
||||
*/
|
||||
virtual IOByteCount getActualTransfer ( void );
|
||||
|
||||
/*!@function getEndStatusReg
|
||||
@abstract the value of the status register on the end of the command.
|
||||
*/
|
||||
virtual UInt8 getEndStatusReg (void); // always returned
|
||||
|
||||
/*!@function getEndErrorReg
|
||||
@abstract If the error bit was set in the status register, the value of the error register is returned at the end of a command.
|
||||
*/
|
||||
virtual UInt8 getEndErrorReg( void );
|
||||
|
||||
/*!@function getCommandInUse
|
||||
@abstract returns true if IOATAController is still in control of the command.
|
||||
*/
|
||||
virtual bool getCommandInUse( void ); // returns true if IOATAController is using the command.
|
||||
|
||||
// for use by disk drivers, clients of IOATADevice only.
|
||||
// IOATADevice and IOATAControllers shall not use this field in any manner
|
||||
/*!@var refCon
|
||||
@abstract for use by disk drivers, clients of IOATADevice only. IOATADevice and IOATAControllers shall not use this field in any manner.
|
||||
*/
|
||||
void* refCon;
|
||||
|
||||
/*!@var refCon2
|
||||
@abstract for use by disk drivers, clients of IOATADevice only. IOATADevice and IOATAControllers shall not use this field in any manner.
|
||||
*/
|
||||
void* refCon2;
|
||||
|
||||
protected:
|
||||
// < return from ATA controllers to disk drivers
|
||||
// > sent to ATA controllers from disk drivers
|
||||
ataOpcode _opCode; // > Command code for the controller.
|
||||
UInt32 _flags; // > Flags for this command
|
||||
ataRegisterImage _taskFile; // <> Taskfile + data and control registers.
|
||||
ATAPICmdPacket _packet; // > ATAPI packet
|
||||
ataUnitID _unit; // > Unit number
|
||||
UInt32 _timeoutMS; // > timeout command in ms.
|
||||
IOMemoryDescriptor* _desc; // > Buffer for data may be nil if command transfer no data
|
||||
IOByteCount _position; // > Position within the descriptor for this command
|
||||
IOByteCount _byteCount; // > How many bytes to transfer.
|
||||
IOByteCount _logicalChunkSize; // > How many bytes between intervening interrupts (R/W Multiple)
|
||||
ataRegMask _regMask; // > Which registers to write or read for reg access commands
|
||||
IOATACompletionFunction* _callback; // > if nil, command is synchronous
|
||||
|
||||
IOReturn _result; // < result
|
||||
IOByteCount _actualByteCount; // < actual bytes transfered.
|
||||
UInt8 _status; // < Status register at end of command
|
||||
UInt8 _errReg; // < Error register at end of command if error bit set.
|
||||
bool _inUse; // < true while IOATAController has possesion of the command
|
||||
|
||||
|
||||
virtual bool init();
|
||||
protected:
|
||||
/*! @struct ExpansionData
|
||||
@discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
|
||||
*/
|
||||
struct ExpansionData {IOExtendedLBA* extLBA; };
|
||||
|
||||
/*! @var reserved
|
||||
Reserved for future use. (Internal use only) */
|
||||
ExpansionData *fExpansionData;
|
||||
|
||||
// overrides
|
||||
virtual void free();
|
||||
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUsed(IOATACommand, 0); // set end result
|
||||
OSMetaClassDeclareReservedUsed(IOATACommand, 1); // get extendedLBAPtr
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 10);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 11);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 12);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 13);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 14);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 15);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 16);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 17);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 18);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 19);
|
||||
OSMetaClassDeclareReservedUnused(IOATACommand, 20);
|
||||
|
||||
public:
|
||||
virtual void setEndResult(UInt8 inStatus, UInt8 endError );
|
||||
virtual IOExtendedLBA* getExtendedLBA(void);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
@class IOExtendedLBA
|
||||
|
||||
@discussion
|
||||
If 48-bit LBAs are supported, IOExtendedLBA is used to represent a 48-bit LBA.
|
||||
The driver examines the ATA identify data to determine if 48-bit addressing is
|
||||
supported.
|
||||
*/
|
||||
|
||||
class IOExtendedLBA : public OSObject
|
||||
{
|
||||
OSDeclareDefaultStructors( IOExtendedLBA );
|
||||
|
||||
public:
|
||||
static IOExtendedLBA* createIOExtendedLBA(IOATACommand* owner);
|
||||
|
||||
// terminology as established in ATA/ATAPI-6.
|
||||
// for the extended LBA address
|
||||
|
||||
/*!@function setLBALow16
|
||||
@abstract convenience method that sets the lower 16 bits of a 48-bit LBA
|
||||
*/
|
||||
virtual void setLBALow16( UInt16 lbaLow);
|
||||
|
||||
/*!@function getLBALow16
|
||||
@abstract convenience method that gets the lower 16 bits of a 48-bit LBA
|
||||
*/
|
||||
virtual UInt16 getLBALow16 (void);
|
||||
|
||||
/*!@function setLBAMid16
|
||||
@abstract convenience method that sets the middle 16 bits of a 48-bit LBA
|
||||
*/
|
||||
virtual void setLBAMid16 (UInt16 lbaMid);
|
||||
|
||||
/*!@function getLBAMid16
|
||||
@abstract convenience method that gets the middle 16 bits of a 48-bit LBA
|
||||
*/
|
||||
virtual UInt16 getLBAMid16( void );
|
||||
|
||||
/*!@function setLBAHigh16
|
||||
@abstract convenience method that sets the high 16 bits of a 48-bit LBA
|
||||
*/
|
||||
virtual void setLBAHigh16( UInt16 lbaHigh );
|
||||
|
||||
/*!@function getLBAHigh16
|
||||
@abstract convenience method that gets the high 16 bits of a 48-bit LBA
|
||||
*/
|
||||
virtual UInt16 getLBAHigh16( void );
|
||||
|
||||
/*!@function setSectorCount16
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual void setSectorCount16( UInt16 sectorCount );
|
||||
|
||||
/*!@function getSectorCount16
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual UInt16 getSectorCount16( void );
|
||||
|
||||
/*!@function setFeatures16
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual void setFeatures16( UInt16 features );
|
||||
|
||||
/*!@function getFeatures16
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual UInt16 getFeatures16( void );
|
||||
|
||||
/*!@function setDevice
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual void setDevice( UInt8 inDevice );
|
||||
|
||||
/*!@function getDevice
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual UInt8 getDevice( void );
|
||||
|
||||
/*!@function setCommand
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual void setCommand( UInt8 inCommand );
|
||||
|
||||
/*!@function getCommand
|
||||
@abstract Taskfile access. Registers are named in accordance with ATA Standards conventions
|
||||
*/
|
||||
virtual UInt8 getCommand( void );
|
||||
|
||||
/*!@function setExtendedLBA
|
||||
@abstract convenience method that sets the taskfile registers into a 48-bit LBA address, along with sector count, and unit selected and LBA bit set
|
||||
*/
|
||||
virtual void setExtendedLBA( UInt32 inLBAHi, UInt32 inLBALo, ataUnitID inUnit, UInt16 extendedCount, UInt8 extendedCommand);
|
||||
|
||||
/*!@function getExtendedLBA
|
||||
@abstract convenience method that gets a 48-bit LBA
|
||||
*/
|
||||
virtual void getExtendedLBA( UInt32* outLBAHi, UInt32* outLBALo );
|
||||
|
||||
/*!@function zeroData
|
||||
@abstract convenience method that zeros out the lba, sector count, features, device, and command member variables
|
||||
*/
|
||||
virtual void zeroData(void);
|
||||
|
||||
/*! @struct ExpansionData
|
||||
@discussion This structure will be used to expand the capablilties in the future.
|
||||
*/
|
||||
struct ExpansionData { };
|
||||
|
||||
/*! @var reserved
|
||||
Reserved for future use. (Internal use only) */
|
||||
ExpansionData *reserved;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
IOATACommand* owner;
|
||||
UInt16 lbaLow;
|
||||
UInt16 lbaMid;
|
||||
UInt16 lbaHigh;
|
||||
UInt16 sectorCount;
|
||||
UInt16 features;
|
||||
UInt16 device;
|
||||
UInt16 command;
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUnused(IOExtendedLBA, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOExtendedLBA, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOExtendedLBA, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOExtendedLBA, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOExtendedLBA, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOExtendedLBA, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOExtendedLBA, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOExtendedLBA, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOExtendedLBA, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOExtendedLBA, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOExtendedLBA, 10);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _IOATACONTROLLER_H
|
||||
#define _IOATACONTROLLER_H
|
||||
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include <IOKit/IOBufferMemoryDescriptor.h>
|
||||
#include <IOKit/IOCommandGate.h>
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/IOWorkLoop.h>
|
||||
#include "ATATimerEventSource.h"
|
||||
|
||||
class IOATADevice;
|
||||
class IOATABusCommand;
|
||||
class IOATABusInfo;
|
||||
class IOATADevConfig;
|
||||
|
||||
/*! @class IOATAController
|
||||
@abstract The base class for ata controller family. Provides the interface common to all ata bus controllers.
|
||||
@discussion Subclasses of IOATAController implement drivers for specific bus hardware. Disk devices are clients of
|
||||
IOATAController and communicate via the IOATABusNub instantiated for each device discovered by the specific IOATAController
|
||||
subclass when it probes hardware. Via the nub, the ATA Controller provides standard information about bus capability, accepts
|
||||
requests for transfer mode configuration (timing), accepts requests for IO and bus operations, notifies the device driver about
|
||||
bus events which may affect the device, such as soft-resets or device removal (ie, media-bay and PC-card) and removal of queued
|
||||
IO requests which have not been dispatched into the hardware.
|
||||
|
||||
@discussion The header doc for this class is incomplete. The source however is heavily commented and should be consulted until
|
||||
such time as complete header doc is available.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class IOATAController : public IOService
|
||||
{
|
||||
OSDeclareDefaultStructors(IOATAController);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
/*--- Common ATA Controller Interface ---*/
|
||||
// find out bus capability
|
||||
virtual IOReturn provideBusInfo( IOATABusInfo* infoOut);
|
||||
|
||||
// set and get bus timing configuration for a specific unit
|
||||
virtual IOReturn selectConfig( IOATADevConfig* configRequest, UInt32 unitNumber);
|
||||
virtual IOReturn getConfig( IOATADevConfig* configRequest, UInt32 unitNumber);
|
||||
|
||||
// The main call puts something on the work loop
|
||||
virtual IOReturn executeCommand( IOATADevice* nub, IOATABusCommand* cmd);
|
||||
|
||||
|
||||
|
||||
/*-- Power Management ---*/
|
||||
|
||||
// TBD
|
||||
|
||||
|
||||
/*--- Overrides from IOService ---*/
|
||||
virtual bool init(OSDictionary * properties);
|
||||
|
||||
virtual IOService* probe( IOService* provider, SInt32* score );
|
||||
virtual bool start( IOService* provider );
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
enum {
|
||||
kBusFree = 'free', // bus is available
|
||||
kBusBusy = 'busy', // bus is busy with request
|
||||
kQueueOpen = '!lck', // queue is not locked
|
||||
kQueueLocked = 'LOCK', // queue is frozen and not
|
||||
kImmediateLocked = '!Imd', // immediate commands may not be processed
|
||||
kImmediateOK = 'Immd' // immediate commands allowed.
|
||||
};
|
||||
|
||||
/* Transaction State indicator definition - indicates what action is next*/
|
||||
enum transState {
|
||||
kATAInitial = 0x00, // in queue
|
||||
kATAStarted = 0x01, // issue taskfile
|
||||
kATAPICmd = 0x02, // issue packet
|
||||
kATADataTx = 0x03, // data transfer phase
|
||||
kATAStatus = 0x04, // read status
|
||||
kATAComplete = 0x05, // io complete
|
||||
kATADone = 0x06 // completion callout called
|
||||
};
|
||||
|
||||
struct ataDevInfo {
|
||||
ataDeviceType type; // ata, atapi, unknown
|
||||
atapiConfig packetSend; // slow DRQ, IRQ, or fast DRQ for packet
|
||||
};
|
||||
|
||||
|
||||
struct ataDoubleBuffer
|
||||
{
|
||||
IOPhysicalAddress physicalBuffer;
|
||||
IOLogicalAddress logicalBuffer;
|
||||
IOByteCount bufferSize;
|
||||
|
||||
};
|
||||
|
||||
|
||||
IOService* _provider;
|
||||
IOWorkLoop* _workLoop;
|
||||
IOCommandGate* _cmdGate;
|
||||
ATATimerEventSource* _timer;
|
||||
queue_head_t _commandQueue;
|
||||
IOATABusCommand* _currentCommand;
|
||||
UInt32 _busState;
|
||||
UInt32 _queueState;
|
||||
UInt32 _immediateGate;
|
||||
ataUnitID _selectedUnit;
|
||||
ataDevInfo _devInfo[2];
|
||||
IOATADevice* _nub[2];
|
||||
ataDoubleBuffer _doubleBuffer;
|
||||
|
||||
IOATARegPtr8 _tfFeatureReg;
|
||||
IOATARegPtr8 _tfSCountReg;
|
||||
IOATARegPtr8 _tfSectorNReg;
|
||||
IOATARegPtr8 _tfCylLoReg;
|
||||
IOATARegPtr8 _tfCylHiReg;
|
||||
IOATARegPtr8 _tfSDHReg;
|
||||
IOATARegPtr8 _tfStatusCmdReg;
|
||||
IOATARegPtr16 _tfDataReg;
|
||||
IOATARegPtr8 _tfAltSDevCReg;
|
||||
|
||||
|
||||
// false if couldn't allocate the per-bus double buffer.
|
||||
// controllers should provide implementation where needed
|
||||
// for DMA hardware compatibility. The default method provides
|
||||
// a 4K buffer for PIO since MemoryDescriptors do not by default have
|
||||
// logical addresses in the kernel space.
|
||||
virtual bool allocateDoubleBuffer( void );
|
||||
|
||||
// perform 2-byte endian swap. Only useful on PIO transfers and identify data
|
||||
virtual void swapBytes16( UInt8* dataBuffer, IOByteCount length);
|
||||
|
||||
/*! @function handleCommand
|
||||
@abstract Called by executeCommand() to handle the client command
|
||||
from the workloop context.
|
||||
@param command The command code.
|
||||
@param param1 Command parameter.
|
||||
@param param2 Command parameter.
|
||||
@param param3 Command parameter.
|
||||
@result kIOReturnSuccess on success, or an error code otherwise. */
|
||||
|
||||
virtual IOReturn handleCommand( void * command,
|
||||
void * param1 = 0,
|
||||
void * param2 = 0,
|
||||
void * param3 = 0);
|
||||
|
||||
|
||||
/*! @function busCanDispatch
|
||||
@abstract answers whether the bus is in state such that the next command
|
||||
can be dispatched.
|
||||
@result true - bus is free to issue commands. false - bus cannot issue
|
||||
commands at this time. */
|
||||
virtual bool busCanDispatch( void );
|
||||
|
||||
|
||||
/*! @function dispatchNext
|
||||
@abstract Causes the command at the front of the queue to dequeue, made the
|
||||
current command and begin execution.
|
||||
@result noErr indicates successful dispatch. */
|
||||
virtual IOReturn dispatchNext( void );
|
||||
|
||||
// sets the result code, free's the bus state, dispatch next command and execute completion
|
||||
virtual void completeIO( IOReturn commandResult );
|
||||
|
||||
// Command queue handlers.
|
||||
virtual IOReturn enqueueCommand( IOATABusCommand* command);
|
||||
virtual IOATABusCommand* dequeueFirstCommand( void );
|
||||
|
||||
// event notifier for clients
|
||||
virtual void executeEventCallouts( ataEventCode event, ataUnitID unit);
|
||||
|
||||
// default handler for device interrupts.
|
||||
virtual IOReturn handleDeviceInterrupt( void );
|
||||
|
||||
|
||||
// timer functions
|
||||
// starts the timeout on the current command
|
||||
virtual IOReturn startTimer( UInt32 inMS);
|
||||
//disable and clear a running timer.
|
||||
virtual void stopTimer( void );
|
||||
// called when a timeout occurs.
|
||||
virtual void handleTimeout( void );
|
||||
// true if the timer has expired
|
||||
virtual bool checkTimeout( void );
|
||||
|
||||
// handle IO opcodes
|
||||
virtual IOReturn handleExecIO( void );
|
||||
virtual IOReturn handleRegAccess( void );
|
||||
virtual IOReturn handleBusReset(void);
|
||||
virtual IOReturn handleQueueFlush( void );
|
||||
|
||||
// various protocol phases
|
||||
virtual IOReturn asyncData(void);
|
||||
virtual IOReturn asyncStatus(void);
|
||||
virtual IOReturn asyncIO(void);
|
||||
virtual IOReturn asyncCommand(void);
|
||||
virtual IOReturn synchronousIO(void);
|
||||
|
||||
// hardware access
|
||||
virtual IOReturn selectDevice( ataUnitID unit );
|
||||
virtual IOReturn issueCommand( void );
|
||||
virtual IOReturn writePacket( void );
|
||||
virtual IOReturn softResetBus( bool doATAPI = false );
|
||||
|
||||
virtual IOReturn startDMA( void );
|
||||
virtual IOReturn stopDMA( void );
|
||||
|
||||
virtual bool ATAPISlaveExists( void );
|
||||
virtual UInt32 scanForDrives( void );
|
||||
|
||||
virtual bool waitForU8Status (UInt8 mask, UInt8 value);
|
||||
|
||||
virtual IOByteCount readATAPIByteCount( void );
|
||||
virtual void handleOverrun( IOByteCount length);
|
||||
virtual IOReturn registerAccess(bool isWrite);
|
||||
|
||||
// PIO data transfers
|
||||
virtual IOReturn txDataIn (IOLogicalAddress buf, IOByteCount length);
|
||||
virtual IOReturn txDataOut (IOLogicalAddress buf, IOByteCount length);
|
||||
|
||||
virtual IOATAController::transState determineATAPIState(void);
|
||||
|
||||
// device should set the controller to the config for this device
|
||||
virtual void selectIOTiming( ataUnitID unit );
|
||||
|
||||
// subclasses MUST implement this function in order to initialize
|
||||
// the pointers to the ATA task file registers during start() time.
|
||||
virtual bool configureTFPointers(void);
|
||||
|
||||
// convert a bit-significant indicator to a numeric value.
|
||||
virtual UInt16 bitSigToNumeric( UInt16 binary);
|
||||
|
||||
// for 48 bit register reading and writing
|
||||
UInt16 readExtRegister( IOATARegPtr8 inRegister );
|
||||
void writeExtRegister( IOATARegPtr8 inRegister, UInt16 inValue );
|
||||
|
||||
// overrides
|
||||
virtual void free();
|
||||
|
||||
private:
|
||||
|
||||
// used called by the commandgate in executeCommand.
|
||||
static void executeCommandAction(OSObject * owner,
|
||||
void * arg0,
|
||||
void * arg1,
|
||||
void * arg2,
|
||||
void * arg3);
|
||||
|
||||
// callout used by the timer to indicate the timeout failure.
|
||||
static void timeoutOccured( OSObject *owner,
|
||||
IOTimerEventSource *sender);
|
||||
|
||||
protected:
|
||||
/*! @struct ExpansionData
|
||||
@discussion This structure will be used to expand the capablilties of the IOATAController in the future.
|
||||
*/
|
||||
typedef struct ExpansionData
|
||||
{
|
||||
IOBufferMemoryDescriptor* _doubleBufferDesc;
|
||||
} ExpansionData;
|
||||
|
||||
/*! @var reserved
|
||||
Reserved for future use. (Internal use only) */
|
||||
ExpansionData *reserved;
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 10);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 11);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 12);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 13);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 14);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 15);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 16);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 17);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 18);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 19);
|
||||
OSMetaClassDeclareReservedUnused(IOATAController, 20);
|
||||
};
|
||||
#endif /* !_IOATACONTROLLER_H */
|
||||
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2008 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _IOATADEVCONFIG_H
|
||||
#define _IOATADEVCONFIG_H
|
||||
|
||||
#include <libkern/c++/OSObject.h>
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include "IOATATypes.h"
|
||||
#include "IOATABusInfo.h"
|
||||
|
||||
|
||||
/*!
|
||||
@class IOATADevConfig
|
||||
@abstract used for configuring and communicating the desired transfer modes of a device.
|
||||
A disk driver would typically use this object in conjunction with the 512-bytes of identification
|
||||
data from the drive and the IOATABusInfo object for the bus it is connected to.
|
||||
This object will determine the best matching transfer speeds available.
|
||||
the device driver will then send a series of Set Features commands to configure the drive
|
||||
and this object to the bus through the IOATADevice nub in order to configure the optimum transfer mode.
|
||||
The driver for the disk drive may choose to populate this object with whatever transfer mode
|
||||
desired, in the event that a different mode is required.
|
||||
@discussion usually use the initWithBestSelection to make a best mode match.
|
||||
The Mode accessors use bit significance to indicate a selected mode or supported modes(s)
|
||||
ie, 00000001b indicates Mode-0, 00000010b indicates mode 1, etc.
|
||||
Selected mode is indicated by a single set bit. No bit set indicates no mode in that class is selected.
|
||||
ie, a bus will support multiple possible modes, but will only have one mode selected at that time.
|
||||
|
||||
*/
|
||||
|
||||
class IOATADevConfig : public OSObject {
|
||||
|
||||
OSDeclareDefaultStructors( IOATADevConfig );
|
||||
|
||||
public:
|
||||
|
||||
/*!@function atadevconfig
|
||||
@abstract static creator function.
|
||||
*/
|
||||
static IOATADevConfig* atadevconfig(void);
|
||||
|
||||
/*!@function initWithBestSelection
|
||||
@abstract Handy initializer: pass the 512-byte result of the Identify Device or
|
||||
Identify Packet Device in endian-order for your platform (byte-swapped on PPC)
|
||||
and the IOATABusInfo object for the bus. The object will initialize all fields
|
||||
and select the best transfer modes that match on bus and device.
|
||||
If the return value was 0 (success or noErr), then a matching mode is supported.
|
||||
Examine the PIO and UDMA/DMA fields and to generate the apropriate SET FEATURES
|
||||
parameters for your drive and send this initialised object to the IOATAController
|
||||
when requesting a speed configuration.
|
||||
failure means no supported transfer modes matched between bus and device info.
|
||||
|
||||
@param identifyData 512 bytes of data obtained from the device via IDENTIFY DEVICE or IDENTIFY PACKET DEVICE command.
|
||||
@param busInfo pointer to an IOATAbusInfo object obtained from a previous atanub->provideBusInfo() call.
|
||||
@result kIOSuccess (0) when a matching transfer mode is available between the device and controller.
|
||||
*/
|
||||
IOReturn initWithBestSelection( const UInt16* identifyData, IOATABusInfo* busInfo);
|
||||
|
||||
// intitialize with the 512 byte data from an ATA device identify command
|
||||
IOReturn assignFromData( const UInt16* identifyData );
|
||||
|
||||
/*!@function setPacketConfig
|
||||
@param packetConfig
|
||||
@abstract For ATAPI devices, if the device asserts interrupt after the Packet Command when it is ready to accept the packet, set this value to true (mostly older devices). If the device accepts the packet only by asserting DRQ bit in status, then set this value false. Tells the bus controller whether to wait for packet acceptance or set pending interrupt.
|
||||
*/
|
||||
void setPacketConfig ( atapiConfig packetConfig);
|
||||
|
||||
/*!@function getPacketConfig
|
||||
@result atapiConfig as defined in IOATATypes.h
|
||||
*/
|
||||
atapiConfig getPacketConfig( void );
|
||||
|
||||
// The following Mode accessors use bit significance to indicate a selected mode or supported modes(s)
|
||||
// ie, 00000001b indicates Mode-0, 00000010b indicates mode 1, etc.
|
||||
// Selected mode is indicated by a single set bit. No bit set indicates no mode in that class is selected.
|
||||
// ie, a bus will support multiple possible modes, but will only have one mode selected at that time.
|
||||
|
||||
/*!@function setPIOMode
|
||||
@param inModeBitMap bit-significant map of PIO mode
|
||||
*/
|
||||
void setPIOMode( UInt8 inModeBitMap); // bit-significant map of PIO mode(s)
|
||||
|
||||
/*!@function getPIOMode
|
||||
@result bit-significant map of PIO mode
|
||||
*/
|
||||
UInt8 getPIOMode( void );
|
||||
|
||||
/*!@function setDMAMode
|
||||
@param inModeBitMap bit-significant map of DMA mode
|
||||
*/
|
||||
void setDMAMode( UInt8 inModeBitMap ); // bit-significant map of DMA mode(s)
|
||||
|
||||
/*!@function getDMAMode
|
||||
@result bit-significant map of DMA mode
|
||||
*/
|
||||
UInt8 getDMAMode( void );
|
||||
|
||||
/*!@function setUltraMode
|
||||
@param inModeBitMap bit-significant map of Ultra mode
|
||||
*/
|
||||
void setUltraMode( UInt8 inModeBitMap ); // bit-significant map of Ultra mode(s)
|
||||
|
||||
/*!@function getUltraMode
|
||||
@result bit-significant map of Ultra mode
|
||||
*/
|
||||
UInt8 getUltraMode( void );
|
||||
|
||||
// The following cycle time accessors report cycle times in nanoseconds.
|
||||
// A device requesting a mode should also request a cycle time as reported in the device's identification page.
|
||||
// A bus controller will configure the bus not to exceed (go faster than) the minimum time requested.
|
||||
// When a bus controller reports a mode configuration, the cycle time indicates the busses contract not to go
|
||||
// faster than. However an actual cycle time may be slower than the indicated time.
|
||||
/*!@function setPIOCycleTime
|
||||
@param inNS PIO cycle time in nanoseconds.
|
||||
*/
|
||||
void setPIOCycleTime( UInt16 inNS );
|
||||
|
||||
/*!@function getPIOCycleTime
|
||||
@result reported PIO CycleTime in nanoseconds.
|
||||
*/
|
||||
UInt16 getPIOCycleTime( void );
|
||||
|
||||
/*!@function setDMACycleTime
|
||||
@param inNS reported multiword DMA Cycle time in nanoseconds.
|
||||
*/
|
||||
void setDMACycleTime( UInt16 inNS );
|
||||
|
||||
/*!@function getDMACycleTime
|
||||
@result Reported multiword DMA cycle time in nanoseconds.
|
||||
*/
|
||||
UInt16 getDMACycleTime( void );
|
||||
|
||||
// Ultra ATA defines cycle times a device must meet to comply with standards.
|
||||
// No cycle time field is needed.
|
||||
|
||||
// convert bit-significant to numeric value
|
||||
/*!@function bitSigToNumeric
|
||||
@abstract converts a bit-significant field to a numerical value. Note that a bit field of 0x00 has no defined result.
|
||||
@param binary the bit significant field.
|
||||
@result the numerical value of the highest bit set in the field.
|
||||
*/
|
||||
virtual UInt8 bitSigToNumeric( UInt16 binary);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
atapiConfig _atapiIRQForPacket; // enum for bits 5 and 6 of word zero of
|
||||
// the identify packet device info data for PACKET devices ONLY.
|
||||
// shift word-0 5-bits left, mask 0x03 and these enums apply.
|
||||
// values are:
|
||||
|
||||
// kATAPIDRQSlow = 0x00 - wait up to 3MS for packet on DRQ
|
||||
// kATAPIIRQPacket = 0x01, - device asserts IRQ for packet
|
||||
// kATAPIDRQFast = 0x10, - packet on DRQ within 50us
|
||||
// kATAPIUnknown = 0x11 - reserved as of ATA/ATAPI-5
|
||||
|
||||
|
||||
|
||||
|
||||
UInt8 _ataPIOMode; /* <->: PIO Mode Timing class bit-significant */
|
||||
UInt16 _ataPIOCycleTime; /* <->: Cycle time in ns for PIO mode */
|
||||
UInt8 _ataMultiDMAMode; /* <->: Multiple Word DMA Timing Class bit-significant*/
|
||||
UInt16 _ataMultiCycleTime; /* <->: Cycle time in ns for Multiword DMA mode */
|
||||
UInt8 _ataUltraDMAMode; /* <->: Ultra DMA timing class bit-significant */
|
||||
|
||||
IOReturn _AssignPIOData( const UInt16* identifyData);
|
||||
IOReturn _AssignDMAData(const UInt16* identifyData);
|
||||
IOReturn _AssignUltraData(const UInt16* identifyData);
|
||||
UInt8 _MostSignificantBit( UInt8 inByte);
|
||||
|
||||
|
||||
virtual bool init();
|
||||
protected:
|
||||
/*! @struct ExpansionData
|
||||
@discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
|
||||
*/
|
||||
struct ExpansionData { };
|
||||
|
||||
/*! @var reserved
|
||||
Reserved for future use. (Internal use only) */
|
||||
ExpansionData *reserved;
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 10);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 11);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 12);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 13);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 14);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 15);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 16);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 17);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 18);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 19);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevConfig, 20);
|
||||
|
||||
public:
|
||||
|
||||
//some static utility functions to parse the identify data for feature support
|
||||
|
||||
static bool sDriveSupports48BitLBA( const UInt16* identifyData );
|
||||
static UInt32 sDriveExtendedLBASize( UInt32* lbaHi, UInt32* lbaLo, const UInt16* identifyData); // result returned is same as lbaLo.
|
||||
|
||||
};
|
||||
|
||||
|
||||
// header doc info goes here. I find putting it within the delcarations more confusing than putting it all in the bottom of the header.
|
||||
|
||||
|
||||
#endif /* !_IOATADEVCONFIG_H */
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* IOATADevice.h
|
||||
*
|
||||
* This object implements a relay to an ATA Bus where a drive is attached.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _IOATADEVICE_H
|
||||
#define _IOATADEVICE_H
|
||||
|
||||
#include <IOKit/IOService.h>
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include "IOATATypes.h"
|
||||
#include "IOATACommand.h"
|
||||
#include "IOATABusInfo.h"
|
||||
#include "IOATADevConfig.h"
|
||||
|
||||
class IOATAController;
|
||||
|
||||
|
||||
/*!
|
||||
@class IOATADevice
|
||||
@abstract This object implements a relay to an ATA Bus where a drive is attached.
|
||||
@discussion IOATADevice is the superclass which represents a particular device attached to a particular IOATAController (bus). IOATADevice is the provider for ATA mass-storage device drivers.IOATADevice is the factory for all IOATACommand objects and is responsible for creating and freeing IOATACommands. IOATAControllers will create an instance of IOATADevice for each device physically connected to the ata bus. IOATADevice is virtual and specific subclass should be implemented for particular types of IOATAController. In this manner, controller-specifc IOATACommands may be paired with the proper type of controller.
|
||||
*/
|
||||
|
||||
class IOATADevice : public IOService
|
||||
{
|
||||
OSDeclareDefaultStructors(IOATADevice);
|
||||
|
||||
public:
|
||||
|
||||
//
|
||||
/*!@function getUnitID
|
||||
@abstract Determine whether this device is number 0 or 1 (ie, master/slave)
|
||||
@result ataUnitID - 0 or 1.
|
||||
*/
|
||||
virtual ataUnitID getUnitID( void );
|
||||
|
||||
//
|
||||
/*!@function getDeviceType
|
||||
@abstract Find out what kind of device this nub is (ata or atapi)
|
||||
@result ataDeviceType as defined in IOATATypes.h
|
||||
*/
|
||||
virtual ataDeviceType getDeviceType( void );
|
||||
|
||||
//
|
||||
/*!@function provideBusInfo
|
||||
@abstract Find out the bus capability so the client can choose the features to set and commands to run.
|
||||
@param getInfo a pointer to a valid IOATABusInfo object.
|
||||
@result kIOSuccess (0) and the getInfo object will be filled out by the bus controller with information about the bus.
|
||||
*/
|
||||
virtual IOReturn provideBusInfo( IOATABusInfo* getInfo);
|
||||
|
||||
//
|
||||
/*!@function selectConfig
|
||||
@abstract Tell the bus what speed to use for your device.
|
||||
@param configRequest pointer to a valid and initialized IOATADevConfig object.
|
||||
@result kIOSuccess (0) if the configuration was succesfully selected.
|
||||
@discussion This should only be called once during a disk drivers start method before registering its availability, and must be called prior to issuing any data IO transactions.
|
||||
*/
|
||||
virtual IOReturn selectConfig( IOATADevConfig* configRequest);
|
||||
|
||||
//
|
||||
/*!@function provideConfig
|
||||
@abstract Find out what speed the bus has configured for this unit.
|
||||
@param configRequest pointer to a valid IOATADevConfig object.
|
||||
@result kIOSuccess (0) on successful completion and configRequest will contain the configuration information.
|
||||
*/
|
||||
virtual IOReturn provideConfig( IOATADevConfig* configRequest);
|
||||
|
||||
// Submit IO requests
|
||||
/*!
|
||||
@function executeCommand
|
||||
@abstract Submit IO requests
|
||||
@param command pointer to a valid IOATACommand with the command to be executed.
|
||||
@result kIOSuccess (0) if the command was successfully queued in the controller.
|
||||
*/
|
||||
virtual IOReturn executeCommand(IOATACommand* command);
|
||||
|
||||
// create and destroy IOATACommands
|
||||
/*!
|
||||
@function allocCommand
|
||||
@abstract create IOATACommands. Device drivers should allocate command objects only through this method.
|
||||
@result null if allocation failed. Retain count is one.
|
||||
*/
|
||||
virtual IOATACommand* allocCommand( void );
|
||||
|
||||
/*!
|
||||
@function freeCommand
|
||||
@abstract release a command object that is no longer needed. Do not free an object in use and do not release the object anymore times than you have retained it.
|
||||
@param inCommand the command to be released.
|
||||
*/
|
||||
virtual void freeCommand( IOATACommand* inCommand);
|
||||
|
||||
// matching stuff for IOBSDInit and so on.
|
||||
/*!@function matchPropertyTable
|
||||
@abstract matching stuff for IOBSDInit and so on.
|
||||
*/
|
||||
virtual bool matchPropertyTable(OSDictionary * table);
|
||||
|
||||
/*!@function matchLocation
|
||||
@abstract matching stuff for IOBSDInit and so on.
|
||||
*/
|
||||
virtual IOService* matchLocation(IOService * client);
|
||||
|
||||
/*!@function matchPropertyTable
|
||||
@abstract matching stuff for IOBSDInit and so on.
|
||||
*/
|
||||
virtual bool matchPropertyTable(OSDictionary * table, SInt32 * score);
|
||||
|
||||
// called by controllers when they need to send a message to client drivers.
|
||||
/*!
|
||||
@function notifyEvent
|
||||
@abstract called by controllers when they need to send a message to client (disk) drivers.
|
||||
*/
|
||||
virtual void notifyEvent( UInt32 event );
|
||||
|
||||
|
||||
protected:
|
||||
IOATAController* _provider;
|
||||
ataUnitID _unitNumber; // 0 - master, 1 - slave, -1 = not Valid
|
||||
ataDeviceType _deviceType; // ata, atapi, unknown
|
||||
protected:
|
||||
/*! @struct ExpansionData
|
||||
@discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
|
||||
*/
|
||||
struct ExpansionData { };
|
||||
|
||||
/*! @var reserved
|
||||
Reserved for future use. (Internal use only) */
|
||||
ExpansionData *reserved;
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 10);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 11);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 12);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 13);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 14);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 15);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 16);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 17);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 18);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 19);
|
||||
OSMetaClassDeclareReservedUnused(IOATADevice, 20);
|
||||
};
|
||||
|
||||
#endif /* !_IOATABUSNUB_H */
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2008 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOATAREGI386_H
|
||||
#define _IOATAREGI386_H
|
||||
|
||||
#include <libkern/c++/OSObject.h>
|
||||
|
||||
/*
|
||||
* IOATAReg: ATA register abstract base class.
|
||||
*/
|
||||
#define DefineIOATAReg(w) \
|
||||
class IOATAReg##w : public OSObject \
|
||||
{ \
|
||||
OSDeclareAbstractStructors( IOATAReg##w ) \
|
||||
\
|
||||
public: \
|
||||
virtual void operator = (UInt##w rhs) = 0; \
|
||||
virtual operator UInt##w() const = 0; \
|
||||
}
|
||||
|
||||
DefineIOATAReg( 8 );
|
||||
DefineIOATAReg( 16 );
|
||||
DefineIOATAReg( 32 );
|
||||
|
||||
typedef IOATAReg8 * IOATARegPtr8;
|
||||
typedef IOATAReg16 * IOATARegPtr16;
|
||||
typedef IOATAReg32 * IOATARegPtr32;
|
||||
|
||||
#define IOATARegPtr8Cast(x) (x)
|
||||
|
||||
/*
|
||||
* IOATAIOReg: I/O mapped ATA registers.
|
||||
*/
|
||||
#define DefineIOATAIOReg(w) \
|
||||
class IOATAIOReg##w : public IOATAReg##w \
|
||||
{ \
|
||||
OSDeclareDefaultStructors( IOATAIOReg##w ) \
|
||||
\
|
||||
protected: \
|
||||
UInt16 _address; \
|
||||
\
|
||||
public: \
|
||||
static IOATAIOReg##w * withAddress( UInt16 address ); \
|
||||
\
|
||||
virtual bool initWithAddress( UInt16 address ); \
|
||||
virtual UInt16 getAddress() const; \
|
||||
\
|
||||
virtual void operator = (UInt##w rhs); \
|
||||
virtual operator UInt##w() const; \
|
||||
}
|
||||
|
||||
DefineIOATAIOReg( 8 );
|
||||
DefineIOATAIOReg( 16 );
|
||||
DefineIOATAIOReg( 32 );
|
||||
|
||||
#endif /* !_IOATAREGI386_H */
|
||||
@@ -0,0 +1,393 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2008 Apple, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _IOATATYPES_H
|
||||
#define _IOATATYPES_H
|
||||
|
||||
#include <IOKit/IOTypes.h>
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
@header IOATAtypes.h
|
||||
@discussion contains various definitions and constants for use in the IOATAFamily and clients. Header Doc is incomplete at this point, but file is heavily commented.
|
||||
|
||||
*/
|
||||
// property strings
|
||||
#define kATADevPropertyKey "ata device type"
|
||||
#define kATATypeATAString "ata"
|
||||
#define kATATypeATAPIString "atapi"
|
||||
#define kATATypeUnknownString "unknown"
|
||||
|
||||
#define kATAVendorPropertyKey "device model"
|
||||
#define kATARevisionPropertyKey "device revision"
|
||||
#define kATASerialNumPropertyKey "device serial"
|
||||
|
||||
#define kATAUnitNumberKey "unit number"
|
||||
|
||||
#define kATASocketKey "socket type"
|
||||
#define kATAInternalSocketString "internal"
|
||||
#define kATAMediaBaySocketString "media-bay"
|
||||
#define kATAPCCardSocketString "pccard"
|
||||
#define kATAInternalSATAString "serial-ata"
|
||||
#define kATASATABayString "sata-bay"
|
||||
#define kATAInternalSATA2 "serial-ata-2"
|
||||
#define kATASATA2BayString "sata-2-bay"
|
||||
#define kATAUnkownSocketString "unknown"
|
||||
|
||||
#define kATANotifyOnChangeKey "media-notify"
|
||||
|
||||
// allows for porting to non-memory-mapped IO systems, such as x86.
|
||||
// for such a platform, create a class and overload the assignment operators
|
||||
// so that the correct IO operation is performed and define the type for that architecture port.
|
||||
#ifdef __ppc__
|
||||
#define IOATARegPtr8 volatile UInt8*
|
||||
#define IOATARegPtr16 volatile UInt16*
|
||||
#define IOATARegPtr32 volatile UInt32*
|
||||
#define IOATARegPtr8Cast(x) ((IOATARegPtr8)(x))
|
||||
#elif defined( __i386__ ) || defined( __x86_64__ )
|
||||
#include <IOKit/ata/IOATARegI386.h>
|
||||
#else
|
||||
#error Unknown machine architecture
|
||||
#endif
|
||||
|
||||
enum ataSocketType{
|
||||
|
||||
kUnknownSocket = 0,
|
||||
kInternalATASocket,
|
||||
kMediaBaySocket ,
|
||||
kPCCardSocket,
|
||||
kInternalSATA,
|
||||
kSATABay,
|
||||
kInternalSATA2,
|
||||
kSATA2Bay
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
enum ataDeviceType {
|
||||
|
||||
kUnknownATADeviceType = 0,
|
||||
kATADeviceType,
|
||||
kATAPIDeviceType
|
||||
|
||||
} ;
|
||||
|
||||
// enum for bits 5 and 6 of word zero of
|
||||
// the identify packet device info data.
|
||||
// shift word-0 5-bits left, mask 0x03 and these enums apply.
|
||||
enum atapiConfig {
|
||||
|
||||
kATAPIDRQSlow = 0x00,
|
||||
kATAPIIRQPacket = 0x01,
|
||||
kATAPIDRQFast = 0x10,
|
||||
kATAPIUnknown = 0x11
|
||||
|
||||
};
|
||||
|
||||
|
||||
enum ataUnitID {
|
||||
|
||||
kATAInvalidDeviceID = -1,
|
||||
kATADevice0DeviceID = 0, /* aka, Master. Device 0 is the correct terminology */
|
||||
kATADevice1DeviceID = 1 /* aka, Slave. Device 1 is the correct terminology */
|
||||
|
||||
} ;
|
||||
|
||||
enum {
|
||||
|
||||
kATADefaultSectorSize = 512
|
||||
};
|
||||
|
||||
/* Task file definition *** Error Register *** */
|
||||
enum {
|
||||
bATABadBlock = 7, /* bit number of bad block error bit*/
|
||||
bATAUncorrectable = 6, /* bit number of uncorrectable error bit*/
|
||||
bATAMediaChanged = 5, /* bit number of media changed indicator*/
|
||||
bATAIDNotFound = 4, /* bit number of ID not found error bit*/
|
||||
bATAMediaChangeReq = 3, /* bit number of media changed request*/
|
||||
bATACommandAborted = 2, /* bit number of command abort bit*/
|
||||
bATATrack0NotFound = 1, /* bit number of track not found*/
|
||||
bATAAddressNotFound = 0, /* bit number of address mark not found*/
|
||||
mATABadBlock = 1 << bATABadBlock, /* Bad Block Detected*/
|
||||
mATAUncorrectable = 1 << bATAUncorrectable, /* Uncorrectable Data Error*/
|
||||
mATAMediaChanged = 1 << bATAMediaChanged, /* Media Changed Indicator (for removable)*/
|
||||
mATAIDNotFound = 1 << bATAIDNotFound, /* ID Not Found*/
|
||||
mATAMediaChangeReq = 1 << bATAMediaChangeReq, /* Media Change Requested (NOT IMPLEMENTED)*/
|
||||
mATACommandAborted = 1 << bATACommandAborted, /* Aborted Command*/
|
||||
mATATrack0NotFound = 1 << bATATrack0NotFound, /* Track 0 Not Found*/
|
||||
mATAAddressNotFound = 1 << bATAAddressNotFound /* Address Mark Not Found*/
|
||||
};
|
||||
|
||||
/* Task file definition *** Features register *** */
|
||||
enum {
|
||||
bATAPIuseDMA = 0, /* bit number of useDMA bit (ATAPI)*/
|
||||
mATAPIuseDMA = 1 << bATAPIuseDMA
|
||||
};
|
||||
|
||||
/* Task file definition *** ataTFSDH Register *** */
|
||||
enum {
|
||||
mATAHeadNumber = 0x0F, /* Head Number (bits 0-3) */
|
||||
mATASectorSize = 0xA0, /* bit 7=1; bit 5 = 01 (512 sector size) <DP4>*/
|
||||
mATADriveSelect = 0x10, /* Drive (0 = master, 1 = slave) */
|
||||
mATALBASelect = 0x40 /* LBA mode bit (0 = chs, 1 = LBA)*/
|
||||
};
|
||||
|
||||
/* Task file definition *** Status Register *** */
|
||||
enum {
|
||||
bATABusy = 7, /* bit number of BSY bit*/
|
||||
bATADriveReady = 6, /* bit number of drive ready bit*/
|
||||
bATAWriteFault = 5, /* bit number of write fault bit*/
|
||||
bATASeekComplete = 4, /* bit number of seek complete bit*/
|
||||
bATADataRequest = 3, /* bit number of data request bit*/
|
||||
bATADataCorrected = 2, /* bit number of data corrected bit*/
|
||||
bATAIndex = 1, /* bit number of index mark*/
|
||||
bATAError = 0, /* bit number of error bit*/
|
||||
mATABusy = 1 << bATABusy, /* Unit is busy*/
|
||||
mATADriveReady = 1 << bATADriveReady, /* Unit is ready*/
|
||||
mATAWriteFault = 1 << bATAWriteFault, /* Unit has a write fault condition*/
|
||||
mATASeekComplete = 1 << bATASeekComplete, /* Unit seek complete*/
|
||||
mATADataRequest = 1 << bATADataRequest, /* Unit data request*/
|
||||
mATADataCorrected = 1 << bATADataCorrected, /* Data corrected*/
|
||||
mATAIndex = 1 << bATAIndex, /* Index mark - NOT USED*/
|
||||
mATAError = 1 << bATAError /* Error condition - see error register*/
|
||||
};
|
||||
|
||||
/* Task file definition *** Device Control Register *** */
|
||||
enum {
|
||||
bATADCROne = 3, /* bit number of always one bit*/
|
||||
bATADCRReset = 2, /* bit number of reset bit*/
|
||||
bATADCRnIntEnable = 1, /* bit number of interrupt disable*/
|
||||
mATADCROne = 1 << bATADCROne, /* always one bit*/
|
||||
mATADCRReset = 1 << bATADCRReset, /* Reset (1 = reset)*/
|
||||
mATADCRnIntEnable = 1 << bATADCRnIntEnable /* Interrupt Disable(0 = enabled)*/
|
||||
};
|
||||
|
||||
|
||||
/* 'ataRegMask' field of the ataRegAccess definition*/
|
||||
enum ataRegMask{
|
||||
|
||||
bATAAltSDevCValid = 14, /* bit number of alternate status/device cntrl valid bit*/
|
||||
bATAStatusCmdValid = 7, /* bit number of status/command valid bit*/
|
||||
bATASDHValid = 6, /* bit number of ataTFSDH valid bit*/
|
||||
bATACylinderHiValid = 5, /* bit number of cylinder high valid bit*/
|
||||
bATACylinderLoValid = 4, /* bit number of cylinder low valid bit*/
|
||||
bATASectorNumValid = 3, /* bit number of sector number valid bit*/
|
||||
bATASectorCntValid = 2, /* bit number of sector count valid bit*/
|
||||
bATAErrFeaturesValid = 1, /* bit number of error/features valid bit*/
|
||||
bATADataValid = 0, /* bit number of data valid bit*/
|
||||
mATAAltSDevCValid = 1 << bATAAltSDevCValid, /* alternate status/device control valid*/
|
||||
mATAStatusCmdValid = 1 << bATAStatusCmdValid, /* status/command valid*/
|
||||
mATASDHValid = 1 << bATASDHValid, /* ataTFSDH valid*/
|
||||
mATACylinderHiValid = 1 << bATACylinderHiValid, /* cylinder high valid*/
|
||||
mATACylinderLoValid = 1 << bATACylinderLoValid, /* cylinder low valid*/
|
||||
mATASectorNumValid = 1 << bATASectorNumValid, /* sector number valid*/
|
||||
mATASectorCntValid = 1 << bATASectorCntValid, /* sector count valid*/
|
||||
mATAErrFeaturesValid = 1 << bATAErrFeaturesValid, /* error/features valid*/
|
||||
mATADataValid = 1 << bATADataValid /* data valid*/
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
enum ataFlags{
|
||||
bATAFlagQuiesce = 20,
|
||||
bATAFlagNoIRQ = 19, /* bit Number of no IRQ protocol flag*/
|
||||
bATAFlag48BitLBA = 18,
|
||||
bATAFlagDMAQueued = 17,
|
||||
bATAFlagOverlapped = 16,
|
||||
bATAFlagUseConfigSpeed = 15, /* bit number of use configured speed flag*/
|
||||
bATAFlagByteSwap = 14, /* bit number of byte swap flag*/
|
||||
bATAFlagIORead = 13, /* bit number of I/O read flag*/
|
||||
bATAFlagIOWrite = 12, /* bit number of I/O write flag*/
|
||||
bATAFlagTFAccessResult = 8, /* bit number of get register results on command completion.*/
|
||||
bATAFlagUseDMA = 7, /* bit number of use DMA flag*/
|
||||
bATAFlagProtocolATAPI = 5, /* bit number of ATAPI protocol*/
|
||||
bATAFlagImmediate = 1, /* bit number of immediate flag */
|
||||
bATAFlagTFAccess = 0, /* bit number of TF access */
|
||||
|
||||
mATAFlagQuiesce = 1 << bATAFlagQuiesce,
|
||||
mATAFlagUseNoIRQ = 1 << bATAFlagNoIRQ, /* Special purpose! Avoid using! No-IRQ, polled synchronous protocol valid only for PIO commands*/
|
||||
mATAFlag48BitLBA = 1 << bATAFlag48BitLBA, /* Use 48 bit extended LBA protocol on this command. Requires support from the controller.*/
|
||||
mATAFlagDMAQueued = 1 << bATAFlagDMAQueued, /* Use tagged dma queuing protocol on this command. Requires support from the controller.*/
|
||||
mATAFlagOverlapped = 1 << bATAFlagOverlapped, /* Use overllaped protocol on this command. Requires support from the controller.*/
|
||||
mATAFlagUseConfigSpeed = 1 << bATAFlagUseConfigSpeed, /* Use the configured interface speed = true. False = use default PIO (slow) speed. valid only for PIO commands*/
|
||||
mATAFlagByteSwap = 1 << bATAFlagByteSwap, /* Swap data bytes (read - after; write - before)*/
|
||||
mATAFlagIORead = 1 << bATAFlagIORead, /* Read (in) operation*/
|
||||
mATAFlagIOWrite = 1 << bATAFlagIOWrite, /* Write (out) operation*/
|
||||
mATAFlagTFAccessResult = 1 << bATAFlagTFAccessResult, /* get contents of TaskFile registers indicated in TFMask on command completion, even if no error*/
|
||||
mATAFlagUseDMA = 1 << bATAFlagUseDMA,
|
||||
mATAFlagProtocolATAPI = 1 << bATAFlagProtocolATAPI, /* ATAPI protocol indicator*/
|
||||
mATAFlagImmediate = 1 << bATAFlagImmediate, /* Put command at head of queue */
|
||||
mATAFlagTFAccess = 1 << bATAFlagTFAccess, /* Return Taskfile on error status*/
|
||||
|
||||
} ;
|
||||
|
||||
/* The Function codes sent to controllers*/
|
||||
enum ataOpcode {
|
||||
|
||||
kATANoOp = 0,
|
||||
kATAFnExecIO , /* Execute ATA I/O */
|
||||
kATAPIFnExecIO, /* ATAPI I/O */
|
||||
kATAFnRegAccess , /* Register Access */
|
||||
|
||||
kATAFnQFlush , /* I/O Queue flush requests for your unit number */
|
||||
kATAFnBusReset /* Reset ATA bus */
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
/* The ATA Event codes */
|
||||
/* sent when calling the device driver's event handler*/
|
||||
enum ataEventCode {
|
||||
kATANullEvent = 0x00, /* Just kidding -- nothing happened*/
|
||||
kATAOnlineEvent = 0x01, /* An ATA device has come online*/
|
||||
kATAOfflineEvent = 0x02, /* An ATA device has gone offline*/
|
||||
kATARemovedEvent = 0x03, /* An ATA device has been removed from the bus*/
|
||||
kATAResetEvent = 0x04, /* Someone gave a hard reset to the drive*/
|
||||
kATAOfflineRequest = 0x05, /* Someone requesting to offline the drive*/
|
||||
kATAEjectRequest = 0x06, /* Someone requesting to eject the drive*/
|
||||
kATAPIResetEvent = 0x07, /* Someone gave a ATAPI reset to the drive*/
|
||||
kATAReservedEvent = 0x80 /* RESERVED*/
|
||||
};
|
||||
|
||||
|
||||
// These need to be combined with a new enumeration of the current ATA/ATAPI command set.
|
||||
// Some opcodes are of interest to ATA controllers, since they imply special protocols
|
||||
// or handling. Device Reset, Execute Device Diagnostics have subtle side effects that
|
||||
// controllers need to be aware of, so we snoop for those commands being issued.
|
||||
// the rest are here for informational purposes.
|
||||
|
||||
// BUG make new enum for all current ATA commands.
|
||||
|
||||
enum {
|
||||
kSOFTRESET = 0x008, // ATAPI Soft Reset command
|
||||
kPACKET = 0x0A0, // ATAPI Packet command
|
||||
kID_DRIVE = 0x0A1 // ATAPI Identify drive command
|
||||
};
|
||||
/* ATA Command Opcode definition*/
|
||||
enum {
|
||||
kATAcmdWORetry = 0x01, /* Without I/O retry option*/
|
||||
kATAcmdNOP = 0x0000, /* NOP operation - media detect*/
|
||||
kATAcmdRecal = 0x0010, /* Recalibrate command */
|
||||
kATAcmdRead = 0x0020, /* Read command */
|
||||
kATAcmdReadLong = 0x0022, /* Read Long command*/
|
||||
kATAcmdReadExtended = 0x0024, /* Read Extended (with retries)*/
|
||||
kATAcmdReadDMAExtended = 0x0025, /* Read DMA Extended (with retries)*/
|
||||
kATAcmdWrite = 0x0030, /* Write command */
|
||||
kATAcmdWriteLong = 0x0032, /* Write Long*/
|
||||
kATAcmdWriteExtended = 0x0034, /* Write Extended (with retries)*/
|
||||
kATAcmdWriteDMAExtended = 0x0035, /* Write DMA Extended (with retries)*/
|
||||
kATAcmdWriteVerify = 0x003C, /* Write verify*/
|
||||
kATAcmdReadVerify = 0x0040, /* Read Verify command */
|
||||
kATAcmdFormatTrack = 0x0050, /* Format Track command */
|
||||
kATAcmdSeek = 0x0070, /* Seek command */
|
||||
kATAcmdDiagnostic = 0x0090, /* Drive Diagnostic command */
|
||||
kATAcmdInitDrive = 0x0091, /* Init drive parameters command */
|
||||
kATAcmdReadMultiple = 0x00C4, /* Read multiple*/
|
||||
kATAcmdWriteMultiple = 0x00C5, /* Write multiple*/
|
||||
kATAcmdSetRWMultiple = 0x00C6, /* Set Multiple for Read/Write Multiple*/
|
||||
kATAcmdReadDMA = 0x00C8, /* Read DMA (with retries)*/
|
||||
kATAcmdWriteDMA = 0x00CA, /* Write DMA (with retries)*/
|
||||
kATAcmdMCAcknowledge = 0x00DB, /* Acknowledge media change - removable*/
|
||||
kATAcmdDoorLock = 0x00DE, /* Door lock*/
|
||||
kATAcmdDoorUnlock = 0x00DF, /* Door unlock*/
|
||||
kATAcmdStandbyImmed = 0x00E0, /* Standby Immediate*/
|
||||
kATAcmdIdleImmed = 0x00E1, /* Idle Immediate*/
|
||||
kATAcmdStandby = 0x00E2, /* Standby*/
|
||||
kATAcmdIdle = 0x00E3, /* Idle*/
|
||||
kATAcmdReadBuffer = 0x00E4, /* Read sector buffer command */
|
||||
kATAcmdCheckPowerMode = 0x00E5, /* Check power mode command <04/04/94>*/
|
||||
kATAcmdSleep = 0x00E6, /* Sleep*/
|
||||
kATAcmdFlushCache = 0x00E7, /* Flush Cache */
|
||||
kATAcmdWriteBuffer = 0x00E8, /* Write sector buffer command */
|
||||
kATAcmdWriteSame = 0x00E9, /* Write same data to multiple sectors*/
|
||||
kATAcmdFlushCacheExtended = 0x00EA, /* Flush Cache Extended */
|
||||
kATAcmdDriveIdentify = 0x00EC, /* Identify Drive command */
|
||||
kATAcmdMediaEject = 0x00ED, /* Media Eject*/
|
||||
kATAcmdSetFeatures = 0x00EF /* Set Features*/
|
||||
};
|
||||
|
||||
/* Set feature command opcodes*/
|
||||
enum {
|
||||
kATAEnableWriteCache = 0x02, /* Enable write cache*/
|
||||
kATASetTransferMode = 0x03, /* Set transfer mode*/
|
||||
kATAEnableAPM = 0x05, /* Enable Advanced Power Management*/
|
||||
kATASetPIOMode = 0x08, /* PIO Flow Control Tx Mode bit*/
|
||||
kATADisableWriteCache = 0x82, /* disable write cache*/
|
||||
kATAEnableReadAhead = 0xAA /* Read look-ahead enable*/
|
||||
};
|
||||
|
||||
// revisit the opcode enumerations.
|
||||
|
||||
//////////////////////
|
||||
|
||||
|
||||
/* task file for ata */
|
||||
typedef struct ataTaskFile {
|
||||
|
||||
UInt8 ataTFFeatures; /* <-> Error(R) or ataTFFeatures(W) register image */
|
||||
UInt8 ataTFCount; /* <-> Sector count/remaining */
|
||||
UInt8 ataTFSector; /* <-> Sector start/finish */
|
||||
UInt8 ataTFCylLo; /* <-> ataTFCylLo */
|
||||
UInt8 ataTFCylHigh; /* <-> ataTFCylHigh */
|
||||
UInt8 ataTFSDH; /* <-> ataTFSDH register image*/
|
||||
UInt8 ataTFCommand; /* <-> Status(R) or Command(W) register image */
|
||||
|
||||
} ataTaskFile;
|
||||
|
||||
|
||||
typedef struct ataRegisterImage {
|
||||
|
||||
ataTaskFile taskFile;
|
||||
UInt16 ataDataRegister; /* <-> Data register. */
|
||||
UInt8 ataAltSDevCReg; /* <->: Alternate status(R) or Device Control(W) register image*/
|
||||
|
||||
} ataRegisterImage ;
|
||||
|
||||
|
||||
typedef struct ATAPICmdPacket{
|
||||
|
||||
UInt16 atapiPacketSize; /* Size of command packet in bytes */
|
||||
UInt16 atapiCommandByte[8]; /* The command packet itself*/
|
||||
|
||||
}ATAPICmdPacket;
|
||||
|
||||
|
||||
|
||||
// Error and result codes: TBD
|
||||
enum {
|
||||
kATAErrUnknownType = -1,
|
||||
kATANoErr = 0,
|
||||
kATAQueueEmpty = 1,
|
||||
kATAUnknownOpcode,
|
||||
kATATimeoutErr,
|
||||
kATAInvalidDevID,
|
||||
kATAErrDevBusy,
|
||||
kATAModeNotSupported,
|
||||
kATADevIntNoCmd,
|
||||
kATADeviceError,
|
||||
kATADMAErr
|
||||
};
|
||||
|
||||
|
||||
#endif /* !_IOATATYPES_H */
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2008 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _DRV_PCI_ATA_H
|
||||
#define _DRV_PCI_ATA_H
|
||||
|
||||
#include <libkern/c++/OSObject.h>
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include "IOATAController.h"
|
||||
#include <IOKit/IOMemoryCursor.h>
|
||||
#include <IOKit/IOBufferMemoryDescriptor.h>
|
||||
|
||||
#include <IOKit/IOInterruptEventSource.h>
|
||||
|
||||
/*! @class IOPCIATA
|
||||
@abstract The base class for PCI-IDE ata controller family.
|
||||
@discussion class defining the common elements of bus-mastering PCI ATA controllers which meet or at least loosely follow the pci bus mastering pci-ide controller spec. Header doc is incomplete, but source is heavily commented.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class IOPCIATA : public IOATAController
|
||||
{
|
||||
OSDeclareDefaultStructors(IOPCIATA);
|
||||
|
||||
public:
|
||||
|
||||
/*--- Overrides from IOATAController ---*/
|
||||
virtual bool init(OSDictionary * properties);
|
||||
virtual bool start( IOService* provider );
|
||||
|
||||
protected:
|
||||
|
||||
// The DMA states: not in use, in use and running with additional passes needed,
|
||||
// in use on final pass, transfer complete, and failure
|
||||
enum ATADMAState
|
||||
{
|
||||
// DMA state flags
|
||||
kATADMAInactive,
|
||||
kATADMAStarting,
|
||||
kATADMAActive,
|
||||
kATADMAStatus,
|
||||
kATADMAComplete,
|
||||
kATADMAError,
|
||||
|
||||
};
|
||||
|
||||
enum {
|
||||
// PRD flags
|
||||
kLast_PRD = 0x8000,
|
||||
kContinue_PRD = 0,
|
||||
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
mBMCmdStartOutput = 0x01, // start engine to transfer from memory to device.
|
||||
mBMCmdStartInput = (1 << 3 ) | 0x01, // start engine to transfer from device to memory
|
||||
mBMCmdStop = 0x00, // halt engine.
|
||||
};
|
||||
|
||||
enum {
|
||||
// bus master status register definitions.
|
||||
bBMStatusSimplex = 7, // 0 = simultaneous transactions allowed. 1 = primary and secondary busses may not be active at same time.
|
||||
bBMStatusDrv1 = 6, // 1 = device 1 and bus are already configured by some other software/firmware
|
||||
bBMStatusDrv0 = 5, // 1 = device 0 and bus are already configured by some other software/firmware
|
||||
bBMStatusInt = 2, // 1 = device has asserted INTRQ and all data is flushed to/from memory.
|
||||
bBMStatusError = 1, // 1 = an error in the DMA has occured. Software clears by writing 1 to this bit.
|
||||
bBMStatusActive = 0, // 1 = DMA engine is active.
|
||||
};
|
||||
|
||||
enum{
|
||||
|
||||
mBMStatusSimplex = 1 << 7,
|
||||
mBMStatusDrv1 = 1 << 6,
|
||||
mBMStatusDrv0 = 1 << 5,
|
||||
mBMStatusInt = 1 << 2,
|
||||
mBMStatusError = 1 << 1,
|
||||
mBMStatusActive = 1
|
||||
};
|
||||
|
||||
// the physical region descriptor used for the dma engine.
|
||||
struct PRD
|
||||
{
|
||||
UInt32 bufferPtr; // address
|
||||
UInt16 byteCount; // 16 bit byte count where 0x0000 = 64K
|
||||
UInt16 flags; // 0 in flags means contine, 0x80 means stop
|
||||
};
|
||||
|
||||
|
||||
// descendants of this class MUST initialize these values
|
||||
// prior to activating any DMA command.
|
||||
IOATARegPtr8 _bmCommandReg;
|
||||
IOATARegPtr8 _bmStatusReg;
|
||||
IOATARegPtr32 _bmPRDAddresReg;
|
||||
|
||||
// semaphore for DMA state
|
||||
UInt32 _dmaState;
|
||||
|
||||
// table of PRD descriptors
|
||||
PRD* _prdTable;
|
||||
IOPhysicalAddress _prdTablePhysical;
|
||||
|
||||
IONaturalMemoryCursor* _DMACursor;
|
||||
|
||||
// override from IOATAController
|
||||
// activate the DMA engine as per the current command
|
||||
virtual IOReturn startDMA( void );
|
||||
|
||||
// override from IOATAController
|
||||
// safely halt the DMA engine regardless of state
|
||||
virtual IOReturn stopDMA( void );
|
||||
|
||||
// allocate memory for the PRD descriptors.
|
||||
virtual bool allocDMAChannel(void);
|
||||
|
||||
// fill CC with stop commands.
|
||||
virtual void initATADMAChains (PRD* descPtr);
|
||||
|
||||
// fill out a PRD, respecting endianess
|
||||
virtual void setPRD(UInt8 *bffr, UInt16 count, PRD *tableElement, UInt16 end);
|
||||
|
||||
// setup the CC with IO commands
|
||||
virtual IOReturn createChannelCommands(void);
|
||||
|
||||
// deallocate memory for the DMA engine
|
||||
virtual bool freeDMAChannel(void);
|
||||
|
||||
// clean up on device interrupt
|
||||
virtual IOReturn handleDeviceInterrupt(void);
|
||||
|
||||
// activate the DMA engine
|
||||
virtual void activateDMAEngine(void);
|
||||
|
||||
// shutdown the DMA engine
|
||||
virtual void stopDMAEngine(void);
|
||||
|
||||
// safely suspend the DMA engine
|
||||
virtual void shutDownATADMA (void);
|
||||
|
||||
// overrides
|
||||
virtual void free();
|
||||
protected:
|
||||
/*! @struct ExpansionData
|
||||
@discussion This structure will be used to expand the capablilties of the IOPCIATA class in the future.
|
||||
*/
|
||||
typedef struct ExpansionData
|
||||
{
|
||||
IOBufferMemoryDescriptor* _prdBuffer;
|
||||
} ExpansionData;
|
||||
|
||||
/*! @var reserved
|
||||
Reserved for future use. (Internal use only) */
|
||||
ExpansionData *reserved;
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 0);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 1);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 10);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 11);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 12);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 13);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 14);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 15);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 16);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 17);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 18);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 19);
|
||||
OSMetaClassDeclareReservedUnused(IOPCIATA, 20);
|
||||
};
|
||||
|
||||
#endif // _DRV_PCI_ATA_H
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2012 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __BIGNUM128_H__
|
||||
#define __BIGNUM128_H__
|
||||
|
||||
#include <libkern/OSTypes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class U128
|
||||
{
|
||||
public:
|
||||
U128(uint64_t _lo = 0) : lo(_lo), hi(0) { };
|
||||
U128(uint64_t _hi, uint64_t _lo) : lo(_lo), hi(_hi) { };
|
||||
inline bool operator==( const U128 &A ) const { return ( A.hi == hi ) && ( A.lo == lo ); }
|
||||
inline bool operator>( const U128 &A ) const { return ( ( A.hi > hi ) || ( ( A.hi == hi ) && ( A.lo > lo ) ) ); }
|
||||
inline bool operator<( const U128 &A ) const { return !( ( A.hi > hi ) || ( ( A.hi == hi ) && ( A.lo > lo ) ) ); }
|
||||
|
||||
U128 operator++( int )
|
||||
{
|
||||
if ( ++lo==0 )
|
||||
hi++;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
U128 operator--( int )
|
||||
{
|
||||
if ( 0 == lo-- )
|
||||
{
|
||||
hi--;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
U128& operator=( const U128 &A )
|
||||
{
|
||||
hi = A.hi;
|
||||
lo = A.lo;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
U128 operator+( const U128 &A ) const
|
||||
{
|
||||
U128 result(A.hi + hi, A.lo + lo);
|
||||
|
||||
if ( ( result.lo < A.lo ) || ( result.lo < lo ) )
|
||||
{
|
||||
result.hi++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
U128& operator+=( const U128 &A )
|
||||
{
|
||||
U128 result(A.hi + hi, A.lo + lo);
|
||||
|
||||
if ( ( result.lo < A.lo ) || ( result.lo < lo ) )
|
||||
{
|
||||
result.hi++;
|
||||
}
|
||||
|
||||
*this = result;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend U128 operator-( const U128 &A, const U128 &B ) // assumes A >= B
|
||||
{
|
||||
U128 C = A;
|
||||
|
||||
C.hi -= B.hi;
|
||||
C.lo -= B.lo;
|
||||
|
||||
if ( C.lo > A.lo ) // borrow ?
|
||||
{
|
||||
C.hi--;
|
||||
}
|
||||
|
||||
return C;
|
||||
}
|
||||
|
||||
|
||||
friend U128 operator<<( const U128& A, int n )
|
||||
{
|
||||
U128 res = A;
|
||||
|
||||
while ( n-- )
|
||||
{
|
||||
res.hi <<= 1;
|
||||
res.hi |= ( ( res.lo & MSB64 ) ? 1 : 0 );
|
||||
res.lo <<= 1;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
friend U128 operator>>( const U128& A, int n )
|
||||
{
|
||||
U128 res = A;
|
||||
|
||||
while ( n-- )
|
||||
{
|
||||
res.lo >>= 1;
|
||||
res.lo |= ( ( res.hi & 0x1 ) ? MSB64 : 0 );
|
||||
res.hi >>= 1;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
uint64_t hi;
|
||||
uint64_t lo;
|
||||
#else
|
||||
uint64_t lo;
|
||||
uint64_t hi;
|
||||
#endif
|
||||
|
||||
private:
|
||||
enum { MSB64 = 0x8000000000000000ULL };
|
||||
};
|
||||
|
||||
extern U128 UInt64mult(const uint64_t A, const uint64_t B);
|
||||
|
||||
#endif //__BIGNUM128_H__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
/* Copyright: © Copyright 2011 Apple Computer, Inc. All rights reserved.
|
||||
|
||||
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
|
||||
("Apple") in consideration of your agreement to the following terms, and your
|
||||
use, installation, modification or redistribution of this Apple software
|
||||
constitutes acceptance of these terms. If you do not agree with these terms,
|
||||
please do not use, install, modify or redistribute this Apple software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and subject
|
||||
to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs
|
||||
copyrights in this original Apple software (the "Apple Software"), to use,
|
||||
reproduce, modify and redistribute the Apple Software, with or without
|
||||
modifications, in source and/or binary forms; provided that if you redistribute
|
||||
the Apple Software in its entirety and without modifications, you must retain
|
||||
this notice and the following text and disclaimers in all such redistributions of
|
||||
the Apple Software. Neither the name, trademarks, service marks or logos of
|
||||
Apple Computer, Inc. may be used to endorse or promote products derived from the
|
||||
Apple Software without specific prior written permission from Apple. Except as
|
||||
expressly stated in this notice, no other rights or licenses, express or implied,
|
||||
are granted by Apple herein, including but not limited to any patent rights that
|
||||
may be infringed by your derivative works or by other works in which the Apple
|
||||
Software may be incorporated.
|
||||
|
||||
The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
|
||||
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
|
||||
WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
|
||||
COMBINATION WITH YOUR PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
|
||||
OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
|
||||
(INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* @header IOAudioBlitterLibDispatch
|
||||
*/
|
||||
|
||||
#ifndef __IOAudioBlitterLibDispatch_h__
|
||||
#define __IOAudioBlitterLibDispatch_h__
|
||||
|
||||
#include <libkern/OSTypes.h>
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Alternate names
|
||||
|
||||
// Alternate names for the functions below: these explicitly specify the endianness of the integer format instead of "native"/"swap"
|
||||
#if TARGET_RT_BIG_ENDIAN
|
||||
#define IOAF_BEInt16ToFloat32 IOAF_NativeInt16ToFloat32
|
||||
#define IOAF_LEInt16ToFloat32 IOAF_SwapInt16ToFloat32
|
||||
#define IOAF_BEInt24ToFloat32 IOAF_NativeInt24ToFloat32
|
||||
#define IOAF_LEInt24ToFloat32 IOAF_SwapInt24ToFloat32
|
||||
#define IOAF_BEInt32ToFloat32 IOAF_NativeInt32ToFloat32
|
||||
#define IOAF_LEInt32ToFloat32 IOAF_SwapInt32ToFloat32
|
||||
|
||||
#define IOAF_Float32ToBEInt16 IOAF_Float32ToNativeInt16
|
||||
#define IOAF_Float32ToLEInt16 IOAF_Float32ToSwapInt16
|
||||
#define IOAF_Float32ToBEInt24 IOAF_Float32ToNativeInt24
|
||||
#define IOAF_Float32ToLEInt24 IOAF_Float32ToSwapInt24
|
||||
#define IOAF_Float32ToBEInt32 IOAF_Float32ToNativeInt32
|
||||
#define IOAF_Float32ToLEInt32 IOAF_Float32ToSwapInt32
|
||||
#else
|
||||
#define IOAF_LEInt16ToFloat32 IOAF_NativeInt16ToFloat32
|
||||
#define IOAF_BEInt16ToFloat32 IOAF_SwapInt16ToFloat32
|
||||
#define IOAF_LEInt24ToFloat32 IOAF_NativeInt24ToFloat32
|
||||
#define IOAF_BEInt24ToFloat32 IOAF_SwapInt24ToFloat32
|
||||
#define IOAF_LEInt32ToFloat32 IOAF_NativeInt32ToFloat32
|
||||
#define IOAF_BEInt32ToFloat32 IOAF_SwapInt32ToFloat32
|
||||
|
||||
#define IOAF_Float32ToLEInt16 IOAF_Float32ToNativeInt16
|
||||
#define IOAF_Float32ToBEInt16 IOAF_Float32ToSwapInt16
|
||||
#define IOAF_Float32ToLEInt24 IOAF_Float32ToNativeInt24
|
||||
#define IOAF_Float32ToBEInt24 IOAF_Float32ToSwapInt24
|
||||
#define IOAF_Float32ToLEInt32 IOAF_Float32ToNativeInt32
|
||||
#define IOAF_Float32ToBEInt32 IOAF_Float32ToSwapInt32
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @typedef Float32
|
||||
* @abstract Convenience type that represent a 32-bit floating point number
|
||||
*/
|
||||
typedef float Float32;
|
||||
|
||||
/*!
|
||||
* @typedef Float64
|
||||
* @abstract Convenience type that represent a 64-bit floating point number
|
||||
*/
|
||||
typedef double Float64;
|
||||
|
||||
#ifndef __OPEN_SOURCE__
|
||||
/*!
|
||||
* @function IOAF_Int8ToFloat32
|
||||
* @abstract Converts 8-bit integer float to 32-bit float
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_Int8ToFloat32( const SInt8 *src, Float32 *dest, unsigned int count );
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @function IOAF_NativeInt16ToFloat32
|
||||
* @abstract Converts native 16-bit integer float to 32-bit float
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_NativeInt16ToFloat32( const SInt16 *src, Float32 *dest, unsigned int count );
|
||||
|
||||
/*!
|
||||
* @function IOAF_SwapInt16ToFloat32
|
||||
* @abstract Converts non-native 16-bit integer float to 32-bit float
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_SwapInt16ToFloat32( const SInt16 *src, Float32 *dest, unsigned int count );
|
||||
|
||||
/*!
|
||||
* @function IOAF_NativeInt24ToFloat32
|
||||
* @abstract Converts native 24-bit integer float to 32-bit float
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_NativeInt24ToFloat32( const UInt8 *src, Float32 *dest, unsigned int count );
|
||||
|
||||
/*!
|
||||
* @function IOAF_SwapInt24ToFloat32
|
||||
* @abstract Converts non-native 24-bit integer float to 32-bit float
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_SwapInt24ToFloat32( const UInt8 *src, Float32 *dest, unsigned int count );
|
||||
|
||||
/*!
|
||||
* @function IOAF_NativeInt32ToFloat32
|
||||
* @abstract Converts native 32-bit integer float to 32-bit float
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_NativeInt32ToFloat32( const SInt32 *src, Float32 *dest, unsigned int count );
|
||||
|
||||
/*!
|
||||
* @function IOAF_SwapInt32ToFloat32
|
||||
* @abstract Converts non-native 32-bit integer float to 32-bit float
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_SwapInt32ToFloat32( const SInt32 *src, Float32 *dest, unsigned int count );
|
||||
|
||||
#ifndef __OPEN_SOURCE__
|
||||
/*!
|
||||
* @function IOAF_Float32ToInt8
|
||||
* @abstract Converts 32-bit floating point to 8-bit integer
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_Float32ToInt8( const Float32 *src, SInt8 *dest, unsigned int count );
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @function IOAF_Float32ToNativeInt16
|
||||
* @abstract Converts 32-bit floating point to native 16-bit integer
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_Float32ToNativeInt16( const Float32 *src, SInt16 *dest, unsigned int count );
|
||||
|
||||
/*!
|
||||
* @function IOAF_Float32ToSwapInt16
|
||||
* @abstract Converts 32-bit floating point to non-native 16-bit integer
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_Float32ToSwapInt16( const Float32 *src, SInt16 *dest, unsigned int count );
|
||||
|
||||
/*!
|
||||
* @function IOAF_Float32ToNativeInt24
|
||||
* @abstract Converts 32-bit floating point to native 24-bit integer
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_Float32ToNativeInt24( const Float32 *src, UInt8 *dest, unsigned int count );
|
||||
|
||||
/*!
|
||||
* @function IOAF_Float32ToSwapInt24
|
||||
* @abstract Converts 32-bit floating point to non-native 24-bit integer
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_Float32ToSwapInt24( const Float32 *src, UInt8 *dest, unsigned int count );
|
||||
|
||||
/*!
|
||||
* @function IOAF_Float32ToNativeInt32
|
||||
* @abstract Converts 32-bit floating point to native 32-bit integer
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_Float32ToNativeInt32( const Float32 *src, SInt32 *dest, unsigned int count );
|
||||
|
||||
/*!
|
||||
* @function IOAF_Float32ToSwapInt32
|
||||
* @abstract Converts 32-bit floating point to non-native 32-bit integer
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_Float32ToSwapInt32( const Float32 *src, SInt32 *dest, unsigned int count );
|
||||
|
||||
/*!
|
||||
* @function IOAF_bcopy_WriteCombine
|
||||
* @abstract An efficient bcopy from "write combine" memory to regular memory. It is safe to assume that all memory has been copied when the function has completed
|
||||
* @param src Pointer to the data to convert
|
||||
* @param dest Pointer to the converted data
|
||||
* @param count The number of items to convert
|
||||
*/
|
||||
extern void IOAF_bcopy_WriteCombine(const void *src, void *dest, unsigned int count );
|
||||
|
||||
#endif // __IOAudioBlitterLibDispatch_h__
|
||||
@@ -0,0 +1,600 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2014 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IOAUDIOCONTROL_H
|
||||
#define _IOKIT_IOAUDIOCONTROL_H
|
||||
|
||||
#include <IOKit/IOService.h>
|
||||
#include <AvailabilityMacros.h>
|
||||
#ifndef IOAUDIOFAMILY_SELF_BUILD
|
||||
#include <IOKit/audio/IOAudioEngine.h>
|
||||
#else
|
||||
#include "IOAudioEngine.h"
|
||||
#endif
|
||||
|
||||
class IOAudioPort;
|
||||
class OSDictionary;
|
||||
class OSSet;
|
||||
class IOAudioUserClient;
|
||||
class IOAudioControlUserClient;
|
||||
class IOWorkLoop;
|
||||
class IOCommandGate;
|
||||
|
||||
/*!
|
||||
* @class IOAudioControl
|
||||
* @abstract Represents any controllable attribute of an IOAudioDevice.
|
||||
* @discussion An IOAudioControl instance may belong to one IOAudioPort. Additionally, it may associated
|
||||
* with an IOAudioEngine as a default control for that IOAudioEngine.
|
||||
*
|
||||
* When its value changes, it sends a notification to the CoreAudio.framework (HAL). It also makes a call
|
||||
* to the ValueChangeHandler.
|
||||
*
|
||||
* The base IOAudioControl class contains a type, a value and a channel ID representing the channel(s) which
|
||||
* the control acts on. It may also contain a readable format for the name of the channel as well as a
|
||||
* control ID that can be used to identify unique controls. Additionally it may contain a subType and a usage.
|
||||
* Each type has its own set of possible subTypes. There currently four different control types defined:
|
||||
* kIOAudioControlTypeLevel, kIOAudioControlTypeToggle, kIOAudioControlTypeSelector.
|
||||
* Each one is represented by a subclass of IOAudioControl: IOAudioLevelControl, IOAudioToggleControl,
|
||||
* IOAudioSelectorControl. The level control defines a range of allowed values and has
|
||||
* a defined subtype of kIOAudioLevelControlSubTypeVolume used to define a volume control. The toggle control
|
||||
* allows for a boolean value and has a defined subtype kIOAudioToggleControlSubTypeMute for a mute control. The
|
||||
* selector control has a list of allowed selections with a value and description for each allowed selection and
|
||||
* has the following sub types: kIOAudioSelectorControlSubTypeOutput for an output selector and
|
||||
* kIOAudioSelectorControlSubTypeInput for an input selector. See the subclass documentation for a more
|
||||
* complete description of each
|
||||
*
|
||||
* There are enums for default channel ID values and common channel names in IOAudioTypes.h. The channel ID
|
||||
* values are prefixed with 'kIOAudioControlChannelID' and the common channel names are prefixed with
|
||||
* 'kIOAudioControlChannelName'. All of the attributes of the IOAudioControl are stored in the registry.
|
||||
* The key used for each attribute is defined in IOAudioTypes.h with the define matching the following
|
||||
* pattern: 'kIOAudioControl<attribute name>Key'. For example: kIOAudioControlChannelIDKey.
|
||||
*
|
||||
* In addition to the existing defined control types, drivers can define their own as well for other purposes.
|
||||
*
|
||||
* Changes to the IOAudioControl's value made by the CoreAudio.framework are done through the IORegistry.
|
||||
* When the CoreAudio.framework initiates a value change, the control receives a setProperties() message.
|
||||
* The setProperties() implementation looks for the property 'IOAudioControlValue' and if present, calls
|
||||
* setValue() on the driver's IOWorkLoop with the new value. The setValue() function first checks to see
|
||||
* if the new value is different. If so, it calls performValueChange() to call through to the driver
|
||||
* to make the change in the hardware. If that call succeeds the value is changed and the new value is set
|
||||
* in the registry. Additionally notifications are sent to all clients that have registered for them.
|
||||
*/
|
||||
class IOAudioControl : public IOService
|
||||
{
|
||||
friend class IOAudioPort;
|
||||
friend class IOAudioDevice;
|
||||
friend class IOAudioEngine;
|
||||
|
||||
OSDeclareDefaultStructors(IOAudioControl)
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* @typedef IntValueChangeHandler
|
||||
* @abstract Handler function used to make a notification when a value is to be changed.
|
||||
* @param target Reference supplied when the handler was registered.
|
||||
* @param audioControl The IOAudioControl that is changing.
|
||||
* @param oldValue The old value of the control.
|
||||
* @param newValue The new value the control is being changed to.
|
||||
* @result Must return kIOReturnSuccess when the hardware is successfully updated.
|
||||
*/
|
||||
typedef IOReturn (*IntValueChangeHandler)(OSObject *target, IOAudioControl *audioControl, SInt32 oldValue, SInt32 newValue ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
typedef IOReturn (*DataValueChangeHandler)(OSObject *target, IOAudioControl *audioControl, const void *oldData, UInt32 oldDataSize, const void *newData, UInt32 newDataSize ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
typedef IOReturn (*ObjectValueChangeHandler)(OSObject *target, IOAudioControl *audioControl, OSObject *oldValue, OSObject *newValue ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
protected:
|
||||
/*! @var workLoop
|
||||
The IOWorkLoop for the audio driver - shared from the IOAudioDevice.
|
||||
*/
|
||||
IOWorkLoop *workLoop;
|
||||
/*! @var commandGate
|
||||
The IOCommandGate for this control - attached to the driver's IOWorkLoop.
|
||||
*/
|
||||
IOCommandGate *commandGate;
|
||||
|
||||
/*! @var isStarted
|
||||
Internal state keeping track of when the IOAudioControl has been started.
|
||||
*/
|
||||
bool isStarted;
|
||||
|
||||
/*! @var controlID
|
||||
An optional identifier that can be used to identify the control.
|
||||
*/
|
||||
UInt32 controlID;
|
||||
/*! @var channelID
|
||||
The ID of the channel this control affects - may be kIOAudioControlChannelIDAll if it represents all channels.
|
||||
*/
|
||||
UInt32 channelID;
|
||||
|
||||
UInt32 type;
|
||||
UInt32 subType;
|
||||
UInt32 usage;
|
||||
|
||||
OSObject *value;
|
||||
|
||||
typedef enum {
|
||||
kIntValueChangeHandler,
|
||||
kDataValueChangeHandler,
|
||||
kObjectValueChangeHandler
|
||||
} ValueChangeHandlerType;
|
||||
|
||||
ValueChangeHandlerType valueChangeHandlerType;
|
||||
|
||||
union {
|
||||
IntValueChangeHandler intHandler;
|
||||
DataValueChangeHandler dataHandler;
|
||||
ObjectValueChangeHandler objectHandler;
|
||||
} valueChangeHandler;
|
||||
|
||||
OSObject *valueChangeTarget;
|
||||
|
||||
/*! @var clients
|
||||
A list of user clients that have requested value change notifications.
|
||||
*/
|
||||
OSSet *userClients;
|
||||
|
||||
protected:
|
||||
struct ExpansionData {
|
||||
IOAudioEngine * providerEngine;
|
||||
OSArray * notificationQueue;
|
||||
UInt32 commandGateStatus; // <rdar://8518215>
|
||||
SInt32 commandGateUsage; // <rdar://8518215>
|
||||
};
|
||||
|
||||
ExpansionData *reserved;
|
||||
|
||||
public:
|
||||
// OSMetaClassDeclareReservedUsed(IOAudioControl, 0);
|
||||
virtual void sendChangeNotification(UInt32 notificationType ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
// OSMetaClassDeclareReservedUsed(IOAudioControl, 1);
|
||||
/*!
|
||||
* @function setReadOnlyFlag
|
||||
* @abstract Call this function to say that a control is read only.
|
||||
* This call cannot be undone, so if a control is only temporarily unsetable,
|
||||
* do not use this call but instead return an error from the control handler.
|
||||
*/
|
||||
virtual void setReadOnlyFlag( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
// OSMetaClassDeclareReservedUsed(IOAudioControl, 2);
|
||||
virtual void sendQueuedNotifications(void ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
// OSMetaClassDeclareReservedUsed(IOAudioControl, 3);
|
||||
/*!
|
||||
* @function createUserClient
|
||||
* @abstract Creates a new IOAudioControlUserClient instance.
|
||||
* @discussion This function is called by newUserClient() to create a new IOAudioControlUserClient instance. This function may be overridden by subclasses that need to add functionality
|
||||
* to the IOAudioControlUserClient. In that case, they must subclass IOAudioControlUserClient
|
||||
* and return a new, initialized instance of that subclass.
|
||||
* A derived class that requires overriding of createUserClient should override the version with the properties
|
||||
* parameter for Intel targets, and without the properties parameter for PPC targets. The #if __i386__ directive
|
||||
* can be used to select between the two behaviors.
|
||||
* @param task The task requesting the new user client.
|
||||
* @param securityID Optional security paramater passed in by the client - ignored.
|
||||
* @param type Optional user client type passed in by the client.
|
||||
* @param newUserClient The IOAudioControlUserClient * must be stored in this param on a successful
|
||||
* completion.
|
||||
* @param properties A dictionary of additional properties for the connection.
|
||||
* @result Returns kIOReturnSuccess on success.
|
||||
*/
|
||||
virtual IOReturn createUserClient(task_t task, void *securityID, UInt32 taskType, IOAudioControlUserClient **newUserClient, OSDictionary *properties) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUsed(IOAudioControl, 0);
|
||||
OSMetaClassDeclareReservedUsed(IOAudioControl, 1);
|
||||
OSMetaClassDeclareReservedUsed(IOAudioControl, 2);
|
||||
OSMetaClassDeclareReservedUsed(IOAudioControl, 3);
|
||||
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 10);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 11);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 12);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 13);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 14);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 15);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 16);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 17);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 18);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 19);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 20);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 21);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 22);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControl, 23);
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* @function withAttributes
|
||||
* @abstract Static function that allocates a new IOAudioControl with the given attributes.
|
||||
* @param type The type of the control. Common, known types are defined in IOAudioTypes.h. They currently
|
||||
* consist of kIOAudioControlTypeLevel, kIOAudioControlTypeToggle, kIOAudioControlTypeSelector.
|
||||
* @param channelID The ID of the channel(s) that the control acts on. Common IDs are located in IOAudioTypes.h.
|
||||
* @param channelName An optional name for the channel. Common names are located in IOAudioDefines.h. Any name not
|
||||
* defined in IOAudioDefines.h must be localized in order to be properly displayed in multiple languages.
|
||||
* @param cntrlID An optional ID for the control that can be used to uniquely identify controls
|
||||
* @param subType An optional subType specific to the given type
|
||||
* @param usage An optional value specifying how the control will be used. Currently defined usages are kIOAudioControlUsageInput,
|
||||
* kIOAudioControlUsageOutput and kIOAudioControlUsagePassThru. This value is used when a control is set as a default control
|
||||
* on an IOAudioEngine.
|
||||
* @result Returns a newly allocated and initialized IOAudioControl.
|
||||
*/
|
||||
static IOAudioControl *withAttributes(UInt32 type,
|
||||
OSObject *initialValue,
|
||||
UInt32 channelID,
|
||||
const char *channelName = 0,
|
||||
UInt32 cntrlID = 0,
|
||||
UInt32 subType = 0,
|
||||
UInt32 usage = 0) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 ;
|
||||
|
||||
/*!
|
||||
* @function init
|
||||
* @abstract Initializes a newly allocated IOAudioControl with the given attributes.
|
||||
* @param type The type of the control. Common, known types are defined in IOAudioTypes.h. They currently
|
||||
* consist of kIOAudioControlTypeLevel, kIOAudioControlTypeToggle, kIOAudioControlTypeSelector.
|
||||
* @param channelID The ID of the channel(s) that the control acts on. Common IDs are located in IOAudioTypes.h.
|
||||
* @param channelName An optional name for the channel. Common names are located in IOAudioDefines.h. Any name not
|
||||
* defined in IOAudioDefines.h must be localized in order to be properly displayed in multiple languages.
|
||||
* @param cntrlID An optional ID for the control that can be used to uniquely identify controls
|
||||
* @param subType An optional subType specific to the given type
|
||||
* @param usage An optional value specifying how the control will be used. Currently defined usages are kIOAudioControlUsageInput,
|
||||
* kIOAudioControlUsageOutput and kIOAudioControlUsagePassThru. This value is used when a control is set as a default control
|
||||
* on an IOAudioEngine.
|
||||
* @param properties Standard property list passed to the init() function of any new IOService. This dictionary
|
||||
* gets stored in the registry entry for this instance.
|
||||
* @result Returns true on success.
|
||||
*/
|
||||
virtual bool init(UInt32 type,
|
||||
OSObject *initialValue,
|
||||
UInt32 channelID,
|
||||
const char *channelName = 0,
|
||||
UInt32 cntrlID = 0,
|
||||
UInt32 subType = 0,
|
||||
UInt32 usage = 0,
|
||||
OSDictionary *properties = 0) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 ;
|
||||
|
||||
/*!
|
||||
* @function free
|
||||
* @abstract Frees all of the resources allocated by the IOAudioControl.
|
||||
* @discussion Do not call this directly. This is called automatically by the system when the instance's
|
||||
* refcount goes to 0. To decrement the refcount, call release() on the object.
|
||||
*/
|
||||
virtual void free( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function start
|
||||
* @abstract Starts a newly created IOAudioControl.
|
||||
* @discussion This is called automatically by IOAudioPort when addAudioControl() is called or by IOAudioEngine
|
||||
* when addDefaultAudioControl() is called. It will only be called by the first call to either addAudioControl() or
|
||||
* addDefaultAudioControl().
|
||||
* @param provider The IOAudioPort or IOAudioEngine that owns this control.
|
||||
* @result Returns true on success.
|
||||
*/
|
||||
virtual bool start(IOService *provider) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
virtual bool attachAndStart(IOService *provider) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function getIsStarted
|
||||
* @abstract Returns true after start() has been called.
|
||||
* @discussion Used by IOAudioPort and IOAudioEngine to decide if the control needs to be started.
|
||||
*/
|
||||
virtual bool getIsStarted() AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function stop
|
||||
* @abstract Stops the control when the provider is going away.
|
||||
* @param provider The IOAudioPort or IOAudioEngine that owns this control.
|
||||
*/
|
||||
virtual void stop(IOService *provider) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function getWorkLoop
|
||||
* @abstract Returns the IOWorkLoop for the whole audio driver.
|
||||
*/
|
||||
virtual IOWorkLoop *getWorkLoop() AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function getCommandGate
|
||||
* @abstract Returns the IOCommandGate for this IOAudioControl.
|
||||
*/
|
||||
virtual IOCommandGate *getCommandGate() AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 ;
|
||||
|
||||
/*!
|
||||
* @function newUserClient
|
||||
* @abstract Creates a new user client object for this IOAudioControl instance.
|
||||
* @discussion This is called automatically by I/O Kit when a user process opens a connection to this
|
||||
* IOAudioControl. This is typically done when the user process needs to register for value change
|
||||
* notifications. This implementation allocates a new IOAudioControlUserClient object. There is no
|
||||
* need to call this directly.
|
||||
* A derived class that requires overriding of newUserClient should override the version with the properties
|
||||
* parameter for Intel targets, and without the properties parameter for PPC targets. The #if __i386__ directive
|
||||
* can be used to select between the two behaviors.
|
||||
* @param task The task requesting the new user client.
|
||||
* @param securityID Optional security paramater passed in by the client - ignored.
|
||||
* @param type Optional user client type passed in by the client - 0 for the default user client type.
|
||||
* @param handler The new IOUserClient * must be stored in this param on a successful completion.
|
||||
* @param properties A dictionary of additional properties for the connection.
|
||||
* @result Returns kIOReturnSuccess on success. May also result kIOReturnError or kIOReturnNoMemory.
|
||||
*/
|
||||
virtual IOReturn newUserClient(task_t task, void *securityID, UInt32 type, IOUserClient **handler) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
virtual IOReturn newUserClient(task_t task, void *securityID, UInt32 type, OSDictionary *properties, IOUserClient **handler) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function createUserClient
|
||||
* @abstract Creates a new IOAudioControlUserClient instance.
|
||||
* @discussion This function is called by newUserClient() to create a new IOAudioControlUserClient instance. This function may be overridden by subclasses that need to add functionality
|
||||
* to the IOAudioControlUserClient. In that case, they must subclass IOAudioControlUserClient
|
||||
* and return a new, initialized instance of that subclass.
|
||||
* A derived class that requires overriding of createUserClient should override the version with the properties
|
||||
* parameter for Intel targets, and without the properties parameter for PPC targets. The #if __i386__ directive
|
||||
* can be used to select between the two behaviors.
|
||||
* @param task The task requesting the new user client.
|
||||
* @param securityID Optional security paramater passed in by the client - ignored.
|
||||
* @param type Optional user client type passed in by the client.
|
||||
* @param newUserClient The IOAudioControlUserClient * must be stored in this param on a successful
|
||||
* completion.
|
||||
* @result Returns kIOReturnSuccess on success.
|
||||
*/
|
||||
virtual IOReturn createUserClient(task_t task, void *securityID, UInt32 type, IOAudioControlUserClient **newUserClient) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 ;
|
||||
|
||||
/*!
|
||||
* @function clientClosed
|
||||
* @abstract Called automatically by the IOAudioControlUserClient when a user client closes its
|
||||
* connection to the control.
|
||||
* @param client The user client object that has disconnected.
|
||||
*/
|
||||
virtual void clientClosed(IOAudioControlUserClient *client) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function setProperties
|
||||
* @abstract Changes a property of this IOService.
|
||||
* @discussion This is called when the user client changes a property of this
|
||||
* IOAudioControl. In this case it is used to change the value. This function
|
||||
* looks for that property and then calls setValue() through the IOCommandGate and
|
||||
* setValueAction().
|
||||
* @param properties An OSDictionary containing the properties to change.
|
||||
* @result Returns kIOReturnSuccess on success.
|
||||
*/
|
||||
virtual IOReturn setProperties(OSObject *properties) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
virtual void setValueChangeHandler(IntValueChangeHandler intValueChangeHandler, OSObject *target) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
virtual void setValueChangeHandler(DataValueChangeHandler dataValueChangeHandler, OSObject *target) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
virtual void setValueChangeHandler(ObjectValueChangeHandler objectValueChangeHandler, OSObject *target) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
virtual void setValueChangeTarget(OSObject *target) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function flushValue
|
||||
* @abstract Forces the control to be flushed out to the hardware.
|
||||
* @discussion This function calls performValueChange() directly with the current value of the IOAudioControl.
|
||||
* @result Returns the result of performValueChange() - kIOReturnSuccess on success.
|
||||
*/
|
||||
virtual IOReturn flushValue() AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function setValueAction
|
||||
* @abstract IOCommandGate Action which calls setValue() while holding the IOCommandGate.
|
||||
* @discussion This is needed to allow setValue() to be called on the IOWorkLoop.
|
||||
* @param owner The owner of the IOCommandGate (the IOAudioControl in this case).
|
||||
* @param arg1 The new value for the IOAudioControl.
|
||||
* @result Returns the result of setValue() - kIOReturnSuccess on success.
|
||||
*/
|
||||
static IOReturn setValueAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
static IOReturn _setValueAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10; // <rdar://7529580>
|
||||
|
||||
/*!
|
||||
* @function setValue
|
||||
* @abstract Sets the value for this control.
|
||||
* @discussion When the control's value is changed, a call is made to performValueChange(). If that call
|
||||
* succeeds, the value is set and sendValueChangeNotification() is called to send a notification to the
|
||||
* user clients. This function must be called on the IOWorkLoop.
|
||||
* @param newValue The new value for this control.
|
||||
* @result Returns kIOReturnSuccess if the value is successfully set.
|
||||
*/
|
||||
virtual IOReturn setValue(OSObject *newValue ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
virtual IOReturn setValue(SInt32 intValue ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function hardwareValueChanged
|
||||
* @abstract Updates the value for this control and sends out the value changed notification.
|
||||
* @discussion This is designed to be called by the driver when it detects that the hardware's value has
|
||||
* changed without driver intervention (e.g. when an external event causes the change). The difference between
|
||||
* hardwareValueChanged() and setValue() is that hardwareValueChanged() doesn't call performValueChange() which
|
||||
* sends a message back to the driver to cause it to change the hardware with the new value. This function must
|
||||
* be called on the IOWorkLoop.
|
||||
* @param newValue The new value for this control.
|
||||
* @result Returns kIOReturnSuccess if the value is successfully updated.
|
||||
*/
|
||||
virtual IOReturn hardwareValueChanged(OSObject *newValue ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function getValue
|
||||
* @abstract Returns the current value of the control.
|
||||
*/
|
||||
virtual OSObject *getValue( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
virtual SInt32 getIntValue( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
virtual const void *getDataBytes( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
virtual UInt32 getDataLength( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function getControlID
|
||||
* @abstract Returns the control ID for the control.
|
||||
*/
|
||||
virtual UInt32 getControlID( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function getChannelID
|
||||
* @abstract Returns the channel ID for the control.
|
||||
*/
|
||||
virtual UInt32 getChannelID( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
virtual UInt32 getType( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
virtual UInt32 getSubType( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
virtual UInt32 getUsage( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
virtual void setCoreAudioPropertyID(UInt32 propertyID ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
void setWorkLoop(IOWorkLoop *wl ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* @function sendValueChangeNotification
|
||||
* @abstract Called when the value has changed for the control.
|
||||
* @discussion This function sends out the value change notification to the user clients.
|
||||
*/
|
||||
virtual void sendValueChangeNotification( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function setChannelName
|
||||
* @abstract Called at init time to set the channel name for this IOAudioControl.
|
||||
*/
|
||||
virtual void setChannelName(const char *channelName ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function setChannelID
|
||||
* @abstract Called at init time to set the channel ID for this IOAudioControl.
|
||||
*/
|
||||
virtual void setChannelID(UInt32 newChannelID ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
virtual void setChannelNumber(SInt32 channelNumber ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function setSubType
|
||||
* @abstract Called at init time to set the control subType.
|
||||
*/
|
||||
virtual void setType(UInt32 type ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function setType
|
||||
* @abstract Called at init time to set the control type.
|
||||
*/
|
||||
virtual void setSubType(UInt32 subType ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function setUsage
|
||||
* @abstract Called at init time to set the control usage.
|
||||
*/
|
||||
virtual void setUsage(UInt32 usage ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function setControlID
|
||||
* @abstract Sets the controlID for this control.
|
||||
* @discussion The control ID is an optional attribute that can be used to track IOAudioControls. A typical
|
||||
* use is for the IOAudioDevice to assign a unique controlID to each control that it creates and then
|
||||
* do a switch statement on the id of the control when it gets an audioControlValueChanged() notification.
|
||||
* Typically the control ID is set when the object is created and doesn't need to be called again.
|
||||
* @param cntrlID The control ID for the control.
|
||||
*/
|
||||
virtual void setControlID(UInt32 cntrlID ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function validateValue
|
||||
* @abstract Called by setValue() to verify that the value is valid.
|
||||
* @param newValue The new value to be verified.
|
||||
* @result Returns kIOReturnSuccess if the value is valid.
|
||||
*/
|
||||
virtual IOReturn validateValue(OSObject *newValue ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function updateValue
|
||||
* @abstract Called by setValue() in order to update the value and the registry.
|
||||
* @discussion It also calls
|
||||
* sendValueChangedNotification() to send notifications to the user clients.
|
||||
* @param newValue The new value to b updated.
|
||||
* @result Returns kIOReturnSuccess if the value is successfully updated.
|
||||
*/
|
||||
virtual IOReturn updateValue(OSObject *newValue ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
virtual IOReturn _setValue(OSObject *newValue ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function performValueChange
|
||||
* @abstract Called by setValue() to make the call to the valueChangeHandler
|
||||
* to update the hardware.
|
||||
* @result Returns the result of the handler call (or kIOReturnError on an error).
|
||||
*/
|
||||
virtual IOReturn performValueChange(OSObject *newValue ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function addUserClientAction
|
||||
* @abstract IOCommandGate Action which calls addUserClient() while holding the IOCommandGate.
|
||||
* @discussion This is needed to allow addUserClient() to be called on the IOWorkLoop.
|
||||
* @param owner The owner of the IOCommandGate (the IOAudioControl in this case).
|
||||
* @param arg1 The IOAudioControlUserClient to be added.
|
||||
* @result Returns the result of addUserClient() - kIOReturnSuccess on success.
|
||||
*/
|
||||
static IOReturn addUserClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4 ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
static IOReturn _addUserClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3 ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10; // <rdar://7529580>
|
||||
|
||||
/*!
|
||||
* @function removeUserClientAction
|
||||
* @abstract IOCommandGate Action which calls removeUserClient() while holding the IOCommandGate.
|
||||
* @discussion This is needed to allow removeUserClient() to be called on the IOWorkLoop.
|
||||
* @param owner The owner of the IOCommandGate (the IOAudioControl in this case).
|
||||
* @param arg1 The IOAudioControlUserClient to be removed.
|
||||
* @result Returns the result of removeUserClient() - kIOReturnSuccess on success.
|
||||
*/
|
||||
static IOReturn removeUserClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4 ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
static IOReturn _removeUserClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3 ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10; // <rdar://7529580>
|
||||
|
||||
/*!
|
||||
* @function detachUserClientsAction
|
||||
*/
|
||||
static IOReturn detachUserClientsAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4 ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function addUserClient
|
||||
* @abstract Called on the IOWorkLoop to add a new IOAudioControlUserClient.
|
||||
* @discussion There is no need to call this directly. It is called on the workLoop
|
||||
* by newUserClient() through addUserClientAction().
|
||||
* @param newUserClient The IOAudioControlUserClientto be added.
|
||||
* @result Returns kIOReturnSuccess on success.
|
||||
*/
|
||||
virtual IOReturn addUserClient(IOAudioControlUserClient *newUserClient ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
/*!
|
||||
* @function removeUserClient
|
||||
* @abstract Called on the IOWorkLoop to remove an IOAudioControlUserClient.
|
||||
* @discussion This is called on the IOWorkLoop by clientClosed() through
|
||||
* removeUserClientAction() when the user client is going away. It should
|
||||
* not be called directly.
|
||||
* @param userClient The IOAudioControlUserClient to be removed.
|
||||
* @result Returns kIOReturnSuccess on success.
|
||||
*/
|
||||
virtual IOReturn removeUserClient(IOAudioControlUserClient *userClient ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
virtual IOReturn detachUserClients( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
static void setCommandGateUsage(IOAudioControl *control, bool increment ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10; // <rdar://8518215>
|
||||
|
||||
};
|
||||
|
||||
#endif /* _IOKIT_IOAUDIOCONTROL_H */
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2014 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOKIT_IOAUDIOCONTROLUSERCLIENT_H
|
||||
#define _IOKIT_IOAUDIOCONTROLUSERCLIENT_H
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <IOKit/IOUserClient.h>
|
||||
|
||||
#ifndef IOAUDIOFAMILY_SELF_BUILD
|
||||
#include <IOKit/audio/IOAudioTypes.h>
|
||||
#else
|
||||
#include "IOAudioTypes.h"
|
||||
#endif
|
||||
|
||||
class IOAudioControl;
|
||||
|
||||
class IOAudioControlUserClient : public IOUserClient
|
||||
{
|
||||
OSDeclareDefaultStructors(IOAudioControlUserClient)
|
||||
|
||||
protected:
|
||||
task_t clientTask;
|
||||
IOAudioControl * audioControl;
|
||||
IOAudioNotificationMessage * notificationMessage;
|
||||
|
||||
virtual IOReturn clientClose( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
virtual IOReturn clientDied( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
protected:
|
||||
struct ExpansionData { };
|
||||
|
||||
ExpansionData *reserved;
|
||||
|
||||
public:
|
||||
virtual void sendChangeNotification(UInt32 notificationType ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
// OSMetaClassDeclareReservedUsed(IOAudioControlUserClient, 1);
|
||||
virtual bool initWithAudioControl(IOAudioControl *control, task_t owningTask, void *securityID, UInt32 type, OSDictionary *properties ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
private:
|
||||
OSMetaClassDeclareReservedUsed(IOAudioControlUserClient, 0);
|
||||
OSMetaClassDeclareReservedUsed(IOAudioControlUserClient, 1);
|
||||
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 2);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 3);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 4);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 5);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 6);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 7);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 8);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 9);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 10);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 11);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 12);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 13);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 14);
|
||||
OSMetaClassDeclareReservedUnused(IOAudioControlUserClient, 15);
|
||||
|
||||
public:
|
||||
static IOAudioControlUserClient *withAudioControl(IOAudioControl *control, task_t clientTask, void *securityID, UInt32 type ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
static IOAudioControlUserClient *withAudioControl(IOAudioControl *control, task_t clientTask, void *securityID, UInt32 type, OSDictionary *properties ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
virtual bool initWithAudioControl(IOAudioControl *control, task_t owningTask, void *securityID, UInt32 type ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
virtual void free( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
virtual IOReturn registerNotificationPort(mach_port_t port, UInt32 type, UInt32 refCon ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
|
||||
virtual void sendValueChangeNotification( ) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10;
|
||||
};
|
||||
|
||||
#endif /* _IOKIT_IOAUDIOCONTROLUSERCLIENT_H */
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2014 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef _IOAUDIODEBUG_H
|
||||
#define _IOAUDIODEBUG_H
|
||||
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include <sys/kdebug.h>
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEBUG_LEVEL 4 //<rdar://problem/9725460>
|
||||
//#define DEBUG_USE_FIRELOG 1
|
||||
#define DEBUG_USE_FIREWIRE_KPRINTF 1
|
||||
|
||||
#ifdef DEBUG_USE_FIRELOG
|
||||
#include <IOKit/firewire/FireLog.h>
|
||||
#define audioDebugIOLog( level, message... ) \
|
||||
do {FireLog( message ); FireLog("\n");} while (0)
|
||||
#define audioErrorIOLog( message... ) \
|
||||
do { FireLog( message ); FireLog("\n"); IOLog( message );} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_USE_IOUSBLOG
|
||||
#include <IOKit/usb/IOUSBLog.h>
|
||||
#define audioDebugIOLog( level, message... ) \
|
||||
do {USBLog( level, message );} while (0)
|
||||
#define audioErrorIOLog( level, message... ) \
|
||||
do { USBLog( DEBUG_LEVEL_BETA, message ); IOLog( message );} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_USE_FIREWIRE_KPRINTF
|
||||
#define audioDebugIOLog( level, message... ) \
|
||||
do { if (level <= DEBUG_LEVEL) kprintf( message );} while (0)
|
||||
#define audioErrorIOLog( message... ) \
|
||||
do { kprintf( message ); IOLog( message );} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef assert
|
||||
#undef assert
|
||||
|
||||
#define AssertionMessage( cond, file, line ) \
|
||||
"assert \"" #cond "\" failed in " #file " at line " #line
|
||||
|
||||
#define AssertionFailed( cond, file, line ) \
|
||||
panic(AssertionMessage( cond, file, line ));
|
||||
|
||||
#define assert( cond ) \
|
||||
if( !(cond) ) { \
|
||||
AssertionFailed( cond, __FILE__, __LINE__ ) \
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#define DEBUG_LEVEL 3
|
||||
|
||||
#include <os/log.h>
|
||||
#define audioDebugIOLog( level, message... ) \
|
||||
do { if ( __builtin_expect(level <= DEBUG_LEVEL, 0) ) { os_log( OS_LOG_DEFAULT, message ); } } while (0)
|
||||
|
||||
#define audioErrorIOLog( message... ) \
|
||||
do { os_log_error( OS_LOG_DEFAULT, message ); IOLog( message );} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _IOAUDIODEBUG_H */
|
||||
Loaded 100 of 405 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user