| 1 | /* |
| 2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. |
| 3 | * |
| 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
| 5 | * |
| 6 | * This file contains Original Code and/or Modifications of Original Code |
| 7 | * as defined in and that are subject to the Apple Public Source License |
| 8 | * Version 2.0 (the 'License'). You may not use this file except in |
| 9 | * compliance with the License. The rights granted to you under the License |
| 10 | * may not be used to create, or enable the creation or redistribution of, |
| 11 | * unlawful or unlicensed copies of an Apple operating system, or to |
| 12 | * circumvent, violate, or enable the circumvention or violation of, any |
| 13 | * terms of an Apple operating system software license agreement. |
| 14 | * |
| 15 | * Please obtain a copy of the License at |
| 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. |
| 17 | * |
| 18 | * The Original Code and all software distributed under the License are |
| 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
| 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
| 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, |
| 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
| 23 | * Please see the License for the specific language governing rights and |
| 24 | * limitations under the License. |
| 25 | * |
| 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
| 27 | */ |
| 28 | /* |
| 29 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. |
| 30 | * |
| 31 | * DRI: Josh de Cesare |
| 32 | * |
| 33 | */ |
| 34 | |
| 35 | #ifndef _IOKIT_CPU_H |
| 36 | #define _IOKIT_CPU_H |
| 37 | |
| 38 | extern "C" { |
| 39 | #include <pexpert/pexpert.h> |
| 40 | } |
| 41 | |
| 42 | #include <machine/machine_routines.h> |
| 43 | #include <IOKit/IOService.h> |
| 44 | #include <IOKit/IOInterruptController.h> |
| 45 | #include <IOKit/IOPlatformActions.h> |
| 46 | #include <libkern/c++/OSPtr.h> |
| 47 | |
| 48 | enum { |
| 49 | kIOCPUStateUnregistered = 0, |
| 50 | kIOCPUStateUninitalized, |
| 51 | kIOCPUStateStopped, |
| 52 | kIOCPUStateRunning, |
| 53 | kIOCPUStateCount |
| 54 | }; |
| 55 | |
| 56 | class IOCPU : public IOService |
| 57 | { |
| 58 | OSDeclareAbstractStructors(IOCPU); |
| 59 | |
| 60 | private: |
| 61 | OSPtr<OSArray> _cpuGroup; |
| 62 | UInt32 _cpuNumber; |
| 63 | UInt32 _cpuState; |
| 64 | |
| 65 | protected: |
| 66 | IOService *cpuNub; |
| 67 | processor_t machProcessor; |
| 68 | ipi_handler_t ipi_handler; |
| 69 | |
| 70 | struct ExpansionData { }; |
| 71 | ExpansionData *iocpu_reserved; |
| 72 | |
| 73 | virtual void setCPUNumber(UInt32 cpuNumber); |
| 74 | virtual void setCPUState(UInt32 cpuState); |
| 75 | |
| 76 | public: |
| 77 | virtual bool start(IOService *provider) APPLE_KEXT_OVERRIDE; |
| 78 | virtual void detach(IOService *provider) APPLE_KEXT_OVERRIDE; |
| 79 | |
| 80 | virtual OSObject *getProperty(const OSSymbol *aKey) const APPLE_KEXT_OVERRIDE; |
| 81 | virtual bool setProperty(const OSSymbol *aKey, OSObject *anObject) APPLE_KEXT_OVERRIDE; |
| 82 | virtual bool serializeProperties(OSSerialize *serialize) const APPLE_KEXT_OVERRIDE; |
| 83 | virtual IOReturn setProperties(OSObject *properties) APPLE_KEXT_OVERRIDE; |
| 84 | virtual void initCPU(bool boot) = 0; |
| 85 | virtual void quiesceCPU(void) = 0; |
| 86 | virtual kern_return_t startCPU(vm_offset_t start_paddr, |
| 87 | vm_offset_t arg_paddr) = 0; |
| 88 | virtual void haltCPU(void) = 0; |
| 89 | virtual void signalCPU(IOCPU *target); |
| 90 | virtual void signalCPUDeferred(IOCPU * target); |
| 91 | virtual void signalCPUCancel(IOCPU * target); |
| 92 | virtual void enableCPUTimeBase(bool enable); |
| 93 | |
| 94 | virtual UInt32 getCPUNumber(void); |
| 95 | virtual UInt32 getCPUState(void); |
| 96 | virtual OSArray *getCPUGroup(void); |
| 97 | virtual UInt32 getCPUGroupSize(void); |
| 98 | virtual processor_t getMachProcessor(void); |
| 99 | |
| 100 | virtual const OSSymbol *getCPUName(void) = 0; |
| 101 | |
| 102 | OSMetaClassDeclareReservedUnused(IOCPU, 0); |
| 103 | OSMetaClassDeclareReservedUnused(IOCPU, 1); |
| 104 | OSMetaClassDeclareReservedUnused(IOCPU, 2); |
| 105 | OSMetaClassDeclareReservedUnused(IOCPU, 3); |
| 106 | OSMetaClassDeclareReservedUnused(IOCPU, 4); |
| 107 | OSMetaClassDeclareReservedUnused(IOCPU, 5); |
| 108 | OSMetaClassDeclareReservedUnused(IOCPU, 6); |
| 109 | OSMetaClassDeclareReservedUnused(IOCPU, 7); |
| 110 | }; |
| 111 | |
| 112 | class IOCPUInterruptController : public IOInterruptController |
| 113 | { |
| 114 | OSDeclareDefaultStructors(IOCPUInterruptController); |
| 115 | |
| 116 | private: |
| 117 | int enabledCPUs; |
| 118 | |
| 119 | protected: |
| 120 | int numCPUs; |
| 121 | int numSources; |
| 122 | |
| 123 | struct ExpansionData { }; |
| 124 | ExpansionData *iocpuic_reserved; |
| 125 | |
| 126 | public: |
| 127 | virtual IOReturn initCPUInterruptController(int sources); |
| 128 | virtual void registerCPUInterruptController(void); |
| 129 | virtual void enableCPUInterrupt(IOCPU *cpu); |
| 130 | |
| 131 | virtual void setCPUInterruptProperties(IOService *service) APPLE_KEXT_OVERRIDE; |
| 132 | virtual IOReturn registerInterrupt(IOService *nub, int source, |
| 133 | void *target, |
| 134 | IOInterruptHandler handler, |
| 135 | void *refCon) APPLE_KEXT_OVERRIDE; |
| 136 | |
| 137 | virtual IOReturn getInterruptType(IOService *nub, int source, |
| 138 | int *interruptType) APPLE_KEXT_OVERRIDE; |
| 139 | |
| 140 | virtual IOReturn enableInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE; |
| 141 | virtual IOReturn disableInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE; |
| 142 | virtual IOReturn causeInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE; |
| 143 | |
| 144 | virtual IOReturn handleInterrupt(void *refCon, IOService *nub, |
| 145 | int source) APPLE_KEXT_OVERRIDE; |
| 146 | |
| 147 | virtual IOReturn initCPUInterruptController(int sources, int cpus); |
| 148 | |
| 149 | OSMetaClassDeclareReservedUnused(IOCPUInterruptController, 1); |
| 150 | OSMetaClassDeclareReservedUnused(IOCPUInterruptController, 2); |
| 151 | OSMetaClassDeclareReservedUnused(IOCPUInterruptController, 3); |
| 152 | OSMetaClassDeclareReservedUnused(IOCPUInterruptController, 4); |
| 153 | OSMetaClassDeclareReservedUnused(IOCPUInterruptController, 5); |
| 154 | }; |
| 155 | |
| 156 | #endif /* ! _IOKIT_CPU_H */ |
| 157 | |