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

Re: [MiNT] [PATCH][MiNTlib] Add ColdFire information to sysinfo



2016-02-04 11:01 GMT+01:00 Alan Hourihane <alanh@fairlite.co.uk>:
> Hi David,
>
> That 'case -1' doesn't look right. Shouldn't it be 'case 0xFFFF' ?
>

Yes you're right. Attached there is a corrected new version, also the
typo reported by Miro.

Thanks for reviewing



> Alan.
>
> On 04/02/16 09:42, David Gálvez wrote:
>> Attached version 3 of this patch.
>>
>> Commit message:
>>
>> Add ColdFIre systems information to sysinfo function
>>
>> Contributed by David Galvez
>>
>> 2016-01-27 14:01 GMT+01:00 David Gálvez <dgalvez75@gmail.com>:
>>> Attached is the new version of the patch with some corrections to
>>> comments describing the _MCF cookie.
>>>
>>> Please commit this patch instead.
>>>
>>> Sorry
>>>
>>> 2016-01-26 17:41 GMT+01:00 David Gálvez <dgalvez75@gmail.com>:
>>>> Please apply this patch to mintlib. Thanks!
>>>>
>>>>
>>>> Commit message:
>>>>
>>>> Add ColdFIre systems information to sysinfo function
>>>>
>>>> Contributed by David Galvez
>
>
>
Index: include/mint/cookie.h
===================================================================
RCS file: /mint/mintlib/include/mint/cookie.h,v
retrieving revision 1.8
diff -u -8 -r1.8 cookie.h
--- include/mint/cookie.h	28 Dec 2015 18:51:27 -0000	1.8
+++ include/mint/cookie.h	4 Feb 2016 10:43:27 -0000
@@ -525,27 +525,29 @@
 #define C_XSSI 0x58535349L     /* Extended Screen Saver Information */
 #define C_XTOS 0x58544F53L     /* Extend TOS */
 #define C_xUFC 0x78554643L     /* Extended Universal Font Selector Configuration Program */
 #define C_XWin 0x5857696EL     /* Extended Windows moudle */
 #define C_zCAC 0x7A434143L     /* 680x0 Cache Control CPX */
 #define C_zDCF 0x7A444346L     /* DCF-Time receiver */
 #define C__AFM 0x5F41464DL     /* Audio Fun Machine */
 #define C__AKP 0x5F414B50L     /* Keyboard/Language Configuration */
+#define C__CF_ 0x5F43465FL     /* ColdFire CPU */
 #define C__CPU 0x5F435055L     /* Central Processor Unit Type */
 #define C__DOS 0x5F444F53L     /* GEMDOS-Einsprung (im GEMDOS 0.30) */
 #define C__FDC 0x5F464443L     /* Disk Drive Type */
 #define C__FLK 0x5F464C4BL     /* File Locking Extension */
 #define C__FPU 0x5F465055L     /* Floating Point Unit Type */
 #define C__FRB 0x5F465242L     /* Fast Ram Buffer */
 #define C__FSR 0x5F465352L     /* Patch program for serial (TOS 4.00->4.04) */
 #define C__IDT 0x5F494454L     /* International Date/Time Format */
 #define C__INF 0x5F494E46L     /* STEFIX Program */
 #define C__ISO 0x5F49534FL     /* specifies the real keyboard/font nationality  */
 #define C__JPD 0x5F4A5044L     /* Falcon030 JPEG Decoder by Brainstorm */
+#define C__MCF 0x5F4D4346      /* ColdFire features */
 #define C__MCH 0x5F4D4348L     /* Machine Type */
 #define C__MET 0x5F4D4554L     /* MetaDOS */
 #define C__MIL 0x5F4D494CL     /* Milan computer */
 #define C__NET 0x5F4E4554L     /* GEMDOS Network Support */
 #define C__OOL 0x5F4F4F4CL     /* Pool Fix */
 #define C__PCI 0x5F504349L     /* PCIbios */
 #define C__PKT 0x5F504B54L     /* Paket Driver Cookie */
 #define C__PWR 0x5F505752L     /* Power Management unit */
