i8042.hh (11175:2324ed5fa9f4) | i8042.hh (12653:4f6b6c1a8e2f) |
---|---|
1/* 2 * Copyright (c) 2008 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 19 unchanged lines hidden (view full) --- 28 * Authors: Gabe Black 29 */ 30 31#ifndef __DEV_X86_I8042_HH__ 32#define __DEV_X86_I8042_HH__ 33 34#include <deque> 35 | 1/* 2 * Copyright (c) 2008 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 19 unchanged lines hidden (view full) --- 28 * Authors: Gabe Black 29 */ 30 31#ifndef __DEV_X86_I8042_HH__ 32#define __DEV_X86_I8042_HH__ 33 34#include <deque> 35 |
36#include "dev/x86/intdev.hh" | |
37#include "dev/io_device.hh" | 36#include "dev/io_device.hh" |
37#include "dev/ps2/device.hh" 38#include "dev/x86/intdev.hh" |
|
38#include "params/I8042.hh" 39 40namespace X86ISA 41{ 42 43class IntPin; 44 | 39#include "params/I8042.hh" 40 41namespace X86ISA 42{ 43 44class IntPin; 45 |
45class PS2Device 46{ 47 protected: 48 std::deque<uint8_t> outBuffer; 49 50 static const uint16_t NoCommand = (uint16_t)(-1); 51 52 uint16_t lastCommand; 53 void bufferData(const uint8_t *data, int size); 54 void ack(); 55 void nack(); 56 57 public: 58 virtual ~PS2Device() 59 {}; 60 61 PS2Device() : lastCommand(NoCommand) 62 {} 63 64 virtual void serialize(const std::string &base, CheckpointOut &cp) const; 65 virtual void unserialize(const std::string &base, CheckpointIn &cp); 66 67 bool hasData() 68 { 69 return !outBuffer.empty(); 70 } 71 72 uint8_t getData() 73 { 74 uint8_t data = outBuffer.front(); 75 outBuffer.pop_front(); 76 return data; 77 } 78 79 virtual bool processData(uint8_t data) = 0; 80}; 81 82class PS2Mouse : public PS2Device 83{ 84 protected: 85 static const uint8_t ID[]; 86 87 enum Command 88 { 89 Scale1to1 = 0xE6, 90 Scale2to1 = 0xE7, 91 SetResolution = 0xE8, 92 GetStatus = 0xE9, 93 ReadData = 0xEB, 94 ResetWrapMode = 0xEC, 95 WrapMode = 0xEE, 96 RemoteMode = 0xF0, 97 ReadID = 0xF2, 98 SampleRate = 0xF3, 99 EnableReporting = 0xF4, 100 DisableReporting = 0xF5, 101 DefaultsAndDisable = 0xF6, 102 Resend = 0xFE, 103 Reset = 0xFF 104 }; 105 106 BitUnion8(Status) 107 Bitfield<6> remote; 108 Bitfield<5> enabled; 109 Bitfield<4> twoToOne; 110 Bitfield<2> leftButton; 111 Bitfield<0> rightButton; 112 EndBitUnion(Status) 113 114 Status status; 115 uint8_t resolution; 116 uint8_t sampleRate; 117 public: 118 PS2Mouse() : PS2Device(), status(0), resolution(4), sampleRate(100) 119 {} 120 121 bool processData(uint8_t data) override; 122 123 void serialize(const std::string &base, CheckpointOut &cp) const override; 124 void unserialize(const std::string &base, CheckpointIn &cp) override; 125}; 126 127class PS2Keyboard : public PS2Device 128{ 129 protected: 130 static const uint8_t ID[]; 131 132 enum Command 133 { 134 LEDWrite = 0xED, 135 DiagnosticEcho = 0xEE, 136 AlternateScanCodes = 0xF0, 137 ReadID = 0xF2, 138 TypematicInfo = 0xF3, 139 Enable = 0xF4, 140 Disable = 0xF5, 141 DefaultsAndDisable = 0xF6, 142 AllKeysToTypematic = 0xF7, 143 AllKeysToMakeRelease = 0xF8, 144 AllKeysToMake = 0xF9, 145 AllKeysToTypematicMakeRelease = 0xFA, 146 KeyToTypematic = 0xFB, 147 KeyToMakeRelease = 0xFC, 148 KeyToMakeOnly = 0xFD, 149 Resend = 0xFE, 150 Reset = 0xFF 151 }; 152 153 public: 154 bool processData(uint8_t data) override; 155}; 156 | |
157class I8042 : public BasicPioDevice 158{ 159 protected: 160 enum Command 161 { 162 GetCommandByte = 0x20, 163 ReadControllerRamBase = 0x20, 164 WriteCommandByte = 0x60, --- 54 unchanged lines hidden (view full) --- 219 uint8_t dataReg; 220 221 static const uint16_t NoCommand = (uint16_t)(-1); 222 uint16_t lastCommand; 223 224 IntSourcePin *mouseIntPin; 225 IntSourcePin *keyboardIntPin; 226 | 46class I8042 : public BasicPioDevice 47{ 48 protected: 49 enum Command 50 { 51 GetCommandByte = 0x20, 52 ReadControllerRamBase = 0x20, 53 WriteCommandByte = 0x60, --- 54 unchanged lines hidden (view full) --- 108 uint8_t dataReg; 109 110 static const uint16_t NoCommand = (uint16_t)(-1); 111 uint16_t lastCommand; 112 113 IntSourcePin *mouseIntPin; 114 IntSourcePin *keyboardIntPin; 115 |
227 PS2Mouse mouse; 228 PS2Keyboard keyboard; | 116 PS2Device *mouse; 117 PS2Device *keyboard; |
229 230 void writeData(uint8_t newData, bool mouse = false); 231 uint8_t readDataOut(); 232 233 public: 234 typedef I8042Params Params; 235 236 const Params * --- 20 unchanged lines hidden --- | 118 119 void writeData(uint8_t newData, bool mouse = false); 120 uint8_t readDataOut(); 121 122 public: 123 typedef I8042Params Params; 124 125 const Params * --- 20 unchanged lines hidden --- |