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
50b42eda
Verified
Commit
50b42eda
authored
3 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
VBE mode info in Rust binary
parent
b7a1f531
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
+101
-2
101 additions, 2 deletions
src/lib.rs
with
101 additions
and
2 deletions
src/lib.rs
+
101
−
2
View file @
50b42eda
...
@@ -55,6 +55,61 @@ impl ThunkData {
...
@@ -55,6 +55,61 @@ impl ThunkData {
}
}
}
}
#[derive(Clone,
Copy,
Debug)]
#[repr(packed)]
pub
struct
VbeCardInfo
{
signature
:
[
u8
;
4
],
version
:
u16
,
oemstring
:
u32
,
capabilities
:
u32
,
videomodeptr
:
u32
,
totalmemory
:
u16
,
oemsoftwarerev
:
u16
,
oemvendornameptr
:
u32
,
oemproductnameptr
:
u32
,
oemproductrevptr
:
u32
,
reserved
:
[
u8
;
222
],
oemdata
:
[
u8
;
256
],
}
#[derive(Clone,
Copy,
Debug)]
#[repr(packed)]
pub
struct
VbeModeInfo
{
attributes
:
u16
,
winA
:
u8
,
winB
:
u8
,
granularity
:
u16
,
winsize
:
u16
,
segmentA
:
u16
,
segmentB
:
u16
,
winfuncptr
:
u32
,
bytesperscanline
:
u16
,
xresolution
:
u16
,
yresolution
:
u16
,
xcharsize
:
u8
,
ycharsize
:
u8
,
numberofplanes
:
u8
,
bitsperpixel
:
u8
,
numberofbanks
:
u8
,
memorymodel
:
u8
,
banksize
:
u8
,
numberofimagepages
:
u8
,
unused
:
u8
,
redmasksize
:
u8
,
redfieldposition
:
u8
,
greenmasksize
:
u8
,
greenfieldposition
:
u8
,
bluemasksize
:
u8
,
bluefieldposition
:
u8
,
rsvdmasksize
:
u8
,
rsvdfieldposition
:
u8
,
directcolormodeinfo
:
u8
,
physbaseptr
:
u32
,
offscreenmemoryoffset
:
u32
,
offscreenmemsize
:
u16
,
reserved
:
[
u8
;
206
],
}
#[derive(Clone,
Copy)]
#[derive(Clone,
Copy)]
#[repr(packed)]
#[repr(packed)]
pub
struct
VgaTextBlock
{
pub
struct
VgaTextBlock
{
...
@@ -178,15 +233,59 @@ pub unsafe extern "C" fn kstart(
...
@@ -178,15 +233,59 @@ pub unsafe extern "C" fn kstart(
(
VgaTextColor
::
White
as
u8
);
(
VgaTextColor
::
White
as
u8
);
}
}
writeln!
(
vga
,
"Arrow keys and space select mode, enter to continue"
);
{
// Get card info
let
mut
data
=
ThunkData
::
new
();
data
.ax
=
0x4F00
;
data
.di
=
0x1000
;
data
.with
(
thunk10
);
if
data
.ax
==
0x004F
{
let
card_info
=
ptr
::
read
(
0x1000
as
*
const
VbeCardInfo
);
let
mut
modes
=
card_info
.videomodeptr
as
*
const
u16
;
loop
{
let
mode
=
*
modes
;
if
mode
==
0xFFFF
{
break
;
}
modes
=
modes
.add
(
1
);
// Get mode info
let
mut
data
=
ThunkData
::
new
();
data
.ax
=
0x4F01
;
// Ask for linear frame buffer with mode
data
.cx
=
mode
|
(
1
<<
14
);
data
.di
=
0x2000
;
data
.with
(
thunk10
);
if
data
.ax
==
0x004F
{
let
mode_info
=
ptr
::
read
(
0x2000
as
*
const
VbeModeInfo
);
// We only support 32-bits per pixel modes
if
mode_info
.bitsperpixel
==
32
{
writeln!
(
vga
,
"{}x{}"
,
mode_info
.xresolution
,
mode_info
.yresolution
);
}
}
else
{
writeln!
(
vga
,
"Failed to read VBE mode 0x{:04X} info: 0x{:04X}"
,
mode
,
data
.ax
);
}
}
}
else
{
writeln!
(
vga
,
"Failed to read VBE card info: 0x{:04X}"
,
data
.ax
);
}
}
writeln!
(
vga
,
"Arrow keys and space select mode, enter to continue"
);
loop
{
loop
{
// Read keypress
// Read keypress
let
mut
data
=
ThunkData
::
new
();
let
mut
data
=
ThunkData
::
new
();
data
.with
(
thunk16
);
data
.with
(
thunk16
);
writeln!
(
writeln!
(
vga
,
vga
,
"
'{}'
0x{:02X}"
,
"
{:?}
0x{:02X}"
,
(
data
.ax
as
u8
)
as
char
,
(
data
.ax
as
u8
)
as
char
,
(
data
.ax
>>
8
)
as
u8
(
data
.ax
>>
8
)
as
u8
);
);
...
...
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