2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
27 #include <IOKit/IODeviceTreeSupport.h>
28 #include <IOKit/IORangeAllocator.h>
29 #include <IOKit/nvram/IONVRAMController.h>
31 #include <IOKit/platform/ApplePlatformExpert.h>
34 const OSSymbol
*gGetDefaultBusSpeedsKey
;
36 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
38 #define super IODTPlatformExpert
40 OSDefineMetaClassAndAbstractStructors(ApplePlatformExpert
, IODTPlatformExpert
);
42 OSMetaClassDefineReservedUnused(ApplePlatformExpert
, 0);
43 OSMetaClassDefineReservedUnused(ApplePlatformExpert
, 1);
44 OSMetaClassDefineReservedUnused(ApplePlatformExpert
, 2);
45 OSMetaClassDefineReservedUnused(ApplePlatformExpert
, 3);
47 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
49 bool ApplePlatformExpert::start( IOService
* provider
)
53 gGetDefaultBusSpeedsKey
= OSSymbol::withCString("GetDefaultBusSpeeds");
55 if (provider
->getProperty(gIODTNWInterruptMappingKey
)) {
56 // new world interrupt mapping => new world, for now
57 setBootROMType(kBootROMTypeNewWorld
);
59 setBootROMType(kBootROMTypeOldWorld
);
61 // Get the Rom Minor Version from the 68k ROM.
62 romVersion
= ml_phys_read(0xffc00010) & 0x0000ffff;
63 provider
->setProperty("rom-version", &romVersion
, sizeof(romVersion
));
66 return super::start(provider
);
69 bool ApplePlatformExpert::configure( IOService
* provider
)
71 IORangeAllocator
* physicalRanges
;
73 if((physicalRanges
= getPhysicalRangeAllocator())) {
74 physicalRanges
->allocateRange(0,0x80000000); // RAM
75 physicalRanges
->allocateRange(0xff000000,0x01000000); // ROM
77 return(super::configure(provider
));
80 const char * ApplePlatformExpert::deleteList ( void )
82 return( "('packages', 'psuedo-usb', 'psuedo-hid', 'multiboot', 'rtas')" );
85 const char * ApplePlatformExpert::excludeList( void )
87 return( "('chosen', 'memory', 'openprom', 'AAPL,ROM', 'rom', 'options', 'aliases')");
90 void ApplePlatformExpert::registerNVRAMController( IONVRAMController
* nvram
)
93 enum { kXPRAMTimeToGMTOffset
= 0xEC };
95 super::registerNVRAMController(nvram
);
97 // Here we are saving off the time zone info that's in PRAM.
98 // This probably should be a separate call that the
99 // ApplePlatformExpert does in it's initialization. -ECH
101 err
= readXPRAM(kXPRAMTimeToGMTOffset
, (UInt8
*)&_timeToGMT
,
103 if (err
== kIOReturnSuccess
) {
104 // Convert from a SInt24 - sign extend from bit 23.
105 if (_timeToGMT
& (1 << 23))
106 _timeToGMT
|= 0xFF000000;
108 _timeToGMT
&= 0x00FFFFFF;
112 #define SECS_BETWEEN_1904_1970 2082844800
114 long ApplePlatformExpert::getGMTTimeOfDay(void)
118 // to avid to hang the kernel at boot
119 // I set a limit of 15 seconds waiting
120 // for the real time clock.
124 if (waitForService(resourceMatching("IORTC"), &t
) != NULL
) {
125 if (PE_read_write_time_of_day(kPEReadTOD
, &localtime
) == 0)
126 return (localtime
- _timeToGMT
- SECS_BETWEEN_1904_1970
);
129 IOLog("ApplePlatformExpert::getGMTTimeOfDay can not provide time of day RTC did not show up\n");
134 void ApplePlatformExpert::setGMTTimeOfDay(long secs
)
136 // to avid to hang the kernel at boot
137 // I set a limit of 15 seconds waiting
138 // for the real time clock.
142 if (waitForService(resourceMatching("IORTC"), &t
) != NULL
) {
143 secs
+= SECS_BETWEEN_1904_1970
;
145 PE_read_write_time_of_day(kPEWriteTOD
, &secs
);
148 IOLog("ApplePlatformExpert::setGMTTimeOfDay can not set time of day RTC did not show up\n");
152 bool ApplePlatformExpert::getMachineName(char *name
, int maxLength
)
154 strncpy(name
, "Power Macintosh", maxLength
);