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