diff --git a/Headers/Availability.h b/Headers/Availability.h index 7600ebf..d096b76 100644 --- a/Headers/Availability.h +++ b/Headers/Availability.h @@ -166,10 +166,19 @@ #define __API_TO_BE_DEPRECATED_DRIVERKIT 100000 #endif -#ifndef __API_TO_BE_DEPRECATED_XROS -#define __API_TO_BE_DEPRECATED_XROS 100000 +#ifndef __API_TO_BE_DEPRECATED_VISIONOS +#define __API_TO_BE_DEPRECATED_VISIONOS 100000 #endif +#ifndef __API_TO_BE_DEPRECATED_EXCLAVEKIT + +#endif + + + +#ifndef __OPEN_SOURCE__ + +#endif /* __OPEN_SOURCE__ */ #include #include @@ -379,9 +388,6 @@ #define __WATCHOS_DEPRECATED(_start, _dep, _msg) #endif - - - /* for use marking APIs unavailable for swift */ #if defined(__has_feature) #if __has_feature(attribute_availability_swift) @@ -429,9 +435,9 @@ * __API_AVAILABLE(macos(10.4), ios(8.0), watchos(2.0), tvos(10.0)) * __API_AVAILABLE(driverkit(19.0)) */ - #define __API_AVAILABLE(...) __API_AVAILABLE_GET_MACRO(__VA_ARGS__,__API_AVAILABLE7,__API_AVAILABLE6,__API_AVAILABLE5,__API_AVAILABLE4,__API_AVAILABLE3,__API_AVAILABLE2,__API_AVAILABLE1,__API_AVAILABLE0,0)(__VA_ARGS__) + #define __API_AVAILABLE(...) __API_AVAILABLE_GET_MACRO(__VA_ARGS__,__API_AVAILABLE8,__API_AVAILABLE7,__API_AVAILABLE6,__API_AVAILABLE5,__API_AVAILABLE4,__API_AVAILABLE3,__API_AVAILABLE2,__API_AVAILABLE1,__API_AVAILABLE0,0)(__VA_ARGS__) - #define __API_AVAILABLE_BEGIN(...) _Pragma("clang attribute push") __API_AVAILABLE_BEGIN_GET_MACRO(__VA_ARGS__,__API_AVAILABLE_BEGIN7,__API_AVAILABLE_BEGIN6,__API_AVAILABLE_BEGIN5,__API_AVAILABLE_BEGIN4,__API_AVAILABLE_BEGIN3,__API_AVAILABLE_BEGIN2,__API_AVAILABLE_BEGIN1,__API_AVAILABLE_BEGIN0,0)(__VA_ARGS__) + #define __API_AVAILABLE_BEGIN(...) _Pragma("clang attribute push") __API_AVAILABLE_BEGIN_GET_MACRO(__VA_ARGS__,__API_AVAILABLE_BEGIN8,__API_AVAILABLE_BEGIN7,__API_AVAILABLE_BEGIN6,__API_AVAILABLE_BEGIN5,__API_AVAILABLE_BEGIN4,__API_AVAILABLE_BEGIN3,__API_AVAILABLE_BEGIN2,__API_AVAILABLE_BEGIN1,__API_AVAILABLE_BEGIN0,0)(__VA_ARGS__) #define __API_AVAILABLE_END _Pragma("clang attribute pop") /* @@ -450,13 +456,13 @@ * __API_DEPRECATED_WITH_REPLACEMENT("-setName:", tvos(10.0, 10.4), ios(9.0, 10.0)) * __API_DEPRECATED_WITH_REPLACEMENT("SomeClassName", macos(10.4, 10.6), watchos(2.0, 3.0)) */ - #define __API_DEPRECATED(...) __API_DEPRECATED_MSG_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_MSG7,__API_DEPRECATED_MSG6,__API_DEPRECATED_MSG5,__API_DEPRECATED_MSG4,__API_DEPRECATED_MSG3,__API_DEPRECATED_MSG2,__API_DEPRECATED_MSG1,__API_DEPRECATED_MSG0,0,0)(__VA_ARGS__) - #define __API_DEPRECATED_WITH_REPLACEMENT(...) __API_DEPRECATED_REP_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_REP7,__API_DEPRECATED_REP6,__API_DEPRECATED_REP5,__API_DEPRECATED_REP4,__API_DEPRECATED_REP3,__API_DEPRECATED_REP2,__API_DEPRECATED_REP1,__API_DEPRECATED_REP0,0,0)(__VA_ARGS__) + #define __API_DEPRECATED(...) __API_DEPRECATED_MSG_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_MSG8,__API_DEPRECATED_MSG7,__API_DEPRECATED_MSG6,__API_DEPRECATED_MSG5,__API_DEPRECATED_MSG4,__API_DEPRECATED_MSG3,__API_DEPRECATED_MSG2,__API_DEPRECATED_MSG1,__API_DEPRECATED_MSG0,0,0)(__VA_ARGS__) + #define __API_DEPRECATED_WITH_REPLACEMENT(...) __API_DEPRECATED_REP_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_REP8,__API_DEPRECATED_REP7,__API_DEPRECATED_REP6,__API_DEPRECATED_REP5,__API_DEPRECATED_REP4,__API_DEPRECATED_REP3,__API_DEPRECATED_REP2,__API_DEPRECATED_REP1,__API_DEPRECATED_REP0,0,0)(__VA_ARGS__) - #define __API_DEPRECATED_BEGIN(...) _Pragma("clang attribute push") __API_DEPRECATED_BEGIN_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_BEGIN7,__API_DEPRECATED_BEGIN6,__API_DEPRECATED_BEGIN5,__API_DEPRECATED_BEGIN4,__API_DEPRECATED_BEGIN3,__API_DEPRECATED_BEGIN2,__API_DEPRECATED_BEGIN1,__API_DEPRECATED_BEGIN0,0,0)(__VA_ARGS__) + #define __API_DEPRECATED_BEGIN(...) _Pragma("clang attribute push") __API_DEPRECATED_BEGIN_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_BEGIN8,__API_DEPRECATED_BEGIN7,__API_DEPRECATED_BEGIN6,__API_DEPRECATED_BEGIN5,__API_DEPRECATED_BEGIN4,__API_DEPRECATED_BEGIN3,__API_DEPRECATED_BEGIN2,__API_DEPRECATED_BEGIN1,__API_DEPRECATED_BEGIN0,0,0)(__VA_ARGS__) #define __API_DEPRECATED_END _Pragma("clang attribute pop") - #define __API_DEPRECATED_WITH_REPLACEMENT_BEGIN(...) _Pragma("clang attribute push") __API_DEPRECATED_WITH_REPLACEMENT_BEGIN_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN7,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN6,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN5,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN4,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN3,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN2,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN1,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN0,0,0)(__VA_ARGS__) + #define __API_DEPRECATED_WITH_REPLACEMENT_BEGIN(...) _Pragma("clang attribute push") __API_DEPRECATED_WITH_REPLACEMENT_BEGIN_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN8,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN7,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN6,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN5,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN4,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN3,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN2,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN1,__API_DEPRECATED_WITH_REPLACEMENT_BEGIN0,0,0)(__VA_ARGS__) #define __API_DEPRECATED_WITH_REPLACEMENT_END _Pragma("clang attribute pop") /* @@ -467,9 +473,9 @@ * __API_UNAVAILABLE(macos) * __API_UNAVAILABLE(watchos, tvos) */ - #define __API_UNAVAILABLE(...) __API_UNAVAILABLE_GET_MACRO(__VA_ARGS__,__API_UNAVAILABLE7,__API_UNAVAILABLE6,__API_UNAVAILABLE5,__API_UNAVAILABLE4,__API_UNAVAILABLE3,__API_UNAVAILABLE2,__API_UNAVAILABLE1,__API_UNAVAILABLE0,0)(__VA_ARGS__) + #define __API_UNAVAILABLE(...) __API_UNAVAILABLE_GET_MACRO(__VA_ARGS__,__API_UNAVAILABLE8,__API_UNAVAILABLE7,__API_UNAVAILABLE6,__API_UNAVAILABLE5,__API_UNAVAILABLE4,__API_UNAVAILABLE3,__API_UNAVAILABLE2,__API_UNAVAILABLE1,__API_UNAVAILABLE0,0)(__VA_ARGS__) - #define __API_UNAVAILABLE_BEGIN(...) _Pragma("clang attribute push") __API_UNAVAILABLE_BEGIN_GET_MACRO(__VA_ARGS__,__API_UNAVAILABLE_BEGIN7,__API_UNAVAILABLE_BEGIN6,__API_UNAVAILABLE_BEGIN5,__API_UNAVAILABLE_BEGIN4,__API_UNAVAILABLE_BEGIN3,__API_UNAVAILABLE_BEGIN2,__API_UNAVAILABLE_BEGIN1,__API_UNAVAILABLE_BEGIN0,0)(__VA_ARGS__) + #define __API_UNAVAILABLE_BEGIN(...) _Pragma("clang attribute push") __API_UNAVAILABLE_BEGIN_GET_MACRO(__VA_ARGS__,__API_UNAVAILABLE_BEGIN8,__API_UNAVAILABLE_BEGIN7,__API_UNAVAILABLE_BEGIN6,__API_UNAVAILABLE_BEGIN5,__API_UNAVAILABLE_BEGIN4,__API_UNAVAILABLE_BEGIN3,__API_UNAVAILABLE_BEGIN2,__API_UNAVAILABLE_BEGIN1,__API_UNAVAILABLE_BEGIN0,0)(__VA_ARGS__) #define __API_UNAVAILABLE_END _Pragma("clang attribute pop") #endif /* __has_attribute(availability) */ #endif /* #if defined(__has_feature) && defined(__has_attribute) */ @@ -534,6 +540,14 @@ #define __SPI_AVAILABLE(...) #endif +#ifndef __SPI_AVAILABLE_BEGIN + #define __SPI_AVAILABLE_BEGIN(...) +#endif + +#ifndef __SPI_AVAILABLE_END + #define __SPI_AVAILABLE_END(...) +#endif + #ifndef __SPI_DEPRECATED #define __SPI_DEPRECATED(...) #endif diff --git a/Headers/AvailabilityInternal.h b/Headers/AvailabilityInternal.h index 607f185..88f425c 100644 --- a/Headers/AvailabilityInternal.h +++ b/Headers/AvailabilityInternal.h @@ -35,21 +35,26 @@ #endif #ifndef __MAC_OS_X_VERSION_MIN_REQUIRED - #ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - /* compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ */ + #if defined(__has_builtin) && __has_builtin(__is_target_os) + #if __is_target_os(macos) + #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ + #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_14_5 + #endif + #elif __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - #endif -#endif /* __MAC_OS_X_VERSION_MIN_REQUIRED*/ + #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_14_5 + #endif /* __has_builtin(__is_target_os) && __is_target_os(macos) */ +#endif /* __MAC_OS_X_VERSION_MIN_REQUIRED */ #ifndef __IPHONE_OS_VERSION_MIN_REQUIRED #if defined(__has_builtin) && __has_builtin(__is_target_os) #if __is_target_os(ios) #define __IPHONE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ - #define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_17_0 + #define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_17_5 #endif #elif __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ #define __IPHONE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ - #define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_17_0 + #define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_17_5 #endif /* __has_builtin(__is_target_os) && __is_target_os(ios) */ #endif /* __IPHONE_OS_VERSION_MIN_REQUIRED */ @@ -57,13 +62,13 @@ #if defined(__has_builtin) && __has_builtin(__is_target_os) #if __is_target_os(watchos) #define __WATCH_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ - #define __WATCH_OS_VERSION_MAX_ALLOWED __WATCHOS_10_0 + #define __WATCH_OS_VERSION_MAX_ALLOWED __WATCHOS_10_5 /* for compatibility with existing code. New code should use platform specific checks */ #define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_9_0 #endif #elif __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ #define __WATCH_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ - #define __WATCH_OS_VERSION_MAX_ALLOWED __WATCHOS_10_0 + #define __WATCH_OS_VERSION_MAX_ALLOWED __WATCHOS_10_5 /* for compatibility with existing code. New code should use platform specific checks */ #define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_9_0 #endif /* __has_builtin(__is_target_os) && __is_target_os(watchos) */ @@ -73,13 +78,13 @@ #if defined(__has_builtin) && __has_builtin(__is_target_os) #if __is_target_os(tvos) #define __TV_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ - #define __TV_OS_VERSION_MAX_ALLOWED __TVOS_17_0 + #define __TV_OS_VERSION_MAX_ALLOWED __TVOS_17_5 /* for compatibility with existing code. New code should use platform specific checks */ #define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_9_0 #endif #elif __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ #define __TV_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ - #define __TV_OS_VERSION_MAX_ALLOWED __TVOS_17_0 + #define __TV_OS_VERSION_MAX_ALLOWED __TVOS_17_5 /* for compatibility with existing code. New code should use platform specific checks */ #define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_9_0 #endif /* __has_builtin(__is_target_os) && __is_target_os(tvos) */ @@ -89,7 +94,7 @@ #if defined(__has_builtin) && __has_builtin(__is_target_os) #if __is_target_os(bridgeos) #define __BRIDGE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ - #define __BRIDGE_OS_VERSION_MAX_ALLOWED __BRIDGEOS_8_0 + #define __BRIDGE_OS_VERSION_MAX_ALLOWED __BRIDGEOS_8_5 /* for compatibility with existing code. New code should use platform specific checks */ #define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_11_0 #endif @@ -100,22 +105,45 @@ #if defined(__has_builtin) && __has_builtin(__is_target_os) #if __is_target_os(driverkit) #define __DRIVERKIT_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ - #define __DRIVERKIT_VERSION_MAX_ALLOWED __DRIVERKIT_23_0 + #define __DRIVERKIT_VERSION_MAX_ALLOWED __DRIVERKIT_23_5 #endif #endif /* __has_builtin(__is_target_os) && __is_target_os(driverkit) */ #endif /* __DRIVERKIT_VERSION_MIN_REQUIRED */ -#ifndef __XR_OS_VERSION_MIN_REQUIRED +#ifndef __VISION_OS_VERSION_MIN_REQUIRED + #if defined(__has_builtin) && __has_builtin(__is_target_os) + #if __is_target_os(visionos) + #define __VISION_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ + #define __VISION_OS_VERSION_MAX_ALLOWED __VISIONOS_1_2 + /* for compatibility with existing code. New code should use platform specific checks */ + #define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_17_1 + #endif + #endif /* __has_builtin(__is_target_os) && __is_target_os(visionos) */ +#endif /* __VISION_OS_VERSION_MIN_REQUIRED */ + + +//FIXME: Workaround for rdar://116062344 +#ifndef __VISION_OS_VERSION_MIN_REQUIRED #if defined(__has_builtin) && __has_builtin(__is_target_os) #if __is_target_os(xros) - #define __XR_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ - #define __XR_OS_VERSION_MAX_ALLOWED __XROS_1_0 + #define __VISION_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ + // Hardcoded these since until compiler fix for rdar://116062344 will land + #if defined(__VISIONOS_2_0) + #define __VISION_OS_VERSION_MAX_ALLOWED __VISIONOS_2_0 + #elif defined(__VISIONOS_1_1) + #define __VISION_OS_VERSION_MAX_ALLOWED __VISIONOS_1_1 + #elif defined(__VISIONOS_1_0) + #define __VISION_OS_VERSION_MAX_ALLOWED __VISIONOS_1_0 + #endif /* for compatibility with existing code. New code should use platform specific checks */ - #define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_17_0 + #define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_17_1 #endif - #endif /* __has_builtin(__is_target_os) && __is_target_os(xros) */ -#endif /* __XR_OS_VERSION_MIN_REQUIRED */ + #endif /* __has_builtin(__is_target_os) && __is_target_os(visionos) */ +#endif /* __VISION_OS_VERSION_MIN_REQUIRED */ +#ifndef __OPEN_SOURCE__ + +#endif /* __OPEN_SOURCE__ */ #ifdef __IPHONE_OS_VERSION_MIN_REQUIRED /* make sure a default max version is set */ @@ -150,35 +178,39 @@ #if defined(__has_feature) && defined(__has_attribute) #if __has_attribute(availability) #define __API_AVAILABLE_PLATFORM_macos(x) macos,introduced=x - #define __API_UNAVAILABLE_PLATFORM_macos macos,unavailable #define __API_DEPRECATED_PLATFORM_macos(x,y) macos,introduced=x,deprecated=y + #define __API_UNAVAILABLE_PLATFORM_macos macos,unavailable #define __API_AVAILABLE_PLATFORM_macosx(x) macos,introduced=x - #define __API_UNAVAILABLE_PLATFORM_macosx macos,unavailable #define __API_DEPRECATED_PLATFORM_macosx(x,y) macos,introduced=x,deprecated=y + #define __API_UNAVAILABLE_PLATFORM_macosx macos,unavailable #define __API_AVAILABLE_PLATFORM_ios(x) ios,introduced=x - #define __API_UNAVAILABLE_PLATFORM_ios ios,unavailable #define __API_DEPRECATED_PLATFORM_ios(x,y) ios,introduced=x,deprecated=y + #define __API_UNAVAILABLE_PLATFORM_ios ios,unavailable #define __API_AVAILABLE_PLATFORM_macCatalyst(x) macCatalyst,introduced=x - #define __API_UNAVAILABLE_PLATFORM_macCatalyst macCatalyst,unavailable #define __API_DEPRECATED_PLATFORM_macCatalyst(x,y) macCatalyst,introduced=x,deprecated=y - #define __API_AVAILABLE_PLATFORM_macCatalyst(x) macCatalyst,introduced=x #define __API_UNAVAILABLE_PLATFORM_macCatalyst macCatalyst,unavailable + #define __API_AVAILABLE_PLATFORM_macCatalyst(x) macCatalyst,introduced=x #define __API_DEPRECATED_PLATFORM_macCatalyst(x,y) macCatalyst,introduced=x,deprecated=y + #define __API_UNAVAILABLE_PLATFORM_macCatalyst macCatalyst,unavailable #define __API_AVAILABLE_PLATFORM_watchos(x) watchos,introduced=x - #define __API_UNAVAILABLE_PLATFORM_watchos watchos,unavailable #define __API_DEPRECATED_PLATFORM_watchos(x,y) watchos,introduced=x,deprecated=y + #define __API_UNAVAILABLE_PLATFORM_watchos watchos,unavailable #define __API_AVAILABLE_PLATFORM_tvos(x) tvos,introduced=x - #define __API_UNAVAILABLE_PLATFORM_tvos tvos,unavailable #define __API_DEPRECATED_PLATFORM_tvos(x,y) tvos,introduced=x,deprecated=y + #define __API_UNAVAILABLE_PLATFORM_tvos tvos,unavailable #define __API_AVAILABLE_PLATFORM_driverkit(x) driverkit,introduced=x - #define __API_UNAVAILABLE_PLATFORM_driverkit driverkit,unavailable #define __API_DEPRECATED_PLATFORM_driverkit(x,y) driverkit,introduced=x,deprecated=y - #define __API_AVAILABLE_PLATFORM_xros(x) xros,introduced=x - #define __API_UNAVAILABLE_PLATFORM_xros xros,unavailable - #define __API_DEPRECATED_PLATFORM_xros(x,y) xros,introduced=x,deprecated=y + #define __API_UNAVAILABLE_PLATFORM_driverkit driverkit,unavailable + #define __API_AVAILABLE_PLATFORM_visionos(x) visionos,introduced=x + #define __API_DEPRECATED_PLATFORM_visionos(x,y) visionos,introduced=x,deprecated=y + #define __API_UNAVAILABLE_PLATFORM_visionos visionos,unavailable + #define __API_AVAILABLE_PLATFORM_xros(x) visionos,introduced=x + #define __API_DEPRECATED_PLATFORM_xros(x,y) visionos,introduced=x,deprecated=y + #define __API_UNAVAILABLE_PLATFORM_xros visionos,unavailable + #endif /* __has_attribute(availability) */ #endif /* defined(__has_feature) && defined(__has_attribute) */ @@ -210,7 +242,8 @@ #define __API_AVAILABLE5(arg0,arg1,arg2,arg3,arg4,arg5) __API_A(arg0) __API_A(arg1) __API_A(arg2) __API_A(arg3) __API_A(arg4) __API_A(arg5) #define __API_AVAILABLE6(arg0,arg1,arg2,arg3,arg4,arg5,arg6) __API_A(arg0) __API_A(arg1) __API_A(arg2) __API_A(arg3) __API_A(arg4) __API_A(arg5) __API_A(arg6) #define __API_AVAILABLE7(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7) __API_A(arg0) __API_A(arg1) __API_A(arg2) __API_A(arg3) __API_A(arg4) __API_A(arg5) __API_A(arg6) __API_A(arg7) - #define __API_AVAILABLE_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,NAME,...) NAME + #define __API_AVAILABLE8(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) __API_A(arg0) __API_A(arg1) __API_A(arg2) __API_A(arg3) __API_A(arg4) __API_A(arg5) __API_A(arg6) __API_A(arg7) __API_A(arg8) + #define __API_AVAILABLE_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME #define __API_A_BEGIN(x) _Pragma(__API_RANGE_STRINGIFY (clang attribute (__attribute__((availability(__API_AVAILABLE_PLATFORM_##x))), apply_to = __API_APPLY_TO))) @@ -222,7 +255,8 @@ #define __API_AVAILABLE_BEGIN5(arg0,arg1,arg2,arg3,arg4,arg5) __API_A_BEGIN(arg0) __API_A_BEGIN(arg1) __API_A_BEGIN(arg2) __API_A_BEGIN(arg3) __API_A_BEGIN(arg4) __API_A_BEGIN(arg5) #define __API_AVAILABLE_BEGIN6(arg0,arg1,arg2,arg3,arg4,arg5,arg6) __API_A_BEGIN(arg0) __API_A_BEGIN(arg1) __API_A_BEGIN(arg2) __API_A_BEGIN(arg3) __API_A_BEGIN(arg4) __API_A_BEGIN(arg5) __API_A_BEGIN(arg6) #define __API_AVAILABLE_BEGIN7(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7) __API_A_BEGIN(arg0) __API_A_BEGIN(arg1) __API_A_BEGIN(arg2) __API_A_BEGIN(arg3) __API_A_BEGIN(arg4) __API_A_BEGIN(arg5) __API_A_BEGIN(arg6) __API_A_BEGIN(arg7) - #define __API_AVAILABLE_BEGIN_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,NAME,...) NAME + #define __API_AVAILABLE_BEGIN8(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) __API_A_BEGIN(arg0) __API_A_BEGIN(arg1) __API_A_BEGIN(arg2) __API_A_BEGIN(arg3) __API_A_BEGIN(arg4) __API_A_BEGIN(arg5) __API_A_BEGIN(arg6) __API_A_BEGIN(arg7) __API_A_BEGIN(arg8) + #define __API_AVAILABLE_BEGIN_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME @@ -236,7 +270,8 @@ #define __API_DEPRECATED_MSG5(msg,arg0,arg1,arg2,arg3,arg4,arg5) __API_D(msg,arg0) __API_D(msg,arg1) __API_D(msg,arg2) __API_D(msg,arg3) __API_D(msg,arg4) __API_D(msg,arg5) #define __API_DEPRECATED_MSG6(msg,arg0,arg1,arg2,arg3,arg4,arg5,arg6) __API_D(msg,arg0) __API_D(msg,arg1) __API_D(msg,arg2) __API_D(msg,arg3) __API_D(msg,arg4) __API_D(msg,arg5) __API_D(msg,arg6) #define __API_DEPRECATED_MSG7(msg,arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7) __API_D(msg,arg0) __API_D(msg,arg1) __API_D(msg,arg2) __API_D(msg,arg3) __API_D(msg,arg4) __API_D(msg,arg5) __API_D(msg,arg6) __API_D(msg,arg7) - #define __API_DEPRECATED_MSG_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME + #define __API_DEPRECATED_MSG8(msg,arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) __API_D(msg,arg0) __API_D(msg,arg1) __API_D(msg,arg2) __API_D(msg,arg3) __API_D(msg,arg4) __API_D(msg,arg5) __API_D(msg,arg6) __API_D(msg,arg7) __API_D(msg,arg8) + #define __API_DEPRECATED_MSG_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,NAME,...) NAME #define __API_D_BEGIN(msg, x) _Pragma(__API_RANGE_STRINGIFY (clang attribute (__attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg))), apply_to = __API_APPLY_TO))) @@ -248,7 +283,8 @@ #define __API_DEPRECATED_BEGIN5(msg,arg0,arg1,arg2,arg3,arg4,arg5) __API_D_BEGIN(msg,arg0) __API_D_BEGIN(msg,arg1) __API_D_BEGIN(msg,arg2) __API_D_BEGIN(msg,arg3) __API_D_BEGIN(msg,arg4) __API_D_BEGIN(msg,arg5) #define __API_DEPRECATED_BEGIN6(msg,arg0,arg1,arg2,arg3,arg4,arg5,arg6) __API_D_BEGIN(msg,arg0) __API_D_BEGIN(msg,arg1) __API_D_BEGIN(msg,arg2) __API_D_BEGIN(msg,arg3) __API_D_BEGIN(msg,arg4) __API_D_BEGIN(msg,arg5) __API_D_BEGIN(msg,arg6) #define __API_DEPRECATED_BEGIN7(msg,arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7) __API_D_BEGIN(msg,arg0) __API_D_BEGIN(msg,arg1) __API_D_BEGIN(msg,arg2) __API_D_BEGIN(msg,arg3) __API_D_BEGIN(msg,arg4) __API_D_BEGIN(msg,arg5) __API_D_BEGIN(msg,arg6) __API_D_BEGIN(msg,arg7) - #define __API_DEPRECATED_BEGIN_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME + #define __API_DEPRECATED_BEGIN8(msg,arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) __API_D_BEGIN(msg,arg0) __API_D_BEGIN(msg,arg1) __API_D_BEGIN(msg,arg2) __API_D_BEGIN(msg,arg3) __API_D_BEGIN(msg,arg4) __API_D_BEGIN(msg,arg5) __API_D_BEGIN(msg,arg6) __API_D_BEGIN(msg,arg7) __API_D_BEGIN(msg,arg8) + #define __API_DEPRECATED_BEGIN_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,NAME,...) NAME #if __has_feature(attribute_availability_with_replacement) #define __API_R(rep,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,replacement=rep))) @@ -264,7 +300,8 @@ #define __API_DEPRECATED_REP5(msg,arg0,arg1,arg2,arg3,arg4,arg5) __API_R(msg,arg0) __API_R(msg,arg1) __API_R(msg,arg2) __API_R(msg,arg3) __API_R(msg,arg4) __API_R(msg,arg5) #define __API_DEPRECATED_REP6(msg,arg0,arg1,arg2,arg3,arg4,arg5,arg6) __API_R(msg,arg0) __API_R(msg,arg1) __API_R(msg,arg2) __API_R(msg,arg3) __API_R(msg,arg4) __API_R(msg,arg5) __API_R(msg,arg6) #define __API_DEPRECATED_REP7(msg,arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7) __API_R(msg,arg0) __API_R(msg,arg1) __API_R(msg,arg2) __API_R(msg,arg3) __API_R(msg,arg4) __API_R(msg,arg5) __API_R(msg,arg6) __API_R(msg,arg7) - #define __API_DEPRECATED_REP_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME + #define __API_DEPRECATED_REP8(msg,arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) __API_R(msg,arg0) __API_R(msg,arg1) __API_R(msg,arg2) __API_R(msg,arg3) __API_R(msg,arg4) __API_R(msg,arg5) __API_R(msg,arg6) __API_R(msg,arg7) __API_R(msg,arg8) + #define __API_DEPRECATED_REP_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,NAME,...) NAME #if __has_feature(attribute_availability_with_replacement) #define __API_R_BEGIN(rep,x) _Pragma(__API_RANGE_STRINGIFY (clang attribute (__attribute__((availability(__API_DEPRECATED_PLATFORM_##x,replacement=rep))), apply_to = __API_APPLY_TO))) @@ -280,7 +317,8 @@ #define __API_DEPRECATED_BEGIN_REP5(msg,arg0,arg1,arg2,arg3,arg4,arg5) __API_R_BEGIN(msg,arg0) __API_R_BEGIN(msg,arg1) __API_R_BEGIN(msg,arg2) __API_R_BEGIN(msg,arg3) __API_R_BEGIN(msg,arg4) __API_R_BEGIN(msg,arg5) #define __API_DEPRECATED_BEGIN_REP6(msg,arg0,arg1,arg2,arg3,arg4,arg5,arg6) __API_R_BEGIN(msg,arg0) __API_R_BEGIN(msg,arg1) __API_R_BEGIN(msg,arg2) __API_R_BEGIN(msg,arg3) __API_R_BEGIN(msg,arg4) __API_R_BEGIN(msg,arg5) __API_R_BEGIN(msg,arg6) #define __API_DEPRECATED_BEGIN_REP7(msg,arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7) __API_R_BEGIN(msg,arg0) __API_R_BEGIN(msg,arg1) __API_R_BEGIN(msg,arg2) __API_R_BEGIN(msg,arg3) __API_R_BEGIN(msg,arg4) __API_R_BEGIN(msg,arg5) __API_R_BEGIN(msg,arg6) __API_R_BEGIN(msg,arg7) - #define __API_DEPRECATED_BEGIN_REP_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME + #define __API_DEPRECATED_BEGIN_REP8(msg,arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) __API_R_BEGIN(msg,arg0) __API_R_BEGIN(msg,arg1) __API_R_BEGIN(msg,arg2) __API_R_BEGIN(msg,arg3) __API_R_BEGIN(msg,arg4) __API_R_BEGIN(msg,arg5) __API_R_BEGIN(msg,arg6) __API_R_BEGIN(msg,arg7) __API_R_BEGIN(msg,arg8) + #define __API_DEPRECATED_BEGIN_REP_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,NAME,...) NAME /* * API Unavailability @@ -301,7 +339,8 @@ #define __API_UNAVAILABLE5(arg0,arg1,arg2,arg3,arg4,arg5) __API_U(arg0) __API_U(arg1) __API_U(arg2) __API_U(arg3) __API_U(arg4) __API_U(arg5) #define __API_UNAVAILABLE6(arg0,arg1,arg2,arg3,arg4,arg5,arg6) __API_U(arg0) __API_U(arg1) __API_U(arg2) __API_U(arg3) __API_U(arg4) __API_U(arg5) __API_U(arg6) #define __API_UNAVAILABLE7(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7) __API_U(arg0) __API_U(arg1) __API_U(arg2) __API_U(arg3) __API_U(arg4) __API_U(arg5) __API_U(arg6) __API_U(arg7) - #define __API_UNAVAILABLE_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,NAME,...) NAME + #define __API_UNAVAILABLE8(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) __API_U(arg0) __API_U(arg1) __API_U(arg2) __API_U(arg3) __API_U(arg4) __API_U(arg5) __API_U(arg6) __API_U(arg7) __API_U(arg8) + #define __API_UNAVAILABLE_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME #define __API_U_BEGIN(x) _Pragma(__API_RANGE_STRINGIFY (clang attribute (__attribute__((availability(__API_UNAVAILABLE_PLATFORM_##x))), apply_to = __API_APPLY_TO))) @@ -313,7 +352,8 @@ #define __API_UNAVAILABLE_BEGIN5(arg0,arg1,arg2,arg3,arg4,arg5) __API_U_BEGIN(arg0) __API_U_BEGIN(arg1) __API_U_BEGIN(arg2) __API_U_BEGIN(arg3) __API_U_BEGIN(arg4) __API_U_BEGIN(arg5) #define __API_UNAVAILABLE_BEGIN6(arg0,arg1,arg2,arg3,arg4,arg5,arg6) __API_U_BEGIN(arg0) __API_U_BEGIN(arg1) __API_U_BEGIN(arg2) __API_U_BEGIN(arg3) __API_U_BEGIN(arg4) __API_U_BEGIN(arg5) __API_U_BEGIN(arg6) #define __API_UNAVAILABLE_BEGIN7(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7) __API_U_BEGIN(arg0) __API_U_BEGIN(arg1) __API_U_BEGIN(arg2) __API_U_BEGIN(arg3) __API_U_BEGIN(arg4) __API_U_BEGIN(arg5) __API_U_BEGIN(arg6) __API_U_BEGIN(arg7) - #define __API_UNAVAILABLE_BEGIN_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,NAME,...) NAME + #define __API_UNAVAILABLE_BEGIN8(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) __API_U_BEGIN(arg0) __API_U_BEGIN(arg1) __API_U_BEGIN(arg2) __API_U_BEGIN(arg3) __API_U_BEGIN(arg4) __API_U_BEGIN(arg5) __API_U_BEGIN(arg6) __API_U_BEGIN(arg7) __API_U_BEGIN(arg8) + #define __API_UNAVAILABLE_BEGIN_GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME #endif /* __has_attribute(availability) */ #endif /* #if defined(__has_feature) && defined(__has_attribute) */ @@ -346,4 +386,12 @@ #define __SPI_AVAILABLE(...) #endif +#ifndef __SPI_AVAILABLE_BEGIN + #define __SPI_AVAILABLE_BEGIN(...) +#endif + +#ifndef __SPI_AVAILABLE_END + #define __SPI_AVAILABLE_END(...) +#endif + #endif /* __AVAILABILITY_INTERNAL__ */ diff --git a/Headers/AvailabilityVersions.h b/Headers/AvailabilityVersions.h index 5a6d419..e759f24 100644 --- a/Headers/AvailabilityVersions.h +++ b/Headers/AvailabilityVersions.h @@ -70,13 +70,22 @@ #define __MAC_12_3 120300 #define __MAC_12_4 120400 #define __MAC_12_5 120500 +#define __MAC_12_6 120600 +#define __MAC_12_7 120700 #define __MAC_13_0 130000 #define __MAC_13_1 130100 #define __MAC_13_1 130100 #define __MAC_13_2 130200 #define __MAC_13_3 130300 #define __MAC_13_4 130400 +#define __MAC_13_5 130500 +#define __MAC_13_6 130600 #define __MAC_14_0 140000 +#define __MAC_14_1 140100 +#define __MAC_14_2 140200 +#define __MAC_14_3 140300 +#define __MAC_14_4 140400 +#define __MAC_14_5 140500 /* __MAC__NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */ #define __IPHONE_2_0 20000 @@ -143,13 +152,22 @@ #define __IPHONE_15_4 150400 #define __IPHONE_15_5 150500 #define __IPHONE_15_6 150600 +#define __IPHONE_15_7 150700 +#define __IPHONE_15_8 150800 #define __IPHONE_16_0 160000 #define __IPHONE_16_1 160100 #define __IPHONE_16_2 160200 #define __IPHONE_16_3 160300 #define __IPHONE_16_4 160400 #define __IPHONE_16_5 160500 +#define __IPHONE_16_6 160600 +#define __IPHONE_16_7 160700 #define __IPHONE_17_0 170000 +#define __IPHONE_17_1 170100 +#define __IPHONE_17_2 170200 +#define __IPHONE_17_3 170300 +#define __IPHONE_17_4 170400 +#define __IPHONE_17_5 170500 /* __IPHONE__NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */ #define __WATCHOS_1_0 10000 @@ -185,13 +203,20 @@ #define __WATCHOS_8_5 80500 #define __WATCHOS_8_6 80600 #define __WATCHOS_8_7 80700 +#define __WATCHOS_8_8 80800 #define __WATCHOS_9_0 90000 #define __WATCHOS_9_1 90100 #define __WATCHOS_9_2 90200 #define __WATCHOS_9_3 90300 #define __WATCHOS_9_4 90400 #define __WATCHOS_9_5 90500 +#define __WATCHOS_9_6 90600 #define __WATCHOS_10_0 100000 +#define __WATCHOS_10_1 100100 +#define __WATCHOS_10_2 100200 +#define __WATCHOS_10_3 100300 +#define __WATCHOS_10_4 100400 +#define __WATCHOS_10_5 100500 /* __WATCHOS__NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */ #define __TVOS_9_0 90000 @@ -235,7 +260,13 @@ #define __TVOS_16_3 160300 #define __TVOS_16_4 160400 #define __TVOS_16_5 160500 +#define __TVOS_16_6 160600 #define __TVOS_17_0 170000 +#define __TVOS_17_1 170100 +#define __TVOS_17_2 170200 +#define __TVOS_17_3 170300 +#define __TVOS_17_4 170400 +#define __TVOS_17_5 170500 /* __TVOS__NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */ #define __BRIDGEOS_2_0 20000 @@ -258,7 +289,13 @@ #define __BRIDGEOS_7_2 70200 #define __BRIDGEOS_7_3 70300 #define __BRIDGEOS_7_4 70400 +#define __BRIDGEOS_7_6 70600 #define __BRIDGEOS_8_0 80000 +#define __BRIDGEOS_8_1 80100 +#define __BRIDGEOS_8_2 80200 +#define __BRIDGEOS_8_3 80300 +#define __BRIDGEOS_8_4 80400 +#define __BRIDGEOS_8_5 80500 #define __DRIVERKIT_19_0 190000 @@ -267,13 +304,27 @@ #define __DRIVERKIT_22_0 220000 #define __DRIVERKIT_22_4 220400 #define __DRIVERKIT_22_5 220500 +#define __DRIVERKIT_22_6 220600 #define __DRIVERKIT_23_0 230000 +#define __DRIVERKIT_23_1 230100 +#define __DRIVERKIT_23_2 230200 +#define __DRIVERKIT_23_3 230300 +#define __DRIVERKIT_23_4 230400 +#define __DRIVERKIT_23_5 230500 /* __DRIVERKIT__NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */ -#define __XROS_1_0 10000 -/* __XROS__NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */ +#define __VISIONOS_1_0 10000 +#define __VISIONOS_1_1 10100 +#define __VISIONOS_1_2 10200 +/* __VISIONOS__NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */ + + +#ifndef __OPEN_SOURCE__ + +#endif /* __OPEN_SOURCE__ */ + /* * Set up standard Mac OS X versions */ @@ -326,13 +377,22 @@ #define MAC_OS_VERSION_12_3 __MAC_12_3 #define MAC_OS_VERSION_12_4 __MAC_12_4 #define MAC_OS_VERSION_12_5 __MAC_12_5 +#define MAC_OS_VERSION_12_6 __MAC_12_6 +#define MAC_OS_VERSION_12_7 __MAC_12_7 #define MAC_OS_VERSION_13_0 __MAC_13_0 #define MAC_OS_VERSION_13_1 __MAC_13_1 #define MAC_OS_VERSION_13_1 __MAC_13_1 #define MAC_OS_VERSION_13_2 __MAC_13_2 #define MAC_OS_VERSION_13_3 __MAC_13_3 #define MAC_OS_VERSION_13_4 __MAC_13_4 +#define MAC_OS_VERSION_13_5 __MAC_13_5 +#define MAC_OS_VERSION_13_6 __MAC_13_6 #define MAC_OS_VERSION_14_0 __MAC_14_0 +#define MAC_OS_VERSION_14_1 __MAC_14_1 +#define MAC_OS_VERSION_14_2 __MAC_14_2 +#define MAC_OS_VERSION_14_3 __MAC_14_3 +#define MAC_OS_VERSION_14_4 __MAC_14_4 +#define MAC_OS_VERSION_14_5 __MAC_14_5 #endif /* #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) */ diff --git a/Headers/IOKit/pci/IOPCIBridge.h b/Headers/IOKit/pci/IOPCIBridge.h index 6c186eb..b3da32a 100644 --- a/Headers/IOKit/pci/IOPCIBridge.h +++ b/Headers/IOKit/pci/IOPCIBridge.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1998-2021 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -44,6 +44,13 @@ class IOPCIConfigurator; class IOPCIDevice; class IOPCIMessagedInterruptController; +class IOPCIHostBridgeData; + +enum +{ + kCheckLinkParents = 0x00000001, + kCheckLinkForPower = 0x00000002, +}; enum { kIOPCIResourceTypeMemory = 0, @@ -53,6 +60,64 @@ enum { kIOPCIResourceTypeCount = 4, }; +// Adapter hotplug states +enum { + kIOPCIAdapterPresent = 0, + // Summary: Adapter present, slot powered, power indicator on + // Transitions: + // -> kIOPCIAdapterHotRemovePending: Attn Button pressed + + kIOPCIAdapterHotAddPending = 1, + // Summary: Adapter present, slot not powered, power indicator blinking. 5s + // "abort interval" timer started. + // Transitions: + // -> kIOPCIAdapterPresent: 5s elapses. Power controller turned. + // -> kIOPCIAdapterNotPresent: Attention button pressed again before 5s + // elapses. Timer cancelled. + + kIOPCIAdapterNotPresent = 2, + // Summary: Adapter not present, slot not powered, power indicator off + // Transitions: + // -> kIOPCIAdapterHotAddPending: Attn Button pressed + + kIOPCIAdapterHotRemovePending = 3, + // Summary: Adapter present, slot powered, power indicator blinking. 5s + // "abort interval" timer started. + // Transitions: + // -> kIOPCIAdapterNotPresentPending: 5s elapses. nub terminated and + // power controller turned off. Another timer set for 1s. + // -> kIOPCIAdapterPresent: Attention button pressed again before 5s + // elapses. Timer cancelled. + + kIOPCIAdapterNotPresentPending = 4, + // Summary: Adapter not present, slot not powered, power indicator blinking. + // 1s timer started. + // + // In this state, software must 1 second before turning off the + // power indicator or attempting to turn on the power controller. + // (PCIe base spec sec 6.7.1.8 ("Power Controller")) + // Transitions: + // -> kIOPCIAdapterNotPresent: 1s timer elapses, turn off power + // indicator, allow hotplugs. + + kIOPCIAdapterUnused = 5, + // Summary: Adapter hotplug not supported. +}; + +typedef struct +{ + IOService * device; + uintptr_t op; + void * result; + void * arg; +} configOpParams; + +typedef struct +{ + IOService * provider; + uint8_t busNum; +} probeBusParams; + /*! @class IOPCIBridge @abstract Base class for all PCI bridge drivers. @@ -63,6 +128,8 @@ class IOPCIBridge : public IOService friend class IOPCIDevice; friend class IOPCI2PCIBridge; friend class IOPCIConfigurator; + friend class IOPCIEventSource; + friend class IOPCIHostBridge; OSDeclareAbstractStructors(IOPCIBridge) @@ -74,27 +141,26 @@ class IOPCIBridge : public IOService void removeDevice( IOPCIDevice * device, IOOptionBits options = 0 ); - void restoreQEnter(IOPCIDevice * device); + void restoreQEnter(IOPCIDevice * device); void restoreQRemove(IOPCIDevice * device); - IOReturn restoreTunnelState(IOPCIDevice * rootDevice, IOOptionBits options, + IOReturn restoreTunnelState(IOPCIDevice * rootDevice, IOOptionBits options, bool * didTunnelController); IOReturn restoreMachineState( IOOptionBits options, IOPCIDevice * device ); void tunnelsWait(IOPCIDevice * device); - static IOReturn finishMachineState(IOOptionBits options); - static IOReturn systemPowerChange(void * target, void * refCon, - UInt32 messageType, IOService * service, - void * messageArgument, vm_size_t argSize); IOReturn _restoreDeviceState( IOPCIDevice * device, IOOptionBits options ); IOReturn _restoreDeviceDependents(IOPCIDevice * device, IOOptionBits options, IOPCIDevice * forDependent); + + IOReturn resolveInterrupts(IOPCIDevice * nub ); IOReturn resolveLegacyInterrupts( IOService * provider, IOPCIDevice * nub ); - IOReturn resolveMSIInterrupts ( IOService * provider, IOPCIDevice * nub ); + IOReturn resolveMSIInterrupts ( IOService * provider, IOPCIDevice * nub, UInt32 numRequired = 0, UInt32 numRequested = 0 ); IOReturn relocate(IOPCIDevice * device, uint32_t options); - void spaceFromProperties( IORegistryEntry * regEntry, + void spaceFromProperties( IORegistryEntry * regEntry, IOPCIAddressSpace * space ); - void updateWakeReason(IOPCIDevice * device); + void updateWakeReason(IOPCIDevice * device); + bool childPrefersMSIX( IOPCIDevice * device ); protected: #if !defined(__arm64__) @@ -103,12 +169,22 @@ class IOPCIBridge : public IOService static SInt64 compareAddressCell( UInt32 cellCount, UInt32 cleft[], UInt32 cright[] ); #endif IOReturn setDeviceASPMBits(IOPCIDevice * device, uint32_t bits); + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_12_0 + IOReturn setDeviceASPML1Bit(IOPCIDevice * device, uint32_t bits); +#endif + IOReturn setDeviceL1PMBits(IOPCIDevice * device, uint32_t bits); IOReturn setDeviceCLKREQBits(IOPCIDevice * device, uint32_t bits); - IOReturn setDevicePowerState(IOPCIDevice * device, IOOptionBits options, - unsigned long prevState, unsigned long newState); + IOReturn setDevicePowerState(IOPCIDevice * device, IOOptionBits options, unsigned long prevState, unsigned long newState); + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_12_0 + IOReturn configOp(configOpParams *params); +#else static IOReturn configOp(IOService * device, uintptr_t op, void * result, void * arg = 0); +#endif + static void deferredProbe(IOPCIDevice * device); void * __reserved1; @@ -121,6 +197,11 @@ class IOPCIBridge : public IOService { struct IOPCIRange * rangeLists[kIOPCIResourceTypeCount]; IOPCIMessagedInterruptController *messagedInterruptController; + IOPCIHostBridgeData *hostBridgeData; + atomic_bool readyToProbe; + bool commandCompletedSupport; + bool commandSent; + bool childrenInReset; }; /*! @var reserved @@ -130,11 +211,10 @@ class IOPCIBridge : public IOService ExpansionData *reserved; protected: - IOWorkLoop * getConfiguratorWorkLoop(void) const; + IOWorkLoop * getConfiguratorWorkLoop(void) const; public: - static IOPCIEventSource * createEventSource( - OSObject * owner, IOPCIEventSource::Action action, uint32_t options); + static IOPCIEventSource * createEventSource(OSObject * owner, IOPCIEventSource::Action action, uint32_t options); public: virtual void probeBus( IOService * provider, UInt8 busNum ); @@ -183,28 +263,28 @@ class IOPCIBridge : public IOService virtual IOReturn getDTNubAddressing( IOPCIDevice * nub ); public: - virtual void free( void ) APPLE_KEXT_OVERRIDE; + virtual void free( void ); - virtual bool start( IOService * provider ) APPLE_KEXT_OVERRIDE; + virtual bool start( IOService * provider ); - virtual void stop( IOService * provider ) APPLE_KEXT_OVERRIDE; + virtual void stop( IOService * provider ); virtual bool configure( IOService * provider ); - virtual IOReturn setProperties(OSObject * properties) APPLE_KEXT_OVERRIDE; + virtual IOReturn setProperties(OSObject * properties); virtual IOReturn newUserClient(task_t owningTask, void * securityID, UInt32 type, OSDictionary * properties, - IOUserClient ** handler) APPLE_KEXT_OVERRIDE; + IOUserClient ** handler); - virtual unsigned long maxCapabilityForDomainState ( IOPMPowerFlags domainState ) APPLE_KEXT_OVERRIDE; - virtual unsigned long initialPowerStateForDomainState ( IOPMPowerFlags domainState ) APPLE_KEXT_OVERRIDE; - virtual unsigned long powerStateForDomainState ( IOPMPowerFlags domainState ) APPLE_KEXT_OVERRIDE; + virtual unsigned long maxCapabilityForDomainState ( IOPMPowerFlags domainState ); + virtual unsigned long initialPowerStateForDomainState ( IOPMPowerFlags domainState ); + virtual unsigned long powerStateForDomainState ( IOPMPowerFlags domainState ); virtual IOReturn callPlatformFunction(const OSSymbol * functionName, bool waitForFunction, void * param1, void * param2, - void * param3, void * param4) APPLE_KEXT_OVERRIDE; + void * param3, void * param4); /* * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -236,30 +316,30 @@ class IOPCIBridge : public IOService /* * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - virtual IOReturn createAGPSpace( IOAGPDevice * master, + virtual IOReturn createAGPSpace( IOAGPDevice * lead, IOOptionBits options, IOPhysicalAddress * address, IOPhysicalLength * length ); - virtual IOReturn destroyAGPSpace( IOAGPDevice * master ); + virtual IOReturn destroyAGPSpace( IOAGPDevice * lead ); - virtual IORangeAllocator * getAGPRangeAllocator( IOAGPDevice * master ); + virtual IORangeAllocator * getAGPRangeAllocator( IOAGPDevice * lead ); - virtual IOOptionBits getAGPStatus( IOAGPDevice * master, + virtual IOOptionBits getAGPStatus( IOAGPDevice * lead, IOOptionBits options = 0 ); - virtual IOReturn resetAGPDevice( IOAGPDevice * master, + virtual IOReturn resetAGPDevice( IOAGPDevice * lead, IOOptionBits options = 0 ); - virtual IOReturn getAGPSpace( IOAGPDevice * master, + virtual IOReturn getAGPSpace( IOAGPDevice * lead, IOPhysicalAddress * address, IOPhysicalLength * length ); - virtual IOReturn commitAGPMemory( IOAGPDevice * master, + virtual IOReturn commitAGPMemory( IOAGPDevice * lead, IOMemoryDescriptor * memory, IOByteCount agpOffset, IOOptionBits options ); - virtual IOReturn releaseAGPMemory( IOAGPDevice * master, + virtual IOReturn releaseAGPMemory( IOAGPDevice * lead, IOMemoryDescriptor * memory, IOByteCount agpOffset, IOOptionBits options ); @@ -296,7 +376,7 @@ class IOPCIBridge : public IOService #if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10 OSMetaClassDeclareReservedUsed(IOPCIBridge, 4); - virtual IOReturn enableLTR(IOPCIDevice * device, bool enable); + virtual IOReturn enableLTR(IOPCIDevice * device, bool enable); OSMetaClassDeclareReservedUsed(IOPCIBridge, 5); virtual IOPCIEventSource * createEventSource(IOPCIDevice * device, @@ -316,14 +396,43 @@ class IOPCIBridge : public IOService #else OSMetaClassDeclareReservedUnused(IOPCIBridge, 6); #endif - - // Unused Padding + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_0 +protected: + OSMetaClassDeclareReservedUsed(IOPCIBridge, 7); + virtual IOReturn setLinkSpeed(tIOPCILinkSpeed linkSpeed, bool retrain) = 0; + + OSMetaClassDeclareReservedUsed(IOPCIBridge, 8); + virtual IOReturn getLinkSpeed(tIOPCILinkSpeed *linkSpeed) = 0; + + bool isSupportedLinkSpeed(IOPCIDevice *device, tIOPCILinkSpeed linkSpeed); + void setTargetLinkSpeed(IOPCIDevice *device, tIOPCILinkSpeed linkSpeed); + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_4 + IOReturn linkRetrain(IOPCIDevice *device, bool waitForLinkUp); +#endif + + OSMetaClassDeclareReservedUsed(IOPCIBridge, 9); + virtual void warmResetDisable(void); + + OSMetaClassDeclareReservedUsed(IOPCIBridge, 10); + virtual void warmResetEnable(void); + + OSMetaClassDeclareReservedUsed(IOPCIBridge, 11); + virtual bool supportsWarmReset(void); + + OSMetaClassDeclareReservedUsed(IOPCIBridge, 12); + virtual IOReturn waitForLinkUp(IOPCIDevice *bridgeDevice); +#else OSMetaClassDeclareReservedUnused(IOPCIBridge, 7); OSMetaClassDeclareReservedUnused(IOPCIBridge, 8); OSMetaClassDeclareReservedUnused(IOPCIBridge, 9); OSMetaClassDeclareReservedUnused(IOPCIBridge, 10); OSMetaClassDeclareReservedUnused(IOPCIBridge, 11); OSMetaClassDeclareReservedUnused(IOPCIBridge, 12); +#endif + + // Unused Padding OSMetaClassDeclareReservedUnused(IOPCIBridge, 13); OSMetaClassDeclareReservedUnused(IOPCIBridge, 14); OSMetaClassDeclareReservedUnused(IOPCIBridge, 15); @@ -343,6 +452,70 @@ class IOPCIBridge : public IOService OSMetaClassDeclareReservedUnused(IOPCIBridge, 29); OSMetaClassDeclareReservedUnused(IOPCIBridge, 30); OSMetaClassDeclareReservedUnused(IOPCIBridge, 31); + +#if TARGET_CPU_ARM || TARGET_CPU_ARM64 +protected: + + virtual IOReturn deviceMemoryRead(IOMemoryDescriptor* sourceBase, + IOByteCount sourceOffset, + IOMemoryDescriptor* destinationBase, + IOByteCount destinationOffset, + IOByteCount size); + + virtual IOReturn deviceMemoryRead(IOMemoryDescriptor* sourceBase, + IOByteCount sourceOffset, + void* destination, + IOByteCount size); + +#endif + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_0 +private: + IOReturn terminateChild(IOPCIDevice *child); + IOReturn terminateChildGated(IOPCIDevice *child); + void hotReset(IOPCIDevice *bridgeDevice); + void warmReset(void); + IOReturn waitForResetComplete(void); + IOReturn resetDeviceGated(tIOPCIDeviceResetTypes *type, + tIOPCIDeviceResetOptions *options); + IOReturn waitForTerminateThreadCall(thread_call_t threadCall); + IOReturn waitForDeviceReady(IOPCIDevice *child); + +protected: + void slotControlWrite(IOPCIDevice *device, uint16_t data, uint16_t mask); + +public: + void setInReset(bool inReset); + +private: + void probeBusGated( probeBusParams *params ); + +public: + /*! @function resetDevice + * @abstract Reset the downstream PCIe device. + * @discussion If this is a multi-function device, all functions associated with the device will be reset. + * Device configuration state is saved prior to resetting the device and restored after reset completes. + * During reset, the caller must not attempt to access the device. + * This call will block until the link comes up and the device is usable (except for type kIOPCIDeviceResetTypeWarmResetDisable). + * @param type tIOPCIDeviceResetTypes. + * @param options tIOPCIDeviceResetOptions. + * @return kIOReturnSuccess if the reset specified is supported + */ + IOReturn resetDevice(tIOPCIDeviceResetTypes type, + tIOPCIDeviceResetOptions options = kIOPCIDeviceResetOptionNone); + +protected: + void updateLinkStatusProperty(uint16_t linkStatus); +#endif + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_4 + // findDeviceByXXX retains the returned IOPCIDevice object + IOPCIDevice *findDeviceByBDF(IOPCIAddressSpace space); + IOPCIDevice *findDeviceByMemAddress(IOPhysicalAddress address); +#endif + +private: + void waitForDartToQuiesce(IOPCIDevice *nub); }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -355,35 +528,42 @@ class IOPCI2PCIBridge : public IOPCIBridge OSDeclareDefaultStructors(IOPCI2PCIBridge) protected: - IOFilterInterruptEventSource * fBridgeInterruptSource; +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_11_0 + IOInterruptEventSource * fBridgeInterruptSource; +#else + IOFilterInterruptEventSource * fBridgeInterruptSource; +#endif private: IOPCIDevice * fBridgeDevice; - IOTimerEventSource * fTimerProbeES; - IOWorkLoop * fWorkLoop; - IOPMDriverAssertionID fPMAssertion; + IOTimerEventSource * fTimerProbeES; + IOTimerEventSource * fAttnButtonTimer; + IOTimerEventSource * fDLLSCEventTimer; + IOWorkLoop * fWorkLoop; + IOPMDriverAssertionID fPMAssertion; IOSimpleLock * fISRLock; struct IOPCIAERRoot * fAERRoot; - uint32_t __resvA[6]; - int32_t fTunnelL1EnableCount; - uint32_t fHotplugCount; + uint32_t __resvA[6]; + int32_t fTunnelL1EnableCount; + uint32_t fHotplugCount; - uint8_t _resvA[3]; + uint8_t _resvA[3]; uint8_t fHotPlugInts; - uint8_t fIntsPending; - uint8_t fIsAERRoot; - - uint8_t fPresence; - uint8_t fWaitingLinkEnable; - uint8_t fLinkChangeOnly; - uint8_t fBridgeInterruptEnablePending; - uint8_t fNeedProbe; - uint8_t fPresenceInt; - uint8_t fBridgeMSI; - uint8_t fNoDevice; - uint8_t fLinkControlWithPM; - uint8_t fPowerState; - char fLogName[32]; + uint8_t fIntsPending; + uint8_t fIsAERRoot; + + uint8_t fPresence; + uint8_t fWaitingLinkEnable; + uint8_t fLinkChangeOnly; + uint8_t fBridgeInterruptEnablePending; + uint8_t fNeedProbe; + uint8_t fPresenceInt; + uint8_t fBridgeMSI; + uint8_t fNoDevice; + uint8_t fLinkControlWithPM; + uint8_t fPowerState; + uint8_t fAdapterState; + char fLogName[32]; ; /*! @struct ExpansionData @@ -397,29 +577,29 @@ class IOPCI2PCIBridge : public IOPCIBridge public: - virtual UInt8 firstBusNum( void ) APPLE_KEXT_OVERRIDE; - virtual UInt8 lastBusNum( void ) APPLE_KEXT_OVERRIDE; + virtual UInt8 firstBusNum( void ) override; + virtual UInt8 lastBusNum( void ) override; public: - virtual void free() APPLE_KEXT_OVERRIDE; + virtual void free() override; - virtual bool serializeProperties( OSSerialize * serialize ) const APPLE_KEXT_OVERRIDE; + virtual bool serializeProperties( OSSerialize * serialize ) const override; virtual IOService * probe( IOService * provider, - SInt32 * score ) APPLE_KEXT_OVERRIDE; + SInt32 * score ) override; - virtual bool start( IOService * provider ) APPLE_KEXT_OVERRIDE; + virtual bool start( IOService * provider ) override; - virtual void stop( IOService * provider ) APPLE_KEXT_OVERRIDE; + virtual void stop( IOService * provider ) override; - virtual bool configure( IOService * provider ) APPLE_KEXT_OVERRIDE; + virtual bool configure( IOService * provider ) override; - virtual void probeBus( IOService * provider, UInt8 busNum ) APPLE_KEXT_OVERRIDE; + virtual void probeBus( IOService * provider, UInt8 busNum ) override; - virtual IOReturn requestProbe( IOOptionBits options ) APPLE_KEXT_OVERRIDE; + virtual IOReturn requestProbe( IOOptionBits options ) override; #if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_5 - virtual void systemWillShutdown(IOOptionBits specifier) APPLE_KEXT_OVERRIDE; + virtual void systemWillShutdown(IOOptionBits specifier) override; #endif virtual void saveBridgeState( void ); @@ -427,43 +607,61 @@ class IOPCI2PCIBridge : public IOPCIBridge virtual void restoreBridgeState( void ); IOReturn setPowerState( unsigned long powerState, - IOService * whatDevice ) APPLE_KEXT_OVERRIDE; + IOService * whatDevice ) override; - void adjustPowerState(unsigned long state); +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_14_4 + virtual IOReturn powerStateDidChangeTo (IOPMPowerFlags capabilities, + unsigned long stateNumber, + IOService* whatDevice) override; +#endif + + void adjustPowerState(unsigned long state); + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_0 + virtual IOReturn addPowerChild( IOService * theChild ) override; + + virtual IOReturn removePowerChild( IOPowerConnection * theChild ) override; +#endif virtual IOReturn saveDeviceState( IOPCIDevice * device, - IOOptionBits options = 0 ) APPLE_KEXT_OVERRIDE; + IOOptionBits options = 0 ) override; - virtual bool publishNub( IOPCIDevice * nub, UInt32 index ) APPLE_KEXT_OVERRIDE; + virtual bool publishNub( IOPCIDevice * nub, UInt32 index ) override; - virtual IODeviceMemory * ioDeviceMemory( void ) APPLE_KEXT_OVERRIDE; + virtual IODeviceMemory * ioDeviceMemory( void ) override; - virtual IOPCIAddressSpace getBridgeSpace( void ) APPLE_KEXT_OVERRIDE; + virtual IOPCIAddressSpace getBridgeSpace( void ) override; - virtual UInt32 configRead32( IOPCIAddressSpace space, UInt8 offset ) APPLE_KEXT_OVERRIDE; + virtual UInt32 configRead32( IOPCIAddressSpace space, UInt8 offset ) override; virtual void configWrite32( IOPCIAddressSpace space, - UInt8 offset, UInt32 data ) APPLE_KEXT_OVERRIDE; - virtual UInt16 configRead16( IOPCIAddressSpace space, UInt8 offset ) APPLE_KEXT_OVERRIDE; + UInt8 offset, UInt32 data ) override; + virtual UInt16 configRead16( IOPCIAddressSpace space, UInt8 offset ) override; virtual void configWrite16( IOPCIAddressSpace space, - UInt8 offset, UInt16 data ) APPLE_KEXT_OVERRIDE; - virtual UInt8 configRead8( IOPCIAddressSpace space, UInt8 offset ) APPLE_KEXT_OVERRIDE; + UInt8 offset, UInt16 data ) override; + virtual UInt8 configRead8( IOPCIAddressSpace space, UInt8 offset ) override; virtual void configWrite8( IOPCIAddressSpace space, - UInt8 offset, UInt8 data ) APPLE_KEXT_OVERRIDE; + UInt8 offset, UInt8 data ) override; #if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6 virtual IOReturn setDeviceASPMState(IOPCIDevice * device, - IOService * client, IOOptionBits state) APPLE_KEXT_OVERRIDE; + IOService * client, IOOptionBits state) override; #endif #if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_7 - virtual IOReturn checkLink(uint32_t options = 0) APPLE_KEXT_OVERRIDE; + virtual IOReturn checkLink(uint32_t options = 0) override; #endif #if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10 - virtual IOReturn enableLTR(IOPCIDevice * device, bool enable) APPLE_KEXT_OVERRIDE; + virtual IOReturn enableLTR(IOPCIDevice * device, bool enable) override; virtual IOPCIEventSource * createEventSource(IOPCIDevice * device, - OSObject * owner, IOPCIEventSource::Action action, uint32_t options) APPLE_KEXT_OVERRIDE; + OSObject * owner, IOPCIEventSource::Action action, uint32_t options) override; +#endif + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_0 + virtual IOReturn setLinkSpeed(tIOPCILinkSpeed linkSpeed, bool retrain) override; + + virtual IOReturn getLinkSpeed(tIOPCILinkSpeed *linkSpeed) override; #endif // Unused Padding @@ -479,24 +677,35 @@ class IOPCI2PCIBridge : public IOPCIBridge protected: void allocateBridgeInterrupts(IOService * provider); - void startBridgeInterrupts(IOService * provider); - void enableBridgeInterrupts(void); - void disableBridgeInterrupts(void); + void startBridgeInterrupts(IOService * provider); + void enableBridgeInterrupts(void); + void disableBridgeInterrupts(void); private: - IOReturn setTunnelL1Enable(IOPCIDevice * device, IOService * client, - bool l1Enable); + IOReturn setTunnelL1Enable(IOPCIDevice * device, IOService * client, bool l1Enable); public: - void startBootDefer(IOService * provider); + void startBootDefer(IOService * provider); +#if __MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_11_0 bool filterInterrupt( IOFilterInterruptEventSource * source); - +#endif + void handleInterrupt( IOInterruptEventSource * source, int count ); - void timerProbe(IOTimerEventSource * es); + void timerProbe(IOTimerEventSource * es); }; +private: + void attnButtonTimer(IOTimerEventSource * es); + IOReturn attnButtonHandlerFinish(thread_call_t threadCall); + void dllscEventTimer(IOTimerEventSource * es); + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_3 +public: + void handleAEREvent(bool synchronous); +#endif + #define kIOPCI2PCIBridgeName "IOPP" #if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_12_0 @@ -509,9 +718,20 @@ class IOPCIHostBridge : public IOPCIBridge virtual IOService *probe(IOService * provider, SInt32 *score) APPLE_KEXT_OVERRIDE; virtual bool configure(IOService * provider) APPLE_KEXT_OVERRIDE; +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_0 + // Return true if all children are in kIOPCIDeviceOnState. + bool allChildrenPoweredOn(void); +#endif + // Host bridge data is shared, when bridges have shared resources, i.e. PCIe config space (legacy systems). // They must be unique, if bridge has no resources to share (Apple Silicone). IOService *bridgeData; + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_0 +protected: + virtual IOReturn setLinkSpeed(tIOPCILinkSpeed linkSpeed, bool retrain) override { return kIOReturnUnsupported; }; + virtual IOReturn getLinkSpeed(tIOPCILinkSpeed *linkSpeed) override { return kIOReturnUnsupported; }; +#endif }; #endif diff --git a/Headers/IOKit/pci/IOPCIDevice.h b/Headers/IOKit/pci/IOPCIDevice.h index 20b3d8a..063bf82 100644 --- a/Headers/IOKit/pci/IOPCIDevice.h +++ b/Headers/IOKit/pci/IOPCIDevice.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1998-2021 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -27,7 +27,9 @@ #include #include -#if TARGET_OS_OSX +#define TARGET_OS_HAS_PCIDRIVERKIT_IOPCIDEVICE __has_include() + +#if TARGET_OS_HAS_PCIDRIVERKIT_IOPCIDEVICE #include #endif @@ -174,20 +176,6 @@ struct IOPCIPhysicalAddress { #endif }; -// IOPCIDevice matching property names -#define kIOPCITunnelCompatibleKey "IOPCITunnelCompatible" -#define kIOPCITunnelledKey "IOPCITunnelled" -#define kIOPCITunnelL1EnableKey "IOPCITunnelL1Enable" - -#define kIOPCIPauseCompatibleKey "IOPCIPauseCompatible" - -// property to control PCI default config space save on sleep -#define kIOPMPCIConfigSpaceVolatileKey "IOPMPCIConfigSpaceVolatile" -// property to disable express link on sleep -#define kIOPMPCISleepLinkDisableKey "IOPMPCISleepLinkDisable" -// property to reset secondary bus on sleep -#define kIOPMPCISleepResetKey "IOPMPCISleepReset" - #ifndef kIOPlatformDeviceASPMEnableKey #define kIOPlatformDeviceASPMEnableKey "IOPlatformDeviceASPMEnable" #endif @@ -205,6 +193,12 @@ struct IOPCIPhysicalAddress { #define kIOPCIDeviceDeviceTreeEntryKey "IOPCIDeviceDeviceTreeEntry" +#if ACPI_SUPPORT +#define kIOPCIUseDeviceMapperKey "IOPCIUseDeviceMapper" +#define kIOPCIChildBundleIdentifierKey "driver-child-bundle" +#define kIOPCIDeviceMapArgLen 1024 +#endif + enum { kIOPCIDevicePowerStateCount = 4, kIOPCIDeviceOffState = 0, @@ -213,12 +207,6 @@ enum { kIOPCIDevicePausedState = 3, }; -enum -{ - // bits getInterruptType result - kIOInterruptTypePCIMessaged = 0x00010000 -}; - // setLatencyTolerance options enum { @@ -252,6 +240,7 @@ class IOPCI2PCIBridge; class IOPCIMessagedInterruptController; class IOPCIConfigurator; class IOPCIEventSource; +class IOPCIHostBridgeData; // IOPCIEvent.event enum @@ -270,6 +259,11 @@ struct IOPCIEvent uint32_t data[5]; }; +enum IOPCIResetType { + kIOPCIResetNone, + kIOPCIResetHot, +}; + class IOPCIEventSource : public IOEventSource { friend class IOPCIBridge; @@ -289,7 +283,8 @@ class IOPCIEventSource : public IOEventSource uint8_t fWriteIndex; IOPCIEvent * fEvents; -public: + IOPCIHostBridgeData *getHostBridgeData(void); +public: virtual void enable( void ) APPLE_KEXT_OVERRIDE; virtual void disable( void ) APPLE_KEXT_OVERRIDE; @@ -302,6 +297,8 @@ class IOPCIEventSource : public IOEventSource typedef IOReturn (*IOPCIDeviceConfigHandler)(void * ref, IOMessage message, IOPCIDevice * device, uint32_t state); +typedef IOPCIResetType (* IOPCIDeviceCrashNotification_t)(void *clientObject, IOPCIDevice *device); + /*! @class IOPCIDevice : public IOService @abstract An IOService class representing a PCI device. @discussion The discovery of a PCI device by the PCI bus family results in an instance of the IOPCIDevice being created and published. It provides services for looking up and mapping memory mapped hardware, and access to the PCI configuration and I/O spaces. @@ -366,7 +363,7 @@ Matches a device whose class code is 0x0200zz, an ethernet device. class IOPCIDevice : public IOService { -#if TARGET_OS_OSX +#if TARGET_OS_HAS_PCIDRIVERKIT_IOPCIDEVICE OSDeclareDefaultStructorsWithDispatch(IOPCIDevice) #else OSDeclareDefaultStructors(IOPCIDevice) @@ -376,6 +373,7 @@ class IOPCIDevice : public IOService friend class IOPCI2PCIBridge; friend class IOPCIMessagedInterruptController; friend class IOPCIConfigurator; + friend class IOPCIHostBridgeData; protected: IOPCIBridge * parent; @@ -399,14 +397,16 @@ class IOPCIDevice : public IOService virtual void free( void ) APPLE_KEXT_OVERRIDE; virtual bool attach( IOService * provider ) APPLE_KEXT_OVERRIDE; virtual void detach( IOService * provider ) APPLE_KEXT_OVERRIDE; - virtual void detachAbove(const IORegistryPlane *) APPLE_KEXT_OVERRIDE; + virtual void detachAbove(const IORegistryPlane *) APPLE_KEXT_OVERRIDE; virtual IOReturn newUserClient( task_t owningTask, void * securityID, UInt32 type, OSDictionary * properties, IOUserClient ** handler ) APPLE_KEXT_OVERRIDE; - virtual bool handleOpen(IOService * forClient, IOOptionBits options, void * arg) APPLE_KEXT_OVERRIDE; - virtual void handleClose(IOService * forClient, IOOptionBits options) APPLE_KEXT_OVERRIDE; +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_11_0 + virtual bool handleOpen(IOService * forClient, IOOptionBits options, void * arg); + virtual void handleClose(IOService * forClient, IOOptionBits options); +#endif virtual IOReturn requestProbe( IOOptionBits options ) APPLE_KEXT_OVERRIDE; @@ -415,16 +415,31 @@ class IOPCIDevice : public IOService IOService* whatDevice) APPLE_KEXT_OVERRIDE; virtual IOReturn setPowerState( unsigned long, IOService * ) APPLE_KEXT_OVERRIDE; - virtual unsigned long maxCapabilityForDomainState ( IOPMPowerFlags domainState ) APPLE_KEXT_OVERRIDE; - virtual unsigned long initialPowerStateForDomainState ( IOPMPowerFlags domainState ) APPLE_KEXT_OVERRIDE; - virtual unsigned long powerStateForDomainState ( IOPMPowerFlags domainState ) APPLE_KEXT_OVERRIDE; +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_0 + virtual IOReturn addPowerChild( IOService * theChild ) APPLE_KEXT_OVERRIDE; + virtual IOReturn removePowerChild( IOPowerConnection * theChild ) APPLE_KEXT_OVERRIDE; +#endif + + virtual unsigned long maxCapabilityForDomainState ( IOPMPowerFlags domainState ) APPLE_KEXT_OVERRIDE; + virtual unsigned long initialPowerStateForDomainState ( IOPMPowerFlags domainState ) APPLE_KEXT_OVERRIDE; + virtual unsigned long powerStateForDomainState ( IOPMPowerFlags domainState ) APPLE_KEXT_OVERRIDE; virtual bool compareName( OSString * name, OSString ** matched = 0 ) const APPLE_KEXT_OVERRIDE; + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_11_0 virtual bool matchPropertyTable(OSDictionary * table) APPLE_KEXT_OVERRIDE; +#endif + virtual bool matchPropertyTable( OSDictionary * table, SInt32 * score ) APPLE_KEXT_OVERRIDE; virtual IOService * matchLocation( IOService * client ) APPLE_KEXT_OVERRIDE; virtual IOReturn getResources( void ) APPLE_KEXT_OVERRIDE; + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_12_0 + using IOService::getProperty; + virtual OSObject * getProperty( const OSSymbol * aKey) const APPLE_KEXT_OVERRIDE; +#endif + virtual IOReturn setProperties(OSObject * properties) APPLE_KEXT_OVERRIDE; virtual IOReturn callPlatformFunction(const OSSymbol * functionName, bool waitForFunction, @@ -443,6 +458,7 @@ class IOPCIDevice : public IOService void updateWakeReason(uint16_t pmeState); IOReturn enableLTR(IOPCIDevice * device, bool enable); IOReturn enableACS(IOPCIDevice * device, bool enable); + IOReturn clientCrashedThreadCall(thread_call_t threadCall); public: @@ -537,7 +553,7 @@ class IOPCIDevice : public IOService @discussion This method sets masked bits in a configuration space register on the device by reading and writing the register. The value of the masked bits before the write is returned. @param offset An 8-bit offset into configuration space, of which bits 0-1 are ignored. @param mask An 32-bit mask indicating which bits in the value parameter are valid. - @param value An 32-bit value to be written in host byte order (big endian on PPC). + @param data An 32-bit value to be written in host byte order (big endian on PPC). @result The value of the register masked with the mask before the write. */ virtual UInt32 setConfigBits( UInt8 offset, UInt32 mask, UInt32 value ); @@ -565,7 +581,7 @@ class IOPCIDevice : public IOService @param enable True or false to enable or disable bus mastering. @result True if bus mastering was previously enabled, false otherwise. */ - virtual bool setBusMasterEnable( bool enable ); + virtual bool setBusMasterEnable( bool enable ) /* API_DEPRECATED_WITH_REPLACEMENT("setBusLeadEnable", macos(10.0, 12.4), ios(1.0, 15.4), watchos(1.0, 8.5), tvos(1.0, 15.4)) */; /*! @function findPCICapability @abstract Search configuration space for a PCI capability register. @@ -687,7 +703,7 @@ class IOPCIDevice : public IOService /*! @function hasPCIPowerManagement @abstract determine whether or not the device supports PCI Bus Power Management. @discussion This method will look at the device's capabilties registers and determine whether or not the device supports the PCI BUS Power Management Specification. - @param state (optional) Check for support of a specific state (e.g. kPCIPMCPMESupportFromD3Cold). If state is not suuplied or is 0, then check for a property in the registry which tells which state the hardware expects the device to go to during sleep. + @param state(optional) Check for support of a specific state (e.g. kPCIPMCPMESupportFromD3Cold). If state is not suuplied or is 0, then check for a property in the registry which tells which state the hardware expects the device to go to during sleep. @result true if the specified state is supported */ virtual bool hasPCIPowerManagement(IOOptionBits state = 0); @@ -695,7 +711,7 @@ class IOPCIDevice : public IOService /*! @function enablePCIPowerManagement @abstract enable PCI power management for sleep state @discussion This method will enable PCI Bus Powermanagement when going to sleep mode. - @param state (optional) Enables PCI Power Management by placing the function in the given state (e.g. kPCIPMCSPowerStateD3). If state is not specified or is 0xffffffff, then the IOPCIDevice determines the desired state. If state is kPCIPMCSPowerStateD0 (0) then PCI Power Management is disabled. + @param state(optional) Enables PCI Power Management by placing the function in the given state (e.g. kPCIPMCSPowerStateD3). If state is not specified or is 0xffffffff, then the IOPCIDevice determines the desired state. If state is kPCIPMCSPowerStateD0 (0) then PCI Power Management is disabled. @result kIOReturnSuccess if there were no errors */ virtual IOReturn enablePCIPowerManagement(IOOptionBits state = 0xffffffff); @@ -709,8 +725,26 @@ class IOPCIDevice : public IOService virtual UInt32 extendedFindPCICapability( UInt32 capabilityID, IOByteCount * offset = 0 ); - // Unused Padding +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_12_3 + OSMetaClassDeclareReservedUsed(IOPCIDevice, 3); +/*! @function configureInterrupts + @abstract Configure interrupts. + @discussion This method allocates interrupts based on the passed parameters and the device's capabilities, i.e. MSI(X). + @param interruptType kIOInterruptTypeLevel, kIOInterruptTypePCIMessaged or kIOInterruptTypePCIMessagedX. + @param numRequired The minimum number of vectors for allocation to succeed. + @param numRequested The desired number of vectors to allocate. + @param options Unused + @result kIOReturnSuccess if there were no errors */ + + virtual IOReturn configureInterrupts( UInt32 interruptType = kIOInterruptTypeLevel, + UInt32 numRequired = 1, + UInt32 numRequested = 1, + IOOptionBits options = 0 ); +else OSMetaClassDeclareReservedUnused(IOPCIDevice, 3); +#endif + + // Unused Padding OSMetaClassDeclareReservedUnused(IOPCIDevice, 4); OSMetaClassDeclareReservedUnused(IOPCIDevice, 5); OSMetaClassDeclareReservedUnused(IOPCIDevice, 6); @@ -805,6 +839,183 @@ class IOPCIDevice : public IOService enum { kIOPCIAERErrorDescriptionMaxLength = 256 }; void copyAERErrorDescriptionForBit(bool correctable, uint32_t bit, char * string, size_t maxLength); + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_11_0 + /*! + * @brief Reads a 64-bit value from the PCI device's aperture at a given memory index. + * @discussion This method reads a 64-bit register on the device and returns its value. + * @param memoryIndex An index into the array of ranges assigned to the device. + * @param offset An offset into the device's memory specified by the index. + * @param readData An out parameter containing the 64-bit value in host byte order. -1 is written to readData on error. + */ + IOReturn deviceMemoryRead64(uint8_t memoryIndex, + uint64_t offset, + uint64_t* readData); + + /*! + * @brief Reads a 32-bit value from the PCI device's aperture at a given memory index. + * @discussion This method reads a 32-bit register on the device and returns its value. + * @param memoryIndex An index into the array of ranges assigned to the device. + * @param offset An offset into the device's memory specified by the index. + * @param readData An out parameter containing the 32-bit value in host byte order. -1 is written to readData on error. + */ + IOReturn deviceMemoryRead32(uint8_t memoryIndex, + uint64_t offset, + uint32_t* readData); + + /*! + * @brief Reads a 16-bit value from the PCI device's aperture at a given memory index. + * @discussion This method reads a 16-bit register on the device and returns its value. + * @param memoryIndex An index into the array of ranges assigned to the device. + * @param offset An offset into the device's memory specified by the index. + * @param readData An out parameter containing the 16-bit value in host byte order. -1 is written to readData on error. + */ + IOReturn deviceMemoryRead16(uint8_t memoryIndex, + uint64_t offset, + uint16_t* readData); + + /*! + * @brief Reads an 8-bit value from the PCI device's aperture at a given memory index. + * @discussion This method reads an 8-bit register on the device and returns its value. + * @param memoryIndex An index into the array of ranges assigned to the device. + * @param offset An offset into the device's memory specified by the index. + * @param readData An out parameter containing the 8-bit. -1 is written to readData on error. + */ + IOReturn deviceMemoryRead8(uint8_t memoryIndex, + uint64_t offset, + uint8_t* readData); + + /*! + * @brief Writes a 64-bit value to the PCI device's aperture at a given memory index. + * @discussion This method writes a 64-bit register on the device and returns its value. + * @param memoryIndex An index into the array of ranges assigned to the device + * @param offset An offset into the device's memory specified by the index. + * @param data A 64-bit value to be written in host byte order. + */ + IOReturn deviceMemoryWrite64(uint8_t memoryIndex, + uint64_t offset, + uint64_t data); + + /*! + * @brief Writes a 32-bit value to the PCI device's aperture at a given memory index. + * @discussion This method writes a 32-bit register on the device and returns its value. + * @param memoryIndex An index into the array of ranges assigned to the device. + * @param offset An offset into the device's memory specified by the index. + * @param data A 32-bit value to be written in host byte order. + */ + IOReturn deviceMemoryWrite32(uint8_t memoryIndex, + uint64_t offset, + uint32_t data); + + /*! + * @brief Writes a 16-bit value to the PCI device's aperture at a given memory index. + * @discussion This method writes a 16-bit register on the device and returns its value. + * @param memoryIndex An index into the array of ranges assigned to the device. + * @param offset An offset into the device's memory specified by the index. + * @param data A 16-bit value to be written in host byte order. + */ + IOReturn deviceMemoryWrite16(uint8_t memoryIndex, + uint64_t offset, + uint16_t data); + + /*! + * @brief Writes an 8-bit value to the PCI device's aperture at a given memory index. + * @discussion This method writes an 8-bit register on the device and returns its value. + * @param memoryIndex An index into the array of ranges assigned to the device + * @param offset An offset into the device's memory specified by the index. + * @param data An 8-bit value. + */ + IOReturn deviceMemoryWrite8(uint8_t memoryIndex, + uint64_t offset, + uint8_t data); +#endif + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_0 + /*! + * @brief Register a dext crash notification handler for this PCI device. + * @discussion The handler is invoked prior to disabling and terminating the crashed device, + * and it returns an IOPCIResetType to control whether and how the device is reset. + * kIOPCIResetNone: Do not reset the device, only terminate it + * kIOPCIResetHot: Perform a hot reset, terminate the device and any multi-function peers + * @param handler The notification handler + * @param clientObject The client object pointer passed to the handler + */ + void registerCrashNotification(IOPCIDeviceCrashNotification_t handler, void *clientObject); + + void unregisterCrashNotification(void); + + /*! @function setLinkSpeed + * @abstract Set the link speed upper bound and optionally retrain + * @discussion This function writes the device's upstream bridge's target-link-speed. This setting will be enforced during subsequent + * reset-initiated link trainings, and the function will immediately retrain the link if the retrain parameter is true. + * If retrain is true, this function will not return until training completes. The user must call IOPCIDevice::getLinkSpeed() to + * see the result of link training; a return value of kIOReturnSuccess does not indicate the requested link speed was reached. + * @param linkSpeed A tIOPCILinkSpeed. + * @param retrain If true, the function will retrain the link. + * @result kIOReturnSuccess if there were no errors, such as linkSpeed unsupported by the upstream bridge. kIOReturnSuccess does not + * indicate the requested link speed was reached. + */ + IOReturn setLinkSpeed(tIOPCILinkSpeed linkSpeed, + bool retrain = false); + + /*! @function getLinkSpeed + * @abstract Get the endpoint's link speed + * @param linkSpeed A pointer to a tIOPCILinkSpeed. + * @result Returns an IOReturn code indicating success or failure. + */ + IOReturn getLinkSpeed(tIOPCILinkSpeed *linkSpeed); +#endif + +private: + static uint16_t getCloseCommandMask(uint32_t vendorDevice); + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_12_3 +public: + /*! @function setBusLeadEnable + * @abstract Sets the device's bus lead enable. + * @discussion This method sets the bus lead enable bit in the device's command config space register to the passed value, and returns the previous state of the enable. + * @param enable True or false to enable or disable bus leading capability. + * @result True if bus leading was previously enabled, false otherwise. + */ + bool setBusLeadEnable( bool enable ); +#endif + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_0 + /*! @function reset + * @abstract Reset the PCIe device. + * @discussion If this is a multi-function device, all functions associated with the device will be reset. + * Device configuration state is saved prior to resetting the device and restored after reset completes. + * During reset, the caller must not attempt to access the device. + * This call will block until the link comes up and the device is usable (except for type kIOPCIDeviceResetTypeWarmResetDisable). + * @param type tIOPCIDeviceResetTypes. + * @param options tIOPCIDeviceResetOptions. + * @return kIOReturnSuccess if the reset specified is supported + */ + IOReturn reset(tIOPCIDeviceResetTypes type, + tIOPCIDeviceResetOptions options = kIOPCIDeviceResetOptionNone); +#endif + +private: + void releasePowerAssertion(void); + void powerAssertionTimeout(IOTimerEventSource* timer); + bool childPublished(void* refcon __unused, IOService* newService, IONotifier* notifier __unused); + bool childMatched(void* refcon __unused, IOService* newService, IONotifier* notifier __unused); + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_0 +public: + virtual bool setProperty(const OSSymbol * aKey, OSObject * anObject); + virtual bool setProperty(const OSString * aKey, OSObject * anObject); + virtual bool setProperty(const char * aKey, OSObject * anObject); + virtual bool setProperty(const char * aKey, const char * aString); + virtual bool setProperty(const char * aKey, bool aBoolean); + virtual bool setProperty(const char * aKey, unsigned long long aValue, unsigned int aNumberOfBits); + virtual bool setProperty(const char * aKey, void * bytes, unsigned int length); +#endif + +private: + uint32_t configWrite32Filter(IOByteCount offset, uint32_t data); + uint16_t configWrite16Filter(IOByteCount offset, uint16_t data); + uint8_t configWrite8Filter(IOByteCount offset, uint8_t data); }; #endif /* defined(KERNEL) */ diff --git a/Headers/IOKit/pci/IOPCIFamilyDefinitions.h b/Headers/IOKit/pci/IOPCIFamilyDefinitions.h index 4cf01c4..f1d9e3b 100644 --- a/Headers/IOKit/pci/IOPCIFamilyDefinitions.h +++ b/Headers/IOKit/pci/IOPCIFamilyDefinitions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 Apple Inc. All rights reserved. + * Copyright (c) 2018-2021 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -30,6 +30,7 @@ #define IOPCIDefinitions_h #include +// #include #if TARGET_OS_DRIVERKIT #include #include @@ -60,6 +61,47 @@ #define kIOPCIDeviceMemoryArrayKey "IODeviceMemory" +// base address of the device's memory map +#define kIOPCIDeviceMemoryMapBase "IOPCIDeviceMemoryMapBase" +// size of device memory map +#define kIOPCIDeviceMemoryMapSize "IOPCIDeviceMemoryMapSize" +// mapper page size +#define kIOPCIDeviceMapperPageSize "IOPCIDeviceMapperPageSize" + +// IOPCIDevice matching property names +#define kIOPCITunnelCompatibleKey "IOPCITunnelCompatible" +#define kIOPCITunnelledKey "IOPCITunnelled" +#define kIOPCITunnelL1EnableKey "IOPCITunnelL1Enable" + +#define kIOPCITunnelRootDeviceModelIDKey "IOPCITunnelRootDeviceModelID" +#define kIOPCITunnelRootDeviceVendorIDKey "IOPCITunnelRootDeviceVendorID" + +#define kIOPCIPauseCompatibleKey "IOPCIPauseCompatible" + +// Properties that can be set on the IOPCIDevice +// property to control PCI default config space save on sleep. +// If false, config space will not be save/restored on power state transitions +#define kIOPMPCIConfigSpaceVolatileKey "IOPMPCIConfigSpaceVolatile" +// property to disable express link on sleep +#define kIOPMPCISleepLinkDisableKey "IOPMPCISleepLinkDisable" +// property to issue a secondary bus reset on sleep +#define kIOPMPCISleepResetKey "IOPMPCISleepReset" +// property to provide bitmask for link train while scanning +#define kIOPCIRetrainLinkMaskKey "IOPCIRetrainLinkMask" +// property to issue a link retrain while on wake +#define kIOPCIRetrainLinkKey "IOPCIRetrainLink" +// property to check if endpoint is present on bridge +#define kIOPCIEndpointPrsnt "IOPCIEndpointPrsnt" +// property to change the wait time for link up from spec default +#define kIOPCIWaitForLinkUpKey "wait-for-link-up" + +/* bits getInterruptType result */ +enum +{ + kIOInterruptTypePCIMessaged = 0x00010000, + kIOInterruptTypePCIMessagedX = 0x00020000 +}; + /* Definitions of PCI Config Registers */ enum { @@ -114,13 +156,27 @@ enum kIOPCICapabilityIDMSIX = 0x11, kIOPCICapabilityIDFPB = 0x15, +#if defined(__LP64__) + kIOPCIExpressCapabilityIDErrorReporting = -0x01U, + kIOPCIExpressCapabilityIDVirtualChannel = -0x02U, + kIOPCIExpressCapabilityIDDeviceSerialNumber = -0x03U, + kIOPCIExpressCapabilityIDPowerBudget = -0x04U, + kIOPCIExpressCapabilityIDAccessControlServices = -0x0DU, + kIOPCIExpressCapabilityIDAlternativeRoutingID = -0x0EU, + kIOPCIExpressCapabilityIDLatencyTolerenceReporting = -0x18U, + kIOPCIExpressCapabilityIDL1PMSubstates = -0x1EU, + kIOPCIExpressCapabilityIDPrecisionTimeManagement = -0x1FU, +#else /* defined(__LP64__) */ kIOPCIExpressCapabilityIDErrorReporting = -0x01UL, kIOPCIExpressCapabilityIDVirtualChannel = -0x02UL, kIOPCIExpressCapabilityIDDeviceSerialNumber = -0x03UL, kIOPCIExpressCapabilityIDPowerBudget = -0x04UL, kIOPCIExpressCapabilityIDAccessControlServices = -0x0DUL, + kIOPCIExpressCapabilityIDAlternativeRoutingID = -0x0EUL, kIOPCIExpressCapabilityIDLatencyTolerenceReporting = -0x18UL, kIOPCIExpressCapabilityIDL1PMSubstates = -0x1EUL, + kIOPCIExpressCapabilityIDPrecisionTimeManagement = -0x1FUL, +#endif /* !defined(__LP64__) */ }; /* Command register definitions */ @@ -128,7 +184,8 @@ enum { kIOPCICommandIOSpace = 0x0001, kIOPCICommandMemorySpace = 0x0002, - kIOPCICommandBusMaster = 0x0004, + kIOPCICommandBusLead = 0x0004, + kIOPCICommandBusMaster /* API_DEPRECATED_WITH_REPLACEMENT("kIOPCICommandBusLead", macos(10.0, 12.4), ios(1.0, 15.4), watchos(1.0, 8.5), tvos(1.0, 15.4)) */ = kIOPCICommandBusLead, kIOPCICommandSpecialCycles = 0x0008, kIOPCICommandMemWrInvalidate = 0x0010, kIOPCICommandPaletteSnoop = 0x0020, @@ -153,7 +210,8 @@ enum kIOPCIStatusDevSel3 = 0x0600, kIOPCIStatusTargetAbortCapable = 0x0800, kIOPCIStatusTargetAbortActive = 0x1000, - kIOPCIStatusMasterAbortActive = 0x2000, + kIOPCIStatusLeadAbortActive = 0x2000, + kIOPCIStatusMasterAbortActive /* API_DEPRECATED_WITH_REPLACEMENT("kIOPCIStatusLeadAbortActive", macos(10.0, 12.4), ios(1.0, 15.4), watchos(1.0, 8.5), tvos(1.0, 15.4)) */ = kIOPCIStatusLeadAbortActive, kIOPCIStatusSERRActive = 0x4000, kIOPCIStatusParityErrActive = 0x8000 }; @@ -205,6 +263,19 @@ enum kPCIPMCSPMEWakeReason = 0x00020000 }; +enum +{ + kIOPCISlotCapabilitiesBitAttentionButtonPresent = (1 << 0), + kIOPCISlotCapabilitiesBitPowerControllerPresent = (1 << 1), + kIOPCISlotCapabilitiesBitMRLSensorPresent = (1 << 2), + kIOPCISlotCapabilitiesBitAttentionIndicatorPresent = (1 << 3), + kIOPCISlotCapabilitiesBitPowerIndicatorPresent = (1 << 4), + kIOPCISlotCapabilitiesBitHotPlugSurprise = (1 << 5), + kIOPCISlotCapabilitiesBitHotPlugCapable = (1 << 6), + kIOPCISlotCapabilitiesBitElectromechanicalInterlockPresent = (1 << 17), + kIOPCISlotCapabilitiesBitNoCommandCompletedSupport = (1 << 18) +}; + // PCIe error bits enum { @@ -239,5 +310,57 @@ enum kIOPCICorrectableErrorBitHeaderLogOverflow = 15, }; +typedef enum tIOPCILinkSpeed +{ + kIOPCILinkSpeed_2_5_GTs = 1, // Gen 1 + kIOPCILinkSpeed_5_GTs, // Gen 2 + kIOPCILinkSpeed_8_GTs, // Gen 3 + kIOPCILinkSpeed_16_GTs, // Gen 4 + kIOPCILinkSpeed_32_GTs, // Gen 5 +} tIOPCILinkSpeed; + +/*! @enum tIOPCIDeviceResetTypes + * @constant kIOPCIDeviceResetTypeHotReset Issues a hot reset to the device without power being removed from the device. + * This will issue a hot reset from its upstream bridge by setting the secondary bus reset bit in the bridge's control + * register. + * @constant kIOPCIDeviceResetTypeWarmReset Issues a warm reset to the device without power being removed from the device, if a platform + * specific function exists. + * @constant kIOPCIDeviceResetTypeWarmResetDisable Performs the first half of a warm reset (e.g. assert PERST#), if a platform + * specific function exists. Upon completion, the device is unusable until the caller requests reset with type + * kIOPCIDeviceResetTypeWarmResetEnable. + * + * This type facilitates the generation of a cold reset, i.e. by removing power before using kIOPCIDeviceResetTypeWarmResetDisable + * and re-applying it before using kIOPCIDeviceResetTypeWarmResetEnable. + * @constant kIOPCIDeviceResetTypeWarmResetEnable Completes the warm reset operation initiated with type kIOPCIDeviceResetTypeWarmResetDisable + * (e.g. deassert PERST#). See kIOPCIDeviceResetTypeWarmResetDisable for more details. + */ +typedef enum tIOPCIDeviceResetTypes +{ + kIOPCIDeviceResetTypeHotReset = 0x00000001, + kIOPCIDeviceResetTypeWarmReset = 0x00000002, + kIOPCIDeviceResetTypeWarmResetDisable = 0x00000004, + kIOPCIDeviceResetTypeWarmResetEnable = 0x00000008, +} tIOPCIDeviceResetTypes; + +/*! @enum tIOPCIDeviceResetOptions + * @constant kIOPCIDeviceResetOptionNone No options selected + * @constant kIOPCIDeviceResetOptionTerminate Terminate the IOPCIDevice(s) that were reset and re-probe the bus. This will stop + * any attached client drivers. Devices with reset-initiated personality changes should use this option. + * + * This option causes the reset function to initiate the asynchronous termination process, but not block on its completion. + */ +typedef enum tIOPCIDeviceResetOptions +{ + kIOPCIDeviceResetOptionNone = 0x00000000, + kIOPCIDeviceResetOptionTerminate = 0x00000001, +} tIOPCIDeviceResetOptions; + +enum tIOPCILinkControlASPMBits +{ + kIOPCILinkControlASPMBitsDisabled = 0, + kIOPCILinkControlASPMBitsL0s = (1 << 0), + kIOPCILinkControlASPMBitsL1 = (1 << 1), + kIOPCILinkControlASPMBitsL0sL1 = kIOPCILinkControlASPMBitsL0s | kIOPCILinkControlASPMBitsL1 +}; #endif /* IOPCIDefinitions_h */