在Android NDK中找不到iopl,ioperm,inb,outb

时间:2015-06-23 03:42:46

标签: android c++ android-ndk

我正尝试使用Android(andrioid4.4, x86-64)将Linux上的库项目移植到android-ndk-r10d

该项目使用I / O端口API,但在使用NDK编译时未找到标头sys/io.h和API。 (也试过asm/io.h但没有运气)

错误日志和Android.mk,Application.mk以及部分源代码如下。

有关解决这个问题的任何建议吗?

The error logs:


    D:\xxxxxx/dio.cpp: In function 'BOOL OpenIOPort()':
      if( iopl(3) )
                ^
      if (ioperm(IOPORT_DI_ADDRESS, 1, 1))
                                        ^
      if (ioperm(IOPORT_DO_ADDRESS, 1, 1))
                                        ^
    D:\xxxxxx/dio.cpp: In function 'USHORT DIO_ReadDIPin(PIN_STATUS&)':
      data = inb(IOPORT_DI_ADDRESS);
                                  ^
      ...


    Error:(131, 12) error: 'iopl' was not declared in this scope
    Error:(137, 36) error: 'ioperm' was not declared in this scope
    Error:(143, 36) error: 'ioperm' was not declared in this scope
    Error:(198, 30) error: 'inb' was not declared in this scope
    Error:(268, 29) error: 'outb' was not declared in this scope

Application.mk

APP_ABI := x86_64

APP_PLATFORM := \
    android-19

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := \
    myprokect

LOCAL_C_INCLUDES := \
    $(LOCAL_PATH)/../include_internal

LOCAL_SRC_FILES := \
    $(SRC_PATH)/dio.cpp

LOCAL_LDLIBS := \
    -llog

include $(BUILD_SHARED_LIBRARY)

dio.cpp

#if !defined(__ANDROID__)
#include <sys/io.h>
#endif

#include <unistd.h>

//....

BOOL OpenIOPort(void)
{
    if( iopl(3) )
    {
        printf("[DIO] iopl fail.\n");
        return false;
    }

    if (ioperm(IOPORT_DI_ADDRESS, 1, 1))
    {
        printf("[DIO] ioperm IOPORT_DI_ADDRESS\n");
        return false;
    }

    if (ioperm(IOPORT_DO_ADDRESS, 1, 1))
    {
        printf("[DIO] IOPORT_DO_ADDRESS fail\n");
        return false;
    }

    is_DIO_init = true;
    return true;
}


USHORT ReadDIPin(PIN_STATUS& PinStatus)
{
   //...
    int data = 0;
    data = inb(IOPORT_DI_ADDRESS);
   //...
}

0 个答案:

没有答案