keyboard.cc (12657:b0e98d6b4456) | keyboard.cc (12660:c5caca5f7d68) |
---|---|
1/* 2 * Copyright (c) 2017-2018 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 31 unchanged lines hidden (view full) --- 40 * Authors: Gabe Black 41 * Andreas Sandberg 42 */ 43 44#include "dev/ps2/keyboard.hh" 45 46#include "base/logging.hh" 47#include "debug/PS2.hh" | 1/* 2 * Copyright (c) 2017-2018 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 31 unchanged lines hidden (view full) --- 40 * Authors: Gabe Black 41 * Andreas Sandberg 42 */ 43 44#include "dev/ps2/keyboard.hh" 45 46#include "base/logging.hh" 47#include "debug/PS2.hh" |
48#include "dev/ps2.hh" | 48#include "dev/ps2/types.hh" |
49#include "params/PS2Keyboard.hh" 50 | 49#include "params/PS2Keyboard.hh" 50 |
51const uint8_t PS2Keyboard::ID[] = {0xab, 0x83}; 52 | |
53PS2Keyboard::PS2Keyboard(const PS2KeyboardParams *p) 54 : PS2Device(p), 55 shiftDown(false), 56 enabled(false) 57{ 58 if (p->vnc) 59 p->vnc->setKeyboard(this); 60} --- 13 unchanged lines hidden (view full) --- 74 UNSERIALIZE_SCALAR(shiftDown); 75 UNSERIALIZE_SCALAR(enabled); 76} 77 78bool 79PS2Keyboard::recv(const std::vector<uint8_t> &data) 80{ 81 switch (data[0]) { | 51PS2Keyboard::PS2Keyboard(const PS2KeyboardParams *p) 52 : PS2Device(p), 53 shiftDown(false), 54 enabled(false) 55{ 56 if (p->vnc) 57 p->vnc->setKeyboard(this); 58} --- 13 unchanged lines hidden (view full) --- 72 UNSERIALIZE_SCALAR(shiftDown); 73 UNSERIALIZE_SCALAR(enabled); 74} 75 76bool 77PS2Keyboard::recv(const std::vector<uint8_t> &data) 78{ 79 switch (data[0]) { |
82 case LEDWrite: | 80 case Ps2::ReadID: 81 DPRINTF(PS2, "Got keyboard read ID command.\n"); 82 sendAck(); 83 send(Ps2::Keyboard::ID); 84 return true; 85 case Ps2::Enable: 86 DPRINTF(PS2, "Enabling the keyboard.\n"); 87 enabled = true; 88 sendAck(); 89 return true; 90 case Ps2::Disable: 91 DPRINTF(PS2, "Disabling the keyboard.\n"); 92 enabled = false; 93 sendAck(); 94 return true; 95 case Ps2::DefaultsAndDisable: 96 DPRINTF(PS2, "Disabling and resetting the keyboard.\n"); 97 enabled = false; 98 sendAck(); 99 return true; 100 case Ps2::Reset: 101 DPRINTF(PS2, "Resetting keyboard.\n"); 102 enabled = true; 103 sendAck(); 104 send(Ps2::SelfTestPass); 105 return true; 106 case Ps2::Resend: 107 panic("Keyboard resend unimplemented.\n"); 108 109 case Ps2::Keyboard::LEDWrite: |
83 if (data.size() == 1) { 84 DPRINTF(PS2, "Got LED write command.\n"); 85 sendAck(); 86 return false; 87 } else { 88 DPRINTF(PS2, "Setting LEDs: " 89 "caps lock %s, num lock %s, scroll lock %s\n", 90 bits(data[1], 2) ? "on" : "off", 91 bits(data[1], 1) ? "on" : "off", 92 bits(data[1], 0) ? "on" : "off"); 93 sendAck(); 94 return true; 95 } | 110 if (data.size() == 1) { 111 DPRINTF(PS2, "Got LED write command.\n"); 112 sendAck(); 113 return false; 114 } else { 115 DPRINTF(PS2, "Setting LEDs: " 116 "caps lock %s, num lock %s, scroll lock %s\n", 117 bits(data[1], 2) ? "on" : "off", 118 bits(data[1], 1) ? "on" : "off", 119 bits(data[1], 0) ? "on" : "off"); 120 sendAck(); 121 return true; 122 } |
96 case DiagnosticEcho: | 123 case Ps2::Keyboard::DiagnosticEcho: |
97 panic("Keyboard diagnostic echo unimplemented.\n"); | 124 panic("Keyboard diagnostic echo unimplemented.\n"); |
98 case AlternateScanCodes: | 125 case Ps2::Keyboard::AlternateScanCodes: |
99 panic("Accessing alternate scan codes unimplemented.\n"); | 126 panic("Accessing alternate scan codes unimplemented.\n"); |
100 case ReadID: 101 DPRINTF(PS2, "Got keyboard read ID command.\n"); 102 sendAck(); 103 send((uint8_t *)&ID, sizeof(ID)); 104 return true; 105 case TypematicInfo: | 127 case Ps2::Keyboard::TypematicInfo: |
106 if (data.size() == 1) { 107 DPRINTF(PS2, "Setting typematic info.\n"); 108 sendAck(); 109 return false; 110 } else { 111 DPRINTF(PS2, "Setting typematic info to %#02x.\n", data[1]); 112 sendAck(); 113 return true; 114 } | 128 if (data.size() == 1) { 129 DPRINTF(PS2, "Setting typematic info.\n"); 130 sendAck(); 131 return false; 132 } else { 133 DPRINTF(PS2, "Setting typematic info to %#02x.\n", data[1]); 134 sendAck(); 135 return true; 136 } |
115 case Enable: 116 DPRINTF(PS2, "Enabling the keyboard.\n"); 117 enabled = true; 118 sendAck(); 119 return true; 120 case Disable: 121 DPRINTF(PS2, "Disabling the keyboard.\n"); 122 enabled = false; 123 sendAck(); 124 return true; 125 case DefaultsAndDisable: 126 DPRINTF(PS2, "Disabling and resetting the keyboard.\n"); 127 enabled = false; 128 sendAck(); 129 return true; 130 case Reset: 131 DPRINTF(PS2, "Resetting keyboard.\n"); 132 sendAck(); 133 enabled = true; 134 send(Ps2::SelfTestPass); 135 return true; 136 case AllKeysToTypematic: | 137 case Ps2::Keyboard::AllKeysToTypematic: |
137 panic("Setting all keys to typemantic unimplemented.\n"); | 138 panic("Setting all keys to typemantic unimplemented.\n"); |
138 case AllKeysToMakeRelease: | 139 case Ps2::Keyboard::AllKeysToMakeRelease: |
139 panic("Setting all keys to make/release unimplemented.\n"); | 140 panic("Setting all keys to make/release unimplemented.\n"); |
140 case AllKeysToMake: | 141 case Ps2::Keyboard::AllKeysToMake: |
141 panic("Setting all keys to make unimplemented.\n"); | 142 panic("Setting all keys to make unimplemented.\n"); |
142 case AllKeysToTypematicMakeRelease: | 143 case Ps2::Keyboard::AllKeysToTypematicMakeRelease: |
143 panic("Setting all keys to " 144 "typematic/make/release unimplemented.\n"); | 144 panic("Setting all keys to " 145 "typematic/make/release unimplemented.\n"); |
145 case KeyToTypematic: | 146 case Ps2::Keyboard::KeyToTypematic: |
146 panic("Setting a key to typematic unimplemented.\n"); | 147 panic("Setting a key to typematic unimplemented.\n"); |
147 case KeyToMakeRelease: | 148 case Ps2::Keyboard::KeyToMakeRelease: |
148 panic("Setting a key to make/release unimplemented.\n"); | 149 panic("Setting a key to make/release unimplemented.\n"); |
149 case KeyToMakeOnly: | 150 case Ps2::Keyboard::KeyToMakeOnly: |
150 panic("Setting key to make only unimplemented.\n"); | 151 panic("Setting key to make only unimplemented.\n"); |
151 case Resend: 152 panic("Keyboard resend unimplemented.\n"); | |
153 default: 154 panic("Unknown keyboard command %#02x.\n", data[0]); 155 } 156} 157 158void 159PS2Keyboard::keyPress(uint32_t key, bool down) 160{ --- 23 unchanged lines hidden --- | 152 default: 153 panic("Unknown keyboard command %#02x.\n", data[0]); 154 } 155} 156 157void 158PS2Keyboard::keyPress(uint32_t key, bool down) 159{ --- 23 unchanged lines hidden --- |