public virtual bool writeDP(REG_APnDP_A3_A2 addr, UInt32 data) { Debug.Assert(Enum.IsDefined(typeof(REG_APnDP_A3_A2), addr)); var num = this.next_access_number; // Skip writing DP SELECT register if its value is not changing. if (addr == DP_REG["SELECT"]) { if (data == this._dp_select) { if (LOG_DAP) { Trace.TraceInformation("writeDP:%06d cached (addr=0x%08x) = 0x%08x", num, addr, data); } return(true); } this._dp_select = (int)data; } // Write the DP register. try { if (LOG_DAP) { Trace.TraceInformation("writeDP:%06d (addr=0x%08x) = 0x%08x", num, addr, data); } this.link.write_reg(addr, data); } catch (Exception error) { this._handle_error(error, num); throw; } return(true); }
public Func <List <UInt32> > reg_read_repeat(UInt16 num_repeats, REG_APnDP_A3_A2 reg_id, byte dap_index = 0, bool now = true) { //Debug.Assert(num_repeats is six.integer_types); Debug.Assert(Enum.IsDefined(typeof(REG_APnDP_A3_A2), reg_id)); //Debug.Assert(dap_index is six.integer_types); //Debug.Assert(now is @bool); EDapTransferRequestByte request = DebugUnitV2_0_0.DapReadTransferRequestByte(reg_id); var transfer = this._write(dap_index, num_repeats, request, null); Debug.Assert(transfer != null); List <uint> reg_read_repeat_cb() { List <UInt32> res = transfer.get_result(); Debug.Assert(res.Count == num_repeats); return(res); } if (now) { List <UInt32> result = reg_read_repeat_cb(); return(new Func <List <UInt32> >(() => result)); } else { return(new Func <List <UInt32> >(() => reg_read_repeat_cb())); } }
public Func <UInt32> read_reg(REG_APnDP_A3_A2 reg_id, byte dap_index = 0, bool now = true) { Debug.Assert(Enum.IsDefined(typeof(REG_APnDP_A3_A2), reg_id)); EDapTransferRequestByte request = DebugUnitV2_0_0.DapReadTransferRequestByte(reg_id); var transfer = this._write(dap_index, 1, request, null); Debug.Assert(transfer != null); uint read_reg_cb() { List <UInt32> res = transfer.get_result(); Debug.Assert(res.Count == 1); return(res[0]); } if (now) { UInt32 result = read_reg_cb(); return(new Func <UInt32>(() => result)); } else { return(new Func <UInt32>(() => read_reg_cb())); } }
public static REG_APnDP_A3_A2 _ap_addr_to_reg(UInt32 addr) { REG_APnDP_A3_A2 result = (REG_APnDP_A3_A2)(4 + ((addr & A3_A2) >> 2)); Debug.Assert(Enum.IsDefined(typeof(REG_APnDP_A3_A2), result)); return(result); }
// read aligned word (the size is in words) public virtual List <UInt32> _readBlock32(UInt32 addr, UInt16 size) { var num = this.dp.next_access_number; if (DebugAccessPort.LOG_DAP) { Trace.TraceInformation("_readBlock32:%06d (addr=0x%08x, size=%d) {", num, addr, size); } // put address in TAR this.write_reg(DebugAccessPort.AP_REG["CSW"], CSW_VALUE | CSW_SIZE32); this.write_reg(DebugAccessPort.AP_REG["TAR"], addr); List <UInt32> resp; try { REG_APnDP_A3_A2 reg = DebugAccessPort._ap_addr_to_reg((this.ap_num << DebugAccessPort.APSEL_SHIFT) | DebugAccessPort.READ | DebugAccessPort.AP_ACC | DebugAccessPort.AP_REG["DRW"]); resp = this.link.reg_read_repeat(size, reg)(); } catch (Exception error) { // Annotate error with target address. this._handle_error(error, num); throw new Exception(string.Format("Fault Address {0:X8}", addr), error); // error.fault_address = addr; } if (DebugAccessPort.LOG_DAP) { Trace.TraceInformation("_readBlock32:%06d }", num); } return(resp); }
// write aligned word ("data" are words) public virtual void _writeBlock32(UInt32 addr, List <UInt32> data) { var num = this.dp.next_access_number; if (DebugAccessPort.LOG_DAP) { Trace.TraceInformation("_writeBlock32:%06d (addr=0x%08x, size=%d) {", num, addr, data.Count); } // put address in TAR this.write_reg(DebugAccessPort.AP_REG["CSW"], CSW_VALUE | CSW_SIZE32); this.write_reg(DebugAccessPort.AP_REG["TAR"], addr); try { REG_APnDP_A3_A2 reg = DebugAccessPort._ap_addr_to_reg(this.ap_num << DebugAccessPort.APSEL_SHIFT | DebugAccessPort.WRITE | DebugAccessPort.AP_ACC | DebugAccessPort.AP_REG["DRW"]); this.link.reg_write_repeat((UInt16)data.Count, reg, data); } catch (Exception error) { // Annotate error with target address. this._handle_error(error, num); throw new Exception(string.Format("Fault Address {0:X8}", addr), error); // error.fault_address = addr; } if (DebugAccessPort.LOG_DAP) { Trace.TraceInformation("_writeBlock32:%06d }", num); } }
public void write_reg(REG_APnDP_A3_A2 reg_id, UInt32 value, byte dap_index = 0) { Debug.Assert(Enum.IsDefined(typeof(REG_APnDP_A3_A2), reg_id)); EDapTransferRequestByte request = DebugUnitV2_0_0.DapWriteTransferRequestByte(reg_id); this._write(dap_index, 1, request, new List <UInt32> { value }); }
public void reg_write_repeat(UInt16 num_repeats, REG_APnDP_A3_A2 reg_id, List <UInt32> data_array, byte dap_index = 0) { //Debug.Assert(num_repeats is six.integer_types); Debug.Assert(num_repeats == data_array.Count); Debug.Assert(Enum.IsDefined(typeof(REG_APnDP_A3_A2), reg_id)); //Debug.Assert(dap_index is six.integer_types); EDapTransferRequestByte request = DebugUnitV2_0_0.DapWriteTransferRequestByte(reg_id); this._write(dap_index, num_repeats, request, data_array); }
public virtual Func <UInt32> readAP(UInt32 addr, bool now = true) { // Debug.Assert(six.integer_types.Contains(type(addr))); var num = this.next_access_number; //object res = null; REG_APnDP_A3_A2 ap_reg = _ap_addr_to_reg(READ | AP_ACC | (addr & A3_A2)); Func <UInt32> result_cb; try { UInt32 ap_sel = addr & APSEL; var bank_sel = addr & APBANKSEL; this.writeDP(DP_REG["SELECT"], ap_sel | bank_sel); result_cb = this.link.read_reg(ap_reg, now: false); } catch (Exception error) { this._handle_error(error, num); throw; } uint readAPCb() { try { var result = result_cb(); if (LOG_DAP) { Trace.TraceInformation("readAP:%06d %s(addr=0x%08x) -> 0x%08x", num, now ? "" : "...", addr, result); } return(result); } catch (Exception error) { this._handle_error(error, num); throw; } } if (now) { UInt32 result = readAPCb(); return(new Func <UInt32>(() => result)); } else { if (LOG_DAP) { Trace.TraceInformation("readAP:%06d (addr=0x%08x) -> ...", num, addr); } return(readAPCb); } }
public static EDapTransferRequestByte DapWriteTransferRequestByte(REG_APnDP_A3_A2 reg_id) { Debug.Assert(Enum.IsDefined(typeof(REG_APnDP_A3_A2), reg_id)); EDapTransferRequestByte request = EDapTransferRequestByte.WRITE; if ((int)reg_id < 4) { request |= EDapTransferRequestByte.DP_ACC; } else { request |= EDapTransferRequestByte.AP_ACC; } request |= (EDapTransferRequestByte)((int)reg_id % 4 * 4); return(request); }
public virtual Func <UInt32> readDP(REG_APnDP_A3_A2 addr, bool now = true) { Debug.Assert(Enum.IsDefined(typeof(REG_APnDP_A3_A2), addr)); var num = this.next_access_number; Func <UInt32> result_cb; try { result_cb = this.link.read_reg(addr, now: false); } catch (Exception error) { this._handle_error(error, num); throw; } uint readDPCb() { try { var result = result_cb(); if (LOG_DAP) { Trace.TraceInformation("readDP:%06d %s(addr=0x%08x) -> 0x%08x", num, now ? "" : "...", addr, result); } return(result); } catch (Exception error) { this._handle_error(error, num); throw; } } if (now) { UInt32 result = readDPCb(); return(new Func <UInt32>(() => result)); } else { if (LOG_DAP) { Trace.TraceInformation("readDP:%06d (addr=0x%08x) -> ...", num, addr); } return(readDPCb); } }
public virtual bool writeAP(UInt32 addr, UInt32 data) { // Debug.Assert(six.integer_types.Contains(type(addr))); var num = this.next_access_number; UInt32 ap_sel = addr & APSEL; byte bank_sel = (byte)(addr & APBANKSEL); byte ap_regaddr = (byte)(addr & APREG_MASK); // Don't need to write CSW if it's not changing value. if (ap_regaddr == AP_REG["CSW"]) { if (this._csw.ContainsKey(ap_sel) && (data == this._csw[ap_sel])) { if (LOG_DAP) { Trace.TraceInformation("writeAP:%06d cached (addr=0x%08x) = 0x%08x", num, addr, data); } return(true); } this._csw[ap_sel] = data; } // Select the AP and bank. this.writeDP(DP_REG["SELECT"], ap_sel | bank_sel); // Perform the AP register write. REG_APnDP_A3_A2 ap_reg = _ap_addr_to_reg(WRITE | AP_ACC | (addr & A3_A2)); try { if (LOG_DAP) { Trace.TraceInformation("writeAP:%06d (addr=0x%08x) = 0x%08x", num, addr, data); } this.link.write_reg(ap_reg, data); } catch (Exception error) { this._handle_error(error, num); throw; } return(true); }
public virtual void write_reg(REG_APnDP_A3_A2 addr, UInt32 data) { this.writeDP(addr, data); }
public virtual Func <UInt32> read_reg(REG_APnDP_A3_A2 addr, bool now = true) { return(this.readDP(addr, now)); }