Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4973 right-hear 1
#include
2
 
3
#define PCI_FN		62
4
 
5
void get_pci_version(__u8 * major,__u8 * minor)
6
{
7
 int r;
8
 __asm__ __volatile__("int $0x40":"=a"(r):"0"(PCI_FN),"b"(0));
9
 *minor=r&0xFF;
10
 *major=(r>>8)&0xFF;
11
}
12
 
13
void pci_get_last_bus(__u8 * last_bus)
14
{
15
 __asm__ __volatile__("int $0x40":"=a"(*last_bus):"0"(PCI_FN),"b"(1));
16
}
17
 
18
void get_pci_access_mechanism(__u8 * mechanism)
19
{
20
 __asm__ __volatile__("int $0x40":"=a"(*mechanism):"0"(PCI_FN),"b"(2));
21
}
22
 
23
#define read_config(x,c,bits) \
24
    __u##bits pci_read_config_##x (__u8 bus,__u8 dev,__u8 fn,__u8 reg) \
25
    { \
26
      __u##bits __ret; \
27
      __u16 cx; \
28
      __u16 bx; \
29
      cx=(((fn&7)|(((dev)&~7)<<3))<<8)|reg; \
30
      bx=(bus<<8)|(c); \
31
      __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(PCI_FN),"b"(bx),"c"(cx)); \
32
      return __ret; \
33
     }
34
 
35
#define write_config(x,c,bits) \
36
    void pci_write_config_##x (__u8 bus,__u8 dev,__u8 fn,__u8 reg,__u##bits val) \
37
    { \
38
     __u16 cx,bx; \
39
     cx=(((fn&7)|(((dev)&~7)<<3))<<8)|reg; \
40
     bx=(bus<<8)|(c); \
41
     __asm__ __volatile__("int $0x40"::"a"(PCI_FN),"b"(bx),"c"(cx),"d"(val)); \
42
    }
43
 
44
#define rw_config(x,c,bits) \
45
    read_config(x,4+c,bits) \
46
    write_config(x,7+c,bits)
47
 
48
rw_config(byte,0,8)
49
rw_config(word,1,16)
50
rw_config(dword,2,32)