diff options
-rw-r--r-- | include/private/android_filesystem_config.h | 1 | ||||
-rw-r--r-- | logcat/tests/logcat_test.cpp | 1 | ||||
-rwxr-xr-x | rootdir/etc/init.testmenu | 322 | ||||
-rw-r--r-- | toolbox/Android.mk | 8 | ||||
-rw-r--r-- | toolbox/alarm.c | 190 | ||||
-rw-r--r-- | toolbox/exists.c | 16 | ||||
-rw-r--r-- | toolbox/insmod.c | 97 | ||||
-rw-r--r-- | toolbox/lsmod.c | 10 | ||||
-rw-r--r-- | toolbox/lsusb.c | 227 | ||||
-rw-r--r-- | toolbox/readtty.c | 183 | ||||
-rw-r--r-- | toolbox/rmmod.c | 53 | ||||
-rw-r--r-- | toolbox/rotatefb.c | 71 | ||||
-rw-r--r-- | toolbox/setkey.c | 89 | ||||
-rw-r--r-- | toolbox/syren.c | 158 |
14 files changed, 0 insertions, 1426 deletions
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h index b2f91a5..5efe2e1 100644 --- a/include/private/android_filesystem_config.h +++ b/include/private/android_filesystem_config.h @@ -232,7 +232,6 @@ static const struct fs_path_config android_files[] = { { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.sh" }, { 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.trout.rc" }, { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.ril" }, - { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.testmenu" }, { 00550, AID_DHCP, AID_SHELL, 0, "system/etc/dhcpcd/dhcpcd-run-hooks" }, { 00444, AID_RADIO, AID_AUDIO, 0, "system/etc/AudioPara4.csv" }, { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/ppp/*" }, diff --git a/logcat/tests/logcat_test.cpp b/logcat/tests/logcat_test.cpp index b1412ff..b358485 100644 --- a/logcat/tests/logcat_test.cpp +++ b/logcat/tests/logcat_test.cpp @@ -548,7 +548,6 @@ TEST(logcat, logrotate_suffix) { static const char rotated_log_filename_prefix[] = "log.txt."; static const size_t rotated_log_filename_prefix_len = strlen(rotated_log_filename_prefix); - static const char total[] = "total "; static const char log_filename[] = "log.txt"; if (!strncmp(buffer, rotated_log_filename_prefix, rotated_log_filename_prefix_len)) { diff --git a/rootdir/etc/init.testmenu b/rootdir/etc/init.testmenu deleted file mode 100755 index 7ae16d5..0000000 --- a/rootdir/etc/init.testmenu +++ /dev/null @@ -1,322 +0,0 @@ -#!/system/bin/sh - -atdev=/dev/omap_csmi_tty0 -pppdev=/dev/omap_csmi_tty1 - -n1=`cat /data/phoneentry1 2>/dev/null` -n2=`cat /data/phoneentry2 2>/dev/null` -n3=`cat /data/phoneentry3 2>/dev/null` -n1=${n1:-"*#06#"} -n2=${n2:-"*#06#"} -n3=${n3:-"*#06#"} -phoneoutputpid= -eventoutputpid= -notifypid= -notifytoggle=false -pppdpid= -powerdidletime=120 - -# map phone specific keys -setkey -k 0xe4 -v 0x23 # map # -setkey -k 0xe3 -v 0x2a # map * -setkey -k 231 -v 513 # map send to newline -#setkey -k 0x67 -v 0x20b # map up to scroll back -#setkey -k 0x6c -v 0x20a # map down to scroll forward -setkey -k 0x73 -v 0x20b # map volume up to scroll back -setkey -k 0x72 -v 0x20a # map volume down to scroll forward -setkey -k 0x60 -v 0x211 # map PoC to next console - -# tuttle keys -setkey -k 0x38 -v 0x703 # map leftalt to alt -setkey -k 0x9b -v 0x703 # map mail to alt -setkey -t 8 -k 0x9b -v 0x703 # map alt-mail to alt -setkey -t 8 -k 0x10 -v 0x21 # map alt-q to ! -setkey -t 8 -k 0x11 -v 0x31 # map alt-w to 1 -setkey -t 8 -k 0x12 -v 0x32 # map alt-e to 2 -setkey -t 8 -k 0x13 -v 0x33 # map alt-r to 3 -setkey -t 8 -k 0x14 -v 0x2b # map alt-t to + -setkey -t 8 -k 0x15 -v 0x28 # map alt-y to ( -setkey -t 8 -k 0x16 -v 0x29 # map alt-u to ) -setkey -t 8 -k 0x17 -v 0x2d # map alt-i to - -setkey -t 8 -k 0x18 -v 0x5f # map alt-o to _ -setkey -t 8 -k 0x19 -v 0x22 # map alt-p to " -setkey -t 8 -k 0x1e -v 0x23 # map alt-a to # -setkey -t 8 -k 0x1f -v 0x34 # map alt-s to 4 -setkey -t 8 -k 0x20 -v 0x35 # map alt-d to 5 -setkey -t 8 -k 0x21 -v 0x36 # map alt-f to 6 -setkey -t 8 -k 0x22 -v 0x2f # map alt-g to / -setkey -t 8 -k 0x23 -v 0x3f # map alt-h to ? -setkey -t 8 -k 0x24 -v 0xa3 # map alt-j to pound -setkey -t 8 -k 0x25 -v 0x24 # map alt-k to $ -setkey -t 8 -k 0x2c -v 0x2a # map alt-z to * -setkey -t 8 -k 0x2d -v 0x37 # map alt-x to 7 -setkey -t 8 -k 0x2e -v 0x38 # map alt-c to 8 -setkey -t 8 -k 0x2f -v 0x39 # map alt-v to 9 -setkey -t 8 -k 0x30 -v 0x7c # map alt-b to | -setkey -t 8 -k 0x31 -v 0x40 # map alt-n to @ -setkey -t 8 -k 0x32 -v 0x3d # map alt-m to = -setkey -t 8 -k 0x33 -v 0x3b # map alt-, to ; -setkey -t 8 -k 0x34 -v 0x3a # map alt-. to : -setkey -t 8 -k 0x0f -v 0x30 # map alt-tab to 0 -setkey -t 8 -k 0x67 -v 0x20b # map alt-up to scroll back -setkey -t 8 -k 0x6c -v 0x20a # map alt-down to scroll forward - -while true -do - echo - echo "------------------------------" - echo " 1: init commands" - echo " 2: call commands" - echo " 3: misc phone" - echo " 4: phone debug output" - echo " 5: test data connection" - echo " 6: start runtime" - echo " 7: start runtime w/output" - echo " 8: stop runtime" - echo " 9: misc" - echo -n ": " - while true - do - c=`readtty -t 50 -f -a 1234567890#` - case "$c" in - "" ) ;; - * ) break; - esac - done - echo Got key -$c- - case $c in - "1" ) - while true; do - echo - echo "------------------------------" - echo " 1: Print phone output" - echo " 2: ATQ0V1E1+CMEE=2;+CREG=0" - echo " 3: AT+CFUN=1" - echo " 4: AT+COPS=0" - echo " 5: AT+CREG?" - echo " 6: Stop phone output" - echo " 0: back" - echo -n ": " - c=`readtty -f -a 1234560#` - echo Got key -$c- - case "$c" in - "1" ) kill $phoneoutputpid; cat $atdev & phoneoutputpid=$! ;; - "2" ) echo -e "ATQ0V1E1+CMEE=2;+CREG=0\r" >$atdev;; - "3" ) echo -e "AT+CFUN=1\r" >$atdev;; - "4" ) echo -e "AT+COPS=0\r" >$atdev;; - "5" ) echo -e "AT+CREG?\r" >$atdev;; - "6" ) kill $phoneoutputpid; phoneoutputpid= ;; - "0" ) break;; - esac - done - ;; - "2" ) - while true; do - echo - echo "------------------------------" - echo " 1: Dial: ATD $n1;" - echo " 2: Dial: ATD $n2;" - echo " 3: Dial: ATD $n3;" - echo " 4: Set number for 1" - echo " 5: Set number for 2" - echo " 6: Set number for 3" - echo " 7: Dial: ATD ...;" - echo " 8: Hang up: ATH" - echo " 9: Answer: ATA" - echo " 0: back" - echo -n ": " - c=`readtty -f -a 1234567890#` - echo Got key -$c- - case "$c" in - "1" ) echo "Dialing $n1"; echo -e "ATD $n1;\r" >$atdev;; - "2" ) echo "Dialing $n2"; echo -e "ATD $n2;\r" >$atdev;; - "3" ) echo "Dialing $n3"; echo -e "ATD $n3;\r" >$atdev;; - "4" ) echo -n "Number: "; read n1; echo $n1 >/data/phoneentry1;; - "5" ) echo -n "Number: "; read n2; echo $n2 >/data/phoneentry2;; - "6" ) echo -n "Number: "; read n3; echo $n3 >/data/phoneentry3;; - "7" ) echo -n "Number: "; read n; echo "Dialing $n"; echo -e "ATD $n;\r" >$atdev;; - "8" ) echo -e "ATH\r" >$atdev;; - "9" ) echo -e "ATA\r" >$atdev;; - "0" ) break;; - esac - done - ;; - "3" ) - while true; do - echo - echo "------------------------------" - echo " 1: Save FFS data" - echo " 2: Load user FFS data" - echo " 3: Load system FFS data" - echo " 4: Reset FFS data" - echo " 5: Set uplink gain" - echo " 6: Set echo" - echo " 7: cat /dev/omap_csmi_battery_t" - echo " 8: cat /dev/omap_csmi_htc" - echo " 0: back" - echo -n ": " - c=`readtty -f -a 123456780#` - echo Got key -$c- - case "$c" in - "1" ) cat /dev/omap_csmi_ffs >/data/ffsdata;; - "2" ) cat /data/ffsdata >/dev/omap_csmi_ffs;; - "3" ) cat /system/ffsdata >/dev/omap_csmi_ffs;; - "4" ) echo - >/dev/omap_csmi_ffs;; - "5" ) - echo -n "Gain: "; read g; - echo gu$g >/tmp/gain; - cat /tmp/gain 2>/dev/null >/dev/omap_csmi_audio_tes - ;; - "6" ) - echo -n "Echo param (hex): "; read e; - echo "e0x$e" >/tmp/echo; - cat /tmp/echo 2>/dev/null >/dev/omap_csmi_audio_tes - ;; - "7" ) cat /dev/omap_csmi_battery_t;; - "8" ) cat /dev/omap_csmi_htc;; - "0" ) break;; - esac - done - ;; - "4" ) - while true; do - echo - echo "------------------------------" - echo " 1: Toggle debug I/O" - echo " 2: Toggle debug Flow" - echo " 3: Toggle debug Interrupt" - echo " 4: Toggle debug Info" - echo " 5: Toggle GSM run state" - echo " 6: Clear GSM data area" - echo " 0: back" - echo -n ": " - c=`readtty -f -a 1234560#` - echo Got key -$c- - case "$c" in - "1" ) echo -n "i" >/sys/devices/system/omap_csmi/debug;; - "2" ) echo -n "f" >/sys/devices/system/omap_csmi/debug;; - "3" ) echo -n "I" >/sys/devices/system/omap_csmi/debug;; - "4" ) echo -n "F" >/sys/devices/system/omap_csmi/debug;; - "5" ) echo -n "s" >/sys/devices/system/omap_csmi/debug;; - "6" ) echo -n "c" >/sys/devices/system/omap_csmi/debug;; - "0" ) break;; - esac - done - ;; - "5" ) - while true; do - echo - echo "------------------------------" - echo " 1: Start pppd - userspace" - echo " 2: Start pppd - kernel" - echo " 3: Start pppd - kernel <at1" - echo " 4: Configure ppp data to at2" - echo " 5: Test with HTTP GET" - echo " 6: Kill pppd" - echo " 0: back" - echo -n ": " - c=`readtty -f -a 1234560#` - echo Got key -$c- - case "$c" in - "1" ) kill $pppdpid; pppd notty < $pppdev > $pppdev & pppdpid=$!;; - "2" ) kill $pppdpid; pppd nodetach $pppdev & pppdpid=$!;; - "3" ) kill &pppdpid; pppd nodetach $pppdev connect "sh -c \"chat -v -f /etc/ppp/connect-data <$atdev >$atdev\"" & pppdpid=$!;; - "4" ) echo -e 'AT%DATA=2,"UART",1,,"SER","UART",0\r' >$atdev;; - "5" ) test-data-connection;; - "6" ) kill $pppdpid; pppdpid=;; - "0" ) break;; - esac - done - ;; - "6" ) - echo - echo ------------------------ - echo Starting android runtime - echo ------------------------ - start - ;; - "7" ) - echo - echo ------------------------ - echo Starting android runtime - echo ------------------------ - if exists /data/singleproc - then - single_process="-s" - else - single_process="" - fi - start runtime $single_process - ;; - "8" ) - stop - ;; - "9" ) - while true; do - echo - echo "------------------------------" - echo " 1: Print events" - echo " 2: Stop event output" - if $notifytoggle - then - echo " 3: stop notify" - else - echo " 3: notify /sys/android_power" - fi - echo " 4: start powerd" - echo " 5: start powerd verbose" - echo " 6: stop powerd" - echo " 7: set powerd idletime ($powerdidletime)" - echo " 8: start multitap shell" - if exists /data/singleproc - then - echo " 9: enable multiprocess" - else - echo " 9: disable multiprocess" - fi - echo " c: start shell" - echo " 0: back" - echo -n ": " - c=`readtty -f -a 1234567890c#` - echo Got key -$c- - case "$c" in - "1" ) kill $eventoutputpid; getevent & eventoutputpid=$! ;; - "2" ) kill $eventoutputpid; eventoutputpid= ;; - "3" ) - if $notifytoggle - then - kill $notifypid - notifypid= - notifytoggle=false - else - kill $notifypid - notify -m 0x00000002 -c 0 -p -v 0 -w 30 /sys/android_power & - notifypid=$! - notifytoggle=true - fi - ;; - "4" ) start powerd -i $powerdidletime ;; - "5" ) start powerd -i $powerdidletime -v ;; - "6" ) stop powerd ;; - "7" ) echo -n "Idle time (seconds): "; read powerdidletime ;; - "8" ) - readtty -f -p -t 10 -e "[ ~" | sh -i - ;; - "9" ) - if exists /data/singleproc - then - echo "Enabling multiprocess environment." - rm /data/singleproc - else - echo "Disabling multiprocess environment." - echo >/data/singleproc "true" - fi - ;; - "c" ) sh -i <>/dev/tty0 1>&0 2>&1 ;; - "0" ) break;; - esac - done - ;; - esac -done - diff --git a/toolbox/Android.mk b/toolbox/Android.mk index 5e019b6..242c200 100644 --- a/toolbox/Android.mk +++ b/toolbox/Android.mk @@ -153,13 +153,11 @@ OUR_TOOLS := \ id \ ifconfig \ iftop \ - insmod \ ioctl \ ionice \ load_policy \ log \ ls \ - lsmod \ lsof \ md5 \ mkdir \ @@ -175,7 +173,6 @@ OUR_TOOLS := \ readlink \ renice \ restorecon \ - rmmod \ route \ runcon \ schedtop \ @@ -218,11 +215,6 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libselinux \ -# libusbhost is only used by lsusb, and that isn't usually included in toolbox. -# The linker strips out all the unused library code in the normal case. -LOCAL_STATIC_LIBRARIES := \ - libusbhost \ - LOCAL_WHOLE_STATIC_LIBRARIES := $(patsubst %,libtoolbox_%,$(BSD_TOOLS)) LOCAL_MODULE := toolbox diff --git a/toolbox/alarm.c b/toolbox/alarm.c deleted file mode 100644 index 9bd58aa..0000000 --- a/toolbox/alarm.c +++ /dev/null @@ -1,190 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <fcntl.h> -#include <string.h> -#include <errno.h> -#include <time.h> -#include <asm/ioctl.h> -//#include <linux/rtc.h> -#include <linux/android_alarm.h> - -int alarm_main(int argc, char *argv[]) -{ - int c; - int res; - struct tm tm; - time_t t; - struct timespec ts; -// struct rtc_time rtc_time; - char strbuf[26]; - int afd; - int nfd; -// struct timeval timeout = { 0, 0 }; - int wait = 0; - fd_set rfds; - const char wake_lock_id[] = "alarm_test"; - int waitalarmmask = 0; - - int useutc = 0; - android_alarm_type_t alarmtype_low = ANDROID_ALARM_RTC_WAKEUP; - android_alarm_type_t alarmtype_high = ANDROID_ALARM_RTC_WAKEUP; - android_alarm_type_t alarmtype = 0; - - do { - //c = getopt(argc, argv, "uw:"); - c = getopt(argc, argv, "uwat:"); - if (c == EOF) - break; - switch (c) { - case 'u': - useutc = 1; - break; - case 't': - alarmtype_low = alarmtype_high = strtol(optarg, NULL, 0); - break; - case 'a': - alarmtype_low = ANDROID_ALARM_RTC_WAKEUP; - alarmtype_high = ANDROID_ALARM_TYPE_COUNT - 1; - break; - case 'w': - //timeout.tv_sec = strtol(optarg, NULL, 0); - wait = 1; - break; - case '?': - fprintf(stderr, "%s: invalid option -%c\n", - argv[0], optopt); - exit(1); - } - } while (1); - if(optind + 2 < argc) { - fprintf(stderr,"%s [-uwa] [-t type] [seconds]\n", argv[0]); - return 1; - } - - afd = open("/dev/alarm", O_RDWR); - if(afd < 0) { - fprintf(stderr, "Unable to open rtc: %s\n", strerror(errno)); - return 1; - } - - if(optind == argc) { - for(alarmtype = alarmtype_low; alarmtype <= alarmtype_high; alarmtype++) { - waitalarmmask |= 1U << alarmtype; - } -#if 0 - res = ioctl(fd, RTC_ALM_READ, &tm); - if(res < 0) { - fprintf(stderr, "Unable to read alarm: %s\n", strerror(errno)); - return 1; - } -#endif -#if 0 - t = timegm(&tm); - if(useutc) - gmtime_r(&t, &tm); - else - localtime_r(&t, &tm); -#endif -#if 0 - asctime_r(&tm, strbuf); - printf("%s", strbuf); -#endif - } - else if(optind + 1 == argc) { -#if 0 - res = ioctl(fd, RTC_RD_TIME, &tm); - if(res < 0) { - fprintf(stderr, "Unable to set alarm: %s\n", strerror(errno)); - return 1; - } - asctime_r(&tm, strbuf); - printf("Now: %s", strbuf); - time(&tv.tv_sec); -#endif -#if 0 - time(&ts.tv_sec); - ts.tv_nsec = 0; - - //strptime(argv[optind], NULL, &tm); - //tv.tv_sec = mktime(&tm); - //tv.tv_usec = 0; -#endif - for(alarmtype = alarmtype_low; alarmtype <= alarmtype_high; alarmtype++) { - waitalarmmask |= 1U << alarmtype; - res = ioctl(afd, ANDROID_ALARM_GET_TIME(alarmtype), &ts); - if(res < 0) { - fprintf(stderr, "Unable to get current time: %s\n", strerror(errno)); - return 1; - } - ts.tv_sec += strtol(argv[optind], NULL, 0); - //strtotimeval(argv[optind], &tv); - gmtime_r(&ts.tv_sec, &tm); - printf("time %s -> %ld.%09ld\n", argv[optind], ts.tv_sec, ts.tv_nsec); - asctime_r(&tm, strbuf); - printf("Requested %s", strbuf); - - res = ioctl(afd, ANDROID_ALARM_SET(alarmtype), &ts); - if(res < 0) { - fprintf(stderr, "Unable to set alarm: %s\n", strerror(errno)); - return 1; - } - } -#if 0 - res = ioctl(fd, RTC_ALM_SET, &tm); - if(res < 0) { - fprintf(stderr, "Unable to set alarm: %s\n", strerror(errno)); - return 1; - } - res = ioctl(fd, RTC_AIE_ON); - if(res < 0) { - fprintf(stderr, "Unable to enable alarm: %s\n", strerror(errno)); - return 1; - } -#endif - } - else { - fprintf(stderr,"%s [-u] [date]\n", argv[0]); - return 1; - } - - if(wait) { - while(waitalarmmask) { - printf("wait for alarm %x\n", waitalarmmask); - res = ioctl(afd, ANDROID_ALARM_WAIT); - if(res < 0) { - fprintf(stderr, "alarm wait failed\n"); - } - printf("got alarm %x\n", res); - waitalarmmask &= ~res; - nfd = open("/sys/android_power/acquire_full_wake_lock", O_RDWR); - write(nfd, wake_lock_id, sizeof(wake_lock_id) - 1); - close(nfd); - //sleep(5); - nfd = open("/sys/android_power/release_wake_lock", O_RDWR); - write(nfd, wake_lock_id, sizeof(wake_lock_id) - 1); - close(nfd); - } - printf("done\n"); - } -#if 0 - FD_ZERO(&rfds); - FD_SET(fd, &rfds); - res = select(fd + 1, &rfds, NULL, NULL, &timeout); - if(res < 0) { - fprintf(stderr, "select failed: %s\n", strerror(errno)); - return 1; - } - if(res > 0) { - int event; - read(fd, &event, sizeof(event)); - fprintf(stderr, "got %x\n", event); - } - else { - fprintf(stderr, "timeout waiting for alarm\n"); - } -#endif - - close(afd); - - return 0; -} diff --git a/toolbox/exists.c b/toolbox/exists.c deleted file mode 100644 index e348668..0000000 --- a/toolbox/exists.c +++ /dev/null @@ -1,16 +0,0 @@ -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> - -int exists_main(int argc, char *argv[]) -{ - struct stat s; - - if(argc < 2) return 1; - - if(stat(argv[1], &s)) { - return 1; - } else { - return 0; - } -} diff --git a/toolbox/insmod.c b/toolbox/insmod.c deleted file mode 100644 index d252433..0000000 --- a/toolbox/insmod.c +++ /dev/null @@ -1,97 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <fcntl.h> -#include <unistd.h> -#include <malloc.h> -#include <errno.h> -#include <sys/param.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> - -extern int init_module(void *, unsigned long, const char *); - -static void *read_file(const char *filename, ssize_t *_size) -{ - int ret, fd; - struct stat sb; - ssize_t size; - void *buffer = NULL; - - /* open the file */ - fd = open(filename, O_RDONLY); - if (fd < 0) - return NULL; - - /* find out how big it is */ - if (fstat(fd, &sb) < 0) - goto bail; - size = sb.st_size; - - /* allocate memory for it to be read into */ - buffer = malloc(size); - if (!buffer) - goto bail; - - /* slurp it into our buffer */ - ret = read(fd, buffer, size); - if (ret != size) - goto bail; - - /* let the caller know how big it is */ - *_size = size; - -bail: - close(fd); - return buffer; -} - -int insmod_main(int argc, char **argv) -{ - void *file; - ssize_t size = 0; - char opts[1024]; - int ret; - - /* make sure we've got an argument */ - if (argc < 2) { - fprintf(stderr, "usage: insmod <module.o>\n"); - return -1; - } - - /* read the file into memory */ - file = read_file(argv[1], &size); - if (!file) { - fprintf(stderr, "insmod: can't open '%s'\n", argv[1]); - return -1; - } - - opts[0] = '\0'; - if (argc > 2) { - int i, len; - char *end = opts + sizeof(opts) - 1; - char *ptr = opts; - - for (i = 2; (i < argc) && (ptr < end); i++) { - len = MIN(strlen(argv[i]), (size_t)(end - ptr)); - memcpy(ptr, argv[i], len); - ptr += len; - *ptr++ = ' '; - } - *(ptr - 1) = '\0'; - } - - /* pass it to the kernel */ - ret = init_module(file, size, opts); - if (ret != 0) { - fprintf(stderr, - "insmod: init_module '%s' failed (%s)\n", - argv[1], strerror(errno)); - } - - /* free the file buffer */ - free(file); - - return ret; -} - diff --git a/toolbox/lsmod.c b/toolbox/lsmod.c deleted file mode 100644 index 8b55ee6..0000000 --- a/toolbox/lsmod.c +++ /dev/null @@ -1,10 +0,0 @@ -#include <stdio.h> - -extern int cat_main(int argc, char **argv); - -int lsmod_main(int argc, char **argv) -{ - char *cat_argv[] = { "cat", "/proc/modules", NULL }; - return cat_main(2, cat_argv); -} - diff --git a/toolbox/lsusb.c b/toolbox/lsusb.c deleted file mode 100644 index 236e74b..0000000 --- a/toolbox/lsusb.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <endian.h> -#include <errno.h> -#include <stdio.h> -#include <stdint.h> -#include <string.h> - -#include <usbhost/usbhost.h> - -static int verbose = 0; -static char str_buff[4096]; - -static const char *get_str(struct usb_device *dev, int id) -{ - char *str = usb_device_get_string(dev, id); - - if (id && str) { - strlcpy(str_buff, str, sizeof(str_buff)); - free(str); - } else { - snprintf(str_buff, sizeof(str_buff), "%02x", id); - } - - return str_buff; -} - - -static void lsusb_parse_device_descriptor(struct usb_device *dev, - struct usb_device_descriptor *desc) -{ - printf(" Device Descriptor\n"); - printf("\tbcdUSB: %04x\n", letoh16(desc->bcdUSB)); - printf("\tbDeviceClass: %02x\n", desc->bDeviceClass); - printf("\tbDeviceSubClass: %02x\n", desc->bDeviceSubClass); - printf("\tbDeviceProtocol: %02x\n", desc->bDeviceProtocol); - printf("\tbMaxPacketSize0: %02x\n", desc->bMaxPacketSize0); - printf("\tidVendor: %04x\n", letoh16(desc->idVendor)); - printf("\tidProduct: %04x\n", letoh16(desc->idProduct)); - printf("\tbcdDevice: %04x\n", letoh16(desc->bcdDevice)); - printf("\tiManufacturer: %s\n", get_str(dev, desc->iManufacturer)); - printf("\tiProduct: %s\n", get_str(dev, desc->iProduct)); - printf("\tiSerialNumber: %s\n", get_str(dev,desc->iSerialNumber)); - printf("\tbNumConfiguration: %02x\n", desc->bNumConfigurations); - printf("\n"); -} - -static void lsusb_parse_config_descriptor(struct usb_device *dev, - struct usb_config_descriptor *desc) -{ - printf(" Config Descriptor\n"); - printf("\twTotalLength: %04x\n", letoh16(desc->wTotalLength)); - printf("\tbNumInterfaces: %02x\n", desc->bNumInterfaces); - printf("\tbConfigurationValue: %02x\n", desc->bConfigurationValue); - printf("\tiConfiguration: %s\n", get_str(dev, desc->iConfiguration)); - printf("\tbmAttributes: %02x\n", desc->bmAttributes); - printf("\tbMaxPower: %d mA\n", desc->bMaxPower * 2); - printf("\n"); -} - -static void lsusb_parse_interface_descriptor(struct usb_device *dev, - struct usb_interface_descriptor *desc) -{ - printf(" Interface Descriptor\n"); - printf("\tbInterfaceNumber: %02x\n", desc->bInterfaceNumber); - printf("\tbAlternateSetting: %02x\n", desc->bAlternateSetting); - printf("\tbNumEndpoints: %02x\n", desc->bNumEndpoints); - printf("\tbInterfaceClass: %02x\n", desc->bInterfaceClass); - printf("\tbInterfaceSubClass: %02x\n", desc->bInterfaceSubClass); - printf("\tbInterfaceProtocol: %02x\n", desc->bInterfaceProtocol); - printf("\tiInterface: %s\n", get_str(dev, desc->iInterface)); - printf("\n"); -} - -static void lsusb_parse_endpoint_descriptor(struct usb_device *dev, - struct usb_endpoint_descriptor *desc) -{ - printf(" Endpoint Descriptor\n"); - printf("\tbEndpointAddress: %02x\n", desc->bEndpointAddress); - printf("\tbmAttributes: %02x\n", desc->bmAttributes); - printf("\twMaxPacketSize: %02x\n", letoh16(desc->wMaxPacketSize)); - printf("\tbInterval: %02x\n", desc->bInterval); - printf("\tbRefresh: %02x\n", desc->bRefresh); - printf("\tbSynchAddress: %02x\n", desc->bSynchAddress); - printf("\n"); -} - -static void lsusb_dump_descriptor(struct usb_device *dev, - struct usb_descriptor_header *desc) -{ - int i; - printf(" Descriptor type %02x\n", desc->bDescriptorType); - - for (i = 0; i < desc->bLength; i++ ) { - if ((i % 16) == 0) - printf("\t%02x:", i); - printf(" %02x", ((uint8_t *)desc)[i]); - if ((i % 16) == 15) - printf("\n"); - } - - if ((i % 16) != 0) - printf("\n"); - printf("\n"); -} - -static void lsusb_parse_descriptor(struct usb_device *dev, - struct usb_descriptor_header *desc) -{ - switch (desc->bDescriptorType) { - case USB_DT_DEVICE: - lsusb_parse_device_descriptor(dev, (struct usb_device_descriptor *) desc); - break; - - case USB_DT_CONFIG: - lsusb_parse_config_descriptor(dev, (struct usb_config_descriptor *) desc); - break; - - case USB_DT_INTERFACE: - lsusb_parse_interface_descriptor(dev, (struct usb_interface_descriptor *) desc); - break; - - case USB_DT_ENDPOINT: - lsusb_parse_endpoint_descriptor(dev, (struct usb_endpoint_descriptor *) desc); - break; - - default: - lsusb_dump_descriptor(dev, desc); - - break; - } -} - -static int lsusb_device_added(const char *dev_name, void *client_data) -{ - struct usb_device *dev = usb_device_open(dev_name); - - if (!dev) { - fprintf(stderr, "can't open device %s: %s\n", dev_name, strerror(errno)); - return 0; - } - - if (verbose) { - struct usb_descriptor_iter iter; - struct usb_descriptor_header *desc; - - printf("%s:\n", dev_name); - - usb_descriptor_iter_init(dev, &iter); - - while ((desc = usb_descriptor_iter_next(&iter)) != NULL) - lsusb_parse_descriptor(dev, desc); - - } else { - uint16_t vid, pid; - char *mfg_name, *product_name, *serial; - - vid = usb_device_get_vendor_id(dev); - pid = usb_device_get_product_id(dev); - mfg_name = usb_device_get_manufacturer_name(dev); - product_name = usb_device_get_product_name(dev); - serial = usb_device_get_serial(dev); - - printf("%s: %04x:%04x %s %s %s\n", dev_name, vid, pid, - mfg_name, product_name, serial); - - free(mfg_name); - free(product_name); - free(serial); - } - - usb_device_close(dev); - - return 0; -} - -static int lsusb_device_removed(const char *dev_name, void *client_data) -{ - return 0; -} - - -static int lsusb_discovery_done(void *client_data) -{ - return 1; -} - - - -int lsusb_main(int argc, char **argv) -{ - struct usb_host_context *ctx; - - if (argc == 2 && !strcmp(argv[1], "-v")) - verbose = 1; - - ctx = usb_host_init(); - if (!ctx) { - perror("usb_host_init:"); - return 1; - } - - usb_host_run(ctx, - lsusb_device_added, - lsusb_device_removed, - lsusb_discovery_done, - NULL); - - usb_host_cleanup(ctx); - - return 0; -} - diff --git a/toolbox/readtty.c b/toolbox/readtty.c deleted file mode 100644 index 2b27548..0000000 --- a/toolbox/readtty.c +++ /dev/null @@ -1,183 +0,0 @@ -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/mman.h> -#include <fcntl.h> -#include <string.h> -#include <termios.h> -#include <unistd.h> - -struct { - char key; - char *chars; -} map[] = { - { '1', "_ -1?!,.:;\"'<=>()_" }, - { '2', "Cabc2ABC" }, - { '3', "Fdef3DEF" }, - { '4', "Ighi4GHI" }, - { '5', "Ljkl5JKL" }, - { '6', "Omno6MNO" }, - { '7', "Spqrs7PQRS" }, - { '8', "Vtuv8TUV" }, - { '9', "Zwxyz9WXYZ" }, - { '0', "*+&0@/#*" }, -}; - -char next_char(char key, char current) -{ - int i; - char *next; - for(i = 0; i < sizeof(map) / sizeof(map[0]); i++) { - if(key == map[i].key) { - next = strchr(map[i].chars, current); - if(next && next[1]) - return next[1]; - return map[i].chars[1]; - } - } - return key; -} - -char prev_char(char key, char current) -{ - int i; - char *next; - for(i = 0; i < sizeof(map) / sizeof(map[0]); i++) { - if(key == map[i].key) { - next = strchr(map[i].chars+1, current); - if(next && next[-1]) - return next[-1]; - return map[i].chars[1]; - } - } - return key; -} - -int readtty_main(int argc, char *argv[]) -{ - int c; - //int flags; - char buf[1]; - int res; - struct termios ttyarg; - struct termios savedttyarg; - int nonblock = 0; - int timeout = 0; - int flush = 0; - int phone = 0; - char *accept = NULL; - char *rejectstring = NULL; - char last_char_in = 0; - char current_char = 0; - char *exit_string = NULL; - int exit_match = 0; - - do { - c = getopt(argc, argv, "nt:fa:r:pe:"); - if (c == EOF) - break; - switch (c) { - case 't': - timeout = atoi(optarg); - break; - case 'n': - nonblock = 1; - break; - case 'f': - flush = 1; - break; - case 'a': - accept = optarg; - break; - case 'r': - rejectstring = optarg; - break; - case 'p': - phone = 1; - break; - case 'e': - exit_string = optarg; - break; - case '?': - fprintf(stderr, "%s: invalid option -%c\n", - argv[0], optopt); - exit(1); - } - } while (1); - - if(flush) - tcflush(STDIN_FILENO, TCIFLUSH); - ioctl(STDIN_FILENO, TCGETS , &savedttyarg) ; /* set changed tty arguments */ - ttyarg = savedttyarg; - ttyarg.c_cc[VMIN] = (timeout > 0 || nonblock) ? 0 : 1; /* minimum of 0 chars */ - ttyarg.c_cc[VTIME] = timeout; /* wait max 15/10 sec */ - ttyarg.c_iflag = BRKINT | ICRNL; - ttyarg.c_lflag &= ~(ECHO | ICANON); - ioctl(STDIN_FILENO, TCSETS , &ttyarg); - - while (1) { - res = read(STDIN_FILENO, buf, 1); - if(res <= 0) { - if(phone) { - if(current_char) { - write(STDERR_FILENO, ¤t_char, 1); - write(STDOUT_FILENO, ¤t_char, 1); - if(exit_string && current_char == exit_string[exit_match]) { - exit_match++; - if(exit_string[exit_match] == '\0') - break; - } - else - exit_match = 0; - current_char = 0; - } - continue; - } - break; - } - if(accept && strchr(accept, buf[0]) == NULL) { - if(rejectstring) { - write(STDOUT_FILENO, rejectstring, strlen(rejectstring)); - break; - } - if(flush) - tcflush(STDIN_FILENO, TCIFLUSH); - continue; - } - if(phone) { - //if(!isprint(buf[0])) { - // fprintf(stderr, "got unprintable character 0x%x\n", buf[0]); - //} - if(buf[0] == '\0') { - if(current_char) { - current_char = prev_char(last_char_in, current_char); - write(STDERR_FILENO, ¤t_char, 1); - write(STDERR_FILENO, "\b", 1); - } - continue; - } - if(current_char && buf[0] != last_char_in) { - write(STDERR_FILENO, ¤t_char, 1); - write(STDOUT_FILENO, ¤t_char, 1); - if(exit_string && current_char == exit_string[exit_match]) { - exit_match++; - if(exit_string[exit_match] == '\0') - break; - } - else - exit_match = 0; - current_char = 0; - } - last_char_in = buf[0]; - current_char = next_char(last_char_in, current_char); - write(STDERR_FILENO, ¤t_char, 1); - write(STDERR_FILENO, "\b", 1); - continue; - } - write(STDOUT_FILENO, buf, 1); - break; - } - ioctl(STDIN_FILENO, TCSETS , &savedttyarg) ; /* set changed tty arguments */ - - return 0; -} diff --git a/toolbox/rmmod.c b/toolbox/rmmod.c deleted file mode 100644 index c7e0d6a..0000000 --- a/toolbox/rmmod.c +++ /dev/null @@ -1,53 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <fcntl.h> -#include <unistd.h> -#include <malloc.h> -#include <errno.h> -#include <asm/unistd.h> - -extern int delete_module(const char *, unsigned int); - -int rmmod_main(int argc, char **argv) -{ - int ret, i; - char *modname, *dot; - - /* make sure we've got an argument */ - if (argc < 2) { - fprintf(stderr, "usage: rmmod <module>\n"); - return -1; - } - - /* if given /foo/bar/blah.ko, make a weak attempt - * to convert to "blah", just for convenience - */ - modname = strrchr(argv[1], '/'); - if (!modname) - modname = argv[1]; - else modname++; - - dot = strchr(argv[1], '.'); - if (dot) - *dot = '\0'; - - /* Replace "-" with "_". This would keep rmmod - * compatible with module-init-tools version of - * rmmod - */ - for (i = 0; modname[i] != '\0'; i++) { - if (modname[i] == '-') - modname[i] = '_'; - } - - /* pass it to the kernel */ - ret = delete_module(modname, O_NONBLOCK | O_EXCL); - if (ret != 0) { - fprintf(stderr, "rmmod: delete_module '%s' failed (errno %d)\n", - modname, errno); - return -1; - } - - return 0; -} - diff --git a/toolbox/rotatefb.c b/toolbox/rotatefb.c deleted file mode 100644 index 2ff4127..0000000 --- a/toolbox/rotatefb.c +++ /dev/null @@ -1,71 +0,0 @@ -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/mman.h> -#include <fcntl.h> -#include <string.h> -#include <termios.h> -#include <unistd.h> -#include <errno.h> -#include <linux/fb.h> - - -int rotatefb_main(int argc, char *argv[]) -{ - int c; - char *fbdev = "/dev/graphics/fb0"; - int rotation = 0; - int fd; - int res; - struct fb_var_screeninfo fbinfo; - - do { - c = getopt(argc, argv, "d:"); - if (c == EOF) - break; - switch (c) { - case 'd': - fbdev = optarg; - break; - case '?': - fprintf(stderr, "%s: invalid option -%c\n", - argv[0], optopt); - exit(1); - } - } while (1); - - if(optind + 1 != argc) { - fprintf(stderr, "%s: specify rotation\n", argv[0]); - exit(1); - } - rotation = atoi(argv[optind]); - - fd = open(fbdev, O_RDWR); - if(fd < 0) { - fprintf(stderr, "cannot open %s\n", fbdev); - return 1; - } - - res = ioctl(fd, FBIOGET_VSCREENINFO, &fbinfo); - if(res < 0) { - fprintf(stderr, "failed to get fbinfo: %s\n", strerror(errno)); - return 1; - } - if((fbinfo.rotate ^ rotation) & 1) { - unsigned int xres = fbinfo.yres; - fbinfo.yres = fbinfo.xres; - fbinfo.xres = xres; - fbinfo.xres_virtual = fbinfo.xres; - fbinfo.yres_virtual = fbinfo.yres * 2; - if(fbinfo.yoffset == xres) - fbinfo.yoffset = fbinfo.yres; - } - fbinfo.rotate = rotation; - res = ioctl(fd, FBIOPUT_VSCREENINFO, &fbinfo); - if(res < 0) { - fprintf(stderr, "failed to set fbinfo: %s\n", strerror(errno)); - return 1; - } - - return 0; -} diff --git a/toolbox/setkey.c b/toolbox/setkey.c deleted file mode 100644 index 1ff2774..0000000 --- a/toolbox/setkey.c +++ /dev/null @@ -1,89 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <fcntl.h> -#include <string.h> -#include <linux/kd.h> -#include <linux/vt.h> -#include <errno.h> - -static void setkey_usage(char *argv[]) -{ - fprintf(stderr, "%s [-t <table>] [-k <index>] [-v value] [-r] [-h]\n" - " -t <table> Select table\n" - " -k <index> Select key\n" - " -v <value> Set entry\n" - " -r Read current entry\n" - " -h Print help\n", argv[0]); -} - -#define TTYDEV "/dev/tty0" - -int setkey_main(int argc, char *argv[]) -{ - int fd; - struct kbentry kbe; - int did_something = 0; - - kbe.kb_table = 0; - kbe.kb_index = -1; - kbe.kb_value = 0; - - fd = open(TTYDEV, O_RDWR | O_SYNC); - if (fd < 0) { - fprintf(stderr, "open %s: %s\n", TTYDEV, strerror(errno)); - return 1; - } - - do { - int c, ret; - - c = getopt(argc, argv, "t:k:v:hr"); - if (c == EOF) - break; - - switch (c) { - case 't': - kbe.kb_table = strtol(optarg, NULL, 0); - break; - case 'k': - kbe.kb_index = strtol(optarg, NULL, 0); - break; - case 'v': - kbe.kb_value = strtol(optarg, NULL, 0); - ret = ioctl(fd, KDSKBENT, &kbe); - if (ret < 0) { - fprintf(stderr, "KDSKBENT %d %d %d failed: %s\n", - kbe.kb_table, kbe.kb_index, kbe.kb_value, - strerror(errno)); - return 1; - } - did_something = 1; - break; - case 'r': - ret = ioctl(fd, KDGKBENT, &kbe); - if (ret < 0) { - fprintf(stderr, "KDGKBENT %d %d failed: %s\n", - kbe.kb_table, kbe.kb_index, strerror(errno)); - return 1; - } - printf("0x%x 0x%x 0x%x\n", - kbe.kb_table, kbe.kb_index, kbe.kb_value); - did_something = 1; - break; - case 'h': - setkey_usage(argv); - return 1; - case '?': - fprintf(stderr, "%s: invalid option -%c\n", - argv[0], optopt); - return 1; - } - } while (1); - - if(optind != argc || !did_something) { - setkey_usage(argv); - return 1; - } - - return 0; -} diff --git a/toolbox/syren.c b/toolbox/syren.c deleted file mode 100644 index 47c2460..0000000 --- a/toolbox/syren.c +++ /dev/null @@ -1,158 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <fcntl.h> -#include <malloc.h> - -/* ioctl crap */ -#define SYREN_RD 101 -#define SYREN_WR 102 -#define SYREN_OLD_RD 108 -#define SYREN_OLD_WR 109 - -struct syren_io_args { - unsigned long page; - unsigned long addr; - unsigned long value; -}; - -typedef struct { - u_char page; - u_char addr; - const char *name; -} syren_reg; - -static syren_reg registers[] = { - { 0, 0x04, "TOGBR1" }, - { 0, 0x05, "TOGBR2" }, - { 0, 0x06, "VBDCTRL" }, - { 1, 0x07, "VBUCTRL" }, - { 1, 0x08, "VBCTRL" }, - { 1, 0x09, "PWDNRG" }, - { 1, 0x0a, "VBPOP" }, - { 1, 0x0b, "VBCTRL2" }, - { 1, 0x0f, "VAUDCTRL" }, - { 1, 0x10, "VAUSCTRL" }, - { 1, 0x11, "VAUOCTRL" }, - { 1, 0x12, "VAUDPLL" }, - { 1, 0x17, "VRPCSIMR" }, - { 0, 0, 0 } -}; - -static syren_reg *find_reg(const char *name) -{ - int i; - - for (i = 0; registers[i].name != 0; i++) { - if (!strcasecmp(registers[i].name, name)) - return ®isters[i]; - } - - return NULL; -} - -static int usage(void) -{ - fprintf(stderr, "usage: syren [r/w] [REGNAME | page:addr] (value)\n"); - return 1; -} - -int -syren_main(int argc, char **argv) -{ - int cmd = -1; - syren_reg *r; - struct syren_io_args sio; - char name[32]; - int fd; - - if (argc < 3) { - return usage(); - } - - switch(argv[1][0]) { - case 'r': - cmd = SYREN_RD; - break; - case 'w': - cmd = SYREN_WR; - break; - case 'R': - cmd = SYREN_OLD_RD; - break; - case 'W': - cmd = SYREN_OLD_WR; - break; - default: - return usage(); - } - - if (cmd == SYREN_WR || cmd == SYREN_OLD_WR) { - if (argc < 4) - return usage(); - sio.value = strtoul(argv[3], 0, 0); - } - - fd = open("/dev/eac", O_RDONLY); - if (fd < 0) { - fprintf(stderr, "can't open /dev/eac\n"); - return 1; - } - - if (strcasecmp(argv[2], "all") == 0) { - int i; - if (cmd != SYREN_RD && cmd != SYREN_OLD_RD) { - fprintf(stderr, "can only read all registers\n"); - return 1; - } - - for (i = 0; registers[i].name; i++) { - sio.page = registers[i].page; - sio.addr = registers[i].addr; - if (ioctl(fd, cmd, &sio) < 0) { - fprintf(stderr, "%s: error\n", registers[i].name); - } else { - fprintf(stderr, "%s: %04x\n", registers[i].name, sio.value); - } - } - - close(fd); - return 0; - } - - r = find_reg(argv[2]); - if (r == NULL) { - if(strlen(argv[2]) >= sizeof(name)){ - fprintf(stderr, "REGNAME too long\n"); - return 0; - } - strlcpy(name, argv[2], sizeof(name)); - char *addr_str = strchr(argv[2], ':'); - if (addr_str == NULL) - return usage(); - *addr_str++ = 0; - sio.page = strtoul(argv[2], 0, 0); - sio.addr = strtoul(addr_str, 0, 0); - } else { - strlcpy(name, r->name, sizeof(name)); - sio.page = r->page; - sio.addr = r->addr; - } - - if (ioctl(fd, cmd, &sio) < 0) { - fprintf(stderr, "ioctl(%d) failed\n", cmd); - return 1; - } - - if (cmd == SYREN_RD || cmd == SYREN_OLD_RD) { - printf("%s: %04x\n", name, sio.value); - } else { - printf("wrote %04x to %s\n", sio.value, name); - } - - close(fd); - - return 0; -} - |