Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
redox-os
kernel
Commits
0e22ba24
Commit
0e22ba24
authored
8 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Initialize PIC in Rust
parent
571b2aa2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
arch/x86_64/src/device/mod.rs
+2
-0
2 additions, 0 deletions
arch/x86_64/src/device/mod.rs
arch/x86_64/src/device/pic.rs
+48
-0
48 additions, 0 deletions
arch/x86_64/src/device/pic.rs
arch/x86_64/src/start.rs
+0
-4
0 additions, 4 deletions
arch/x86_64/src/start.rs
with
50 additions
and
4 deletions
arch/x86_64/src/device/mod.rs
+
2
−
0
View file @
0e22ba24
...
@@ -2,10 +2,12 @@ use paging::ActivePageTable;
...
@@ -2,10 +2,12 @@ use paging::ActivePageTable;
pub
mod
cpu
;
pub
mod
cpu
;
pub
mod
local_apic
;
pub
mod
local_apic
;
pub
mod
pic
;
pub
mod
rtc
;
pub
mod
rtc
;
pub
mod
serial
;
pub
mod
serial
;
pub
unsafe
fn
init
(
active_table
:
&
mut
ActivePageTable
){
pub
unsafe
fn
init
(
active_table
:
&
mut
ActivePageTable
){
pic
::
init
();
local_apic
::
init
(
active_table
);
local_apic
::
init
(
active_table
);
rtc
::
init
();
rtc
::
init
();
serial
::
init
();
serial
::
init
();
...
...
This diff is collapsed.
Click to expand it.
arch/x86_64/src/device/pic.rs
0 → 100644
+
48
−
0
View file @
0e22ba24
use
syscall
::
io
::{
Io
,
Pio
};
pub
static
mut
MASTER
:
Pic
=
Pic
::
new
(
0x20
);
pub
static
mut
SLAVE
:
Pic
=
Pic
::
new
(
0xA0
);
pub
unsafe
fn
init
()
{
// Start initialization
MASTER
.cmd
.write
(
0x11
);
SLAVE
.cmd
.write
(
0x11
);
// Set offsets
MASTER
.data
.write
(
0x20
);
SLAVE
.data
.write
(
0x28
);
// Set up cascade
MASTER
.data
.write
(
4
);
SLAVE
.data
.write
(
2
);
// Set up interrupt mode (1 is manual, 2 is auto EOI)
MASTER
.data
.write
(
1
);
SLAVE
.data
.write
(
1
);
// Unmask interrupts
MASTER
.data
.write
(
0
);
SLAVE
.data
.write
(
0
);
// Ack remaining interrupts
MASTER
.ack
();
SLAVE
.ack
();
}
pub
struct
Pic
{
cmd
:
Pio
<
u8
>
,
data
:
Pio
<
u8
>
,
}
impl
Pic
{
pub
const
fn
new
(
port
:
u16
)
->
Pic
{
Pic
{
cmd
:
Pio
::
new
(
port
),
data
:
Pio
::
new
(
port
+
1
),
}
}
pub
fn
ack
(
&
mut
self
)
{
self
.cmd
.write
(
0x20
);
}
}
This diff is collapsed.
Click to expand it.
arch/x86_64/src/start.rs
+
0
−
4
View file @
0e22ba24
...
@@ -120,10 +120,6 @@ pub unsafe extern fn kstart() -> ! {
...
@@ -120,10 +120,6 @@ pub unsafe extern fn kstart() -> ! {
// Read ACPI tables, starts APs
// Read ACPI tables, starts APs
acpi
::
init
(
&
mut
active_table
);
acpi
::
init
(
&
mut
active_table
);
// Clear pending IRQs
// TODO: Remove this and ack all IRQs without listeners
interrupt
::
irq
::
acknowledge
(
8
);
BSP_READY
.store
(
true
,
Ordering
::
SeqCst
);
BSP_READY
.store
(
true
,
Ordering
::
SeqCst
);
}
}
...
...
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