SlideShare a Scribd company logo
1 of 5
Download to read offline
Starter code provided below answer should be in C code please.
Starter code to edit IN C please:
#include "io.h"
#include "kernel.h"
#include "keyboard.h"
/**
* Initializes keyboard data structures and variables
*/
void keyboard_init() {
kernel_log_info("Initializing keyboard driver");
}
/**
* Scans for keyboard input and returns the raw character data
* @return raw character data from the keyboard
*/
unsigned int keyboard_scan(void) {
unsigned int c = KEY_NULL;
return c;
}
/**
* Polls for a keyboard character to be entered.
*
* If a keyboard character data is present, will scan and return
* the decoded keyboard output.
*
* @return decoded character or KEY_NULL (0) for any character
* that cannot be decoded
*/
unsigned int keyboard_poll(void) {
unsigned int c = KEY_NULL;
return c;
}
/**
* Blocks until a keyboard character has been entered
* @return decoded character entered by the keyboard or KEY_NULL
* for any character that cannot be decoded
*/
unsigned int keyboard_getc(void) {
unsigned int c = KEY_NULL;
while ((c = keyboard_poll()) == KEY_NULL);
return c;
}
/**
* Processes raw keyboard input and decodes it.
*
* Should keep track of the keyboard status for the following keys:
* SHIFT, CTRL, ALT, CAPS, NUMLOCK
*
* For all other characters, they should be decoded/mapped to ASCII
* or ASCII-friendly characters.
*
* For any character that cannot be mapped, KEY_NULL should be returned.
*
* If *all* of the status keys defined in KEY_KERNEL_DEBUG are pressed,
* while another character is entered, the kernel_debug_command()
* function should be called.
*/
unsigned int keyboard_decode(unsigned int c) {
return c;
}#include "io.h"
#include "kernel.h"
#include "keyboard.h"
/**
* Initializes keyboard data structures and variables
*/
void keyboard_init() {
kernel_log_info("Initializing keyboard driver");
}
/**
* Scans for keyboard input and returns the raw character data
* @return raw character data from the keyboard
*/
unsigned int keyboard_scan(void) {
unsigned int c = KEY_NULL;
return c;
}
/**
* Polls for a keyboard character to be entered.
*
* If a keyboard character data is present, will scan and return
* the decoded keyboard output.
*
* @return decoded character or KEY_NULL (0) for any character
* that cannot be decoded
*/
unsigned int keyboard_poll(void) {
unsigned int c = KEY_NULL;
return c;
}
/**
* Blocks until a keyboard character has been entered
* @return decoded character entered by the keyboard or KEY_NULL
* for any character that cannot be decoded
*/
unsigned int keyboard_getc(void) {
unsigned int c = KEY_NULL;
while ((c = keyboard_poll()) == KEY_NULL);
return c;
}
/**
* Processes raw keyboard input and decodes it.
*
* Should keep track of the keyboard status for the following keys:
* SHIFT, CTRL, ALT, CAPS, NUMLOCK
*
* For all other characters, they should be decoded/mapped to ASCII
* or ASCII-friendly characters.
*
* For any character that cannot be mapped, KEY_NULL should be returned.
*
* If *all* of the status keys defined in KEY_KERNEL_DEBUG are pressed,
* while another character is entered, the kernel_debug_command()
* function should be called.
*/
unsigned int keyboard_decode(unsigned int c) {
return c;
}
Part 5: Keyboard Input In addition to text output, we will want to support text input from the
keyboard. Keyboard input is handled by reading individual bytes with direct I/O. These bytes
refer to the keyboard status or keyboard data. This status or data can be read using the following
ports: Reading a byte from a port can be performed using the inportb () function: Reading in the
status can tell us if data is available as well as other parameters of the keyboard itself. For now
(especially with our emulated environment) we will simply be concerned with bit 0 which if set
indicates that keyboard data is available if the bit is set. Reading keyboard data will provide us
with something called the keyboard scan code: The keyboard scan code tells us a number of
details: 1. If the key is being pressed 2. If the key is being released 3. Which specific key is being
pressed or released Bit 7, if set (080), indicates that the key is pressed. If unset, it indicates that
the key is released. The remaining bits (06, effectively values 001 through 07f) indicate which
key is being pressed. While we are generally used to working with ASCII character codes for
representing text, keep in mind that there are many other keys that do not have any direct ASCII
character code associated. Additionally, keyboard data/characters also have a historical
relationship to the physical hardware layout for specific keyboards. A scancode of usually
indicates an error or lack of input when reading the keyboard data port. As a result, all keyboard
scan codes need to be handled and potentially mapped to characters that would be of use for
human input and output. Any key that cannot be decoded or determined to be valid when
scanning should be referred to via the defined KEY NULL value.
When decoding, you may want to refer to the list of ASCII Character Codes If we review the
scan codes, we will see that there is no distinction in case for letters (example: 01E is mapped to
the letter A). Additionally, several scan codes have multiple characters associated (example: xD
maps to both the = and + character). Since keyboard scancodes come in for single key events
(press or release), we need to make a distinction on how we interpret when a key is entered.
Keyboard hardware will naturally support "repeat" functionality so if you hold a key down, it
will appear as a sequence of press/releases. In our implementation, we will consider that a key is
entered when it is released. While alphanumeric characters and symbols are certainly important,
we should consider how other keys are handled as well. Several keys contain special meaning,
such as the "CAPS LOCK" key or "SHIFT" key. This is crucial when consider that pressing the
"SHIFT" key allows us to distingish between alternate representations. As such, for some keys,
we will want to maintain the state of whether or not they are pressed (or in some cases, such as
with "CAPS LOCK" if it was "toggled"). This will be incredibly important when we need to
decode scan codes into ASCII characters or other representations. To support keyboard input in
our operating system, we will implement the following functions: 1. keyboard_scan () to read the
keyboard scan code from the data port. 2. keyboard_decode() Decodes a scancode into an ASCII
character code or "special key" definition 3. keyboard_poll () to check if keyboard data is
present, read they keyboard scan code, decode it, and return the value 4. keyboard_getc() to
block (loop) until a valid keyboard character has been entered

