tools/thermal/tmon/tui.c
Source file repositories/reference/linux-study-clean/tools/thermal/tmon/tui.c
File Facts
- System
- Linux kernel
- Corpus path
tools/thermal/tmon/tui.c- Extension
.c- Size
- 16560 bytes
- Lines
- 657
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
Dependency Surface
unistd.hstdio.hstdlib.hstring.hstdint.hncurses.htime.hsyslog.hpanel.hpthread.hsignal.htmon.h
Detected Declarations
function close_panelfunction close_windowfunction close_windowsfunction write_status_barfunction diag_dev_rowsfunction setup_windowsfunction resize_handlerfunction show_cooling_devicefunction show_dialoguefunction write_dialogue_winfunction show_control_wfunction initialize_cursesfunction show_title_barfunction handle_input_valfunction handle_input_choicefunction draw_hbarfunction trip_type_to_charfunction draw_tp_linefunction show_data_wfunction show_sensors_wfunction disable_tui
Annotated Snippet
if (dialogue_window) {
dialogue_panel = new_panel(dialogue_window);
if (!dialogue_panel)
syslog(LOG_DEBUG, "No dialogue panel\n");
else {
/* Set up the user pointer to the next panel*/
set_panel_userptr(data_panel, dialogue_panel);
set_panel_userptr(dialogue_panel, data_panel);
top = data_panel;
}
} else
syslog(LOG_INFO, "no dialogue win, term too small\n");
}
doupdate();
werase(stdscr);
refresh();
}
void resize_handler(int sig)
{
/* start over when term gets resized, but first we clean up */
close_windows();
endwin();
refresh();
clear();
getmaxyx(stdscr, maxy, maxx); /* get the new screen size */
setup_windows();
/* rate limit */
sleep(1);
syslog(LOG_DEBUG, "SIG %d, term resized to %d x %d\n",
sig, maxy, maxx);
signal(SIGWINCH, resize_handler);
}
const char cdev_title[] = " COOLING DEVICES ";
void show_cooling_device(void)
{
int i, j, x, y = 0;
if (tui_disabled || !cooling_device_window)
return;
werase(cooling_device_window);
wattron(cooling_device_window, A_BOLD);
mvwprintw(cooling_device_window, 1, 1,
"ID Cooling Dev Cur Max Thermal Zone Binding");
wattroff(cooling_device_window, A_BOLD);
for (j = 0; j < ptdata.nr_cooling_dev; j++) {
/* draw cooling device list on the left in the order of
* cooling device instances. skip unused idr.
*/
mvwprintw(cooling_device_window, j + 2, 1,
"%02d %12.12s%6lu %6lu",
ptdata.cdi[j].instance,
ptdata.cdi[j].type,
ptdata.cdi[j].cur_state,
ptdata.cdi[j].max_state);
}
/* show cdev binding, y is the global cooling device instance */
for (i = 0; i < ptdata.nr_tz_sensor; i++) {
int tz_inst = ptdata.tzi[i].instance;
for (j = 0; j < ptdata.nr_cooling_dev; j++) {
int cdev_inst;
y = j;
x = tz_inst * TZONE_RECORD_SIZE + TZ_LEFT_ALIGN;
draw_hbar(cooling_device_window, y+2, x,
TZONE_RECORD_SIZE-1, ACS_VLINE, false);
/* draw a column of spaces to separate thermal zones */
mvwprintw(cooling_device_window, y+2, x-1, " ");
if (ptdata.tzi[i].cdev_binding) {
cdev_inst = ptdata.cdi[j].instance;
unsigned long trip_binding =
ptdata.tzi[i].trip_binding[cdev_inst];
int k = 0; /* per zone trip point id that
* binded to this cdev, one to
* many possible based on the
* binding bitmask.
*/
syslog(LOG_DEBUG,
"bind tz%d cdev%d tp%lx %d cdev%lx\n",
i, j, trip_binding, y,
ptdata.tzi[i].cdev_binding);
/* draw each trip binding for the cdev */
while (trip_binding >>= 1) {
k++;
if (!(trip_binding & 1))
continue;
Annotation
- Immediate include surface: `unistd.h`, `stdio.h`, `stdlib.h`, `string.h`, `stdint.h`, `ncurses.h`, `time.h`, `syslog.h`.
- Detected declarations: `function close_panel`, `function close_window`, `function close_windows`, `function write_status_bar`, `function diag_dev_rows`, `function setup_windows`, `function resize_handler`, `function show_cooling_device`, `function show_dialogue`, `function write_dialogue_win`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.