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