23 #include <util/atomic.h> 29 template <u
int8_t Size,
typename TDiagnostics = NullDiagnostics>
30 class KeyboardOutputBuffer {
36 TDiagnostics *diagnostics;
38 const uint8_t EmptyMarker = 0xff;
41 KeyboardOutputBuffer(TDiagnostics &diagnostics) {
42 this->head = EmptyMarker;
44 this->diagnostics = &diagnostics;
51 uint8_t nextTail = (this->tail + 1) % Size;
52 if (this->head == EmptyMarker) {
53 this->head = this->tail;
55 else if (this->head == this->tail) {
56 this->diagnostics->bufferOverflow();
59 buffer[this->tail] = valueAtTop;
60 this->tail = nextTail;
68 ATOMIC_BLOCK(ATOMIC_FORCEON)
70 if (this->head == EmptyMarker) {
74 valueAtTop = buffer[this->head];
75 int h = (this->head + 1) % Size;
76 this->head = (h == this->tail) ? EmptyMarker : h;
84 ATOMIC_BLOCK(ATOMIC_FORCEON)
86 uint8_t h = this->head;
93 ATOMIC_BLOCK(ATOMIC_FORCEON) {
94 this->head = EmptyMarker;
105 template <
typename TDiagnostics>
106 class KeyboardOutputBuffer<1, TDiagnostics> {
108 TDiagnostics *diagnostics;
111 KeyboardOutputBuffer(TDiagnostics &diagnostics) {
112 this->diagnostics = &diagnostics;
121 this->diagnostics->bufferOverflow();
123 this->buffer = valueAtTop;
131 ATOMIC_BLOCK(ATOMIC_FORCEON)
133 valueAtTop = this->buffer;
Definition: ps2_AnsiTranslator.h:24
KeyboardOutput
Byte-codes sent back from the Ps2 keyboard to the host.
Definition: ps2_KeyboardOutput.h:31