X86: Hook the speaker device to the pit device.

This commit is contained in:
Gabe Black 2008-06-12 00:56:17 -04:00
parent da7f512067
commit 16e26fbf03
5 changed files with 45 additions and 25 deletions

View file

@ -1,6 +1,6 @@
# -*- mode:python -*- # -*- 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. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # 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('i8254.cc')
Source('i8259.cc') Source('i8259.cc')
Source('speaker.cc') Source('speaker.cc')
TraceFlag('PCSpeaker')

View file

@ -43,10 +43,8 @@ namespace X86ISA
class I8254 : public SubDevice class I8254 : public SubDevice
{ {
protected:
Intel8254Timer pit;
public: public:
Intel8254Timer pit;
I8254(const std::string &name) : pit(name) I8254(const std::string &name) : pit(name)
{} {}

View file

@ -70,7 +70,7 @@ SouthBridge::SouthBridge(const Params *p) : PioDevice(p),
pic2(0xA0, 2, p->pio_latency), pic2(0xA0, 2, p->pio_latency),
pit(p->name + ".pit", 0x40, 4, p->pio_latency), pit(p->name + ".pit", 0x40, 4, p->pio_latency),
cmos(0x70, 2, 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(pic1);
addDevice(pic2); addDevice(pic2);

View file

@ -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. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -29,26 +29,23 @@
*/ */
#include "base/bitunion.hh" #include "base/bitunion.hh"
#include "base/trace.hh"
#include "dev/x86/south_bridge/i8254.hh"
#include "dev/x86/south_bridge/speaker.hh" #include "dev/x86/south_bridge/speaker.hh"
#include "mem/packet_access.hh" #include "mem/packet_access.hh"
BitUnion8(SpeakerControl)
Bitfield<0> gate;
Bitfield<1> speaker;
Bitfield<5> timer;
EndBitUnion(SpeakerControl)
Tick Tick
X86ISA::Speaker::read(PacketPtr pkt) X86ISA::Speaker::read(PacketPtr pkt)
{ {
assert(pkt->getAddr() == addrRange.start); assert(pkt->getAddr() == addrRange.start);
assert(pkt->getSize() == 1); assert(pkt->getSize() == 1);
SpeakerControl val = 0xFF; controlVal.timer = timer->pit.counter2.outputHigh() ? 1 : 0;
warn("Reading from speaker device: gate %s, speaker %s, output %s.\n", DPRINTF(PCSpeaker,
val.gate ? "on" : "off", "Reading from speaker device: gate %s, speaker %s, output %s.\n",
val.speaker ? "on" : "off", controlVal.gate ? "on" : "off",
val.timer ? "on" : "off"); controlVal.speaker ? "on" : "off",
pkt->set((uint8_t)val); controlVal.timer ? "on" : "off");
pkt->set((uint8_t)controlVal);
return latency; return latency;
} }
@ -58,7 +55,16 @@ X86ISA::Speaker::write(PacketPtr pkt)
assert(pkt->getAddr() == addrRange.start); assert(pkt->getAddr() == addrRange.start);
assert(pkt->getSize() == 1); assert(pkt->getSize() == 1);
SpeakerControl val = pkt->get<uint8_t>(); SpeakerControl val = pkt->get<uint8_t>();
warn("Writing to speaker device: gate %s, speaker %s.\n", controlVal.gate = val.gate;
val.gate ? "on" : "off", val.speaker ? "on" : "off"); //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; return latency;
} }

View file

@ -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. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -38,16 +38,30 @@
namespace X86ISA namespace X86ISA
{ {
class I8254;
class Speaker : public SubDevice class Speaker : public SubDevice
{ {
protected:
BitUnion8(SpeakerControl)
Bitfield<0> gate;
Bitfield<1> speaker;
Bitfield<5> timer;
EndBitUnion(SpeakerControl)
SpeakerControl controlVal;
I8254 * timer;
public: 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) : Speaker(I8254 * _timer, Addr start, Addr size, Tick _latency) :
SubDevice(start, size, _latency) SubDevice(start, size, _latency), timer(_timer)
{} {}
Tick read(PacketPtr pkt); Tick read(PacketPtr pkt);