@@ -5,7 +5,6 @@ use fixedvec::FixedVec;
55use x86_64:: structures:: paging:: mapper:: { MapToError , MapperFlush , UnmapError } ;
66use x86_64:: structures:: paging:: {
77 self , Mapper , Page , PageSize , PageTableFlags , PhysFrame , RecursivePageTable , Size4KiB ,
8- UnusedPhysFrame ,
98} ;
109use x86_64:: { align_up, PhysAddr , VirtAddr } ;
1110use xmas_elf:: program:: { self , ProgramHeader64 } ;
@@ -18,12 +17,12 @@ pub struct MemoryInfo {
1817
1918#[ derive( Debug ) ]
2019pub enum MapKernelError {
21- Mapping ( MapToError ) ,
20+ Mapping ( MapToError < Size4KiB > ) ,
2221 MultipleTlsSegments ,
2322}
2423
25- impl From < MapToError > for MapKernelError {
26- fn from ( e : MapToError ) -> Self {
24+ impl From < MapToError < Size4KiB > > for MapKernelError {
25+ fn from ( e : MapToError < Size4KiB > ) -> Self {
2726 MapKernelError :: Mapping ( e)
2827 }
2928}
@@ -71,7 +70,7 @@ pub(crate) fn map_segment(
7170 kernel_start : PhysAddr ,
7271 page_table : & mut RecursivePageTable ,
7372 frame_allocator : & mut FrameAllocator ,
74- ) -> Result < Option < TlsTemplate > , MapToError > {
73+ ) -> Result < Option < TlsTemplate > , MapToError < Size4KiB > > {
7574 let typ = segment. get_type ( ) . unwrap ( ) ;
7675 match typ {
7776 program:: Type :: Load => {
@@ -97,16 +96,8 @@ pub(crate) fn map_segment(
9796 for frame in PhysFrame :: range_inclusive ( start_frame, end_frame) {
9897 let offset = frame - start_frame;
9998 let page = start_page + offset;
100- unsafe {
101- map_page (
102- page,
103- UnusedPhysFrame :: new ( frame) ,
104- page_table_flags,
105- page_table,
106- frame_allocator,
107- ) ?
108- }
109- . flush ( ) ;
99+ unsafe { map_page ( page, frame, page_table_flags, page_table, frame_allocator) ? }
100+ . flush ( ) ;
110101 }
111102
112103 if mem_size > file_size {
@@ -126,7 +117,7 @@ pub(crate) fn map_segment(
126117 unsafe {
127118 map_page (
128119 temp_page. clone ( ) ,
129- UnusedPhysFrame :: new ( new_frame. clone ( ) ) ,
120+ new_frame. clone ( ) ,
130121 page_table_flags,
131122 page_table,
132123 frame_allocator,
@@ -202,19 +193,19 @@ pub(crate) fn map_segment(
202193
203194pub ( crate ) unsafe fn map_page < ' a , S > (
204195 page : Page < S > ,
205- phys_frame : UnusedPhysFrame < S > ,
196+ phys_frame : PhysFrame < S > ,
206197 flags : PageTableFlags ,
207198 page_table : & mut RecursivePageTable < ' a > ,
208199 frame_allocator : & mut FrameAllocator ,
209- ) -> Result < MapperFlush < S > , MapToError >
200+ ) -> Result < MapperFlush < S > , MapToError < S > >
210201where
211202 S : PageSize ,
212203 RecursivePageTable < ' a > : Mapper < S > ,
213204{
214205 struct PageTableAllocator < ' a , ' b : ' a > ( & ' a mut FrameAllocator < ' b > ) ;
215206
216207 unsafe impl < ' a , ' b > paging:: FrameAllocator < Size4KiB > for PageTableAllocator < ' a , ' b > {
217- fn allocate_frame ( & mut self ) -> Option < UnusedPhysFrame < Size4KiB > > {
208+ fn allocate_frame ( & mut self ) -> Option < PhysFrame < Size4KiB > > {
218209 self . 0 . allocate_frame ( MemoryRegionType :: PageTable )
219210 }
220211 }
0 commit comments