PCI 액세스 전체 코드

7859 단어
PCI, BUS 0, DEV 0, FUN 0 구성 공간에서 전체 256바이트의 데이터를 읽습니다.
#include   
#include   
#include   
#include   
  
  
int a[16][16];  
void output()/* */  
{  
  
    int i,j,h;  
    clrscr();  
    printf("  ");  
    for(i = 1;i<17;i++)  
    {  
        a[0][i] = i-1;  
        printf(" %02x",a[0][i]);  
    }  
    printf("
"); for(j = 0;j<16;j++) { a[j+1][0] = j; printf("%02x",a[j+1][0]); for(h = 1;h<17;h++) { printf(" %02x",a[j+1][h]); } printf("
"); } } unsigned long int get(unsigned long int Addr)/* */ { unsigned long int data; asm mov dx,0xcf8 asm db 0x66 asm mov ax, Addr asm db 0x66 asm out dx,ax asm mov dx,0xcfc asm db 0x66 asm in ax,dx asm db 0x66 asm mov data,ax return data; } void main() { int n,m,k,l; int offset; unsigned long int Addr,Bus,Dev,Fun,data,ll,lh,hl,hh; unsigned long int Baseaddress; offset = 0; Baseaddress = 0x80000000; Bus = 0; Dev = 0; Fun = 0; l = 0; m = 1; for(n = 0;n<64;n++) { Addr = Baseaddress+(Bus<<16)+(Dev<<11)+(Fun<<8)+offset; data = get(Addr); offset = offset+4; ll = data&0x000000ff;/* 32 8 */ lh = (data>>8)&0x0000ff; hl = (data>>16)&0x00ff; hh = (data>>24)&0xff; a[m][l*4+1] = ll; a[m][l*4+2] = lh; a[m][l*4+3] = hl; a[m][l*4+4] = hh; l++; if(0 == n%4&& 0 != n) { m++; l = l-4; } } output(); getch(); }

 
전재 대상:https://www.cnblogs.com/wudibuzaijia/p/8481071.html

좋은 웹페이지 즐겨찾기