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 no processor is specified, query the BP */
39 selectedprocessor
= (ULONG
)GetTagData(GCIT_SelectedProcessor
, 0, tagList
);
41 /* If selectedprocessor not in line with number of processors, report on
42 first available processor */
43 if (selectedprocessor
>= ProcessorBase
->cpucount
)
44 selectedprocessor
= 0;
46 processor
= sysprocs
[selectedprocessor
];
48 /* Go over each passed tag and fill appropriate data */
49 while ((passedTag
= NextTagItem(&tagList
)) != NULL
)
51 if ((passedTag
->ti_Tag
> GCIT_FeaturesBase
) &&
52 (passedTag
->ti_Tag
<= GCIT_FeaturesLast
))
54 ProcessFeaturesTag(processor
, passedTag
);
58 switch(passedTag
->ti_Tag
)
60 case(GCIT_NumberOfProcessors
):
61 *((ULONG
*)passedTag
->ti_Data
) = ProcessorBase
->cpucount
;
63 case(GCIT_ModelString
):
64 *((CONST_STRPTR
*)passedTag
->ti_Data
) = processor
->BrandString
;
67 *((ULONG
*)passedTag
->ti_Data
) = processor
->Family
;
69 case(GCIT_VectorUnit
):
70 *((ULONG
*)passedTag
->ti_Data
) = processor
->VectorUnit
;
72 case(GCIT_L1CacheSize
):
73 *((ULONG
*)passedTag
->ti_Data
) =
74 (processor
->L1DataCacheSize
+ processor
->L1InstructionCacheSize
);
76 case(GCIT_L1DataCacheSize
):
77 *((ULONG
*)passedTag
->ti_Data
) = processor
->L1DataCacheSize
;
79 case(GCIT_L1InstructionCacheSize
):
80 *((ULONG
*)passedTag
->ti_Data
) = processor
->L1InstructionCacheSize
;
82 case(GCIT_L2CacheSize
):
83 *((ULONG
*)passedTag
->ti_Data
) = processor
->L2CacheSize
;
85 case(GCIT_CacheLineSize
):
86 *((ULONG
*)passedTag
->ti_Data
) = processor
->CacheLineSize
;
88 case(GCIT_Architecture
):
89 *((ULONG
*)passedTag
->ti_Data
) = PROCESSORARCH_ARM
;
91 case(GCIT_Endianness
):
92 if (processor
->Features1
& FEATF_BIGEND
)
93 *((ULONG
*)passedTag
->ti_Data
) = ENDIANNESS_BE
;
95 *((ULONG
*)passedTag
->ti_Data
) = ENDIANNESS_LE
;
97 case(GCIT_ProcessorSpeed
):
98 *((UQUAD
*)passedTag
->ti_Data
) = GetCurrentProcessorFrequency(processor
);
100 case(GCIT_ProcessorLoad
):
101 *((UBYTE
*)passedTag
->ti_Data
) = 0; /* TODO: IMPLEMENT */
104 *((ULONG
*)passedTag
->ti_Data
) = processor
->Vendor
;
113 static void ProcessFeaturesTag(struct ARMProcessorInformation
* info
, struct TagItem
* tag
)
115 D(bug("[processor.ARM] :%s()\n", __PRETTY_FUNCTION__
));
119 case(GCIT_SupportsVFP
):
120 case(GCIT_SupportsFPU
):
121 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_FPU
) >> FEATB_FPU
); break;
122 case(GCIT_SupportsVFPv3
):
123 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_FPU_VFP3
) >> FEATB_FPU_VFP3
); break;
124 case(GCIT_SupportsVFPv3D16
):
125 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_FPU_VFP3_16
) >> FEATB_FPU_VFP3_16
); break;
126 case(GCIT_SupportsNeon
):
127 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_NEON
) >> FEATB_NEON
); break;
128 case(GCIT_SupportsVFPv4
):
129 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_FPU_VFP4
) >> FEATB_FPU_VFP4
); break;
130 case(GCIT_SupportsSecurityExt
):
131 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_SECURE
) >> FEATB_SECURE
); break;
132 case(GCIT_SupportsBranchPred
):
133 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_BRANCHP
) >> FEATB_BRANCHP
); break;
134 case(GCIT_SupportsThumbEE
):
135 *((BOOL
*)tag
->ti_Data
) = (BOOL
)((info
->Features1
& FEATF_THUMBEX
) >> FEATB_THUMBEX
); break;
137 *((BOOL
*)tag
->ti_Data
) = FALSE
; break;