kmi.cc (11793:ef606668d247) kmi.cc (11895:ff66da931b6d)
1/*
1/*
2 * Copyright (c) 2010 ARM Limited
2 * Copyright (c) 2010, 2017 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

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

48#include "debug/Pl050.hh"
49#include "dev/arm/amba_device.hh"
50#include "dev/ps2.hh"
51#include "mem/packet.hh"
52#include "mem/packet_access.hh"
53
54Pl050::Pl050(const Params *p)
55 : AmbaIntDevice(p, 0xfff), control(0), status(0x43), clkdiv(0),
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

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

48#include "debug/Pl050.hh"
49#include "dev/arm/amba_device.hh"
50#include "dev/ps2.hh"
51#include "mem/packet.hh"
52#include "mem/packet_access.hh"
53
54Pl050::Pl050(const Params *p)
55 : AmbaIntDevice(p, 0xfff), control(0), status(0x43), clkdiv(0),
56 interrupts(0), rawInterrupts(0), ackNext(false), shiftDown(false),
56 rawInterrupts(0), ackNext(false), shiftDown(false),
57 vnc(p->vnc), driverInitialized(false), intEvent(this)
58{
59 if (vnc) {
60 if (!p->is_mouse)
61 vnc->setKeyboard(this);
62 else
63 vnc->setMouse(this);
64 }

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

96 }
97 DPRINTF(Pl050, "Read Data: %#x\n", (uint32_t)data);
98 updateIntStatus();
99 break;
100 case kmiClkDiv:
101 data = clkdiv;
102 break;
103 case kmiISR:
57 vnc(p->vnc), driverInitialized(false), intEvent(this)
58{
59 if (vnc) {
60 if (!p->is_mouse)
61 vnc->setKeyboard(this);
62 else
63 vnc->setMouse(this);
64 }

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

96 }
97 DPRINTF(Pl050, "Read Data: %#x\n", (uint32_t)data);
98 updateIntStatus();
99 break;
100 case kmiClkDiv:
101 data = clkdiv;
102 break;
103 case kmiISR:
104 data = interrupts;
105 DPRINTF(Pl050, "Read Interrupts: %#x\n", (uint32_t)interrupts);
104 data = getInterrupt();
105 DPRINTF(Pl050, "Read Interrupts: %#x\n", getInterrupt());
106 break;
107 default:
108 if (readId(pkt, ambaId, pioAddr)) {
109 // Hack for variable size accesses
110 data = pkt->get<uint32_t>();
111 break;
112 }
113

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

233
234 updateIntStatus();
235}
236
237
238void
239Pl050::updateIntStatus()
240{
106 break;
107 default:
108 if (readId(pkt, ambaId, pioAddr)) {
109 // Hack for variable size accesses
110 data = pkt->get<uint32_t>();
111 break;
112 }
113

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

233
234 updateIntStatus();
235}
236
237
238void
239Pl050::updateIntStatus()
240{
241 const bool old_interrupt(getInterrupt());
242
241 if (!rxQueue.empty())
242 rawInterrupts.rx = 1;
243 else
244 rawInterrupts.rx = 0;
245
243 if (!rxQueue.empty())
244 rawInterrupts.rx = 1;
245 else
246 rawInterrupts.rx = 0;
247
246 interrupts.tx = rawInterrupts.tx & control.txint_enable;
247 interrupts.rx = rawInterrupts.rx & control.rxint_enable;
248
249 DPRINTF(Pl050, "rawInterupts=%#x control=%#x interrupts=%#x\n",
250 (uint32_t)rawInterrupts, (uint32_t)control, (uint32_t)interrupts);
251
252 if (interrupts && !intEvent.scheduled())
248 if ((!old_interrupt && getInterrupt()) && !intEvent.scheduled()) {
253 schedule(intEvent, curTick() + intDelay);
249 schedule(intEvent, curTick() + intDelay);
250 } else if (old_interrupt && !(getInterrupt())) {
251 gic->clearInt(intNum);
252 }
254}
255
256void
257Pl050::generateInterrupt()
258{
253}
254
255void
256Pl050::generateInterrupt()
257{
258 DPRINTF(Pl050, "Generate Interrupt: rawInt=%#x ctrl=%#x int=%#x\n",
259 rawInterrupts, control, getInterrupt());
259
260
260 if (interrupts) {
261 if (getInterrupt()) {
261 gic->sendInt(intNum);
262 gic->sendInt(intNum);
262 DPRINTF(Pl050, "Generated interrupt\n");
263 DPRINTF(Pl050, " -- Generated\n");
263 }
264}
265
266void
267Pl050::mouseAt(uint16_t x, uint16_t y, uint8_t buttons)
268{
269 using namespace Ps2;
270

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

313{
314 uint8_t ctrlreg = control;
315 SERIALIZE_SCALAR(ctrlreg);
316
317 uint8_t stsreg = status;
318 SERIALIZE_SCALAR(stsreg);
319 SERIALIZE_SCALAR(clkdiv);
320
264 }
265}
266
267void
268Pl050::mouseAt(uint16_t x, uint16_t y, uint8_t buttons)
269{
270 using namespace Ps2;
271

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

314{
315 uint8_t ctrlreg = control;
316 SERIALIZE_SCALAR(ctrlreg);
317
318 uint8_t stsreg = status;
319 SERIALIZE_SCALAR(stsreg);
320 SERIALIZE_SCALAR(clkdiv);
321
321 uint8_t ints = interrupts;
322 SERIALIZE_SCALAR(ints);
323
324 uint8_t raw_ints = rawInterrupts;
325 SERIALIZE_SCALAR(raw_ints);
326
327 SERIALIZE_SCALAR(ackNext);
328 SERIALIZE_SCALAR(shiftDown);
329 SERIALIZE_SCALAR(driverInitialized);
330
331 SERIALIZE_CONTAINER(rxQueue);

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

339 control = ctrlreg;
340
341 uint8_t stsreg;
342 UNSERIALIZE_SCALAR(stsreg);
343 status = stsreg;
344
345 UNSERIALIZE_SCALAR(clkdiv);
346
322 uint8_t raw_ints = rawInterrupts;
323 SERIALIZE_SCALAR(raw_ints);
324
325 SERIALIZE_SCALAR(ackNext);
326 SERIALIZE_SCALAR(shiftDown);
327 SERIALIZE_SCALAR(driverInitialized);
328
329 SERIALIZE_CONTAINER(rxQueue);

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

337 control = ctrlreg;
338
339 uint8_t stsreg;
340 UNSERIALIZE_SCALAR(stsreg);
341 status = stsreg;
342
343 UNSERIALIZE_SCALAR(clkdiv);
344
347 uint8_t ints;
348 UNSERIALIZE_SCALAR(ints);
349 interrupts = ints;
350
351 uint8_t raw_ints;
352 UNSERIALIZE_SCALAR(raw_ints);
353 rawInterrupts = raw_ints;
354
355 UNSERIALIZE_SCALAR(ackNext);
356 UNSERIALIZE_SCALAR(shiftDown);
357 UNSERIALIZE_SCALAR(driverInitialized);
358
359 UNSERIALIZE_CONTAINER(rxQueue);
360}
361
362
363
364Pl050 *
365Pl050Params::create()
366{
367 return new Pl050(this);
368}
345 uint8_t raw_ints;
346 UNSERIALIZE_SCALAR(raw_ints);
347 rawInterrupts = raw_ints;
348
349 UNSERIALIZE_SCALAR(ackNext);
350 UNSERIALIZE_SCALAR(shiftDown);
351 UNSERIALIZE_SCALAR(driverInitialized);
352
353 UNSERIALIZE_CONTAINER(rxQueue);
354}
355
356
357
358Pl050 *
359Pl050Params::create()
360{
361 return new Pl050(this);
362}