diff --git a/fastboot/Android.mk b/fastboot/Android.mk
new file mode 100644
index 0000000..7a9d35f
--- /dev/null
+++ b/fastboot/Android.mk
@@ -0,0 +1,57 @@
+# Copyright (C) 2007 Google Inc.
+#
+# 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.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/../mkbootimg
+LOCAL_SRC_FILES := protocol.c engine.c bootimg.c fastboot.c 
+LOCAL_MODULE := fastboot
+
+ifeq ($(HOST_OS),linux)
+  LOCAL_SRC_FILES += usb_linux.c util_linux.c
+endif
+
+ifeq ($(HOST_OS),darwin)
+  LOCAL_SRC_FILES += usb_osx.c util_osx.c
+  LOCAL_LDLIBS += -lpthread -framework CoreFoundation -framework IOKit \
+	-framework Carbon
+endif
+
+ifeq ($(HOST_OS),windows)
+  LOCAL_SRC_FILES += usb_windows.c util_windows.c
+  EXTRA_STATIC_LIBS := AdbWinApi
+  LOCAL_C_INCLUDES += /usr/include/w32api/ddk development/host/windows/usb/api
+  ifeq ($(strip $(USE_CYGWIN)),)
+    LOCAL_LDLIBS += -lws2_32
+    USE_SYSDEPS_WIN32 := 1
+  endif
+endif
+
+LOCAL_STATIC_LIBRARIES := $(EXTRA_STATIC_LIBS) libzipfile libunz
+
+include $(BUILD_HOST_EXECUTABLE)
+$(call dist-for-goals,droid,$(LOCAL_BUILT_MODULE))
+
+ifeq ($(HOST_OS),linux)
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := usbtest.c usb_linux.c
+LOCAL_MODULE := usbtest
+include $(BUILD_HOST_EXECUTABLE)
+endif
+
+ifeq ($(HOST_OS),windows)
+$(LOCAL_INSTALLED_MODULE): $(HOST_OUT_EXECUTABLES)/AdbWinApi.dll
+endif
diff --git a/fastboot/bootimg.c b/fastboot/bootimg.c
new file mode 100644
index 0000000..1d77b3c
--- /dev/null
+++ b/fastboot/bootimg.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the 
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <bootimg.h>
+
+void bootimg_set_cmdline(boot_img_hdr *h, const char *cmdline)
+{
+    strcpy((char*) h->cmdline, cmdline);
+}
+
+boot_img_hdr *mkbootimg(void *kernel, unsigned kernel_size,
+                        void *ramdisk, unsigned ramdisk_size,
+                        void *second, unsigned second_size,
+                        unsigned page_size,
+                        unsigned *bootimg_size)
+{
+    unsigned kernel_actual;
+    unsigned ramdisk_actual;
+    unsigned second_actual;
+    unsigned page_mask;
+    boot_img_hdr *hdr;
+    
+    page_mask = page_size - 1;
+    
+    kernel_actual = (kernel_size + page_mask) & (~page_mask);
+    ramdisk_actual = (ramdisk_size + page_mask) & (~page_mask);
+    second_actual = (second_size + page_mask) & (~page_mask);
+    
+    *bootimg_size = page_size + kernel_actual + ramdisk_actual + second_actual;
+    
+    hdr = calloc(*bootimg_size, 1);
+    
+    if(hdr == 0) {
+        return hdr;
+    }
+
+    memcpy(hdr->magic, BOOT_MAGIC, BOOT_MAGIC_SIZE);
+    
+    hdr->kernel_size = kernel_size;
+    hdr->kernel_addr = 0x10008000;
+    hdr->ramdisk_size = ramdisk_size;
+    hdr->ramdisk_addr = 0x11000000;
+    hdr->second_size = second_size;
+    hdr->second_addr = 0x10F00000;
+    
+    hdr->tags_addr = 0x10000100;
+    hdr->page_size = page_size;
+
+    memcpy(hdr->magic + page_size, 
+           kernel, kernel_size);
+    memcpy(hdr->magic + page_size + kernel_actual, 
+           ramdisk, ramdisk_size);
+    memcpy(hdr->magic + page_size + kernel_actual + ramdisk_actual,
+           second, second_size);
+    return hdr;
+}
diff --git a/fastboot/engine.c b/fastboot/engine.c
new file mode 100644
index 0000000..4c7e197
--- /dev/null
+++ b/fastboot/engine.c
@@ -0,0 +1,289 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the 
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include "fastboot.h"
+
+char *mkmsg(const char *fmt, ...)
+{
+    char buf[256];
+    char *s;
+    va_list ap;
+
+    va_start(ap, fmt);
+    vsprintf(buf, fmt, ap);
+    va_end(ap);
+    
+    s = strdup(buf);
+    if (s == 0) die("out of memory");
+    return s;
+}
+
+#define OP_DOWNLOAD   1
+#define OP_COMMAND    2
+#define OP_QUERY      3
+#define OP_NOTICE     4
+
+typedef struct Action Action;
+
+struct Action 
+{
+    unsigned op;
+    Action *next;
+
+    char cmd[64];    
+    void *data;
+    unsigned size;
+
+    const char *msg;
+    int (*func)(Action *a, int status, char *resp);
+};
+
+static Action *action_list = 0;
+static Action *action_last = 0;
+
+static int cb_default(Action *a, int status, char *resp)
+{
+    if (status) {
+        fprintf(stderr,"FAILED (%s)\n", resp);
+    } else {
+        fprintf(stderr,"OKAY\n");
+    }
+    return status;
+}
+
+static Action *queue_action(unsigned op, const char *fmt, ...)
+{
+    Action *a;
+    va_list ap;
+
+    a = calloc(1, sizeof(Action));
+    if (a == 0) die("out of memory");
+
+    va_start(ap, fmt);
+    vsprintf(a->cmd, fmt, ap);
+    va_end(ap);
+
+    if (action_last) {
+        action_last->next = a;
+    } else {
+        action_list = a;
+    }
+    action_last = a;
+    a->op = op;
+    a->func = cb_default;
+    return a;
+}
+
+void fb_queue_erase(const char *ptn)
+{
+    Action *a;
+    a = queue_action(OP_COMMAND, "erase:%s", ptn);
+    a->msg = mkmsg("erasing '%s'", ptn);
+}
+
+void fb_queue_flash(const char *ptn, void *data, unsigned sz)
+{
+    Action *a;
+
+    a = queue_action(OP_DOWNLOAD, "");
+    a->data = data;
+    a->size = sz;
+    a->msg = mkmsg("sending '%s' (%d KB)", ptn, sz / 1024);
+
+    a = queue_action(OP_COMMAND, "flash:%s", ptn);
+    a->msg = mkmsg("writing '%s'", ptn);
+}
+
+static int match(char *str, const char **value, unsigned count)
+{
+    const char *val;
+    unsigned n;
+    int len;
+
+    for (n = 0; n < count; n++) {
+        const char *val = value[n];
+        int len = strlen(val);
+        int match;
+
+        if ((len > 1) && (val[len-1] == '*')) {
+            len--;
+            match = !strncmp(val, str, len);
+        } else {
+            match = !strcmp(val, str);
+        }
+
+        if (match) return 1;
+    }
+
+    return 0;
+}
+
+
+
+static int cb_check(Action *a, int status, char *resp, int invert)
+{
+    const char **value = a->data;
+    unsigned count = a->size;
+    unsigned n;
+    int yes;
+
+    if (status) {
+        fprintf(stderr,"FAILED (%s)\n", resp);
+        return status;
+    }
+
+    yes = match(resp, value, count);
+    if (invert) yes = !yes;
+
+    if (yes) {
+        fprintf(stderr,"OKAY\n");
+        return 0;
+    }
+
+    fprintf(stderr,"FAILED\n\n");
+    fprintf(stderr,"Device %s is '%s'.\n", a->cmd + 7, resp);
+    fprintf(stderr,"Update %s '%s'",
+            invert ? "rejects" : "requires", value[0]);
+    for (n = 1; n < count; n++) {
+        fprintf(stderr," or '%s'", value[n]);
+    }
+    fprintf(stderr,".\n\n");
+    return -1;
+}
+
+static int cb_require(Action *a, int status, char *resp)
+{
+    return cb_check(a, status, resp, 0);
+}
+
+static int cb_reject(Action *a, int status, char *resp)
+{
+    return cb_check(a, status, resp, 1);
+}
+
+void fb_queue_require(const char *var, int invert, unsigned nvalues, const char **value)
+{
+    Action *a;
+    a = queue_action(OP_QUERY, "getvar:%s", var);
+    a->data = value;
+    a->size = nvalues;
+    a->msg = mkmsg("checking %s", var);
+    a->func = invert ? cb_reject : cb_require;
+    if (a->data == 0) die("out of memory");
+}
+
+static int cb_display(Action *a, int status, char *resp)
+{
+    if (status) {
+        fprintf(stderr, "%s FAILED (%s)\n", a->cmd, resp);
+        return status;
+    }
+    fprintf(stderr, "%s: %s\n", (char*) a->data, resp);
+    return 0;
+}
+
+void fb_queue_display(const char *var, const char *prettyname)
+{
+    Action *a;
+    a = queue_action(OP_QUERY, "getvar:%s", var);
+    a->data = strdup(prettyname);
+    if (a->data == 0) die("out of memory");
+    a->func = cb_display;
+}
+
+static int cb_do_nothing(Action *a, int status, char *resp)
+{
+    fprintf(stderr,"\n");
+    return 0;
+}
+
+void fb_queue_reboot(void)
+{
+    Action *a = queue_action(OP_COMMAND, "reboot");
+    a->func = cb_do_nothing;
+    a->msg = "rebooting";
+}
+
+void fb_queue_command(const char *cmd, const char *msg)
+{
+    Action *a = queue_action(OP_COMMAND, cmd);
+    a->msg = msg;
+}
+
+void fb_queue_download(const char *name, void *data, unsigned size)
+{
+    Action *a = queue_action(OP_DOWNLOAD, "");
+    a->data = data;
+    a->size = size;
+    a->msg = mkmsg("downloading '%s'", name);
+}
+
+void fb_queue_notice(const char *notice)
+{
+    Action *a = queue_action(OP_NOTICE, "");
+    a->data = (void*) notice;
+}
+
+void fb_execute_queue(usb_handle *usb)
+{
+    Action *a;
+    char resp[FB_RESPONSE_SZ+1];
+    int status;
+
+    a = action_list;
+    resp[FB_RESPONSE_SZ] = 0;
+
+    for (a = action_list; a; a = a->next) {
+        if (a->msg) {
+            fprintf(stderr,"%s... ",a->msg);
+        }
+        if (a->op == OP_DOWNLOAD) {
+            status = fb_download_data(usb, a->data, a->size);
+            status = a->func(a, status, status ? fb_get_error() : "");
+            if (status) break;
+        } else if (a->op == OP_COMMAND) {
+            status = fb_command(usb, a->cmd);
+            status = a->func(a, status, status ? fb_get_error() : "");
+            if (status) break;
+        } else if (a->op == OP_QUERY) {
+            status = fb_command_response(usb, a->cmd, resp);
+            status = a->func(a, status, status ? fb_get_error() : resp);
+            if (status) break;
+        } else if (a->op == OP_NOTICE) {
+            fprintf(stderr,"%s\n",(char*)a->data);
+        } else {
+            die("bogus action");
+        }
+    }
+}
+
diff --git a/fastboot/engineering_key.p12 b/fastboot/engineering_key.p12
new file mode 100644
index 0000000..d8183b0
--- /dev/null
+++ b/fastboot/engineering_key.p12
Binary files differ
diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c
new file mode 100644
index 0000000..e220dbe
--- /dev/null
+++ b/fastboot/fastboot.c
@@ -0,0 +1,673 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the 
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <limits.h>
+#include <ctype.h>
+
+#include <sys/time.h>
+#include <bootimg.h>
+#include <zipfile/zipfile.h>
+
+#include "fastboot.h"
+
+static usb_handle *usb = 0;
+static const char *serial = 0;
+static const char *product = 0;
+static const char *cmdline = 0;
+static int wipe_data = 0;
+static unsigned short vendor_id = 0;
+
+void die(const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+    fprintf(stderr,"error: ");
+    vfprintf(stderr, fmt, ap);
+    fprintf(stderr,"\n");
+    va_end(ap);
+    exit(1);
+}    
+
+void get_my_path(char *path);
+
+char *find_item(const char *item, const char *product)
+{
+    char *dir;
+    char *fn;
+    char path[PATH_MAX + 128];
+
+    if(!strcmp(item,"boot")) {
+        fn = "boot.img";
+    } else if(!strcmp(item,"recovery")) {
+        fn = "recovery.img";
+    } else if(!strcmp(item,"system")) {
+        fn = "system.img";
+    } else if(!strcmp(item,"userdata")) {
+        fn = "userdata.img";
+    } else if(!strcmp(item,"info")) {
+        fn = "android-info.txt";
+    } else {
+        fprintf(stderr,"unknown partition '%s'\n", item);
+        return 0;
+    }
+
+    if(product) {
+        get_my_path(path);
+        sprintf(path + strlen(path),
+                "../../../target/product/%s/%s", product, fn);
+        return strdup(path);
+    }
+        
+    dir = getenv("ANDROID_PRODUCT_OUT");
+    if((dir == 0) || (dir[0] == 0)) {
+        die("neither -p product specified nor ANDROID_PRODUCT_OUT set");
+        return 0;
+    }
+    
+    sprintf(path, "%s/%s", dir, fn);
+    return strdup(path);
+}
+
+#ifdef _WIN32
+void *load_file(const char *fn, unsigned *_sz);
+#else
+void *load_file(const char *fn, unsigned *_sz)
+{
+    char *data;
+    int sz;
+    int fd;
+
+    data = 0;
+    fd = open(fn, O_RDONLY);
+    if(fd < 0) return 0;
+
+    sz = lseek(fd, 0, SEEK_END);
+    if(sz < 0) goto oops;
+
+    if(lseek(fd, 0, SEEK_SET) != 0) goto oops;
+
+    data = (char*) malloc(sz);
+    if(data == 0) goto oops;
+
+    if(read(fd, data, sz) != sz) goto oops;
+    close(fd);
+
+    if(_sz) *_sz = sz;
+    return data;
+
+oops:
+    close(fd);
+    if(data != 0) free(data);
+    return 0;
+}
+#endif
+
+int match_fastboot(usb_ifc_info *info)
+{
+    if(!(vendor_id && (info->dev_vendor == vendor_id)) &&
+       (info->dev_vendor != 0x18d1) &&
+       (info->dev_vendor != 0x0bb4)) return -1;
+    if(info->ifc_class != 0xff) return -1;
+    if(info->ifc_subclass != 0x42) return -1;
+    if(info->ifc_protocol != 0x03) return -1;
+    // require matching serial number if a serial number is specified
+    // at the command line with the -s option.
+    if (serial && strcmp(serial, info->serial_number) != 0) return -1;
+    return 0;
+}
+
+int list_devices_callback(usb_ifc_info *info)
+{
+    if (match_fastboot(info) == 0) {
+        char* serial = info->serial_number;
+        if (!serial[0]) {
+            serial = "????????????";
+        }
+        // output compatible with "adb devices"
+        printf("%s\tfastboot\n", serial);
+    }
+
+    return -1;
+}
+
+usb_handle *open_device(void)
+{
+    static usb_handle *usb = 0;
+    int announce = 1;
+
+    if(usb) return usb;
+    
+    for(;;) {
+        usb = usb_open(match_fastboot);
+        if(usb) return usb;
+        if(announce) {
+            announce = 0;    
+            fprintf(stderr,"< waiting for device >\n");
+        }
+        sleep(1);
+    }
+}
+
+void list_devices(void) {
+    // We don't actually open a USB device here,
+    // just getting our callback called so we can
+    // list all the connected devices.
+    usb_open(list_devices_callback);
+}
+
+void usage(void)
+{
+    fprintf(stderr,
+/*           1234567890123456789012345678901234567890123456789012345678901234567890123456 */
+            "usage: fastboot [ <option> ] <command>\n"
+            "\n"
+            "commands:\n"
+            "  update <filename>                        reflash device from update.zip\n"
+            "  flashall                                 flash boot + recovery + system\n"
+            "  flash <partition> [ <filename> ]         write a file to a flash partition\n"
+            "  erase <partition>                        erase a flash partition\n"
+            "  getvar <variable>                        display a bootloader variable\n"
+            "  boot <kernel> [ <ramdisk> ]              download and boot kernel\n"
+            "  flash:raw boot <kernel> [ <ramdisk> ]    create bootimage and flash it\n"
+            "  devices                                  list all connected devices\n"
+            "  reboot                                   reboot device normally\n"
+            "  reboot-bootloader                        reboot device into bootloader\n"
+            "\n"
+            "options:\n"
+            "  -w                                       erase userdata and cache\n"
+            "  -s <serial number>                       specify device serial number\n"
+            "  -p <product>                             specify product name\n"
+            "  -c <cmdline>                             override kernel commandline\n"
+            "  -i <vendor id>                           specify a custom USB vendor id\n"
+        );
+    exit(1);
+}
+
+void *load_bootable_image(const char *kernel, const char *ramdisk, 
+                          unsigned *sz, const char *cmdline)
+{
+    void *kdata = 0, *rdata = 0;
+    unsigned ksize = 0, rsize = 0;
+    void *bdata;
+    unsigned bsize;
+
+    if(kernel == 0) {
+        fprintf(stderr, "no image specified\n");
+        return 0;
+    }
+
+    kdata = load_file(kernel, &ksize);
+    if(kdata == 0) {
+        fprintf(stderr, "cannot load '%s'\n", kernel);
+        return 0;
+    }
+    
+        /* is this actually a boot image? */
+    if(!memcmp(kdata, BOOT_MAGIC, BOOT_MAGIC_SIZE)) {
+        if(cmdline) bootimg_set_cmdline((boot_img_hdr*) kdata, cmdline);
+        
+        if(ramdisk) {
+            fprintf(stderr, "cannot boot a boot.img *and* ramdisk\n");
+            return 0;
+        }
+        
+        *sz = ksize;
+        return kdata;
+    }
+
+    if(ramdisk) {
+        rdata = load_file(ramdisk, &rsize);
+        if(rdata == 0) {
+            fprintf(stderr,"cannot load '%s'\n", ramdisk);
+            return  0;
+        }
+    }
+
+    fprintf(stderr,"creating boot image...\n");
+    bdata = mkbootimg(kdata, ksize, rdata, rsize, 0, 0, 2048, &bsize);
+    if(bdata == 0) {
+        fprintf(stderr,"failed to create boot.img\n");
+        return 0;
+    }
+    if(cmdline) bootimg_set_cmdline((boot_img_hdr*) bdata, cmdline);
+    fprintf(stderr,"creating boot image - %d bytes\n", bsize);
+    *sz = bsize;
+    
+    return bdata;
+}
+
+void *unzip_file(zipfile_t zip, const char *name, unsigned *sz)
+{
+    void *data;
+    zipentry_t entry;
+    unsigned datasz;
+    
+    entry = lookup_zipentry(zip, name);
+    if (entry == NULL) {
+        fprintf(stderr, "archive does not contain '%s'\n", name);
+        return 0;
+    }
+
+    *sz = get_zipentry_size(entry);
+
+    datasz = *sz * 1.001;
+    data = malloc(datasz);
+
+    if(data == 0) {
+        fprintf(stderr, "failed to allocate %d bytes\n", *sz);
+        return 0;
+    }
+
+    if (decompress_zipentry(entry, data, datasz)) {
+        fprintf(stderr, "failed to unzip '%s' from archive\n", name);
+        free(data);
+        return 0;
+    }
+
+    return data;
+}
+
+static char *strip(char *s)
+{
+    int n;
+    while(*s && isspace(*s)) s++;
+    n = strlen(s);
+    while(n-- > 0) {
+        if(!isspace(s[n])) break;
+        s[n] = 0;
+    }
+    return s;
+}
+
+#define MAX_OPTIONS 32
+static int setup_requirement_line(char *name)
+{
+    char *val[MAX_OPTIONS];
+    const char **out;
+    unsigned n, count;
+    char *x;
+    int invert = 0;
+    
+    if (!strncmp(name, "reject ", 7)) {
+        name += 7;
+        invert = 1;
+    } else if (!strncmp(name, "require ", 8)) {
+        name += 8;
+        invert = 0;
+    }
+
+    x = strchr(name, '=');
+    if (x == 0) return 0;
+    *x = 0;
+    val[0] = x + 1;
+
+    for(count = 1; count < MAX_OPTIONS; count++) {
+        x = strchr(val[count - 1],'|');
+        if (x == 0) break;
+        *x = 0;
+        val[count] = x + 1;
+    }
+    
+    name = strip(name);
+    for(n = 0; n < count; n++) val[n] = strip(val[n]);
+    
+    name = strip(name);
+    if (name == 0) return -1;
+
+        /* work around an unfortunate name mismatch */
+    if (!strcmp(name,"board")) name = "product";
+
+    out = malloc(sizeof(char*) * count);
+    if (out == 0) return -1;
+
+    for(n = 0; n < count; n++) {
+        out[n] = strdup(strip(val[n]));
+        if (out[n] == 0) return -1;
+    }
+
+    fb_queue_require(name, invert, n, out);
+    return 0;
+}
+
+static void setup_requirements(char *data, unsigned sz)
+{
+    char *s;
+
+    s = data;
+    while (sz-- > 0) {
+        if(*s == '\n') {
+            *s++ = 0;
+            if (setup_requirement_line(data)) {
+                die("out of memory");
+            }
+            data = s;
+        } else {
+            s++;
+        }
+    }
+}
+
+void queue_info_dump(void)
+{
+    fb_queue_notice("--------------------------------------------");
+    fb_queue_display("version-bootloader", "Bootloader Version...");
+    fb_queue_display("version-baseband",   "Baseband Version.....");
+    fb_queue_display("serialno",           "Serial Number........");
+    fb_queue_notice("--------------------------------------------");
+}
+
+void do_update_signature(zipfile_t zip, char *fn)
+{
+    void *data;
+    unsigned sz;
+    data = unzip_file(zip, fn, &sz);
+    if (data == 0) return;
+    fb_queue_download("signature", data, sz);
+    fb_queue_command("signature", "installing signature");
+}
+
+void do_update(char *fn)
+{
+    void *zdata;
+    unsigned zsize;
+    void *data;
+    unsigned sz;
+    zipfile_t zip;
+
+    queue_info_dump();
+
+    zdata = load_file(fn, &zsize);
+    if (zdata == 0) die("failed to load '%s'", fn);
+
+    zip = init_zipfile(zdata, zsize);
+    if(zip == 0) die("failed to access zipdata in '%s'");
+
+    data = unzip_file(zip, "android-info.txt", &sz);
+    if (data == 0) {
+        char *tmp;
+            /* fallback for older zipfiles */
+        data = unzip_file(zip, "android-product.txt", &sz);
+        if ((data == 0) || (sz < 1)) {
+            die("update package has no android-info.txt or android-product.txt");
+        }
+        tmp = malloc(sz + 128);
+        if (tmp == 0) die("out of memory");
+        sprintf(tmp,"board=%sversion-baseband=0.66.04.19\n",(char*)data);
+        data = tmp;
+        sz = strlen(tmp);
+    }
+
+    setup_requirements(data, sz);
+
+    data = unzip_file(zip, "boot.img", &sz);
+    if (data == 0) die("update package missing boot.img");
+    do_update_signature(zip, "boot.sig");
+    fb_queue_flash("boot", data, sz);
+
+    data = unzip_file(zip, "recovery.img", &sz);
+    if (data != 0) {
+        do_update_signature(zip, "recovery.sig");
+        fb_queue_flash("recovery", data, sz);
+    }
+
+    data = unzip_file(zip, "system.img", &sz);
+    if (data == 0) die("update package missing system.img");
+    do_update_signature(zip, "system.sig");
+    fb_queue_flash("system", data, sz);
+}
+
+void do_send_signature(char *fn)
+{
+    void *data;
+    unsigned sz;
+    char *xtn;
+	
+    xtn = strrchr(fn, '.');
+    if (!xtn) return;
+    if (strcmp(xtn, ".img")) return;
+	
+    strcpy(xtn,".sig");
+    data = load_file(fn, &sz);
+    strcpy(xtn,".img");
+    if (data == 0) return;
+    fb_queue_download("signature", data, sz);
+    fb_queue_command("signature", "installing signature");
+}
+
+void do_flashall(void)
+{
+    char *fname;
+    void *data;
+    unsigned sz;
+
+    queue_info_dump();
+
+    fname = find_item("info", product);
+    if (fname == 0) die("cannot find android-info.txt");
+    data = load_file(fname, &sz);
+    if (data == 0) die("could not load android-info.txt");
+    setup_requirements(data, sz);
+
+    fname = find_item("boot", product);
+    data = load_file(fname, &sz);
+    if (data == 0) die("could not load boot.img");
+    do_send_signature(fname);
+    fb_queue_flash("boot", data, sz);
+
+    fname = find_item("recovery", product);
+    data = load_file(fname, &sz);
+    if (data != 0) {
+        do_send_signature(fname);
+        fb_queue_flash("recovery", data, sz);
+    }
+
+    fname = find_item("system", product);
+    data = load_file(fname, &sz);
+    if (data == 0) die("could not load system.img");
+    do_send_signature(fname);
+    fb_queue_flash("system", data, sz);   
+}
+
+#define skip(n) do { argc -= (n); argv += (n); } while (0)
+#define require(n) do { if (argc < (n)) usage(); } while (0)
+
+int do_oem_command(int argc, char **argv)
+{
+    int i;
+    char command[256];
+    if (argc <= 1) return 0;
+    
+    command[0] = 0;
+    while(1) {
+        strcat(command,*argv);
+        skip(1);
+        if(argc == 0) break;
+        strcat(command," ");
+    }
+
+    fb_queue_command(command,"");    
+    return 0;
+}
+
+int main(int argc, char **argv)
+{
+    int wants_wipe = 0;
+    int wants_reboot = 0;
+    int wants_reboot_bootloader = 0;
+    void *data;
+    unsigned sz;
+
+    skip(1);
+    if (argc == 0) {
+        usage();
+        return 0;
+    }
+
+    if (!strcmp(*argv, "devices")) {
+        list_devices();
+        return 0;
+    }
+
+    while (argc > 0) {
+        if(!strcmp(*argv, "-w")) {
+            wants_wipe = 1;
+            skip(1);
+        } else if(!strcmp(*argv, "-s")) {
+            require(2);
+            serial = argv[1];
+            skip(2);
+        } else if(!strcmp(*argv, "-p")) {
+            require(2);
+            product = argv[1];
+            skip(2);
+        } else if(!strcmp(*argv, "-c")) {
+            require(2);
+            cmdline = argv[1];
+            skip(2);
+        } else if(!strcmp(*argv, "-i")) {
+            char *endptr = NULL;
+            unsigned long val;
+
+            require(2);
+            val = strtoul(argv[1], &endptr, 0);
+            if (!endptr || *endptr != '\0' || (val & ~0xffff))
+                die("invalid vendor id '%s'", argv[1]);
+            vendor_id = (unsigned short)val;
+            skip(2);
+        } else if(!strcmp(*argv, "getvar")) {
+            require(2);
+            fb_queue_display(argv[1], argv[1]);
+            skip(2);
+        } else if(!strcmp(*argv, "erase")) {
+            require(2);
+            fb_queue_erase(argv[1]);
+            skip(2);
+        } else if(!strcmp(*argv, "signature")) {
+            require(2);
+            data = load_file(argv[1], &sz);
+            if (data == 0) die("could not load '%s'", argv[1]);
+            if (sz != 256) die("signature must be 256 bytes");
+            fb_queue_download("signature", data, sz);
+            fb_queue_command("signature", "installing signature");
+            skip(2);
+        } else if(!strcmp(*argv, "reboot")) {
+            wants_reboot = 1;
+            skip(1);
+        } else if(!strcmp(*argv, "reboot-bootloader")) {
+            wants_reboot_bootloader = 1;
+            skip(1);
+        } else if (!strcmp(*argv, "continue")) {
+            fb_queue_command("continue", "resuming boot");
+            skip(1);
+        } else if(!strcmp(*argv, "boot")) {
+            char *kname = 0;
+            char *rname = 0;
+            skip(1);
+            if (argc > 0) {
+                kname = argv[0];
+                skip(1);
+            }
+            if (argc > 0) {
+                rname = argv[0];
+                skip(1);
+            }
+            data = load_bootable_image(kname, rname, &sz, cmdline);
+            if (data == 0) return 1;
+            fb_queue_download("boot.img", data, sz);
+            fb_queue_command("boot", "booting");
+        } else if(!strcmp(*argv, "flash")) {
+            char *pname = argv[1];
+            char *fname = 0;
+            require(2);
+            if (argc > 2) {
+                fname = argv[2];
+                skip(3);
+            } else {
+                fname = find_item(pname, product);
+                skip(2);
+            }
+            if (fname == 0) die("cannot determine image filename for '%s'", pname);
+            data = load_file(fname, &sz);
+            if (data == 0) die("cannot load '%s'\n", fname);
+            fb_queue_flash(pname, data, sz);
+        } else if(!strcmp(*argv, "flash:raw")) {
+            char *pname = argv[1];
+            char *kname = argv[2];
+            char *rname = 0;
+            require(3);
+            if(argc > 3) {
+                rname = argv[3];
+                skip(4);
+            } else {
+                skip(3);
+            }
+            data = load_bootable_image(kname, rname, &sz, cmdline);
+            if (data == 0) die("cannot load bootable image");
+            fb_queue_flash(pname, data, sz);
+        } else if(!strcmp(*argv, "flashall")) {
+            skip(1);
+            do_flashall();
+            wants_reboot = 1;
+        } else if(!strcmp(*argv, "update")) {
+            if (argc > 1) {
+                do_update(argv[1]);
+                skip(2);
+            } else {
+                do_update("update.zip");
+                skip(1);
+            }
+            wants_reboot = 1;
+        } else if(!strcmp(*argv, "oem")) {
+            argc = do_oem_command(argc, argv);
+        } else {
+            usage();
+        }
+    }
+
+    if (wants_wipe) {
+        fb_queue_erase("userdata");
+        fb_queue_erase("cache");
+    }
+    if (wants_reboot) {
+        fb_queue_reboot();
+    } else if (wants_reboot_bootloader) {
+        fb_queue_command("reboot-bootloader", "rebooting into bootloader");
+    }
+
+    usb = open_device();
+
+    fb_execute_queue(usb);
+    return 0;
+}
diff --git a/fastboot/fastboot.h b/fastboot/fastboot.h
new file mode 100644
index 0000000..a36c569
--- /dev/null
+++ b/fastboot/fastboot.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the 
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _FASTBOOT_H_
+#define _FASTBOOT_H_
+
+#include "usb.h"
+
+/* protocol.c - fastboot protocol */
+int fb_command(usb_handle *usb, const char *cmd);
+int fb_command_response(usb_handle *usb, const char *cmd, char *response);
+int fb_download_data(usb_handle *usb, const void *data, unsigned size);
+char *fb_get_error(void);
+
+#define FB_COMMAND_SZ 64
+#define FB_RESPONSE_SZ 64
+
+/* engine.c - high level command queue engine */
+void fb_queue_flash(const char *ptn, void *data, unsigned sz);;
+void fb_queue_erase(const char *ptn);
+void fb_queue_require(const char *var, int invert, unsigned nvalues, const char **value);
+void fb_queue_display(const char *var, const char *prettyname);
+void fb_queue_reboot(void);
+void fb_queue_command(const char *cmd, const char *msg);
+void fb_queue_download(const char *name, void *data, unsigned size);
+void fb_queue_notice(const char *notice);
+void fb_execute_queue(usb_handle *usb);
+
+/* util stuff */
+void die(const char *fmt, ...);
+
+#endif
diff --git a/fastboot/genkey.sh b/fastboot/genkey.sh
new file mode 100755
index 0000000..011e902
--- /dev/null
+++ b/fastboot/genkey.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+if [ $# -ne 2 ]
+then
+ echo "Usage: $0 alias \"pass phrase\""
+ exit -1
+fi
+
+# Generate a 2048 bit RSA key with public exponent 3.
+# Encrypt private key with provided password.
+openssl genrsa -3 -out $1.pem -passout pass:"$2" 2048
+
+# Create a self-signed cert for this key.
+openssl req -new -x509 -key $1.pem -passin pass:"$2" \
+        -out $1-cert.pem \
+        -batch -days 10000
+
+# Create a PKCS12 store containing the generated private key.
+# Protect the keystore and the private key with the provided password.
+openssl pkcs12 -export -in $1-cert.pem -inkey $1.pem -passin pass:"$2" \
+        -out $1.p12 -name $1 -passout pass:"$2"
+
+rm $1.pem
+rm $1-cert.pem
+
diff --git a/fastboot/p12topem.sh b/fastboot/p12topem.sh
new file mode 100755
index 0000000..f081eb5
--- /dev/null
+++ b/fastboot/p12topem.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+if [ $# -ne 2 ]
+then
+ echo "Usage: $0 alias passphrase"
+ exit -1
+fi
+
+openssl pkcs12 -passin pass:"$2" -passout pass:"$2" -in $1.p12 -out $1.pem
diff --git a/fastboot/protocol.c b/fastboot/protocol.c
new file mode 100644
index 0000000..c788a12
--- /dev/null
+++ b/fastboot/protocol.c
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the 
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "fastboot.h"
+
+static char ERROR[128];
+
+char *fb_get_error(void)
+{
+    return ERROR;
+}
+
+static int check_response(usb_handle *usb, unsigned size, 
+                          unsigned data_okay, char *response)
+{
+    unsigned char status[65];
+    int r;
+
+    for(;;) {
+        r = usb_read(usb, status, 64);
+        if(r < 0) {
+            sprintf(ERROR, "status read failed (%s)", strerror(errno));
+            usb_close(usb);
+            return -1;
+        }
+        status[r] = 0;
+
+        if(r < 4) {
+            sprintf(ERROR, "status malformed (%d bytes)", r);
+            usb_close(usb);
+            return -1;
+        }
+
+        if(!memcmp(status, "INFO", 4)) {
+            fprintf(stderr,"%s\n", status);
+            continue;
+        }
+
+        if(!memcmp(status, "OKAY", 4)) {
+            if(response) {
+                strcpy(response, (char*) status + 4);
+            }
+            return 0;
+        }
+
+        if(!memcmp(status, "FAIL", 4)) {
+            if(r > 4) {
+                sprintf(ERROR, "remote: %s", status + 4);
+            } else {
+                strcpy(ERROR, "remote failure");
+            }
+            return -1;
+        }
+
+        if(!memcmp(status, "DATA", 4) && data_okay){
+            unsigned dsize = strtoul((char*) status + 4, 0, 16);
+            if(dsize > size) {
+                strcpy(ERROR, "data size too large");
+                usb_close(usb);
+                return -1;
+            }
+            return dsize;
+        }
+
+        strcpy(ERROR,"unknown status code");
+        usb_close(usb);
+        break;
+    }
+
+    return -1;
+}
+
+static int _command_send(usb_handle *usb, const char *cmd,
+                         const void *data, unsigned size,
+                         char *response)
+{
+    int cmdsize = strlen(cmd);
+    int r;
+    
+    if(response) {
+        response[0] = 0;
+    }
+
+    if(cmdsize > 64) {
+        sprintf(ERROR,"command too large");
+        return -1;
+    }
+
+    if(usb_write(usb, cmd, cmdsize) != cmdsize) {
+        sprintf(ERROR,"command write failed (%s)", strerror(errno));
+        usb_close(usb);
+        return -1;
+    }
+
+    if(data == 0) {
+        return check_response(usb, size, 0, response);
+    }
+
+    r = check_response(usb, size, 1, 0);
+    if(r < 0) {
+        return -1;
+    }
+    size = r;
+
+    if(size) {
+        r = usb_write(usb, data, size);
+        if(r < 0) {
+            sprintf(ERROR, "data transfer failure (%s)", strerror(errno));
+            usb_close(usb);
+            return -1;
+        }
+        if(r != ((int) size)) {
+            sprintf(ERROR, "data transfer failure (short transfer)");
+            usb_close(usb);
+            return -1;
+        }
+    }
+    
+    r = check_response(usb, 0, 0, 0);
+    if(r < 0) {
+        return -1;
+    } else {
+        return size;
+    }
+}
+
+int fb_command(usb_handle *usb, const char *cmd)
+{
+    return _command_send(usb, cmd, 0, 0, 0);
+}
+
+int fb_command_response(usb_handle *usb, const char *cmd, char *response)
+{
+    return _command_send(usb, cmd, 0, 0, response);
+}
+
+int fb_download_data(usb_handle *usb, const void *data, unsigned size)
+{
+    char cmd[64];
+    int r;
+    
+    sprintf(cmd, "download:%08x", size);
+    r = _command_send(usb, cmd, data, size, 0);
+    
+    if(r < 0) {
+        return -1;
+    } else {
+        return 0;
+    }
+}
+
diff --git a/fastboot/signfile.sh b/fastboot/signfile.sh
new file mode 100755
index 0000000..3188d2d
--- /dev/null
+++ b/fastboot/signfile.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+if [ $# -ne 3 ]
+then
+ echo "Usage: $0 alias filename passpharse"
+ exit -1
+fi
+
+openssl dgst -passin pass:"$3" -binary -sha1 -sign $1.pem $2 > $2.sign
+
diff --git a/fastboot/usb.h b/fastboot/usb.h
new file mode 100644
index 0000000..f3ec5bf
--- /dev/null
+++ b/fastboot/usb.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the 
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _USB_H_
+#define _USB_H_
+
+typedef struct usb_handle usb_handle;
+
+typedef struct usb_ifc_info usb_ifc_info;
+
+struct usb_ifc_info
+{
+        /* from device descriptor */
+    unsigned short dev_vendor;
+    unsigned short dev_product;
+
+    unsigned char dev_class;
+    unsigned char dev_subclass;
+    unsigned char dev_protocol;
+    
+    unsigned char ifc_class;
+    unsigned char ifc_subclass;
+    unsigned char ifc_protocol;
+
+    unsigned char has_bulk_in;
+    unsigned char has_bulk_out;
+    
+    char serial_number[256];
+};
+  
+typedef int (*ifc_match_func)(usb_ifc_info *ifc);
+
+usb_handle *usb_open(ifc_match_func callback);
+int usb_close(usb_handle *h);
+int usb_read(usb_handle *h, void *_data, int len);
+int usb_write(usb_handle *h, const void *_data, int len);
+
+
+#endif
diff --git a/fastboot/usb_linux.c b/fastboot/usb_linux.c
new file mode 100644
index 0000000..06c62b8
--- /dev/null
+++ b/fastboot/usb_linux.c
@@ -0,0 +1,373 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the 
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <pthread.h>
+#include <ctype.h>
+
+#include <linux/usbdevice_fs.h>
+#include <linux/usbdevice_fs.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
+#include <linux/usb/ch9.h>
+#else
+#include <linux/usb_ch9.h>
+#endif
+#include <asm/byteorder.h>
+
+#include "usb.h"
+
+#if TRACE_USB
+#define DBG1(x...) fprintf(stderr, x)
+#define DBG(x...) fprintf(stderr, x)
+#else
+#define DBG(x...)
+#define DBG1(x...)
+#endif
+
+struct usb_handle 
+{
+    char fname[64];
+    int desc;
+    unsigned char ep_in;
+    unsigned char ep_out;
+};
+
+static inline int badname(const char *name)
+{
+    while(*name) {
+        if(!isdigit(*name++)) return 1;
+    }
+    return 0;
+}
+
+static int check(void *_desc, int len, unsigned type, int size)
+{
+    unsigned char *desc = _desc;
+    
+    if(len < size) return -1;
+    if(desc[0] < size) return -1;
+    if(desc[0] > len) return -1;
+    if(desc[1] != type) return -1;
+    
+    return 0;
+}
+
+static int filter_usb_device(int fd, char *ptr, int len, ifc_match_func callback,
+                             int *ept_in_id, int *ept_out_id, int *ifc_id)
+{
+    struct usb_device_descriptor *dev;
+    struct usb_config_descriptor *cfg;
+    struct usb_interface_descriptor *ifc;
+    struct usb_endpoint_descriptor *ept;
+    struct usb_ifc_info info;
+    
+    int in, out;
+    unsigned i;
+    unsigned e;
+    
+    if(check(ptr, len, USB_DT_DEVICE, USB_DT_DEVICE_SIZE))
+        return -1;
+    dev = (void*) ptr;
+    len -= dev->bLength;
+    ptr += dev->bLength;
+    
+    if(check(ptr, len, USB_DT_CONFIG, USB_DT_CONFIG_SIZE))
+        return -1;
+    cfg = (void*) ptr;
+    len -= cfg->bLength;
+    ptr += cfg->bLength;
+    
+    info.dev_vendor = dev->idVendor;
+    info.dev_product = dev->idProduct;
+    info.dev_class = dev->bDeviceClass;
+    info.dev_subclass = dev->bDeviceSubClass;
+    info.dev_protocol = dev->bDeviceProtocol;
+
+    // read device serial number (if there is one)
+    info.serial_number[0] = 0;
+    if (dev->iSerialNumber) {
+        struct usbdevfs_ctrltransfer  ctrl;
+        __u16 buffer[128];
+        int result;
+
+        memset(buffer, 0, sizeof(buffer));
+
+        ctrl.bRequestType = USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE;
+        ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
+        ctrl.wValue = (USB_DT_STRING << 8) | dev->iSerialNumber;
+        ctrl.wIndex = 0;
+        ctrl.wLength = sizeof(buffer);
+        ctrl.data = buffer;
+
+        result = ioctl(fd, USBDEVFS_CONTROL, &ctrl);
+        if (result > 0) {
+            int i;
+            // skip first word, and copy the rest to the serial string, changing shorts to bytes.
+            result /= 2;
+            for (i = 1; i < result; i++)
+                info.serial_number[i - 1] = buffer[i];
+            info.serial_number[i - 1] = 0;
+        }
+    }
+
+    for(i = 0; i < cfg->bNumInterfaces; i++) {
+        if(check(ptr, len, USB_DT_INTERFACE, USB_DT_INTERFACE_SIZE))
+            return -1;
+        ifc = (void*) ptr;
+        len -= ifc->bLength;
+        ptr += ifc->bLength;
+        
+        in = -1;
+        out = -1;
+        info.ifc_class = ifc->bInterfaceClass;
+        info.ifc_subclass = ifc->bInterfaceSubClass;
+        info.ifc_protocol = ifc->bInterfaceProtocol;
+        
+        for(e = 0; e < ifc->bNumEndpoints; e++) {
+            if(check(ptr, len, USB_DT_ENDPOINT, USB_DT_ENDPOINT_SIZE))
+                return -1;
+            ept = (void*) ptr;
+            len -= ept->bLength;
+            ptr += ept->bLength;
+    
+            if((ept->bmAttributes & 0x03) != 0x02)
+                continue;
+            
+            if(ept->bEndpointAddress & 0x80) {
+                in = ept->bEndpointAddress;
+            } else {
+                out = ept->bEndpointAddress;
+            }
+        }
+
+        info.has_bulk_in = (in != -1);
+        info.has_bulk_out = (out != -1);
+        
+        if(callback(&info) == 0) {
+            *ept_in_id = in;
+            *ept_out_id = out;
+            *ifc_id = ifc->bInterfaceNumber;
+            return 0;
+        }
+    }
+
+    return -1;
+}
+
+static usb_handle *find_usb_device(const char *base, ifc_match_func callback)
+{
+    usb_handle *usb = 0;
+    char busname[64], devname[64];
+    char desc[1024];
+    int n, in, out, ifc;
+    
+    DIR *busdir, *devdir;
+    struct dirent *de;
+    int fd;
+    
+    busdir = opendir(base);
+    if(busdir == 0) return 0;
+
+    while((de = readdir(busdir)) && (usb == 0)) {
+        if(badname(de->d_name)) continue;
+        
+        sprintf(busname, "%s/%s", base, de->d_name);
+        devdir = opendir(busname);
+        if(devdir == 0) continue;
+        
+//        DBG("[ scanning %s ]\n", busname);
+        while((de = readdir(devdir)) && (usb == 0)) {
+            
+            if(badname(de->d_name)) continue;
+            sprintf(devname, "%s/%s", busname, de->d_name);
+
+//            DBG("[ scanning %s ]\n", devname);
+            if((fd = open(devname, O_RDWR)) < 0) {
+                continue;
+            }
+
+            n = read(fd, desc, sizeof(desc));
+            
+            if(filter_usb_device(fd, desc, n, callback, &in, &out, &ifc) == 0){
+                usb = calloc(1, sizeof(usb_handle));
+                strcpy(usb->fname, devname);
+                usb->ep_in = in;
+                usb->ep_out = out;
+                usb->desc = fd;
+
+                n = ioctl(fd, USBDEVFS_CLAIMINTERFACE, &ifc);
+                if(n != 0) {
+                    close(fd);
+                    free(usb);
+                    usb = 0;
+                    continue;
+                }
+            } else {
+                close(fd);
+            }
+        }
+        closedir(devdir);
+    }
+    closedir(busdir);
+
+    return usb;
+}
+
+int usb_write(usb_handle *h, const void *_data, int len)
+{
+    unsigned char *data = (unsigned char*) _data;
+    unsigned count = 0;
+    struct usbdevfs_bulktransfer bulk;
+    int n;
+
+    if(h->ep_out == 0) {
+        return -1;
+    }
+    
+    if(len == 0) {
+        bulk.ep = h->ep_out;
+        bulk.len = 0;
+        bulk.data = data;
+        bulk.timeout = 0;
+        
+        n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
+        if(n != 0) {
+            fprintf(stderr,"ERROR: n = %d, errno = %d (%s)\n",
+                    n, errno, strerror(errno));
+            return -1;
+        }
+        return 0;
+    }
+    
+    while(len > 0) {
+        int xfer;
+        xfer = (len > 4096) ? 4096 : len;
+        
+        bulk.ep = h->ep_out;
+        bulk.len = xfer;
+        bulk.data = data;
+        bulk.timeout = 0;
+        
+        n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
+        if(n != xfer) {
+            DBG("ERROR: n = %d, errno = %d (%s)\n",
+                n, errno, strerror(errno));
+            return -1;
+        }
+
+        count += xfer;
+        len -= xfer;
+        data += xfer;
+    }
+
+    return count;
+}
+
+int usb_read(usb_handle *h, void *_data, int len)
+{
+    unsigned char *data = (unsigned char*) _data;
+    unsigned count = 0;
+    struct usbdevfs_bulktransfer bulk;
+    int n;
+
+    if(h->ep_in == 0) {
+        return -1;
+    }
+    
+    while(len > 0) {
+        int xfer = (len > 4096) ? 4096 : len;
+        
+        bulk.ep = h->ep_in;
+        bulk.len = xfer;
+        bulk.data = data;
+        bulk.timeout = 0;
+        
+        DBG("[ usb read %d fd = %d], fname=%s\n", xfer, h->desc, h->fname);
+        n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
+        DBG("[ usb read %d ] = %d, fname=%s\n", xfer, n, h->fname);
+
+        if(n < 0) {
+            DBG1("ERROR: n = %d, errno = %d (%s)\n",
+                n, errno, strerror(errno));
+            return -1;
+        }
+
+        count += n;
+        len -= n;
+        data += n;
+        
+        if(n < xfer) {
+            break;
+        }
+    }
+    
+    return count;
+}
+
+void usb_kick(usb_handle *h)
+{
+    int fd;
+
+    fd = h->desc;
+    h->desc = -1;
+    if(fd >= 0) {
+        close(fd);
+        DBG("[ usb closed %d ]\n", fd);
+    }
+}
+
+int usb_close(usb_handle *h)
+{
+    int fd;
+    
+    fd = h->desc;
+    h->desc = -1;
+    if(fd >= 0) {
+        close(fd);
+        DBG("[ usb closed %d ]\n", fd);
+    }
+
+    return 0;
+}
+
+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
new file mode 100644
index 0000000..d6a8260
--- /dev/null
+++ b/fastboot/usb_osx.c
@@ -0,0 +1,538 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the 
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include <IOKit/IOKitLib.h>
+#include <IOKit/IOCFPlugIn.h>
+#include <IOKit/usb/IOUSBLib.h>
+#include <IOKit/IOMessage.h>
+#include <mach/mach_port.h>
+
+#include "usb.h"
+
+
+/*
+ * Internal helper functions and associated definitions.
+ */
+
+#if TRACE_USB
+#define WARN(x...) fprintf(stderr, x)
+#else
+#define WARN(x...)
+#endif
+
+#define ERR(x...) fprintf(stderr, "ERROR: " x)
+
+/** An open usb device */
+struct usb_handle
+{
+    int success;
+    ifc_match_func callback;
+    usb_ifc_info info;
+    
+    UInt8 bulkIn;
+    UInt8 bulkOut;
+    IOUSBInterfaceInterface190 **interface;
+    unsigned int zero_mask;
+};
+
+/** Try out all the interfaces and see if there's a match. Returns 0 on
+ * success, -1 on failure. */
+static int try_interfaces(IOUSBDeviceInterface **dev, usb_handle *handle) {
+    IOReturn kr;
+    IOUSBFindInterfaceRequest request;
+    io_iterator_t iterator;
+    io_service_t usbInterface;
+    IOCFPlugInInterface **plugInInterface;
+    IOUSBInterfaceInterface190 **interface = NULL;
+    HRESULT result;
+    SInt32 score;
+    UInt8 interfaceNumEndpoints;
+    UInt8 endpoint;
+    UInt8 configuration;
+
+    // Placing the constant KIOUSBFindInterfaceDontCare into the following
+    // fields of the IOUSBFindInterfaceRequest structure will allow us to
+    // find all of the interfaces
+    request.bInterfaceClass = kIOUSBFindInterfaceDontCare;
+    request.bInterfaceSubClass = kIOUSBFindInterfaceDontCare;
+    request.bInterfaceProtocol = kIOUSBFindInterfaceDontCare;
+    request.bAlternateSetting = kIOUSBFindInterfaceDontCare;
+
+    // SetConfiguration will kill an existing UMS connection, so let's
+    // not do this if not necessary.
+    configuration = 0;
+    (*dev)->GetConfiguration(dev, &configuration);
+    if (configuration != 1)
+        (*dev)->SetConfiguration(dev, 1);
+
+    // Get an iterator for the interfaces on the device
+    kr = (*dev)->CreateInterfaceIterator(dev, &request, &iterator);
+
+    if (kr != 0) {
+        ERR("Couldn't create a device interface iterator: (%08x)\n", kr);
+        return -1;
+    }
+
+    while ((usbInterface = IOIteratorNext(iterator))) {
+        // Create an intermediate plugin
+        kr = IOCreatePlugInInterfaceForService(
+                usbInterface,
+                kIOUSBInterfaceUserClientTypeID,
+                kIOCFPlugInInterfaceID,
+                &plugInInterface,
+                &score);
+
+        // No longer need the usbInterface object now that we have the plugin
+        (void) IOObjectRelease(usbInterface);
+
+        if ((kr != 0) || (!plugInInterface)) {
+            WARN("Unable to create plugin (%08x)\n", kr);
+            continue;
+        }
+
+        // Now create the interface interface for the interface
+        result = (*plugInInterface)->QueryInterface(
+                plugInInterface,
+                CFUUIDGetUUIDBytes(kIOUSBInterfaceInterfaceID),
+                (LPVOID) &interface);
+
+        // No longer need the intermediate plugin
+        (*plugInInterface)->Release(plugInInterface);
+
+        if (result || !interface) {
+            ERR("Couldn't create interface interface: (%08x)\n",
+               (unsigned int) result);
+            // continue so we can try the next interface
+            continue;
+        }
+        
+        /*
+         * Now open the interface. This will cause the pipes
+         * associated with the endpoints in the interface descriptor
+         * to be instantiated.
+         */
+
+        /*
+         * TODO: Earlier comments here indicated that it was a bad
+         * idea to just open any interface, because opening "mass
+         * storage endpoints" is bad. However, the only way to find
+         * out if an interface does bulk in or out is to open it, and
+         * the framework in this application wants to be told about
+         * bulk in / out before deciding whether it actually wants to
+         * use the interface. Maybe something needs to be done about
+         * this situation.
+         */
+        
+        kr = (*interface)->USBInterfaceOpen(interface);
+
+        if (kr != 0) {
+            WARN("Could not open interface: (%08x)\n", kr);
+            (void) (*interface)->Release(interface);
+            // continue so we can try the next interface
+            continue;
+        }
+        
+        // Get the number of endpoints associated with this interface.
+        kr = (*interface)->GetNumEndpoints(interface, &interfaceNumEndpoints);
+
+        if (kr != 0) {
+            ERR("Unable to get number of endpoints: (%08x)\n", kr);
+            goto next_interface;
+        }
+
+        // Get interface class, subclass and protocol
+        if ((*interface)->GetInterfaceClass(interface, &handle->info.ifc_class) != 0 ||
+            (*interface)->GetInterfaceSubClass(interface, &handle->info.ifc_subclass) != 0 ||
+            (*interface)->GetInterfaceProtocol(interface, &handle->info.ifc_protocol) != 0)
+        {
+            ERR("Unable to get interface class, subclass and protocol\n");
+            goto next_interface;
+        }
+
+        handle->info.has_bulk_in = 0;
+        handle->info.has_bulk_out = 0;
+
+        // Iterate over the endpoints for this interface and see if there
+        // are any that do bulk in/out.
+        for (endpoint = 0; endpoint <= interfaceNumEndpoints; endpoint++) {
+            UInt8   transferType;
+            UInt16  maxPacketSize;
+            UInt8   interval;
+            UInt8   number;
+            UInt8   direction;
+
+            kr = (*interface)->GetPipeProperties(interface, endpoint,
+                    &direction,
+                    &number, &transferType, &maxPacketSize, &interval);
+
+            if (kr == 0) {
+                if (transferType != kUSBBulk) {
+                    continue;
+                }
+
+                if (direction == kUSBIn) {
+                    handle->info.has_bulk_in = 1;
+                    handle->bulkIn = endpoint;
+                } else if (direction == kUSBOut) {
+                    handle->info.has_bulk_out = 1;
+                    handle->bulkOut = endpoint;
+                }
+
+                if (handle->info.ifc_protocol == 0x01) {
+                    handle->zero_mask = maxPacketSize - 1;
+                }
+            } else {
+                ERR("could not get pipe properties\n");
+            }
+
+            if (handle->info.has_bulk_in && handle->info.has_bulk_out) {
+                break;
+            }
+        }
+
+        if (handle->callback(&handle->info) == 0) {
+            handle->interface = interface;
+            handle->success = 1;
+
+            /*
+             * Clear both the endpoints, because it has been observed
+             * that the Mac may otherwise (incorrectly) start out with
+             * them in bad state.
+             */
+
+            if (handle->info.has_bulk_in) {
+                kr = (*interface)->ClearPipeStallBothEnds(interface,
+                        handle->bulkIn);
+                if (kr != 0) {
+                    ERR("could not clear input pipe; result %d", kr);
+                    return -1;
+                }
+            }
+
+            if (handle->info.has_bulk_out) {
+                kr = (*interface)->ClearPipeStallBothEnds(interface,
+                        handle->bulkOut);
+                if (kr != 0) {
+                    ERR("could not clear output pipe; result %d", kr);
+                    return -1;
+                }
+            }
+            
+            return 0;
+        }
+        
+next_interface:
+        (*interface)->USBInterfaceClose(interface);
+        (*interface)->Release(interface);
+    }
+
+    return 0;
+}
+
+/** Try out the given device and see if there's a match. Returns 0 on
+ * success, -1 on failure.
+ */
+static int try_device(io_service_t device, usb_handle *handle) {
+    kern_return_t kr;
+    IOCFPlugInInterface **plugin = NULL;
+    IOUSBDeviceInterface182 **dev = NULL;
+    SInt32 score;
+    HRESULT result;
+    UInt8 serialIndex;
+
+    // Create an intermediate plugin.
+    kr = IOCreatePlugInInterfaceForService(device,
+            kIOUSBDeviceUserClientTypeID,
+            kIOCFPlugInInterfaceID,
+            &plugin, &score);
+
+    if ((kr != 0) || (plugin == NULL)) {
+        ERR("Unable to create a plug-in (%08x)\n", kr);
+        goto error;
+    }
+
+    // Now create the device interface.
+    result = (*plugin)->QueryInterface(plugin,
+            CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), (LPVOID) &dev);
+    if ((result != 0) || (dev == NULL)) {
+        ERR("Couldn't create a device interface (%08x)\n", (int) result);
+        goto error;
+    }
+
+    /* 
+     * We don't need the intermediate interface after the device interface
+     * is created.
+     */
+    IODestroyPlugInInterface(plugin);
+
+    // So, we have a device, finally. Grab its vitals.
+
+    kr = (*dev)->GetDeviceVendor(dev, &handle->info.dev_vendor);
+    if (kr != 0) {
+        ERR("GetDeviceVendor");
+        goto error;
+    }
+
+    kr = (*dev)->GetDeviceProduct(dev, &handle->info.dev_product);
+    if (kr != 0) {
+        ERR("GetDeviceProduct");
+        goto error;
+    }
+
+    kr = (*dev)->GetDeviceClass(dev, &handle->info.dev_class);
+    if (kr != 0) {
+        ERR("GetDeviceClass");
+        goto error;
+    }
+
+    kr = (*dev)->GetDeviceSubClass(dev, &handle->info.dev_subclass);
+    if (kr != 0) {
+        ERR("GetDeviceSubClass");
+        goto error;
+    }
+
+    kr = (*dev)->GetDeviceProtocol(dev, &handle->info.dev_protocol);
+    if (kr != 0) {
+        ERR("GetDeviceProtocol");
+        goto error;
+    }
+
+    kr = (*dev)->USBGetSerialNumberStringIndex(dev, &serialIndex);
+
+    if (serialIndex > 0) {
+        IOUSBDevRequest req;
+        UInt16  buffer[256];
+
+        req.bmRequestType = USBmakebmRequestType(kUSBIn, kUSBStandard, kUSBDevice);
+        req.bRequest = kUSBRqGetDescriptor;
+        req.wValue = (kUSBStringDesc << 8) | serialIndex;
+        req.wIndex = 0;
+        req.pData = buffer;
+        req.wLength = sizeof(buffer);
+        kr = (*dev)->DeviceRequest(dev, &req);
+
+        if (kr == kIOReturnSuccess && req.wLenDone > 0) {
+            int i, count;
+            
+            // skip first word, and copy the rest to the serial string, changing shorts to bytes.
+            count = (req.wLenDone - 1) / 2;
+            for (i = 0; i < count; i++)
+              handle->info.serial_number[i] = buffer[i + 1];
+            handle->info.serial_number[i] = 0;
+        }
+    } else {
+        // device has no serial number
+        handle->info.serial_number[0] = 0;
+    }
+
+    if (try_interfaces(dev, handle)) {
+        goto error;
+    }
+
+    (*dev)->Release(dev);
+    return 0;
+
+    error:
+
+    if (dev != NULL) {
+        (*dev)->Release(dev);
+    }
+    
+    return -1;    
+}
+
+
+/** Initializes the USB system. Returns 0 on success, -1 on error. */
+static int init_usb(ifc_match_func callback, usb_handle **handle) {
+    int ret = -1;
+    CFMutableDictionaryRef matchingDict;
+    kern_return_t result;
+    io_iterator_t iterator;
+    usb_handle h;
+
+    h.success = 0;
+    h.callback = callback;
+
+    /*
+     * Create our matching dictionary to find appropriate devices.
+     * IOServiceAddMatchingNotification consumes the reference, so we
+     * do not need to release it.
+     */
+    matchingDict = IOServiceMatching(kIOUSBDeviceClassName);
+
+    if (matchingDict == NULL) {
+        ERR("Couldn't create USB matching dictionary.\n");
+        return -1;
+    }
+
+    result = IOServiceGetMatchingServices(
+            kIOMasterPortDefault, matchingDict, &iterator);
+
+    if (result != 0) {
+        ERR("Could not create iterator.");
+        return -1;
+    }
+    
+    for (;;) {
+        if (! IOIteratorIsValid(iterator)) {
+            /*
+             * Apple documentation advises resetting the iterator if
+             * it should become invalid during iteration.
+             */
+            IOIteratorReset(iterator);
+            continue;
+        }
+                
+        io_service_t device = IOIteratorNext(iterator);
+
+        if (device == 0) {
+            break;
+        }
+
+        usb_ifc_info info;
+
+        if (try_device(device, &h) != 0) {
+            IOObjectRelease(device);
+            ret = -1;
+            break;
+        }
+
+        if (h.success) {
+            *handle = calloc(1, sizeof(usb_handle));
+            memcpy(*handle, &h, sizeof(usb_handle));
+            ret = 0;
+            break;
+        }
+
+        IOObjectRelease(device);
+    }
+
+    IOObjectRelease(iterator);
+
+    return ret;
+}
+
+
+
+/*
+ * Definitions of this file's public functions.
+ */
+
+usb_handle *usb_open(ifc_match_func callback) {
+    usb_handle *handle = NULL;
+
+    if (init_usb(callback, &handle) < 0) {
+        /* Something went wrong initializing USB. */
+        return NULL;
+    }
+
+    return handle;
+}
+
+int usb_close(usb_handle *h) {
+    /* TODO: Something better here? */
+    return 0;
+}
+
+int usb_read(usb_handle *h, void *data, int len) {
+    IOReturn result;
+    UInt32 numBytes = len;
+
+    if (len == 0) {
+        return 0;
+    }
+
+    if (h == NULL) {
+        return -1;
+    }
+
+    if (h->interface == NULL) {
+        ERR("usb_read interface was null\n");
+        return -1;
+    }
+
+    if (h->bulkIn == 0) {
+        ERR("bulkIn endpoint not assigned\n");
+        return -1;
+    }
+
+    result = (*h->interface)->ReadPipe(
+            h->interface, h->bulkIn, data, &numBytes);
+
+    if (result == 0) {
+        return (int) numBytes;
+    } else {
+        ERR("usb_read failed with status %x\n", result);
+    }
+
+    return -1;
+}
+
+int usb_write(usb_handle *h, const void *data, int len) {
+    IOReturn result;
+
+    if (len == 0) {
+        return 0;
+    }
+
+    if (h == NULL) {
+        return -1;
+    }
+
+    if (h->interface == NULL) {
+        ERR("usb_write interface was null\n");
+        return -1;
+    }
+
+    if (h->bulkOut == 0) {
+        ERR("bulkOut endpoint not assigned\n");
+        return -1;
+    }
+
+    result = (*h->interface)->WritePipe(
+            h->interface, h->bulkOut, (void *)data, len);
+
+    #if 0
+    if ((result == 0) && (h->zero_mask)) {
+        /* we need 0-markers and our transfer */
+        if(!(len & h->zero_mask)) {
+            result = (*h->interface)->WritePipe(
+                    h->interface, h->bulkOut, (void *)data, 0);
+        }
+    }
+    #endif
+
+    if (result != 0) {
+        ERR("usb_write failed with status %x\n", result);
+        return -1;
+    }
+
+    return len;
+}
diff --git a/fastboot/usb_windows.c b/fastboot/usb_windows.c
new file mode 100644
index 0000000..9c0a9cb
--- /dev/null
+++ b/fastboot/usb_windows.c
@@ -0,0 +1,375 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the 
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <windows.h>
+#include <winerror.h>
+#include <errno.h>
+#include <usb100.h>
+#include <adb_api.h>
+#include <stdio.h>
+
+#include "usb.h"
+
+//#define TRACE_USB 1
+#if TRACE_USB
+#define DBG(x...) fprintf(stderr, x)
+#else
+#define DBG(x...)
+#endif
+
+
+/** Structure usb_handle describes our connection to the usb device via
+  AdbWinApi.dll. This structure is returned from usb_open() routine and
+  is expected in each subsequent call that is accessing the device.
+*/
+struct usb_handle {
+    /// Handle to USB interface
+    ADBAPIHANDLE  adb_interface;
+    
+    /// Handle to USB read pipe (endpoint)
+    ADBAPIHANDLE  adb_read_pipe;
+    
+    /// Handle to USB write pipe (endpoint)
+    ADBAPIHANDLE  adb_write_pipe;
+    
+    /// Interface name
+    char*         interface_name;
+};
+
+/// Class ID assigned to the device by androidusb.sys
+static const GUID usb_class_id = ANDROID_USB_CLASS_ID;
+
+
+/// Checks if interface (device) matches certain criteria
+int recognized_device(usb_handle* handle, ifc_match_func callback);
+
+/// Opens usb interface (device) by interface (device) name.
+usb_handle* do_usb_open(const wchar_t* interface_name);
+
+/// Writes data to the opened usb handle
+int usb_write(usb_handle* handle, const void* data, int len);
+
+/// Reads data using the opened usb handle
+int usb_read(usb_handle *handle, void* data, int len);
+
+/// Cleans up opened usb handle
+void usb_cleanup_handle(usb_handle* handle);
+
+/// Cleans up (but don't close) opened usb handle
+void usb_kick(usb_handle* handle);
+
+/// Closes opened usb handle
+int usb_close(usb_handle* handle);
+
+
+usb_handle* do_usb_open(const wchar_t* interface_name) {
+    // Allocate our handle
+    usb_handle* ret = (usb_handle*)malloc(sizeof(usb_handle));
+    if (NULL == ret)
+        return NULL;
+
+    // Create interface.
+    ret->adb_interface = AdbCreateInterfaceByName(interface_name);
+
+    if (NULL == ret->adb_interface) {
+        free(ret);
+        errno = GetLastError();
+        return NULL;
+    }
+
+    // Open read pipe (endpoint)
+    ret->adb_read_pipe =
+        AdbOpenDefaultBulkReadEndpoint(ret->adb_interface,
+                                   AdbOpenAccessTypeReadWrite,
+                                   AdbOpenSharingModeReadWrite);
+    if (NULL != ret->adb_read_pipe) {
+        // Open write pipe (endpoint)
+        ret->adb_write_pipe =
+            AdbOpenDefaultBulkWriteEndpoint(ret->adb_interface,
+                                      AdbOpenAccessTypeReadWrite,
+                                      AdbOpenSharingModeReadWrite);
+        if (NULL != ret->adb_write_pipe) {
+            // Save interface name
+            unsigned long name_len = 0;
+
+            // First get expected name length
+            AdbGetInterfaceName(ret->adb_interface,
+                          NULL,
+                          &name_len,
+                          true);
+            if (0 != name_len) {
+                ret->interface_name = (char*)malloc(name_len);
+
+                if (NULL != ret->interface_name) {
+                    // Now save the name
+                    if (AdbGetInterfaceName(ret->adb_interface,
+                                  ret->interface_name,
+                                  &name_len,
+                                  true)) {
+                        // We're done at this point
+                        return ret;
+                    }
+                } else {
+                    SetLastError(ERROR_OUTOFMEMORY);
+                }
+            }
+        }
+    }
+
+    // Something went wrong.
+    errno = GetLastError();
+    usb_cleanup_handle(ret);
+    free(ret);
+    SetLastError(errno);
+
+    return NULL;
+}
+
+int usb_write(usb_handle* handle, const void* data, int len) {
+    unsigned long time_out = 500 + len * 8;
+    unsigned long written = 0;
+    unsigned count = 0;
+    int ret;
+
+    DBG("usb_write %d\n", len);
+    if (NULL != handle) {
+        // Perform write
+        while(len > 0) {
+            int xfer = (len > 4096) ? 4096 : len;
+            ret = AdbWriteEndpointSync(handle->adb_write_pipe,
+                                   (void*)data,
+                                   (unsigned long)xfer,
+                                   &written,
+                                   time_out);
+            errno = GetLastError();
+            DBG("AdbWriteEndpointSync returned %d, errno: %d\n", ret, errno);
+            if (ret == 0) {
+                // assume ERROR_INVALID_HANDLE indicates we are disconnected
+                if (errno == ERROR_INVALID_HANDLE)
+                usb_kick(handle);
+                return -1;
+            }
+
+            count += written;
+            len -= written;
+            data += written;
+
+            if (len == 0)
+                return count;
+        }
+    } else {
+        DBG("usb_write NULL handle\n");
+        SetLastError(ERROR_INVALID_HANDLE);
+    }
+
+    DBG("usb_write failed: %d\n", errno);
+
+    return -1;
+}
+
+int usb_read(usb_handle *handle, void* data, int len) {
+    unsigned long time_out = 500 + len * 8;
+    unsigned long read = 0;
+    int ret;
+
+    DBG("usb_read %d\n", len);
+    if (NULL != handle) {
+        while (1) {
+            int xfer = (len > 4096) ? 4096 : len;
+
+	        ret = AdbReadEndpointSync(handle->adb_read_pipe,
+	                              (void*)data,
+	                              (unsigned long)xfer,
+	                              &read,
+	                              time_out);
+            errno = GetLastError();
+            DBG("usb_read got: %ld, expected: %d, errno: %d\n", read, xfer, errno);
+            if (ret) {
+                return read;
+            } else if (errno != ERROR_SEM_TIMEOUT) {
+                // assume ERROR_INVALID_HANDLE indicates we are disconnected
+                if (errno == ERROR_INVALID_HANDLE)
+                    usb_kick(handle);
+                break;
+            }
+            // else we timed out - try again
+        }
+    } else {
+        DBG("usb_read NULL handle\n");
+        SetLastError(ERROR_INVALID_HANDLE);
+    }
+
+    DBG("usb_read failed: %d\n", errno);
+
+    return -1;
+}
+
+void usb_cleanup_handle(usb_handle* handle) {
+    if (NULL != handle) {
+        if (NULL != handle->interface_name)
+            free(handle->interface_name);
+        if (NULL != handle->adb_write_pipe)
+            AdbCloseHandle(handle->adb_write_pipe);
+        if (NULL != handle->adb_read_pipe)
+            AdbCloseHandle(handle->adb_read_pipe);
+        if (NULL != handle->adb_interface)
+            AdbCloseHandle(handle->adb_interface);
+
+        handle->interface_name = NULL;
+        handle->adb_write_pipe = NULL;
+        handle->adb_read_pipe = NULL;
+        handle->adb_interface = NULL;
+    }
+}
+
+void usb_kick(usb_handle* handle) {
+    if (NULL != handle) {
+        usb_cleanup_handle(handle);
+    } else {
+        SetLastError(ERROR_INVALID_HANDLE);
+        errno = ERROR_INVALID_HANDLE;
+    }
+}
+
+int usb_close(usb_handle* handle) {
+    DBG("usb_close\n");
+
+    if (NULL != handle) {
+        // Cleanup handle
+        usb_cleanup_handle(handle);
+        free(handle);
+    }
+
+    return 0;
+}
+
+int recognized_device(usb_handle* handle, ifc_match_func callback) {
+    struct usb_ifc_info info;
+    USB_DEVICE_DESCRIPTOR device_desc;
+    USB_INTERFACE_DESCRIPTOR interf_desc;
+
+    if (NULL == handle)
+        return 0;
+
+    // Check vendor and product id first
+    if (!AdbGetUsbDeviceDescriptor(handle->adb_interface,
+                                 &device_desc)) {
+        return 0;
+    }
+
+    // Then check interface properties
+    if (!AdbGetUsbInterfaceDescriptor(handle->adb_interface,
+                                    &interf_desc)) {
+        return 0;
+    }
+
+    // Must have two endpoints
+    if (2 != interf_desc.bNumEndpoints) {
+        return 0;
+    }
+
+    info.dev_vendor = device_desc.idVendor;
+    info.dev_product = device_desc.idProduct;
+    info.dev_class = device_desc.bDeviceClass;
+    info.dev_subclass = device_desc.bDeviceSubClass;
+    info.dev_protocol = device_desc.bDeviceProtocol;
+    info.ifc_class = interf_desc.bInterfaceClass;
+    info.ifc_subclass = interf_desc.bInterfaceSubClass;
+    info.ifc_protocol = interf_desc.bInterfaceProtocol;
+    
+    // read serial number (if there is one)
+    unsigned long serial_number_len = sizeof(info.serial_number);
+    if (!AdbGetSerialNumber(handle->adb_interface, info.serial_number,
+                    &serial_number_len, true)) {
+        info.serial_number[0] = 0;
+    }
+
+    if (callback(&info) == 0) {
+        return 1;
+    }
+
+    return 0;
+}
+
+static usb_handle *find_usb_device(ifc_match_func callback) {
+	usb_handle* handle = NULL;
+    char entry_buffer[2048];
+    char interf_name[2048];
+    AdbInterfaceInfo* next_interface = (AdbInterfaceInfo*)(&entry_buffer[0]);
+    unsigned long entry_buffer_size = sizeof(entry_buffer);
+    char* copy_name;
+
+    // Enumerate all present and active interfaces.
+    ADBAPIHANDLE enum_handle =
+        AdbEnumInterfaces(usb_class_id, true, true, true);
+
+    if (NULL == enum_handle)
+        return NULL;
+
+    while (AdbNextInterface(enum_handle, next_interface, &entry_buffer_size)) {
+        // TODO(vchtchetkine): FIXME - temp hack converting wchar_t into char.
+        // It would be better to change AdbNextInterface so it will return
+        // interface name as single char string.
+        const wchar_t* wchar_name = next_interface->device_name;
+        for(copy_name = interf_name;
+                L'\0' != *wchar_name;
+                wchar_name++, copy_name++) {
+            *copy_name = (char)(*wchar_name);
+        }
+        *copy_name = '\0';
+
+        handle = do_usb_open(next_interface->device_name);
+        if (NULL != handle) {
+            // Lets see if this interface (device) belongs to us
+            if (recognized_device(handle, callback)) {
+                // found it!
+                break;
+            } else {
+                usb_cleanup_handle(handle);
+                free(handle);
+                handle = NULL;
+            }
+        }
+
+        entry_buffer_size = sizeof(entry_buffer);
+    }
+
+    AdbCloseHandle(enum_handle);
+    return handle;
+}
+
+usb_handle *usb_open(ifc_match_func callback)
+{
+    return find_usb_device(callback);
+}
+
+// called from fastboot.c
+void sleep(int seconds)
+{
+    Sleep(seconds * 1000);
+}
diff --git a/fastboot/usbtest.c b/fastboot/usbtest.c
new file mode 100644
index 0000000..e34d7e6
--- /dev/null
+++ b/fastboot/usbtest.c
@@ -0,0 +1,212 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the 
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/time.h>
+
+#include "usb.h"
+
+static unsigned arg_size = 4096;
+static unsigned arg_count = 4096;
+
+long long NOW(void) 
+{
+    struct timeval tv;
+    gettimeofday(&tv, 0);
+    
+    return (((long long) tv.tv_sec) * ((long long) 1000000)) +
+        (((long long) tv.tv_usec));
+}
+
+int printifc(usb_ifc_info *info)
+{
+    printf("dev: csp=%02x/%02x/%02x v=%04x p=%04x  ",
+           info->dev_class, info->dev_subclass, info->dev_protocol,
+           info->dev_vendor, info->dev_product);
+    printf("ifc: csp=%02x/%02x/%02x%s%s\n",
+           info->ifc_class, info->ifc_subclass, info->ifc_protocol,
+           info->has_bulk_in ? " in" : "",
+           info->has_bulk_out ? " out" : "");
+    return -1;
+}
+
+int match_null(usb_ifc_info *info)
+{
+    if(info->dev_vendor != 0x18d1) return -1;
+    if(info->ifc_class != 0xff) return -1;
+    if(info->ifc_subclass != 0xfe) return -1;
+    if(info->ifc_protocol != 0x01) return -1;
+    return 0;
+}
+
+int match_zero(usb_ifc_info *info)
+{
+    if(info->dev_vendor != 0x18d1) return -1;
+    if(info->ifc_class != 0xff) return -1;
+    if(info->ifc_subclass != 0xfe) return -1;
+    if(info->ifc_protocol != 0x02) return -1;
+    return 0;
+}
+
+int match_loop(usb_ifc_info *info)
+{
+    if(info->dev_vendor != 0x18d1) return -1;
+    if(info->ifc_class != 0xff) return -1;
+    if(info->ifc_subclass != 0xfe) return -1;
+    if(info->ifc_protocol != 0x03) return -1;
+    return 0;
+}
+
+int test_null(usb_handle *usb)
+{
+    int i;
+    unsigned char buf[4096];
+    memset(buf, 0xee, 4096);
+    long long t0, t1;
+
+    t0 = NOW();
+    for(i = 0; i < arg_count; i++) {
+        if(usb_write(usb, buf, arg_size) != arg_size) {
+            fprintf(stderr,"write failed (%s)\n", strerror(errno));
+            return -1;
+        }
+    }
+    t1 = NOW();
+    fprintf(stderr,"%d bytes in %lld uS\n", arg_count * arg_size, (t1 - t0));
+    return 0;
+}
+
+int test_zero(usb_handle *usb)
+{
+    int i;
+    unsigned char buf[4096];
+    long long t0, t1;
+    
+    t0 = NOW();
+    for(i = 0; i < arg_count; i++) {
+        if(usb_read(usb, buf, arg_size) != arg_size) {
+            fprintf(stderr,"read failed (%s)\n", strerror(errno));
+            return -1;
+        }
+    }
+    t1 = NOW();
+    fprintf(stderr,"%d bytes in %lld uS\n", arg_count * arg_size, (t1 - t0));
+    return 0;
+}
+
+struct 
+{
+    const char *cmd;
+    ifc_match_func match;
+    int (*test)(usb_handle *usb);
+    const char *help;
+} tests[] = {
+    { "list", printifc,   0,         "list interfaces" },
+    { "send", match_null, test_null, "send to null interface" },
+    { "recv", match_zero, test_zero, "recv from zero interface" },
+    { "loop", match_loop, 0,         "exercise loopback interface" },
+    {},
+};
+
+int usage(void)
+{
+    int i;
+
+    fprintf(stderr,"usage: usbtest <testname>\n\navailable tests:\n");
+    for(i = 0; tests[i].cmd; i++) {
+        fprintf(stderr," %-8s %s\n", tests[i].cmd, tests[i].help);
+    }
+    return -1;
+}
+
+int process_args(int argc, char **argv)
+{
+    while(argc-- > 0) {
+        char *arg = *argv++;
+        if(!strncmp(arg,"count=",6)) {
+            arg_count = atoi(arg + 6);
+        } else if(!strncmp(arg,"size=",5)) {
+            arg_size = atoi(arg + 5);
+        } else {
+            fprintf(stderr,"unknown argument: %s\n", arg);
+            return -1;
+        }
+    }
+
+    if(arg_count == 0) {
+        fprintf(stderr,"count may not be zero\n");
+        return -1;
+    }
+
+    if(arg_size > 4096) {
+        fprintf(stderr,"size may not be greater than 4096\n");
+        return -1;
+    }
+
+    return 0;
+}
+
+int main(int argc, char **argv)
+{
+    usb_handle *usb;
+    int i;
+    
+    if(argc < 2)
+        return usage();
+
+    if(argc > 2) {
+        if(process_args(argc - 2, argv + 2)) 
+            return -1;
+    }
+
+    for(i = 0; tests[i].cmd; i++) {
+        if(!strcmp(argv[1], tests[i].cmd)) {
+            usb = usb_open(tests[i].match);
+            if(tests[i].test) {
+                if(usb == 0) {
+                    fprintf(stderr,"usbtest: %s: could not find interface\n",
+                            tests[i].cmd);
+                    return -1;
+                }
+                if(tests[i].test(usb)) {
+                    fprintf(stderr,"usbtest: %s: FAIL\n", tests[i].cmd);
+                    return -1;
+                } else {
+                    fprintf(stderr,"usbtest: %s: OKAY\n", tests[i].cmd);
+                }
+            }
+            return 0;
+        }
+    }
+
+    return usage();
+}
diff --git a/fastboot/util_linux.c b/fastboot/util_linux.c
new file mode 100644
index 0000000..912e16f
--- /dev/null
+++ b/fastboot/util_linux.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the 
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <limits.h>
+
+void get_my_path(char *path)
+{
+    char proc[64];
+    char *x;
+    
+    sprintf(proc, "/proc/%d/exe", getpid());
+    int err = readlink(proc, path, PATH_MAX - 1);
+
+    if(err <= 0) {
+        path[0] = 0;
+    } else {
+        path[err] = 0;
+        x = strrchr(path,'/');
+        if(x) x[1] = 0;
+    }
+}
diff --git a/fastboot/util_osx.c b/fastboot/util_osx.c
new file mode 100644
index 0000000..068241c
--- /dev/null
+++ b/fastboot/util_osx.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the 
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <utils/executablepath.h>
+#import <Carbon/Carbon.h>
+#include <unistd.h>
+
+void get_my_path(char s[PATH_MAX])
+{
+    char *x;
+    ProcessSerialNumber psn;
+    GetCurrentProcess(&psn);
+    CFDictionaryRef dict;
+    dict = ProcessInformationCopyDictionary(&psn, 0xffffffff);
+    CFStringRef value = (CFStringRef)CFDictionaryGetValue(dict,
+                CFSTR("CFBundleExecutable"));
+    CFStringGetCString(value, s, PATH_MAX - 1, kCFStringEncodingUTF8);
+    x = strrchr(s, '/');
+    if(x) x[1] = 0;
+}
+
+
diff --git a/fastboot/util_windows.c b/fastboot/util_windows.c
new file mode 100644
index 0000000..37077a4
--- /dev/null
+++ b/fastboot/util_windows.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the 
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <limits.h>
+
+#include <windows.h>
+
+void get_my_path(char exe[PATH_MAX])
+{
+	char*  r;
+
+	GetModuleFileName( NULL, exe, PATH_MAX-1 );
+	exe[PATH_MAX-1] = 0;
+	r = strrchr( exe, '\\' );
+	if (r)
+		*r = 0;
+}
+
+
+void *load_file(const char *fn, unsigned *_sz)
+{
+    HANDLE    file;
+    char     *data;
+    DWORD     file_size;
+
+    file = CreateFile( fn,
+                       GENERIC_READ,
+                       FILE_SHARE_READ,
+                       NULL,
+                       OPEN_EXISTING,
+                       0,
+                       NULL );
+
+    if (file == INVALID_HANDLE_VALUE)
+        return NULL;
+
+    file_size = GetFileSize( file, NULL );
+    data      = NULL;
+
+    if (file_size > 0) {
+        data = (char*) malloc( file_size );
+        if (data == NULL) {
+            fprintf(stderr, "load_file: could not allocate %ld bytes\n", file_size );
+            file_size = 0;
+        } else {
+            DWORD  out_bytes;
+
+            if ( !ReadFile( file, data, file_size, &out_bytes, NULL ) ||
+                 out_bytes != file_size )
+            {
+                fprintf(stderr, "load_file: could not read %ld bytes from '%s'\n", file_size, fn);
+                free(data);
+                data      = NULL;
+                file_size = 0;
+            }
+        }
+    }
+    CloseHandle( file );
+
+    *_sz = (unsigned) file_size;
+    return  data;
+}
