Skip to content

Commit

Permalink
zynq7000: Defined memory mappings for the On-Chip Memory RAM regions
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmux committed Nov 14, 2023
1 parent 55e455f commit ace41ae
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/target/zynq7000.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,16 @@

#define CORTEXA_DBG_IDR 0x000U

/* On-Chip Memory (OCM) region definitions */
#define ZYNQ7_OCM_LOW_BASE 0x00000000U
#define ZYNQ7_OCM_HIGH_BASE 0xfffc0000U
#define ZYNQ7_OCM_CHUNK_SIZE 0x00010000U

/* System Level Control Registers */
#define ZYNQ7_SLCR_BASE 0xf8000000U
#define ZYNQ7_SLCR_UNLOCK (ZYNQ7_SLCR_BASE + 0x008U)
#define ZYNQ7_SLCR_PSS_RST_CTRL (ZYNQ7_SLCR_BASE + 0x200U)
#define ZYNQ7_SLCR_OCM_CFG (ZYNQ7_SLCR_BASE + 0x910U)

/* UG585 Appendix A: Register Details, pg1639 */
#define ZYNQ7_SLCR_UNLOCK_KEY 0x0000df0dU
Expand All @@ -72,6 +78,17 @@ bool zynq7_probe(target_s *const target)

target->driver = "Zynq-7000";
target->reset = zynq7_reset;

/* Read back the OCM mapping status */
const uint8_t ocm_mapping = target_mem_read32(target, ZYNQ7_SLCR_OCM_CFG) & 0x0fU;
/* For each of the 4 chunks, pull out if it's mapped low or high and define a mapping accordingly */
for (uint8_t chunk = 0U; chunk < 4U; ++chunk) {
const bool chunk_high = (ocm_mapping >> chunk) & 1U;
const uint32_t chunk_offset = chunk * ZYNQ7_OCM_CHUNK_SIZE;
target_add_ram(
target, (chunk_high ? ZYNQ7_OCM_HIGH_BASE : ZYNQ7_OCM_LOW_BASE) + chunk_offset, ZYNQ7_OCM_CHUNK_SIZE);
}

return true;
}

Expand Down

0 comments on commit ace41ae

Please sign in to comment.