@@ -556,15 +558,79 @@
 #define C__T30 0x5F543330L     /* KAOS TOS */
 #define C__VDI 0x5F564449L     /* Milan VDI */
 #define C__VDO 0x5F56444FL     /* Video Type */
 #define C___NF 0x5F5F4E46L     /* Native features proposal */
 #define C__FSC 0x5F465343L     /* Falcon Screen */
 
 #define C_MACCEL 0x00AA006EL		/* MACCELL */
 
+/* Structures pointed by some cookie's value */
+
+/*
+ *  Structure pointed by the '_MCF' cookie's value
+ *
+ *  Values defined below taken from ColdFire Family Programmer's Reference
+ *  Manual (CFPRM). Section 1.10 Hardware Configuration Information.
+ *
+ *  The struct's member "device_name" is the "device identification number" as
+ *  specified in the different families reference manuals, in sections describing
+ *  the registers SDID, CIR, DEVICEID or JTAGID (depending on the CF family).
+ *  For example: MCF5474, MCF5485, MCF54455, etc ...
+ */
+
+/* ColdFire core version */
+#define MCF_V1  1
+#define MCF_V2  2
+#define MCF_V3  3
+#define MCF_V4  4
+#define MCF_V5  5
+
+/* Instruction-Set Architecture (ISA) revision level */
+#define MCF_ISA_A       0
+#define MCF_ISA_B       1
+#define MCF_ISA_C       2
+#define MCF_ISA_A_PLUS  8
+
+/* Debug module revision number */
+#define MCF_DEBUG_A             0
+#define MCF_DEBUG_B             1
+#define MCF_DEBUG_C             2
+#define MCF_DEBUG_D             3
+#define MCF_DEBUG_E             4
+#define MCF_DEBUG_B_PLUS        9
+#define MCF_DEBUG_D_PLUS        11
+#define MCF_DEBUG_D_PLUS_PST    15
+
+/* Bit mask for units, set when present */
+#define MCF_UNITS_MAC           1
+#define MCF_UNITS_DIV           2
+#define MCF_UNITS_EMAC          4
+#define MCF_UNITS_FPU           8
+#define MCF_UNITS_MMU           16
+
+/*
+ * To use with the struct members: version, core,
+ * revision, isa, debug and sysbus_frequency
+ * In the bitmask set to 0 when unknown.
+ */
+#define MCF_VALUE_UNKNOWN     -1
+
+typedef struct {
+    char magic[3];            /* Magic number 0x4d4346 (MCF), identifies this struct */
+#define COOKIE_MCF_VERSION    1
+    unsigned char version;   /* This struct version */
+    char device_name[16];     /* Device identification number, null terminated */
+    char core;                /* ColdFire core version number */
+    char revision;            /* Processor revision number */
+    unsigned long units;     /* Bit mask. b0: MAC, b1: DIV, b2: EMAC, b3: FPU, b4: MMU */
+    char isa;                 /* Instruction-Set Architecture (ISA) revision level */
+    char debug;               /* Debug module revision */
+    short sysbus_frequency;   /* System bus frequency in Mhz */
+} MCF_COOKIE;
+
 /* Return values of Getcookie() */
 #define C_FOUND		0
 #define C_NOTFOUND	-1	/* EERROR */
 
 extern int 	Getcookie(long cookie, long *val);
 
 #endif
Index: unix/sysinfo.c
===================================================================
RCS file: /mint/mintlib/unix/sysinfo.c,v
retrieving revision 1.11
diff -u -8 -r1.11 sysinfo.c
--- unix/sysinfo.c	22 Feb 2011 23:32:58 -0000	1.11
+++ unix/sysinfo.c	4 Feb 2016 10:43:27 -0000
@@ -335,56 +335,116 @@
 static char* architecture = NULL;
 static long architecture_len;
 #define _CPU_60 0
 #define _CPU_40 1
 #define _CPU_30 2
 #define _CPU_20 3
 #define _CPU_10 4
 #define _CPU_00 5
