OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.61/] [tools/] [tcl/] [rw11/] [cpumon.tcl] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 21 wfjm
# $Id: cpumon.tcl 512 2013-04-28 07:44:02Z mueller $
2 20 wfjm
#
3
# Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
#
5
# This program is free software; you may redistribute and/or modify it under
6
# the terms of the GNU General Public License as published by the Free
7
# Software Foundation, either version 2, or at your option any later version.
8
#
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
# for complete details.
13
#
14
#  Revision History:
15
# Date         Rev Version  Comment
16
# 2013-04-26   510   1.0    Initial version
17
#
18
 
19
package provide rw11 1.0
20
 
21
package require rlink
22
package require rwxxtpp
23
 
24
namespace eval rw11 {
25
 
26
  #
27
  # cpumon: special command environment while cpu is running
28
  # 
29
 
30
  variable cpumon_active 0
31
  variable cpumon_prompt ">"
32
  variable cpumon_attnhdl_added 0
33
  variable cpumon_eofchar_save {puts {}}
34
 
35
  proc cpumon {{prompt "cpumon> "} } {
36
    variable cpumon_active
37
    variable cpumon_prompt
38
    variable cpumon_attnhdl_added
39
    variable cpumon_eofchar_save
40
    global   tirri_interactive
41
 
42
    # quit if cpumon already active
43
    if {$cpumon_active} {
44
      error "cpumon already active"
45
    }
46
 
47
    # check that attn handler is installed
48
    if {!$cpumon_attnhdl_added} {
49
      rls attn -add 0x0001 { rw11::cpumon_attncpu }
50
      set cpumon_attnhdl_added 1
51
    }
52
 
53
    # redefine ti_rri prompt and eof handling
54
    if { $tirri_interactive } {
55
      # setup new prompt (save old one...)
56
      set cpumon_prompt $prompt
57
      rename ::tclreadline::prompt1 ::rw11::cpumon_prompt1_save
58
      namespace eval ::tclreadline {
59
        proc prompt1 {} {
60
          return $rw11::cpumon_prompt
61
        }
62
      }
63
      # disable ^D (and save old setting)
64
      set cpumon_eofchar_save [::tclreadline::readline eofchar]
65
      ::tclreadline::readline eofchar \
66
        {puts {^D disabled, use tirri_exit if you really want to bail-out}}
67
    }
68
 
69
    set cpumon_active 1
70
    return ""
71
  }
72
 
73
  #
74
  # cpumon_attncpu: cpu attn handler
75
  #
76
  proc cpumon_attncpu {} {
77
    variable cpumon_active
78
    variable cpumon_eofchar_save
79
    global tirri_interactive
80
 
81
    if {$cpumon_active} {
82
      puts "CPU down attention"
83 21 wfjm
      puts [cpu0 show -r0ps]
84 20 wfjm
      # restore ti_rri prompt and eof handling
85
      if { $tirri_interactive } {
86
        rename ::tclreadline::prompt1 {}
87
        rename ::rw11::cpumon_prompt1_save ::tclreadline::prompt1
88
        ::tclreadline::readline eofchar $cpumon_eofchar_save
89
      }
90
      set cpumon_active 0
91
    }
92
    return ""
93
  }
94
 
95
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.