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
ab42a3e9
authored
Sep 28, 2015
by
malcolm
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Added IDT c code
parent
7ff5b79f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
0 deletions
src/idt.c
src/idt.h
src/idt.c
0 → 100644
View file @
ab42a3e9
#include "idt.h"
struct
idtr
{
uint16_t
limit
;
uint32_t
base
;
};
static
struct
idt_desc
_idt
[
MAX_IDT_INT
];
static
struct
idtr
_idtr
;
static
void
idt_install
()
{
//TODO: VOODOO MAGIC
}
static
void
_cdecl
default_handler
()
{
//DEBUG OUTPUT MAYBE?
for
(;;);
}
idt_descriptor
*
get_ir
(
uint32_t
i
)
{
if
(
i
>
MAX_IDT_INT
)
return
0
;
return
&
_idt
[
i
];
}
int
install_ir
(
uint32_t
i
,
uint16_t
flags
,
uint16_t
sel
,
IRQ_HANDLER
irq
)
{
if
(
i
>
MAX_IDT_INT
)
return
0
;
if
(
!
irq
)
return
0
;
uint64_t
uiBase
=
(
uint64_t
)
&
(
*
irq
);
_idt
[
i
].
low_base
=
uint16_t
(
uiBase
&
0xffff
);
_idt
[
i
].
high_base
=
uint16_t
((
uiBase
>>
16
)
&
0xffff
);
_idt
[
i
].
reserved
=
0
;
_idt
[
i
].
flags
=
uint8_t
(
flags
);
_idt
[
i
].
code_sel
=
sel
;
return
0
;
}
int
idt_init
(
uint16_t
code_sel
)
{
_idtr
.
limit
=
sizeof
(
struct
idt_desc
)
*
MAX_IDT_INT
-
1
;
_idtr
.
base
=
(
uint32_t
)
&
_idt
[
0
];
memset
((
void
*
)
&
_idt
[
0
],
0
,
sizeof
(
idt_desc
)
*
MAX_IDT_INT
-
1
);
for
(
int
i
=
0
;
i
<
MAX_IDT_INT
;
i
++
)
install_ir
(
i
,
IDT_PR
|
IDT_32
,
code_sel
,(
IRQ_HANDLER
)
default_handler
);
idt_install
();
return
0
;
}
src/idt.h
0 → 100644
View file @
ab42a3e9
#ifndef _IDT_INC
#define _IDT_INC
#include <stdint.h>
#define MAX_IDT_INT 256
#define IDT_16 0x06
#define IDT_32 0x0E
#define IDT_R1 0x40
#define IDT_R2 0x20
#define IDT_R3 0x60
#define IDT_PR 0x80
//voodoo magic. find out what it does.
typedef
void
(
_cdecl
*
IRQ_HANDLER
)(
void
);
struct
idt_desc
{
uint16_t
low_base
;
uint16_t
code_sel
;
uint8_t
reserved
;
uint8_t
flags
;
uint16_t
high_base
;
};
extern
idt_desc
*
get_ir
(
uint32_t
i
);
extern
int
install_ir
(
uint32_t
i
,
uint16_t
flags
,
uint16_c
code_sel
,
IRQ_HANDLER
);
extern
int
idt_init
(
uint16_t
code_sel
);
#endif
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