kernel: Add more architecture code post-scheduler

* Fix incorrect cpu vendor name mapping
* Add additional CPU architectures
* Add additional CPU vendors
* Rework PowerPC arch_system_info passing
  PVR back for cpu model
This commit is contained in:
Alexander von Gluck IV
2014-01-19 21:53:56 -06:00
parent e1720098c6
commit 14919567d1
3 changed files with 82 additions and 56 deletions
+13 -2
View File
@@ -475,7 +475,15 @@ enum topology_level_type {
enum cpu_platform { enum cpu_platform {
B_CPU_UNKNOWN, B_CPU_UNKNOWN,
B_CPU_x86, B_CPU_x86,
B_CPU_x86_64 B_CPU_x86_64,
B_CPU_PPC,
B_CPU_PPC_64,
B_CPU_M68K,
B_CPU_ARM,
B_CPU_ARM_64,
B_CPU_ALPHA,
B_CPU_MIPS,
B_CPU_SH
}; };
enum cpu_vendor { enum cpu_vendor {
@@ -487,7 +495,10 @@ enum cpu_vendor {
B_CPU_VENDOR_NATIONAL_SEMICONDUCTOR, B_CPU_VENDOR_NATIONAL_SEMICONDUCTOR,
B_CPU_VENDOR_RISE, B_CPU_VENDOR_RISE,
B_CPU_VENDOR_TRANSMETA, B_CPU_VENDOR_TRANSMETA,
B_CPU_VENDOR_VIA B_CPU_VENDOR_VIA,
B_CPU_VENDOR_IBM,
B_CPU_VENDOR_MOTOROLA,
B_CPU_VENDOR_NEC
}; };
typedef struct { typedef struct {
+3 -1
View File
@@ -170,8 +170,10 @@ parse_amd(const char* name)
static const char* static const char*
get_cpu_vendor_string(enum cpu_vendor cpuVendor) get_cpu_vendor_string(enum cpu_vendor cpuVendor)
{ {
// Should match vendors in OS.h
static const char* vendorStrings[] = { static const char* vendorStrings[] = {
NULL, "AMD", "Cyrix", "IDT", "Intel", "Rise", "Transmeta", "VIA", NULL, "AMD", "Cyrix", "IDT", "Intel", "National Semiconductor", "Rise",
"Transmeta", "VIA", "IBM", "Motorola", "NEC"
}; };
if ((size_t)cpuVendor >= sizeof(vendorStrings) / sizeof(const char*)) if ((size_t)cpuVendor >= sizeof(vendorStrings) / sizeof(const char*))
+65 -52
View File
@@ -10,65 +10,79 @@
#include <boot/kernel_args.h> #include <boot/kernel_args.h>
enum cpu_vendor sCPUVendor;
uint32 sPVR;
static uint64 sCPUClockFrequency; static uint64 sCPUClockFrequency;
static uint64 sBusClockFrequency; static uint64 sBusClockFrequency;
static enum cpu_types sCPUType;
static uint16 sCPURevision;
struct cpu_model { struct cpu_model {
uint16 version; uint16 version;
enum cpu_types beos_type; enum cpu_vendor vendor;
}; };
// mapping of CPU versions to BeOS enum cpu_types // mapping of CPU versions to vendors
struct cpu_model kCPUModels[] = { struct cpu_model kCPUModels[] = {
{ MPC601, B_CPU_PPC_601 }, { MPC601, B_CPU_VENDOR_MOTOROLA },
{ MPC603, B_CPU_PPC_603 }, { MPC603, B_CPU_VENDOR_MOTOROLA },
{ MPC604, B_CPU_PPC_604 }, { MPC604, B_CPU_VENDOR_MOTOROLA },
{ MPC602, B_CPU_PPC_603ev }, { MPC602, B_CPU_VENDOR_MOTOROLA },
{ MPC603e, B_CPU_PPC_603e }, { MPC603e, B_CPU_VENDOR_MOTOROLA },
{ MPC603ev, B_CPU_PPC_603ev }, { MPC603ev, B_CPU_VENDOR_MOTOROLA },
{ MPC750, B_CPU_PPC_750 }, { MPC750, B_CPU_VENDOR_MOTOROLA },
{ MPC604ev, B_CPU_PPC_604ev }, { MPC604ev, B_CPU_VENDOR_MOTOROLA },
{ MPC7400, B_CPU_PPC_7400 }, { MPC7400, B_CPU_VENDOR_MOTOROLA },
{ MPC620, B_CPU_PPC_620 }, { MPC620, B_CPU_VENDOR_MOTOROLA },
{ IBM403, B_CPU_PPC_IBM_403 }, { IBM403, B_CPU_VENDOR_IBM },
{ IBM401A1, B_CPU_PPC_IBM_401A1 }, { IBM401A1, B_CPU_VENDOR_IBM },
{ IBM401B2, B_CPU_PPC_IBM_401B2 }, { IBM401B2, B_CPU_VENDOR_IBM },
{ IBM401C2, B_CPU_PPC_IBM_401C2 }, { IBM401C2, B_CPU_VENDOR_IBM },
{ IBM401D2, B_CPU_PPC_IBM_401D2 }, { IBM401D2, B_CPU_VENDOR_IBM },
{ IBM401E2, B_CPU_PPC_IBM_401E2 }, { IBM401E2, B_CPU_VENDOR_IBM },
{ IBM401F2, B_CPU_PPC_IBM_401F2 }, { IBM401F2, B_CPU_VENDOR_IBM },
{ IBM401G2, B_CPU_PPC_IBM_401G2 }, { IBM401G2, B_CPU_VENDOR_IBM },
{ IBMPOWER3, B_CPU_PPC_IBM_POWER3 }, { IBMPOWER3, B_CPU_VENDOR_IBM },
{ MPC860, B_CPU_PPC_860 }, { MPC860, B_CPU_VENDOR_MOTOROLA },
{ MPC8240, B_CPU_PPC_8240 }, { MPC8240, B_CPU_VENDOR_MOTOROLA },
{ IBM405GP, B_CPU_PPC_IBM_405GP }, { IBM405GP, B_CPU_VENDOR_IBM },
{ IBM405L, B_CPU_PPC_IBM_405L }, { IBM405L, B_CPU_VENDOR_IBM },
{ IBM750FX, B_CPU_PPC_IBM_750FX }, { IBM750FX, B_CPU_VENDOR_IBM },
{ MPC7450, B_CPU_PPC_7450 }, { MPC7450, B_CPU_VENDOR_MOTOROLA },
{ MPC7455, B_CPU_PPC_7455 }, { MPC7455, B_CPU_VENDOR_MOTOROLA },
{ MPC7457, B_CPU_PPC_7457 }, { MPC7457, B_CPU_VENDOR_MOTOROLA },
{ MPC7447A, B_CPU_PPC_7447A }, { MPC7447A, B_CPU_VENDOR_MOTOROLA },
{ MPC7448, B_CPU_PPC_7448 }, { MPC7448, B_CPU_VENDOR_MOTOROLA },
{ MPC7410, B_CPU_PPC_7410 }, { MPC7410, B_CPU_VENDOR_MOTOROLA },
{ MPC8245, B_CPU_PPC_8245 }, { MPC8245, B_CPU_VENDOR_MOTOROLA },
{ 0, B_CPU_PPC_UNKNOWN } { 0, B_CPU_VENDOR_UNKNOWN }
}; };
status_t void
arch_get_system_info(system_info *info, size_t size) arch_fill_topology_node(cpu_topology_node_info* node, int32 cpu)
{ {
info->cpu_type = sCPUType; switch (node->type) {
info->cpu_revision = sCPURevision; case B_TOPOLOGY_ROOT:
#if __powerpc64__
node->data.root.platform = B_CPU_PPC_64;
#else
node->data.root.platform = B_CPU_PPC;
#endif
break;
info->cpu_clock_speed = sCPUClockFrequency; case B_TOPOLOGY_PACKAGE:
info->bus_clock_speed = sBusClockFrequency; node->data.package.vendor = sCPUVendor;
node->data.package.cache_line_size = CACHE_LINE_SIZE;
break;
info->platform_type = B_MAC_PLATFORM; case B_TOPOLOGY_CORE:
node->data.core.model = sPVR;
node->data.core.default_frequency = sCPUClockFrequency;
break;
return B_OK; default:
break;
}
} }
@@ -82,15 +96,14 @@ arch_system_info_init(struct kernel_args *args)
// The PVR (processor version register) contains processor version and // The PVR (processor version register) contains processor version and
// revision. // revision.
uint32 pvr = get_pvr(); sPVR = get_pvr();
uint16 version = (uint16)(pvr >> 16); uint16 model = (uint16)(sPVR >> 16);
sCPURevision = (uint16)(pvr & 0xffff); //sCPURevision = (uint16)(pvr & 0xffff);
// translate the version to a BeOS cpu_types constant // Populate vendor
sCPUType = B_CPU_PPC_UNKNOWN; for (i = 0; kCPUModels[i].vendor != B_CPU_VENDOR_UNKNOWN; i++) {
for (i = 0; kCPUModels[i].beos_type != B_CPU_PPC_UNKNOWN; i++) { if (model == kCPUModels[i].version) {
if (version == kCPUModels[i].version) { sCPUVendor = kCPUModels[i].vendor;
sCPUType = kCPUModels[i].beos_type;
break; break;
} }
} }