Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bootloader
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
bootloader
Commits
5313f46e
Verified
Commit
5313f46e
authored
3 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Put magic addresses in one place
parent
14993ed4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib.rs
+13
-17
13 additions, 17 deletions
src/lib.rs
with
13 additions
and
17 deletions
src/lib.rs
+
13
−
17
View file @
5313f46e
...
...
@@ -17,6 +17,11 @@ use linked_list_allocator::LockedHeap;
mod
panic
;
const
VBE_CARD_INFO_ADDR
:
usize
=
0x1000
;
const
VBE_MODE_INFO_ADDR
:
usize
=
0x2000
;
const
STACK_ADDR
:
usize
=
0x7C00
;
const
VGA_ADDR
:
usize
=
0xB8000
;
#[global_allocator]
static
ALLOCATOR
:
LockedHeap
=
LockedHeap
::
empty
();
...
...
@@ -34,14 +39,12 @@ pub struct ThunkData {
}
impl
ThunkData
{
pub
const
STACK
:
usize
=
0x7C00
;
pub
fn
new
()
->
Self
{
Self
{
di
:
0
,
si
:
0
,
bp
:
0
,
sp
:
S
elf
::
STACK
as
u16
,
sp
:
S
TACK_ADDR
as
u16
,
bx
:
0
,
dx
:
0
,
cx
:
0
,
...
...
@@ -50,11 +53,11 @@ impl ThunkData {
}
pub
unsafe
fn
save
(
&
self
)
{
ptr
::
write
((
S
elf
::
STACK
-
16
)
as
*
mut
ThunkData
,
*
self
);
ptr
::
write
((
S
TACK_ADDR
-
16
)
as
*
mut
ThunkData
,
*
self
);
}
pub
unsafe
fn
load
(
&
mut
self
)
{
*
self
=
ptr
::
read
((
S
elf
::
STACK
-
16
)
as
*
const
ThunkData
);
*
self
=
ptr
::
read
((
S
TACK_ADDR
-
16
)
as
*
const
ThunkData
);
}
pub
unsafe
fn
with
(
&
mut
self
,
f
:
extern
"C"
fn
())
{
...
...
@@ -241,7 +244,7 @@ pub unsafe extern "C" fn kstart(
data
.with
(
thunk10
);
}
let
mut
vga
=
Vga
::
new
(
0xb8000
as
*
mut
VgaTextBlock
,
80
,
25
);
let
mut
vga
=
Vga
::
new
(
VGA_ADDR
as
*
mut
VgaTextBlock
,
80
,
25
);
for
i
in
0
..
vga
.blocks
.len
()
{
vga
.blocks
[
i
]
.char
=
0
;
...
...
@@ -263,10 +266,10 @@ pub unsafe extern "C" fn kstart(
// Get card info
let
mut
data
=
ThunkData
::
new
();
data
.ax
=
0x4F00
;
data
.di
=
0x1000
;
data
.di
=
VBE_CARD_INFO_ADDR
as
u16
;
data
.with
(
thunk10
);
if
data
.ax
==
0x004F
{
let
card_info
=
ptr
::
read
(
0x1000
as
*
const
VbeCardInfo
);
let
card_info
=
ptr
::
read
(
VBE_CARD_INFO_ADDR
as
*
const
VbeCardInfo
);
let
mut
mode_ptr
=
card_info
.videomodeptr
as
*
const
u16
;
loop
{
...
...
@@ -281,10 +284,10 @@ pub unsafe extern "C" fn kstart(
let
mut
data
=
ThunkData
::
new
();
data
.ax
=
0x4F01
;
data
.cx
=
mode
;
data
.di
=
0x2000
;
data
.di
=
VBE_MODE_INFO_ADDR
as
u16
;
data
.with
(
thunk10
);
if
data
.ax
==
0x004F
{
let
mode_info
=
ptr
::
read
(
0x2000
as
*
const
VbeModeInfo
);
let
mode_info
=
ptr
::
read
(
VBE_MODE_INFO_ADDR
as
*
const
VbeModeInfo
);
// We only support 32-bits per pixel modes
if
mode_info
.bitsperpixel
!=
32
{
...
...
@@ -354,13 +357,6 @@ pub unsafe extern "C" fn kstart(
// Read keypress
let
mut
data
=
ThunkData
::
new
();
data
.with
(
thunk16
);
writeln!
(
vga
,
"{:?} 0x{:02X}"
,
(
data
.ax
as
u8
)
as
char
,
(
data
.ax
>>
8
)
as
u8
);
match
(
data
.ax
>>
8
)
as
u8
{
0x4B
/* Left */
=>
{
if
let
Some
(
mut
mode_i
)
=
modes
.iter
()
.position
(|
x
|
x
.0
==
selected
)
{
...
...
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