i8042.hh (10905:a6ca6831e775) i8042.hh (11007:179bc8ca2d8c)
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;

--- 17 unchanged lines hidden (view full) ---

26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Gabe Black
29 */
30
31#ifndef __DEV_X86_I8042_HH__
32#define __DEV_X86_I8042_HH__
33
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;

--- 17 unchanged lines hidden (view full) ---

26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Gabe Black
29 */
30
31#ifndef __DEV_X86_I8042_HH__
32#define __DEV_X86_I8042_HH__
33
34#include <queue>
34#include <deque>
35
36#include "dev/x86/intdev.hh"
37#include "dev/io_device.hh"
38#include "params/I8042.hh"
39
40namespace X86ISA
41{
42
43class IntPin;
44
45class PS2Device
46{
47 protected:
35
36#include "dev/x86/intdev.hh"
37#include "dev/io_device.hh"
38#include "params/I8042.hh"
39
40namespace X86ISA
41{
42
43class IntPin;
44
45class PS2Device
46{
47 protected:
48 std::queue<uint8_t> outBuffer;
48 std::deque<uint8_t> outBuffer;
49
50 static const uint16_t NoCommand = (uint16_t)(-1);
51
52 uint16_t lastCommand;
53 void bufferData(const uint8_t *data, int size);
54 void ack();
55 void nack();
56
57 public:
58 virtual ~PS2Device()
59 {};
60
61 PS2Device() : lastCommand(NoCommand)
62 {}
63
49
50 static const uint16_t NoCommand = (uint16_t)(-1);
51
52 uint16_t lastCommand;
53 void bufferData(const uint8_t *data, int size);
54 void ack();
55 void nack();
56
57 public:
58 virtual ~PS2Device()
59 {};
60
61 PS2Device() : lastCommand(NoCommand)
62 {}
63
64 virtual void serialize(const std::string &base, CheckpointOut &cp) const;
65 virtual void unserialize(const std::string &base, CheckpointIn &cp);
66
64 bool hasData()
65 {
66 return !outBuffer.empty();
67 }
68
69 uint8_t getData()
70 {
71 uint8_t data = outBuffer.front();
67 bool hasData()
68 {
69 return !outBuffer.empty();
70 }
71
72 uint8_t getData()
73 {
74 uint8_t data = outBuffer.front();
72 outBuffer.pop();
75 outBuffer.pop_front();
73 return data;
74 }
75
76 virtual bool processData(uint8_t data) = 0;
77};
78
79class PS2Mouse : public PS2Device
80{

--- 31 unchanged lines hidden (view full) ---

112 uint8_t resolution;
113 uint8_t sampleRate;
114 public:
115 PS2Mouse() : PS2Device(), status(0), resolution(4), sampleRate(100)
116 {}
117
118 bool processData(uint8_t data);
119
76 return data;
77 }
78
79 virtual bool processData(uint8_t data) = 0;
80};
81
82class PS2Mouse : public PS2Device
83{

--- 31 unchanged lines hidden (view full) ---

115 uint8_t resolution;
116 uint8_t sampleRate;
117 public:
118 PS2Mouse() : PS2Device(), status(0), resolution(4), sampleRate(100)
119 {}
120
121 bool processData(uint8_t data);
122
120 void serialize(const std::string &base, CheckpointOut &cp);
121 void unserialize(const std::string &base, CheckpointIn &cp);
123 void serialize(const std::string &base,
124 CheckpointOut &cp) const M5_ATTR_OVERRIDE;
125 void unserialize(const std::string &base,
126 CheckpointIn &cp) M5_ATTR_OVERRIDE;
122};
123
124class PS2Keyboard : public PS2Device
125{
126 protected:
127 static const uint8_t ID[];
128
129 enum Command

--- 14 unchanged lines hidden (view full) ---

144 KeyToMakeRelease = 0xFC,
145 KeyToMakeOnly = 0xFD,
146 Resend = 0xFE,
147 Reset = 0xFF
148 };
149
150 public:
151 bool processData(uint8_t data);
127};
128
129class PS2Keyboard : public PS2Device
130{
131 protected:
132 static const uint8_t ID[];
133
134 enum Command

--- 14 unchanged lines hidden (view full) ---

149 KeyToMakeRelease = 0xFC,
150 KeyToMakeOnly = 0xFD,
151 Resend = 0xFE,
152 Reset = 0xFF
153 };
154
155 public:
156 bool processData(uint8_t data);
152
153 void serialize(const std::string &base, CheckpointOut &cp);
154 void unserialize(const std::string &base, CheckpointIn &cp);
155};
156
157class I8042 : public BasicPioDevice
158{
159 protected:
160 enum Command
161 {
162 GetCommandByte = 0x20,

--- 79 unchanged lines hidden (view full) ---

242 I8042(Params *p);
243
244 AddrRangeList getAddrRanges() const;
245
246 Tick read(PacketPtr pkt);
247
248 Tick write(PacketPtr pkt);
249
157};
158
159class I8042 : public BasicPioDevice
160{
161 protected:
162 enum Command
163 {
164 GetCommandByte = 0x20,

--- 79 unchanged lines hidden (view full) ---

244 I8042(Params *p);
245
246 AddrRangeList getAddrRanges() const;
247
248 Tick read(PacketPtr pkt);
249
250 Tick write(PacketPtr pkt);
251
250 void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE;
252 void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
251 void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
252};
253
254} // namespace X86ISA
255
256#endif //__DEV_X86_I8042_HH__
253 void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
254};
255
256} // namespace X86ISA
257
258#endif //__DEV_X86_I8042_HH__