You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

73 lines
1.6 KiB

  1. proc proc_exists { NAME } {
  2. set n [info commands $NAME]
  3. set l [string length $n]
  4. return [expr $l != 0]
  5. }
  6. # Give: REGISTER name - must be a global variable.
  7. proc show_mmr32_reg { NAME } {
  8. global $NAME
  9. # we want $($NAME)
  10. set a [set [set NAME]]
  11. if ![catch { set v [memread32 $a] } msg ] {
  12. puts [format "%15s: (0x%08x): 0x%08x" $NAME $a $v]
  13. # Was a helper defined?
  14. set fn show_${NAME}_helper
  15. if [ proc_exists $fn ] {
  16. # Then call it
  17. $fn $NAME $a $v
  18. }
  19. return $v;
  20. } else {
  21. error [format "%s (%s)" $msg $NAME ]
  22. }
  23. }
  24. # Give: NAMES - an array of names accessable
  25. # in the callers symbol-scope.
  26. # VAL - the bits to display.
  27. proc show_mmr32_bits { NAMES VAL } {
  28. upvar $NAMES MYNAMES
  29. set w 5
  30. foreach {IDX N} $MYNAMES {
  31. set l [string length $N]
  32. if { $l > $w } { set w $l }
  33. }
  34. for { set x 24 } { $x >= 0 } { incr x -8 } {
  35. puts -nonewline " "
  36. for { set y 7 } { $y >= 0 } { incr y -1 } {
  37. set s $MYNAMES([expr $x + $y])
  38. puts -nonewline [format "%2d: %-*s | " [expr $x + $y] $w $s ]
  39. }
  40. puts ""
  41. puts -nonewline " "
  42. for { set y 7 } { $y >= 0 } { incr y -1 } {
  43. puts -nonewline [format " %d%*s | " [expr !!($VAL & (1 << ($x + $y)))] [expr $w -1] ""]
  44. }
  45. puts ""
  46. }
  47. }
  48. proc show_mmr_bitfield { MSB LSB VAL FIELDNAME FIELDVALUES } {
  49. set width [expr (($MSB - $LSB + 1) + 7) / 4]
  50. set nval [show_normalize_bitfield $VAL $MSB $LSB ]
  51. set name0 [lindex $FIELDVALUES 0 ]
  52. if [ string compare $name0 _NUMBER_ ] {
  53. set sval [lindex $FIELDVALUES $nval]
  54. } else {
  55. set sval ""
  56. }
  57. puts [format "%-15s: %d (0x%0*x) %s" $FIELDNAME $nval $width $nval $sval ]
  58. }