1 /*
2  * Copyright (c) 2021 Travis Geiselbrecht
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 #pragma once
9 
10 #include "pci_backend.h"
11 
12 class pci_type1 final : public pci_backend {
13 #if ARCH_X86
14 public:
15     virtual ~pci_type1() = default;
16 
17     // factory to detect and create an instance
18     static pci_type1 *detect();
19 
20     // a few overridden methods
21     int read_config_byte(const pci_location_t *state, uint32_t reg, uint8_t *value) override;
22     int read_config_half(const pci_location_t *state, uint32_t reg, uint16_t *value) override;
23     int read_config_word(const pci_location_t *state, uint32_t reg, uint32_t *value) override;
24 
25 private:
26     // only created via the detect() factory
27     pci_type1() = default;
28 #else // !ARCH_X86
29 public:
30     // non x86s dont support this mechanism
31     static pci_type1 *detect() { return nullptr; }
32 #endif
33 };
34 
35