2 Copyright © 2013, The AROS Development Team. All rights reserved.
5 Desc: GetCPUInfo() - Provides information about installed CPUs
10 #include <aros/debug.h>
12 #include <aros/libcall.h>
13 #include <resources/processor.h>
14 #include <proto/utility.h>
16 #include "processor_intern.h"
17 #include "processor_arch_intern.h"
19 static void ProcessFeaturesTag(struct ARMProcessorInformation
* info
, struct TagItem
* tag
);
21 #include <proto/processor.h>
23 /* See rom/processor/getcpuinfo.c for documentation */
25 AROS_LH1(void, GetCPUInfo
,
26 AROS_LHA(struct TagItem
*, tagList
, A0
),
27 struct ProcessorBase
*, ProcessorBase
, 1, Processor
)
31 struct TagItem
* passedTag
= NULL
;
32 struct ARMProcessorInformation
*processor
= NULL
;
33 struct ARMProcessorInformation
**sysprocs
= ProcessorBase
->Private1
;
34 ULONG selectedprocessor
= 0;
36 D(bug("[processor.ARM] :%s()\n", __PRETTY_FUNCTION__
));
38 /* If processor was not selected, fall back to legacy mode and report on
39 first available processor */
40 selectedprocessor
= (ULONG
)GetTagData(GCIT_SelectedProcessor
, 0, tagList
);
42 /* If selectedprocessor not in line with number of processors, report on
43 first available processor */
44 if (selectedprocessor
>= ProcessorBase
->cpucount
)
45 selectedprocessor
= 0;
47 processor
= sysprocs
[selectedprocessor
];
49 /* Go over each passed tag and fill appropriate data */
50 while ((passedTag
= NextTagItem(&tagList
)) != NULL
)
52 if ((passedTag
->ti_Tag
> GCIT_FeaturesBase
) &&
53 (passedTag
->ti_Tag
<= GCIT_FeaturesLast
))
55 ProcessFeaturesTag(processor
, passedTag
);
59 switch(passedTag
->ti_Tag
)
61 case(GCIT_NumberOfProcessors
):
62 *((ULONG
*)passedTag
->ti_Data
) = ProcessorBase
->cpucount
;
64 case(GCIT_ModelString
):
65 *((CONST_STRPTR
*)passedTag
->ti_Data
) = processor
->BrandString
;
68 *((ULONG
*)passedTag
->ti_Data
) = processor
->Family
;
70 case(GCIT_VectorUnit
):
71 *((ULONG
*)passedTag
->ti_Data
) = processor
->VectorUnit
;
73 case(GCIT_L1CacheSize
):
74 *((ULONG
*)passedTag
->ti_Data
) =
75 (processor
->L1DataCacheSize
+ processor
->L1InstructionCacheSize
);
77 case(GCIT_L1DataCacheSize
):
78 *((ULONG
*)passedTag
->ti_Data
) = processor
->L1DataCacheSize
;
80 case(GCIT_L1InstructionCacheSize
):
81 *((ULONG
*)passedTag
->ti_Data
) = processor
->L1InstructionCacheSize
;
83 case(GCIT_L2CacheSize
):
84 *((ULONG
*)passedTag
->ti_Data
) = processor
->L2CacheSize
;
86 case(GCIT_CacheLineSize
):
87 *((ULONG
*)passedTag
->ti_Data
) = processor
->CacheLineSize
;
89 case(GCIT_Architecture
):
90 *((ULONG
*)passedTag
->ti_Data
) = PROCESSORARCH_ARM
;
92 case(GCIT_Endianness
):
93 if (processor
->Features1
& FEATF_BIGEND
)
94 *((ULONG
*)passedTag
->ti_Data
) = ENDIANNESS_BE
;
96 *((ULONG
*)passedTag
->ti_Data
) = ENDIANNESS_LE
;
98 case(GCIT_ProcessorSpeed
):
99 *((UQUAD
*)passedTag
->ti_Data
) = GetCurrentProcessorFrequency(processor
);
101 case(GCIT_ProcessorLoad
):
102 *((UBYTE
*)passedTag
->ti_Data
) = 0; /* TODO: IMPLEMENT */
105 *((ULONG
*)passedTag
->ti_Data
) = processor
->Vendor
;
114 static void ProcessFeaturesTag(struct ARMProcessorInformation
* info
, struct TagItem
* tag
)
116 D(bug("[processor.ARM] :%s()\n", __PRETTY_FUNCTION__
));
120 case(GCIT_SupportsVFP
):
121 case(GCIT_SupportsFPU
):
122 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_FPU
) >> FEATB_FPU
); break;
123 case(GCIT_SupportsVFPv3
):
124 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_FPU_VFP3
) >> FEATB_FPU_VFP3
); break;
125 case(GCIT_SupportsVFPv3D16
):
126 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_FPU_VFP3_16
) >> FEATB_FPU_VFP3_16
); break;
127 case(GCIT_SupportsNeon
):
128 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_NEON
) >> FEATB_NEON
); break;
129 case(GCIT_SupportsVFPv4
):
130 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_FPU_VFP4
) >> FEATB_FPU_VFP4
); break;
131 case(GCIT_SupportsSecurityExt
):
132 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_SECURE
) >> FEATB_SECURE
); break;
133 case(GCIT_SupportsBranchPred
):
134 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_BRANCHP
) >> FEATB_BRANCHP
); break;
135 case(GCIT_SupportsThumbEE
):
136 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_THUMBEX
) >> FEATB_THUMBEX
); break;
138 *((BOOL
*)tag
->ti_Data
) = FALSE
; break;