The Pedigree Project  0.1
Pci.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef PCI_COMMON_H
21 #define PCI_COMMON_H
22 
23 #include "pedigree/kernel/compiler.h"
24 #include "pedigree/kernel/processor/types.h"
25 
26 class Device;
27 
30 {
31  public:
32  PciBus();
33  virtual ~PciBus();
34 
35  static PciBus &instance()
36  {
37  return m_Instance;
38  }
39 
43  void initialise();
44 
50  uint32_t readConfigSpace(Device *pDev, uint8_t offset);
51 
59  uint32_t readConfigSpace(
60  uint8_t bus, uint8_t device, uint8_t function, uint8_t offset);
61 
68  void writeConfigSpace(Device *pDev, uint8_t offset, uint32_t data);
69 
78  void writeConfigSpace(
79  uint8_t bus, uint8_t device, uint8_t function, uint8_t offset,
80  uint32_t data);
81 
82  struct ConfigSpace
83  {
84  uint16_t vendor;
85  uint16_t device;
86  uint16_t command;
87  uint16_t status;
88  uint8_t revision;
89  uint8_t progif;
90  uint8_t subclass;
91  uint8_t class_code;
92  uint8_t cache_line_size;
93  uint8_t latency_timer;
94  uint8_t header_type;
95  uint8_t bist;
96  uint32_t bar[6];
97  uint32_t cardbus_pointer;
98  uint16_t subsys_vendor;
99  uint16_t subsys_id;
100  uint32_t rom_base_address;
101  uint32_t reserved0;
102  uint32_t reserved1;
103  uint8_t interrupt_line;
104  uint8_t interrupt_pin;
105  uint8_t min_grant;
106  uint8_t max_latency;
107  } __attribute__((packed));
108 
109  private:
110  static PciBus m_Instance;
111 };
112 
113 #endif
Definition: Device.h:43
Definition: Pci.h:29