本次C语言代写的主要内容是使用OS操作系统完成驱动程序开发
Task Description
The objective of this assignment is to extend a character device driver and get familiar with accessing kernel data structures. Specifically, you will:
- ● Extend a character device driver as a kernel module
- ● Implement an IOCTL interface in the character device driver, following the specifications
which we will describe later
- ● Extend a user space program to interact with the character device driver, following the
specifications which we will describe later
- ● Test the code in the VM we distributed for the class, using the default kernel
Project Steps
a) Fork the repository including a basic character driver and a user-space program interacting with it (you will have a private repo
containing the driver after you click the link and accept the assignment)
b) Study about characters device drivers
c) Extend the character device driver (under driver/) and user-space program (under src/) to satisfy the specifications of the assignment. DO NOT include new files. Modify existing files to introduce your functionality.
i) (30pts) Extend the scull device driver by adding support for a new IOCTL command:
1) We have prepared several example commands in the “scull_ioctl” function in the “scull.c” file; You may refer to those examples when adding a new command.
2) This command should return (copy) a task_info structure (shown below) to the issuer of the IOCTL in userspace. The struct should be populated with the corresponding fields in task_struct of the task corresponding to the issuer of the IOCTL, which can be accessed using the “current” macro in the IOCTL handler in the driver. Note: You need to define this structure as shown below.
3) The command should be defined with the appropriate IOCTL MACRO using ‘k’ and 7 as code and sequence numbers, and struct task_info as the type of the data being transferred.
struct task_info { long state;
void *stack; unsigned int cpu; int prio; int static_prio; int normal_prio; unsigned int rt_priority; pid_t pid; pid_t tgid; unsigned long nvcsw; unsigned long nivcsw;
};