dev: Move generic serial devices to src/dev/serial

Change-Id: I104227fc460f8b561e7375b329a541c1fce881b2
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Curtis Dunham <curtis.dunham@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/4291
Reviewed-by: Gabe Black <gabeblack@google.com>
diff --git a/src/dev/SConscript b/src/dev/SConscript
index b95d360..6939e03 100644
--- a/src/dev/SConscript
+++ b/src/dev/SConscript
@@ -44,9 +44,6 @@
 
 SimObject('BadDevice.py')
 SimObject('Platform.py')
-SimObject('Serial.py')
-SimObject('Terminal.py')
-SimObject('Uart.py')
 
 Source('baddev.cc')
 Source('intel_8254_timer.cc')
@@ -54,13 +51,6 @@
 Source('pixelpump.cc')
 Source('platform.cc')
 Source('ps2.cc')
-Source('serial.cc')
-Source('terminal.cc')
-Source('uart.cc')
-Source('uart8250.cc')
 
 DebugFlag('Intel8254Timer')
 DebugFlag('MC146818')
-DebugFlag('Terminal')
-DebugFlag('TerminalVerbose')
-DebugFlag('Uart')
diff --git a/src/dev/alpha/backdoor.cc b/src/dev/alpha/backdoor.cc
index 5187e5b..e2de197 100644
--- a/src/dev/alpha/backdoor.cc
+++ b/src/dev/alpha/backdoor.cc
@@ -52,7 +52,7 @@
 #include "dev/alpha/tsunami_io.hh"
 #include "dev/platform.hh"
 #include "dev/storage/simple_disk.hh"
-#include "dev/terminal.hh"
+#include "dev/serial/terminal.hh"
 #include "mem/packet.hh"
 #include "mem/packet_access.hh"
 #include "mem/physical.hh"
diff --git a/src/dev/alpha/tsunami.cc b/src/dev/alpha/tsunami.cc
index 82a3812..30df89d 100644
--- a/src/dev/alpha/tsunami.cc
+++ b/src/dev/alpha/tsunami.cc
@@ -44,7 +44,6 @@
 #include "dev/alpha/tsunami_cchip.hh"
 #include "dev/alpha/tsunami_io.hh"
 #include "dev/alpha/tsunami_pchip.hh"
-#include "dev/terminal.hh"
 
 using namespace std;
 //Should this be AlphaISA?
diff --git a/src/dev/arm/gic_pl390.cc b/src/dev/arm/gic_pl390.cc
index d2ec1d7..4818be6 100644
--- a/src/dev/arm/gic_pl390.cc
+++ b/src/dev/arm/gic_pl390.cc
@@ -48,7 +48,6 @@
 #include "debug/GIC.hh"
 #include "debug/IPI.hh"
 #include "debug/Interrupt.hh"
-#include "dev/terminal.hh"
 #include "mem/packet.hh"
 #include "mem/packet_access.hh"
 
diff --git a/src/dev/arm/pl011.hh b/src/dev/arm/pl011.hh
index d6c839c..2317b31 100644
--- a/src/dev/arm/pl011.hh
+++ b/src/dev/arm/pl011.hh
@@ -50,7 +50,7 @@
 #define __DEV_ARM_PL011_H__
 
 #include "dev/arm/amba_device.hh"
-#include "dev/uart.hh"
+#include "dev/serial/uart.hh"
 
 class BaseGic;
 struct Pl011Params;
diff --git a/src/dev/arm/realview.cc b/src/dev/arm/realview.cc
index e5e7afd..8524b23 100644
--- a/src/dev/arm/realview.cc
+++ b/src/dev/arm/realview.cc
@@ -53,7 +53,6 @@
 #include "config/the_isa.hh"
 #include "cpu/intr_control.hh"
 #include "dev/arm/base_gic.hh"
-#include "dev/terminal.hh"
 #include "sim/system.hh"
 
 using namespace std;
