diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b25c15b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*~
diff --git a/adb/commandline.c b/adb/commandline.c
index 548d362..ad1021c 100644
--- a/adb/commandline.c
+++ b/adb/commandline.c
@@ -96,7 +96,8 @@
         " -e                            - directs command to the only running emulator.\n"
         "                                 returns an error if more than one emulator is running.\n"
         " -s <serial number>            - directs command to the USB device or emulator with\n"
-        "                                 the given serial number\n"
+        "                                 the given serial number. Overrides ANDROID_SERIAL\n"
+        "                                 envivornment variable.\n"
         " -p <product name or path>     - simple product name like 'sooner', or\n"
         "                                 a relative/absolute path to a product\n"
         "                                 out directory like 'out/target/product/sooner'.\n"
@@ -766,6 +767,8 @@
     }
     // TODO: also try TARGET_PRODUCT/TARGET_DEVICE as a hint
 
+    serial = getenv("ANDROID_SERIAL");
+
         /* modifiers and flags */
     while(argc > 0) {
         if(!strcmp(argv[0],"nodaemon")) {
diff --git a/adb/get_my_path_darwin.c b/adb/get_my_path_darwin.c
index 00dfee4..6125cb4 100644
--- a/adb/get_my_path_darwin.c
+++ b/adb/get_my_path_darwin.c
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-#include <utils/executablepath.h>
 #import <Carbon/Carbon.h>
 #include <unistd.h>
 
diff --git a/fastboot/util_osx.c b/fastboot/util_osx.c
index 068241c..b43e316 100644
--- a/fastboot/util_osx.c
+++ b/fastboot/util_osx.c
@@ -26,7 +26,6 @@
  * SUCH DAMAGE.
  */
 
-#include <utils/executablepath.h>
 #import <Carbon/Carbon.h>
 #include <unistd.h>
 
diff --git a/include/acc/acc.h b/include/acc/acc.h
new file mode 100644
index 0000000..e25fde0
--- /dev/null
+++ b/include/acc/acc.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_ACC_ACC_H
+#define ANDROID_ACC_ACC_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+typedef char                        ACCchar;
+typedef int32_t                     ACCint;
+typedef uint32_t                    ACCuint;
+typedef ssize_t                     ACCsizei;
+typedef unsigned int                ACCenum;
+typedef void                        ACCvoid;
+typedef struct ACCscript            ACCscript;
+
+#define ACC_NO_ERROR                0x0000
+#define ACC_INVALID_ENUM            0x0500
+#define ACC_INVALID_OPERATION       0x0502
+#define ACC_INVALID_VALUE           0x0501
+#define ACC_OUT_OF_MEMORY           0x0505
+
+#define ACC_COMPILE_STATUS          0x8B81
+#define ACC_INFO_LOG_LENGTH         0x8B84
+
+
+// ----------------------------------------------------------------------------
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ACCscript* accCreateScript();
+
+void accDeleteScript(ACCscript* script);
+
+ACCenum accGetError( ACCscript* script );
+
+void accScriptSource(ACCscript* script,
+    ACCsizei count,
+    const ACCchar** string,
+    const ACCint* length);
+
+void accCompileScript(ACCscript* script);
+
+void accGetScriptiv(ACCscript* script,
+    ACCenum pname,
+    ACCint* params);
+
+void accGetScriptInfoLog(ACCscript* script,
+    ACCsizei maxLength,
+    ACCsizei* length,
+    ACCchar* infoLog);
+
+void accGetScriptLabel(ACCscript* script, const ACCchar * name,
+                       ACCvoid** address);
+
+void accGetPragmas(ACCscript* script, ACCsizei* actualStringCount,
+                   ACCsizei maxStringCount, ACCchar** strings);
+
+#ifdef __cplusplus
+};
+#endif
+
+// ----------------------------------------------------------------------------
+
+#endif
diff --git a/include/arch/freebsd-x86/AndroidConfig.h b/include/arch/freebsd-x86/AndroidConfig.h
new file mode 100644
index 0000000..cc118f4
--- /dev/null
+++ b/include/arch/freebsd-x86/AndroidConfig.h
@@ -0,0 +1,317 @@
+/*
+ * Copyright (C) 2005 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Android config -- "FreeBSD".  Used for desktop x86 FreeBSD.
+ */
+#ifndef _ANDROID_CONFIG_H
+#define _ANDROID_CONFIG_H
+
+/*
+ * make sure we are building for FreeBSD
+ */
+#ifndef OS_FREEBSD
+#define OS_FREEBSD
+#endif
+/*
+ * ===========================================================================
+ *                              !!! IMPORTANT !!!
+ * ===========================================================================
+ *
+ * This file is included by ALL C/C++ source files.  Don't put anything in
+ * here unless you are absolutely certain it can't go anywhere else.
+ *
+ * Any C++ stuff must be wrapped with "#ifdef __cplusplus".  Do not use "//"
+ * comments.
+ */
+
+/*
+ * Threading model.  Choose one:
+ *
+ * HAVE_PTHREADS - use the pthreads library.
+ * HAVE_WIN32_THREADS - use Win32 thread primitives.
+ *  -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX
+ */
+#define HAVE_PTHREADS
+
+/*
+ * Do we have the futex syscall?
+ */
+/* #define HAVE_FUTEX */
+
+/*
+ * Process creation model.  Choose one:
+ *
+ * HAVE_FORKEXEC - use fork() and exec()
+ * HAVE_WIN32_PROC - use CreateProcess()
+ */
+#define HAVE_FORKEXEC
+
+/*
+ * Process out-of-memory adjustment.  Set if running on Linux,
+ * where we can write to /proc/<pid>/oom_adj to modify the out-of-memory
+ * badness adjustment.
+ */
+/* #define HAVE_OOM_ADJ */
+
+/*
+ * IPC model.  Choose one:
+ *
+ * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget).
+ * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap).
+ * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping).
+ * HAVE_ANDROID_IPC - use Android versions (?, mmap).
+ */
+#define HAVE_SYSV_IPC
+
+/*
+ * Memory-mapping model. Choose one:
+ *
+ * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h
+ * HAVE_WIN32_FILEMAP - use Win32 filemaps
+ */
+#define  HAVE_POSIX_FILEMAP
+
+/*
+ * Define this if you have <termio.h>
+ */
+/* #define  HAVE_TERMIO_H */
+
+/*
+ * Define this if you build against MSVCRT.DLL
+ */
+/* #define HAVE_MS_C_RUNTIME */
+
+/*
+ * Define this if you have sys/uio.h
+ */
+#define  HAVE_SYS_UIO_H
+
+/*
+ * Define this if your platforms implements symbolic links
+ * in its filesystems
+ */
+#define HAVE_SYMLINKS
+
+/*
+ * Define this if we have localtime_r().
+ */
+#define HAVE_LOCALTIME_R
+
+/*
+ * Define this if we have gethostbyname_r().
+ */
+/* #define HAVE_GETHOSTBYNAME_R */
+
+/*
+ * Define this if we have ioctl().
+ */
+#define HAVE_IOCTL
+
+/*
+ * Define this if we want to use WinSock.
+ */
+/* #define HAVE_WINSOCK */
+
+/*
+ * Define this if have clock_gettime() and friends
+ *
+ * Desktop Linux has this in librt, but it's broken in goobuntu, yielding
+ * mildly or wildly inaccurate results.
+ */
+#define HAVE_POSIX_CLOCKS
+
+/*
+ * Define this if we have pthread_cond_timedwait_monotonic() and
+ * clock_gettime(CLOCK_MONOTONIC).
+ */
+/* #define HAVE_TIMEDWAIT_MONOTONIC */
+
+/*
+ * Define this if we have linux style epoll()
+ */
+/* #define HAVE_EPOLL */
+
+/*
+ * Endianness of the target machine.  Choose one:
+ *
+ * HAVE_ENDIAN_H -- have endian.h header we can include.
+ * HAVE_LITTLE_ENDIAN -- we are little endian.
+ * HAVE_BIG_ENDIAN -- we are big endian.
+ */
+/* #define HAVE_ENDIAN_H */
+#define HAVE_LITTLE_ENDIAN
+
+/*
+ * Define this if you have sys/endian.h
+ * NOTE: mutually exclusive with HAVE_ENDIAN_H
+ */
+#define HAVE_SYS_ENDIAN_H
+
+/*
+ * We need to choose between 32-bit and 64-bit off_t.  All of our code should
+ * agree on the same size.  For desktop systems, use 64-bit values,
+ * because some of our libraries (e.g. wxWidgets) expect to be built that way.
+ */
+#define _FILE_OFFSET_BITS 64
+#define _LARGEFILE_SOURCE 1
+
+/*
+ * Defined if we have the backtrace() call for retrieving a stack trace.
+ * Needed for CallStack to operate; if not defined, CallStack is
+ * non-functional.
+ */
+#define HAVE_BACKTRACE 0
+
+/*
+ * Defined if we have the dladdr() call for retrieving the symbol associated
+ * with a memory address.  If not defined, stack crawls will not have symbolic
+ * information.
+ */
+#define HAVE_DLADDR 1
+
+/*
+ * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
+ * not defined, stack crawls will be displayed with raw mangled symbols
+ */
+#define HAVE_CXXABI 0
+
+/*
+ * Defined if we have the gettid() system call.
+ */
+/* #define HAVE_GETTID */
+
+/* 
+ * Defined if we have the sched_setscheduler() call
+ */
+#define HAVE_SCHED_SETSCHEDULER
+
+/*
+ * Add any extra platform-specific defines here.
+ */
+
+/*
+ * Define if we have <malloc.h> header
+ */
+#define HAVE_MALLOC_H
+
+/*
+ * Define if we have Linux-style non-filesystem Unix Domain Sockets
+ */
+
+/*
+ * What CPU architecture does this platform use?
+ */
+#define ARCH_X86
+
+
+/*
+ * Define if we have Linux's inotify in <sys/inotify.h>.
+ */
+/*#define HAVE_INOTIFY 1*/
+
+/*
+ * Define if we have madvise() in <sys/mman.h>
+ */
+#define HAVE_MADVISE 1
+
+/*
+ * Define if tm struct has tm_gmtoff field
+ */
+#define HAVE_TM_GMTOFF 1
+
+/*
+ * Define if dirent struct has d_type field
+ */
+#define HAVE_DIRENT_D_TYPE 1
+
+/*
+ * Define if libc includes Android system properties implementation.
+ */
+/* #define HAVE_LIBC_SYSTEM_PROPERTIES */
+
+/*
+ * Define if system provides a system property server (should be
+ * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES).
+ */
+#define HAVE_SYSTEM_PROPERTY_SERVER
+
+/*
+ * sprintf() format string for shared library naming.
+ */
+#define OS_SHARED_LIB_FORMAT_STR    "lib%s.so"
+
+/*
+ * type for the third argument to mincore().
+ */
+#define MINCORE_POINTER_TYPE char *
+
+/*
+ * Do we have the sigaction flag SA_NOCLDWAIT?
+ */
+#define HAVE_SA_NOCLDWAIT
+
+/*
+ * Define if we include <sys/mount.h> for statfs()
+ */
+#define INCLUDE_SYS_MOUNT_FOR_STATFS 1
+  
+/*
+ * The default path separator for the platform
+ */
+#define OS_PATH_SEPARATOR '/'
+
+/*
+ * Is the filesystem case sensitive?
+ */
+#define OS_CASE_SENSITIVE
+
+/*
+ * Define if <sys/socket.h> exists.
+ */
+#define HAVE_SYS_SOCKET_H 1
+
+/*
+ * Define if the strlcpy() function exists on the system.
+ */
+#define HAVE_STRLCPY 1
+
+/*
+ * Define if prctl() exists
+ */
+/* #define HAVE_PRCTL 1 */
+
+/*
+ * Define if writev() exists
+ */
+#define HAVE_WRITEV 1
+
+/*
+ * Define if <alloca.h> does not exist
+ * NOTE: <alloca.h> defines alloca() which
+ *   on FreeBSD is defined in <stdlib.h>
+ */
+#define HAVE_NO_ALLOCA_H
+
+/*
+ * Defines CLOCK_PROCESS_CPUTIME_ID for clock_gettime()
+ * XXX: CLOCK_PROF seems to be commonly used replacement
+ */
+#ifndef  CLOCK_PROCESS_CPUTIME_ID
+#define CLOCK_PROCESS_CPUTIME_ID CLOCK_PROF
+#endif
+
+#endif /*_ANDROID_CONFIG_H*/
diff --git a/include/cutils/abort_socket.h b/include/cutils/abort_socket.h
new file mode 100644
index 0000000..fbb1112
--- /dev/null
+++ b/include/cutils/abort_socket.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* Helper to perform abortable blocking operations on a socket:
+ *   asocket_connect()
+ *   asocket_accept()
+ *   asocket_read()
+ *   asocket_write()
+ * These calls are similar to the regular syscalls, but can be aborted with:
+ *   asocket_abort()
+ *
+ * Calling close() on a regular POSIX socket does not abort blocked syscalls on
+ * that socket in other threads.
+ *
+ * After calling asocket_abort() the socket cannot be reused.
+ *
+ * Call asocket_destory() *after* all threads have finished with the socket to
+ * finish closing the socket and free the asocket structure.
+ *
+ * The helper is implemented by setting the socket non-blocking to initiate
+ * syscalls connect(), accept(), read(), write(), then using a blocking poll()
+ * on both the primary socket and a local pipe. This makes the poll() abortable
+ * by writing a byte to the local pipe in asocket_abort().
+ *
+ * asocket_create() sets the fd to non-blocking mode. It must not be changed to
+ * blocking mode.
+ *
+ * Using asocket will triple the number of file descriptors required per
+ * socket, due to the local pipe. It may be possible to use a global pipe per
+ * process rather than per socket, but we have not been able to come up with a
+ * race-free implementation yet.
+ *
+ * All functions except asocket_init() and asocket_destroy() are thread safe.
+ */
+
+#include <stdlib.h>
+#include <sys/socket.h>
+
+#ifndef __CUTILS_ABORT_SOCKET_H__
+#define __CUTILS_ABORT_SOCKET_H__
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct asocket {
+    int fd;           /* primary socket fd */
+    int abort_fd[2];  /* pipe used to abort */
+};
+
+/* Create an asocket from fd.
+ * Sets the socket to non-blocking mode.
+ * Returns NULL on error with errno set.
+ */
+struct asocket *asocket_init(int fd);
+
+/* Blocking socket I/O with timeout.
+ * Calling asocket_abort() from another thread will cause each of these
+ * functions to immediately return with value -1 and errno ECANCELED.
+ * timeout is in ms, use -1 to indicate no timeout. On timeout -1 is returned
+ * with errno ETIMEDOUT.
+ * EINTR is handled in-call.
+ * Other semantics are identical to the regular syscalls.
+ */
+int asocket_connect(struct asocket *s, const struct sockaddr *addr,
+        socklen_t addrlen, int timeout);
+
+int asocket_accept(struct asocket *s, struct sockaddr *addr,
+        socklen_t *addrlen, int timeout);
+
+int asocket_read(struct asocket *s, void *buf, size_t count, int timeout);
+
+int asocket_write(struct asocket *s, const void *buf, size_t count,
+        int timeout);
+
+/* Abort above calls and shutdown socket.
+ * Further I/O operations on this socket will immediately fail after this call.
+ * asocket_destroy() should be used to release resources once all threads
+ * have returned from blocking calls on the socket.
+ */
+void asocket_abort(struct asocket *s);
+
+/* Close socket and free asocket structure.
+ * Must not be called until all calls on this structure have completed.
+ */
+void asocket_destroy(struct asocket *s);
+
+#ifdef __cplusplus
+}
+#endif
+#endif //__CUTILS_ABORT_SOCKET__H__
diff --git a/include/cutils/ashmem.h b/include/cutils/ashmem.h
index 0683bf2..fd56dbe 100644
--- a/include/cutils/ashmem.h
+++ b/include/cutils/ashmem.h
@@ -10,6 +10,8 @@
 #ifndef _CUTILS_ASHMEM_H
 #define _CUTILS_ASHMEM_H
 
+#include <stdint.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/include/cutils/compiler.h b/include/cutils/compiler.h
new file mode 100644
index 0000000..09112d5
--- /dev/null
+++ b/include/cutils/compiler.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_CUTILS_COMPILER_H
+#define ANDROID_CUTILS_COMPILER_H
+
+/*
+ * helps the compiler's optimizer predicting branches
+ */
+
+#ifdef __cplusplus
+#   define CC_LIKELY( exp )    (__builtin_expect( !!(exp), true ))
+#   define CC_UNLIKELY( exp )  (__builtin_expect( !!(exp), false ))
+#else
+#   define CC_LIKELY( exp )    (__builtin_expect( !!(exp), 1 ))
+#   define CC_UNLIKELY( exp )  (__builtin_expect( !!(exp), 0 ))
+#endif
+
+#endif // ANDROID_CUTILS_COMPILER_H
diff --git a/include/cutils/tztime.h b/include/cutils/tztime.h
index 69dbc88..cf103ca 100644
--- a/include/cutils/tztime.h
+++ b/include/cutils/tztime.h
@@ -17,6 +17,8 @@
 #ifndef _CUTILS_TZTIME_H
 #define _CUTILS_TZTIME_H
 
+#include <time.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -24,6 +26,9 @@
 time_t mktime_tz(struct tm * const tmp, char const * tz);
 void localtime_tz(const time_t * const timep, struct tm * tmp, const char* tz);
 
+#ifndef HAVE_ANDROID_OS
+/* the following is defined in <time.h> in Bionic */
+
 struct strftime_locale {
     const char *mon[12];    /* short names */
     const char *month[12];  /* long names */
@@ -40,6 +45,8 @@
 
 size_t strftime_tz(char *s, size_t max, const char *format, const struct tm *tm, const struct strftime_locale *locale);
 
+#endif /* !HAVE_ANDROID_OS */
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h
index 6ba574b..ad4bd74 100644
--- a/include/private/android_filesystem_config.h
+++ b/include/private/android_filesystem_config.h
@@ -156,7 +156,7 @@
     { 00550, AID_ROOT,      AID_SHELL,     "system/etc/init.testmenu" },
     { 00550, AID_DHCP,      AID_SHELL,     "system/etc/dhcpcd/dhcpcd-run-hooks" },
     { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/dbus.conf" },
-    { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluez/hcid.conf" },
+    { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluez/main.conf" },
     { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluez/input.conf" },
     { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluez/audio.conf" },
     { 00440, AID_RADIO,     AID_AUDIO,     "system/etc/AudioPara4.csv" },
diff --git a/include/private/pixelflinger/ggl_context.h b/include/private/pixelflinger/ggl_context.h
index 3a030c5..8a36fa9 100644
--- a/include/private/pixelflinger/ggl_context.h
+++ b/include/private/pixelflinger/ggl_context.h
@@ -21,8 +21,8 @@
 #include <stddef.h>
 #include <string.h>
 #include <sys/types.h>
+#include <endian.h>
 
-#include <utils/Endian.h>
 #include <pixelflinger/pixelflinger.h>
 #include <private/pixelflinger/ggl_fixed.h>
 
diff --git a/include/sysutils/SocketListener.h b/include/sysutils/SocketListener.h
index 68dcb8f..c7edfeb 100644
--- a/include/sysutils/SocketListener.h
+++ b/include/sysutils/SocketListener.h
@@ -33,7 +33,7 @@
     SocketListener(const char *socketNames, bool listen);
     SocketListener(int socketFd, bool listen);
 
-    virtual ~SocketListener() {}
+    virtual ~SocketListener();
     int startListener();
     int stopListener();
 
diff --git a/init/builtins.c b/init/builtins.c
index 17df0af..16601ce 100644
--- a/init/builtins.c
+++ b/init/builtins.c
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <sys/mount.h>
 #include <sys/resource.h>
+#include <linux/loop.h>
 
 #include "init.h"
 #include "keywords.h"
@@ -48,7 +49,7 @@
     fd = open(path, O_WRONLY|O_CREAT, 0622);
 
     if (fd < 0)
-        return -1;
+        return -errno;
 
     len = strlen(value);
 
@@ -58,7 +59,7 @@
 
     close(fd);
     if (ret < 0) {
-        return -1;
+        return -errno;
     } else {
         return 0;
     }
@@ -257,7 +258,7 @@
 int do_mount(int nargs, char **args)
 {
     char tmp[64];
-    char *source;
+    char *source, *target, *system;
     char *options = NULL;
     unsigned flags = 0;
     int n, i;
@@ -275,15 +276,70 @@
             options = args[n];
     }
 
+    system = args[1];
     source = args[2];
+    target = args[3];
+
     if (!strncmp(source, "mtd@", 4)) {
         n = mtd_name_to_number(source + 4);
-        if (n >= 0) {
-            sprintf(tmp, "/dev/block/mtdblock%d", n);
-            source = tmp;
+        if (n < 0) {
+            return -1;
         }
+
+        sprintf(tmp, "/dev/block/mtdblock%d", n);
+
+        if (mount(tmp, target, system, flags, options) < 0) {
+            return -1;
+        }
+
+        return 0;
+    } else if (!strncmp(source, "loop@", 5)) {
+        int mode, loop, fd;
+        struct loop_info info;
+
+        mode = (flags & MS_RDONLY) ? O_RDONLY : O_RDWR;
+        fd = open(source + 5, mode);
+        if (fd < 0) {
+            return -1;
+        }
+
+        for (n = 0; ; n++) {
+            sprintf(tmp, "/dev/block/loop%d", n);
+            loop = open(tmp, mode);
+            if (loop < 0) {
+                return -1;
+            }
+
+            /* if it is a blank loop device */
+            if (ioctl(loop, LOOP_GET_STATUS, &info) < 0 && errno == ENXIO) {
+                /* if it becomes our loop device */
+                if (ioctl(loop, LOOP_SET_FD, fd) >= 0) {
+                    close(fd);
+
+                    if (mount(tmp, target, system, flags, options) < 0) {
+                        ioctl(loop, LOOP_CLR_FD, 0);
+                        close(loop);
+                        return -1;
+                    }
+
+                    close(loop);
+                    return 0;
+                }
+            }
+
+            close(loop);
+        }
+
+        close(fd);
+        ERROR("out of loopback devices");
+        return -1;
+    } else {
+        if (mount(source, target, system, flags, options) < 0) {
+            return -1;
+        }
+
+        return 0;
     }
-    return mount(source, args[3], args[1], flags, options);
 }
 
 int do_setkey(int nargs, char **args)
diff --git a/init/devices.c b/init/devices.c
index ac72b34..4c7b7da 100644
--- a/init/devices.c
+++ b/init/devices.c
@@ -118,6 +118,10 @@
     { "/dev/msm_camera/",   0660,   AID_SYSTEM,     AID_SYSTEM,     1 },
     { "/dev/akm8976_daemon",0640,   AID_COMPASS,    AID_SYSTEM,     0 },
     { "/dev/akm8976_aot",   0640,   AID_COMPASS,    AID_SYSTEM,     0 },
+    { "/dev/akm8973_daemon",0640,   AID_COMPASS,    AID_SYSTEM,     0 },
+    { "/dev/akm8973_aot",   0640,   AID_COMPASS,    AID_SYSTEM,     0 },
+    { "/dev/bma150",        0640,   AID_COMPASS,    AID_SYSTEM,     0 },
+    { "/dev/cm3602",        0640,   AID_COMPASS,    AID_SYSTEM,     0 },
     { "/dev/akm8976_pffd",  0640,   AID_COMPASS,    AID_SYSTEM,     0 },
     { "/dev/msm_pcm_out",   0660,   AID_SYSTEM,     AID_AUDIO,      1 },
     { "/dev/msm_pcm_in",    0660,   AID_SYSTEM,     AID_AUDIO,      1 },
@@ -126,12 +130,17 @@
     { "/dev/msm_mp3",       0660,   AID_SYSTEM,     AID_AUDIO,      1 },
     { "/dev/msm_audpre",    0660,   AID_SYSTEM,     AID_AUDIO,      0 },
     { "/dev/htc-acoustic",  0660,   AID_SYSTEM,     AID_AUDIO,      0 },
+    { "/dev/snd/dsp",       0660,   AID_SYSTEM,     AID_AUDIO,      0 },
+    { "/dev/snd/dsp1",      0660,   AID_SYSTEM,     AID_AUDIO,      0 },
+    { "/dev/snd/mixer",     0660,   AID_SYSTEM,     AID_AUDIO,      0 },
     { "/dev/smd0",          0640,   AID_RADIO,      AID_RADIO,      0 },
     { "/dev/qemu_trace",    0666,   AID_SYSTEM,     AID_SYSTEM,     0 },
     { "/dev/qmi",           0640,   AID_RADIO,      AID_RADIO,      0 },
     { "/dev/qmi0",          0640,   AID_RADIO,      AID_RADIO,      0 },
     { "/dev/qmi1",          0640,   AID_RADIO,      AID_RADIO,      0 },
     { "/dev/qmi2",          0640,   AID_RADIO,      AID_RADIO,      0 },
+        /* CDMA radio interface MUX */
+    { "/dev/ts0710mux",     0640,   AID_RADIO,      AID_RADIO,      1 },
     { "/dev/ppp",           0660,   AID_RADIO,      AID_VPN,        0 },
     { "/dev/tun",           0640,   AID_VPN,        AID_VPN,        0 },
     { NULL, 0, 0, 0, 0 },
@@ -393,6 +402,9 @@
         } else if(!strncmp(uevent->subsystem, "mtd", 3)) {
             base = "/dev/mtd/";
             mkdir(base, 0755);
+        } else if(!strncmp(uevent->subsystem, "sound", 5)) {
+            base = "/dev/snd/";
+            mkdir(base, 0755);
         } else if(!strncmp(uevent->subsystem, "misc", 4) &&
                     !strncmp(name, "log_", 4)) {
             base = "/dev/log/";
diff --git a/init/init.c b/init/init.c
index 0c1ad3f..8c2a058 100644
--- a/init/init.c
+++ b/init/init.c
@@ -255,9 +255,11 @@
             setuid(svc->uid);
         }
 
-        if (!dynamic_args)
-            execve(svc->args[0], (char**) svc->args, (char**) ENV);
-        else {
+        if (!dynamic_args) {
+            if (execve(svc->args[0], (char**) svc->args, (char**) ENV) < 0) {
+                ERROR("cannot execve('%s'): %s\n", svc->args[0], strerror(errno));
+            }
+        } else {
             char *arg_ptrs[SVC_MAXARGS+1];
             int arg_idx = svc->nargs;
             char *tmp = strdup(dynamic_args);
diff --git a/libacc/Android.mk b/libacc/Android.mk
new file mode 100644
index 0000000..f77e2b3
--- /dev/null
+++ b/libacc/Android.mk
@@ -0,0 +1,39 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+# Shared library for target
+# ========================================================
+
+LOCAL_MODULE:= libacc
+LOCAL_SRC_FILES := acc.cpp
+
+ifeq ($(TARGET_ARCH),arm)
+LOCAL_SRC_FILES += disassem.cpp
+endif
+
+LOCAL_SHARED_LIBRARIES := libdl libcutils
+
+include $(BUILD_SHARED_LIBRARY)
+
+# Shared library for host
+# ========================================================
+
+include $(CLEAR_VARS)
+LOCAL_MODULE:= libacc
+LOCAL_SRC_FILES := acc.cpp
+
+LOCAL_CFLAGS := -O0 -g
+
+ifeq ($(TARGET_ARCH),arm)
+LOCAL_SRC_FILES += disassem.cpp
+endif
+
+LOCAL_STATIC_LIBRARIES := libcutils
+LOCAL_LDLIBS := -ldl
+
+include $(BUILD_HOST_SHARED_LIBRARY)
+
+# Build children
+# ========================================================
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/libacc/FEATURES b/libacc/FEATURES
new file mode 100644
index 0000000..1a44415
--- /dev/null
+++ b/libacc/FEATURES
@@ -0,0 +1,65 @@
+
+Supported C language subset (read joint example 'otccex.c' to have
+    an introduction to OTCC dialect):
+
+    - Expressions:
+
+        * binary operators, by decreasing priority order: '*' '/' '%',
+          '+' '-', '>>' '<<', '<' '<=' '>' '>=', '==' '!=', '&',
+          '^', '|', '=', '&&', '||'.
+
+        * '&&' and '||' have the same semantics as C : left to right
+          evaluation and early exit.
+
+        * Parenthesis are supported.
+
+        * Unary operators: '&', '*' (pointer indirection), '-'
+          (negation), '+', '!', '~', post fixed '++' and '--'.
+
+        * Pointer indirection ('*') only works with explicit cast to
+          'char *', 'int *' or 'int (*)()' (function pointer).
+
+        * '++', '--', and unary '&' can only be used with variable
+          lvalue (left value).
+
+        * '=' can only be used with variable or '*' (pointer
+          indirection) lvalue.
+
+        * Function calls are supported with standard i386 calling
+          convention. Function pointers are supported with explicit
+          cast. Functions can be used before being declared.
+
+    - Types: only signed integer ('int') variables and functions can
+      be declared. Variables cannot be initialized in
+      declarations. Only old K&R function declarations are parsed
+      (implicit integer return value and no types on arguments).
+
+    - Any function or variable from the libc can be used because OTCC
+      uses the libc dynamic linker to resolve undefined symbols.
+
+    - Instructions: blocks ('{' '}') are supported as in C. 'if' and
+      'else' can be used for tests. The 'while' and 'for' C constructs
+      are supported for loops. 'break' can be used to exit
+      loops. 'return' is used for the return value of a function.
+
+    - Identifiers are parsed the same way as C. Local variables are
+      handled, but there is no local name space (not a problem if
+      different names are used for local and global variables).
+
+    - Numbers can be entered in decimal, hexadecimal ('0x' or '0X'
+      prefix), or octal ('0' prefix).
+
+    - '#define' is supported without function like arguments. No macro
+      recursion is tolerated. Other preprocessor directives are
+      ignored.
+
+    - C Strings and C character constants are supported. Only '\n',
+      '\"', '\'' and '\\' escapes are recognized.
+
+    - Both C comments ( /* */ ) and C++ comments ( // ... end-of-line ) can be used.
+
+    - No error is displayed if an incorrect program is given.
+
+    - Memory: the code, data, and symbol sizes are limited to 100KB
+      (it can be changed in the source code).
+
diff --git a/libacc/LICENSE b/libacc/LICENSE
new file mode 100644
index 0000000..aea41e0
--- /dev/null
+++ b/libacc/LICENSE
@@ -0,0 +1,21 @@
+ Obfuscated Tiny C Compiler
+
+ Copyright (C) 2001-2003 Fabrice Bellard
+
+ This software is provided 'as-is', without any express or implied
+ warranty.  In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product and its documentation
+ *is* required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+
diff --git a/libacc/MODULE_LICENSE_BSD_LIKE b/libacc/MODULE_LICENSE_BSD_LIKE
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libacc/MODULE_LICENSE_BSD_LIKE
diff --git a/libacc/acc.cpp b/libacc/acc.cpp
new file mode 100644
index 0000000..219a436
--- /dev/null
+++ b/libacc/acc.cpp
@@ -0,0 +1,4813 @@
+/*
+ * Android "Almost" C Compiler.
+ * This is a compiler for a small subset of the C language, intended for use
+ * in scripting environments where speed and memory footprint are important.
+ *
+ * This code is based upon the "unobfuscated" version of the
+ * Obfuscated Tiny C compiler, see the file LICENSE for details.
+ *
+ */
+
+#include <ctype.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <cutils/hashmap.h>
+
+#if defined(__i386__)
+#include <sys/mman.h>
+#endif
+
+#if defined(__arm__)
+#include <unistd.h>
+#endif
+
+#if defined(__arm__)
+#define DEFAULT_ARM_CODEGEN
+#define PROVIDE_ARM_CODEGEN
+#elif defined(__i386__)
+#define DEFAULT_X86_CODEGEN
+#define PROVIDE_X86_CODEGEN
+#elif defined(__x86_64__)
+#define DEFAULT_X64_CODEGEN
+#define PROVIDE_X64_CODEGEN
+#endif
+
+#ifdef PROVIDE_ARM_CODEGEN
+#include "disassem.h"
+#endif
+
+#include <acc/acc.h>
+
+#define LOG_API(...) do {} while(0)
+// #define LOG_API(...) fprintf (stderr, __VA_ARGS__)
+
+#define LOG_STACK(...) do {} while(0)
+// #define LOG_STACK(...) fprintf (stderr, __VA_ARGS__)
+
+// #define ENABLE_ARM_DISASSEMBLY
+// #define PROVIDE_TRACE_CODEGEN
+
+namespace acc {
+
+// Subset of STL vector.
+template<class E> class Vector {
+    public:
+    Vector() {
+        mpBase = 0;
+        mUsed = 0;
+        mSize = 0;
+    }
+
+    ~Vector() {
+        if (mpBase) {
+            for(size_t i = 0; i < mUsed; i++)  {
+                mpBase[mUsed].~E();
+            }
+            free(mpBase);
+        }
+    }
+
+    inline E& operator[](size_t i) {
+        return mpBase[i];
+    }
+
+    inline E& front() {
+        return mpBase[0];
+    }
+
+    inline E& back() {
+        return mpBase[mUsed - 1];
+    }
+
+    void pop_back() {
+        mUsed -= 1;
+        mpBase[mUsed].~E();
+    }
+
+    void push_back(const E& item) {
+        * ensure(1) = item;
+    }
+
+    size_t size() {
+        return mUsed;
+    }
+
+private:
+    E* ensure(int n) {
+        size_t newUsed = mUsed + n;
+        if (newUsed > mSize) {
+            size_t newSize = mSize * 2 + 10;
+            if (newSize < newUsed) {
+                newSize = newUsed;
+            }
+            mpBase = (E*) realloc(mpBase, sizeof(E) * newSize);
+            mSize = newSize;
+        }
+        E* result = mpBase + mUsed;
+        mUsed = newUsed;
+        return result;
+    }
+
+    E* mpBase;
+    size_t mUsed;
+    size_t mSize;
+};
+
+class ErrorSink {
+public:
+    void error(const char *fmt, ...) {
+        va_list ap;
+        va_start(ap, fmt);
+        verror(fmt, ap);
+        va_end(ap);
+    }
+
+    virtual ~ErrorSink() {}
+    virtual void verror(const char* fmt, va_list ap) = 0;
+};
+
+class Compiler : public ErrorSink {
+    typedef int tokenid_t;
+    enum TypeTag {
+        TY_INT, TY_CHAR, TY_VOID, TY_FLOAT, TY_DOUBLE,
+        TY_POINTER, TY_FUNC, TY_PARAM
+    };
+
+    struct Type {
+        TypeTag tag;
+        tokenid_t id; // For function arguments
+        Type* pHead;
+        Type* pTail;
+    };
+
+    class CodeBuf {
+        char* ind; // Output code pointer
+        char* pProgramBase;
+        ErrorSink* mErrorSink;
+        int mSize;
+        bool mOverflowed;
+
+        void release() {
+            if (pProgramBase != 0) {
+                free(pProgramBase);
+                pProgramBase = 0;
+            }
+        }
+
+        bool check(int n) {
+            int newSize = ind - pProgramBase + n;
+            bool overflow = newSize > mSize;
+            if (overflow && !mOverflowed) {
+                mOverflowed = true;
+                if (mErrorSink) {
+                    mErrorSink->error("Code too large: %d bytes", newSize);
+                }
+            }
+            return overflow;
+        }
+
+    public:
+        CodeBuf() {
+            pProgramBase = 0;
+            ind = 0;
+            mErrorSink = 0;
+            mSize = 0;
+            mOverflowed = false;
+        }
+
+        ~CodeBuf() {
+            release();
+        }
+
+        void init(int size) {
+            release();
+            mSize = size;
+            pProgramBase = (char*) calloc(1, size);
+            ind = pProgramBase;
+        }
+
+        void setErrorSink(ErrorSink* pErrorSink) {
+            mErrorSink = pErrorSink;
+        }
+
+        int o4(int n) {
+            if(check(4)) {
+                return 0;
+            }
+            intptr_t result = (intptr_t) ind;
+            * (int*) ind = n;
+            ind += 4;
+            return result;
+        }
+
+        /*
+         * Output a byte. Handles all values, 0..ff.
+         */
+        void ob(int n) {
+            if(check(1)) {
+                return;
+            }
+            *ind++ = n;
+        }
+
+        inline void* getBase() {
+            return (void*) pProgramBase;
+        }
+
+        intptr_t getSize() {
+            return ind - pProgramBase;
+        }
+
+        intptr_t getPC() {
+            return (intptr_t) ind;
+        }
+    };
+
+    /**
+     * A code generator creates an in-memory program, generating the code on
+     * the fly. There is one code generator implementation for each supported
+     * architecture.
+     *
+     * The code generator implements the following abstract machine:
+     * R0 - the accumulator.
+     * FP - a frame pointer for accessing function arguments and local
+     *      variables.
+     * SP - a stack pointer for storing intermediate results while evaluating
+     *      expressions. The stack pointer grows downwards.
+     *
+     * The function calling convention is that all arguments are placed on the
+     * stack such that the first argument has the lowest address.
+     * After the call, the result is in R0. The caller is responsible for
+     * removing the arguments from the stack.
+     * The R0 register is not saved across function calls. The
+     * FP and SP registers are saved.
+     */
+
+    class CodeGenerator {
+    public:
+        CodeGenerator() {
+            mErrorSink = 0;
+            pCodeBuf = 0;
+            pushType();
+        }
+        virtual ~CodeGenerator() {}
+
+        virtual void init(CodeBuf* pCodeBuf) {
+            this->pCodeBuf = pCodeBuf;
+            pCodeBuf->setErrorSink(mErrorSink);
+        }
+
+        virtual void setErrorSink(ErrorSink* pErrorSink) {
+            mErrorSink = pErrorSink;
+            if (pCodeBuf) {
+                pCodeBuf->setErrorSink(mErrorSink);
+            }
+        }
+
+        /* Emit a function prolog.
+         * pDecl is the function declaration, which gives the arguments.
+         * Save the old value of the FP.
+         * Set the new value of the FP.
+         * Convert from the native platform calling convention to
+         * our stack-based calling convention. This may require
+         * pushing arguments from registers to the stack.
+         * Allocate "N" bytes of stack space. N isn't known yet, so
+         * just emit the instructions for adjusting the stack, and return
+         * the address to patch up. The patching will be done in
+         * functionExit().
+         * returns address to patch with local variable size.
+        */
+        virtual int functionEntry(Type* pDecl) = 0;
+
+        /* Emit a function epilog.
+         * Restore the old SP and FP register values.
+         * Return to the calling function.
+         * argCount - the number of arguments to the function.
+         * localVariableAddress - returned from functionEntry()
+         * localVariableSize - the size in bytes of the local variables.
+         */
+        virtual void functionExit(Type* pDecl, int localVariableAddress,
+                                  int localVariableSize) = 0;
+
+        /* load immediate value to R0 */
+        virtual void li(int i, Type* pType) = 0;
+
+        /* Load floating point value from global address. */
+        virtual void loadFloat(int address, Type* pType) = 0;
+
+        /* Jump to a target, and return the address of the word that
+         * holds the target data, in case it needs to be fixed up later.
+         */
+        virtual int gjmp(int t) = 0;
+
+        /* Test R0 and jump to a target if the test succeeds.
+         * l = 0: je, l == 1: jne
+         * Return the address of the word that holds the targed data, in
+         * case it needs to be fixed up later.
+         */
+        virtual int gtst(bool l, int t) = 0;
+
+        /* Compare TOS against R0, and store the boolean result in R0.
+         * Pops TOS.
+         * op specifies the comparison.
+         */
+        virtual void gcmp(int op, Type* pResultType) = 0;
+
+        /* Perform the arithmetic op specified by op. TOS is the
+         * left argument, R0 is the right argument.
+         * Pops TOS.
+         */
+        virtual void genOp(int op) = 0;
+
+        /* Compare 0 against R0, and store the boolean result in R0.
+         * op specifies the comparison.
+         */
+        virtual void gUnaryCmp(int op, Type* pResultType) = 0;
+
+        /* Perform the arithmetic op specified by op. 0 is the
+         * left argument, R0 is the right argument.
+         */
+        virtual void genUnaryOp(int op) = 0;
+
+        /* Push R0 onto the stack.
+         */
+        virtual void pushR0() = 0;
+
+        /* Store R0 to the address stored in TOS.
+         * The TOS is popped.
+         * pPointerType is the type of the pointer (of the input R0).
+         */
+        virtual void storeR0ToTOS(Type* pPointerType) = 0;
+
+        /* Load R0 from the address stored in R0.
+         * pPointerType is the type of the pointer (of the input R0).
+         */
+        virtual void loadR0FromR0(Type* pPointerType) = 0;
+
+        /* Load the absolute address of a variable to R0.
+         * If ea <= LOCAL, then this is a local variable, or an
+         * argument, addressed relative to FP.
+         * else it is an absolute global address.
+         */
+        virtual void leaR0(int ea, Type* pPointerType) = 0;
+
+        /* Store R0 to a variable.
+         * If ea <= LOCAL, then this is a local variable, or an
+         * argument, addressed relative to FP.
+         * else it is an absolute global address.
+         */
+        virtual void storeR0(int ea, Type* pType) = 0;
+
+        /* load R0 from a variable.
+         * If ea <= LOCAL, then this is a local variable, or an
+         * argument, addressed relative to FP.
+         * else it is an absolute global address.
+         * If isIncDec is true, then the stored variable's value
+         * should be post-incremented or post-decremented, based
+         * on the value of op.
+         */
+        virtual void loadR0(int ea, bool isIncDec, int op, Type* pType) = 0;
+
+        /**
+         * Convert R0 to the given type.
+         */
+        virtual void convertR0(Type* pType) = 0;
+
+        /* Emit code to adjust the stack for a function call. Return the
+         * label for the address of the instruction that adjusts the
+         * stack size. This will be passed as argument "a" to
+         * endFunctionCallArguments.
+         */
+        virtual int beginFunctionCallArguments() = 0;
+
+        /* Emit code to store R0 to the stack at byte offset l.
+         * Returns stack size of object (typically 4 or 8 bytes)
+         */
+        virtual size_t storeR0ToArg(int l) = 0;
+
+        /* Patch the function call preamble.
+         * a is the address returned from beginFunctionCallArguments
+         * l is the number of bytes the arguments took on the stack.
+         * Typically you would also emit code to convert the argument
+         * list into whatever the native function calling convention is.
+         * On ARM for example you would pop the first 5 arguments into
+         * R0..R4
+         */
+        virtual void endFunctionCallArguments(Type* pDecl, int a, int l) = 0;
+
+        /* Emit a call to an unknown function. The argument "symbol" needs to
+         * be stored in the location where the address should go. It forms
+         * a chain. The address will be patched later.
+         * Return the address of the word that has to be patched.
+         */
+        virtual int callForward(int symbol, Type* pFunc) = 0;
+
+        /* Call a function using PC-relative addressing. t is the PC-relative
+         * address of the function. It has already been adjusted for the
+         * architectural jump offset, so just store it as-is.
+         */
+        virtual void callRelative(int t, Type* pFunc) = 0;
+
+        /* Call a function pointer. L is the number of bytes the arguments
+         * take on the stack. The address of the function is stored at
+         * location SP + l.
+         */
+        virtual void callIndirect(int l, Type* pFunc) = 0;
+
+        /* Adjust SP after returning from a function call. l is the
+         * number of bytes of arguments stored on the stack. isIndirect
+         * is true if this was an indirect call. (In which case the
+         * address of the function is stored at location SP + l.)
+         */
+        virtual void adjustStackAfterCall(Type* pDecl, int l, bool isIndirect) = 0;
+
+        /* Print a disassembly of the assembled code to out. Return
+         * non-zero if there is an error.
+         */
+        virtual int disassemble(FILE* out) = 0;
+
+        /* Generate a symbol at the current PC. t is the head of a
+         * linked list of addresses to patch.
+         */
+        virtual void gsym(int t) = 0;
+
+        /*
+         * Do any cleanup work required at the end of a compile.
+         * For example, an instruction cache might need to be
+         * invalidated.
+         * Return non-zero if there is an error.
+         */
+        virtual int finishCompile() = 0;
+
+        /**
+         * Adjust relative branches by this amount.
+         */
+        virtual int jumpOffset() = 0;
+
+        /**
+         * Memory alignment (in bytes) for this type of data
+         */
+        virtual size_t alignmentOf(Type* type) = 0;
+
+        /**
+         * Array element alignment (in bytes) for this type of data.
+         */
+        virtual size_t sizeOf(Type* type) = 0;
+
+        /**
+         * Stack argument size of this data type.
+         */
+        virtual size_t stackSizeOf(Type* pType) = 0;
+
+        virtual Type* getR0Type() {
+            return mExpressionStack.back();
+        }
+
+    protected:
+        /*
+         * Output a byte. Handles all values, 0..ff.
+         */
+        void ob(int n) {
+            pCodeBuf->ob(n);
+        }
+
+        intptr_t o4(int data) {
+            return pCodeBuf->o4(data);
+        }
+
+        intptr_t getBase() {
+            return (intptr_t) pCodeBuf->getBase();
+        }
+
+        intptr_t getPC() {
+            return pCodeBuf->getPC();
+        }
+
+        intptr_t getSize() {
+            return pCodeBuf->getSize();
+        }
+
+        void error(const char* fmt,...) {
+            va_list ap;
+            va_start(ap, fmt);
+            mErrorSink->verror(fmt, ap);
+            va_end(ap);
+        }
+
+        void assert(bool test) {
+            if (!test) {
+                * (char*) 0 = 0;
+                error("code generator assertion failed.");
+            }
+        }
+
+        void setR0Type(Type* pType) {
+            mExpressionStack.back() = pType;
+        }
+
+        Type* getTOSType() {
+            return mExpressionStack[mExpressionStack.size()-2];
+        }
+
+        void pushType() {
+            mExpressionStack.push_back(NULL);
+        }
+
+        void popType() {
+            mExpressionStack.pop_back();
+        }
+
+        bool bitsSame(Type* pA, Type* pB) {
+            return collapseType(pA->tag) == collapseType(pB->tag);
+        }
+
+        TypeTag collapseType(TypeTag tag) {
+            static const TypeTag collapsedTag[] = {
+                    TY_INT, TY_INT, TY_VOID, TY_FLOAT, TY_DOUBLE, TY_INT,
+                    TY_VOID, TY_VOID};
+            return collapsedTag[tag];
+        }
+
+        TypeTag collapseTypeR0() {
+            return collapseType(getR0Type()->tag);
+        }
+
+        bool isFloatType(Type* pType) {
+            return isFloatTag(pType->tag);
+        }
+
+        bool isFloatTag(TypeTag tag) {
+            return tag == TY_FLOAT || tag == TY_DOUBLE;
+        }
+
+    private:
+        Vector<Type*> mExpressionStack;
+        CodeBuf* pCodeBuf;
+        ErrorSink* mErrorSink;
+    };
+
+#ifdef PROVIDE_ARM_CODEGEN
+
+    class ARMCodeGenerator : public CodeGenerator {
+    public:
+        ARMCodeGenerator() {}
+
+        virtual ~ARMCodeGenerator() {}
+
+        /* returns address to patch with local variable size
+        */
+        virtual int functionEntry(Type* pDecl) {
+            LOG_API("functionEntry(%d);\n", pDecl);
+            mStackUse = 0;
+            // sp -> arg4 arg5 ...
+            // Push our register-based arguments back on the stack
+            int regArgCount = calcRegArgCount(pDecl);
+            if (regArgCount > 0) {
+                mStackUse += regArgCount * 4;
+                o4(0xE92D0000 | ((1 << regArgCount) - 1)); // stmfd    sp!, {}
+            }
+            // sp -> arg0 arg1 ...
+            o4(0xE92D4800); // stmfd sp!, {fp, lr}
+            mStackUse += 2 * 4;
+            // sp, fp -> oldfp, retadr, arg0 arg1 ....
+            o4(0xE1A0B00D); // mov    fp, sp
+            LOG_STACK("functionEntry: %d\n", mStackUse);
+            return o4(0xE24DD000); // sub    sp, sp, # <local variables>
+            // We don't know how many local variables we are going to use,
+            // but we will round the allocation up to a multiple of
+            // STACK_ALIGNMENT, so it won't affect the stack alignment.
+        }
+
+        virtual void functionExit(Type* pDecl, int localVariableAddress, int localVariableSize) {
+            LOG_API("functionExit(%d, %d, %d);\n", argCount, localVariableAddress, localVariableSize);
+            // Round local variable size up to a multiple of stack alignment
+            localVariableSize = ((localVariableSize + STACK_ALIGNMENT - 1) /
+                STACK_ALIGNMENT) * STACK_ALIGNMENT;
+            // Patch local variable allocation code:
+            if (localVariableSize < 0 || localVariableSize > 255) {
+                error("localVariables out of range: %d", localVariableSize);
+            }
+            *(char*) (localVariableAddress) = localVariableSize;
+
+            // sp -> locals .... fp -> oldfp, retadr, arg0, arg1, ...
+            o4(0xE1A0E00B); // mov lr, fp
+            o4(0xE59BB000); // ldr fp, [fp]
+            o4(0xE28ED004); // add sp, lr, #4
+            // sp -> retadr, arg0, ...
+            o4(0xE8BD4000); // ldmfd    sp!, {lr}
+            // sp -> arg0 ....
+
+            // We store the PC into the lr so we can adjust the sp before
+            // returning. We need to pull off the registers we pushed
+            // earlier. We don't need to actually store them anywhere,
+            // just adjust the stack.
+            int regArgCount = calcRegArgCount(pDecl);
+            if (regArgCount) {
+                o4(0xE28DD000 | (regArgCount << 2)); // add sp, sp, #argCount << 2
+            }
+            o4(0xE12FFF1E); // bx lr
+        }
+
+        /* load immediate value */
+        virtual void li(int t, Type* pType) {
+            LOG_API("li(%d);\n", t);
+            if (t >= 0 && t < 255) {
+                 o4(0xE3A00000 + t); // mov    r0, #0
+            } else if (t >= -256 && t < 0) {
+                // mvn means move constant ^ ~0
+                o4(0xE3E00001 - t); // mvn    r0, #0
+            } else {
+                  o4(0xE51F0000); //         ldr    r0, .L3
+                  o4(0xEA000000); //         b .L99
+                  o4(t);          // .L3:   .word 0
+                                  // .L99:
+            }
+            setR0Type(pType);
+        }
+
+        virtual void loadFloat(int address, Type* pType) {
+            setR0Type(pType);
+            // Global, absolute address
+            o4(0xE59F0000); //        ldr r0, .L1
+            o4(0xEA000000); //        b .L99
+            o4(address);         // .L1:   .word ea
+                                 // .L99:
+
+            switch (pType->tag) {
+            case TY_FLOAT:
+                o4(0xE5900000);      // ldr r0, [r0]
+                break;
+            case TY_DOUBLE:
+                o4(0xE1C000D0);      // ldrd r0, [r0]
+                break;
+            default:
+                assert(false);
+                break;
+            }
+        }
+
+        virtual int gjmp(int t) {
+            LOG_API("gjmp(%d);\n", t);
+            return o4(0xEA000000 | encodeAddress(t)); // b .L33
+        }
+
+        /* l = 0: je, l == 1: jne */
+        virtual int gtst(bool l, int t) {
+            LOG_API("gtst(%d, %d);\n", l, t);
+            Type* pR0Type = getR0Type();
+            TypeTag tagR0 = pR0Type->tag;
+            switch(tagR0) {
+                case TY_FLOAT:
+                    callRuntime((void*) runtime_is_non_zero_f);
+                    break;
+                case TY_DOUBLE:
+                    callRuntime((void*) runtime_is_non_zero_d);
+                    break;
+                default:
+                    break;
+            }
+            o4(0xE3500000); // cmp r0,#0
+            int branch = l ? 0x1A000000 : 0x0A000000; // bne : beq
+            return o4(branch | encodeAddress(t));
+        }
+
+        virtual void gcmp(int op, Type* pResultType) {
+            LOG_API("gcmp(%d);\n", op);
+            Type* pR0Type = getR0Type();
+            Type* pTOSType = getTOSType();
+            TypeTag tagR0 = collapseType(pR0Type->tag);
+            TypeTag tagTOS = collapseType(pTOSType->tag);
+            if (tagR0 == TY_INT && tagTOS == TY_INT) {
+                o4(0xE8BD0002);  // ldmfd   sp!,{r1}
+                mStackUse -= 4;
+                o4(0xE1510000); // cmp r1, r1
+                switch(op) {
+                case OP_EQUALS:
+                    o4(0x03A00001); // moveq r0,#1
+                    o4(0x13A00000); // movne r0,#0
+                    break;
+                case OP_NOT_EQUALS:
+                    o4(0x03A00000); // moveq r0,#0
+                    o4(0x13A00001); // movne r0,#1
+                    break;
+                case OP_LESS_EQUAL:
+                    o4(0xD3A00001); // movle r0,#1
+                    o4(0xC3A00000); // movgt r0,#0
+                    break;
+                case OP_GREATER:
+                    o4(0xD3A00000); // movle r0,#0
+                    o4(0xC3A00001); // movgt r0,#1
+                    break;
+                case OP_GREATER_EQUAL:
+                    o4(0xA3A00001); // movge r0,#1
+                    o4(0xB3A00000); // movlt r0,#0
+                    break;
+                case OP_LESS:
+                    o4(0xA3A00000); // movge r0,#0
+                    o4(0xB3A00001); // movlt r0,#1
+                    break;
+                default:
+                    error("Unknown comparison op %d", op);
+                    break;
+                }
+                popType();
+            } else if (tagR0 == TY_DOUBLE || tagTOS == TY_DOUBLE) {
+                setupDoubleArgs();
+                switch(op) {
+                    case OP_EQUALS:
+                        callRuntime((void*) runtime_cmp_eq_dd);
+                        break;
+                    case OP_NOT_EQUALS:
+                        callRuntime((void*) runtime_cmp_ne_dd);
+                        break;
+                    case OP_LESS_EQUAL:
+                        callRuntime((void*) runtime_cmp_le_dd);
+                        break;
+                    case OP_GREATER:
+                        callRuntime((void*) runtime_cmp_gt_dd);
+                        break;
+                    case OP_GREATER_EQUAL:
+                        callRuntime((void*) runtime_cmp_ge_dd);
+                        break;
+                    case OP_LESS:
+                        callRuntime((void*) runtime_cmp_lt_dd);
+                        break;
+                    default:
+                        error("Unknown comparison op %d", op);
+                        break;
+                }
+            } else {
+                setupFloatArgs();
+                switch(op) {
+                    case OP_EQUALS:
+                        callRuntime((void*) runtime_cmp_eq_ff);
+                        break;
+                    case OP_NOT_EQUALS:
+                        callRuntime((void*) runtime_cmp_ne_ff);
+                        break;
+                    case OP_LESS_EQUAL:
+                        callRuntime((void*) runtime_cmp_le_ff);
+                        break;
+                    case OP_GREATER:
+                        callRuntime((void*) runtime_cmp_gt_ff);
+                        break;
+                    case OP_GREATER_EQUAL:
+                        callRuntime((void*) runtime_cmp_ge_ff);
+                        break;
+                    case OP_LESS:
+                        callRuntime((void*) runtime_cmp_lt_ff);
+                        break;
+                    default:
+                        error("Unknown comparison op %d", op);
+                        break;
+                }
+            }
+            setR0Type(pResultType);
+        }
+
+        virtual void genOp(int op) {
+            LOG_API("genOp(%d);\n", op);
+            Type* pR0Type = getR0Type();
+            Type* pTOSType = getTOSType();
+            TypeTag tagR0 = collapseType(pR0Type->tag);
+            TypeTag tagTOS = collapseType(pTOSType->tag);
+            if (tagR0 == TY_INT && tagTOS == TY_INT) {
+                o4(0xE8BD0002);  // ldmfd   sp!,{r1}
+                mStackUse -= 4;
+                switch(op) {
+                case OP_MUL:
+                    o4(0x0E0000091); // mul     r0,r1,r0
+                    break;
+                case OP_DIV:
+                    callRuntime((void*) runtime_DIV);
+                    break;
+                case OP_MOD:
+                    callRuntime((void*) runtime_MOD);
+                    break;
+                case OP_PLUS:
+                    o4(0xE0810000);  // add     r0,r1,r0
+                    break;
+                case OP_MINUS:
+                    o4(0xE0410000);  // sub     r0,r1,r0
+                    break;
+                case OP_SHIFT_LEFT:
+                    o4(0xE1A00011);  // lsl     r0,r1,r0
+                    break;
+                case OP_SHIFT_RIGHT:
+                    o4(0xE1A00051);  // asr     r0,r1,r0
+                    break;
+                case OP_BIT_AND:
+                    o4(0xE0010000);  // and     r0,r1,r0
+                    break;
+                case OP_BIT_XOR:
+                    o4(0xE0210000);  // eor     r0,r1,r0
+                    break;
+                case OP_BIT_OR:
+                    o4(0xE1810000);  // orr     r0,r1,r0
+                    break;
+                case OP_BIT_NOT:
+                    o4(0xE1E00000);  // mvn     r0, r0
+                    break;
+                default:
+                    error("Unimplemented op %d\n", op);
+                    break;
+                }
+                popType();
+            } else {
+                Type* pResultType = tagR0 > tagTOS ? pR0Type : pTOSType;
+                if (pResultType->tag == TY_DOUBLE) {
+                    setupDoubleArgs();
+                    switch(op) {
+                    case OP_MUL:
+                        callRuntime((void*) runtime_op_mul_dd);
+                        break;
+                    case OP_DIV:
+                        callRuntime((void*) runtime_op_div_dd);
+                        break;
+                    case OP_PLUS:
+                        callRuntime((void*) runtime_op_add_dd);
+                        break;
+                    case OP_MINUS:
+                        callRuntime((void*) runtime_op_sub_dd);
+                        break;
+                    default:
+                        error("Unsupported binary floating operation %d\n", op);
+                        break;
+                    }
+                } else {
+                    setupFloatArgs();
+                    switch(op) {
+                    case OP_MUL:
+                        callRuntime((void*) runtime_op_mul_ff);
+                        break;
+                    case OP_DIV:
+                        callRuntime((void*) runtime_op_div_ff);
+                        break;
+                    case OP_PLUS:
+                        callRuntime((void*) runtime_op_add_ff);
+                        break;
+                    case OP_MINUS:
+                        callRuntime((void*) runtime_op_sub_ff);
+                        break;
+                    default:
+                        error("Unsupported binary floating operation %d\n", op);
+                        break;
+                    }
+                }
+                setR0Type(pResultType);
+            }
+        }
+
+        virtual void gUnaryCmp(int op, Type* pResultType) {
+            LOG_API("gUnaryCmp(%d);\n", op);
+            if (op != OP_LOGICAL_NOT) {
+                error("Unknown unary cmp %d", op);
+            } else {
+                Type* pR0Type = getR0Type();
+                TypeTag tag = collapseType(pR0Type->tag);
+                switch(tag) {
+                    case TY_INT:
+                        o4(0xE3A01000); // mov    r1, #0
+                        o4(0xE1510000); // cmp r1, r1
+                        o4(0x03A00000); // moveq r0,#0
+                        o4(0x13A00001); // movne r0,#1
+                        break;
+                    case TY_FLOAT:
+                        callRuntime((void*) runtime_is_zero_f);
+                        break;
+                    case TY_DOUBLE:
+                        callRuntime((void*) runtime_is_zero_d);
+                        break;
+                    default:
+                        error("gUnaryCmp unsupported type");
+                        break;
+                }
+            }
+            setR0Type(pResultType);
+        }
+
+        virtual void genUnaryOp(int op) {
+            LOG_API("genOp(%d);\n", op);
+            Type* pR0Type = getR0Type();
+            TypeTag tag = collapseType(pR0Type->tag);
+            switch(tag) {
+                case TY_INT:
+                    switch(op) {
+                    case OP_MINUS:
+                        o4(0xE3A01000);  // mov    r1, #0
+                        o4(0xE0410000);  // sub     r0,r1,r0
+                        break;
+                    case OP_BIT_NOT:
+                        o4(0xE1E00000);  // mvn     r0, r0
+                        break;
+                    default:
+                        error("Unknown unary op %d\n", op);
+                        break;
+                    }
+                    break;
+                case TY_FLOAT:
+                case TY_DOUBLE:
+                    switch (op) {
+                        case OP_MINUS:
+                            if (tag == TY_FLOAT) {
+                                callRuntime((void*) runtime_op_neg_f);
+                            } else {
+                                callRuntime((void*) runtime_op_neg_d);
+                            }
+                            break;
+                        case OP_BIT_NOT:
+                            error("Can't apply '~' operator to a float or double.");
+                            break;
+                        default:
+                            error("Unknown unary op %d\n", op);
+                            break;
+                        }
+                    break;
+                default:
+                    error("genUnaryOp unsupported type");
+                    break;
+            }
+        }
+
+        virtual void pushR0() {
+            LOG_API("pushR0();\n");
+            Type* pR0Type = getR0Type();
+            TypeTag r0ct = collapseType(pR0Type->tag);
+            if (r0ct != TY_DOUBLE) {
+                    o4(0xE92D0001);  // stmfd   sp!,{r0}
+                    mStackUse += 4;
+            } else {
+                    o4(0xE92D0003);  // stmfd   sp!,{r0,r1}
+                    mStackUse += 8;
+            }
+            pushType();
+            LOG_STACK("pushR0: %d\n", mStackUse);
+        }
+
+        virtual void storeR0ToTOS(Type* pPointerType) {
+            LOG_API("storeR0ToTOS(%d);\n", isInt);
+            assert(pPointerType->tag == TY_POINTER);
+            o4(0xE8BD0004);  // ldmfd   sp!,{r2}
+            popType();
+            mStackUse -= 4;
+            switch (pPointerType->pHead->tag) {
+                case TY_INT:
+                case TY_FLOAT:
+                    o4(0xE5820000); // str r0, [r2]
+                    break;
+                case TY_CHAR:
+                    o4(0xE5C20000); // strb r0, [r2]
+                    break;
+                case TY_DOUBLE:
+                    o4(0xE1C200F0); // strd r0, [r2]
+                    break;
+                default:
+                    error("storeR0ToTOS: unimplemented type");
+                    break;
+            }
+        }
+
+        virtual void loadR0FromR0(Type* pPointerType) {
+            LOG_API("loadR0FromR0(%d);\n", pPointerType);
+            assert(pPointerType->tag == TY_POINTER);
+            switch (pPointerType->pHead->tag) {
+                case TY_INT:
+                case TY_FLOAT:
+                    o4(0xE5900000); // ldr r0, [r0]
+                    break;
+                case TY_CHAR:
+                    o4(0xE5D00000); // ldrb r0, [r0]
+                    break;
+                case TY_DOUBLE:
+                    o4(0xE1C000D0); // ldrd r0, [r0]
+                    break;
+                default:
+                    error("loadR0FromR0: unimplemented type");
+                    break;
+            }
+            setR0Type(pPointerType->pHead);
+        }
+
+        virtual void leaR0(int ea, Type* pPointerType) {
+            LOG_API("leaR0(%d);\n", ea);
+            if (ea > -LOCAL && ea < LOCAL) {
+                // Local, fp relative
+                if (ea < -1023 || ea > 1023 || ((ea & 3) != 0)) {
+                    error("Offset out of range: %08x", ea);
+                }
+                if (ea < 0) {
+                    o4(0xE24B0F00 | (0xff & ((-ea) >> 2))); // sub    r0, fp, #ea
+                } else {
+                    o4(0xE28B0F00 | (0xff & (ea >> 2))); // add    r0, fp, #ea
+                }
+            } else {
+                // Global, absolute.
+                o4(0xE59F0000); //        ldr    r0, .L1
+                o4(0xEA000000); //        b .L99
+                o4(ea);         // .L1:   .word 0
+                                // .L99:
+            }
+            setR0Type(pPointerType);
+        }
+
+        virtual void storeR0(int ea, Type* pType) {
+            LOG_API("storeR0(%d);\n", ea);
+            TypeTag tag = pType->tag;
+            switch (tag) {
+                case TY_INT:
+                case TY_FLOAT:
+                    if (ea > -LOCAL && ea < LOCAL) {
+                        // Local, fp relative
+                        if (ea < -4095 || ea > 4095) {
+                            error("Offset out of range: %08x", ea);
+                        }
+                        if (ea < 0) {
+                            o4(0xE50B0000 | (0xfff & (-ea))); // str r0, [fp,#-ea]
+                        } else {
+                            o4(0xE58B0000 | (0xfff & ea)); // str r0, [fp,#ea]
+                        }
+                    } else{
+                        // Global, absolute
+                        o4(0xE59F1000); //         ldr r1, .L1
+                        o4(0xEA000000); //         b .L99
+                        o4(ea);         // .L1:    .word 0
+                        o4(0xE5810000); // .L99:   str r0, [r1]
+                    }
+                    break;
+                case TY_DOUBLE:
+                    if ((ea & 0x7) != 0) {
+                        error("double address is not aligned: %d", ea);
+                    }
+                    if (ea > -LOCAL && ea < LOCAL) {
+                        // Local, fp relative
+                        if (ea < -4095 || ea > 4095) {
+                            error("Offset out of range: %08x", ea);
+                        }
+                        if (ea < 0) {
+                            o4(0xE50B0000 | (0xfff & (-ea))); // str r0, [fp,#-ea]
+                            o4(0xE50B1000 | (0xfff & (-ea + 4))); // str r1, [fp,#-ea+4]
+#if 0
+                            // strd doesn't seem to work. Is encoding wrong?
+                        } else if (ea < 0) {
+                            o4(0xE1CB000F | ((0xff & (-ea)) << 4)); // strd r0, [fp,#-ea]
+                        } else if (ea < 256) {
+                            o4(0xE14B000F | ((0xff & ea) << 4)); // strd r0, [fp,#ea]
+#endif
+                        } else {
+                            o4(0xE58B0000 | (0xfff & ea)); // str r0, [fp,#ea]
+                            o4(0xE58B1000 | (0xfff & (ea + 4))); // str r1, [fp,#ea+4]
+                        }
+                    } else{
+                        // Global, absolute
+                        o4(0xE59F2000); //         ldr r2, .L1
+                        o4(0xEA000000); //         b .L99
+                        o4(ea);         // .L1:    .word 0
+                        o4(0xE1C200F0); // .L99:   strd r0, [r2]
+                    }
+                    break;
+                default:
+                    error("Unable to store to type %d", tag);
+                    break;
+            }
+        }
+
+        virtual void loadR0(int ea, bool isIncDec, int op, Type* pType) {
+            LOG_API("loadR0(%d, %d, %d, %d);\n", ea, isIncDec, op, pType);
+            TypeTag tag = collapseType(pType->tag);
+            switch (tag) {
+                case TY_INT:
+                case TY_FLOAT:
+                    if (ea < LOCAL) {
+                        // Local, fp relative
+                        if (ea < -4095 || ea > 4095) {
+                            error("Offset out of range: %08x", ea);
+                        }
+                        if (ea < 0) {
+                            o4(0xE51B0000 | (0xfff & (-ea))); // ldr r0, [fp,#-ea]
+                        } else {
+                            o4(0xE59B0000 | (0xfff & ea));    // ldr r0, [fp,#ea]
+                        }
+                    } else {
+                        // Global, absolute
+                        o4(0xE59F2000); //        ldr r2, .L1
+                        o4(0xEA000000); //        b .L99
+                        o4(ea);         // .L1:   .word ea
+                        o4(0xE5920000); // .L99:  ldr r0, [r2]
+                    }
+
+                    if (isIncDec) {
+                        if (tag == TY_INT) {
+                            switch (op) {
+                            case OP_INCREMENT:
+                                o4(0xE2801001); // add r1, r0, #1
+                                break;
+                            case OP_DECREMENT:
+                                o4(0xE2401001); // sub r1, r0, #1
+                                break;
+                            default:
+                                error("unknown opcode: %d", op);
+                            }
+                            if (ea < LOCAL) {
+                                // Local, fp relative
+                                // Don't need range check, was already checked above
+                                if (ea < 0) {
+                                    o4(0xE50B1000 | (0xfff & (-ea))); // str r1, [fp,#-ea]
+                                } else {
+                                    o4(0xE58B1000 | (0xfff & ea));    // str r1, [fp,#ea]
+                                }
+                            } else{
+                                // Global, absolute
+                                // r2 is already set up from before.
+                                o4(0xE5821000); // str r1, [r2]
+                           }
+                        }
+                        else {
+                            error("inc/dec not implemented for float.");
+                        }
+                    }
+                    break;
+                case TY_DOUBLE:
+                    if ((ea & 0x7) != 0) {
+                        error("double address is not aligned: %d", ea);
+                    }
+                    if (ea < LOCAL) {
+                        // Local, fp relative
+                        if (ea < -4095 || ea > 4095) {
+                            error("Offset out of range: %08x", ea);
+                        }
+                        if (ea < 0) {
+                            o4(0xE51B0000 | (0xfff & (-ea))); // ldr r0, [fp,#-ea]
+                            o4(0xE51B1000 | (0xfff & (-ea+4))); // ldr r1, [fp,#-ea+4]
+                        } else {
+                            o4(0xE59B0000 | (0xfff & ea));    // ldr r0, [fp,#ea]
+                            o4(0xE59B1000 | (0xfff & (ea+4)));    // ldr r0, [fp,#ea+4]
+                        }
+                    } else {
+                        // Global, absolute
+                        o4(0xE59F2000); //        ldr r2, .L1
+                        o4(0xEA000000); //        b .L99
+                        o4(ea);         // .L1:   .word ea
+                        o4(0xE1C200D0); // .L99:  ldrd r0, [r2]
+                    }
+                    break;
+                default:
+                    error("Unable to load type %d", tag);
+                    break;
+            }
+            setR0Type(pType);
+        }
+
+        virtual void convertR0(Type* pType){
+            Type* pR0Type = getR0Type();
+            if (bitsSame(pType, pR0Type)) {
+                // do nothing special
+            } else {
+                TypeTag r0Tag = collapseType(pR0Type->tag);
+                TypeTag destTag = collapseType(pType->tag);
+                if (r0Tag == TY_INT) {
+                    if (destTag == TY_FLOAT) {
+                        callRuntime((void*) runtime_int_to_float);
+                    } else {
+                        assert(destTag == TY_DOUBLE);
+                        callRuntime((void*) runtime_int_to_double);
+                    }
+                } else if (r0Tag == TY_FLOAT) {
+                    if (destTag == TY_INT) {
+                        callRuntime((void*) runtime_float_to_int);
+                    } else {
+                        assert(destTag == TY_DOUBLE);
+                        callRuntime((void*) runtime_float_to_double);
+                    }
+                } else {
+                    assert (r0Tag == TY_DOUBLE);
+                    if (destTag == TY_INT) {
+                        callRuntime((void*) runtime_double_to_int);
+                    } else {
+                        assert(destTag == TY_FLOAT);
+                        callRuntime((void*) runtime_double_to_float);
+                    }
+                }
+            }
+            setR0Type(pType);
+        }
+
+        virtual int beginFunctionCallArguments() {
+            LOG_API("beginFunctionCallArguments();\n");
+            return o4(0xE24DDF00); // Placeholder
+        }
+
+        virtual size_t storeR0ToArg(int l) {
+            LOG_API("storeR0ToArg(%d);\n", l);
+            Type* pR0Type = getR0Type();
+            TypeTag r0ct = collapseType(pR0Type->tag);
+            switch(r0ct) {
+                case TY_INT:
+                case TY_FLOAT:
+                    if (l < 0 || l > 4096-4) {
+                        error("l out of range for stack offset: 0x%08x", l);
+                    }
+                    o4(0xE58D0000 + l); // str r0, [sp, #l]
+                    return 4;
+                case TY_DOUBLE: {
+                    // Align to 8 byte boundary
+                    int l2 = (l + 7) & ~7;
+                    if (l2 < 0 || l2 > 4096-8) {
+                        error("l out of range for stack offset: 0x%08x", l);
+                    }
+                    o4(0xE58D0000 + l2); // str r0, [sp, #l]
+                    o4(0xE58D1000 + l2 + 4); // str r1, [sp, #l+4]
+                    return (l2 - l) + 8;
+                }
+                default:
+                    assert(false);
+                    return 0;
+            }
+        }
+
+        virtual void endFunctionCallArguments(Type* pDecl, int a, int l) {
+            LOG_API("endFunctionCallArguments(0x%08x, %d);\n", a, l);
+            int argumentStackUse = l;
+            // Have to calculate register arg count from actual stack size,
+            // in order to properly handle ... functions.
+            int regArgCount = l >> 2;
+            if (regArgCount > 4) {
+                regArgCount = 4;
+            }
+            if (regArgCount > 0) {
+                argumentStackUse -= regArgCount * 4;
+                o4(0xE8BD0000 | ((1 << regArgCount) - 1)); // ldmfd   sp!,{}
+            }
+            mStackUse += argumentStackUse;
+
+            // Align stack.
+            int missalignment = mStackUse - ((mStackUse / STACK_ALIGNMENT)
+                    * STACK_ALIGNMENT);
+            mStackAlignmentAdjustment = 0;
+            if (missalignment > 0) {
+                mStackAlignmentAdjustment = STACK_ALIGNMENT - missalignment;
+            }
+            l += mStackAlignmentAdjustment;
+
+            if (l < 0 || l > 0x3FC) {
+                error("L out of range for stack adjustment: 0x%08x", l);
+            }
+            * (int*) a = 0xE24DDF00 | (l >> 2); // sub    sp, sp, #0 << 2
+            mStackUse += mStackAlignmentAdjustment;
+            LOG_STACK("endFunctionCallArguments mStackUse: %d, mStackAlignmentAdjustment %d\n",
+                      mStackUse, mStackAlignmentAdjustment);
+        }
+
+        virtual int callForward(int symbol, Type* pFunc) {
+            LOG_API("callForward(%d);\n", symbol);
+            setR0Type(pFunc->pHead);
+            // Forward calls are always short (local)
+            return o4(0xEB000000 | encodeAddress(symbol));
+        }
+
+        virtual void callRelative(int t, Type* pFunc) {
+            LOG_API("callRelative(%d);\n", t);
+            setR0Type(pFunc->pHead);
+            int abs = t + getPC() + jumpOffset();
+            LOG_API("abs=%d (0x%08x)\n", abs, abs);
+            if (t >= - (1 << 25) && t < (1 << 25)) {
+                o4(0xEB000000 | encodeAddress(t));
+            } else {
+                // Long call.
+                o4(0xE59FC000); //         ldr    r12, .L1
+                o4(0xEA000000); //         b .L99
+                o4(t - 12);     // .L1:    .word 0
+                o4(0xE08CC00F); // .L99:   add r12,pc
+                o4(0xE12FFF3C); //         blx r12
+           }
+        }
+
+        virtual void callIndirect(int l, Type* pFunc) {
+            LOG_API("callIndirect(%d);\n", l);
+            setR0Type(pFunc->pHead);
+            int argCount = l >> 2;
+            int poppedArgs = argCount > 4 ? 4 : argCount;
+            int adjustedL = l - (poppedArgs << 2) + mStackAlignmentAdjustment;
+            if (adjustedL < 0 || adjustedL > 4096-4) {
+                error("l out of range for stack offset: 0x%08x", l);
+            }
+            o4(0xE59DC000 | (0xfff & adjustedL)); // ldr    r12, [sp,#adjustedL]
+            o4(0xE12FFF3C); // blx r12
+        }
+
+        virtual void adjustStackAfterCall(Type* pDecl, int l, bool isIndirect) {
+            LOG_API("adjustStackAfterCall(%d, %d);\n", l, isIndirect);
+            int argCount = l >> 2;
+            // Have to calculate register arg count from actual stack size,
+            // in order to properly handle ... functions.
+            int regArgCount = l >> 2;
+            if (regArgCount > 4) {
+                regArgCount = 4;
+            }
+            int stackArgs = argCount - regArgCount;
+            int stackUse =  stackArgs + (isIndirect ? 1 : 0)
+                + (mStackAlignmentAdjustment >> 2);
+            if (stackUse) {
+                if (stackUse < 0 || stackUse > 255) {
+                    error("L out of range for stack adjustment: 0x%08x", l);
+                }
+                o4(0xE28DDF00 | stackUse); // add    sp, sp, #stackUse << 2
+                mStackUse -= stackUse * 4;
+                LOG_STACK("adjustStackAfterCall: %d\n", mStackUse);
+            }
+        }
+
+        virtual int jumpOffset() {
+            return 8;
+        }
+
+        /* output a symbol and patch all calls to it */
+        virtual void gsym(int t) {
+            LOG_API("gsym(0x%x)\n", t);
+            int n;
+            int base = getBase();
+            int pc = getPC();
+            LOG_API("pc = 0x%x\n", pc);
+            while (t) {
+                int data = * (int*) t;
+                int decodedOffset = ((BRANCH_REL_ADDRESS_MASK & data) << 2);
+                if (decodedOffset == 0) {
+                    n = 0;
+                } else {
+                    n = base + decodedOffset; /* next value */
+                }
+                *(int *) t = (data & ~BRANCH_REL_ADDRESS_MASK)
+                    | encodeRelAddress(pc - t - 8);
+                t = n;
+            }
+        }
+
+        virtual int finishCompile() {
+#if defined(__arm__)
+            const long base = long(getBase());
+            const long curr = long(getPC());
+            int err = cacheflush(base, curr, 0);
+            return err;
+#else
+            return 0;
+#endif
+        }
+
+        virtual int disassemble(FILE* out) {
+#ifdef ENABLE_ARM_DISASSEMBLY
+            disasmOut = out;
+            disasm_interface_t  di;
+            di.di_readword = disassemble_readword;
+            di.di_printaddr = disassemble_printaddr;
+            di.di_printf = disassemble_printf;
+
+            int base = getBase();
+            int pc = getPC();
+            for(int i = base; i < pc; i += 4) {
+                fprintf(out, "%08x: %08x  ", i, *(int*) i);
+                ::disasm(&di, i, 0);
+            }
+#endif
+            return 0;
+        }
+
+        /**
+         * alignment (in bytes) for this type of data
+         */
+        virtual size_t alignmentOf(Type* pType){
+            switch(pType->tag) {
+                case TY_DOUBLE:
+                    return 8;
+                default:
+                    return 4;
+            }
+        }
+
+        /**
+         * Array element alignment (in bytes) for this type of data.
+         */
+        virtual size_t sizeOf(Type* pType){
+            switch(pType->tag) {
+                case TY_INT:
+                    return 4;
+                case TY_CHAR:
+                    return 1;
+                default:
+                    return 0;
+                case TY_FLOAT:
+                    return 4;
+                case TY_DOUBLE:
+                    return 8;
+                case TY_POINTER:
+                    return 4;
+            }
+        }
+
+        virtual size_t stackSizeOf(Type* pType) {
+            switch(pType->tag) {
+                case TY_DOUBLE:
+                    return 8;
+                default:
+                    return 4;
+            }
+        }
+
+    private:
+        static FILE* disasmOut;
+
+        static u_int
+        disassemble_readword(u_int address)
+        {
+            return(*((u_int *)address));
+        }
+
+        static void
+        disassemble_printaddr(u_int address)
+        {
+            fprintf(disasmOut, "0x%08x", address);
+        }
+
+        static void
+        disassemble_printf(const char *fmt, ...) {
+            va_list ap;
+            va_start(ap, fmt);
+            vfprintf(disasmOut, fmt, ap);
+            va_end(ap);
+        }
+
+        static const int BRANCH_REL_ADDRESS_MASK = 0x00ffffff;
+
+        /** Encode a relative address that might also be
+         * a label.
+         */
+        int encodeAddress(int value) {
+            int base = getBase();
+            if (value >= base && value <= getPC() ) {
+                // This is a label, encode it relative to the base.
+                value = value - base;
+            }
+            return encodeRelAddress(value);
+        }
+
+        int encodeRelAddress(int value) {
+            return BRANCH_REL_ADDRESS_MASK & (value >> 2);
+        }
+
+        int calcRegArgCount(Type* pDecl) {
+            int reg = 0;
+            Type* pArgs = pDecl->pTail;
+            while (pArgs && reg < 4) {
+                Type* pArg = pArgs->pHead;
+                if ( pArg->tag == TY_DOUBLE) {
+                    int evenReg = (reg + 1) & ~1;
+                    if (evenReg >= 4) {
+                        break;
+                    }
+                    reg = evenReg + 2;
+                } else {
+                    reg++;
+                }
+                pArgs = pArgs->pTail;
+            }
+            return reg;
+        }
+
+        /* Pop TOS to R1
+         * Make sure both R0 and TOS are floats. (Could be ints)
+         * We know that at least one of R0 and TOS is already a float
+         */
+        void setupFloatArgs() {
+            Type* pR0Type = getR0Type();
+            Type* pTOSType = getTOSType();
+            TypeTag tagR0 = collapseType(pR0Type->tag);
+            TypeTag tagTOS = collapseType(pTOSType->tag);
+            if (tagR0 != TY_FLOAT) {
+                assert(tagR0 == TY_INT);
+                callRuntime((void*) runtime_int_to_float);
+            }
+            if (tagTOS != TY_FLOAT) {
+                assert(tagTOS == TY_INT);
+                assert(tagR0 == TY_FLOAT);
+                o4(0xE92D0001);  // stmfd   sp!,{r0}  // push R0
+                o4(0xE59D0004);  // ldr     r0, [sp, #4]
+                callRuntime((void*) runtime_int_to_float);
+                o4(0xE1A01000);  // mov r1, r0
+                o4(0xE8BD0001);  // ldmfd   sp!,{r0}  // pop R0
+                o4(0xE28DD004);  // add sp, sp, #4 // Pop sp
+            } else {
+                // Pop TOS
+                o4(0xE8BD0002);  // ldmfd   sp!,{r1}
+            }
+            mStackUse -= 4;
+            popType();
+        }
+
+        /* Pop TOS into R2..R3
+         * Make sure both R0 and TOS are doubles. Could be floats or ints.
+         * We know that at least one of R0 and TOS are already a double.
+         */
+
+        void setupDoubleArgs() {
+            Type* pR0Type = getR0Type();
+            Type* pTOSType = getTOSType();
+            TypeTag tagR0 = collapseType(pR0Type->tag);
+            TypeTag tagTOS = collapseType(pTOSType->tag);
+            if (tagR0 != TY_DOUBLE) {
+                if (tagR0 == TY_INT) {
+                    callRuntime((void*) runtime_int_to_double);
+                } else {
+                    assert(tagR0 == TY_FLOAT);
+                    callRuntime((void*) runtime_float_to_double);
+                }
+            }
+            if (tagTOS != TY_DOUBLE) {
+                o4(0xE92D0003);  // stmfd   sp!,{r0,r1}  // push r0,r1
+                o4(0xE59D0008);  // ldr     r0, [sp, #8]
+                if (tagTOS == TY_INT) {
+                    callRuntime((void*) runtime_int_to_double);
+                } else {
+                    assert(tagTOS == TY_FLOAT);
+                    callRuntime((void*) runtime_float_to_double);
+                }
+                o4(0xE1A02000);  // mov r2, r0
+                o4(0xE1A03001);  // mov r3, r1
+                o4(0xE8BD0003);  // ldmfd   sp!,{r0, r1}  // Restore R0
+                o4(0xE28DD004);  // add sp, sp, #4 // Pop sp
+                mStackUse -= 4;
+            } else {
+                o4(0xE8BD000C);  // ldmfd   sp!,{r2,r3}
+                mStackUse -= 8;
+            }
+            popType();
+        }
+
+        void callRuntime(void* fn) {
+            o4(0xE59FC000); // ldr    r12, .L1
+            o4(0xEA000000); // b      .L99
+            o4((int) fn);   //.L1:  .word  fn
+            o4(0xE12FFF3C); //.L99: blx    r12
+        }
+
+        // Integer math:
+
+        static int runtime_DIV(int b, int a) {
+            return a / b;
+        }
+
+        static int runtime_MOD(int b, int a) {
+            return a % b;
+        }
+
+        // Comparison to zero
+
+        static int runtime_is_non_zero_f(float a) {
+            return a != 0;
+        }
+
+        static int runtime_is_non_zero_d(double a) {
+            return a != 0;
+        }
+
+        // Comparison to zero
+
+        static int runtime_is_zero_f(float a) {
+            return a == 0;
+        }
+
+        static int runtime_is_zero_d(double a) {
+            return a == 0;
+        }
+
+        // Type conversion
+
+        static int runtime_float_to_int(float a) {
+            return (int) a;
+        }
+
+        static double runtime_float_to_double(float a) {
+            return (double) a;
+        }
+
+        static int runtime_double_to_int(double a) {
+            return (int) a;
+        }
+
+        static float runtime_double_to_float(double a) {
+            return (float) a;
+        }
+
+        static float runtime_int_to_float(int a) {
+            return (float) a;
+        }
+
+        static double runtime_int_to_double(int a) {
+            return (double) a;
+        }
+
+        // Comparisons float
+
+        static int runtime_cmp_eq_ff(float b, float a) {
+            return a == b;
+        }
+
+        static int runtime_cmp_ne_ff(float b, float a) {
+            return a != b;
+        }
+
+        static int runtime_cmp_lt_ff(float b, float a) {
+            return a < b;
+        }
+
+        static int runtime_cmp_le_ff(float b, float a) {
+            return a <= b;
+        }
+
+        static int runtime_cmp_ge_ff(float b, float a) {
+            return a >= b;
+        }
+
+        static int runtime_cmp_gt_ff(float b, float a) {
+            return a > b;
+        }
+
+        // Comparisons double
+
+        static int runtime_cmp_eq_dd(double b, double a) {
+            return a == b;
+        }
+
+        static int runtime_cmp_ne_dd(double b, double a) {
+            return a != b;
+        }
+
+        static int runtime_cmp_lt_dd(double b, double a) {
+            return a < b;
+        }
+
+        static int runtime_cmp_le_dd(double b, double a) {
+            return a <= b;
+        }
+
+        static int runtime_cmp_ge_dd(double b, double a) {
+            return a >= b;
+        }
+
+        static int runtime_cmp_gt_dd(double b, double a) {
+            return a > b;
+        }
+
+        // Math float
+
+        static float runtime_op_add_ff(float b, float a) {
+            return a + b;
+        }
+
+        static float runtime_op_sub_ff(float b, float a) {
+            return a - b;
+        }
+
+        static float runtime_op_mul_ff(float b, float a) {
+            return a * b;
+        }
+
+        static float runtime_op_div_ff(float b, float a) {
+            return a / b;
+        }
+
+        static float runtime_op_neg_f(float a) {
+            return -a;
+        }
+
+        // Math double
+
+        static double runtime_op_add_dd(double b, double a) {
+            return a + b;
+        }
+
+        static double runtime_op_sub_dd(double b, double a) {
+            return a - b;
+        }
+
+        static double runtime_op_mul_dd(double b, double a) {
+            return a * b;
+        }
+
+        static double runtime_op_div_dd(double b, double a) {
+            return a / b;
+        }
+
+        static double runtime_op_neg_d(double a) {
+            return -a;
+        }
+
+        static const int STACK_ALIGNMENT = 8;
+        int mStackUse;
+        // This variable holds the amount we adjusted the stack in the most
+        // recent endFunctionCallArguments call. It's examined by the
+        // following adjustStackAfterCall call.
+        int mStackAlignmentAdjustment;
+    };
+
+#endif // PROVIDE_ARM_CODEGEN
+
+#ifdef PROVIDE_X86_CODEGEN
+
+    class X86CodeGenerator : public CodeGenerator {
+    public:
+        X86CodeGenerator() {}
+        virtual ~X86CodeGenerator() {}
+
+        /* returns address to patch with local variable size
+        */
+        virtual int functionEntry(Type* pDecl) {
+            o(0xe58955); /* push   %ebp, mov %esp, %ebp */
+            return oad(0xec81, 0); /* sub $xxx, %esp */
+        }
+
+        virtual void functionExit(Type* pDecl, int localVariableAddress, int localVariableSize) {
+            o(0xc3c9); /* leave, ret */
+            *(int *) localVariableAddress = localVariableSize; /* save local variables */
+        }
+
+        /* load immediate value */
+        virtual void li(int i, Type* pType) {
+            oad(0xb8, i); /* mov $xx, %eax */
+            setR0Type(pType);
+        }
+
+        virtual void loadFloat(int address, Type* pType) {
+            setR0Type(pType);
+            switch (pType->tag) {
+            case TY_FLOAT:
+                oad(0x05D9, address);      // flds
+                break;
+            case TY_DOUBLE:
+                oad(0x05DD, address);      // fldl
+                break;
+            default:
+                assert(false);
+                break;
+            }
+        }
+
+        virtual int gjmp(int t) {
+            return psym(0xe9, t);
+        }
+
+        /* l = 0: je, l == 1: jne */
+        virtual int gtst(bool l, int t) {
+            Type* pR0Type = getR0Type();
+            TypeTag tagR0 = pR0Type->tag;
+            bool isFloatR0 = isFloatTag(tagR0);
+            if (isFloatR0) {
+                o(0xeed9); // fldz
+                o(0xe9da); // fucompp
+                o(0xe0df); // fnstsw %ax
+                o(0x9e);   // sahf
+            } else {
+                o(0xc085); // test %eax, %eax
+            }
+            // Use two output statements to generate one instruction.
+            o(0x0f);   // je/jne xxx
+            return psym(0x84 + l, t);
+        }
+
+        virtual void gcmp(int op, Type* pResultType) {
+            Type* pR0Type = getR0Type();
+            Type* pTOSType = getTOSType();
+            TypeTag tagR0 = pR0Type->tag;
+            TypeTag tagTOS = pTOSType->tag;
+            bool isFloatR0 = isFloatTag(tagR0);
+            bool isFloatTOS = isFloatTag(tagTOS);
+            if (!isFloatR0 && !isFloatTOS) {
+                int t = decodeOp(op);
+                o(0x59); /* pop %ecx */
+                o(0xc139); /* cmp %eax,%ecx */
+                li(0, NULL);
+                o(0x0f); /* setxx %al */
+                o(t + 0x90);
+                o(0xc0);
+                popType();
+            } else {
+                setupFloatOperands();
+                switch (op) {
+                    case OP_EQUALS:
+                        o(0xe9da);   // fucompp
+                        o(0xe0df);   // fnstsw %ax
+                        o(0x9e);     // sahf
+                        o(0xc0940f); // sete %al
+                        o(0xc29b0f); // setnp %dl
+                        o(0xd021);   // andl %edx, %eax
+                        break;
+                    case OP_NOT_EQUALS:
+                        o(0xe9da);   // fucompp
+                        o(0xe0df);   // fnstsw %ax
+                        o(0x9e);     // sahf
+                        o(0xc0950f); // setne %al
+                        o(0xc29a0f); // setp %dl
+                        o(0xd009);   // orl %edx, %eax
+                        break;
+                    case OP_GREATER_EQUAL:
+                        o(0xe9da);   // fucompp
+                        o(0xe0df);   // fnstsw %ax
+                        o(0x05c4f6); // testb $5, %ah
+                        o(0xc0940f); // sete %al
+                        break;
+                    case OP_LESS:
+                        o(0xc9d9);   // fxch %st(1)
+                        o(0xe9da);   // fucompp
+                        o(0xe0df);   // fnstsw %ax
+                        o(0x9e);     // sahf
+                        o(0xc0970f); // seta %al
+                        break;
+                    case OP_LESS_EQUAL:
+                        o(0xc9d9);   // fxch %st(1)
+                        o(0xe9da);   // fucompp
+                        o(0xe0df);   // fnstsw %ax
+                        o(0x9e);     // sahf
+                        o(0xc0930f); // setea %al
+                        break;
+                    case OP_GREATER:
+                        o(0xe9da);   // fucompp
+                        o(0xe0df);   // fnstsw %ax
+                        o(0x45c4f6); // testb $69, %ah
+                        o(0xc0940f); // sete %al
+                        break;
+                    default:
+                        error("Unknown comparison op");
+                }
+                o(0xc0b60f); // movzbl %al, %eax
+            }
+            setR0Type(pResultType);
+        }
+
+        virtual void genOp(int op) {
+            Type* pR0Type = getR0Type();
+            Type* pTOSType = getTOSType();
+            TypeTag tagR0 = pR0Type->tag;
+            TypeTag tagTOS = pTOSType->tag;
+            bool isFloatR0 = isFloatTag(tagR0);
+            bool isFloatTOS = isFloatTag(tagTOS);
+            if (!isFloatR0 && !isFloatTOS) {
+                // TODO: Deal with pointer arithmetic
+                o(0x59); /* pop %ecx */
+                o(decodeOp(op));
+                if (op == OP_MOD)
+                    o(0x92); /* xchg %edx, %eax */
+                popType();
+            } else {
+                Type* pResultType = tagR0 > tagTOS ? pR0Type : pTOSType;
+                setupFloatOperands();
+                // Both float. x87 R0 == left hand, x87 R1 == right hand
+                switch (op) {
+                    case OP_MUL:
+                        o(0xc9de); // fmulp
+                        break;
+                    case OP_DIV:
+                        o(0xf1de); // fdivp
+                        break;
+                    case OP_PLUS:
+                        o(0xc1de); // faddp
+                        break;
+                    case OP_MINUS:
+                        o(0xe1de); // fsubp
+                        break;
+                    default:
+                        error("Unsupported binary floating operation.");
+                        break;
+                }
+                setR0Type(pResultType);
+            }
+        }
+
+        virtual void gUnaryCmp(int op, Type* pResultType) {
+            if (op != OP_LOGICAL_NOT) {
+                error("Unknown unary cmp %d", op);
+            } else {
+                Type* pR0Type = getR0Type();
+                TypeTag tag = collapseType(pR0Type->tag);
+                switch(tag) {
+                    case TY_INT: {
+                            oad(0xb9, 0); /* movl $0, %ecx */
+                            int t = decodeOp(op);
+                            o(0xc139); /* cmp %eax,%ecx */
+                            li(0, NULL);
+                            o(0x0f); /* setxx %al */
+                            o(t + 0x90);
+                            o(0xc0);
+                        }
+                        break;
+                    case TY_FLOAT:
+                    case TY_DOUBLE:
+                        o(0xeed9);   // fldz
+                        o(0xe9da);   // fucompp
+                        o(0xe0df);   // fnstsw %ax
+                        o(0x9e);     // sahf
+                        o(0xc0950f); // setne %al
+                        o(0xc29a0f); // setp %dl
+                        o(0xd009);   // orl %edx, %eax
+                        o(0xc0b60f); // movzbl %al, %eax
+                        o(0x01f083); // xorl $1,  %eax
+                        break;
+                    default:
+                        error("gUnaryCmp unsupported type");
+                        break;
+                }
+            }
+            setR0Type(pResultType);
+        }
+
+        virtual void genUnaryOp(int op) {
+            Type* pR0Type = getR0Type();
+            TypeTag tag = collapseType(pR0Type->tag);
+            switch(tag) {
+                case TY_INT:
+                    oad(0xb9, 0); /* movl $0, %ecx */
+                    o(decodeOp(op));
+                    break;
+                case TY_FLOAT:
+                case TY_DOUBLE:
+                    switch (op) {
+                        case OP_MINUS:
+                            o(0xe0d9);  // fchs
+                            break;
+                        case OP_BIT_NOT:
+                            error("Can't apply '~' operator to a float or double.");
+                            break;
+                        default:
+                            error("Unknown unary op %d\n", op);
+                            break;
+                        }
+                    break;
+                default:
+                    error("genUnaryOp unsupported type");
+                    break;
+            }
+        }
+
+        virtual void pushR0() {
+            Type* pR0Type = getR0Type();
+            TypeTag r0ct = collapseType(pR0Type->tag);
+            switch(r0ct) {
+                case TY_INT:
+                    o(0x50); /* push %eax */
+                    break;
+                case TY_FLOAT:
+                    o(0x50); /* push %eax */
+                    o(0x241cd9); // fstps 0(%esp)
+                    break;
+                case TY_DOUBLE:
+                    o(0x50); /* push %eax */
+                    o(0x50); /* push %eax */
+                    o(0x241cdd); // fstpl 0(%esp)
+                    break;
+                default:
+                    error("pushR0 unsupported type %d", r0ct);
+                    break;
+            }
+            pushType();
+        }
+
+        virtual void storeR0ToTOS(Type* pPointerType) {
+            assert(pPointerType->tag == TY_POINTER);
+            o(0x59); /* pop %ecx */
+            popType();
+            switch (pPointerType->pHead->tag) {
+                case TY_INT:
+                    o(0x0189); /* movl %eax/%al, (%ecx) */
+                    break;
+                case TY_CHAR:
+                    o(0x0188); /* movl %eax/%al, (%ecx) */
+                    break;
+                case TY_FLOAT:
+                    o(0x19d9); /* fstps (%ecx) */
+                    break;
+                case TY_DOUBLE:
+                    o(0x19dd); /* fstpl (%ecx) */
+                    break;
+                default:
+                    error("storeR0ToTOS: unsupported type");
+                    break;
+            }
+        }
+
+        virtual void loadR0FromR0(Type* pPointerType) {
+            assert(pPointerType->tag == TY_POINTER);
+            switch (pPointerType->pHead->tag) {
+                case TY_INT:
+                    o2(0x008b); /* mov (%eax), %eax */
+                    break;
+                case TY_CHAR:
+                    o(0xbe0f); /* movsbl (%eax), %eax */
+                    ob(0); /* add zero in code */
+                    break;
+                case TY_FLOAT:
+                    o2(0x00d9); // flds (%eax)
+                    break;
+                case TY_DOUBLE:
+                    o2(0x00dd); // fldl (%eax)
+                    break;
+                default:
+                    error("loadR0FromR0: unsupported type");
+                    break;
+            }
+            setR0Type(pPointerType->pHead);
+        }
+
+        virtual void leaR0(int ea, Type* pPointerType) {
+            gmov(10, ea); /* leal EA, %eax */
+            setR0Type(pPointerType);
+        }
+
+        virtual void storeR0(int ea, Type* pType) {
+            TypeTag tag = pType->tag;
+            switch (tag) {
+                case TY_INT:
+                    gmov(6, ea); /* mov %eax, EA */
+                    break;
+                case TY_FLOAT:
+                    if (ea < -LOCAL || ea > LOCAL) {
+                        oad(0x1dd9, ea); // fstps ea
+                    } else {
+                        oad(0x9dd9, ea); // fstps ea(%ebp)
+                    }
+                    break;
+                case TY_DOUBLE:
+                    if (ea < -LOCAL || ea > LOCAL) {
+                        oad(0x1ddd, ea); // fstpl ea
+                    } else {
+                        oad(0x9ddd, ea); // fstpl ea(%ebp)
+                    }
+                    break;
+                default:
+                    error("Unable to store to type %d", tag);
+                    break;
+            }
+        }
+
+        virtual void loadR0(int ea, bool isIncDec, int op, Type* pType) {
+            TypeTag tag = collapseType(pType->tag);
+            switch (tag) {
+                case TY_INT:
+                    gmov(8, ea); /* mov EA, %eax */
+                    if (isIncDec) {
+                        /* Implement post-increment or post decrement.
+                         */
+                        gmov(0, ea); /* 83 ADD */
+                        o(decodeOp(op));
+                    }
+                    break;
+                case TY_FLOAT:
+                    if (ea < -LOCAL || ea > LOCAL) {
+                        oad(0x05d9, ea); // flds ea
+                    } else {
+                        oad(0x85d9, ea); // flds ea(%ebp)
+                    }
+                    if (isIncDec) {
+                        error("inc/dec not implemented for float.");
+                    }
+                    break;
+                case TY_DOUBLE:
+                    if (ea < -LOCAL || ea > LOCAL) {
+                        oad(0x05dd, ea); // fldl ea
+                    } else {
+                        oad(0x85dd, ea); // fldl ea(%ebp)
+                    }
+                    if (isIncDec) {
+                        error("inc/dec not implemented for double.");
+                    }
+                    break;
+                default:
+                    error("Unable to load type %d", tag);
+                    break;
+            }
+            setR0Type(pType);
+        }
+
+        virtual void convertR0(Type* pType){
+            Type* pR0Type = getR0Type();
+            if (pR0Type == NULL) {
+                assert(false);
+                setR0Type(pType);
+                return;
+            }
+            if (bitsSame(pType, pR0Type)) {
+                // do nothing special
+            } else if (isFloatType(pType) && isFloatType(pR0Type)) {
+                // do nothing special, both held in same register on x87.
+            } else {
+                TypeTag r0Tag = collapseType(pR0Type->tag);
+                TypeTag destTag = collapseType(pType->tag);
+                if (r0Tag == TY_INT && isFloatTag(destTag)) {
+                    // Convert R0 from int to float
+                    o(0x50);      // push %eax
+                    o(0x2404DB);  // fildl 0(%esp)
+                    o(0x58);      // pop %eax
+                } else if (isFloatTag(r0Tag) && destTag == TY_INT) {
+                    // Convert R0 from float to int. Complicated because
+                    // need to save and restore the rounding mode.
+                    o(0x50);       // push %eax
+                    o(0x50);       // push %eax
+                    o(0x02247cD9); // fnstcw 2(%esp)
+                    o(0x2444b70f); // movzwl 2(%esp), %eax
+                    o(0x02);
+                    o(0x0cb4);     // movb $12, %ah
+                    o(0x24048966); // movw %ax, 0(%esp)
+                    o(0x242cd9);   // fldcw 0(%esp)
+                    o(0x04245cdb); // fistpl 4(%esp)
+                    o(0x02246cd9); // fldcw  2(%esp)
+                    o(0x58); // pop %eax
+                    o(0x58); // pop %eax
+                } else {
+                    error("Incompatible types old: %d new: %d",
+                          pR0Type->tag, pType->tag);
+                }
+            }
+            setR0Type(pType);
+        }
+
+        virtual int beginFunctionCallArguments() {
+            return oad(0xec81, 0); /* sub $xxx, %esp */
+        }
+
+        virtual size_t storeR0ToArg(int l) {
+            Type* pR0Type = getR0Type();
+            TypeTag r0ct = collapseType(pR0Type->tag);
+            switch(r0ct) {
+                case TY_INT:
+                    oad(0x248489, l); /* movl %eax, xxx(%esp) */
+                    return 4;
+                case TY_FLOAT:
+                    oad(0x249CD9, l); /* fstps   xxx(%esp) */
+                    return 4;
+                case TY_DOUBLE:
+                    oad(0x249CDD, l); /* fstpl   xxx(%esp) */
+                    return 8;
+                default:
+                    assert(false);
+                    return 0;
+            }
+        }
+
+        virtual void endFunctionCallArguments(Type* pDecl, int a, int l) {
+            * (int*) a = l;
+        }
+
+        virtual int callForward(int symbol, Type* pFunc) {
+            setR0Type(pFunc->pHead);
+            return psym(0xe8, symbol); /* call xxx */
+        }
+
+        virtual void callRelative(int t, Type* pFunc) {
+            setR0Type(pFunc->pHead);
+            psym(0xe8, t); /* call xxx */
+        }
+
+        virtual void callIndirect(int l, Type* pFunc) {
+            setR0Type(pFunc->pHead);
+            oad(0x2494ff, l); /* call *xxx(%esp) */
+        }
+
+        virtual void adjustStackAfterCall(Type* pDecl, int l, bool isIndirect) {
+            if (isIndirect) {
+                l += 4;
+            }
+            if (l > 0) {
+                oad(0xc481, l); /* add $xxx, %esp */
+            }
+        }
+
+        virtual int jumpOffset() {
+            return 5;
+        }
+
+        virtual int disassemble(FILE* out) {
+            return 0;
+        }
+
+        /* output a symbol and patch all calls to it */
+        virtual void gsym(int t) {
+            int n;
+            int pc = getPC();
+            while (t) {
+                n = *(int *) t; /* next value */
+                *(int *) t = pc - t - 4;
+                t = n;
+            }
+        }
+
+        virtual int finishCompile() {
+            size_t pagesize = 4096;
+            size_t base = (size_t) getBase() & ~ (pagesize - 1);
+            size_t top =  ((size_t) getPC() + pagesize - 1) & ~ (pagesize - 1);
+            int err = mprotect((void*) base, top - base, PROT_READ | PROT_WRITE | PROT_EXEC);
+            if (err) {
+               error("mprotect() failed: %d", errno);
+            }
+            return err;
+        }
+
+        /**
+         * Alignment (in bytes) for this type of data
+         */
+        virtual size_t alignmentOf(Type* pType){
+            return 4;
+        }
+
+        /**
+         * Array element alignment (in bytes) for this type of data.
+         */
+        virtual size_t sizeOf(Type* pType){
+            switch(pType->tag) {
+                case TY_INT:
+                    return 4;
+                case TY_CHAR:
+                    return 1;
+                default:
+                    return 0;
+                case TY_FLOAT:
+                    return 4;
+                case TY_DOUBLE:
+                    return 8;
+                case TY_POINTER:
+                    return 4;
+            }
+        }
+
+        virtual size_t stackSizeOf(Type* pType) {
+            switch(pType->tag) {
+                case TY_DOUBLE:
+                    return 8;
+                default:
+                    return 4;
+            }
+        }
+
+    private:
+
+        /** Output 1 to 4 bytes.
+         *
+         */
+        void o(int n) {
+            /* cannot use unsigned, so we must do a hack */
+            while (n && n != -1) {
+                ob(n & 0xff);
+                n = n >> 8;
+            }
+        }
+
+        /* Output exactly 2 bytes
+         */
+        void o2(int n) {
+            ob(n & 0xff);
+            ob(0xff & (n >> 8));
+        }
+
+        /* psym is used to put an instruction with a data field which is a
+         reference to a symbol. It is in fact the same as oad ! */
+        int psym(int n, int t) {
+            return oad(n, t);
+        }
+
+        /* instruction + address */
+        int oad(int n, int t) {
+            o(n);
+            int result = getPC();
+            o4(t);
+            return result;
+        }
+
+
+        static const int operatorHelper[];
+
+        int decodeOp(int op) {
+            if (op < 0 || op > OP_COUNT) {
+                error("Out-of-range operator: %d\n", op);
+                op = 0;
+            }
+            return operatorHelper[op];
+        }
+
+        void gmov(int l, int t) {
+            o(l + 0x83);
+            oad((t > -LOCAL && t < LOCAL) << 7 | 5, t);
+        }
+
+        void setupFloatOperands() {
+            Type* pR0Type = getR0Type();
+            Type* pTOSType = getTOSType();
+            TypeTag tagR0 = pR0Type->tag;
+            TypeTag tagTOS = pTOSType->tag;
+            bool isFloatR0 = isFloatTag(tagR0);
+            bool isFloatTOS = isFloatTag(tagTOS);
+            if (! isFloatR0) {
+                // Convert R0 from int to float
+                o(0x50);      // push %eax
+                o(0x2404DB);  // fildl 0(%esp)
+                o(0x58);      // pop %eax
+            }
+            if (! isFloatTOS){
+                o(0x2404DB);  // fildl 0(%esp);
+                o(0x58);      // pop %eax
+            } else {
+                if (tagTOS == TY_FLOAT) {
+                    o(0x2404d9);  // flds (%esp)
+                    o(0x58);      // pop %eax
+                } else {
+                    o(0x2404dd);  // fldl (%esp)
+                    o(0x58);      // pop %eax
+                    o(0x58);      // pop %eax
+                }
+            }
+            popType();
+        }
+    };
+
+#endif // PROVIDE_X86_CODEGEN
+
+#ifdef PROVIDE_TRACE_CODEGEN
+    class TraceCodeGenerator : public CodeGenerator {
+    private:
+        CodeGenerator* mpBase;
+
+    public:
+        TraceCodeGenerator(CodeGenerator* pBase) {
+            mpBase = pBase;
+        }
+
+        virtual ~TraceCodeGenerator() {
+            delete mpBase;
+        }
+
+        virtual void init(CodeBuf* pCodeBuf) {
+            mpBase->init(pCodeBuf);
+        }
+
+        void setErrorSink(ErrorSink* pErrorSink) {
+            mpBase->setErrorSink(pErrorSink);
+        }
+
+        /* returns address to patch with local variable size
+        */
+        virtual int functionEntry(Type* pDecl) {
+            int result = mpBase->functionEntry(pDecl);
+            fprintf(stderr, "functionEntry(pDecl) -> %d\n", result);
+            return result;
+        }
+
+        virtual void functionExit(Type* pDecl, int localVariableAddress, int localVariableSize) {
+            fprintf(stderr, "functionExit(pDecl, %d, %d)\n",
+                    localVariableAddress, localVariableSize);
+            mpBase->functionExit(pDecl, localVariableAddress, localVariableSize);
+        }
+
+        /* load immediate value */
+        virtual void li(int t, Type* pType) {
+            fprintf(stderr, "li(%d)\n", t);
+            mpBase->li(t, pType);
+        }
+
+        virtual void loadFloat(int address, Type* pType) {
+            fprintf(stderr, "loadFloat(%d, type)\n", address);
+            mpBase->loadFloat(address, pType);
+        }
+
+        virtual int gjmp(int t) {
+            int result = mpBase->gjmp(t);
+            fprintf(stderr, "gjmp(%d) = %d\n", t, result);
+            return result;
+        }
+
+        /* l = 0: je, l == 1: jne */
+        virtual int gtst(bool l, int t) {
+            int result = mpBase->gtst(l, t);
+            fprintf(stderr, "gtst(%d,%d) = %d\n", l, t, result);
+            return result;
+        }
+
+        virtual void gcmp(int op, Type* pResultType) {
+            fprintf(stderr, "gcmp(%d, pResultType)\n", op);
+            mpBase->gcmp(op, pResultType);
+        }
+
+        virtual void genOp(int op) {
+            fprintf(stderr, "genOp(%d)\n", op);
+            mpBase->genOp(op);
+        }
+
+
+        virtual void gUnaryCmp(int op, Type* pResultType) {
+            fprintf(stderr, "gUnaryCmp(%d, pResultType)\n", op);
+            mpBase->gUnaryCmp(op, pResultType);
+        }
+
+        virtual void genUnaryOp(int op) {
+            fprintf(stderr, "genUnaryOp(%d)\n", op);
+            mpBase->genUnaryOp(op);
+        }
+
+        virtual void pushR0() {
+            fprintf(stderr, "pushR0()\n");
+            mpBase->pushR0();
+        }
+
+        virtual void storeR0ToTOS(Type* pPointerType) {
+            fprintf(stderr, "storeR0ToTOS(%d)\n", pPointerType->pHead->tag);
+            mpBase->storeR0ToTOS(pPointerType);
+        }
+
+        virtual void loadR0FromR0(Type* pPointerType) {
+            fprintf(stderr, "loadR0FromR0(%d)\n", pPointerType->pHead->tag);
+            mpBase->loadR0FromR0(pPointerType);
+        }
+
+        virtual void leaR0(int ea, Type* pPointerType) {
+            fprintf(stderr, "leaR0(%d)\n", ea);
+            mpBase->leaR0(ea, pPointerType);
+        }
+
+        virtual void storeR0(int ea, Type* pType) {
+            fprintf(stderr, "storeR0(%d, pType)\n", ea);
+            mpBase->storeR0(ea, pType);
+        }
+
+        virtual void loadR0(int ea, bool isIncDec, int op, Type* pType) {
+            fprintf(stderr, "loadR0(%d, %d, %d, pType)\n", ea, isIncDec, op);
+            mpBase->loadR0(ea, isIncDec, op, pType);
+        }
+
+        virtual void convertR0(Type* pType){
+            fprintf(stderr, "convertR0(pType)\n");
+            mpBase->convertR0(pType);
+        }
+
+        virtual int beginFunctionCallArguments() {
+            int result = mpBase->beginFunctionCallArguments();
+            fprintf(stderr, "beginFunctionCallArguments() = %d\n", result);
+            return result;
+        }
+
+        virtual size_t storeR0ToArg(int l) {
+            fprintf(stderr, "storeR0ToArg(%d)\n", l);
+            return mpBase->storeR0ToArg(l);
+        }
+
+        virtual void endFunctionCallArguments(Type* pDecl, int a, int l) {
+            fprintf(stderr, "endFunctionCallArguments(%d, %d)\n", a, l);
+            mpBase->endFunctionCallArguments(pDecl, a, l);
+        }
+
+        virtual int callForward(int symbol, Type* pFunc) {
+            int result = mpBase->callForward(symbol, pFunc);
+            fprintf(stderr, "callForward(%d) = %d\n", symbol, result);
+            return result;
+        }
+
+        virtual void callRelative(int t, Type* pFunc) {
+            fprintf(stderr, "callRelative(%d)\n", t);
+            mpBase->callRelative(t, pFunc);
+        }
+
+        virtual void callIndirect(int l, Type* pFunc) {
+            fprintf(stderr, "callIndirect(%d)\n", l);
+            mpBase->callIndirect(l, pFunc);
+        }
+
+        virtual void adjustStackAfterCall(Type* pDecl, int l, bool isIndirect) {
+            fprintf(stderr, "adjustStackAfterCall(pType, %d, %d)\n", l, isIndirect);
+            mpBase->adjustStackAfterCall(pDecl, l, isIndirect);
+        }
+
+        virtual int jumpOffset() {
+            return mpBase->jumpOffset();
+        }
+
+        virtual int disassemble(FILE* out) {
+            return mpBase->disassemble(out);
+        }
+
+        /* output a symbol and patch all calls to it */
+        virtual void gsym(int t) {
+            fprintf(stderr, "gsym(%d)\n", t);
+            mpBase->gsym(t);
+        }
+
+        virtual int finishCompile() {
+            int result = mpBase->finishCompile();
+            fprintf(stderr, "finishCompile() = %d\n", result);
+            return result;
+        }
+
+        /**
+         * Alignment (in bytes) for this type of data
+         */
+        virtual size_t alignmentOf(Type* pType){
+            return mpBase->alignmentOf(pType);
+        }
+
+        /**
+         * Array element alignment (in bytes) for this type of data.
+         */
+        virtual size_t sizeOf(Type* pType){
+            return mpBase->sizeOf(pType);
+        }
+
+
+        virtual size_t stackSizeOf(Type* pType) {
+            return mpBase->stackSizeOf(pType);
+        }
+
+
+        virtual Type* getR0Type() {
+            return mpBase->getR0Type();
+        }
+    };
+
+#endif // PROVIDE_TRACE_CODEGEN
+
+    class Arena {
+    public:
+        // Used to record a given allocation amount.
+        // Used:
+        // Mark mark = arena.mark();
+        // ... lots of arena.allocate()
+        // arena.free(mark);
+
+        struct Mark {
+            size_t chunk;
+            size_t offset;
+        };
+
+        Arena() {
+            mCurrentChunk = 0;
+            Chunk start(CHUNK_SIZE);
+            mData.push_back(start);
+        }
+
+        ~Arena() {
+            for(size_t i = 0; i < mData.size(); i++) {
+                mData[i].free();
+            }
+        }
+
+        // Alloc using the standard alignment size safe for any variable
+        void* alloc(size_t size) {
+            return alloc(size, 8);
+        }
+
+        Mark mark(){
+            Mark result;
+            result.chunk = mCurrentChunk;
+            result.offset = mData[mCurrentChunk].mOffset;
+            return result;
+        }
+
+        void freeToMark(const Mark& mark) {
+            mCurrentChunk = mark.chunk;
+            mData[mCurrentChunk].mOffset = mark.offset;
+        }
+
+    private:
+        // Allocate memory aligned to a given size
+        // and a given power-of-two-sized alignment (e.g. 1,2,4,8,...)
+        // Memory is not zero filled.
+
+        void* alloc(size_t size, size_t alignment) {
+            while (size > mData[mCurrentChunk].remainingCapacity(alignment)) {
+                if (mCurrentChunk + 1 < mData.size()) {
+                    mCurrentChunk++;
+                } else {
+                    size_t allocSize = CHUNK_SIZE;
+                    if (allocSize < size + alignment - 1) {
+                        allocSize = size + alignment - 1;
+                    }
+                    Chunk chunk(allocSize);
+                    mData.push_back(chunk);
+                    mCurrentChunk++;
+                }
+            }
+            return mData[mCurrentChunk].allocate(size, alignment);
+        }
+
+        static const size_t CHUNK_SIZE = 128*1024;
+        // Note: this class does not deallocate its
+        // memory when it's destroyed. It depends upon
+        // its parent to deallocate the memory.
+        struct Chunk {
+            Chunk() {
+                mpData = 0;
+                mSize = 0;
+                mOffset = 0;
+            }
+
+            Chunk(size_t size) {
+                mSize = size;
+                mpData = (char*) malloc(size);
+                mOffset = 0;
+            }
+
+            ~Chunk() {
+                // Doesn't deallocate memory.
+            }
+
+            void* allocate(size_t size, size_t alignment) {
+                size_t alignedOffset = aligned(mOffset, alignment);
+                void* result = mpData + alignedOffset;
+                mOffset = alignedOffset + size;
+                return result;
+            }
+
+            void free() {
+                if (mpData) {
+                    ::free(mpData);
+                    mpData = 0;
+                }
+            }
+
+            size_t remainingCapacity(size_t alignment) {
+                return aligned(mSize, alignment) - aligned(mOffset, alignment);
+            }
+
+            // Assume alignment is a power of two
+            inline size_t aligned(size_t v, size_t alignment) {
+                size_t mask = alignment-1;
+                return (v + mask) & ~mask;
+            }
+
+            char* mpData;
+            size_t mSize;
+            size_t mOffset;
+        };
+
+        size_t mCurrentChunk;
+
+        Vector<Chunk> mData;
+    };
+
+    struct VariableInfo;
+
+    struct Token {
+        int hash;
+        size_t length;
+        char* pText;
+        tokenid_t id;
+
+        // Current values for the token
+        char* mpMacroDefinition;
+        VariableInfo* mpVariableInfo;
+    };
+
+    class TokenTable {
+    public:
+        // Don't use 0..0xff, allows characters and operators to be tokens too.
+
+        static const int TOKEN_BASE = 0x100;
+        TokenTable() {
+            mpMap = hashmapCreate(128, hashFn, equalsFn);
+        }
+
+        ~TokenTable() {
+            hashmapFree(mpMap);
+        }
+
+        void setArena(Arena* pArena) {
+            mpArena = pArena;
+        }
+
+        // Returns a token for a given string of characters.
+        tokenid_t intern(const char* pText, size_t length) {
+            Token probe;
+            int hash = hashmapHash((void*) pText, length);
+            {
+                Token probe;
+                probe.hash = hash;
+                probe.length = length;
+                probe.pText = (char*) pText;
+                Token* pValue = (Token*) hashmapGet(mpMap, &probe);
+                if (pValue) {
+                    return pValue->id;
+                }
+            }
+
+            Token* pToken = (Token*) mpArena->alloc(sizeof(Token));
+            memset(pToken, 0, sizeof(*pToken));
+            pToken->hash = hash;
+            pToken->length = length;
+            pToken->pText = (char*) mpArena->alloc(length + 1);
+            memcpy(pToken->pText, pText, length);
+            pToken->pText[length] = 0;
+            pToken->id = mTokens.size() + TOKEN_BASE;
+            mTokens.push_back(pToken);
+            hashmapPut(mpMap, pToken, pToken);
+            return pToken->id;
+        }
+
+        // Return the Token for a given tokenid.
+        Token& operator[](tokenid_t id) {
+            return *mTokens[id - TOKEN_BASE];
+        }
+
+        inline size_t size() {
+            return mTokens.size();
+        }
+
+    private:
+
+        static int hashFn(void* pKey) {
+            Token* pToken = (Token*) pKey;
+            return pToken->hash;
+        }
+
+        static bool equalsFn(void* keyA, void* keyB) {
+            Token* pTokenA = (Token*) keyA;
+            Token* pTokenB = (Token*) keyB;
+            // Don't need to compare hash values, they should always be equal
+            return pTokenA->length == pTokenB->length
+                && strcmp(pTokenA->pText, pTokenB->pText) == 0;
+        }
+
+        Hashmap* mpMap;
+        Vector<Token*> mTokens;
+        Arena* mpArena;
+    };
+
+    class InputStream {
+    public:
+        virtual ~InputStream() {}
+        int getChar() {
+            if (bumpLine) {
+                line++;
+                bumpLine = false;
+            }
+            int ch = get();
+            if (ch == '\n') {
+                bumpLine = true;
+            }
+            return ch;
+        }
+        int getLine() {
+            return line;
+        }
+    protected:
+        InputStream() :
+            line(1), bumpLine(false) {
+        }
+    private:
+        virtual int get() = 0;
+        int line;
+        bool bumpLine;
+    };
+
+    class FileInputStream : public InputStream {
+    public:
+        FileInputStream(FILE* in) : f(in) {}
+    private:
+        virtual int get() { return fgetc(f); }
+        FILE* f;
+    };
+
+    class TextInputStream : public InputStream {
+    public:
+        TextInputStream(const char* text, size_t textLength)
+            : pText(text), mTextLength(textLength), mPosition(0) {
+        }
+
+    private:
+        virtual int get() {
+            return mPosition < mTextLength ? pText[mPosition++] : EOF;
+        }
+
+        const char* pText;
+        size_t mTextLength;
+        size_t mPosition;
+    };
+
+    class String {
+    public:
+        String() {
+            mpBase = 0;
+            mUsed = 0;
+            mSize = 0;
+        }
+
+        String(const char* item, int len, bool adopt) {
+            if (len < 0) {
+                len = strlen(item);
+            }
+            if (adopt) {
+                mpBase = (char*) item;
+                mUsed = len;
+                mSize = len + 1;
+            } else {
+                mpBase = 0;
+                mUsed = 0;
+                mSize = 0;
+                appendBytes(item, len);
+            }
+        }
+
+        String(const String& other) {
+            mpBase = 0;
+            mUsed = 0;
+            mSize = 0;
+            appendBytes(other.getUnwrapped(), other.len());
+        }
+
+        ~String() {
+            if (mpBase) {
+                free(mpBase);
+            }
+        }
+
+        String& operator=(const String& other) {
+            clear();
+            appendBytes(other.getUnwrapped(), other.len());
+            return *this;
+        }
+
+        inline char* getUnwrapped() const {
+            return mpBase;
+        }
+
+        void clear() {
+            mUsed = 0;
+            if (mSize > 0) {
+                mpBase[0] = 0;
+            }
+        }
+
+        void appendCStr(const char* s) {
+            appendBytes(s, strlen(s));
+        }
+
+        void appendBytes(const char* s, int n) {
+            memcpy(ensure(n), s, n + 1);
+        }
+
+        void append(char c) {
+            * ensure(1) = c;
+        }
+
+        void append(String& other) {
+            appendBytes(other.getUnwrapped(), other.len());
+        }
+
+        char* orphan() {
+            char* result = mpBase;
+            mpBase = 0;
+            mUsed = 0;
+            mSize = 0;
+            return result;
+        }
+
+        void printf(const char* fmt,...) {
+            va_list ap;
+            va_start(ap, fmt);
+            vprintf(fmt, ap);
+            va_end(ap);
+        }
+
+        void vprintf(const char* fmt, va_list ap) {
+            char* temp;
+            int numChars = vasprintf(&temp, fmt, ap);
+            memcpy(ensure(numChars), temp, numChars+1);
+            free(temp);
+        }
+
+        inline size_t len() const {
+            return mUsed;
+        }
+
+    private:
+        char* ensure(int n) {
+            size_t newUsed = mUsed + n;
+            if (newUsed > mSize) {
+                size_t newSize = mSize * 2 + 10;
+                if (newSize < newUsed) {
+                    newSize = newUsed;
+                }
+                mpBase = (char*) realloc(mpBase, newSize + 1);
+                mSize = newSize;
+            }
+            mpBase[newUsed] = '\0';
+            char* result = mpBase + mUsed;
+            mUsed = newUsed;
+            return result;
+        }
+
+        char* mpBase;
+        size_t mUsed;
+        size_t mSize;
+    };
+
+    void internKeywords() {
+        // Note: order has to match TOK_ constants
+        static const char* keywords[] = {
+            "int",
+            "char",
+            "void",
+            "if",
+            "else",
+            "while",
+            "break",
+            "return",
+            "for",
+            "pragma",
+            "define",
+            "auto",
+            "case",
+            "const",
+            "continue",
+            "default",
+            "do",
+            "double",
+            "enum",
+            "extern",
+            "float",
+            "goto",
+            "long",
+            "register",
+            "short",
+            "signed",
+            "sizeof",
+            "static",
+            "struct",
+            "switch",
+            "typedef",
+            "union",
+            "unsigned",
+            "volatile",
+            "_Bool",
+            "_Complex",
+            "_Imaginary",
+            "inline",
+            "restrict",
+            0};
+
+        for(int i = 0; keywords[i]; i++) {
+            mTokenTable.intern(keywords[i], strlen(keywords[i]));
+        }
+    }
+
+    struct InputState {
+        InputStream* pStream;
+        int oldCh;
+    };
+
+    struct VariableInfo {
+        void* pAddress;
+        void* pForward; // For a forward direction, linked list of data to fix up
+        tokenid_t tok;
+        size_t level;
+        VariableInfo* pOldDefinition;
+        Type* pType;
+    };
+
+    class SymbolStack {
+    public:
+        SymbolStack() {
+            mpArena = 0;
+            mpTokenTable = 0;
+        }
+
+        void setArena(Arena* pArena) {
+            mpArena = pArena;
+        }
+
+        void setTokenTable(TokenTable* pTokenTable) {
+            mpTokenTable = pTokenTable;
+        }
+
+        void pushLevel() {
+            Mark mark;
+            mark.mArenaMark = mpArena->mark();
+            mark.mSymbolHead = mStack.size();
+            mLevelStack.push_back(mark);
+        }
+
+        void popLevel() {
+            // Undo any shadowing that was done:
+            Mark mark = mLevelStack.back();
+            mLevelStack.pop_back();
+            while (mStack.size() > mark.mSymbolHead) {
+                VariableInfo* pV = mStack.back();
+                mStack.pop_back();
+                (*mpTokenTable)[pV->tok].mpVariableInfo = pV->pOldDefinition;
+            }
+            mpArena->freeToMark(mark.mArenaMark);
+        }
+
+        bool isDefinedAtCurrentLevel(tokenid_t tok) {
+            VariableInfo* pV = (*mpTokenTable)[tok].mpVariableInfo;
+            return pV && pV->level == level();
+        }
+
+        VariableInfo* add(tokenid_t tok) {
+            Token& token = (*mpTokenTable)[tok];
+            VariableInfo* pOldV = token.mpVariableInfo;
+            VariableInfo* pNewV =
+                (VariableInfo*) mpArena->alloc(sizeof(VariableInfo));
+            memset(pNewV, 0, sizeof(VariableInfo));
+            pNewV->tok = tok;
+            pNewV->level = level();
+            pNewV->pOldDefinition = pOldV;
+            token.mpVariableInfo = pNewV;
+            mStack.push_back(pNewV);
+            return pNewV;
+        }
+
+        VariableInfo* add(Type* pType) {
+            VariableInfo* pVI = add(pType->id);
+            pVI->pType = pType;
+            return pVI;
+        }
+
+        void forEach(bool (*fn)(VariableInfo*, void*), void* context) {
+            for (size_t i = 0; i < mStack.size(); i++) {
+                if (! fn(mStack[i], context)) {
+                    break;
+                }
+            }
+        }
+
+    private:
+        inline size_t level() {
+            return mLevelStack.size();
+        }
+
+        struct Mark {
+            Arena::Mark mArenaMark;
+            size_t mSymbolHead;
+        };
+
+        Arena* mpArena;
+        TokenTable* mpTokenTable;
+        Vector<VariableInfo*> mStack;
+        Vector<Mark> mLevelStack;
+    };
+
+    int ch; // Current input character, or EOF
+    tokenid_t tok;      // token
+    intptr_t tokc;    // token extra info
+    double tokd;     // floating point constant value
+    int tokl;         // token operator level
+    intptr_t rsym; // return symbol
+    Type* pReturnType; // type of the current function's return.
+    intptr_t loc; // local variable index
+    char* glo;  // global variable index
+    String mTokenString;
+    char* dptr; // Macro state: Points to macro text during macro playback.
+    int dch;    // Macro state: Saves old value of ch during a macro playback.
+    char* pGlobalBase;
+
+    // Arena for the duration of the compile
+    Arena mGlobalArena;
+    // Arena for data that's only needed when compiling a single function
+    Arena mLocalArena;
+
+    TokenTable mTokenTable;
+    SymbolStack mGlobals;
+    SymbolStack mLocals;
+
+    // Prebuilt types, makes things slightly faster.
+    Type* mkpInt;        // int
+    Type* mkpChar;       // char
+    Type* mkpVoid;       // void
+    Type* mkpFloat;
+    Type* mkpDouble;
+    Type* mkpIntFn;
+    Type* mkpIntPtr;
+    Type* mkpCharPtr;
+    Type* mkpFloatPtr;
+    Type* mkpDoublePtr;
+    Type* mkpPtrIntFn;
+
+    InputStream* file;
+
+    CodeBuf codeBuf;
+    CodeGenerator* pGen;
+
+    String mErrorBuf;
+
+    String mPragmas;
+    int mPragmaStringCount;
+
+    static const int ALLOC_SIZE = 99999;
+
+    static const int TOK_DUMMY = 1;
+    static const int TOK_NUM = 2;
+    static const int TOK_NUM_FLOAT = 3;
+    static const int TOK_NUM_DOUBLE = 4;
+
+    // 3..255 are character and/or operators
+
+    // Keywords start at 0x100 and increase by 1
+    // Order has to match string list in "internKeywords".
+    enum {
+        TOK_KEYWORD = TokenTable::TOKEN_BASE,
+        TOK_INT = TOK_KEYWORD,
+        TOK_CHAR,
+        TOK_VOID,
+        TOK_IF,
+        TOK_ELSE,
+        TOK_WHILE,
+        TOK_BREAK,
+        TOK_RETURN,
+        TOK_FOR,
+        TOK_PRAGMA,
+        TOK_DEFINE,
+        TOK_AUTO,
+        TOK_CASE,
+        TOK_CONST,
+        TOK_CONTINUE,
+        TOK_DEFAULT,
+        TOK_DO,
+        TOK_DOUBLE,
+        TOK_ENUM,
+        TOK_EXTERN,
+        TOK_FLOAT,
+        TOK_GOTO,
+        TOK_LONG,
+        TOK_REGISTER,
+        TOK_SHORT,
+        TOK_SIGNED,
+        TOK_SIZEOF,
+        TOK_STATIC,
+        TOK_STRUCT,
+        TOK_SWITCH,
+        TOK_TYPEDEF,
+        TOK_UNION,
+        TOK_UNSIGNED,
+        TOK_VOLATILE,
+        TOK__BOOL,
+        TOK__COMPLEX,
+        TOK__IMAGINARY,
+        TOK_INLINE,
+        TOK_RESTRICT,
+        // Symbols start after tokens
+        TOK_SYMBOL
+    };
+
+    static const int LOCAL = 0x200;
+
+    static const int SYM_FORWARD = 0;
+    static const int SYM_DEFINE = 1;
+
+    /* tokens in string heap */
+    static const int TAG_TOK = ' ';
+
+    static const int OP_INCREMENT = 0;
+    static const int OP_DECREMENT = 1;
+    static const int OP_MUL = 2;
+    static const int OP_DIV = 3;
+    static const int OP_MOD = 4;
+    static const int OP_PLUS = 5;
+    static const int OP_MINUS = 6;
+    static const int OP_SHIFT_LEFT = 7;
+    static const int OP_SHIFT_RIGHT = 8;
+    static const int OP_LESS_EQUAL = 9;
+    static const int OP_GREATER_EQUAL = 10;
+    static const int OP_LESS = 11;
+    static const int OP_GREATER = 12;
+    static const int OP_EQUALS = 13;
+    static const int OP_NOT_EQUALS = 14;
+    static const int OP_LOGICAL_AND = 15;
+    static const int OP_LOGICAL_OR = 16;
+    static const int OP_BIT_AND = 17;
+    static const int OP_BIT_XOR = 18;
+    static const int OP_BIT_OR = 19;
+    static const int OP_BIT_NOT = 20;
+    static const int OP_LOGICAL_NOT = 21;
+    static const int OP_COUNT = 22;
+
+    /* Operators are searched from front, the two-character operators appear
+     * before the single-character operators with the same first character.
+     * @ is used to pad out single-character operators.
+     */
+    static const char* operatorChars;
+    static const char operatorLevel[];
+
+    /* Called when we detect an internal problem. Does nothing in production.
+     *
+     */
+    void internalError() {
+        * (char*) 0 = 0;
+    }
+
+    void assert(bool isTrue) {
+        if (!isTrue) {
+            internalError();
+        }
+    }
+
+    bool isSymbol(tokenid_t t) {
+        return t >= TOK_SYMBOL &&
+            ((size_t) (t-TOK_SYMBOL)) < mTokenTable.size();
+    }
+
+    bool isSymbolOrKeyword(tokenid_t t) {
+        return t >= TOK_KEYWORD &&
+            ((size_t) (t-TOK_KEYWORD)) < mTokenTable.size();
+    }
+
+    VariableInfo* VI(tokenid_t t) {
+        assert(isSymbol(t));
+        VariableInfo* pV = mTokenTable[t].mpVariableInfo;
+        if (pV && pV->tok != t) {
+            internalError();
+        }
+        return pV;
+    }
+
+    inline bool isDefined(tokenid_t t) {
+        return t >= TOK_SYMBOL && VI(t) != 0;
+    }
+
+    const char* nameof(tokenid_t t) {
+        assert(isSymbolOrKeyword(t));
+        return mTokenTable[t].pText;
+    }
+
+    void pdef(int t) {
+        mTokenString.append(t);
+    }
+
+    void inp() {
+        if (dptr) {
+            ch = *dptr++;
+            if (ch == 0) {
+                dptr = 0;
+                ch = dch;
+            }
+        } else
+            ch = file->getChar();
+#if 0
+        printf("ch='%c' 0x%x\n", ch, ch);
+#endif
+    }
+
+    int isid() {
+        return isalnum(ch) | (ch == '_');
+    }
+
+    /* read a character constant, advances ch to after end of constant */
+    int getq() {
+        int val = ch;
+        if (ch == '\\') {
+            inp();
+            if (isoctal(ch)) {
+                // 1 to 3 octal characters.
+                val = 0;
+                for(int i = 0; i < 3; i++) {
+                    if (isoctal(ch)) {
+                        val = (val << 3) + ch - '0';
+                        inp();
+                    }
+                }
+                return val;
+            } else if (ch == 'x' || ch == 'X') {
+                // N hex chars
+                inp();
+                if (! isxdigit(ch)) {
+                    error("'x' character escape requires at least one digit.");
+                } else {
+                    val = 0;
+                    while (isxdigit(ch)) {
+                        int d = ch;
+                        if (isdigit(d)) {
+                            d -= '0';
+                        } else if (d <= 'F') {
+                            d = d - 'A' + 10;
+                        } else {
+                            d = d - 'a' + 10;
+                        }
+                        val = (val << 4) + d;
+                        inp();
+                    }
+                }
+            } else {
+                int val = ch;
+                switch (ch) {
+                    case 'a':
+                        val = '\a';
+                        break;
+                    case 'b':
+                        val = '\b';
+                        break;
+                    case 'f':
+                        val = '\f';
+                        break;
+                    case 'n':
+                        val = '\n';
+                        break;
+                    case 'r':
+                        val = '\r';
+                        break;
+                    case 't':
+                        val = '\t';
+                        break;
+                    case 'v':
+                        val = '\v';
+                        break;
+                    case '\\':
+                        val = '\\';
+                        break;
+                    case '\'':
+                        val = '\'';
+                        break;
+                    case '"':
+                        val = '"';
+                        break;
+                    case '?':
+                        val = '?';
+                        break;
+                    default:
+                        error("Undefined character escape %c", ch);
+                        break;
+                }
+                inp();
+                return val;
+            }
+        } else {
+            inp();
+        }
+        return val;
+    }
+
+    static bool isoctal(int ch) {
+        return ch >= '0' && ch <= '7';
+    }
+
+    bool acceptCh(int c) {
+        bool result = c == ch;
+        if (result) {
+            pdef(ch);
+            inp();
+        }
+        return result;
+    }
+
+    bool acceptDigitsCh() {
+        bool result = false;
+        while (isdigit(ch)) {
+            result = true;
+            pdef(ch);
+            inp();
+        }
+        return result;
+    }
+
+    void parseFloat() {
+        tok = TOK_NUM_DOUBLE;
+        // mTokenString already has the integral part of the number.
+        acceptCh('.');
+        acceptDigitsCh();
+        bool doExp = true;
+        if (acceptCh('e') || acceptCh('E')) {
+            // Don't need to do any extra work
+        } else if (ch == 'f' || ch == 'F') {
+            pdef('e'); // So it can be parsed by strtof.
+            inp();
+            tok = TOK_NUM_FLOAT;
+        } else {
+            doExp = false;
+        }
+        if (doExp) {
+            bool digitsRequired = acceptCh('-');
+            bool digitsFound = acceptDigitsCh();
+            if (digitsRequired && ! digitsFound) {
+                error("malformed exponent");
+            }
+        }
+        char* pText = mTokenString.getUnwrapped();
+        if (tok == TOK_NUM_FLOAT) {
+            tokd = strtof(pText, 0);
+        } else {
+            tokd = strtod(pText, 0);
+        }
+        //fprintf(stderr, "float constant: %s (%d) %g\n", pText, tok, tokd);
+    }
+
+    void next() {
+        int l, a;
+
+        while (isspace(ch) | (ch == '#')) {
+            if (ch == '#') {
+                inp();
+                next();
+                if (tok == TOK_DEFINE) {
+                    doDefine();
+                } else if (tok == TOK_PRAGMA) {
+                    doPragma();
+                } else {
+                    error("Unsupported preprocessor directive \"%s\"",
+                          mTokenString.getUnwrapped());
+                }
+            }
+            inp();
+        }
+        tokl = 0;
+        tok = ch;
+        /* encode identifiers & numbers */
+        if (isid()) {
+            mTokenString.clear();
+            while (isid()) {
+                pdef(ch);
+                inp();
+            }
+            if (isdigit(tok)) {
+                // Start of a numeric constant. Could be integer, float, or
+                // double, won't know until we look further.
+                if (ch == '.' || ch == 'e' || ch == 'e'
+                    || ch == 'f' || ch == 'F')  {
+                    parseFloat();
+                } else {
+                    // It's an integer constant
+                    tokc = strtol(mTokenString.getUnwrapped(), 0, 0);
+                    tok = TOK_NUM;
+                }
+            } else {
+                tok = mTokenTable.intern(mTokenString.getUnwrapped(),
+                                         mTokenString.len());
+                // Is this a macro?
+                char* pMacroDefinition = mTokenTable[tok].mpMacroDefinition;
+                if(pMacroDefinition) {
+                    // Yes, it is a macro
+                    dptr = pMacroDefinition;
+                    dch = ch;
+                    inp();
+                    next();
+                }
+            }
+        } else {
+            inp();
+            if (tok == '\'') {
+                tok = TOK_NUM;
+                tokc = getq();
+                if (ch != '\'') {
+                    error("Expected a ' character, got %c", ch);
+                } else {
+                  inp();
+                }
+            } else if ((tok == '/') & (ch == '*')) {
+                inp();
+                while (ch && ch != EOF) {
+                    while (ch != '*' && ch != EOF)
+                        inp();
+                    inp();
+                    if (ch == '/')
+                        ch = 0;
+                }
+                if (ch == EOF) {
+                    error("End of file inside comment.");
+                }
+                inp();
+                next();
+            } else if ((tok == '/') & (ch == '/')) {
+                inp();
+                while (ch && (ch != '\n') && (ch != EOF)) {
+                    inp();
+                }
+                inp();
+                next();
+            } else {
+                const char* t = operatorChars;
+                int opIndex = 0;
+                while ((l = *t++) != 0) {
+                    a = *t++;
+                    tokl = operatorLevel[opIndex];
+                    tokc = opIndex;
+                    if ((l == tok) & ((a == ch) | (a == '@'))) {
+#if 0
+                        printf("%c%c -> tokl=%d tokc=0x%x\n",
+                                l, a, tokl, tokc);
+#endif
+                        if (a == ch) {
+                            inp();
+                            tok = TOK_DUMMY; /* dummy token for double tokens */
+                        }
+                        break;
+                    }
+                    opIndex++;
+                }
+                if (l == 0) {
+                    tokl = 0;
+                    tokc = 0;
+                }
+            }
+        }
+#if 0
+        {
+            String buf;
+            decodeToken(buf, tok);
+            fprintf(stderr, "%s\n", buf.getUnwrapped());
+        }
+#endif
+    }
+
+    void doDefine() {
+        next();
+        tokenid_t name = tok;
+        String* pName = new String();
+        while (isspace(ch)) {
+            inp();
+        }
+        if (ch == '(') {
+            delete pName;
+            error("Defines with arguments not supported");
+            return;
+        }
+        while (isspace(ch)) {
+            inp();
+        }
+        String value;
+        while (ch != '\n' && ch != EOF) {
+            value.append(ch);
+            inp();
+        }
+        char* pDefn = (char*)mGlobalArena.alloc(value.len() + 1);
+        memcpy(pDefn, value.getUnwrapped(), value.len());
+        pDefn[value.len()] = 0;
+        mTokenTable[name].mpMacroDefinition = pDefn;
+    }
+
+    void doPragma() {
+        // # pragma name(val)
+        int state = 0;
+        while(ch != EOF && ch != '\n' && state < 10) {
+            switch(state) {
+                case 0:
+                    if (isspace(ch)) {
+                        inp();
+                    } else {
+                        state++;
+                    }
+                    break;
+                case 1:
+                    if (isalnum(ch)) {
+                        mPragmas.append(ch);
+                        inp();
+                    } else if (ch == '(') {
+                        mPragmas.append(0);
+                        inp();
+                        state++;
+                    } else {
+                        state = 11;
+                    }
+                    break;
+                case 2:
+                    if (isalnum(ch)) {
+                        mPragmas.append(ch);
+                        inp();
+                    } else if (ch == ')') {
+                        mPragmas.append(0);
+                        inp();
+                        state = 10;
+                    } else {
+                        state = 11;
+                    }
+                    break;
+            }
+        }
+        if(state != 10) {
+            error("Unexpected pragma syntax");
+        }
+        mPragmaStringCount += 2;
+    }
+
+    virtual void verror(const char* fmt, va_list ap) {
+        mErrorBuf.printf("%ld: ", file->getLine());
+        mErrorBuf.vprintf(fmt, ap);
+        mErrorBuf.printf("\n");
+    }
+
+    void skip(intptr_t c) {
+        if (tok != c) {
+            error("'%c' expected", c);
+        }
+        next();
+    }
+
+    bool accept(intptr_t c) {
+        if (tok == c) {
+            next();
+            return true;
+        }
+        return false;
+    }
+
+    bool acceptStringLiteral() {
+        if (tok == '"') {
+            pGen->li((int) glo, mkpCharPtr);
+            // This while loop merges multiple adjacent string constants.
+            while (tok == '"') {
+                while (ch != '"' && ch != EOF) {
+                    *allocGlobalSpace(1,1) = getq();
+                }
+                if (ch != '"') {
+                    error("Unterminated string constant.");
+                }
+                inp();
+                next();
+            }
+            /* Null terminate */
+            *glo = 0;
+            /* align heap */
+            allocGlobalSpace(1,(char*) (((intptr_t) glo + 4) & -4) - glo);
+
+            return true;
+        }
+        return false;
+    }
+    /* Parse and evaluate a unary expression.
+     * allowAssignment is true if '=' parsing wanted (quick hack)
+     */
+    void unary(bool allowAssignment) {
+        intptr_t n, t, a;
+        t = 0;
+        n = 1; /* type of expression 0 = forward, 1 = value, other = lvalue */
+        if (acceptStringLiteral()) {
+            // Nothing else to do.
+        } else {
+            int c = tokl;
+            a = tokc;
+            double ad = tokd;
+            t = tok;
+            next();
+            if (t == TOK_NUM) {
+                pGen->li(a, mkpInt);
+            } else if (t == TOK_NUM_FLOAT) {
+                // Align to 4-byte boundary
+                glo = (char*) (((intptr_t) glo + 3) & -4);
+                * (float*) glo = (float) ad;
+                pGen->loadFloat((int) glo, mkpFloat);
+                glo += 4;
+            } else if (t == TOK_NUM_DOUBLE) {
+                // Align to 8-byte boundary
+                glo = (char*) (((intptr_t) glo + 7) & -8);
+                * (double*) glo = ad;
+                pGen->loadFloat((int) glo, mkpDouble);
+                glo += 8;
+            } else if (c == 2) {
+                /* -, +, !, ~ */
+                unary(false);
+                if (t == '!')
+                    pGen->gUnaryCmp(a, mkpInt);
+                else if (t == '+') {
+                    // ignore unary plus.
+                } else {
+                    pGen->genUnaryOp(a);
+                }
+            } else if (t == '(') {
+                expr();
+                skip(')');
+            } else if (t == '*') {
+                /* This is a pointer dereference, but we currently only
+                 * support a pointer dereference if it's immediately
+                 * in front of a cast. So parse the cast right here.
+                 */
+                skip('(');
+                Type* pCast = expectCastTypeDeclaration(mLocalArena);
+                // We currently only handle 3 types of cast:
+                // (int*), (char*) , (int (*)())
+                if(typeEqual(pCast, mkpIntPtr)) {
+                    t = TOK_INT;
+                } else if (typeEqual(pCast, mkpCharPtr)) {
+                    t = TOK_CHAR;
+                } else if (typeEqual(pCast, mkpFloatPtr)) {
+                    t = TOK_FLOAT;
+                } else if (typeEqual(pCast, mkpDoublePtr)) {
+                    t = TOK_DOUBLE;
+                } else if (typeEqual(pCast, mkpPtrIntFn)){
+                    t = 0;
+                } else {
+                    String buffer;
+                    decodeType(buffer, pCast);
+                    error("Unsupported cast type %s", buffer.getUnwrapped());
+                    decodeType(buffer, mkpPtrIntFn);
+                }
+                skip(')');
+                unary(false);
+                if (accept('=')) {
+                    pGen->pushR0();
+                    expr();
+                    pGen->storeR0ToTOS(pCast);
+                } else if (t) {
+                    pGen->loadR0FromR0(pCast);
+                }
+                // Else we fall through to the function call below, with
+                // t == 0 to trigger an indirect function call. Hack!
+            } else if (t == '&') {
+                VariableInfo* pVI = VI(tok);
+                pGen->leaR0((int) pVI->pAddress,
+                            createPtrType(pVI->pType, mLocalArena));
+                next();
+            } else if (t == EOF ) {
+                error("Unexpected EOF.");
+            } else if (!checkSymbol(t)) {
+                // Don't have to do anything special here, the error
+                // message was printed by checkSymbol() above.
+            } else {
+                if (!isDefined(t)) {
+                    mGlobals.add(t);
+                    // printf("Adding new global function %s\n", nameof(t));
+                }
+                VariableInfo* pVI = VI(t);
+                n = (intptr_t) pVI->pAddress;
+                /* forward reference: try dlsym */
+                if (!n) {
+                    n = (intptr_t) dlsym(RTLD_DEFAULT, nameof(t));
+                    if (tok == '(') {
+                        pVI->pType = mkpIntFn;
+                    } else {
+                        pVI->pType = mkpInt;
+                    }
+                    pVI->pAddress = (void*) n;
+                }
+                if ((tok == '=') & allowAssignment) {
+                    /* assignment */
+                    next();
+                    expr();
+                    pGen->storeR0(n, pVI->pType);
+                } else if (tok != '(') {
+                    /* variable */
+                    if (!n) {
+                        error("Undefined variable %s", nameof(t));
+                    }
+                    pGen->loadR0(n, tokl == 11, tokc, pVI->pType);
+                    if (tokl == 11) {
+                        next();
+                    }
+                }
+            }
+        }
+
+        /* function call */
+        if (accept('(')) {
+            Type* pDecl = NULL;
+            VariableInfo* pVI = NULL;
+            if (n == 1) { // Indirect function call, push address of fn.
+                pDecl = pGen->getR0Type();
+                pGen->pushR0();
+            } else {
+                pVI = VI(t);
+                pDecl = pVI->pType;
+            }
+            Type* pArgList = pDecl->pTail;
+            bool varArgs = pArgList == NULL;
+            /* push args and invert order */
+            a = pGen->beginFunctionCallArguments();
+            int l = 0;
+            int argCount = 0;
+            while (tok != ')' && tok != EOF) {
+                if (! varArgs && !pArgList) {
+                    error ("Unexpected argument.");
+                }
+                expr();
+                Type* pTargetType;
+                if (pArgList) {
+                    pTargetType = pArgList->pHead;
+                    pArgList = pArgList->pTail;
+                } else {
+                    pTargetType = pGen->getR0Type();
+                    if (pTargetType->tag == TY_FLOAT) {
+                        pTargetType = mkpDouble;
+                    }
+                }
+                if (pTargetType->tag == TY_VOID) {
+                    error("Can't pass void value for argument %d",
+                          argCount + 1);
+                } else {
+                    pGen->convertR0(pTargetType);
+                    l += pGen->storeR0ToArg(l);
+                }
+                if (accept(',')) {
+                    // fine
+                } else if ( tok != ')') {
+                    error("Expected ',' or ')'");
+                }
+                argCount += 1;
+            }
+            if (! varArgs && pArgList) {
+                error ("Expected more argument(s). Saw %d", argCount);
+            }
+            pGen->endFunctionCallArguments(pDecl, a, l);
+            skip(')');
+            if (!n) {
+                /* forward reference */
+                pVI->pForward = (void*) pGen->callForward((int) pVI->pForward,
+                                                          pVI->pType);
+            } else if (n == 1) {
+                pGen->callIndirect(l, mkpPtrIntFn->pHead);
+            } else {
+                pGen->callRelative(n - codeBuf.getPC() - pGen->jumpOffset(),
+                                   VI(t)->pType);
+            }
+            pGen->adjustStackAfterCall(pDecl, l, n == 1);
+        }
+    }
+
+    /* Recursive descent parser for binary operations.
+     */
+    void binaryOp(int level) {
+        intptr_t t, n, a;
+        t = 0;
+        if (level-- == 1)
+            unary(true);
+        else {
+            binaryOp(level);
+            a = 0;
+            while (level == tokl) {
+                n = tok;
+                t = tokc;
+                next();
+
+                if (level > 8) {
+                    a = pGen->gtst(t == OP_LOGICAL_OR, a); /* && and || output code generation */
+                    binaryOp(level);
+                } else {
+                    pGen->pushR0();
+                    binaryOp(level);
+
+                    if ((level == 4) | (level == 5)) {
+                        pGen->gcmp(t, mkpInt);
+                    } else {
+                        pGen->genOp(t);
+                    }
+                }
+            }
+            /* && and || output code generation */
+            if (a && level > 8) {
+                a = pGen->gtst(t == OP_LOGICAL_OR, a);
+                pGen->li(t != OP_LOGICAL_OR, mkpInt);
+                pGen->gjmp(5); /* jmp $ + 5 (sizeof li, FIXME for ARM) */
+                pGen->gsym(a);
+                pGen->li(t == OP_LOGICAL_OR, mkpInt);
+            }
+        }
+    }
+
+    void expr() {
+        binaryOp(11);
+    }
+
+    int test_expr() {
+        expr();
+        return pGen->gtst(0, 0);
+    }
+
+    void block(intptr_t l, bool outermostFunctionBlock) {
+        intptr_t a, n, t;
+
+        Type* pBaseType;
+        if ((pBaseType = acceptPrimitiveType(mLocalArena))) {
+            /* declarations */
+            localDeclarations(pBaseType);
+        } else if (tok == TOK_IF) {
+            next();
+            skip('(');
+            a = test_expr();
+            skip(')');
+            block(l, false);
+            if (tok == TOK_ELSE) {
+                next();
+                n = pGen->gjmp(0); /* jmp */
+                pGen->gsym(a);
+                block(l, false);
+                pGen->gsym(n); /* patch else jmp */
+            } else {
+                pGen->gsym(a); /* patch if test */
+            }
+        } else if ((tok == TOK_WHILE) | (tok == TOK_FOR)) {
+            t = tok;
+            next();
+            skip('(');
+            if (t == TOK_WHILE) {
+                n = codeBuf.getPC(); // top of loop, target of "next" iteration
+                a = test_expr();
+            } else {
+                if (tok != ';')
+                    expr();
+                skip(';');
+                n = codeBuf.getPC();
+                a = 0;
+                if (tok != ';')
+                    a = test_expr();
+                skip(';');
+                if (tok != ')') {
+                    t = pGen->gjmp(0);
+                    expr();
+                    pGen->gjmp(n - codeBuf.getPC() - pGen->jumpOffset());
+                    pGen->gsym(t);
+                    n = t + 4;
+                }
+            }
+            skip(')');
+            block((intptr_t) &a, false);
+            pGen->gjmp(n - codeBuf.getPC() - pGen->jumpOffset()); /* jmp */
+            pGen->gsym(a);
+        } else if (tok == '{') {
+            if (! outermostFunctionBlock) {
+                mLocals.pushLevel();
+            }
+            next();
+            while (tok != '}' && tok != EOF)
+                block(l, false);
+            skip('}');
+            if (! outermostFunctionBlock) {
+                mLocals.popLevel();
+            }
+        } else {
+            if (accept(TOK_RETURN)) {
+                if (tok != ';') {
+                    expr();
+                    if (pReturnType->tag == TY_VOID) {
+                        error("Must not return a value from a void function");
+                    } else {
+                        pGen->convertR0(pReturnType);
+                    }
+                } else {
+                    if (pReturnType->tag != TY_VOID) {
+                        error("Must specify a value here");
+                    }
+                }
+                rsym = pGen->gjmp(rsym); /* jmp */
+            } else if (accept(TOK_BREAK)) {
+                *(int *) l = pGen->gjmp(*(int *) l);
+            } else if (tok != ';')
+                expr();
+            skip(';');
+        }
+    }
+
+    bool typeEqual(Type* a, Type* b) {
+        if (a == b) {
+            return true;
+        }
+        if (a == NULL || b == NULL) {
+            return false;
+        }
+        TypeTag at = a->tag;
+        if (at != b->tag) {
+            return false;
+        }
+        if (at == TY_POINTER) {
+            return typeEqual(a->pHead, b->pHead);
+        } else if (at == TY_FUNC || at == TY_PARAM) {
+            return typeEqual(a->pHead, b->pHead)
+                && typeEqual(a->pTail, b->pTail);
+        }
+        return true;
+    }
+
+    Type* createType(TypeTag tag, Type* pHead, Type* pTail, Arena& arena) {
+        assert(tag >= TY_INT && tag <= TY_PARAM);
+        Type* pType = (Type*) arena.alloc(sizeof(Type));
+        memset(pType, 0, sizeof(*pType));
+        pType->tag = tag;
+        pType->pHead = pHead;
+        pType->pTail = pTail;
+        return pType;
+    }
+
+    Type* createPtrType(Type* pType, Arena& arena) {
+        return createType(TY_POINTER, pType, NULL, arena);
+    }
+
+    /**
+     * Try to print a type in declaration order
+     */
+    void decodeType(String& buffer, Type* pType) {
+        buffer.clear();
+        if (pType == NULL) {
+            buffer.appendCStr("null");
+            return;
+        }
+        decodeTypeImp(buffer, pType);
+    }
+
+    void decodeTypeImp(String& buffer, Type* pType) {
+        decodeTypeImpPrefix(buffer, pType);
+
+        String temp;
+        if (pType->id != 0) {
+            decodeToken(temp, pType->id);
+            buffer.append(temp);
+        }
+
+        decodeTypeImpPostfix(buffer, pType);
+    }
+
+    void decodeTypeImpPrefix(String& buffer, Type* pType) {
+        TypeTag tag = pType->tag;
+
+        if (tag >= TY_INT && tag <= TY_VOID) {
+            switch (tag) {
+                case TY_INT:
+                    buffer.appendCStr("int");
+                    break;
+                case TY_CHAR:
+                    buffer.appendCStr("char");
+                    break;
+                case TY_VOID:
+                    buffer.appendCStr("void");
+                    break;
+                case TY_FLOAT:
+                    buffer.appendCStr("float");
+                    break;
+                case TY_DOUBLE:
+                    buffer.appendCStr("double");
+                    break;
+                default:
+                    break;
+            }
+            buffer.append(' ');
+        }
+
+        switch (tag) {
+            case TY_INT:
+                break;
+            case TY_CHAR:
+                break;
+            case TY_VOID:
+                 break;
+            case TY_FLOAT:
+                 break;
+            case TY_DOUBLE:
+                break;
+            case TY_POINTER:
+                decodeTypeImpPrefix(buffer, pType->pHead);
+                if(pType->pHead && pType->pHead->tag == TY_FUNC) {
+                    buffer.append('(');
+                }
+                buffer.append('*');
+                break;
+            case TY_FUNC:
+                decodeTypeImp(buffer, pType->pHead);
+                break;
+            case TY_PARAM:
+                decodeTypeImp(buffer, pType->pHead);
+                break;
+            default:
+                String temp;
+                temp.printf("Unknown tag %d", pType->tag);
+                buffer.append(temp);
+                break;
+        }
+    }
+
+    void decodeTypeImpPostfix(String& buffer, Type* pType) {
+        TypeTag tag = pType->tag;
+
+        switch(tag) {
+            case TY_POINTER:
+                if(pType->pHead && pType->pHead->tag == TY_FUNC) {
+                    buffer.append(')');
+                }
+                decodeTypeImpPostfix(buffer, pType->pHead);
+                break;
+            case TY_FUNC:
+                buffer.append('(');
+                for(Type* pArg = pType->pTail; pArg; pArg = pArg->pTail) {
+                    decodeTypeImp(buffer, pArg);
+                    if (pArg->pTail) {
+                        buffer.appendCStr(", ");
+                    }
+                }
+                buffer.append(')');
+                break;
+            default:
+                break;
+        }
+    }
+
+    void printType(Type* pType) {
+        String buffer;
+        decodeType(buffer, pType);
+        fprintf(stderr, "%s\n", buffer.getUnwrapped());
+    }
+
+    Type* acceptPrimitiveType(Arena& arena) {
+        Type* pType;
+        if (tok == TOK_INT) {
+            pType = mkpInt;
+        } else if (tok == TOK_CHAR) {
+            pType = mkpChar;
+        } else if (tok == TOK_VOID) {
+            pType = mkpVoid;
+        } else if (tok == TOK_FLOAT) {
+            pType = mkpFloat;
+        } else if (tok == TOK_DOUBLE) {
+            pType = mkpDouble;
+        } else {
+            return NULL;
+        }
+        next();
+        return pType;
+    }
+
+    Type* acceptDeclaration(Type* pType, bool nameAllowed, bool nameRequired,
+                            Arena& arena) {
+        tokenid_t declName = 0;
+        pType = acceptDecl2(pType, declName, nameAllowed,
+                                  nameRequired, arena);
+        if (declName) {
+            // Clone the parent type so we can set a unique ID
+            pType = createType(pType->tag, pType->pHead,
+                                      pType->pTail, arena);
+
+            pType->id = declName;
+        }
+        // fprintf(stderr, "Parsed a declaration:       ");
+        // printType(pType);
+        return pType;
+    }
+
+    Type* expectDeclaration(Type* pBaseType, Arena& arena) {
+        Type* pType = acceptDeclaration(pBaseType, true, true, arena);
+        if (! pType) {
+            error("Expected a declaration");
+        }
+        return pType;
+    }
+
+    /* Used for accepting types that appear in casts */
+    Type* acceptCastTypeDeclaration(Arena& arena) {
+        Type* pType = acceptPrimitiveType(arena);
+        if (pType) {
+            pType = acceptDeclaration(pType, false, false, arena);
+        }
+        return pType;
+    }
+
+    Type* expectCastTypeDeclaration(Arena& arena) {
+        Type* pType = acceptCastTypeDeclaration(arena);
+        if (! pType) {
+            error("Expected a declaration");
+        }
+        return pType;
+    }
+
+    Type* acceptDecl2(Type* pType, tokenid_t& declName,
+                      bool nameAllowed, bool nameRequired, Arena& arena) {
+        int ptrCounter = 0;
+        while (accept('*')) {
+            ptrCounter++;
+        }
+        pType = acceptDecl3(pType, declName, nameAllowed, nameRequired, arena);
+        while (ptrCounter-- > 0) {
+            pType = createType(TY_POINTER, pType, NULL, arena);
+        }
+        return pType;
+    }
+
+    Type* acceptDecl3(Type* pType, tokenid_t& declName,
+                      bool nameAllowed, bool nameRequired, Arena& arena) {
+        // direct-dcl :
+        //   name
+        //  (dcl)
+        //   direct-dcl()
+        //   direct-dcl[]
+        Type* pNewHead = NULL;
+        if (accept('(')) {
+            pNewHead = acceptDecl2(pNewHead, declName, nameAllowed,
+                                nameRequired, arena);
+            skip(')');
+        } else if ((declName = acceptSymbol()) != 0) {
+            if (nameAllowed == false && declName) {
+                error("Symbol %s not allowed here", nameof(declName));
+            } else if (nameRequired && ! declName) {
+                String temp;
+                decodeToken(temp, tok);
+                error("Expected symbol. Got %s", temp.getUnwrapped());
+            }
+        }
+        while (accept('(')) {
+            // Function declaration
+            Type* pTail = acceptArgs(nameAllowed, arena);
+            pType = createType(TY_FUNC, pType, pTail, arena);
+            skip(')');
+        }
+
+        if (pNewHead) {
+            Type* pA = pNewHead;
+            while (pA->pHead) {
+                pA = pA->pHead;
+            }
+            pA->pHead = pType;
+            pType = pNewHead;
+        }
+        return pType;
+    }
+
+    Type* acceptArgs(bool nameAllowed, Arena& arena) {
+        Type* pHead = NULL;
+        Type* pTail = NULL;
+        for(;;) {
+            Type* pBaseArg = acceptPrimitiveType(arena);
+            if (pBaseArg) {
+                Type* pArg = acceptDeclaration(pBaseArg, nameAllowed, false,
+                                               arena);
+                if (pArg) {
+                    Type* pParam = createType(TY_PARAM, pArg, NULL, arena);
+                    if (!pHead) {
+                        pHead = pParam;
+                        pTail = pParam;
+                    } else {
+                        pTail->pTail = pParam;
+                        pTail = pParam;
+                    }
+                }
+            }
+            if (! accept(',')) {
+                break;
+            }
+        }
+        return pHead;
+    }
+
+    Type* expectPrimitiveType(Arena& arena) {
+        Type* pType = acceptPrimitiveType(arena);
+        if (!pType) {
+            String buf;
+            decodeToken(buf, tok);
+            error("Expected a type, got %s", buf.getUnwrapped());
+        }
+        return pType;
+    }
+
+    void addGlobalSymbol(Type* pDecl) {
+        tokenid_t t = pDecl->id;
+        VariableInfo* pVI = VI(t);
+        if(pVI && pVI->pAddress) {
+            reportDuplicate(t);
+        }
+        mGlobals.add(pDecl);
+    }
+
+    void reportDuplicate(tokenid_t t) {
+        error("Duplicate definition of %s", nameof(t));
+    }
+
+    void addLocalSymbol(Type* pDecl) {
+        tokenid_t t = pDecl->id;
+        if (mLocals.isDefinedAtCurrentLevel(t)) {
+            reportDuplicate(t);
+        }
+        mLocals.add(pDecl);
+    }
+
+    void localDeclarations(Type* pBaseType) {
+        intptr_t a;
+
+        while (pBaseType) {
+            while (tok != ';' && tok != EOF) {
+                Type* pDecl = expectDeclaration(pBaseType, mLocalArena);
+                if (!pDecl) {
+                    break;
+                }
+                int variableAddress = 0;
+                addLocalSymbol(pDecl);
+                size_t alignment = pGen->alignmentOf(pDecl);
+                loc = (loc + alignment - 1) & ~ (alignment-1);
+                loc = loc + pGen->sizeOf(pDecl);
+                variableAddress = -loc;
+                VI(pDecl->id)->pAddress = (void*) variableAddress;
+                if (accept('=')) {
+                    /* assignment */
+                    expr();
+                    pGen->storeR0(variableAddress, pDecl);
+                }
+                if (tok == ',')
+                    next();
+            }
+            skip(';');
+            pBaseType = acceptPrimitiveType(mLocalArena);
+        }
+    }
+
+    bool checkSymbol() {
+        return checkSymbol(tok);
+    }
+
+    void decodeToken(String& buffer, tokenid_t token) {
+        if (token == EOF ) {
+            buffer.printf("EOF");
+        } else if (token == TOK_NUM) {
+            buffer.printf("numeric constant");
+        } else if (token >= 0 && token < 256) {
+            if (token < 32) {
+                buffer.printf("'\\x%02x'", token);
+            } else {
+                buffer.printf("'%c'", token);
+            }
+        } else if (token >= TOK_KEYWORD && token < TOK_SYMBOL) {
+            buffer.printf("keyword \"%s\"", nameof(token));
+        } else {
+            buffer.printf("symbol \"%s\"", nameof(token));
+        }
+    }
+
+    bool checkSymbol(tokenid_t token) {
+        bool result = token >= TOK_SYMBOL;
+        if (!result) {
+            String temp;
+            decodeToken(temp, token);
+            error("Expected symbol. Got %s", temp.getUnwrapped());
+        }
+        return result;
+    }
+
+    tokenid_t acceptSymbol() {
+        tokenid_t result = 0;
+        if (tok >= TOK_SYMBOL) {
+            result = tok;
+            next();
+        }
+        return result;
+    }
+
+    void globalDeclarations() {
+        while (tok != EOF) {
+            Type* pBaseType = expectPrimitiveType(mGlobalArena);
+            if (!pBaseType) {
+                break;
+            }
+            Type* pDecl = expectDeclaration(pBaseType, mGlobalArena);
+            if (!pDecl) {
+                break;
+            }
+            if (! isDefined(pDecl->id)) {
+                addGlobalSymbol(pDecl);
+            }
+            VariableInfo* name = VI(pDecl->id);
+            if (name && name->pAddress) {
+                error("Already defined global %s", nameof(pDecl->id));
+            }
+            if (pDecl->tag < TY_FUNC) {
+                // it's a variable declaration
+                for(;;) {
+                    if (name && !name->pAddress) {
+                        name->pAddress = (int*) allocGlobalSpace(
+                                                   pGen->alignmentOf(name->pType),
+                                                   pGen->sizeOf(name->pType));
+                    }
+                    if (accept('=')) {
+                        if (tok == TOK_NUM) {
+                            if (name) {
+                                * (int*) name->pAddress = tokc;
+                            }
+                            next();
+                        } else {
+                            error("Expected an integer constant");
+                        }
+                    }
+                    if (!accept(',')) {
+                        break;
+                    }
+                    pDecl = expectDeclaration(pBaseType, mGlobalArena);
+                    if (!pDecl) {
+                        break;
+                    }
+                    if (! isDefined(pDecl->id)) {
+                        addGlobalSymbol(pDecl);
+                    }
+                    name = VI(pDecl->id);
+                }
+                skip(';');
+            } else {
+                // Function declaration
+                if (accept(';')) {
+                    // forward declaration.
+                } else {
+                    if (name) {
+                        /* patch forward references (XXX: does not work for function
+                         pointers) */
+                        pGen->gsym((int) name->pForward);
+                        /* put function address */
+                        name->pAddress = (void*) codeBuf.getPC();
+                    }
+                    // Calculate stack offsets for parameters
+                    mLocals.pushLevel();
+                    intptr_t a = 8;
+                    int argCount = 0;
+                    for (Type* pP = pDecl->pTail; pP; pP = pP->pTail) {
+                        Type* pArg = pP->pHead;
+                        addLocalSymbol(pArg);
+                        /* read param name and compute offset */
+                        size_t alignment = pGen->alignmentOf(pArg);
+                        a = (a + alignment - 1) & ~ (alignment-1);
+                        VI(pArg->id)->pAddress = (void*) a;
+                        a = a + pGen->stackSizeOf(pArg);
+                        argCount++;
+                    }
+                    rsym = loc = 0;
+                    pReturnType = pDecl->pHead;
+                    a = pGen->functionEntry(pDecl);
+                    block(0, true);
+                    pGen->gsym(rsym);
+                    pGen->functionExit(pDecl, a, loc);
+                    mLocals.popLevel();
+                }
+            }
+        }
+    }
+
+    char* allocGlobalSpace(size_t alignment, size_t bytes) {
+        size_t base = (((size_t) glo) + alignment - 1) & ~(alignment-1);
+        size_t end = base + bytes;
+        if ((end - (size_t) pGlobalBase) > (size_t) ALLOC_SIZE) {
+            error("Global space exhausted");
+            return NULL;
+        }
+        char* result = (char*) base;
+        glo = (char*) end;
+        return result;
+    }
+
+    void cleanup() {
+        if (pGlobalBase != 0) {
+            free(pGlobalBase);
+            pGlobalBase = 0;
+        }
+        if (pGen) {
+            delete pGen;
+            pGen = 0;
+        }
+        if (file) {
+            delete file;
+            file = 0;
+        }
+    }
+
+    void clear() {
+        tok = 0;
+        tokc = 0;
+        tokl = 0;
+        ch = 0;
+        rsym = 0;
+        loc = 0;
+        glo = 0;
+        dptr = 0;
+        dch = 0;
+        file = 0;
+        pGlobalBase = 0;
+        pGen = 0;
+        mPragmaStringCount = 0;
+    }
+
+    void setArchitecture(const char* architecture) {
+        delete pGen;
+        pGen = 0;
+
+        if (architecture != NULL) {
+#ifdef PROVIDE_ARM_CODEGEN
+            if (! pGen && strcmp(architecture, "arm") == 0) {
+                pGen = new ARMCodeGenerator();
+            }
+#endif
+#ifdef PROVIDE_X86_CODEGEN
+            if (! pGen && strcmp(architecture, "x86") == 0) {
+                pGen = new X86CodeGenerator();
+            }
+#endif
+            if (!pGen ) {
+                error("Unknown architecture %s\n", architecture);
+            }
+        }
+
+        if (pGen == NULL) {
+#if defined(DEFAULT_ARM_CODEGEN)
+            pGen = new ARMCodeGenerator();
+#elif defined(DEFAULT_X86_CODEGEN)
+            pGen = new X86CodeGenerator();
+#endif
+        }
+        if (pGen == NULL) {
+            error("No code generator defined.");
+        } else {
+            pGen->setErrorSink(this);
+        }
+    }
+
+public:
+    struct args {
+        args() {
+            architecture = 0;
+        }
+        const char* architecture;
+    };
+
+    Compiler() {
+        clear();
+    }
+
+    ~Compiler() {
+        cleanup();
+    }
+
+    int compile(const char* text, size_t textLength) {
+        int result;
+
+        cleanup();
+        clear();
+        mTokenTable.setArena(&mGlobalArena);
+        mGlobals.setArena(&mGlobalArena);
+        mGlobals.setTokenTable(&mTokenTable);
+        mLocals.setArena(&mLocalArena);
+        mLocals.setTokenTable(&mTokenTable);
+
+        internKeywords();
+        createPrimitiveTypes();
+        codeBuf.init(ALLOC_SIZE);
+        setArchitecture(NULL);
+        if (!pGen) {
+            return -1;
+        }
+#ifdef PROVIDE_TRACE_CODEGEN
+            pGen = new TraceCodeGenerator(pGen);
+#endif
+            pGen->setErrorSink(this);
+        pGen->init(&codeBuf);
+        file = new TextInputStream(text, textLength);
+        pGlobalBase = (char*) calloc(1, ALLOC_SIZE);
+        glo = pGlobalBase;
+        inp();
+        next();
+        globalDeclarations();
+        checkForUndefinedForwardReferences();
+        result = pGen->finishCompile();
+        if (result == 0) {
+            if (mErrorBuf.len()) {
+                result = -2;
+            }
+        }
+        return result;
+    }
+
+    void createPrimitiveTypes() {
+        mkpInt = createType(TY_INT, NULL, NULL, mGlobalArena);
+        mkpChar = createType(TY_CHAR, NULL, NULL, mGlobalArena);
+        mkpVoid = createType(TY_VOID, NULL, NULL, mGlobalArena);
+        mkpFloat = createType(TY_FLOAT, NULL, NULL, mGlobalArena);
+        mkpDouble = createType(TY_DOUBLE, NULL, NULL, mGlobalArena);
+        mkpIntFn =  createType(TY_FUNC, mkpInt, NULL, mGlobalArena);
+        mkpIntPtr = createPtrType(mkpInt, mGlobalArena);
+        mkpCharPtr = createPtrType(mkpChar, mGlobalArena);
+        mkpFloatPtr = createPtrType(mkpFloat, mGlobalArena);
+        mkpDoublePtr = createPtrType(mkpDouble, mGlobalArena);
+        mkpPtrIntFn = createPtrType(mkpIntFn, mGlobalArena);
+    }
+
+    void checkForUndefinedForwardReferences() {
+        mGlobals.forEach(static_ufrcFn, this);
+    }
+
+    static bool static_ufrcFn(VariableInfo* value, void* context) {
+        Compiler* pCompiler = (Compiler*) context;
+        return pCompiler->undefinedForwardReferenceCheck(value);
+    }
+
+    bool undefinedForwardReferenceCheck(VariableInfo* value) {
+        if (!value->pAddress && value->pForward) {
+            error("Undefined forward reference: %s",
+                  mTokenTable[value->tok].pText);
+        }
+        return true;
+    }
+
+    int dump(FILE* out) {
+        fwrite(codeBuf.getBase(), 1, codeBuf.getSize(), out);
+        return 0;
+    }
+
+    int disassemble(FILE* out) {
+        return pGen->disassemble(out);
+    }
+
+    /* Look through the symbol table to find a symbol.
+     * If found, return its value.
+     */
+    void* lookup(const char* name) {
+        tokenid_t tok = mTokenTable.intern(name, strlen(name));
+        VariableInfo* pVariableInfo = VI(tok);
+        if (pVariableInfo) {
+            return pVariableInfo->pAddress;
+        }
+        return NULL;
+    }
+
+    void getPragmas(ACCsizei* actualStringCount,
+                    ACCsizei maxStringCount, ACCchar** strings) {
+        int stringCount = mPragmaStringCount;
+        if (actualStringCount) {
+            *actualStringCount = stringCount;
+        }
+        if (stringCount > maxStringCount) {
+            stringCount = maxStringCount;
+        }
+        if (strings) {
+            char* pPragmas = mPragmas.getUnwrapped();
+            while (stringCount-- > 0) {
+                *strings++ = pPragmas;
+                pPragmas += strlen(pPragmas) + 1;
+            }
+        }
+    }
+
+    char* getErrorMessage() {
+        return mErrorBuf.getUnwrapped();
+    }
+
+};
+
+const char* Compiler::operatorChars =
+    "++--*@/@%@+@-@<<>><=>=<@>@==!=&&||&@^@|@~@!@";
+
+const char Compiler::operatorLevel[] =
+    {11, 11, 1, 1, 1, 2, 2, 3, 3, 4, 4, 4, 4,
+            5, 5, /* ==, != */
+            9, 10, /* &&, || */
+            6, 7, 8, /* & ^ | */
+            2, 2 /* ~ ! */
+            };
+
+#ifdef PROVIDE_ARM_CODEGEN
+FILE* Compiler::ARMCodeGenerator::disasmOut;
+#endif
+
+#ifdef PROVIDE_X86_CODEGEN
+const int Compiler::X86CodeGenerator::operatorHelper[] = {
+        0x1,     // ++
+        0xff,    // --
+        0xc1af0f, // *
+        0xf9f79991, // /
+        0xf9f79991, // % (With manual assist to swap results)
+        0xc801, // +
+        0xd8f7c829, // -
+        0xe0d391, // <<
+        0xf8d391, // >>
+        0xe, // <=
+        0xd, // >=
+        0xc, // <
+        0xf, // >
+        0x4, // ==
+        0x5, // !=
+        0x0, // &&
+        0x1, // ||
+        0xc821, // &
+        0xc831, // ^
+        0xc809, // |
+        0xd0f7, // ~
+        0x4     // !
+};
+#endif
+
+struct ACCscript {
+    ACCscript() {
+        text = 0;
+        textLength = 0;
+        accError = ACC_NO_ERROR;
+    }
+
+    ~ACCscript() {
+        delete text;
+    }
+
+    void setError(ACCenum error) {
+        if (accError == ACC_NO_ERROR && error != ACC_NO_ERROR) {
+            accError = error;
+        }
+    }
+
+    ACCenum getError() {
+        ACCenum result = accError;
+        accError = ACC_NO_ERROR;
+        return result;
+    }
+
+    Compiler compiler;
+    char* text;
+    int textLength;
+    ACCenum accError;
+};
+
+
+extern "C"
+ACCscript* accCreateScript() {
+    return new ACCscript();
+}
+
+extern "C"
+ACCenum accGetError( ACCscript* script ) {
+    return script->getError();
+}
+
+extern "C"
+void accDeleteScript(ACCscript* script) {
+    delete script;
+}
+
+extern "C"
+void accScriptSource(ACCscript* script,
+    ACCsizei count,
+    const ACCchar ** string,
+    const ACCint * length) {
+    int totalLength = 0;
+    for(int i = 0; i < count; i++) {
+        int len = -1;
+        const ACCchar* s = string[i];
+        if (length) {
+            len = length[i];
+        }
+        if (len < 0) {
+            len = strlen(s);
+        }
+        totalLength += len;
+    }
+    delete script->text;
+    char* text = new char[totalLength + 1];
+    script->text = text;
+    script->textLength = totalLength;
+    char* dest = text;
+    for(int i = 0; i < count; i++) {
+        int len = -1;
+        const ACCchar* s = string[i];
+        if (length) {
+            len = length[i];
+        }
+        if (len < 0) {
+            len = strlen(s);
+        }
+        memcpy(dest, s, len);
+        dest += len;
+    }
+    text[totalLength] = '\0';
+}
+
+extern "C"
+void accCompileScript(ACCscript* script) {
+    int result = script->compiler.compile(script->text, script->textLength);
+    if (result) {
+        script->setError(ACC_INVALID_OPERATION);
+    }
+}
+
+extern "C"
+void accGetScriptiv(ACCscript* script,
+    ACCenum pname,
+    ACCint * params) {
+    switch (pname) {
+        case ACC_INFO_LOG_LENGTH:
+            *params = 0;
+            break;
+    }
+}
+
+extern "C"
+void accGetScriptInfoLog(ACCscript* script,
+    ACCsizei maxLength,
+    ACCsizei * length,
+    ACCchar * infoLog) {
+    char* message = script->compiler.getErrorMessage();
+    int messageLength = strlen(message) + 1;
+    if (length) {
+        *length = messageLength;
+    }
+    if (infoLog && maxLength > 0) {
+        int trimmedLength = maxLength < messageLength ?
+                maxLength : messageLength;
+        memcpy(infoLog, message, trimmedLength);
+        infoLog[trimmedLength] = 0;
+    }
+}
+
+extern "C"
+void accGetScriptLabel(ACCscript* script, const ACCchar * name,
+                       ACCvoid ** address) {
+    void* value = script->compiler.lookup(name);
+    if (value) {
+        *address = value;
+    } else {
+        script->setError(ACC_INVALID_VALUE);
+    }
+}
+
+extern "C"
+void accGetPragmas(ACCscript* script, ACCsizei* actualStringCount,
+                   ACCsizei maxStringCount, ACCchar** strings){
+    script->compiler.getPragmas(actualStringCount, maxStringCount, strings);
+}
+
+extern "C"
+void accDisassemble(ACCscript* script) {
+    script->compiler.disassemble(stderr);
+}
+
+
+} // namespace acc
+
diff --git a/libacc/armreg.h b/libacc/armreg.h
new file mode 100644
index 0000000..fde81ba
--- /dev/null
+++ b/libacc/armreg.h
@@ -0,0 +1,300 @@
+/*	$NetBSD: armreg.h,v 1.28 2003/10/31 16:30:15 scw Exp $	*/
+
+/*-
+ * Copyright (c) 1998, 2001 Ben Harris
+ * Copyright (c) 1994-1996 Mark Brinicombe.
+ * Copyright (c) 1994 Brini.
+ * All rights reserved.
+ *
+ * This code is derived from software written for Brini by Mark Brinicombe
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Brini.
+ * 4. The name of the company nor the name of the author may be used to
+ *    endorse or promote products derived from this software without specific
+ *    prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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.
+ *
+ * $FreeBSD: /repoman/r/ncvs/src/sys/arm/include/armreg.h,v 1.3 2005/11/21 19:06:25 cognet Exp $
+ */
+
+#ifndef MACHINE_ARMREG_H
+#define MACHINE_ARMREG_H
+#define INSN_SIZE	4
+#define INSN_COND_MASK	0xf0000000	/* Condition mask */
+#define PSR_MODE        0x0000001f      /* mode mask */
+#define PSR_USR26_MODE  0x00000000
+#define PSR_FIQ26_MODE  0x00000001
+#define PSR_IRQ26_MODE  0x00000002
+#define PSR_SVC26_MODE  0x00000003
+#define PSR_USR32_MODE  0x00000010
+#define PSR_FIQ32_MODE  0x00000011
+#define PSR_IRQ32_MODE  0x00000012
+#define PSR_SVC32_MODE  0x00000013
+#define PSR_ABT32_MODE  0x00000017
+#define PSR_UND32_MODE  0x0000001b
+#define PSR_SYS32_MODE  0x0000001f
+#define PSR_32_MODE     0x00000010
+#define PSR_FLAGS	0xf0000000    /* flags */
+
+#define PSR_C_bit (1 << 29)       /* carry */
+
+/* The high-order byte is always the implementor */
+#define CPU_ID_IMPLEMENTOR_MASK	0xff000000
+#define CPU_ID_ARM_LTD		0x41000000 /* 'A' */
+#define CPU_ID_DEC		0x44000000 /* 'D' */
+#define CPU_ID_INTEL		0x69000000 /* 'i' */
+#define	CPU_ID_TI		0x54000000 /* 'T' */
+
+/* How to decide what format the CPUID is in. */
+#define CPU_ID_ISOLD(x)		(((x) & 0x0000f000) == 0x00000000)
+#define CPU_ID_IS7(x)		(((x) & 0x0000f000) == 0x00007000)
+#define CPU_ID_ISNEW(x)		(!CPU_ID_ISOLD(x) && !CPU_ID_IS7(x))
+
+/* On ARM3 and ARM6, this byte holds the foundry ID. */
+#define CPU_ID_FOUNDRY_MASK	0x00ff0000
+#define CPU_ID_FOUNDRY_VLSI	0x00560000
+
+/* On ARM7 it holds the architecture and variant (sub-model) */
+#define CPU_ID_7ARCH_MASK	0x00800000
+#define CPU_ID_7ARCH_V3		0x00000000
+#define CPU_ID_7ARCH_V4T	0x00800000
+#define CPU_ID_7VARIANT_MASK	0x007f0000
+
+/* On more recent ARMs, it does the same, but in a different format */
+#define CPU_ID_ARCH_MASK	0x000f0000
+#define CPU_ID_ARCH_V3		0x00000000
+#define CPU_ID_ARCH_V4		0x00010000
+#define CPU_ID_ARCH_V4T		0x00020000
+#define CPU_ID_ARCH_V5		0x00030000
+#define CPU_ID_ARCH_V5T		0x00040000
+#define CPU_ID_ARCH_V5TE	0x00050000
+#define CPU_ID_VARIANT_MASK	0x00f00000
+
+/* Next three nybbles are part number */
+#define CPU_ID_PARTNO_MASK	0x0000fff0
+
+/* Intel XScale has sub fields in part number */
+#define CPU_ID_XSCALE_COREGEN_MASK	0x0000e000 /* core generation */
+#define CPU_ID_XSCALE_COREREV_MASK	0x00001c00 /* core revision */
+#define CPU_ID_XSCALE_PRODUCT_MASK	0x000003f0 /* product number */
+
+/* And finally, the revision number. */
+#define CPU_ID_REVISION_MASK	0x0000000f
+
+/* Individual CPUs are probably best IDed by everything but the revision. */
+#define CPU_ID_CPU_MASK		0xfffffff0
+
+/* Fake CPU IDs for ARMs without CP15 */
+#define CPU_ID_ARM2		0x41560200
+#define CPU_ID_ARM250		0x41560250
+
+/* Pre-ARM7 CPUs -- [15:12] == 0 */
+#define CPU_ID_ARM3		0x41560300
+#define CPU_ID_ARM600		0x41560600
+#define CPU_ID_ARM610		0x41560610
+#define CPU_ID_ARM620		0x41560620
+
+/* ARM7 CPUs -- [15:12] == 7 */
+#define CPU_ID_ARM700		0x41007000 /* XXX This is a guess. */
+#define CPU_ID_ARM710		0x41007100
+#define CPU_ID_ARM7500		0x41027100 /* XXX This is a guess. */
+#define CPU_ID_ARM710A		0x41047100 /* inc ARM7100 */
+#define CPU_ID_ARM7500FE	0x41077100
+#define CPU_ID_ARM710T		0x41807100
+#define CPU_ID_ARM720T		0x41807200
+#define CPU_ID_ARM740T8K	0x41807400 /* XXX no MMU, 8KB cache */
+#define CPU_ID_ARM740T4K	0x41817400 /* XXX no MMU, 4KB cache */
+
+/* Post-ARM7 CPUs */
+#define CPU_ID_ARM810		0x41018100
+#define CPU_ID_ARM920T		0x41129200
+#define CPU_ID_ARM920T_ALT	0x41009200
+#define CPU_ID_ARM922T		0x41029220
+#define CPU_ID_ARM940T		0x41029400 /* XXX no MMU */
+#define CPU_ID_ARM946ES		0x41049460 /* XXX no MMU */
+#define	CPU_ID_ARM966ES		0x41049660 /* XXX no MMU */
+#define	CPU_ID_ARM966ESR1	0x41059660 /* XXX no MMU */
+#define CPU_ID_ARM1020E		0x4115a200 /* (AKA arm10 rev 1) */
+#define CPU_ID_ARM1022ES	0x4105a220
+#define CPU_ID_SA110		0x4401a100
+#define CPU_ID_SA1100		0x4401a110
+#define	CPU_ID_TI925T		0x54029250
+#define CPU_ID_SA1110		0x6901b110
+#define CPU_ID_IXP1200		0x6901c120
+#define CPU_ID_80200		0x69052000
+#define CPU_ID_PXA250    	0x69052100 /* sans core revision */
+#define CPU_ID_PXA210    	0x69052120
+#define CPU_ID_PXA250A		0x69052100 /* 1st version Core */
+#define CPU_ID_PXA210A		0x69052120 /* 1st version Core */
+#define CPU_ID_PXA250B		0x69052900 /* 3rd version Core */
+#define CPU_ID_PXA210B		0x69052920 /* 3rd version Core */
+#define CPU_ID_PXA250C		0x69052d00 /* 4th version Core */
+#define CPU_ID_PXA210C		0x69052d20 /* 4th version Core */
+#define	CPU_ID_80321_400	0x69052420
+#define	CPU_ID_80321_600	0x69052430
+#define	CPU_ID_80321_400_B0	0x69052c20
+#define	CPU_ID_80321_600_B0	0x69052c30
+#define	CPU_ID_IXP425_533	0x690541c0
+#define	CPU_ID_IXP425_400	0x690541d0
+#define	CPU_ID_IXP425_266	0x690541f0
+
+/* ARM3-specific coprocessor 15 registers */
+#define ARM3_CP15_FLUSH		1
+#define ARM3_CP15_CONTROL	2
+#define ARM3_CP15_CACHEABLE	3
+#define ARM3_CP15_UPDATEABLE	4
+#define ARM3_CP15_DISRUPTIVE	5	
+
+/* ARM3 Control register bits */
+#define ARM3_CTL_CACHE_ON	0x00000001
+#define ARM3_CTL_SHARED		0x00000002
+#define ARM3_CTL_MONITOR	0x00000004
+
+/*
+ * Post-ARM3 CP15 registers:
+ *
+ *	1	Control register
+ *
+ *	2	Translation Table Base
+ *
+ *	3	Domain Access Control
+ *
+ *	4	Reserved
+ *
+ *	5	Fault Status
+ *
+ *	6	Fault Address
+ *
+ *	7	Cache/write-buffer Control
+ *
+ *	8	TLB Control
+ *
+ *	9	Cache Lockdown
+ *
+ *	10	TLB Lockdown
+ *
+ *	11	Reserved
+ *
+ *	12	Reserved
+ *
+ *	13	Process ID (for FCSE)
+ *
+ *	14	Reserved
+ *
+ *	15	Implementation Dependent
+ */
+
+/* Some of the definitions below need cleaning up for V3/V4 architectures */
+
+/* CPU control register (CP15 register 1) */
+#define CPU_CONTROL_MMU_ENABLE	0x00000001 /* M: MMU/Protection unit enable */
+#define CPU_CONTROL_AFLT_ENABLE	0x00000002 /* A: Alignment fault enable */
+#define CPU_CONTROL_DC_ENABLE	0x00000004 /* C: IDC/DC enable */
+#define CPU_CONTROL_WBUF_ENABLE 0x00000008 /* W: Write buffer enable */
+#define CPU_CONTROL_32BP_ENABLE 0x00000010 /* P: 32-bit exception handlers */
+#define CPU_CONTROL_32BD_ENABLE 0x00000020 /* D: 32-bit addressing */
+#define CPU_CONTROL_LABT_ENABLE 0x00000040 /* L: Late abort enable */
+#define CPU_CONTROL_BEND_ENABLE 0x00000080 /* B: Big-endian mode */
+#define CPU_CONTROL_SYST_ENABLE 0x00000100 /* S: System protection bit */
+#define CPU_CONTROL_ROM_ENABLE	0x00000200 /* R: ROM protection bit */
+#define CPU_CONTROL_CPCLK	0x00000400 /* F: Implementation defined */
+#define CPU_CONTROL_BPRD_ENABLE 0x00000800 /* Z: Branch prediction enable */
+#define CPU_CONTROL_IC_ENABLE   0x00001000 /* I: IC enable */
+#define CPU_CONTROL_VECRELOC	0x00002000 /* V: Vector relocation */
+#define CPU_CONTROL_ROUNDROBIN	0x00004000 /* RR: Predictable replacement */
+#define CPU_CONTROL_V4COMPAT	0x00008000 /* L4: ARMv4 compat LDR R15 etc */
+
+#define CPU_CONTROL_IDC_ENABLE	CPU_CONTROL_DC_ENABLE
+
+/* XScale Auxillary Control Register (CP15 register 1, opcode2 1) */
+#define	XSCALE_AUXCTL_K		0x00000001 /* dis. write buffer coalescing */
+#define	XSCALE_AUXCTL_P		0x00000002 /* ECC protect page table access */
+#define	XSCALE_AUXCTL_MD_WB_RA	0x00000000 /* mini-D$ wb, read-allocate */
+#define	XSCALE_AUXCTL_MD_WB_RWA	0x00000010 /* mini-D$ wb, read/write-allocate */
+#define	XSCALE_AUXCTL_MD_WT	0x00000020 /* mini-D$ wt, read-allocate */
+#define	XSCALE_AUXCTL_MD_MASK	0x00000030
+
+/* Cache type register definitions */
+#define	CPU_CT_ISIZE(x)		((x) & 0xfff)		/* I$ info */
+#define	CPU_CT_DSIZE(x)		(((x) >> 12) & 0xfff)	/* D$ info */
+#define	CPU_CT_S		(1U << 24)		/* split cache */
+#define	CPU_CT_CTYPE(x)		(((x) >> 25) & 0xf)	/* cache type */
+
+#define	CPU_CT_CTYPE_WT		0	/* write-through */
+#define	CPU_CT_CTYPE_WB1	1	/* write-back, clean w/ read */
+#define	CPU_CT_CTYPE_WB2	2	/* w/b, clean w/ cp15,7 */
+#define	CPU_CT_CTYPE_WB6	6	/* w/b, cp15,7, lockdown fmt A */
+#define	CPU_CT_CTYPE_WB7	7	/* w/b, cp15,7, lockdown fmt B */
+
+#define	CPU_CT_xSIZE_LEN(x)	((x) & 0x3)		/* line size */
+#define	CPU_CT_xSIZE_M		(1U << 2)		/* multiplier */
+#define	CPU_CT_xSIZE_ASSOC(x)	(((x) >> 3) & 0x7)	/* associativity */
+#define	CPU_CT_xSIZE_SIZE(x)	(((x) >> 6) & 0x7)	/* size */
+
+/* Fault status register definitions */
+
+#define FAULT_TYPE_MASK 0x0f
+#define FAULT_USER      0x10
+
+#define FAULT_WRTBUF_0  0x00 /* Vector Exception */
+#define FAULT_WRTBUF_1  0x02 /* Terminal Exception */
+#define FAULT_BUSERR_0  0x04 /* External Abort on Linefetch -- Section */
+#define FAULT_BUSERR_1  0x06 /* External Abort on Linefetch -- Page */
+#define FAULT_BUSERR_2  0x08 /* External Abort on Non-linefetch -- Section */
+#define FAULT_BUSERR_3  0x0a /* External Abort on Non-linefetch -- Page */
+#define FAULT_BUSTRNL1  0x0c /* External abort on Translation -- Level 1 */
+#define FAULT_BUSTRNL2  0x0e /* External abort on Translation -- Level 2 */
+#define FAULT_ALIGN_0   0x01 /* Alignment */
+#define FAULT_ALIGN_1   0x03 /* Alignment */
+#define FAULT_TRANS_S   0x05 /* Translation -- Section */
+#define FAULT_TRANS_P   0x07 /* Translation -- Page */
+#define FAULT_DOMAIN_S  0x09 /* Domain -- Section */
+#define FAULT_DOMAIN_P  0x0b /* Domain -- Page */
+#define FAULT_PERM_S    0x0d /* Permission -- Section */
+#define FAULT_PERM_P    0x0f /* Permission -- Page */
+
+#define	FAULT_IMPRECISE	0x400	/* Imprecise exception (XSCALE) */
+
+/*
+ * Address of the vector page, low and high versions.
+ */
+#define	ARM_VECTORS_LOW		0x00000000U
+#define	ARM_VECTORS_HIGH	0xffff0000U
+
+/*
+ * ARM Instructions
+ *
+ *       3 3 2 2 2                              
+ *       1 0 9 8 7                                                     0
+ *      +-------+-------------------------------------------------------+
+ *      | cond  |              instruction dependant                    |
+ *      |c c c c|                                                       |
+ *      +-------+-------------------------------------------------------+
+ */
+
+#define INSN_SIZE		4		/* Always 4 bytes */
+#define INSN_COND_MASK		0xf0000000	/* Condition mask */
+#define INSN_COND_AL		0xe0000000	/* Always condition */
+
+#endif /* !MACHINE_ARMREG_H */
diff --git a/libacc/disassem.cpp b/libacc/disassem.cpp
new file mode 100644
index 0000000..ac35342
--- /dev/null
+++ b/libacc/disassem.cpp
@@ -0,0 +1,711 @@
+/*	$NetBSD: disassem.c,v 1.14 2003/03/27 16:58:36 mycroft Exp $	*/
+
+/*-
+ * Copyright (c) 1996 Mark Brinicombe.
+ * Copyright (c) 1996 Brini.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Brini.
+ * 4. The name of the company nor the name of the author may be used to
+ *    endorse or promote products derived from this software without specific
+ *    prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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.
+ *
+ * RiscBSD kernel project
+ *
+ * db_disasm.c
+ *
+ * Kernel disassembler
+ *
+ * Created      : 10/02/96
+ *
+ * Structured after the sparc/sparc/db_disasm.c by David S. Miller &
+ * Paul Kranenburg
+ *
+ * This code is not complete. Not all instructions are disassembled.
+ */
+
+#include <sys/cdefs.h>
+//__FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/arm/arm/disassem.c,v 1.2 2005/01/05 21:58:47 imp Exp $");
+#include <sys/param.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "disassem.h"
+#include "armreg.h"
+//#include <ddb/ddb.h>
+
+/*
+ * General instruction format
+ *
+ *	insn[cc][mod]	[operands]
+ *
+ * Those fields with an uppercase format code indicate that the field
+ * follows directly after the instruction before the separator i.e.
+ * they modify the instruction rather than just being an operand to
+ * the instruction. The only exception is the writeback flag which
+ * follows a operand.
+ *
+ *
+ * 2 - print Operand 2 of a data processing instruction
+ * d - destination register (bits 12-15)
+ * n - n register (bits 16-19)
+ * s - s register (bits 8-11)
+ * o - indirect register rn (bits 16-19) (used by swap)
+ * m - m register (bits 0-3)
+ * a - address operand of ldr/str instruction
+ * e - address operand of ldrh/strh instruction
+ * l - register list for ldm/stm instruction
+ * f - 1st fp operand (register) (bits 12-14)
+ * g - 2nd fp operand (register) (bits 16-18)
+ * h - 3rd fp operand (register/immediate) (bits 0-4)
+ * b - branch address
+ * t - thumb branch address (bits 24, 0-23)
+ * k - breakpoint comment (bits 0-3, 8-19)
+ * X - block transfer type
+ * Y - block transfer type (r13 base)
+ * c - comment field bits(0-23)
+ * p - saved or current status register
+ * F - PSR transfer fields
+ * D - destination-is-r15 (P) flag on TST, TEQ, CMP, CMN
+ * L - co-processor transfer size
+ * S - set status flag
+ * P - fp precision
+ * Q - fp precision (for ldf/stf)
+ * R - fp rounding
+ * v - co-processor data transfer registers + addressing mode
+ * W - writeback flag
+ * x - instruction in hex
+ * # - co-processor number
+ * y - co-processor data processing registers
+ * z - co-processor register transfer registers
+ */
+
+struct arm32_insn {
+	u_int mask;
+	u_int pattern;
+	const char* name;
+	const char* format;
+};
+
+static const struct arm32_insn arm32_i[] = {
+    { 0x0fffffff, 0x0ff00000, "imb",	"c" },		/* Before swi */
+    { 0x0fffffff, 0x0ff00001, "imbrange",	"c" },	/* Before swi */
+    { 0x0f000000, 0x0f000000, "swi",	"c" },
+    { 0xfe000000, 0xfa000000, "blx",	"t" },		/* Before b and bl */
+    { 0x0f000000, 0x0a000000, "b",	"b" },
+    { 0x0f000000, 0x0b000000, "bl",	"b" },
+    { 0x0fe000f0, 0x00000090, "mul",	"Snms" },
+    { 0x0fe000f0, 0x00200090, "mla",	"Snmsd" },
+    { 0x0fe000f0, 0x00800090, "umull",	"Sdnms" },
+    { 0x0fe000f0, 0x00c00090, "smull",	"Sdnms" },
+    { 0x0fe000f0, 0x00a00090, "umlal",	"Sdnms" },
+    { 0x0fe000f0, 0x00e00090, "smlal",	"Sdnms" },
+    { 0x0d700000, 0x04200000, "strt",	"daW" },
+    { 0x0d700000, 0x04300000, "ldrt",	"daW" },
+    { 0x0d700000, 0x04600000, "strbt",	"daW" },
+    { 0x0d700000, 0x04700000, "ldrbt",	"daW" },
+    { 0x0c500000, 0x04000000, "str",	"daW" },
+    { 0x0c500000, 0x04100000, "ldr",	"daW" },
+    { 0x0c500000, 0x04400000, "strb",	"daW" },
+    { 0x0c500000, 0x04500000, "ldrb",	"daW" },
+    { 0x0e1f0000, 0x080d0000, "stm",	"YnWl" },/* separate out r13 base */
+    { 0x0e1f0000, 0x081d0000, "ldm",	"YnWl" },/* separate out r13 base */    
+    { 0x0e100000, 0x08000000, "stm",	"XnWl" },
+    { 0x0e100000, 0x08100000, "ldm",	"XnWl" },    
+    { 0x0e1000f0, 0x00100090, "ldrb",	"deW" },
+    { 0x0e1000f0, 0x00000090, "strb",	"deW" },
+    { 0x0e1000f0, 0x001000d0, "ldrsb",	"deW" },
+    { 0x0e1000f0, 0x001000b0, "ldrh",	"deW" },
+    { 0x0e1000f0, 0x000000b0, "strh",	"deW" },
+    { 0x0e1000f0, 0x001000f0, "ldrsh",	"deW" },
+    { 0x0f200090, 0x00200090, "und",	"x" },	/* Before data processing */
+    { 0x0e1000d0, 0x000000d0, "und",	"x" },	/* Before data processing */
+    { 0x0ff00ff0, 0x01000090, "swp",	"dmo" },
+    { 0x0ff00ff0, 0x01400090, "swpb",	"dmo" },
+    { 0x0fbf0fff, 0x010f0000, "mrs",	"dp" },	/* Before data processing */
+    { 0x0fb0fff0, 0x0120f000, "msr",	"pFm" },/* Before data processing */
+    { 0x0fb0f000, 0x0320f000, "msr",	"pF2" },/* Before data processing */
+    { 0x0ffffff0, 0x012fff10, "bx",     "m" },
+    { 0x0fff0ff0, 0x016f0f10, "clz",	"dm" },
+    { 0x0ffffff0, 0x012fff30, "blx",	"m" },
+    { 0xfff000f0, 0xe1200070, "bkpt",	"k" },
+    { 0x0de00000, 0x00000000, "and",	"Sdn2" },
+    { 0x0de00000, 0x00200000, "eor",	"Sdn2" },
+    { 0x0de00000, 0x00400000, "sub",	"Sdn2" },
+    { 0x0de00000, 0x00600000, "rsb",	"Sdn2" },
+    { 0x0de00000, 0x00800000, "add",	"Sdn2" },
+    { 0x0de00000, 0x00a00000, "adc",	"Sdn2" },
+    { 0x0de00000, 0x00c00000, "sbc",	"Sdn2" },
+    { 0x0de00000, 0x00e00000, "rsc",	"Sdn2" },
+    { 0x0df00000, 0x01100000, "tst",	"Dn2" },
+    { 0x0df00000, 0x01300000, "teq",	"Dn2" },
+    { 0x0df00000, 0x01500000, "cmp",	"Dn2" },
+    { 0x0df00000, 0x01700000, "cmn",	"Dn2" },
+    { 0x0de00000, 0x01800000, "orr",	"Sdn2" },
+    { 0x0de00000, 0x01a00000, "mov",	"Sd2" },
+    { 0x0de00000, 0x01c00000, "bic",	"Sdn2" },
+    { 0x0de00000, 0x01e00000, "mvn",	"Sd2" },
+    { 0x0ff08f10, 0x0e000100, "adf",	"PRfgh" },
+    { 0x0ff08f10, 0x0e100100, "muf",	"PRfgh" },
+    { 0x0ff08f10, 0x0e200100, "suf",	"PRfgh" },
+    { 0x0ff08f10, 0x0e300100, "rsf",	"PRfgh" },
+    { 0x0ff08f10, 0x0e400100, "dvf",	"PRfgh" },
+    { 0x0ff08f10, 0x0e500100, "rdf",	"PRfgh" },
+    { 0x0ff08f10, 0x0e600100, "pow",	"PRfgh" },
+    { 0x0ff08f10, 0x0e700100, "rpw",	"PRfgh" },
+    { 0x0ff08f10, 0x0e800100, "rmf",	"PRfgh" },
+    { 0x0ff08f10, 0x0e900100, "fml",	"PRfgh" },
+    { 0x0ff08f10, 0x0ea00100, "fdv",	"PRfgh" },
+    { 0x0ff08f10, 0x0eb00100, "frd",	"PRfgh" },
+    { 0x0ff08f10, 0x0ec00100, "pol",	"PRfgh" },
+    { 0x0f008f10, 0x0e000100, "fpbop",	"PRfgh" },
+    { 0x0ff08f10, 0x0e008100, "mvf",	"PRfh" },
+    { 0x0ff08f10, 0x0e108100, "mnf",	"PRfh" },
+    { 0x0ff08f10, 0x0e208100, "abs",	"PRfh" },
+    { 0x0ff08f10, 0x0e308100, "rnd",	"PRfh" },
+    { 0x0ff08f10, 0x0e408100, "sqt",	"PRfh" },
+    { 0x0ff08f10, 0x0e508100, "log",	"PRfh" },
+    { 0x0ff08f10, 0x0e608100, "lgn",	"PRfh" },
+    { 0x0ff08f10, 0x0e708100, "exp",	"PRfh" },
+    { 0x0ff08f10, 0x0e808100, "sin",	"PRfh" },
+    { 0x0ff08f10, 0x0e908100, "cos",	"PRfh" },
+    { 0x0ff08f10, 0x0ea08100, "tan",	"PRfh" },
+    { 0x0ff08f10, 0x0eb08100, "asn",	"PRfh" },
+    { 0x0ff08f10, 0x0ec08100, "acs",	"PRfh" },
+    { 0x0ff08f10, 0x0ed08100, "atn",	"PRfh" },
+    { 0x0f008f10, 0x0e008100, "fpuop",	"PRfh" },
+    { 0x0e100f00, 0x0c000100, "stf",	"QLv" },
+    { 0x0e100f00, 0x0c100100, "ldf",	"QLv" },
+    { 0x0ff00f10, 0x0e000110, "flt",	"PRgd" },
+    { 0x0ff00f10, 0x0e100110, "fix",	"PRdh" },
+    { 0x0ff00f10, 0x0e200110, "wfs",	"d" },
+    { 0x0ff00f10, 0x0e300110, "rfs",	"d" },
+    { 0x0ff00f10, 0x0e400110, "wfc",	"d" },
+    { 0x0ff00f10, 0x0e500110, "rfc",	"d" },
+    { 0x0ff0ff10, 0x0e90f110, "cmf",	"PRgh" },
+    { 0x0ff0ff10, 0x0eb0f110, "cnf",	"PRgh" },
+    { 0x0ff0ff10, 0x0ed0f110, "cmfe",	"PRgh" },
+    { 0x0ff0ff10, 0x0ef0f110, "cnfe",	"PRgh" },
+    { 0xff100010, 0xfe000010, "mcr2",	"#z" },
+    { 0x0f100010, 0x0e000010, "mcr",	"#z" },
+    { 0xff100010, 0xfe100010, "mrc2",	"#z" },
+    { 0x0f100010, 0x0e100010, "mrc",	"#z" },
+    { 0xff000010, 0xfe000000, "cdp2",	"#y" },
+    { 0x0f000010, 0x0e000000, "cdp",	"#y" },
+    { 0xfe100090, 0xfc100000, "ldc2",	"L#v" },
+    { 0x0e100090, 0x0c100000, "ldc",	"L#v" },
+    { 0xfe100090, 0xfc000000, "stc2",	"L#v" },
+    { 0x0e100090, 0x0c000000, "stc",	"L#v" },
+    { 0xf550f000, 0xf550f000, "pld",	"ne" },
+    { 0x0ff00ff0, 0x01000050, "qaad",	"dmn" },
+    { 0x0ff00ff0, 0x01400050, "qdaad",	"dmn" },
+    { 0x0ff00ff0, 0x01600050, "qdsub",	"dmn" },
+    { 0x0ff00ff0, 0x01200050, "dsub",	"dmn" },
+    { 0x0ff000f0, 0x01000080, "smlabb",	"nmsd" },   // d & n inverted!!
+    { 0x0ff000f0, 0x010000a0, "smlatb",	"nmsd" },   // d & n inverted!!
+    { 0x0ff000f0, 0x010000c0, "smlabt",	"nmsd" },   // d & n inverted!!
+    { 0x0ff000f0, 0x010000e0, "smlatt",	"nmsd" },   // d & n inverted!!
+    { 0x0ff000f0, 0x01400080, "smlalbb","ndms" },   // d & n inverted!!
+    { 0x0ff000f0, 0x014000a0, "smlaltb","ndms" },   // d & n inverted!!
+    { 0x0ff000f0, 0x014000c0, "smlalbt","ndms" },   // d & n inverted!!
+    { 0x0ff000f0, 0x014000e0, "smlaltt","ndms" },   // d & n inverted!!
+    { 0x0ff000f0, 0x01200080, "smlawb", "nmsd" },   // d & n inverted!!
+    { 0x0ff0f0f0, 0x012000a0, "smulwb","nms" },   // d & n inverted!!
+    { 0x0ff000f0, 0x012000c0, "smlawt", "nmsd" },   // d & n inverted!!
+    { 0x0ff0f0f0, 0x012000e0, "smulwt","nms" },   // d & n inverted!!
+    { 0x0ff0f0f0, 0x01600080, "smulbb","nms" },   // d & n inverted!!
+    { 0x0ff0f0f0, 0x016000a0, "smultb","nms" },   // d & n inverted!!
+    { 0x0ff0f0f0, 0x016000c0, "smulbt","nms" },   // d & n inverted!!
+    { 0x0ff0f0f0, 0x016000e0, "smultt","nms" },   // d & n inverted!!
+    { 0x00000000, 0x00000000, NULL,	NULL }
+};
+
+static char const arm32_insn_conditions[][4] = {
+	"eq", "ne", "cs", "cc",
+	"mi", "pl", "vs", "vc",
+	"hi", "ls", "ge", "lt",
+	"gt", "le", "",   "nv"
+};
+
+static char const insn_block_transfers[][4] = {
+	"da", "ia", "db", "ib"
+};
+
+static char const insn_stack_block_transfers[][4] = {
+	"ed", "ea", "fd", "fa"
+};
+
+static char const op_shifts[][4] = {
+	"lsl", "lsr", "asr", "ror"
+};
+
+static char const insn_fpa_rounding[][2] = {
+	"", "p", "m", "z"
+};
+
+static char const insn_fpa_precision[][2] = {
+	"s", "d", "e", "p"
+};
+
+static char const insn_fpaconstants[][8] = {
+	"0.0", "1.0", "2.0", "3.0",
+	"4.0", "5.0", "0.5", "10.0"
+};
+
+#define insn_condition(x)	arm32_insn_conditions[(x >> 28) & 0x0f]
+#define insn_blktrans(x)	insn_block_transfers[(x >> 23) & 3]
+#define insn_stkblktrans(x)	insn_stack_block_transfers[(x >> 23) & 3]
+#define op2_shift(x)		op_shifts[(x >> 5) & 3]
+#define insn_fparnd(x)		insn_fpa_rounding[(x >> 5) & 0x03]
+#define insn_fpaprec(x)		insn_fpa_precision[(((x >> 18) & 2)|(x >> 7)) & 1]
+#define insn_fpaprect(x)	insn_fpa_precision[(((x >> 21) & 2)|(x >> 15)) & 1]
+#define insn_fpaimm(x)		insn_fpaconstants[x & 0x07]
+
+/* Local prototypes */
+static void disasm_register_shift(const disasm_interface_t *di, u_int insn);
+static void disasm_print_reglist(const disasm_interface_t *di, u_int insn);
+static void disasm_insn_ldrstr(const disasm_interface_t *di, u_int insn,
+    u_int loc);
+static void disasm_insn_ldrhstrh(const disasm_interface_t *di, u_int insn,
+    u_int loc);
+static void disasm_insn_ldcstc(const disasm_interface_t *di, u_int insn,
+    u_int loc);
+static u_int disassemble_readword(u_int address);
+static void disassemble_printaddr(u_int address);
+
+u_int
+disasm(const disasm_interface_t *di, u_int loc, int altfmt)
+{
+	const struct arm32_insn *i_ptr = &arm32_i[0];
+
+	u_int insn;
+	int matchp;
+	int branch;
+	const char* f_ptr;
+	int fmt;
+
+	fmt = 0;
+	matchp = 0;
+	insn = di->di_readword(loc);
+
+/*	di->di_printf("loc=%08x insn=%08x : ", loc, insn);*/
+
+	while (i_ptr->name) {
+		if ((insn & i_ptr->mask) ==  i_ptr->pattern) {
+			matchp = 1;
+			break;
+		}
+		i_ptr++;
+	}
+
+	if (!matchp) {
+		di->di_printf("und%s\t%08x\n", insn_condition(insn), insn);
+		return(loc + INSN_SIZE);
+	}
+
+	/* If instruction forces condition code, don't print it. */
+	if ((i_ptr->mask & 0xf0000000) == 0xf0000000)
+		di->di_printf("%s", i_ptr->name);
+	else
+		di->di_printf("%s%s", i_ptr->name, insn_condition(insn));
+
+	f_ptr = i_ptr->format;
+
+	/* Insert tab if there are no instruction modifiers */
+
+	if (*(f_ptr) < 'A' || *(f_ptr) > 'Z') {
+		++fmt;
+		di->di_printf("\t");
+	}
+
+	while (*f_ptr) {
+		switch (*f_ptr) {
+		/* 2 - print Operand 2 of a data processing instruction */
+		case '2':
+			if (insn & 0x02000000) {
+				int rotate= ((insn >> 7) & 0x1e);
+
+				di->di_printf("#0x%08x",
+					      (insn & 0xff) << (32 - rotate) |
+					      (insn & 0xff) >> rotate);
+			} else {  
+				disasm_register_shift(di, insn);
+			}
+			break;
+		/* d - destination register (bits 12-15) */
+		case 'd':
+			di->di_printf("r%d", ((insn >> 12) & 0x0f));
+			break;
+		/* D - insert 'p' if Rd is R15 */
+		case 'D':
+			if (((insn >> 12) & 0x0f) == 15)
+				di->di_printf("p");
+			break;
+		/* n - n register (bits 16-19) */
+		case 'n':
+			di->di_printf("r%d", ((insn >> 16) & 0x0f));
+			break;
+		/* s - s register (bits 8-11) */
+		case 's':
+			di->di_printf("r%d", ((insn >> 8) & 0x0f));
+			break;
+		/* o - indirect register rn (bits 16-19) (used by swap) */
+		case 'o':
+			di->di_printf("[r%d]", ((insn >> 16) & 0x0f));
+			break;
+		/* m - m register (bits 0-4) */
+		case 'm':
+			di->di_printf("r%d", ((insn >> 0) & 0x0f));
+			break;
+		/* a - address operand of ldr/str instruction */
+		case 'a':
+			disasm_insn_ldrstr(di, insn, loc);
+			break;
+		/* e - address operand of ldrh/strh instruction */
+		case 'e':
+			disasm_insn_ldrhstrh(di, insn, loc);
+			break;
+		/* l - register list for ldm/stm instruction */
+		case 'l':
+			disasm_print_reglist(di, insn);
+			break;
+		/* f - 1st fp operand (register) (bits 12-14) */
+		case 'f':
+			di->di_printf("f%d", (insn >> 12) & 7);
+			break;
+		/* g - 2nd fp operand (register) (bits 16-18) */
+		case 'g':
+			di->di_printf("f%d", (insn >> 16) & 7);
+			break;
+		/* h - 3rd fp operand (register/immediate) (bits 0-4) */
+		case 'h':
+			if (insn & (1 << 3))
+				di->di_printf("#%s", insn_fpaimm(insn));
+			else
+				di->di_printf("f%d", insn & 7);
+			break;
+		/* b - branch address */
+		case 'b':
+			branch = ((insn << 2) & 0x03ffffff);
+			if (branch & 0x02000000)
+				branch |= 0xfc000000;
+			di->di_printaddr(loc + 8 + branch);
+			break;
+		/* t - blx address */
+		case 't':
+			branch = ((insn << 2) & 0x03ffffff) |
+			    (insn >> 23 & 0x00000002);
+			if (branch & 0x02000000)
+				branch |= 0xfc000000;
+			di->di_printaddr(loc + 8 + branch);
+			break;
+		/* X - block transfer type */
+		case 'X':
+			di->di_printf("%s", insn_blktrans(insn));
+			break;
+		/* Y - block transfer type (r13 base) */
+		case 'Y':
+			di->di_printf("%s", insn_stkblktrans(insn));
+			break;
+		/* c - comment field bits(0-23) */
+		case 'c':
+			di->di_printf("0x%08x", (insn & 0x00ffffff));
+			break;
+		/* k - breakpoint comment (bits 0-3, 8-19) */
+		case 'k':
+			di->di_printf("0x%04x",
+			    (insn & 0x000fff00) >> 4 | (insn & 0x0000000f));
+			break;
+		/* p - saved or current status register */
+		case 'p':
+			if (insn & 0x00400000)
+				di->di_printf("spsr");
+			else
+				di->di_printf("cpsr");
+			break;
+		/* F - PSR transfer fields */
+		case 'F':
+			di->di_printf("_");
+			if (insn & (1 << 16))
+				di->di_printf("c");
+			if (insn & (1 << 17))
+				di->di_printf("x");
+			if (insn & (1 << 18))
+				di->di_printf("s");
+			if (insn & (1 << 19))
+				di->di_printf("f");
+			break;
+		/* B - byte transfer flag */
+		case 'B':
+			if (insn & 0x00400000)
+				di->di_printf("b");
+			break;
+		/* L - co-processor transfer size */
+		case 'L':
+			if (insn & (1 << 22))
+				di->di_printf("l");
+			break;
+		/* S - set status flag */
+		case 'S':
+			if (insn & 0x00100000)
+				di->di_printf("s");
+			break;
+		/* P - fp precision */
+		case 'P':
+			di->di_printf("%s", insn_fpaprec(insn));
+			break;
+		/* Q - fp precision (for ldf/stf) */
+		case 'Q':
+			break;
+		/* R - fp rounding */
+		case 'R':
+			di->di_printf("%s", insn_fparnd(insn));
+			break;
+		/* W - writeback flag */
+		case 'W':
+			if (insn & (1 << 21))
+				di->di_printf("!");
+			break;
+		/* # - co-processor number */
+		case '#':
+			di->di_printf("p%d", (insn >> 8) & 0x0f);
+			break;
+		/* v - co-processor data transfer registers+addressing mode */
+		case 'v':
+			disasm_insn_ldcstc(di, insn, loc);
+			break;
+		/* x - instruction in hex */
+		case 'x':
+			di->di_printf("0x%08x", insn);
+			break;
+		/* y - co-processor data processing registers */
+		case 'y':
+			di->di_printf("%d, ", (insn >> 20) & 0x0f);
+
+			di->di_printf("c%d, c%d, c%d", (insn >> 12) & 0x0f,
+			    (insn >> 16) & 0x0f, insn & 0x0f);
+
+			di->di_printf(", %d", (insn >> 5) & 0x07);
+			break;
+		/* z - co-processor register transfer registers */
+		case 'z':
+			di->di_printf("%d, ", (insn >> 21) & 0x07);
+			di->di_printf("r%d, c%d, c%d, %d",
+			    (insn >> 12) & 0x0f, (insn >> 16) & 0x0f,
+			    insn & 0x0f, (insn >> 5) & 0x07);
+
+/*			if (((insn >> 5) & 0x07) != 0)
+				di->di_printf(", %d", (insn >> 5) & 0x07);*/
+			break;
+		default:
+			di->di_printf("[%c - unknown]", *f_ptr);
+			break;
+		}
+		if (*(f_ptr+1) >= 'A' && *(f_ptr+1) <= 'Z')
+			++f_ptr;
+		else if (*(++f_ptr)) {
+			++fmt;
+			if (fmt == 1)
+				di->di_printf("\t");
+			else
+				di->di_printf(", ");
+		}
+	};
+
+	di->di_printf("\n");
+
+	return(loc + INSN_SIZE);
+}
+
+
+static void
+disasm_register_shift(const disasm_interface_t *di, u_int insn)
+{
+	di->di_printf("r%d", (insn & 0x0f));
+	if ((insn & 0x00000ff0) == 0)
+		;
+	else if ((insn & 0x00000ff0) == 0x00000060)
+		di->di_printf(", rrx");
+	else {
+		if (insn & 0x10)
+			di->di_printf(", %s r%d", op2_shift(insn),
+			    (insn >> 8) & 0x0f);
+		else
+			di->di_printf(", %s #%d", op2_shift(insn),
+			    (insn >> 7) & 0x1f);
+	}
+}
+
+
+static void
+disasm_print_reglist(const disasm_interface_t *di, u_int insn)
+{
+	int loop;
+	int start;
+	int comma;
+
+	di->di_printf("{");
+	start = -1;
+	comma = 0;
+
+	for (loop = 0; loop < 17; ++loop) {
+		if (start != -1) {
+			if (loop == 16 || !(insn & (1 << loop))) {
+				if (comma)
+					di->di_printf(", ");
+				else
+					comma = 1;
+        			if (start == loop - 1)
+        				di->di_printf("r%d", start);
+        			else
+        				di->di_printf("r%d-r%d", start, loop - 1);
+        			start = -1;
+        		}
+        	} else {
+        		if (insn & (1 << loop))
+        			start = loop;
+        	}
+        }
+	di->di_printf("}");
+
+	if (insn & (1 << 22))
+		di->di_printf("^");
+}
+
+static void
+disasm_insn_ldrstr(const disasm_interface_t *di, u_int insn, u_int loc)
+{
+	int offset;
+
+	offset = insn & 0xfff;
+	if ((insn & 0x032f0000) == 0x010f0000) {
+		/* rA = pc, immediate index */
+		if (insn & 0x00800000)
+			loc += offset;
+		else
+			loc -= offset;
+		di->di_printaddr(loc + 8);
+ 	} else {
+		di->di_printf("[r%d", (insn >> 16) & 0x0f);
+		if ((insn & 0x03000fff) != 0x01000000) {
+			di->di_printf("%s, ", (insn & (1 << 24)) ? "" : "]");
+			if (!(insn & 0x00800000))
+				di->di_printf("-");
+			if (insn & (1 << 25))
+				disasm_register_shift(di, insn);
+			else
+				di->di_printf("#0x%03x", offset);
+		}
+		if (insn & (1 << 24))
+			di->di_printf("]");
+	}
+}
+
+static void
+disasm_insn_ldrhstrh(const disasm_interface_t *di, u_int insn, u_int loc)
+{
+	int offset;
+
+	offset = ((insn & 0xf00) >> 4) | (insn & 0xf);
+	if ((insn & 0x004f0000) == 0x004f0000) {
+		/* rA = pc, immediate index */
+		if (insn & 0x00800000)
+			loc += offset;
+		else
+			loc -= offset;
+		di->di_printaddr(loc + 8);
+ 	} else {
+		di->di_printf("[r%d", (insn >> 16) & 0x0f);
+		if ((insn & 0x01400f0f) != 0x01400000) {
+			di->di_printf("%s, ", (insn & (1 << 24)) ? "" : "]");
+			if (!(insn & 0x00800000))
+				di->di_printf("-");
+			if (insn & (1 << 22))
+				di->di_printf("#0x%02x", offset);
+			else
+				di->di_printf("r%d", (insn & 0x0f));
+		}
+		if (insn & (1 << 24))
+			di->di_printf("]");
+	}
+}
+
+static void
+disasm_insn_ldcstc(const disasm_interface_t *di, u_int insn, u_int loc)
+{
+	if (((insn >> 8) & 0xf) == 1)
+		di->di_printf("f%d, ", (insn >> 12) & 0x07);
+	else
+		di->di_printf("c%d, ", (insn >> 12) & 0x0f);
+
+	di->di_printf("[r%d", (insn >> 16) & 0x0f);
+
+	di->di_printf("%s, ", (insn & (1 << 24)) ? "" : "]");
+
+	if (!(insn & (1 << 23)))
+		di->di_printf("-");
+
+	di->di_printf("#0x%03x", (insn & 0xff) << 2);
+
+	if (insn & (1 << 24))
+		di->di_printf("]");
+
+	if (insn & (1 << 21))
+		di->di_printf("!");
+}
+
+static u_int
+disassemble_readword(u_int address)
+{
+	return(*((u_int *)address));
+}
+
+static void
+disassemble_printaddr(u_int address)
+{
+	printf("0x%08x", address);
+}
+
+static void
+disassemble_printf(const char *fmt, ...) {
+	va_list ap;
+	va_start(ap, fmt);
+	vprintf(fmt, ap);
+	va_end(ap);
+}
+
+static const disasm_interface_t disassemble_di = {
+	disassemble_readword, disassemble_printaddr, disassemble_printf
+};
+
+void
+disassemble(u_int address)
+{
+
+	(void)disasm(&disassemble_di, address, 0);
+}
+
+/* End of disassem.c */
diff --git a/libacc/disassem.h b/libacc/disassem.h
new file mode 100644
index 0000000..02747cd
--- /dev/null
+++ b/libacc/disassem.h
@@ -0,0 +1,65 @@
+/*	$NetBSD: disassem.h,v 1.4 2001/03/04 04:15:58 matt Exp $	*/
+
+/*-
+ * Copyright (c) 1997 Mark Brinicombe.
+ * Copyright (c) 1997 Causality Limited.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Mark Brinicombe.
+ * 4. The name of the company nor the name of the author may be used to
+ *    endorse or promote products derived from this software without specific
+ *    prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *
+ * Define the interface structure required by the disassembler.
+ *
+ * $FreeBSD: /repoman/r/ncvs/src/sys/arm/include/disassem.h,v 1.2 2005/01/05 21:58:48 imp Exp $
+ */
+
+#ifndef ANDROID_MACHINE_DISASSEM_H
+#define ANDROID_MACHINE_DISASSEM_H
+
+#include <sys/types.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+	u_int	(*di_readword)(u_int);
+	void	(*di_printaddr)(u_int);	
+	void	(*di_printf)(const char *, ...);
+} disasm_interface_t;
+
+/* Prototypes for callable functions */
+
+u_int disasm(const disasm_interface_t *, u_int, int);
+void disassemble(u_int);
+
+#if __cplusplus
+}
+#endif
+
+#endif /* !ANDROID_MACHINE_DISASSEM_H */
diff --git a/libacc/tests/.gitignore b/libacc/tests/.gitignore
new file mode 100644
index 0000000..a26b298
--- /dev/null
+++ b/libacc/tests/.gitignore
@@ -0,0 +1,2 @@
+test-acc
+*.out
diff --git a/libacc/tests/Android.mk b/libacc/tests/Android.mk
new file mode 100644
index 0000000..f8907b4
--- /dev/null
+++ b/libacc/tests/Android.mk
@@ -0,0 +1,33 @@
+LOCAL_PATH:= $(call my-dir)
+
+# Executable for host
+# ========================================================
+include $(CLEAR_VARS)
+LOCAL_MODULE:= acc
+
+LOCAL_SRC_FILES:= \
+	main.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+    libacc
+
+LOCAL_MODULE_TAGS := tests
+
+include $(BUILD_HOST_EXECUTABLE)
+
+# Executable for target
+# ========================================================
+include $(CLEAR_VARS)
+LOCAL_MODULE:= acc
+
+LOCAL_SRC_FILES:= \
+	main.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+    libacc
+
+LOCAL_CFLAGS := -O0 -g 
+
+LOCAL_MODULE_TAGS := tests
+
+include $(BUILD_EXECUTABLE)
diff --git a/libacc/tests/data/bellard.otccex.c b/libacc/tests/data/bellard.otccex.c
new file mode 100644
index 0000000..e8f0989
--- /dev/null
+++ b/libacc/tests/data/bellard.otccex.c
@@ -0,0 +1,126 @@
+/* #!/usr/local/bin/otcc */
+/*
+ * Sample OTCC C example. You can uncomment the first line and install
+ * otcc in /usr/local/bin to make otcc scripts !  
+ */
+
+/* Any preprocessor directive except #define are ignored. We put this
+   include so that a standard C compiler can compile this code too. */
+#include <stdio.h>
+
+/* defines are handled, but macro arguments cannot be given. No
+   recursive defines are tolerated */
+#define DEFAULT_BASE 10
+
+/*
+ * Only old style K&R prototypes are parsed. Only int arguments are
+ * allowed (implicit types).
+ * 
+ * By benchmarking the execution time of this function (for example
+ * for fib(35)), you'll notice that OTCC is quite fast because it
+ * generates native i386 machine code.  
+ */
+fib(n)
+{
+    if (n <= 2)
+        return 1;
+    else
+        return fib(n-1) + fib(n-2);
+}
+
+/* Identifiers are parsed the same way as C: begins with letter or
+   '_', and then letters, '_' or digits */
+fact(n)
+{
+    /* local variables can be declared. Only 'int' type is supported */
+    int i, r;
+    r = 1;
+    /* 'while' and 'for' loops are supported */
+    for(i=2;i<=n;i++)
+        r = r * i;
+    return r;
+}
+
+/* Well, we could use printf, but it would be too easy */
+print_num(n, b)
+{
+    int tab, p, c;
+    /* Numbers can be entered in decimal, hexadecimal ('0x' prefix) and
+       octal ('0' prefix) */
+    /* more complex programs use malloc */
+    tab = malloc(0x100); 
+    p = tab;
+    while (1) {
+        c = n % b;
+        /* Character constants can be used */
+        if (c >= 10)
+            c = c + 'a' - 10;
+        else
+            c = c + '0';
+        *(char *)p = c;
+        p++;
+        n = n / b;
+        /* 'break' is supported */
+        if (n == 0)
+            break;
+    }
+    while (p != tab) {
+        p--;
+        printf("%c", *(char *)p);
+    }
+    free(tab);
+}
+
+/* 'main' takes standard 'argc' and 'argv' parameters */
+main(argc, argv)
+{
+    /* no local name space is supported, but local variables ARE
+       supported. As long as you do not use a globally defined
+       variable name as local variable (which is a bad habbit), you
+       won't have any problem */
+    int s, n, f, base;
+    
+    /* && and || operator have the same semantics as C (left to right
+       evaluation and early exit) */
+    if (argc != 2 && argc != 3) {
+        /* '*' operator is supported with explicit casting to 'int *',
+           'char *' or 'int (*)()' (function pointer). Of course, 'int'
+           are supposed to be used as pointers too. */
+        s = *(int *)argv;
+        help(s);
+        return 1;
+    }
+    /* Any libc function can be used because OTCC uses dynamic linking */
+    n = atoi(*(int *)(argv + 4));
+    base = DEFAULT_BASE;
+    if (argc >= 3) {
+        base = atoi(*(int *)(argv + 8));
+        if (base < 2 || base > 36) {
+            /* external variables can be used too (here: 'stderr') */
+            fprintf(stderr, "Invalid base\n");
+            return 1;
+        }
+    }
+    printf("fib(%d) = ", n);
+    print_num(fib(n), base);
+    printf("\n");
+
+    printf("fact(%d) = ", n);
+    if (n > 12) {
+        printf("Overflow");
+    } else {
+        /* why not using a function pointer ? */
+        f = &fact;
+        print_num((*(int (*)())f)(n), base);
+    }
+    printf("\n");
+    return 0;
+}
+
+/* functions can be used before being defined */
+help(name)
+{
+    printf("usage: %s n [base]\n", name);
+    printf("Compute fib(n) and fact(n) and output the result in base 'base'\n");
+}
+
diff --git a/libacc/tests/data/constants.c b/libacc/tests/data/constants.c
new file mode 100644
index 0000000..230109a
--- /dev/null
+++ b/libacc/tests/data/constants.c
@@ -0,0 +1,30 @@
+#define FOO 0x10
+
+int main() {
+    printf("0 = %d\n", 0);
+    printf("010 = %d\n", 010);
+    printf("0x10 = %d\n", FOO);
+    printf("'\\a' = %d\n", '\a');
+    printf("'\\b' = %d\n", '\b');
+    printf("'\\f' = %d\n", '\f');
+    printf("'\\n' = %d\n", '\n');
+    printf("'\\r' = %d\n", '\r');
+    printf("'\\t' = %d\n", '\t');
+    printf("'\\v' = %d\n", '\v');
+    // Undefined
+    // printf("'\\z' = %d\n", '\z');
+    printf("'\\\\' = %d\n", '\\');
+    printf("'\\'' = %d\n", '\'');
+    printf("'\\\"' = %d\n", '\"');
+    printf("'\\?' = %d\n", '\?');
+    printf("'\\0' = %d\n", '\0');
+    printf("'\\1' = %d\n", '\1');
+    printf("'\\12' = %d\n", '\12');
+    printf("'\\123' = %d\n", '\123');
+    printf("'\\x0' = %d\n", '\x0');
+    printf("'\\x1' = %d\n", '\x1');
+    printf("'\\x12' = %d\n", '\x12');
+    printf("'\\x123' = %d\n", '\x123');
+    printf("'\\x1f' = %d\n", '\x1f');
+    printf("'\\x1F' = %d\n", '\x1F');
+}
diff --git a/libacc/tests/data/double.c b/libacc/tests/data/double.c
new file mode 100644
index 0000000..5bc20a3
--- /dev/null
+++ b/libacc/tests/data/double.c
@@ -0,0 +1,7 @@
+double atof(char *nptr);
+
+int main() {
+    printf("Value = %g\n", atof("10.42"));
+    return 0;
+}
+
diff --git a/libacc/tests/data/error.c b/libacc/tests/data/error.c
new file mode 100644
index 0000000..2e08dcc
--- /dev/null
+++ b/libacc/tests/data/error.c
@@ -0,0 +1,2 @@
+void foo;
+
diff --git a/libacc/tests/data/expr-ansi.c b/libacc/tests/data/expr-ansi.c
new file mode 100644
index 0000000..d463659
--- /dev/null
+++ b/libacc/tests/data/expr-ansi.c
@@ -0,0 +1,60 @@
+/* Test operators */
+
+void testInc() { int a, b; a = 3; b = a++; printf("3++ = %d %d\n", b, a); }
+void testDec() { int a, b; a = 3; b = a--; printf("3-- = %d %d\n", b, a); }
+void testTimes(){ printf("%d * %d = %d\n", 10, 4, 10 * 4); }
+void testDiv(){ printf("%d / %d = %d\n", 11, 4, 11 / 4); }
+void testMod(){ printf("%d %% %d = %d\n", 11, 4, 11 % 4); }
+void testPlus(){ printf("%d + %d = %d\n", 10, 4, 10 + 4); }
+void testMinus(){ printf("%d - %d = %d\n", 10, 4, 10 - 4); }
+void testShiftLeft(){ printf("%d << %d = %d\n", 10, 4, 10 << 4); }
+void testShiftRight(){ printf("%d >> %d = %d\n", 100, 4, 100 >> 4); }
+void testLess(){ printf("%d < %d = %d\n", 10, 4, 10 < 4); }
+void testLesEqual(){ printf("%d <= %d = %d\n", 10, 4, 10 <= 4); }
+void testGreater(){ printf("%d > %d = %d\n", 10, 4, 10 > 4); }
+void testGreaterEqual(){ printf("%d >= %d = %d\n", 10, 4, 10 >= 4); }
+void testEqualTo(){ printf("%d == %d = %d\n", 10, 4, 10 == 4); }
+void testNotEqualTo(){ printf("%d != %d = %d\n", 10, 4, 10 != 4); }
+void testBitAnd(){ printf("%d & %d = %d\n", 10, 7, 10 & 7); }
+void testBitXor(){ printf("%d ^ %d = %d\n", 10, 7, 10 ^ 7); }
+void testBitOr(){ printf("%d | %d = %d\n", 10, 4, 10 | 4); }
+void testAssignment(){ int a, b; a = 3; b = a; printf("b == %d\n", b); }
+void testLogicalAnd(){ printf("%d && %d = %d\n", 10, 4, 10 && 4); }
+void testLogicalOr(){ printf("%d || %d = %d\n", 10, 4, 10 || 4); }
+void testAddressOf(){ int a; printf("&a is %d\n", &a); }
+void testPointerIndirection(){ int a, b; a = &b; b = 17; printf("*%d  = %d =?= %d\n", a, * (int*) a, b); }
+void testNegation(){ printf("-%d = %d\n", 10, -10); }
+void testUnaryPlus(){ printf("+%d = %d\n", 10, +10); }
+void testUnaryNot(){ printf("!%d = %d\n", 10, !10); }
+void testBitNot(){ printf("~%d = %d\n", 10, ~10); }
+
+int main(int a, char** b) {
+    testInc();
+    testDec();
+    testTimes();
+    testDiv();
+    testMod();
+    testPlus();
+    testMinus();
+    testShiftLeft();
+    testShiftRight();
+    testLess();
+    testLesEqual();
+    testGreater();
+    testGreaterEqual();
+    testEqualTo();
+    testNotEqualTo();
+    testBitAnd();
+    testBinXor();
+    testBitOr();
+    testAssignment();
+    testLogicalAnd();
+    testLogicalOr();
+    testAddressOf();
+    testPointerIndirection();
+    testNegation();
+    testUnaryPlus();
+    testUnaryNot();
+    testBitNot();
+    return 0;
+}
diff --git a/libacc/tests/data/expr.c b/libacc/tests/data/expr.c
new file mode 100644
index 0000000..4f2d2e7
--- /dev/null
+++ b/libacc/tests/data/expr.c
@@ -0,0 +1,60 @@
+/* Test operators */
+
+testInc() { int a, b; a = 3; b = a++; printf("3++ = %d %d\n", b, a); }
+testDec() { int a, b; a = 3; b = a--; printf("3-- = %d %d\n", b, a); }
+testTimes(){ printf("%d * %d = %d\n", 10, 4, 10 * 4); }
+testDiv(){ printf("%d / %d = %d\n", 11, 4, 11 / 4); }
+testMod(){ printf("%d %% %d = %d\n", 11, 4, 11 % 4); }
+testPlus(){ printf("%d + %d = %d\n", 10, 4, 10 + 4); }
+testMinus(){ printf("%d - %d = %d\n", 10, 4, 10 - 4); }
+testShiftLeft(){ printf("%d << %d = %d\n", 10, 4, 10 << 4); }
+testShiftRight(){ printf("%d >> %d = %d\n", 100, 4, 100 >> 4); }
+testLess(){ printf("%d < %d = %d\n", 10, 4, 10 < 4); }
+testLesEqual(){ printf("%d <= %d = %d\n", 10, 4, 10 <= 4); }
+testGreater(){ printf("%d > %d = %d\n", 10, 4, 10 > 4); }
+testGreaterEqual(){ printf("%d >= %d = %d\n", 10, 4, 10 >= 4); }
+testEqualTo(){ printf("%d == %d = %d\n", 10, 4, 10 == 4); }
+testNotEqualTo(){ printf("%d != %d = %d\n", 10, 4, 10 != 4); }
+testBitAnd(){ printf("%d & %d = %d\n", 10, 7, 10 & 7); }
+testBitXor(){ printf("%d ^ %d = %d\n", 10, 7, 10 ^ 7); }
+testBitOr(){ printf("%d | %d = %d\n", 10, 4, 10 | 4); }
+testAssignment(){ int a, b; a = 3; b = a; printf("b == %d\n", b); }
+testLogicalAnd(){ printf("%d && %d = %d\n", 10, 4, 10 && 4); }
+testLogicalOr(){ printf("%d || %d = %d\n", 10, 4, 10 || 4); }
+testAddressOf(){ int a; printf("&a is %d\n", &a); }
+testPointerIndirection(){ int a, b; a = &b; b = 17; printf("*%d  = %d =?= %d\n", a, * (int*) a, b); }
+testNegation(){ printf("-%d = %d\n", 10, -10); }
+testUnaryPlus(){ printf("+%d = %d\n", 10, +10); }
+testUnaryNot(){ printf("!%d = %d\n", 10, !10); }
+testBitNot(){ printf("~%d = %d\n", 10, ~10); }
+
+main(a,b) {
+    testInc();
+    testDec();
+    testTimes();
+    testDiv();
+    testMod();
+    testPlus();
+    testMinus();
+    testShiftLeft();
+    testShiftRight();
+    testLess();
+    testLesEqual();
+    testGreater();
+    testGreaterEqual();
+    testEqualTo();
+    testNotEqualTo();
+    testBitAnd();
+    testBinXor();
+    testBitOr();
+    testAssignment();
+    testLogicalAnd();
+    testLogicalOr();
+    testAddressOf();
+    testPointerIndirection();
+    testNegation();
+    testUnaryPlus();
+    testUnaryNot();
+    testBitNot();
+    return 0;
+}
\ No newline at end of file
diff --git a/libacc/tests/data/expr2.c b/libacc/tests/data/expr2.c
new file mode 100644
index 0000000..04b6a38
--- /dev/null
+++ b/libacc/tests/data/expr2.c
@@ -0,0 +1,6 @@
+/* Test operators */
+
+main() {
+    int a;
+    a = a++;
+}
diff --git a/libacc/tests/data/float.c b/libacc/tests/data/float.c
new file mode 100644
index 0000000..8625cf1
--- /dev/null
+++ b/libacc/tests/data/float.c
@@ -0,0 +1,51 @@
+int ftoi(float f) {
+    return f;
+}
+
+int dtoi(double d) {
+    return d;
+}
+
+float itof(int i) {
+    return i;
+}
+
+double itod(int i) {
+    return i;
+}
+
+float f0, f1;
+double d0, d1;
+
+void testVars(float arg0, float arg1, double arg2, double arg3) {
+    float local0, local1;
+    double local2, local3;
+    f0 = arg0;
+    f1 = arg1;
+    d0 = arg2;
+    d1 = arg3;
+    local0 = arg0;
+    local1 = arg1;
+    local2 = arg2;
+    local3 = arg3;
+    printf("globals: %g %g %g %g\n", f0, f1, d0, d1);
+    printf("args: %g %g %g %g\n", arg0, arg1, arg2, arg3);
+    printf("locals: %g %g %g %g\n", local0, local1, local2, local3);
+
+
+    printf("cast rval: %g %g\n", * (float*) & f1, * (double*) & d1);
+
+    * (float*) & f0 = 1.1f;
+    * (double*) & d0 = 3.3;
+    printf("cast lval: %g %g %g %g\n", f0, f1, d0, d1);
+}
+
+int main() {
+    printf("int: %d float: %g double: %g\n", 1, 2.2f, 3.3);
+    printf(" ftoi(1.4f)=%d\n", ftoi(1.4f));
+    printf(" dtoi(2.4)=%d\n", dtoi(2.4));
+    printf(" itof(3)=%g\n", itof(3));
+    printf(" itod(4)=%g\n", itod(4));
+    testVars(1.0f, 2.0f, 3.0, 4.0);
+    return 0;
+}
diff --git a/libacc/tests/data/flops.c b/libacc/tests/data/flops.c
new file mode 100644
index 0000000..7374056
--- /dev/null
+++ b/libacc/tests/data/flops.c
@@ -0,0 +1,151 @@
+// Test floating point operations.
+
+void unaryOps() {
+    // Unary ops
+    printf("-%g = %g\n", 1.1, -1.1);
+    printf("!%g = %d\n", 1.2, !1.2);
+    printf("!%g = %d\n", 0.0, !0.0);
+}
+
+void binaryOps() {
+    printf("double op double:\n");
+    printf("%g + %g = %g\n", 1.0, 2.0, 1.0 + 2.0);
+    printf("%g - %g = %g\n", 1.0, 2.0, 1.0 - 2.0);
+    printf("%g * %g = %g\n", 1.0, 2.0, 1.0 * 2.0);
+    printf("%g / %g = %g\n", 1.0, 2.0, 1.0 / 2.0);
+
+    printf("float op float:\n");
+    printf("%g + %g = %g\n", 1.0f, 2.0f, 1.0f + 2.0f);
+    printf("%g - %g = %g\n", 1.0f, 2.0f, 1.0f - 2.0f);
+    printf("%g * %g = %g\n", 1.0f, 2.0f, 1.0f * 2.0f);
+    printf("%g / %g = %g\n", 1.0f, 2.0f, 1.0f / 2.0f);
+
+    printf("double op float:\n");
+    printf("%g + %g = %g\n", 1.0, 2.0f, 1.0 + 2.0f);
+    printf("%g - %g = %g\n", 1.0, 2.0f, 1.0 - 2.0f);
+    printf("%g * %g = %g\n", 1.0, 2.0f, 1.0 * 2.0f);
+    printf("%g / %g = %g\n", 1.0, 2.0f, 1.0 / 2.0f);
+
+    printf("double op int:\n");
+    printf("%g + %d = %g\n", 1.0, 2, 1.0 + 2);
+    printf("%g - %d = %g\n", 1.0, 2, 1.0 - 2);
+    printf("%g * %d = %g\n", 1.0, 2, 1.0 * 2);
+    printf("%g / %d = %g\n", 1.0, 2, 1.0 / 2);
+
+    printf("int op double:\n");
+    printf("%d + %g = %g\n", 1, 2.0, 1 + 2.0);
+    printf("%d - %g = %g\n", 1, 2.0, 1 - 2.0);
+    printf("%d * %g = %g\n", 1, 2.0, 1 * 2.0);
+    printf("%d / %g = %g\n", 1, 2.0, 1 / 2.0);
+}
+
+void comparisonTestdd(double a, double b) {
+    printf("%g op %g: < %d   <= %d   == %d   >= %d   > %d   != %d\n",
+           a, b, a < b, a <= b, a == b, a >= b, a > b, a != b);
+}
+
+void comparisonOpsdd() {
+    printf("double op double:\n");
+    comparisonTestdd(1.0, 2.0);
+    comparisonTestdd(1.0, 1.0);
+    comparisonTestdd(2.0, 1.0);
+}
+
+
+void comparisonTestdf(double a, float b) {
+    printf("%g op %g: < %d   <= %d   == %d   >= %d   > %d   != %d\n",
+           a, b, a < b, a <= b, a == b, a >= b, a > b, a != b);
+}
+
+void comparisonOpsdf() {
+    printf("double op float:\n");
+    comparisonTestdf(1.0, 2.0f);
+    comparisonTestdf(1.0, 1.0f);
+    comparisonTestdf(2.0, 1.0f);
+}
+
+void comparisonTestff(float a, float b) {
+    printf("%g op %g: < %d   <= %d   == %d   >= %d   > %d   != %d\n",
+           a, b, a < b, a <= b, a == b, a >= b, a > b, a != b);
+}
+
+void comparisonOpsff() {
+    printf("float op float:\n");
+    comparisonTestff(1.0f, 2.0f);
+    comparisonTestff(1.0f, 1.0f);
+    comparisonTestff(2.0f, 1.0f);
+}
+
+void comparisonTestid(int a, double b) {
+    printf("%d op %g: < %d   <= %d   == %d   >= %d   > %d   != %d\n",
+           a, b, a < b, a <= b, a == b, a >= b, a > b, a != b);
+}
+
+void comparisonOpsid() {
+    printf("int op double:\n");
+    comparisonTestid(1, 2.0);
+    comparisonTestid(1, 1.0);
+    comparisonTestid(2, 1.0);
+}
+void comparisonTestdi(double a, int b) {
+    printf("%g op %d: < %d   <= %d   == %d   >= %d   > %d   != %d\n",
+           a, b, a < b, a <= b, a == b, a >= b, a > b, a != b);
+}
+
+void comparisonOpsdi() {
+    printf("double op int:\n");
+    comparisonTestdi(1.0f, 2);
+    comparisonTestdi(1.0f, 1);
+    comparisonTestdi(2.0f, 1);
+}
+
+void comparisonOps() {
+    comparisonOpsdd();
+    comparisonOpsdf();
+    comparisonOpsff();
+    comparisonOpsid();
+    comparisonOpsdi();
+}
+
+int branch(double d) {
+    if (d) {
+        return 1;
+    }
+    return 0;
+}
+
+void testBranching() {
+    printf("branching: %d %d %d\n", branch(-1.0), branch(0.0), branch(1.0));
+}
+
+void testpassi(int a, int b, int c, int d, int e, int f, int g, int h) {
+    printf("testpassi: %d %d %d %d %d %d %d %d\n", a, b, c, d, e, f, g, h);
+}
+
+void testpassf(float a, float b, float c, float d, float e, float f, float g, float h) {
+    printf("testpassf: %g %g %g %g %g %g %g %g\n", a, b, c, d, e, f, g, h);
+}
+
+void testpassd(double a, double b, double c, double d, double e, double f, double g, double h) {
+    printf("testpassd: %g %g %g %g %g %g %g %g\n", a, b, c, d, e, f, g, h);
+}
+
+void testpassidf(int i, double d, float f) {
+    printf("testpassidf: %d %g %g\n", i, d, f);
+}
+
+void testParameterPassing() {
+    testpassi(1, 2, 3, 4, 5, 6, 7, 8);
+    testpassf(1, 2, 3, 4, 5, 6, 7, 8);
+    testpassd(1, 2, 3, 4, 5, 6, 7, 8);
+    testpassidf(1, 2.0, 3.0f);
+}
+
+int main() {
+    unaryOps();
+    binaryOps();
+    comparisonOps();
+    testBranching();
+    testParameterPassing();
+    return 0;
+}
diff --git a/libacc/tests/data/hello.c b/libacc/tests/data/hello.c
new file mode 100644
index 0000000..585ce6c
--- /dev/null
+++ b/libacc/tests/data/hello.c
@@ -0,0 +1,3 @@
+main(a,b) {
+    printf("Hello, world\n");
+}
diff --git a/libacc/tests/data/locals.c b/libacc/tests/data/locals.c
new file mode 100644
index 0000000..f1ef363
--- /dev/null
+++ b/libacc/tests/data/locals.c
@@ -0,0 +1,71 @@
+int a;
+
+int f() {
+    int a;
+    // Undefined variable b
+    // printf("f 0: a = %d b = %d\n", a, b);
+    printf("f 0: a = %d\n", a);
+    a = 2;
+    printf("f 1: a = %d\n", a);
+}
+
+int g(int a) {
+    printf("g 0: a = %d\n", a);
+    a = 3;
+    printf("g 1: a = %d\n", a);
+}
+
+int h(int a) {
+    // int a; // gcc 4.3 says error: 'a' redeclared as different kind of symbol
+
+    printf("h 0: a = %d\n", a);
+    a = 4;
+    printf("h 1: a = %d\n", a);
+}
+
+// Already defined global 
+// int h() {}
+int globCheck() {
+    fprintf(stdout, "globCheck()\n");
+}
+
+int fwdCheck() {
+    b();
+    // Undefined forward reference
+    // c();
+}
+
+int b() {
+    printf("b()\n");
+}
+
+int nested() {
+    int a;
+    printf("nested 0: a = %d\n", a);
+    a = 50;
+    printf("nested 1: a = %d\n", a);
+    {
+        int a;
+        printf("nested 2: a = %d\n", a);
+        a = 51;
+        printf("nested 3: a = %d\n", a);
+    }
+    printf("nested 4: a = %d\n", a);
+}
+
+int main() {
+    globCheck();
+    fwdCheck();
+    printf("main 0: a = %d\n", a);
+    a = 5;
+    printf("main 1: a = %d\n", a);
+    f();
+    printf("main 2: a = %d\n", a);
+    g(77);
+    printf("main 3: a = %d\n", a);
+    h(30);
+    printf("main 4: a = %d\n", a);
+    nested();
+    printf("main 5: a = %d\n", a);
+    return 0;
+}
diff --git a/libacc/tests/data/missing-main.c b/libacc/tests/data/missing-main.c
new file mode 100644
index 0000000..e73eec4
--- /dev/null
+++ b/libacc/tests/data/missing-main.c
@@ -0,0 +1,4 @@
+/* No main. */
+
+a() {
+}
\ No newline at end of file
diff --git a/libacc/tests/data/otcc-ansi.c b/libacc/tests/data/otcc-ansi.c
new file mode 100644
index 0000000..72580e9
--- /dev/null
+++ b/libacc/tests/data/otcc-ansi.c
@@ -0,0 +1,466 @@
+// #include <stdio.h>
+int d, z, C, h, P, K, ac, q, G, v, Q, R, D, L, W, M;
+
+void E(int e) {
+    *(char*) D++ = e;
+}
+
+void o() {
+    if (L) {
+        h = *(char*) L++;
+        if (h == 2) {
+            L = 0;
+            h = W;
+        }
+    } else
+        h = fgetc(Q);
+}
+
+int X() {
+    return isalnum(h) | h == 95;
+}
+
+void Y() {
+    if (h == 92) {
+        o();
+        if (h == 110)
+            h = 10;
+    }
+}
+
+void ad() {
+    int e, j, m;
+    while (isspace(h) | h == 35) {
+        if (h == 35) {
+            o();
+            ad();
+            if (d == 536) {
+                ad();
+                E(32);
+                *(int*) d = 1;
+                *(int*) (d + 4) = D;
+            }
+            while (h != 10) {
+                E(h);
+                o();
+            }
+            E(h);
+            E(2);
+        }
+        o();
+    }
+    C = 0;
+    d = h;	
+    if (X()) {
+        E(32);
+        M = D;
+        while (X()) {
+            E(h);
+            o();
+        }
+        if (isdigit(d)) {
+            z = strtol(M, 0, 0);
+            d = 2;
+        } else {
+            *(char*) D = 32;
+            d = strstr(R, M - 1) - R;
+            *(char*) D = 0;
+            d = d * 8 + 256;
+            if (d > 536) {
+                d = P + d;
+                if (*(int*) d == 1) {
+                    L = *(int*) (d + 4);
+                    W = h;
+                    o();
+                    ad();
+                }
+            }
+        }
+    } else {
+        o();
+        if (d == 39) {
+            d = 2;
+            Y();
+            z = h;
+            o();
+            o();
+        } else if (d == 47 & h == 42) {
+            o();
+            while (h) {
+                while (h != 42)
+                    o();
+                o();
+                if (h == 47)
+                    h = 0;
+            }
+            o();
+            ad();
+        } else {
+            e
+                    = "++#m--%am*@R<^1c/@%[_[H3c%@%[_[H3c+@.B#d-@%:_^BKd<<Z/03e>>`/03e<=0f>=/f<@.f>@1f==&g!='g&&k||#l&@.BCh^@.BSi|@.B+j~@/%Yd!@&d*@b";
+            while (j = *(char*) e++) {
+                m = *(char*) e++;
+                z = 0;
+                while ((C = *(char*) e++ - 98) < 0)
+                    z = z * 64 + C + 64;
+                if (j == d & (m == h | m == 64)) {
+                    if (m == h) {
+                        o();
+                        d = 1;
+                    }
+                    break;
+                }
+            }
+        }
+    }
+}
+
+void ae(int g) {
+    while( g&&g!=-1) {
+        *(char*) q++=g;
+        g=g>>8;
+    }
+}
+
+void A(int e) {
+    int g;
+    while( e) {
+        g=*(int*) e;
+        *(int*) e=q-e-4;
+        e=g;
+    }
+}
+
+int s(int g, int e) {
+    ae(g);
+    *(int*) q = e;
+    e = q;
+    q = q + 4;
+    return e;
+}
+
+void H(int e) {
+    s(184,e);
+}
+
+int B(int e) {
+    return s(233,e);
+}
+
+int S(int j, int e) {
+    ae(1032325);
+    return s(132 + j, e);
+}
+
+void Z(int e) {
+    ae( 49465);
+    H(0);
+    ae( 15);
+    ae( e+144);
+    ae( 192);
+}
+
+void N(int j, int e) {
+    ae(j + 131);
+    s((e > -512 && e < 512) << 7 | 5, e);
+}
+
+void T (int j) {
+    int g,e,m,aa;
+    g=1;
+    if( d == 34) {
+        H(v);
+        while( h!=34) {
+            Y ();
+            *(char*) v++=h;
+            o ();
+        }
+        *(char*) v=0;
+        v=v +4&-4;
+        o ();
+        ad();
+    }
+    else {
+        aa=C;
+        m= z;
+        e=d;
+        ad();
+        if( e == 2) {
+            H(m);
+        }
+        else if( aa == 2) {
+            T(0);
+            s(185,0);
+            if( e == 33)Z(m);
+            else ae( m);
+        }
+        else if( e == 40) {
+            w ();
+            ad();
+        }
+        else if( e == 42) {
+            ad();
+            e=d;
+            ad();
+            ad();
+            if( d == 42) {
+                ad();
+                ad();
+                ad();
+                ad();
+                e=0;
+            }
+            ad();
+            T(0);
+            if( d == 61) {
+                ad();
+                ae( 80);
+                w ();
+                ae( 89);
+                ae( 392+(e == 256));
+            }
+            else if( e) {
+                if( e == 256)ae( 139);
+                else ae( 48655);
+                q++;
+            }
+        }
+        else if( e == 38) {
+            N(10,*(int*) d);
+            ad();
+        }
+        else {
+            g=*(int*) e;
+            if(!g)g=dlsym(0,M);
+            if( d == 61&j) {
+                ad();
+                w ();
+                N(6,g);
+            }
+            else if( d!= 40) {
+                N(8,g);
+                if( C == 11) {
+                    N(0,g);
+                    ae( z);
+                    ad();
+                }
+            }
+        }
+    }
+    if( d == 40) {
+        if( g == 1)ae( 80);
+        m= s(60545,0);
+        ad();
+        j=0;
+        while( d!= 41) {
+            w ();
+            s(2393225,j);
+            if( d == 44)ad();
+            j=j +4;
+        }
+        *(int*) m= j;
+        ad();
+        if(!g) {
+            e=e +4;
+            *(int*) e=s(232,*(int*) e);
+        }
+        else if( g == 1) {
+            s(2397439,j);
+            j=j +4;
+        }
+        else {
+            s(232,g-q-5);
+        }
+        if( j)s(50305,j);
+    }
+}
+
+void O (int j) {
+    int e,g,m;
+    if( j--== 1)T(1);
+    else {
+        O (j);
+        m= 0;
+        while( j == C) {
+            g=d;
+            e=z;
+            ad();
+            if( j>8) {
+                m= S(e,m);
+                O (j);
+            }
+            else {
+                ae( 80);
+                O (j);
+                ae( 89);
+                if( j == 4|j == 5) {
+                    Z(e);
+                }
+                else {
+                    ae( e);
+                    if( g == 37)ae( 146);
+                }
+            }
+        }
+        if( m&&j>8) {
+            m= S(e,m);
+            H(e^1);
+            B(5);
+            A(m);
+            H(e);
+        }
+    }
+}
+
+void w() {
+    O(11);
+}
+
+int U() {
+    w();
+    return S(0, 0);
+}
+
+void I (int j) {
+    int m,g,e;
+    if( d == 288) {
+        ad();
+        ad();
+        m= U ();
+        ad();
+        I (j);
+        if( d == 312) {
+            ad();
+            g=B(0);
+            A(m);
+            I (j);
+            A(g);
+        }
+        else {
+            A(m);
+        }
+    }
+    else if( d == 352|d == 504) {
+        e=d;
+        ad();
+        ad();
+        if( e == 352) {
+            g=q;
+            m= U ();
+        }
+        else {
+            if( d!= 59)w ();
+            ad();
+            g=q;
+            m= 0;
+            if( d!= 59)m= U ();
+            ad();
+            if( d!= 41) {
+                e=B(0);
+                w ();
+                B(g-q-5);
+                A(e);
+                g=e +4;
+            }
+        }
+        ad();
+        I(&m);
+        B(g-q-5);
+        A(m);
+    }
+    else if( d == 123) {
+        ad();
+        ab(1);
+        while( d!= 125)I (j);
+        ad();
+    }
+    else {
+        if( d == 448) {
+            ad();
+            if( d!= 59)w ();
+            K=B(K);
+        }
+        else if( d == 400) {
+            ad();
+            *(int*) j=B(*(int*) j);
+        }
+        else if( d!= 59)w ();
+        ad();
+    }
+}
+
+void ab (int j) {
+    int m;
+    while( d == 256|d!=-1&!j) {
+        if( d == 256) {
+            ad();
+            while( d!= 59) {
+                if( j) {
+                    G=G +4;
+                    *(int*) d=-G;
+                }
+                else {
+                    *(int*) d=v;
+                    v=v +4;
+                }
+                ad();
+                if( d == 44)ad()	;
+            }
+            ad();
+        }
+        else {
+            A(*(int*)(d +4));
+            *(int*) d=q;
+            ad();
+            ad();
+            m= 8;
+            while( d!= 41) {
+                *(int*) d=m;
+                m= m +4;
+                ad();
+                if( d == 44)ad();
+            }
+            ad();
+            K=G=0;
+            ae( 15042901);
+            m= s(60545,0);
+            I(0);
+            A(K);
+            ae( 50121);
+            *(int*) m= G;
+        }
+    }
+}
+
+int run(int g, int e) {
+    return (*(int(*)()) *(int*) (P + 592))(g, e);
+}
+
+int main(int g, int e) {
+    int result;
+    Q = stdin;
+    if (g-- > 1) {
+        e = e + 4;
+        Q = fopen(*(int*) e, "r");
+        if (!Q) {
+            fprintf(stderr, "otcc-ansi.c: could not open file %s\n", *(int*) e);
+            return -2;
+        }
+    }
+    D = strcpy(R = calloc(1, 99999), " int if else while break return for define main ") + 48;
+    v = calloc(1, 99999);
+    q = ac = calloc(1, 99999);
+    P = calloc(1, 99999);
+    o();
+    ad();
+    ab(0);
+    if (mprotect(ac & (~ 4095), (99999 + 4095) & (~ 4095), 7)) {
+        printf("Mprotect failed. %d\n", errno);
+        return -1;
+    }
+    fprintf(stderr, "otcc-ansi.c: About to execute compiled code:\n");
+    result = run(g, e);
+    fprintf(stderr, "atcc-ansi.c: result: %d\n", result);
+    return result;
+}
+
diff --git a/libacc/tests/data/otcc-noinclude.c b/libacc/tests/data/otcc-noinclude.c
new file mode 100644
index 0000000..530f9e2
--- /dev/null
+++ b/libacc/tests/data/otcc-noinclude.c
@@ -0,0 +1,446 @@
+// #include <stdio.h>
+#define k *(int*)
+#define a if(
+#define c ad()
+#define i else
+#define p while(
+#define x *(char*)
+#define b ==
+#define V =calloc(1,99999)
+#define f ()
+#define J return
+#define l ae(
+#define n e)
+#define u d!=
+#define F int 
+#define y (j)
+#define r m=
+#define t +4
+F d,z,C,h,P,K,ac,q,G,v,Q,R,D,L,W,M;
+E(n{
+x D++=e;
+}
+o f{
+a L){
+h=x L++;
+a h b 2){
+L=0;
+h=W;
+}
+}
+i h=fgetc(Q);
+}
+X f{
+J isalnum(h)|h b 95;
+}
+Y f{
+a h b 92){
+o f;
+a h b 110)h=10;
+}
+}
+c{
+F e,j,m;
+p isspace(h)|h b 35){
+a h b 35){
+o f;
+c;
+a d b 536){
+c;
+E(32);
+k d=1;
+k(d t)=D;
+}
+p h!=10){
+E(h);
+o f;
+}
+E(h);
+E(2);
+}
+o f;
+}
+C=0;
+d=h;
+a X f){
+E(32);
+M=D;
+p X f){
+E(h);
+o f;
+}
+a isdigit(d)){
+z=strtol(M,0,0);
+d=2;
+}
+i{
+x D=32;
+d=strstr(R,M-1)-R;
+x D=0;
+d=d*8+256;
+a d>536){
+d=P+d;
+a k d b 1){
+L=k(d t);
+W=h;
+o f;
+c;
+}
+}
+}
+}
+i{
+o f;
+a d b 39){
+d=2;
+Y f;
+z=h;
+o f;
+o f;
+}
+i a d b 47&h b 42){
+o f;
+p h){
+p h!=42)o f;
+o f;
+a h b 47)h=0;
+}
+o f;
+c;
+}
+i{
+e="++#m--%am*@R<^1c/@%[_[H3c%@%[_[H3c+@.B#d-@%:_^BKd<<Z/03e>>`/03e<=0f>=/f<@.f>@1f==&g!='g&&k||#l&@.BCh^@.BSi|@.B+j~@/%Yd!@&d*@b";
+p j=x e++){
+r x e++;
+z=0;
+p(C=x e++-98)<0)z=z*64+C+64;
+a j b d&(m b h|m b 64)){
+a m b h){
+o f;
+d=1;
+}
+break;
+}
+}
+}
+}
+}
+l g){
+p g&&g!=-1){
+x q++=g;
+g=g>>8;
+}
+}
+A(n{
+F g;
+p n{
+g=k e;
+k e=q-e-4;
+e=g;
+}
+}
+s(g,n{
+l g);
+k q=e;
+e=q;
+q=q t;
+J e;
+}
+H(n{
+s(184,n;
+}
+B(n{
+J s(233,n;
+}
+S(j,n{
+l 1032325);
+J s(132+j,n;
+}
+Z(n{
+l 49465);
+H(0);
+l 15);
+l e+144);
+l 192);
+}
+N(j,n{
+l j+131);
+s((e<512)<<7|5,n;
+}
+T y{
+F g,e,m,aa;
+g=1;
+a d b 34){
+H(v);
+p h!=34){
+Y f;
+x v++=h;
+o f;
+}
+x v=0;
+v=v t&-4;
+o f;
+c;
+}
+i{
+aa=C;
+r z;
+e=d;
+c;
+a e b 2){
+H(m);
+}
+i a aa b 2){
+T(0);
+s(185,0);
+a e b 33)Z(m);
+i l m);
+}
+i a e b 40){
+w f;
+c;
+}
+i a e b 42){
+c;
+e=d;
+c;
+c;
+a d b 42){
+c;
+c;
+c;
+c;
+e=0;
+}
+c;
+T(0);
+a d b 61){
+c;
+l 80);
+w f;
+l 89);
+l 392+(e b 256));
+}
+i a n{
+a e b 256)l 139);
+i l 48655);
+q++;
+}
+}
+i a e b 38){
+N(10,k d);
+c;
+}
+i{
+g=k e;
+a!g)g=dlsym(0,M);
+a d b 61&j){
+c;
+w f;
+N(6,g);
+}
+i a u 40){
+N(8,g);
+a C b 11){
+N(0,g);
+l z);
+c;
+}
+}
+}
+}
+a d b 40){
+a g b 1)l 80);
+r s(60545,0);
+c;
+j=0;
+p u 41){
+w f;
+s(2393225,j);
+a d b 44)c;
+j=j t;
+}
+k r j;
+c;
+a!g){
+e=e t;
+k e=s(232,k n;
+}
+i a g b 1){
+s(2397439,j);
+j=j t;
+}
+i{
+s(232,g-q-5);
+}
+a j)s(50305,j);
+}
+}
+O y{
+F e,g,m;
+a j--b 1)T(1);
+i{
+O y;
+r 0;
+p j b C){
+g=d;
+e=z;
+c;
+a j>8){
+r S(e,m);
+O y;
+}
+i{
+l 80);
+O y;
+l 89);
+a j b 4|j b 5){
+Z(n;
+}
+i{
+l n;
+a g b 37)l 146);
+}
+}
+}
+a m&&j>8){
+r S(e,m);
+H(e^1);
+B(5);
+A(m);
+H(n;
+}
+}
+}
+w f{
+O(11);
+}
+U f{
+w f;
+J S(0,0);
+}
+I y{
+F m,g,e;
+a d b 288){
+c;
+c;
+r U f;
+c;
+I y;
+a d b 312){
+c;
+g=B(0);
+A(m);
+I y;
+A(g);
+}
+i{
+A(m);
+}
+}
+i a d b 352|d b 504){
+e=d;
+c;
+c;
+a e b 352){
+g=q;
+r U f;
+}
+i{
+a u 59)w f;
+c;
+g=q;
+r 0;
+a u 59)r U f;
+c;
+a u 41){
+e=B(0);
+w f;
+B(g-q-5);
+A(n;
+g=e t;
+}
+}
+c;
+I(&m);
+B(g-q-5);
+A(m);
+}
+i a d b 123){
+c;
+ab(1);
+p u 125)I y;
+c;
+}
+i{
+a d b 448){
+c;
+a u 59)w f;
+K=B(K);
+}
+i a d b 400){
+c;
+k j=B(k j);
+}
+i a u 59)w f;
+c;
+}
+}
+ab y{
+F m;
+p d b 256|u-1&!j){
+a d b 256){
+c;
+p u 59){
+a j){
+G=G t;
+k d=-G;
+}
+i{
+k d=v;
+v=v t;
+}
+c;
+a d b 44)c;
+}
+c;
+}
+i{
+A(k(d t));
+k d=q;
+c;
+c;
+r 8;
+p u 41){
+k d=m;
+r m t;
+c;
+a d b 44)c;
+}
+c;
+K=G=0;
+l 15042901);
+r s(60545,0);
+I(0);
+A(K);
+l 50121);
+k r G;
+}
+}
+}
+main(g,n{
+Q=stdin;
+a g-->1){
+e=e t;
+Q=fopen(k e,"r");
+}
+D=strcpy(R V," int if else while break return for define main ")+48;
+v V;
+q=ac V;
+P V;
+o f;
+c;
+ab(0);
+J(*(int(*)f)k(P+592))(g,n;
+}
+
diff --git a/libacc/tests/data/otcc.c b/libacc/tests/data/otcc.c
new file mode 100644
index 0000000..433ae2e
--- /dev/null
+++ b/libacc/tests/data/otcc.c
@@ -0,0 +1,448 @@
+#include <stdio.h>
+#define k *(int*)
+#define a if(
+#define c ad()
+#define i else
+#define p while(
+#define x *(char*)
+#define b ==
+#define V =calloc(1,99999)
+#define f ()
+#define J return
+#define l ae(
+#define n e)
+#define u d!=
+#define F int 
+#define y (j)
+#define r m=
+#define t +4
+F d,z,C,h,P,K,ac,q,G,v,Q,R,D,L,W,M;
+E(n{
+x D++=e;
+}
+o f{
+a L){
+h=x L++;
+a h b 2){
+L=0;
+h=W;
+}
+}
+i h=fgetc(Q);
+}
+X f{
+J isalnum(h)|h b 95;
+}
+Y f{
+a h b 92){
+o f;
+a h b 110)h=10;
+}
+}
+c{
+F e,j,m;
+p isspace(h)|h b 35){
+a h b 35){
+o f;
+c;
+a d b 536){
+c;
+E(32);
+k d=1;
+k(d t)=D;
+}
+p h!=10){
+E(h);
+o f;
+}
+E(h);
+E(2);
+}
+o f;
+}
+C=0;
+d=h;
+a X f){
+E(32);
+M=D;
+p X f){
+E(h);
+o f;
+}
+a isdigit(d)){
+z=strtol(M,0,0);
+d=2;
+}
+i{
+x D=32;
+d=strstr(R,M-1)-R;
+x D=0;
+d=d*8+256;
+a d>536){
+d=P+d;
+a k d b 1){
+L=k(d t);
+W=h;
+o f;
+c;
+}
+}
+}
+}
+i{
+o f;
+a d b 39){
+d=2;
+Y f;
+z=h;
+o f;
+o f;
+}
+i a d b 47&h b 42){
+o f;
+p h){
+p h!=42)o f;
+o f;
+a h b 47)h=0;
+}
+o f;
+c;
+}
+i{
+e="++#m--%am*@R<^1c/@%[_[H3c%@%[_[H3c+@.B#d-@%:_^BKd<<Z/03e>>`/03e<=0f>=/f<@.f>@1f==&g!='g&&k||#l&@.BCh^@.BSi|@.B+j~@/%Yd!@&d*@b";
+p j=x e++){
+r x e++;
+z=0;
+p(C=x e++-98)<0)z=z*64+C+64;
+a j b d&(m b h|m b 64)){
+a m b h){
+o f;
+d=1;
+}
+break;
+}
+}
+}
+}
+}
+l g){
+p g&&g!=-1){
+x q++=g;
+g=g>>8;
+}
+}
+A(n{
+F g;
+p n{
+g=k e;
+k e=q-e-4;
+e=g;
+}
+}
+s(g,n{
+l g);
+k q=e;
+e=q;
+q=q t;
+J e;
+}
+H(n{
+s(184,n;
+}
+B(n{
+J s(233,n;
+}
+S(j,n{
+l 1032325);
+J s(132+j,n;
+}
+Z(n{
+l 49465);
+H(0);
+l 15);
+l e+144);
+l 192);
+}
+N(j,n{
+l j+131);
+s((e<512)<<7|5,n;
+}
+T y{
+F g,e,m,aa;
+g=1;
+a d b 34){
+H(v);
+p h!=34){
+Y f;
+x v++=h;
+o f;
+}
+x v=0;
+v=v t&-4;
+o f;
+c;
+}
+i{
+aa=C;
+r z;
+e=d;
+c;
+a e b 2){
+H(m);
+}
+i a aa b 2){
+T(0);
+s(185,0);
+a e b 33)Z(m);
+i l m);
+}
+i a e b 40){
+w f;
+c;
+}
+i a e b 42){
+c;
+e=d;
+c;
+c;
+a d b 42){
+c;
+c;
+c;
+c;
+e=0;
+}
+c;
+T(0);
+a d b 61){
+c;
+l 80);
+w f;
+l 89);
+l 392+(e b 256));
+}
+i a n{
+a e b 256)l 139);
+i l 48655);
+q++;
+}
+}
+i a e b 38){
+N(10,k d);
+c;
+}
+i{
+g=k e;
+a!g)g=dlsym(0,M);
+a d b 61&j){
+c;
+w f;
+N(6,g);
+}
+i a u 40){
+N(8,g);
+a C b 11){
+N(0,g);
+l z);
+c;
+}
+}
+}
+}
+a d b 40){
+a g b 1)l 80);
+r s(60545,0);
+c;
+j=0;
+p u 41){
+w f;
+s(2393225,j);
+a d b 44)c;
+j=j t;
+}
+k r j;
+c;
+a!g){
+e=e t;
+k e=s(232,k n;
+}
+i a g b 1){
+s(2397439,j);
+j=j t;
+}
+i{
+s(232,g-q-5);
+}
+a j)s(50305,j);
+}
+}
+O y{
+F e,g,m;
+a j--b 1)T(1);
+i{
+O y;
+r 0;
+p j b C){
+g=d;
+e=z;
+c;
+a j>8){
+r S(e,m);
+O y;
+}
+i{
+l 80);
+O y;
+l 89);
+a j b 4|j b 5){
+Z(n;
+}
+i{
+l n;
+a g b 37)l 146);
+}
+}
+}
+a m&&j>8){
+r S(e,m);
+H(e^1);
+B(5);
+A(m);
+H(n;
+}
+}
+}
+w f{
+O(11);
+}
+U f{
+w f;
+J S(0,0);
+}
+I y{
+F m,g,e;
+a d b 288){
+c;
+c;
+r U f;
+c;
+I y;
+a d b 312){
+c;
+g=B(0);
+A(m);
+I y;
+A(g);
+}
+i{
+A(m);
+}
+}
+i a d b 352|d b 504){
+e=d;
+c;
+c;
+a e b 352){
+g=q;
+r U f;
+}
+i{
+a u 59)w f;
+c;
+g=q;
+r 0;
+a u 59)r U f;
+c;
+a u 41){
+e=B(0);
+w f;
+B(g-q-5);
+A(n;
+g=e t;
+}
+}
+c;
+I(&m);
+B(g-q-5);
+A(m);
+}
+i a d b 123){
+c;
+ab(1);
+p u 125)I y;
+c;
+}
+i{
+a d b 448){
+c;
+a u 59)w f;
+K=B(K);
+}
+i a d b 400){
+c;
+k j=B(k j);
+}
+i a u 59)w f;
+c;
+}
+}
+ab y{
+F m;
+p d b 256|u-1&!j){
+a d b 256){
+c;
+p u 59){
+a j){
+G=G t;
+k d=-G;
+}
+i{
+k d=v;
+v=v t;
+}
+c;
+a d b 44)c;
+}
+c;
+}
+i{
+A(k(d t));
+k d=q;
+c;
+c;
+r 8;
+p u 41){
+k d=m;
+r m t;
+c;
+a d b 44)c;
+}
+c;
+K=G=0;
+l 15042901);
+r s(60545,0);
+I(0);
+A(K);
+l 50121);
+k r G;
+}
+}
+}
+main(g,n{
+Q=stdin;
+a g-->1){
+e=e t;
+Q=fopen(k e,"r");
+}
+D=strcpy(R V," int if else while break return for define main ")+48;
+v V;
+q=ac V;
+P V;
+o f;
+c;
+ab(0);
+mprotect(ac & (~ 4095), (99999 + 4095) & (~ 4095), 7);
+fprintf(stderr, "otcc.c: about to execute compiled code.\n");
+J(*(int(*)f)k(P+592))(g,n;
+}
+
diff --git a/libacc/tests/data/returnval-ansi.c b/libacc/tests/data/returnval-ansi.c
new file mode 100644
index 0000000..6b53fd5
--- /dev/null
+++ b/libacc/tests/data/returnval-ansi.c
@@ -0,0 +1,8 @@
+
+int main(int argc, char** argv) {
+  return f();
+}
+
+int f() {
+    return 42;
+}
diff --git a/libacc/tests/data/returnval.c b/libacc/tests/data/returnval.c
new file mode 100644
index 0000000..1cf5bae
--- /dev/null
+++ b/libacc/tests/data/returnval.c
@@ -0,0 +1,4 @@
+main() {
+  return 42;
+}
+
diff --git a/libacc/tests/data/simplest.c b/libacc/tests/data/simplest.c
new file mode 100644
index 0000000..bae895a
--- /dev/null
+++ b/libacc/tests/data/simplest.c
@@ -0,0 +1 @@
+main() {}
diff --git a/libacc/tests/data/testStringConcat.c b/libacc/tests/data/testStringConcat.c
new file mode 100644
index 0000000..bf06ae1
--- /dev/null
+++ b/libacc/tests/data/testStringConcat.c
@@ -0,0 +1,4 @@
+int main() {
+    return printf("Hello" "," " world\n");
+}
+
diff --git a/libacc/tests/main.cpp b/libacc/tests/main.cpp
new file mode 100644
index 0000000..13a30d4
--- /dev/null
+++ b/libacc/tests/main.cpp
@@ -0,0 +1,142 @@
+/*
+ * Android "Almost" C Compiler.
+ * This is a compiler for a small subset of the C language, intended for use
+ * in scripting environments where speed and memory footprint are important.
+ *
+ * This code is based upon the "unobfuscated" version of the
+ * Obfuscated Tiny C compiler, see the file LICENSE for details.
+ *
+ */
+
+#include <ctype.h>
+#include <dlfcn.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(__arm__)
+#include <unistd.h>
+#endif
+
+#include <acc/acc.h>
+
+
+typedef int (*MainPtr)(int, char**);
+// This is a separate function so it can easily be set by breakpoint in gdb.
+int run(MainPtr mainFunc, int argc, char** argv) {
+    return mainFunc(argc, argv);
+}
+
+// Private API for development:
+
+extern "C"
+void accDisassemble(ACCscript* script);
+
+int main(int argc, char** argv) {
+    const char* inFile = NULL;
+    bool printListing;
+    bool runResults = false;
+    FILE* in = stdin;
+    int i;
+    for (i = 1; i < argc; i++) {
+        char* arg = argv[i];
+        if (arg[0] == '-') {
+            switch (arg[1]) {
+                case 'S':
+                    printListing = true;
+                    break;
+                case 'R':
+                    runResults = true;
+                    break;
+            default:
+                fprintf(stderr, "Unrecognized flag %s\n", arg);
+                return 3;
+            }
+        } else if (inFile == NULL) {
+            inFile = arg;
+        } else {
+            break;
+        }
+    }
+
+    if (! inFile) {
+        fprintf(stderr, "input file required\n");
+        return 2;
+    }
+
+    if (inFile) {
+        in = fopen(inFile, "r");
+        if (!in) {
+            fprintf(stderr, "Could not open input file %s\n", inFile);
+            return 1;
+        }
+    }
+
+    fseek(in, 0, SEEK_END);
+    size_t fileSize = (size_t) ftell(in);
+    rewind(in);
+    ACCchar* text = new ACCchar[fileSize + 1];
+    size_t bytesRead = fread(text, 1, fileSize, in);
+    if (bytesRead != fileSize) {
+        fprintf(stderr, "Could not read all of file %s\n", inFile);
+    }
+
+    text[fileSize] = '\0';
+
+    ACCscript* script = accCreateScript();
+
+    const ACCchar* scriptSource[] = {text};
+    accScriptSource(script, 1, scriptSource, NULL);
+    delete[] text;
+
+    accCompileScript(script);
+    int result = accGetError(script);
+    MainPtr mainPointer = 0;
+    if (result != 0) {
+        char buf[1024];
+        accGetScriptInfoLog(script, sizeof(buf), NULL, buf);
+        fprintf(stderr, "%s", buf);
+        goto exit;
+    }
+
+    {
+        ACCsizei numPragmaStrings;
+        accGetPragmas(script, &numPragmaStrings, 0, NULL);
+        if (numPragmaStrings) {
+            char** strings = new char*[numPragmaStrings];
+            accGetPragmas(script, NULL, numPragmaStrings, strings);
+            for(ACCsizei i = 0; i < numPragmaStrings; i += 2) {
+                fprintf(stderr, "#pragma %s(%s)\n", strings[i], strings[i+1]);
+            }
+            delete[] strings;
+        }
+    }
+
+    if (printListing) {
+        accDisassemble(script);
+    }
+
+    if (runResults) {
+        accGetScriptLabel(script, "main", (ACCvoid**) & mainPointer);
+
+        result = accGetError(script);
+        if (result != ACC_NO_ERROR) {
+            fprintf(stderr, "Could not find main: %d\n", result);
+        } else {
+            fprintf(stderr, "Executing compiled code:\n");
+            int codeArgc = argc - i + 1;
+            char** codeArgv = argv + i - 1;
+            codeArgv[0] = (char*) (inFile ? inFile : "stdin");
+            result = run(mainPointer, codeArgc, codeArgv);
+            fprintf(stderr, "result: %d\n", result);
+        }
+    }
+
+exit:
+
+    accDeleteScript(script);
+
+    return result;
+}
diff --git a/libacc/tests/test b/libacc/tests/test
new file mode 100755
index 0000000..ef10500
--- /dev/null
+++ b/libacc/tests/test
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+SCRIPT_DIR=`dirname $BASH_SOURCE`
+cd $SCRIPT_DIR
+python test.py
+
diff --git a/libacc/tests/test.py b/libacc/tests/test.py
new file mode 100644
index 0000000..ff9af9b
--- /dev/null
+++ b/libacc/tests/test.py
@@ -0,0 +1,189 @@
+#
+# Test the acc compiler
+
+import unittest
+import subprocess
+import os
+
+def compile(args):
+    proc = subprocess.Popen(["acc"] + args, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+    result = proc.communicate()
+    return result
+
+def runCmd(args):
+    proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    result = proc.communicate()
+    return result[0].strip()
+
+def which(item):
+    return runCmd(["which", item])
+
+def fileType(item):
+    return runCmd(["file", item])
+
+def outputCanRun():
+    ft = fileType(which("acc"))
+    return ft.find("ELF 32-bit LSB executable, Intel 80386") >= 0
+
+def adb(args):
+    return runCmd(["adb"] + args)
+
+gArmInitialized = False
+
+def setupArm():
+    if gArmInitialized:
+        return
+    print "Setting up arm"
+    adb(["remount"])
+    adb(["shell", "rm", "/system/bin/acc"])
+    adb(["shell", "mkdir", "/system/bin/accdata"])
+    adb(["shell", "mkdir", "/system/bin/accdata/data"])
+    # Clear out old data TODO: handle recursion
+    adb(["shell", "rm", "/system/bin/accdata/data/*"])
+    # Copy over data
+    for root, dirs, files in os.walk("data"):
+        for d in dirs:
+            adb(["shell", "mkdir", os.path.join(root, d)])
+        for f in files:
+            adb(["push", os.path.join(root, f), os.path.join("/system/bin/accdata", root, f)])
+    # Copy over compiler
+    adb(["sync"])
+    gArmInitialied = True
+
+def compileArm(args):
+    setupArm()
+    proc = subprocess.Popen(["adb", "shell", "/system/bin/acc"] + args, stdout=subprocess.PIPE)
+    result = proc.communicate()
+    return result[0].replace("\r","")
+
+def compare(a, b):
+    if a != b:
+        firstDiff = firstDifference(a, b)
+        print "Strings differ at character %d. Common: %s. Difference '%s' != '%s'" % (
+            firstDiff, a[0:firstDiff], safeAccess(a, firstDiff), safeAccess(b, firstDiff))
+
+def safeAccess(s, i):
+    if 0 <= i < len(s):
+        return s[i]
+    else:
+        return '?'
+
+def firstDifference(a, b):
+    commonLen = min(len(a), len(b))
+    for i in xrange(0, commonLen):
+        if a[i] != b[i]:
+            return i
+    return commonLen
+
+class TestACC(unittest.TestCase):
+ 
+    def compileCheck(self, args, stdErrResult, stdOutResult=""):
+        out, err = compile(args)
+        compare(out, stdOutResult)
+        compare(err, stdErrResult)
+        self.assertEqual(out, stdOutResult)
+        self.assertEqual(err, stdErrResult)
+
+    def compileCheckArm(self, args, result):
+        self.assertEqual(compileArm(args), result)
+
+    def testCompileReturnVal(self):
+        self.compileCheck(["data/returnval-ansi.c"], "") 
+
+    def testCompileReturnVal(self):
+        self.compileCheck(["data/otcc-ansi.c"], "")
+
+    def testRunReturnVal(self):
+        self.compileCheck(["-R", "data/returnval-ansi.c"],
+		"Executing compiled code:\nresult: 42\n")
+
+    def testStringLiteralConcatenation(self):
+        self.compileCheck(["-R", "data/testStringConcat.c"],
+		"Executing compiled code:\nresult: 13\n", "Hello, world\n")
+
+    def testRunOTCCANSI(self):
+        self.compileCheck(["-R", "data/otcc-ansi.c", "data/returnval.c"], 
+            "Executing compiled code:\notcc-ansi.c: About to execute compiled code:\natcc-ansi.c: result: 42\nresult: 42\n")
+
+    def testRunOTCCANSI2(self):
+        self.compileCheck(["-R", "data/otcc-ansi.c", "data/otcc.c", "data/returnval.c"], 
+            "Executing compiled code:\notcc-ansi.c: About to execute compiled code:\notcc.c: about to execute compiled code.\natcc-ansi.c: result: 42\nresult: 42\n")
+
+    def testRunConstants(self):
+        self.compileCheck(["-R", "data/constants.c"],
+            "Executing compiled code:\nresult: 12\n",
+            "0 = 0\n010 = 8\n0x10 = 16\n'\\a' = 7\n'\\b' = 8\n'\\f' = 12\n'\\n' = 10\n'\\r' = 13\n'\\t' = 9\n'\\v' = 11\n'\\\\' = 92\n'\\'' = 39\n" +
+            "'\\\"' = 34\n'\\?' = 63\n'\\0' = 0\n'\\1' = 1\n'\\12' = 10\n'\\123' = 83\n'\\x0' = 0\n'\\x1' = 1\n'\\x12' = 18\n'\\x123' = 291\n'\\x1f' = 31\n'\\x1F' = 31\n")
+
+    def testRunFloat(self):
+        self.compileCheck(["-R", "data/float.c"],
+            "Executing compiled code:\nresult: 0\n",
+            "int: 1 float: 2.2 double: 3.3\n ftoi(1.4f)=1\n dtoi(2.4)=2\n itof(3)=3\n itod(4)=4\nglobals: 1 2 3 4\nargs: 1 2 3 4\nlocals: 1 2 3 4\ncast rval: 2 4\ncast lval: 1.1 2 3.3 4\n")
+        
+    def testRunFlops(self):
+        self.compileCheck(["-R", "data/flops.c"],
+            "Executing compiled code:\nresult: 0\n",
+            "-1.1 = -1.1\n" +
+            "!1.2 = 0\n" +
+            "!0 = 1\n" +
+            "double op double:\n" +
+            "1 + 2 = 3\n" +
+            "1 - 2 = -1\n" +
+            "1 * 2 = 2\n" +
+            "1 / 2 = 0.5\n" +
+            "float op float:\n" +
+            "1 + 2 = 3\n" +
+            "1 - 2 = -1\n" +
+            "1 * 2 = 2\n" +
+            "1 / 2 = 0.5\n" +
+            "double op float:\n" +
+            "1 + 2 = 3\n" +
+            "1 - 2 = -1\n" +
+            "1 * 2 = 2\n" +
+            "1 / 2 = 0.5\n" +
+            "double op int:\n" +
+            "1 + 2 = 3\n" +
+            "1 - 2 = -1\n" +
+            "1 * 2 = 2\n" +
+            "1 / 2 = 0.5\n" +
+            "int op double:\n" +
+            "1 + 2 = 3\n" +
+            "1 - 2 = -1\n" +
+            "1 * 2 = 2\n" +
+            "1 / 2 = 0.5\n" +
+            "double op double:\n" +
+            "1 op 2: < 1   <= 1   == 0   >= 0   > 0   != 1\n" +
+            "1 op 1: < 0   <= 1   == 1   >= 1   > 0   != 0\n" +
+            "2 op 1: < 0   <= 0   == 0   >= 1   > 1   != 1\n" +
+            "double op float:\n" +
+            "1 op 2: < 1   <= 1   == 0   >= 0   > 0   != 1\n" +
+            "1 op 1: < 0   <= 1   == 1   >= 1   > 0   != 0\n" +
+            "2 op 1: < 0   <= 0   == 0   >= 1   > 1   != 1\n" +
+            "float op float:\n" +
+            "1 op 2: < 1   <= 1   == 0   >= 0   > 0   != 1\n" +
+            "1 op 1: < 0   <= 1   == 1   >= 1   > 0   != 0\n" +
+            "2 op 1: < 0   <= 0   == 0   >= 1   > 1   != 1\n" +
+            "int op double:\n" +
+            "1 op 2: < 1   <= 1   == 0   >= 0   > 0   != 1\n" +
+            "1 op 1: < 0   <= 1   == 1   >= 1   > 0   != 0\n" +
+            "2 op 1: < 0   <= 0   == 0   >= 1   > 1   != 1\n" +
+            "double op int:\n" +
+            "1 op 2: < 1   <= 1   == 0   >= 0   > 0   != 1\n" +
+            "1 op 1: < 0   <= 1   == 1   >= 1   > 0   != 0\n" +
+            "2 op 1: < 0   <= 0   == 0   >= 1   > 1   != 1\n" +
+            "branching: 1 0 1\n" +
+            "testpassi: 1 2 3 4 5 6 7 8\n" +
+            "testpassf: 1 2 3 4 5 6 7 8\n" +
+            "testpassd: 1 2 3 4 5 6 7 8\n" +
+            "testpassidf: 1 2 3\n"
+            )
+        
+    def testArmRunReturnVal(self):
+        self.compileCheckArm(["-R", "/system/bin/accdata/data/returnval-ansi.c"],
+            "Executing compiled code:\nresult: 42\n")
+
+if __name__ == '__main__':
+    if not outputCanRun():
+        print "Many tests are expected to fail, because acc is not a 32-bit x86 Linux executable."
+    unittest.main()
+
diff --git a/libcutils/Android.mk b/libcutils/Android.mk
index 18d0ee3..087d652 100644
--- a/libcutils/Android.mk
+++ b/libcutils/Android.mk
@@ -20,7 +20,7 @@
 	array.c \
 	hashmap.c \
 	atomic.c \
-        native_handle.c \
+	native_handle.c \
 	buffer.c \
 	socket_inaddr_any_server.c \
 	socket_local_client.c \
@@ -38,38 +38,44 @@
 	properties.c \
 	threads.c
 
+commonHostSources := \
+        ashmem-host.c
+
 # some files must not be compiled when building against Mingw
 # they correspond to features not used by our host development tools
 # which are also hard or even impossible to port to native Win32
-WITH_MINGW :=
+WINDOWS_HOST_ONLY :=
 ifeq ($(HOST_OS),windows)
     ifeq ($(strip $(USE_CYGWIN)),)
-        WITH_MINGW := 1
+        WINDOWS_HOST_ONLY := 1
     endif
 endif
 # USE_MINGW is defined when we build against Mingw on Linux
 ifneq ($(strip $(USE_MINGW)),)
-    WITH_MINGW := 1
+    WINDOWS_HOST_ONLY := 1
 endif
 
-ifeq ($(WITH_MINGW),1)
+ifeq ($(WINDOWS_HOST_ONLY),1)
     commonSources += \
         uio.c
 else
     commonSources += \
+        abort_socket.c \
         mspace.c \
         selector.c \
         tztime.c \
-        tzstrftime.c \
         adb_networking.c \
-	zygote.c
+        zygote.c
+
+    commonHostSources += \
+        tzstrftime.c
 endif
 
 
 # Static library for host
 # ========================================================
 LOCAL_MODULE := libcutils
-LOCAL_SRC_FILES := $(commonSources) ashmem-host.c
+LOCAL_SRC_FILES := $(commonSources) $(commonHostSources)
 LOCAL_LDLIBS := -lpthread
 LOCAL_STATIC_LIBRARIES := liblog
 include $(BUILD_HOST_STATIC_LIBRARY)
@@ -81,7 +87,7 @@
 # ========================================================
 include $(CLEAR_VARS)
 LOCAL_MODULE := libcutils
-LOCAL_SRC_FILES := $(commonSources) memory.c dlmalloc_stubs.c ashmem-host.c
+LOCAL_SRC_FILES := $(commonSources) $(commonHostSources) memory.c dlmalloc_stubs.c
 LOCAL_LDLIBS := -lpthread
 LOCAL_SHARED_LIBRARIES := liblog
 include $(BUILD_SHARED_LIBRARY)
diff --git a/libcutils/abort_socket.c b/libcutils/abort_socket.c
new file mode 100644
index 0000000..6a5e5e4
--- /dev/null
+++ b/libcutils/abort_socket.c
@@ -0,0 +1,293 @@
+/*
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <sys/poll.h>
+
+#include "cutils/abort_socket.h"
+
+struct asocket *asocket_init(int fd) {
+    int abort_fd[2];
+    int flags;
+    struct asocket *s;
+
+    /* set primary socket to non-blocking */
+    flags = fcntl(fd, F_GETFL);
+    if (flags == -1)
+        return NULL;
+    if (fcntl(fd, F_SETFL, flags | O_NONBLOCK))
+        return NULL;
+
+    /* create pipe with non-blocking write, so that asocket_close() cannot
+       block */
+    if (pipe(abort_fd))
+        return NULL;
+    flags = fcntl(abort_fd[1], F_GETFL);
+    if (flags == -1)
+        return NULL;
+    if (fcntl(abort_fd[1], F_SETFL, flags | O_NONBLOCK))
+        return NULL;
+
+    s = malloc(sizeof(struct asocket));
+    if (!s)
+        return NULL;
+
+    s->fd = fd;
+    s->abort_fd[0] = abort_fd[0];
+    s->abort_fd[1] = abort_fd[1];
+
+    return s;
+}
+
+int asocket_connect(struct asocket *s, const struct sockaddr *addr,
+        socklen_t addrlen, int timeout) {
+
+    int ret;
+
+    do {
+        ret = connect(s->fd, addr, addrlen);
+    } while (ret && errno == EINTR);
+
+    if (ret && errno == EINPROGRESS) {
+        /* ready to poll() */
+        socklen_t retlen;
+        struct pollfd pfd[2];
+
+        pfd[0].fd = s->fd;
+        pfd[0].events = POLLOUT;
+        pfd[0].revents = 0;
+        pfd[1].fd = s->abort_fd[0];
+        pfd[1].events = POLLIN;
+        pfd[1].revents = 0;
+
+        do {
+            ret = poll(pfd, 2, timeout);
+        } while (ret < 0 && errno == EINTR);
+
+        if (ret < 0)
+            return -1;
+        else if (ret == 0) {
+            /* timeout */
+            errno = ETIMEDOUT;
+            return -1;
+        }
+
+        if (pfd[1].revents) {
+            /* abort due to asocket_abort() */
+            errno = ECANCELED;
+            return -1;
+        }
+
+        if (pfd[0].revents) {
+            if (pfd[0].revents & POLLOUT) {
+                /* connect call complete, read return code */
+                retlen = sizeof(ret);
+                if (getsockopt(s->fd, SOL_SOCKET, SO_ERROR, &ret, &retlen))
+                    return -1;
+                /* got connect() return code */
+                if (ret) {
+                    errno = ret;
+                }
+            } else {
+                /* some error event on this fd */
+                errno = ECONNABORTED;
+                return -1;
+            }
+        }
+    }
+
+    return ret;
+}
+
+int asocket_accept(struct asocket *s, struct sockaddr *addr,
+        socklen_t *addrlen, int timeout) {
+
+    int ret;
+    struct pollfd pfd[2];
+
+    pfd[0].fd = s->fd;
+    pfd[0].events = POLLIN;
+    pfd[0].revents = 0;
+    pfd[1].fd = s->abort_fd[0];
+    pfd[1].events = POLLIN;
+    pfd[1].revents = 0;
+
+    do {
+        ret = poll(pfd, 2, timeout);
+    } while (ret < 0 && errno == EINTR);
+
+    if (ret < 0)
+        return -1;
+    else if (ret == 0) {
+        /* timeout */
+        errno = ETIMEDOUT;
+        return -1;
+    }
+
+    if (pfd[1].revents) {
+        /* abort due to asocket_abort() */
+        errno = ECANCELED;
+        return -1;
+    }
+
+    if (pfd[0].revents) {
+        if (pfd[0].revents & POLLIN) {
+            /* ready to accept() without blocking */
+            do {
+                ret = accept(s->fd, addr, addrlen);
+            } while (ret < 0 && errno == EINTR);
+        } else {
+            /* some error event on this fd */
+            errno = ECONNABORTED;
+            return -1;
+        }
+    }
+
+    return ret;
+}
+
+int asocket_read(struct asocket *s, void *buf, size_t count, int timeout) {
+    int ret;
+    struct pollfd pfd[2];
+
+    pfd[0].fd = s->fd;
+    pfd[0].events = POLLIN;
+    pfd[0].revents = 0;
+    pfd[1].fd = s->abort_fd[0];
+    pfd[1].events = POLLIN;
+    pfd[1].revents = 0;
+
+    do {
+        ret = poll(pfd, 2, timeout);
+    } while (ret < 0 && errno == EINTR);
+
+    if (ret < 0)
+        return -1;
+    else if (ret == 0) {
+        /* timeout */
+        errno = ETIMEDOUT;
+        return -1;
+    }
+
+    if (pfd[1].revents) {
+        /* abort due to asocket_abort() */
+        errno = ECANCELED;
+        return -1;
+    }
+
+    if (pfd[0].revents) {
+        if (pfd[0].revents & POLLIN) {
+            /* ready to read() without blocking */
+            do {
+                ret = read(s->fd, buf, count);
+            } while (ret < 0 && errno == EINTR);
+        } else {
+            /* some error event on this fd */
+            errno = ECONNABORTED;
+            return -1;
+        }
+    }
+
+    return ret;
+}
+
+int asocket_write(struct asocket *s, const void *buf, size_t count,
+        int timeout) {
+    int ret;
+    struct pollfd pfd[2];
+
+    pfd[0].fd = s->fd;
+    pfd[0].events = POLLOUT;
+    pfd[0].revents = 0;
+    pfd[1].fd = s->abort_fd[0];
+    pfd[1].events = POLLIN;
+    pfd[1].revents = 0;
+
+    do {
+        ret = poll(pfd, 2, timeout);
+    } while (ret < 0 && errno == EINTR);
+
+    if (ret < 0)
+        return -1;
+    else if (ret == 0) {
+        /* timeout */
+        errno = ETIMEDOUT;
+        return -1;
+    }
+
+    if (pfd[1].revents) {
+        /* abort due to asocket_abort() */
+        errno = ECANCELED;
+        return -1;
+    }
+
+    if (pfd[0].revents) {
+        if (pfd[0].revents & POLLOUT) {
+            /* ready to write() without blocking */
+            do {
+                ret = write(s->fd, buf, count);
+            } while (ret < 0 && errno == EINTR);
+        } else {
+            /* some error event on this fd */
+            errno = ECONNABORTED;
+            return -1;
+        }
+    }
+
+    return ret;
+}
+
+void asocket_abort(struct asocket *s) {
+    int ret;
+    char buf = 0;
+
+    /* Prevent further use of fd, without yet releasing the fd */
+    shutdown(s->fd, SHUT_RDWR);
+
+    /* wake up calls blocked at poll() */
+    do {
+        ret = write(s->abort_fd[1], &buf, 1);
+    } while (ret < 0 && errno == EINTR);
+}
+
+void asocket_destroy(struct asocket *s) {
+    struct asocket s_copy = *s;
+
+    /* Clients should *not* be using these fd's after calling
+       asocket_destroy(), but in case they do, set to -1 so they cannot use a
+       stale fd */
+    s->fd = -1;
+    s->abort_fd[0] = -1;
+    s->abort_fd[1] = -1;
+
+    /* Call asocket_abort() in case there are still threads blocked on this
+       socket. Clients should not rely on this behavior - it is racy because we
+       are about to close() these sockets - clients should instead make sure
+       all threads are done with the socket before calling asocket_destory().
+     */
+    asocket_abort(&s_copy);
+
+    /* enough safety checks, close and release memory */
+    close(s_copy.abort_fd[1]);
+    close(s_copy.abort_fd[0]);
+    close(s_copy.fd);
+
+    free(s);
+}
diff --git a/libcutils/strdup16to8.c b/libcutils/strdup16to8.c
index fadaabe..1a8ba86 100644
--- a/libcutils/strdup16to8.c
+++ b/libcutils/strdup16to8.c
@@ -15,6 +15,8 @@
 ** limitations under the License.
 */
 
+#include <limits.h>  /* for SIZE_MAX */
+
 #include <cutils/jstring.h>
 #include <assert.h>
 #include <stdlib.h>
@@ -26,19 +28,67 @@
  */
 extern size_t strnlen16to8(const char16_t* utf16Str, size_t len)
 {
-   size_t utf8Len = 0;
+    size_t utf8Len = 0;
 
-   while (len--) {
-       unsigned int uic = *utf16Str++;
+    /* A small note on integer overflow. The result can
+     * potentially be as big as 3*len, which will overflow
+     * for len > SIZE_MAX/3.
+     *
+     * Moreover, the result of a strnlen16to8 is typically used
+     * to allocate a destination buffer to strncpy16to8 which
+     * requires one more byte to terminate the UTF-8 copy, and
+     * this is generally done by careless users by incrementing
+     * the result without checking for integer overflows, e.g.:
+     *
+     *   dst = malloc(strnlen16to8(utf16,len)+1)
+     *
+     * Due to this, the following code will try to detect
+     * overflows, and never return more than (SIZE_MAX-1)
+     * when it detects one. A careless user will try to malloc
+     * SIZE_MAX bytes, which will return NULL which can at least
+     * be detected appropriately.
+     *
+     * As far as I know, this function is only used by strndup16(),
+     * but better be safe than sorry.
+     */
 
-       if (uic > 0x07ff)
-           utf8Len += 3;
-       else if (uic > 0x7f || uic == 0)
-           utf8Len += 2;
-       else
-           utf8Len++;
-   }
-   return utf8Len;
+    /* Fast path for the usual case where 3*len is < SIZE_MAX-1.
+     */
+    if (len < (SIZE_MAX-1)/3) {
+        while (len--) {
+            unsigned int uic = *utf16Str++;
+
+            if (uic > 0x07ff)
+                utf8Len += 3;
+            else if (uic > 0x7f || uic == 0)
+                utf8Len += 2;
+            else
+                utf8Len++;
+        }
+        return utf8Len;
+    }
+
+    /* The slower but paranoid version */
+    while (len--) {
+        unsigned int  uic     = *utf16Str++;
+        size_t        utf8Cur = utf8Len;
+
+        if (uic > 0x07ff)
+            utf8Len += 3;
+        else if (uic > 0x7f || uic == 0)
+            utf8Len += 2;
+        else
+            utf8Len++;
+
+        if (utf8Len < utf8Cur) /* overflow detected */
+            return SIZE_MAX-1;
+    }
+
+    /* don't return SIZE_MAX to avoid common user bug */
+    if (utf8Len == SIZE_MAX)
+        utf8Len = SIZE_MAX-1;
+
+    return utf8Len;
 }
 
 
@@ -50,7 +100,7 @@
  *
  * Make sure you allocate "utf8Str" with the result of strlen16to8() + 1,
  * not just "len".
- * 
+ *
  * Please note, a terminated \0 is always added, so your result will always
  * be "strlen16to8() + 1" bytes long.
  */
@@ -58,6 +108,10 @@
 {
     char* utf8cur = utf8Str;
 
+    /* Note on overflows: We assume the user did check the result of
+     * strnlen16to8() properly or at a minimum checked the result of
+     * its malloc(SIZE_MAX) in case of overflow.
+     */
     while (len--) {
         unsigned int uic = *utf16Str++;
 
@@ -73,8 +127,8 @@
 
             if (uic == 0) {
                 break;
-            }           
-        }       
+            }
+        }
     }
 
    *utf8cur = '\0';
@@ -85,20 +139,30 @@
 /**
  * Convert a UTF-16 string to UTF-8.
  *
- * Make sure you allocate "dest" with the result of strblen16to8(),
- * not just "strlen16()".
  */
 char * strndup16to8 (const char16_t* s, size_t n)
 {
-    char *ret;
+    char*   ret;
+    size_t  len;
 
     if (s == NULL) {
         return NULL;
     }
 
-    ret = malloc(strnlen16to8(s, n) + 1);
+    len = strnlen16to8(s, n);
+
+    /* We are paranoid, and we check for SIZE_MAX-1
+     * too since it is an overflow value for our
+     * strnlen16to8 implementation.
+     */
+    if (len >= SIZE_MAX-1)
+        return NULL;
+
+    ret = malloc(len + 1);
+    if (ret == NULL)
+        return NULL;
 
     strncpy16to8 (ret, s, n);
-    
-    return ret;    
+
+    return ret;
 }
diff --git a/liblog/logprint.c b/liblog/logprint.c
index 2cf1254..080f9e3 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -23,7 +23,6 @@
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
-#include <alloca.h>
 #include <assert.h>
 #include <arpa/inet.h>
 
diff --git a/libnetutils/ifc_utils.c b/libnetutils/ifc_utils.c
index 88635d9..bde336f 100644
--- a/libnetutils/ifc_utils.c
+++ b/libnetutils/ifc_utils.c
@@ -224,6 +224,16 @@
     return result;
 }
 
+int ifc_enable(const char *ifname)
+{
+    int result;
+
+    ifc_init();
+    result = ifc_up(ifname);
+    ifc_close();
+    return result;
+}
+
 int ifc_disable(const char *ifname)
 {
     int result;
diff --git a/libpixelflinger/Android.mk b/libpixelflinger/Android.mk
index 50eb5f5..0cc85d9 100644
--- a/libpixelflinger/Android.mk
+++ b/libpixelflinger/Android.mk
@@ -64,12 +64,14 @@
 LOCAL_MODULE:= libpixelflinger
 LOCAL_SRC_FILES := $(PIXELFLINGER_SRC_FILES)
 LOCAL_CFLAGS := $(PIXELFLINGER_CFLAGS)
+
 ifneq ($(BUILD_TINY_ANDROID),true)
 # Really this should go away entirely or at least not depend on
 # libhardware, but this at least gets us built.
 LOCAL_SHARED_LIBRARIES += libhardware_legacy
 LOCAL_CFLAGS += -DWITH_LIB_HARDWARE
 endif
+
 ifeq ($(TARGET_ARCH),arm)
 LOCAL_WHOLE_STATIC_LIBRARIES := libpixelflinger_armv6
 endif
diff --git a/libsysutils/src/FrameworkListener.cpp b/libsysutils/src/FrameworkListener.cpp
index e9ca897..4c74765 100644
--- a/libsysutils/src/FrameworkListener.cpp
+++ b/libsysutils/src/FrameworkListener.cpp
@@ -56,24 +56,73 @@
 }
 
 void FrameworkListener::dispatchCommand(SocketClient *cli, char *data) {
-    int argc;
+    FrameworkCommandCollection::iterator i;
+    int argc = 0;
     char *argv[FrameworkListener::CMD_ARGS_MAX];
+    char tmp[255];
+    char *p = data;
+    char *q = tmp;
+    bool esc = false;
+    bool quote = false;
+    int k;
 
-    if (!index(data, '"')) {
-        char *next = data;
-        char *field;
-        int i;
+    memset(argv, 0, sizeof(argv));
+    memset(tmp, 0, sizeof(tmp));
+    while(*p) {
+        if (*p == '\\') {
+            if (esc) {
+                *q++ = '\\';
+                esc = false;
+            } else
+                esc = true;
+            p++;
+            continue;
+        } else if (esc) {
+            if (*p == '"')
+                *q++ = '"';
+            else if (*p == '\\')
+                *q++ = '\\';
+            else {
+                cli->sendMsg(500, "Unsupported escape sequence", false);
+                goto out;
+            }
+            p++;
+            esc = false;
+            continue;
+        }
 
-        for (i = 0; (i < FrameworkListener::CMD_ARGS_MAX) &&
-                    (argv[i] = strsep(&next, " ")); i++);
-        argc = i+1;
-    } else {
-        LOGD("blehhh not supported");
-        return;
+        if (*p == '"') {
+            if (quote)
+                quote = false;
+            else
+                quote = true;
+            p++;
+            continue;
+        }
+
+        *q = *p++;
+        if (!quote && *q == ' ') {
+            *q = '\0';
+            argv[argc++] = strdup(tmp);
+            memset(tmp, 0, sizeof(tmp));
+            q = tmp;
+            continue;
+        }
+        q++;
     }
 
-    FrameworkCommandCollection::iterator i;
+    argv[argc++] = strdup(tmp);
+#if 0
+    for (k = 0; k < argc; k++) {
+        LOGD("arg[%d] = '%s'", k, argv[k]);
+    }
+#endif
 
+    if (quote) {
+        cli->sendMsg(500, "Unclosed quotes error", false);
+        goto out;
+    }
+    
     for (i = mCommands->begin(); i != mCommands->end(); ++i) {
         FrameworkCommand *c = *i;
 
@@ -81,10 +130,14 @@
             if (c->runCommand(cli, argc, argv)) {
                 LOGW("Handler '%s' error (%s)", c->getCommand(), strerror(errno));
             }
-            return;
+            goto out;
         }
     }
 
     cli->sendMsg(500, "Command not recognized", false);
+out:
+    int j;
+    for (j = 0; j < argc; j++)
+        free(argv[j]);
     return;
 }
diff --git a/libsysutils/src/SocketListener.cpp b/libsysutils/src/SocketListener.cpp
index 1a937c2..72e128d 100644
--- a/libsysutils/src/SocketListener.cpp
+++ b/libsysutils/src/SocketListener.cpp
@@ -45,9 +45,26 @@
     mClients = new SocketClientCollection();
 }
 
+SocketListener::~SocketListener() {
+    if (mSocketName && mSock > -1)
+        close(mSock);
+
+    if (mCtrlPipe[0] != -1) {
+        close(mCtrlPipe[0]);
+        close(mCtrlPipe[1]);
+    }
+    SocketClientCollection::iterator it;
+    for (it = mClients->begin(); it != mClients->end(); ++it) {
+        delete (*it);
+        it = mClients->erase(it);
+    }
+    delete mClients;
+}
+
 int SocketListener::startListener() {
 
     if (!mSocketName && mSock == -1) {
+        LOGE("Failed to start unbound listener");
         errno = EINVAL;
         return -1;
     } else if (mSocketName) {
@@ -64,11 +81,15 @@
     } else if (!mListen)
         mClients->push_back(new SocketClient(mSock));
 
-    if (pipe(mCtrlPipe))
+    if (pipe(mCtrlPipe)) {
+        LOGE("pipe failed (%s)", strerror(errno));
         return -1;
+    }
 
-    if (pthread_create(&mThread, NULL, SocketListener::threadStart, this))
+    if (pthread_create(&mThread, NULL, SocketListener::threadStart, this)) {
+        LOGE("pthread_create (%s)", strerror(errno));
         return -1;
+    }
 
     return 0;
 }
@@ -88,6 +109,19 @@
     }
     close(mCtrlPipe[0]);
     close(mCtrlPipe[1]);
+    mCtrlPipe[0] = -1;
+    mCtrlPipe[1] = -1;
+
+    if (mSocketName && mSock > -1) {
+        close(mSock);
+        mSock = -1;
+    }
+
+    SocketClientCollection::iterator it;
+    for (it = mClients->begin(); it != mClients->end(); ++it) {
+        delete (*it);
+        it = mClients->erase(it);
+    }
     return 0;
 }
 
diff --git a/libzipfile/centraldir.c b/libzipfile/centraldir.c
index 4387ceb..0391c09 100644
--- a/libzipfile/centraldir.c
+++ b/libzipfile/centraldir.c
@@ -13,7 +13,7 @@
     // central directory entries
     ENTRY_SIGNATURE = 0x02014b50,
     ENTRY_LEN = 46,          // CentralDirEnt len, excl. var fields
-    
+
     // local file header
     LFH_SIZE = 30,
 };
@@ -73,8 +73,6 @@
     unsigned short  lastModFileTime;
     unsigned short  lastModFileDate;
     unsigned long   crc32;
-    unsigned long   compressedSize;
-    unsigned long   uncompressedSize;
     unsigned short  extraFieldLength;
     unsigned short  fileCommentLength;
     unsigned short  diskNumberStart;
@@ -85,7 +83,7 @@
     const unsigned char*  fileComment;
     unsigned int dataOffset;
     unsigned short lfhExtraFieldSize;
-    
+
 
     p = *buf;
 
@@ -106,7 +104,7 @@
     lastModFileTime = read_le_short(&p[0x0c]);
     lastModFileDate = read_le_short(&p[0x0e]);
     crc32 = read_le_int(&p[0x10]);
-    compressedSize = read_le_int(&p[0x14]);
+    entry->compressedSize = read_le_int(&p[0x14]);
     entry->uncompressedSize = read_le_int(&p[0x18]);
     entry->fileNameLength = read_le_short(&p[0x1c]);
     extraFieldLength = read_le_short(&p[0x1e]);
@@ -141,14 +139,14 @@
         fileComment = NULL;
     }
     p += fileCommentLength;
-    
+
     *buf = p;
 
     // the size of the extraField in the central dir is how much data there is,
     // but the one in the local file header also contains some padding.
     p = file->buf + localHeaderRelOffset;
     extraFieldLength = read_le_short(&p[0x1c]);
-    
+
     dataOffset = localHeaderRelOffset + LFH_SIZE
         + entry->fileNameLength + extraFieldLength;
     entry->data = file->buf + dataOffset;
@@ -243,7 +241,7 @@
             free(entry);
             goto bail;
         }
-        
+
         // add it to our list
         entry->next = file->entries;
         file->entries = entry;
@@ -253,4 +251,3 @@
 bail:
     return -1;
 }
-
diff --git a/libzipfile/zipfile.c b/libzipfile/zipfile.c
index b52d02d..a401a9b 100644
--- a/libzipfile/zipfile.c
+++ b/libzipfile/zipfile.c
@@ -82,13 +82,13 @@
     unsigned long crc;
     int err = 0;
     int zerr;
-    
+
     memset(&zstream, 0, sizeof(zstream));
     zstream.zalloc = Z_NULL;
     zstream.zfree = Z_NULL;
     zstream.opaque = Z_NULL;
     zstream.next_in = (void*)in;
-    zstream.avail_in = unlen;
+    zstream.avail_in = clen;
     zstream.next_out = (Bytef*) out;
     zstream.avail_out = unlen;
     zstream.data_type = Z_UNKNOWN;
@@ -99,7 +99,7 @@
     if (zerr != Z_OK) {
         return -1;
     }
-    
+
     // uncompress the data
     zerr = inflate(&zstream, Z_FINISH);
     if (zerr != Z_STREAM_END) {
@@ -107,7 +107,7 @@
                     zstream.total_out);
         err = -1;
     }
-    
+
      inflateEnd(&zstream);
     return err;
 }
diff --git a/logcat/event-log-tags b/logcat/event-log-tags
index 6df3792..4dabbbc 100644
--- a/logcat/event-log-tags
+++ b/logcat/event-log-tags
@@ -21,7 +21,7 @@
 # 2: long
 # 3: string
 # 4: list
-# 
+#
 # The data unit is a number taken from the following list:
 # 1: Number of objects
 # 2: Number of bytes
@@ -58,11 +58,11 @@
 # This is logged when the partial wake lock (keeping the device awake
 # regardless of whether the screen is off) is acquired or released.
 2729 power_partial_wake_state (releasedorAcquired|1|5),(tag|3)
-# This is logged when battery goes from discharging to charging. 
+# This is logged when battery goes from discharging to charging.
 # It lets us count the total amount of time between charges and the discharge level
 2730 battery_discharge (duration|2|3),(minLevel|1|6),(maxLevel|1|6)
 #
-# Leave IDs through 2739 for more power logs 
+# Leave IDs through 2739 for more power logs
 #
 
 # This event is logged when the location service uploads location data.
@@ -94,7 +94,7 @@
 2800 gtalkservice (eventType|1)
 # This event is logged for GTalk connection state changes. The status field is an int, but
 # it really contains 4 separate values, each taking up a byte
-# (eventType, connection state, connection error, network state)
+#     (eventType << 24) + (connection state << 16) + (connection error << 8) + network state
 2801 gtalk_connection (status|1)
 
 2802 watchdog (Service|3)
@@ -135,6 +135,26 @@
 3100 boot_progress_pms_ready (time|2|3)
 # + check activity_launch_time for Home app
 
+# This event is logged when GTalk connection is closed.
+# The status field is an int, but contains 2 different values, it's represented as
+#
+#     (networkType << 8) + connection error
+#
+# the possible error values are
+#
+# no_error=0, no_network=1, connection_failed=2, unknown_host=3, auth_failed=4,
+# auth_expired=5, heart_beat_timeout=6, server_error=7, server_reject_rate_limiting=8, unknown=10
+#
+# duration is the connection duration.
+4000 gtalk_conn_close (status|1),(duration|1)
+
+# This event is logged for GTalk heartbeat resets
+# interval_and_nt contains both the heartbeat interval and the network type, It's represented as
+#     (networkType << 16) + interval
+# interval is in seconds; network type can be 0 (mobile) or 1 (wifi); ip is the host ip addr.
+4001 gtalk_heartbeat_reset (interval_and_nt|1),(ip|3)
+
+
 # Do not change these names without updating the checkin_events setting in
 # google3/googledata/wireless/android/provisioning/gservices.config !!
 #
@@ -160,9 +180,9 @@
 30010 am_proc_bound (PID|1|5),(Process Name|3)
 # Application process died
 30011 am_proc_died (PID|1|5),(Process Name|3)
-# The Activity Manager failed to pause the given activity. 
+# The Activity Manager failed to pause the given activity.
 30012 am_failed_to_pause (Token|1|5),(Wanting to pause|3),(Currently pausing|3)
-# Attempting to pause the current activity 
+# Attempting to pause the current activity
 30013 am_pause_activity (Token|1|5),(Component Name|3)
 # Application process has been started
 30014 am_proc_start (PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3)
@@ -262,28 +282,28 @@
 # Connectivity state changed:
 # [31-13] Reserved for future use
 # [12- 9] Network subtype (for mobile network, as defined by TelephonyManager)
-# [ 8- 3] Detailed state ordinal (as defined by NetworkInfo.DetailedState)   
+# [ 8- 3] Detailed state ordinal (as defined by NetworkInfo.DetailedState)
 # [ 2- 0] Network type (as defined by ConnectivityManager)
 50020 connectivity_state_changed (custom|1|5)
 
 # Wi-Fi network state changed:
 # [31- 6] Reserved for future use
-# [ 5- 0] Detailed state ordinal (as defined by NetworkInfo.DetailedState)   
+# [ 5- 0] Detailed state ordinal (as defined by NetworkInfo.DetailedState)
 50021 wifi_network_state_changed (network_state|1|5)
 
 # Wi-Fi supplicant state changed:
 # [31- 6] Reserved for future use
-# [ 5- 0] Supplicant state ordinal (as defined by SupplicantState)   
+# [ 5- 0] Supplicant state ordinal (as defined by SupplicantState)
 50022 wifi_supplicant_state_changed (supplicant_state|1|5)
 
 # Wi-Fi driver state changed:
 # [31- 1] Reserved for future use
-# [ 0- 0] Driver start (1) or stopped (0)   
+# [ 0- 0] Driver start (1) or stopped (0)
 50023 wifi_driver_state_changed (driver_state|1|5)
 
 # Wi-Fi interface configuration state changed:
 # [31- 1] Reserved for future use
-# [ 0- 0] Interface configuration succeeded (1) or failed (0)   
+# [ 0- 0] Interface configuration succeeded (1) or failed (0)
 50024 wifi_interface_configuration_state_changed (IP_configuration|1|5)
 
 # Wi-Fi supplicant connection state changed:
@@ -333,7 +353,7 @@
 #//device/dalvik/libcore/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.c
 51000 socket_stats (send|1|2),(recv|1|2),(ip|1|5),(port|1|5),(close|1|5)
 
-# db stats.  0 is query, 1 is write (may become more fine grained in the 
+# db stats.  0 is query, 1 is write (may become more fine grained in the
 # future)
 52000 db_operation (name|3),(op_type|1|5),(time|2|3)
 
@@ -351,5 +371,9 @@
 70101 browser_zoom_level_change (start level|1|5),(end level|1|5),(time|2|3)
 70102 browser_double_tap_duration (duration|1|3),(time|2|3)
 
+# aggregation service
+70200 aggregation (aggregation time|2|3)
+70201 aggregation_test (field1|1|2),(field2|1|2),(field3|1|2),(field4|1|2),(field5|1|2)
+
 # NOTE - the range 1000000-2000000 is reserved for partners and others who
 # want to define their own log tags without conflicting with the core platform.
diff --git a/nexus/Android.mk b/nexus/Android.mk
index cd477ef..f9f7110 100644
--- a/nexus/Android.mk
+++ b/nexus/Android.mk
@@ -7,23 +7,22 @@
 
 LOCAL_SRC_FILES:=                                      \
                   main.cpp                             \
-                  NetworkManager.cpp                   \
+                  NexusCommand.cpp                     \
                   CommandListener.cpp                  \
+                  Property.cpp                         \
+                  PropertyManager.cpp                  \
+                  InterfaceConfig.cpp                  \
+                  NetworkManager.cpp                   \
                   Controller.cpp                       \
                   WifiController.cpp                   \
-                  LoopController.cpp                   \
-                  NexusCommand.cpp                     \
                   TiwlanWifiController.cpp             \
+                  TiwlanEventListener.cpp              \
+                  WifiNetwork.cpp                      \
+                  WifiStatusPoller.cpp                 \
+                  ScanResult.cpp                       \
                   Supplicant.cpp                       \
                   SupplicantEvent.cpp                  \
                   SupplicantListener.cpp               \
-                  VpnController.cpp                    \
-                  ScanResult.cpp                       \
-                  WifiScanner.cpp                      \
-                  WifiNetwork.cpp                      \
-                  OpenVpnController.cpp                \
-                  InterfaceConfig.cpp                  \
-                  PropertyManager.cpp                  \
                   SupplicantState.cpp                  \
                   SupplicantEventFactory.cpp           \
                   SupplicantConnectedEvent.cpp         \
@@ -34,8 +33,11 @@
                   SupplicantConnectionTimeoutEvent.cpp \
                   SupplicantDisconnectedEvent.cpp      \
                   SupplicantStatus.cpp                 \
-                  TiwlanEventListener.cpp              \
+                  OpenVpnController.cpp                \
+                  VpnController.cpp                    \
+                  LoopController.cpp                   \
                   DhcpClient.cpp DhcpListener.cpp      \
+                  DhcpState.cpp DhcpEvent.cpp          \
 
 LOCAL_MODULE:= nexus
 
diff --git a/nexus/CommandListener.cpp b/nexus/CommandListener.cpp
index 8eb378b..5973ff5 100644
--- a/nexus/CommandListener.cpp
+++ b/nexus/CommandListener.cpp
@@ -31,7 +31,7 @@
 #include "NetworkManager.h"
 #include "WifiController.h"
 #include "VpnController.h"
-#include "ErrorCode.h"
+#include "ResponseCode.h"
 
 CommandListener::CommandListener() :
                  FrameworkListener("nexus") {
@@ -60,11 +60,11 @@
     WifiNetwork *wn;
 
     if (!(wn = wc->createNetwork()))
-        cli->sendMsg(ErrorCode::OperationFailed, "Failed to create network", true);
+        cli->sendMsg(ResponseCode::OperationFailed, "Failed to create network", true);
     else {
         char tmp[128];
         sprintf(tmp, "Created network id %d.", wn->getNetworkId());
-        cli->sendMsg(ErrorCode::CommandOkay, tmp, false);
+        cli->sendMsg(ResponseCode::CommandOkay, tmp, false);
     }
     return 0;
 }
@@ -79,9 +79,9 @@
     WifiController *wc = (WifiController *) nm->findController("WIFI");
 
     if (wc->removeNetwork(atoi(argv[1])))
-        cli->sendMsg(ErrorCode::OperationFailed, "Failed to remove network", true);
+        cli->sendMsg(ResponseCode::OperationFailed, "Failed to remove network", true);
     else {
-        cli->sendMsg(ErrorCode::CommandOkay, "Network removed.", false);
+        cli->sendMsg(ResponseCode::CommandOkay, "Network removed.", false);
     }
     return 0;
 }
@@ -100,16 +100,16 @@
     char buffer[256];
 
     for(it = src->begin(); it != src->end(); ++it) {
-        sprintf(buffer, "%s:%u:%d:%s:%s",
+        sprintf(buffer, "%s %u %d %s %s",
                 (*it)->getBssid(), (*it)->getFreq(), (*it)->getLevel(),
                 (*it)->getFlags(), (*it)->getSsid());
-        cli->sendMsg(ErrorCode::WifiScanResult, buffer, false);
+        cli->sendMsg(ResponseCode::WifiScanResult, buffer, false);
         delete (*it);
         it = src->erase(it);
     }
 
     delete src;
-    cli->sendMsg(ErrorCode::CommandOkay, "Scan results complete.", false);
+    cli->sendMsg(ResponseCode::CommandOkay, "Scan results complete.", false);
     return 0;
 }
 
@@ -128,12 +128,12 @@
 
     for(it = src->begin(); it != src->end(); ++it) {
         sprintf(buffer, "%d:%s", (*it)->getNetworkId(), (*it)->getSsid());
-        cli->sendMsg(ErrorCode::WifiNetworkList, buffer, false);
+        cli->sendMsg(ResponseCode::WifiNetworkList, buffer, false);
         delete (*it);
     }
 
     delete src;
-    cli->sendMsg(ErrorCode::CommandOkay, "Network listing complete.", false);
+    cli->sendMsg(ResponseCode::CommandOkay, "Network listing complete.", false);
     return 0;
 }
 
@@ -159,14 +159,14 @@
 
     char *tmp;
     asprintf(&tmp, "%s %s", argv[1], val);
-    cli->sendMsg(ErrorCode::PropertyRead, tmp, false);
+    cli->sendMsg(ResponseCode::PropertyRead, tmp, false);
     free(tmp);
 
-    cli->sendMsg(ErrorCode::CommandOkay, "Property read.", false);
+    cli->sendMsg(ResponseCode::CommandOkay, "Property read.", false);
     return 0;
 out_inval:
     errno = EINVAL;
-    cli->sendMsg(ErrorCode::CommandParameterError, "Failed to read property.", true);
+    cli->sendMsg(ResponseCode::CommandParameterError, "Failed to read property.", true);
     return 0;
 }
 
@@ -179,12 +179,12 @@
     if (NetworkManager::Instance()->getPropMngr()->set(argv[1], argv[2]))
         goto out_inval;
 
-    cli->sendMsg(ErrorCode::CommandOkay, "Property set.", false);
+    cli->sendMsg(ResponseCode::CommandOkay, "Property set.", false);
     return 0;
 
 out_inval:
     errno = EINVAL;
-    cli->sendMsg(ErrorCode::CommandParameterError, "Failed to set property.", true);
+    cli->sendMsg(ResponseCode::CommandParameterError, "Failed to set property.", true);
     return 0;
 }
 
@@ -194,10 +194,14 @@
 
 int CommandListener::ListCmd::runCommand(SocketClient *cli, int argc, char **argv) {
     android::List<char *> *pc;
+    char *prefix = NULL;
 
-    if (!(pc = NetworkManager::Instance()->getPropMngr()->createPropertyList())) {
+    if (argc > 1)
+        prefix = argv[1];
+
+    if (!(pc = NetworkManager::Instance()->getPropMngr()->createPropertyList(prefix))) {
         errno = ENODATA;
-        cli->sendMsg(ErrorCode::CommandParameterError, "Failed to list properties.", true);
+        cli->sendMsg(ResponseCode::CommandParameterError, "Failed to list properties.", true);
         return 0;
     }
 
@@ -218,7 +222,7 @@
             free((*it));
             continue;
         }
-        cli->sendMsg(ErrorCode::PropertyList, buf, false);
+        cli->sendMsg(ResponseCode::PropertyList, buf, false);
         free(buf);
 
         free((*it));
@@ -226,6 +230,6 @@
 
     delete pc;
 
-    cli->sendMsg(ErrorCode::CommandOkay, "Properties list complete.", false);
+    cli->sendMsg(ResponseCode::CommandOkay, "Properties list complete.", false);
     return 0;
 }
diff --git a/nexus/Controller.cpp b/nexus/Controller.cpp
index 17fb519..f6a2436 100644
--- a/nexus/Controller.cpp
+++ b/nexus/Controller.cpp
@@ -30,6 +30,7 @@
 #include <cutils/log.h>
 
 #include "Controller.h"
+#include "InterfaceConfig.h"
 
 extern "C" int init_module(void *, unsigned int, const char *);
 extern "C" int delete_module(const char *, unsigned int);
@@ -57,16 +58,6 @@
     return 0;
 }
 
-int Controller::set(const char *name, const char *value) {
-    errno = ENOENT;
-    return -1;
-}
-
-const char *Controller::get(const char *name, char *buffer, size_t maxsize) {
-    errno = ENOENT;
-    return NULL;
-}
-
 int Controller::loadKernelModule(char *modpath, const char *args) {
     void *module;
     unsigned int size;
@@ -164,13 +155,11 @@
 
 int Controller::bindInterface(const char *ifname) {
     mBoundInterface = strdup(ifname);
-    LOGD("Controller %s bound to %s", mName, ifname);
     return 0;
 }
 
 int Controller::unbindInterface(const char *ifname) {
     free(mBoundInterface);
     mBoundInterface = NULL;
-    LOGD("Controller %s unbound from %s", mName, ifname);
     return 0;
 }
diff --git a/nexus/Controller.h b/nexus/Controller.h
index af03d2e..e7e17c5 100644
--- a/nexus/Controller.h
+++ b/nexus/Controller.h
@@ -26,9 +26,8 @@
 class IControllerHandler;
 
 #include "PropertyManager.h"
-#include "IPropertyProvider.h"
 
-class Controller : public IPropertyProvider {
+class Controller {
     /*
      * Name of this controller - WIFI/VPN/USBNET/BTNET/BTDUN/LOOP/etc
      */
@@ -54,11 +53,7 @@
 
     const char *getName() { return mName; }
     const char *getBoundInterface() { return mBoundInterface; }
-
-    /* IPropertyProvider methods */
-    virtual int set(const char *name, const char *value);
-    virtual const char *get(const char *name, char *buffer, size_t maxsize);
-
+    
 protected:
     int loadKernelModule(char *modpath, const char *args);
     bool isKernelModuleLoaded(const char *modtag);
diff --git a/nexus/DhcpClient.cpp b/nexus/DhcpClient.cpp
index 2bd9c68..a5654d2 100644
--- a/nexus/DhcpClient.cpp
+++ b/nexus/DhcpClient.cpp
@@ -17,7 +17,9 @@
 #include <stdio.h>
 #include <errno.h>
 #include <sys/types.h>
+#include <sys/socket.h>
 #include <arpa/inet.h>
+#include <pthread.h>
 
 #define LOG_TAG "DhcpClient"
 #include <cutils/log.h>
@@ -29,6 +31,7 @@
 #include "DhcpState.h"
 #include "DhcpListener.h"
 #include "IDhcpEventHandlers.h"
+#include "Controller.h"
 
 extern "C" {
 int ifc_disable(const char *ifname);
@@ -54,9 +57,13 @@
 }
 
 DhcpClient::DhcpClient(IDhcpEventHandlers *handlers) :
-            mState(DhcpState::STOPPED), mHandlers(handlers) {
+            mState(DhcpState::INIT), mHandlers(handlers) {
     mServiceManager = new ServiceManager();
     mListener = NULL;
+    mListenerSocket = NULL;
+    mController = NULL;
+    mDoArpProbe = false;
+    pthread_mutex_init(&mLock, NULL);
 }
 
 DhcpClient::~DhcpClient() {
@@ -65,41 +72,89 @@
         delete mListener;
 }
 
-int DhcpClient::start(const char *interface) {
-
+int DhcpClient::start(Controller *c) {
+    LOGD("Starting DHCP service (arp probe = %d)", mDoArpProbe);
     char svc[PROPERTY_VALUE_MAX];
-    snprintf(svc, sizeof(svc), "dhcpcd_ng:%s", interface);
+    snprintf(svc,
+             sizeof(svc),
+             "dhcpcd:%s%s",
+             (!mDoArpProbe ? "-A " : ""),
+             c->getBoundInterface());
 
-    if (mServiceManager->start(svc)) {
-        LOGE("Failed to start dhcp service");
+    pthread_mutex_lock(&mLock);
+
+    if (mController) {
+        pthread_mutex_unlock(&mLock);
+        errno = EBUSY;
+        return -1;
+    }
+    mController = c;
+
+    sockaddr_in addr;
+    if ((mListenerSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
+        LOGE("Failed to create DHCP listener socket");
+        pthread_mutex_unlock(&mLock);
+        return -1;
+    }
+    memset(&addr, 0, sizeof(addr));
+    addr.sin_family = AF_INET;
+    addr.sin_addr.s_addr = inet_addr("127.0.0.1");
+    addr.sin_port = htons(DhcpClient::STATUS_MONITOR_PORT);
+
+    if (bind(mListenerSocket, (struct sockaddr *) &addr, sizeof(addr))) {
+        LOGE("Failed to bind DHCP listener socket");
+        close(mListenerSocket);
+        mListenerSocket = -1;
+        pthread_mutex_unlock(&mLock);
         return -1;
     }
 
-    mListener = new DhcpListener(mHandlers);
+    if (mServiceManager->start(svc)) {
+        LOGE("Failed to start dhcp service");
+        pthread_mutex_unlock(&mLock);
+        return -1;
+    }
+
+    mListener = new DhcpListener(mController, mListenerSocket, mHandlers);
     if (mListener->startListener()) {
         LOGE("Failed to start listener");
 #if 0
-        mServiceManager->stop("dhcpcd_ng");
+        mServiceManager->stop("dhcpcd");
         return -1;
 #endif
         delete mListener;
         mListener = NULL;
+        pthread_mutex_unlock(&mLock);
     }
 
-    mState = DhcpState::STARTED;
-
+    pthread_mutex_unlock(&mLock);
     return 0;
 }
 
 int DhcpClient::stop() {
+    pthread_mutex_lock(&mLock);
+    if (!mController) {
+        pthread_mutex_unlock(&mLock);
+        return 0;
+    }
+
     if (mListener) {
         mListener->stopListener();
         delete mListener;
         mListener = NULL;
     }
+    close(mListenerSocket);
 
-    if (mServiceManager->stop("dhcpcd_ng")) 
+    if (mServiceManager->stop("dhcpcd")) {
         LOGW("Failed to stop DHCP service (%s)", strerror(errno));
-    mState = DhcpState::STOPPED;
+        // XXX: Kill it the hard way.. but its gotta go!
+    }
+
+    mController = NULL;
+    pthread_mutex_unlock(&mLock);
     return 0;
 }
+
+void DhcpClient::setDoArpProbe(bool probe) {
+    mDoArpProbe = probe;
+}
diff --git a/nexus/DhcpClient.h b/nexus/DhcpClient.h
index e0a2784..42bfda0 100644
--- a/nexus/DhcpClient.h
+++ b/nexus/DhcpClient.h
@@ -18,23 +18,36 @@
 #ifndef _DhcpClient_H
 #define _DhcpClient_H
 
+#include <pthread.h>
+
 class IDhcpEventHandlers;
 class ServiceManager;
 class DhcpListener;
+class Controller;
 
 class DhcpClient {
+public:
+    static const int STATUS_MONITOR_PORT = 6666;
+
+private:
     int                mState;
     IDhcpEventHandlers *mHandlers;
     ServiceManager     *mServiceManager;
     DhcpListener       *mListener;
+    int                mListenerSocket;
+    pthread_mutex_t    mLock;
+    Controller         *mController;
+    bool               mDoArpProbe;
 
 public:
     DhcpClient(IDhcpEventHandlers *handlers);
     virtual ~DhcpClient();
 
     int getState() { return mState; }
+    bool getDoArpProbe() { return mDoArpProbe; }
+    void setDoArpProbe(bool probe);
 
-    int start(const char *interface);
+    int start(Controller *c);
     int stop();
 };
 
diff --git a/nexus/DhcpEvent.cpp b/nexus/DhcpEvent.cpp
new file mode 100644
index 0000000..58893f4
--- /dev/null
+++ b/nexus/DhcpEvent.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+
+#define LOG_TAG "DhcpEvent"
+#include <cutils/log.h>
+
+#include "DhcpEvent.h"
+
+char *DhcpEvent::toString(int val, char *buffer, int max) {
+    if (val == DhcpEvent::UNKNOWN)
+        strncpy(buffer, "UNKNOWN", max);
+    else if (val == DhcpEvent::STOP)
+        strncpy(buffer, "STOP", max);
+    else if (val == DhcpEvent::RENEW)
+        strncpy(buffer, "RENEW", max);
+    else if (val == DhcpEvent::RELEASE)
+        strncpy(buffer, "RELEASE", max);
+    else if (val == DhcpEvent::TIMEOUT)
+        strncpy(buffer, "TIMEOUT", max);
+    else
+        strncpy(buffer, "(internal error)", max);
+
+    return buffer;
+}
+
+int DhcpEvent::parseString(const char *buffer) {
+    if (!strcasecmp(buffer, "UNKNOWN"))
+        return DhcpEvent::UNKNOWN;
+    else if (!strcasecmp(buffer, "STOP"))
+        return DhcpEvent::STOP;
+    else if (!strcasecmp(buffer, "RENEW"))
+        return DhcpEvent::RENEW;
+    else if (!strcasecmp(buffer, "RELEASE"))
+        return DhcpEvent::RELEASE;
+    else if (!strcasecmp(buffer, "TIMEOUT"))
+        return DhcpEvent::TIMEOUT;
+    else {
+        LOGW("Bad event '%s'", buffer);
+        return -1;
+    }
+}
diff --git a/nexus/IPropertyProvider.h b/nexus/DhcpEvent.h
similarity index 63%
copy from nexus/IPropertyProvider.h
copy to nexus/DhcpEvent.h
index 17ad5f8..f77834d 100644
--- a/nexus/IPropertyProvider.h
+++ b/nexus/DhcpEvent.h
@@ -14,20 +14,20 @@
  * limitations under the License.
  */
 
-#ifndef _IPROPERTY_PROVIDER_H
-#define _IPROPERTY_PROVIDER_H
+#ifndef _DHCP_EVENT_H
+#define _DHCP_EVENT_H
 
-#include <unistd.h>
-#include <sys/types.h>
-
-#include <utils/List.h>
-
-class IPropertyProvider {
+class DhcpEvent {
 public:
-    virtual int set(const char *name, const char *value) = 0;
-    virtual const char *get(const char *name, char *buffer, size_t max) = 0;
-};
+    static const int UNKNOWN = 0;
+    static const int STOP    = 1;
+    static const int RENEW   = 2;
+    static const int RELEASE = 3;
+    static const int TIMEOUT = 4;
 
-typedef android::List<IPropertyProvider *> IPropertyProviderCollection;
+    static char *toString(int val, char *buffer, int max);
+
+    static int parseString(const char *buffer);
+};
 
 #endif
diff --git a/nexus/DhcpListener.cpp b/nexus/DhcpListener.cpp
index 2d07ee8..afa68eb 100644
--- a/nexus/DhcpListener.cpp
+++ b/nexus/DhcpListener.cpp
@@ -14,21 +14,95 @@
  * limitations under the License.
  */
 
+#include <errno.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
 #define LOG_TAG "DhcpListener"
 #include <cutils/log.h>
 
 #include <DhcpListener.h>
 #include "IDhcpEventHandlers.h"
+#include "DhcpState.h"
+#include "DhcpEvent.h"
+#include "Controller.h"
 
-DhcpListener::DhcpListener(IDhcpEventHandlers *handlers) :
-              SocketListener("dhcp_ng", false) {
+DhcpListener::DhcpListener(Controller *c, int socket, IDhcpEventHandlers *handlers) :
+              SocketListener(socket, false) {
     mHandlers = handlers;
+    mController = c;
 }
 
 DhcpListener::~DhcpListener() {
 }
 
 bool DhcpListener::onDataAvailable(SocketClient *cli) {
-    LOGD("onDataAvailable()");
+    char buffer[255];
+    int rc;
+
+    if ((rc = read(cli->getSocket(), buffer, sizeof(buffer))) < 0) {
+        LOGW("Error reading dhcp status msg (%s)", strerror(errno));
+        return true;
+    }
+
+    if (!strncmp(buffer, "STATE:", 6)) {
+        char *next = buffer;
+        char *tmp;
+        int i;
+
+        for (i = 0; i < 2; i++) {
+            if (!(tmp = strsep(&next, ":"))) {
+                LOGW("Error parsing state '%s'", buffer);
+                return true;
+            }
+        }
+
+        int st = DhcpState::parseString(tmp);
+        mHandlers->onDhcpStateChanged(mController, st);
+    } else if (!strncmp(buffer, "ADDRINFO:", 9)) {
+        char *next = buffer + 9;
+	struct in_addr ipaddr, netmask, gateway, broadcast, dns1, dns2;
+
+        if (!inet_aton(strsep(&next, ":"), &ipaddr)) {
+            LOGW("Malformatted IP specified");
+        }
+        if (!inet_aton(strsep(&next, ":"), &netmask)) {
+            LOGW("Malformatted netmask specified");
+        }
+        if (!inet_aton(strsep(&next, ":"), &broadcast)) {
+            LOGW("Malformatted broadcast specified");
+        }
+        if (!inet_aton(strsep(&next, ":"), &gateway)) {
+            LOGW("Malformatted gateway specified");
+        }
+        if (!inet_aton(strsep(&next, ":"), &dns1)) {
+            LOGW("Malformatted dns1 specified");
+        }
+        if (!inet_aton(strsep(&next, ":"), &dns2)) {
+            LOGW("Malformatted dns2 specified");
+        }
+        mHandlers->onDhcpLeaseUpdated(mController, &ipaddr, &netmask,
+                                      &broadcast, &gateway, &dns1, &dns2);
+ 
+    } else if (!strncmp(buffer, "EVENT:", 6)) {
+        char *next = buffer;
+        char *tmp;
+        int i;
+
+        for (i = 0; i < 2; i++) {
+            if (!(tmp = strsep(&next, ":"))) {
+                LOGW("Error parsing event '%s'", buffer);
+                return true;
+            }
+        }
+
+        int ev = DhcpEvent::parseString(tmp);
+        mHandlers->onDhcpEvent(mController, ev);
+  
+    } else {
+        LOGW("Unknown DHCP monitor msg '%s'", buffer);
+    }
+
     return true;
 }
diff --git a/nexus/DhcpListener.h b/nexus/DhcpListener.h
index bfc5a37..ca6fe37 100644
--- a/nexus/DhcpListener.h
+++ b/nexus/DhcpListener.h
@@ -20,13 +20,15 @@
 #include <sysutils/SocketListener.h>
 
 class IDhcpEventHandlers;
+class Controller;
 
 class DhcpListener : public SocketListener {
     IDhcpEventHandlers *mHandlers;
+    Controller         *mController;
 
 public:
 
-    DhcpListener(IDhcpEventHandlers *handlers);
+    DhcpListener(Controller *c, int socket, IDhcpEventHandlers *handlers);
     virtual ~DhcpListener();
 
 private:
diff --git a/nexus/DhcpState.cpp b/nexus/DhcpState.cpp
new file mode 100644
index 0000000..c9d5135
--- /dev/null
+++ b/nexus/DhcpState.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+
+#define LOG_TAG "DhcpState"
+#include <cutils/log.h>
+
+#include "DhcpState.h"
+
+char *DhcpState::toString(int val, char *buffer, int max) {
+    if (val == DhcpState::INIT)
+        strncpy(buffer, "INIT", max);
+    else if (val == DhcpState::DISCOVERING)
+        strncpy(buffer, "DISCOVERING", max);
+    else if (val == DhcpState::REQUESTING)
+        strncpy(buffer, "REQUESTING", max);
+    else if (val == DhcpState::BOUND)
+        strncpy(buffer, "BOUND", max);
+    else if (val == DhcpState::RENEWING)
+        strncpy(buffer, "RENEWING", max);
+    else if (val == DhcpState::REBINDING)
+        strncpy(buffer, "REBINDING", max);
+    else if (val == DhcpState::REBOOT)
+        strncpy(buffer, "REBOOT", max);
+    else if (val == DhcpState::RENEW_REQUESTED)
+        strncpy(buffer, "RENEW_REQUESTED", max);
+    else if (val == DhcpState::INIT_IPV4LL)
+        strncpy(buffer, "INIT_IPV4LL", max);
+    else if (val == DhcpState::PROBING)
+        strncpy(buffer, "PROBING", max);
+    else if (val == DhcpState::ANNOUNCING)
+        strncpy(buffer, "ANNOUNCING", max);
+    else
+        strncpy(buffer, "(internal error)", max);
+
+    return buffer;
+}
+
+int DhcpState::parseString(const char *buffer) {
+    if (!strcasecmp(buffer, "INIT"))
+        return DhcpState::INIT;
+    else if (!strcasecmp(buffer, "DISCOVERING"))
+        return DhcpState::DISCOVERING;
+    else if (!strcasecmp(buffer, "REQUESTING"))
+        return DhcpState::REQUESTING;
+    else if (!strcasecmp(buffer, "BOUND"))
+        return DhcpState::BOUND;
+    else if (!strcasecmp(buffer, "RENEWING"))
+        return DhcpState::RENEWING;
+    else if (!strcasecmp(buffer, "REBINDING"))
+        return DhcpState::REBINDING;
+    else if (!strcasecmp(buffer, "REBOOT"))
+        return DhcpState::REBOOT;
+    else if (!strcasecmp(buffer, "RENEW_REQUESTED"))
+        return DhcpState::INIT_IPV4LL;
+    else if (!strcasecmp(buffer, "INIT_IPV4LL"))
+        return DhcpState::INIT_IPV4LL;
+    else if (!strcasecmp(buffer, "PROBING"))
+        return DhcpState::PROBING;
+    else if (!strcasecmp(buffer, "ANNOUNCING"))
+        return DhcpState::ANNOUNCING;
+    else {
+        LOGW("Bad state '%s'", buffer);
+        return -1;
+    }
+}
diff --git a/nexus/DhcpState.h b/nexus/DhcpState.h
index 27d7c7e..041c5d2 100644
--- a/nexus/DhcpState.h
+++ b/nexus/DhcpState.h
@@ -14,14 +14,26 @@
  * limitations under the License.
  */
 
-#ifndef _DhcpState_H
-#define _DhcpState_H
+#ifndef _DHCP_STATE_H
+#define _DHCP_STATE_H
 
 class DhcpState {
 public:
-    static const int UNKNOWN = 0;
-    static const int STOPPED = 1;
-    static const int STARTED = 2;
+    static const int INIT            = 0;
+    static const int DISCOVERING     = 1;
+    static const int REQUESTING      = 2;
+    static const int BOUND           = 3;
+    static const int RENEWING        = 4;
+    static const int REBINDING       = 5;
+    static const int REBOOT          = 6;
+    static const int RENEW_REQUESTED = 7;
+    static const int INIT_IPV4LL     = 8;
+    static const int PROBING         = 9;
+    static const int ANNOUNCING      = 10;
+
+    static char *toString(int val, char *buffer, int max);
+
+    static int parseString(const char *buffer);
 };
 
 #endif
diff --git a/nexus/IControllerHandler.h b/nexus/IControllerHandler.h
index f7be39c..3151587 100644
--- a/nexus/IControllerHandler.h
+++ b/nexus/IControllerHandler.h
@@ -22,8 +22,11 @@
 
 class IControllerHandler {
 public:
-    virtual void onInterfaceConnected(Controller *c, const InterfaceConfig *cfg) = 0;
-    virtual void onInterfaceDisconnected(Controller *c, const char *name) = 0;
+    virtual ~IControllerHandler() {}
+    virtual void onInterfaceConnected(Controller *c) = 0;
+    virtual void onInterfaceDisconnected(Controller *c) = 0;
+    virtual void onControllerSuspending(Controller *c) = 0;
+    virtual void onControllerResumed(Controller *c) = 0;
 };
 
 #endif
diff --git a/nexus/IDhcpEventHandlers.h b/nexus/IDhcpEventHandlers.h
index 3f51f64..2568f09 100644
--- a/nexus/IDhcpEventHandlers.h
+++ b/nexus/IDhcpEventHandlers.h
@@ -20,6 +20,14 @@
 
 class IDhcpEventHandlers {
 public:
+    virtual ~IDhcpEventHandlers() {}
+    virtual void onDhcpStateChanged(Controller *c, int state) = 0;
+    virtual void onDhcpEvent(Controller *c, int event) = 0;
+    virtual void onDhcpLeaseUpdated(Controller *c,
+                                    struct in_addr *addr, struct in_addr *net,
+                                    struct in_addr *brd,
+                                    struct in_addr *gw, struct in_addr *dns1,
+                                    struct in_addr *dns2) = 0;
 };
 
 #endif
diff --git a/nexus/ISupplicantEventHandler.h b/nexus/ISupplicantEventHandler.h
index b7fd17b..1a3aa07 100644
--- a/nexus/ISupplicantEventHandler.h
+++ b/nexus/ISupplicantEventHandler.h
@@ -27,6 +27,7 @@
 
 class ISupplicantEventHandler {
 public:
+    virtual ~ISupplicantEventHandler(){}
     virtual void onAssociatingEvent(SupplicantAssociatingEvent *evt) = 0;
     virtual void onAssociatedEvent(SupplicantAssociatedEvent *evt) = 0;
     virtual void onConnectedEvent(SupplicantConnectedEvent *evt) = 0;
diff --git a/nexus/IPropertyProvider.h b/nexus/IWifiStatusPollerHandler.h
similarity index 63%
rename from nexus/IPropertyProvider.h
rename to nexus/IWifiStatusPollerHandler.h
index 17ad5f8..9b94945 100644
--- a/nexus/IPropertyProvider.h
+++ b/nexus/IWifiStatusPollerHandler.h
@@ -14,20 +14,13 @@
  * limitations under the License.
  */
 
-#ifndef _IPROPERTY_PROVIDER_H
-#define _IPROPERTY_PROVIDER_H
+#ifndef _IWIFISTATUSPOLLER_HANDLER_H
+#define _IWIFISTATUSPOLLER_HANDLER_H
 
-#include <unistd.h>
-#include <sys/types.h>
-
-#include <utils/List.h>
-
-class IPropertyProvider {
+class IWifiStatusPollerHandler {
 public:
-    virtual int set(const char *name, const char *value) = 0;
-    virtual const char *get(const char *name, char *buffer, size_t max) = 0;
+    virtual ~IWifiStatusPollerHandler() {}
+    virtual void onStatusPollInterval() = 0;
 };
 
-typedef android::List<IPropertyProvider *> IPropertyProviderCollection;
-
 #endif
diff --git a/nexus/InterfaceConfig.cpp b/nexus/InterfaceConfig.cpp
index 66861d0..832cbca 100644
--- a/nexus/InterfaceConfig.cpp
+++ b/nexus/InterfaceConfig.cpp
@@ -23,147 +23,72 @@
 #include "InterfaceConfig.h"
 #include "NetworkManager.h"
 
-const char *InterfaceConfig::PropertyNames[] = { "dhcp", "ip",
-                                                 "netmask",
-                                                 "gateway", "dns1", "dns2",
-                                                 "dns3", '\0' };
-
-InterfaceConfig::InterfaceConfig(const char *prop_prefix) {
-    mPropPrefix = strdup(prop_prefix);
-    mUseDhcp = true;
-    registerProperties();
+InterfaceConfig::InterfaceConfig(bool propertiesReadOnly) {
+    mStaticProperties.propIp = new IPV4AddressPropertyHelper("Addr", propertiesReadOnly, &mIp);
+    mStaticProperties.propNetmask = new IPV4AddressPropertyHelper("Netmask", propertiesReadOnly, &mNetmask);
+    mStaticProperties.propGateway = new IPV4AddressPropertyHelper("Gateway", propertiesReadOnly, &mGateway);
+    mStaticProperties.propBroadcast = new IPV4AddressPropertyHelper("Broadcast", propertiesReadOnly, &mBroadcast);
+    mStaticProperties.propDns = new InterfaceDnsProperty(this, propertiesReadOnly);
 }
 
 InterfaceConfig::~InterfaceConfig() {
-    unregisterProperties();
-    free(mPropPrefix);
+    delete mStaticProperties.propIp;
+    delete mStaticProperties.propNetmask;
+    delete mStaticProperties.propGateway;
+    delete mStaticProperties.propBroadcast;
+    delete mStaticProperties.propDns;
 }
 
-InterfaceConfig::InterfaceConfig(const char *prop_prefix,
-                    const char *ip, const char *nm,
-                    const char *gw, const char *dns1, const char *dns2,
-                    const char *dns3) {
-    mPropPrefix = strdup(prop_prefix);
-    mUseDhcp = false;
-
-    if (!inet_aton(ip, &mIp))
-        LOGW("Unable to parse ip (%s)", ip);
-    if (!inet_aton(nm, &mNetmask))
-        LOGW("Unable to parse netmask (%s)", nm);
-    if (!inet_aton(gw, &mGateway))
-        LOGW("Unable to parse gateway (%s)", gw);
-    if (!inet_aton(dns1, &mDns1))
-        LOGW("Unable to parse dns1 (%s)", dns1);
-    if (!inet_aton(dns2, &mDns2))
-        LOGW("Unable to parse dns2 (%s)", dns2);
-    if (!inet_aton(dns3, &mDns3))
-        LOGW("Unable to parse dns3 (%s)", dns3);
-    registerProperties();
+void InterfaceConfig::setIp(struct in_addr *addr) {
+    memcpy(&mIp, addr, sizeof(struct in_addr));
 }
 
-InterfaceConfig::InterfaceConfig(const char *prop_prefix,
-                    const struct in_addr *ip,
-                    const struct in_addr *nm, const struct in_addr *gw,
-                    const struct in_addr *dns1, const struct in_addr *dns2,
-                    const struct in_addr *dns3) {
-    mPropPrefix = strdup(prop_prefix);
-    mUseDhcp = false;
-
-    memcpy(&mIp, ip, sizeof(struct in_addr));
-    memcpy(&mNetmask, nm, sizeof(struct in_addr));
-    memcpy(&mGateway, gw, sizeof(struct in_addr));
-    memcpy(&mDns1, dns1, sizeof(struct in_addr));
-    memcpy(&mDns2, dns2, sizeof(struct in_addr));
-    memcpy(&mDns3, dns3, sizeof(struct in_addr));
-    registerProperties();
+void InterfaceConfig::setNetmask(struct in_addr *addr) {
+    memcpy(&mNetmask, addr, sizeof(struct in_addr));
 }
 
-int InterfaceConfig::registerProperties() {
-    for (const char **p = InterfaceConfig::PropertyNames; *p != '\0'; p++) {
-        char *tmp;
-        asprintf(&tmp, "%s.if.%s", mPropPrefix, *p);
+void InterfaceConfig::setGateway(struct in_addr *addr) {
+    memcpy(&mGateway, addr, sizeof(struct in_addr));
+}
 
-        if (NetworkManager::Instance()->getPropMngr()->registerProperty(tmp,
-                                                                        this)) {
-            free(tmp);
-            return -1;
-        }
-        free(tmp);
-    }
+void InterfaceConfig::setBroadcast(struct in_addr *addr) {
+    memcpy(&mBroadcast, addr, sizeof(struct in_addr));
+}
+
+void InterfaceConfig::setDns(int idx, struct in_addr *addr) {
+    memcpy(&mDns[idx], addr, sizeof(struct in_addr));
+}
+
+int InterfaceConfig::attachProperties(PropertyManager *pm, const char *nsName) {
+    pm->attachProperty(nsName, mStaticProperties.propIp);
+    pm->attachProperty(nsName, mStaticProperties.propNetmask);
+    pm->attachProperty(nsName, mStaticProperties.propGateway);
+    pm->attachProperty(nsName, mStaticProperties.propBroadcast);
+    pm->attachProperty(nsName, mStaticProperties.propDns);
     return 0;
 }
 
-int InterfaceConfig::unregisterProperties() {
-    for (const char **p = InterfaceConfig::PropertyNames; *p != '\0'; p++) {
-        char *tmp;
-        asprintf(&tmp, "%s.if.%s", mPropPrefix, *p);
-
-        if (NetworkManager::Instance()->getPropMngr()->unregisterProperty(tmp))
-            LOGW("Unable to remove property '%s' (%s)", tmp, strerror(errno));
-        free(tmp);
-    }
+int InterfaceConfig::detachProperties(PropertyManager *pm, const char *nsName) {
+    pm->detachProperty(nsName, mStaticProperties.propIp);
+    pm->detachProperty(nsName, mStaticProperties.propNetmask);
+    pm->detachProperty(nsName, mStaticProperties.propGateway);
+    pm->detachProperty(nsName, mStaticProperties.propBroadcast);
+    pm->detachProperty(nsName, mStaticProperties.propDns);
     return 0;
 }
 
-int InterfaceConfig::set(const char *name, const char *value) {
-    const char *n;
+InterfaceConfig::InterfaceDnsProperty::InterfaceDnsProperty(InterfaceConfig *c,
+                                                            bool ro) :
+                 IPV4AddressProperty("Dns", ro, 2) {
+    mCfg = c;
+}
 
-    for (n = &name[strlen(name)]; *n != '.'; n--);
-    n++;
-
-    if (!strcasecmp(n, "name")) {
-        errno = EROFS;
-        return -1;
-    } else if (!strcasecmp(n, "ip") && !inet_aton(value, &mIp))
-        goto out_inval;
-    else if (!strcasecmp(n, "dhcp"))
-        mUseDhcp = (atoi(value) == 0 ? false : true);
-    else if (!strcasecmp(n, "netmask") && !inet_aton(value, &mNetmask))
-        goto out_inval;
-    else if (!strcasecmp(n, "gateway") && !inet_aton(value, &mGateway))
-        goto out_inval;
-    else if (!strcasecmp(n, "dns1") && !inet_aton(value, &mDns1))
-        goto out_inval;
-    else if (!strcasecmp(n, "dns2") && !inet_aton(value, &mDns2))
-        goto out_inval;
-    else if (!strcasecmp(n, "dns3") && !inet_aton(value, &mDns3))
-        goto out_inval;
-    else {
-        errno = ENOENT;
-        return -1;
-    }
-
+int InterfaceConfig::InterfaceDnsProperty::set(int idx, struct in_addr *value) {
+    memcpy(&mCfg->mDns[idx], value, sizeof(struct in_addr));
     return 0;
-
-out_inval:
-    errno = EINVAL;
-    return -1;
+}
+int InterfaceConfig::InterfaceDnsProperty::get(int idx, struct in_addr *buf) {
+    memcpy(buf, &mCfg->mDns[idx], sizeof(struct in_addr));
+    return 0;
 }
 
-const char *InterfaceConfig::get(const char *name, char *buffer, size_t max) {
-    const char *n;
-
-    for (n = &name[strlen(name)]; *n != '.'; n--);
-    n++;
-
-    if (!strcasecmp(n, "ip"))
-        strncpy(buffer, inet_ntoa(mIp), max);
-    else if (!strcasecmp(n, "dhcp"))
-        snprintf(buffer, max, "%d", mUseDhcp);
-    else if (!strcasecmp(n, "netmask"))
-        strncpy(buffer, inet_ntoa(mNetmask), max);
-    else if (!strcasecmp(n, "gateway"))
-        strncpy(buffer, inet_ntoa(mGateway), max);
-    else if (!strcasecmp(n, "dns1"))
-        strncpy(buffer, inet_ntoa(mDns1), max);
-    else if (!strcasecmp(n, "dns2"))
-        strncpy(buffer, inet_ntoa(mDns2), max);
-    else if (!strcasecmp(n, "dns3"))
-        strncpy(buffer, inet_ntoa(mDns3), max);
-    else {
-        strncpy(buffer, "(internal error)", max);
-        errno = ENOENT;
-        return NULL;
-    }
-    return buffer;
-}
diff --git a/nexus/InterfaceConfig.h b/nexus/InterfaceConfig.h
index d97f20b..3fc7390 100644
--- a/nexus/InterfaceConfig.h
+++ b/nexus/InterfaceConfig.h
@@ -22,53 +22,58 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
-#include "IPropertyProvider.h"
-
+#include "Property.h"
 class PropertyManager;
 
-class InterfaceConfig : public IPropertyProvider {
-public:
-    static const char *PropertyNames[];
+class InterfaceConfig {
+    class InterfaceDnsProperty;
+    friend class InterfaceConfig::InterfaceDnsProperty;
 
-private:
-    char *mPropPrefix;
-    bool mUseDhcp;
+    struct {
+        IPV4AddressPropertyHelper *propIp;
+        IPV4AddressPropertyHelper *propNetmask;
+        IPV4AddressPropertyHelper *propGateway;
+        IPV4AddressPropertyHelper *propBroadcast;
+        InterfaceDnsProperty      *propDns;
+    } mStaticProperties;
+
     struct in_addr mIp;
     struct in_addr mNetmask;
     struct in_addr mGateway;
-    struct in_addr mDns1;
-    struct in_addr mDns2;
-    struct in_addr mDns3;
+    struct in_addr mBroadcast;
+    struct in_addr mDns[2];
 
 public:
-    InterfaceConfig(const char *prop_prefix);
-    InterfaceConfig(const char *prop_prefix,
-                    const char *ip, const char *nm,
-                    const char *gw, const char *dns1, const char *dns2,
-                    const char *dns3);
-
-    InterfaceConfig(const char *prop_prefix,
-                    const struct in_addr *ip,
-                    const struct in_addr *nm, const struct in_addr *gw,
-                    const struct in_addr *dns1, const struct in_addr *dns2,
-                    const struct in_addr *dns3);
-
+    InterfaceConfig(bool propertiesReadOnly);
     virtual ~InterfaceConfig();
     
     int set(const char *name, const char *value);
     const char *get(const char *name, char *buffer, size_t maxsize);
 
-    bool            getUseDhcp() const { return mUseDhcp; }
     const struct in_addr &getIp() const { return mIp; }
     const struct in_addr &getNetmask() const { return mNetmask; }
     const struct in_addr &getGateway() const { return mGateway; }
-    const struct in_addr &getDns1() const { return mDns1; }
-    const struct in_addr &getDns2() const { return mDns2; }
-    const struct in_addr &getDns3() const { return mDns3; }
+    const struct in_addr &getBroadcast() const { return mBroadcast; }
+    const struct in_addr &getDns(int idx) const { return mDns[idx]; }
+
+    void setIp(struct in_addr *addr);
+    void setNetmask(struct in_addr *addr);
+    void setGateway(struct in_addr *addr);
+    void setBroadcast(struct in_addr *addr);
+    void setDns(int idx, struct in_addr *addr);
+
+    int attachProperties(PropertyManager *pm, const char *nsName);
+    int detachProperties(PropertyManager *pm, const char *nsName);
 
 private:
-    int registerProperties();
-    int unregisterProperties();
+
+    class InterfaceDnsProperty : public IPV4AddressProperty {
+        InterfaceConfig *mCfg;
+    public:
+        InterfaceDnsProperty(InterfaceConfig *cfg, bool ro);
+        int set(int idx, struct in_addr *value);
+        int get(int idx, struct in_addr *buffer);
+    };
 };
 
 
diff --git a/nexus/LoopController.cpp b/nexus/LoopController.cpp
index 5cfb1fe..f8e01d7 100644
--- a/nexus/LoopController.cpp
+++ b/nexus/LoopController.cpp
@@ -21,14 +21,5 @@
 
 LoopController::LoopController(PropertyManager *propmngr,
                                IControllerHandler *handlers) :
-                Controller("LOOP", propmngr, handlers) {
+                Controller("loop", propmngr, handlers) {
 }
-
-int LoopController::set(const char *name, const char *value) {
-    return Controller::set(name, value);
-}
-
-const char *LoopController::get(const char *name, char *buffer, size_t maxsize) {
-    return Controller::get(name, buffer, maxsize);
-}
-
diff --git a/nexus/NetworkManager.cpp b/nexus/NetworkManager.cpp
index 7450b95..e0df409 100644
--- a/nexus/NetworkManager.cpp
+++ b/nexus/NetworkManager.cpp
@@ -24,6 +24,9 @@
 #include "NetworkManager.h"
 #include "InterfaceConfig.h"
 #include "DhcpClient.h"
+#include "DhcpState.h"
+#include "DhcpEvent.h"
+#include "ResponseCode.h"
 
 NetworkManager *NetworkManager::sInstance = NULL;
 
@@ -35,8 +38,9 @@
 
 NetworkManager::NetworkManager(PropertyManager *propMngr) {
     mBroadcaster = NULL;
-    mControllers = new ControllerCollection();
+    mControllerBindings = new ControllerBindingCollection();
     mPropMngr = propMngr;
+    mLastDhcpState = DhcpState::INIT;
     mDhcp = new DhcpClient(this);
 }
 
@@ -51,17 +55,17 @@
 }
 
 int NetworkManager::attachController(Controller *c) {
-    mControllers->push_back(c);
+    ControllerBinding *cb = new ControllerBinding(c);
+    mControllerBindings->push_back(cb);
     return 0;
 }
 
 int NetworkManager::startControllers() {
     int rc = 0;
-    ControllerCollection::iterator i;
+    ControllerBindingCollection::iterator it;
 
-    for (i = mControllers->begin(); i != mControllers->end(); ++i) {
-        int irc = (*i)->start();
-        LOGD("Controller '%s' start rc = %d", (*i)->getName(), irc);
+    for (it = mControllerBindings->begin(); it != mControllerBindings->end(); ++it) {
+        int irc = (*it)->getController()->start();
         if (irc && !rc)
             rc = irc;
     }
@@ -70,52 +74,132 @@
 
 int NetworkManager::stopControllers() {
     int rc = 0;
-    ControllerCollection::iterator i;
+    ControllerBindingCollection::iterator it;
 
-    for (i = mControllers->begin(); i != mControllers->end(); ++i) {
-        int irc = (*i)->stop();
-        LOGD("Controller '%s' stop rc = %d", (*i)->getName(), irc);
+    for (it = mControllerBindings->begin(); it != mControllerBindings->end(); ++it) {
+        int irc = (*it)->getController()->stop();
         if (irc && !rc)
             rc = irc;
     }
     return rc;
 }
 
-Controller *NetworkManager::findController(const char *name) {
-    ControllerCollection::iterator i;
-    for (i = mControllers->begin(); i != mControllers->end(); ++i) {
-        if (!strcmp((*i)->getName(), name))
-            return *i;
+NetworkManager::ControllerBinding *NetworkManager::lookupBinding(Controller *c) {
+    ControllerBindingCollection::iterator it;
+
+    for (it = mControllerBindings->begin(); it != mControllerBindings->end(); ++it) {
+        if ((*it)->getController() == c)
+            return (*it);
     }
-    LOGW("Controller '%s' not found", name);
+    errno = ENOENT;
     return NULL;
 }
 
-void NetworkManager::onInterfaceConnected(Controller *c, const InterfaceConfig *cfg) {
+Controller *NetworkManager::findController(const char *name) {
+    ControllerBindingCollection::iterator it;
+
+    for (it = mControllerBindings->begin(); it != mControllerBindings->end(); ++it) {
+        if (!strcasecmp((*it)->getController()->getName(), name))
+            return (*it)->getController();
+    }
+    errno = ENOENT;
+    return NULL;
+}
+
+void NetworkManager::onInterfaceConnected(Controller *c) {
     LOGD("Controller %s interface %s connected", c->getName(), c->getBoundInterface());
 
-    // Look up the interface
-
-    if (0) { // already started?
-    }
-
-    if (cfg) {
-        if (cfg->getUseDhcp() && mDhcp->start(c->getBoundInterface())) {
-            LOGE("DHCP start failed");
-        } else if (!cfg->getUseDhcp()) {
-            // Static configuration
-        }
-    } else {
-        LOGD("No InterfaceConfig for %s:%s - assuming self-managed",
-            c->getName(), c->getBoundInterface());
+    if (mDhcp->start(c)) {
+        LOGE("Failed to start DHCP (%s)", strerror(errno));
+        return;
     }
 }
 
-void NetworkManager::onInterfaceDisconnected(Controller *c, const char *name) {
-    LOGD("Controller %s interface %s disconnected", c->getName(), name);
+void NetworkManager::onInterfaceDisconnected(Controller *c) {
+    LOGD("Controller %s interface %s disconnected", c->getName(),
+         c->getBoundInterface());
 
-    // If we have a DHCP request out on this interface then stop it
-    if (1) {
-        mDhcp->stop();
-    }
+    mDhcp->stop();
 }
+
+void NetworkManager::onControllerSuspending(Controller *c) {
+    LOGD("Controller %s interface %s suspending", c->getName(),
+         c->getBoundInterface());
+    mDhcp->stop();
+}
+
+void NetworkManager::onControllerResumed(Controller *c) {
+    LOGD("Controller %s interface %s resumed", c->getName(),
+         c->getBoundInterface());
+}
+
+void NetworkManager::onDhcpStateChanged(Controller *c, int state) {
+    char tmp[255];
+    char tmp2[255];
+
+    LOGD("onDhcpStateChanged(%s -> %s)",
+         DhcpState::toString(mLastDhcpState, tmp, sizeof(tmp)),
+         DhcpState::toString(state, tmp2, sizeof(tmp2)));
+
+    switch(state) {
+        case DhcpState::BOUND:
+            // Refresh the 'net.xxx' for the controller
+            break;
+        case DhcpState::RENEWING:
+            break;
+        default:
+            break;
+    }
+
+    char *tmp3;
+    asprintf(&tmp3,
+             "DHCP state changed from %d (%s) -> %d (%s)", 
+             mLastDhcpState,
+             DhcpState::toString(mLastDhcpState, tmp, sizeof(tmp)),
+             state,
+             DhcpState::toString(state, tmp2, sizeof(tmp2)));
+
+    getBroadcaster()->sendBroadcast(ResponseCode::DhcpStateChange,
+                                    tmp3,
+                                    false);
+    free(tmp3);
+                          
+    mLastDhcpState = state;
+}
+
+void NetworkManager::onDhcpEvent(Controller *c, int evt) {
+    char tmp[64];
+    LOGD("onDhcpEvent(%s)", DhcpEvent::toString(evt, tmp, sizeof(tmp)));
+}
+
+void NetworkManager::onDhcpLeaseUpdated(Controller *c, struct in_addr *addr,
+                                        struct in_addr *net,
+                                        struct in_addr *brd,
+                                        struct in_addr *gw,
+                                        struct in_addr *dns1,
+                                        struct in_addr *dns2) {
+    ControllerBinding *bind = lookupBinding(c);
+
+    if (!bind->getCurrentCfg())
+        bind->setCurrentCfg(new InterfaceConfig(true));
+
+    bind->getCurrentCfg()->setIp(addr);
+    bind->getCurrentCfg()->setNetmask(net);
+    bind->getCurrentCfg()->setGateway(gw);
+    bind->getCurrentCfg()->setBroadcast(brd);
+    bind->getCurrentCfg()->setDns(0, dns1);
+    bind->getCurrentCfg()->setDns(1, dns2);
+}
+
+NetworkManager::ControllerBinding::ControllerBinding(Controller *c) :
+                mController(c) {
+}
+
+void NetworkManager::ControllerBinding::setCurrentCfg(InterfaceConfig *c) {
+    mCurrentCfg = c;
+}
+
+void NetworkManager::ControllerBinding::setBoundCfg(InterfaceConfig *c) {
+    mBoundCfg = c;
+}
+
diff --git a/nexus/NetworkManager.h b/nexus/NetworkManager.h
index 44f3417..93702ce 100644
--- a/nexus/NetworkManager.h
+++ b/nexus/NetworkManager.h
@@ -17,6 +17,7 @@
 #ifndef _NETWORKMANAGER_H
 #define _NETWORKMANAGER_H
 
+#include <utils/List.h>
 #include <sysutils/SocketListener.h>
 
 #include "Controller.h"
@@ -28,14 +29,33 @@
 class DhcpClient;
 
 class NetworkManager : public IControllerHandler, public IDhcpEventHandlers {
-private:
     static NetworkManager *sInstance;
 
+    class ControllerBinding {
+        Controller      *mController;
+        InterfaceConfig *mCurrentCfg;
+        InterfaceConfig *mBoundCfg;
+
+    public:
+        ControllerBinding(Controller *c);
+        virtual ~ControllerBinding() {}
+
+        InterfaceConfig *getCurrentCfg() { return mCurrentCfg; }
+        InterfaceConfig *getBoundCfg() { return mCurrentCfg; }
+        Controller *getController() { return mController; }
+
+        void setCurrentCfg(InterfaceConfig *cfg);
+        void setBoundCfg(InterfaceConfig *cfg);
+    };
+
+    typedef android::List<ControllerBinding *> ControllerBindingCollection;
+
 private:
-    ControllerCollection *mControllers;
-    SocketListener       *mBroadcaster;
-    PropertyManager      *mPropMngr;
-    DhcpClient           *mDhcp;
+    ControllerBindingCollection *mControllerBindings;
+    SocketListener              *mBroadcaster;
+    PropertyManager             *mPropMngr;
+    DhcpClient                  *mDhcp;
+    int                         mLastDhcpState;
 
 public:
     virtual ~NetworkManager();
@@ -57,8 +77,19 @@
     int stopControllers();
 
     NetworkManager(PropertyManager *propMngr);
+    ControllerBinding *lookupBinding(Controller *c);
 
-    void onInterfaceConnected(Controller *c, const InterfaceConfig *cfg);
-    void onInterfaceDisconnected(Controller *c, const char *name);
+    void onInterfaceConnected(Controller *c);
+    void onInterfaceDisconnected(Controller *c);
+    void onControllerSuspending(Controller *c);
+    void onControllerResumed(Controller *c);
+
+    void onDhcpStateChanged(Controller *c, int state);
+    void onDhcpEvent(Controller *c, int event);
+    void onDhcpLeaseUpdated(Controller *c,
+                            struct in_addr *addr, struct in_addr *net,
+                            struct in_addr *brd,
+                            struct in_addr *gw, struct in_addr *dns1,
+                            struct in_addr *dns2);
 };
 #endif
diff --git a/nexus/Property.cpp b/nexus/Property.cpp
new file mode 100644
index 0000000..d02769d
--- /dev/null
+++ b/nexus/Property.cpp
@@ -0,0 +1,203 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <errno.h>
+#include <strings.h>
+#include <netinet/in.h>
+
+#define LOG_TAG "Property"
+
+#include <cutils/log.h>
+
+#include "Property.h"
+
+Property::Property(const char *name, bool readOnly,
+                   int type, int numElements) :
+          mName(name), mReadOnly(readOnly), mType(type),
+          mNumElements(numElements) {
+    if (index(name, '.')) {
+        LOGW("Property name %s violates namespace rules", name);
+    }
+}
+
+StringProperty::StringProperty(const char *name, bool ro, int elements) :
+                Property(name, ro, Property::Type_STRING, elements) {
+}
+int StringProperty::set(int idx, int value) {
+    LOGE("Integer 'set' called on string property!");
+    errno = EINVAL;
+    return -1;
+}
+int StringProperty::set(int idx, struct in_addr *value) {
+    LOGE("IpAddr 'set' called on string property!");
+    errno = EINVAL;
+    return -1;
+}
+int StringProperty::get(int idx, int *buffer) {
+    LOGE("Integer 'get' called on string property!");
+    errno = EINVAL;
+    return -1;
+}
+int StringProperty::get(int idx, struct in_addr *buffer) {
+    LOGE("IpAddr 'get' called on string property!");
+    errno = EINVAL;
+    return -1;
+}
+
+StringPropertyHelper::StringPropertyHelper(const char *name, bool ro,
+                                           char *buffer, size_t max) :
+                      StringProperty(name, ro, 1) {
+    mBuffer = buffer;
+    mMax = max;
+}
+
+int StringPropertyHelper::set(int idx, const char *value) {
+    if (idx != 0) {
+        LOGW("Attempt to use array index on StringPropertyHelper::set");
+        errno = EINVAL;
+        return -1;
+    }
+    strncpy(mBuffer, value, mMax);
+    return 0;
+}
+
+int StringPropertyHelper::get(int idx, char *buffer, size_t max) {
+    if (idx != 0) {
+        LOGW("Attempt to use array index on StringPropertyHelper::get");
+        errno = EINVAL;
+        return -1;
+    }
+    strncpy(buffer, mBuffer, max);
+    return 0;
+}
+ 
+IntegerProperty::IntegerProperty(const char *name, bool ro, int elements) :
+                Property(name, ro, Property::Type_INTEGER, elements) {
+}
+
+int IntegerProperty::set(int idx, const char *value) {
+    LOGE("String 'set' called on integer property!");
+    errno = EINVAL;
+    return -1;
+}
+int IntegerProperty::set(int idx, struct in_addr *value) {
+    LOGE("IpAddr 'set' called on integer property!");
+    errno = EINVAL;
+    return -1;
+}
+int IntegerProperty::get(int idx, char *buffer, size_t max) {
+    LOGE("String 'get' called on integer property!");
+    errno = EINVAL;
+    return -1;
+}
+int IntegerProperty::get(int idx, struct in_addr *buffer) {
+    LOGE("IpAddr 'get' called on integer property!");
+    errno = EINVAL;
+    return -1;
+}
+
+IntegerPropertyHelper::IntegerPropertyHelper(const char *name, bool ro,
+                                             int *buffer) :
+                       IntegerProperty(name, ro, 1) {
+    mBuffer = buffer;
+}
+
+int IntegerPropertyHelper::set(int idx, int value) {
+    if (idx != 0) {
+        LOGW("Attempt to use array index on IntegerPropertyHelper::set");
+        errno = EINVAL;
+        return -1;
+    }
+    *mBuffer = value;
+    return 0;
+}
+
+int IntegerPropertyHelper::get(int idx, int *buffer) {
+    if (idx != 0) {
+        LOGW("Attempt to use array index on IntegerPropertyHelper::get");
+        errno = EINVAL;
+        return -1;
+    }
+    *buffer = *mBuffer;
+    return 0;
+}
+
+IPV4AddressProperty::IPV4AddressProperty(const char *name, bool ro, int elements) :
+                Property(name, ro, Property::Type_IPV4, elements) {
+}
+
+int IPV4AddressProperty::set(int idx, const char *value) {
+    LOGE("String 'set' called on ipv4 property!");
+    errno = EINVAL;
+    return -1;
+}
+int IPV4AddressProperty::set(int idx, int value) {
+    LOGE("Integer 'set' called on ipv4 property!");
+    errno = EINVAL;
+    return -1;
+}
+int IPV4AddressProperty::get(int idx, char *buffer, size_t max) {
+    LOGE("String 'get' called on ipv4 property!");
+    errno = EINVAL;
+    return -1;
+}
+int IPV4AddressProperty::get(int idx, int *buffer) {
+    LOGE("Integer 'get' called on ipv4 property!");
+    errno = EINVAL;
+    return -1;
+}
+
+IPV4AddressPropertyHelper::IPV4AddressPropertyHelper(const char *name, bool ro,
+                                                     struct in_addr *buffer) :
+                       IPV4AddressProperty(name, ro, 1) {
+    mBuffer = buffer;
+}
+
+int IPV4AddressPropertyHelper::set(int idx, struct in_addr *value) {
+    if (idx != 0) {
+        LOGW("Attempt to use array index on IPV4AddressPropertyHelper::set");
+        errno = EINVAL;
+        return -1;
+    }
+    memcpy(mBuffer, value, sizeof(struct in_addr));
+    return 0;
+}
+
+int IPV4AddressPropertyHelper::get(int idx, struct in_addr *buffer) {
+    if (idx != 0) {
+        LOGW("Attempt to use array index on IPV4AddressPropertyHelper::get");
+        errno = EINVAL;
+        return -1;
+    }
+    memcpy(buffer, mBuffer, sizeof(struct in_addr));
+    return 0;
+}
+
+PropertyNamespace::PropertyNamespace(const char *name) {
+    mName = strdup(name);
+    mProperties = new PropertyCollection();
+}
+
+PropertyNamespace::~PropertyNamespace() {
+    PropertyCollection::iterator it;
+    for (it = mProperties->begin(); it != mProperties->end();) {
+        delete (*it);
+        it = mProperties->erase(it);
+    }
+    delete mProperties;
+    free(mName);
+}
diff --git a/nexus/Property.h b/nexus/Property.h
index 198f722..ceea2d3 100644
--- a/nexus/Property.h
+++ b/nexus/Property.h
@@ -14,8 +14,124 @@
  * limitations under the License.
  */
 
+#ifndef _PROPERTY_H
+#define _PROPERTY_H
+
+#include <netinet/in.h>
+#include <utils/List.h>
+
 class Property {
+    const char *mName;
+    bool       mReadOnly;
+    int        mType;
+    int        mNumElements;
+
 public:
-    static const int NameMaxSize = 128;
+    static const int NameMaxSize   = 128;
     static const int ValueMaxSize  = 255;
+
+    static const int Type_STRING  = 1;
+    static const int Type_INTEGER = 2;
+    static const int Type_IPV4    = 3;
+
+    Property(const char *name, bool ro, int type, int elements);
+    virtual ~Property() {}
+
+    virtual int set(int idx, const char *value) = 0;
+    virtual int set(int idx, int value) = 0;
+    virtual int set(int idx, struct in_addr *value) = 0;
+
+    virtual int get(int idx, char *buffer, size_t max) = 0;
+    virtual int get(int idx, int *buffer) = 0;
+    virtual int get(int idx, struct in_addr *buffer) = 0;
+
+    int getType() { return mType; }
+    bool getReadOnly() { return mReadOnly; }
+    int getNumElements() { return mNumElements; }
+    const char *getName() { return mName; }
 };
+
+class StringProperty : public Property {
+public:
+    StringProperty(const char *name, bool ro, int elements);
+    virtual ~StringProperty() {}
+ 
+    virtual int set(int idx, const char *value) = 0;
+    int set(int idx, int value);
+    int set(int idx, struct in_addr *value);
+
+    virtual int get(int idx, char *buffer, size_t max) = 0;
+    int get(int idx, int *buffer);
+    int get(int idx, struct in_addr *buffer);
+};
+
+class StringPropertyHelper : public StringProperty {
+    char *mBuffer;
+    size_t mMax;
+public:
+    StringPropertyHelper(const char *name, bool ro,
+                         char *buffer, size_t max);
+    int set(int idx, const char *value);
+    int get(int idx, char *buffer, size_t max);
+};
+
+class IntegerProperty : public Property {
+public:
+    IntegerProperty(const char *name, bool ro, int elements);
+    virtual ~IntegerProperty() {}
+ 
+    int set(int idx, const char *value);
+    virtual int set(int idx, int value) = 0;
+    int set(int idx, struct in_addr *value);
+
+    int get(int idx, char *buffer, size_t max);
+    virtual int get(int idx, int *buffer) = 0;
+    int get(int idx, struct in_addr *buffer);
+};
+
+class IntegerPropertyHelper : public IntegerProperty {
+    int *mBuffer;
+public:
+    IntegerPropertyHelper(const char *name, bool ro, int *buffer);
+    int set(int idx, int value);
+    int get(int idx, int *buffer);
+};
+
+class IPV4AddressProperty : public Property {
+public:
+    IPV4AddressProperty(const char *name, bool ro, int elements);
+    virtual ~IPV4AddressProperty() {}
+ 
+    int set(int idx, const char *value);
+    int set(int idx, int value);
+    virtual int set(int idx, struct in_addr *value) = 0;
+
+    int get(int idx, char *buffer, size_t max);
+    int get(int idx, int *buffer);
+    virtual int get(int idx, struct in_addr *buffer) = 0;
+};
+
+class IPV4AddressPropertyHelper : public IPV4AddressProperty {
+    struct in_addr *mBuffer;
+public:
+    IPV4AddressPropertyHelper(const char *name, bool ro, struct in_addr *buf);
+    int set(int idx, struct in_addr *value);
+    int get(int idx, struct in_addr *buffer);
+};
+
+typedef android::List<Property *> PropertyCollection;
+
+class PropertyNamespace {
+    char         *mName;
+    PropertyCollection *mProperties;
+
+public:
+    PropertyNamespace(const char *name);
+    virtual ~PropertyNamespace();
+
+    const char *getName() { return mName; }
+    PropertyCollection *getProperties() { return mProperties; }
+};
+
+typedef android::List<PropertyNamespace *> PropertyNamespaceCollection;
+#endif
diff --git a/nexus/PropertyManager.cpp b/nexus/PropertyManager.cpp
index 6faf9b8..704b223 100644
--- a/nexus/PropertyManager.cpp
+++ b/nexus/PropertyManager.cpp
@@ -14,6 +14,11 @@
  * limitations under the License.
  */
 
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
 #define LOG_TAG "PropertyManager"
 
 #include <cutils/log.h>
@@ -21,103 +26,255 @@
 #include "PropertyManager.h"
 
 PropertyManager::PropertyManager() {
-    mPropertyPairs = new PropertyPairCollection();
+    mNamespaces = new PropertyNamespaceCollection();
     pthread_mutex_init(&mLock, NULL);
 }
 
 PropertyManager::~PropertyManager() {
-    delete mPropertyPairs;
+    PropertyNamespaceCollection::iterator it;
+
+    for (it = mNamespaces->begin(); it != mNamespaces->end();) {
+        delete (*it);
+        it = mNamespaces->erase(it);
+    }
+    delete mNamespaces;
 }
 
-int PropertyManager::registerProperty(const char *name, IPropertyProvider *pp) {
-    PropertyPairCollection::iterator it;
+PropertyNamespace *PropertyManager::lookupNamespace_UNLOCKED(const char *ns) {
+    PropertyNamespaceCollection::iterator ns_it;
 
-//    LOGD("registerProperty(%s)", name);
-    pthread_mutex_lock(&mLock);
-    for (it = mPropertyPairs->begin(); it != mPropertyPairs->end(); ++it) {
-        if (!strcmp(name, (*it)->getName())) {
-            errno = EADDRINUSE;
-            LOGE("Failed to register property %s (%s)",
-                 name, strerror(errno));
-            pthread_mutex_unlock(&mLock);
-            return -1;
-        }
+    for (ns_it = mNamespaces->begin(); ns_it != mNamespaces->end(); ++ns_it) {
+        if (!strcasecmp(ns, (*ns_it)->getName()))
+            return (*ns_it);
     }
-    mPropertyPairs->push_back(new PropertyPair(name, pp));
+    errno = ENOENT;
+    return NULL;
+}
+
+Property *PropertyManager::lookupProperty_UNLOCKED(PropertyNamespace *ns, const char *name) {
+    PropertyCollection::iterator it;
+
+    for (it = ns->getProperties()->begin();
+         it != ns->getProperties()->end(); ++it) {
+        if (!strcasecmp(name, (*it)->getName()))
+            return (*it);
+    }
+    errno = ENOENT;
+    return NULL;
+}
+
+int PropertyManager::attachProperty(const char *ns_name, Property *p) {
+    PropertyNamespace *ns;
+
+    LOGD("Attaching property %s to namespace %s", p->getName(), ns_name);
+    pthread_mutex_lock(&mLock);
+    if (!(ns = lookupNamespace_UNLOCKED(ns_name))) {
+        LOGD("Creating namespace %s", ns_name);
+        ns = new PropertyNamespace(ns_name);
+        mNamespaces->push_back(ns);
+    }
+
+    if (lookupProperty_UNLOCKED(ns, p->getName())) {
+        errno = EADDRINUSE;
+        pthread_mutex_unlock(&mLock);
+        LOGE("Failed to register property %s.%s (%s)",
+            ns_name, p->getName(), strerror(errno));
+        return -1;
+    }
+
+    ns->getProperties()->push_back(p);
     pthread_mutex_unlock(&mLock);
     return 0;
 }
 
-int PropertyManager::unregisterProperty(const char *name) {
-    PropertyPairCollection::iterator it;
+int PropertyManager::detachProperty(const char *ns_name, Property *p) {
+    PropertyNamespace *ns;
 
-//    LOGD("unregisterProperty(%s)", name);
+    LOGD("Detaching property %s from namespace %s", p->getName(), ns_name);
     pthread_mutex_lock(&mLock);
-    for (it = mPropertyPairs->begin(); it != mPropertyPairs->end(); ++it) {
-        if (!strcmp(name, (*it)->getName())) {
+    if (!(ns = lookupNamespace_UNLOCKED(ns_name))) {
+        pthread_mutex_unlock(&mLock);
+        LOGE("Namespace '%s' not found", ns_name);
+        return -1;
+    }
+
+    PropertyCollection::iterator it;
+
+    for (it = ns->getProperties()->begin();
+         it != ns->getProperties()->end(); ++it) {
+        if (!strcasecmp(p->getName(), (*it)->getName())) {
             delete ((*it));
-            mPropertyPairs->erase(it);
+            ns->getProperties()->erase(it);
             pthread_mutex_unlock(&mLock);
             return 0;
         }
     }
+
+    LOGE("Property %s.%s not found", ns_name, p->getName());
     pthread_mutex_unlock(&mLock);
     errno = ENOENT;
     return -1;
 }
 
+int PropertyManager::doSet(Property *p, int idx, const char *value) {
+
+    if (p->getReadOnly()) {
+        errno = EROFS;
+        return -1;
+    }
+
+    if (p->getType() == Property::Type_STRING) {
+        return p->set(idx, value);
+    } else if (p->getType() == Property::Type_INTEGER) {
+        int tmp;
+        errno = 0;
+        tmp = strtol(value, (char **) NULL, 10);
+        if (errno) {
+            LOGE("Failed to convert '%s' to int", value);
+            errno = EINVAL;
+            return -1;
+        }
+        return p->set(idx, tmp);
+    } else if (p->getType() == Property::Type_IPV4) {
+        struct in_addr tmp;
+        if (!inet_aton(value, &tmp)) {
+            LOGE("Failed to convert '%s' to ipv4", value);
+            errno = EINVAL;
+            return -1;
+        }
+        return p->set(idx, &tmp);
+    } else {
+        LOGE("Property '%s' has an unknown type (%d)", p->getName(),
+             p->getType());
+        errno = EINVAL;
+        return -1;
+    }
+    errno = ENOENT;
+    return -1;
+}
+
+int PropertyManager::doGet(Property *p, int idx, char *buffer, size_t max) {
+
+    if (p->getType() == Property::Type_STRING) {
+        if (p->get(idx, buffer, max)) {
+            LOGW("String property %s get failed (%s)", p->getName(),
+                 strerror(errno));
+            return -1;
+        }
+    }
+    else if (p->getType() == Property::Type_INTEGER) {
+        int tmp;
+        if (p->get(idx, &tmp)) {
+            LOGW("Integer property %s get failed (%s)", p->getName(),
+                 strerror(errno));
+            return -1;
+        }
+        snprintf(buffer, max, "%d", tmp);
+    } else if (p->getType() == Property::Type_IPV4) {
+        struct in_addr tmp;
+        if (p->get(idx, &tmp)) {
+            LOGW("IPV4 property %s get failed (%s)", p->getName(),
+                 strerror(errno));
+            return -1;
+        }
+        strncpy(buffer, inet_ntoa(tmp), max);
+    } else {
+        LOGE("Property '%s' has an unknown type (%d)", p->getName(),
+             p->getType());
+        errno = EINVAL;
+        return -1;
+    }
+    return 0;
+}
+
 /*
  * IPropertyManager methods
  */
 
 int PropertyManager::set(const char *name, const char *value) {
-    PropertyPairCollection::iterator it;
 
+    LOGD("set %s = '%s'", name, value);
     pthread_mutex_lock(&mLock);
-    for (it = mPropertyPairs->begin(); it != mPropertyPairs->end(); ++it) {
-        if (!strcmp(name, (*it)->getName())) {
-            pthread_mutex_unlock(&mLock);
-            return (*it)->getProvider()->set(name, value);
+    PropertyNamespaceCollection::iterator ns_it;
+    for (ns_it = mNamespaces->begin(); ns_it != mNamespaces->end(); ++ns_it) {
+        PropertyCollection::iterator p_it;
+        for (p_it = (*ns_it)->getProperties()->begin();
+             p_it != (*ns_it)->getProperties()->end(); ++p_it) {
+            for (int i = 0; i < (*p_it)->getNumElements(); i++) {
+                char fqn[255];
+                char tmp[8];
+                sprintf(tmp, "_%d", i);
+                snprintf(fqn, sizeof(fqn), "%s.%s%s",
+                         (*ns_it)->getName(), (*p_it)->getName(),
+                         ((*p_it)->getNumElements() > 1 ? tmp : ""));
+                if (!strcasecmp(name, fqn)) {
+                    pthread_mutex_unlock(&mLock);
+                    return doSet((*p_it), i, value);
+                }
+            }
         }
     }
+
+    LOGE("Property %s not found", name);
     pthread_mutex_unlock(&mLock);
     errno = ENOENT;
     return -1;
 }
 
 const char *PropertyManager::get(const char *name, char *buffer, size_t max) {
-    PropertyPairCollection::iterator it;
-
-    memset(buffer, 0, max);
     pthread_mutex_lock(&mLock);
-    for (it = mPropertyPairs->begin(); it != mPropertyPairs->end(); ++it) {
-        if (!strcmp(name, (*it)->getName())) {
-            pthread_mutex_unlock(&mLock);
-            return (*it)->getProvider()->get(name, buffer, max);
+    PropertyNamespaceCollection::iterator ns_it;
+    for (ns_it = mNamespaces->begin(); ns_it != mNamespaces->end(); ++ns_it) {
+        PropertyCollection::iterator p_it;
+        for (p_it = (*ns_it)->getProperties()->begin();
+             p_it != (*ns_it)->getProperties()->end(); ++p_it) {
+
+            for (int i = 0; i < (*p_it)->getNumElements(); i++) {
+                char fqn[255];
+                char tmp[8];
+                sprintf(tmp, "_%d", i);
+                snprintf(fqn, sizeof(fqn), "%s.%s%s",
+                         (*ns_it)->getName(), (*p_it)->getName(),
+                         ((*p_it)->getNumElements() > 1 ? tmp : ""));
+                if (!strcasecmp(name, fqn)) {
+                    pthread_mutex_unlock(&mLock);
+                    if (doGet((*p_it), i, buffer, max))
+                        return NULL;
+                    return buffer;
+                }
             }
+        }
     }
+
+    LOGE("Property %s not found", name);
     pthread_mutex_unlock(&mLock);
     errno = ENOENT;
     return NULL;
 }
 
-android::List<char *> *PropertyManager::createPropertyList() {
+android::List<char *> *PropertyManager::createPropertyList(const char *prefix) {
     android::List<char *> *c = new android::List<char *>();
 
-    PropertyPairCollection::iterator it;
-
     pthread_mutex_lock(&mLock);
-    for (it = mPropertyPairs->begin(); it != mPropertyPairs->end(); ++it)
-         c->push_back(strdup((*it)->getName()));
+    PropertyNamespaceCollection::iterator ns_it;
+    for (ns_it = mNamespaces->begin(); ns_it != mNamespaces->end(); ++ns_it) {
+        PropertyCollection::iterator p_it;
+        for (p_it = (*ns_it)->getProperties()->begin();
+             p_it != (*ns_it)->getProperties()->end(); ++p_it) {
+            for (int i = 0; i < (*p_it)->getNumElements(); i++) {
+                char fqn[255];
+                char tmp[8];
+                sprintf(tmp, "_%d", i);
+                snprintf(fqn, sizeof(fqn), "%s.%s%s",
+                         (*ns_it)->getName(), (*p_it)->getName(),
+                         ((*p_it)->getNumElements() > 1 ? tmp : ""));
+                if (!prefix ||
+                    (prefix && !strncasecmp(fqn, prefix, strlen(prefix)))) {
+                    c->push_back(strdup(fqn));
+                }
+            }
+        }
+    }
     pthread_mutex_unlock(&mLock);
     return c;
 }
-
-PropertyPair::PropertyPair(const char *name, IPropertyProvider *pp) {
-    mName = strdup(name);
-    mPp = pp;
-}
-
-PropertyPair::~PropertyPair() {
-    free(mName);
-}
diff --git a/nexus/PropertyManager.h b/nexus/PropertyManager.h
index 10d0b2a..af56a9c 100644
--- a/nexus/PropertyManager.h
+++ b/nexus/PropertyManager.h
@@ -22,36 +22,28 @@
 
 #include <utils/List.h>
 
-#include "IPropertyProvider.h"
-
-class PropertyPair {
-private:
-    char *mName;
-    IPropertyProvider *mPp;
- 
-public:
-    PropertyPair(const char *name, IPropertyProvider *pp);
-    virtual ~PropertyPair();
-
-    const char *getName() { return mName; }
-    IPropertyProvider *getProvider() { return mPp; }
-};
-
-typedef android::List<PropertyPair *> PropertyPairCollection;
+#include "Property.h"
 
 class PropertyManager {
-    PropertyPairCollection *mPropertyPairs;
-    pthread_mutex_t         mLock;
+    PropertyNamespaceCollection *mNamespaces;
+    pthread_mutex_t    mLock;
 
 public:
     PropertyManager();
-    virtual ~PropertyManager();   
-    int registerProperty(const char *name, IPropertyProvider *pp);
-    int unregisterProperty(const char *name);
-    android::List<char *> *createPropertyList();
+    virtual ~PropertyManager();
+    int attachProperty(const char *ns, Property *p);
+    int detachProperty(const char *ns, Property *p);
+
+    android::List<char *> *createPropertyList(const char *prefix);
 
     int set(const char *name, const char *value);
     const char *get(const char *name, char *buffer, size_t max);
+
+private:
+    PropertyNamespace *lookupNamespace_UNLOCKED(const char *ns);
+    Property *lookupProperty_UNLOCKED(PropertyNamespace *ns, const char *name);
+    int doSet(Property *p, int idx, const char *value);
+    int doGet(Property *p, int idx, char *buffer, size_t max);
 };
 
 #endif
diff --git a/nexus/ErrorCode.h b/nexus/ResponseCode.h
similarity index 84%
rename from nexus/ErrorCode.h
rename to nexus/ResponseCode.h
index 414dd2c..4b6cac8 100644
--- a/nexus/ErrorCode.h
+++ b/nexus/ResponseCode.h
@@ -14,10 +14,10 @@
  * limitations under the License.
  */
 
-#ifndef _ERRORCODE_H
-#define _ERRORCODE_H
+#ifndef _RESPONSECODE_H
+#define _RESPONSECODE_H
 
-class ErrorCode {
+class ResponseCode {
 public:
     // 100 series - Requestion action was initiated; expect another reply
     // before proceeding with a new command.
@@ -44,5 +44,10 @@
 
     // 600 series - Unsolicited broadcasts
     static const int UnsolicitedInformational = 600;
+    static const int DhcpStateChange = 605;
+    static const int SupplicantStateChange = 610;
+    static const int ScanResultsReady = 615;
+    static const int LinkSpeedChange = 620;
+    static const int RssiChange = 625;
 };
 #endif
diff --git a/nexus/Supplicant.cpp b/nexus/Supplicant.cpp
index 9bb6bf2..6aa36e8 100644
--- a/nexus/Supplicant.cpp
+++ b/nexus/Supplicant.cpp
@@ -30,7 +30,6 @@
 #include "Supplicant.h"
 #include "SupplicantListener.h"
 #include "NetworkManager.h"
-#include "ErrorCode.h"
 #include "WifiController.h"
 #include "SupplicantStatus.h"
 
@@ -114,6 +113,29 @@
     return mServiceManager->isRunning(SUPPLICANT_SERVICE_NAME);
 }
 
+int Supplicant::sendCommand(const char *cmd, char *reply, size_t *reply_len) {
+
+    if (!mCtrl) {
+        errno = ENOTCONN;
+        return -1;
+    }
+
+//    LOGD("sendCommand(): -> '%s'", cmd);
+
+    int rc;
+    memset(reply, 0, *reply_len);
+    if ((rc = wpa_ctrl_request(mCtrl, cmd, strlen(cmd), reply, reply_len, NULL)) == -2)  {
+        errno = ETIMEDOUT;
+        return -1;
+    } else if (rc < 0 || !strncmp(reply, "FAIL", 4)) {
+        strcpy(reply, "FAIL");
+        errno = EIO;
+        return -1;
+    }
+
+ //   LOGD("sendCommand(): <- '%s'", reply);
+    return 0;
+}
 SupplicantStatus *Supplicant::getStatus() {
     char *reply;
     size_t len = 4096;
@@ -162,6 +184,7 @@
         return -1;
     }
 
+    PropertyManager *pm = NetworkManager::Instance()->getPropMngr();
     pthread_mutex_lock(&mNetworksLock);
 
     int num_added = 0;
@@ -182,7 +205,9 @@
             delete new_wn;
         } else {
             num_added++;
-            new_wn->registerProperties();
+            char new_ns[20];
+            snprintf(new_ns, sizeof(new_ns), "wifi.net.%d", new_wn->getNetworkId());
+            new_wn->attachProperties(pm, new_ns);
             mNetworks->push_back(new_wn);
             if (new_wn->refresh()) {
                 LOGW("Unable to refresh network id %d (%s)",
@@ -198,7 +223,9 @@
         for (i = mNetworks->begin(); i != mNetworks->end(); ++i) {
             if (0) {
                 num_removed++;
-                (*i)->unregisterProperties();
+                char del_ns[20];
+                snprintf(del_ns, sizeof(del_ns), "wifi.net.%d", (*i)->getNetworkId());
+                (*i)->detachProperties(pm, del_ns);
                 delete (*i);
                 i = mNetworks->erase(i);
             }
@@ -247,31 +274,7 @@
     return 0;
 }
 
-int Supplicant::sendCommand(const char *cmd, char *reply, size_t *reply_len)
-{
-    if (!mCtrl) {
-        errno = ENOTCONN;
-        return -1;
-    }
-
-//    LOGD("sendCommand(): -> '%s'", cmd);
-
-    int rc;
-    memset(reply, 0, *reply_len);
-    if ((rc = wpa_ctrl_request(mCtrl, cmd, strlen(cmd), reply, reply_len, NULL)) == -2)  {
-        errno = ETIMEDOUT;
-        return -1;
-    } else if (rc < 0 || !strncmp(reply, "FAIL", 4)) {
-        strcpy(reply, "FAIL");
-        errno = EIO;
-        return -1;
-    }
-
-//   LOGD("sendCommand(): <- '%s'", reply);
-    return 0;
-}
-
-int Supplicant::triggerScan(bool active) {
+int Supplicant::setScanMode(bool active) {
     char reply[255];
     size_t len = sizeof(reply);
 
@@ -281,10 +284,88 @@
              strerror(errno));
         return -1;
     }
-    len = sizeof(reply);
+    return 0;
+}
+
+int Supplicant::triggerScan() {
+    char reply[255];
+    size_t len = sizeof(reply);
 
     if (sendCommand("SCAN", reply, &len)) {
-        LOGW("triggerScan(%d): Error initiating scan", active);
+        LOGW("triggerScan(): Error initiating scan");
+        return -1;
+    }
+    return 0;
+}
+
+int Supplicant::getRssi(int *buffer) {
+    char reply[64];
+    size_t len = sizeof(reply);
+
+    if (sendCommand("DRIVER RSSI", reply, &len)) {
+        LOGW("Failed to get RSSI (%s)", strerror(errno));
+        return -1;
+    }
+
+    char *next = reply;
+    char *s;
+    for (int i = 0; i < 3; i++) {
+        if (!(s = strsep(&next, " "))) {
+            LOGE("Error parsing RSSI");
+            errno = EIO;
+            return -1;
+        }
+    }
+    *buffer = atoi(s);
+    return 0;
+}
+
+int Supplicant::getLinkSpeed() {
+    char reply[64];
+    size_t len = sizeof(reply);
+
+    if (sendCommand("DRIVER LINKSPEED", reply, &len)) {
+        LOGW("Failed to get LINKSPEED (%s)", strerror(errno));
+        return -1;
+    }
+
+    char *next = reply;
+    char *s;
+
+    if (!(s = strsep(&next, " "))) {
+        LOGE("Error parsing LINKSPEED");
+        errno = EIO;
+        return -1;
+    }
+
+    if (!(s = strsep(&next, " "))) {
+        LOGE("Error parsing LINKSPEED");
+        errno = EIO;
+        return -1;
+    }
+    return atoi(s);
+}
+
+int Supplicant::stopDriver() {
+    char reply[64];
+    size_t len = sizeof(reply);
+
+    LOGD("stopDriver()");
+
+    if (sendCommand("DRIVER STOP", reply, &len)) {
+        LOGW("Failed to stop driver (%s)", strerror(errno));
+        return -1;
+    }
+    return 0;
+}
+
+int Supplicant::startDriver() {
+    char reply[64];
+    size_t len = sizeof(reply);
+
+    LOGD("startDriver()");
+    if (sendCommand("DRIVER START", reply, &len)) {
+        LOGW("Failed to start driver (%s)", strerror(errno));
         return -1;
     }
     return 0;
@@ -301,7 +382,11 @@
         reply[strlen(reply) -1] = '\0';
 
     WifiNetwork *wn = new WifiNetwork(mController, this, atoi(reply));
+    PropertyManager *pm = NetworkManager::Instance()->getPropMngr();
     pthread_mutex_lock(&mNetworksLock);
+    char new_ns[20];
+    snprintf(new_ns, sizeof(new_ns), "wifi.net.%d", wn->getNetworkId());
+    wn->attachProperties(pm, new_ns);
     mNetworks->push_back(wn);
     pthread_mutex_unlock(&mNetworksLock);
     return wn;
@@ -411,8 +496,9 @@
     char reply[255];
     size_t len = sizeof(reply) -1;
 
+    LOGD("netid %d, var '%s' = '%s'", networkId, var, val);
     char *tmp;
-    asprintf(&tmp, "SET_NETWORK %d %s \"%s\"", networkId, var, val);
+    asprintf(&tmp, "SET_NETWORK %d %s %s", networkId, var, val);
     if (sendCommand(tmp, reply, &len)) {
         free(tmp);
         return -1;
@@ -457,6 +543,95 @@
     return 0;
 }
 
+int Supplicant::enablePacketFilter() {
+    char req[128];
+    char reply[16];
+    size_t len;
+    int i;
+    
+    for (i = 0; i <=3; i++) {
+        snprintf(req, sizeof(req), "DRIVER RXFILTER-ADD %d", i);
+        len = sizeof(reply);
+        if (sendCommand(req, reply, &len))
+            return -1;
+    }
+
+    len = sizeof(reply);
+    if (sendCommand("DRIVER RXFILTER-START", reply, &len))
+        return -1;
+    return 0;
+}
+  
+int Supplicant::disablePacketFilter() {
+    char req[128];
+    char reply[16];
+    size_t len;
+    int i;
+    
+    len = sizeof(reply);
+    if (sendCommand("DRIVER RXFILTER-STOP", reply, &len))
+        return -1;
+
+    for (i = 3; i >=0; i--) {
+        snprintf(req, sizeof(req), "DRIVER RXFILTER-REMOVE %d", i);
+        len = sizeof(reply);
+        if (sendCommand(req, reply, &len))
+            return -1;
+    }
+    return 0;
+}
+
+int Supplicant::enableBluetoothCoexistenceScan() {
+    char req[128];
+    char reply[16];
+    size_t len;
+    int i;
+    
+    len = sizeof(reply);
+    if (sendCommand("DRIVER BTCOEXSCAN-START", reply, &len))
+        return -1;
+    return 0;
+}
+
+int Supplicant::disableBluetoothCoexistenceScan() {
+    char req[128];
+    char reply[16];
+    size_t len;
+    int i;
+    
+    len = sizeof(reply);
+    if (sendCommand("DRIVER BTCOEXSCAN-STOP", reply, &len))
+        return -1;
+    return 0;
+}
+
+int Supplicant::setBluetoothCoexistenceMode(int mode) {
+    char req[64];
+
+    sprintf(req, "DRIVER BTCOEXMODE %d", mode);
+
+    char reply[16];
+    size_t len = sizeof(reply) -1;
+
+    if (sendCommand(req, reply, &len))
+        return -1;
+    return 0;
+}
+
+int Supplicant::setApScanMode(int mode) {
+    char req[64];
+
+//    LOGD("setApScanMode(%d)", mode);
+    sprintf(req, "AP_SCAN %d", mode);
+
+    char reply[16];
+    size_t len = sizeof(reply) -1;
+
+    if (sendCommand(req, reply, &len))
+        return -1;
+    return 0;
+}
+
 
 int Supplicant::retrieveInterfaceName() {
     char reply[255];
@@ -469,3 +644,34 @@
     mInterfaceName = strdup(reply);
     return 0;
 }
+
+int Supplicant::reconnect() {
+    char req[128];
+    char reply[16];
+    size_t len;
+    int i;
+    
+    len = sizeof(reply);
+    if (sendCommand("RECONNECT", reply, &len))
+        return -1;
+    return 0;
+}
+
+int Supplicant::disconnect() {
+    char req[128];
+    char reply[16];
+    size_t len;
+    int i;
+    
+    len = sizeof(reply);
+    if (sendCommand("DISCONNECT", reply, &len))
+        return -1;
+    return 0;
+}
+
+int Supplicant::getNetworkCount() {
+    pthread_mutex_lock(&mNetworksLock);
+    int cnt = mNetworks->size();
+    pthread_mutex_unlock(&mNetworksLock);
+    return cnt;
+}
diff --git a/nexus/Supplicant.h b/nexus/Supplicant.h
index 3efbe4c..3900f4f 100644
--- a/nexus/Supplicant.h
+++ b/nexus/Supplicant.h
@@ -30,7 +30,6 @@
 #include "ISupplicantEventHandler.h"
 
 class Supplicant {
-private:
     struct wpa_ctrl      *mCtrl;
     struct wpa_ctrl      *mMonitor;
     SupplicantListener   *mListener;
@@ -50,7 +49,8 @@
     int stop();
     bool isStarted();
 
-    int triggerScan(bool active);
+    int setScanMode(bool active);
+    int triggerScan();
 
     WifiNetwork *createNetwork();
     WifiNetwork *lookupNetwork(int networkId);
@@ -63,6 +63,21 @@
                               size_t max);
     int enableNetwork(int networkId, bool enabled);
 
+    int disconnect();
+    int reconnect();
+    int reassociate();
+    int setApScanMode(int mode);
+    int enablePacketFilter();
+    int disablePacketFilter();
+    int setBluetoothCoexistenceMode(int mode);
+    int enableBluetoothCoexistenceScan();
+    int disableBluetoothCoexistenceScan();
+    int stopDriver();
+    int startDriver();
+    int getRssi(int *buffer);
+    int getLinkSpeed();
+    int getNetworkCount();
+
     SupplicantStatus *getStatus();
 
     Controller *getController() { return (Controller *) mController; }
diff --git a/nexus/SupplicantState.cpp b/nexus/SupplicantState.cpp
index a16d370..2815430 100644
--- a/nexus/SupplicantState.cpp
+++ b/nexus/SupplicantState.cpp
@@ -23,25 +23,25 @@
 
 char *SupplicantState::toString(int val, char *buffer, int max) {
     if (val == SupplicantState::UNKNOWN)
-        strncpy(buffer, "Unknown", max);
+        strncpy(buffer, "UNKNOWN", max);
     else if (val == SupplicantState::DISCONNECTED)
-        strncpy(buffer, "Disconnected", max);
+        strncpy(buffer, "DISCONNECTED", max);
     else if (val == SupplicantState::INACTIVE)
-        strncpy(buffer, "Inactive", max);
+        strncpy(buffer, "INACTIVE", max);
     else if (val == SupplicantState::SCANNING)
-        strncpy(buffer, "Scanning", max);
+        strncpy(buffer, "SCANNING", max);
     else if (val == SupplicantState::ASSOCIATING)
-        strncpy(buffer, "Associating", max);
+        strncpy(buffer, "ASSOCIATING", max);
     else if (val == SupplicantState::ASSOCIATED)
-        strncpy(buffer, "Associated", max);
+        strncpy(buffer, "ASSOCIATED", max);
     else if (val == SupplicantState::FOURWAY_HANDSHAKE)
-        strncpy(buffer, "Fourway Handshake", max);
+        strncpy(buffer, "FOURWAY_HANDSHAKE", max);
     else if (val == SupplicantState::GROUP_HANDSHAKE)
-        strncpy(buffer, "Group Handshake", max);
+        strncpy(buffer, "GROUP_HANDSHAKE", max);
     else if (val == SupplicantState::COMPLETED)
-        strncpy(buffer, "Completed", max);
+        strncpy(buffer, "COMPLETED", max);
     else if (val == SupplicantState::IDLE)
-        strncpy(buffer, "Idle", max);
+        strncpy(buffer, "IDLE", max);
     else
         strncpy(buffer, "(internal error)", max);
 
diff --git a/nexus/TiwlanWifiController.cpp b/nexus/TiwlanWifiController.cpp
index 61535c3..016c790 100644
--- a/nexus/TiwlanWifiController.cpp
+++ b/nexus/TiwlanWifiController.cpp
@@ -51,6 +51,7 @@
 int TiwlanWifiController::powerDown() {
     if (mEventListener) {
         delete mEventListener;
+        shutdown(mListenerSock, SHUT_RDWR);
         close(mListenerSock);
         mListenerSock = -1;
         mEventListener = NULL;
@@ -77,7 +78,8 @@
                 LOGD("Firmware loaded OK");
 
                 if (startDriverEventListener()) {
-                    LOGW("Failed to start driver event listener");
+                    LOGW("Failed to start driver event listener (%s)",
+                         strerror(errno));
                 }
 
                 return 0;
@@ -95,32 +97,48 @@
 
 int TiwlanWifiController::startDriverEventListener() {
     struct sockaddr_in addr;
-    int s;
 
-    if ((s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
+    if (mListenerSock != -1) {
+        LOGE("Listener already started!");
+        errno = EBUSY;
         return -1;
+    }
+
+    if ((mListenerSock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
+        LOGE("socket failed (%s)", strerror(errno));
+        return -1;
+    }
 
     memset(&addr, 0, sizeof(addr));
     addr.sin_family = AF_INET;
     addr.sin_addr.s_addr = htonl(INADDR_ANY);
     addr.sin_port = htons(TI_DRIVER_MSG_PORT);
 
-    if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
-        close(s);
-        return -1;
+    if (bind(mListenerSock,
+             (struct sockaddr *) &addr,
+             sizeof(addr)) < 0) {
+        LOGE("bind failed (%s)", strerror(errno));
+        goto out_err;
     }
 
-    mEventListener = new TiwlanEventListener(s);
+    mEventListener = new TiwlanEventListener(mListenerSock);
 
     if (mEventListener->startListener()) {
         LOGE("Error starting driver listener (%s)", strerror(errno));
+        goto out_err;
+    }
+    return 0;
+out_err:
+    if (mEventListener) {
         delete mEventListener;
         mEventListener = NULL;
-        close(s);
-        return -1;
     }
-    mListenerSock = s;
-    return 0;
+    if (mListenerSock != -1) {
+        shutdown(mListenerSock, SHUT_RDWR);
+        close(mListenerSock);
+        mListenerSock = -1;
+    }
+    return -1;
 }
 
 bool TiwlanWifiController::isFirmwareLoaded() {
diff --git a/nexus/VpnController.cpp b/nexus/VpnController.cpp
index add4dc3..015710f 100644
--- a/nexus/VpnController.cpp
+++ b/nexus/VpnController.cpp
@@ -27,56 +27,66 @@
 
 VpnController::VpnController(PropertyManager *propmngr,
                              IControllerHandler *handlers) :
-               Controller("VPN", propmngr, handlers) {
+               Controller("vpn", propmngr, handlers) {
     mEnabled = false;
+
+    mStaticProperties.propEnabled = new VpnEnabledProperty(this);
+    mDynamicProperties.propGateway = new IPV4AddressPropertyHelper("Gateway",
+                                                                   false,
+                                                                   &mGateway);
 }
 
 int VpnController::start() {
-    mPropMngr->registerProperty("vpn.enabled", this);
+    mPropMngr->attachProperty("vpn", mStaticProperties.propEnabled);
     return 0;
 }
 
 int VpnController::stop() {
-    mPropMngr->unregisterProperty("vpn.enabled");
+    mPropMngr->detachProperty("vpn", mStaticProperties.propEnabled);
     return 0;
 }
 
-int VpnController::set(const char *name, const char *value) {
-    if (!strcmp(name, "vpn.enabled")) {
-        int en = atoi(value);
-        int rc;
-
-        if (en == mEnabled)
-            return 0;
-        rc = (en ? enable() : disable());
-
-        if (!rc) {
-            mEnabled = en;
-            if (en) 
-                mPropMngr->unregisterProperty("vpn.gateway");
-            else
-                mPropMngr->unregisterProperty("vpn.gateway");
-        }
-        return rc;
-    } if (!strcmp(name, "vpn.gateway")) {
-        if (!inet_aton(value, &mVpnGateway)) {
-            errno = EINVAL;
-            return -1;
-        }
-        return 0;
-    }
-
-    return Controller::set(name, value);
+VpnController::VpnIntegerProperty::VpnIntegerProperty(VpnController *c,
+                                                      const char *name,
+                                                      bool ro,
+                                                      int elements) :
+                IntegerProperty(name, ro, elements) {
+    mVc = c;
 }
 
-const char *VpnController::get(const char *name, char *buffer, size_t maxsize) {
-    if (!strcmp(name, "vpn.enabled")) {
-        snprintf(buffer, maxsize, "%d", mEnabled);
-        return buffer;
-    } if (!strcmp(name, "vpn.gateway")) {
-        snprintf(buffer, maxsize, "%s", inet_ntoa(mVpnGateway));
-        return buffer;
-    }
+VpnController::VpnStringProperty::VpnStringProperty(VpnController *c,
+                                                    const char *name,
+                                                    bool ro, int elements) :
+                StringProperty(name, ro, elements) {
+    mVc = c;
+}
 
-    return Controller::get(name, buffer, maxsize);
+VpnController::VpnIPV4AddressProperty::VpnIPV4AddressProperty(VpnController *c,
+                                                              const char *name,
+                                                              bool ro, int elements) :
+                IPV4AddressProperty(name, ro, elements) {
+    mVc = c;
+}
+
+VpnController::VpnEnabledProperty::VpnEnabledProperty(VpnController *c) :
+                VpnIntegerProperty(c, "Enabled", false, 1) {
+}
+int VpnController::VpnEnabledProperty::get(int idx, int *buffer) {
+    *buffer = mVc->mEnabled;
+    return 0;
+}
+int VpnController::VpnEnabledProperty::set(int idx, int value) {
+    int rc;
+    if (!value) {
+        mVc->mPropMngr->detachProperty("vpn", mVc->mDynamicProperties.propGateway);
+        rc = mVc->disable();
+    } else {
+        rc = mVc->enable();
+        if (!rc) {
+            mVc->mPropMngr->attachProperty("vpn", mVc->mDynamicProperties.propGateway);
+        }
+    }
+    if (!rc)
+        mVc->mEnabled = value;
+    return rc;
 }
diff --git a/nexus/VpnController.h b/nexus/VpnController.h
index 1af4d9f..4bd86b5 100644
--- a/nexus/VpnController.h
+++ b/nexus/VpnController.h
@@ -24,11 +24,63 @@
 class IControllerHandler;
 
 class VpnController : public Controller {
+    class VpnIntegerProperty : public IntegerProperty {
+    protected:
+        VpnController *mVc;
+    public:
+        VpnIntegerProperty(VpnController *c, const char *name, bool ro,
+                            int elements);
+        virtual ~VpnIntegerProperty() {}
+        virtual int set(int idx, int value) = 0;
+        virtual int get(int idx, int *buffer) = 0;
+    };
+    friend class VpnController::VpnIntegerProperty;
+
+    class VpnStringProperty : public StringProperty {
+    protected:
+        VpnController *mVc;
+    public:
+        VpnStringProperty(VpnController *c, const char *name, bool ro,
+                            int elements);
+        virtual ~VpnStringProperty() {}
+        virtual int set(int idx, const char *value) = 0;
+        virtual int get(int idx, char *buffer, size_t max) = 0;
+    };
+    friend class VpnController::VpnStringProperty;
+
+    class VpnIPV4AddressProperty : public IPV4AddressProperty {
+    protected:
+        VpnController *mVc;
+    public:
+        VpnIPV4AddressProperty(VpnController *c, const char *name, bool ro,
+                          int elements);
+        virtual ~VpnIPV4AddressProperty() {}
+        virtual int set(int idx, struct in_addr *value) = 0;
+        virtual int get(int idx, struct in_addr *buffer) = 0;
+    };
+    friend class VpnController::VpnIPV4AddressProperty;
+
+    class VpnEnabledProperty : public VpnIntegerProperty {
+    public:
+        VpnEnabledProperty(VpnController *c);
+        virtual ~VpnEnabledProperty() {};
+        int set(int idx, int value);
+        int get(int idx, int *buffer);
+    };
+
     bool           mEnabled;
     /*
      * Gateway of the VPN server to connect to
      */
-    struct in_addr mVpnGateway;
+    struct in_addr mGateway;
+
+    struct {
+        VpnEnabledProperty *propEnabled;
+    } mStaticProperties;
+
+    struct {
+        IPV4AddressPropertyHelper *propGateway;
+    } mDynamicProperties;
 
 public:
     VpnController(PropertyManager *propmngr, IControllerHandler *handlers);
@@ -37,13 +89,9 @@
     virtual int start();
     virtual int stop();
 
-    virtual int set(const char *name, const char *value);
-    virtual const char *get(const char *name, char *buffer, size_t maxlen);
-
 protected:
     virtual int enable() = 0;
     virtual int disable() = 0;
-
 };
 
 #endif
diff --git a/nexus/WifiController.cpp b/nexus/WifiController.cpp
index ef5ecae..c218c30 100644
--- a/nexus/WifiController.cpp
+++ b/nexus/WifiController.cpp
@@ -23,9 +23,8 @@
 
 #include "Supplicant.h"
 #include "WifiController.h"
-#include "WifiScanner.h"
 #include "NetworkManager.h"
-#include "ErrorCode.h"
+#include "ResponseCode.h"
 #include "WifiNetwork.h"
 #include "ISupplicantEventHandler.h"
 #include "SupplicantState.h"
@@ -37,11 +36,12 @@
 #include "SupplicantStateChangeEvent.h"
 #include "SupplicantConnectionTimeoutEvent.h"
 #include "SupplicantDisconnectedEvent.h"
+#include "WifiStatusPoller.h"
 
 WifiController::WifiController(PropertyManager *mPropMngr,
                                IControllerHandler *handlers,
                                char *modpath, char *modname, char *modargs) :
-                Controller("WIFI", mPropMngr, handlers) {
+                Controller("wifi", mPropMngr, handlers) {
     strncpy(mModulePath, modpath, sizeof(mModulePath));
     strncpy(mModuleName, modname, sizeof(mModuleName));
     strncpy(mModuleArgs, modargs, sizeof(mModuleArgs));
@@ -49,22 +49,59 @@
     mLatestScanResults = new ScanResultCollection();
     pthread_mutex_init(&mLatestScanResultsLock, NULL);
 
-    mSupplicant = new Supplicant(this, this);
-    mScanner = new WifiScanner(mSupplicant, 10);
-    mCurrentScanMode = 0;
+    pthread_mutex_init(&mLock, NULL);
 
+    mSupplicant = new Supplicant(this, this);
+    mActiveScan = false;
     mEnabled = false;
+    mScanOnly = false;
+    mPacketFilter = false;
+    mBluetoothCoexScan = false;
+    mBluetoothCoexMode = 0;
+    mCurrentlyConnectedNetworkId = -1;
+    mStatusPoller = new WifiStatusPoller(this);
+    mRssiEventThreshold = 5;
+    mLastLinkSpeed = 0;
 
     mSupplicantState = SupplicantState::UNKNOWN;
+
+    mStaticProperties.propEnabled = new WifiEnabledProperty(this);
+    mStaticProperties.propScanOnly = new WifiScanOnlyProperty(this);
+    mStaticProperties.propAllowedChannels = new WifiAllowedChannelsProperty(this);
+
+    mStaticProperties.propRssiEventThreshold =
+            new IntegerPropertyHelper("RssiEventThreshold", false, &mRssiEventThreshold);
+
+    mDynamicProperties.propSupplicantState = new WifiSupplicantStateProperty(this);
+    mDynamicProperties.propActiveScan = new WifiActiveScanProperty(this);
+    mDynamicProperties.propInterface = new WifiInterfaceProperty(this);
+    mDynamicProperties.propSearching = new WifiSearchingProperty(this);
+    mDynamicProperties.propPacketFilter = new WifiPacketFilterProperty(this);
+    mDynamicProperties.propBluetoothCoexScan = new WifiBluetoothCoexScanProperty(this);
+    mDynamicProperties.propBluetoothCoexMode = new WifiBluetoothCoexModeProperty(this);
+    mDynamicProperties.propCurrentNetwork = new WifiCurrentNetworkProperty(this);
+
+    mDynamicProperties.propRssi = new IntegerPropertyHelper("Rssi", true, &mLastRssi);
+    mDynamicProperties.propLinkSpeed = new IntegerPropertyHelper("LinkSpeed", true, &mLastLinkSpeed);
+
+    mDynamicProperties.propSuspended = new WifiSuspendedProperty(this);
+    mDynamicProperties.propNetCount = new WifiNetCountProperty(this);
+    mDynamicProperties.propTriggerScan = new WifiTriggerScanProperty(this);
 }
 
 int WifiController::start() {
-    mPropMngr->registerProperty("wifi.enabled", this);
+    mPropMngr->attachProperty("wifi", mStaticProperties.propEnabled);
+    mPropMngr->attachProperty("wifi", mStaticProperties.propScanOnly);
+    mPropMngr->attachProperty("wifi", mStaticProperties.propAllowedChannels);
+    mPropMngr->attachProperty("wifi", mStaticProperties.propRssiEventThreshold);
     return 0;
 }
 
 int WifiController::stop() {
-    mPropMngr->unregisterProperty("wifi.enabled");
+    mPropMngr->detachProperty("wifi", mStaticProperties.propEnabled);
+    mPropMngr->detachProperty("wifi", mStaticProperties.propScanOnly);
+    mPropMngr->detachProperty("wifi", mStaticProperties.propAllowedChannels);
+    mPropMngr->detachProperty("wifi", mStaticProperties.propRssiEventThreshold);
     return 0;
 }
 
@@ -114,9 +151,21 @@
     if (mSupplicant->refreshNetworkList())
         LOGW("Error getting list of networks (%s)", strerror(errno));
 
-    mPropMngr->registerProperty("wifi.supplicant.state", this);
-    mPropMngr->registerProperty("wifi.scanmode", this);
-    mPropMngr->registerProperty("wifi.interface", this);
+    LOGW("TODO: Set # of allowed regulatory channels!");
+
+    mPropMngr->attachProperty("wifi", mDynamicProperties.propSupplicantState);
+    mPropMngr->attachProperty("wifi", mDynamicProperties.propActiveScan);
+    mPropMngr->attachProperty("wifi", mDynamicProperties.propInterface);
+    mPropMngr->attachProperty("wifi", mDynamicProperties.propSearching);
+    mPropMngr->attachProperty("wifi", mDynamicProperties.propPacketFilter);
+    mPropMngr->attachProperty("wifi", mDynamicProperties.propBluetoothCoexScan);
+    mPropMngr->attachProperty("wifi", mDynamicProperties.propBluetoothCoexMode);
+    mPropMngr->attachProperty("wifi", mDynamicProperties.propCurrentNetwork);
+    mPropMngr->attachProperty("wifi", mDynamicProperties.propRssi);
+    mPropMngr->attachProperty("wifi", mDynamicProperties.propLinkSpeed);
+    mPropMngr->attachProperty("wifi", mDynamicProperties.propSuspended);
+    mPropMngr->attachProperty("wifi", mDynamicProperties.propNetCount);
+    mPropMngr->attachProperty("wifi", mDynamicProperties.propTriggerScan);
 
     LOGI("Enabled successfully");
     return 0;
@@ -135,17 +184,87 @@
     return -1;
 }
 
+bool WifiController::getSuspended() {
+    pthread_mutex_lock(&mLock);
+    bool r = mSuspended;
+    pthread_mutex_unlock(&mLock);
+    return r;
+}
+
+int WifiController::setSuspend(bool suspend) {
+
+    pthread_mutex_lock(&mLock);
+    if (suspend == mSuspended) {
+        LOGW("Suspended state already = %d", suspend);
+        pthread_mutex_unlock(&mLock);
+        return 0;
+    }
+
+    if (suspend) {
+        mHandlers->onControllerSuspending(this);
+
+        char tmp[80];
+        LOGD("Suspending from supplicant state %s",
+             SupplicantState::toString(mSupplicantState,
+                                       tmp,
+                                       sizeof(tmp)));
+
+        if (mSupplicantState != SupplicantState::IDLE) {
+            LOGD("Forcing Supplicant disconnect");
+            if (mSupplicant->disconnect()) {
+                LOGW("Error disconnecting (%s)", strerror(errno));
+            }
+        }
+
+        LOGD("Stopping Supplicant driver");
+        if (mSupplicant->stopDriver()) {
+            LOGE("Error stopping driver (%s)", strerror(errno));
+            pthread_mutex_unlock(&mLock);
+            return -1;
+        }
+    } else {
+        LOGD("Resuming");
+
+        if (mSupplicant->startDriver()) {
+            LOGE("Error resuming driver (%s)", strerror(errno));
+            pthread_mutex_unlock(&mLock);
+            return -1;
+        }
+        // XXX: set regulatory max channels 
+        if (mScanOnly)
+            mSupplicant->triggerScan();
+        else
+            mSupplicant->reconnect();
+
+        mHandlers->onControllerResumed(this);
+    }
+
+    mSuspended = suspend;
+    pthread_mutex_unlock(&mLock);
+    LOGD("Suspend / Resume completed");
+    return 0;
+}
+
 void WifiController::sendStatusBroadcast(const char *msg) {
     NetworkManager::Instance()->
                     getBroadcaster()->
-                    sendBroadcast(ErrorCode::UnsolicitedInformational, msg, false);
+                    sendBroadcast(ResponseCode::UnsolicitedInformational, msg, false);
 }
 
 int WifiController::disable() {
 
-    mPropMngr->unregisterProperty("wifi.scanmode");
-    mPropMngr->unregisterProperty("wifi.supplicant.state");
-    mPropMngr->unregisterProperty("wifi.scanmode");
+    mPropMngr->detachProperty("wifi", mDynamicProperties.propSupplicantState);
+    mPropMngr->detachProperty("wifi", mDynamicProperties.propActiveScan);
+    mPropMngr->detachProperty("wifi", mDynamicProperties.propInterface);
+    mPropMngr->detachProperty("wifi", mDynamicProperties.propSearching);
+    mPropMngr->detachProperty("wifi", mDynamicProperties.propPacketFilter);
+    mPropMngr->detachProperty("wifi", mDynamicProperties.propBluetoothCoexScan);
+    mPropMngr->detachProperty("wifi", mDynamicProperties.propBluetoothCoexMode);
+    mPropMngr->detachProperty("wifi", mDynamicProperties.propCurrentNetwork);
+    mPropMngr->detachProperty("wifi", mDynamicProperties.propRssi);
+    mPropMngr->detachProperty("wifi", mDynamicProperties.propLinkSpeed);
+    mPropMngr->detachProperty("wifi", mDynamicProperties.propSuspended);
+    mPropMngr->detachProperty("wifi", mDynamicProperties.propNetCount);
 
     if (mSupplicant->isStarted()) {
         sendStatusBroadcast("Stopping WPA Supplicant");
@@ -178,35 +297,61 @@
     return 0;
 }
 
-int WifiController::setScanMode(uint32_t mode) {
-    int rc = 0;
+int WifiController::triggerScan() {
+    pthread_mutex_lock(&mLock);
+    if (verifyNotSuspended()) {
+        pthread_mutex_unlock(&mLock);
+        return -1;
+    }
 
-    if (mCurrentScanMode == mode)
+    switch (mSupplicantState) {
+        case SupplicantState::DISCONNECTED:
+        case SupplicantState::INACTIVE:
+        case SupplicantState::SCANNING:
+        case SupplicantState::IDLE:
+            break;
+        default:
+            // Switch to scan only mode
+            mSupplicant->setApScanMode(2);
+            break;
+    }
+
+    int rc = mSupplicant->triggerScan();
+    pthread_mutex_unlock(&mLock);
+    return rc;
+}
+
+int WifiController::setActiveScan(bool active) {
+    pthread_mutex_lock(&mLock);
+    if (mActiveScan == active) {
+        pthread_mutex_unlock(&mLock);
         return 0;
+    }
+    mActiveScan = active;
 
-    if (!(mode & SCAN_ENABLE_MASK)) {
-        if (mCurrentScanMode & SCAN_REPEAT_MASK)
-            mScanner->stop();
-    } else if (mode & SCAN_REPEAT_MASK)
-        rc = mScanner->start(mode & SCAN_ACTIVE_MASK);
-    else
-        rc = mSupplicant->triggerScan(mode & SCAN_ACTIVE_MASK);
-
-    mCurrentScanMode = mode;
+    int rc = mSupplicant->setScanMode(active);
+    pthread_mutex_unlock(&mLock);
     return rc;
 }
 
 WifiNetwork *WifiController::createNetwork() {
+    pthread_mutex_lock(&mLock);
     WifiNetwork *wn = mSupplicant->createNetwork();
+    pthread_mutex_unlock(&mLock);
     return wn;
 }
 
 int WifiController::removeNetwork(int networkId) {
+    pthread_mutex_lock(&mLock);
     WifiNetwork *wn = mSupplicant->lookupNetwork(networkId);
 
-    if (!wn)
+    if (!wn) {
+        pthread_mutex_unlock(&mLock);
         return -1;
-    return mSupplicant->removeNetwork(wn);
+    }
+    int rc = mSupplicant->removeNetwork(wn);
+    pthread_mutex_unlock(&mLock);
+    return rc;
 }
 
 ScanResultCollection *WifiController::createScanResults() {
@@ -225,45 +370,59 @@
     return mSupplicant->createNetworkList();
 }
 
-int WifiController::set(const char *name, const char *value) {
+int WifiController::setPacketFilter(bool enable) {
     int rc;
 
-    if (!strcmp(name, "wifi.enabled")) {
-        int en = atoi(value);
+    pthread_mutex_lock(&mLock);
+    if (enable)
+        rc = mSupplicant->enablePacketFilter();
+    else
+        rc = mSupplicant->disablePacketFilter();
 
-        if (en == mEnabled)
-            return 0;
-        rc = (en ? enable() : disable());
-        if (!rc)
-            mEnabled = en;
-    } else if (!strcmp(name, "wifi.interface")) {
-        errno = EROFS;
-        return -1;
-    } else if (!strcmp(name, "wifi.scanmode"))
-        return setScanMode((uint32_t) strtoul(value, NULL, 0));
-    else if (!strcmp(name, "wifi.supplicant.state")) {
-        errno = EROFS;
-        return -1;
-    } else
-        return Controller::set(name, value);
+    if (!rc)
+        mPacketFilter = enable;
+    pthread_mutex_unlock(&mLock);
     return rc;
 }
 
-const char *WifiController::get(const char *name, char *buffer, size_t maxsize) {
+int WifiController::setBluetoothCoexistenceScan(bool enable) {
+    int rc;
 
-    if (!strcmp(name, "wifi.enabled"))
-        snprintf(buffer, maxsize, "%d", mEnabled);
-    else if (!strcmp(name, "wifi.interface")) {
-        snprintf(buffer, maxsize, "%s",
-                 (getBoundInterface() ? getBoundInterface() : "none"));
-    } else if (!strcmp(name, "wifi.scanmode"))
-        snprintf(buffer, maxsize, "0x%.8x", mCurrentScanMode);
-    else if (!strcmp(name, "wifi.supplicant.state"))
-        return SupplicantState::toString(mSupplicantState, buffer, maxsize);
+    pthread_mutex_lock(&mLock);
+
+    if (enable)
+        rc = mSupplicant->enableBluetoothCoexistenceScan();
     else
-        return Controller::get(name, buffer, maxsize);
+        rc = mSupplicant->disableBluetoothCoexistenceScan();
 
-    return buffer;
+    if (!rc)
+        mBluetoothCoexScan = enable;
+    pthread_mutex_unlock(&mLock);
+    return rc;
+}
+
+int WifiController::setScanOnly(bool scanOnly) {
+    pthread_mutex_lock(&mLock);
+    int rc = mSupplicant->setApScanMode((scanOnly ? 2 : 1));
+    if (!rc)
+        mScanOnly = scanOnly;
+    if (!mSuspended) {
+        if (scanOnly)
+            mSupplicant->disconnect();
+        else
+            mSupplicant->reconnect();
+    }
+    pthread_mutex_unlock(&mLock);
+    return rc;
+}
+
+int WifiController::setBluetoothCoexistenceMode(int mode) {
+    pthread_mutex_lock(&mLock);
+    int rc = mSupplicant->setBluetoothCoexistenceMode(mode);
+    if (!rc)
+        mBluetoothCoexMode = mode;
+    pthread_mutex_unlock(&mLock);
+    return rc;
 }
 
 void WifiController::onAssociatingEvent(SupplicantAssociatingEvent *evt) {
@@ -296,6 +455,7 @@
         return;
     }
     
+    mCurrentlyConnectedNetworkId = ss->getId();
     if (!(wn = mSupplicant->lookupNetwork(ss->getId()))) {
         LOGW("Error looking up connected network id %d (%s)",
              ss->getId(), strerror(errno));
@@ -303,7 +463,7 @@
     }
   
     delete ss;
-    mHandlers->onInterfaceConnected(this, wn->getIfaceCfg());
+    mHandlers->onInterfaceConnected(this);
 }
 
 void WifiController::onScanResultsEvent(SupplicantScanResultsEvent *evt) {
@@ -314,6 +474,10 @@
         return;
     }
 
+    mNumScanResultsSinceLastStateChange++;
+    if (mNumScanResultsSinceLastStateChange >= 3)
+        mIsSupplicantSearching = false;
+
     size_t len = 4096;
 
     if (mSupplicant->sendCommand("SCAN_RESULTS", reply, &len)) {
@@ -346,10 +510,14 @@
     while((linep = strtok_r(NULL, "\n", &linep_next)))
         mLatestScanResults->push_back(new ScanResult(linep));
 
+    // Switch handling of scan results back to normal mode
+    mSupplicant->setApScanMode(1);
+
     char *tmp;
     asprintf(&tmp, "Scan results ready (%d)", mLatestScanResults->size());
     NetworkManager::Instance()->getBroadcaster()->
-                                sendBroadcast(ErrorCode::UnsolicitedInformational, tmp, false);
+                                sendBroadcast(ResponseCode::ScanResultsReady,
+                                              tmp, false);
     free(tmp);
     pthread_mutex_unlock(&mLatestScanResultsLock);
     free(reply);
@@ -359,11 +527,35 @@
     char tmp[32];
     char tmp2[32];
     
+    if (evt->getState() == mSupplicantState)
+        return;
+
     LOGD("onStateChangeEvent(%s -> %s)", 
          SupplicantState::toString(mSupplicantState, tmp, sizeof(tmp)),
          SupplicantState::toString(evt->getState(), tmp2, sizeof(tmp2)));
 
+    if (evt->getState() != SupplicantState::SCANNING) {
+        mIsSupplicantSearching = true;
+        mNumScanResultsSinceLastStateChange = 0;
+    }
+
+    char *tmp3;
+    asprintf(&tmp3,
+             "Supplicant state changed from %d (%s) -> %d (%s)",
+             mSupplicantState, tmp, evt->getState(), tmp2);
+
     mSupplicantState = evt->getState();
+
+    if (mSupplicantState == SupplicantState::COMPLETED) {
+        mStatusPoller->start();
+    } else if (mStatusPoller->isStarted()) {
+        mStatusPoller->stop();
+    }
+
+    NetworkManager::Instance()->getBroadcaster()->
+                                sendBroadcast(ResponseCode::SupplicantStateChange,
+                                              tmp3, false);
+    free(tmp3);
 }
 
 void WifiController::onConnectionTimeoutEvent(SupplicantConnectionTimeoutEvent *evt) {
@@ -371,7 +563,8 @@
 }
 
 void WifiController::onDisconnectedEvent(SupplicantDisconnectedEvent *evt) {
-    mHandlers->onInterfaceDisconnected(this, getBoundInterface());
+    mCurrentlyConnectedNetworkId = -1;
+    mHandlers->onInterfaceDisconnected(this);
 }
 
 #if 0
@@ -411,3 +604,216 @@
     LOGD("onDriverStateEvent(%s)", evt->getEvent());
 }
 #endif
+
+void WifiController::onStatusPollInterval() {
+    pthread_mutex_lock(&mLock);
+    int rssi;
+    if (mSupplicant->getRssi(&rssi)) {
+        LOGE("Failed to get rssi (%s)", strerror(errno));
+        pthread_mutex_unlock(&mLock);
+        return;
+    }
+
+    if (abs(mLastRssi - rssi) > mRssiEventThreshold) {
+        char *tmp3;
+        asprintf(&tmp3, "RSSI changed from %d -> %d",
+                 mLastRssi, rssi);
+        mLastRssi = rssi;
+        NetworkManager::Instance()->getBroadcaster()->
+                               sendBroadcast(ResponseCode::RssiChange,
+                                             tmp3, false);
+        free(tmp3);
+    }
+
+    int linkspeed = mSupplicant->getLinkSpeed();
+    if (linkspeed != mLastLinkSpeed) {
+        char *tmp3;
+        asprintf(&tmp3, "Link speed changed from %d -> %d",
+                 mLastLinkSpeed, linkspeed);
+        mLastLinkSpeed = linkspeed;
+        NetworkManager::Instance()->getBroadcaster()->
+                               sendBroadcast(ResponseCode::LinkSpeedChange,
+                                             tmp3, false);
+        free(tmp3);
+        
+    }
+    pthread_mutex_unlock(&mLock);
+}
+
+int WifiController::verifyNotSuspended() {
+    if (mSuspended) {
+        errno = ESHUTDOWN;
+        return -1;
+    }
+    return 0;
+}
+
+/*
+ * Property inner classes
+ */
+
+WifiController::WifiIntegerProperty::WifiIntegerProperty(WifiController *c, 
+                                                         const char *name,
+                                                         bool ro,
+                                                         int elements) :
+                IntegerProperty(name, ro, elements) {
+    mWc = c;
+}
+
+WifiController::WifiStringProperty::WifiStringProperty(WifiController *c, 
+                                                       const char *name,
+                                                       bool ro, int elements) :
+                StringProperty(name, ro, elements) {
+    mWc = c;
+}
+
+WifiController::WifiEnabledProperty::WifiEnabledProperty(WifiController *c) :
+                WifiIntegerProperty(c, "Enabled", false, 1) {
+}
+
+int WifiController::WifiEnabledProperty::get(int idx, int *buffer) {
+    *buffer = mWc->mEnabled;
+    return 0;
+}
+int WifiController::WifiEnabledProperty::set(int idx, int value) {
+    int rc = (value ? mWc->enable() : mWc->disable());
+    if (!rc)
+        mWc->mEnabled = value;
+    return rc;
+}
+
+WifiController::WifiScanOnlyProperty::WifiScanOnlyProperty(WifiController *c) :
+                WifiIntegerProperty(c, "ScanOnly", false, 1) {
+}
+int WifiController::WifiScanOnlyProperty::get(int idx, int *buffer) {
+    *buffer = mWc->mScanOnly;
+    return 0;
+}
+int WifiController::WifiScanOnlyProperty::set(int idx, int value) {
+    return mWc->setScanOnly(value == 1);
+}
+
+WifiController::WifiAllowedChannelsProperty::WifiAllowedChannelsProperty(WifiController *c) :
+                WifiIntegerProperty(c, "AllowedChannels", false, 1) {
+}
+int WifiController::WifiAllowedChannelsProperty::get(int idx, int *buffer) {
+    *buffer = mWc->mNumAllowedChannels;
+    return 0;
+}
+int WifiController::WifiAllowedChannelsProperty::set(int idx, int value) {
+    // XXX: IMPL
+    errno = ENOSYS;
+    return -1;
+}
+
+WifiController::WifiSupplicantStateProperty::WifiSupplicantStateProperty(WifiController *c) :
+                WifiStringProperty(c, "SupplicantState", true, 1) {
+}
+int WifiController::WifiSupplicantStateProperty::get(int idx, char *buffer, size_t max) {
+    if (!SupplicantState::toString(mWc->mSupplicantState, buffer, max))
+        return -1;
+    return 0;
+}
+
+WifiController::WifiActiveScanProperty::WifiActiveScanProperty(WifiController *c) :
+                WifiIntegerProperty(c, "ActiveScan", false, 1) {
+}
+int WifiController::WifiActiveScanProperty::get(int idx, int *buffer) {
+    *buffer = mWc->mActiveScan;
+    return 0;
+}
+int WifiController::WifiActiveScanProperty::set(int idx, int value) {
+    return mWc->setActiveScan(value);
+}
+
+WifiController::WifiInterfaceProperty::WifiInterfaceProperty(WifiController *c) :
+                WifiStringProperty(c, "Interface", true, 1) {
+}
+int WifiController::WifiInterfaceProperty::get(int idx, char *buffer, size_t max) {
+    strncpy(buffer, (mWc->getBoundInterface() ? mWc->getBoundInterface() : "none"), max);
+    return 0;
+}
+
+WifiController::WifiSearchingProperty::WifiSearchingProperty(WifiController *c) :
+                WifiIntegerProperty(c, "Searching", true, 1) {
+}
+int WifiController::WifiSearchingProperty::get(int idx, int *buffer) {
+    *buffer = mWc->mIsSupplicantSearching;
+    return 0;
+}
+
+WifiController::WifiPacketFilterProperty::WifiPacketFilterProperty(WifiController *c) :
+                WifiIntegerProperty(c, "PacketFilter", false, 1) {
+}
+int WifiController::WifiPacketFilterProperty::get(int idx, int *buffer) {
+    *buffer = mWc->mPacketFilter;
+    return 0;
+}
+int WifiController::WifiPacketFilterProperty::set(int idx, int value) {
+    return mWc->setPacketFilter(value);
+}
+
+WifiController::WifiBluetoothCoexScanProperty::WifiBluetoothCoexScanProperty(WifiController *c) :
+                WifiIntegerProperty(c, "BluetoothCoexScan", false, 1) {
+}
+int WifiController::WifiBluetoothCoexScanProperty::get(int idx, int *buffer) {
+    *buffer = mWc->mBluetoothCoexScan;
+    return 0;
+}
+int WifiController::WifiBluetoothCoexScanProperty::set(int idx, int value) {
+    return mWc->setBluetoothCoexistenceScan(value == 1);
+}
+
+WifiController::WifiBluetoothCoexModeProperty::WifiBluetoothCoexModeProperty(WifiController *c) :
+                WifiIntegerProperty(c, "BluetoothCoexMode", false, 1) {
+}
+int WifiController::WifiBluetoothCoexModeProperty::get(int idx, int *buffer) {
+    *buffer = mWc->mBluetoothCoexMode;
+    return 0;
+}
+int WifiController::WifiBluetoothCoexModeProperty::set(int idx, int value) {
+    return mWc->setBluetoothCoexistenceMode(value);
+}
+
+WifiController::WifiCurrentNetworkProperty::WifiCurrentNetworkProperty(WifiController *c) :
+                WifiIntegerProperty(c, "CurrentlyConnectedNetworkId", true, 1) {
+}
+int WifiController::WifiCurrentNetworkProperty::get(int idx, int *buffer) {
+    *buffer = mWc->mCurrentlyConnectedNetworkId;
+    return 0;
+}
+
+WifiController::WifiSuspendedProperty::WifiSuspendedProperty(WifiController *c) :
+                WifiIntegerProperty(c, "Suspended", false, 1) {
+}
+int WifiController::WifiSuspendedProperty::get(int idx, int *buffer) {
+    *buffer = mWc->getSuspended();
+    return 0;
+}
+int WifiController::WifiSuspendedProperty::set(int idx, int value) {
+    return mWc->setSuspend(value == 1);
+}
+
+WifiController::WifiNetCountProperty::WifiNetCountProperty(WifiController *c) :
+                WifiIntegerProperty(c, "NetCount", true, 1) {
+}
+int WifiController::WifiNetCountProperty::get(int idx, int *buffer) {
+    pthread_mutex_lock(&mWc->mLock);
+    *buffer = mWc->mSupplicant->getNetworkCount();
+    pthread_mutex_unlock(&mWc->mLock);
+    return 0;
+}
+
+WifiController::WifiTriggerScanProperty::WifiTriggerScanProperty(WifiController *c) :
+                WifiIntegerProperty(c, "TriggerScan", false, 1) {
+}
+int WifiController::WifiTriggerScanProperty::get(int idx, int *buffer) {
+    // XXX: Need action type
+    *buffer = 0;
+    return 0;
+}
+
+int WifiController::WifiTriggerScanProperty::set(int idx, int value) {
+    return mWc->triggerScan();
+}
+
diff --git a/nexus/WifiController.h b/nexus/WifiController.h
index c61d97a..b1524f6 100644
--- a/nexus/WifiController.h
+++ b/nexus/WifiController.h
@@ -23,41 +23,207 @@
 #include "ScanResult.h"
 #include "WifiNetwork.h"
 #include "ISupplicantEventHandler.h"
+#include "IWifiStatusPollerHandler.h"
 
 class NetInterface;
 class Supplicant;
-class WifiScanner;
 class SupplicantAssociatingEvent;
 class SupplicantAssociatedEvent;
 class SupplicantConnectedEvent;
 class SupplicantScanResultsEvent;
 class SupplicantStateChangeEvent;
 class SupplicantDisconnectedEvent;
+class WifiStatusPoller;
 
-class WifiController : public Controller, public ISupplicantEventHandler {
-public:
-    static const uint32_t SCAN_ENABLE_MASK       = 0x01;
-    static const uint32_t SCAN_ACTIVE_MASK       = 0x02;
-    static const uint32_t SCAN_REPEAT_MASK       = 0x04;
+class WifiController : public Controller,
+                       public ISupplicantEventHandler,
+                       public IWifiStatusPollerHandler {
 
-    static const uint32_t SCANMODE_NONE               = 0;
-    static const uint32_t SCANMODE_PASSIVE_ONESHOT    = SCAN_ENABLE_MASK;
-    static const uint32_t SCANMODE_PASSIVE_CONTINUOUS = SCAN_ENABLE_MASK | SCAN_REPEAT_MASK;
-    static const uint32_t SCANMODE_ACTIVE_ONESHOT     = SCAN_ENABLE_MASK | SCAN_ACTIVE_MASK;
-    static const uint32_t SCANMODE_ACTIVE_CONTINUOUS  = SCAN_ENABLE_MASK | SCAN_ACTIVE_MASK | SCAN_REPEAT_MASK;
+    class WifiIntegerProperty : public IntegerProperty {
+    protected:
+        WifiController *mWc;
+    public:
+        WifiIntegerProperty(WifiController *c, const char *name, bool ro, 
+                            int elements);
+        virtual ~WifiIntegerProperty() {}
+        virtual int set(int idx, int value) = 0;
+        virtual int get(int idx, int *buffer) = 0;
+    };
+    friend class WifiController::WifiIntegerProperty;
 
-private:
+    class WifiStringProperty : public StringProperty {
+    protected:
+        WifiController *mWc;
+    public:
+        WifiStringProperty(WifiController *c, const char *name, bool ro, 
+                            int elements);
+        virtual ~WifiStringProperty() {}
+        virtual int set(int idx, const char *value) = 0;
+        virtual int get(int idx, char *buffer, size_t max) = 0;
+    };
+    friend class WifiController::WifiStringProperty;
+
+    class WifiEnabledProperty : public WifiIntegerProperty {
+    public:
+        WifiEnabledProperty(WifiController *c);
+        virtual ~WifiEnabledProperty() {}
+        int set(int idx, int value);
+        int get(int idx, int *buffer);
+    };
+
+    class WifiScanOnlyProperty : public WifiIntegerProperty {
+    public:
+        WifiScanOnlyProperty(WifiController *c);
+        virtual ~WifiScanOnlyProperty() {}
+        int set(int idx, int value);
+        int get(int idx, int *buffer);
+    };
+
+    class WifiAllowedChannelsProperty : public WifiIntegerProperty {
+    public:
+        WifiAllowedChannelsProperty(WifiController *c);
+        virtual ~WifiAllowedChannelsProperty() {}
+        int set(int idx, int value);
+        int get(int idx, int *buffer);
+    };
+
+    class WifiActiveScanProperty : public WifiIntegerProperty {
+    public:
+        WifiActiveScanProperty(WifiController *c);
+        virtual ~WifiActiveScanProperty() {}
+        int set(int idx, int value);
+        int get(int idx, int *buffer);
+    };
+
+    class WifiSearchingProperty : public WifiIntegerProperty {
+    public:
+        WifiSearchingProperty(WifiController *c);
+        virtual ~WifiSearchingProperty() {}
+        int set(int idx, int value) { return -1; }
+        int get(int idx, int *buffer);
+    };
+
+    class WifiPacketFilterProperty : public WifiIntegerProperty {
+    public:
+        WifiPacketFilterProperty(WifiController *c);
+        virtual ~WifiPacketFilterProperty() {}
+        int set(int idx, int value);
+        int get(int idx, int *buffer);
+    };
+
+    class WifiBluetoothCoexScanProperty : public WifiIntegerProperty {
+    public:
+        WifiBluetoothCoexScanProperty(WifiController *c);
+        virtual ~WifiBluetoothCoexScanProperty() {}
+        int set(int idx, int value);
+        int get(int idx, int *buffer);
+    };
+
+    class WifiBluetoothCoexModeProperty : public WifiIntegerProperty {
+    public:
+        WifiBluetoothCoexModeProperty(WifiController *c);
+        virtual ~WifiBluetoothCoexModeProperty() {}
+        int set(int idx, int value);
+        int get(int idx, int *buffer);
+    };
+
+    class WifiCurrentNetworkProperty : public WifiIntegerProperty {
+    public:
+        WifiCurrentNetworkProperty(WifiController *c);
+        virtual ~WifiCurrentNetworkProperty() {}
+        int set(int idx, int value) { return -1; }
+        int get(int idx, int *buffer);
+    };
+
+    class WifiSuspendedProperty : public WifiIntegerProperty {
+    public:
+        WifiSuspendedProperty(WifiController *c);
+        virtual ~WifiSuspendedProperty() {}
+        int set(int idx, int value);
+        int get(int idx, int *buffer);
+    };
+
+    class WifiNetCountProperty : public WifiIntegerProperty {
+    public:
+        WifiNetCountProperty(WifiController *c);
+        virtual ~WifiNetCountProperty() {}
+        int set(int idx, int value) { return -1; }
+        int get(int idx, int *buffer);
+    };
+
+    class WifiTriggerScanProperty : public WifiIntegerProperty {
+    public:
+        WifiTriggerScanProperty(WifiController *c);
+        virtual ~WifiTriggerScanProperty() {}
+        int set(int idx, int value);
+        int get(int idx, int *buffer);
+    };
+
+    class WifiSupplicantStateProperty : public WifiStringProperty {
+    public:
+        WifiSupplicantStateProperty(WifiController *c);
+        virtual ~WifiSupplicantStateProperty() {}
+        int set(int idx, const char *value) { return -1; }
+        int get(int idx, char *buffer, size_t max);
+    };
+
+    class WifiInterfaceProperty : public WifiStringProperty {
+    public:
+        WifiInterfaceProperty(WifiController *c);
+        virtual ~WifiInterfaceProperty() {}
+        int set(int idx, const char *value) { return -1; }
+        int get(int idx, char *buffer, size_t max);
+    };
+
     Supplicant *mSupplicant;
     char        mModulePath[255];
     char        mModuleName[64];
     char        mModuleArgs[255];
 
-    uint32_t    mCurrentScanMode;
-    WifiScanner *mScanner;
     int         mSupplicantState;
+    bool        mActiveScan;
+    bool        mScanOnly;
+    bool        mPacketFilter;
+    bool        mBluetoothCoexScan;
+    int         mBluetoothCoexMode;
+    int         mCurrentlyConnectedNetworkId;
+    bool        mSuspended;
+    int         mLastRssi;
+    int         mRssiEventThreshold;
+    int         mLastLinkSpeed;
+    int         mNumAllowedChannels;
 
     ScanResultCollection *mLatestScanResults;
     pthread_mutex_t      mLatestScanResultsLock;
+    pthread_mutex_t      mLock;
+    WifiStatusPoller     *mStatusPoller;
+
+    struct {
+        WifiEnabledProperty         *propEnabled;
+        WifiScanOnlyProperty        *propScanOnly;
+        WifiAllowedChannelsProperty *propAllowedChannels;
+        IntegerPropertyHelper       *propRssiEventThreshold;
+    } mStaticProperties;
+
+    struct {
+        WifiActiveScanProperty        *propActiveScan;
+        WifiSearchingProperty         *propSearching;
+        WifiPacketFilterProperty      *propPacketFilter;
+        WifiBluetoothCoexScanProperty *propBluetoothCoexScan;
+        WifiBluetoothCoexModeProperty *propBluetoothCoexMode;
+        WifiCurrentNetworkProperty    *propCurrentNetwork;
+        IntegerPropertyHelper         *propRssi;
+        IntegerPropertyHelper         *propLinkSpeed;
+        WifiSuspendedProperty         *propSuspended;
+        WifiNetCountProperty          *propNetCount;
+        WifiSupplicantStateProperty   *propSupplicantState;
+        WifiInterfaceProperty         *propInterface;
+        WifiTriggerScanProperty       *propTriggerScan;
+    } mDynamicProperties;
+
+    // True if supplicant is currently searching for a network
+    bool mIsSupplicantSearching;
+    int  mNumScanResultsSinceLastStateChange;
 
     bool        mEnabled;
 
@@ -72,9 +238,6 @@
     int removeNetwork(int networkId);
     WifiNetworkCollection *createNetworkList();
 
-    virtual int set(const char *name, const char *value);
-    virtual const char *get(const char *name, char *buffer, size_t maxlen);
-
     ScanResultCollection *createScanResults();
 
     char *getModulePath() { return mModulePath; }
@@ -94,18 +257,25 @@
 
 private:
     void sendStatusBroadcast(const char *msg);
-    int setScanMode(uint32_t mode);
+    int setActiveScan(bool active);
+    int triggerScan();
     int enable();
     int disable();
+    int setSuspend(bool suspend);
+    bool getSuspended();
+    int setBluetoothCoexistenceScan(bool enable);
+    int setBluetoothCoexistenceMode(int mode);
+    int setPacketFilter(bool enable);
+    int setScanOnly(bool scanOnly);
 
     // ISupplicantEventHandler methods
-    virtual void onAssociatingEvent(SupplicantAssociatingEvent *evt);
-    virtual void onAssociatedEvent(SupplicantAssociatedEvent *evt);
-    virtual void onConnectedEvent(SupplicantConnectedEvent *evt);
-    virtual void onScanResultsEvent(SupplicantScanResultsEvent *evt);
-    virtual void onStateChangeEvent(SupplicantStateChangeEvent *evt);
-    virtual void onConnectionTimeoutEvent(SupplicantConnectionTimeoutEvent *evt);
-    virtual void onDisconnectedEvent(SupplicantDisconnectedEvent *evt);
+    void onAssociatingEvent(SupplicantAssociatingEvent *evt);
+    void onAssociatedEvent(SupplicantAssociatedEvent *evt);
+    void onConnectedEvent(SupplicantConnectedEvent *evt);
+    void onScanResultsEvent(SupplicantScanResultsEvent *evt);
+    void onStateChangeEvent(SupplicantStateChangeEvent *evt);
+    void onConnectionTimeoutEvent(SupplicantConnectionTimeoutEvent *evt);
+    void onDisconnectedEvent(SupplicantDisconnectedEvent *evt);
 #if 0
     virtual void onTerminatingEvent(SupplicantEvent *evt);
     virtual void onPasswordChangedEvent(SupplicantEvent *evt);
@@ -118,6 +288,9 @@
     virtual void onDriverStateEvent(SupplicantEvent *evt);
 #endif
 
+    void onStatusPollInterval();
+
+    int verifyNotSuspended();
 };
 
 #endif
diff --git a/nexus/WifiNetwork.cpp b/nexus/WifiNetwork.cpp
index 7059bd0..6a0f684 100644
--- a/nexus/WifiNetwork.cpp
+++ b/nexus/WifiNetwork.cpp
@@ -26,17 +26,7 @@
 #include "WifiNetwork.h"
 #include "Supplicant.h"
 #include "WifiController.h"
-#include "InterfaceConfig.h"
 
-const char *WifiNetwork::PropertyNames[] = { "ssid", "bssid", "psk", "wepkey.1",
-                                             "wepkey.2", "wepkey.3", "wepkey.4",
-                                             "defkeyidx", "pri", "hiddenssid",
-                                             "AllowedKeyManagement",
-                                             "AllowedProtocols",
-                                             "AllowedAuthAlgorithms",
-                                             "AllowedPairwiseCiphers",
-                                             "AllowedGroupCiphers",
-                                             "enabled", '\0' };
 WifiNetwork::WifiNetwork() {
    // This is private to restrict copy constructors
 }
@@ -76,11 +66,11 @@
     mDefaultKeyIndex = -1;
     mPriority = -1;
     mHiddenSsid = NULL;
-    mAllowedKeyManagement = KeyManagementMask::UNKNOWN;
-    mAllowedProtocols = 0;
-    mAllowedAuthAlgorithms = 0;
-    mAllowedPairwiseCiphers = 0;
-    mAllowedGroupCiphers = 0;
+    mKeyManagement = KeyManagementMask::UNKNOWN;
+    mProtocols = 0;
+    mAuthAlgorithms = 0;
+    mPairwiseCiphers = 0;
+    mGroupCiphers = 0;
     mEnabled = true;
 
     if (flags && flags[0] != '\0') {
@@ -90,11 +80,8 @@
             LOGW("Unsupported flags '%s'", flags);
     }
 
-    char *tmp2;
-    asprintf(&tmp2, "wifi.net.%d", mNetid);
-    mIfaceCfg = new InterfaceConfig(tmp2);
-    free(tmp2);
     free(tmp);
+    createProperties();
 }
 
 WifiNetwork::WifiNetwork(WifiController *c, Supplicant *suppl, int networkId) {
@@ -108,17 +95,13 @@
     mDefaultKeyIndex = -1;
     mPriority = -1;
     mHiddenSsid = NULL;
-    mAllowedKeyManagement = 0;
-    mAllowedProtocols = 0;
-    mAllowedAuthAlgorithms = 0;
-    mAllowedPairwiseCiphers = 0;
-    mAllowedGroupCiphers = 0;
+    mKeyManagement = 0;
+    mProtocols = 0;
+    mAuthAlgorithms = 0;
+    mPairwiseCiphers = 0;
+    mGroupCiphers = 0;
     mEnabled = false;
-
-    char *tmp2;
-    asprintf(&tmp2, "wifi.net.%d", mNetid);
-    mIfaceCfg = new InterfaceConfig(tmp2);
-    free(tmp2);
+    createProperties();
 }
 
 WifiNetwork *WifiNetwork::clone() {
@@ -140,15 +123,35 @@
     r->mPriority = mPriority;
     if (mHiddenSsid)
         r->mHiddenSsid = strdup(mHiddenSsid);
-    r->mAllowedKeyManagement = mAllowedKeyManagement;
-    r->mAllowedProtocols = mAllowedProtocols;
-    r->mAllowedAuthAlgorithms = mAllowedAuthAlgorithms;
-    r->mAllowedPairwiseCiphers = mAllowedPairwiseCiphers;
-    r->mAllowedGroupCiphers = mAllowedGroupCiphers;
+    r->mKeyManagement = mKeyManagement;
+    r->mProtocols = mProtocols;
+    r->mAuthAlgorithms = mAuthAlgorithms;
+    r->mPairwiseCiphers = mPairwiseCiphers;
+    r->mGroupCiphers = mGroupCiphers;
     return r;
 }
 
+void WifiNetwork::createProperties() {
+    asprintf(&mPropNamespace, "wifi.net.%d", mNetid);
+
+    mStaticProperties.propEnabled = new WifiNetworkEnabledProperty(this);
+    mStaticProperties.propSsid = new WifiNetworkSsidProperty(this);
+    mStaticProperties.propBssid = new WifiNetworkBssidProperty(this);
+    mStaticProperties.propPsk = new WifiNetworkPskProperty(this);
+    mStaticProperties.propWepKey = new WifiNetworkWepKeyProperty(this);
+    mStaticProperties.propDefKeyIdx = new WifiNetworkDefaultKeyIndexProperty(this);
+    mStaticProperties.propPriority = new WifiNetworkPriorityProperty(this);
+    mStaticProperties.propKeyManagement = new WifiNetworkKeyManagementProperty(this);
+    mStaticProperties.propProtocols = new WifiNetworkProtocolsProperty(this);
+    mStaticProperties.propAuthAlgorithms = new WifiNetworkAuthAlgorithmsProperty(this);
+    mStaticProperties.propPairwiseCiphers = new WifiNetworkPairwiseCiphersProperty(this);
+    mStaticProperties.propGroupCiphers = new WifiNetworkGroupCiphersProperty(this);
+    mStaticProperties.propHiddenSsid = new WifiNetworkHiddenSsidProperty(this);
+}
+
 WifiNetwork::~WifiNetwork() {
+    if (mPropNamespace)
+        free(mPropNamespace);
     if (mSsid)
         free(mSsid);
     if (mBssid)
@@ -162,13 +165,26 @@
 
     if (mHiddenSsid)
         free(mHiddenSsid);
-    if (mIfaceCfg)
-        delete(mIfaceCfg);
+
+    delete mStaticProperties.propEnabled;
+    delete mStaticProperties.propSsid;
+    delete mStaticProperties.propBssid;
+    delete mStaticProperties.propPsk;
+    delete mStaticProperties.propWepKey;
+    delete mStaticProperties.propDefKeyIdx;
+    delete mStaticProperties.propPriority;
+    delete mStaticProperties.propKeyManagement;
+    delete mStaticProperties.propProtocols;
+    delete mStaticProperties.propAuthAlgorithms;
+    delete mStaticProperties.propPairwiseCiphers;
+    delete mStaticProperties.propGroupCiphers;
+    delete mStaticProperties.propHiddenSsid;
 }
 
 int WifiNetwork::refresh() {
     char buffer[255];
     size_t len;
+    uint32_t mask;
 
     len = sizeof(buffer);
     if (mSuppl->getNetworkVar(mNetid, "psk", buffer, len))
@@ -198,46 +214,47 @@
 
     len = sizeof(buffer);
     if (mSuppl->getNetworkVar(mNetid, "key_mgmt", buffer, len)) {
-        if (!strcmp(buffer, "NONE"))
-            setAllowedKeyManagement(KeyManagementMask::NONE);
-        else if (index(buffer, ' ')) {
-            char *next = buffer;
-            char *token;
-            uint32_t mask = 0;
-
-            while((token = strsep(&next, " "))) {
-                if (!strcmp(token, "WPA-PSK"))
-                    mask |= KeyManagementMask::WPA_PSK;
-                else if (!strcmp(token, "WPA-EAP"))
-                    mask |= KeyManagementMask::WPA_EAP;
-                else if (!strcmp(token, "IEE8021X"))
-                    mask |= KeyManagementMask::IEEE8021X;
-                else
-                    LOGW("Unsupported key management scheme '%s'" , token);
-            }
-            setAllowedKeyManagement(mask);
-        } else
-            LOGE("Unsupported key management '%s'", buffer);
+        if (WifiNetwork::parseKeyManagementMask(buffer, &mask)) {
+            LOGE("Error parsing key_mgmt (%s)", strerror(errno));
+        } else {
+           mKeyManagement = mask;
+        }
     }
 
     len = sizeof(buffer);
     if (mSuppl->getNetworkVar(mNetid, "proto", buffer, len)) {
-        // TODO
+        if (WifiNetwork::parseProtocolsMask(buffer, &mask)) {
+            LOGE("Error parsing proto (%s)", strerror(errno));
+        } else {
+           mProtocols = mask;
+        }
     }
 
     len = sizeof(buffer);
     if (mSuppl->getNetworkVar(mNetid, "auth_alg", buffer, len)) {
-        // TODO
+        if (WifiNetwork::parseAuthAlgorithmsMask(buffer, &mask)) {
+            LOGE("Error parsing auth_alg (%s)", strerror(errno));
+        } else {
+           mAuthAlgorithms = mask;
+        }
     }
 
     len = sizeof(buffer);
     if (mSuppl->getNetworkVar(mNetid, "pairwise", buffer, len)) {
-        // TODO
+        if (WifiNetwork::parsePairwiseCiphersMask(buffer, &mask)) {
+            LOGE("Error parsing pairwise (%s)", strerror(errno));
+        } else {
+           mPairwiseCiphers = mask;
+        }
     }
 
     len = sizeof(buffer);
     if (mSuppl->getNetworkVar(mNetid, "group", buffer, len)) {
-        // TODO
+        if (WifiNetwork::parseGroupCiphersMask(buffer, &mask)) {
+            LOGE("Error parsing group (%s)", strerror(errno));
+        } else {
+           mGroupCiphers = mask;
+        }
     }
 
     return 0;
@@ -246,179 +263,10 @@
     return -1;
 }
 
-int WifiNetwork::set(const char *name, const char *value) {
-    char *n_tmp = strdup(name + strlen("wifi.net."));
-    char *n_next = n_tmp;
-    char *n_local;
-    char *n_rest;
-    int rc = 0;
-
-    if (!strsep(&n_next, ".")) // skip net id
-        goto out_inval;
-
-    if (!(n_local = strsep(&n_next, ".")))
-        goto out_inval;
-
-    n_rest = n_next;
-
-//    LOGD("set(): var '%s'(%s / %s) = %s", name, n_local, n_rest, value);
-    if (!strcasecmp(n_local, "enabled"))
-        rc = setEnabled(atoi(value));
-    else if (!strcmp(n_local, "ssid"))
-        rc = setSsid(value);
-    else if (!strcasecmp(n_local, "bssid"))
-        rc = setBssid(value);
-    else if (!strcasecmp(n_local, "psk"))
-        rc = setPsk(value);
-    else if (!strcasecmp(n_local, "wepkey"))
-        rc = setWepKey(atoi(n_rest) -1, value);
-    else if (!strcasecmp(n_local, "defkeyidx"))
-        rc = setDefaultKeyIndex(atoi(value));
-    else if (!strcasecmp(n_local, "pri"))
-        rc = setPriority(atoi(value));
-    else if (!strcasecmp(n_local, "hiddenssid"))
-        rc = setHiddenSsid(value);
-    else if (!strcasecmp(n_local, "AllowedKeyManagement")) {
-        uint32_t mask = 0;
-        bool none = false;
-        char *v_tmp = strdup(value);
-        char *v_next = v_tmp;
-        char *v_token;
-
-        while((v_token = strsep(&v_next, " "))) {
-            if (!strcasecmp(v_token, "NONE")) {
-                mask = KeyManagementMask::NONE;
-                none = true;
-            } else if (!none) {
-                if (!strcasecmp(v_token, "WPA_PSK"))
-                    mask |= KeyManagementMask::WPA_PSK;
-                else if (!strcasecmp(v_token, "WPA_EAP"))
-                    mask |= KeyManagementMask::WPA_EAP;
-                else if (!strcasecmp(v_token, "IEEE8021X"))
-                    mask |= KeyManagementMask::IEEE8021X;
-                else {
-                    errno = EINVAL;
-                    rc = -1;
-                    free(v_tmp);
-                    goto out;
-                }
-            } else {
-                errno = EINVAL;
-                rc = -1;
-                free(v_tmp);
-                goto out;
-            }
-        }
-        free(v_tmp);
-    } else if (!strcasecmp(n_local, "AllowedProtocols")) {
-        // TODO
-    } else if (!strcasecmp(n_local, "AllowedPairwiseCiphers")) {
-        // TODO
-    } else if (!strcasecmp(n_local, "AllowedAuthAlgorithms")) {
-        // TODO
-    } else if (!strcasecmp(n_local, "AllowedGroupCiphers")) {
-        // TODO
-    } else {
-        errno = ENOENT;
-        free(n_tmp);
-        return -1;
-    }
-
-out:
-    free(n_tmp);
-    return rc;
-
-out_inval:
-    errno = EINVAL;
-    free(n_tmp);
-    return -1;
-}
-
-const char *WifiNetwork::get(const char *name, char *buffer, size_t maxsize) {
-    char *n_tmp = strdup(name + strlen("wifi.net."));
-    char *n_next = n_tmp;
-    char *n_local;
-    char fc[64];
-    char rc[128];
-
-    if (!strsep(&n_next, ".")) // skip net id
-        goto out_inval;
-
-    if (!(n_local = strsep(&n_next, ".")))
-        goto out_inval;
-
-
-    strncpy(fc, n_local, sizeof(fc));
-    rc[0] = '\0';
-    if (n_next)
-        strncpy(rc, n_next, sizeof(rc));
-
-    free(n_tmp);
-
-    if (!strcasecmp(fc, "enabled"))
-        snprintf(buffer, maxsize, "%d", getEnabled());
-    else if (!strcasecmp(fc, "ssid")) {
-        strncpy(buffer,
-                getSsid() ? getSsid() : "none",
-                maxsize);
-    } else if (!strcasecmp(fc, "bssid")) {
-        strncpy(buffer,
-                getBssid() ? getBssid() : "none",
-                maxsize);
-    } else if (!strcasecmp(fc, "psk")) {
-        strncpy(buffer,
-                getPsk() ? getPsk() : "none",
-                maxsize);
-    } else if (!strcasecmp(fc, "wepkey")) {
-        strncpy(buffer,
-                getWepKey(atoi(rc)-1) ? getWepKey(atoi(rc)-1) : "none",
-                maxsize);
-    } else if (!strcasecmp(fc, "defkeyidx"))
-        snprintf(buffer, maxsize, "%d", getDefaultKeyIndex());
-    else if (!strcasecmp(fc, "pri"))
-        snprintf(buffer, maxsize, "%d", getPriority());
-    else if (!strcasecmp(fc, "AllowedKeyManagement")) {
-        if (getAllowedKeyManagement() == KeyManagementMask::NONE) 
-            strncpy(buffer, "NONE", maxsize);
-        else {
-            char tmp[80] = { '\0' };
-
-            if (getAllowedKeyManagement() & KeyManagementMask::WPA_PSK)
-                strcat(tmp, "WPA_PSK ");
-            if (getAllowedKeyManagement() & KeyManagementMask::WPA_EAP)
-                strcat(tmp, "WPA_EAP ");
-            if (getAllowedKeyManagement() & KeyManagementMask::IEEE8021X)
-                strcat(tmp, "IEEE8021X");
-            if (tmp[0] == '\0') {
-                strncpy(buffer, "(internal error)", maxsize);
-                errno = ENOENT;
-                return NULL;
-            }
-            if (tmp[strlen(tmp)] == ' ')
-                tmp[strlen(tmp)] = '\0';
-
-            strncpy(buffer, tmp, maxsize);
-        }
-    } else if (!strcasecmp(fc, "hiddenssid")) {
-        strncpy(buffer,
-                getHiddenSsid() ? getHiddenSsid() : "none",
-                maxsize);
-    } else {
-        strncpy(buffer, "(internal error)", maxsize);
-        errno = ENOENT;
-        return NULL;
-    }
-
-    return buffer;
-
-out_inval:
-    errno = EINVAL;
-    free(n_tmp);
-    return NULL;
-}
-
 int WifiNetwork::setSsid(const char *ssid) {
-    if (mSuppl->setNetworkVar(mNetid, "ssid", ssid))
+    char tmp[255];
+    snprintf(tmp, sizeof(tmp), "\"%s\"", ssid);
+    if (mSuppl->setNetworkVar(mNetid, "ssid", tmp))
         return -1;
     if (mSsid)
         free(mSsid);
@@ -436,7 +284,9 @@
 }
 
 int WifiNetwork::setPsk(const char *psk) {
-    if (mSuppl->setNetworkVar(mNetid, "psk", psk))
+    char tmp[255];
+    snprintf(tmp, sizeof(tmp), "\"%s\"", psk);
+    if (mSuppl->setNetworkVar(mNetid, "psk", tmp))
         return -1;
 
     if (mPsk)
@@ -491,28 +341,34 @@
     return 0;
 }
 
-int WifiNetwork::setAllowedKeyManagement(uint32_t mask) {
-    char accum[255];
+int WifiNetwork::setKeyManagement(uint32_t mask) {
+    char accum[64] = {'\0'};
 
     if (mask == KeyManagementMask::NONE)
         strcpy(accum, "NONE");
     else {
-        if (mask & KeyManagementMask::WPA_PSK)
-            strcat(accum, "WPA_PSK ");
-        if (mask & KeyManagementMask::WPA_EAP)
-            strcat(accum, "WPA_EAP ");
-        if (mask & KeyManagementMask::IEEE8021X)
-            strcat(accum, "IEEE8021X ");
+        if (mask & KeyManagementMask::WPA_PSK) 
+            strcat(accum, "WPA-PSK");
+        if (mask & KeyManagementMask::WPA_EAP) {
+            if (accum[0] != '\0')
+                strcat(accum, " ");
+            strcat(accum, "WPA-EAP");
+        }
+        if (mask & KeyManagementMask::IEEE8021X) {
+            if (accum[0] != '\0')
+                strcat(accum, " ");
+            strcat(accum, "IEEE8021X");
+        }
     }
 
     if (mSuppl->setNetworkVar(mNetid, "key_mgmt", accum))
         return -1;
-    mAllowedKeyManagement = mask;
+    mKeyManagement = mask;
     return 0;
 }
 
-int WifiNetwork::setAllowedProtocols(uint32_t mask) {
-    char accum[255];
+int WifiNetwork::setProtocols(uint32_t mask) {
+    char accum[64];
 
     accum[0] = '\0';
 
@@ -524,15 +380,18 @@
 
     if (mSuppl->setNetworkVar(mNetid, "proto", accum))
         return -1;
-    mAllowedProtocols = mask;
+    mProtocols = mask;
     return 0;
 }
 
-int WifiNetwork::setAllowedAuthAlgorithms(uint32_t mask) {
-    char accum[255];
+int WifiNetwork::setAuthAlgorithms(uint32_t mask) {
+    char accum[64];
 
     accum[0] = '\0';
 
+    if (mask == 0)
+        strcpy(accum, "");
+
     if (mask & AuthenticationAlgorithmMask::OPEN)
         strcpy(accum, "OPEN ");
 
@@ -545,12 +404,14 @@
     if (mSuppl->setNetworkVar(mNetid, "auth_alg", accum))
         return -1;
 
-    mAllowedAuthAlgorithms = mask;
+    mAuthAlgorithms = mask;
     return 0;
 }
 
-int WifiNetwork::setAllowedPairwiseCiphers(uint32_t mask) {
-    char accum[255];
+int WifiNetwork::setPairwiseCiphers(uint32_t mask) {
+    char accum[64];
+
+    accum[0] = '\0';
 
     if (mask == PairwiseCiphersMask::NONE)
         strcpy(accum, "NONE");
@@ -564,12 +425,14 @@
     if (mSuppl->setNetworkVar(mNetid, "pairwise", accum))
         return -1;
 
-    mAllowedPairwiseCiphers = mask;
+    mPairwiseCiphers = mask;
     return 0;
 }
 
-int WifiNetwork::setAllowedGroupCiphers(uint32_t mask) {
-    char accum[255];
+int WifiNetwork::setGroupCiphers(uint32_t mask) {
+    char accum[64];
+
+    accum[0] = '\0';
 
     if (mask & GroupCiphersMask::WEP40)
         strcat(accum, "WEP40 ");
@@ -582,7 +445,7 @@
 
     if (mSuppl->setNetworkVar(mNetid, "group", accum))
         return -1;
-    mAllowedGroupCiphers = mask;
+    mGroupCiphers = mask;
     return 0;
 }
 
@@ -594,7 +457,7 @@
             errno = EAGAIN;
             return -1;
         }
-        if (getAllowedKeyManagement() == KeyManagementMask::UNKNOWN) {
+        if (getKeyManagement() == KeyManagementMask::UNKNOWN) {
             LOGE("Cannot enable network when KeyManagement is not set");
             errno = EAGAIN;
             return -1;
@@ -608,29 +471,500 @@
     return 0;
 }
 
-int WifiNetwork::registerProperties() {
-    for (const char **p = WifiNetwork::PropertyNames; *p != '\0'; p++) {
-        char *tmp;
-        asprintf(&tmp, "wifi.net.%d.%s", mNetid, *p);
-
-        if (NetworkManager::Instance()->getPropMngr()->registerProperty(tmp,
-                                                                        this)) {
-            free(tmp);
-            return -1;
-        }
-        free(tmp);
-    }
+int WifiNetwork::attachProperties(PropertyManager *pm, const char *nsName) {
+    pm->attachProperty(nsName, mStaticProperties.propSsid);
+    pm->attachProperty(nsName, mStaticProperties.propBssid);
+    pm->attachProperty(nsName, mStaticProperties.propPsk);
+    pm->attachProperty(nsName, mStaticProperties.propWepKey);
+    pm->attachProperty(nsName, mStaticProperties.propDefKeyIdx);
+    pm->attachProperty(nsName, mStaticProperties.propPriority);
+    pm->attachProperty(nsName, mStaticProperties.propKeyManagement);
+    pm->attachProperty(nsName, mStaticProperties.propProtocols);
+    pm->attachProperty(nsName, mStaticProperties.propAuthAlgorithms);
+    pm->attachProperty(nsName, mStaticProperties.propPairwiseCiphers);
+    pm->attachProperty(nsName, mStaticProperties.propGroupCiphers);
+    pm->attachProperty(nsName, mStaticProperties.propHiddenSsid);
+    pm->attachProperty(nsName, mStaticProperties.propEnabled);
     return 0;
 }
 
-int WifiNetwork::unregisterProperties() {
-    for (const char **p = WifiNetwork::PropertyNames; *p != '\0'; p++) {
-        char *tmp;
-        asprintf(&tmp, "wifi.net.%d.%s", mNetid, *p);
+int WifiNetwork::detachProperties(PropertyManager *pm, const char *nsName) {
+    pm->detachProperty(nsName, mStaticProperties.propEnabled);
+    pm->detachProperty(nsName, mStaticProperties.propSsid);
+    pm->detachProperty(nsName, mStaticProperties.propBssid);
+    pm->detachProperty(nsName, mStaticProperties.propPsk);
+    pm->detachProperty(nsName, mStaticProperties.propWepKey);
+    pm->detachProperty(nsName, mStaticProperties.propDefKeyIdx);
+    pm->detachProperty(nsName, mStaticProperties.propPriority);
+    pm->detachProperty(nsName, mStaticProperties.propKeyManagement);
+    pm->detachProperty(nsName, mStaticProperties.propProtocols);
+    pm->detachProperty(nsName, mStaticProperties.propAuthAlgorithms);
+    pm->detachProperty(nsName, mStaticProperties.propPairwiseCiphers);
+    pm->detachProperty(nsName, mStaticProperties.propGroupCiphers);
+    pm->detachProperty(nsName, mStaticProperties.propHiddenSsid);
+    return 0;
+}
 
-        if (NetworkManager::Instance()->getPropMngr()->unregisterProperty(tmp))
-            LOGW("Unable to remove property '%s' (%s)", tmp, strerror(errno));
-        free(tmp);
+int WifiNetwork::parseKeyManagementMask(const char *buffer, uint32_t *mask) {
+    bool none = false;
+    char *v_tmp = strdup(buffer);
+    char *v_next = v_tmp;
+    char *v_token;
+
+//    LOGD("parseKeyManagementMask(%s)", buffer);
+    *mask = 0;
+
+    while((v_token = strsep(&v_next, " "))) {
+        if (!strcasecmp(v_token, "NONE")) {
+            *mask = KeyManagementMask::NONE;
+            none = true;
+        } else if (!none) {
+            if (!strcasecmp(v_token, "WPA-PSK"))
+                *mask |= KeyManagementMask::WPA_PSK;
+            else if (!strcasecmp(v_token, "WPA-EAP"))
+                *mask |= KeyManagementMask::WPA_EAP;
+            else if (!strcasecmp(v_token, "IEEE8021X"))
+                *mask |= KeyManagementMask::IEEE8021X;
+            else {
+                LOGW("Invalid KeyManagementMask value '%s'", v_token);
+                errno = EINVAL;
+                free(v_tmp);
+                return -1;
+            }
+        } else {
+            LOGW("KeyManagementMask value '%s' when NONE", v_token);
+            errno = EINVAL;
+            free(v_tmp);
+            return -1;
+        }
+    }
+    free(v_tmp);
+    return 0;
+}
+
+int WifiNetwork::parseProtocolsMask(const char *buffer, uint32_t *mask) {
+    bool none = false;
+    char *v_tmp = strdup(buffer);
+    char *v_next = v_tmp;
+    char *v_token;
+
+//    LOGD("parseProtocolsMask(%s)", buffer);
+    *mask = 0;
+    while((v_token = strsep(&v_next, " "))) {
+        if (!strcasecmp(v_token, "WPA"))
+            *mask |= SecurityProtocolMask::WPA;
+        else if (!strcasecmp(v_token, "RSN"))
+            *mask |= SecurityProtocolMask::RSN;
+        else {
+            LOGW("Invalid ProtocolsMask value '%s'", v_token);
+            errno = EINVAL;
+            free(v_tmp);
+            return -1;
+        }
+    }
+
+    free(v_tmp);
+    return 0;
+}
+
+int WifiNetwork::parseAuthAlgorithmsMask(const char *buffer, uint32_t *mask) {
+    bool none = false;
+    char *v_tmp = strdup(buffer);
+    char *v_next = v_tmp;
+    char *v_token;
+
+//    LOGD("parseAuthAlgorithmsMask(%s)", buffer);
+
+    *mask = 0;
+    if (buffer[0] == '\0')
+        return 0;
+
+    while((v_token = strsep(&v_next, " "))) {
+        if (!strcasecmp(v_token, "OPEN"))
+            *mask |= AuthenticationAlgorithmMask::OPEN;
+        else if (!strcasecmp(v_token, "SHARED"))
+            *mask |= AuthenticationAlgorithmMask::SHARED;
+        else if (!strcasecmp(v_token, "LEAP"))
+            *mask |= AuthenticationAlgorithmMask::LEAP;
+        else {
+            LOGW("Invalid AuthAlgorithmsMask value '%s'", v_token);
+            errno = EINVAL;
+            free(v_tmp);
+            return -1;
+        }
+    }
+    free(v_tmp);
+    return 0;
+}
+
+int WifiNetwork::parsePairwiseCiphersMask(const char *buffer, uint32_t *mask) {
+    bool none = false;
+    char *v_tmp = strdup(buffer);
+    char *v_next = v_tmp;
+    char *v_token;
+
+//    LOGD("parsePairwiseCiphersMask(%s)", buffer);
+
+    *mask = 0;
+    while((v_token = strsep(&v_next, " "))) {
+        if (!strcasecmp(v_token, "NONE")) {
+            *mask = PairwiseCiphersMask::NONE;
+            none = true;
+        } else if (!none) {
+            if (!strcasecmp(v_token, "TKIP"))
+                *mask |= PairwiseCiphersMask::TKIP;
+            else if (!strcasecmp(v_token, "CCMP"))
+                *mask |= PairwiseCiphersMask::CCMP;
+        else {
+                LOGW("PairwiseCiphersMask value '%s' when NONE", v_token);
+                errno = EINVAL;
+                free(v_tmp);
+                return -1;
+            }
+        } else {
+            LOGW("Invalid PairwiseCiphersMask value '%s'", v_token);
+            errno = EINVAL;
+            free(v_tmp);
+            return -1;
+        }
+    }
+    free(v_tmp);
+    return 0;
+}
+
+int WifiNetwork::parseGroupCiphersMask(const char *buffer, uint32_t *mask) {
+    bool none = false;
+    char *v_tmp = strdup(buffer);
+    char *v_next = v_tmp;
+    char *v_token;
+
+//    LOGD("parseGroupCiphersMask(%s)", buffer);
+
+    *mask = 0;
+    while((v_token = strsep(&v_next, " "))) {
+        if (!strcasecmp(v_token, "WEP40"))
+            *mask |= GroupCiphersMask::WEP40;
+        else if (!strcasecmp(v_token, "WEP104"))
+            *mask |= GroupCiphersMask::WEP104;
+        else if (!strcasecmp(v_token, "TKIP"))
+            *mask |= GroupCiphersMask::TKIP;
+        else if (!strcasecmp(v_token, "CCMP"))
+            *mask |= GroupCiphersMask::CCMP;
+        else {
+            LOGW("Invalid GroupCiphersMask value '%s'", v_token);
+            errno = EINVAL;
+            free(v_tmp);
+            return -1;
+        }
+    }
+    free(v_tmp);
+    return 0;
+}
+
+WifiNetwork::WifiNetworkIntegerProperty::WifiNetworkIntegerProperty(WifiNetwork *wn,
+                                                      const char *name,
+                                                      bool ro,
+                                                      int elements) :
+             IntegerProperty(name, ro, elements) {
+    mWn = wn;
+}
+
+WifiNetwork::WifiNetworkStringProperty::WifiNetworkStringProperty(WifiNetwork *wn,
+                                                                  const char *name,
+                                                              bool ro, int elements) :
+             StringProperty(name, ro, elements) {
+    mWn = wn;
+}
+
+WifiNetwork::WifiNetworkEnabledProperty::WifiNetworkEnabledProperty(WifiNetwork *wn) :
+                WifiNetworkIntegerProperty(wn, "Enabled", false, 1) {
+}
+
+int WifiNetwork::WifiNetworkEnabledProperty::get(int idx, int *buffer) {
+    *buffer = mWn->mEnabled;
+    return 0;
+}
+int WifiNetwork::WifiNetworkEnabledProperty::set(int idx, int value) {
+    return mWn->setEnabled(value == 1);
+}
+
+WifiNetwork::WifiNetworkSsidProperty::WifiNetworkSsidProperty(WifiNetwork *wn) :
+                WifiNetworkStringProperty(wn, "Ssid", false, 1) {
+}
+
+int WifiNetwork::WifiNetworkSsidProperty::get(int idx, char *buffer, size_t max) {
+    strncpy(buffer,
+            mWn->getSsid() ? mWn->getSsid() : "none",
+            max);
+    return 0;
+}
+int WifiNetwork::WifiNetworkSsidProperty::set(int idx, const char *value) {
+    return mWn->setSsid(value);
+}
+
+WifiNetwork::WifiNetworkBssidProperty::WifiNetworkBssidProperty(WifiNetwork *wn) :
+                WifiNetworkStringProperty(wn, "Bssid", false, 1) {
+}
+int WifiNetwork::WifiNetworkBssidProperty::get(int idx, char *buffer, size_t max) {
+    strncpy(buffer,
+            mWn->getBssid() ? mWn->getBssid() : "none",
+            max);
+    return 0;
+}
+int WifiNetwork::WifiNetworkBssidProperty::set(int idx, const char *value) {
+    return mWn->setBssid(value);
+}
+
+WifiNetwork::WifiNetworkPskProperty::WifiNetworkPskProperty(WifiNetwork *wn) :
+                WifiNetworkStringProperty(wn, "Psk", false, 1) {
+}
+int WifiNetwork::WifiNetworkPskProperty::get(int idx, char *buffer, size_t max) {
+    strncpy(buffer,
+            mWn->getPsk() ? mWn->getPsk() : "none",
+            max);
+    return 0;
+}
+int WifiNetwork::WifiNetworkPskProperty::set(int idx, const char *value) {
+    return mWn->setPsk(value);
+}
+
+WifiNetwork::WifiNetworkWepKeyProperty::WifiNetworkWepKeyProperty(WifiNetwork *wn) :
+                WifiNetworkStringProperty(wn, "WepKey", false, 4) {
+}
+
+int WifiNetwork::WifiNetworkWepKeyProperty::get(int idx, char *buffer, size_t max) {
+    const char *key = mWn->getWepKey(idx);
+
+    strncpy(buffer, (key ? key : "none"), max);
+    return 0;
+}
+int WifiNetwork::WifiNetworkWepKeyProperty::set(int idx, const char *value) {
+    return mWn->setWepKey(idx, value);
+}
+
+WifiNetwork::WifiNetworkDefaultKeyIndexProperty::WifiNetworkDefaultKeyIndexProperty(WifiNetwork *wn) :
+                WifiNetworkIntegerProperty(wn, "DefaultKeyIndex", false,  1) {
+}
+int WifiNetwork::WifiNetworkDefaultKeyIndexProperty::get(int idx, int *buffer) {
+    *buffer = mWn->getDefaultKeyIndex();
+    return 0;
+}
+int WifiNetwork::WifiNetworkDefaultKeyIndexProperty::set(int idx, int value) {
+    return mWn->setDefaultKeyIndex(value);
+}
+
+WifiNetwork::WifiNetworkPriorityProperty::WifiNetworkPriorityProperty(WifiNetwork *wn) :
+                WifiNetworkIntegerProperty(wn, "Priority", false, 1) {
+}
+int WifiNetwork::WifiNetworkPriorityProperty::get(int idx, int *buffer) {
+    *buffer = mWn->getPriority();
+    return 0;
+}
+int WifiNetwork::WifiNetworkPriorityProperty::set(int idx, int value) {
+    return mWn->setPriority(value);
+}
+
+WifiNetwork::WifiNetworkKeyManagementProperty::WifiNetworkKeyManagementProperty(WifiNetwork *wn) :
+                WifiNetworkStringProperty(wn, "KeyManagement", false, 1) {
+}
+int WifiNetwork::WifiNetworkKeyManagementProperty::get(int idx, char *buffer, size_t max) {
+
+    if (mWn->getKeyManagement() == KeyManagementMask::NONE)
+        strncpy(buffer, "NONE", max);
+    else {
+        char tmp[80] = { '\0' };
+
+        if (mWn->getKeyManagement() & KeyManagementMask::WPA_PSK)
+            strcat(tmp, "WPA-PSK");
+        if (mWn->getKeyManagement() & KeyManagementMask::WPA_EAP) {
+            if (tmp[0] != '\0')
+                strcat(tmp, " ");
+            strcat(tmp, "WPA-EAP");
+        }
+        if (mWn->getKeyManagement() & KeyManagementMask::IEEE8021X) {
+            if (tmp[0] != '\0')
+                strcat(tmp, " ");
+            strcat(tmp, "IEEE8021X");
+        }
+        if (tmp[0] == '\0') {
+            strncpy(buffer, "(internal error)", max);
+            errno = ENOENT;
+            return -1;
+        }
+        if (tmp[strlen(tmp)] == ' ')
+            tmp[strlen(tmp)] = '\0';
+
+        strncpy(buffer, tmp, max);
     }
     return 0;
 }
+int WifiNetwork::WifiNetworkKeyManagementProperty::set(int idx, const char *value) {
+    uint32_t mask;
+    if (mWn->parseKeyManagementMask(value, &mask))
+        return -1;
+    return mWn->setKeyManagement(mask);
+}
+
+WifiNetwork::WifiNetworkProtocolsProperty::WifiNetworkProtocolsProperty(WifiNetwork *wn) :
+                WifiNetworkStringProperty(wn, "Protocols", false, 1) {
+}
+int WifiNetwork::WifiNetworkProtocolsProperty::get(int idx, char *buffer, size_t max) {
+    char tmp[80] = { '\0' };
+
+    if (mWn->getProtocols() & SecurityProtocolMask::WPA)
+        strcat(tmp, "WPA");
+    if (mWn->getProtocols() & SecurityProtocolMask::RSN) {
+        if (tmp[0] != '\0')
+            strcat(tmp, " ");
+        strcat(tmp, "RSN");
+    }
+
+    if (tmp[0] == '\0') {
+        strncpy(buffer, "(internal error)", max);
+        errno = ENOENT;
+        return NULL;
+    }
+    if (tmp[strlen(tmp)] == ' ')
+        tmp[strlen(tmp)] = '\0';
+
+    strncpy(buffer, tmp, max);
+    return 0;
+}
+int WifiNetwork::WifiNetworkProtocolsProperty::set(int idx, const char *value) {
+    uint32_t mask;
+    if (mWn->parseProtocolsMask(value, &mask))
+        return -1;
+    return mWn->setProtocols(mask);
+}
+
+WifiNetwork::WifiNetworkAuthAlgorithmsProperty::WifiNetworkAuthAlgorithmsProperty(WifiNetwork *wn) :
+                WifiNetworkStringProperty(wn, "AuthAlgorithms", false, 1) {
+}
+int WifiNetwork::WifiNetworkAuthAlgorithmsProperty::get(int idx, char *buffer, size_t max) {
+    char tmp[80] = { '\0' };
+
+    if (mWn->getAuthAlgorithms() == 0) {
+        strncpy(buffer, "NONE", max);
+        return 0;
+    }
+
+    if (mWn->getAuthAlgorithms() & AuthenticationAlgorithmMask::OPEN)
+        strcat(tmp, "OPEN");
+    if (mWn->getAuthAlgorithms() & AuthenticationAlgorithmMask::SHARED) {
+        if (tmp[0] != '\0')
+            strcat(tmp, " ");
+        strcat(tmp, "SHARED");
+    }
+    if (mWn->getAuthAlgorithms() & AuthenticationAlgorithmMask::LEAP) {
+        if (tmp[0] != '\0')
+            strcat(tmp, " ");
+        strcat(tmp, "LEAP");
+    }
+
+    if (tmp[0] == '\0') {
+        strncpy(buffer, "(internal error)", max);
+        errno = ENOENT;
+        return NULL;
+    }
+    if (tmp[strlen(tmp)] == ' ')
+        tmp[strlen(tmp)] = '\0';
+
+    strncpy(buffer, tmp, max);
+    return 0;
+}
+int WifiNetwork::WifiNetworkAuthAlgorithmsProperty::set(int idx, const char *value) {
+    uint32_t mask;
+    if (mWn->parseAuthAlgorithmsMask(value, &mask))
+        return -1;
+    return mWn->setAuthAlgorithms(mask);
+}
+
+WifiNetwork::WifiNetworkPairwiseCiphersProperty::WifiNetworkPairwiseCiphersProperty(WifiNetwork *wn) :
+                WifiNetworkStringProperty(wn, "PairwiseCiphers", false, 1) {
+}
+int WifiNetwork::WifiNetworkPairwiseCiphersProperty::get(int idx, char *buffer, size_t max) {
+    if (mWn->getPairwiseCiphers() == PairwiseCiphersMask::NONE)
+        strncpy(buffer, "NONE", max);
+    else {
+        char tmp[80] = { '\0' };
+
+        if (mWn->getPairwiseCiphers() & PairwiseCiphersMask::TKIP)
+            strcat(tmp, "TKIP");
+        if (mWn->getPairwiseCiphers() & PairwiseCiphersMask::CCMP) {
+            if (tmp[0] != '\0')
+                strcat(tmp, " ");
+            strcat(tmp, "CCMP");
+        }
+        if (tmp[0] == '\0') {
+            strncpy(buffer, "(internal error)", max);
+            errno = ENOENT;
+            return NULL;
+        }
+        if (tmp[strlen(tmp)] == ' ')
+            tmp[strlen(tmp)] = '\0';
+
+        strncpy(buffer, tmp, max);
+    }
+    return 0;
+}
+int WifiNetwork::WifiNetworkPairwiseCiphersProperty::set(int idx, const char *value) {
+    uint32_t mask;
+    if (mWn->parsePairwiseCiphersMask(value, &mask))
+        return -1;
+    return mWn->setPairwiseCiphers(mask);
+}
+
+WifiNetwork::WifiNetworkGroupCiphersProperty::WifiNetworkGroupCiphersProperty(WifiNetwork *wn) :
+                WifiNetworkStringProperty(wn, "GroupCiphers", false, 1) {
+}
+int WifiNetwork::WifiNetworkGroupCiphersProperty::get(int idx, char *buffer, size_t max) {
+   char tmp[80] = { '\0' };
+
+    if (mWn->getGroupCiphers() & GroupCiphersMask::WEP40)
+        strcat(tmp, "WEP40");
+    if (mWn->getGroupCiphers() & GroupCiphersMask::WEP104) {
+        if (tmp[0] != '\0')
+            strcat(tmp, " ");
+        strcat(tmp, "WEP104");
+    }
+    if (mWn->getGroupCiphers() & GroupCiphersMask::TKIP) {
+        if (tmp[0] != '\0')
+            strcat(tmp, " ");
+        strcat(tmp, "TKIP");
+    }
+    if (mWn->getGroupCiphers() & GroupCiphersMask::CCMP) {
+        if (tmp[0] != '\0')
+            strcat(tmp, " ");
+        strcat(tmp, "CCMP");
+    }
+
+    if (tmp[0] == '\0') {
+        strncpy(buffer, "(internal error)", max);
+        errno = ENOENT;
+        return -1;
+    }
+    if (tmp[strlen(tmp)] == ' ')
+        tmp[strlen(tmp)] = '\0';
+
+    strncpy(buffer, tmp, max);
+    return 0;
+}
+int WifiNetwork::WifiNetworkGroupCiphersProperty::set(int idx, const char *value) {
+    uint32_t mask;
+    if (mWn->parseGroupCiphersMask(value, &mask))
+        return -1;
+    return mWn->setGroupCiphers(mask);
+}
+
+WifiNetwork::WifiNetworkHiddenSsidProperty::WifiNetworkHiddenSsidProperty(WifiNetwork *wn) :
+                WifiNetworkStringProperty(wn, "HiddenSsid", false, 1) {
+}
+int WifiNetwork::WifiNetworkHiddenSsidProperty::get(int idx, char *buffer, size_t max) {
+    const char *scan_ssid = mWn->getHiddenSsid();
+    
+    strncpy(buffer, (scan_ssid ? scan_ssid : "none"), max);
+    return 0;
+}
+int WifiNetwork::WifiNetworkHiddenSsidProperty::set(int idx, const char *value) {
+    return mWn->setHiddenSsid(value);
+}
diff --git a/nexus/WifiNetwork.h b/nexus/WifiNetwork.h
index c2f5d23..15ec647 100644
--- a/nexus/WifiNetwork.h
+++ b/nexus/WifiNetwork.h
@@ -21,6 +21,10 @@
 
 #include <utils/List.h>
 
+#include "Property.h"
+
+class PropertyManager;
+
 class KeyManagementMask {
 public:
     static const uint32_t UNKNOWN   = 0;
@@ -60,19 +64,140 @@
 };
 
 class Supplicant;
-class InterfaceConfig;
 class Controller;
 class WifiController;
 
-#include "IPropertyProvider.h"
+class WifiNetwork {
+    class WifiNetworkIntegerProperty : public IntegerProperty {
+    protected:
+        WifiNetwork *mWn;
+    public:
+        WifiNetworkIntegerProperty(WifiNetwork *wn, const char *name, bool ro,
+                                   int elements);
+        virtual ~WifiNetworkIntegerProperty() {}
+        virtual int set(int idx, int value) = 0;
+        virtual int get(int idx, int *buffer) = 0;
+    };
+    friend class WifiNetwork::WifiNetworkIntegerProperty;
 
-class WifiNetwork : public IPropertyProvider{
-public:
-    static const char *PropertyNames[];
+    class WifiNetworkStringProperty : public StringProperty {
+    protected:
+        WifiNetwork *mWn;
+    public:
+        WifiNetworkStringProperty(WifiNetwork *wn, const char *name, bool ro,
+                                 int elements);
+        virtual ~WifiNetworkStringProperty() {}
+        virtual int set(int idx, const char *value) = 0;
+        virtual int get(int idx, char *buffer, size_t max) = 0;
+    };
+    friend class WifiNetwork::WifiNetworkStringProperty;
+
+    class WifiNetworkEnabledProperty : public WifiNetworkIntegerProperty {
+    public:
+        WifiNetworkEnabledProperty(WifiNetwork *wn);
+        virtual ~WifiNetworkEnabledProperty() {};
+        int set(int idx, int value);
+        int get(int idx, int *buffer);
+    };
+
+    class WifiNetworkPriorityProperty : public WifiNetworkIntegerProperty {
+    public:
+        WifiNetworkPriorityProperty(WifiNetwork *wn);
+        virtual ~WifiNetworkPriorityProperty() {};
+        int set(int idx, int value);
+        int get(int idx, int *buffer);
+    };
+
+    class WifiNetworkDefaultKeyIndexProperty : public WifiNetworkIntegerProperty {
+    public:
+        WifiNetworkDefaultKeyIndexProperty(WifiNetwork *wn);
+        virtual ~WifiNetworkDefaultKeyIndexProperty() {};
+        int set(int idx, int value);
+        int get(int idx, int *buffer);
+    };
+
+    class WifiNetworkSsidProperty : public WifiNetworkStringProperty {
+    public:
+        WifiNetworkSsidProperty(WifiNetwork *wn);
+        virtual ~WifiNetworkSsidProperty() {};
+        int set(int idx, const char *value);
+        int get(int idx, char *buffer, size_t max);
+    };
+
+    class WifiNetworkBssidProperty : public WifiNetworkStringProperty {
+    public:
+        WifiNetworkBssidProperty(WifiNetwork *wn);
+        virtual ~WifiNetworkBssidProperty() {};
+        int set(int idx, const char *value);
+        int get(int idx, char *buffer, size_t max);
+    };
+
+    class WifiNetworkPskProperty : public WifiNetworkStringProperty {
+    public:
+        WifiNetworkPskProperty(WifiNetwork *wn);
+        virtual ~WifiNetworkPskProperty() {};
+        int set(int idx, const char *value);
+        int get(int idx, char *buffer, size_t max);
+    };
+
+    class WifiNetworkKeyManagementProperty : public WifiNetworkStringProperty {
+    public:
+        WifiNetworkKeyManagementProperty(WifiNetwork *wn);
+        virtual ~WifiNetworkKeyManagementProperty() {};
+        int set(int idx, const char *value);
+        int get(int idx, char *buffer, size_t max);
+    };
+
+    class WifiNetworkAuthAlgorithmsProperty : public WifiNetworkStringProperty {
+    public:
+        WifiNetworkAuthAlgorithmsProperty(WifiNetwork *wn);
+        virtual ~WifiNetworkAuthAlgorithmsProperty() {};
+        int set(int idx, const char *value);
+        int get(int idx, char *buffer, size_t max);
+    };
+
+    class WifiNetworkProtocolsProperty : public WifiNetworkStringProperty {
+    public:
+        WifiNetworkProtocolsProperty(WifiNetwork *wn);
+        virtual ~WifiNetworkProtocolsProperty() {};
+        int set(int idx, const char *value);
+        int get(int idx, char *buffer, size_t max);
+    };
+
+    class WifiNetworkWepKeyProperty : public WifiNetworkStringProperty {
+    public:
+        WifiNetworkWepKeyProperty(WifiNetwork *wn);
+        virtual ~WifiNetworkWepKeyProperty() {};
+        int set(int idx, const char *value);
+        int get(int idx, char *buffer, size_t max);
+    };
+
+    class WifiNetworkPairwiseCiphersProperty : public WifiNetworkStringProperty {
+    public:
+        WifiNetworkPairwiseCiphersProperty(WifiNetwork *wn);
+        virtual ~WifiNetworkPairwiseCiphersProperty() {};
+        int set(int idx, const char *value);
+        int get(int idx, char *buffer, size_t max);
+    };
+
+    class WifiNetworkGroupCiphersProperty : public WifiNetworkStringProperty {
+    public:
+        WifiNetworkGroupCiphersProperty(WifiNetwork *wn);
+        virtual ~WifiNetworkGroupCiphersProperty() {};
+        int set(int idx, const char *value);
+        int get(int idx, char *buffer, size_t max);
+    };
+
+    class WifiNetworkHiddenSsidProperty : public WifiNetworkStringProperty {
+    public:
+        WifiNetworkHiddenSsidProperty(WifiNetwork *wn);
+        virtual ~WifiNetworkHiddenSsidProperty() {};
+        int set(int idx, const char *value);
+        int get(int idx, char *buffer, size_t max);
+    };
 
 private:
     Supplicant *mSuppl;
-    InterfaceConfig *mIfaceCfg;
     WifiController *mController;
 
     /*
@@ -128,33 +253,49 @@
     /*
      * The set of key management protocols supported by this configuration.
      */
-    uint32_t mAllowedKeyManagement;
+    uint32_t mKeyManagement;
 
     /*
      * The set of security protocols supported by this configuration.
      */
-    uint32_t mAllowedProtocols;
+    uint32_t mProtocols;
 
     /*
      * The set of authentication protocols supported by this configuration.
      */
-    uint32_t mAllowedAuthAlgorithms;
+    uint32_t mAuthAlgorithms;
 
     /*
      * The set of pairwise ciphers for WPA supported by this configuration.
      */
-    uint32_t mAllowedPairwiseCiphers;
+    uint32_t mPairwiseCiphers;
 
     /*
      * The set of group ciphers for WPA supported by this configuration.
      */
-    uint32_t mAllowedGroupCiphers;
+    uint32_t mGroupCiphers;
 
     /*
      * Set if this Network is enabled
      */
     bool mEnabled;
 
+    char *mPropNamespace;
+    struct {
+        WifiNetworkEnabledProperty               *propEnabled;
+        WifiNetworkSsidProperty                  *propSsid;
+        WifiNetworkBssidProperty                 *propBssid;
+        WifiNetworkPskProperty                   *propPsk;
+        WifiNetworkWepKeyProperty                *propWepKey;
+        WifiNetworkDefaultKeyIndexProperty       *propDefKeyIdx;
+        WifiNetworkPriorityProperty              *propPriority;
+        WifiNetworkKeyManagementProperty  *propKeyManagement;
+        WifiNetworkProtocolsProperty      *propProtocols;
+        WifiNetworkAuthAlgorithmsProperty *propAuthAlgorithms;
+        WifiNetworkPairwiseCiphersProperty       *propPairwiseCiphers;
+        WifiNetworkGroupCiphersProperty          *propGroupCiphers;
+        WifiNetworkHiddenSsidProperty            *propHiddenSsid;
+    } mStaticProperties;
 private:
     WifiNetwork();
 
@@ -165,8 +306,8 @@
     virtual ~WifiNetwork();
 
     WifiNetwork *clone();
-    int registerProperties();
-    int unregisterProperties();
+    int attachProperties(PropertyManager *pm, const char *nsName);
+    int detachProperties(PropertyManager *pm, const char *nsName);
 
     int getNetworkId() { return mNetid; }
     const char *getSsid() { return mSsid; }
@@ -176,19 +317,14 @@
     int getDefaultKeyIndex() { return mDefaultKeyIndex; }
     int getPriority() { return mPriority; }
     const char *getHiddenSsid() { return mHiddenSsid; }
-    uint32_t getAllowedKeyManagement() { return mAllowedKeyManagement; }
-    uint32_t getAllowedProtocols() { return mAllowedProtocols; }
-    uint32_t getAllowedAuthAlgorithms() { return mAllowedAuthAlgorithms; }
-    uint32_t getAllowedPairwiseCiphers() { return mAllowedPairwiseCiphers; }
-    uint32_t getAllowedGroupCiphers() { return mAllowedGroupCiphers; }
+    uint32_t getKeyManagement() { return mKeyManagement; }
+    uint32_t getProtocols() { return mProtocols; }
+    uint32_t getAuthAlgorithms() { return mAuthAlgorithms; }
+    uint32_t getPairwiseCiphers() { return mPairwiseCiphers; }
+    uint32_t getGroupCiphers() { return mGroupCiphers; }
     bool getEnabled() { return mEnabled; }
     Controller *getController() { return (Controller *) mController; }
 
-    int set(const char *name, const char *value);
-    const char *get(const char *name, char *buffer, size_t maxsize);
-
-    InterfaceConfig *getIfaceCfg() { return mIfaceCfg; }
-
     int setEnabled(bool enabled);
     int setSsid(const char *ssid);
     int setBssid(const char *bssid);
@@ -197,14 +333,22 @@
     int setDefaultKeyIndex(int idx);
     int setPriority(int pri);
     int setHiddenSsid(const char *ssid);
-    int setAllowedKeyManagement(uint32_t mask);
-    int setAllowedProtocols(uint32_t mask);
-    int setAllowedAuthAlgorithms(uint32_t mask);
-    int setAllowedPairwiseCiphers(uint32_t mask);
-    int setAllowedGroupCiphers(uint32_t mask);
+    int setKeyManagement(uint32_t mask);
+    int setProtocols(uint32_t mask);
+    int setAuthAlgorithms(uint32_t mask);
+    int setPairwiseCiphers(uint32_t mask);
+    int setGroupCiphers(uint32_t mask);
 
     // XXX:Should this really be exposed?.. meh
     int refresh();
+
+private:
+    int parseKeyManagementMask(const char *buffer, uint32_t *mask);
+    int parseProtocolsMask(const char *buffer, uint32_t *mask);
+    int parseAuthAlgorithmsMask(const char *buffer, uint32_t *mask);
+    int parsePairwiseCiphersMask(const char *buffer, uint32_t *mask);
+    int parseGroupCiphersMask(const char *buffer, uint32_t *mask);
+    void createProperties();
 };
 
 typedef android::List<WifiNetwork *> WifiNetworkCollection;
diff --git a/nexus/WifiStatusPoller.cpp b/nexus/WifiStatusPoller.cpp
new file mode 100644
index 0000000..cf71733
--- /dev/null
+++ b/nexus/WifiStatusPoller.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <sys/select.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/un.h>
+
+#define LOG_TAG "WifiStatusPoller"
+#include <cutils/log.h>
+
+#include "WifiStatusPoller.h"
+#include "IWifiStatusPollerHandler.h"
+
+
+WifiStatusPoller::WifiStatusPoller(IWifiStatusPollerHandler *handler) :
+                  mHandlers(handler) {
+    mPollingInterval = 5;
+    mStarted = false;
+}
+
+int WifiStatusPoller::start() {
+
+    if (pipe(mCtrlPipe))
+        return -1;
+
+    if (pthread_create(&mThread, NULL, WifiStatusPoller::threadStart, this))
+        return -1;
+
+    return 0;
+}
+
+int WifiStatusPoller::stop() {
+    char c = 0;
+
+    if (write(mCtrlPipe[1], &c, 1) != 1) {
+        LOGE("Error writing to control pipe (%s)", strerror(errno));
+        return -1;
+    }
+
+    void *ret;
+    if (pthread_join(mThread, &ret)) {
+        LOGE("Error joining to listener thread (%s)", strerror(errno));
+        return -1;
+    }
+    close(mCtrlPipe[0]);
+    close(mCtrlPipe[1]);
+    return 0;
+}
+
+void *WifiStatusPoller::threadStart(void *obj) {
+    WifiStatusPoller *me = reinterpret_cast<WifiStatusPoller *>(obj);
+
+    me->mStarted = true;
+    LOGD("Starting");
+    me->run();
+    me->mStarted = false;
+    LOGD("Stopping");
+    pthread_exit(NULL);
+    return NULL;
+}
+
+void WifiStatusPoller::run() {
+
+    while(1) {
+        struct timeval to;
+        fd_set read_fds;
+        int rc = 0;
+        int max = 0;
+
+        FD_ZERO(&read_fds);
+        to.tv_usec = 0;
+        to.tv_sec = mPollingInterval;
+
+        FD_SET(mCtrlPipe[0], &read_fds);
+        max = mCtrlPipe[0];
+
+        if ((rc = select(max + 1, &read_fds, NULL, NULL, &to)) < 0) {
+            LOGE("select failed (%s)", strerror(errno));
+            sleep(1);
+            continue;
+        } else if (!rc) {
+            mHandlers->onStatusPollInterval();
+        }
+        if (FD_ISSET(mCtrlPipe[0], &read_fds))
+            break;
+    }
+}
diff --git a/nexus/WifiStatusPoller.h b/nexus/WifiStatusPoller.h
new file mode 100644
index 0000000..202bbbf
--- /dev/null
+++ b/nexus/WifiStatusPoller.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _WIFI_STATUS_POLLER_H
+#define _WIFI_STATUS_POLLER_H
+
+#include <pthread.h>
+
+class IWifiStatusPollerHandler;
+
+class WifiStatusPoller {
+    pthread_t                mThread;
+    int                      mCtrlPipe[2];
+    int                      mPollingInterval;
+    IWifiStatusPollerHandler *mHandlers;
+    bool                     mStarted;
+
+public:
+    WifiStatusPoller(IWifiStatusPollerHandler *handler);
+    virtual ~WifiStatusPoller() {}
+
+    int start();
+    int stop();
+    bool isStarted() { return mStarted; }
+
+    void setPollingInterval(int interval);
+    int getPollingInterval() { return mPollingInterval; }
+    
+private:
+    static void *threadStart(void *obj);
+    void run();
+};
+
+#endif
diff --git a/rootdir/init.rc b/rootdir/init.rc
index dab9027..799995a 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -23,6 +23,7 @@
     mkdir /system
     mkdir /data 0771 system system
     mkdir /cache 0770 system cache
+    mkdir /config 0500 root root
     mkdir /sqlite_stmt_journals 01777 root root
     mount tmpfs tmpfs /sqlite_stmt_journals size=4m
 
@@ -74,7 +75,7 @@
 
 # create basic filesystem structure
     mkdir /data/misc 01771 system misc
-    mkdir /data/misc/hcid 0770 bluetooth bluetooth
+    mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
     mkdir /data/misc/keystore 0770 keystore keystore
     mkdir /data/misc/vpn 0770 system system
     mkdir /data/misc/vpn/profiles 0770 system system
@@ -259,16 +260,18 @@
     disabled
     oneshot
 
-service dbus /system/bin/dbus-daemon --system --nofork
+#STOPSHIP: Remove logwrapper before production
+service dbus /system/bin/logwrapper /system/bin/dbus-daemon --system --nofork
     socket dbus stream 660 bluetooth bluetooth
     user bluetooth
     group bluetooth net_bt_admin
 
-service hcid /system/bin/hcid -s -n -f /etc/bluez/hcid.conf
+#STOPSHIP: Remove logwrapper and -d option before production
+service bluetoothd /system/bin/logwrapper /system/bin/bluetoothd -d -n
     socket bluetooth stream 660 bluetooth bluetooth
     socket dbus_bluetooth stream 660 bluetooth bluetooth
     # init.rc does not yet support applying capabilities, so run as root and
-    # let hcid drop uid to bluetooth with the right linux capabilities
+    # let bluetoothd drop uid to bluetooth with the right linux capabilities
     group bluetooth net_bt_admin misc
     disabled
 
diff --git a/toolbox/ls.c b/toolbox/ls.c
index f609df21..087e4d5 100644
--- a/toolbox/ls.c
+++ b/toolbox/ls.c
@@ -15,9 +15,10 @@
 #include <linux/kdev_t.h>
 
 // bits for flags argument
-#define LIST_LONG       (1 << 0)
-#define LIST_ALL        (1 << 1)
-#define LIST_RECURSIVE  (1 << 2)
+#define LIST_LONG           (1 << 0)
+#define LIST_ALL            (1 << 1)
+#define LIST_RECURSIVE      (1 << 2)
+#define LIST_DIRECTORIES    (1 << 3)
 
 // fwd
 static int listpath(const char *name, int flags);
@@ -238,7 +239,7 @@
         return -1;
     }
 
-    if (S_ISDIR(s.st_mode)) {
+    if ((flags & LIST_DIRECTORIES) == 0 && S_ISDIR(s.st_mode)) {
         if (flags & LIST_RECURSIVE)
             printf("\n%s:\n", name);
         return listdir(name, flags);
@@ -269,6 +270,8 @@
                 flags |= LIST_ALL;
             } else if (!strcmp(argv[i], "-R")) {
                 flags |= LIST_RECURSIVE;
+            } else if (!strcmp(argv[i], "-d")) {
+                flags |= LIST_DIRECTORIES;
             } else {
                 listed++;
                 if(listpath(argv[i], flags) != 0) {
diff --git a/toolbox/mount.c b/toolbox/mount.c
index 86047a9..472c952 100644
--- a/toolbox/mount.c
+++ b/toolbox/mount.c
@@ -138,14 +138,17 @@
 
     if (loop) {
         int file_fd, device_fd;
+        int flags;
+
+        flags = (rwflag & MS_RDONLY) ? O_RDONLY : O_RDWR;
         
         // FIXME - only one loop mount supported at a time
-        file_fd = open(dev, O_RDWR);
+        file_fd = open(dev, flags);
         if (file_fd < -1) {
             perror("open backing file failed");
             return 1;
         }
-        device_fd = open(LOOP_DEVICE, O_RDWR);
+        device_fd = open(LOOP_DEVICE, flags);
         if (device_fd < -1) {
             perror("open loop device failed");
             close(file_fd);
diff --git a/toolbox/smd.c b/toolbox/smd.c
index 65ff994e..91e495c 100644
--- a/toolbox/smd.c
+++ b/toolbox/smd.c
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
 #include <errno.h>
diff --git a/vold/mmc.c b/vold/mmc.c
index 0f08964..fb61b2f 100644
--- a/vold/mmc.c
+++ b/vold/mmc.c
@@ -250,7 +250,7 @@
     char filename[255];
     char *uevent_buffer;
     ssize_t sz;
-    char *uevent_params[4];
+    char *uevent_params[5];
     char tmp[255];
     FILE *fp;
     char line[255];
