Fix IO memory access .. SB128 driver makes noises in VMWare - CMI is untested (Curren...
[AROS.git] / workbench / tools / ShowConfig.c
blob5e0c75890f0bdba051abf97ec39807e05d79e6c2
1 #include <aros/bootloader.h>
2 #include <exec/execbase.h>
3 #include <exec/memory.h>
4 #include <proto/aros.h>
5 #include <proto/bootloader.h>
6 #include <proto/exec.h>
7 #include <proto/utility.h>
8 #include <proto/processor.h>
9 #include <resources/processor.h>
11 #include <stdio.h>
13 APTR ProcessorBase = NULL;
15 ULONG ExtUDivMod32(ULONG a, ULONG b, ULONG *mod)
17 *mod = a % b;
19 return a/b;
22 void PrintNum(ULONG num)
24 /* MBytes ? */
25 if(num > 1023)
27 ULONG x, xx;
28 char* fmt = "meg";
30 /* GBytes ? */
31 if(num > 0xfffff)
33 num >>= 10;
34 fmt = "gig";
37 num = ExtUDivMod32(UMult32(num, 100) >> 10, 100, &x);
39 /* round */
40 x = ExtUDivMod32(x, 10, &xx);
42 if(xx > 4)
44 if(++x > 9)
46 x = 0;
47 num++;
51 printf("%d.%d %s", (int)num, (int)x, fmt);
53 else
55 printf("%d K", (int)num);
59 ULONG ComputeKBytes(APTR a, APTR b)
61 IPTR result = b - a;
63 return (ULONG)(result >> 10);
66 static ULONG GetProcessorsCount()
68 ULONG count = 0;
69 struct TagItem tags [] =
71 {GCIT_NumberOfProcessors, (IPTR)&count},
72 {TAG_DONE, TAG_DONE}
75 GetCPUInfo(tags);
77 return count;
80 struct
82 ULONG Architecture;
83 STRPTR Description;
84 } ProcessorArchitecture [] =
86 { PROCESSORARCH_UNKNOWN, "Unknown" },
87 { PROCESSORARCH_M68K, "Motorola 68K" },
88 { PROCESSORARCH_PPC, "PowerPC" },
89 { PROCESSORARCH_X86, "X86" },
90 { PROCESSORARCH_ARM, "ARM" },
91 { 0, NULL }
94 struct
96 ULONG Endianness;
97 STRPTR Description;
98 } CurrentEndianness [] =
100 { ENDIANNESS_UNKNOWN, "Unknown" },
101 { ENDIANNESS_LE, "LE" },
102 { ENDIANNESS_BE, "BE" },
103 { 0, NULL}
106 static VOID PrintProcessorInformation()
108 ULONG count = GetProcessorsCount();
109 ULONG i, j;
110 CONST_STRPTR modelstring;
111 ULONG architecture, endianness;
112 CONST_STRPTR architecturestring = "", endiannessstring = "";
113 UQUAD cpuspeed;
115 for (i = 0; i < count; i++)
117 struct TagItem tags [] =
119 {GCIT_SelectedProcessor, i},
120 {GCIT_ModelString, (IPTR)&modelstring},
121 {GCIT_Architecture, (IPTR)&architecture},
122 {GCIT_Endianness, (IPTR)&endianness},
123 {GCIT_ProcessorSpeed, (IPTR)&cpuspeed},
124 {TAG_DONE, TAG_DONE}
127 GetCPUInfo(tags);
129 j = 0;
130 while(ProcessorArchitecture[j].Description != NULL)
132 if (ProcessorArchitecture[j].Architecture == architecture)
134 architecturestring = ProcessorArchitecture[j].Description;
135 break;
137 j++;
140 j = 0;
141 while(CurrentEndianness[j].Description != NULL)
143 if (CurrentEndianness[j].Endianness == endianness)
145 endiannessstring = CurrentEndianness[j].Description;
146 break;
148 j++;
152 printf("PROCESSOR %d:\t[%s/%s] %s", (int)(i + 1), architecturestring, endiannessstring, modelstring);
153 if (cpuspeed)
154 printf(" (%llu Mhz)", (unsigned long long)(cpuspeed / 1000000));
155 printf("\n");
159 int __nocommandline;
160 char __stdiowin[]="CON://800/400/ShowConfig/AUTO/CLOSE/WAIT";
162 int main()
164 struct MemHeader *mh;
165 APTR BootLoaderBase;
166 STRPTR bootldr;
167 struct List *args;
168 struct Node *n;
170 ProcessorBase = OpenResource(PROCESSORNAME);
171 if (ProcessorBase)
172 PrintProcessorInformation();
174 printf("VERS:\t\tAROS version %d.%d, Exec version %d.%d\n", ArosBase->lib_Version, ArosBase->lib_Revision,
175 SysBase->LibNode.lib_Version, SysBase->LibNode.lib_Revision);
177 printf("RAM:");
178 for (mh = (struct MemHeader *)SysBase->MemList.lh_Head; mh->mh_Node.ln_Succ; mh = (struct MemHeader *)mh->mh_Node.ln_Succ) {
179 char *memtype = "ROM";
181 if (mh->mh_Attributes & MEMF_CHIP)
182 memtype = "CHIP";
183 if (mh->mh_Attributes & MEMF_FAST)
184 memtype = "FAST";
185 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);
186 PrintNum(ComputeKBytes(mh->mh_Lower, mh->mh_Upper));
187 printf(")\n");
190 BootLoaderBase = OpenResource("bootloader.resource");
191 if (BootLoaderBase) {
192 bootldr = GetBootInfo(BL_LoaderName);
194 if (bootldr)
195 printf("BOOTLDR:\t%s\n", bootldr);
197 args = GetBootInfo(BL_Args);
198 if (args) {
199 printf("ARGS:\t\t");
200 for (n = args->lh_Head; n->ln_Succ; n = n->ln_Succ) {
201 printf("%s ", n->ln_Name);
203 printf("\n");
206 return 0;