Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
triazo
/
kernel
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
3
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
180d7c69
authored
Oct 05, 2015
by
malcolm
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fixed reliance on arcane methods. GCC optimization disabled in IDT ang GDT loading.
parent
3b3b9e3c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
src/gdt.c
src/idt.c
src/gdt.c
View file @
180d7c69
#include "gdt.h"
#include "gdt.h"
#include "string.h"
#include "string.h"
#include "serial.h"
#include "serial.h"
//#include "term.h"
#pragma GCC push_options
#pragma GCC optimize ("0")
uint16_t
gdt_limit
;
uint16_t
gdt_limit
;
uint32_t
gdt_base
;
uint32_t
gdt_base
;
gdt_desc
_gdt
[
MAX_GDT_DESC
];
gdt_desc
_gdt
[
MAX_GDT_DESC
];
#define set_cs( cs ) asm volatile ( "ljmp %0, $1337f \n\t 1337: \n\t" :: "i"(cs) )
void
gdt_install
(){
void
gdt_install
(){
struct
{
struct
{
uint16_t
limit
;
uint16_t
limit
;
...
@@ -17,14 +18,13 @@ void gdt_install(){
...
@@ -17,14 +18,13 @@ void gdt_install(){
gdtr
.
limit
=
gdt_limit
;
gdtr
.
limit
=
gdt_limit
;
gdtr
.
base
=
gdt_base
;
gdtr
.
base
=
gdt_base
;
asm
volatile
(
"lgdt (%0)"
:
:
"r"
(
&
gdtr
));
asm
volatile
(
"lgdt (%0)"
:
:
"r"
(
&
gdtr
));
set_cs
(
8
);
asm
volatile
(
"ljmp %0, $1337f
\n\t
1337:
\n\t
"
::
"i"
(
8
)
);
asm
volatile
(
"mov $0x10, %ax; \
asm
volatile
(
"mov $0x10, %ax; \
mov %ax, %ds; \
mov %ax, %ds; \
mov %ax, %es; \
mov %ax, %es; \
mov %ax, %fs; \
mov %ax, %fs; \
mov %ax, %gs; \
mov %ax, %gs; \
mov %ax, %ss;"
);
mov %ax, %ss;"
);
strlen
(
""
);
}
}
void
gdt_set_desc
(
uint32_t
i
,
uint64_t
base
,
uint64_t
limit
,
uint8_t
access
,
uint8_t
gran
){
void
gdt_set_desc
(
uint32_t
i
,
uint64_t
base
,
uint64_t
limit
,
uint8_t
access
,
uint8_t
gran
){
if
(
i
>
MAX_GDT_DESC
)
if
(
i
>
MAX_GDT_DESC
)
...
@@ -58,3 +58,4 @@ int gdt_init() {
...
@@ -58,3 +58,4 @@ int gdt_init() {
gdt_install
();
gdt_install
();
return
0
;
return
0
;
}
}
#pragma GCC pop_options
src/idt.c
View file @
180d7c69
...
@@ -2,6 +2,9 @@
...
@@ -2,6 +2,9 @@
#include "string.h"
#include "string.h"
#include "serial.h"
#include "serial.h"
#pragma GCC push_options
#pragma GCC optimize ("0")
uint16_t
idt_limit
;
uint16_t
idt_limit
;
uint32_t
idt_base
;
uint32_t
idt_base
;
...
@@ -14,9 +17,6 @@ void idt_install() {
...
@@ -14,9 +17,6 @@ void idt_install() {
}
__attribute__
((
packed
))
idtr
;
}
__attribute__
((
packed
))
idtr
;
idtr
.
limit
=
idt_limit
;
idtr
.
limit
=
idt_limit
;
idtr
.
base
=
idt_base
;
idtr
.
base
=
idt_base
;
char
f
[
20
];
itoa
(
idtr
.
limit
,
f
);
itoa
(
idtr
.
base
,
f
);
asm
volatile
(
"lidt (%0)"
:
:
"r"
(
&
idtr
));
asm
volatile
(
"lidt (%0)"
:
:
"r"
(
&
idtr
));
}
}
...
@@ -58,3 +58,4 @@ int idt_init (uint16_t code_sel) {
...
@@ -58,3 +58,4 @@ int idt_init (uint16_t code_sel) {
//serial_writestring(f);
//serial_writestring(f);
return
0
;
return
0
;
}
}
#pragma GCC pop_options
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment