Chinaunix首页 | 论坛 | 博客
  • 博客访问: 137149
  • 博文数量: 36
  • 博客积分: 127
  • 博客等级: 入伍新兵
  • 技术积分: 185
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-05 00:06
文章分类

全部博文(36)

文章存档

2015年(1)

2014年(1)

2013年(3)

2012年(31)

我的朋友

分类: LINUX

2012-08-29 10:06:30

原文地址:LINUX IO CMOS PCI superIO 读写 2   作者:追求存在
 

//
Linux IO access
compile : gcc hello.c -o hello
run : ./hello


debug : gcc -ggdb hello.c -o hello //compile for gdb
 : gdb  //run g debug
 : file hello
 : list  //view source file
 : break xxxx //set breakpoint at line XXXX
 : r  //run hello program
 : s  //if stace in same as TD F7
 : n  //if step same as TD F8
 : q  //exit debug
//

#include
#include
#include
#include

#include
#include


int main()
{
// out<<"hello world"< unsigned char port,value;
// unsigned short wordvaule;
 unsigned dwordport,dwordvaule;

 printf(" -= PCI/SuperIO/CMOS data scan =- \n");

 printf("00-00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");

// PCI IO access
 ioperm(0xcf8,8,1); //permit IO read and write
 
 for(dwordport=0x80000000;dwordport<0x80000100;dwordport+=4)
 {
  outl(dwordport,0xcf8); //output a dword value to 0CF8 IOport
//  dwordvaule=inl(0xcfc);  //read a dword value from 0CFC IOport
//  printf("%08x ",dwordvaule);

  if(!(dwordport & 0x0f))
  {
   printf("\n%02x-",port);
  }
  value=inb(0xcfc);
  printf("%02x ",value);
  value=inb(0xcfd);
  printf("%02x ",value);
  value=inb(0xcfe);
  printf("%02x ",value);
  value=inb(0xcff);
  printf("%02x ",value);
 }
 printf("\n");
//


#if 0 // ITE superIO access
 ioperm(0x2e,2,1);
  outb(0x87,0x2e);
  outb(0x01,0x2e);
  outb(0x55,0x2e);
  outb(0x55,0x2e);

 
 for(port=0;port<=0xfe;port++)
 {
  outb(port,0x2e);
  value=inb(0x2f);
  if(!(port & 0x0f))
  {
   printf("\n%02x-",port);
  }
  printf("%02x ",value);
 }
 printf("\n");
#endif

 

#if 0 // CMOS data access
 ioperm(0x70,4,1);

 for(port=0;port<0x80;port++)
 {
  outb(port,0x70);
  value=inb(0x71);
  if(!(port & 0x0f))
  {
   printf("\n%02x-",port);
  }
  printf("%02x ",value);
 }
 printf("\n");
#endif
}

阅读(1890) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~