btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / system / kernel / arch / ppc / arch_system_info.cpp
blob21e5570aec48e1ce50ad279ed8bde6fa9a5b01f6
1 /*
2 * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
6 #include <OS.h>
8 #include <arch_cpu.h>
9 #include <arch/system_info.h>
10 #include <boot/kernel_args.h>
13 enum cpu_vendor sCPUVendor;
14 uint32 sPVR;
16 static uint64 sCPUClockFrequency;
17 static uint64 sBusClockFrequency;
19 struct cpu_model {
20 uint16 version;
21 enum cpu_vendor vendor;
24 // mapping of CPU versions to vendors
25 struct cpu_model kCPUModels[] = {
26 { MPC601, B_CPU_VENDOR_MOTOROLA },
27 { MPC603, B_CPU_VENDOR_MOTOROLA },
28 { MPC604, B_CPU_VENDOR_MOTOROLA },
29 { MPC602, B_CPU_VENDOR_MOTOROLA },
30 { MPC603e, B_CPU_VENDOR_MOTOROLA },
31 { MPC603ev, B_CPU_VENDOR_MOTOROLA },
32 { MPC750, B_CPU_VENDOR_MOTOROLA },
33 { MPC604ev, B_CPU_VENDOR_MOTOROLA },
34 { MPC7400, B_CPU_VENDOR_MOTOROLA },
35 { MPC620, B_CPU_VENDOR_MOTOROLA },
36 { IBM403, B_CPU_VENDOR_IBM },
37 { IBM401A1, B_CPU_VENDOR_IBM },
38 { IBM401B2, B_CPU_VENDOR_IBM },
39 { IBM401C2, B_CPU_VENDOR_IBM },
40 { IBM401D2, B_CPU_VENDOR_IBM },
41 { IBM401E2, B_CPU_VENDOR_IBM },
42 { IBM401F2, B_CPU_VENDOR_IBM },
43 { IBM401G2, B_CPU_VENDOR_IBM },
44 { IBMPOWER3, B_CPU_VENDOR_IBM },
45 { MPC860, B_CPU_VENDOR_MOTOROLA },
46 { MPC8240, B_CPU_VENDOR_MOTOROLA },
47 { IBM405GP, B_CPU_VENDOR_IBM },
48 { IBM405L, B_CPU_VENDOR_IBM },
49 { IBM750FX, B_CPU_VENDOR_IBM },
50 { MPC7450, B_CPU_VENDOR_MOTOROLA },
51 { MPC7455, B_CPU_VENDOR_MOTOROLA },
52 { MPC7457, B_CPU_VENDOR_MOTOROLA },
53 { MPC7447A, B_CPU_VENDOR_MOTOROLA },
54 { MPC7448, B_CPU_VENDOR_MOTOROLA },
55 { MPC7410, B_CPU_VENDOR_MOTOROLA },
56 { MPC8245, B_CPU_VENDOR_MOTOROLA },
57 { 0, B_CPU_VENDOR_UNKNOWN }
61 void
62 arch_fill_topology_node(cpu_topology_node_info* node, int32 cpu)
64 switch (node->type) {
65 case B_TOPOLOGY_ROOT:
66 #if __powerpc64__
67 node->data.root.platform = B_CPU_PPC_64;
68 #else
69 node->data.root.platform = B_CPU_PPC;
70 #endif
71 break;
73 case B_TOPOLOGY_PACKAGE:
74 node->data.package.vendor = sCPUVendor;
75 node->data.package.cache_line_size = CACHE_LINE_SIZE;
76 break;
78 case B_TOPOLOGY_CORE:
79 node->data.core.model = sPVR;
80 node->data.core.default_frequency = sCPUClockFrequency;
81 break;
83 default:
84 break;
89 status_t
90 arch_system_info_init(struct kernel_args *args)
92 int i;
94 sCPUClockFrequency = args->arch_args.cpu_frequency;
95 sBusClockFrequency = args->arch_args.bus_frequency;
97 // The PVR (processor version register) contains processor version and
98 // revision.
99 sPVR = get_pvr();
100 uint16 model = (uint16)(sPVR >> 16);
101 //sCPURevision = (uint16)(pvr & 0xffff);
103 // Populate vendor
104 for (i = 0; kCPUModels[i].vendor != B_CPU_VENDOR_UNKNOWN; i++) {
105 if (model == kCPUModels[i].version) {
106 sCPUVendor = kCPUModels[i].vendor;
107 break;
111 return B_OK;