i8042.hh revision 12653
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
3612653Sandreas.sandberg@arm.com#include "dev/io_device.hh"
3712653Sandreas.sandberg@arm.com#include "dev/ps2/device.hh"
388229Snate@binkert.org#include "dev/x86/intdev.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 IntPin;
455831Sgblack@eecs.umich.edu
465831Sgblack@eecs.umich.educlass I8042 : public BasicPioDevice
475831Sgblack@eecs.umich.edu{
485831Sgblack@eecs.umich.edu  protected:
495832Sgblack@eecs.umich.edu    enum Command
505832Sgblack@eecs.umich.edu    {
515832Sgblack@eecs.umich.edu        GetCommandByte = 0x20,
525832Sgblack@eecs.umich.edu        ReadControllerRamBase = 0x20,
535832Sgblack@eecs.umich.edu        WriteCommandByte = 0x60,
545832Sgblack@eecs.umich.edu        WriteControllerRamBase = 0x60,
555832Sgblack@eecs.umich.edu        CheckForPassword = 0xA4,
565832Sgblack@eecs.umich.edu        LoadPassword = 0xA5,
575832Sgblack@eecs.umich.edu        CheckPassword = 0xA6,
585832Sgblack@eecs.umich.edu        DisableMouse = 0xA7,
595832Sgblack@eecs.umich.edu        EnableMouse = 0xA8,
605832Sgblack@eecs.umich.edu        TestMouse = 0xA9,
615832Sgblack@eecs.umich.edu        SelfTest = 0xAA,
625832Sgblack@eecs.umich.edu        InterfaceTest = 0xAB,
635832Sgblack@eecs.umich.edu        DiagnosticDump = 0xAC,
645832Sgblack@eecs.umich.edu        DisableKeyboard = 0xAD,
655832Sgblack@eecs.umich.edu        EnableKeyboard = 0xAE,
665832Sgblack@eecs.umich.edu        ReadInputPort = 0xC0,
675832Sgblack@eecs.umich.edu        ContinuousPollLow = 0xC1,
685832Sgblack@eecs.umich.edu        ContinuousPollHigh = 0xC2,
695832Sgblack@eecs.umich.edu        ReadOutputPort = 0xD0,
705832Sgblack@eecs.umich.edu        WriteOutputPort = 0xD1,
715832Sgblack@eecs.umich.edu        WriteKeyboardOutputBuff = 0xD2,
725832Sgblack@eecs.umich.edu        WriteMouseOutputBuff = 0xD3,
735832Sgblack@eecs.umich.edu        WriteToMouse = 0xD4,
745832Sgblack@eecs.umich.edu        DisableA20 = 0xDD,
755832Sgblack@eecs.umich.edu        EnableA20 = 0xDF,
765832Sgblack@eecs.umich.edu        ReadTestInputs = 0xE0,
775832Sgblack@eecs.umich.edu        PulseOutputBitBase = 0xF0,
785832Sgblack@eecs.umich.edu        SystemReset = 0xFE
795832Sgblack@eecs.umich.edu    };
805832Sgblack@eecs.umich.edu
815831Sgblack@eecs.umich.edu    BitUnion8(StatusReg)
825831Sgblack@eecs.umich.edu        Bitfield<7> parityError;
835831Sgblack@eecs.umich.edu        Bitfield<6> timeout;
845831Sgblack@eecs.umich.edu        Bitfield<5> mouseOutputFull;
855831Sgblack@eecs.umich.edu        Bitfield<4> keyboardUnlocked;
865831Sgblack@eecs.umich.edu        Bitfield<3> commandLast;
875831Sgblack@eecs.umich.edu        Bitfield<2> passedSelfTest;
885831Sgblack@eecs.umich.edu        Bitfield<1> inputFull;
895831Sgblack@eecs.umich.edu        Bitfield<0> outputFull;
905831Sgblack@eecs.umich.edu    EndBitUnion(StatusReg)
915831Sgblack@eecs.umich.edu
925831Sgblack@eecs.umich.edu    BitUnion8(CommandByte)
935831Sgblack@eecs.umich.edu        Bitfield<6> convertScanCodes;
945831Sgblack@eecs.umich.edu        Bitfield<5> disableMouse;
955831Sgblack@eecs.umich.edu        Bitfield<4> disableKeyboard;
965831Sgblack@eecs.umich.edu        Bitfield<2> passedSelfTest;
975831Sgblack@eecs.umich.edu        Bitfield<1> mouseFullInt;
985831Sgblack@eecs.umich.edu        Bitfield<0> keyboardFullInt;
995831Sgblack@eecs.umich.edu    EndBitUnion(CommandByte)
1005831Sgblack@eecs.umich.edu
1015831Sgblack@eecs.umich.edu    Tick latency;
1025831Sgblack@eecs.umich.edu    Addr dataPort;
1035831Sgblack@eecs.umich.edu    Addr commandPort;
1045831Sgblack@eecs.umich.edu
1055831Sgblack@eecs.umich.edu    StatusReg statusReg;
1065831Sgblack@eecs.umich.edu    CommandByte commandByte;
1075831Sgblack@eecs.umich.edu
1085831Sgblack@eecs.umich.edu    uint8_t dataReg;
1095831Sgblack@eecs.umich.edu
1105831Sgblack@eecs.umich.edu    static const uint16_t NoCommand = (uint16_t)(-1);
1115831Sgblack@eecs.umich.edu    uint16_t lastCommand;
1125831Sgblack@eecs.umich.edu
1135832Sgblack@eecs.umich.edu    IntSourcePin *mouseIntPin;
1145832Sgblack@eecs.umich.edu    IntSourcePin *keyboardIntPin;
1155831Sgblack@eecs.umich.edu
11612653Sandreas.sandberg@arm.com    PS2Device *mouse;
11712653Sandreas.sandberg@arm.com    PS2Device *keyboard;
1185831Sgblack@eecs.umich.edu
1195832Sgblack@eecs.umich.edu    void writeData(uint8_t newData, bool mouse = false);
1205831Sgblack@eecs.umich.edu    uint8_t readDataOut();
1215831Sgblack@eecs.umich.edu
1225831Sgblack@eecs.umich.edu  public:
1235831Sgblack@eecs.umich.edu    typedef I8042Params Params;
1245831Sgblack@eecs.umich.edu
1255831Sgblack@eecs.umich.edu    const Params *
1265831Sgblack@eecs.umich.edu    params() const
1275831Sgblack@eecs.umich.edu    {
1285831Sgblack@eecs.umich.edu        return dynamic_cast<const Params *>(_params);
1295831Sgblack@eecs.umich.edu    }
1305831Sgblack@eecs.umich.edu
1319808Sstever@gmail.com    I8042(Params *p);
1325831Sgblack@eecs.umich.edu
13311175Sandreas.hansson@arm.com    AddrRangeList getAddrRanges() const override;
1345831Sgblack@eecs.umich.edu
13511175Sandreas.hansson@arm.com    Tick read(PacketPtr pkt) override;
1365831Sgblack@eecs.umich.edu
13711175Sandreas.hansson@arm.com    Tick write(PacketPtr pkt) override;
1387903Shestness@cs.utexas.edu
13911168Sandreas.hansson@arm.com    void serialize(CheckpointOut &cp) const override;
14011168Sandreas.hansson@arm.com    void unserialize(CheckpointIn &cp) override;
1415831Sgblack@eecs.umich.edu};
1425831Sgblack@eecs.umich.edu
1437811Ssteve.reinhardt@amd.com} // namespace X86ISA
1445831Sgblack@eecs.umich.edu
1455831Sgblack@eecs.umich.edu#endif //__DEV_X86_I8042_HH__
146