Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
my-kernel-michiels-saulquin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Michiels
my-kernel-michiels-saulquin
Commits
9f407fe5
Commit
9f407fe5
authored
4 years ago
by
Pierre Michiels
Browse files
Options
Downloads
Plain Diff
commit
parents
15c3dbf7
0ce9bbb7
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/keyboard.h
+1
-0
1 addition, 0 deletions
include/keyboard.h
src/keyboard.c
+22
-5
22 additions, 5 deletions
src/keyboard.c
src/main.c
+57
-5
57 additions, 5 deletions
src/main.c
with
80 additions
and
10 deletions
include/keyboard.h
+
1
−
0
View file @
9f407fe5
...
...
@@ -17,6 +17,7 @@ char keyboard_map(unsigned char key_code);
void
write_character
(
char
car
);
void
print_keyboard
();
char
get_keyboard_input
();
void
print_ascii_read_state
();
char
getc
();
void
init_keyboard
();
...
...
This diff is collapsed.
Click to expand it.
src/keyboard.c
+
22
−
5
View file @
9f407fe5
...
...
@@ -2,13 +2,23 @@
#include
"display.h"
#include
"ioport.h"
#include
"ordo.h"
#include
"idt.h"
#include
<stdlib.h>
unsigned
char
caps_state
;
semaphore
keyboard_sem
;
char
key
;
void
get_keyboard_input_it
(
int_regs_t
*
r
);
void
init_keyboard
(){
init_mutex
(
&
keyboard_sem
);
caps_state
=
NORMAL
;
key
=
0
;
idt_setup_handler
(
1
,
get_keyboard_input_it
);
}
char
keyboard_map
(
unsigned
char
key_code
){
...
...
@@ -81,12 +91,11 @@ void print_keyboard(){
}
char
get_keyboard_input
(){
unsigned
char
key_press
,
ascii
;
unsigned
char
key
,
ascii
;
// lecture sur le port 0x60
key
=
_inb
(
DATA_PORT
);
key_press
=
_inb
(
DATA_PORT
);
return
keyboard_map
(
key
);
return
keyboard_map
(
key
_press
);
}
// depreceted
...
...
@@ -106,14 +115,22 @@ void print_ascii_read_state(){
}
void
get_keyboard_input_it
(
int_regs_t
*
r
){
key
=
keyboard_map
(
_inb
(
DATA_PORT
));
}
char
getc
(){
char
ipt_car
;
sem_up
(
&
keyboard_sem
);
while
(
(
ipt_car
=
get_keyboard_input
())
==
0
);
while
(
key
==
0
);
ipt_car
=
key
;
key
=
0
;
sem_down
(
&
keyboard_sem
);
return
ipt_car
;
}
This diff is collapsed.
Click to expand it.
src/main.c
+
57
−
5
View file @
9f407fe5
...
...
@@ -15,7 +15,10 @@ void f_ping(void *args);
void
f_pong
(
void
*
args
);
void
f_keyboard
(
void
*
args
);
void
f_counter
(
void
*
args
);
void
keyboard_it
(
int_regs_t
*
r
);
void
keyboard_it_queue
(
int_regs_t
*
r
);
void
print_queue
(
int_regs_t
*
r
);
void
f_getc
(
void
*
args
);
void
f_getc_b
(
void
*
args
);
semaphore
screen_sem
;
keyboard_fifo
kb_fifo
;
...
...
@@ -53,10 +56,12 @@ void main(unsigned int * mboot_info)
/* minimal setup done ! */
clear_screen
();
/*** test sched ***/
// create_ctx(16384, f_ping, NULL);
// create_ctx(16384, f_pong, NULL);
/*** test shed ***/
/*** test shed
+ sémaphore
***/
// init_sem(&screen_sem, 1);
// create_ctx(16384, f_keyboard, NULL);
...
...
@@ -67,21 +72,29 @@ void main(unsigned int * mboot_info)
// init_kb_fifo(&kb_fifo);
// idt_setup_handler(1, keyboard_it);
// idt_setup_handler(0, empty_irq);
// idt_setup_handler(1, keyboard_it_queue);
// idt_setup_handler(0, print_queue);
/*** test getc ***/
init_sem
(
&
screen_sem
,
1
);
create_ctx
(
16384
,
f_getc
,
NULL
);
create_ctx
(
16384
,
f_getc_b
,
NULL
);
start_shed
();
while
(
1
){
//print_asciiCode();
}
}
void
keyboard_it
(
int_regs_t
*
r
){
void
keyboard_it
_queue
(
int_regs_t
*
r
){
// print_keyboard();
char
kb_car
;
kb_car
=
get_keyboard_input
();
// évite de déplacer le curseur quand c'est un caractère non valide (caps lock, etc.)
// write_character(kb_car);
if
(
kb_car
!=
0
){
kb_fifo_push
(
&
kb_fifo
,
kb_car
);
}
...
...
@@ -102,10 +115,49 @@ void print_queue(int_regs_t *r){
write_character
(
ipt
);
}
void
f_getc
(
void
*
args
){
char
k
;
while
(
1
){
k
=
getc
();
sem_up
(
&
screen_sem
);
putc
(
'*'
);
write_character
(
k
);
sem_down
(
&
screen_sem
);
}
}
void
f_getc_b
(
void
*
args
){
char
k
;
while
(
1
){
k
=
getc
();
sem_up
(
&
screen_sem
);
putc
(
'+'
);
write_character
(
k
);
sem_down
(
&
screen_sem
);
}
}
void
f_keyboard
(
void
*
args
){
while
(
1
){
sem_up
(
&
screen_sem
);
print_ascii_read_state
();
...
...
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