i8042.hh revision 14291
15831Sgblack@eecs.umich.edu/* 25831Sgblack@eecs.umich.edu * Copyright (c) 2008 The Regents of The University of Michigan 35831Sgblack@eecs.umich.edu * All rights reserved. 45831Sgblack@eecs.umich.edu * 55831Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 65831Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 75831Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 85831Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 95831Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 105831Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 115831Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 125831Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 135831Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 145831Sgblack@eecs.umich.edu * this software without specific prior written permission. 155831Sgblack@eecs.umich.edu * 165831Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175831Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185831Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195831Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205831Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215831Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225831Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235831Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245831Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255831Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265831Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275831Sgblack@eecs.umich.edu * 285831Sgblack@eecs.umich.edu * Authors: Gabe Black 295831Sgblack@eecs.umich.edu */ 305831Sgblack@eecs.umich.edu 315831Sgblack@eecs.umich.edu#ifndef __DEV_X86_I8042_HH__ 325831Sgblack@eecs.umich.edu#define __DEV_X86_I8042_HH__ 335831Sgblack@eecs.umich.edu 3411007Sandreas.sandberg@arm.com#include <deque> 358229Snate@binkert.org 3614290Sgabeblack@google.com#include "dev/intpin.hh" 3712653Sandreas.sandberg@arm.com#include "dev/io_device.hh" 3812653Sandreas.sandberg@arm.com#include "dev/ps2/device.hh" 395831Sgblack@eecs.umich.edu#include "params/I8042.hh" 405831Sgblack@eecs.umich.edu 415831Sgblack@eecs.umich.edunamespace X86ISA 425831Sgblack@eecs.umich.edu{ 435831Sgblack@eecs.umich.edu 445831Sgblack@eecs.umich.educlass I8042 : public BasicPioDevice 455831Sgblack@eecs.umich.edu{ 465831Sgblack@eecs.umich.edu protected: 475832Sgblack@eecs.umich.edu enum Command 485832Sgblack@eecs.umich.edu { 495832Sgblack@eecs.umich.edu GetCommandByte = 0x20, 505832Sgblack@eecs.umich.edu ReadControllerRamBase = 0x20, 515832Sgblack@eecs.umich.edu WriteCommandByte = 0x60, 525832Sgblack@eecs.umich.edu WriteControllerRamBase = 0x60, 535832Sgblack@eecs.umich.edu CheckForPassword = 0xA4, 545832Sgblack@eecs.umich.edu LoadPassword = 0xA5, 555832Sgblack@eecs.umich.edu CheckPassword = 0xA6, 565832Sgblack@eecs.umich.edu DisableMouse = 0xA7, 575832Sgblack@eecs.umich.edu EnableMouse = 0xA8, 585832Sgblack@eecs.umich.edu TestMouse = 0xA9, 595832Sgblack@eecs.umich.edu SelfTest = 0xAA, 605832Sgblack@eecs.umich.edu InterfaceTest = 0xAB, 615832Sgblack@eecs.umich.edu DiagnosticDump = 0xAC, 625832Sgblack@eecs.umich.edu DisableKeyboard = 0xAD, 635832Sgblack@eecs.umich.edu EnableKeyboard = 0xAE, 645832Sgblack@eecs.umich.edu ReadInputPort = 0xC0, 655832Sgblack@eecs.umich.edu ContinuousPollLow = 0xC1, 665832Sgblack@eecs.umich.edu ContinuousPollHigh = 0xC2, 675832Sgblack@eecs.umich.edu ReadOutputPort = 0xD0, 685832Sgblack@eecs.umich.edu WriteOutputPort = 0xD1, 695832Sgblack@eecs.umich.edu WriteKeyboardOutputBuff = 0xD2, 705832Sgblack@eecs.umich.edu WriteMouseOutputBuff = 0xD3, 715832Sgblack@eecs.umich.edu WriteToMouse = 0xD4, 725832Sgblack@eecs.umich.edu DisableA20 = 0xDD, 735832Sgblack@eecs.umich.edu EnableA20 = 0xDF, 745832Sgblack@eecs.umich.edu ReadTestInputs = 0xE0, 755832Sgblack@eecs.umich.edu PulseOutputBitBase = 0xF0, 765832Sgblack@eecs.umich.edu SystemReset = 0xFE 775832Sgblack@eecs.umich.edu }; 785832Sgblack@eecs.umich.edu 795831Sgblack@eecs.umich.edu BitUnion8(StatusReg) 805831Sgblack@eecs.umich.edu Bitfield<7> parityError; 815831Sgblack@eecs.umich.edu Bitfield<6> timeout; 825831Sgblack@eecs.umich.edu Bitfield<5> mouseOutputFull; 835831Sgblack@eecs.umich.edu Bitfield<4> keyboardUnlocked; 845831Sgblack@eecs.umich.edu Bitfield<3> commandLast; 855831Sgblack@eecs.umich.edu Bitfield<2> passedSelfTest; 865831Sgblack@eecs.umich.edu Bitfield<1> inputFull; 875831Sgblack@eecs.umich.edu Bitfield<0> outputFull; 885831Sgblack@eecs.umich.edu EndBitUnion(StatusReg) 895831Sgblack@eecs.umich.edu 905831Sgblack@eecs.umich.edu BitUnion8(CommandByte) 915831Sgblack@eecs.umich.edu Bitfield<6> convertScanCodes; 925831Sgblack@eecs.umich.edu Bitfield<5> disableMouse; 935831Sgblack@eecs.umich.edu Bitfield<4> disableKeyboard; 945831Sgblack@eecs.umich.edu Bitfield<2> passedSelfTest; 955831Sgblack@eecs.umich.edu Bitfield<1> mouseFullInt; 965831Sgblack@eecs.umich.edu Bitfield<0> keyboardFullInt; 975831Sgblack@eecs.umich.edu EndBitUnion(CommandByte) 985831Sgblack@eecs.umich.edu 995831Sgblack@eecs.umich.edu Tick latency; 1005831Sgblack@eecs.umich.edu Addr dataPort; 1015831Sgblack@eecs.umich.edu Addr commandPort; 1025831Sgblack@eecs.umich.edu 1035831Sgblack@eecs.umich.edu StatusReg statusReg; 1045831Sgblack@eecs.umich.edu CommandByte commandByte; 1055831Sgblack@eecs.umich.edu 1065831Sgblack@eecs.umich.edu uint8_t dataReg; 1075831Sgblack@eecs.umich.edu 1085831Sgblack@eecs.umich.edu static const uint16_t NoCommand = (uint16_t)(-1); 1095831Sgblack@eecs.umich.edu uint16_t lastCommand; 1105831Sgblack@eecs.umich.edu 11114291Sgabeblack@google.com std::vector<IntSourcePin<I8042> *> mouseIntPin; 11214291Sgabeblack@google.com std::vector<IntSourcePin<I8042> *> keyboardIntPin; 1135831Sgblack@eecs.umich.edu 11412653Sandreas.sandberg@arm.com PS2Device *mouse; 11512653Sandreas.sandberg@arm.com PS2Device *keyboard; 1165831Sgblack@eecs.umich.edu 1175832Sgblack@eecs.umich.edu void writeData(uint8_t newData, bool mouse = false); 1185831Sgblack@eecs.umich.edu uint8_t readDataOut(); 1195831Sgblack@eecs.umich.edu 1205831Sgblack@eecs.umich.edu public: 1215831Sgblack@eecs.umich.edu typedef I8042Params Params; 1225831Sgblack@eecs.umich.edu 1235831Sgblack@eecs.umich.edu const Params * 1245831Sgblack@eecs.umich.edu params() const 1255831Sgblack@eecs.umich.edu { 1265831Sgblack@eecs.umich.edu return dynamic_cast<const Params *>(_params); 1275831Sgblack@eecs.umich.edu } 1285831Sgblack@eecs.umich.edu 1299808Sstever@gmail.com I8042(Params *p); 1305831Sgblack@eecs.umich.edu 13114290Sgabeblack@google.com Port & 13214290Sgabeblack@google.com getPort(const std::string &if_name, PortID idx=InvalidPortID) override 13314290Sgabeblack@google.com { 13414290Sgabeblack@google.com if (if_name == "mouse_int_pin") 13514290Sgabeblack@google.com return *mouseIntPin.at(idx); 13614290Sgabeblack@google.com else if (if_name == "keyboard_int_pin") 13714290Sgabeblack@google.com return *keyboardIntPin.at(idx); 13814290Sgabeblack@google.com else 13914290Sgabeblack@google.com return BasicPioDevice::getPort(if_name, idx); 14014290Sgabeblack@google.com } 14114290Sgabeblack@google.com 14211175Sandreas.hansson@arm.com AddrRangeList getAddrRanges() const override; 1435831Sgblack@eecs.umich.edu 14411175Sandreas.hansson@arm.com Tick read(PacketPtr pkt) override; 1455831Sgblack@eecs.umich.edu 14611175Sandreas.hansson@arm.com Tick write(PacketPtr pkt) override; 1477903Shestness@cs.utexas.edu 14811168Sandreas.hansson@arm.com void serialize(CheckpointOut &cp) const override; 14911168Sandreas.hansson@arm.com void unserialize(CheckpointIn &cp) override; 1505831Sgblack@eecs.umich.edu}; 1515831Sgblack@eecs.umich.edu 1527811Ssteve.reinhardt@amd.com} // namespace X86ISA 1535831Sgblack@eecs.umich.edu 1545831Sgblack@eecs.umich.edu#endif //__DEV_X86_I8042_HH__ 155