device.hh (12653:4f6b6c1a8e2f) | device.hh (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 --- 31 unchanged lines hidden (view full) --- 40 * Authors: Gabe Black 41 * Andreas Sandberg 42 */ 43 44#ifndef __DEV_PS2_DEVICE_HH__ 45#define __DEV_PS2_DEVICE_HH__ 46 47#include <deque> | 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#ifndef __DEV_PS2_DEVICE_HH__ 45#define __DEV_PS2_DEVICE_HH__ 46 47#include <deque> |
48#include <vector> |
|
48 49#include "sim/sim_object.hh" 50 51struct PS2DeviceParams; 52 53class PS2Device : public SimObject 54{ 55 public: --- 31 unchanged lines hidden (view full) --- 87 * 88 * @param c Received data. 89 */ 90 void hostWrite(uint8_t c); 91 92 protected: /* Device interface */ 93 /** 94 * Data received from host. | 49 50#include "sim/sim_object.hh" 51 52struct PS2DeviceParams; 53 54class PS2Device : public SimObject 55{ 56 public: --- 31 unchanged lines hidden (view full) --- 88 * 89 * @param c Received data. 90 */ 91 void hostWrite(uint8_t c); 92 93 protected: /* Device interface */ 94 /** 95 * Data received from host. |
96 * 97 * Data sent to the device is buffered one byte at a time. Each 98 * time a byte is added, this function is called and passed the 99 * current buffer. It should return true if it has consumed the 100 * data and the buffer can be cleared, or false if more data is 101 * needed to process the current command. 102 * 103 * @param data Pending input data (at least one byte) 104 * @return false if more data is needed to process the current 105 * command, true otherwise. |
|
95 */ | 106 */ |
96 virtual void recv(uint8_t data) = 0; | 107 virtual bool recv(const std::vector<uint8_t> &data) = 0; |
97 98 /** 99 * Send data from a PS/2 device to a host 100 * 101 * @param data Pointer to data array 102 * @param size Size of the data array 103 */ 104 void send(const uint8_t *data, size_t size); --- 18 unchanged lines hidden (view full) --- 123 * output buffer to do rate limiting. 124 */ 125 size_t sendPending() const { return outBuffer.size(); } 126 127 private: 128 /** Device -> host FIFO */ 129 std::deque<uint8_t> outBuffer; 130 | 108 109 /** 110 * Send data from a PS/2 device to a host 111 * 112 * @param data Pointer to data array 113 * @param size Size of the data array 114 */ 115 void send(const uint8_t *data, size_t size); --- 18 unchanged lines hidden (view full) --- 134 * output buffer to do rate limiting. 135 */ 136 size_t sendPending() const { return outBuffer.size(); } 137 138 private: 139 /** Device -> host FIFO */ 140 std::deque<uint8_t> outBuffer; 141 |
142 /** Host -> device buffer */ 143 std::vector<uint8_t> inBuffer; 144 |
|
131 std::function<void()> dataAvailableCallback; 132}; 133 134#endif // __DEV_PS2_HOUSE_HH__ | 145 std::function<void()> dataAvailableCallback; 146}; 147 148#endif // __DEV_PS2_HOUSE_HH__ |