1
1
use fixedvec:: FixedVec ;
2
2
use frame_allocator:: FrameAllocator ;
3
3
use os_bootinfo:: MemoryRegionType ;
4
- use x86_64:: instructions:: tlb;
5
4
use x86_64:: structures:: paging:: { MapToError , RecursivePageTable , UnmapError } ;
6
- use x86_64:: structures:: paging:: { Mapper , Page , PageSize , PageTableFlags , PhysFrame , Size4KB } ;
5
+ use x86_64:: structures:: paging:: { Mapper , MapperFlush , Page , PageSize , PageTableFlags , PhysFrame , Size4KB } ;
7
6
use x86_64:: { align_up, PhysAddr , VirtAddr } ;
8
7
use xmas_elf:: program:: { self , ProgramHeader64 } ;
9
8
@@ -30,7 +29,7 @@ pub(crate) fn map_kernel(
30
29
let frame = frame_allocator
31
30
. allocate_frame ( region_type)
32
31
. ok_or ( MapToError :: FrameAllocationFailed ) ?;
33
- map_page ( page, frame, flags, page_table, frame_allocator) ?;
32
+ map_page ( page, frame, flags, page_table, frame_allocator) ?. flush ( ) ;
34
33
}
35
34
36
35
Ok ( stack_end. start_address ( ) )
@@ -67,7 +66,7 @@ pub(crate) fn map_segment(
67
66
for frame in PhysFrame :: range_inclusive ( start_frame, end_frame) {
68
67
let offset = frame - start_frame;
69
68
let page = start_page + offset;
70
- map_page ( page, frame, page_table_flags, page_table, frame_allocator) ?;
69
+ map_page ( page, frame, page_table_flags, page_table, frame_allocator) ?. flush ( ) ;
71
70
}
72
71
73
72
if mem_size > file_size {
@@ -90,7 +89,7 @@ pub(crate) fn map_segment(
90
89
page_table_flags,
91
90
page_table,
92
91
frame_allocator,
93
- ) ?;
92
+ ) ?. flush ( ) ;
94
93
95
94
type PageArray = [ u64 ; Size4KB :: SIZE as usize / 8 ] ;
96
95
@@ -113,15 +112,14 @@ pub(crate) fn map_segment(
113
112
UnmapError :: InvalidFrameAddressInPageTable => unreachable ! ( ) ,
114
113
} ) ;
115
114
}
116
- tlb:: flush ( last_page. start_address ( ) ) ;
117
115
118
116
map_page (
119
117
last_page,
120
118
new_frame,
121
119
page_table_flags,
122
120
page_table,
123
121
frame_allocator,
124
- ) ?;
122
+ ) ?. flush ( ) ;
125
123
}
126
124
127
125
// Map additional frames.
@@ -134,7 +132,7 @@ pub(crate) fn map_segment(
134
132
let frame = frame_allocator
135
133
. allocate_frame ( MemoryRegionType :: Kernel )
136
134
. ok_or ( MapToError :: FrameAllocationFailed ) ?;
137
- map_page ( page, frame, page_table_flags, page_table, frame_allocator) ?;
135
+ map_page ( page, frame, page_table_flags, page_table, frame_allocator) ?. flush ( ) ;
138
136
}
139
137
140
138
// zero
@@ -155,7 +153,7 @@ pub(crate) fn map_page<'a, S>(
155
153
flags : PageTableFlags ,
156
154
page_table : & mut RecursivePageTable < ' a > ,
157
155
frame_allocator : & mut FrameAllocator ,
158
- ) -> Result < ( ) , MapToError >
156
+ ) -> Result < MapperFlush < S > , MapToError >
159
157
where
160
158
S : PageSize ,
161
159
RecursivePageTable < ' a > : Mapper < S > ,
0 commit comments