2 * Copyright (c) 2008 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef __DEV_X86_I8254_HH__
32 #define __DEV_X86_I8254_HH__
34 #include "dev/intel_8254_timer.hh"
35 #include "dev/intpin.hh"
36 #include "dev/io_device.hh"
37 #include "params/I8254.hh"
42 class I8254 : public BasicPioDevice
46 class X86Intel8254Timer : public Intel8254Timer
52 counterInterrupt(unsigned int num)
54 parent->counterInterrupt(num);
58 X86Intel8254Timer(const std::string &name, I8254 * _parent) :
59 Intel8254Timer(_parent, name), parent(_parent)
64 X86Intel8254Timer pit;
66 std::vector<IntSourcePin<I8254> *> intPin;
68 void counterInterrupt(unsigned int num);
71 typedef I8254Params Params;
74 getPort(const std::string &if_name, PortID idx=InvalidPortID) override
76 if (if_name == "int_pin")
77 return *intPin.at(idx);
79 return BasicPioDevice::getPort(if_name, idx);
85 return dynamic_cast<const Params *>(_params);
88 I8254(Params *p) : BasicPioDevice(p, 4), latency(p->pio_latency),
91 for (int i = 0; i < p->port_int_pin_connection_count; i++) {
92 intPin.push_back(new IntSourcePin<I8254>(csprintf(
93 "%s.int_pin[%d]", name(), i), i, this));
96 Tick read(PacketPtr pkt) override;
98 Tick write(PacketPtr pkt) override;
101 outputHigh(unsigned int num)
103 return pit.outputHigh(num);
107 readCounter(unsigned int num)
109 return pit.readCounter(num);
113 writeCounter(unsigned int num, const uint8_t data)
115 pit.writeCounter(num, data);
119 writeControl(uint8_t val)
121 pit.writeControl(val);
124 void serialize(CheckpointOut &cp) const override;
125 void unserialize(CheckpointIn &cp) override;
127 void startup() override;
131 } // namespace X86ISA
133 #endif //__DEV_X86_SOUTH_BRIDGE_I8254_HH__