Port-amiga archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

procfs_machdep hack (LONG)



Hi.
  I noticed that mounting proc filesystem on amiga with -o linux creates
cpuinfo file, but it's empty.

a1200: {7} cat /proc/cpuinfo
a1200: {8}

So I wrote small dirty hack to display Linux/m68k-style cpuinfo.
Unfortunately I didn't know how to compute "Clocking", "BogoMips" and
"Calibration" values, so this hack shows only CPU, MMU and FPU types
(using cputype, mmutype and fputype globals).

I suspect that "Clocking" is (loop-cycles*1024)/delaydivisor.
i.e. when delay loop is 167/1024 us and CPU is 68030:
8*1024/167
Or maybe I'm wrong - I'm no kernel hacker ;).

As I have no access to other machine than my Amiga right now, I couldn't
cross compile kernel and check if this patch works. But I hope that
someone will correct it and commit ;).

--- ./procfs_machdep.c  Sun Nov 14 01:19:27 2004
+++ ./procfs_machdep_new.c        Sun Nov 14 12:25:35 2004
@@ -9,6 +9,7 @@
 #include <sys/vnode.h>
 #include <miscfs/procfs/procfs.h>

+#include <m68k/m68k.h>

 /*
  * Linux-style /proc/cpuinfo.
@@ -18,6 +19,66 @@
 procfs_getcpuinfstr(char *buf, int *len)
 {
        *len = 0;
+       const char *cpu, *mmu, *fpu;

+       switch (cputype) {
+       case CPU_68020:
+               cpu = "68020";
+               break;
+       case CPU_68030:
+               cpu = "68030";
+               break;
+       case CPU_68040:
+               cpu = "68040";
+               break;
+       case CPU_68060:
+               cpu = "68060";
+               break;
+       default:
+               cpu = "680x0";
+       }
+
+       switch (mmutype) {
+       case MMU_68851:
+               mmu = "68851";
+               break;
+       case MMU_68030:
+               mmu = "68030";
+               break;
+       case MMU_68040:
+               mmu = "68040";
+               break;
+       case MMU_68060:
+               mmu = "68060";
+               break;
+       default:
+               mmu = "unknown";
+       }
+
+       switch (fputype) {
+       case FPU_NONE:
+               fpu = "none(soft float)";
+               break;
+       case FPU_68881:
+               fpu = "68881";
+               break;
+       case FPU_68882:
+               fpu = "68882";
+               break;
+       default:
+               fpu = "none";
+       }
+
+       *len = snprintf(buf, sizeof(buf),
+               /* as seen in Linux 2.4.27 */
+               "CPU:\t\t%s\n"
+               "MMU:\t\t%s\n"
+               "FPU:\t\t%s\n",
+               /*
+                * in Linux m68k /proc/cpuinfo there are also "Clocking",
+                * "BogoMips" and "Calibration".
+                */
+               cpu, mmu, fpu);
+
        return 0;
 }



Radek Kujawa



Home | Main Index | Thread Index | Old Index