CS计算机代考程序代写 /* tuxctl-ioctl.c

/* tuxctl-ioctl.c
*
* Driver (skeleton) for the mp2 tuxcontrollers for ECE391 at UIUC.
*
* Mark Murphy 2006
* Andrew Ofisher 2007
* Steve Lumetta 12-13 Sep 2009
* Puskar Naha 2013
*/

#include
#include

#include #include #include #include #include #include #include #include #include #include

#include “tuxctl-ld.h”
#include “tuxctl-ioctl.h”
#include “mtcp.h”

#define debug(str, …) \
printk(KERN_DEBUG “%s: ” str, __FUNCTION__, ## __VA_ARGS__)

/************************ Protocol Implementation *************************/

/* tuxctl_handle_packet()
* IMPORTANT : Read the header for tuxctl_ldisc_data_callback() in
* tuxctl-ld.c. It calls this function, so all warnings there apply
* here as well.
*/
void tuxctl_handle_packet (struct tty_struct* tty, unsigned char* packet)
{
unsigned a, b, c;

a = packet[0]; /* Avoid printk() sign extending the 8-bit */
b = packet[1]; /* values when printing them. */
c = packet[2];

/*printk(“packet : %x %x %x\n”, a, b, c); */
}

/******** IMPORTANT NOTE: READ THIS BEFORE IMPLEMENTING THE IOCTLS ************
* *
* The ioctls should not spend any time waiting for responses to the commands *
* they send to the controller. The data is sent over the serial line at *
* 9600 BAUD. At this rate, a byte takes approximately 1 millisecond to *
* transmit; this means that there will be about 9 milliseconds between *
* the time you request that the low-level serial driver send the *
* 6-byte SET_LEDS packet and the time the 3-byte ACK packet finishes *
* arriving. This is far too long a time for a system call to take. The *
* ioctls should return immediately with success if their parameters are *
* valid. *
* *
******************************************************************************/
int
tuxctl_ioctl (struct tty_struct* tty, struct file* file,
unsigned cmd, unsigned long arg)
{
switch (cmd) {
case TUX_INIT:
case TUX_BUTTONS:
case TUX_SET_LED:
case TUX_LED_ACK:
case TUX_LED_REQUEST:
case TUX_READ_LED:
default:
return -EINVAL;
}
}