i8254.hh (7903:7fcfb515d7bf) i8254.hh (9808:13ffc0066b76)
1/*
2 * Copyright (c) 2008 The Regents of The University of Michigan
3 * All rights reserved.
4 *
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.
15 *
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.
27 *
28 * Authors: Gabe Black
29 */
30
31#ifndef __DEV_X86_I8254_HH__
32#define __DEV_X86_I8254_HH__
33
34#include "dev/intel_8254_timer.hh"
35#include "dev/io_device.hh"
36#include "params/I8254.hh"
37
38namespace X86ISA
39{
40
41class IntSourcePin;
42
43class I8254 : public BasicPioDevice
44{
45 protected:
46 Tick latency;
47 class X86Intel8254Timer : public Intel8254Timer
48 {
49 protected:
50 I8254 * parent;
51
52 void
53 counterInterrupt(unsigned int num)
54 {
55 parent->counterInterrupt(num);
56 }
57
58 public:
59 X86Intel8254Timer(const std::string &name, I8254 * _parent) :
60 Intel8254Timer(_parent, name), parent(_parent)
61 {}
62 };
63
64
65 X86Intel8254Timer pit;
66
67 IntSourcePin *intPin;
68
69 void counterInterrupt(unsigned int num);
70
71 public:
72 typedef I8254Params Params;
73
74 const Params *
75 params() const
76 {
77 return dynamic_cast<const Params *>(_params);
78 }
79
1/*
2 * Copyright (c) 2008 The Regents of The University of Michigan
3 * All rights reserved.
4 *
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.
15 *
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.
27 *
28 * Authors: Gabe Black
29 */
30
31#ifndef __DEV_X86_I8254_HH__
32#define __DEV_X86_I8254_HH__
33
34#include "dev/intel_8254_timer.hh"
35#include "dev/io_device.hh"
36#include "params/I8254.hh"
37
38namespace X86ISA
39{
40
41class IntSourcePin;
42
43class I8254 : public BasicPioDevice
44{
45 protected:
46 Tick latency;
47 class X86Intel8254Timer : public Intel8254Timer
48 {
49 protected:
50 I8254 * parent;
51
52 void
53 counterInterrupt(unsigned int num)
54 {
55 parent->counterInterrupt(num);
56 }
57
58 public:
59 X86Intel8254Timer(const std::string &name, I8254 * _parent) :
60 Intel8254Timer(_parent, name), parent(_parent)
61 {}
62 };
63
64
65 X86Intel8254Timer pit;
66
67 IntSourcePin *intPin;
68
69 void counterInterrupt(unsigned int num);
70
71 public:
72 typedef I8254Params Params;
73
74 const Params *
75 params() const
76 {
77 return dynamic_cast<const Params *>(_params);
78 }
79
80 I8254(Params *p) : BasicPioDevice(p), latency(p->pio_latency),
80 I8254(Params *p) : BasicPioDevice(p, 4), latency(p->pio_latency),
81 pit(p->name, this), intPin(p->int_pin)
82 {
81 pit(p->name, this), intPin(p->int_pin)
82 {
83 pioSize = 4;
84 }
85 Tick read(PacketPtr pkt);
86
87 Tick write(PacketPtr pkt);
88
89 bool
90 outputHigh(unsigned int num)
91 {
92 return pit.outputHigh(num);
93 }
94
95 uint8_t
96 readCounter(unsigned int num)
97 {
98 return pit.readCounter(num);
99 }
100
101 void
102 writeCounter(unsigned int num, const uint8_t data)
103 {
104 pit.writeCounter(num, data);
105 }
106
107 void
108 writeControl(uint8_t val)
109 {
110 pit.writeControl(val);
111 }
112
113 virtual void serialize(std::ostream &os);
114 virtual void unserialize(Checkpoint *cp, const std::string &section);
115
116};
117
118} // namespace X86ISA
119
120#endif //__DEV_X86_SOUTH_BRIDGE_I8254_HH__
83 }
84 Tick read(PacketPtr pkt);
85
86 Tick write(PacketPtr pkt);
87
88 bool
89 outputHigh(unsigned int num)
90 {
91 return pit.outputHigh(num);
92 }
93
94 uint8_t
95 readCounter(unsigned int num)
96 {
97 return pit.readCounter(num);
98 }
99
100 void
101 writeCounter(unsigned int num, const uint8_t data)
102 {
103 pit.writeCounter(num, data);
104 }
105
106 void
107 writeControl(uint8_t val)
108 {
109 pit.writeControl(val);
110 }
111
112 virtual void serialize(std::ostream &os);
113 virtual void unserialize(Checkpoint *cp, const std::string &section);
114
115};
116
117} // namespace X86ISA
118
119#endif //__DEV_X86_SOUTH_BRIDGE_I8254_HH__