Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/libsaio/platform.c

1/*
2 * platform.c
3 *
4 * AsereBLN: cleanup
5 *
6 *ALL functions and struct. here will be DEPRECATED soon, i prefer Hash. (hmm, i mean hashable structures ... of course)
7 *
8 */
9
10#include "libsaio.h"
11#include "boot.h"
12#include "bootstruct.h"
13#include "pci.h"
14#include "platform.h"
15#include "cpu.h"
16
17#ifndef DEBUG_PLATFORM
18#define DEBUG_PLATFORM 0
19#endif
20
21#if DEBUG_PLATFORM
22#define DBG(x...)printf(x)
23#else
24#define DBG(x...)
25#endif
26
27PlatformInfo_t *Platform;
28
29/** Return if a CPU feature specified by feature is activated (true) or not (false) */
30bool platformCPUFeature(uint32_t feature)
31{
32return (Platform->CPU.Features & feature) ? true : false;
33}
34
35/** Return if a CPU Extended feature specified by feature is activated (true) or not (false) */
36bool platformCPUExtFeature(uint32_t feature)
37{
38return (Platform->CPU.ExtFeatures & feature) ? true : false;
39}
40
41bool platformIsIntel(void)
42{
43return (Platform->CPU.Vendor == 0x756E6547) ? true : false;
44}
45
46uint32_t getCPUnCores(void)
47{
48return Platform->CPU.NoCores;
49}
50
51uint32_t getCPUnThreads(void)
52{
53return Platform->CPU.NoThreads;
54}
55
56uint8_t getCPUModel(void)
57{
58return Platform->CPU.Model;
59}
60
61uint8_t getCPUFamily(void)
62{
63return Platform->CPU.Family;
64}
65
66bool platformIsServer(void)
67{
68return (Platform->CPU.isServer) ? true : false;
69}
70
71bool platformIsMobile(void)
72{
73return (Platform->CPU.isMobile) ? true : false;
74}
75
76/**
77 Scan platform hardware information, called by the main entry point (common_boot() )
78 _before_ bootConfig xml parsing settings are loaded
79*/
80void scan_platform(void)
81{
82Platform = malloc(sizeof(PlatformInfo_t));
83memset(Platform, 0, sizeof(PlatformInfo_t));
84build_pci_dt();
85scan_cpu(Platform);
86}
87

Archive Download this file

Revision: 1825