菜鸟笔记--rtapi/rtapi_io.h:39:43: fatal error: sys/io.h: No such file or directory问题解决

今天进行machinekit安装时出现了如下报警,查找原因,原来是arm64位的系统,在/usr/include/…/sys
/下面没有io.h,但是可以手动进行创建。但是需要根据自己的板子修改下PCI_IOBASE地址

Compiling machinetalk/support/sizes.c
In file included from rtapi/rtapi.h:1016:0,
                 from hal/lib/hal.h:126,
                 from ./emc/motion/motion.h:80,
                 from machinetalk/support/sizes.c:2:
rtapi/rtapi_io.h:39:43: fatal error: sys/io.h: No such file or directory
compilation terminated.
Makefile:420: recipe for target 'objects/machinetalk/support/sizes.o' failed

io.h的源码如下图,记得修改PCI_IOBASE地址

/* 
A largely dummy io.h to statisfy the requirements of Machinekit  
on aarch64
The functions still require a valid base address, which appears to be
#define PCI_IOBASE              ((void __iomem *)(MODULES_VADDR - SZ_2M))
MODULES_VADDR being the address at which insmod begins loading kernel modules
*/

#ifndef	_SYS_IO_H
#define	_SYS_IO_H

#include <features.h>

// as per arch/.../memory.txt
#define PCI_IOBASE   0xfee00000UL
// ((void __iomem *)(MODULES_VADDR - SZ_2M))
//((void __iomem *)PCI_IO_START)

__BEGIN_DECLS

/* If TURN_ON is TRUE, request for permission to do direct i/o on the
   port numbers in the range [FROM,FROM+NUM-1].  Otherwise, turn I/O
   permission off for that range.  This call requires root privileges.

   Portability note: not all Linux platforms support this call.  Most
   platforms based on the PC I/O architecture probably will, however.
   E.g., Linux/Alpha for Alpha PCs supports this.  */
//extern int ioperm (unsigned long int __from, unsigned long int __num,
//                   int __turn_on) __THROW;

/* Set the I/O privilege level to LEVEL.  If LEVEL>3, permission to
   access any I/O port is granted.  This call requires root
   privileges. */

// Does not appear this call is supported
// dummy function to return 0 (success and keep pci_write happy

//int iopl(int __level) { return 0; }


#if defined __GNUC__ && __GNUC__ >= 2

// Does not appear this call is supported
// dummy function to return 0 (success and keep pci_write happy

static __inline int iopl(int __level) { return 0; }



static __inline unsigned char 
inb (unsigned short int __port)
{
    unsigned char val;
    unsigned long addr = ((unsigned long) __port + PCI_IOBASE);
    
    asm volatile("ldrb %w0, [%1]" : "=r" (val) : "r" (addr));
    return val;
}


static __inline unsigned short int
inw (unsigned short int __port)
{
    unsigned short val;
    unsigned long addr = ((unsigned long) __port + PCI_IOBASE);
  
    asm volatile("ldrh %w0, [%1]" : "=r" (val) : "r" (addr));
    return val;
}


static __inline unsigned int
inl (unsigned short int __port)
{
    unsigned int val;
    unsigned long addr = ((unsigned long) __port + PCI_IOBASE);
  
    asm volatile("ldrh %w0, [%1]" : "=r" (val) : "r" (addr));
    
    return val;
}


///


static __inline void
outb (unsigned char __value, unsigned short int __port)
{
    unsigned long addr = ((unsigned long) __port + PCI_IOBASE);
    asm volatile("strb %w0, [%1]" : : "r" (__value), "r" (addr));
}


static __inline void
outw (unsigned short int __value, unsigned short int __port)
{
    unsigned long addr = ((unsigned long) __port + PCI_IOBASE);
    asm volatile("strh %w0, [%1]" : : "r" (__value), "r" (addr));
}


static __inline void
outl (unsigned int __value, unsigned short int __port)
{
    unsigned long addr = ((unsigned long) __port + PCI_IOBASE);
    asm volatile("strh %w0, [%1]" : : "r" (__value), "r" (addr));
}


#endif	/* GNU C */

__END_DECLS
#endif /* _SYS_IO_H */

参考网址 https://github.com/machinekit/machinekit-hal/issues/96

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值