Change HP-PA caching mechanism to use a single database file, stored
authorChris Hanson <org/chris-hanson/cph>
Sat, 1 Dec 1990 00:22:03 +0000 (00:22 +0000)
committerChris Hanson <org/chris-hanson/cph>
Sat, 1 Dec 1990 00:22:03 +0000 (00:22 +0000)
in the library directory, that contains entries indexed by model type.
The `hppacache' program now updates that database by adding new
entries to it.  The filename of the database is given as an explicit
argument.

v7/src/microcode/cmpintmd/hppa.h
v7/src/microcode/hppacach.c
v7/src/microcode/hppacach.h
v7/src/microcode/unxutl/ymkfile
v7/src/microcode/version.h
v8/src/microcode/cmpintmd/hppa.h
v8/src/microcode/version.h

index 596315f4b59e3019e2c2bbd3206f4a1accff4673..14bdc4f9d91c725aafd86585018235c2ecd454fd 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/cmpintmd/hppa.h,v 1.18 1990/11/30 02:45:43 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/cmpintmd/hppa.h,v 1.19 1990/12/01 00:22:03 cph Rel $
 
 Copyright (c) 1989, 1990 Massachusetts Institute of Technology
 
@@ -236,6 +236,7 @@ hppa_store_absolute_address (addr, sourcev, nullify_p)
  */
 
 #include "hppacache.h"
+#include "option.h"
 
 static struct pdc_cache_dump cache_info;
 
@@ -245,59 +246,69 @@ void
 flush_i_cache ()
 {
   extern void cache_flush_all ();
-
-  cache_flush_all ((D_CACHE | I_CACHE),
-                  &cache_info.cache_format);
-  return;
+  /* Newer machines can interrupt this call, so do it twice.
+     Probability of two interrupts in the same cache line is
+     exceedingly small, so this is likely to win. */
+  cache_flush_all ((D_CACHE | I_CACHE), (& (cache_info . cache_format)));
+  cache_flush_all ((D_CACHE | I_CACHE), (& (cache_info . cache_format)));
 }
 
-int
+#ifndef MODELS_FILENAME
+#define MODELS_FILENAME "HPPAmodels"
+#endif
+
+void
 flush_i_cache_initialize ()
 {
-  int fd, read_result;
   struct utsname sysinfo;
-  char filename[MAXPATHLEN];
-
+  CONST char * models_filename =
+    (search_path_for_file (0, MODELS_FILENAME, 1));
   if ((uname (&sysinfo)) < 0)
+    {
+      fprintf (stderr, "\nflush_i_cache: uname failed.\n");
+      goto loser;
+    }
   {
-    fprintf (stderr, "\nflush_i_cache: uname failed.\n");
-    return (-1);
+    int fd = (open (models_filename, O_RDONLY));
+    if (fd < 0)
+      {
+       fprintf (stderr, "\nflush_i_cache: open (%s) failed.\n",
+                models_filename);
+       goto loser;
+      }
+    while (1)
+      {
+       int read_result =
+         (read (fd,
+                ((char *) (&cache_info)),
+                (sizeof (struct pdc_cache_dump))));
+       if (read_result == 0)
+         {
+           close (fd);
+           break;
+         }
+       if (read_result != (sizeof (struct pdc_cache_dump)))
+         {
+           close (fd);
+           fprintf (stderr, "\nflush_i_cache: read (%s) failed.\n",
+                    models_filename);
+           goto loser;
+         }
+       if ((strcmp ((sysinfo . machine), (cache_info . hardware))) == 0)
+         {
+           close (fd);
+           return;
+         }
+      }
   }
-    
-  sprintf (&filename[0],
-          CACHE_FILENAME,
-          CACHE_FILENAME_PATH,
-          sysinfo.nodename,
-          sysinfo.machine);
-
-  fd = (open ((&filename[0]), O_RDONLY));
-  if (fd < 0)
-  {
-    fprintf (stderr, "\nflush_i_cache: open (%s) failed.\n",
-            (&filename[0]));
-    return (-1);
-  }
-
-  read_result = (read (fd,
-                      ((char *) (&cache_info)),
-                      (sizeof (struct pdc_cache_dump))));
-  close (fd);
-
-  if (read_result != (sizeof (struct pdc_cache_dump)))
-  {
-    fprintf (stderr, "\nflush_i_cache: read (%s) failed.\n",
-            (&filename[0]));
-    return (-1);
-  }
-
-  if ((strcmp (sysinfo.machine, cache_info.hardware)) != 0)
-  {
-    fprintf (stderr,
-            "\nflush_i_cache: information in %s does not match hardware.\n",
-            (&filename[0]));
-    return (-1);
-  }
-  return (0);
+  fprintf (stderr,
+          "The cache parameters database has no entry for the %s model.\n",
+          (sysinfo . machine));
+  fprintf (stderr, "Please make an entry in the database;\n");
+  fprintf (stderr, "the installation notes contain instructions for doing so.\n");
+ loser:
+  fprintf (stderr, "\nASM_RESET_HOOK: Unable to read cache parameters.\n");
+  termination_init_error ();
 }
 
 #endif /* IN_CMPINT_C */
@@ -569,8 +580,8 @@ do {                                                                        \
    processor might have old copies of.
  */
 
-#define FLUSH_I_CACHE()                                                        \
-do {                                                                   \
+#define FLUSH_I_CACHE() do                                             \
+{                                                                      \
   extern void flush_i_cache ();                                                \
                                                                        \
   flush_i_cache ();                                                    \
@@ -581,8 +592,8 @@ do {                                                                        \
    Not needed during GC because FLUSH_I_CACHE will be used.
  */   
 
-#define FLUSH_I_CACHE_REGION(address, nwords)                          \
-do {                                                                   \
+#define FLUSH_I_CACHE_REGION(address, nwords) do                       \
+{                                                                      \
   extern void cache_flush_region ();                                   \
                                                                        \
   cache_flush_region (((void *) (address)), nwords);                   \
@@ -591,15 +602,7 @@ do {                                                                       \
 /* This loads the cache information structure for use by flush_i_cache.
  */
 
-#define ASM_RESET_HOOK()                                               \
-do {                                                                   \
-  if ((flush_i_cache_initialize ()) < 0)                               \
-  {                                                                    \
-    fprintf (stderr,                                                   \
-            "\nASM_RESET_HOOK: Unable to read cache parameters.\n");   \
-    Microcode_Termination (TERM_COMPILER_DEATH);                       \
-  }                                                                    \
-} while (0)
+#define ASM_RESET_HOOK() flush_i_cache_initialize ()
 \f
 /* Derived parameters and macros.
 
index be24282badb68cc995a2b1d75ab66e0e7f17f0f8..89e261941e0f84d4f2a7f22807fbb3db65f5ceb2 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/hppacach.c,v 1.1 1990/08/08 20:21:12 jinx Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/hppacach.c,v 1.2 1990/12/01 00:21:19 cph Rel $
 
 Copyright (c) 1990 Massachusetts Institute of Technology
 
@@ -34,10 +34,8 @@ MIT in each case. */
 
 #include <stdio.h>
 #include <math.h>
-
 #include <sys/stat.h>
 #include <memory.h>
-
 #include <nlist.h>
 
 #include "hppacache.h"
@@ -52,9 +50,9 @@ MIT in each case. */
 
 #else
 
-#define DEBUGGING(stmt)                                                        \
-do {                                                                   \
-}while (0)
+#define DEBUGGING(stmt) do                                             \
+{                                                                      \
+} while (0)
 
 #endif
 \f
@@ -69,38 +67,33 @@ do {                                                                        \
 #define UTSNAME_SYMBOL         "utsname"
 #define PDC_CACHE_SYMBOL       "cache_tlb_parms"
 
-/* File where cached locations (to avoid nlist search) live */
-
-#define LOCATIONS_CACHE_FILE   "/tmp/hppa.cache"
-
-/* Operating system name */
-
-#define SYSNAME                        "HP-UX"
-
 static struct utsname sysinfo;
 static char **the_argv;
-\f
+
 void
-io_error (format, fname)
-     char *format, *fname;
+io_error (pname, format, fname)
+     char * pname;
+     char * format;
+     char * fname;
 {
   char errmsg[MAXPATHLEN + 257];
   char errstring[MAXPATHLEN + 257];
 
   sprintf (&errmsg[0], format, fname);
-  sprintf (&errstring[0], "%s: %s", (the_argv[0]), (&errmsg[0]));
+  sprintf (&errstring[0], "%s: %s: %s", (the_argv[0]), pname, (&errmsg[0]));
   perror (&errstring[0]);
-  return;
 }
 
 void
-io_lose (format, fname)
-     char *format, *fname;
+io_lose (pname, format, fname)
+     char * pname;
+     char * format;
+     char * fname;
 {
-  io_error (format, fname);
+  io_error (pname, format, fname);
   exit (1);
 }
-
+\f
 struct kernel_locations
 {
   long utsname_location;
@@ -114,17 +107,14 @@ struct nlist nl[] =
   { 0 },
 };
 
-int
+void
 read_nlist (kloc)
      struct kernel_locations *kloc;
 {
   DEBUGGING (printf ("reading nlist...\n"));
 
   if ((nlist (KERNEL_FILE, nl)) != 0)
-  {
-    io_error ("nlist: failed on %s", KERNEL_FILE);
-    return (-1);
-  }
+    io_lose ("read_nlist", "failed on %s", KERNEL_FILE);
 
   DEBUGGING (printf ("reading nlist done.\n"));
 
@@ -133,114 +123,36 @@ read_nlist (kloc)
 
   DEBUGGING (printf ("utsname location = 0x%x\n", kloc->utsname_location));
   DEBUGGING (printf ("pdc_cache location = 0x%x\n", kloc->pdc_cache_location));
-
-  return (0);
 }
-\f
-void
-read_model (pdc_cache)
-     struct pdc_cache_dump *pdc_cache;
-{
-  int fd, read_result;
-  static char filename[MAXPATHLEN + 1];
-
-  sprintf ((&filename[0]),
-          MODELS_FILENAME,
-          CACHE_FILENAME_PATH);
-  fprintf (stderr, "%s:\n", (the_argv[0]));
-  fprintf (stderr,
-          "\tReading cache information from the model-based database (%s).\n",
-          (&filename[0]));
-  fd = (open ((&filename[0]), O_RDONLY));
-  if (fd < 0)
-  {
-    io_lose ("read_model: open (%s) failed", (&filename[0]));
-  }
 
-  while (true)
-  {
-    read_result = (read (fd, ((char *) pdc_cache), (sizeof (struct pdc_cache_dump))));
-    if (read_result != (sizeof (struct pdc_cache_dump)))
-    {
-      break;
-    }
-    if ((strcmp (sysinfo.machine, pdc_cache->hardware)) == 0)
-    {
-      close (fd);
-      fprintf (stderr,
-              "\tFound information for model %s in %s.\n",
-              sysinfo.machine, (&filename[0]));
-      return;
-    }
-  }
-  close (fd);
-  fprintf (stderr,
-          "\tCould not find information for model %s in %s.\n",
-          sysinfo.machine, (&filename[0]));
-  exit (1);
-}
-\f
 void
 read_parameters (pdc_cache)
      struct pdc_cache_dump *pdc_cache;
 {
-  int kmem;
-
   struct kernel_locations kloc;
   struct utsname kerninfo;
-
-  if ((read_nlist (&kloc)) < 0)
-  {
-    read_model (pdc_cache);
-    return;
-  }
-  kmem = (open (KERNEL_MEMORY_FILE, O_RDONLY));
+  int kmem = (open (KERNEL_MEMORY_FILE, O_RDONLY));
   if (kmem < 0)
-  {
-    io_error ("read_parameters: open (%s) failed", KERNEL_MEMORY_FILE);
-    read_model (pdc_cache);
-    return;
-  }
-  else
-  {
-    if ((lseek (kmem, kloc.utsname_location, 0)) < 0)
-    {
-      io_lose ("read_parameters: lseek (%s) failed", KERNEL_MEMORY_FILE);
-    }
-
-    if ((read (kmem, &kerninfo, (sizeof (kerninfo)))) !=
-       (sizeof (kerninfo)))
-    {
-      io_lose ("read_parameters: read (%s) failed", KERNEL_MEMORY_FILE);
-    }
-
-    if ((memcmp (&kerninfo, &sysinfo, (sizeof (sysinfo)))) != 0)
-    {
-      fprintf (stderr, "read_parameters: uname and %s in %s differ.\n",
-              kloc.utsname_location, KERNEL_MEMORY_FILE);
-    }
-
-    strncpy (pdc_cache->hardware, (kerninfo.machine),
-            (sizeof (kerninfo.machine)));
-
-    if ((lseek (kmem, (kloc.pdc_cache_location), 0)) < 0)
-    {
-      io_lose ("read_parameters: lseek (%s) failed", KERNEL_MEMORY_FILE);
-    }
-
-    if  ((read (kmem, pdc_cache->cache_format,
-               (sizeof (pdc_cache->cache_format)))) !=
-        (sizeof (pdc_cache->cache_format)))
-    {
-      io_lose ("read_parameters: read (%s) failed", KERNEL_MEMORY_FILE);
-    }
-
-    if ((close (kmem)) < 0)
-    {
-      io_lose ("read_parameters: close (%s) failed", KERNEL_MEMORY_FILE);
-    }
-  }
-  return;
+    io_lose ("read_parameters", "open (%s) failed", KERNEL_MEMORY_FILE);
+  read_nlist (&kloc);
+  if ((lseek (kmem, kloc.utsname_location, 0)) < 0)
+    io_lose ("read_parameters", "lseek (%s) failed", KERNEL_MEMORY_FILE);
+  if ((read (kmem, (&kerninfo), (sizeof (kerninfo)))) !=
+      (sizeof (kerninfo)))
+    io_lose ("read_parameters", "read (%s) failed", KERNEL_MEMORY_FILE);
+  if ((memcmp ((&kerninfo), (&sysinfo), (sizeof (sysinfo)))) != 0)
+    fprintf (stderr, "read_parameters: uname and %s in %s differ.\n",
+            kloc.utsname_location, KERNEL_MEMORY_FILE);
+  strncpy (pdc_cache->hardware, (kerninfo.machine),
+          (sizeof (kerninfo.machine)));
+  if ((lseek (kmem, (kloc.pdc_cache_location), 0)) < 0)
+    io_lose ("read_parameters", "lseek (%s) failed", KERNEL_MEMORY_FILE);
+  if  ((read (kmem, pdc_cache->cache_format,
+             (sizeof (pdc_cache->cache_format)))) !=
+       (sizeof (pdc_cache->cache_format)))
+    io_lose ("read_parameters", "read (%s) failed", KERNEL_MEMORY_FILE);
+  if ((close (kmem)) < 0)
+    io_lose ("read_parameters", "close (%s) failed", KERNEL_MEMORY_FILE);
 }
 \f
 void
@@ -429,64 +341,78 @@ print_parameters (pdc_cache)
   return;
 }
 \f
-static char dumpname[MAXPATHLEN + 1];
+int
+search_pdc_database (fd, pdc_cache, filename)
+     int fd;
+     struct pdc_cache_dump * pdc_cache;
+     char * filename;
+{
+  while (1)
+    {
+      int scr =
+       (read (fd, ((char *) pdc_cache), (sizeof (struct pdc_cache_dump))));
+      if (scr < 0)
+       io_lose ("update_pdc_database", "read (%s) failed", filename);
+      if (scr != (sizeof (struct pdc_cache_dump)))
+       {
+         if (scr == 0)
+           return (0);
+         fprintf (stderr, "%s: %s: incomplete read (%s)\n",
+                  (the_argv[0]), "update_pdc_database", filename);
+         fflush (stderr);
+         exit (1);
+       }
+      if ((strcmp ((sysinfo . machine), (pdc_cache -> hardware))) == 0)
+       return (1);
+    }
+}
 
 void
-dump_parameters (pdc_cache)
-     struct pdc_cache_dump *pdc_cache;
+update_pdc_database (pdc_cache, filename)
+     struct pdc_cache_dump * pdc_cache;
+     char * filename;
 {
-  int file;
-
-  sprintf (&dumpname[0],
-          CACHE_FILENAME,
-          CACHE_FILENAME_PATH,
-          sysinfo.nodename,
-          sysinfo.machine);
-
-  file = open (&dumpname[0], (O_WRONLY | O_CREAT | O_TRUNC), 0664);
-  if (file < 0)
-  {
-    io_lose ("dump_parameters: open (%s) failed", dumpname);
-  }
-  if ((write (file, pdc_cache, (sizeof (struct pdc_cache_dump)))) !=
-      (sizeof (struct pdc_cache_dump)))
-  {
-    io_lose ("dump_parameters: write (%s) failed", dumpname);
-  }
-  if ((close (file)) != 0)
-  {
-    io_lose ("dump_parameters: close (%s) failed", dumpname);
-  }
-  return;
+  int fd = (open (filename, (O_RDWR | O_CREAT), 0666));
+  if (fd < 0)
+    io_lose ("update_pdc_database", "open (%s) failed", filename);
+  if (! (search_pdc_database (fd, pdc_cache, filename)))
+    {
+      read_parameters (pdc_cache);
+      {
+       int scr =
+         (write (fd, ((char *) pdc_cache), (sizeof (struct pdc_cache_dump))));
+       if (scr < 0)
+         io_lose ("update_pdc_database", "write (%s) failed", filename);
+       if (scr != (sizeof (struct pdc_cache_dump)))
+         {
+           fprintf (stderr, "%s: %s: incomplete write (%s)\n",
+                    (the_argv[0]), "update_pdc_database", filename);
+           fflush (stderr);
+           exit (1);
+         }
+      }
+    }
+  if ((close (fd)) < 0)
+    io_lose ("update_pdc_database", "close (%s) failed", filename);
 }
 
 void
-read_stored_parameters (old_pdc_cache)
-     struct pdc_cache_dump *old_pdc_cache;
+read_stored_parameters (pdc_cache, filename)
+     struct pdc_cache_dump * pdc_cache;
+     char * filename;
 {
-  int file;
-
-  sprintf (&dumpname[0],
-          CACHE_FILENAME,
-          CACHE_FILENAME_PATH,
-          sysinfo.nodename,
-          sysinfo.machine);
-
-  file = open (&dumpname[0], (O_RDONLY), 0);
-  if (file < 0)
-  {
-    io_lose ("read_stored_parameters: open (%s) failed", dumpname);
-  }
-  if ((read (file, old_pdc_cache, (sizeof (struct pdc_cache_dump)))) !=
-      (sizeof (struct pdc_cache_dump)))
-  {
-    io_lose ("read_stored_parameters: read (%s) failed", dumpname);
-  }
-  if ((close (file)) != 0)
-  {
-    io_lose ("read_stored_parameters: close (%s) failed", dumpname);
-  }
-  return;
+  int fd = (open (filename, (O_RDONLY), 0));
+  if (fd < 0)
+    io_lose ("read_stored_parameters", "open (%s) failed", filename);
+  if (! (search_pdc_database (fd, pdc_cache, filename)))
+    {
+      fprintf (stderr, "%s: %s: unable to find entry in models database\n",
+              (the_argv[0]), "read_stored_parameters");
+      fflush (stderr);
+      exit (1);
+    }
+  if ((close (fd)) < 0)
+    io_lose ("read_stored_parameters", "close (%s) failed", filename);
 }
 
 void
@@ -516,89 +442,51 @@ verify_parameters (new_pdc_cache, old_pdc_cache)
   return;
 }
 \f
+void
+usage ()
+{
+  fprintf (stderr, "usage: one of:\n");
+  fprintf (stderr, " %s -update FILENAME\n");
+  fprintf (stderr, " %s -print FILENAME\n");
+  fprintf (stderr, " %s -verify FILENAME\n");
+  fflush (stderr);
+  exit (1);
+}
+
+void
 main (argc, argv)
      int argc;
      char **argv;
 {
-  int
-    count,
-    uname_result;
-  struct pdc_cache_dump
-    new_pdc_cache_s, old_pdc_cache_s,
-    *new_pdc_cache, *old_pdc_cache;
-
   the_argv = argv;
-  new_pdc_cache = ((struct pdc_cache_dump *) NULL);
-  old_pdc_cache = ((struct pdc_cache_dump *) NULL);
-
-  uname_result = (uname (&sysinfo));
-  if (uname_result < 0)
-  {
-    fprintf (stderr, "%s: uname failed.\n", argv[0]);
-    exit (1);
-  }
-
-  if (argc <= 1)
-  {
-    if (new_pdc_cache == ((struct pdc_cache_dump *) NULL))
-    {
-      read_parameters (&new_pdc_cache_s);
-      new_pdc_cache = &new_pdc_cache_s;
-    }
-    dump_parameters (new_pdc_cache);
-  }
-  else
+  if ((uname (&sysinfo)) < 0)
+    io_lose ("main", "uname failed", 0);
+  if (argc != 3)
+    usage ();
   {
-    for (count = 1; count < argc; count++)
-    {
-      if ((strcmp ((argv[count]), "-printnew")) == 0)
+    char * keyword = (argv[1]);
+    char * filename = (argv[2]);
+    if ((strcmp (keyword, "-update")) == 0)
       {
-       if (new_pdc_cache == ((struct pdc_cache_dump *) NULL))
-       {
-         read_parameters (&new_pdc_cache_s);
-         new_pdc_cache = &new_pdc_cache_s;
-       }
-       print_parameters (new_pdc_cache);
+       struct pdc_cache_dump pdc_cache;
+       update_pdc_database ((&pdc_cache), filename);
       }
-      else if ((strcmp ((argv[count]), "-printold")) == 0)
+    else if ((strcmp (keyword, "-print")) == 0)
       {
-       if (old_pdc_cache == ((struct pdc_cache_dump *) NULL))
-       {
-         read_stored_parameters (&old_pdc_cache_s);
-         old_pdc_cache = &old_pdc_cache_s;
-       }
-       print_parameters (old_pdc_cache);
+       struct pdc_cache_dump pdc_cache;
+       update_pdc_database ((&pdc_cache), filename);
+       print_parameters (&pdc_cache);
       }
-      else if ((strcmp ((argv[count]), "-dump")) == 0)
+    else if ((strcmp (keyword, "-verify")) == 0)
       {
-       if (new_pdc_cache == ((struct pdc_cache_dump *) NULL))
-       {
-         read_parameters (&new_pdc_cache_s);
-         new_pdc_cache = &new_pdc_cache_s;
-       }
-       dump_parameters (new_pdc_cache);
+       struct pdc_cache_dump old_pdc_cache;
+       struct pdc_cache_dump new_pdc_cache;
+       read_stored_parameters ((&old_pdc_cache), filename);
+       read_parameters (&new_pdc_cache);
+       verify_parameters ((&new_pdc_cache), (&old_pdc_cache));
       }
-      else if ((strcmp ((argv[count]), "-verify")) == 0)
-      {
-       if (new_pdc_cache == ((struct pdc_cache_dump *) NULL))
-       {
-         read_parameters (&new_pdc_cache_s);
-         new_pdc_cache = &new_pdc_cache_s;
-       }
-       if (old_pdc_cache == ((struct pdc_cache_dump *) NULL))
-       {
-         read_stored_parameters (&old_pdc_cache_s);
-         old_pdc_cache = &old_pdc_cache_s;
-       }
-       verify_parameters (new_pdc_cache, old_pdc_cache);
-      }
-      else
-      {
-       fprintf (stderr, "usage: %s [-dump] [-verify] [-printnew] [-printold]\n",
-                argv[0]);
-       exit (1);
-      }
-    }
+    else
+      usage ();
   }
   exit (0);
 }
index 3fbad1bc336ea3499ecc1adf5b0f50114c7792a7..9203d6e0b59b0b353c787a3e252a57e1318ede0c 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/hppacach.h,v 1.2 1990/11/13 08:44:50 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/hppacach.h,v 1.3 1990/12/01 00:21:04 cph Rel $
 
 Copyright (c) 1990 Massachusetts Institute of Technology
 
@@ -35,39 +35,6 @@ MIT in each case. */
 #ifndef HPPACACHE_H            /* Prevent multiple inclusion */
 #define HPPACACHE_H
 
-#ifdef MIT_SCHEME
-#include "option.h"
-#define CACHE_FILENAME "%s/%s.cache"
-#define CACHE_FILENAME_PATH "/usr/local/lib/mit-scheme"
-#define MODELS_FILENAME "HPPAmodels"
-#endif
-
-/*
-   Format strings used to determine the name of the file
-   where to store (and examine) the cache description.
-
-   The strings are used as in
-   printf (CACHE_FILENAME, CACHE_FILENAME_PATH, hostname_string, model_string);
-
-   The default value (below) would generate the file name
-   /tmp/altdorf.cache
-   when running on a machine named altdorf.
-
-   To ignore a string parameter, use the %.0s format.
- */
-
-#ifndef CACHE_FILENAME_PATH
-#define CACHE_FILENAME_PATH "/tmp/"
-#endif
-
-#ifndef CACHE_FILENAME
-#define CACHE_FILENAME "%s%s.cache"
-#endif /* CACHE_FILENAME */
-
-#ifndef MODELS_FILENAME
-#define MODELS_FILENAME "%shppamodels"
-#endif
-\f
 #define I_CACHE                1
 #define D_CACHE                2
 
@@ -77,7 +44,7 @@ MIT in each case. */
 #include <machine/cpu.h>
 #include <machine/pdc_rqsts.h>
 #include <fcntl.h>
-
+\f
 /* PDC_CACHE (processor dependent code cache information call)
    return data destructuring.
 
@@ -86,8 +53,7 @@ MIT in each case. */
    section of the I/O Architecture Manual.
 
    The main difference is the cache configuration field.
-   Which is correct?
- */
+   Which is correct?  */
 
 union cache_conf
 {
index 72dd3ef8a167b66b69b743c65c35c36f3449c63b..8e2503e5a9a4480df608c539437a43f762c58208 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/unxutl/Attic/ymkfile,v 1.37 1990/11/28 21:14:41 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/unxutl/Attic/ymkfile,v 1.38 1990/12/01 00:21:34 cph Exp $
 
 Copyright (c) 1989, 1990 Massachusetts Institute of Technology
 
@@ -190,7 +190,7 @@ MACHINE_SWITCHES = -DHAS_COMPILER_SUPPORT
 MACHINE_SOURCES = cmpint.c cmpaux-hppa.m4 dmpwrld.c
 MACHINE_OBJECTS = cmpint.o cmpaux-hppa.o dmpwrld.o
 GC_HEAD_FILES = gccode.h cmpgc.h cmpint-hppa.h hppacache.h
-XTRA_TARGETS = HPPACACHE
+XTRA_TARGETS = hppacache
 #endif /* PROC_TYPE_HPPA */
 
 #if (PROC_TYPE == PROC_TYPE_MIPS)
@@ -553,13 +553,10 @@ float.h : hard-params
 hard-params : hard-params.c
        $(CC) -DNO_SC $(LDFLAGS) -o hard-params hard-params.c
 
-HPPACACHE : hppacache
-       chgrp sys hppacache
-       chmod g+s hppacache
-       ./hppacache -dump
+hppacache.o : hppacache.h
 
-hppacache : hppacache.c hppacache.h option.h
-       $(CC) $(CFLAGS) -o hppacache hppacache.c
+hppacache : hppacache.o
+       $(CC) $(CFLAGS) -o hppacache hppacache.o
 
 lint.out : $(SOURCES) $(SCHEME_SOURCES) $(CSRC) usrdef.c $(HEAD_FILES)
        rm -f lint.out
index 3f3a44c294a992909d01f124dd260248f23cca34..c25c1c4b52939be3e233fa9af86d97d1c9fc1335 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.57 1990/11/27 19:37:43 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.58 1990/12/01 00:21:48 cph Exp $
 
 Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology
 
@@ -46,5 +46,5 @@ MIT in each case. */
 #define VERSION                11
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     57
+#define SUBVERSION     58
 #endif
index 56dda73283a84fd41c18bae61cf94c330646af35..5cc58fd2baf3f884d66155b822b5dcfc00c69c58 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/cmpintmd/hppa.h,v 1.18 1990/11/30 02:45:43 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/cmpintmd/hppa.h,v 1.19 1990/12/01 00:22:03 cph Rel $
 
 Copyright (c) 1989, 1990 Massachusetts Institute of Technology
 
@@ -236,6 +236,7 @@ hppa_store_absolute_address (addr, sourcev, nullify_p)
  */
 
 #include "hppacache.h"
+#include "option.h"
 
 static struct pdc_cache_dump cache_info;
 
@@ -245,59 +246,69 @@ void
 flush_i_cache ()
 {
   extern void cache_flush_all ();
-
-  cache_flush_all ((D_CACHE | I_CACHE),
-                  &cache_info.cache_format);
-  return;
+  /* Newer machines can interrupt this call, so do it twice.
+     Probability of two interrupts in the same cache line is
+     exceedingly small, so this is likely to win. */
+  cache_flush_all ((D_CACHE | I_CACHE), (& (cache_info . cache_format)));
+  cache_flush_all ((D_CACHE | I_CACHE), (& (cache_info . cache_format)));
 }
 
-int
+#ifndef MODELS_FILENAME
+#define MODELS_FILENAME "HPPAmodels"
+#endif
+
+void
 flush_i_cache_initialize ()
 {
-  int fd, read_result;
   struct utsname sysinfo;
-  char filename[MAXPATHLEN];
-
+  CONST char * models_filename =
+    (search_path_for_file (0, MODELS_FILENAME, 1));
   if ((uname (&sysinfo)) < 0)
+    {
+      fprintf (stderr, "\nflush_i_cache: uname failed.\n");
+      goto loser;
+    }
   {
-    fprintf (stderr, "\nflush_i_cache: uname failed.\n");
-    return (-1);
+    int fd = (open (models_filename, O_RDONLY));
+    if (fd < 0)
+      {
+       fprintf (stderr, "\nflush_i_cache: open (%s) failed.\n",
+                models_filename);
+       goto loser;
+      }
+    while (1)
+      {
+       int read_result =
+         (read (fd,
+                ((char *) (&cache_info)),
+                (sizeof (struct pdc_cache_dump))));
+       if (read_result == 0)
+         {
+           close (fd);
+           break;
+         }
+       if (read_result != (sizeof (struct pdc_cache_dump)))
+         {
+           close (fd);
+           fprintf (stderr, "\nflush_i_cache: read (%s) failed.\n",
+                    models_filename);
+           goto loser;
+         }
+       if ((strcmp ((sysinfo . machine), (cache_info . hardware))) == 0)
+         {
+           close (fd);
+           return;
+         }
+      }
   }
-    
-  sprintf (&filename[0],
-          CACHE_FILENAME,
-          CACHE_FILENAME_PATH,
-          sysinfo.nodename,
-          sysinfo.machine);
-
-  fd = (open ((&filename[0]), O_RDONLY));
-  if (fd < 0)
-  {
-    fprintf (stderr, "\nflush_i_cache: open (%s) failed.\n",
-            (&filename[0]));
-    return (-1);
-  }
-
-  read_result = (read (fd,
-                      ((char *) (&cache_info)),
-                      (sizeof (struct pdc_cache_dump))));
-  close (fd);
-
-  if (read_result != (sizeof (struct pdc_cache_dump)))
-  {
-    fprintf (stderr, "\nflush_i_cache: read (%s) failed.\n",
-            (&filename[0]));
-    return (-1);
-  }
-
-  if ((strcmp (sysinfo.machine, cache_info.hardware)) != 0)
-  {
-    fprintf (stderr,
-            "\nflush_i_cache: information in %s does not match hardware.\n",
-            (&filename[0]));
-    return (-1);
-  }
-  return (0);
+  fprintf (stderr,
+          "The cache parameters database has no entry for the %s model.\n",
+          (sysinfo . machine));
+  fprintf (stderr, "Please make an entry in the database;\n");
+  fprintf (stderr, "the installation notes contain instructions for doing so.\n");
+ loser:
+  fprintf (stderr, "\nASM_RESET_HOOK: Unable to read cache parameters.\n");
+  termination_init_error ();
 }
 
 #endif /* IN_CMPINT_C */
@@ -569,8 +580,8 @@ do {                                                                        \
    processor might have old copies of.
  */
 
-#define FLUSH_I_CACHE()                                                        \
-do {                                                                   \
+#define FLUSH_I_CACHE() do                                             \
+{                                                                      \
   extern void flush_i_cache ();                                                \
                                                                        \
   flush_i_cache ();                                                    \
@@ -581,8 +592,8 @@ do {                                                                        \
    Not needed during GC because FLUSH_I_CACHE will be used.
  */   
 
-#define FLUSH_I_CACHE_REGION(address, nwords)                          \
-do {                                                                   \
+#define FLUSH_I_CACHE_REGION(address, nwords) do                       \
+{                                                                      \
   extern void cache_flush_region ();                                   \
                                                                        \
   cache_flush_region (((void *) (address)), nwords);                   \
@@ -591,15 +602,7 @@ do {                                                                       \
 /* This loads the cache information structure for use by flush_i_cache.
  */
 
-#define ASM_RESET_HOOK()                                               \
-do {                                                                   \
-  if ((flush_i_cache_initialize ()) < 0)                               \
-  {                                                                    \
-    fprintf (stderr,                                                   \
-            "\nASM_RESET_HOOK: Unable to read cache parameters.\n");   \
-    Microcode_Termination (TERM_COMPILER_DEATH);                       \
-  }                                                                    \
-} while (0)
+#define ASM_RESET_HOOK() flush_i_cache_initialize ()
 \f
 /* Derived parameters and macros.
 
index 83e7b862d6e9ebe565e68c0b2c4dba1dfb01e82c..34e5b2e00c75786d453e07fd8b94e568ec430427 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.57 1990/11/27 19:37:43 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.58 1990/12/01 00:21:48 cph Exp $
 
 Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology
 
@@ -46,5 +46,5 @@ MIT in each case. */
 #define VERSION                11
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     57
+#define SUBVERSION     58
 #endif