ReactOS  0.4.13-dev-257-gfabbd7c
prep_pci.c File Reference
#include <freeldr.h>
#include "prep.h"
Include dependency graph for prep_pci.c:

Go to the source code of this file.

Classes

struct  _pci_cfg
 
struct  _pci_desc
 

Macros

#define rev16(x)   ((((x)>>8)&0xff)|(((x)&0xff)<<8))
 
#define rev32(x)   ((((x)>>24)&0xff)|(((x)>>8)&0xff00)|(((x)&0xff00)<<8)|(((x)&0xff)<<24))
 
#define pci_addr(bus, dev, fn, reg)
 
#define pci_cfg_addr(bus, dev, fn, reg)   pci_addr(bus,dev,fn,reg)
 
#define PCI_VENDORID   0
 
#define PCI_DEVICEID   2
 
#define PCI_HEADER_TYPE   0xe
 
#define PCI_BASECLASS   0xb
 

Typedefs

typedef struct _pci_cfg pci_cfg
 
typedef struct _pci_desc pci_desc
 

Functions

unsigned long pci_read (pci_desc *desc, int bus, int dev, int fn, int reg, int len)
 
void pci_read_bar (pci_desc *desc, int bus, int dev, int fn, int bar, struct _pci_bar *bar_data)
 
void pci_write (pci_desc *desc, int bus, int dev, int fn, int reg, int len, int val)
 
void pci_write_bar (pci_desc *desc, int bus, int dev, int fn, int bar, struct _pci_bar *bar_data)
 
void print_bar (struct _pci_bar *bar)
 
void pci_setup (PCONFIGURATION_COMPONENT_DATA pcibus, pci_desc *desc)
 

Variables

pci_desc pci1_desc = { (void *)0x80000cf8 }
 

Macro Definition Documentation

◆ pci_addr

#define pci_addr (   bus,
  dev,
  fn,
  reg 
)
Value:
(0x80000000 | \
((bus & 0xff) << 16) | \
((dev & 0x1f) << 11) | \
((fn & 7) << 8) | \
(reg & 0xfc))
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
static int reg
Definition: i386-dis.c:1275

Definition at line 16 of file prep_pci.c.

◆ PCI_BASECLASS

#define PCI_BASECLASS   0xb

Definition at line 94 of file prep_pci.c.

◆ pci_cfg_addr

#define pci_cfg_addr (   bus,
  dev,
  fn,
  reg 
)    pci_addr(bus,dev,fn,reg)

Definition at line 30 of file prep_pci.c.

◆ PCI_DEVICEID

#define PCI_DEVICEID   2

Definition at line 92 of file prep_pci.c.

◆ PCI_HEADER_TYPE

#define PCI_HEADER_TYPE   0xe

Definition at line 93 of file prep_pci.c.

◆ PCI_VENDORID

#define PCI_VENDORID   0

Definition at line 91 of file prep_pci.c.

◆ rev16

#define rev16 (   x)    ((((x)>>8)&0xff)|(((x)&0xff)<<8))

Definition at line 14 of file prep_pci.c.

◆ rev32

#define rev32 (   x)    ((((x)>>24)&0xff)|(((x)>>8)&0xff00)|(((x)&0xff00)<<8)|(((x)&0xff)<<24))

Definition at line 15 of file prep_pci.c.

Typedef Documentation

◆ pci_cfg

◆ pci_desc

Function Documentation

◆ pci_read()

unsigned long pci_read ( pci_desc desc,
int  bus,
int  dev,
int  fn,
int  reg,
int  len 
)

Definition at line 32 of file prep_pci.c.

32  {
33  sync();
34  unsigned long save_state = desc->cfg->addr, ret = 0;
35  unsigned long addr = pci_cfg_addr(bus,dev,fn,reg);
36  unsigned long offset = reg & 3;
37  desc->cfg->addr = rev32(addr);
38  sync();
39  switch( len ) {
40  case 4:
41  ret = desc->cfg->data;
42  break;
43  case 2:
44  ret = desc->cfg->data;
45  ret = (ret >> (offset << 3)) & 0xffff;
46  break;
47  case 1:
48  ret = desc->cfg->data;
49  ret = (ret >> (offset << 3)) & 0xff;
50  break;
51  }
52  desc->cfg->addr = save_state;
53  sync();
54  return ret;
55  }
#define pci_cfg_addr(bus, dev, fn, reg)
Definition: prep_pci.c:30
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
GLintptr offset
Definition: glext.h:5920
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
void sync()
Definition: prep.c:9
int ret
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLsizei len
Definition: glext.h:6722
static int reg
Definition: i386-dis.c:1275
#define rev32(x)
Definition: prep_pci.c:15

Referenced by pci_read_bar(), pci_setup(), and pci_write().

◆ pci_read_bar()

void pci_read_bar ( pci_desc desc,
int  bus,
int  dev,
int  fn,
int  bar,
struct _pci_bar bar_data 
)

Definition at line 57 of file prep_pci.c.

58  {
59  bar_data->data = pci_read( desc, bus, dev, fn, 0x10 + (bar * 4), 4 );
60 }
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
unsigned long data
Definition: prep.h:7
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
unsigned long pci_read(pci_desc *desc, int bus, int dev, int fn, int reg, int len)
Definition: prep_pci.c:32