+#define _MCF_V5 6
+#define _MCF_V4 7
+#define _MCF_V3 8
+#define _MCF_V2 9
+#define _MCF_V1 10
 
 static char* architectures[] = {
   "mc68060",
   "mc68040",
   "mc68030",
   "mc68020",
   "mc68010",
   "mc68000",
+  "cfv5",
+  "cfv4",
+  "cfv3",
+  "cfv2",
+  "cfv1",
   NULL
 };
 
 static char* isalist = NULL;
-static char isalist_buf[] =
-    "mc68060 mc68040 mc68030 mc68020 mc68010 mc68000";
 long isalist_len;
+#define _ISA_C        6
+#define _ISA_B        7
+#define _ISA_A_PLUS   8
+#define _ISA_A        9
+
+static char* isalists[] = {
+    "mc68060", "mc68040", "mc68030", "mc68020", "mc68010", "mc68000",
+     "isac", "isab", "isaaplus", "isaa"};
 
 static int
 si_architecture (buf, bufsize)
   char* buf;
   long bufsize;
 {
   if (architecture == NULL) {
     long int value = 0;
     int cpu = _CPU_00;
+    MCF_COOKIE *mcf_cookie;
+    long version;
 
-    (void) Getcookie (C__CPU, &value);
-    if (value >= 60)
-      cpu = _CPU_60;
-    else if (value >= 40)
-      cpu = _CPU_40;
-    else if (value >= 30)
-      cpu = _CPU_30;
-    else if (value >= 20)
-      cpu = _CPU_20;
-    else if (value >= 10)
-      cpu = _CPU_10;
+    /* m68k */
+    if (!Getcookie (C__CPU, &value)) {
+      if (value >= 60)
+        cpu = _CPU_60;
+      else if (value >= 40)
+        cpu = _CPU_40;
+      else if (value >= 30)
+        cpu = _CPU_30;
+      else if (value >= 20)
+        cpu = _CPU_20;
+      else if (value >= 10)
+        cpu = _CPU_10;
+      architecture_len = sizeof ("mc68xxx");
+      isalist = isalists[cpu];
+    }
+    /* ColdFire */
+    else if (!Getcookie (C__MCF, &value)) {
+      mcf_cookie = (MCF_COOKIE *)value;
+      version = (long)(*(long *)mcf_cookie->magic);
+      if (version == 0x4d434601)     /* 'MCF01' */
+      {
+        switch (mcf_cookie->core) {
+          case 1:
+            cpu = _MCF_V1;
+            break;
+          case 2:
+            cpu = _MCF_V2;
+            break;
+          case 3:
+            cpu = _MCF_V3;
+            break;
+          case 4:
+            cpu = _MCF_V4;
+            break;
+          case 5:
+            cpu = _MCF_V5;
+            break;
+        }
+        switch (mcf_cookie->isa) {
+          case MCF_ISA_A:
+            isalist = isalists[_ISA_A];
+            break;
+          case MCF_ISA_B:
+            isalist = isalists[_ISA_B];
+            break;
+          case MCF_ISA_C:
+            isalist = isalists[_ISA_C];
+            break;
+          case MCF_ISA_A_PLUS:
+            isalist = isalists[_ISA_A_PLUS];
+            break;
+         }
+        architecture_len = sizeof ("cfvx");
+      }
+    }
 
     architecture = architectures[cpu];
-    architecture_len = sizeof ("mc68xxx");
-    isalist = &isalist_buf[cpu * sizeof ("mc68xxx")];
     isalist_len = strlen (isalist) + 1;
   }
 
   fast_strncpy (buf, architecture, bufsize);
   return architecture_len;
 }
 
 /* SI_ISALIST */
