@@ -5,7 +5,6 @@ use fixedvec::FixedVec;
5
5
use x86_64:: structures:: paging:: mapper:: { MapToError , MapperFlush , UnmapError } ;
6
6
use x86_64:: structures:: paging:: {
7
7
self , Mapper , Page , PageSize , PageTableFlags , PhysFrame , RecursivePageTable , Size4KiB ,
8
- UnusedPhysFrame ,
9
8
} ;
10
9
use x86_64:: { align_up, PhysAddr , VirtAddr } ;
11
10
use xmas_elf:: program:: { self , ProgramHeader64 } ;
@@ -18,12 +17,12 @@ pub struct MemoryInfo {
18
17
19
18
#[ derive( Debug ) ]
20
19
pub enum MapKernelError {
21
- Mapping ( MapToError ) ,
20
+ Mapping ( MapToError < Size4KiB > ) ,
22
21
MultipleTlsSegments ,
23
22
}
24
23
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 {
27
26
MapKernelError :: Mapping ( e)
28
27
}
29
28
}
@@ -71,7 +70,7 @@ pub(crate) fn map_segment(
71
70
kernel_start : PhysAddr ,
72
71
page_table : & mut RecursivePageTable ,
73
72
frame_allocator : & mut FrameAllocator ,
74
- ) -> Result < Option < TlsTemplate > , MapToError > {
73
+ ) -> Result < Option < TlsTemplate > , MapToError < Size4KiB > > {
75
74
let typ = segment. get_type ( ) . unwrap ( ) ;
76
75
match typ {
77
76
program:: Type :: Load => {
@@ -97,16 +96,8 @@ pub(crate) fn map_segment(
97
96
for frame in PhysFrame :: range_inclusive ( start_frame, end_frame) {
98
97
let offset = frame - start_frame;
99
98
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 ( ) ;
110
101
}
111
102
112
103
if mem_size > file_size {
@@ -126,7 +117,7 @@ pub(crate) fn map_segment(
126
117
unsafe {
127
118
map_page (
128
119
temp_page. clone ( ) ,
129
- UnusedPhysFrame :: new ( new_frame. clone ( ) ) ,
120
+ new_frame. clone ( ) ,
130
121
page_table_flags,
131
122
page_table,
132
123
frame_allocator,
@@ -202,19 +193,19 @@ pub(crate) fn map_segment(
202
193
203
194
pub ( crate ) unsafe fn map_page < ' a , S > (
204
195
page : Page < S > ,
205
- phys_frame : UnusedPhysFrame < S > ,
196
+ phys_frame : PhysFrame < S > ,
206
197
flags : PageTableFlags ,
207
198
page_table : & mut RecursivePageTable < ' a > ,
208
199
frame_allocator : & mut FrameAllocator ,
209
- ) -> Result < MapperFlush < S > , MapToError >
200
+ ) -> Result < MapperFlush < S > , MapToError < S > >
210
201
where
211
202
S : PageSize ,
212
203
RecursivePageTable < ' a > : Mapper < S > ,
213
204
{
214
205
struct PageTableAllocator < ' a , ' b : ' a > ( & ' a mut FrameAllocator < ' b > ) ;
215
206
216
207
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 > > {
218
209
self . 0 . allocate_frame ( MemoryRegionType :: PageTable )
219
210
}
220
211
}
0 commit comments