i8042.hh revision 12653:4f6b6c1a8e2f
12623SN/A/* 210596Sgabeblack@google.com * Copyright (c) 2008 The Regents of The University of Michigan 311147Smitch.hayenga@arm.com * All rights reserved. 47725SAli.Saidi@ARM.com * 57725SAli.Saidi@ARM.com * Redistribution and use in source and binary forms, with or without 67725SAli.Saidi@ARM.com * modification, are permitted provided that the following conditions are 77725SAli.Saidi@ARM.com * met: redistributions of source code must retain the above copyright 87725SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer; 97725SAli.Saidi@ARM.com * redistributions in binary form must reproduce the above copyright 107725SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer in the 117725SAli.Saidi@ARM.com * documentation and/or other materials provided with the distribution; 127725SAli.Saidi@ARM.com * neither the name of the copyright holders nor the names of its 137725SAli.Saidi@ARM.com * contributors may be used to endorse or promote products derived from 147725SAli.Saidi@ARM.com * this software without specific prior written permission. 152623SN/A * 162623SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172623SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182623SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192623SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202623SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212623SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222623SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232623SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242623SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252623SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262623SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272623SN/A * 282623SN/A * Authors: Gabe Black 292623SN/A */ 302623SN/A 312623SN/A#ifndef __DEV_X86_I8042_HH__ 322623SN/A#define __DEV_X86_I8042_HH__ 332623SN/A 342623SN/A#include <deque> 352623SN/A 362623SN/A#include "dev/io_device.hh" 372623SN/A#include "dev/ps2/device.hh" 382623SN/A#include "dev/x86/intdev.hh" 392623SN/A#include "params/I8042.hh" 402665Ssaidi@eecs.umich.edu 412665Ssaidi@eecs.umich.edunamespace X86ISA 422623SN/A{ 432623SN/A 443170Sstever@eecs.umich.educlass IntPin; 458105Sgblack@eecs.umich.edu 462623SN/Aclass I8042 : public BasicPioDevice 474040Ssaidi@eecs.umich.edu{ 486658Snate@binkert.org protected: 498229Snate@binkert.org enum Command 502623SN/A { 518232Snate@binkert.org GetCommandByte = 0x20, 529152Satgutier@umich.edu ReadControllerRamBase = 0x20, 538232Snate@binkert.org WriteCommandByte = 0x60, 548232Snate@binkert.org WriteControllerRamBase = 0x60, 553348Sbinkertn@umich.edu CheckForPassword = 0xA4, 563348Sbinkertn@umich.edu LoadPassword = 0xA5, 574762Snate@binkert.org CheckPassword = 0xA6, 587678Sgblack@eecs.umich.edu DisableMouse = 0xA7, 598779Sgblack@eecs.umich.edu EnableMouse = 0xA8, 602901Ssaidi@eecs.umich.edu TestMouse = 0xA9, 612623SN/A SelfTest = 0xAA, 6210529Smorr@cs.wisc.edu InterfaceTest = 0xAB, 6310529Smorr@cs.wisc.edu DiagnosticDump = 0xAC, 642623SN/A DisableKeyboard = 0xAD, 652623SN/A EnableKeyboard = 0xAE, 662623SN/A ReadInputPort = 0xC0, 672623SN/A ContinuousPollLow = 0xC1, 682623SN/A ContinuousPollHigh = 0xC2, 692623SN/A ReadOutputPort = 0xD0, 7011147Smitch.hayenga@arm.com WriteOutputPort = 0xD1, 712623SN/A WriteKeyboardOutputBuff = 0xD2, 722623SN/A WriteMouseOutputBuff = 0xD3, 732623SN/A WriteToMouse = 0xD4, 748707Sandreas.hansson@arm.com DisableA20 = 0xDD, 752948Ssaidi@eecs.umich.edu EnableA20 = 0xDF, 762948Ssaidi@eecs.umich.edu ReadTestInputs = 0xE0, 775606Snate@binkert.org PulseOutputBitBase = 0xF0, 782948Ssaidi@eecs.umich.edu SystemReset = 0xFE 792948Ssaidi@eecs.umich.edu }; 805529Snate@binkert.org 818707Sandreas.hansson@arm.com BitUnion8(StatusReg) 829179Sandreas.hansson@arm.com Bitfield<7> parityError; 8310913Sandreas.sandberg@arm.com Bitfield<6> timeout; 842623SN/A Bitfield<5> mouseOutputFull; 852623SN/A Bitfield<4> keyboardUnlocked; 862623SN/A Bitfield<3> commandLast; 872623SN/A Bitfield<2> passedSelfTest; 882623SN/A Bitfield<1> inputFull; 8910030SAli.Saidi@ARM.com Bitfield<0> outputFull; 902623SN/A EndBitUnion(StatusReg) 912623SN/A 922623SN/A BitUnion8(CommandByte) 932623SN/A Bitfield<6> convertScanCodes; 9410913Sandreas.sandberg@arm.com Bitfield<5> disableMouse; 9510913Sandreas.sandberg@arm.com Bitfield<4> disableKeyboard; 962798Sktlim@umich.edu Bitfield<2> passedSelfTest; 979448SAndreas.Sandberg@ARM.com Bitfield<1> mouseFullInt; 9810913Sandreas.sandberg@arm.com Bitfield<0> keyboardFullInt; 999448SAndreas.Sandberg@ARM.com EndBitUnion(CommandByte) 1009342SAndreas.Sandberg@arm.com 1019448SAndreas.Sandberg@ARM.com Tick latency; 1029442SAndreas.Sandberg@ARM.com Addr dataPort; 10311147Smitch.hayenga@arm.com Addr commandPort; 10410913Sandreas.sandberg@arm.com 1052798Sktlim@umich.edu StatusReg statusReg; 10611147Smitch.hayenga@arm.com CommandByte commandByte; 1079442SAndreas.Sandberg@ARM.com 1089442SAndreas.Sandberg@ARM.com uint8_t dataReg; 1099442SAndreas.Sandberg@ARM.com 1109442SAndreas.Sandberg@ARM.com static const uint16_t NoCommand = (uint16_t)(-1); 1119448SAndreas.Sandberg@ARM.com uint16_t lastCommand; 1129648Sdam.sunwoo@arm.com 1139442SAndreas.Sandberg@ARM.com IntSourcePin *mouseIntPin; 11410913Sandreas.sandberg@arm.com IntSourcePin *keyboardIntPin; 1152798Sktlim@umich.edu 1162623SN/A PS2Device *mouse; 1172623SN/A PS2Device *keyboard; 1182623SN/A 1199342SAndreas.Sandberg@arm.com void writeData(uint8_t newData, bool mouse = false); 1202623SN/A uint8_t readDataOut(); 1219442SAndreas.Sandberg@ARM.com 1229448SAndreas.Sandberg@ARM.com public: 1239448SAndreas.Sandberg@ARM.com typedef I8042Params Params; 1249442SAndreas.Sandberg@ARM.com 1255221Ssaidi@eecs.umich.edu const Params * 1269523SAndreas.Sandberg@ARM.com params() const 1273201Shsul@eecs.umich.edu { 1289448SAndreas.Sandberg@ARM.com return dynamic_cast<const Params *>(_params); 1299448SAndreas.Sandberg@ARM.com } 13011147Smitch.hayenga@arm.com 13111147Smitch.hayenga@arm.com I8042(Params *p); 13211147Smitch.hayenga@arm.com 13311147Smitch.hayenga@arm.com AddrRangeList getAddrRanges() const override; 13411147Smitch.hayenga@arm.com 13511147Smitch.hayenga@arm.com Tick read(PacketPtr pkt) override; 13611147Smitch.hayenga@arm.com 13711147Smitch.hayenga@arm.com Tick write(PacketPtr pkt) override; 13811147Smitch.hayenga@arm.com 13911147Smitch.hayenga@arm.com void serialize(CheckpointOut &cp) const override; 14011147Smitch.hayenga@arm.com void unserialize(CheckpointIn &cp) override; 14111147Smitch.hayenga@arm.com}; 14211147Smitch.hayenga@arm.com 14311147Smitch.hayenga@arm.com} // namespace X86ISA 14411147Smitch.hayenga@arm.com 14511147Smitch.hayenga@arm.com#endif //__DEV_X86_I8042_HH__ 14611147Smitch.hayenga@arm.com