i8042.hh revision 12653:4f6b6c1a8e2f
12SN/A/* 21762SN/A * Copyright (c) 2008 The Regents of The University of Michigan 32SN/A * All rights reserved. 42SN/A * 52SN/A * Redistribution and use in source and binary forms, with or without 62SN/A * modification, are permitted provided that the following conditions are 72SN/A * met: redistributions of source code must retain the above copyright 82SN/A * notice, this list of conditions and the following disclaimer; 92SN/A * redistributions in binary form must reproduce the above copyright 102SN/A * notice, this list of conditions and the following disclaimer in the 112SN/A * documentation and/or other materials provided with the distribution; 122SN/A * neither the name of the copyright holders nor the names of its 132SN/A * contributors may be used to endorse or promote products derived from 142SN/A * this software without specific prior written permission. 152SN/A * 162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Gabe Black 292665Ssaidi@eecs.umich.edu */ 302665Ssaidi@eecs.umich.edu 312SN/A#ifndef __DEV_X86_I8042_HH__ 322SN/A#define __DEV_X86_I8042_HH__ 332SN/A 342SN/A#include <deque> 352521SN/A 361110SN/A#include "dev/io_device.hh" 372521SN/A#include "dev/ps2/device.hh" 381110SN/A#include "dev/x86/intdev.hh" 3956SN/A#include "params/I8042.hh" 402521SN/A 412SN/Anamespace X86ISA 422SN/A{ 432107SN/A 442SN/Aclass IntPin; 451111SN/A 462521SN/Aclass I8042 : public BasicPioDevice 472SN/A{ 481111SN/A protected: 492521SN/A enum Command 501111SN/A { 512SN/A GetCommandByte = 0x20, 522SN/A ReadControllerRamBase = 0x20, 532SN/A WriteCommandByte = 0x60, 542SN/A WriteControllerRamBase = 0x60, 551111SN/A CheckForPassword = 0xA4, 562521SN/A LoadPassword = 0xA5, 571111SN/A CheckPassword = 0xA6, 582SN/A DisableMouse = 0xA7, 592SN/A EnableMouse = 0xA8, 602SN/A TestMouse = 0xA9, 612SN/A SelfTest = 0xAA, 621111SN/A InterfaceTest = 0xAB, 632521SN/A DiagnosticDump = 0xAC, 641111SN/A DisableKeyboard = 0xAD, 651111SN/A EnableKeyboard = 0xAE, 661111SN/A ReadInputPort = 0xC0, 671111SN/A ContinuousPollLow = 0xC1, 681111SN/A ContinuousPollHigh = 0xC2, 692SN/A ReadOutputPort = 0xD0, 702SN/A WriteOutputPort = 0xD1, 712SN/A WriteKeyboardOutputBuff = 0xD2, 722521SN/A WriteMouseOutputBuff = 0xD3, 732SN/A WriteToMouse = 0xD4, 742SN/A DisableA20 = 0xDD, 751111SN/A EnableA20 = 0xDF, 762SN/A ReadTestInputs = 0xE0, 771111SN/A PulseOutputBitBase = 0xF0, 781111SN/A SystemReset = 0xFE 792SN/A }; 802SN/A 812SN/A BitUnion8(StatusReg) 822SN/A Bitfield<7> parityError; 832SN/A Bitfield<6> timeout; 842SN/A Bitfield<5> mouseOutputFull; 852SN/A Bitfield<4> keyboardUnlocked; 862SN/A Bitfield<3> commandLast; 872SN/A Bitfield<2> passedSelfTest; 882521SN/A Bitfield<1> inputFull; 892SN/A Bitfield<0> outputFull; 901111SN/A EndBitUnion(StatusReg) 912159SN/A 922SN/A BitUnion8(CommandByte) 93924SN/A Bitfield<6> convertScanCodes; 94924SN/A Bitfield<5> disableMouse; 951147SN/A Bitfield<4> disableKeyboard; 96924SN/A Bitfield<2> passedSelfTest; 97924SN/A Bitfield<1> mouseFullInt; 981111SN/A Bitfield<0> keyboardFullInt; 991111SN/A EndBitUnion(CommandByte) 100973SN/A 101973SN/A Tick latency; 102547SN/A Addr dataPort; 1031111SN/A Addr commandPort; 1042521SN/A 1051111SN/A StatusReg statusReg; 1061111SN/A CommandByte commandByte; 107547SN/A 108924SN/A uint8_t dataReg; 109924SN/A 1102SN/A static const uint16_t NoCommand = (uint16_t)(-1); 1112SN/A uint16_t lastCommand; 1122SN/A 1132SN/A IntSourcePin *mouseIntPin; 1142SN/A IntSourcePin *keyboardIntPin; 1152SN/A 1162521SN/A PS2Device *mouse; 1172521SN/A PS2Device *keyboard; 1182521SN/A 119547SN/A void writeData(uint8_t newData, bool mouse = false); 1202521SN/A uint8_t readDataOut(); 1212521SN/A 122547SN/A public: 1232521SN/A typedef I8042Params Params; 1242521SN/A 1252521SN/A const Params * 1262521SN/A params() const 1272SN/A { 12873SN/A return dynamic_cast<const Params *>(_params); 12973SN/A } 1302521SN/A 13173SN/A I8042(Params *p); 1322521SN/A 1332521SN/A AddrRangeList getAddrRanges() const override; 13473SN/A 1352521SN/A Tick read(PacketPtr pkt) override; 13673SN/A 1372521SN/A Tick write(PacketPtr pkt) override; 13873SN/A 13973SN/A void serialize(CheckpointOut &cp) const override; 14073SN/A void unserialize(CheckpointIn &cp) override; 1412521SN/A}; 142953SN/A 1432521SN/A} // namespace X86ISA 1442521SN/A 145953SN/A#endif //__DEV_X86_I8042_HH__ 1462521SN/A