X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=tcl%2Fmmr_helpers.tcl;h=5c37fcfdc138baeb30ddc553ef43270d4a693840;hb=35b20195b86ceeda1300e0cc405cbbcbefc1f0fd;hp=d9b6e63834678a6c7f791f3cbc67331a2806fcd1;hpb=64d89d5ee1a554fbae8eb0a7231ccb2dc4428c1a;p=fw%2Fopenocd diff --git a/tcl/mmr_helpers.tcl b/tcl/mmr_helpers.tcl index d9b6e6383..5c37fcfdc 100644 --- a/tcl/mmr_helpers.tcl +++ b/tcl/mmr_helpers.tcl @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-or-later proc proc_exists { NAME } { set n [info commands $NAME] @@ -70,3 +71,22 @@ proc show_mmr_bitfield { MSB LSB VAL FIELDNAME FIELDVALUES } { } echo [format "%-15s: %d (0x%0*x) %s" $FIELDNAME $nval $width $nval $sval ] } + +# Give: ADDR - address of the register. +# BIT - bit's number. + +proc get_mmr_bit { ADDR BIT } { + set val [memread32 $ADDR] + set bit_val [expr {$val & [expr {1 << $BIT}]}] + return $bit_val +} + + +# Give: ADDR - address of the register. +# MSB - MSB bit's number. +# LSB - LSB bit's number. + +proc get_mmr_bitfield { ADDR MSB LSB } { + set rval [memread32 $ADDR] + return normalize_bitfield $rval $MSB $LSB +}