Querying for system information from Haiku OS */
| 4966 | |
| 4967 | /** Querying for system information from Haiku OS */ |
| 4968 | bool SystemInformationImplementation::QueryHaikuInfo() |
| 4969 | { |
| 4970 | #if defined(__HAIKU__) |
| 4971 | |
| 4972 | // CPU count |
| 4973 | system_info info; |
| 4974 | get_system_info(&info); |
| 4975 | this->NumberOfPhysicalCPU = info.cpu_count; |
| 4976 | |
| 4977 | // CPU speed |
| 4978 | uint32 topologyNodeCount = 0; |
| 4979 | cpu_topology_node_info* topology = 0; |
| 4980 | get_cpu_topology_info(0, &topologyNodeCount); |
| 4981 | if (topologyNodeCount != 0) |
| 4982 | topology = new cpu_topology_node_info[topologyNodeCount]; |
| 4983 | get_cpu_topology_info(topology, &topologyNodeCount); |
| 4984 | |
| 4985 | for (uint32 i = 0; i < topologyNodeCount; i++) { |
| 4986 | if (topology[i].type == B_TOPOLOGY_CORE) { |
| 4987 | this->CPUSpeedInMHz = |
| 4988 | topology[i].data.core.default_frequency / 1000000.0f; |
| 4989 | break; |
| 4990 | } |
| 4991 | } |
| 4992 | |
| 4993 | delete[] topology; |
| 4994 | |
| 4995 | // Physical Memory |
| 4996 | this->TotalPhysicalMemory = (info.max_pages * B_PAGE_SIZE) / (1024 * 1024); |
| 4997 | this->AvailablePhysicalMemory = this->TotalPhysicalMemory - |
| 4998 | ((info.used_pages * B_PAGE_SIZE) / (1024 * 1024)); |
| 4999 | |
| 5000 | // NOTE: get_system_info_etc is currently a private call so just set to 0 |
| 5001 | // until it becomes public |
| 5002 | this->TotalVirtualMemory = 0; |
| 5003 | this->AvailableVirtualMemory = 0; |
| 5004 | |
| 5005 | // Retrieve cpuid_info union for cpu 0 |
| 5006 | cpuid_info cpu_info; |
| 5007 | get_cpuid(&cpu_info, 0, 0); |
| 5008 | |
| 5009 | // Chip Vendor |
| 5010 | // Use a temporary buffer so that we can add NULL termination to the string |
| 5011 | char vbuf[13]; |
| 5012 | strncpy(vbuf, cpu_info.eax_0.vendor_id, 12); |
| 5013 | vbuf[12] = '\0'; |
| 5014 | this->ChipID.Vendor = vbuf; |
| 5015 | |
| 5016 | this->FindManufacturer(); |
| 5017 | |
| 5018 | // Retrieve cpuid_info union for cpu 0 this time using a register value of 1 |
| 5019 | get_cpuid(&cpu_info, 1, 0); |
| 5020 | |
| 5021 | this->NumberOfLogicalCPU = cpu_info.eax_1.logical_cpus; |
| 5022 | |
| 5023 | // Chip type |
| 5024 | this->ChipID.Type = cpu_info.eax_1.type; |
| 5025 |
no test coverage detected