More Related Content

Similar to Starter code provided below answer should be in C code please.Star.pdf

Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptxvijayapraba1
 
Help create the ccipher-h and ccipher-cc files for the caesar cipher w.pdf
Help create the ccipher-h and ccipher-cc files for the caesar cipher w.pdfHelp create the ccipher-h and ccipher-cc files for the caesar cipher w.pdf
Help create the ccipher-h and ccipher-cc files for the caesar cipher w.pdfgaurav444u
 
#includestdio.h #includestring.h #includestdlib.h.docx
#includestdio.h #includestring.h #includestdlib.h.docx#includestdio.h #includestring.h #includestdlib.h.docx
#includestdio.h #includestring.h #includestdlib.h.docxmayank272369
 
Storm Keyboard / Keypad RS-232 Wedge keyboard solution
Storm Keyboard / Keypad RS-232  Wedge keyboard solutionStorm Keyboard / Keypad RS-232  Wedge keyboard solution
Storm Keyboard / Keypad RS-232 Wedge keyboard solutiontopomax
 
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docxINPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docxjaggernaoma
 
Keyboard interrupt
Keyboard interruptKeyboard interrupt
Keyboard interruptTech_MX
 
Encryption and Decryption using Tag Design
Encryption and Decryption using Tag Design Encryption and Decryption using Tag Design
Encryption and Decryption using Tag Design Joe Jiang
 
Unicode and character sets
Unicode and character setsUnicode and character sets
Unicode and character setsrenchenyu
 
Memory management of datatypes
Memory management of datatypesMemory management of datatypes
Memory management of datatypesMonika Sanghani
 
Python Programming Full Course || Beginner to Intermediate || Bangla (বাংলা) ...
Python Programming Full Course || Beginner to Intermediate || Bangla (বাংলা) ...Python Programming Full Course || Beginner to Intermediate || Bangla (বাংলা) ...
Python Programming Full Course || Beginner to Intermediate || Bangla (বাংলা) ...Marjuk Ahmed Siddiki
 
The Morse code (see Table 6.10 in book) is a common code that is use.pdf
The Morse code (see Table 6.10 in book) is a common code that is use.pdfThe Morse code (see Table 6.10 in book) is a common code that is use.pdf
The Morse code (see Table 6.10 in book) is a common code that is use.pdfbhim1213
 
The functional design scheme of the dedicated keyboard chip kb core based on ...
The functional design scheme of the dedicated keyboard chip kb core based on ...The functional design scheme of the dedicated keyboard chip kb core based on ...
The functional design scheme of the dedicated keyboard chip kb core based on ...Vinsion Chan
 

Similar to Starter code provided below answer should be in C code please.Star.pdf (20)

Quiz 9
Quiz 9Quiz 9
Quiz 9
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptx
 
Storing text
Storing textStoring text
Storing text
 
