New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CPU Information class #545
Comments
There's already an implementation for CPU Information: https://github.com/CosmosOS/Cosmos/blob/master/source/Cosmos.Core/ProcessorInformation.cs |
Yes but it is exposed at the user level? That is there is something usable from System that does "proxy" of the class in HAL? |
You're right, we need a "proxy" class to let the user level access that informations, a CPU Information class in Cosmos.System would be important. |
The class ProcessorInformation could be augmented for example adding the processor frequency, the bogomips, the number of cores, if SSE / AVX is supported and so on... |
This problem will solve by using Smbios. |
I'm working on it (i don't know if i will be able to do all, though). Currently i have parsed the SMBIOS Entry Point Table. |
But we want information on the CPU not on the rest of the machine, do you have familiarity with /proc/cpuinfo or the windows application CPUZ? I think the first pass would be to create a class in system that does as "proxy" for ProcessorInformation... This is what cpuinfo returns on Linux:
we can start "little" for now the things really useful are vendor_id, model name and flags (you will need to know if the CPU supports SSE / AVX or not in future to do CPU dispatching). |
The proxy classes, as I understand the problem, only will act as a facade of the processor information class (only need 2 classes, one in Cosmos.System and another in Cosmos.HAL to make the ring system happy). They are already almost implemented (well, they only have the GetVendorName of the ProcessorInformation class but the idea is there). This clases are called CPUHALInfo and CPUInfo (bad name, should change it later) I know the file /proc/cpuinfo but the matter is that the approach used currently to get the vendor name is just raw x86 (i will be sincere: i don't have any idea how it works since my knoledge of x86 is very limited) and thus, dependant on the architecture. In fact, the function GetVendorName doesn't work in my machine (i call it and i receive nothing as a response but probably is my fault). The SMBIOS approach uses just a bunch of tables in memory to store information regarding BIOS, System, Processor, Memory... However, the parsing is a bit difficult: some information strings are stored just after a formatted table (i.e, a table with predefined size) so accessing a specific table is a bit complicated. Besides, the tables must not be in any specific order (or, at least, i found nothing in the dmtf specification) but i suspect that the bios table (type 0) is always first (as i found in my tests). Almost all the fields in the SMBIOS table are present in /proc/cpuinfo (i think even the flags in the SMBIOS "Processor ID field") As far the implementation is concerned, you must parse the Entry Point Table so as to find the pointer to the list of tables (and, thus, find the CPU table). You can check the current state of the implementation in my fork (branch cpuinfo): https://github.com/ERamaM/Cosmos (i know it needs big refactoring). I think the entry point table is well parsed but the first bios table (i assume it is always first, for now) it's not since the pointer is displaced ~8 bytes further (but i think the table is well parsed until the ROMSize, since it report 64K in vmware and 128K in BOCHS, reasonable numbers). I used the dmtf specification for this: https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.1.1.pdf (the juicy points are 5, 6 and 7). I wil try to continue implementing soon. |
The fact that the code written in Core is x86 only (is probably calling the assembler CPUID instruction) is not a problem and well actually is normal as is there where specific architecture code should be written... when we do ARM there will be another "Core" in which specific code will be for ARM and in case of the ProcessorInformation Class whatever is needed for ARM to get this information.
You find some guidance on rings here: https://github.com/CosmosOS/Cosmos/blob/master/Docs/Kernel/Levels.md This said please note that SMBIOS is x86 only too (that is it will not work on ARM for example) but if it permits to have a totally managed solution it will be better in any case... it has the plus that it we could have other informations on the system too! |
In https://www.dmtf.org/standards/smbios it has this:
|
So it seems a sort of universal solution! We could expect a RasperryPI or a "random" smart phone to have this then.... |
Work on this has been started in pull request #573. A fair lot of it still needs to be done but 10/13 things still need doing. Documentation on implementation and links on this is included in the discussion. |
I think would be better to re-start less ambitiously this time, without being put "out of road" by SMBIOS, the first objective is to read CPUInfo in the really reliable way this works: using ASM to read the values directly from the CPU. After this is done and is surface in a proper system class we could the rest. We will need CPUInfo if we want to do something similar to Net Core 2.1 CPU Intrisics in Cosmos. |
PR merged to master. Closing |
A class that give information regarding the CPU used similarly to Linux /proc/cpuinfo (but without "strange" virtual filesystems).
The text was updated successfully, but these errors were encountered: