I just want to know how to implement “ring buffer” in driver ,so I study the kbdclass in DDK 2600.
And I find the processing section of the buffer locates in KeyboardClassServiceCallback function.
I read it some times , but still can’t understand how the “second move” happens :
if ( ( bytesToMove - moveSize ) > 0 )
/****************************************************************
this is the obscure place. I have deduce it for some times , but I just find ( bytesToMove == moveSize ) , I think there should be a “second move” , but the parametes used here is wrog. /****************************************************************/
{
// Special case. The data must wrap in the class input data buffer.
// Copy the rest of the port input data into the beginning of the
// class input data queue.
// MoveSize <- Number of bytes to handle in the second move.
moveSize = bytesToMove - moveSize;
// Do the move from the port data queue to the class data queue.
KbdPrint((
3,
“KBDCLASS-KeyboardClassServiceCallback: number of bytes in second move to class 0x%lx\n”,
moveSize
));
KbdPrint((
3,
“KBDCLASS-KeyboardClassServiceCallback: move bytes from 0x%lx to 0x%lx\n”,
(PCHAR) InputDataStart,
(PCHAR) deviceExtension->DataIn
));
RtlMoveMemory(
(PCHAR) deviceExtension->DataIn,
(PCHAR) InputDataStart,
moveSize
);
// Update the class input data queue insertion pointer.
deviceExtension->DataIn = (PKEYBOARD_INPUT_DATA)(((PCHAR) deviceExtension->DataIn) + moveSize);
}
// Update the input data queue counter.
deviceExtension->InputCount += ( bytesToMove / sizeof(KEYBOARD_INPUT_DATA));
/****************************************************************/
count all the input charaters ? why ? for what purpose?
/****************************************************************/
*InputDataConsumed += (bytesToMove / sizeof(KEYBOARD_INPUT_DATA));