Help create the ccipher-h and ccipher-cc files for the caesar cipher w.pdf
Help create the ccipher-h and ccipher-cc files for the caesar cipher w.pdfHelp create the ccipher-h and ccipher-cc files for the caesar cipher w.pdf
Help create the ccipher-h and ccipher-cc files for the caesar cipher w.pdf
 
#includestdio.h #includestring.h #includestdlib.h.docx
#includestdio.h #includestring.h #includestdlib.h.docx#includestdio.h #includestring.h #includestdlib.h.docx
#includestdio.h #includestring.h #includestdlib.h.docx
 
Storm Keyboard / Keypad RS-232 Wedge keyboard solution
Storm Keyboard / Keypad RS-232  Wedge keyboard solutionStorm Keyboard / Keypad RS-232  Wedge keyboard solution
Storm Keyboard / Keypad RS-232 Wedge keyboard solution
 
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docxINPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
 
Keyboard interrupt
Keyboard interruptKeyboard interrupt
Keyboard interrupt
 
Encryption and Decryption using Tag Design
Encryption and Decryption using Tag Design Encryption and Decryption using Tag Design
Encryption and Decryption using Tag Design
 
C programming language
C programming languageC programming language
C programming language
 
Unicode and character sets
Unicode and character setsUnicode and character sets
Unicode and character sets
 
Memory management of datatypes
Memory management of datatypesMemory management of datatypes
Memory management of datatypes
 
7512635.ppt
7512635.ppt7512635.ppt
7512635.ppt
 
Python Programming Full Course || Beginner to Intermediate || Bangla (বাংলা) ...
Python Programming Full Course || Beginner to Intermediate || Bangla (বাংলা) ...Python Programming Full Course || Beginner to Intermediate || Bangla (বাংলা) ...
Python Programming Full Course || Beginner to Intermediate || Bangla (বাংলা) ...
 
The Morse code (see Table 6.10 in book) is a common code that is use.pdf
The Morse code (see Table 6.10 in book) is a common code that is use.pdfThe Morse code (see Table 6.10 in book) is a common code that is use.pdf
The Morse code (see Table 6.10 in book) is a common code that is use.pdf
 
What is a Keyboard
What is a KeyboardWhat is a Keyboard
What is a Keyboard
 
The functional design scheme of the dedicated keyboard chip kb core based on ...
The functional design scheme of the dedicated keyboard chip kb core based on ...The functional design scheme of the dedicated keyboard chip kb core based on ...
The functional design scheme of the dedicated keyboard chip kb core based on ...
 
Chapter05.ppt
Chapter05.pptChapter05.ppt
Chapter05.ppt
 
Lập trình C
Lập trình CLập trình C
Lập trình C
 
int 21,16,09 h
int 21,16,09 hint 21,16,09 h
int 21,16,09 h
 

More from akaluza07

Suppose a division of Washington Instruments Incorporated that sells.pdf
Suppose a division of Washington Instruments Incorporated that sells.pdfSuppose a division of Washington Instruments Incorporated that sells.pdf
Suppose a division of Washington Instruments Incorporated that sells.pdfakaluza07
 
Use the ER Diagram that you created in your Homework Assignment ER .pdf
Use the ER Diagram that you created in your Homework Assignment ER .pdfUse the ER Diagram that you created in your Homework Assignment ER .pdf
Use the ER Diagram that you created in your Homework Assignment ER .pdfakaluza07
 
Use the ER Diagram that you created in your Homework Assignment ER.pdf
Use the ER Diagram that you created in your Homework Assignment  ER.pdfUse the ER Diagram that you created in your Homework Assignment  ER.pdf
Use the ER Diagram that you created in your Homework Assignment ER.pdfakaluza07
 
This is to test a balanced tree. I need help testing an unbalanced t.pdf
This is to test a balanced tree. I need help testing an unbalanced t.pdfThis is to test a balanced tree. I need help testing an unbalanced t.pdf
This is to test a balanced tree. I need help testing an unbalanced t.pdfakaluza07
 
This includes the following � Setup MongoDB in the cloud � Gen.pdf
This includes the following � Setup MongoDB in the cloud � Gen.pdfThis includes the following � Setup MongoDB in the cloud � Gen.pdf
This includes the following � Setup MongoDB in the cloud � Gen.pdfakaluza07
 
The Xerox Alto42 Imagine the value of cornering the technological ma.pdf
The Xerox Alto42 Imagine the value of cornering the technological ma.pdfThe Xerox Alto42 Imagine the value of cornering the technological ma.pdf
The Xerox Alto42 Imagine the value of cornering the technological ma.pdfakaluza07
 