diff --git a/src/dev/arm/vgic.cc b/src/dev/arm/vgic.cc
index cc8ad77..5295204 100644
--- a/src/dev/arm/vgic.cc
+++ b/src/dev/arm/vgic.cc
@@ -43,7 +43,6 @@
 #include "debug/Checkpoint.hh"
 #include "debug/VGIC.hh"
 #include "dev/arm/base_gic.hh"
-#include "dev/terminal.hh"
 #include "mem/packet.hh"
 #include "mem/packet_access.hh"
 
diff --git a/src/dev/mips/malta.cc b/src/dev/mips/malta.cc
index 8843d4b..a259047 100755
--- a/src/dev/mips/malta.cc
+++ b/src/dev/mips/malta.cc
@@ -44,7 +44,6 @@
 #include "debug/Malta.hh"
 #include "dev/mips/malta_cchip.hh"
 #include "dev/mips/malta_io.hh"
-#include "dev/terminal.hh"
 #include "params/Malta.hh"
 #include "sim/system.hh"
 
diff --git a/src/dev/Serial.py b/src/dev/serial/SConscript
similarity index 82%
copy from src/dev/Serial.py
copy to src/dev/serial/SConscript
index 7871b48..b9f13f5 100644
--- a/src/dev/Serial.py
+++ b/src/dev/serial/SConscript
@@ -1,4 +1,6 @@
-# Copyright (c) 2014, 2017 ARM Limited
+# -*- mode:python -*-
+
+# Copyright (c) 2017 ARM Limited
 # All rights reserved.
 #
 # The license below extends only to copyright in the software and shall
@@ -10,6 +12,9 @@
 # unmodified and in its entirety in all distributions of the software,
 # modified or unmodified, in source code or in binary form.
 #
+# Copyright (c) 2006 The Regents of The University of Michigan
+# All rights reserved.
+#
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
 # met: redistributions of source code must retain the above copyright
@@ -35,14 +40,20 @@
 #
 # Authors: Andreas Sandberg
 
-from m5.params import *
-from m5.SimObject import SimObject
+Import('*')
 
-class SerialDevice(SimObject):
-    type = 'SerialDevice'
-    abstract = True
-    cxx_header = "dev/serial.hh"
+if env['TARGET_ISA'] == 'null':
+    Return()
 
-class SerialNullDevice(SerialDevice):
-    type = 'SerialNullDevice'
-    cxx_header = "dev/serial.hh"
+SimObject('Serial.py')
+SimObject('Terminal.py')
+SimObject('Uart.py')
+
+Source('serial.cc')
+Source('terminal.cc')
+Source('uart.cc')
+Source('uart8250.cc')
+
+DebugFlag('Terminal')
+DebugFlag('TerminalVerbose')
+DebugFlag('Uart')
diff --git a/src/dev/Serial.py b/src/dev/serial/Serial.py
similarity index 96%
rename from src/dev/Serial.py
rename to src/dev/serial/Serial.py
index 7871b48..3f62ef3 100644
--- a/src/dev/Serial.py
+++ b/src/dev/serial/Serial.py
@@ -41,8 +41,8 @@
 class SerialDevice(SimObject):
     type = 'SerialDevice'
     abstract = True
-    cxx_header = "dev/serial.hh"
+    cxx_header = "dev/serial/serial.hh"
 
 class SerialNullDevice(SerialDevice):
     type = 'SerialNullDevice'
-    cxx_header = "dev/serial.hh"
+    cxx_header = "dev/serial/serial.hh"
diff --git a/src/dev/Terminal.py b/src/dev/serial/Terminal.py
similarity index 97%
rename from src/dev/Terminal.py
rename to src/dev/serial/Terminal.py
index 9b50111..863c487 100644
--- a/src/dev/Terminal.py
+++ b/src/dev/serial/Terminal.py
@@ -33,7 +33,7 @@
 
 class Terminal(SerialDevice):
     type = 'Terminal'
