def get_expected_reg_value(r): i = register_name_to_index(r) if is_psr_subregister(i): return 0x55555555 & sysm_to_psr_mask(i) if i < 0: i += 100 return i + 1
def write_core_registers_raw(self, reg, data): reg = [register_name_to_index(r) for r in reg] # logging.info("mockcore[%x]:write(%s, %s)", id(self), reg, data) for r, v in zip(reg, data): if (r < 0) and (r >= -4): shift = (-r - 1) * 8 mask = 0xffffffff ^ (0xff << shift) data = (self.regs[CORE_REGISTER['cfbp']] & mask) | ((v & 0xff) << shift) self.regs[CORE_REGISTER['cfbp']] = data else: self.regs[r] = v
def read_core_registers_raw(self, reg_list): reg_list = [register_name_to_index(reg) for reg in reg_list] results = [] for r in reg_list: if (r < 0) and (r >= -4): v = self.regs[CORE_REGISTER['cfbp']] v = (v >> ((-r - 1) * 8)) & 0xff else: if r not in self.regs: self.regs[r] = 0 v = self.regs[r] results.append(v) # logging.info("mockcore[%x]:read(%s)=%s", id(self), reg_list, results) return results
def write_core_registers_raw(self, reg, data): reg = [register_name_to_index(r) for r in reg] # logging.info("mockcore[%x]:write(%s, %s)", id(self), reg, data) for r, v in zip(reg, data): if is_cfbp_subregister(r): shift = (-r - 1) * 8 mask = 0xffffffff ^ (0xff << shift) data = (self.regs[CORE_REGISTER['cfbp']] & mask) | ((v & 0xff) << shift) self.regs[CORE_REGISTER['cfbp']] = data elif is_psr_subregister(r): mask = sysm_to_psr_mask(r) data = (self.regs[CORE_REGISTER['xpsr']] & (0xffffffff ^ mask)) | (v & mask) self.regs[CORE_REGISTER['xpsr']] = data else: self.regs[r] = v
def write_core_registers_raw(self, reg, data): reg = [register_name_to_index(r) for r in reg] # logging.info("mockcore[%x]:write(%s, %s)", id(self), reg, data) for r, v in zip(reg, data): if is_cfbp_subregister(r): shift = (-r - 1) * 8 mask = 0xffffffff ^ (0xff << shift) data = (self.regs[CORE_REGISTER['cfbp']] & mask) | ((v & 0xff) << shift) self.regs[CORE_REGISTER['cfbp']] = data elif is_psr_subregister(r): mask = sysm_to_psr_mask(r) data = (self.regs[CORE_REGISTER['xpsr']] & (0xffffffff ^ mask)) | (v & mask) self.regs[CORE_REGISTER['xpsr']] = data else: self.regs[r] = v
def read_core_registers_raw(self, reg_list): reg_list = [register_name_to_index(reg) for reg in reg_list] results = [] for r in reg_list: if is_cfbp_subregister(r): v = self.regs[CORE_REGISTER['cfbp']] v = (v >> ((-r - 1) * 8)) & 0xff elif is_psr_subregister(r): v = self.regs[CORE_REGISTER['xpsr']] v &= sysm_to_psr_mask(r) else: if r not in self.regs: self.regs[r] = 0 v = self.regs[r] results.append(v) # logging.info("mockcore[%x]:read(%s)=%s", id(self), reg_list, results) return results
def read_core_registers_raw(self, reg_list): reg_list = [register_name_to_index(reg) for reg in reg_list] results = [] for r in reg_list: if is_cfbp_subregister(r): v = self.regs[CORE_REGISTER['cfbp']] v = (v >> ((-r - 1) * 8)) & 0xff elif is_psr_subregister(r): v = self.regs[CORE_REGISTER['xpsr']] v &= sysm_to_psr_mask(r) else: if r not in self.regs: self.regs[r] = 0 v = self.regs[r] results.append(v) # logging.info("mockcore[%x]:read(%s)=%s", id(self), reg_list, results) return results
def get_expected_reg_value(r): i = register_name_to_index(r) if i < 0: i += 100 return i + 1