Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tim Crawford
uefi_alloc
Commits
bb9d0d3a
Commit
bb9d0d3a
authored
Jul 06, 2017
by
Jeremy Soller
Browse files
Update uefi library
parent
385e0f29
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib.rs
View file @
bb9d0d3a
#![feature(allocator)]
#![feature(const_fn)]
#![feature(try_trait)]
#![allocator]
#![no_std]
extern
crate
uefi
;
use
uefi
::
boot
::
MemoryType
;
use
core
::
ops
::
Try
;
use
uefi
::
memory
::
MemoryType
;
use
uefi
::
system
::
SystemTable
;
static
mut
UEFI
:
*
mut
SystemTable
=
0
as
*
mut
SystemTable
;
...
...
@@ -29,9 +31,8 @@ fn get_uefi() -> Option<&'static mut SystemTable> {
pub
extern
fn
__rust_allocate
(
size
:
usize
,
_align
:
usize
)
->
*
mut
u8
{
if
let
Some
(
ref
mut
uefi
)
=
get_uefi
()
{
let
mut
ptr
=
0
;
let
ret
=
(
uefi
.BootServices.AllocatePool
)(
MemoryType
::
EfiLoaderData
,
size
,
&
mut
ptr
);
if
ret
!=
0
{
panic!
(
"__rust_allocate: uefi returned {:X}"
,
ret
);
if
let
Err
(
err
)
=
(
uefi
.BootServices.AllocatePool
)(
MemoryType
::
EfiLoaderData
,
size
,
&
mut
ptr
)
.into_result
()
{
panic!
(
"__rust_allocate: uefi returned {:?}"
,
err
);
}
ptr
as
*
mut
u8
}
else
{
...
...
@@ -42,7 +43,7 @@ pub extern fn __rust_allocate(size: usize, _align: usize) -> *mut u8 {
#[no_mangle]
pub
extern
fn
__rust_deallocate
(
ptr
:
*
mut
u8
,
_size
:
usize
,
_align
:
usize
)
{
if
let
Some
(
ref
mut
uefi
)
=
get_uefi
()
{
(
uefi
.BootServices.FreePool
)(
ptr
as
usize
);
let
_
=
(
uefi
.BootServices.FreePool
)(
ptr
as
usize
);
}
else
{
panic!
(
"__rust_deallocate: uefi not initialized"
);
}
...
...
Write
Preview
Supports
Markdown
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