blob: 6ce68cd46275866f9de53571147e196310c0fe77 [file] [log] [blame]
Amit Arora39f29542010-09-14 12:03:22 +05301/*******************************************************************************
2 * Copyright (C) 2010, Linaro
3 * Copyright (C) 2010, IBM Corporation
4 *
5 * This file is part of PowerDebug.
6 *
7 * All rights reserved. This program and the accompanying materials
8 * are made available under the terms of the Eclipse Public License v1.0
9 * which accompanies this distribution, and is available at
10 * http://www.eclipse.org/legal/epl-v10.html
11 *
12 * Contributors:
13 * Amit Arora <amit.arora@linaro.org> (IBM Corporation)
14 * - initial API and implementation
15 *******************************************************************************/
16
Amit Arorae9e16b02010-08-03 10:15:20 +053017#include <stdio.h>
18#include <stdlib.h>
19#include <unistd.h>
20#include <string.h>
21#include <dirent.h>
22#include <getopt.h>
23#include <errno.h>
Amit Arora47fd9182010-08-24 13:26:06 +053024#include <ncurses.h>
Amit Arorae9e16b02010-08-03 10:15:20 +053025
Amit Arorafefe8bf2010-08-05 13:31:20 +053026#define VERSION "1.0"
27
Amit Arorae9e16b02010-08-03 10:15:20 +053028#define VALUE_MAX 16
Amit Arorac93e0712010-10-07 13:51:53 +053029#define TOTAL_FEATURE_WINS 3 /* Regulator, Clock and Sensor (for now) */
30
31WINDOW windows[TOTAL_FEATURE_WINS];
32extern char *win_names[TOTAL_FEATURE_WINS];
33
34enum {REGULATOR, CLOCK, SENSOR};
35extern int selectedwindow;
Amit Arorae9e16b02010-08-03 10:15:20 +053036
37struct regulator_info {
38 char name[NAME_MAX];
39 char state[VALUE_MAX];
40 char status[VALUE_MAX];
41 char type[VALUE_MAX];
42 char opmode[VALUE_MAX];
43 int microvolts;
Amit Arora83faf0e2010-08-05 12:27:42 +053044 int min_microvolts;
45 int max_microvolts;
Amit Arorae9e16b02010-08-03 10:15:20 +053046 int microamps;
Amit Arora83faf0e2010-08-05 12:27:42 +053047 int min_microamps;
48 int max_microamps;
49 int requested_microamps;
Amit Arorae9e16b02010-08-03 10:15:20 +053050 int num_users;
51} *regulators_info;
52
Amit Arora728e0c92010-09-14 12:06:09 +053053struct clock_info {
54 char name[NAME_MAX];
55 int flags;
56 int rate;
57 int usecount;
58} *clocks_info;
59
Amit Arorae9e16b02010-08-03 10:15:20 +053060extern int numregulators;
Amit Arora47fd9182010-08-24 13:26:06 +053061extern int dump;
Amit Arora29cb7572010-10-05 17:40:29 +053062extern double ticktime;
Amit Arorae9e16b02010-08-03 10:15:20 +053063
64extern void usage(char **argv);
Amit Arorafefe8bf2010-08-05 13:31:20 +053065extern void version(void);
Amit Arorae9e16b02010-08-03 10:15:20 +053066extern void print_regulator_info(int verbose);
Amit Arora0e512722010-10-01 12:24:16 +053067extern void dump_clock_info(int verbose);
68extern void dump_clock_info_recur(int verbose, char *clkdirpath);
Amit Arora24ed7d12010-09-14 12:12:58 +053069extern int read_and_print_clock_info(int verbose, int hrow, int selected);
70extern int read_and_print_clock_one_level(int verbose, int hrow, int selected);
Amit Arorae9e16b02010-08-03 10:15:20 +053071extern void get_sensor_info(char *path, char *name, char *sensor, int verbose);
Amit Aroradca56d02010-08-05 14:57:22 +053072extern void print_string_val(char *name, char *val);
Amit Arora24ed7d12010-09-14 12:12:58 +053073extern void init_clock_details(void);
Amit Arora728e0c92010-09-14 12:06:09 +053074extern void print_clock_header(int level);
75extern void print_sensor_header(void);
76extern void print_clock_info_line(int line, char *clockname, int flags,
77 int rate, int usecount, int highlight);
Amit Arora47fd9182010-08-24 13:26:06 +053078
79#define PT_COLOR_DEFAULT 1
80#define PT_COLOR_HEADER_BAR 2
81#define PT_COLOR_ERROR 3
82#define PT_COLOR_RED 4
83#define PT_COLOR_YELLOW 5
84#define PT_COLOR_GREEN 6
85#define PT_COLOR_BRIGHT 7
86#define PT_COLOR_BLUE 8
87
88
89
90extern void init_curses(void);
91extern void fini_curses(void);
Amit Arorac93e0712010-10-07 13:51:53 +053092extern void killall_windows(int all);
Amit Arora47fd9182010-08-24 13:26:06 +053093extern void show_header(void);
94extern void create_windows(void);
Amit Arorac93e0712010-10-07 13:51:53 +053095extern void create_selectedwindow(void);
Amit Arora47fd9182010-08-24 13:26:06 +053096extern void show_regulator_info(int verbose);