]> git.saurik.com Git - apple/xnu.git/blame - iokit/Drivers/platform/drvApplePlatformExpert/ApplePlatformExpert.cpp
xnu-344.49.tar.gz
[apple/xnu.git] / iokit / Drivers / platform / drvApplePlatformExpert / ApplePlatformExpert.cpp
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
43866e37 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
43866e37
A
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
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
43866e37
A
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.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*
26 * HISTORY
27 *
28 */
29
30#include <IOKit/IODeviceTreeSupport.h>
31#include <IOKit/IORangeAllocator.h>
32#include <IOKit/nvram/IONVRAMController.h>
33
34#include <IOKit/platform/ApplePlatformExpert.h>
35
36
37const OSSymbol *gGetDefaultBusSpeedsKey;
38
39/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
40
41#define super IODTPlatformExpert
42
43OSDefineMetaClassAndAbstractStructors(ApplePlatformExpert, IODTPlatformExpert);
44
45OSMetaClassDefineReservedUnused(ApplePlatformExpert, 0);
46OSMetaClassDefineReservedUnused(ApplePlatformExpert, 1);
47OSMetaClassDefineReservedUnused(ApplePlatformExpert, 2);
48OSMetaClassDefineReservedUnused(ApplePlatformExpert, 3);
49
50/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
51
52bool ApplePlatformExpert::start( IOService * provider )
53{
54 UInt16 romVersion;
55
56 gGetDefaultBusSpeedsKey = OSSymbol::withCString("GetDefaultBusSpeeds");
57
58 if (provider->getProperty(gIODTNWInterruptMappingKey)) {
59 // new world interrupt mapping => new world, for now
60 setBootROMType(kBootROMTypeNewWorld);
61 } else {
62 setBootROMType(kBootROMTypeOldWorld);
63
64 // Get the Rom Minor Version from the 68k ROM.
de355530 65 romVersion = ml_phys_read(0xffc00010) & 0x0000ffff;
1c79356b
A
66 provider->setProperty("rom-version", &romVersion, sizeof(romVersion));
67 }
68
69 return super::start(provider);
70}
71
72bool ApplePlatformExpert::configure( IOService * provider )
73{
74 IORangeAllocator * physicalRanges;
75
76 if((physicalRanges = getPhysicalRangeAllocator())) {
77 physicalRanges->allocateRange(0,0x80000000); // RAM
78 physicalRanges->allocateRange(0xff000000,0x01000000); // ROM
79 }
80 return(super::configure(provider));
81}
82
83const char * ApplePlatformExpert::deleteList ( void )
84{
85 return( "('packages', 'psuedo-usb', 'psuedo-hid', 'multiboot', 'rtas')" );
86}
87
88const char * ApplePlatformExpert::excludeList( void )
89{
90 return( "('chosen', 'memory', 'openprom', 'AAPL,ROM', 'rom', 'options', 'aliases')");
91}
92
93void ApplePlatformExpert::registerNVRAMController( IONVRAMController * nvram )
94{
95 IOReturn err;
96 enum { kXPRAMTimeToGMTOffset = 0xEC };
97
98 super::registerNVRAMController(nvram);
99
100 // Here we are saving off the time zone info that's in PRAM.
101 // This probably should be a separate call that the
102 // ApplePlatformExpert does in it's initialization. -ECH
103
104 err = readXPRAM(kXPRAMTimeToGMTOffset, (UInt8 *)&_timeToGMT,
105 sizeof(_timeToGMT));
106 if (err == kIOReturnSuccess) {
107 // Convert from a SInt24 - sign extend from bit 23.
108 if (_timeToGMT & (1 << 23))
109 _timeToGMT |= 0xFF000000;
110 else
111 _timeToGMT &= 0x00FFFFFF;
112 }
113}
114
115#define SECS_BETWEEN_1904_1970 2082844800
116
117long ApplePlatformExpert::getGMTTimeOfDay(void)
118{
119 long localtime;
120
121 // to avid to hang the kernel at boot
122 // I set a limit of 15 seconds waiting
123 // for the real time clock.
124 mach_timespec_t t;
125 t.tv_sec = 30;
126 t.tv_nsec = 0;
127 if (waitForService(resourceMatching("IORTC"), &t ) != NULL) {
128 if (PE_read_write_time_of_day(kPEReadTOD, &localtime) == 0)
129 return (localtime - _timeToGMT - SECS_BETWEEN_1904_1970);
130 }
131 else
132 IOLog("ApplePlatformExpert::getGMTTimeOfDay can not provide time of day RTC did not show up\n");
133
134 return(0);
135}
136
137void ApplePlatformExpert::setGMTTimeOfDay(long secs)
138{
139 // to avid to hang the kernel at boot
140 // I set a limit of 15 seconds waiting
141 // for the real time clock.
142 mach_timespec_t t;
143 t.tv_sec = 30;
144 t.tv_nsec = 0;
145 if (waitForService(resourceMatching("IORTC"), &t ) != NULL) {
146 secs += SECS_BETWEEN_1904_1970;
147 secs += _timeToGMT;
148 PE_read_write_time_of_day(kPEWriteTOD, &secs);
149 }
150 else
151 IOLog("ApplePlatformExpert::setGMTTimeOfDay can not set time of day RTC did not show up\n");
152
153}
154
155bool ApplePlatformExpert::getMachineName(char *name, int maxLength)
156{
157 strncpy(name, "Power Macintosh", maxLength);
158
159 return true;
160}