pic2(0xA0, 2, p->pio_latency),
     pit(p->name + ".pit", 0x40, 4, p->pio_latency),
     cmos(0x70, 2, p->pio_latency),
-    speaker(0x61, 1, p->pio_latency)
+    speaker(&pit, 0x61, 1, p->pio_latency)
 {
     addDevice(pic1);
     addDevice(pic2);
 
 /*
- * Copyright (c) 2004-2005 The Regents of The University of Michigan
+ * Copyright (c) 2008 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  */
 
 #include "base/bitunion.hh"
+#include "base/trace.hh"
+#include "dev/x86/south_bridge/i8254.hh"
 #include "dev/x86/south_bridge/speaker.hh"
 #include "mem/packet_access.hh"
 
-BitUnion8(SpeakerControl)
-    Bitfield<0> gate;
-    Bitfield<1> speaker;
-    Bitfield<5> timer;
-EndBitUnion(SpeakerControl)
-
 Tick
 X86ISA::Speaker::read(PacketPtr pkt)
 {
     assert(pkt->getAddr() == addrRange.start);
     assert(pkt->getSize() == 1);
-    SpeakerControl val = 0xFF;
-    warn("Reading from speaker device: gate %s, speaker %s, output %s.\n",
-            val.gate ? "on" : "off",
-            val.speaker ? "on" : "off",
-            val.timer ? "on" : "off");
-    pkt->set((uint8_t)val);
+    controlVal.timer = timer->pit.counter2.outputHigh() ? 1 : 0;
+    DPRINTF(PCSpeaker,
+            "Reading from speaker device: gate %s, speaker %s, output %s.\n",
+            controlVal.gate ? "on" : "off",
+            controlVal.speaker ? "on" : "off",
+            controlVal.timer ? "on" : "off");
+    pkt->set((uint8_t)controlVal);
     return latency;
 }
 
     assert(pkt->getAddr() == addrRange.start);
     assert(pkt->getSize() == 1);
     SpeakerControl val = pkt->get<uint8_t>();
-    warn("Writing to speaker device: gate %s, speaker %s.\n",
-            val.gate ? "on" : "off", val.speaker ? "on" : "off");
+    controlVal.gate = val.gate;
+    //Change the gate value in the timer.
+    if (!val.gate)
+        warn("The gate bit of the pc speaker isn't implemented and "
+                "is always on.\n");
+    //This would control whether the timer output is hooked up to a physical
+    //speaker. Since M5 can't make noise, it's value doesn't actually do
+    //anything.
+    controlVal.speaker = val.speaker;
+    DPRINTF(PCSpeaker, "Writing to speaker device: gate %s, speaker %s.\n",
+            controlVal.gate ? "on" : "off", controlVal.speaker ? "on" : "off");
     return latency;
 }
 
 /*
- * Copyright (c) 2004-2005 The Regents of The University of Michigan
+ * Copyright (c) 2008 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 namespace X86ISA
 {
 
+class I8254;
+
 class Speaker : public SubDevice
 {
+  protected:
+    BitUnion8(SpeakerControl)
+        Bitfield<0> gate;
+        Bitfield<1> speaker;
+        Bitfield<5> timer;
+    EndBitUnion(SpeakerControl)
+
+    SpeakerControl controlVal;
+
+    I8254 * timer;
+
   public:
 
-    Speaker()
+    Speaker(I8254 * _timer) : timer(_timer)
     {}
-    Speaker(Tick _latency) : SubDevice(_latency)
+    Speaker(I8254 * _timer, Tick _latency) :
+        SubDevice(_latency), timer(_timer)
     {}
-    Speaker(Addr start, Addr size, Tick _latency) :
-        SubDevice(start, size, _latency)
+    Speaker(I8254 * _timer, Addr start, Addr size, Tick _latency) :
+        SubDevice(start, size, _latency), timer(_timer)
     {}
 
     Tick read(PacketPtr pkt);