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