3 # All Memory regions have two components.
4 # (1) A count of regions, in the form N_NAME
5 # (2) An array within info about each region.
9 # <NAME>( RegionNumber , ATTRIBUTE )
11 # Where <NAME> is one of:
13 # N_FLASH & FLASH (internal memory)
14 # N_RAM & RAM (internal memory)
15 # N_MMREGS & MMREGS (for memory mapped registers)
16 # N_XMEM & XMEM (off chip memory, ie: flash on cs0, sdram on cs2)
17 # or N_UNKNOWN & UNKNOWN for things that do not exist.
19 # We have 1 unknown region.
21 # All MEMORY regions must have these attributes
22 # CS - chip select (if internal, use -1)
23 set UNKNOWN
(0,CHIPSELECT
) -1
24 # BASE - base address in memory
26 # LEN - length in bytes
27 set UNKNOWN
(0,LEN
) $CPU_MAX_ADDRESS
28 # HUMAN - human name of the region
29 set UNKNOWN
(0,HUMAN
) "unknown"
31 # flash, ram, mmr, unknown
33 # iflash, dflash, iram, dram
34 set UNKNOWN
(0,TYPE
) "unknown"
36 # unix style chmod bits
41 # hence: 7 - readwrite execute
46 set RWX_RW
[expr {$RWX_R_ONLY + $RWX_W_ONLY}]
47 set RWX_R_X
[expr {$RWX_R_ONLY + $RWX_X_ONLY}]
48 set RWX_RWX
[expr {$RWX_R_ONLY + $RWX_W_ONLY + $RWX_X_ONLY}]
49 set UNKNOWN
(0,RWX
) $RWX_NO_ACCESS
51 # WIDTH - access width
52 # 8,16,32 [0 means ANY]
53 set ACCESS_WIDTH_NONE
0
54 set ACCESS_WIDTH_8
$BIT0
55 set ACCESS_WIDTH_16
$BIT1
56 set ACCESS_WIDTH_32
$BIT2
57 set ACCESS_WIDTH_ANY
[expr {$ACCESS_WIDTH_8 + $ACCESS_WIDTH_16 + $ACCESS_WIDTH_32}]
58 set UNKNOWN
(0,ACCESS_WIDTH
) $ACCESS_WIDTH_NONE
60 proc iswithin
{ ADDRESS BASE LEN
} {
61 return [expr {(($ADDRESS - $BASE) >= 0) && (($BASE + $LEN - $ADDRESS) > 0)}]
64 proc address_info
{ ADDRESS
} {
66 foreach WHERE
{ FLASH RAM MMREGS XMEM UNKNOWN
} {
67 if { info exists
$WHERE } {
68 set lmt
[set N_
[set WHERE
]]
69 for { set region
0 } { $region < $lmt } { incr region
} {
70 if { iswithin
$ADDRESS $WHERE($region,BASE
) $WHERE($region,LEN
) } {
71 return "$WHERE $region";
77 # Return the 'unknown'
81 proc memread32
{ADDR
} {
83 if ![ catch { mem2array foo
32 $ADDR 1 } msg
] {
86 error "memread32: $msg"
90 proc memread16
{ADDR
} {
92 if ![ catch { mem2array foo
16 $ADDR 1 } msg
] {
95 error "memread16: $msg"
99 proc memread8
{ADDR
} {
101 if ![ catch { mem2array foo
8 $ADDR 1 } msg
] {
104 error "memread8: $msg"
108 proc memwrite32
{ADDR DATA
} {
110 if ![ catch { array2mem foo
32 $ADDR 1 } msg
] {
113 error "memwrite32: $msg"
117 proc memwrite16
{ADDR DATA
} {
119 if ![ catch { array2mem foo
16 $ADDR 1 } msg
] {
122 error "memwrite16: $msg"
126 proc memwrite8
{ADDR DATA
} {
128 if ![ catch { array2mem foo
8 $ADDR 1 } msg
] {
131 error "memwrite8: $msg"
135 proc memread32_phys
{ADDR
} {
137 if ![ catch { mem2array foo
32 $ADDR 1 phys
} msg
] {
140 error "memread32: $msg"
144 proc memread16_phys
{ADDR
} {
146 if ![ catch { mem2array foo
16 $ADDR 1 phys
} msg
] {
149 error "memread16: $msg"
153 proc memread8_phys
{ADDR
} {
155 if ![ catch { mem2array foo
8 $ADDR 1 phys
} msg
] {
158 error "memread8: $msg"
162 proc memwrite32_phys
{ADDR DATA
} {
164 if ![ catch { array2mem foo
32 $ADDR 1 phys
} msg
] {
167 error "memwrite32: $msg"
171 proc memwrite16_phys
{ADDR DATA
} {
173 if ![ catch { array2mem foo
16 $ADDR 1 phys
} msg
] {
176 error "memwrite16: $msg"
180 proc memwrite8_phys
{ADDR DATA
} {
182 if ![ catch { array2mem foo
8 $ADDR 1 phys
} msg
] {
185 error "memwrite8: $msg"