C语言代写|ECE391 Machine Problem 1 Text-Mode Fish Animation
AUTHOR
essaygo
PUBLISHED ON:
2022年2月15日
PUBLISHED IN:

这是一个美国的利用程序进行汇编和驱动的C语言代写

In this machine problem, you will modify the Linux real-time clock (RTC) driver to toggle characters on the text-mode video console from one ASCII character to another, with a user-settable toggle rate. This will serve a dual purpose:
first, it will be an exercise in writing x86 assembly, allowing you to gain experience with the x86 ISA. Second, it will provide an introduction into how drivers accomplish tasks inside the Linux kernel.
Please read the entire document before you begin.

A Note On This Handout: The sections entitled “Linux Device Driver Overview,” “RTC Overview,” “Ioctl Functions,” and “Tasklets” contain background Linux knowledge which is not critical for you to complete this MP. The material described in these background sections will be covered in lecture in the next few weeks, but it may be helpful to read these sections to familiarize yourself with the context of your code in this MP.

MP1 Assignment

You will add four new ioctls to the existing RTC driver, as well as a tasklet that will update the text-mode video screen on every RTC interrupt.

Your code will reside in mp1.S, a GNU-style assembly file. Assembly files with a capital-S extension (.S) are prepro cessed using the standard C preprocessor before being assembled, so things like #include and #define are OK to use. Your code must be implemented using GNU x86 assembly.

Please be aware that the preprocessor will catch anything that looks like a directive and may prevent your code from assembling. Use of # to denote comments is problematic, especially for those who like to begin comments with “if.”

The assembler accepts both C-style /* comments */ and C++-style // comments.

MP1 Data Structure

The main structure you will be working with is mp1 blink struct.

struct mp1_blink_struct {
unsigned short location; /* Linear offset on text-mode buffer */
char on_char; /* Char to put during “on” period */
char off_char; /* Char to put during “off” period */
unsigned short on_length; /* Length of on period
* in number of RTC interrupts */
unsigned short off_length; /* Length of off period */
unsigned short countdown; /* Number of RTC interrupts left in period */
unsigned short status; /* Status word (on=1/off=0) */
struct mp1_blink_struct *next; /* pointer to next item in linked list */
}

This structure definition is usable only in C programs. There are constants defined for you at the top of the provided mp1.S that give you easy access to the fields in this struct from your assembly code. See the comments in mp1.S for further information on how to use them.

To implement characters “blinking” on the text-mode video console, a linked list will be created by your modified RTC driver that will allow any location on the text-mode video console to be toggling characters from off char to on char and back, with toggle rates determined by on length and off length. A pointer to the first element in the linked list (the head of the list) is defined in the mp1.S file as a global variable, mp1 list head. mp1 list head is initialized to NULL (the value it holds is zero) to indicate that there are currently no blinking locations on the screen.
The tail element of the list will have its next field equal to NULL to indicate that it is the last element. A diagram of this singly-linked list layout for a three-item list is shown on the following page. Example memory addresses of structures and variables are shown in parentheses.

MP1 Tasklet

The first function you need to write is called mp1 rtc tasklet. The tasklet must update the state of the game. Its C prototype is:

void mp1 rtc tasklet (unsigned long);

Every time an RTC interrupt is generated, mp1 rtc tasklet will be called. Your tasklet will walk down the mp1 list head list, examining each mp1 blink struct structure. The function first decrements the countdown field of the structure. If the countdown field has reached zero after the decrement, the tasklet will examine the status field. If this field is equal to 1, that location currently has the on char character; if this field is 0, that localtion currently has the off char character. The tasklet should put the opposite character (i.e. interchange the status between on/off) out to video memory with a call to mp1 poke. For information on how to draw to the screen, see the “Text-Mode Video” section. Finally, the tasklet updates the countdown field by copying the value from the opposite length field to countdown. For example, if the character was currently off and you just turned it on, copy on length to countdown. In this way, the toggle rate for each character is controlled by the length fields. The tasklet then must move on to the next list element. The function returns when it reaches the end of the list.

You may also like:
扫描二维码或者
添加微信skygpa