blob: 356308c8b2a0eb2693e91e45021d800c70a10e83 [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
29
30struct regulator_info {
31 char name[NAME_MAX];
32 char state[VALUE_MAX];
33 char status[VALUE_MAX];
34 char type[VALUE_MAX];
35 char opmode[VALUE_MAX];
36 int microvolts;
Amit Arora83faf0e2010-08-05 12:27:42 +053037 int min_microvolts;
38 int max_microvolts;
Amit Arorae9e16b02010-08-03 10:15:20 +053039 int microamps;
Amit Arora83faf0e2010-08-05 12:27:42 +053040 int min_microamps;
41 int max_microamps;
42 int requested_microamps;
Amit Arorae9e16b02010-08-03 10:15:20 +053043 int num_users;
44} *regulators_info;
45
Amit Arora728e0c92010-09-14 12:06:09 +053046struct clock_info {
47 char name[NAME_MAX];
48 int flags;
49 int rate;
50 int usecount;
51} *clocks_info;
52
Amit Arorae9e16b02010-08-03 10:15:20 +053053extern int numregulators;
Amit Arora47fd9182010-08-24 13:26:06 +053054extern int dump;
Amit Arorae9e16b02010-08-03 10:15:20 +053055
56extern void usage(char **argv);
Amit Arorafefe8bf2010-08-05 13:31:20 +053057extern void version(void);
Amit Arorae9e16b02010-08-03 10:15:20 +053058extern void print_regulator_info(int verbose);
Amit Arora24ed7d12010-09-14 12:12:58 +053059extern int read_and_print_clock_info(int verbose, int hrow, int selected);
60extern int read_and_print_clock_one_level(int verbose, int hrow, int selected);
Amit Arorae9e16b02010-08-03 10:15:20 +053061extern void get_sensor_info(char *path, char *name, char *sensor, int verbose);
Amit Aroradca56d02010-08-05 14:57:22 +053062extern void print_string_val(char *name, char *val);
Amit Arora24ed7d12010-09-14 12:12:58 +053063extern void init_clock_details(void);
Amit Arora728e0c92010-09-14 12:06:09 +053064extern void print_clock_header(int level);
65extern void print_sensor_header(void);
66extern void print_clock_info_line(int line, char *clockname, int flags,
67 int rate, int usecount, int highlight);
Amit Arora47fd9182010-08-24 13:26:06 +053068
69#define PT_COLOR_DEFAULT 1
70#define PT_COLOR_HEADER_BAR 2
71#define PT_COLOR_ERROR 3
72#define PT_COLOR_RED 4
73#define PT_COLOR_YELLOW 5
74#define PT_COLOR_GREEN 6
75#define PT_COLOR_BRIGHT 7
76#define PT_COLOR_BLUE 8
77
78
79
80extern void init_curses(void);
81extern void fini_curses(void);
82extern void killall_windows(void);
83extern void show_header(void);
84extern void create_windows(void);
Amit Arora24ed7d12010-09-14 12:12:58 +053085extern int create_regulator_win(int row, int numrows, int *pshare);
86extern int create_clock_win(int row, int numrows, int *pshare);
87extern int create_sensor_win(int row, int numrows, int *pshare);
Amit Arora47fd9182010-08-24 13:26:06 +053088extern void show_regulator_info(int verbose);