diff --git a/include/hardware/qemu_pipe.h b/include/hardware/qemu_pipe.h
deleted file mode 100644
index 53aec97..0000000
--- a/include/hardware/qemu_pipe.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2011 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_INCLUDE_HARDWARE_QEMU_PIPE_H
-#define ANDROID_INCLUDE_HARDWARE_QEMU_PIPE_H
-
-#include <sys/cdefs.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <pthread.h>  /* for pthread_once() */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#ifndef D
-#  define  D(...)   do{}while(0)
-#endif
-
-/* Try to open a new Qemu fast-pipe. This function returns a file descriptor
- * that can be used to communicate with a named service managed by the
- * emulator.
- *
- * This file descriptor can be used as a standard pipe/socket descriptor.
- *
- * 'pipeName' is the name of the emulator service you want to connect to.
- * E.g. 'opengles' or 'camera'.
- *
- * On success, return a valid file descriptor
- * Returns -1 on error, and errno gives the error code, e.g.:
- *
- *    EINVAL  -> unknown/unsupported pipeName
- *    ENOSYS  -> fast pipes not available in this system.
- *
- * ENOSYS should never happen, except if you're trying to run within a
- * misconfigured emulator.
- *
- * You should be able to open several pipes to the same pipe service,
- * except for a few special cases (e.g. GSM modem), where EBUSY will be
- * returned if more than one client tries to connect to it.
- */
-static __inline__ int
-qemu_pipe_open(const char*  pipeName)
-{
-    char  buff[256];
-    int   buffLen;
-    int   fd, ret;
-
-    if (pipeName == NULL || pipeName[0] == '\0') {
-        errno = EINVAL;
-        return -1;
-    }
-
-    snprintf(buff, sizeof buff, "pipe:%s", pipeName);
-
-    fd = open("/dev/qemu_pipe", O_RDWR);
-    if (fd < 0 && errno == ENOENT)
-        fd = open("/dev/goldfish_pipe", O_RDWR);
-    if (fd < 0) {
-        D("%s: Could not open /dev/qemu_pipe: %s", __FUNCTION__, strerror(errno));
-        //errno = ENOSYS;
-        return -1;
-    }
-
-    buffLen = strlen(buff);
-
-    ret = TEMP_FAILURE_RETRY(write(fd, buff, buffLen+1));
-    if (ret != buffLen+1) {
-        D("%s: Could not connect to %s pipe service: %s", __FUNCTION__, pipeName, strerror(errno));
-        if (ret == 0) {
-            errno = ECONNRESET;
-        } else if (ret > 0) {
-            errno = EINVAL;
-        }
-        return -1;
-    }
-
-    return fd;
-}
-
-#endif /* ANDROID_INCLUDE_HARDWARE_QEMUD_PIPE_H */
diff --git a/include/hardware/qemud.h b/include/hardware/qemud.h
deleted file mode 100644
index 5c39f9c..0000000
--- a/include/hardware/qemud.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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 ANDROID_INCLUDE_HARDWARE_QEMUD_H
-#define ANDROID_INCLUDE_HARDWARE_QEMUD_H
-
-#include <cutils/sockets.h>
-#include "qemu_pipe.h"
-
-/* the following is helper code that is used by the QEMU-specific
- * hardware HAL modules to communicate with the emulator program
- * through the 'qemud' multiplexing daemon, or through the qemud
- * pipe.
- *
- * see the documentation comments for details in
- * development/emulator/qemud/qemud.c
- *
- * all definitions here are built into the HAL module to avoid
- * having to write a tiny shared library for this.
- */
-
-/* we expect the D macro to be defined to a function macro
- * that sends its formatted string argument(s) to the log.
- * If not, ignore the traces.
- */
-#ifndef D
-#  define  D(...)  ((void)0)
-#endif
-
-static __inline__ int
-qemud_fd_write(int  fd, const void*  buff, int  len)
-{
-    int  len2;
-    do {
-        len2 = write(fd, buff, len);
-    } while (len2 < 0 && errno == EINTR);
-    return len2;
-}
-
-static __inline__ int
-qemud_fd_read(int  fd, void*  buff, int  len)
-{
-    int  len2;
-    do {
-        len2 = read(fd, buff, len);
-    } while (len2 < 0 && errno == EINTR);
-    return len2;
-}
-
-static __inline__ int
-qemud_channel_open(const char*  name)
-{
-    int  fd;
-    int  namelen = strlen(name);
-    char answer[2];
-    char pipe_name[256];
-
-    /* First, try to connect to the pipe. */
-    snprintf(pipe_name, sizeof(pipe_name), "qemud:%s", name);
-    fd = qemu_pipe_open(pipe_name);
-    if (fd < 0) {
-        D("QEMUD pipe is not available for %s: %s", name, strerror(errno));
-        /* If pipe is not available, connect to qemud control socket */
-        fd = socket_local_client( "qemud",
-                                  ANDROID_SOCKET_NAMESPACE_RESERVED,
-                                  SOCK_STREAM );
-        if (fd < 0) {
-            D("no qemud control socket: %s", strerror(errno));
-            return -1;
-        }
-
-        /* send service name to connect */
-        if (qemud_fd_write(fd, name, namelen) != namelen) {
-            D("can't send service name to qemud: %s",
-               strerror(errno));
-            close(fd);
-            return -1;
-        }
-
-        /* read answer from daemon */
-        if (qemud_fd_read(fd, answer, 2) != 2 ||
-            answer[0] != 'O' || answer[1] != 'K') {
-            D("cant' connect to %s service through qemud", name);
-            close(fd);
-            return -1;
-        }
-    }
-    return fd;
-}
-
-static __inline__ int
-qemud_channel_send(int  fd, const void*  msg, int  msglen)
-{
-    char  header[5];
-
-    if (msglen < 0)
-        msglen = strlen((const char*)msg);
-
-    if (msglen == 0)
-        return 0;
-
-    snprintf(header, sizeof header, "%04x", msglen);
-    if (qemud_fd_write(fd, header, 4) != 4) {
-        D("can't write qemud frame header: %s", strerror(errno));
-        return -1;
-    }
-
-    if (qemud_fd_write(fd, msg, msglen) != msglen) {
-        D("can4t write qemud frame payload: %s", strerror(errno));
-        return -1;
-    }
-    return 0;
-}
-
-static __inline__ int
-qemud_channel_recv(int  fd, void*  msg, int  msgsize)
-{
-    char  header[5];
-    int   size, avail;
-
-    if (qemud_fd_read(fd, header, 4) != 4) {
-        D("can't read qemud frame header: %s", strerror(errno));
-        return -1;
-    }
-    header[4] = 0;
-    if (sscanf(header, "%04x", &size) != 1) {
-        D("malformed qemud frame header: '%.*s'", 4, header);
-        return -1;
-    }
-    if (size > msgsize)
-        return -1;
-
-    if (qemud_fd_read(fd, msg, size) != size) {
-        D("can't read qemud frame payload: %s", strerror(errno));
-        return -1;
-    }
-    return size;
-}
-
-#endif /* ANDROID_INCLUDE_HARDWARE_QEMUD_H */
