gem5  v20.1.0.0
i8237.cc
Go to the documentation of this file.
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 
29 #include "dev/x86/i8237.hh"
30 
31 #include "mem/packet.hh"
32 #include "mem/packet_access.hh"
33 
34 Tick
36 {
37  assert(pkt->getSize() == 1);
38  Addr offset = pkt->getAddr() - pioAddr;
39  switch (offset) {
40  case 0x0:
41  panic("Read from i8237 channel 0 current address unimplemented.\n");
42  case 0x1:
43  panic("Read from i8237 channel 0 remaining "
44  "word count unimplemented.\n");
45  case 0x2:
46  panic("Read from i8237 channel 1 current address unimplemented.\n");
47  case 0x3:
48  panic("Read from i8237 channel 1 remaining "
49  "word count unimplemented.\n");
50  case 0x4:
51  panic("Read from i8237 channel 2 current address unimplemented.\n");
52  case 0x5:
53  panic("Read from i8237 channel 2 remaining "
54  "word count unimplemented.\n");
55  case 0x6:
56  panic("Read from i8237 channel 3 current address unimplemented.\n");
57  case 0x7:
58  panic("Read from i8237 channel 3 remaining "
59  "word count unimplemented.\n");
60  case 0x8:
61  panic("Read from i8237 status register unimplemented.\n");
62  default:
63  panic("Read from undefined i8237 register %d.\n", offset);
64  }
65  pkt->makeAtomicResponse();
66  return latency;
67 }
68 
69 Tick
71 {
72  assert(pkt->getSize() == 1);
73  Addr offset = pkt->getAddr() - pioAddr;
74  switch (offset) {
75  case 0x0:
76  panic("Write to i8237 channel 0 starting address unimplemented.\n");
77  case 0x1:
78  panic("Write to i8237 channel 0 starting "
79  "word count unimplemented.\n");
80  case 0x2:
81  panic("Write to i8237 channel 1 starting address unimplemented.\n");
82  case 0x3:
83  panic("Write to i8237 channel 1 starting "
84  "word count unimplemented.\n");
85  case 0x4:
86  panic("Write to i8237 channel 2 starting address unimplemented.\n");
87  case 0x5:
88  panic("Write to i8237 channel 2 starting "
89  "word count unimplemented.\n");
90  case 0x6:
91  panic("Write to i8237 channel 3 starting address unimplemented.\n");
92  case 0x7:
93  panic("Write to i8237 channel 3 starting "
94  "word count unimplemented.\n");
95  case 0x8:
96  panic("Write to i8237 command register unimplemented.\n");
97  case 0x9:
98  panic("Write to i8237 request register unimplemented.\n");
99  case 0xa:
100  {
101  uint8_t command = pkt->getLE<uint8_t>();
102  uint8_t select = bits(command, 1, 0);
103  uint8_t bitVal = bits(command, 2);
104  if (!bitVal)
105  panic("Turning on i8237 channels unimplemented.\n");
106  replaceBits(maskReg, select, bitVal);
107  }
108  break;
109  case 0xb:
110  panic("Write to i8237 mode register unimplemented.\n");
111  case 0xc:
112  panic("Write to i8237 clear LSB/MSB flip-flop "
113  "register unimplemented.\n");
114  case 0xd:
115  panic("Write to i8237 master clear/reset register unimplemented.\n");
116  case 0xe:
117  panic("Write to i8237 clear mask register unimplemented.\n");
118  case 0xf:
119  panic("Write to i8237 write all mask register bits unimplemented.\n");
120  default:
121  panic("Write to undefined i8237 register.\n");
122  }
123  pkt->makeAtomicResponse();
124  return latency;
125 }
126 
127 void
129 {
130  SERIALIZE_SCALAR(maskReg);
131 }
132 
133 void
135 {
136  UNSERIALIZE_SCALAR(maskReg);
137 }
138 
140 I8237Params::create()
141 {
142  return new X86ISA::I8237(this);
143 }
Packet::makeAtomicResponse
void makeAtomicResponse()
Definition: packet.hh:1016
BasicPioDevice::pioAddr
Addr pioAddr
Address that the device listens to.
Definition: io_device.hh:154
replaceBits
void replaceBits(T &val, int first, int last, B bit_val)
A convenience function to replace bits first to last of val with bit_val in place.
Definition: bitfield.hh:179
UNSERIALIZE_SCALAR
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:797
Packet::getAddr
Addr getAddr() const
Definition: packet.hh:754
X86ISA::I8237::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: i8237.cc:128
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
Packet::getSize
unsigned getSize() const
Definition: packet.hh:764
packet.hh
X86ISA::I8237::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: i8237.cc:134
cp
Definition: cprintf.cc:40
X86ISA::I8237
Definition: i8237.hh:38
i8237.hh
X86ISA::I8237::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: i8237.cc:70
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
SERIALIZE_SCALAR
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:790
packet_access.hh
X86ISA::offset
offset
Definition: misc.hh:1024
X86ISA::I8237::latency
Tick latency
Definition: i8237.hh:41
Packet::getLE
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
Definition: packet_access.hh:75
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
X86ISA::I8237::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: i8237.cc:35
CheckpointIn
Definition: serialize.hh:67
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
bits
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:75

Generated on Wed Sep 30 2020 14:02:11 for gem5 by doxygen 1.8.17