Debian Codegraph @

testsuite/systemtap.examples/stapgames/tapset/gmtty.stp

raw
1 # TTY related routines for games
2 # Copyright (C) 2011 Masami Hiramatsu <[email protected]>
3 #
4 # This file is free software and is distributed under the terms of the GNU
5 # General Public License (GPL); either version 2, or (at your option) any
6 # later version.
7
8 global GM_tty_ws_row, GM_tty_ws_col, GM_tty_name
9
10 # Initialize current TTY -- must be called from begin
11 function game_tty_init:long ()
12 {
13 tty = @cast(task_current(), "task_struct", "kernel")->signal->tty
14 if (tty) {
15 namep = @cast(tty,"tty_struct", "kernel")->name
16 GM_tty_name = kernel_string(namep)
17 GM_tty_ws_col = @cast(tty, "tty_struct", "kernel")->winsize->ws_col
18 GM_tty_ws_row = @cast(tty, "tty_struct", "kernel")->winsize->ws_row
19 }
20 return tty
21 }
22
23 probe begin(-100) {
24 if (game_tty_init() == 0) {
25 print("Failed to get current tty\n")
26 exit()
27 }
28 }
29
30 probe game.tty.resize = kernel.function("tty_do_resize") {
31 if (kernel_string($tty->name) == GM_tty_name) {
32 row = $ws->ws_row
33 col = $ws->ws_col
34 }
35 }
36
37 probe game.tty.resize {
38 GM_tty_ws_row = row
39 GM_tty_ws_col = col
40 }
41
42 function game_tty_ws_row:long () {
43 return GM_tty_ws_row
44 }
45
46 function game_tty_ws_col:long () {
47 return GM_tty_ws_col
48 }