2003-06-22 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / sim / ppc / hw_htab.c
index 35aa57113710ee39e7f1c92c1b5512fe87298bfa..d5360686b453b05f50730c25b32e47926f06ceba 100644 (file)
@@ -1,6 +1,6 @@
 /*  This file is part of the program psim.
 
-    Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
+    Copyright 1994, 1995, 1996, 2003 Andrew Cagney
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -217,14 +217,21 @@ htab_decode_hash_table(device *me,
     device_error(parent, "must be a htab device");
   htab_ra = device_find_integer_property(parent, "real-address");
   htab_nr_bytes = device_find_integer_property(parent, "nr-bytes");
+  if (htab_nr_bytes < 0x10000) {
+    device_error(parent, "htab size 0x%x less than 0x1000",
+                htab_nr_bytes);
+  }
   for (n = htab_nr_bytes; n > 1; n = n / 2) {
     if (n % 2 != 0)
       device_error(parent, "htab size 0x%x not a power of two",
                   htab_nr_bytes);
   }
   *htaborg = htab_ra;
+  /* Position the HTABMASK ready for use against a hashed address and
+     not ready for insertion into SDR1.HTABMASK.  */
   *htabmask = MASKED32(htab_nr_bytes - 1, 7, 31-6);
-  if ((htab_ra & INSERTED32(*htabmask, 7, 15)) != 0) {
+  /* Check that the MASK and ADDRESS do not overlap.  */
+  if ((htab_ra & (*htabmask)) != 0) {
     device_error(parent, "htaborg 0x%lx not aligned to htabmask 0x%lx",
                 (unsigned long)*htaborg, (unsigned long)*htabmask);
   }
@@ -571,10 +578,12 @@ htab_map_binary(device *me,
   }
 
   /* set up virtual memory maps for each of the regions */
-  htab_map_region(me, memory, sizes.text_ra, sizes.text_base,
-                 sizes.text_bound - sizes.text_base,
-                 wimg, pp,
-                 htaborg, htabmask);
+  if (sizes.text_bound - sizes.text_base > 0) {
+    htab_map_region(me, memory, sizes.text_ra, sizes.text_base,
+                   sizes.text_bound - sizes.text_base,
+                   wimg, pp,
+                   htaborg, htabmask);
+  }
 
   htab_map_region(me, memory, sizes.data_ra, sizes.data_base,
                  sizes.data_bound - sizes.data_base,
This page took 0.038678 seconds and 4 git commands to generate.