-    cxx_header = "dev/terminal.hh"
+    cxx_header = "dev/serial/terminal.hh"
     intr_control = Param.IntrControl(Parent.any, "interrupt controller")
     port = Param.TcpPort(3456, "listen port")
     number = Param.Int(0, "terminal number")
diff --git a/src/dev/Uart.py b/src/dev/serial/Uart.py
similarity index 95%
rename from src/dev/Uart.py
rename to src/dev/serial/Uart.py
index c3bfd1b..5333705 100644
--- a/src/dev/Uart.py
+++ b/src/dev/serial/Uart.py
@@ -34,10 +34,10 @@
 class Uart(BasicPioDevice):
     type = 'Uart'
     abstract = True
-    cxx_header = "dev/uart.hh"
+    cxx_header = "dev/serial/uart.hh"
     platform = Param.Platform(Parent.any, "Platform this device is part of.")
     device = Param.SerialDevice(Parent.any, "The terminal")
 
 class Uart8250(Uart):
     type = 'Uart8250'
-    cxx_header = "dev/uart8250.hh"
+    cxx_header = "dev/serial/uart8250.hh"
diff --git a/src/dev/serial.cc b/src/dev/serial/serial.cc
similarity index 98%
rename from src/dev/serial.cc
rename to src/dev/serial/serial.cc
index 68fc94c..8733668 100644
--- a/src/dev/serial.cc
+++ b/src/dev/serial/serial.cc
@@ -37,7 +37,7 @@
  * Authors: Andreas Sandberg
  */
 
-#include "dev/serial.hh"
+#include "dev/serial/serial.hh"
 
 #include "base/misc.hh"
 #include "params/SerialDevice.hh"
diff --git a/src/dev/serial.hh b/src/dev/serial/serial.hh
similarity index 100%
rename from src/dev/serial.hh
rename to src/dev/serial/serial.hh
diff --git a/src/dev/terminal.cc b/src/dev/serial/terminal.cc
similarity index 98%
rename from src/dev/terminal.cc
rename to src/dev/serial/terminal.cc
index 4f9881d..7230698 100644
--- a/src/dev/terminal.cc
+++ b/src/dev/serial/terminal.cc
@@ -42,7 +42,7 @@
 #include <sys/termios.h>
 
 #endif
-#include "dev/terminal.hh"
+#include "dev/serial/terminal.hh"
 
 #include <poll.h>
 #include <unistd.h>
@@ -62,7 +62,7 @@
 #include "debug/Terminal.hh"
 #include "debug/TerminalVerbose.hh"
 #include "dev/platform.hh"
-#include "dev/uart.hh"
+#include "dev/serial/uart.hh"
 
 using namespace std;
 
diff --git a/src/dev/terminal.hh b/src/dev/serial/terminal.hh
similarity index 98%
rename from src/dev/terminal.hh
rename to src/dev/serial/terminal.hh
index 8b6ec0b..48bfc07 100644
--- a/src/dev/terminal.hh
+++ b/src/dev/serial/terminal.hh
@@ -43,7 +43,7 @@
 #include "base/pollevent.hh"
 #include "base/socket.hh"
 #include "cpu/intr_control.hh"
-#include "dev/serial.hh"
+#include "dev/serial/serial.hh"
 #include "params/Terminal.hh"
 #include "sim/sim_object.hh"
 
diff --git a/src/dev/uart.cc b/src/dev/serial/uart.cc
similarity index 96%
rename from src/dev/uart.cc
rename to src/dev/serial/uart.cc
index ff952cc..3a4c13c 100644
--- a/src/dev/uart.cc
+++ b/src/dev/serial/uart.cc
@@ -32,11 +32,7 @@
  * Implements a base class for UARTs
  */
 
-#include "dev/uart.hh"
-
-#include "dev/serial.hh"
-
-using namespace std;
+#include "dev/serial/uart.hh"
 
 Uart::Uart(const Params *p, Addr pio_size)
     : BasicPioDevice(p, pio_size),