Referenced by vga_setup().

◆ pci_setup()

void pci_setup ( PCONFIGURATION_COMPONENT_DATA  pcibus,
pci_desc desc 
)

Definition at line 96 of file prep_pci.c.

96  {
97  unsigned char type;
98  unsigned short vendor, device, devclass;
99  int funcs, bus, dev, fn;
100 
101  pci1_desc.cfg = (pci_cfg *)0x80000cf8;
102 
103  printf("PCI Bus:\n");
104  for( bus = 0; bus < 1; bus++ ) {
105  for( dev = 0; dev < 32; dev++ ) {
106  type = pci_read(desc,bus,dev,0,PCI_HEADER_TYPE,1);
107  vendor = pci_read(desc,bus,dev,0,PCI_VENDORID,2);
108  device = pci_read(desc,bus,dev,0,PCI_DEVICEID,2);
109 
110  if(vendor == 0 || vendor == 0xffff) continue;
111  if(type & 0x80) funcs = 8; else funcs = 1;
112 
113  for( fn = 0; fn < funcs; fn++ ) {
114  devclass = pci_read(desc,bus,dev,fn,PCI_BASECLASS,1);
115  printf(" %d:%d -> vendor:device:class %x:%x:%x\n",
116  bus, dev, vendor, device, devclass);
117 
118  if( devclass == 3 ) {
119  printf("Setting up vga...\n");
120  vga_setup(pcibus,desc,&vga1_desc,bus,dev,fn);
121  printf("Done with vga\n");
122  }
123  }
124  }
125  }
126  printf("^-- end PCI\n");
127 }
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static int dev
Definition: mkdosfs.c:536
void vga_setup(PCONFIGURATION_COMPONENT_DATA pci_bus, struct _pci_desc *pci_desc, struct _vga_desc *vga_desc, int bus, int dev, int fn)
Definition: prep_vga.c:13
Definition: devices.h:37
#define PCI_HEADER_TYPE
Definition: prep_pci.c:93
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
#define PCI_BASECLASS
Definition: prep_pci.c:94
const WCHAR * vendor
Definition: db.cpp:860
static struct __wine_debug_functions funcs
Definition: debug.c:59
struct _vga_desc vga1_desc
Definition: prep_vga.c:11
unsigned long pci_read(pci_desc *desc, int bus, int dev, int fn, int reg, int len)
Definition: prep_pci.c:32
pci_cfg * cfg
Definition: prep_pci.c:10
pci_desc pci1_desc
Definition: prep_pci.c:13
#define PCI_DEVICEID
Definition: prep_pci.c:92
#define printf
Definition: config.h:203
#define PCI_VENDORID
Definition: prep_pci.c:91

◆ pci_write()

void pci_write ( pci_desc desc,
int  bus,
int  dev,
int  fn,
int  reg,
int  len,
int  val 
)

Definition at line 68 of file prep_pci.c.

68  {
69  unsigned long save_state = desc->cfg->addr;
70  unsigned long addr = pci_cfg_addr(bus,dev,fn,reg);
71  unsigned long offset = reg & 3;
72  unsigned long oldval = pci_read( desc, bus, dev, fn, reg & ~3, 4 );
73  unsigned long mask = ((1 << (len * 8)) - 1) << (offset << 3);
74  oldval = (oldval & ~mask) | ((val << (offset << 3)) & mask);
75  desc->cfg->addr = rev32(addr);
76  sync();
77  desc->cfg->data = rev32(oldval);
78  sync();
79  desc->cfg->addr = save_state;
80  sync();
81 }
#define pci_cfg_addr(bus, dev, fn, reg)
Definition: prep_pci.c:30
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
GLintptr offset
Definition: glext.h:5920
GLenum GLint GLuint mask
Definition: glext.h:6028
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
GLuint GLfloat * val
Definition: glext.h:7180
void sync()
Definition: prep.c:9
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLsizei len
Definition: glext.h:6722
unsigned long pci_read(pci_desc *desc, int bus, int dev, int fn, int reg, int len)
Definition: prep_pci.c:32
static int reg
Definition: i386-dis.c:1275
#define rev32(x)
Definition: prep_pci.c:15

Referenced by pci_write_bar().

◆ pci_write_bar()

void pci_write_bar ( pci_desc desc,
int  bus,
int  dev,
int  fn,
int  bar,
struct _pci_bar bar_data 
)

Definition at line 83 of file prep_pci.c.

83  {
84  pci_write( desc, bus, dev, fn, 0x10 + (bar * 4), 4, bar_data->data );
85 }
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
unsigned long data
Definition: prep.h:7
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
void pci_write(pci_desc *desc, int bus, int dev, int fn, int reg, int len, int val)
Definition: prep_pci.c:68

◆ print_bar()

void print_bar ( struct _pci_bar bar)

Definition at line 87 of file prep_pci.c.

87  {
88  printf("BAR: %x\n", bar->data);
89 }
unsigned long data
Definition: prep.h:7
#define printf
Definition: config.h:203

Referenced by vga_setup().

Variable Documentation

◆ pci1_desc

pci_desc pci1_desc = { (void *)0x80000cf8 }

Definition at line 13 of file prep_pci.c.

Referenced by pci_setup().