i8042.cc (10905:a6ca6831e775) i8042.cc (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;

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

87 DPRINTF(I8042, "Sending mouse interrupt.\n");
88 mouseIntPin->raise();
89 //This is a hack
90 mouseIntPin->lower();
91 }
92}
93
94void
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;

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

87 DPRINTF(I8042, "Sending mouse interrupt.\n");
88 mouseIntPin->raise();
89 //This is a hack
90 mouseIntPin->lower();
91 }
92}
93
94void
95X86ISA::PS2Device::serialize(const std::string &base, CheckpointOut &cp) const
96{
97 paramOut(cp, base + ".lastCommand", lastCommand);
98
99 std::vector<uint8_t> buffer(outBuffer.size());
100 std::copy(outBuffer.begin(), outBuffer.end(), buffer.begin());
101 arrayParamOut(cp, base + ".outBuffer.elts", buffer);
102}
103
104void
105X86ISA::PS2Device::unserialize(const std::string &base, CheckpointIn &cp)
106{
107 paramIn(cp, base + ".lastCommand", lastCommand);
108
109 std::vector<uint8_t> buffer;
110 arrayParamIn(cp, base + ".outBuffer.elts", buffer);
111 assert(outBuffer.empty());
112 for (auto c : buffer)
113 outBuffer.push_back(c);
114}
115
116
117void
95X86ISA::PS2Device::ack()
96{
97 bufferData(&CommandAck, sizeof(CommandAck));
98}
99
100void
101X86ISA::PS2Device::nack()
102{
103 bufferData(&CommandNack, sizeof(CommandNack));
104}
105
106void
107X86ISA::PS2Device::bufferData(const uint8_t *data, int size)
108{
109 assert(data || size == 0);
110 while (size) {
118X86ISA::PS2Device::ack()
119{
120 bufferData(&CommandAck, sizeof(CommandAck));
121}
122
123void
124X86ISA::PS2Device::nack()
125{
126 bufferData(&CommandNack, sizeof(CommandNack));
127}
128
129void
130X86ISA::PS2Device::bufferData(const uint8_t *data, int size)
131{
132 assert(data || size == 0);
133 while (size) {
111 outBuffer.push(*(data++));
134 outBuffer.push_back(*(data++));
112 size--;
113 }
114}
115
116uint8_t
117X86ISA::I8042::readDataOut()
118{
119 uint8_t data = dataReg;

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

458 } else {
459 panic("Write to unrecognized port %#x.\n", addr);
460 }
461 pkt->makeAtomicResponse();
462 return latency;
463}
464
465void
135 size--;
136 }
137}
138
139uint8_t
140X86ISA::I8042::readDataOut()
141{
142 uint8_t data = dataReg;

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

481 } else {
482 panic("Write to unrecognized port %#x.\n", addr);
483 }
484 pkt->makeAtomicResponse();
485 return latency;
486}
487
488void
466X86ISA::I8042::serializeOld(CheckpointOut &cp)
489X86ISA::I8042::serialize(CheckpointOut &cp) const
467{
468 uint8_t statusRegData = statusReg.__data;
469 uint8_t commandByteData = commandByte.__data;
470
471 SERIALIZE_SCALAR(dataPort);
472 SERIALIZE_SCALAR(commandPort);
473 SERIALIZE_SCALAR(statusRegData);
474 SERIALIZE_SCALAR(commandByteData);

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

493 mouse.unserialize("mouse", cp);
494 keyboard.unserialize("keyboard", cp);
495
496 statusReg.__data = statusRegData;
497 commandByte.__data = commandByteData;
498}
499
500void
490{
491 uint8_t statusRegData = statusReg.__data;
492 uint8_t commandByteData = commandByte.__data;
493
494 SERIALIZE_SCALAR(dataPort);
495 SERIALIZE_SCALAR(commandPort);
496 SERIALIZE_SCALAR(statusRegData);
497 SERIALIZE_SCALAR(commandByteData);

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

516 mouse.unserialize("mouse", cp);
517 keyboard.unserialize("keyboard", cp);
518
519 statusReg.__data = statusRegData;
520 commandByte.__data = commandByteData;
521}
522
523void
501X86ISA::PS2Keyboard::serialize(const std::string &base, CheckpointOut &cp)
524X86ISA::PS2Mouse::serialize(const std::string &base, CheckpointOut &cp) const
502{
525{
503 paramOut(cp, base + ".lastCommand", lastCommand);
504 int bufferSize = outBuffer.size();
505 paramOut(cp, base + ".outBuffer.size", bufferSize);
506 uint8_t *buffer = new uint8_t[bufferSize];
507 for (int i = 0; i < bufferSize; ++i) {
508 buffer[i] = outBuffer.front();
509 outBuffer.pop();
510 }
511 arrayParamOut(cp, base + ".outBuffer.elts", buffer,
512 bufferSize*sizeof(uint8_t));
513 delete[] buffer;
514}
526 PS2Device::serialize(base, cp);
515
527
516void
517X86ISA::PS2Keyboard::unserialize(const std::string &base, CheckpointIn &cp)
518{
519 paramIn(cp, base + ".lastCommand", lastCommand);
520 int bufferSize;
521 paramIn(cp, base + ".outBuffer.size", bufferSize);
522 uint8_t *buffer = new uint8_t[bufferSize];
523 arrayParamIn(cp, base + ".outBuffer.elts", buffer,
524 bufferSize*sizeof(uint8_t));
525 for (int i = 0; i < bufferSize; ++i) {
526 outBuffer.push(buffer[i]);
527 }
528 delete[] buffer;
529}
530
531void
532X86ISA::PS2Mouse::serialize(const std::string &base, CheckpointOut &cp)
533{
534 uint8_t statusData = status.__data;
535 paramOut(cp, base + ".lastCommand", lastCommand);
536 int bufferSize = outBuffer.size();
537 paramOut(cp, base + ".outBuffer.size", bufferSize);
538 uint8_t *buffer = new uint8_t[bufferSize];
539 for (int i = 0; i < bufferSize; ++i) {
540 buffer[i] = outBuffer.front();
541 outBuffer.pop();
542 }
543 arrayParamOut(cp, base + ".outBuffer.elts", buffer,
544 bufferSize*sizeof(uint8_t));
545 delete[] buffer;
546 paramOut(cp, base + ".status", statusData);
528 paramOut(cp, base + ".status", status);
547 paramOut(cp, base + ".resolution", resolution);
548 paramOut(cp, base + ".sampleRate", sampleRate);
549}
550
551void
552X86ISA::PS2Mouse::unserialize(const std::string &base, CheckpointIn &cp)
553{
529 paramOut(cp, base + ".resolution", resolution);
530 paramOut(cp, base + ".sampleRate", sampleRate);
531}
532
533void
534X86ISA::PS2Mouse::unserialize(const std::string &base, CheckpointIn &cp)
535{
554 uint8_t statusData;
555 paramIn(cp, base + ".lastCommand", lastCommand);
556 int bufferSize;
557 paramIn(cp, base + ".outBuffer.size", bufferSize);
558 uint8_t *buffer = new uint8_t[bufferSize];
559 arrayParamIn(cp, base + ".outBuffer.elts", buffer,
560 bufferSize*sizeof(uint8_t));
561 for (int i = 0; i < bufferSize; ++i) {
562 outBuffer.push(buffer[i]);
563 }
564 delete[] buffer;
565 paramIn(cp, base + ".status", statusData);
536 PS2Device::unserialize(base, cp);
537
538 paramIn(cp, base + ".status", status);
566 paramIn(cp, base + ".resolution", resolution);
567 paramIn(cp, base + ".sampleRate", sampleRate);
539 paramIn(cp, base + ".resolution", resolution);
540 paramIn(cp, base + ".sampleRate", sampleRate);
568
569 status.__data = statusData;
570}
571
572X86ISA::I8042 *
573I8042Params::create()
574{
575 return new X86ISA::I8042(this);
576}
541}
542
543X86ISA::I8042 *
544I8042Params::create()
545{
546 return new X86ISA::I8042(this);
547}