2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
35 #include <IOKit/IODeviceTreeSupport.h>
36 #include <IOKit/IORangeAllocator.h>
37 #include <IOKit/nvram/IONVRAMController.h>
39 #include <IOKit/platform/ApplePlatformExpert.h>
42 const OSSymbol
*gGetDefaultBusSpeedsKey
;
44 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
46 #define super IODTPlatformExpert
48 OSDefineMetaClassAndAbstractStructors(ApplePlatformExpert
, IODTPlatformExpert
);
50 OSMetaClassDefineReservedUnused(ApplePlatformExpert
, 0);
51 OSMetaClassDefineReservedUnused(ApplePlatformExpert
, 1);
52 OSMetaClassDefineReservedUnused(ApplePlatformExpert
, 2);
53 OSMetaClassDefineReservedUnused(ApplePlatformExpert
, 3);
55 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
57 bool ApplePlatformExpert::start( IOService
* provider
)
61 gGetDefaultBusSpeedsKey
= OSSymbol::withCString("GetDefaultBusSpeeds");
63 if (provider
->getProperty(gIODTNWInterruptMappingKey
)) {
64 // new world interrupt mapping => new world, for now
65 setBootROMType(kBootROMTypeNewWorld
);
67 setBootROMType(kBootROMTypeOldWorld
);
69 // Get the Rom Minor Version from the 68k ROM.
70 romVersion
= ml_phys_read_64(0xffc00010ULL
) & 0x0000ffff;
71 provider
->setProperty("rom-version", &romVersion
, sizeof(romVersion
));
74 return super::start(provider
);
77 bool ApplePlatformExpert::configure( IOService
* provider
)
79 IORangeAllocator
* physicalRanges
;
81 if((physicalRanges
= getPhysicalRangeAllocator())) {
82 physicalRanges
->allocateRange(0,0x80000000); // RAM
83 physicalRanges
->allocateRange(0xff000000,0x01000000); // ROM
85 return(super::configure(provider
));
88 const char * ApplePlatformExpert::deleteList ( void )
90 return( "('packages', 'psuedo-usb', 'psuedo-hid', 'multiboot', 'rtas')" );
93 const char * ApplePlatformExpert::excludeList( void )
95 return( "('chosen', 'memory', 'openprom', 'AAPL,ROM', 'rom', 'options', 'aliases')");
98 void ApplePlatformExpert::registerNVRAMController( IONVRAMController
* nvram
)
101 enum { kXPRAMTimeToGMTOffset
= 0xEC };
103 super::registerNVRAMController(nvram
);
105 // Here we are saving off the time zone info that's in PRAM.
106 // This probably should be a separate call that the
107 // ApplePlatformExpert does in it's initialization. -ECH
109 err
= readXPRAM(kXPRAMTimeToGMTOffset
, (UInt8
*)&_timeToGMT
,
111 if (err
== kIOReturnSuccess
) {
112 // Convert from a SInt24 - sign extend from bit 23.
113 if (_timeToGMT
& (1 << 23))
114 _timeToGMT
|= 0xFF000000;
116 _timeToGMT
&= 0x00FFFFFF;
120 #define SECS_BETWEEN_1904_1970 2082844800
122 long ApplePlatformExpert::getGMTTimeOfDay(void)
126 // to avid to hang the kernel at boot
127 // I set a limit of 15 seconds waiting
128 // for the real time clock.
132 if (waitForService(resourceMatching("IORTC"), &t
) != NULL
) {
133 if (PE_read_write_time_of_day(kPEReadTOD
, &localtime
) == 0)
134 return (localtime
- _timeToGMT
- SECS_BETWEEN_1904_1970
);
137 IOLog("ApplePlatformExpert::getGMTTimeOfDay can not provide time of day RTC did not show up\n");
142 void ApplePlatformExpert::setGMTTimeOfDay(long secs
)
144 // to avid to hang the kernel at boot
145 // I set a limit of 15 seconds waiting
146 // for the real time clock.
150 if (waitForService(resourceMatching("IORTC"), &t
) != NULL
) {
151 secs
+= SECS_BETWEEN_1904_1970
;
153 PE_read_write_time_of_day(kPEWriteTOD
, &secs
);
156 IOLog("ApplePlatformExpert::setGMTTimeOfDay can not set time of day RTC did not show up\n");
160 bool ApplePlatformExpert::getMachineName(char *name
, int maxLength
)
162 strncpy(name
, "Power Macintosh", maxLength
);