1 | // SPDX-License-Identifier: GPL-3.0-or-later |
2 | |
3 | #include "mos/mm/paging/table_ops/do_map.h" |
4 | |
5 | #include "mos/platform/platform.h" |
6 | |
7 | static void pml1e_do_map_callback(pml1_t pml1, pml1e_t *e, ptr_t vaddr, void *data) |
8 | { |
9 | MOS_UNUSED(pml1); |
10 | MOS_UNUSED(vaddr); |
11 | struct pagetable_do_map_data *map_data = data; |
12 | platform_pml1e_set_pfn(pml1: e, pfn: map_data->pfn); |
13 | platform_pml1e_set_flags(pml1: e, flags: map_data->flags); |
14 | platform_invalidate_tlb(vaddr); |
15 | if (map_data->do_refcount) |
16 | pmm_ref_one(map_data->pfn); |
17 | map_data->pfn++; |
18 | } |
19 | |
20 | static void pml2e_do_map_callback(pml2_t pml2, pml2e_t *e, ptr_t vaddr, void *data) |
21 | { |
22 | MOS_UNUSED(pml2); |
23 | MOS_UNUSED(vaddr); |
24 | struct pagetable_do_map_data *map_data = data; |
25 | platform_pml2e_set_flags(pml2: e, flags: map_data->flags); |
26 | } |
27 | |
28 | static void pml3e_do_map_callback(pml3_t pml3, pml3e_t *e, ptr_t vaddr, void *data) |
29 | { |
30 | MOS_UNUSED(pml3); |
31 | MOS_UNUSED(vaddr); |
32 | struct pagetable_do_map_data *map_data = data; |
33 | platform_pml3e_set_flags(pml3: e, flags: map_data->flags); |
34 | } |
35 | |
36 | static void pml4e_do_map_callback(pml4_t pml4, pml4e_t *e, ptr_t vaddr, void *data) |
37 | { |
38 | MOS_UNUSED(pml4); |
39 | MOS_UNUSED(vaddr); |
40 | struct pagetable_do_map_data *map_data = data; |
41 | platform_pml4e_set_flags(pml4: e, flags: map_data->flags); |
42 | } |
43 | |
44 | const pagetable_walk_options_t pagetable_do_map_callbacks = { |
45 | .pml1e_callback = pml1e_do_map_callback, |
46 | .pml2e_pre_traverse = pml2e_do_map_callback, |
47 | .pml3e_pre_traverse = pml3e_do_map_callback, |
48 | .pml4e_pre_traverse = pml4e_do_map_callback, |
49 | }; |
50 | |