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