def __repr__(self): ret = [] for r in sorted(self._regs, key=self._regs.get, reverse=True): msb, lsb = self._regs[r] val = bitops.bvalsel(msb, lsb, self.value) ret.append('%s[%d:%d]=>0x%0x' % (r, msb, lsb, val)) return "value: 0x%x {%s}" % (self.value, ', '.join(ret))
def __getattr__(self, name): if name not in self._regs: raise AttributeError if self.value is None: return None msb, lsb = self._regs[name] return bitops.bvalsel(msb, lsb, self.value)
def page_table_walk(self, virt): global_offset = bvalsel(31, 20, virt) l1_pte = self.global_page_table[global_offset] bit18 = (l1_pte & 0x40000) >> 18 if (bvalsel(1, 0, l1_pte) == 1): l2_offset = bvalsel(19, 12, virt) l2_pte = self.secondary_page_tables[global_offset][l2_offset] if l2_pte is None: return None if (bvalsel(1, 0, l2_pte) == 2) or (bvalsel(1, 0, l2_pte) == 3): entry4kb = (l2_pte & bm(31, 12)) + bvalsel(11, 0, virt) return entry4kb elif (bvalsel(1, 0, l2_pte) == 1): entry64kb = (l2_pte & bm(31, 16)) + bvalsel(15, 0, virt) return entry64kb if (bvalsel(1, 0, l1_pte) == 2): onemb_entry = bm(31, 20) & l1_pte onemb_entry += bvalsel(19, 0, virt) return onemb_entry return 0
def page_table_walk(self, virt): global_offset = bvalsel(31, 20, virt) l1_pte = self.global_page_table[global_offset] bit18 = (l1_pte & 0x40000) >> 18 if (bvalsel(1, 0, l1_pte) == 1) : l2_offset = bvalsel(19, 12, virt) l2_pte = self.secondary_page_tables[global_offset][l2_offset] if l2_pte is None : return None if (bvalsel(1, 0, l2_pte) == 2) or (bvalsel(1, 0, l2_pte) == 3) : entry4kb = (l2_pte & bm(31, 12)) + bvalsel(11, 0, virt) return entry4kb elif (bvalsel(1, 0, l2_pte) == 1) : entry64kb = (l2_pte & bm(31, 16)) + bvalsel(15, 0, virt) return entry64kb if (bvalsel(1, 0, l1_pte) == 2) : onemb_entry = bm(31, 20) & l1_pte onemb_entry += bvalsel(19, 0, virt) return onemb_entry return 0