typo
[AROS.git] / workbench / tools / ShowConfig / ShowConfig.c
blob0396f1055f5d0bbb1c505e3403d82e74b8ef3e3d
1 #include <aros/kernel.h>
2 #include <exec/execbase.h>
3 #include <exec/memory.h>
4 #include <resources/hpet.h>
5 #include <resources/processor.h>
7 #include <proto/aros.h>
8 #include <proto/hpet.h>
9 #include <proto/kernel.h>
10 #include <proto/exec.h>
11 #include <proto/utility.h>
12 #include <proto/processor.h>
14 #include <stdio.h>
16 #include "cpuspecific.h"
18 APTR ProcessorBase = NULL;
20 ULONG ExtUDivMod32(ULONG a, ULONG b, ULONG *mod)
22 *mod = a % b;
24 return a/b;
27 void PrintNum(ULONG num)
29 /* MBytes ? */
30 if(num > 1023)
32 ULONG x, xx;
33 char* fmt = "meg";
35 /* GBytes ? */
36 if(num > 0xfffff)
38 num >>= 10;
39 fmt = "gig";
42 num = ExtUDivMod32(UMult32(num, 100) >> 10, 100, &x);
44 /* round */
45 x = ExtUDivMod32(x, 10, &xx);
47 if(xx > 4)
49 if(++x > 9)
51 x = 0;
52 num++;
56 printf("%d.%d %s", (int)num, (int)x, fmt);
58 else
60 printf("%d K", (int)num);
64 ULONG ComputeKBytes(APTR a, APTR b)
66 IPTR result = b - a;
68 return (ULONG)(result >> 10);
71 static ULONG GetProcessorsCount()
73 ULONG count = 0;
74 struct TagItem tags [] =
76 {GCIT_NumberOfProcessors, (IPTR)&count},
77 {TAG_DONE, TAG_DONE}
80 GetCPUInfo(tags);
82 return count;
85 struct
87 ULONG Architecture;
88 STRPTR Description;
89 } ProcessorArchitecture [] =
91 { PROCESSORARCH_UNKNOWN, "Unknown" },
92 { PROCESSORARCH_M68K, "Motorola 68K" },
93 { PROCESSORARCH_PPC, "PowerPC" },
94 { PROCESSORARCH_X86, "X86" },
95 { PROCESSORARCH_ARM, "ARM" },
96 { 0, NULL }
99 struct
101 ULONG Endianness;
102 STRPTR Description;
103 } CurrentEndianness [] =
105 { ENDIANNESS_UNKNOWN, "Unknown" },
106 { ENDIANNESS_LE, "LE" },
107 { ENDIANNESS_BE, "BE" },
108 { 0, NULL}
111 static VOID PrintProcessorInformation()
113 ULONG count = GetProcessorsCount();
114 ULONG i, j;
115 CONST_STRPTR modelstring;
116 ULONG architecture, endianness;
117 CONST_STRPTR architecturestring = "", endiannessstring = "";
118 UQUAD cpuspeed;
120 for (i = 0; i < count; i++)
122 struct TagItem tags [] =
124 {GCIT_SelectedProcessor, i},
125 {GCIT_ModelString, (IPTR)&modelstring},
126 {GCIT_Architecture, (IPTR)&architecture},
127 {GCIT_Endianness, (IPTR)&endianness},
128 {GCIT_ProcessorSpeed, (IPTR)&cpuspeed},
129 {TAG_DONE, TAG_DONE}
132 GetCPUInfo(tags);
134 j = 0;
135 while(ProcessorArchitecture[j].Description != NULL)
137 if (ProcessorArchitecture[j].Architecture == architecture)
139 architecturestring = ProcessorArchitecture[j].Description;
140 break;
142 j++;
145 j = 0;
146 while(CurrentEndianness[j].Description != NULL)
148 if (CurrentEndianness[j].Endianness == endianness)
150 endiannessstring = CurrentEndianness[j].Description;
151 break;
153 j++;
156 if (!modelstring)
157 modelstring = "Unknown";
159 printf("PROCESSOR %d:\t[%s/%s] %s", (int)(i + 1), architecturestring, endiannessstring, modelstring);
160 if (cpuspeed)
161 printf(" (%llu MHz)", (unsigned long long)(cpuspeed / 1000000));
162 printf("\n");
164 PrintCPUSpecificInfo(i, ProcessorBase);
168 int __nocommandline;
169 char __stdiowin[]="CON://800/400/ShowConfig/AUTO/CLOSE/WAIT";
171 int main()
173 struct MemHeader *mh;
174 APTR KernelBase;
175 APTR HPETBase;
177 printf("VERS:\t\tAROS version %d.%d, Exec version %d.%d\n", ArosBase->lib_Version, ArosBase->lib_Revision,
178 SysBase->LibNode.lib_Version, SysBase->LibNode.lib_Revision);
180 ProcessorBase = OpenResource(PROCESSORNAME);
181 if (ProcessorBase)
182 PrintProcessorInformation();
184 HPETBase = OpenResource("hpet.resource");
185 if (HPETBase)
187 const char *owner;
188 ULONG i = 0;
190 while (GetUnitAttrs(i, HPET_UNIT_OWNER, &owner, TAG_DONE))
192 if (!owner)
193 owner = "Available for use";
195 printf("HPET %u:\t\t%s\n", (unsigned)(++i), owner);
199 printf("RAM:");
200 for (mh = (struct MemHeader *)SysBase->MemList.lh_Head; mh->mh_Node.ln_Succ; mh = (struct MemHeader *)mh->mh_Node.ln_Succ) {
201 char *memtype = "ROM";
203 if (mh->mh_Attributes & MEMF_CHIP)
204 memtype = "CHIP";
205 if (mh->mh_Attributes & MEMF_FAST)
206 memtype = "FAST";
207 printf("\t\tNode Type 0x%X, Attributes 0x%X (%s), at $%p-$%p (", mh->mh_Node.ln_Type, mh->mh_Attributes, memtype, mh->mh_Lower, mh->mh_Upper - 1);
208 PrintNum(ComputeKBytes(mh->mh_Lower, mh->mh_Upper));
209 printf(")\n");
212 KernelBase = OpenResource("kernel.resource");
213 if (KernelBase)
215 struct TagItem *bootinfo = KrnGetBootInfo();
216 struct TagItem *tag;
218 tag = FindTagItem(KRN_BootLoader, bootinfo);
219 if (tag)
220 printf("BOOTLDR:\t%s\n", (char *)tag->ti_Data);
222 tag = FindTagItem(KRN_CmdLine, bootinfo);
223 if (tag)
224 printf("ARGS:\t\t%s\n", (char *)tag->ti_Data);
227 return 0;