changeset 07c10d7dd62d in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=07c10d7dd62d
description:
        sparc: Fix style, create a helper function for translation.
        The translate function simplifies code and removes some compiler
        warnings in gcc 3.4

diffstat:

2 files changed, 3 deletions(-)
src/arch/sparc/pagetable.hh |    1 -
src/arch/sparc/tlb.hh       |    2 --

diffs (truncated from 520 to 300 lines):

diff -r e6fabe023fe1 -r 07c10d7dd62d src/arch/sparc/pagetable.hh
--- a/src/arch/sparc/pagetable.hh       Mon Sep 22 08:25:58 2008 -0700
+++ b/src/arch/sparc/pagetable.hh       Tue Sep 23 20:38:02 2008 -0700
@@ -38,8 +38,8 @@
 
 class Checkpoint;
 
-namespace SparcISA
-{
+namespace SparcISA {
+
 struct VAddr
 {
     VAddr(Addr a) { panic("not implemented yet."); }
@@ -54,8 +54,15 @@
   public:
     TteTag() : entry(0), populated(false) {}
     TteTag(uint64_t e) : entry(e), populated(true) {}
-    const TteTag &operator=(uint64_t e) { populated = true;
-                                          entry = e; return *this; }
+
+    const TteTag &
+    operator=(uint64_t e) 
+    {
+        populated = true;
+        entry = e;
+        return *this;
+    }
+
     bool valid() const {assert(populated); return !bits(entry,62,62); }
     Addr va()    const {assert(populated); return bits(entry,41,0); }
 };
@@ -76,13 +83,13 @@
     uint64_t entry4u;
     bool populated;
 
-
   public:
-    PageTableEntry() : entry(0), type(invalid), populated(false) {}
+    PageTableEntry()
+        : entry(0), type(invalid), populated(false)
+    {}
 
     PageTableEntry(uint64_t e, EntryType t = sun4u)
         : entry(e), type(t), populated(true)
-
     {
         populate(entry, type);
     }
@@ -113,49 +120,74 @@
         }
     }
 
-    void clear()
+    void
+    clear()
     {
         populated = false;
     }
 
     static int pageSizes[6];
 
+    uint64_t operator()() const { assert(populated); return entry4u; }
+    const PageTableEntry &
+    operator=(uint64_t e)
+    {
+        populated = true;
+        entry4u = e;
+        return *this;
+    }
 
-    uint64_t operator()() const { assert(populated); return entry4u; }
-    const PageTableEntry &operator=(uint64_t e) { populated = true;
-                                                  entry4u = e; return *this; }
+    const PageTableEntry &
+    operator=(const PageTableEntry &e)
+    {
+        populated = true;
+        entry4u = e.entry4u;
+        type = e.type;
+        return *this;
+    }
 
-    const PageTableEntry &operator=(const PageTableEntry &e)
-    { populated = true; entry4u = e.entry4u; type = e.type; return *this; }
+    bool valid() const { return bits(entry4u,63,63) && populated; }
 
-    bool    valid()    const { return bits(entry4u,63,63) && populated; }
-    uint8_t _size()     const { assert(populated);
-                               return bits(entry4u, 62,61) |
-                                      bits(entry4u, 48,48) << 2; }
-    Addr    size()     const { assert(_size() < 6); return pageSizes[_size()]; 
}
-    Addr    sizeMask() const { assert(_size() < 6); return 
pageSizes[_size()]-1;}
-    bool    ie()       const { return bits(entry4u, 59,59); }
-    Addr    pfn()      const { assert(populated); return bits(entry4u,39,13); }
-    Addr    paddr()    const { assert(populated); return mbits(entry4u, 
39,13);}
-    bool    locked()   const { assert(populated); return bits(entry4u,6,6); }
-    bool    cv()       const { assert(populated); return bits(entry4u,4,4); }
-    bool    cp()       const { assert(populated); return bits(entry4u,5,5); }
-    bool    priv()     const { assert(populated); return bits(entry4u,2,2); }
-    bool    writable() const { assert(populated); return bits(entry4u,1,1); }
-    bool    nofault()  const { assert(populated); return bits(entry4u,60,60); }
-    bool    sideffect() const { assert(populated); return bits(entry4u,3,3); }
-    Addr    paddrMask() const { assert(populated);
-                                return mbits(entry4u, 39,13) & ~sizeMask(); }
+    uint8_t
+    _size() const
+    {
+        assert(populated);
+        return bits(entry4u, 62,61) | bits(entry4u, 48,48) << 2;
+    }
+
+    Addr size()     const { assert(_size() < 6); return pageSizes[_size()]; }
+    Addr sizeMask() const { return size() - 1; }
+    bool ie()       const { return bits(entry4u, 59,59); }
+    Addr pfn()      const { assert(populated); return bits(entry4u,39,13); }
+    Addr paddr()    const { assert(populated); return mbits(entry4u, 39,13);}
+    bool locked()   const { assert(populated); return bits(entry4u,6,6); }
+    bool cv()       const { assert(populated); return bits(entry4u,4,4); }
+    bool cp()       const { assert(populated); return bits(entry4u,5,5); }
+    bool priv()     const { assert(populated); return bits(entry4u,2,2); }
+    bool writable() const { assert(populated); return bits(entry4u,1,1); }
+    bool nofault()  const { assert(populated); return bits(entry4u,60,60); }
+    bool sideffect() const { assert(populated); return bits(entry4u,3,3); }
+    Addr paddrMask() const { assert(populated); return paddr() & ~sizeMask(); }
+
+    Addr
+    translate(Addr vaddr) const
+    {
+        assert(populated);
+        Addr mask = sizeMask();
+        return (paddr() & ~mask) | (vaddr & mask);
+    }
 };
 