@@ -407,39 +467,45 @@
 
 #define _PLATFORM_ST 0
 #define _PLATFORM_STE 1
 #define _PLATFORM_TT 2
 #define _PLATFORM_FALCON 3
 #define _PLATFORM_MILAN 4
 #define _PLATFORM_HADES 5
 #define _PLATFORM_ARANYM 6
-#define _PLATFORM_CLONE 7
+#define _PLATFORM_FIREBEE 7
+#define _PLATFORM_CFEVB 8
+#define _PLATFORM_CLONE 9
 
 static char* platforms[] = {
   "atarist",
   "atariste",
   "ataritt",
   "falcon",
   "milan",
   "hades",
   "aranym",
+  "firebee",
+  "cfevb"
   "atariclone",
 };
 
 #define _HW_PROVIDER_ATARI 0
 #define _HW_PROVIDER_MILAN 1
 #define _HW_PROVIDER_HADES 2
 #define _HW_PROVIDER_ARANYM 3
-#define _HW_PROVIDER_UNKNOWN 4
+#define _HW_PROVIDER_FREESCALE 4
+#define _HW_PROVIDER_UNKNOWN 5
 static char* hw_providers[] = {
   "atari",
   "milan",
-  "hades",
+  "hades",  /* This should have been "medusa" */
   "aranym",
+  "freescale",
   "unknown"
 };
 
 /* Cached results.  */
 static char* platform = NULL;
 static char* hw_provider = NULL;
 static long platform_len;
 static long hw_provider_len;
@@ -447,42 +513,59 @@
 static int
 si_platform (buf, bufsize)
   char* buf;
   long bufsize;
 {
   if (platform == NULL) {
     long _mch = 0;  /* = AtariST */
     long hi, lo;
+    int coldfire = 0;
+    long dummy;
 
     /* If we find the Hades cookie ignore the rest.  */
     if (Getcookie (C_hade, &_mch) == 0) {
       platform = platforms[_PLATFORM_HADES];
       hw_provider = hw_providers[_HW_PROVIDER_HADES];
     } else {
+      /* Check for ColdFire CPU */
+      if (!Getcookie (C__CF_, &dummy))
+        coldfire = 1;
+
       (void) Getcookie (C__MCH, &_mch);
       hi = (_mch & 0xffff0000) >> 16;
       lo = (_mch & 0xffff);
 
       switch (hi) {
+        case 0xffff:
+          if(coldfire) {
+            platform = platforms[_PLATFORM_CFEVB];
+            hw_provider = hw_providers[_HW_PROVIDER_FREESCALE];
+          }
+          break;
         case 0:
           platform = platforms[_PLATFORM_ST];
           hw_provider = hw_providers[_HW_PROVIDER_ATARI];
           break;
         case 1:
           platform = platforms[_PLATFORM_STE];
           hw_provider = hw_providers[_HW_PROVIDER_ATARI];
           break;
         case 2:
           platform = platforms[_PLATFORM_TT];
           hw_provider = hw_providers[_HW_PROVIDER_ATARI];
           break;
         case 3:
-          platform = platforms[_PLATFORM_FALCON];
-          hw_provider = hw_providers[_HW_PROVIDER_ATARI];
+          if(coldfire) {
+            platform = platforms[_PLATFORM_FIREBEE];
+            hw_provider = hw_providers[_HW_PROVIDER_HADES];
+          } else {
+            platform = platforms[_PLATFORM_FALCON];
+            hw_provider = hw_providers[_HW_PROVIDER_ATARI];
+          }
           break;
         case 4:
           platform = platforms[_PLATFORM_MILAN];
           hw_provider = hw_providers[_HW_PROVIDER_MILAN];
           break;
         case 5:
           platform = platforms[_PLATFORM_ARANYM];
           hw_provider = hw_providers[_HW_PROVIDER_ARANYM];