From ecd23c09e87d7088285f8b7c2eeb98815c2e69e0 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Sat, 8 Aug 2009 13:54:49 -0700 Subject: [PATCH 001/907] Try not to crash with no error message. --- libacc/acc.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libacc/acc.cpp b/libacc/acc.cpp index b06ad53e933..684d807c463 100644 --- a/libacc/acc.cpp +++ b/libacc/acc.cpp @@ -8,6 +8,9 @@ * */ +#define LOG_TAG "acc" +#include + #include #include #include @@ -51,6 +54,8 @@ #define ENABLE_ARM_DISASSEMBLY // #define PROVIDE_TRACE_CODEGEN +#define assert(b) assertImpl(b, __LINE__) + namespace acc { // Subset of STL vector. @@ -562,10 +567,11 @@ class Compiler : public ErrorSink { va_end(ap); } - void assert(bool test) { + void assertImpl(bool test, int line) { if (!test) { + error("code generator assertion failed at line %s:%d.", __FILE__, line); + LOGD("code generator assertion failed at line %s:%d.", __FILE__, line); * (char*) 0 = 0; - error("code generator assertion failed."); } } @@ -3436,8 +3442,9 @@ class Compiler : public ErrorSink { * (char*) 0 = 0; } - void assert(bool isTrue) { + void assertImpl(bool isTrue, int line) { if (!isTrue) { + LOGD("assertion failed at line %s:%d.", __FILE__, line); internalError(); } } From 9feee025a09ace19b09dbb41d6ba87198c77cdf1 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Sun, 27 Sep 2009 15:13:56 -0700 Subject: [PATCH 002/907] Fix up ls -s. Added the "total" line, which makes it easy to answer questions like, "how the hell much space am I wasting on /data/dalvik-cache?". Also fixed the -s filename output, which was showing mostly-full paths when a simple filename was called for. --- toolbox/ls.c | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/toolbox/ls.c b/toolbox/ls.c index b221074ae4e..f340a8349ef 100644 --- a/toolbox/ls.c +++ b/toolbox/ls.c @@ -86,15 +86,50 @@ static void group2str(unsigned gid, char *out) } } -static int listfile_size(const char *path, int flags) +static int show_total_size(const char *dirname, DIR *d, int flags) { + struct dirent *de; + char tmp[1024]; struct stat s; + int sum = 0; + + /* run through the directory and sum up the file block sizes */ + while ((de = readdir(d)) != 0) { + if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) + continue; + if (de->d_name[0] == '.' && (flags & LIST_ALL) == 0) + continue; + + if (strcmp(dirname, "/") == 0) + snprintf(tmp, sizeof(tmp), "/%s", de->d_name); + else + snprintf(tmp, sizeof(tmp), "%s/%s", dirname, de->d_name); + + if (lstat(tmp, &s) < 0) { + fprintf(stderr, "stat failed on %s: %s\n", tmp, strerror(errno)); + rewinddir(d); + return -1; + } + + sum += s.st_blocks / 2; + } - if (lstat(path, &s) < 0) + printf("total %d\n", sum); + rewinddir(d); + return 0; +} + +static int listfile_size(const char *path, const char *filename, int flags) +{ + struct stat s; + + if (lstat(path, &s) < 0) { + fprintf(stderr, "lstat '%s' failed: %s\n", path, strerror(errno)); return -1; + } /* blocks are 512 bytes, we want output to be KB */ - printf("%lld %s\n", s.st_blocks / 2, path); + printf("%lld %s\n", s.st_blocks / 2, filename); return 0; } @@ -189,7 +224,7 @@ static int listfile(const char *dirname, const char *filename, int flags) if ((flags & LIST_LONG) != 0) { return listfile_long(pathname, flags); } else /*((flags & LIST_SIZE) != 0)*/ { - return listfile_size(pathname, flags); + return listfile_size(pathname, filename, flags); } } @@ -198,13 +233,17 @@ static int listdir(const char *name, int flags) char tmp[4096]; DIR *d; struct dirent *de; - + d = opendir(name); if(d == 0) { fprintf(stderr, "opendir failed, %s\n", strerror(errno)); return -1; } + if ((flags & LIST_SIZE) != 0) { + show_total_size(name, d, flags); + } + while((de = readdir(d)) != 0){ if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) continue; if(de->d_name[0] == '.' && (flags & LIST_ALL) == 0) continue; From 7c953d04bcc9070a1bce171e979c5201dd39325b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= Date: Thu, 17 Sep 2009 17:30:55 -0700 Subject: [PATCH 003/907] toolbox: Add nandread command Extracts a nand image from an mtd partition with page data followed by 64 bytes of extra data. --- toolbox/Android.mk | 3 +- toolbox/nandread.c | 256 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 258 insertions(+), 1 deletion(-) create mode 100644 toolbox/nandread.c diff --git a/toolbox/Android.mk b/toolbox/Android.mk index 70b13dcbc7d..122a5445e59 100644 --- a/toolbox/Android.mk +++ b/toolbox/Android.mk @@ -50,7 +50,8 @@ TOOLS := \ top \ iftop \ id \ - vmstat + vmstat \ + nandread LOCAL_SRC_FILES:= \ toolbox.c \ diff --git a/toolbox/nandread.c b/toolbox/nandread.c new file mode 100644 index 00000000000..aacccdb2669 --- /dev/null +++ b/toolbox/nandread.c @@ -0,0 +1,256 @@ +#include +#include +#include +#include +#include +#include + +#include +#include + +int test_empty(const char *buf, size_t size) +{ + while(size--) { + if (*buf++ != 0xff) + return 0; + } + return 1; +} + +int nandread_main(int argc, char **argv) +{ + char *devname = NULL; + char *filename = NULL; + char *statusfilename = NULL; + char *statusext = ".stat"; + int fd; + int outfd = -1; + FILE *statusfile = NULL; + int ret; + int verbose = 0; + void *buffer; + loff_t pos, opos; + int c; + int i; + int empty_pages = 0; + int page_count = 0; + int bad_block; + uint32_t *oob_data; + uint8_t *oob_fixed; + size_t spare_size = 64; + struct mtd_info_user mtdinfo; + struct mtd_ecc_stats initial_ecc, last_ecc, ecc; + struct mtd_oob_buf oobbuf; + struct nand_ecclayout ecclayout; + + do { + c = getopt(argc, argv, "d:f:s:hv"); + if (c == EOF) + break; + switch (c) { + case 'd': + devname = optarg; + break; + case 'f': + filename = optarg; + break; + case 's': + spare_size = atoi(optarg); + break; + case 'v': + verbose++; + break; + case 'h': + fprintf(stderr, "%s [-d ] [-f file] [-s sparesize] [-vh]\n" + " -d Read from \n" + " -f Write to \n" + " -s Number of spare bytes in file (default 64)\n" + " -v Print info\n" + " -h Print help\n", argv[0]); + return -1; + case '?': + fprintf(stderr, "%s: invalid option -%c\n", + argv[0], optopt); + exit(1); + } + } while (1); + + if (optind < argc) { + fprintf(stderr, "%s: extra arguments\n", argv[0]); + return 1; + } + if (!devname) { + fprintf(stderr, "%s: specify device name\n", argv[0]); + return 1; + } + + fd = open(devname, O_RDONLY); + if (fd < 0) { + fprintf(stderr, "cannot open %s, %s\n", devname, strerror(errno)); + return 1; + } + + if (filename) { + outfd = creat(filename, 0666); + if (outfd < 0) { + fprintf(stderr, "cannot open %s, %s\n", filename, strerror(errno)); + return 1; + } + statusfilename = malloc(strlen(filename) + strlen(statusext) + 1); + strcpy(statusfilename, filename); + strcat(statusfilename, statusext); + statusfile = fopen(statusfilename, "w+"); + if (!statusfile) { + fprintf(stderr, "cannot open %s, %s\n", statusfilename, strerror(errno)); + return 1; + } + } + + ret = ioctl(fd, MEMGETINFO, &mtdinfo); + if (ret) { + fprintf(stderr, "failed get mtd info for %s, %s\n", + devname, strerror(errno)); + return 1; + } + + if (verbose) { + printf("size: %u\n", mtdinfo.size); + printf("erase size: %u\n", mtdinfo.erasesize); + printf("write size: %u\n", mtdinfo.writesize); + printf("oob size: %u\n", mtdinfo.oobsize); + } + + buffer = malloc(mtdinfo.writesize + mtdinfo.oobsize + spare_size); + if (!buffer) { + fprintf(stderr, "failed allocate readbuffer size %u\n", + mtdinfo.writesize + mtdinfo.oobsize); + return 1; + } + + oobbuf.length = mtdinfo.oobsize; + oob_data = (uint32_t *)((uint8_t *)buffer + mtdinfo.writesize); + memset(oob_data, 0xff, spare_size); + oobbuf.ptr = (uint8_t *)oob_data + spare_size; + + ret = ioctl(fd, ECCGETLAYOUT, &ecclayout); + if (ret) { + fprintf(stderr, "failed get ecc layout for %s, %s\n", + devname, strerror(errno)); + return 1; + } + if (verbose) { + printf("ecc bytes: %u\n", ecclayout.eccbytes); + printf("oobavail: %u\n", ecclayout.oobavail); + } + if (ecclayout.oobavail > spare_size) + printf("oobavail, %d > image spare size, %d\n", ecclayout.oobavail, spare_size); + + ret = ioctl(fd, ECCGETSTATS, &initial_ecc); + if (ret) { + fprintf(stderr, "failed get ecc stats for %s, %s\n", + devname, strerror(errno)); + return 1; + } + last_ecc = initial_ecc; + + if (verbose) { + printf("initial ecc corrected: %u\n", initial_ecc.corrected); + printf("initial ecc failed: %u\n", initial_ecc.failed); + printf("initial ecc badblocks: %u\n", initial_ecc.badblocks); + printf("initial ecc bbtblocks: %u\n", initial_ecc.bbtblocks); + } + + for (pos = 0, opos = 0; pos < mtdinfo.size; pos += mtdinfo.writesize) { + bad_block = 0; + if (verbose > 3) + printf("reading at %llx\n", pos); + lseek64(fd, pos, SEEK_SET); + ret = read(fd, buffer, mtdinfo.writesize); + if (ret < (int)mtdinfo.writesize) { + fprintf(stderr, "short read at %llx, %d\n", pos, ret); + bad_block = 2; + } + oobbuf.start = pos; + ret = ioctl(fd, MEMREADOOB, &oobbuf); + if (ret) { + fprintf(stderr, "failed to read oob data at %llx, %d\n", pos, ret); + bad_block = 2; + } + ret = ioctl(fd, ECCGETSTATS, &ecc); + if (ret) { + fprintf(stderr, "failed get ecc stats for %s, %s\n", + devname, strerror(errno)); + return 1; + } + ret = ioctl(fd, MEMGETBADBLOCK, &pos); + if (ret && errno != EOPNOTSUPP) { + printf("badblock at %llx\n", pos); + bad_block = 1; + } + if (ecc.corrected != last_ecc.corrected) + printf("ecc corrected, %u, at %llx\n", ecc.corrected - last_ecc.corrected, pos); + if (ecc.failed != last_ecc.failed) + printf("ecc failed, %u, at %llx\n", ecc.failed - last_ecc.failed, pos); + if (ecc.badblocks != last_ecc.badblocks) + printf("ecc badblocks, %u, at %llx\n", ecc.badblocks - last_ecc.badblocks, pos); + if (ecc.bbtblocks != last_ecc.bbtblocks) + printf("ecc bbtblocks, %u, at %llx\n", ecc.bbtblocks - last_ecc.bbtblocks, pos); + + oob_fixed = (uint8_t *)oob_data; + for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES; i++) { + int len = ecclayout.oobfree[i].length; + if (oob_fixed + len > oobbuf.ptr) + len = oobbuf.ptr - oob_fixed; + if (len) { + memcpy(oob_fixed, oobbuf.ptr + ecclayout.oobfree[i].offset, len); + oob_fixed += len; + } + } + + if (outfd >= 0) { + ret = write(outfd, buffer, mtdinfo.writesize + spare_size); + if (ret < (int)(mtdinfo.writesize + spare_size)) { + fprintf(stderr, "short write at %llx, %d\n", pos, ret); + close(outfd); + outfd = -1; + } + if (ecc.corrected != last_ecc.corrected) + fprintf(statusfile, "%08llx: ecc corrected\n", opos); + if (ecc.failed != last_ecc.failed) + fprintf(statusfile, "%08llx: ecc failed\n", opos); + if (bad_block == 1) + fprintf(statusfile, "%08llx: badblock\n", opos); + if (bad_block == 2) + fprintf(statusfile, "%08llx: read error\n", opos); + opos += mtdinfo.writesize + spare_size; + } + + last_ecc = ecc; + page_count++; + if (test_empty(buffer, mtdinfo.writesize + mtdinfo.oobsize + spare_size)) + empty_pages++; + else if (verbose > 2 || (verbose > 1 && !(pos & (mtdinfo.erasesize - 1)))) + printf("page at %llx (%d oobbytes): %08x %08x %08x %08x " + "%08x %08x %08x %08x\n", pos, oobbuf.start, + oob_data[0], oob_data[1], oob_data[2], oob_data[3], + oob_data[4], oob_data[5], oob_data[6], oob_data[7]); + } + + if (outfd >= 0) { + fprintf(statusfile, "read %d pages, %d empty\n", page_count, empty_pages); + fprintf(statusfile, "total ecc corrected, %u\n", ecc.corrected - initial_ecc.corrected); + fprintf(statusfile, "total ecc failed, %u\n", ecc.failed - initial_ecc.failed); + fprintf(statusfile, "total ecc badblocks, %u\n", ecc.badblocks - initial_ecc.badblocks); + fprintf(statusfile, "total ecc bbtblocks, %u\n", ecc.bbtblocks - initial_ecc.bbtblocks); + } + if (verbose) { + printf("total ecc corrected, %u\n", ecc.corrected - initial_ecc.corrected); + printf("total ecc failed, %u\n", ecc.failed - initial_ecc.failed); + printf("total ecc badblocks, %u\n", ecc.badblocks - initial_ecc.badblocks); + printf("total ecc bbtblocks, %u\n", ecc.bbtblocks - initial_ecc.bbtblocks); + } + printf("read %d pages, %d empty\n", page_count, empty_pages); + + return 0; +} + From ab9ad14429c1b21236210d234db5da17ee67cca5 Mon Sep 17 00:00:00 2001 From: Doug Kwan Date: Fri, 2 Oct 2009 12:02:02 -0700 Subject: [PATCH 004/907] Add back missing libdl in linker command. The executables here contain call to function defined in libdl.so but the library is missing the linker commands. Currently, the library is linked via dependency of another library. While this works, it is not the right thing to do. --- libacc/tests/Android.mk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libacc/tests/Android.mk b/libacc/tests/Android.mk index e9fbe03199d..b3af6f12a8b 100644 --- a/libacc/tests/Android.mk +++ b/libacc/tests/Android.mk @@ -25,7 +25,8 @@ LOCAL_SRC_FILES:= \ disassem.cpp LOCAL_SHARED_LIBRARIES := \ - libacc + libacc \ + libdl LOCAL_CFLAGS := -O0 -g @@ -57,7 +58,8 @@ LOCAL_SRC_FILES:= \ runtimeTest.cpp LOCAL_SHARED_LIBRARIES := \ - libacc + libacc \ + libdl LOCAL_CFLAGS := -O0 -g From 67a2ea3deac5c0d2ec9c6f4a6bd154d78ed4d470 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 2 Oct 2009 13:28:02 -0700 Subject: [PATCH 005/907] Now all the callers are gone, remove adb_networking.*. (This is the final patch removing adb networking.) Bug: 1122968 --- include/cutils/adb_networking.h | 35 ------- libcutils/Android.mk | 1 - libcutils/adb_networking.c | 172 -------------------------------- 3 files changed, 208 deletions(-) delete mode 100755 include/cutils/adb_networking.h delete mode 100644 libcutils/adb_networking.c diff --git a/include/cutils/adb_networking.h b/include/cutils/adb_networking.h deleted file mode 100755 index 409d577ecd0..00000000000 --- a/include/cutils/adb_networking.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2006 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. - */ - -#ifndef _ADB_NETWORKING_H -#define _ADB_NETWORKING_H 1 -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -extern int adb_networking_connect_fd(int fd, struct sockaddr_in *p_address); -extern int adb_networking_gethostbyname(const char *name, struct in_addr *p_out_addr); - -#ifdef __cplusplus -} -#endif - -#endif /*_ADB_NETWORKING_H*/ - diff --git a/libcutils/Android.mk b/libcutils/Android.mk index 1d1e57603de..afa64bc3ffa 100644 --- a/libcutils/Android.mk +++ b/libcutils/Android.mk @@ -65,7 +65,6 @@ else mspace.c \ selector.c \ tztime.c \ - adb_networking.c \ zygote.c commonHostSources += \ diff --git a/libcutils/adb_networking.c b/libcutils/adb_networking.c deleted file mode 100644 index d819d44c8de..00000000000 --- a/libcutils/adb_networking.c +++ /dev/null @@ -1,172 +0,0 @@ -/* libs/utils/adb_networking.c -** -** Copyright 2006, 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. -*/ - -#define ADB_PORT 5037 - -#define _GNU_SOURCE /* for asprintf */ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define ADB_RESPONSE_SIZE 4 - -/** - * Unfortunately, java.net.Socket wants to create it's filedescriptor early - * So, this function takes an fd that must be an unconnected - * PF_LOCAL SOCK_STREAM - */ -int adb_networking_connect_fd(int fd, struct sockaddr_in *p_address) -{ - struct sockaddr_in local_addr; - socklen_t alen; - char *cmd; - char buf[ADB_RESPONSE_SIZE + 1]; - ssize_t count_read; - int ret; - int err; - /* for impl of inet_ntoa below*/ - union { - uint8_t b[4]; - uint32_t l; - } a; - - /* First, connect to adb */ - - memset(&local_addr, 0, sizeof(local_addr)); - local_addr.sin_family = AF_INET; - local_addr.sin_port = htons(ADB_PORT); - local_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - - do { - err = connect(fd, (struct sockaddr *) &local_addr, sizeof(local_addr)); - } while (err < 0 && errno == EINTR); - - if (err < 0) { - return -1; - } - - a.l = p_address->sin_addr.s_addr; - - // compose the command - asprintf(&cmd, "tcp:%u:%u.%u.%u.%u", - (unsigned int)ntohs(p_address->sin_port), - a.b[0],a.b[1],a.b[2],a.b[3]); - - // buf is now the ascii hex length of cmd - snprintf(buf, sizeof(buf), "%04X", strlen(cmd)); - - // write the 4-byte length - do { - err = write(fd, buf, 4); - } while (err < 0 && errno == EINTR); - - // write the command - do { - err = write(fd, cmd, strlen(cmd)); - } while (err < 0 && errno == EINTR); - - // read the result - do { - count_read = read(fd, buf, sizeof(buf) - 1); - } while (count_read < 0 && errno != EINTR); - - if (count_read == ADB_RESPONSE_SIZE - && 0 == strncmp(buf, "OKAY", ADB_RESPONSE_SIZE)) { - ret = 0; - } else { - /* what errno here? s_addr), sizeof(p_out_addr->s_addr)); - } while (count_read < 0 && errno != EINTR); - - if (count_read != 4) { - goto error; - } - - free(cmd); - close(fd); - return 0; -error: - free(cmd); - close(fd); - memset(p_out_addr, 0, sizeof(struct in_addr)); - return -1; -} - From b4add9b74525210478bac702d27fdaf9cf7ab18f Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 6 Oct 2009 18:07:49 -0700 Subject: [PATCH 006/907] Make fastboot say "no permissions" for non-writable devices. Without this patch, "adb devices" will say "no permissions" when it sees a device it can't write to, but "fastboot devices" will silently ignore it. This is confusing to n00bs, especially since it doesn't seem to be widely known that a device's USB id might be different in the bootloader (meaning two udev rules are needed). It can also be confusing if you're sshed in, when you can't access the device because you won't be in the "plugdev" group, but "fastboot devices" won't make this clear. I'm not sure about the Mac OS and Windows changes. AIUI, devices are always writable on those platforms, but I don't use either, so I can't test this. This patch shouldn't alter the behavior on either of those platforms. --- fastboot/fastboot.c | 3 +++ fastboot/usb.h | 2 ++ fastboot/usb_linux.c | 19 +++++++++++++------ fastboot/usb_osx.c | 3 +-- fastboot/usb_windows.c | 1 + 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c index c81222a823c..8e92017d890 100644 --- a/fastboot/fastboot.c +++ b/fastboot/fastboot.c @@ -165,6 +165,9 @@ int list_devices_callback(usb_ifc_info *info) { if (match_fastboot(info) == 0) { char* serial = info->serial_number; + if (!info->writable) { + serial = "no permissions"; // like "adb devices" + } if (!serial[0]) { serial = "????????????"; } diff --git a/fastboot/usb.h b/fastboot/usb.h index f3ec5bfdad4..cc157d56ee9 100644 --- a/fastboot/usb.h +++ b/fastboot/usb.h @@ -50,6 +50,8 @@ struct usb_ifc_info unsigned char has_bulk_in; unsigned char has_bulk_out; + unsigned char writable; + char serial_number[256]; }; diff --git a/fastboot/usb_linux.c b/fastboot/usb_linux.c index 3b40ba7f9ef..088c23a5d38 100644 --- a/fastboot/usb_linux.c +++ b/fastboot/usb_linux.c @@ -89,7 +89,8 @@ static int check(void *_desc, int len, unsigned type, int size) return 0; } -static int filter_usb_device(int fd, char *ptr, int len, ifc_match_func callback, +static int filter_usb_device(int fd, char *ptr, int len, int writable, + ifc_match_func callback, int *ept_in_id, int *ept_out_id, int *ifc_id) { struct usb_device_descriptor *dev; @@ -119,7 +120,8 @@ static int filter_usb_device(int fd, char *ptr, int len, ifc_match_func callback info.dev_class = dev->bDeviceClass; info.dev_subclass = dev->bDeviceSubClass; info.dev_protocol = dev->bDeviceProtocol; - + info.writable = writable; + // read device serial number (if there is one) info.serial_number[0] = 0; if (dev->iSerialNumber) { @@ -201,6 +203,7 @@ static usb_handle *find_usb_device(const char *base, ifc_match_func callback) DIR *busdir, *devdir; struct dirent *de; int fd; + int writable = 1; busdir = opendir(base); if(busdir == 0) return 0; @@ -220,12 +223,18 @@ static usb_handle *find_usb_device(const char *base, ifc_match_func callback) // DBG("[ scanning %s ]\n", devname); if((fd = open(devname, O_RDWR)) < 0) { - continue; + // Check if we have read-only access, so we can give a helpful + // diagnostic like "adb devices" does. + writable = 0; + if((fd = open(devname, O_RDONLY)) < 0) { + continue; + } } n = read(fd, desc, sizeof(desc)); - if(filter_usb_device(fd, desc, n, callback, &in, &out, &ifc) == 0){ + if(filter_usb_device(fd, desc, n, writable, callback, + &in, &out, &ifc) == 0) { usb = calloc(1, sizeof(usb_handle)); strcpy(usb->fname, devname); usb->ep_in = in; @@ -375,5 +384,3 @@ usb_handle *usb_open(ifc_match_func callback) { return find_usb_device("/dev/bus/usb", callback); } - - diff --git a/fastboot/usb_osx.c b/fastboot/usb_osx.c index d6a826094b8..0b0512d1ccb 100644 --- a/fastboot/usb_osx.c +++ b/fastboot/usb_osx.c @@ -351,6 +351,7 @@ static int try_device(io_service_t device, usb_handle *handle) { // device has no serial number handle->info.serial_number[0] = 0; } + handle->info.writable = 1; if (try_interfaces(dev, handle)) { goto error; @@ -416,8 +417,6 @@ static int init_usb(ifc_match_func callback, usb_handle **handle) { break; } - usb_ifc_info info; - if (try_device(device, &h) != 0) { IOObjectRelease(device); ret = -1; diff --git a/fastboot/usb_windows.c b/fastboot/usb_windows.c index 9c0a9cbf134..54008a4233d 100644 --- a/fastboot/usb_windows.c +++ b/fastboot/usb_windows.c @@ -301,6 +301,7 @@ int recognized_device(usb_handle* handle, ifc_match_func callback) { info.ifc_class = interf_desc.bInterfaceClass; info.ifc_subclass = interf_desc.bInterfaceSubClass; info.ifc_protocol = interf_desc.bInterfaceProtocol; + info.writable = 1; // read serial number (if there is one) unsigned long serial_number_len = sizeof(info.serial_number); From 31dbed7b60d8237d6d05dc6bf230167a5854b77a Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 7 Oct 2009 15:38:53 -0700 Subject: [PATCH 007/907] Add adb's ANDROID_SERIAL to fastboot too. We noticed this when trying to script on-device testing for the dalvik continuous build. Also fix a typo in adb's help. --- adb/commandline.c | 2 +- fastboot/fastboot.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/adb/commandline.c b/adb/commandline.c index 411bb82a3f1..f41146bf501 100644 --- a/adb/commandline.c +++ b/adb/commandline.c @@ -97,7 +97,7 @@ void help() " returns an error if more than one emulator is running.\n" " -s - directs command to the USB device or emulator with\n" " the given serial number. Overrides ANDROID_SERIAL\n" - " envivornment variable.\n" + " environment variable.\n" " -p - simple product name like 'sooner', or\n" " a relative/absolute path to a product\n" " out directory like 'out/target/product/sooner'.\n" diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c index 8e92017d890..911c3f60c3f 100644 --- a/fastboot/fastboot.c +++ b/fastboot/fastboot.c @@ -557,6 +557,8 @@ int main(int argc, char **argv) return 0; } + serial = getenv("ANDROID_SERIAL"); + while (argc > 0) { if(!strcmp(*argv, "-w")) { wants_wipe = 1; From c500be926cf07c43aeb828ae86b04b856c6b7c63 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 7 Oct 2009 17:24:39 -0700 Subject: [PATCH 008/907] Fix flashstation breakage. We need to reset 'writable' each time round the loop (i.e. for each device). --- fastboot/usb_linux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fastboot/usb_linux.c b/fastboot/usb_linux.c index 088c23a5d38..2ce53eb83e4 100644 --- a/fastboot/usb_linux.c +++ b/fastboot/usb_linux.c @@ -203,7 +203,7 @@ static usb_handle *find_usb_device(const char *base, ifc_match_func callback) DIR *busdir, *devdir; struct dirent *de; int fd; - int writable = 1; + int writable; busdir = opendir(base); if(busdir == 0) return 0; @@ -222,6 +222,7 @@ static usb_handle *find_usb_device(const char *base, ifc_match_func callback) sprintf(devname, "%s/%s", busname, de->d_name); // DBG("[ scanning %s ]\n", devname); + writable = 1; if((fd = open(devname, O_RDWR)) < 0) { // Check if we have read-only access, so we can give a helpful // diagnostic like "adb devices" does. From 8a0a5274ff37cbf3acad0199735a05e5fe3b5c9d Mon Sep 17 00:00:00 2001 From: Ben Cheng Date: Mon, 12 Oct 2009 16:51:23 -0700 Subject: [PATCH 009/907] Add stack unwinding directives to atomic-android-arm.S. --- libcutils/atomic-android-arm.S | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libcutils/atomic-android-arm.S b/libcutils/atomic-android-arm.S index f4299fdedf2..7befd780268 100644 --- a/libcutils/atomic-android-arm.S +++ b/libcutils/atomic-android-arm.S @@ -66,6 +66,8 @@ android_atomic_write: */ android_atomic_inc: + .fnstart + .save {r4, lr} stmdb sp!, {r4, lr} mov r2, r0 1: @ android_atomic_inc @@ -85,6 +87,7 @@ android_atomic_inc: sub r0, r1, #1 ldmia sp!, {r4, lr} bx lr + .fnend /* * ---------------------------------------------------------------------------- @@ -94,6 +97,8 @@ android_atomic_inc: */ android_atomic_dec: + .fnstart + .save {r4, lr} stmdb sp!, {r4, lr} mov r2, r0 1: @ android_atomic_dec @@ -113,6 +118,7 @@ android_atomic_dec: add r0, r1, #1 ldmia sp!, {r4, lr} bx lr + .fnend /* * ---------------------------------------------------------------------------- @@ -122,6 +128,8 @@ android_atomic_dec: */ android_atomic_add: + .fnstart + .save {r4, lr} stmdb sp!, {r4, lr} mov r2, r1 mov r4, r0 @@ -142,6 +150,7 @@ android_atomic_add: sub r0, r1, r4 ldmia sp!, {r4, lr} bx lr + .fnend /* @@ -152,6 +161,8 @@ android_atomic_add: */ android_atomic_and: + .fnstart + .save {r4, r5, lr} stmdb sp!, {r4, r5, lr} mov r2, r1 /* r2 = address */ mov r4, r0 /* r4 = the value */ @@ -174,6 +185,7 @@ android_atomic_and: mov r0, r5 ldmia sp!, {r4, r5, lr} bx lr + .fnend /* * ---------------------------------------------------------------------------- @@ -183,6 +195,8 @@ android_atomic_and: */ android_atomic_or: + .fnstart + .save {r4, r5, lr} stmdb sp!, {r4, r5, lr} mov r2, r1 /* r2 = address */ mov r4, r0 /* r4 = the value */ @@ -205,6 +219,7 @@ android_atomic_or: mov r0, r5 ldmia sp!, {r4, r5, lr} bx lr + .fnend /* * ---------------------------------------------------------------------------- @@ -228,6 +243,8 @@ android_atomic_swap: */ android_atomic_cmpxchg: + .fnstart + .save {r4, lr} stmdb sp!, {r4, lr} mov r4, r0 /* r4 = save oldvalue */ 1: @ android_atomic_cmpxchg @@ -249,6 +266,7 @@ android_atomic_cmpxchg: 2: @ android_atomic_cmpxchg ldmia sp!, {r4, lr} bx lr + .fnend /* * ---------------------------------------------------------------------------- From 66d487487fd117df392e6bb88ffa7d7b3d16d45d Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Tue, 27 Oct 2009 13:58:08 -0700 Subject: [PATCH 010/907] Print out error message when symbol lookup fails. --- libacc/tests/main.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libacc/tests/main.cpp b/libacc/tests/main.cpp index e4e386fc2b9..948f4cb47bc 100644 --- a/libacc/tests/main.cpp +++ b/libacc/tests/main.cpp @@ -38,7 +38,14 @@ int run(MainPtr mainFunc, int argc, char** argv) { } ACCvoid* symbolLookup(ACCvoid* pContext, const ACCchar* name) { - return (ACCvoid*) dlsym(RTLD_DEFAULT, name); + // Call dlerror once to clear out any preexisting error condition. + (void) dlerror(); + ACCvoid* result = (ACCvoid*) dlsym(RTLD_DEFAULT, name); + const char* error = dlerror(); + if (error) { + fprintf(stderr, "%s\"%s\"\n", error, name); + } + return result; } #ifdef PROVIDE_ARM_DISASSEMBLY From 188a5a7a3af54bd45383c72e452d627d33e63391 Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Tue, 27 Oct 2009 17:23:20 -0700 Subject: [PATCH 011/907] Support nested macros. (Still don't support macro arguments.) Now you can say: #define A B #define B C #define C 4 int x = A; And it will work as expected. Print an error message rather than assert when we're expecting a function value, but don't find one. --- libacc/acc.cpp | 174 +++++++++++++++++++++++-------------- libacc/tests/data/macros.c | 10 +++ libacc/tests/main.cpp | 9 +- libacc/tests/test.py | 6 ++ 4 files changed, 124 insertions(+), 75 deletions(-) create mode 100644 libacc/tests/data/macros.c diff --git a/libacc/acc.cpp b/libacc/acc.cpp index 6d9213c74cf..09ce64d16ba 100644 --- a/libacc/acc.cpp +++ b/libacc/acc.cpp @@ -3896,6 +3896,16 @@ class Compiler : public ErrorSink { Vector mLevelStack; }; + struct MacroState { + tokenid_t name; // Name of the current macro we are expanding + char* dptr; // point to macro text during macro playback + int dch; // Saves old value of ch during a macro playback + }; + +#define MACRO_NESTING_MAX 32 + MacroState macroState[MACRO_NESTING_MAX]; + int macroLevel; // -1 means not playing any macro. + int ch; // Current input character, or EOF tokenid_t tok; // token intptr_t tokc; // token extra info @@ -3907,8 +3917,6 @@ class Compiler : public ErrorSink { char* glo; // global variable index String mTokenString; bool mbSuppressMacroExpansion; - char* dptr; // Macro state: Points to macro text during macro playback. - int dch; // Macro state: Saves old value of ch during a macro playback. char* pGlobalBase; ACCSymbolLookupFn mpSymbolLookupFn; void* mpSymbolLookupContext; @@ -4016,9 +4024,6 @@ class Compiler : public ErrorSink { static const int LOCAL = 0x200; - static const int SYM_FORWARD = 0; - static const int SYM_DEFINE = 1; - /* tokens in string heap */ static const int TAG_TOK = ' '; @@ -4100,11 +4105,17 @@ class Compiler : public ErrorSink { } void inp() { - if (dptr) { - ch = *dptr++; + // Close any totally empty macros. We leave them on the stack until now + // so that we know which macros are being expanded when checking if the + // last token in the macro is a macro that's already being expanded. + while (macroLevel >= 0 && macroState[macroLevel].dptr == NULL) { + macroLevel--; + } + if (macroLevel >= 0) { + ch = *macroState[macroLevel].dptr++; if (ch == 0) { - dptr = 0; - ch = dch; + ch = macroState[macroLevel].dch; + macroState[macroLevel].dptr = NULL; // This macro's done } } else { if (mbBumpLine) { @@ -4269,6 +4280,15 @@ class Compiler : public ErrorSink { // fprintf(stderr, "float constant: %s (%d) %g\n", pText, tok, tokd); } + bool currentlyBeingExpanded(tokenid_t id) { + for (int i = 0; i <= macroLevel; i++) { + if (macroState[macroLevel].name == id) { + return true; + } + } + return false; + } + void next() { int l, a; @@ -4350,12 +4370,22 @@ class Compiler : public ErrorSink { if (! mbSuppressMacroExpansion) { // Is this a macro? char* pMacroDefinition = mTokenTable[tok].mpMacroDefinition; - if (pMacroDefinition) { + if (pMacroDefinition && !currentlyBeingExpanded(tok)) { // Yes, it is a macro - dptr = pMacroDefinition; - dch = ch; - inp(); - next(); +#if 0 + printf("Expanding macro %s -> %s", + mTokenString.getUnwrapped(), pMacroDefinition); +#endif + if (macroLevel >= MACRO_NESTING_MAX-1) { + error("Too many levels of macro recursion."); + } else { + macroLevel++; + macroState[macroLevel].name = tok; + macroState[macroLevel].dptr = pMacroDefinition; + macroState[macroLevel].dch = ch; + inp(); + next(); + } } } } else { @@ -4441,9 +4471,7 @@ class Compiler : public ErrorSink { next(); mbSuppressMacroExpansion = false; tokenid_t name = tok; - String* pName = new String(); if (ch == '(') { - delete pName; error("Defines with arguments not supported"); return; } @@ -4471,6 +4499,13 @@ class Compiler : public ErrorSink { memcpy(pDefn, value.getUnwrapped(), value.len()); pDefn[value.len()] = 0; mTokenTable[name].mpMacroDefinition = pDefn; +#if 0 + { + String buf; + decodeToken(buf, name, true); + fprintf(stderr, "define %s = \"%s\"\n", buf.getUnwrapped(), pDefn); + } +#endif } void doPragma() { @@ -4769,57 +4804,59 @@ class Compiler : public ErrorSink { Type* pDecl = NULL; VariableInfo* pVI = NULL; Type* pFn = pGen->getR0Type(); - assert(pFn->tag == TY_POINTER); - assert(pFn->pHead->tag == TY_FUNC); - pDecl = pFn->pHead; - pGen->pushR0(); - Type* pArgList = pDecl->pTail; - bool varArgs = pArgList == NULL; - /* push args and invert order */ - a = pGen->beginFunctionCallArguments(); - int l = 0; - int argCount = 0; - while (tok != ')' && tok != EOF) { - if (! varArgs && !pArgList) { - error("Unexpected argument."); - } - expr(); - pGen->forceR0RVal(); - Type* pTargetType; - if (pArgList) { - pTargetType = pArgList->pHead; - pArgList = pArgList->pTail; - } else { - // This is a ... function, just pass arguments in their - // natural type. - pTargetType = pGen->getR0Type(); - if (pTargetType->tag == TY_FLOAT) { - pTargetType = mkpDouble; - } else if (pTargetType->tag == TY_ARRAY) { - // Pass arrays by pointer. - pTargetType = pTargetType->pTail; + if (pFn->tag == TY_POINTER && pFn->pHead->tag == TY_FUNC) { + pDecl = pFn->pHead; + pGen->pushR0(); + Type* pArgList = pDecl->pTail; + bool varArgs = pArgList == NULL; + /* push args and invert order */ + a = pGen->beginFunctionCallArguments(); + int l = 0; + int argCount = 0; + while (tok != ')' && tok != EOF) { + if (! varArgs && !pArgList) { + error("Unexpected argument."); } + expr(); + pGen->forceR0RVal(); + Type* pTargetType; + if (pArgList) { + pTargetType = pArgList->pHead; + pArgList = pArgList->pTail; + } else { + // This is a ... function, just pass arguments in their + // natural type. + pTargetType = pGen->getR0Type(); + if (pTargetType->tag == TY_FLOAT) { + pTargetType = mkpDouble; + } else if (pTargetType->tag == TY_ARRAY) { + // Pass arrays by pointer. + pTargetType = pTargetType->pTail; + } + } + if (pTargetType->tag == TY_VOID) { + error("Can't pass void value for argument %d", + argCount + 1); + } else { + l += pGen->storeR0ToArg(l, pTargetType); + } + if (accept(',')) { + // fine + } else if ( tok != ')') { + error("Expected ',' or ')'"); + } + argCount += 1; } - if (pTargetType->tag == TY_VOID) { - error("Can't pass void value for argument %d", - argCount + 1); - } else { - l += pGen->storeR0ToArg(l, pTargetType); - } - if (accept(',')) { - // fine - } else if ( tok != ')') { - error("Expected ',' or ')'"); + if (! varArgs && pArgList) { + error("Expected more argument(s). Saw %d", argCount); } - argCount += 1; - } - if (! varArgs && pArgList) { - error("Expected more argument(s). Saw %d", argCount); + pGen->endFunctionCallArguments(pDecl, a, l); + skip(')'); + pGen->callIndirect(l, pDecl); + pGen->adjustStackAfterCall(pDecl, l, true); + } else { + error("Expected a function value to left of '('."); } - pGen->endFunctionCallArguments(pDecl, a, l); - skip(')'); - pGen->callIndirect(l, pDecl); - pGen->adjustStackAfterCall(pDecl, l, true); } else { break; } @@ -5620,8 +5657,12 @@ class Compiler : public ErrorSink { if (token == EOF ) { buffer.printf("EOF"); } else if (token == TOK_NUM) { - buffer.printf("numeric constant"); - } else if (token >= 0 && token < 256) { + buffer.printf("numeric constant %d(0x%x)", tokc, tokc); + } else if (token == TOK_NUM_FLOAT) { + buffer.printf("numeric constant float %g", tokd); + } else if (token == TOK_NUM_DOUBLE) { + buffer.printf("numeric constant double %g", tokd); + } else if (token >= 0 && token < 256) { if (token < 32) { buffer.printf("'\\x%02x'", token); } else { @@ -5828,8 +5869,7 @@ class Compiler : public ErrorSink { rsym = 0; loc = 0; glo = 0; - dptr = 0; - dch = 0; + macroLevel = -1; file = 0; pGlobalBase = 0; pCodeBuf = 0; diff --git a/libacc/tests/data/macros.c b/libacc/tests/data/macros.c new file mode 100644 index 00000000000..50e54dcd61a --- /dev/null +++ b/libacc/tests/data/macros.c @@ -0,0 +1,10 @@ +#define A B + B +#define B C + +int main() { + int C = 3; + printf("A = %d\n", A); +#define C 5 + printf("A = %d\n", A); + return 0; +} diff --git a/libacc/tests/main.cpp b/libacc/tests/main.cpp index 948f4cb47bc..e4e386fc2b9 100644 --- a/libacc/tests/main.cpp +++ b/libacc/tests/main.cpp @@ -38,14 +38,7 @@ int run(MainPtr mainFunc, int argc, char** argv) { } ACCvoid* symbolLookup(ACCvoid* pContext, const ACCchar* name) { - // Call dlerror once to clear out any preexisting error condition. - (void) dlerror(); - ACCvoid* result = (ACCvoid*) dlsym(RTLD_DEFAULT, name); - const char* error = dlerror(); - if (error) { - fprintf(stderr, "%s\"%s\"\n", error, name); - } - return result; + return (ACCvoid*) dlsym(RTLD_DEFAULT, name); } #ifdef PROVIDE_ARM_DISASSEMBLY diff --git a/libacc/tests/test.py b/libacc/tests/test.py index c982d16c36f..8f4920b8963 100644 --- a/libacc/tests/test.py +++ b/libacc/tests/test.py @@ -371,6 +371,12 @@ def testFilm(self): self.compileCheck(["-R", "data/film.c"], """Executing compiled code: result: 0""", """testing... Total bad: 0 +""") + + def testMacros(self): + self.compileCheck(["-R", "data/macros.c"], """Executing compiled code: +result: 0""", """A = 6 +A = 10 """) def testpointers2(self): From 22f5c6b8a28dba60cda05110e4bd514329a37f67 Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Tue, 27 Oct 2009 17:34:45 -0700 Subject: [PATCH 012/907] Update FEATURES for recent additions. --- libacc/FEATURES | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libacc/FEATURES b/libacc/FEATURES index 97a876d9e35..ce48c6f9c89 100644 --- a/libacc/FEATURES +++ b/libacc/FEATURES @@ -21,7 +21,7 @@ Supported C language subset: * Pointer indirection ('*') is supported. - * Square brackets can be used for pointer arithmetic. + * Square brackets are supported. * '=' and = are supported. @@ -37,11 +37,12 @@ Supported C language subset: + variables can be initialized in declarations. + Only ANSI-style function declarations are supported. - "..." is not supported. - - short is not supported + - short is supported - const is not supported - - arrays are not supported + - signed and unsigned are not supported. + - arrays are supported - long doubles are not supported - - structs are not supported + - structs and unions are supported - Unknown functions and variables are bound at compile time by calling back to the caller. For the 'acc' command-line tool unknown functions @@ -66,9 +67,12 @@ Supported C language subset: - Float and double constants are supported. - - '#define' is supported without function like arguments. No macro - recursion is tolerated. Other preprocessor directives are - ignored. + - '#define' is supported without function like arguments. + - Macro recursion is allowed. + - Self-referential macros are handled as in gcc. + - '#pragma' is supported. The pragma text is passed to a callback function, + and is used to implement meta-information. + - Other preprocessor directives are ignored. - C Strings and C character constants are supported. All ANSI C character escapes are supported. From ee1f829dd45a3a45fd0eb453b76a30cb99043be2 Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Wed, 28 Oct 2009 16:10:17 -0700 Subject: [PATCH 013/907] Implement typedef. --- libacc/FEATURES | 2 + libacc/acc.cpp | 197 +++++++++++++++++++++++++++--------- libacc/tests/data/typedef.c | 40 ++++++++ libacc/tests/test.py | 6 ++ 4 files changed, 199 insertions(+), 46 deletions(-) create mode 100644 libacc/tests/data/typedef.c diff --git a/libacc/FEATURES b/libacc/FEATURES index ce48c6f9c89..20f9d987b5a 100644 --- a/libacc/FEATURES +++ b/libacc/FEATURES @@ -43,6 +43,8 @@ Supported C language subset: - arrays are supported - long doubles are not supported - structs and unions are supported + - typedef is supported + - explicit storage class specifiers are not supported: register, auto, static, extern - Unknown functions and variables are bound at compile time by calling back to the caller. For the 'acc' command-line tool unknown functions diff --git a/libacc/acc.cpp b/libacc/acc.cpp index 09ce64d16ba..d9cecdd6c6e 100644 --- a/libacc/acc.cpp +++ b/libacc/acc.cpp @@ -151,6 +151,7 @@ class ErrorSink { class Compiler : public ErrorSink { typedef int tokenid_t; enum TypeTag { + TY_UNKNOWN = -1, TY_INT, // 0 TY_CHAR, // 1 TY_SHORT, // 2 @@ -164,8 +165,18 @@ class Compiler : public ErrorSink { TY_PARAM // 10 }; + enum StorageClass { + SC_DEFAULT, // 0 + SC_AUTO, // 1 + SC_REGISTER, // 2 + SC_STATIC, // 3 + SC_EXTERN, // 4 + SC_TYPEDEF // 5 + }; + struct Type { TypeTag tag; + StorageClass storageClass; tokenid_t id; // For function arguments, global vars, local vars, struct elements tokenid_t structTag; // For structs the name of the struct int length; // length of array, offset of struct element. -1 means struct is forward defined @@ -4996,7 +5007,7 @@ class Compiler : public ErrorSink { intptr_t a, n, t; Type* pBaseType; - if ((pBaseType = acceptPrimitiveType())) { + if ((pBaseType = acceptPrimitiveType(true))) { /* declarations */ localDeclarations(pBaseType); } else if (tok == TOK_IF) { @@ -5102,9 +5113,10 @@ class Compiler : public ErrorSink { } Type* createType(TypeTag tag, Type* pHead, Type* pTail) { - assert(tag >= TY_INT && tag <= TY_PARAM); + assert(tag >= TY_UNKNOWN && tag <= TY_PARAM); Type* pType = (Type*) mpCurrentArena->alloc(sizeof(Type)); memset(pType, 0, sizeof(*pType)); + pType->storageClass = SC_DEFAULT; pType->tag = tag; pType->pHead = pHead; pType->pTail = pTail; @@ -5267,38 +5279,124 @@ class Compiler : public ErrorSink { fprintf(stderr, "%s\n", buffer.getUnwrapped()); } - Type* acceptPrimitiveType() { - Type* pType; - if (tok == TOK_INT) { - pType = mkpInt; - } else if (tok == TOK_SHORT) { - pType = mkpShort; - } else if (tok == TOK_CHAR) { - pType = mkpChar; - } else if (tok == TOK_VOID) { - pType = mkpVoid; - } else if (tok == TOK_FLOAT) { - pType = mkpFloat; - } else if (tok == TOK_DOUBLE) { - pType = mkpDouble; - } else if (tok == TOK_STRUCT || tok == TOK_UNION) { - return acceptStruct(); + void insertTypeSpecifier(Type** ppType, TypeTag tag) { + if (! *ppType) { + *ppType = createType(tag, NULL, NULL); } else { - return NULL; + if ((*ppType)->tag != TY_UNKNOWN) { + error("Only one type specifier allowed."); + } else { + (*ppType)->tag = tag; + } + } + } + + void insertStorageClass(Type** ppType, StorageClass storageClass) { + if (! *ppType) { + *ppType = createType(TY_UNKNOWN, NULL, NULL); + } + if ((*ppType)->storageClass != SC_DEFAULT) { + error("Only one storage class allowed."); + } else { + (*ppType)->storageClass = storageClass; + } + } + + Type* acceptPrimitiveType(bool allowStorageClass) { + Type* pType = NULL; + for (bool keepGoing = true; keepGoing;) { + switch(tok) { + case TOK_AUTO: + insertStorageClass(&pType, SC_AUTO); + break; + case TOK_REGISTER: + insertStorageClass(&pType, SC_REGISTER); + break; + case TOK_STATIC: + insertStorageClass(&pType, SC_STATIC); + break; + case TOK_EXTERN: + insertStorageClass(&pType, SC_EXTERN); + break; + case TOK_TYPEDEF: + insertStorageClass(&pType, SC_TYPEDEF); + break; + case TOK_INT: + insertTypeSpecifier(&pType, TY_INT); + break; + case TOK_SHORT: + insertTypeSpecifier(&pType, TY_SHORT); + break; + case TOK_CHAR: + insertTypeSpecifier(&pType, TY_CHAR); + break; + case TOK_VOID: + insertTypeSpecifier(&pType, TY_VOID); + break; + case TOK_FLOAT: + insertTypeSpecifier(&pType, TY_FLOAT); + break; + case TOK_DOUBLE: + insertTypeSpecifier(&pType, TY_DOUBLE); + break; + case TOK_STRUCT: + case TOK_UNION: + { + insertTypeSpecifier(&pType, TY_STRUCT); + bool isStruct = (tok == TOK_STRUCT); + next(); + pType = acceptStruct(pType, isStruct); + keepGoing = false; + } + break; + default: + // Is it a typedef? + if (isSymbol(tok)) { + VariableInfo* pV = VI(tok); + if (pV && pV->pType->storageClass == SC_TYPEDEF) { + if (! pType) { + pType = createType(TY_UNKNOWN, NULL, NULL); + } + StorageClass storageClass = pType->storageClass; + *pType = *pV->pType; + pType->storageClass = storageClass; + } else { + keepGoing = false; + } + } else { + keepGoing = false; + } + } + if (keepGoing) { + next(); + } + } + if (pType) { + if (pType->tag == TY_UNKNOWN) { + pType->tag = TY_INT; + } + if (allowStorageClass) { + switch(pType->storageClass) { + case SC_AUTO: error("auto not supported."); break; + case SC_REGISTER: error("register not supported."); break; + case SC_STATIC: error("static not supported."); break; + case SC_EXTERN: error("extern not supported."); break; + default: break; + } + } else { + if (pType->storageClass != SC_DEFAULT) { + error("An explicit storage class is not allowed in this type declaration"); + } + } } - next(); return pType; } - Type* acceptStruct() { - assert(tok == TOK_STRUCT || tok == TOK_UNION); - bool isStruct = tok == TOK_STRUCT; - next(); + Type* acceptStruct(Type* pStructType, bool isStruct) { tokenid_t structTag = acceptSymbol(); bool isDeclaration = accept('{'); bool fail = false; - Type* pStructType = createType(TY_STRUCT, NULL, NULL); if (structTag) { Token* pToken = &mTokenTable[structTag]; VariableInfo* pStructInfo = pToken->mpStructInfo; @@ -5327,9 +5425,11 @@ class Compiler : public ErrorSink { if (needToDeclare) { // This is a new struct name pToken->mpStructInfo = mpCurrentSymbolStack->addStructTag(structTag); + StorageClass storageClass = pStructType->storageClass; pStructType = createType(TY_STRUCT, NULL, NULL); pStructType->structTag = structTag; pStructType->pHead = pStructType; + pStructType->storageClass = storageClass; if (! isDeclaration) { // A forward declaration pStructType->length = -1; @@ -5347,7 +5447,7 @@ class Compiler : public ErrorSink { size_t structAlignment = 0; Type** pParamHolder = & pStructType->pHead->pTail; while (tok != '}' && tok != EOF) { - Type* pPrimitiveType = expectPrimitiveType(); + Type* pPrimitiveType = expectPrimitiveType(false); if (pPrimitiveType) { while (tok != ';' && tok != EOF) { Type* pItem = acceptDeclaration(pPrimitiveType, true, false); @@ -5410,6 +5510,7 @@ class Compiler : public ErrorSink { Type* acceptDeclaration(Type* pType, bool nameAllowed, bool nameRequired) { tokenid_t declName = 0; bool reportFailure = false; + StorageClass storageClass = pType->storageClass; pType = acceptDecl2(pType, declName, nameAllowed, nameRequired, reportFailure); if (declName) { @@ -5418,6 +5519,7 @@ class Compiler : public ErrorSink { pType = createType(pType->tag, pType->pHead, pType->pTail); *pType = *pOldType; pType->id = declName; + pType->storageClass = storageClass; } else if (nameRequired) { error("Expected a variable name"); } @@ -5442,7 +5544,7 @@ class Compiler : public ErrorSink { /* Used for accepting types that appear in casts */ Type* acceptCastTypeDeclaration() { - Type* pType = acceptPrimitiveType(); + Type* pType = acceptPrimitiveType(false); if (pType) { pType = acceptDeclaration(pType, false, false); } @@ -5530,7 +5632,7 @@ class Compiler : public ErrorSink { Type* pHead = NULL; Type* pTail = NULL; for(;;) { - Type* pBaseArg = acceptPrimitiveType(); + Type* pBaseArg = acceptPrimitiveType(false); if (pBaseArg) { Type* pArg = acceptDeclaration(pBaseArg, nameAllowed, false); if (pArg) { @@ -5551,8 +5653,8 @@ class Compiler : public ErrorSink { return pHead; } - Type* expectPrimitiveType() { - Type* pType = acceptPrimitiveType(); + Type* expectPrimitiveType(bool allowStorageClass) { + Type* pType = acceptPrimitiveType(allowStorageClass); if (!pType) { String buf; decodeToken(buf, tok, true); @@ -5620,7 +5722,7 @@ class Compiler : public ErrorSink { break; } // Else it's a forward declaration of a function. - } else { + } else if (pDecl->storageClass != SC_TYPEDEF) { int variableAddress = 0; size_t alignment = pGen->alignmentOf(pDecl); assert(alignment > 0); @@ -5645,7 +5747,7 @@ class Compiler : public ErrorSink { next(); } skip(';'); - pBaseType = acceptPrimitiveType(); + pBaseType = acceptPrimitiveType(true); } } @@ -5709,7 +5811,7 @@ class Compiler : public ErrorSink { void globalDeclarations() { mpCurrentSymbolStack = &mGlobals; while (tok != EOF) { - Type* pBaseType = expectPrimitiveType(); + Type* pBaseType = expectPrimitiveType(true); if (!pBaseType) { break; } @@ -5726,7 +5828,6 @@ class Compiler : public ErrorSink { skip(';'); continue; } - if (! isDefined(pDecl->id)) { addGlobalSymbol(pDecl); } @@ -5737,19 +5838,23 @@ class Compiler : public ErrorSink { if (pDecl->tag < TY_FUNC) { // it's a variable declaration for(;;) { - if (name && !name->pAddress) { - name->pAddress = (int*) allocGlobalSpace( - pGen->alignmentOf(name->pType), - pGen->sizeOf(name->pType)); - } - if (accept('=')) { - if (tok == TOK_NUM) { - if (name) { - * (int*) name->pAddress = tokc; + if (pDecl->storageClass == SC_TYPEDEF) { + // Do not allocate storage. + } else { + if (name && !name->pAddress) { + name->pAddress = (int*) allocGlobalSpace( + pGen->alignmentOf(name->pType), + pGen->sizeOf(name->pType)); + } + if (accept('=')) { + if (tok == TOK_NUM) { + if (name) { + * (int*) name->pAddress = tokc; + } + next(); + } else { + error("Expected an integer constant"); } - next(); - } else { - error("Expected an integer constant"); } } if (!accept(',')) { diff --git a/libacc/tests/data/typedef.c b/libacc/tests/data/typedef.c new file mode 100644 index 00000000000..c392f6a3050 --- /dev/null +++ b/libacc/tests/data/typedef.c @@ -0,0 +1,40 @@ +typedef short COORD; +typedef struct Point { + COORD x; + COORD y; +} Point; + +void add(Point* result, Point* a, Point* b) { + result->x = a->x + b->x; + result->y = a->y + b->y; +} + +void print(Point* p) { + printf("(%d, %d)", p->x, p->y); +} + +void set(Point* p, int x, int y) { + p->x = x; + p->y = y; +} + +int main() { + typedef char* String; + String s = "x = %d\n"; + { + typedef int item; + item x = 3; + printf(s, x); + } + Point a, b, c; + set(&a, 1,2); + set(&b, 3,4); + add(&c, &a, &b); + print(&c); + printf(" = "); + print(&a); + printf(" + "); + print(&b); + printf("\n"); + return 0; +} diff --git a/libacc/tests/test.py b/libacc/tests/test.py index 8f4920b8963..6e0899cd82d 100644 --- a/libacc/tests/test.py +++ b/libacc/tests/test.py @@ -311,6 +311,12 @@ def testChar(self): result: 0""", """a = 99, b = 41 ga = 100, gb = 44""") + def testTypedef(self): + self.compileCheck(["-R", "data/typedef.c"], """Executing compiled code: +result: 0""", """x = 3 +(4, 6) = (1, 2) + (3, 4) +""") + def testPointerArithmetic(self): self.compileCheck(["-R", "data/pointers.c"], """Executing compiled code: result: 0""", """Pointer difference: 1 4 From c951c59232f59f1e0235725103f8636fe2f580f7 Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Thu, 29 Oct 2009 15:04:27 -0700 Subject: [PATCH 014/907] Add support for the continue statement Add error check for a break statement that's not inside a loop. (We just generated bad code before. Oops!) --- libacc/acc.cpp | 24 +++++++++++++++++------- libacc/tests/data/continue.c | 13 +++++++++++++ libacc/tests/test.py | 4 ++++ 3 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 libacc/tests/data/continue.c diff --git a/libacc/acc.cpp b/libacc/acc.cpp index d9cecdd6c6e..98401977928 100644 --- a/libacc/acc.cpp +++ b/libacc/acc.cpp @@ -5003,7 +5003,7 @@ class Compiler : public ErrorSink { return pGen->gtst(0, 0); } - void block(intptr_t l, bool outermostFunctionBlock) { + void block(int* breakLabel, int continueAddress, bool outermostFunctionBlock) { intptr_t a, n, t; Type* pBaseType; @@ -5015,12 +5015,12 @@ class Compiler : public ErrorSink { skip('('); a = test_expr(); skip(')'); - block(l, false); + block(breakLabel, continueAddress, false); if (tok == TOK_ELSE) { next(); n = pGen->gjmp(0); /* jmp */ pGen->gsym(a); - block(l, false); + block(breakLabel, continueAddress, false); pGen->gsym(n); /* patch else jmp */ } else { pGen->gsym(a); /* patch if test */ @@ -5050,7 +5050,7 @@ class Compiler : public ErrorSink { } } skip(')'); - block((intptr_t) &a, false); + block(&a, n, false); pGen->gjmp(n - pCodeBuf->getPC() - pGen->jumpOffset()); /* jmp */ pGen->gsym(a); } else if (tok == '{') { @@ -5059,7 +5059,7 @@ class Compiler : public ErrorSink { } next(); while (tok != '}' && tok != EOF) - block(l, false); + block(breakLabel, continueAddress, false); skip('}'); if (! outermostFunctionBlock) { mLocals.popLevel(); @@ -5081,7 +5081,17 @@ class Compiler : public ErrorSink { } rsym = pGen->gjmp(rsym); /* jmp */ } else if (accept(TOK_BREAK)) { - *(int *) l = pGen->gjmp(*(int *) l); + if (breakLabel) { + *breakLabel = pGen->gjmp(*breakLabel); + } else { + error("break statement must be within a for, do, while, or switch statement"); + } + } else if (accept(TOK_CONTINUE)) { + if (continueAddress) { + pGen->gjmp(continueAddress - pCodeBuf->getPC() - pGen->jumpOffset()); + } else { + error("continue statement must be within a for, do, or while statement"); + } } else if (tok != ';') commaExpr(); skip(';'); @@ -5907,7 +5917,7 @@ class Compiler : public ErrorSink { rsym = loc = 0; pReturnType = pDecl->pHead; a = pGen->functionEntry(pDecl); - block(0, true); + block(0, 0, true); pGen->gsym(rsym); pGen->functionExit(pDecl, a, loc); mLocals.popLevel(); diff --git a/libacc/tests/data/continue.c b/libacc/tests/data/continue.c new file mode 100644 index 00000000000..d8b8e36cabf --- /dev/null +++ b/libacc/tests/data/continue.c @@ -0,0 +1,13 @@ +int main() { + int i, j, sum; + sum = 0; + for (i = 0; i < 10; i++) { + if (i & 1) continue; + for (j = 0; j < 10; j++) { + if (j & 1) continue; + sum += i * j; + } + } + return sum; +} + diff --git a/libacc/tests/test.py b/libacc/tests/test.py index 6e0899cd82d..d93af468659 100644 --- a/libacc/tests/test.py +++ b/libacc/tests/test.py @@ -187,6 +187,10 @@ def testRunReturnVal(self): self.compileCheck(["-R", "data/returnval-ansi.c"], "Executing compiled code:\nresult: 42\n") + def testContinue(self): + self.compileCheck(["-R", "data/continue.c"], + "Executing compiled code:\nresult: 400\n") + def testStringLiteralConcatenation(self): self.compileCheck(["-R", "data/testStringConcat.c"], "Executing compiled code:\nresult: 13\n", "Hello, world\n") From 46f2bd2080115122f1ba5f3e12f6ce6a81a82fae Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Thu, 29 Oct 2009 17:56:56 -0700 Subject: [PATCH 015/907] Fix type bug that breaks 64-bit OSX build. --- libacc/acc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libacc/acc.cpp b/libacc/acc.cpp index 98401977928..0c32f25625b 100644 --- a/libacc/acc.cpp +++ b/libacc/acc.cpp @@ -5003,7 +5003,7 @@ class Compiler : public ErrorSink { return pGen->gtst(0, 0); } - void block(int* breakLabel, int continueAddress, bool outermostFunctionBlock) { + void block(intptr_t* breakLabel, intptr_t continueAddress, bool outermostFunctionBlock) { intptr_t a, n, t; Type* pBaseType; From 43ba23f30889f9e4dee0afd762f2f9a1cd5a99a8 Mon Sep 17 00:00:00 2001 From: Dan Bornstein Date: Fri, 30 Oct 2009 17:15:13 -0700 Subject: [PATCH 016/907] Define HAVE_SYS_SENDFILE_H. Platforms differ on whether sys/sendfile.h or sys/socket.h is where to find the declaration for sendfile(). Change-Id: Ib6e882534b7dc605d30aefed55732dc1ee2b6772 --- include/arch/darwin-x86/AndroidConfig.h | 5 +++++ include/arch/freebsd-x86/AndroidConfig.h | 5 +++++ include/arch/linux-arm/AndroidConfig.h | 5 +++++ include/arch/linux-sh/AndroidConfig.h | 5 +++++ include/arch/linux-x86/AndroidConfig.h | 5 +++++ include/arch/target_linux-x86/AndroidConfig.h | 5 +++++ include/arch/windows/AndroidConfig.h | 7 +++++++ 7 files changed, 37 insertions(+) diff --git a/include/arch/darwin-x86/AndroidConfig.h b/include/arch/darwin-x86/AndroidConfig.h index ad16e0c2626..20e00001581 100644 --- a/include/arch/darwin-x86/AndroidConfig.h +++ b/include/arch/darwin-x86/AndroidConfig.h @@ -85,6 +85,11 @@ */ #define HAVE_TERMIO_H +/* + * Define this if you have + */ +/* #define HAVE_SYS_SENDFILE_H 1 */ + /* * Define this if you build against MSVCRT.DLL */ diff --git a/include/arch/freebsd-x86/AndroidConfig.h b/include/arch/freebsd-x86/AndroidConfig.h index 39c564b93a2..b01a854f37b 100644 --- a/include/arch/freebsd-x86/AndroidConfig.h +++ b/include/arch/freebsd-x86/AndroidConfig.h @@ -90,6 +90,11 @@ */ /* #define HAVE_TERMIO_H */ +/* + * Define this if you have + */ +/* #define HAVE_SYS_SENDFILE_H 1 */ + /* * Define this if you build against MSVCRT.DLL */ diff --git a/include/arch/linux-arm/AndroidConfig.h b/include/arch/linux-arm/AndroidConfig.h index 82e39c01dff..26547a21639 100644 --- a/include/arch/linux-arm/AndroidConfig.h +++ b/include/arch/linux-arm/AndroidConfig.h @@ -91,6 +91,11 @@ */ #define HAVE_TERMIO_H +/* + * Define this if you have + */ +#define HAVE_SYS_SENDFILE_H 1 + /* * Define this if you build against MSVCRT.DLL */ diff --git a/include/arch/linux-sh/AndroidConfig.h b/include/arch/linux-sh/AndroidConfig.h index 4af39d94e56..67ac2777d23 100644 --- a/include/arch/linux-sh/AndroidConfig.h +++ b/include/arch/linux-sh/AndroidConfig.h @@ -91,6 +91,11 @@ */ #define HAVE_TERMIO_H +/* + * Define this if you have + */ +#define HAVE_SYS_SENDFILE_H 1 + /* * Define this if you build against MSVCRT.DLL */ diff --git a/include/arch/linux-x86/AndroidConfig.h b/include/arch/linux-x86/AndroidConfig.h index 557ec5f9466..31bdb5f95cf 100644 --- a/include/arch/linux-x86/AndroidConfig.h +++ b/include/arch/linux-x86/AndroidConfig.h @@ -85,6 +85,11 @@ */ #define HAVE_TERMIO_H +/* + * Define this if you have + */ +#define HAVE_SYS_SENDFILE_H 1 + /* * Define this if you build against MSVCRT.DLL */ diff --git a/include/arch/target_linux-x86/AndroidConfig.h b/include/arch/target_linux-x86/AndroidConfig.h index 6605723291b..d89d0547ef1 100644 --- a/include/arch/target_linux-x86/AndroidConfig.h +++ b/include/arch/target_linux-x86/AndroidConfig.h @@ -77,6 +77,11 @@ */ #define HAVE_TERMIO_H 1 +/* + * Define this if you have + */ +#define HAVE_SYS_SENDFILE_H 1 + /* * Define this if you build against have Microsoft C runtime (MSVCRT.DLL) */ diff --git a/include/arch/windows/AndroidConfig.h b/include/arch/windows/AndroidConfig.h index b240519a058..0fc4955ed2d 100644 --- a/include/arch/windows/AndroidConfig.h +++ b/include/arch/windows/AndroidConfig.h @@ -100,6 +100,13 @@ # define HAVE_TERMIO_H #endif +/* + * Define this if you have + */ +#ifdef __CYGWIN__ +# define HAVE_SYS_SENDFILE_H 1 +#endif + /* * Define this if you build against MSVCRT.DLL */ From 464407588fce5991b7e6e654695f0665d7f2d008 Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Thu, 12 Nov 2009 14:57:50 +0800 Subject: [PATCH 017/907] Build acc tool with static rather than shared library. OS X does not allow relative shared library path names in compiled apps, so we have to create and link with a static library version of libacc. --- libacc/Android.mk | 4 ++-- libacc/tests/Android.mk | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libacc/Android.mk b/libacc/Android.mk index 2b4998e5902..5101e169d8a 100644 --- a/libacc/Android.mk +++ b/libacc/Android.mk @@ -11,7 +11,7 @@ LOCAL_SHARED_LIBRARIES := libdl libcutils include $(BUILD_SHARED_LIBRARY) -# Shared library for host +# Static library for host # ======================================================== include $(CLEAR_VARS) @@ -23,7 +23,7 @@ LOCAL_CFLAGS := -O0 -g LOCAL_STATIC_LIBRARIES := libcutils LOCAL_LDLIBS := -ldl -include $(BUILD_HOST_SHARED_LIBRARY) +include $(BUILD_HOST_STATIC_LIBRARY) # Build children # ======================================================== diff --git a/libacc/tests/Android.mk b/libacc/tests/Android.mk index b3af6f12a8b..9188edb061a 100644 --- a/libacc/tests/Android.mk +++ b/libacc/tests/Android.mk @@ -8,8 +8,9 @@ LOCAL_MODULE:= acc LOCAL_SRC_FILES:= \ main.cpp -LOCAL_SHARED_LIBRARIES := \ - libacc +LOCAL_STATIC_LIBRARIES := \ + libacc \ + libcutils LOCAL_MODULE_TAGS := tests From e0f9d91dc73d293764822dcb1b49a4cef5d12275 Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Thu, 12 Nov 2009 15:21:42 +0800 Subject: [PATCH 018/907] Skip OTCCANSI test on OS X OS X can't load stderr/stdin/stdout through the DLL symbol lookup interface, so it can't compile the otcc-ansi.c test. --- libacc/tests/test.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libacc/tests/test.py b/libacc/tests/test.py index c32ce9fefe3..1b444c7fb0b 100644 --- a/libacc/tests/test.py +++ b/libacc/tests/test.py @@ -10,6 +10,7 @@ gUseArm = True gUseX86 = True gRunOTCCOutput = True +gCompileOTCCANSI = True def parseArgv(): @@ -59,7 +60,12 @@ def outputCanRun(): def checkEnvironment(): global gRunOTCCOutput - gRunOTCCOutput = uname() == "Linux" and unameM() != "x86_64" and outputCanRun() + global gCompileOTCCANSI + osName = uname() + gRunOTCCOutput = osName == "Linux" and unameM() != "x86_64" and outputCanRun() + # OSX doesn't have stdin/stdout/stderr accessible through dll load symbols, so + # we can't compile the ANSI version of the OTCC compiler on OS X. + gCompileOTCCANSI = osName == "Linux" def adb(args): return runCmd(["adb"] + args) @@ -180,8 +186,10 @@ def compileCheckArm(self, args, result): def testCompileReturnVal(self): self.compileCheck(["data/returnval-ansi.c"], "") - def testCompileOTCCANSII(self): - self.compileCheck(["data/otcc-ansi.c"], "", "", ['x86']) + def testCompileOTCCANSI(self): + global gCompileOTCCANSI + if gCompileOTCCANSI: + self.compileCheck(["data/otcc-ansi.c"], "", "", ['x86']) def testRunReturnVal(self): self.compileCheck(["-R", "data/returnval-ansi.c"], From b5d2ad66dfb042ac87017f944b3aabc1eb7b5783 Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Thu, 12 Nov 2009 15:38:44 +0800 Subject: [PATCH 019/907] Build accRuntimeTest with static library rather than shared library. --- libacc/tests/Android.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libacc/tests/Android.mk b/libacc/tests/Android.mk index 9188edb061a..ba5522fcf42 100644 --- a/libacc/tests/Android.mk +++ b/libacc/tests/Android.mk @@ -43,8 +43,9 @@ LOCAL_MODULE:= accRuntimeTest LOCAL_SRC_FILES:= \ runtimeTest.cpp -LOCAL_SHARED_LIBRARIES := \ - libacc +LOCAL_STATIC_LIBRARIES := \ + libacc \ + libcutils LOCAL_MODULE_TAGS := tests From a998b1c407ecfed5000d84acbc6934975a5e39fe Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Thu, 12 Nov 2009 16:06:28 +0800 Subject: [PATCH 020/907] Fix static and shared library usage for acc and accRuntimeTest --- libacc/tests/Android.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libacc/tests/Android.mk b/libacc/tests/Android.mk index ba5522fcf42..6ddfa74f45a 100644 --- a/libacc/tests/Android.mk +++ b/libacc/tests/Android.mk @@ -12,6 +12,9 @@ LOCAL_STATIC_LIBRARIES := \ libacc \ libcutils +LOCAL_LDLIBS := -ldl + + LOCAL_MODULE_TAGS := tests include $(BUILD_HOST_EXECUTABLE) @@ -47,6 +50,8 @@ LOCAL_STATIC_LIBRARIES := \ libacc \ libcutils +LOCAL_LDLIBS := -ldl + LOCAL_MODULE_TAGS := tests include $(BUILD_HOST_EXECUTABLE) From ef4e21520cef69aaa7b488a3f44b2490dc2e3eb5 Mon Sep 17 00:00:00 2001 From: Oscar Montemayor Date: Thu, 12 Nov 2009 12:02:24 -0800 Subject: [PATCH 021/907] Encrypted File SYstems project. Enabling EFS security properties. This change enables persist.security.* flags in the device, allowing oly the system to modify them. Change is necessary to allow for further progress in the project, as this is an ideal location for access both from the framework as well as from the recovery mode / transition. --- init/property_service.c | 1 + 1 file changed, 1 insertion(+) diff --git a/init/property_service.c b/init/property_service.c index 7db7c2cbf17..d2505dd1399 100644 --- a/init/property_service.c +++ b/init/property_service.c @@ -77,6 +77,7 @@ struct { { "service.adb.root", AID_SHELL, 0 }, { "persist.sys.", AID_SYSTEM, 0 }, { "persist.service.", AID_SYSTEM, 0 }, + { "persist.security.", AID_SYSTEM, 0 }, { NULL, 0, 0 } }; From eb67fac4723892ac8ae3fae87c05e776c49029c5 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 19 Nov 2009 16:52:02 -0800 Subject: [PATCH 022/907] change /cache/recovery group to cache To unbundle system update, we need users other than system to be able to write the /cache/recovery directory. --- rootdir/init.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootdir/init.rc b/rootdir/init.rc index f62d1d816b7..cd3fd9e36cf 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -97,7 +97,7 @@ loglevel 3 chmod 0770 /cache # This may have been created by the recovery system with odd permissions - chown system system /cache/recovery + chown system cache /cache/recovery chmod 0770 /cache/recovery #change permissions on vmallocinfo so we can grab it from bugreports From d3fe19fa14102bbd520365beb1a86778ffb8014c Mon Sep 17 00:00:00 2001 From: Dan Egnor Date: Mon, 23 Nov 2009 14:49:21 -0800 Subject: [PATCH 023/907] Update db_operation log tag information to match updated sampling code. --- logcat/event-log-tags | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/logcat/event-log-tags b/logcat/event-log-tags index 1262f4470a6..a51e2fa4399 100644 --- a/logcat/event-log-tags +++ b/logcat/event-log-tags @@ -375,9 +375,13 @@ #//device/dalvik/libcore/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.c 51000 socket_stats (send|1|2),(recv|1|2),(ip|1|5),(port|1|5),(close|1|5) -# db stats. 0 is query, 1 is write (may become more fine grained in the -# future) -52000 db_operation (name|3),(op_type|1|5),(time|2|3) +# Database operation samples. +# db: the filename of the database +# sql: the executed query (without query args) +# time: cpu time millis (not wall time), including lock acquisition +# blocking_package: if this is on a main thread, the package name, otherwise "" +# sample_percent: the percent likelihood this query was logged +52000 db_operation (db|3),(sql|3),(time|1|3),(blocking_package|3),(sample_percent|1|6) # http request/response stats 52001 http_stats (useragent|3),(response|2|3),(processing|2|3),(tx|1|2),(rx|1|2) From 7359c16a852c23740ef2874aa6b66f629d1473b7 Mon Sep 17 00:00:00 2001 From: Dan Egnor Date: Mon, 23 Nov 2009 19:25:44 -0800 Subject: [PATCH 024/907] Don't copy /proc/last_kmsg to /data/dontpanic/last_kmsg -- it gets generated on every boot, so this is a bunch of writing for no particularly good reason. --- rootdir/init.rc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/rootdir/init.rc b/rootdir/init.rc index cd3fd9e36cf..808255ee1b8 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -86,11 +86,6 @@ loglevel 3 write /proc/apanic_console 1 - # Collect ramconsole data - copy /proc/last_kmsg /data/dontpanic/last_kmsg - chown root log /data/dontpanic/last_kmsg - chmod 0640 /data/dontpanic/last_kmsg - # Same reason as /data above mount yaffs2 mtd@cache /cache nosuid nodev chown system cache /cache From ba48fe2f4e8bbcf53dbf66c40503a5751354f379 Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Fri, 27 Nov 2009 11:51:36 +0800 Subject: [PATCH 025/907] Fix memory deallocation bug in toy vector class. Yet another reason to use standard collection classes. :-) --- libacc/acc.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libacc/acc.cpp b/libacc/acc.cpp index 22cfb55f7ff..8f33b0bdd5b 100644 --- a/libacc/acc.cpp +++ b/libacc/acc.cpp @@ -82,9 +82,7 @@ template class Vector { ~Vector() { if (mpBase) { - for(size_t i = 0; i < mUsed; i++) { - mpBase[mUsed].~E(); - } + clear(); free(mpBase); } } @@ -110,10 +108,20 @@ template class Vector { * ensure(1) = item; } - size_t size() { + inline size_t size() { return mUsed; } + void clear() { + if (mpBase) { + size_t used = mUsed; + for(size_t i = 0; i < used; i++) { + mpBase[i].~E(); + } + } + mUsed = 0; + } + private: E* ensure(int n) { size_t newUsed = mUsed + n; From 64e99545d4b5600bb5ca044fcad636ae8389b381 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Sat, 28 Nov 2009 12:46:13 -0500 Subject: [PATCH 026/907] adb: fix -d and -e options for "adb forward" command. Change-Id: I9166572a1c398ce5ef1423d19a30895385118ee5 Signed-off-by: Mike Lockwood --- adb/commandline.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/adb/commandline.c b/adb/commandline.c index 055aa104e73..39ffdae85f7 100644 --- a/adb/commandline.c +++ b/adb/commandline.c @@ -990,9 +990,13 @@ int adb_commandline(int argc, char **argv) if(!strcmp(argv[0], "forward")) { if(argc != 3) return usage(); if (serial) { - snprintf(buf, sizeof buf, "host-serial:%s:forward:%s;%s",serial,argv[1],argv[2]); + snprintf(buf, sizeof buf, "host-serial:%s:forward:%s;%s",serial, argv[1], argv[2]); + } else if (ttype == kTransportUsb) { + snprintf(buf, sizeof buf, "host-usb:forward:%s;%s", argv[1], argv[2]); + } else if (ttype == kTransportLocal) { + snprintf(buf, sizeof buf, "host-local:forward:%s;%s", argv[1], argv[2]); } else { - snprintf(buf, sizeof buf, "host:forward:%s;%s",argv[1],argv[2]); + snprintf(buf, sizeof buf, "host:forward:%s;%s", argv[1], argv[2]); } if(adb_command(buf)) { fprintf(stderr,"error: %s\n", adb_error()); From 3bfdcc979da0f857b014318f3df5d95a0f93eb27 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Tue, 1 Dec 2009 12:37:26 -0800 Subject: [PATCH 027/907] Minor tweaks to debuggerd. Changed "process has crashed" message: - say ":5039" instead of ":port" so mouse-paste of command is trivial - removed trailing spaces, which consume log buffer to little effect - improved (I hope) the short explanation of what's going on and what the HOME key does Fixed typo ("ignorning"). --- debuggerd/debuggerd.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/debuggerd/debuggerd.c b/debuggerd/debuggerd.c index 996e6c2044f..145135fcb58 100644 --- a/debuggerd/debuggerd.c +++ b/debuggerd/debuggerd.c @@ -606,15 +606,16 @@ static void wait_for_user_action(unsigned tid, struct ucred* cr) (void)tid; /* First log a helpful message */ LOG( "********************************************************\n" - "* process %d crashed. debuggerd waiting for gdbserver \n" - "* \n" - "* adb shell gdbserver :port --attach %d & \n" - "* \n" - "* and press the HOME key. \n" + "* Process %d has been suspended while crashing. To\n" + "* attach gdbserver for a gdb connection on port 5039:\n" + "*\n" + "* adb shell gdbserver :5039 --attach %d &\n" + "*\n" + "* Press HOME key to let the process continue crashing.\n" "********************************************************\n", cr->pid, cr->pid); - /* wait for HOME key */ + /* wait for HOME key (TODO: something useful for devices w/o HOME key) */ if (init_getevent() == 0) { int ms = 1200 / 10; int dit = 1; @@ -698,7 +699,7 @@ static void handle_crashing_process(int fd) sprintf(buf,"/proc/%d/task/%d", cr.pid, tid); if(stat(buf, &s)) { - LOG("tid %d does not exist in pid %d. ignorning debug request\n", + LOG("tid %d does not exist in pid %d. ignoring debug request\n", tid, cr.pid); close(fd); return; From da077ee77a298f370a0df991aa43794916fe25b4 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Wed, 25 Nov 2009 13:03:06 -0800 Subject: [PATCH 028/907] construct event-log-tags via the new build mechanism The build system now unions together all *.logtags files found in LOCAL_SRC_FILES to construct /system/etc/event-log-tags. --- logcat/Android.mk | 16 +--------------- logcat/{event-log-tags => event.logtags} | 0 2 files changed, 1 insertion(+), 15 deletions(-) rename logcat/{event-log-tags => event.logtags} (100%) diff --git a/logcat/Android.mk b/logcat/Android.mk index 5a9f12da040..7b8eb01e3e0 100644 --- a/logcat/Android.mk +++ b/logcat/Android.mk @@ -3,24 +3,10 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -LOCAL_SRC_FILES:= logcat.cpp +LOCAL_SRC_FILES:= logcat.cpp event.logtags LOCAL_SHARED_LIBRARIES := liblog LOCAL_MODULE:= logcat include $(BUILD_EXECUTABLE) - -######################## -include $(CLEAR_VARS) - -LOCAL_MODULE := event-log-tags - -# This will install the file in /system/etc -# -LOCAL_MODULE_CLASS := ETC - -LOCAL_SRC_FILES := $(LOCAL_MODULE) -LOCAL_PREBUILT_STRIP_COMMENTS := 1 - -include $(BUILD_PREBUILT) diff --git a/logcat/event-log-tags b/logcat/event.logtags similarity index 100% rename from logcat/event-log-tags rename to logcat/event.logtags From 37c586e6b11138beab400d1208183d49c12a9ef2 Mon Sep 17 00:00:00 2001 From: Oscar Montemayor Date: Wed, 2 Dec 2009 16:43:52 -0800 Subject: [PATCH 029/907] Encrypted File Systems Project. Temporarily creating emulated encrypted directories manually. Will remove those lines once a true encrypted FS is mounted, and proper framework chanfes have been made. This is required for the feature to work with the other changes. --- rootdir/init.rc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rootdir/init.rc b/rootdir/init.rc index 808255ee1b8..71a98825bb4 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -116,6 +116,12 @@ loglevel 3 mkdir /data/app 0771 system system mkdir /data/property 0700 root root + # STOPSHIP: Temporary Encrypted File Systems workaround + mkdir /data/secure 0771 system system + mkdir /data/secure/data 0771 system system + mkdir /data/secure/misc 01771 system misc + mkdir /data/securemisc/vpn 0770 system system + mkdir /data/secure/misc/vpn/profiles 0770 system system # create dalvik-cache and double-check the perms mkdir /data/dalvik-cache 0771 system system From 092799072fc215b6f95b2d628e670ba2bb14d13b Mon Sep 17 00:00:00 2001 From: Doug Kwan Date: Thu, 3 Dec 2009 17:20:58 -0800 Subject: [PATCH 030/907] Add missing symbol type directives. --- debuggerd/crashglue.S | 4 +++- libcutils/atomic-android-arm.S | 8 ++++++++ libcutils/atomic-android-armv6.S | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/debuggerd/crashglue.S b/debuggerd/crashglue.S index 888951b9c47..0c1fd9b0327 100644 --- a/debuggerd/crashglue.S +++ b/debuggerd/crashglue.S @@ -1,5 +1,7 @@ .globl crash1 +.type crash1, %function .globl crashnostack +.type crashnostack, %function crash1: ldr r0, =0xa5a50000 @@ -25,4 +27,4 @@ crashnostack: mov sp, #0 mov r0, #0 ldr r0, [r0] - b . \ No newline at end of file + b . diff --git a/libcutils/atomic-android-arm.S b/libcutils/atomic-android-arm.S index da5c26b06d2..1dd2363d66a 100644 --- a/libcutils/atomic-android-arm.S +++ b/libcutils/atomic-android-arm.S @@ -24,17 +24,25 @@ .align .global android_atomic_write + .type android_atomic_write, %function .global android_atomic_inc + .type android_atomic_inc, %function .global android_atomic_dec + .type android_atomic_dec, %function .global android_atomic_add + .type android_atomic_add, %function .global android_atomic_and + .type android_atomic_and, %function .global android_atomic_or + .type android_atomic_or, %function .global android_atomic_swap + .type android_atomic_swap, %function .global android_atomic_cmpxchg + .type android_atomic_cmpxchg, %function /* * ---------------------------------------------------------------------------- diff --git a/libcutils/atomic-android-armv6.S b/libcutils/atomic-android-armv6.S index a71308966c9..1574c9c929e 100644 --- a/libcutils/atomic-android-armv6.S +++ b/libcutils/atomic-android-armv6.S @@ -19,17 +19,25 @@ .align .global android_atomic_write + .type android_atomic_write, %function .global android_atomic_inc + .type android_atomic_inc, %function .global android_atomic_dec + .type android_atomic_dec, %function .global android_atomic_add + .type android_atomic_add, %function .global android_atomic_and + .type android_atomic_and, %function .global android_atomic_or + .type android_atomic_or, %function .global android_atomic_swap + .type android_atomic_swap, %function .global android_atomic_cmpxchg + .type android_atomic_cmpxchg, %function From 22078f2c05281763726d152f62b59f7cce96c73e Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Fri, 4 Dec 2009 09:37:08 -0500 Subject: [PATCH 031/907] NDK header for accessing pixels of a java bitmap --- include/android/bitmap.h | 79 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 include/android/bitmap.h diff --git a/include/android/bitmap.h b/include/android/bitmap.h new file mode 100644 index 00000000000..5078277b58b --- /dev/null +++ b/include/android/bitmap.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2009 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. + */ + +#ifndef ANDROID_BITMAP_H +#define ANDROID_BITMAP_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define ANDROID_BITMAP_RESUT_SUCCESS 0 +#define ANDROID_BITMAP_RESULT_BAD_PARAMETER -1 +#define ANDROID_BITMAP_RESULT_JNI_EXCEPTION -2 +#define ANDROID_BITMAP_RESULT_ALLOCATION_FAILED -3 + +enum AndroidBitmapFormat { + ANDROID_BITMAP_FORMAT_NONE = 0, + ANDROID_BITMAP_FORMAT_RGBA_8888 = 1, + ANDROID_BITMAP_FORMAT_RGB_565 = 4, + ANDROID_BITMAP_FORMAT_RGBA_4444 = 7, + ANDROID_BITMAP_FORMAT_A_8 = 8, +}; + +typedef struct { + uint32_t width; + uint32_t height; + uint32_t stride; + int32_t format; + uint32_t flags; // 0 for now +} AndroidBitmapInfo; + +/** + * Given a java bitmap object, fill out the AndroidBitmap struct for it. + * If the call fails, the info parameter will be ignored + */ +int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap, + AndroidBitmapInfo* info); + +/** + * Given a java bitmap object, attempt to lock the pixel address. + * Locking will ensure that the memory for the pixels will not move + * until the unlockPixels call, and ensure that, if the pixels had been + * previously purged, they will have been restored. + * + * If this call succeeds, it must be balanced by a call to + * AndroidBitmap_unlockPixels, after which time the address of the pixels should + * no longer be used. + * + * If this succeeds, *addrPtr will be set to the pixel address. If the call + * fails, addrPtr will be ignored. + */ +int AndroidBitmap_lockPixels(JNIEnv* env, jobject jbitmap, void** addrPtr); + +/** + * Call this to balanace a successful call to AndroidBitmap_lockPixels + */ +int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap); + +#ifdef __cplusplus +} +#endif + +#endif From a43d27539156daf08b34bcaa07661fe0e66fa345 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Fri, 4 Dec 2009 10:42:08 -0800 Subject: [PATCH 032/907] remove system server tags from global event.logtags file These tags are being moved to a .logtags file in the system server package. --- logcat/event.logtags | 88 -------------------------------------------- 1 file changed, 88 deletions(-) diff --git a/logcat/event.logtags b/logcat/event.logtags index a51e2fa4399..c942d7ea2bf 100644 --- a/logcat/event.logtags +++ b/logcat/event.logtags @@ -43,28 +43,6 @@ # "account" is the java hash of the account name 2720 sync (id|3),(event|1|5),(source|1|5),(account|1|5) 2721 cpu (total|1|6),(user|1|6),(system|1|6),(iowait|1|6),(irq|1|6),(softirq|1|6) -2722 battery_level (level|1|6),(voltage|1|1),(temperature|1|1) -2723 battery_status (status|1|5),(health|1|5),(present|1|5),(plugged|1|5),(technology|3) -# This is logged when the device is being forced to sleep (typically by -# the user pressing the power button). -2724 power_sleep_requested (wakeLocksCleared|1|1) -# This is logged when the screen on broadcast has completed -2725 power_screen_broadcast_send (wakelockCount|1|1) -# This is logged when the screen broadcast has completed -2726 power_screen_broadcast_done (on|1|5),(broadcastDuration|2|3),(wakelockCount|1|1) -# This is logged when the screen on broadcast has completed -2727 power_screen_broadcast_stop (which|1|5),(wakelockCount|1|1) -# This is logged when the screen is turned on or off. -2728 power_screen_state (offOrOn|1|5),(becauseOfUser|1|5),(totalTouchDownTime|2|3),(touchCycles|1|1) -# This is logged when the partial wake lock (keeping the device awake -# regardless of whether the screen is off) is acquired or released. -2729 power_partial_wake_state (releasedorAcquired|1|5),(tag|3) -# This is logged when battery goes from discharging to charging. -# It lets us count the total amount of time between charges and the discharge level -2730 battery_discharge (duration|2|3),(minLevel|1|6),(maxLevel|1|6) -# -# Leave IDs through 2739 for more power logs -# # This event is logged when the location service uploads location data. 2740 location_controller @@ -76,25 +54,10 @@ # operation details) 2743 sync_details (authority|3),(send|1|2),(recv|1|2),(details|3) -# The disk space free on the /data partition, in bytes -2744 free_storage_changed (data|2|2) -# Device low memory notification and disk space free on the /data partition, in bytes at that time -2745 low_storage (data|2|2) -# disk space free on the /data, /system, and /cache partitions in bytes -2746 free_storage_left (data|2|2),(system|2|2),(cache|2|2) - # contacts aggregation: time and number of contacts. # count is negative for query phase, positive for merge phase 2747 contacts_aggregation (aggregation time|2|3), (count|1|1) -# when a NotificationManager.notify is called -2750 notification_enqueue (pkg|3),(id|1|5),(notification|3) -# when someone tries to cancel a notification, the notification manager sometimes -# calls this with flags too -2751 notification_cancel (pkg|3),(id|1|5),(required_flags|1) -# when someone tries to cancel all of the notifications for a particular package -2752 notification_cancel_all (pkg|3),(required_flags|1) - # This event is logged when GTalkService encounters important events 2800 gtalkservice (eventType|1) # This event is logged for GTalk connection state changes. The status field is an int, but @@ -102,39 +65,11 @@ # (eventType << 24) + (connection state << 16) + (connection error << 8) + network state 2801 gtalk_connection (status|1) -2802 watchdog (Service|3) -2803 watchdog_proc_pss (Process|3),(Pid|1|5),(Pss|1|2) -2804 watchdog_soft_reset (Process|3),(Pid|1|5),(MaxPss|1|2),(Pss|1|2),(Skip|3) -2805 watchdog_hard_reset (Process|3),(Pid|1|5),(MaxPss|1|2),(Pss|1|2) -2806 watchdog_pss_stats (EmptyPss|1|2),(EmptyCount|1|1),(BackgroundPss|1|2),(BackgroundCount|1|1),(ServicePss|1|2),(ServiceCount|1|1),(VisiblePss|1|2),(VisibleCount|1|1),(ForegroundPss|1|2),(ForegroundCount|1|1),(NoPssCount|1|1) -2807 watchdog_proc_stats (DeathsInOne|1|1),(DeathsInTwo|1|1),(DeathsInThree|1|1),(DeathsInFour|1|1),(DeathsInFive|1|1) -2808 watchdog_scheduled_reboot (Now|2|1),(Interval|1|3),(StartTime|1|3),(Window|1|3),(Skip|3) -2809 watchdog_meminfo (MemFree|1|2),(Buffers|1|2),(Cached|1|2),(Active|1|2),(Inactive|1|2),(AnonPages|1|2),(Mapped|1|2),(Slab|1|2),(SReclaimable|1|2),(SUnreclaim|1|2),(PageTables|1|2) -2810 watchdog_vmstat (runtime|2|3),(pgfree|1|1),(pgactivate|1|1),(pgdeactivate|1|1),(pgfault|1|1),(pgmajfault|1|1) -2811 watchdog_requested_reboot (NoWait|1|1),(ScheduleInterval|1|3),(RecheckInterval|1|3),(StartTime|1|3),(Window|1|3),(MinScreenOff|1|3),(MinNextAlarm|1|3) - -2820 backup_data_changed (Package|3) -2821 backup_start (Transport|3) -2822 backup_transport_failure (Package|3) -2823 backup_agent_failure (Package|3),(Message|3) -2824 backup_package (Package|3),(Size|1|2) -2825 backup_success (Packages|1|1),(Time|1|3) -2826 backup_reset (Transport|3) -2827 backup_initialize - -2830 restore_start (Transport|3),(Source|2|5) -2831 restore_transport_failure -2832 restore_agent_failure (Package|3),(Message|3) -2833 restore_package (Package|3),(Size|1|2) -2834 restore_success (Packages|1|1),(Time|1|3) - # Device boot timings. We include monotonic clock values because the # intrinsic event log times are wall-clock. # # Runtime starts: 3000 boot_progress_start (time|2|3) -# SystemServer.run() starts: -3010 boot_progress_system_run (time|2|3) # ZygoteInit class preloading starts: 3020 boot_progress_preload_start (time|2|3) # ZygoteInit class preloading ends: @@ -143,17 +78,6 @@ 3040 boot_progress_ams_ready (time|2|3) # ActivityManagerService calls enableScreenAfterBoot(): 3050 boot_progress_enable_screen (time|2|3) -# Package Manager starts: -3060 boot_progress_pms_start (time|2|3) -# Package Manager .apk scan starts: -3070 boot_progress_pms_system_scan_start (time|2|3) -# Package Manager .apk scan starts: -3080 boot_progress_pms_data_scan_start (time|2|3) -# Package Manager .apk scan ends: -3090 boot_progress_pms_scan_end (time|2|3) -# Package Manager ready: -3100 boot_progress_pms_ready (time|2|3) -# + check activity_launch_time for Home app # This event is logged when GTalk connection is closed. # The status field is an int, but contains 2 different values, it's represented as @@ -285,12 +209,6 @@ # The activity manager gave up on a new process taking too long to start 30037 am_process_start_timeout (PID|1|5),(UID|1|5),(Process Name|3) -# Out of memory for surfaces. -31000 wm_no_surface_memory (Window|3),(PID|1|5),(Operation|3) - -# Re-connecting to input method service because we haven't received its interface -32000 imf_force_reconnect_ime (IME|4),(Time Since Connect|2|3),(Showing|1|1) - 75000 sqlite_mem_alarm_current (current|1|2) 75001 sqlite_mem_alarm_max (max|1|2) 75002 sqlite_mem_alarm_alloc_attempt (attempts|1|4) @@ -301,12 +219,6 @@ 50000 menu_item_selected (Menu type where 0 is options and 1 is context|1|5),(Menu item title|3) 50001 menu_opened (Menu type where 0 is options and 1 is context|1|5) -# Connectivity state changed: -# [31-13] Reserved for future use -# [12- 9] Network subtype (for mobile network, as defined by TelephonyManager) -# [ 8- 3] Detailed state ordinal (as defined by NetworkInfo.DetailedState) -# [ 2- 0] Network type (as defined by ConnectivityManager) -50020 connectivity_state_changed (custom|1|5) # Wi-Fi network state changed: # [31- 6] Reserved for future use From dd75019da80cf49361fd355d4d6b66c02c73896e Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Fri, 4 Dec 2009 16:47:40 -0800 Subject: [PATCH 033/907] remove ActivityManager-related event log tags These have been migrated to the ActivityManagerService package. --- logcat/event.logtags | 75 -------------------------------------------- 1 file changed, 75 deletions(-) diff --git a/logcat/event.logtags b/logcat/event.logtags index c942d7ea2bf..3e68efb2350 100644 --- a/logcat/event.logtags +++ b/logcat/event.logtags @@ -39,10 +39,8 @@ 314 pi 2718 e -2719 configuration_changed (config mask|1|5) # "account" is the java hash of the account name 2720 sync (id|3),(event|1|5),(source|1|5),(account|1|5) -2721 cpu (total|1|6),(user|1|6),(system|1|6),(iowait|1|6),(irq|1|6),(softirq|1|6) # This event is logged when the location service uploads location data. 2740 location_controller @@ -74,10 +72,6 @@ 3020 boot_progress_preload_start (time|2|3) # ZygoteInit class preloading ends: 3030 boot_progress_preload_end (time|2|3) -# ActivityManagerService.systemReady() starts: -3040 boot_progress_ams_ready (time|2|3) -# ActivityManagerService calls enableScreenAfterBoot(): -3050 boot_progress_enable_screen (time|2|3) # This event is logged when GTalk connection is closed. # The status field is an int, but contains 2 different values, it's represented as @@ -140,75 +134,6 @@ 20001 dvm_gc_info (custom|2),(custom|2),(custom|2),(custom|2) 20002 dvm_gc_madvise_info (total|1|2),(zygote|1|2) -# Do not change these names without updating the checkin_events setting in -# google3/googledata/wireless/android/provisioning/gservices.config !! -# -# An activity is being finished: -30001 am_finish_activity (Token|1|5),(Task ID|1|5),(Component Name|3),(Reason|3) -# A task is being brought to the front of the screen: -30002 am_task_to_front (Task|1|5) -# An existing activity is being given a new intent: -30003 am_new_intent (Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5) -# A new task is being created: -30004 am_create_task (Task ID|1|5) -# A new activity is being created in an existing task: -30005 am_create_activity (Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5) -# An activity has been resumed into the foreground but was not already running: -30006 am_restart_activity (Token|1|5),(Task ID|1|5),(Component Name|3) -# An activity has been resumed and is now in the foreground: -30007 am_resume_activity (Token|1|5),(Task ID|1|5),(Component Name|3) -# Application Not Responding -30008 anr (pid|1|5),(Package Name|3),(reason|3) -# Activity launch time -30009 activity_launch_time (Token|1|5),(Component Name|3),(time|2|3) -# Application process bound to work -30010 am_proc_bound (PID|1|5),(Process Name|3) -# Application process died -30011 am_proc_died (PID|1|5),(Process Name|3) -# The Activity Manager failed to pause the given activity. -30012 am_failed_to_pause (Token|1|5),(Wanting to pause|3),(Currently pausing|3) -# Attempting to pause the current activity -30013 am_pause_activity (Token|1|5),(Component Name|3) -# Application process has been started -30014 am_proc_start (PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3) -# An application process has been marked as bad -30015 am_proc_bad (UID|1|5),(Process Name|3) -# An application process that was bad is now marked as good -30016 am_proc_good (UID|1|5),(Process Name|3) -# Reporting to applications that memory is low -30017 am_low_memory (Num Processes|1|1) -# An activity is being destroyed: -30018 am_destroy_activity (Token|1|5),(Task ID|1|5),(Component Name|3) -# An activity has been relaunched, resumed, and is now in the foreground: -30019 am_relaunch_resume_activity (Token|1|5),(Task ID|1|5),(Component Name|3) -# An activity has been relaunched: -30020 am_relaunch_activity (Token|1|5),(Task ID|1|5),(Component Name|3) -# The activity's onPause has been called. -30021 am_on_paused_called (Component Name|3) -# The activity's onResume has been called. -30022 am_on_resume_called (Component Name|3) -# Kill a process to reclaim memory. -30023 am_kill_for_memory (PID|1|5),(Process Name|3),(OomAdj|1|5) -# Discard an undelivered serialized broadcast (timeout/ANR/crash) -30024 am_broadcast_discard_filter (Broadcast|1|5),(Action|3),(Receiver Number|1|1),(BroadcastFilter|1|5) -30025 am_broadcast_discard_app (Broadcast|1|5),(Action|3),(Receiver Number|1|1),(App|3) -# A service is being created -30030 am_create_service (Service Record|1|5),(Name|3),(Intent|3),(PID|1|5) -# A service is being destroyed -30031 am_destroy_service (Service Record|1|5),(Name|3),(PID|1|5) -# A process has crashed too many times, it is being cleared -30032 am_process_crashed_too_much (Name|3),(PID|1|5) -# An unknown process is trying to attach to the activity manager -30033 am_drop_process (PID|1|5) -# A service has crashed too many times, it is being stopped -30034 am_service_crashed_too_much (Crash Count|1|1),(Component Name|3),(PID|1|5) -# A service is going to be restarted after its process went away -30035 am_schedule_service_restart (Component Name|3),(Time|2|3) -# A client was waiting for a content provider, but its process was lost -30036 am_provider_lost_process (Package Name|3),(UID|1|5),(Name|3) -# The activity manager gave up on a new process taking too long to start -30037 am_process_start_timeout (PID|1|5),(UID|1|5),(Process Name|3) - 75000 sqlite_mem_alarm_current (current|1|2) 75001 sqlite_mem_alarm_max (max|1|2) 75002 sqlite_mem_alarm_alloc_attempt (attempts|1|4) From 88660fa5d897a74f2fe07f4b827d37a453e32181 Mon Sep 17 00:00:00 2001 From: Ben Winslow Date: Sat, 15 Aug 2009 09:52:10 -0400 Subject: [PATCH 034/907] vold: Check partitions 1-4 instead of 0-3 In mmc_bootstrap_mmcblk, bootstrap partitions 1-4 instead of 0-3, since that's how the kernel labels them. Additionally, use the NDOSPART constant from diskmbr.h instead of hardcoding 4 when scanning partitions. Signed-off-by: San Mehat --- vold/blkdev.c | 4 ++-- vold/mmc.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/vold/blkdev.c b/vold/blkdev.c index 22d000e5d9c..33fed1b8375 100644 --- a/vold/blkdev.c +++ b/vold/blkdev.c @@ -113,7 +113,7 @@ int blkdev_refresh(blkdev_t *blk) goto out; } - for (i = 0; i < 4; i++) { + for (i = 0; i < NDOSPART; i++) { struct dos_partition part; dos_partition_dec(block + DOSPARTOFF + i * sizeof(struct dos_partition), &part); @@ -140,7 +140,7 @@ int blkdev_refresh(blkdev_t *blk) else part_no = blk->minor -1; - if (part_no < 4) { + if (part_no < NDOSPART) { dos_partition_dec(block + DOSPARTOFF + part_no * sizeof(struct dos_partition), &part); blk->part_type = part.dp_typ; } else { diff --git a/vold/mmc.c b/vold/mmc.c index b321c80f716..22894a1fde0 100644 --- a/vold/mmc.c +++ b/vold/mmc.c @@ -25,6 +25,7 @@ #include "vold.h" #include "mmc.h" #include "media.h" +#include "diskmbr.h" /* for NDOSPART */ #define DEBUG_BOOTSTRAP 0 @@ -233,7 +234,7 @@ static int mmc_bootstrap_mmcblk(char *devpath) *mmcblk_devname != '/'; mmcblk_devname--); mmcblk_devname++; - for (part_no = 0; part_no < 4; part_no++) { + for (part_no = 1; part_no <= NDOSPART; part_no++) { char part_file[255]; sprintf(part_file, "/sys%s/%sp%d", devpath, mmcblk_devname, part_no); if (!access(part_file, F_OK)) { From 96dbb4fc58fe2dcf4390e073dbb42cc77ef2f0b5 Mon Sep 17 00:00:00 2001 From: Martyn Capewell Date: Mon, 7 Dec 2009 13:59:59 +0000 Subject: [PATCH 035/907] Adds UXTB16 support to Pixelflinger * Add support for UXTB16 to the disassembler * Add encoding of the UXTB16 instruction to the Pixelflinger JIT. Introducing the UXTB16 instruction allows removal of some masking code, and is beneficial from a pipeline point of view - lots of UXTB16 followed by MUL sequences. Also, further rescheduling and use of SMULWB brings extra performance improvements. * Use UXTB16 in bilinear filtered texturing Uses UXTB16 to extract channels for SIMD operations, rather than creating and ANDing with masks. Saves a register and is faster on A8, as UXTB16 result can feed into first stage of multiply, unlike AND. Also, used SMULWB rather than SMULBB, which allows removal of MOVs used to rescale results. Code has been scheduled for A8 pipeline, specifically aiming to allow multiplies to issue in pipeline 0, for efficient dual issue operation. Testing on SpriteMethodTest (http://code.google.com/p/apps-for-android/) gives 8% improvement (12.7 vs. 13.7 fps.) SMULBB to SMULWB trick could be used in > 3) << 10) | Rm; +} + }; // namespace android diff --git a/libpixelflinger/codeflinger/ARMAssembler.h b/libpixelflinger/codeflinger/ARMAssembler.h index ef3b66af7b9..a667cb51125 100644 --- a/libpixelflinger/codeflinger/ARMAssembler.h +++ b/libpixelflinger/codeflinger/ARMAssembler.h @@ -123,6 +123,7 @@ class ARMAssembler : public ARMAssemblerInterface int RdHi, int RdLo, int Rs, int Rm); virtual void SMLAW(int cc, int y, int Rd, int Rm, int Rs, int Rn); + virtual void UXTB16(int cc, int Rd, int Rm, int rotate); private: ARMAssembler(const ARMAssembler& rhs); diff --git a/libpixelflinger/codeflinger/ARMAssemblerInterface.h b/libpixelflinger/codeflinger/ARMAssemblerInterface.h index 465b3bd9d98..ff6af2a22b2 100644 --- a/libpixelflinger/codeflinger/ARMAssemblerInterface.h +++ b/libpixelflinger/codeflinger/ARMAssemblerInterface.h @@ -203,6 +203,9 @@ class ARMAssemblerInterface virtual void SMLAW(int cc, int y, int Rd, int Rm, int Rs, int Rn) = 0; + // byte/half word extract... + virtual void UXTB16(int cc, int Rd, int Rm, int rotate) = 0; + // ----------------------------------------------------------------------- // convenience... // ----------------------------------------------------------------------- diff --git a/libpixelflinger/codeflinger/ARMAssemblerProxy.cpp b/libpixelflinger/codeflinger/ARMAssemblerProxy.cpp index 18c46186499..7c422dbadb2 100644 --- a/libpixelflinger/codeflinger/ARMAssemblerProxy.cpp +++ b/libpixelflinger/codeflinger/ARMAssemblerProxy.cpp @@ -195,6 +195,9 @@ void ARMAssemblerProxy::SMLAW(int cc, int y, int Rd, int Rm, int Rs, int Rn) { mTarget->SMLAW(cc, y, Rd, Rm, Rs, Rn); } +void ARMAssemblerProxy::UXTB16(int cc, int Rd, int Rm, int rotate) { + mTarget->UXTB16(cc, Rd, Rm, rotate); +} }; // namespace android diff --git a/libpixelflinger/codeflinger/ARMAssemblerProxy.h b/libpixelflinger/codeflinger/ARMAssemblerProxy.h index 4bdca9cf5ca..9134cce6f17 100644 --- a/libpixelflinger/codeflinger/ARMAssemblerProxy.h +++ b/libpixelflinger/codeflinger/ARMAssemblerProxy.h @@ -114,6 +114,8 @@ class ARMAssemblerProxy : public ARMAssemblerInterface virtual void SMLAW(int cc, int y, int Rd, int Rm, int Rs, int Rn); + virtual void UXTB16(int cc, int Rd, int Rm, int rotate); + private: ARMAssemblerInterface* mTarget; }; diff --git a/libpixelflinger/codeflinger/disassem.c b/libpixelflinger/codeflinger/disassem.c index 4676da0d82d..ee5e63a2b26 100644 --- a/libpixelflinger/codeflinger/disassem.c +++ b/libpixelflinger/codeflinger/disassem.c @@ -80,6 +80,7 @@ * f - 1st fp operand (register) (bits 12-14) * g - 2nd fp operand (register) (bits 16-18) * h - 3rd fp operand (register/immediate) (bits 0-4) + * j - xtb rotate literal (bits 10-11) * b - branch address * t - thumb branch address (bits 24, 0-23) * k - breakpoint comment (bits 0-3, 8-19) @@ -122,6 +123,7 @@ static const struct arm32_insn arm32_i[] = { { 0x0fe000f0, 0x00c00090, "smull", "Sdnms" }, { 0x0fe000f0, 0x00a00090, "umlal", "Sdnms" }, { 0x0fe000f0, 0x00e00090, "smlal", "Sdnms" }, + { 0x0fff03f0, 0x06cf0070, "uxtb16", "dmj" }, { 0x0d700000, 0x04200000, "strt", "daW" }, { 0x0d700000, 0x04300000, "ldrt", "daW" }, { 0x0d700000, 0x04600000, "strbt", "daW" }, @@ -406,6 +408,10 @@ disasm(const disasm_interface_t *di, u_int loc, int altfmt) else di->di_printf("f%d", insn & 7); break; + /* j - xtb rotate literal (bits 10-11) */ + case 'j': + di->di_printf("ror #%d", ((insn >> 10) & 3) << 3); + break; /* b - branch address */ case 'b': branch = ((insn << 2) & 0x03ffffff); diff --git a/libpixelflinger/codeflinger/texturing.cpp b/libpixelflinger/codeflinger/texturing.cpp index 90e658407bf..ba13fb3035a 100644 --- a/libpixelflinger/codeflinger/texturing.cpp +++ b/libpixelflinger/codeflinger/texturing.cpp @@ -25,6 +25,7 @@ #include "codeflinger/GGLAssembler.h" +#include namespace android { @@ -567,7 +568,7 @@ void GGLAssembler::build_textures( fragment_parts_t& parts, RSB(GE, 0, height, height, imm(0)); MUL(AL, 0, height, stride, height); } else { - // u has not been CLAMPed yet + // v has not been CLAMPed yet CMP(AL, height, reg_imm(v, ASR, FRAC_BITS)); MOV(LE, 0, v, reg_imm(height, LSL, FRAC_BITS)); MOV(LE, 0, height, imm(0)); @@ -868,6 +869,106 @@ void GGLAssembler::filter24( load(txPtr, texel, 0); } +#if __ARM_ARCH__ >= 6 +// ARMv6 version, using UXTB16, and scheduled for Cortex-A8 pipeline +void GGLAssembler::filter32( + const fragment_parts_t& parts, + pixel_t& texel, const texture_unit_t& tmu, + int U, int V, pointer_t& txPtr, + int FRAC_BITS) +{ + const int adjust = FRAC_BITS*2 - 8; + const int round = 0; + const int prescale = 16 - adjust; + + Scratch scratches(registerFile()); + + int pixel= scratches.obtain(); + int dh = scratches.obtain(); + int u = scratches.obtain(); + int k = scratches.obtain(); + + int temp = scratches.obtain(); + int dl = scratches.obtain(); + + int offsetrt = scratches.obtain(); + int offsetlb = scratches.obtain(); + + int pixellb = offsetlb; + + // RB -> U * V + CONTEXT_LOAD(offsetrt, generated_vars.rt); + CONTEXT_LOAD(offsetlb, generated_vars.lb); + if(!round) { + MOV(AL, 0, U, reg_imm(U, LSL, prescale)); + } + ADD(AL, 0, u, offsetrt, offsetlb); + + LDR(AL, pixel, txPtr.reg, reg_scale_pre(u)); + if (round) { + SMULBB(AL, u, U, V); + RSB(AL, 0, U, U, imm(1< (1-U) * V + if (round) { + SMULBB(AL, u, U, V); + } else { + SMULWB(AL, u, U, V); + } + UXTB16(AL, temp, pixellb, 0); + if (round) { + ADD(AL, 0, u, u, imm(1<<(adjust-1))); + MOV(AL, 0, u, reg_imm(u, LSR, adjust)); + } + MLA(AL, 0, dh, temp, u, dh); + UXTB16(AL, temp, pixellb, 8); + MLA(AL, 0, dl, temp, u, dl); + SUB(AL, 0, k, k, u); + + // LT -> (1-U)*(1-V) + RSB(AL, 0, V, V, imm(1< U*(1-V) + LDR(AL, pixel, txPtr.reg, reg_scale_pre(offsetrt)); + SUB(AL, 0, u, k, u); + UXTB16(AL, temp, pixel, 0); + MLA(AL, 0, dh, temp, u, dh); + UXTB16(AL, temp, pixel, 8); + MLA(AL, 0, dl, temp, u, dl); + + UXTB16(AL, dh, dh, 8); + UXTB16(AL, dl, dl, 8); + ORR(AL, 0, texel.reg, dh, reg_imm(dl, LSL, 8)); +} +#else void GGLAssembler::filter32( const fragment_parts_t& parts, pixel_t& texel, const texture_unit_t& tmu, @@ -955,6 +1056,7 @@ void GGLAssembler::filter32( AND(AL, 0, dl, dl, reg_imm(mask, LSL, 8)); ORR(AL, 0, texel.reg, dh, dl); } +#endif void GGLAssembler::build_texture_environment( component_t& fragment, From f9e8ab03bd93d98567e96822535090a877594aba Mon Sep 17 00:00:00 2001 From: Martyn Capewell Date: Mon, 7 Dec 2009 15:00:19 +0000 Subject: [PATCH 036/907] NEON shortcut for flat colour blending into 16-bit This is a shortcut for the needs descriptor 00000077:03515104_00000000_00000000. It requires blending a single 32-bit colour value into a 16-bit framebuffer. It's used when fading out the screen, eg. when a modal requester pops-up. The PF JIT produces code for this using 24 instructions/pixel. The NEON implementation requires 2.1 instructions/pixel. Performance hasn't been benchmarked, but the improvement is quite visible. This code has only been tested by inspection of the fading effect described above, when press+holding a finger on the home screen to pop up the Shortcuts/Widgets/Folders/Wallpaper requester. Along with the NEON version, a fallback v5TE implementation is also provided. This ARM version of col32cb16blend is not fully optimised, but is a reasonable implementation, and better than the version produced by the JIT. It is here as a fallback, if NEON is not available. --- libpixelflinger/Android.mk | 6 + libpixelflinger/col32cb16blend.S | 78 +++++++++++++ libpixelflinger/col32cb16blend_neon.S | 153 ++++++++++++++++++++++++++ libpixelflinger/scanline.cpp | 47 ++++++++ 4 files changed, 284 insertions(+) create mode 100644 libpixelflinger/col32cb16blend.S create mode 100644 libpixelflinger/col32cb16blend_neon.S diff --git a/libpixelflinger/Android.mk b/libpixelflinger/Android.mk index 0cc85d9dcc3..6491d243b29 100644 --- a/libpixelflinger/Android.mk +++ b/libpixelflinger/Android.mk @@ -40,7 +40,13 @@ PIXELFLINGER_SRC_FILES:= \ buffer.cpp ifeq ($(TARGET_ARCH),arm) +ifeq ($(TARGET_ARCH_VERSION),armv7-a) +PIXELFLINGER_SRC_FILES += col32cb16blend_neon.S +PIXELFLINGER_SRC_FILES += col32cb16blend.S +else PIXELFLINGER_SRC_FILES += t32cb16blend.S +PIXELFLINGER_SRC_FILES += col32cb16blend.S +endif endif ifeq ($(TARGET_ARCH),arm) diff --git a/libpixelflinger/col32cb16blend.S b/libpixelflinger/col32cb16blend.S new file mode 100644 index 00000000000..1450bde84b5 --- /dev/null +++ b/libpixelflinger/col32cb16blend.S @@ -0,0 +1,78 @@ +/* libs/pixelflinger/col32cb16blend.S +** +** (C) COPYRIGHT 2009 ARM Limited. +** +** 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. +** +*/ + + .text + .align + + .global scanline_col32cb16blend_arm + +// +// This function alpha blends a fixed color into a destination scanline, using +// the formula: +// +// d = s + (((a + (a >> 7)) * d) >> 8) +// +// where d is the destination pixel, +// s is the source color, +// a is the alpha channel of the source color. +// + +// r0 = destination buffer pointer +// r1 = color value +// r2 = count + + +scanline_col32cb16blend_arm: + push {r4-r10, lr} // stack ARM regs + + mov r5, r1, lsr #24 // shift down alpha + mov r9, #0xff // create mask + add r5, r5, r5, lsr #7 // add in top bit + rsb r5, r5, #256 // invert alpha + and r10, r1, #0xff // extract red + and r12, r9, r1, lsr #8 // extract green + and r4, r9, r1, lsr #16 // extract blue + mov r10, r10, lsl #5 // prescale red + mov r12, r12, lsl #6 // prescale green + mov r4, r4, lsl #5 // prescale blue + mov r9, r9, lsr #2 // create dest green mask + +1: + ldrh r8, [r0] // load dest pixel + subs r2, r2, #1 // decrement loop counter + mov r6, r8, lsr #11 // extract dest red + and r7, r9, r8, lsr #5 // extract dest green + and r8, r8, #0x1f // extract dest blue + + smlabb r6, r6, r5, r10 // dest red * alpha + src red + smlabb r7, r7, r5, r12 // dest green * alpha + src green + smlabb r8, r8, r5, r4 // dest blue * alpha + src blue + + mov r6, r6, lsr #8 // shift down red + mov r7, r7, lsr #8 // shift down green + mov r6, r6, lsl #11 // shift red into 565 + orr r6, r7, lsl #5 // shift green into 565 + orr r6, r8, lsr #8 // shift blue into 565 + + strh r6, [r0], #2 // store pixel to dest, update ptr + bne 1b // if count != 0, loop + + pop {r4-r10, pc} // return + + + diff --git a/libpixelflinger/col32cb16blend_neon.S b/libpixelflinger/col32cb16blend_neon.S new file mode 100644 index 00000000000..17b0d01a846 --- /dev/null +++ b/libpixelflinger/col32cb16blend_neon.S @@ -0,0 +1,153 @@ +/* libs/pixelflinger/col32cb16blend_neon.S +** +** (C) COPYRIGHT 2009 ARM Limited. +** +** 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. +** +*/ + + .text + .align + + .global scanline_col32cb16blend_neon + +// +// This function alpha blends a fixed color into a destination scanline, using +// the formula: +// +// d = s + (((a + (a >> 7)) * d) >> 8) +// +// where d is the destination pixel, +// s is the source color, +// a is the alpha channel of the source color. +// +// The NEON implementation processes 16 pixels per iteration. The remaining 0 - 15 +// pixels are processed in ARM code. +// + +// r0 = destination buffer pointer +// r1 = color pointer +// r2 = count + + +scanline_col32cb16blend_neon: + push {r4-r11, lr} // stack ARM regs + + vmov.u16 q15, #256 // create alpha constant + movs r3, r2, lsr #4 // calc. sixteens iterations + vmov.u16 q14, #0x1f // create blue mask + + beq 2f // if r3 == 0, branch to singles + + vld4.8 {d0[], d2[], d4[], d6[]}, [r1] // load color into four registers + // split and duplicate them, such that + // d0 = 8 equal red values + // d2 = 8 equal green values + // d4 = 8 equal blue values + // d6 = 8 equal alpha values + vshll.u8 q0, d0, #5 // shift up red and widen + vshll.u8 q1, d2, #6 // shift up green and widen + vshll.u8 q2, d4, #5 // shift up blue and widen + + vshr.u8 d7, d6, #7 // extract top bit of alpha + vaddl.u8 q3, d6, d7 // add top bit into alpha + vsub.u16 q3, q15, q3 // invert alpha + +1: + // This loop processes 16 pixels per iteration. In the comments, references to + // the first eight pixels are suffixed with "0" (red0, green0, blue0), + // the second eight are suffixed "1". + // q8 = dst red0 + // q9 = dst green0 + // q10 = dst blue0 + // q13 = dst red1 + // q12 = dst green1 + // q11 = dst blue1 + + vld1.16 {d20, d21, d22, d23}, [r0] // load 16 dest pixels + vshr.u16 q8, q10, #11 // shift dst red0 to low 5 bits + pld [r0, #63] // preload next dest pixels + vshl.u16 q9, q10, #5 // shift dst green0 to top 6 bits + vand q10, q10, q14 // extract dst blue0 + vshr.u16 q9, q9, #10 // shift dst green0 to low 6 bits + vmul.u16 q8, q8, q3 // multiply dst red0 by src alpha + vshl.u16 q12, q11, #5 // shift dst green1 to top 6 bits + vmul.u16 q9, q9, q3 // multiply dst green0 by src alpha + vshr.u16 q13, q11, #11 // shift dst red1 to low 5 bits + vmul.u16 q10, q10, q3 // multiply dst blue0 by src alpha + vshr.u16 q12, q12, #10 // shift dst green1 to low 6 bits + vand q11, q11, q14 // extract dst blue1 + vadd.u16 q8, q8, q0 // add src red to dst red0 + vmul.u16 q13, q13, q3 // multiply dst red1 by src alpha + vadd.u16 q9, q9, q1 // add src green to dst green0 + vmul.u16 q12, q12, q3 // multiply dst green1 by src alpha + vadd.u16 q10, q10, q2 // add src blue to dst blue0 + vmul.u16 q11, q11, q3 // multiply dst blue1 by src alpha + vshr.u16 q8, q8, #8 // shift down red0 + vadd.u16 q13, q13, q0 // add src red to dst red1 + vshr.u16 q9, q9, #8 // shift down green0 + vadd.u16 q12, q12, q1 // add src green to dst green1 + vshr.u16 q10, q10, #8 // shift down blue0 + vadd.u16 q11, q11, q2 // add src blue to dst blue1 + vsli.u16 q10, q9, #5 // shift & insert green0 into blue0 + vshr.u16 q13, q13, #8 // shift down red1 + vsli.u16 q10, q8, #11 // shift & insert red0 into blue0 + vshr.u16 q12, q12, #8 // shift down green1 + vshr.u16 q11, q11, #8 // shift down blue1 + subs r3, r3, #1 // decrement loop counter + vsli.u16 q11, q12, #5 // shift & insert green1 into blue1 + vsli.u16 q11, q13, #11 // shift & insert red1 into blue1 + + vst1.16 {d20, d21, d22, d23}, [r0]! // write 16 pixels back to dst + bne 1b // if count != 0, loop + +2: + ands r3, r2, #15 // calc. single iterations + beq 4f // if r3 == 0, exit + + ldr r4, [r1] // load source color + mov r5, r4, lsr #24 // shift down alpha + add r5, r5, r5, lsr #7 // add in top bit + rsb r5, r5, #256 // invert alpha + and r11, r4, #0xff // extract red + ubfx r12, r4, #8, #8 // extract green + ubfx r4, r4, #16, #8 // extract blue + mov r11, r11, lsl #5 // prescale red + mov r12, r12, lsl #6 // prescale green + mov r4, r4, lsl #5 // prescale blue + +3: + ldrh r8, [r0] // load dest pixel + subs r3, r3, #1 // decrement loop counter + mov r6, r8, lsr #11 // extract dest red + ubfx r7, r8, #5, #6 // extract dest green + and r8, r8, #0x1f // extract dest blue + + smlabb r6, r6, r5, r11 // dest red * alpha + src red + smlabb r7, r7, r5, r12 // dest green * alpha + src green + smlabb r8, r8, r5, r4 // dest blue * alpha + src blue + + mov r6, r6, lsr #8 // shift down red + mov r7, r7, lsr #8 // shift down green + mov r6, r6, lsl #11 // shift red into 565 + orr r6, r7, lsl #5 // shift green into 565 + orr r6, r8, lsr #8 // shift blue into 565 + + strh r6, [r0], #2 // store pixel to dest, update ptr + bne 3b // if count != 0, loop +4: + + pop {r4-r11, pc} // return + + + diff --git a/libpixelflinger/scanline.cpp b/libpixelflinger/scanline.cpp index f7003068069..a2f43eb0816 100644 --- a/libpixelflinger/scanline.cpp +++ b/libpixelflinger/scanline.cpp @@ -80,6 +80,7 @@ static void scanline_perspective(context_t* c); static void scanline_perspective_single(context_t* c); static void scanline_t32cb16blend(context_t* c); static void scanline_t32cb16(context_t* c); +static void scanline_col32cb16blend(context_t* c); static void scanline_memcpy(context_t* c); static void scanline_memset8(context_t* c); static void scanline_memset16(context_t* c); @@ -93,6 +94,8 @@ static void rect_memcpy(context_t* c, size_t yc); extern "C" void scanline_t32cb16blend_arm(uint16_t*, uint32_t*, size_t); extern "C" void scanline_t32cb16_arm(uint16_t *dst, uint32_t *src, size_t ct); +extern "C" void scanline_col32cb16blend_neon(uint16_t *dst, uint32_t *col, size_t ct); +extern "C" void scanline_col32cb16blend_arm(uint16_t *dst, uint32_t col, size_t ct); // ---------------------------------------------------------------------------- @@ -111,6 +114,9 @@ static shortcut_t shortcuts[] = { { { { 0x03010104, 0x00000077, { 0x00000A01, 0x00000000 } }, { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } }, "565 fb, 8888 tx", scanline_t32cb16, init_y_noop }, + { { { 0x03515104, 0x00000077, { 0x00000000, 0x00000000 } }, + { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0xFFFFFFFF } } }, + "565 fb, 8888 fixed color", scanline_col32cb16blend, init_y_packed }, { { { 0x00000000, 0x00000000, { 0x00000000, 0x00000000 } }, { 0x00000000, 0x00000007, { 0x00000000, 0x00000000 } } }, "(nop) alpha test", scanline_noop, init_y_noop }, @@ -943,6 +949,8 @@ void init_y_packed(context_t* c, int32_t y0) uint8_t f = c->state.buffers.color.format; c->packed = ggl_pack_color(c, f, c->shade.r0, c->shade.g0, c->shade.b0, c->shade.a0); + c->packed8888 = ggl_pack_color(c, GGL_PIXEL_FORMAT_RGBA_8888, + c->shade.r0, c->shade.g0, c->shade.b0, c->shade.a0); c->iterators.y = y0; c->step_y = step_y__nop; // choose the rectangle blitter @@ -1253,6 +1261,45 @@ void scanline_perspective_single(context_t* c) // ---------------------------------------------------------------------------- +void scanline_col32cb16blend(context_t* c) +{ + int32_t x = c->iterators.xl; + size_t ct = c->iterators.xr - x; + int32_t y = c->iterators.y; + surface_t* cb = &(c->state.buffers.color); + union { + uint16_t* dst; + uint32_t* dst32; + }; + dst = reinterpret_cast(cb->data) + (x+(cb->stride*y)); + +#if ((ANDROID_CODEGEN >= ANDROID_CODEGEN_ASM) && defined(__arm__)) +#if defined(__ARM_HAVE_NEON) && BYTE_ORDER == LITTLE_ENDIAN + scanline_col32cb16blend_neon(dst, &(c->packed8888), ct); +#else // defined(__ARM_HAVE_NEON) && BYTE_ORDER == LITTLE_ENDIAN + scanline_col32cb16blend_arm(dst, GGL_RGBA_TO_HOST(c->packed8888), ct); +#endif // defined(__ARM_HAVE_NEON) && BYTE_ORDER == LITTLE_ENDIAN +#else + uint32_t s = GGL_RGBA_TO_HOST(c->packed8888); + int sA = (s>>24); + int f = 0x100 - (sA + (sA>>7)); + while (ct--) { + uint16_t d = *dst; + int dR = (d>>11)&0x1f; + int dG = (d>>5)&0x3f; + int dB = (d)&0x1f; + int sR = (s >> ( 3))&0x1F; + int sG = (s >> ( 8+2))&0x3F; + int sB = (s >> (16+3))&0x1F; + sR += (f*dR)>>8; + sG += (f*dG)>>8; + sB += (f*dB)>>8; + *dst++ = uint16_t((sR<<11)|(sG<<5)|sB); + } +#endif + +} + void scanline_t32cb16(context_t* c) { int32_t x = c->iterators.xl; From 8cd7bd5efbb1809fe657718d6754c7762ca6653b Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Mon, 7 Dec 2009 16:31:49 -0500 Subject: [PATCH 037/907] first impl for NDK access to bitmaps --- libjnigraphics/Android.mk | 34 ++++++++++++++ libjnigraphics/bitmap.cpp | 94 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 libjnigraphics/Android.mk create mode 100644 libjnigraphics/bitmap.cpp diff --git a/libjnigraphics/Android.mk b/libjnigraphics/Android.mk new file mode 100644 index 00000000000..2af67c3b51e --- /dev/null +++ b/libjnigraphics/Android.mk @@ -0,0 +1,34 @@ +BASE_PATH := $(call my-dir) +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_PRELINK_MODULE := false + +# setup for skia optimizations +# +ifneq ($(ARCH_ARM_HAVE_VFP),true) + LOCAL_CFLAGS += -DSK_SOFTWARE_FLOAT +endif + +ifeq ($(ARCH_ARM_HAVE_NEON),true) + LOCAL_CFLAGS += -D__ARM_HAVE_NEON +endif + +# our source files +# +LOCAL_SRC_FILES:= \ + bitmap.cpp + +LOCAL_SHARED_LIBRARIES := \ + libandroid_runtime + +LOCAL_C_INCLUDES += \ + external/skia/include/core \ + frameworks/base/core/jni/android/graphics \ + dalvik/libnativehelper/include/nativehelper + +LOCAL_MODULE:= libjnigraphics + +include $(BUILD_SHARED_LIBRARY) + diff --git a/libjnigraphics/bitmap.cpp b/libjnigraphics/bitmap.cpp new file mode 100644 index 00000000000..fd73430bf7a --- /dev/null +++ b/libjnigraphics/bitmap.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2009 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 +#include + +int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap, + AndroidBitmapInfo* info) { + if (NULL == env || NULL == jbitmap) { + return ANDROID_BITMAP_RESULT_BAD_PARAMETER; + } + + SkBitmap* bm = GraphicsJNI::getNativeBitmap(env, jbitmap); + if (NULL == bm) { + return ANDROID_BITMAP_RESULT_JNI_EXCEPTION; + } + + if (info) { + info->width = bm->width(); + info->height = bm->height(); + info->stride = bm->rowBytes(); + info->flags = 0; + + switch (bm->config()) { + case SkBitmap::kARGB_8888_Config: + info->format = ANDROID_BITMAP_FORMAT_RGBA_8888; + break; + case SkBitmap::kRGB_565_Config: + info->format = ANDROID_BITMAP_FORMAT_RGB_565; + break; + case SkBitmap::kARGB_4444_Config: + info->format = ANDROID_BITMAP_FORMAT_RGBA_4444; + break; + case SkBitmap::kA8_Config: + info->format = ANDROID_BITMAP_FORMAT_A_8; + break; + default: + info->format = ANDROID_BITMAP_FORMAT_NONE; + break; + } + } + return ANDROID_BITMAP_RESUT_SUCCESS; +} + +int AndroidBitmap_lockPixels(JNIEnv* env, jobject jbitmap, void** addrPtr) { + if (NULL == env || NULL == jbitmap) { + return ANDROID_BITMAP_RESULT_BAD_PARAMETER; + } + + SkBitmap* bm = GraphicsJNI::getNativeBitmap(env, jbitmap); + if (NULL == bm) { + return ANDROID_BITMAP_RESULT_JNI_EXCEPTION; + } + + bm->lockPixels(); + void* addr = bm->getPixels(); + if (NULL == addr) { + bm->unlockPixels(); + return ANDROID_BITMAP_RESULT_ALLOCATION_FAILED; + } + + if (addrPtr) { + *addrPtr = addr; + } + return ANDROID_BITMAP_RESUT_SUCCESS; +} + +int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap) { + if (NULL == env || NULL == jbitmap) { + return ANDROID_BITMAP_RESULT_BAD_PARAMETER; + } + + SkBitmap* bm = GraphicsJNI::getNativeBitmap(env, jbitmap); + if (NULL == bm) { + return ANDROID_BITMAP_RESULT_JNI_EXCEPTION; + } + + bm->unlockPixels(); + return ANDROID_BITMAP_RESUT_SUCCESS; +} + From 1b217b0c6d36b7f6f550f45d2b694b0f154a22b7 Mon Sep 17 00:00:00 2001 From: San Mehat Date: Tue, 8 Dec 2009 08:55:00 -0800 Subject: [PATCH 038/907] system: vold: Conditionalize build (default on) Signed-off-by: San Mehat --- vold/Android.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vold/Android.mk b/vold/Android.mk index 3dd9f871b71..60d60266ede 100644 --- a/vold/Android.mk +++ b/vold/Android.mk @@ -1,3 +1,6 @@ +BUILD_VOLD := true +ifeq ($(BUILD_VOLD),true) + LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) @@ -30,3 +33,5 @@ LOCAL_CFLAGS := LOCAL_SHARED_LIBRARIES := libcutils include $(BUILD_EXECUTABLE) + +endif # ifeq ($(BUILD_VOLD),true) From 021529fe63d931815fe7aad09578caf130c28670 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Tue, 8 Dec 2009 13:20:58 -0500 Subject: [PATCH 039/907] link explicitly against libskia --- libjnigraphics/Android.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libjnigraphics/Android.mk b/libjnigraphics/Android.mk index 2af67c3b51e..9458f282c59 100644 --- a/libjnigraphics/Android.mk +++ b/libjnigraphics/Android.mk @@ -21,7 +21,8 @@ LOCAL_SRC_FILES:= \ bitmap.cpp LOCAL_SHARED_LIBRARIES := \ - libandroid_runtime + libandroid_runtime \ + libskia LOCAL_C_INCLUDES += \ external/skia/include/core \ From 8cd186d9e0aac1b18e4c8b32e3d79beedb728ab3 Mon Sep 17 00:00:00 2001 From: Barry Hayes Date: Wed, 9 Dec 2009 10:18:41 -0800 Subject: [PATCH 040/907] Fix bogus pointer math. --- libcutils/mspace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libcutils/mspace.c b/libcutils/mspace.c index 8fd5de77de8..2110b434258 100644 --- a/libcutils/mspace.c +++ b/libcutils/mspace.c @@ -179,7 +179,8 @@ mspace create_contiguous_mspace_with_name(size_t starting_capacity, /* Create the mspace, pointing to the memory we just reserved. */ - m = create_mspace_with_base(base + sizeof(*cs), starting_capacity, locked); + m = create_mspace_with_base((char *)base + sizeof(*cs), starting_capacity, + locked); if (m == (mspace)0) goto error; From 311add489e4a1712d201c3b83fa364d5569e6788 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Mon, 14 Dec 2009 14:42:17 -0800 Subject: [PATCH 041/907] Add adb reboot-bootloader to match fastboot reboot-bootloader. Also fix the formatting of one of the options in the help message. --- adb/commandline.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/adb/commandline.c b/adb/commandline.c index 3b3e6df4e42..cb98d05fa5e 100644 --- a/adb/commandline.c +++ b/adb/commandline.c @@ -151,8 +151,9 @@ void help() " adb status-window - continuously print device status for a specified device\n" " adb remount - remounts the /system partition on the device read-write\n" " adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program\n" + " adb reboot-bootloader - reboots the device into the bootloader\n" " adb root - restarts the adbd daemon with root permissions\n" - " adb usb - restarts the adbd daemon listening on USB" + " adb usb - restarts the adbd daemon listening on USB\n" " adb tcpip - restarts the adbd daemon listening on TCP on the specified port" "\n" "networking:\n" @@ -929,10 +930,13 @@ int adb_commandline(int argc, char **argv) } if(!strcmp(argv[0], "remount") || !strcmp(argv[0], "reboot") + || !strcmp(argv[0], "reboot-bootloader") || !strcmp(argv[0], "tcpip") || !strcmp(argv[0], "usb") || !strcmp(argv[0], "root")) { char command[100]; - if (argc > 1) + if (!strcmp(argv[0], "reboot-bootloader")) + snprintf(command, sizeof(command), "reboot:bootloader"); + else if (argc > 1) snprintf(command, sizeof(command), "%s:%s", argv[0], argv[1]); else snprintf(command, sizeof(command), "%s:", argv[0]); From 9363b7d5da7e17842432251384f8dc46902ac323 Mon Sep 17 00:00:00 2001 From: Dmitry Shmidt Date: Mon, 14 Dec 2009 15:41:54 -0800 Subject: [PATCH 042/907] dhcp: Add hostname support Signed-off-by: Dmitry Shmidt --- libnetutils/dhcp_utils.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libnetutils/dhcp_utils.c b/libnetutils/dhcp_utils.c index bad2e2ffda2..0f8a6c43472 100644 --- a/libnetutils/dhcp_utils.c +++ b/libnetutils/dhcp_utils.c @@ -24,8 +24,9 @@ #include -static const char DAEMON_NAME[] = "dhcpcd"; -static const char DAEMON_PROP_NAME[] = "init.svc.dhcpcd"; +static const char DAEMON_NAME[] = "dhcpcd"; +static const char DAEMON_PROP_NAME[] = "init.svc.dhcpcd"; +static const char HOSTNAME_PROP_NAME[] = "net.hostname"; static const char DHCP_PROP_NAME_PREFIX[] = "dhcp"; static const int NAP_TIME = 1; /* wait for 1 second at a time */ /* when polling for property values */ @@ -129,6 +130,7 @@ int dhcp_do_request(const char *interface, { char result_prop_name[PROPERTY_KEY_MAX]; char prop_value[PROPERTY_VALUE_MAX] = {'\0'}; + char daemon_cmd[PROPERTY_VALUE_MAX * 2]; const char *ctrl_prop = "ctl.start"; const char *desired_status = "running"; @@ -139,7 +141,13 @@ int dhcp_do_request(const char *interface, property_set(result_prop_name, ""); /* Start the daemon and wait until it's ready */ - property_set(ctrl_prop, DAEMON_NAME); + if (property_get(HOSTNAME_PROP_NAME, prop_value, NULL) && (prop_value[0] != '\0')) + snprintf(daemon_cmd, sizeof(daemon_cmd), "%s:-h %s %s", DAEMON_NAME, + prop_value, interface); + else + snprintf(daemon_cmd, sizeof(daemon_cmd), "%s:%s", DAEMON_NAME, interface); + memset(prop_value, '\0', PROPERTY_VALUE_MAX); + property_set(ctrl_prop, daemon_cmd); if (wait_for_property(DAEMON_PROP_NAME, desired_status, 10) < 0) { snprintf(errmsg, sizeof(errmsg), "%s", "Timed out waiting for dhcpcd to start"); return -1; From bdcff7d66ef8f6602e017d03cf4ffa57bac39b92 Mon Sep 17 00:00:00 2001 From: Ben Cheng Date: Thu, 17 Dec 2009 12:50:58 -0800 Subject: [PATCH 043/907] Dump VFP registers and status word when native app crashes. Bug: 2226399 Caveat: d0/d1 appear to be clobbered by ptrace. It will be tracked by a new bug. --- debuggerd/Android.mk | 14 ++++++++++++-- debuggerd/debuggerd.c | 18 ++++++++++++++++++ debuggerd/vfp-crasher.c | 7 +++++++ debuggerd/vfp.S | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 debuggerd/vfp-crasher.c create mode 100644 debuggerd/vfp.S diff --git a/debuggerd/Android.mk b/debuggerd/Android.mk index b22e1a81d75..b86f2a57eca 100644 --- a/debuggerd/Android.mk +++ b/debuggerd/Android.mk @@ -14,13 +14,23 @@ LOCAL_STATIC_LIBRARIES := libcutils libc include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) -LOCAL_SRC_FILES := crasher.c +LOCAL_SRC_FILES := crasher.c LOCAL_SRC_FILES += crashglue.S -LOCAL_MODULE := crasher +LOCAL_MODULE := crasher LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) LOCAL_MODULE_TAGS := eng #LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_SHARED_LIBRARIES := libcutils libc include $(BUILD_EXECUTABLE) +ifeq ($(TARGET_ARCH_VARIANT),armv7-a) +include $(CLEAR_VARS) +LOCAL_SRC_FILES := vfp-crasher.c vfp.S +LOCAL_MODULE := vfp-crasher +LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) +LOCAL_MODULE_TAGS := eng +LOCAL_SHARED_LIBRARIES := libcutils libc +include $(BUILD_EXECUTABLE) +endif # TARGET_ARCH_VARIANT == armv7-a + endif # TARGET_ARCH == arm diff --git a/debuggerd/debuggerd.c b/debuggerd/debuggerd.c index 145135fcb58..3757cd5f925 100644 --- a/debuggerd/debuggerd.c +++ b/debuggerd/debuggerd.c @@ -285,6 +285,24 @@ void dump_registers(int tfd, int pid, bool at_fault) _LOG(tfd, only_in_tombstone, " ip %08x sp %08x lr %08x pc %08x cpsr %08x\n", r.ARM_ip, r.ARM_sp, r.ARM_lr, r.ARM_pc, r.ARM_cpsr); + +#if __VFP_FP__ + struct user_vfp vfp_regs; + int i; + + if(ptrace(PTRACE_GETVFPREGS, pid, 0, &vfp_regs)) { + _LOG(tfd, only_in_tombstone, + "cannot get registers: %s\n", strerror(errno)); + return; + } + + for (i = 0; i < 32; i += 2) { + _LOG(tfd, only_in_tombstone, + " d%-2d %016llx d%-2d %016llx\n", + i, vfp_regs.fpregs[i], i+1, vfp_regs.fpregs[i+1]); + } + _LOG(tfd, only_in_tombstone, " scr %08lx\n\n", vfp_regs.fpscr); +#endif } const char *get_signame(int sig) diff --git a/debuggerd/vfp-crasher.c b/debuggerd/vfp-crasher.c new file mode 100644 index 00000000000..7a19cdd8e06 --- /dev/null +++ b/debuggerd/vfp-crasher.c @@ -0,0 +1,7 @@ +int main() +{ + extern void crash(void); + + crash(); + return 0; +} diff --git a/debuggerd/vfp.S b/debuggerd/vfp.S new file mode 100644 index 00000000000..2192415264d --- /dev/null +++ b/debuggerd/vfp.S @@ -0,0 +1,41 @@ + .text + .align 2 + .global crash + .type crash, %function +crash: + fconstd d0, #0 + fconstd d1, #1 + fconstd d2, #2 + fconstd d3, #3 + fconstd d4, #4 + fconstd d5, #5 + fconstd d6, #6 + fconstd d7, #7 + fconstd d8, #8 + fconstd d9, #9 + fconstd d10, #10 + fconstd d11, #11 + fconstd d12, #12 + fconstd d13, #13 + fconstd d14, #14 + fconstd d15, #15 + fconstd d16, #16 + fconstd d17, #17 + fconstd d18, #18 + fconstd d19, #19 + fconstd d20, #20 + fconstd d21, #21 + fconstd d22, #22 + fconstd d23, #23 + fconstd d24, #24 + fconstd d25, #25 + fconstd d26, #26 + fconstd d27, #27 + fconstd d28, #28 + fconstd d29, #29 + fconstd d30, #30 + fconstd d31, #31 + mov r0, #0 + str r0, [r0] + bx lr + From 6170404867631317ab57c67bf074494e6e775556 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Tue, 22 Dec 2009 09:02:21 -0500 Subject: [PATCH 044/907] adb: Add USB vendor ID for Foxconn Change-Id: I88e4051b6e5cd820cab7e3ec417a545f50925a33 Signed-off-by: Mike Lockwood --- adb/usb_vendors.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/adb/usb_vendors.c b/adb/usb_vendors.c index 064abc008a7..63bf97a6196 100644 --- a/adb/usb_vendors.c +++ b/adb/usb_vendors.c @@ -51,6 +51,9 @@ #define VENDOR_ID_ACER 0x0502 // Sony Ericsson's USB Vendor ID #define VENDOR_ID_SONY_ERICSSON 0x0FCE +// Foxconn's USB Vendor ID +#define VENDOR_ID_FOXCONN 0x0489 + /** built-in vendor list */ int builtInVendorIds[] = { @@ -62,6 +65,7 @@ int builtInVendorIds[] = { VENDOR_ID_HUAWEI, VENDOR_ID_ACER, VENDOR_ID_SONY_ERICSSON, + VENDOR_ID_FOXCONN, }; #define BUILT_IN_VENDOR_COUNT (sizeof(builtInVendorIds)/sizeof(builtInVendorIds[0])) From 5184fc5c797849ee861dd4068ad57cbbe829c9d6 Mon Sep 17 00:00:00 2001 From: San Mehat Date: Thu, 17 Dec 2009 07:13:16 -0800 Subject: [PATCH 045/907] rootdir: Switch to vold.fstab Signed-off-by: San Mehat --- rootdir/Android.mk | 2 +- rootdir/etc/vold.conf | 10 ---------- rootdir/etc/vold.fstab | 24 ++++++++++++++++++++++++ 3 files changed, 25 insertions(+), 11 deletions(-) delete mode 100644 rootdir/etc/vold.conf create mode 100644 rootdir/etc/vold.fstab diff --git a/rootdir/Android.mk b/rootdir/Android.mk index 3bb226211e0..7ac991cb624 100644 --- a/rootdir/Android.mk +++ b/rootdir/Android.mk @@ -8,7 +8,7 @@ copy_from := \ etc/hosts ifeq ($(TARGET_PRODUCT),generic) -copy_from += etc/vold.conf +copy_from += etc/vold.fstab endif # the /system/etc/init.goldfish.sh is needed to enable emulator support diff --git a/rootdir/etc/vold.conf b/rootdir/etc/vold.conf deleted file mode 100644 index 4e045090ebf..00000000000 --- a/rootdir/etc/vold.conf +++ /dev/null @@ -1,10 +0,0 @@ -## vold configuration file for the 'generic' target - -volume_sdcard { - ## This is the direct uevent device path to the SD slot on the device - media_path /devices/platform/goldfish_mmc.0/mmc_host/mmc0 - - media_type mmc - mount_point /sdcard - ums_path /devices/platform/usb_mass_storage/lun0 -} diff --git a/rootdir/etc/vold.fstab b/rootdir/etc/vold.fstab new file mode 100644 index 00000000000..16065e9f76f --- /dev/null +++ b/rootdir/etc/vold.fstab @@ -0,0 +1,24 @@ +## Vold 2.0 Generic fstab +## - San Mehat (san@android.com) +## + +####################### +## Regular device mount +## +## Format: dev_mount