keyboard.cc (12654:749de33b7af6) | keyboard.cc (12656:335489e574f3) |
---|---|
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 --- 38 unchanged lines hidden (view full) --- 47#include "debug/PS2.hh" 48#include "dev/ps2.hh" 49#include "params/PS2Keyboard.hh" 50 51const uint8_t PS2Keyboard::ID[] = {0xab, 0x83}; 52 53PS2Keyboard::PS2Keyboard(const PS2KeyboardParams *p) 54 : PS2Device(p), | 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 --- 38 unchanged lines hidden (view full) --- 47#include "debug/PS2.hh" 48#include "dev/ps2.hh" 49#include "params/PS2Keyboard.hh" 50 51const uint8_t PS2Keyboard::ID[] = {0xab, 0x83}; 52 53PS2Keyboard::PS2Keyboard(const PS2KeyboardParams *p) 54 : PS2Device(p), |
55 lastCommand(NoCommand), | |
56 shiftDown(false), 57 enabled(false) 58{ 59 if (p->vnc) 60 p->vnc->setKeyboard(this); 61} 62 63void 64PS2Keyboard::serialize(CheckpointOut &cp) const 65{ 66 PS2Device::serialize(cp); | 55 shiftDown(false), 56 enabled(false) 57{ 58 if (p->vnc) 59 p->vnc->setKeyboard(this); 60} 61 62void 63PS2Keyboard::serialize(CheckpointOut &cp) const 64{ 65 PS2Device::serialize(cp); |
67 SERIALIZE_SCALAR(lastCommand); | |
68 SERIALIZE_SCALAR(shiftDown); 69 SERIALIZE_SCALAR(enabled); 70} 71 72void 73PS2Keyboard::unserialize(CheckpointIn &cp) 74{ 75 PS2Device::unserialize(cp); | 66 SERIALIZE_SCALAR(shiftDown); 67 SERIALIZE_SCALAR(enabled); 68} 69 70void 71PS2Keyboard::unserialize(CheckpointIn &cp) 72{ 73 PS2Device::unserialize(cp); |
76 UNSERIALIZE_SCALAR(lastCommand); | |
77 UNSERIALIZE_SCALAR(shiftDown); 78 UNSERIALIZE_SCALAR(enabled); 79} 80 | 74 UNSERIALIZE_SCALAR(shiftDown); 75 UNSERIALIZE_SCALAR(enabled); 76} 77 |
81void 82PS2Keyboard::recv(uint8_t data) | 78bool 79PS2Keyboard::recv(const std::vector<uint8_t> &data) |
83{ | 80{ |
84 if (lastCommand != NoCommand) { 85 switch (lastCommand) { 86 case LEDWrite: | 81 switch (data[0]) { 82 case LEDWrite: 83 if (data.size() == 1) { 84 DPRINTF(PS2, "Got LED write command.\n"); 85 sendAck(); 86 return false; 87 } else { |
87 DPRINTF(PS2, "Setting LEDs: " 88 "caps lock %s, num lock %s, scroll lock %s\n", | 88 DPRINTF(PS2, "Setting LEDs: " 89 "caps lock %s, num lock %s, scroll lock %s\n", |
89 bits(data, 2) ? "on" : "off", 90 bits(data, 1) ? "on" : "off", 91 bits(data, 0) ? "on" : "off"); | 90 bits(data[1], 2) ? "on" : "off", 91 bits(data[1], 1) ? "on" : "off", 92 bits(data[1], 0) ? "on" : "off"); |
92 sendAck(); | 93 sendAck(); |
93 lastCommand = NoCommand; 94 break; 95 case TypematicInfo: 96 DPRINTF(PS2, "Setting typematic info to %#02x.\n", data); 97 sendAck(); 98 lastCommand = NoCommand; 99 break; | 94 return true; |
100 } | 95 } |
101 return; 102 } 103 104 switch (data) { 105 case LEDWrite: 106 DPRINTF(PS2, "Got LED write command.\n"); 107 sendAck(); 108 lastCommand = LEDWrite; 109 break; | |
110 case DiagnosticEcho: 111 panic("Keyboard diagnostic echo unimplemented.\n"); 112 case AlternateScanCodes: 113 panic("Accessing alternate scan codes unimplemented.\n"); 114 case ReadID: 115 DPRINTF(PS2, "Got keyboard read ID command.\n"); 116 sendAck(); 117 send((uint8_t *)&ID, sizeof(ID)); | 96 case DiagnosticEcho: 97 panic("Keyboard diagnostic echo unimplemented.\n"); 98 case AlternateScanCodes: 99 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)); |
118 break; | 104 return true; |
119 case TypematicInfo: | 105 case TypematicInfo: |
120 DPRINTF(PS2, "Setting typematic info.\n"); 121 sendAck(); 122 lastCommand = TypematicInfo; 123 break; | 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 } |
124 case Enable: 125 DPRINTF(PS2, "Enabling the keyboard.\n"); 126 enabled = true; 127 sendAck(); | 115 case Enable: 116 DPRINTF(PS2, "Enabling the keyboard.\n"); 117 enabled = true; 118 sendAck(); |
128 break; | 119 return true; |
129 case Disable: 130 DPRINTF(PS2, "Disabling the keyboard.\n"); 131 enabled = false; 132 sendAck(); | 120 case Disable: 121 DPRINTF(PS2, "Disabling the keyboard.\n"); 122 enabled = false; 123 sendAck(); |
133 break; | 124 return true; |
134 case DefaultsAndDisable: 135 DPRINTF(PS2, "Disabling and resetting the keyboard.\n"); 136 enabled = false; 137 sendAck(); | 125 case DefaultsAndDisable: 126 DPRINTF(PS2, "Disabling and resetting the keyboard.\n"); 127 enabled = false; 128 sendAck(); |
138 break; | 129 return true; |
139 case AllKeysToTypematic: 140 panic("Setting all keys to typemantic unimplemented.\n"); 141 case AllKeysToMakeRelease: 142 panic("Setting all keys to make/release unimplemented.\n"); 143 case AllKeysToMake: 144 panic("Setting all keys to make unimplemented.\n"); 145 case AllKeysToTypematicMakeRelease: 146 panic("Setting all keys to " --- 4 unchanged lines hidden (view full) --- 151 panic("Setting a key to make/release unimplemented.\n"); 152 case KeyToMakeOnly: 153 panic("Setting key to make only unimplemented.\n"); 154 case Resend: 155 panic("Keyboard resend unimplemented.\n"); 156 case Reset: 157 panic("Keyboard reset unimplemented.\n"); 158 default: | 130 case AllKeysToTypematic: 131 panic("Setting all keys to typemantic unimplemented.\n"); 132 case AllKeysToMakeRelease: 133 panic("Setting all keys to make/release unimplemented.\n"); 134 case AllKeysToMake: 135 panic("Setting all keys to make unimplemented.\n"); 136 case AllKeysToTypematicMakeRelease: 137 panic("Setting all keys to " --- 4 unchanged lines hidden (view full) --- 142 panic("Setting a key to make/release unimplemented.\n"); 143 case KeyToMakeOnly: 144 panic("Setting key to make only unimplemented.\n"); 145 case Resend: 146 panic("Keyboard resend unimplemented.\n"); 147 case Reset: 148 panic("Keyboard reset unimplemented.\n"); 149 default: |
159 panic("Unknown keyboard command %#02x.\n", data); | 150 panic("Unknown keyboard command %#02x.\n", data[0]); |
160 } 161} 162 163void 164PS2Keyboard::keyPress(uint32_t key, bool down) 165{ 166 std::list<uint8_t> keys; 167 --- 21 unchanged lines hidden --- | 151 } 152} 153 154void 155PS2Keyboard::keyPress(uint32_t key, bool down) 156{ 157 std::list<uint8_t> keys; 158 --- 21 unchanged lines hidden --- |