2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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.
23 * @APPLE_LICENSE_HEADER_END@
30 #include <IOKit/IODeviceTreeSupport.h>
31 #include <IOKit/IORangeAllocator.h>
32 #include <IOKit/nvram/IONVRAMController.h>
34 #include <IOKit/platform/ApplePlatformExpert.h>
37 const OSSymbol
*gGetDefaultBusSpeedsKey
;
39 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
41 #define super IODTPlatformExpert
43 OSDefineMetaClassAndAbstractStructors(ApplePlatformExpert
, IODTPlatformExpert
);
45 OSMetaClassDefineReservedUnused(ApplePlatformExpert
, 0);
46 OSMetaClassDefineReservedUnused(ApplePlatformExpert
, 1);
47 OSMetaClassDefineReservedUnused(ApplePlatformExpert
, 2);
48 OSMetaClassDefineReservedUnused(ApplePlatformExpert
, 3);
50 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
52 bool ApplePlatformExpert::start( IOService
* provider
)
56 gGetDefaultBusSpeedsKey
= OSSymbol::withCString("GetDefaultBusSpeeds");
58 if (provider
->getProperty(gIODTNWInterruptMappingKey
)) {
59 // new world interrupt mapping => new world, for now
60 setBootROMType(kBootROMTypeNewWorld
);
62 setBootROMType(kBootROMTypeOldWorld
);
64 // Get the Rom Minor Version from the 68k ROM.
65 romVersion
= ml_phys_read_64(0xffc00010ULL
) & 0x0000ffff;
66 provider
->setProperty("rom-version", &romVersion
, sizeof(romVersion
));
69 return super::start(provider
);
72 bool ApplePlatformExpert::configure( IOService
* provider
)
74 IORangeAllocator
* physicalRanges
;
76 if((physicalRanges
= getPhysicalRangeAllocator())) {
77 physicalRanges
->allocateRange(0,0x80000000); // RAM
78 physicalRanges
->allocateRange(0xff000000,0x01000000); // ROM
80 return(super::configure(provider
));
83 const char * ApplePlatformExpert::deleteList ( void )
85 return( "('packages', 'psuedo-usb', 'psuedo-hid', 'multiboot', 'rtas')" );
88 const char * ApplePlatformExpert::excludeList( void )
90 return( "('chosen', 'memory', 'openprom', 'AAPL,ROM', 'rom', 'options', 'aliases')");
93 void ApplePlatformExpert::registerNVRAMController( IONVRAMController
* nvram
)
96 enum { kXPRAMTimeToGMTOffset
= 0xEC };
98 super::registerNVRAMController(nvram
);
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
104 err
= readXPRAM(kXPRAMTimeToGMTOffset
, (UInt8
*)&_timeToGMT
,
106 if (err
== kIOReturnSuccess
) {
107 // Convert from a SInt24 - sign extend from bit 23.
108 if (_timeToGMT
& (1 << 23))
109 _timeToGMT
|= 0xFF000000;
111 _timeToGMT
&= 0x00FFFFFF;
115 #define SECS_BETWEEN_1904_1970 2082844800
117 long ApplePlatformExpert::getGMTTimeOfDay(void)
121 // to avid to hang the kernel at boot
122 // I set a limit of 15 seconds waiting
123 // for the real time clock.
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
);
132 IOLog("ApplePlatformExpert::getGMTTimeOfDay can not provide time of day RTC did not show up\n");
137 void ApplePlatformExpert::setGMTTimeOfDay(long secs
)
139 // to avid to hang the kernel at boot
140 // I set a limit of 15 seconds waiting
141 // for the real time clock.
145 if (waitForService(resourceMatching("IORTC"), &t
) != NULL
) {
146 secs
+= SECS_BETWEEN_1904_1970
;
148 PE_read_write_time_of_day(kPEWriteTOD
, &secs
);
151 IOLog("ApplePlatformExpert::setGMTTimeOfDay can not set time of day RTC did not show up\n");
155 bool ApplePlatformExpert::getMachineName(char *name
, int maxLength
)
157 strncpy(name
, "Power Macintosh", maxLength
);