Chameleon

Chameleon Svn Source Tree

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

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

Archive Download this file

Revision: 1815