]>
git.saurik.com Git - apple/xnu.git/blob - pexpert/ppc/pe_identify_machine.c
2 * Copyright (c) 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@
22 #include <pexpert/protos.h>
23 #include <pexpert/pexpert.h>
24 #include <pexpert/ppc/powermac.h>
25 #include <pexpert/device_tree.h>
27 /* External declarations */
29 unsigned int LockTimeOut
= 12500000;
31 /* pe_identify_machine:
33 * Sets up platform parameters.
36 void pe_identify_machine(void)
42 // Clear the gPEClockFrequencyInfo struct
43 bzero((void *)&gPEClockFrequencyInfo
, sizeof(clock_frequency_info_t
));
45 // Start with default values.
46 gPEClockFrequencyInfo
.bus_clock_rate_hz
= 100000000;
47 gPEClockFrequencyInfo
.cpu_clock_rate_hz
= 300000000;
48 gPEClockFrequencyInfo
.dec_clock_rate_hz
= 25000000;
50 // Try to get the values from the device tree.
51 if (DTFindEntry("device_type", "cpu", &cpu
) == kSuccess
) {
52 if (DTGetProperty(cpu
, "bus-frequency",
53 (void **)&value
, &size
) == kSuccess
)
54 gPEClockFrequencyInfo
.bus_clock_rate_hz
= *value
;
56 if (DTLookupEntry(0, "/", &root
) == kSuccess
)
57 if (DTGetProperty(root
, "clock-frequency",
58 (void **)&value
, &size
) == kSuccess
)
59 gPEClockFrequencyInfo
.bus_clock_rate_hz
= *value
;
62 if (DTGetProperty(cpu
, "clock-frequency",
63 (void **)&value
, &size
) == kSuccess
)
64 gPEClockFrequencyInfo
.cpu_clock_rate_hz
= *value
;
66 if (DTGetProperty(cpu
, "timebase-frequency",
67 (void **)&value
, &size
) == kSuccess
)
68 gPEClockFrequencyInfo
.dec_clock_rate_hz
= *value
;
71 // Set the num / den pairs form the hz values.
72 gPEClockFrequencyInfo
.bus_clock_rate_num
= gPEClockFrequencyInfo
.bus_clock_rate_hz
;
73 gPEClockFrequencyInfo
.bus_clock_rate_den
= 1;
75 gPEClockFrequencyInfo
.bus_to_cpu_rate_num
=
76 (2 * gPEClockFrequencyInfo
.cpu_clock_rate_hz
) / gPEClockFrequencyInfo
.bus_clock_rate_hz
;
77 gPEClockFrequencyInfo
.bus_to_cpu_rate_den
= 2;
79 gPEClockFrequencyInfo
.bus_to_dec_rate_num
= 1;
80 gPEClockFrequencyInfo
.bus_to_dec_rate_den
=
81 gPEClockFrequencyInfo
.bus_clock_rate_hz
/ gPEClockFrequencyInfo
.dec_clock_rate_hz
;
84 /* get_io_base_addr():
86 * Get the base address of the io controller.
88 vm_offset_t
get_io_base_addr(void)
94 if ((DTFindEntry("device_type", "dbdma", &entryP
) == kSuccess
)
95 || (DTFindEntry("device_type", "mac-io", &entryP
) == kSuccess
))
97 if (DTGetProperty(entryP
, "AAPL,address", (void **)&address
, &size
) == kSuccess
)
100 if (DTGetProperty(entryP
, "assigned-addresses", (void **)&address
, &size
) == kSuccess
)
101 // address calculation not correct
105 panic("Can't find this machine's io base address\n");
109 boolean_t
PE_init_ethernet_debugger(void)
114 vm_offset_t
*address
;
115 unsigned char *netAddr
;
119 if ((io
= get_io_base_addr())
120 && (DTFindEntry("name", "mace", &entryP
) == kSuccess
)
121 && (DTGetProperty(entryP
, "local-mac-address", (void **)&netAddr
, &size
) == kSuccess
)
122 && (DTGetProperty(entryP
, "reg", (void **)&address
, &size
) == kSuccess
)
123 && (size
== (2 * 3 * sizeof(vm_offset_t
)) ))
125 extern boolean_t
kdp_mace_init(void *baseAddresses
[3],
126 unsigned char *netAddr
);
129 // address calculation not correct
130 maceAddrs
[0] = (void *) io_map(io
+ address
[0], address
[1]);
131 maceAddrs
[1] = (void *) io_map(io
+ address
[2], 0x1000);
132 maceAddrs
[2] = (void *) (((vm_offset_t
)maceAddrs
[1])
133 + address
[4] - address
[2]);
134 result
= kdp_mace_init( maceAddrs
, netAddr
);
143 vm_offset_t
PE_find_scc(void)
148 if ((io
= get_io_base_addr())
149 && (DTFindEntry("name", "escc", &entryP
) == kSuccess
))
150 io
+= 0x12000; /* Offset to legacy SCC Registers */