i8042.hh revision 14290:fa11f961ae4e
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
368229Snate@binkert.org#include "dev/intpin.hh"
375831Sgblack@eecs.umich.edu#include "dev/io_device.hh"
385831Sgblack@eecs.umich.edu#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
455832Sgblack@eecs.umich.edu{
465832Sgblack@eecs.umich.edu  protected:
475832Sgblack@eecs.umich.edu    enum Command
4811007Sandreas.sandberg@arm.com    {
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,
6411007Sandreas.sandberg@arm.com        ReadInputPort = 0xC0,
6511007Sandreas.sandberg@arm.com        ContinuousPollLow = 0xC1,
6611007Sandreas.sandberg@arm.com        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,
7511007Sandreas.sandberg@arm.com        PulseOutputBitBase = 0xF0,
765832Sgblack@eecs.umich.edu        SystemReset = 0xFE
775832Sgblack@eecs.umich.edu    };
785832Sgblack@eecs.umich.edu
795832Sgblack@eecs.umich.edu    BitUnion8(StatusReg)
805832Sgblack@eecs.umich.edu        Bitfield<7> parityError;
815832Sgblack@eecs.umich.edu        Bitfield<6> timeout;
825832Sgblack@eecs.umich.edu        Bitfield<5> mouseOutputFull;
835832Sgblack@eecs.umich.edu        Bitfield<4> keyboardUnlocked;
845832Sgblack@eecs.umich.edu        Bitfield<3> commandLast;
855832Sgblack@eecs.umich.edu        Bitfield<2> passedSelfTest;
865832Sgblack@eecs.umich.edu        Bitfield<1> inputFull;
875832Sgblack@eecs.umich.edu        Bitfield<0> outputFull;
885832Sgblack@eecs.umich.edu    EndBitUnion(StatusReg)
895832Sgblack@eecs.umich.edu
905832Sgblack@eecs.umich.edu    BitUnion8(CommandByte)
915832Sgblack@eecs.umich.edu        Bitfield<6> convertScanCodes;
925832Sgblack@eecs.umich.edu        Bitfield<5> disableMouse;
935832Sgblack@eecs.umich.edu        Bitfield<4> disableKeyboard;
945832Sgblack@eecs.umich.edu        Bitfield<2> passedSelfTest;
955832Sgblack@eecs.umich.edu        Bitfield<1> mouseFullInt;
965832Sgblack@eecs.umich.edu        Bitfield<0> keyboardFullInt;
975832Sgblack@eecs.umich.edu    EndBitUnion(CommandByte)
985832Sgblack@eecs.umich.edu
995832Sgblack@eecs.umich.edu    Tick latency;
1005832Sgblack@eecs.umich.edu    Addr dataPort;
1015832Sgblack@eecs.umich.edu    Addr commandPort;
1025832Sgblack@eecs.umich.edu
1035832Sgblack@eecs.umich.edu    StatusReg statusReg;
1045832Sgblack@eecs.umich.edu    CommandByte commandByte;
1055832Sgblack@eecs.umich.edu
1065832Sgblack@eecs.umich.edu    uint8_t dataReg;
1075832Sgblack@eecs.umich.edu
1085832Sgblack@eecs.umich.edu    static const uint16_t NoCommand = (uint16_t)(-1);
1095832Sgblack@eecs.umich.edu    uint16_t lastCommand;
1105832Sgblack@eecs.umich.edu
1115832Sgblack@eecs.umich.edu    std::vector<::IntSourcePin<I8042> *> mouseIntPin;
1125832Sgblack@eecs.umich.edu    std::vector<::IntSourcePin<I8042> *> keyboardIntPin;
1135832Sgblack@eecs.umich.edu
1145832Sgblack@eecs.umich.edu    PS2Device *mouse;
1155832Sgblack@eecs.umich.edu    PS2Device *keyboard;
1165832Sgblack@eecs.umich.edu
1175832Sgblack@eecs.umich.edu    void writeData(uint8_t newData, bool mouse = false);
1185832Sgblack@eecs.umich.edu    uint8_t readDataOut();
1195832Sgblack@eecs.umich.edu
1205832Sgblack@eecs.umich.edu  public:
12111175Sandreas.hansson@arm.com    typedef I8042Params Params;
1227903Shestness@cs.utexas.edu
12311168Sandreas.hansson@arm.com    const Params *
12411168Sandreas.hansson@arm.com    params() const
1255832Sgblack@eecs.umich.edu    {
1265832Sgblack@eecs.umich.edu        return dynamic_cast<const Params *>(_params);
1275832Sgblack@eecs.umich.edu    }
1285832Sgblack@eecs.umich.edu
1295832Sgblack@eecs.umich.edu    I8042(Params *p);
1305832Sgblack@eecs.umich.edu
1315832Sgblack@eecs.umich.edu    Port &
1325832Sgblack@eecs.umich.edu    getPort(const std::string &if_name, PortID idx=InvalidPortID) override
1335832Sgblack@eecs.umich.edu    {
1345832Sgblack@eecs.umich.edu        if (if_name == "mouse_int_pin")
1355832Sgblack@eecs.umich.edu            return *mouseIntPin.at(idx);
1365832Sgblack@eecs.umich.edu        else if (if_name == "keyboard_int_pin")
1375832Sgblack@eecs.umich.edu            return *keyboardIntPin.at(idx);
1385832Sgblack@eecs.umich.edu        else
1395832Sgblack@eecs.umich.edu            return BasicPioDevice::getPort(if_name, idx);
1405832Sgblack@eecs.umich.edu    }
1415832Sgblack@eecs.umich.edu
1425832Sgblack@eecs.umich.edu    AddrRangeList getAddrRanges() const override;
1435832Sgblack@eecs.umich.edu
1445832Sgblack@eecs.umich.edu    Tick read(PacketPtr pkt) override;
1455832Sgblack@eecs.umich.edu
1465832Sgblack@eecs.umich.edu    Tick write(PacketPtr pkt) override;
1475832Sgblack@eecs.umich.edu
1485832Sgblack@eecs.umich.edu    void serialize(CheckpointOut &cp) const override;
1495832Sgblack@eecs.umich.edu    void unserialize(CheckpointIn &cp) override;
1505832Sgblack@eecs.umich.edu};
1515832Sgblack@eecs.umich.edu
1525832Sgblack@eecs.umich.edu} // namespace X86ISA
1535832Sgblack@eecs.umich.edu
15411175Sandreas.hansson@arm.com#endif //__DEV_X86_I8042_HH__
1555832Sgblack@eecs.umich.edu