diff --git a/src/dev/uart.hh b/src/dev/serial/uart.hh
similarity index 98%
rename from src/dev/uart.hh
rename to src/dev/serial/uart.hh
index bf3dcf7..04e9ec2 100644
--- a/src/dev/uart.hh
+++ b/src/dev/serial/uart.hh
@@ -37,7 +37,7 @@
 
 #include "base/callback.hh"
 #include "dev/io_device.hh"
-#include "dev/serial.hh"
+#include "dev/serial/serial.hh"
 #include "params/Uart.hh"
 
 class Platform;
diff --git a/src/dev/uart8250.cc b/src/dev/serial/uart8250.cc
similarity index 99%
rename from src/dev/uart8250.cc
rename to src/dev/serial/uart8250.cc
index f99b247..43300f5 100644
--- a/src/dev/uart8250.cc
+++ b/src/dev/serial/uart8250.cc
@@ -32,7 +32,7 @@
  * Implements a 8250 UART
  */
 
-#include "dev/uart8250.hh"
+#include "dev/serial/uart8250.hh"
 
 #include <string>
 #include <vector>
diff --git a/src/dev/uart8250.hh b/src/dev/serial/uart8250.hh
similarity index 98%
rename from src/dev/uart8250.hh
rename to src/dev/serial/uart8250.hh
index b7fefc5..585fbb2 100644
--- a/src/dev/uart8250.hh
+++ b/src/dev/serial/uart8250.hh
@@ -36,7 +36,7 @@
 #define __DEV_UART8250_HH__
 
 #include "dev/io_device.hh"
-#include "dev/uart.hh"
+#include "dev/serial/uart.hh"
 #include "params/Uart8250.hh"
 
 /* UART8250 Interrupt ID Register
diff --git a/src/dev/sparc/t1000.cc b/src/dev/sparc/t1000.cc
index f658462..0bc7ad8 100644
--- a/src/dev/sparc/t1000.cc
+++ b/src/dev/sparc/t1000.cc
@@ -40,7 +40,6 @@
 
 #include "config/the_isa.hh"
 #include "cpu/intr_control.hh"
-#include "dev/terminal.hh"
 #include "sim/system.hh"
 
 using namespace std;
diff --git a/src/dev/virtio/block.hh b/src/dev/virtio/block.hh
index fbbb518..be88bd0 100644
--- a/src/dev/virtio/block.hh
+++ b/src/dev/virtio/block.hh
@@ -42,7 +42,6 @@
 
 #include "dev/virtio/base.hh"
 #include "dev/storage/disk_image.hh"
-#include "dev/terminal.hh"
 
 struct VirtIOBlockParams;
 
diff --git a/src/dev/virtio/console.hh b/src/dev/virtio/console.hh
index 720b600..cd044b1 100644
--- a/src/dev/virtio/console.hh
+++ b/src/dev/virtio/console.hh
@@ -40,7 +40,7 @@
 #ifndef __DEV_VIRTIO_CONSOLE_HH__
 #define __DEV_VIRTIO_CONSOLE_HH__
 
-#include "dev/serial.hh"
+#include "dev/serial/serial.hh"
 #include "dev/virtio/base.hh"
 
 struct VirtIOConsoleParams;
diff --git a/src/dev/x86/pc.cc b/src/dev/x86/pc.cc
index 6d182c0..6746b50 100644
--- a/src/dev/x86/pc.cc
+++ b/src/dev/x86/pc.cc
@@ -42,7 +42,6 @@
 #include "arch/x86/x86_traits.hh"
 #include "config/the_isa.hh"
 #include "cpu/intr_control.hh"
-#include "dev/terminal.hh"
 #include "dev/x86/i82094aa.hh"
 #include "dev/x86/i8254.hh"
 #include "dev/x86/i8259.hh"