免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1158 | 回复: 5
打印 上一主题 下一主题

[求助]关于对I/O操作的问题(附C代码)!!! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-07-27 10:36 |只看该作者 |倒序浏览
请看代码:
#include<stdio.h>;
#include<stdlib.h>;
#include <sys/io.h>;
#include <linux/ioport.h>;

int base=0x210;              //base address
int x;
int main()
{
x=check_region(0x210,0x;

if(x==0)
{
  request_region(0x210,0x8,"AC1082";
  int nDI;
  nDI=inb(0x216);
}
else printf("ERROR";

  return 0;
}

我想要对I/O进行操作,不知上面的方法是否正确?
在编译时,提示如下错误:
/tmp/ccqsb5EC.o(.text+0x1b): In function `main':
: undefined reference to `ioport_resource'
/tmp/ccqsb5EC.o(.text+0x20): In function `main':
: undefined reference to `__check_region'
/tmp/ccqsb5EC.o(.text+0x5: In function `main':
: undefined reference to `ioport_resource'
/tmp/ccqsb5EC.o(.text+0x5d): In function `main':
: undefined reference to `__request_region'
collect2: ld returned 1 exit status

这是怎么回事?那到不是#include <linux/ioport.h>;这个头文件吗?

论坛徽章:
0
2 [报告]
发表于 2005-07-27 10:38 |只看该作者

[求助]关于对I/O操作的问题(附C代码)!!!

另外,现在使用ioperm获得控制权就没有问题,可正常运行。

#include<stdio.h>;
#include<stdlib.h>;
#include <sys/io.h>;

unsigned long start,len;
int nDI;

int main()
{
start=0x210;//基地址
len=8;//长度

ioperm(start,len,1);//获得I/O控制权

//AC1082 DIO Test
outb(0xff,0x216);

nDI=inb(0x216);

printf("nDI=%d\n",nDI);

ioperm(start,len,0);//释放I/O控制权

return 0;
}

上面那种利用request_region的方法,问题出在什么地方啊?

论坛徽章:
0
3 [报告]
发表于 2005-07-27 10:47 |只看该作者

[求助]关于对I/O操作的问题(附C代码)!!!

check_region
request_region

这些你是哪里来的?

论坛徽章:
0
4 [报告]
发表于 2005-07-27 10:57 |只看该作者

[求助]关于对I/O操作的问题(附C代码)!!!

原帖由 "luojiannx" 发表:

这些你是哪里来的?


书上介绍的都是用request_region,网上介绍的方法也大都是用request_region。

请看:
http://www.linuxfocus.org/ChineseGB/November2002/article264.shtml

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
5 [报告]
发表于 2005-07-27 11:01 |只看该作者

[求助]关于对I/O操作的问题(附C代码)!!!

我记得写 模块 没有主函数吧?

论坛徽章:
0
6 [报告]
发表于 2005-07-27 11:04 |只看该作者

[求助]关于对I/O操作的问题(附C代码)!!!

[quote]原帖由 "mq110"]我记得写 模块 没有主函数吧?[/quote 发表:


我只是要写个很小的测试程序,是对ISA接口的数据采集卡进行I/O操作。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP