From: Gabe Black Date: Thu, 12 Jun 2008 04:56:17 +0000 (-0400) Subject: X86: Hook the speaker device to the pit device. X-Git-Tag: m5_2.0_beta6~137 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=16e26fbf03260f362f6090503626f2068d76f89e;p=gem5.git X86: Hook the speaker device to the pit device. --- diff --git a/src/dev/x86/south_bridge/SConscript b/src/dev/x86/south_bridge/SConscript index a7cb77b9b..d01106c5c 100644 --- a/src/dev/x86/south_bridge/SConscript +++ b/src/dev/x86/south_bridge/SConscript @@ -1,6 +1,6 @@ # -*- mode:python -*- -# Copyright (c) 2006 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 @@ -40,3 +40,5 @@ if env['FULL_SYSTEM'] and env['TARGET_ISA'] == 'x86': Source('i8254.cc') Source('i8259.cc') Source('speaker.cc') + + TraceFlag('PCSpeaker') diff --git a/src/dev/x86/south_bridge/i8254.hh b/src/dev/x86/south_bridge/i8254.hh index 519049e93..6f718a853 100644 --- a/src/dev/x86/south_bridge/i8254.hh +++ b/src/dev/x86/south_bridge/i8254.hh @@ -43,10 +43,8 @@ namespace X86ISA class I8254 : public SubDevice { - protected: - Intel8254Timer pit; - public: + Intel8254Timer pit; I8254(const std::string &name) : pit(name) {} diff --git a/src/dev/x86/south_bridge/south_bridge.cc b/src/dev/x86/south_bridge/south_bridge.cc index cc20ea09e..57cc27bcc 100644 --- a/src/dev/x86/south_bridge/south_bridge.cc +++ b/src/dev/x86/south_bridge/south_bridge.cc @@ -70,7 +70,7 @@ SouthBridge::SouthBridge(const Params *p) : PioDevice(p), 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); diff --git a/src/dev/x86/south_bridge/speaker.cc b/src/dev/x86/south_bridge/speaker.cc index 734dba4c2..784c9504b 100644 --- a/src/dev/x86/south_bridge/speaker.cc +++ b/src/dev/x86/south_bridge/speaker.cc @@ -1,5 +1,5 @@ /* - * 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 @@ -29,26 +29,23 @@ */ #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; } @@ -58,7 +55,16 @@ X86ISA::Speaker::write(PacketPtr pkt) assert(pkt->getAddr() == addrRange.start); assert(pkt->getSize() == 1); SpeakerControl val = pkt->get(); - 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; } diff --git a/src/dev/x86/south_bridge/speaker.hh b/src/dev/x86/south_bridge/speaker.hh index df738e42b..2385b80cc 100644 --- a/src/dev/x86/south_bridge/speaker.hh +++ b/src/dev/x86/south_bridge/speaker.hh @@ -1,5 +1,5 @@ /* - * 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 @@ -38,16 +38,30 @@ 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);