-struct TlbRange {
+struct TlbRange
+{
     Addr va;
     Addr size;
     int contextId;
     int partitionId;
     bool real;
 
-    inline bool operator<(const TlbRange &r2) const
+    inline bool
+    operator<(const TlbRange &r2) const
     {
         if (real && !r2.real)
             return true;
@@ -178,7 +210,9 @@
             return true;
         return false;
     }
-    inline bool operator==(const TlbRange &r2) const
+
+    inline bool
+    operator==(const TlbRange &r2) const
     {
         return va == r2.va &&
                size == r2.size &&
@@ -189,7 +223,11 @@
 };
 
 
-struct TlbEntry {
+struct TlbEntry
+{
+    TlbEntry()
+    {}
+
     TlbEntry(Addr asn, Addr vaddr, Addr paddr)
     {
         uint64_t entry = 0;
@@ -215,8 +253,7 @@
 
         valid = true;
     }
-    TlbEntry()
-    {}
+
     TlbRange range;
     PageTableEntry pte;
     bool used;
@@ -229,11 +266,9 @@
 
     void serialize(std::ostream &os);
     void unserialize(Checkpoint *cp, const std::string &section);
-
 };
 
-
-}; // namespace SparcISA
+} // namespace SparcISA
 
 #endif // __ARCH_SPARC_PAGE_TABLE_HH__
 
diff -r e6fabe023fe1 -r 07c10d7dd62d src/arch/sparc/tlb.cc
--- a/src/arch/sparc/tlb.cc     Mon Sep 22 08:25:58 2008 -0700
+++ b/src/arch/sparc/tlb.cc     Tue Sep 23 20:38:02 2008 -0700
@@ -51,7 +51,7 @@
 {
     // To make this work you'll have to change the hypervisor and OS
     if (size > 64)
-        fatal("SPARC T1 TLB registers don't support more than 64 TLB 
entries.");
+        fatal("SPARC T1 TLB registers don't support more than 64 TLB entries");
 
     tlb = new TlbEntry[size];
     std::memset(tlb, 0, sizeof(TlbEntry) * size);
@@ -87,8 +87,6 @@
 TLB::insert(Addr va, int partition_id, int context_id, bool real,
         const PageTableEntry& PTE, int entry)
 {
-
-
     MapIter i;
     TlbEntry *new_entry = NULL;
 //    TlbRange tr;
@@ -103,8 +101,9 @@
     tr.real = real;
 */
 
-    DPRINTF(TLB, "TLB: Inserting TLB Entry; va=%#x pa=%#x pid=%d cid=%d r=%d 
entryid=%d\n",
-            va, PTE.paddr(), partition_id, context_id, (int)real, entry);
+    DPRINTF(TLB,
+        "TLB: Inserting Entry; va=%#x pa=%#x pid=%d cid=%d r=%d entryid=%d\n",
+        va, PTE.paddr(), partition_id, context_id, (int)real, entry);
 
     // Demap any entry that conflicts
     for (x = 0; x < size; x++) {
@@ -127,7 +126,6 @@
             }
         }
     }
-
 
 /*
     i = lookupTable.find(tr);
@@ -195,25 +193,22 @@
     new_entry->valid = true;
     usedEntries++;
 
-
-
     i = lookupTable.insert(new_entry->range, new_entry);
     assert(i != lookupTable.end());
 
-    // If all entries have there used bit set, clear it on them all, but the
-    // one we just inserted
+    // If all entries have their used bit set, clear it on them all,
+    // but the one we just inserted
     if (usedEntries == size) {
         clearUsedBits();
         new_entry->used = true;
         usedEntries++;
     }
-
 }
 
 
 TlbEntry*
-TLB::lookup(Addr va, int partition_id, bool real, int context_id, bool
-        update_used)
+TLB::lookup(Addr va, int partition_id, bool real, int context_id,
+            bool update_used)
 {
     MapIter i;
     TlbRange tr;
@@ -240,8 +235,8 @@
     DPRINTF(TLB, "TLB: Valid entry found pa: %#x size: %#x\n", t->pte.paddr(),
             t->pte.size());
 
-    // Update the used bits only if this is a real access (not a fake one from
-    // virttophys()
+    // Update the used bits only if this is a real access (not a fake
+    // one from virttophys()
     if (!t->used && update_used) {
         t->used = true;
         usedEntries++;
@@ -304,11 +299,10 @@
 void
 TLB::demapContext(int partition_id, int context_id)
 {
-    int x;
     DPRINTF(IPR, "TLB: Demapping Context pid=%#d cid=%d\n",
             partition_id, context_id);
     cacheValid = false;
-    for (x = 0; x < size; x++) {
+    for (int x = 0; x < size; x++) {
         if (tlb[x].range.contextId == context_id &&
             tlb[x].range.partitionId == partition_id) {
             if (tlb[x].valid == true) {
@@ -327,10 +321,9 @@
 void
 TLB::demapAll(int partition_id)
 {
-    int x;
     DPRINTF(TLB, "TLB: Demapping All pid=%#d\n", partition_id);
     cacheValid = false;
-    for (x = 0; x < size; x++) {
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to