Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
my-kernel
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
ASE-2021
my-kernel
Commits
d1532c84
Commit
d1532c84
authored
4 years ago
by
Thierno souleymane Bah
Browse files
Options
Downloads
Patches
Plain Diff
feat(Two contexts demonstration done)
parent
9ae56c41
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/main.c
+81
-25
81 additions, 25 deletions
src/main.c
with
81 additions
and
25 deletions
src/main.c
+
81
−
25
View file @
d1532c84
...
@@ -2,16 +2,61 @@
...
@@ -2,16 +2,61 @@
#include
"gdt.h"
#include
"gdt.h"
#include
"idt.h"
#include
"idt.h"
#include
"keyboard.h"
#include
"keyboard.h"
#include
"utils.h"
#include
"context.h"
void
clear_screen
();
/* clear screen */
/* print a char on the screen */
void
putc
(
char
aChar
);
/* print a single char on screen */
int
cursor_x
=
0
;
/* here is the cursor position on X [0..79] */
void
puts
(
char
*
aString
);
/* print a string on the screen */
int
cursor_y
=
0
;
/* here is the cursor position on Y [0..24] */
void
puthex
(
int
aNumber
);
/* print an Hex number on screen */
int
counter
=
0
;
void
empty_irq
(
int_regs_t
*
r
)
void
empty_irq
(
int_regs_t
*
r
)
{
{
}
}
void
timer_it
(
int_regs_t
*
r
)
{
yield
();
}
void
counter_handler
(
void
*
args
)
{
while
(
1
)
{
irq_disable
();
int
tmp_cursor
[
2
]
=
{
cursor_x
,
cursor_y
};
cursor_x
=
70
;
cursor_y
=
0
;
puthex
(
counter
++
);
cursor_x
=
tmp_cursor
[
0
];
cursor_y
=
tmp_cursor
[
1
];
irq_enable
();
}
}
void
keyboard_handler
(
void
*
args
)
{
init_keymapping
();
while
(
1
)
{
irq_disable
();
if
(
_inb
(
0x64
)
==
(
0x1D
))
{
_outb
(
0x64
,
0x1C
);
unsigned
char
s
=
_inb
(
0x60
);
char
c
=
keyboard_map
(
s
);
if
(
c
)
putc
(
c
);
// puthex(s);
}
irq_enable
();
}
}
/* multiboot entry-point with datastructure as arg. */
/* multiboot entry-point with datastructure as arg. */
void
main
(
unsigned
int
*
mboot_info
)
void
main
(
unsigned
int
*
mboot_info
)
{
{
...
@@ -28,8 +73,8 @@ void main(unsigned int *mboot_info)
...
@@ -28,8 +73,8 @@ void main(unsigned int *mboot_info)
puts
(
"
\n\n
"
);
puts
(
"
\n\n
"
);
idt_setup_handler
(
0
,
empty_irq
);
idt_setup_handler
(
0
,
timer_it
);
idt_setup_handler
(
0
,
empty_irq
);
idt_setup_handler
(
1
,
empty_irq
);
__asm
volatile
(
"sti"
);
__asm
volatile
(
"sti"
);
...
@@ -37,22 +82,37 @@ void main(unsigned int *mboot_info)
...
@@ -37,22 +82,37 @@ void main(unsigned int *mboot_info)
puts
(
"Hello world
\n\n
"
);
puts
(
"Hello world
\n\n
"
);
init_keymapping
();
ctx_t
*
ctx1
=
create_ctx
(
counter_handler
,
NULL
);
while
(
1
)
ctx_t
*
ctx2
=
create_ctx
(
keyboard_handler
,
NULL
);
for
(;;)
;
/* nothing more to do... really nothing ! */
}
void
assert0
(
char
b
,
const
char
*
filename
,
const
char
*
fct_name
,
const
int
line
)
{
{
if
(
_inb
(
0x64
)
==
(
0x1D
)
)
if
(
!
b
)
{
{
_outb
(
0x64
,
0x1C
);
puts
(
"Assertion error in "
);
unsigned
char
s
=
_inb
(
0x60
);
puts
(
filename
);
char
c
=
keyboard_map
(
s
);
puts
(
" in "
);
if
(
c
)
puts
(
fct_name
);
putc
(
c
);
puts
(
" at 0x"
);
// puthex(s);
puthex
(
line
);
puts
(
"
\n
"
);
}
}
}
}
for
(;;)
void
irq_disable
()
;
/* nothing more to do... really nothing ! */
{
__asm
volatile
(
"cli"
);
}
void
irq_enable
()
{
__asm
volatile
(
"sti"
);
_outb
(
0xA0
,
0x20
);
_outb
(
0x20
,
0x20
);
}
}
/* base address for the video output assume to be set as character oriented by the multiboot */
/* base address for the video output assume to be set as character oriented by the multiboot */
...
@@ -70,9 +130,9 @@ void clear_screen()
...
@@ -70,9 +130,9 @@ void clear_screen()
}
}
/* print a string on the screen */
/* print a string on the screen */
void
puts
(
char
*
aString
)
void
puts
(
const
char
*
aString
)
{
{
char
*
current_char
=
aString
;
const
char
*
current_char
=
aString
;
while
(
*
current_char
!=
0
)
while
(
*
current_char
!=
0
)
{
{
putc
(
*
current_char
++
);
putc
(
*
current_char
++
);
...
@@ -96,10 +156,6 @@ void puthex(int aNumber)
...
@@ -96,10 +156,6 @@ void puthex(int aNumber)
}
}
}
}
/* print a char on the screen */
int
cursor_x
=
0
;
/* here is the cursor position on X [0..79] */
int
cursor_y
=
0
;
/* here is the cursor position on Y [0..24] */
void
setCursor
()
void
setCursor
()
{
{
int
cursor_offset
=
cursor_x
+
cursor_y
*
80
;
int
cursor_offset
=
cursor_x
+
cursor_y
*
80
;
...
...
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