From 79cea8e59e74e9f8b4f13cb58617b04ae265798b Mon Sep 17 00:00:00 2001
From: Avi Kivity <avi.kivity@gmail.com>
Date: Tue, 1 Jan 2013 10:05:21 +0200
Subject: [PATCH] Add header for common types

---
 arch/x64/processor.hh |  8 +-------
 drivers/isa-serial.cc |  2 +-
 drivers/isa-serial.hh |  4 ++--
 drivers/pci.hh        |  6 +-----
 types.hh              | 14 ++++++++++++++
 5 files changed, 19 insertions(+), 15 deletions(-)
 create mode 100644 types.hh

diff --git a/arch/x64/processor.hh b/arch/x64/processor.hh
index 1bfb40c39..1624d9d56 100644
--- a/arch/x64/processor.hh
+++ b/arch/x64/processor.hh
@@ -1,16 +1,10 @@
 #ifndef ARCH_X86_PROCESSOR_H
 #define ARCH_X86_PROCESSOR_H
 
-#include <stdint.h>
+#include "types.hh"
 
 namespace processor {
 
-	typedef unsigned long ulong;
-	typedef uint8_t u8;
-	typedef uint16_t u16;
-	typedef uint32_t u32;
-	typedef uint64_t u64;
-
 	inline ulong read_cr0() {
 	    ulong r;
 	    asm volatile ("mov %%cr0, %0" : "=r"(r));
diff --git a/drivers/isa-serial.cc b/drivers/isa-serial.cc
index 1dd767999..f0ee36d0d 100644
--- a/drivers/isa-serial.cc
+++ b/drivers/isa-serial.cc
@@ -14,7 +14,7 @@ void IsaSerialConsole::write(const char *str)
 
 void IsaSerialConsole::writeByte(const char letter)
 {
-	pci::u8 lsr;
+	u8 lsr;
 
 	do {
 		lsr = pci::inb(ioport + LSR_ADDRESS);
diff --git a/drivers/isa-serial.hh b/drivers/isa-serial.hh
index 42cf61dd4..f5b9a5d6f 100644
--- a/drivers/isa-serial.hh
+++ b/drivers/isa-serial.hh
@@ -11,8 +11,8 @@ public:
     virtual void write(const char *str);
     virtual void newline();
 private:
-    static const pci::u16 ioport = 0x3f8;
-    pci::u8 lcr;
+    static const u16 ioport = 0x3f8;
+    u8 lcr;
     enum IsaSerialValues {
     	LCR_ADDRESS = 0x3,
     	LCR_DIVISOR_LATCH_ACCESS_BIT = 0x7,
diff --git a/drivers/pci.hh b/drivers/pci.hh
index 6eff05e62..492f24086 100644
--- a/drivers/pci.hh
+++ b/drivers/pci.hh
@@ -3,14 +3,10 @@
 
 #include <stdint.h>
 #include "processor.hh"
+#include "types.hh"
 
 namespace pci {
 
-	typedef unsigned long ulong;
-	typedef uint8_t u8;
-	typedef uint16_t u16;
-	typedef uint32_t u32;
-	typedef uint64_t u64;
 
 	inline u8 inb(u16 port) {
 	    return processor::inb(port);
diff --git a/types.hh b/types.hh
new file mode 100644
index 000000000..988be5963
--- /dev/null
+++ b/types.hh
@@ -0,0 +1,14 @@
+#ifndef TYPES_HH_
+#define TYPES_HH_
+
+#include <stdint.h>
+#include <cstdint>
+
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef uint64_t u64;
+
+typedef unsigned long ulong;
+
+#endif /* TYPES_HH_ */
-- 
GitLab