@@ -2,7 +2,7 @@ use core::ptr;
22use core:: mem;
33
44use void:: { NotYetDef , CVoid } ;
5- use base:: { Event , Handle , Handles , MemoryType , Status } ;
5+ use base:: { AllocateType , Event , Handle , Handles , MemoryType , Status } ;
66use event:: { EventType , EventNotify , TimerDelay } ;
77use task:: TPL ;
88use protocol:: { DevicePathProtocol , Protocol , get_current_image} ;
@@ -33,8 +33,8 @@ pub struct BootServices {
3333 header : table:: TableHeader ,
3434 raise_tpl : * const NotYetDef ,
3535 restore_tpl : * const NotYetDef ,
36- allocate_pages : * const NotYetDef ,
37- free_pages : * const NotYetDef ,
36+ allocate_pages : unsafe extern "win64" fn ( allocate_type : AllocateType , pool_type : MemoryType , pages : usize , memory : * mut * mut CVoid ) -> Status ,
37+ free_pages : unsafe extern "win64" fn ( memory : * mut CVoid , pages : usize ) -> Status ,
3838 get_memory_map : * const NotYetDef ,
3939 allocate_pool : unsafe extern "win64" fn ( pool_type : MemoryType , size : usize , out : * mut * mut u8 ) -> Status ,
4040 free_pool : unsafe extern "win64" fn ( * mut CVoid ) ,
@@ -79,6 +79,23 @@ pub struct BootServices {
7979}
8080
8181impl BootServices {
82+ pub fn allocate_pages ( & self , pages : usize ) -> Result < * mut CVoid , Status > {
83+ let mut ptr: * mut CVoid = ptr:: null_mut ( ) ;
84+
85+ let result = unsafe { ( self . allocate_pages ) ( AllocateType :: AnyPages , get_current_image ( ) . image_data_type , pages, & mut ptr) } ;
86+ if result != Status :: Success {
87+ return Err ( result) ;
88+ }
89+
90+ Ok ( ptr)
91+ }
92+
93+ pub fn free_pages < T > ( & self , p : * const T , pages : usize ) {
94+ unsafe {
95+ ( self . free_pages ) ( p as * mut CVoid , pages) ;
96+ }
97+ }
98+
8299 /// Allocate `size` bytes of memory using type `T`.
83100 pub fn allocate_pool < T > ( & self , size : usize ) -> Result < * mut T , Status > {
84101 let mut ptr: * mut u8 = 0 as * mut u8 ;
0 commit comments