The Pedigree Project  0.1
IoBase.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 KERNEL_PROCESSOR_IOBASE_H
21 #define KERNEL_PROCESSOR_IOBASE_H
22 
23 #include "pedigree/kernel/compiler.h"
24 #include "pedigree/kernel/processor/types.h"
25 
32 {
33  public:
35  virtual ~IoBase();
36 
38  virtual size_t size() const = 0;
42  virtual uint8_t read8(size_t offset = 0) = 0;
46  virtual uint16_t read16(size_t offset = 0) = 0;
50  virtual uint32_t read32(size_t offset = 0) = 0;
51 #if defined(BITS_64)
52 
55  virtual uint64_t read64(size_t offset = 0) = 0;
56 #endif
57 
62  inline uint64_t read64LowFirst(size_t offset = 0);
68  inline uint64_t read64HighFirst(size_t offset = 0);
69 
74  virtual void write8(uint8_t value, size_t offset = 0) = 0;
79  virtual void write16(uint16_t value, size_t offset = 0) = 0;
84  virtual void write32(uint32_t value, size_t offset = 0) = 0;
85 #if defined(BITS_64)
86 
89  virtual void write64(uint64_t value, size_t offset = 0) = 0;
90 #endif
91 
96  void write64LowFirst(uint64_t value, size_t offset = 0);
102  void write64HighFirst(uint64_t value, size_t offset = 0);
103 
107  virtual operator bool() const = 0;
108 
109  protected:
111  IoBase();
112 
113  private:
116  IoBase(const IoBase &);
119  IoBase &operator=(const IoBase &);
120 };
121 
124 #endif
Abstrace base class for hardware I/O capabilities.
Definition: IoBase.h:31