i8042.hh revision 12653
16184SN/A/* 26184SN/A * Copyright (c) 2008 The Regents of The University of Michigan 36184SN/A * All rights reserved. 46184SN/A * 56184SN/A * Redistribution and use in source and binary forms, with or without 66184SN/A * modification, are permitted provided that the following conditions are 76184SN/A * met: redistributions of source code must retain the above copyright 86184SN/A * notice, this list of conditions and the following disclaimer; 96184SN/A * redistributions in binary form must reproduce the above copyright 106184SN/A * notice, this list of conditions and the following disclaimer in the 116184SN/A * documentation and/or other materials provided with the distribution; 126184SN/A * neither the name of the copyright holders nor the names of its 136184SN/A * contributors may be used to endorse or promote products derived from 146184SN/A * this software without specific prior written permission. 156184SN/A * 166184SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176184SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186184SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196184SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206184SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216184SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226184SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236184SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246184SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256184SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266184SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276184SN/A * 286184SN/A * Authors: Gabe Black 296184SN/A */ 306184SN/A 316184SN/A#ifndef __DEV_X86_I8042_HH__ 326184SN/A#define __DEV_X86_I8042_HH__ 336184SN/A 346226Snate@binkert.org#include <deque> 358232Snate@binkert.org 366184SN/A#include "dev/io_device.hh" 3710785Sgope@wisc.edu#include "dev/ps2/device.hh" 389480Snilay@cs.wisc.edu#include "dev/x86/intdev.hh" 399480Snilay@cs.wisc.edu#include "params/I8042.hh" 4010785Sgope@wisc.edu 416184SN/Anamespace X86ISA 426184SN/A{ 436184SN/A 446184SN/Aclass IntPin; 456184SN/A 466184SN/Aclass I8042 : public BasicPioDevice 476184SN/A{ 486184SN/A protected: 496184SN/A enum Command 506184SN/A { 516184SN/A GetCommandByte = 0x20, 526184SN/A ReadControllerRamBase = 0x20, 536184SN/A WriteCommandByte = 0x60, 546184SN/A WriteControllerRamBase = 0x60, 559480Snilay@cs.wisc.edu CheckForPassword = 0xA4, 566184SN/A LoadPassword = 0xA5, 576184SN/A CheckPassword = 0xA6, 586184SN/A DisableMouse = 0xA7, 596184SN/A EnableMouse = 0xA8, 606227Snate@binkert.org TestMouse = 0xA9, 619480Snilay@cs.wisc.edu SelfTest = 0xAA, 626184SN/A InterfaceTest = 0xAB, 639480Snilay@cs.wisc.edu DiagnosticDump = 0xAC, 646184SN/A DisableKeyboard = 0xAD, 656184SN/A EnableKeyboard = 0xAE, 669480Snilay@cs.wisc.edu ReadInputPort = 0xC0, 676184SN/A ContinuousPollLow = 0xC1, 689480Snilay@cs.wisc.edu ContinuousPollHigh = 0xC2, 696184SN/A ReadOutputPort = 0xD0, 706184SN/A WriteOutputPort = 0xD1, 716184SN/A WriteKeyboardOutputBuff = 0xD2, 726184SN/A WriteMouseOutputBuff = 0xD3, 736184SN/A WriteToMouse = 0xD4, 746184SN/A DisableA20 = 0xDD, 756227Snate@binkert.org EnableA20 = 0xDF, 766184SN/A ReadTestInputs = 0xE0, 776184SN/A PulseOutputBitBase = 0xF0, 786184SN/A SystemReset = 0xFE 796184SN/A }; 808842Smrinmoy.ghosh@arm.com 8111434Smitch.hayenga@arm.com BitUnion8(StatusReg) 828842Smrinmoy.ghosh@arm.com Bitfield<7> parityError; 838842Smrinmoy.ghosh@arm.com Bitfield<6> timeout; 848842Smrinmoy.ghosh@arm.com Bitfield<5> mouseOutputFull; 858842Smrinmoy.ghosh@arm.com Bitfield<4> keyboardUnlocked; 868842Smrinmoy.ghosh@arm.com Bitfield<3> commandLast; 878842Smrinmoy.ghosh@arm.com Bitfield<2> passedSelfTest; 886184SN/A Bitfield<1> inputFull; 8911434Smitch.hayenga@arm.com Bitfield<0> outputFull; 906184SN/A EndBitUnion(StatusReg) 916184SN/A 926184SN/A BitUnion8(CommandByte) 936184SN/A Bitfield<6> convertScanCodes; 946184SN/A Bitfield<5> disableMouse; 959480Snilay@cs.wisc.edu Bitfield<4> disableKeyboard; 966184SN/A Bitfield<2> passedSelfTest; 976184SN/A Bitfield<1> mouseFullInt; 986184SN/A Bitfield<0> keyboardFullInt; 996184SN/A EndBitUnion(CommandByte) 1009480Snilay@cs.wisc.edu 1016184SN/A Tick latency; 1026184SN/A Addr dataPort; 1036184SN/A Addr commandPort; 1046184SN/A 1056184SN/A StatusReg statusReg; 1066184SN/A CommandByte commandByte; 1076184SN/A 1089480Snilay@cs.wisc.edu uint8_t dataReg; 1096184SN/A 1106184SN/A static const uint16_t NoCommand = (uint16_t)(-1); 1119480Snilay@cs.wisc.edu uint16_t lastCommand; 1126184SN/A 1136184SN/A IntSourcePin *mouseIntPin; 1146184SN/A IntSourcePin *keyboardIntPin; 1156184SN/A 1166184SN/A PS2Device *mouse; 1176184SN/A PS2Device *keyboard; 1186184SN/A 1196184SN/A void writeData(uint8_t newData, bool mouse = false); 12011434Smitch.hayenga@arm.com uint8_t readDataOut(); 12111434Smitch.hayenga@arm.com 1226184SN/A public: 1236184SN/A typedef I8042Params Params; 1246184SN/A 1256184SN/A const Params * 1266184SN/A params() const 1276184SN/A { 1286184SN/A return dynamic_cast<const Params *>(_params); 1299480Snilay@cs.wisc.edu } 1306184SN/A 1316184SN/A I8042(Params *p); 1329480Snilay@cs.wisc.edu 1336184SN/A AddrRangeList getAddrRanges() const override; 1346184SN/A 1359480Snilay@cs.wisc.edu Tick read(PacketPtr pkt) override; 1366184SN/A 1376184SN/A Tick write(PacketPtr pkt) override; 1386184SN/A 1396184SN/A void serialize(CheckpointOut &cp) const override; 1406184SN/A void unserialize(CheckpointIn &cp) override; 1416184SN/A}; 1426184SN/A 1436184SN/A} // namespace X86ISA 1446184SN/A 1456184SN/A#endif //__DEV_X86_I8042_HH__ 1466184SN/A