Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pintos_forked_resit
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
s2-alsaloumi
Pintos_forked_resit
Commits
9457213c
Commit
9457213c
authored
1 year ago
by
h2-addad
Browse files
Options
Downloads
Patches
Plain Diff
Update
parent
bab30b91
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/devices/input.c
+52
-0
52 additions, 0 deletions
src/devices/input.c
with
52 additions
and
0 deletions
src/devices/input.c
0 → 100644
+
52
−
0
View file @
9457213c
#include
"devices/input.h"
#include
<debug.h>
#include
"devices/intq.h"
#include
"devices/serial.h"
/* Stores keys from the keyboard and serial port. */
static
struct
intq
buffer
;
/* Initializes the input buffer. */
void
input_init
(
void
)
{
intq_init
(
&
buffer
);
}
/* Adds a key to the input buffer.
Interrupts must be off and the buffer must not be full. */
void
input_putc
(
uint8_t
key
)
{
ASSERT
(
intr_get_level
()
==
INTR_OFF
);
ASSERT
(
!
intq_full
(
&
buffer
));
intq_putc
(
&
buffer
,
key
);
serial_notify
();
}
/* Retrieves a key from the input buffer.
If the buffer is empty, waits for a key to be pressed. */
uint8_t
input_getc
(
void
)
{
enum
intr_level
old_level
;
uint8_t
key
;
old_level
=
intr_disable
();
key
=
intq_getc
(
&
buffer
);
serial_notify
();
intr_set_level
(
old_level
);
return
key
;
}
/* Returns true if the input buffer is full,
false otherwise.
Interrupts must be off. */
bool
input_full
(
void
)
{
ASSERT
(
intr_get_level
()
==
INTR_OFF
);
return
intq_full
(
&
buffer
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment