]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/IOKit/IOKitDebug.h
xnu-4903.241.1.tar.gz
[apple/xnu.git] / iokit / IOKit / IOKitDebug.h
index 3e9c1de3b2062910f92a303db1306296397421dd..a6c64b8ebaadf4cfdd0680a190847dde0b7f307f 100644 (file)
@@ -44,10 +44,10 @@ class IOKitDiagnostics : public OSObject
 
 public:
     static OSObject * diagnostics( void );
-    virtual bool serialize(OSSerialize *s) const;
+    virtual bool serialize(OSSerialize *s) const APPLE_KEXT_OVERRIDE;
 private:
     static void updateOffset( OSDictionary * dict,
-            UInt32 value, const char * name );
+            UInt64 value, const char * name );
 };
 
 #endif /* __cplusplus */
@@ -77,17 +77,42 @@ enum {
     kIOLogHibernate     =         0x00100000ULL,
     kIOStatistics       =         0x04000000ULL,
     kIOSleepWakeWdogOff =         0x40000000ULL,
+    kIOKextSpinDump     =         0x80000000ULL,
 
     // debug aids - change behaviour
     kIONoFreeObjects    =         0x00100000ULL,
-    kIOLogSynchronous   =         0x00200000ULL,  // IOLog completes synchronously
-    kOSTraceObjectAlloc =         0x00400000ULL,
+//    kIOLogSynchronous   =         0x00200000ULL,  // IOLog completes synchronously -- obsolete
+    kIOTracking         =         0x00400000ULL,
     kIOWaitQuietPanics  =         0x00800000ULL,
-    kIOWaitQuietBeforeRoot  =     0x01000000ULL,
+    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
@@ -126,6 +151,131 @@ 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"
+
+#if XNU_KERNEL_PRIVATE && IOTRACKING
+
+struct IOTrackingQueue;
+struct IOTrackingCallSite;
+
+struct IOTracking
+{
+    queue_chain_t        link;
+    IOTrackingCallSite * site;
+#if !defined(__LP64__)
+    uint32_t             flags;
+#endif
+};
+
+struct IOTrackingAddress
+{
+    IOTracking    tracking;
+    uintptr_t     address;
+    size_t        size;
+#if defined(__LP64__)
+    uint32_t      flags;
+#endif
+};
+
+struct IOTrackingUser
+{
+    queue_chain_t link;
+    pid_t         btPID;
+    uint8_t       user32;
+    uint8_t       userCount;
+    uintptr_t     bt[kIOTrackingCallSiteBTs];
+    uintptr_t     btUser[kIOTrackingCallSiteBTs];
+};
+
+enum
+{
+    kIOTrackingQueueTypeDefaultOn = 0x00000001,
+    kIOTrackingQueueTypeAlloc     = 0x00000002,
+    kIOTrackingQueueTypeMap       = 0x00000004,
+    kIOTrackingQueueTypeUser      = 0x00000008,
+};
+
+
+void              IOTrackingInit(void);
+IOTrackingQueue * IOTrackingQueueAlloc(const char * name, uintptr_t btEntry,
+                                       size_t allocSize, size_t minCaptureSize,
+                                       uint32_t type, uint32_t numSiteQs);
+void              IOTrackingQueueFree(IOTrackingQueue * head);
+void              IOTrackingAdd(IOTrackingQueue * head, IOTracking * mem, size_t size, bool address, vm_tag_t tag);
+void              IOTrackingRemove(IOTrackingQueue * head, IOTracking * mem, size_t size);
+void              IOTrackingAddUser(IOTrackingQueue * queue, IOTrackingUser * mem, vm_size_t size);
+void              IOTrackingRemoveUser(IOTrackingQueue * head, IOTrackingUser * tracking);
+
+void              IOTrackingAlloc(IOTrackingQueue * head, uintptr_t address, size_t size);
+void              IOTrackingFree(IOTrackingQueue * head, uintptr_t address, size_t size);
+void              IOTrackingReset(IOTrackingQueue * head);
+void              IOTrackingAccumSize(IOTrackingQueue * head, IOTracking * mem, size_t size);
+kern_return_t     IOTrackingDebug(uint32_t selector, uint32_t options,
+                                 const char * names, size_t namesLen, 
+                                 size_t size, OSObject ** result);
+
+extern IOTrackingQueue * gIOMallocTracking;
+extern IOTrackingQueue * gIOWireTracking;
+extern IOTrackingQueue * gIOMapTracking;
+
+#endif /* XNU_KERNEL_PRIVATE && IOTRACKING */
+
+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 */