]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOCPU.h
xnu-6153.61.1.tar.gz
[apple/xnu.git] / iokit / IOKit / IOCPU.h
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 <machine/machine_routines.h>
40 #include <pexpert/pexpert.h>
41 }
42
43 #include <IOKit/IOService.h>
44 #include <IOKit/IOInterruptController.h>
45
46 enum {
47 kIOCPUStateUnregistered = 0,
48 kIOCPUStateUninitalized,
49 kIOCPUStateStopped,
50 kIOCPUStateRunning,
51 kIOCPUStateCount
52 };
53
54 class IOCPU : public IOService
55 {
56 OSDeclareAbstractStructors(IOCPU);
57
58 private:
59 OSArray *_cpuGroup;
60 UInt32 _cpuNumber;
61 UInt32 _cpuState;
62
63 protected:
64 IOService *cpuNub;
65 processor_t machProcessor;
66 ipi_handler_t ipi_handler;
67
68 struct ExpansionData { };
69 ExpansionData *iocpu_reserved;
70
71 virtual void setCPUNumber(UInt32 cpuNumber);
72 virtual void setCPUState(UInt32 cpuState);
73
74 public:
75 virtual bool start(IOService *provider) APPLE_KEXT_OVERRIDE;
76 virtual void detach(IOService *provider) APPLE_KEXT_OVERRIDE;
77
78 virtual OSObject *getProperty(const OSSymbol *aKey) const APPLE_KEXT_OVERRIDE;
79 virtual bool setProperty(const OSSymbol *aKey, OSObject *anObject) APPLE_KEXT_OVERRIDE;
80 virtual bool serializeProperties(OSSerialize *serialize) const APPLE_KEXT_OVERRIDE;
81 virtual IOReturn setProperties(OSObject *properties) APPLE_KEXT_OVERRIDE;
82 virtual void initCPU(bool boot) = 0;
83 virtual void quiesceCPU(void) = 0;
84 virtual kern_return_t startCPU(vm_offset_t start_paddr,
85 vm_offset_t arg_paddr) = 0;
86 virtual void haltCPU(void) = 0;
87 virtual void signalCPU(IOCPU *target);
88 virtual void signalCPUDeferred(IOCPU * target);
89 virtual void signalCPUCancel(IOCPU * target);
90 virtual void enableCPUTimeBase(bool enable);
91
92 virtual UInt32 getCPUNumber(void);
93 virtual UInt32 getCPUState(void);
94 virtual OSArray *getCPUGroup(void);
95 virtual UInt32 getCPUGroupSize(void);
96 virtual processor_t getMachProcessor(void);
97
98 virtual const OSSymbol *getCPUName(void) = 0;
99
100 OSMetaClassDeclareReservedUnused(IOCPU, 0);
101 OSMetaClassDeclareReservedUnused(IOCPU, 1);
102 OSMetaClassDeclareReservedUnused(IOCPU, 2);
103 OSMetaClassDeclareReservedUnused(IOCPU, 3);
104 OSMetaClassDeclareReservedUnused(IOCPU, 4);
105 OSMetaClassDeclareReservedUnused(IOCPU, 5);
106 OSMetaClassDeclareReservedUnused(IOCPU, 6);
107 OSMetaClassDeclareReservedUnused(IOCPU, 7);
108 };
109
110 void IOCPUSleepKernel(void);
111 extern "C" kern_return_t IOCPURunPlatformQuiesceActions(void);
112 extern "C" kern_return_t IOCPURunPlatformActiveActions(void);
113 extern "C" kern_return_t IOCPURunPlatformHaltRestartActions(uint32_t message);
114 extern "C" kern_return_t IOCPURunPlatformPanicActions(uint32_t message);
115 extern "C" kern_return_t IOCPURunPlatformPanicSyncAction(void *addr, uint32_t offset, uint32_t len);
116
117 class IOCPUInterruptController : public IOInterruptController
118 {
119 OSDeclareDefaultStructors(IOCPUInterruptController);
120
121 private:
122 int enabledCPUs;
123
124 protected:
125 int numCPUs;
126 int numSources;
127
128 struct ExpansionData { };
129 ExpansionData *iocpuic_reserved;
130
131 public:
132 virtual IOReturn initCPUInterruptController(int sources);
133 virtual void registerCPUInterruptController(void);
134 virtual void setCPUInterruptProperties(IOService *service);
135 virtual void enableCPUInterrupt(IOCPU *cpu);
136
137 virtual IOReturn registerInterrupt(IOService *nub, int source,
138 void *target,
139 IOInterruptHandler handler,
140 void *refCon) APPLE_KEXT_OVERRIDE;
141
142 virtual IOReturn getInterruptType(IOService *nub, int source,
143 int *interruptType) APPLE_KEXT_OVERRIDE;
144
145 virtual IOReturn enableInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
146 virtual IOReturn disableInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
147 virtual IOReturn causeInterrupt(IOService *nub, int source) APPLE_KEXT_OVERRIDE;
148
149 virtual IOReturn handleInterrupt(void *refCon, IOService *nub,
150 int source) APPLE_KEXT_OVERRIDE;
151
152 virtual IOReturn initCPUInterruptController(int sources, int cpus);
153
154 OSMetaClassDeclareReservedUnused(IOCPUInterruptController, 1);
155 OSMetaClassDeclareReservedUnused(IOCPUInterruptController, 2);
156 OSMetaClassDeclareReservedUnused(IOCPUInterruptController, 3);
157 OSMetaClassDeclareReservedUnused(IOCPUInterruptController, 4);
158 OSMetaClassDeclareReservedUnused(IOCPUInterruptController, 5);
159 };
160
161 #endif /* ! _IOKIT_CPU_H */