Submit1) Java Files2) Doc file with the following contents.pdf
Submit1) Java Files2) Doc file with the following contents.pdfSubmit1) Java Files2) Doc file with the following contents.pdf
Submit1) Java Files2) Doc file with the following contents.pdfakaluza07
 
The java code works, I just need it to display the results as in t.pdf
The java code works, I just need it to display the results as in t.pdfThe java code works, I just need it to display the results as in t.pdf
The java code works, I just need it to display the results as in t.pdfakaluza07
 
The first assignment is about assessing the feasibility of the proje.pdf
The first assignment is about assessing the feasibility of the proje.pdfThe first assignment is about assessing the feasibility of the proje.pdf
The first assignment is about assessing the feasibility of the proje.pdfakaluza07
 

More from akaluza07 (9)

Suppose a division of Washington Instruments Incorporated that sells.pdf
Suppose a division of Washington Instruments Incorporated that sells.pdfSuppose a division of Washington Instruments Incorporated that sells.pdf
Suppose a division of Washington Instruments Incorporated that sells.pdf
 
Use the ER Diagram that you created in your Homework Assignment ER .pdf
Use the ER Diagram that you created in your Homework Assignment ER .pdfUse the ER Diagram that you created in your Homework Assignment ER .pdf
Use the ER Diagram that you created in your Homework Assignment ER .pdf
 
Use the ER Diagram that you created in your Homework Assignment ER.pdf
Use the ER Diagram that you created in your Homework Assignment  ER.pdfUse the ER Diagram that you created in your Homework Assignment  ER.pdf
Use the ER Diagram that you created in your Homework Assignment ER.pdf
 
This is to test a balanced tree. I need help testing an unbalanced t.pdf
This is to test a balanced tree. I need help testing an unbalanced t.pdfThis is to test a balanced tree. I need help testing an unbalanced t.pdf
This is to test a balanced tree. I need help testing an unbalanced t.pdf
 
This includes the following � Setup MongoDB in the cloud � Gen.pdf
This includes the following � Setup MongoDB in the cloud � Gen.pdfThis includes the following � Setup MongoDB in the cloud � Gen.pdf
This includes the following � Setup MongoDB in the cloud � Gen.pdf
 
The Xerox Alto42 Imagine the value of cornering the technological ma.pdf
The Xerox Alto42 Imagine the value of cornering the technological ma.pdfThe Xerox Alto42 Imagine the value of cornering the technological ma.pdf
The Xerox Alto42 Imagine the value of cornering the technological ma.pdf
 
Submit1) Java Files2) Doc file with the following contents.pdf
Submit1) Java Files2) Doc file with the following contents.pdfSubmit1) Java Files2) Doc file with the following contents.pdf
Submit1) Java Files2) Doc file with the following contents.pdf
 
The java code works, I just need it to display the results as in t.pdf
The java code works, I just need it to display the results as in t.pdfThe java code works, I just need it to display the results as in t.pdf
The java code works, I just need it to display the results as in t.pdf
 
The first assignment is about assessing the feasibility of the proje.pdf
The first assignment is about assessing the feasibility of the proje.pdfThe first assignment is about assessing the feasibility of the proje.pdf
The first assignment is about assessing the feasibility of the proje.pdf
 

Recently uploaded

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 

