]> git.saurik.com Git - apple/xnu.git/blob - iokit/Drivers/platform/drvAppleI386Generic/AppleI386CPU.cpp
xnu-344.12.2.tar.gz
[apple/xnu.git] / iokit / Drivers / platform / drvAppleI386Generic / AppleI386CPU.cpp
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) 2000 Apple Computer, Inc. All rights reserved.
24 *
25 * AppleI386CPU.cpp
26 *
27 * March 6, 2000 jliu
28 * Created based on AppleCPU.
29 */
30
31 #include "AppleI386CPU.h"
32
33 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
34
35 #undef super
36 #define super IOCPU
37
38 OSDefineMetaClassAndStructors(AppleI386CPU, IOCPU);
39
40 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
41
42 bool AppleI386CPU::start(IOService * provider)
43 {
44 // kern_return_t result;
45
46 if (!super::start(provider)) return false;
47
48 cpuIC = new AppleI386CPUInterruptController;
49 if (cpuIC == 0) return false;
50
51 if (cpuIC->initCPUInterruptController(1) != kIOReturnSuccess)
52 return false;
53
54 cpuIC->attach(this);
55
56 cpuIC->registerCPUInterruptController();
57
58 #ifdef NOTYET
59 // Register this CPU with mach.
60 result = ml_processor_register((cpu_id_t)this, 0,
61 &machProcessor, &ipi_handler, true);
62 if (result == KERN_FAILURE) return false;
63 #endif
64
65 setCPUState(kIOCPUStateUninitalized);
66
67 #ifdef NOTYET
68 processor_start(machProcessor);
69 #endif
70
71 // Hack. Call initCPU() ourself since no one else will.
72 initCPU(true);
73
74 registerService();
75
76 return true;
77 }
78
79 void AppleI386CPU::initCPU(bool /*boot*/)
80 {
81 cpuIC->enableCPUInterrupt(this);
82
83 setCPUState(kIOCPUStateRunning);
84 }
85
86 void AppleI386CPU::quiesceCPU(void)
87 {
88 }
89
90 kern_return_t AppleI386CPU::startCPU(vm_offset_t /*start_paddr*/,
91 vm_offset_t /*arg_paddr*/)
92 {
93 return KERN_FAILURE;
94 }
95
96 void AppleI386CPU::haltCPU(void)
97 {
98 }
99
100 const OSSymbol * AppleI386CPU::getCPUName(void)
101 {
102 return OSSymbol::withCStringNoCopy("Primary0");
103 }
104
105 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
106
107 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
108
109 #undef super
110 #define super IOCPUInterruptController
111
112 OSDefineMetaClassAndStructors(AppleI386CPUInterruptController,
113 IOCPUInterruptController);
114
115 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
116
117 IOReturn AppleI386CPUInterruptController::handleInterrupt(void * /*refCon*/,
118 IOService * /*nub*/,
119 int source)
120 {
121 IOInterruptVector * vector;
122
123 // Override the implementation in IOCPUInterruptController to
124 // dispatch interrupts the old way.
125 //
126 // source argument is ignored, use the first IOCPUInterruptController
127 // in the vector array.
128 //
129 vector = &vectors[0];
130
131 if (!vector->interruptRegistered)
132 return kIOReturnInvalid;
133
134 vector->handler(vector->target,
135 vector->refCon,
136 vector->nub,
137 source);
138
139 return kIOReturnSuccess;
140 }