Amit Arora | 39f2954 | 2010-09-14 12:03:22 +0530 | [diff] [blame] | 1 | /******************************************************************************* |
| 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 Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 17 | #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 Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 24 | #include <ncurses.h> |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 25 | |
Amit Arora | fefe8bf | 2010-08-05 13:31:20 +0530 | [diff] [blame] | 26 | #define VERSION "1.0" |
| 27 | |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 28 | #define VALUE_MAX 16 |
Amit Arora | c93e071 | 2010-10-07 13:51:53 +0530 | [diff] [blame^] | 29 | #define TOTAL_FEATURE_WINS 3 /* Regulator, Clock and Sensor (for now) */ |
| 30 | |
| 31 | WINDOW windows[TOTAL_FEATURE_WINS]; |
| 32 | extern char *win_names[TOTAL_FEATURE_WINS]; |
| 33 | |
| 34 | enum {REGULATOR, CLOCK, SENSOR}; |
| 35 | extern int selectedwindow; |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 36 | |
| 37 | struct 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 Arora | 83faf0e | 2010-08-05 12:27:42 +0530 | [diff] [blame] | 44 | int min_microvolts; |
| 45 | int max_microvolts; |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 46 | int microamps; |
Amit Arora | 83faf0e | 2010-08-05 12:27:42 +0530 | [diff] [blame] | 47 | int min_microamps; |
| 48 | int max_microamps; |
| 49 | int requested_microamps; |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 50 | int num_users; |
| 51 | } *regulators_info; |
| 52 | |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 53 | struct clock_info { |
| 54 | char name[NAME_MAX]; |
| 55 | int flags; |
| 56 | int rate; |
| 57 | int usecount; |
| 58 | } *clocks_info; |
| 59 | |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 60 | extern int numregulators; |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 61 | extern int dump; |
Amit Arora | 29cb757 | 2010-10-05 17:40:29 +0530 | [diff] [blame] | 62 | extern double ticktime; |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 63 | |
| 64 | extern void usage(char **argv); |
Amit Arora | fefe8bf | 2010-08-05 13:31:20 +0530 | [diff] [blame] | 65 | extern void version(void); |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 66 | extern void print_regulator_info(int verbose); |
Amit Arora | 0e51272 | 2010-10-01 12:24:16 +0530 | [diff] [blame] | 67 | extern void dump_clock_info(int verbose); |
| 68 | extern void dump_clock_info_recur(int verbose, char *clkdirpath); |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 69 | extern int read_and_print_clock_info(int verbose, int hrow, int selected); |
| 70 | extern int read_and_print_clock_one_level(int verbose, int hrow, int selected); |
Amit Arora | e9e16b0 | 2010-08-03 10:15:20 +0530 | [diff] [blame] | 71 | extern void get_sensor_info(char *path, char *name, char *sensor, int verbose); |
Amit Arora | dca56d0 | 2010-08-05 14:57:22 +0530 | [diff] [blame] | 72 | extern void print_string_val(char *name, char *val); |
Amit Arora | 24ed7d1 | 2010-09-14 12:12:58 +0530 | [diff] [blame] | 73 | extern void init_clock_details(void); |
Amit Arora | 728e0c9 | 2010-09-14 12:06:09 +0530 | [diff] [blame] | 74 | extern void print_clock_header(int level); |
| 75 | extern void print_sensor_header(void); |
| 76 | extern void print_clock_info_line(int line, char *clockname, int flags, |
| 77 | int rate, int usecount, int highlight); |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 78 | |
| 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 | |
| 90 | extern void init_curses(void); |
| 91 | extern void fini_curses(void); |
Amit Arora | c93e071 | 2010-10-07 13:51:53 +0530 | [diff] [blame^] | 92 | extern void killall_windows(int all); |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 93 | extern void show_header(void); |
| 94 | extern void create_windows(void); |
Amit Arora | c93e071 | 2010-10-07 13:51:53 +0530 | [diff] [blame^] | 95 | extern void create_selectedwindow(void); |
Amit Arora | 47fd918 | 2010-08-24 13:26:06 +0530 | [diff] [blame] | 96 | extern void show_regulator_info(int verbose); |