Recently uploaded (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 

Starter code provided below answer should be in C code please.Star.pdf

  • 1. Starter code provided below answer should be in C code please. Starter code to edit IN C please: #include "io.h" #include "kernel.h" #include "keyboard.h" /** * Initializes keyboard data structures and variables */ void keyboard_init() { kernel_log_info("Initializing keyboard driver"); } /** * Scans for keyboard input and returns the raw character data * @return raw character data from the keyboard */ unsigned int keyboard_scan(void) { unsigned int c = KEY_NULL; return c; } /** * Polls for a keyboard character to be entered. * * If a keyboard character data is present, will scan and return * the decoded keyboard output. * * @return decoded character or KEY_NULL (0) for any character * that cannot be decoded */ unsigned int keyboard_poll(void) { unsigned int c = KEY_NULL; return c; } /** * Blocks until a keyboard character has been entered * @return decoded character entered by the keyboard or KEY_NULL
  • 2. * for any character that cannot be decoded */ unsigned int keyboard_getc(void) { unsigned int c = KEY_NULL; while ((c = keyboard_poll()) == KEY_NULL); return c; } /** * Processes raw keyboard input and decodes it. * * Should keep track of the keyboard status for the following keys: * SHIFT, CTRL, ALT, CAPS, NUMLOCK * * For all other characters, they should be decoded/mapped to ASCII * or ASCII-friendly characters. * * For any character that cannot be mapped, KEY_NULL should be returned. * * If *all* of the status keys defined in KEY_KERNEL_DEBUG are pressed, * while another character is entered, the kernel_debug_command() * function should be called. */ unsigned int keyboard_decode(unsigned int c) { return c; }#include "io.h" #include "kernel.h" #include "keyboard.h" /** * Initializes keyboard data structures and variables */ void keyboard_init() { kernel_log_info("Initializing keyboard driver"); } /** * Scans for keyboard input and returns the raw character data * @return raw character data from the keyboard
  • 3. */ unsigned int keyboard_scan(void) { unsigned int c = KEY_NULL; return c; } /** * Polls for a keyboard character to be entered. * * If a keyboard character data is present, will scan and return * the decoded keyboard output. * * @return decoded character or KEY_NULL (0) for any character * that cannot be decoded */ unsigned int keyboard_poll(void) { unsigned int c = KEY_NULL; return c; } /** * Blocks until a keyboard character has been entered * @return decoded character entered by the keyboard or KEY_NULL * for any character that cannot be decoded */ unsigned int keyboard_getc(void) { unsigned int c = KEY_NULL; while ((c = keyboard_poll()) == KEY_NULL); return c; } /** * Processes raw keyboard input and decodes it. * * Should keep track of the keyboard status for the following keys: * SHIFT, CTRL, ALT, CAPS, NUMLOCK * * For all other characters, they should be decoded/mapped to ASCII * or ASCII-friendly characters.
  • 4. * * For any character that cannot be mapped, KEY_NULL should be returned. * * If *all* of the status keys defined in KEY_KERNEL_DEBUG are pressed, * while another character is entered, the kernel_debug_command() * function should be called. */ unsigned int keyboard_decode(unsigned int c) { return c; } Part 5: Keyboard Input In addition to text output, we will want to support text input from the keyboard. Keyboard input is handled by reading individual bytes with direct I/O. These bytes refer to the keyboard status or keyboard data. This status or data can be read using the following ports: Reading a byte from a port can be performed using the inportb () function: Reading in the status can tell us if data is available as well as other parameters of the keyboard itself. For now (especially with our emulated environment) we will simply be concerned with bit 0 which if set indicates that keyboard data is available if the bit is set. Reading keyboard data will provide us with something called the keyboard scan code: The keyboard scan code tells us a number of details: 1. If the key is being pressed 2. If the key is being released 3. Which specific key is being pressed or released Bit 7, if set (080), indicates that the key is pressed. If unset, it indicates that the key is released. The remaining bits (06, effectively values 001 through 07f) indicate which key is being pressed. While we are generally used to working with ASCII character codes for representing text, keep in mind that there are many other keys that do not have any direct ASCII character code associated. Additionally, keyboard data/characters also have a historical relationship to the physical hardware layout for specific keyboards. A scancode of usually indicates an error or lack of input when reading the keyboard data port. As a result, all keyboard scan codes need to be handled and potentially mapped to characters that would be of use for human input and output. Any key that cannot be decoded or determined to be valid when scanning should be referred to via the defined KEY NULL value. When decoding, you may want to refer to the list of ASCII Character Codes If we review the scan codes, we will see that there is no distinction in case for letters (example: 01E is mapped to the letter A). Additionally, several scan codes have multiple characters associated (example: xD maps to both the = and + character). Since keyboard scancodes come in for single key events
  • 5. (press or release), we need to make a distinction on how we interpret when a key is entered. Keyboard hardware will naturally support "repeat" functionality so if you hold a key down, it will appear as a sequence of press/releases. In our implementation, we will consider that a key is entered when it is released. While alphanumeric characters and symbols are certainly important, we should consider how other keys are handled as well. Several keys contain special meaning, such as the "CAPS LOCK" key or "SHIFT" key. This is crucial when consider that pressing the "SHIFT" key allows us to distingish between alternate representations. As such, for some keys, we will want to maintain the state of whether or not they are pressed (or in some cases, such as with "CAPS LOCK" if it was "toggled"). This will be incredibly important when we need to decode scan codes into ASCII characters or other representations. To support keyboard input in our operating system, we will implement the following functions: 1. keyboard_scan () to read the keyboard scan code from the data port. 2. keyboard_decode() Decodes a scancode into an ASCII character code or "special key" definition 3. keyboard_poll () to check if keyboard data is present, read they keyboard scan code, decode it, and return the value 4. keyboard_getc() to block (loop) until a valid keyboard character has been entered