i8042.cc (5898:541097c69e22) i8042.cc (7903:7fcfb515d7bf)
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;

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

434 }
435 } else {
436 panic("Write to unrecognized port %#x.\n", addr);
437 }
438 pkt->makeAtomicResponse();
439 return latency;
440}
441
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;

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

434 }
435 } else {
436 panic("Write to unrecognized port %#x.\n", addr);
437 }
438 pkt->makeAtomicResponse();
439 return latency;
440}
441
442void
443X86ISA::I8042::serialize(std::ostream &os)
444{
445 uint8_t statusRegData = statusReg.__data;
446 uint8_t commandByteData = commandByte.__data;
447
448 SERIALIZE_SCALAR(dataPort);
449 SERIALIZE_SCALAR(commandPort);
450 SERIALIZE_SCALAR(statusRegData);
451 SERIALIZE_SCALAR(commandByteData);
452 SERIALIZE_SCALAR(dataReg);
453 SERIALIZE_SCALAR(lastCommand);
454 mouse.serialize("mouse", os);
455 keyboard.serialize("keyboard", os);
456}
457
458void
459X86ISA::I8042::unserialize(Checkpoint *cp, const std::string &section)
460{
461 uint8_t statusRegData;
462 uint8_t commandByteData;
463
464 UNSERIALIZE_SCALAR(dataPort);
465 UNSERIALIZE_SCALAR(commandPort);
466 UNSERIALIZE_SCALAR(statusRegData);
467 UNSERIALIZE_SCALAR(commandByteData);
468 UNSERIALIZE_SCALAR(dataReg);
469 UNSERIALIZE_SCALAR(lastCommand);
470 mouse.unserialize("mouse", cp, section);
471 keyboard.unserialize("keyboard", cp, section);
472
473 statusReg.__data = statusRegData;
474 commandByte.__data = commandByteData;
475}
476
477void
478X86ISA::PS2Keyboard::serialize(const std::string &base, std::ostream &os)
479{
480 paramOut(os, base + ".lastCommand", lastCommand);
481 int bufferSize = outBuffer.size();
482 paramOut(os, base + ".outBuffer.size", bufferSize);
483 uint8_t *buffer = new uint8_t[bufferSize];
484 for (int i = 0; i < bufferSize; ++i) {
485 buffer[i] = outBuffer.front();
486 outBuffer.pop();
487 }
488 arrayParamOut(os, base + ".outBuffer.elts", buffer,
489 bufferSize*sizeof(uint8_t));
490 delete buffer;
491}
492
493void
494X86ISA::PS2Keyboard::unserialize(const std::string &base, Checkpoint *cp,
495 const std::string &section)
496{
497 paramIn(cp, section, base + ".lastCommand", lastCommand);
498 int bufferSize;
499 paramIn(cp, section, base + ".outBuffer.size", bufferSize);
500 uint8_t *buffer = new uint8_t[bufferSize];
501 arrayParamIn(cp, section, base + ".outBuffer.elts", buffer,
502 bufferSize*sizeof(uint8_t));
503 for (int i = 0; i < bufferSize; ++i) {
504 outBuffer.push(buffer[i]);
505 }
506 delete buffer;
507}
508
509void
510X86ISA::PS2Mouse::serialize(const std::string &base, std::ostream &os)
511{
512 uint8_t statusData = status.__data;
513 paramOut(os, base + ".lastCommand", lastCommand);
514 int bufferSize = outBuffer.size();
515 paramOut(os, base + ".outBuffer.size", bufferSize);
516 uint8_t *buffer = new uint8_t[bufferSize];
517 for (int i = 0; i < bufferSize; ++i) {
518 buffer[i] = outBuffer.front();
519 outBuffer.pop();
520 }
521 arrayParamOut(os, base + ".outBuffer.elts", buffer,
522 bufferSize*sizeof(uint8_t));
523 delete buffer;
524 paramOut(os, base + ".status", statusData);
525 paramOut(os, base + ".resolution", resolution);
526 paramOut(os, base + ".sampleRate", sampleRate);
527}
528
529void
530X86ISA::PS2Mouse::unserialize(const std::string &base, Checkpoint *cp,
531 const std::string &section)
532{
533 uint8_t statusData;
534 paramIn(cp, section, base + ".lastCommand", lastCommand);
535 int bufferSize;
536 paramIn(cp, section, base + ".outBuffer.size", bufferSize);
537 uint8_t *buffer = new uint8_t[bufferSize];
538 arrayParamIn(cp, section, base + ".outBuffer.elts", buffer,
539 bufferSize*sizeof(uint8_t));
540 for (int i = 0; i < bufferSize; ++i) {
541 outBuffer.push(buffer[i]);
542 }
543 delete buffer;
544 paramIn(cp, section, base + ".status", statusData);
545 paramIn(cp, section, base + ".resolution", resolution);
546 paramIn(cp, section, base + ".sampleRate", sampleRate);
547
548 status.__data = statusData;
549}
550
442X86ISA::I8042 *
443I8042Params::create()
444{
445 return new X86ISA::I8042(this);
446}
551X86ISA::I8042 *
552I8042Params::create()
553{
554 return new X86ISA::I8042(this);
555}