3 PS2Device::~PS2Device(void)
7 uint32_t PS2Device::read(void)
11 if (this->count
== 0) {
12 /* NOTE: if no data left, we return the last keyboard one
13 (needed for EMM386) */
14 /* XXX: need a timer to do things correctly */
15 index
= this->rptr
- 1;
17 index
= PS2_QUEUE_SIZE
- 1;
19 val
= this->data
[index
];
21 val
= this->data
[this->rptr
];
22 if (++this->rptr
== PS2_QUEUE_SIZE
) {
26 /* reading deasserts IRQ */
28 if (this->count
!= 0) {
29 /* reassert IRQs if data left */
36 void PS2Device::queue(int b
)
38 if (this->count
>= PS2_QUEUE_SIZE
) {
41 this->data
[this->wptr
] = b
;
42 if (++this->wptr
== PS2_QUEUE_SIZE
) {
49 void PS2Device::marshal(Marshaller
*m
, const char *name
)
51 m
->start_struct(name
, "PS2Device");
52 ::marshal(m
, "irq", &this->irq
);
53 ::marshal(m
, "write_cmd", &this->write_cmd
);
54 ::marshal_array(m
, "data", this->data
, PS2_QUEUE_SIZE
);
55 ::marshal(m
, "rptr", &this->rptr
);
56 ::marshal(m
, "wptr", &this->wptr
);
57 ::marshal(m
, "count", &this->count
);