MOS Source Code
Loading...
Searching...
No Matches
do_copy.c
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
4
11
12#include <mos/mos_global.h>
13#include <mos_string.h>
14
15static void pml1e_do_copy_callback(pml1_t pml1, pml1e_t *src_e, ptr_t vaddr, void *data)
16{
17 MOS_UNUSED(pml1);
18 struct pagetable_do_copy_data *copy_data = data;
19 copy_data->dest_pml1e = pml1_entry(copy_data->dest_pml1, vaddr);
20
21 const pfn_t old_pfn = platform_pml1e_get_present(copy_data->dest_pml1e) ? platform_pml1e_get_pfn(copy_data->dest_pml1e) : 0;
22
24 {
26 copy_data->dest_pml1e->content = src_e->content;
27 }
28 else
29 {
30 pmlxe_destroy(copy_data->dest_pml1e);
31 }
32
33 if (old_pfn)
34 pmm_unref_one(old_pfn);
35}
36
37static void pml2e_do_copy_callback(pml2_t pml2, pml2e_t *e, ptr_t vaddr, void *data)
38{
39 MOS_UNUSED(pml2);
40 struct pagetable_do_copy_data *copy_data = data;
41 copy_data->dest_pml2e = pml2_entry(copy_data->dest_pml2, vaddr);
42 copy_data->dest_pml1 = pml2e_get_or_create_pml1(copy_data->dest_pml2e);
43
45}
46
47static void pml3e_do_copy_callback(pml3_t pml3, pml3e_t *e, ptr_t vaddr, void *data)
48{
49 MOS_UNUSED(pml3);
50 struct pagetable_do_copy_data *copy_data = data;
51 copy_data->dest_pml3e = pml3_entry(copy_data->dest_pml3, vaddr);
52 copy_data->dest_pml2 = pml3e_get_or_create_pml2(copy_data->dest_pml3e);
53
55}
56
57static void pml4e_do_copy_callback(pml4_t pml4, pml4e_t *e, ptr_t vaddr, void *data)
58{
59 MOS_UNUSED(pml4);
60 struct pagetable_do_copy_data *copy_data = data;
61 copy_data->dest_pml4e = pml4_entry(copy_data->dest_pml4, vaddr);
62 copy_data->dest_pml3 = pml4e_get_or_create_pml3(copy_data->dest_pml4e);
63
65}
66
68 .pml1e_callback = pml1e_do_copy_callback,
69 .pml2e_pre_traverse = pml2e_do_copy_callback,
70 .pml3e_pre_traverse = pml3e_do_copy_callback,
71 .pml4e_pre_traverse = pml4e_do_copy_callback,
72};
void platform_pml2e_set_flags(pml2e_t *pml2, vm_flags flags)
Definition mm.c:125
void platform_pml4e_set_flags(pml4e_t *pml4, vm_flags flags)
Definition mm.c:225
vm_flags platform_pml3e_get_flags(const pml3e_t *pml3e)
Definition mm.c:181
vm_flags platform_pml4e_get_flags(const pml4e_t *pml4e)
Definition mm.c:231
pfn_t platform_pml1e_get_pfn(const pml1e_t *pml1e)
Definition mm.c:78
bool platform_pml1e_get_present(const pml1e_t *pml1)
Definition mm.c:90
void platform_pml3e_set_flags(pml3e_t *pml3, vm_flags flags)
Definition mm.c:175
vm_flags platform_pml2e_get_flags(const pml2e_t *pml2e)
Definition mm.c:131
static void pml3e_do_copy_callback(pml3_t pml3, pml3e_t *e, ptr_t vaddr, void *data)
Definition do_copy.c:47
const pagetable_walk_options_t pagetable_do_copy_callbacks
Definition do_copy.c:67
static void pml1e_do_copy_callback(pml1_t pml1, pml1e_t *src_e, ptr_t vaddr, void *data)
Definition do_copy.c:15
static void pml4e_do_copy_callback(pml4_t pml4, pml4e_t *e, ptr_t vaddr, void *data)
Definition do_copy.c:57
static void pml2e_do_copy_callback(pml2_t pml2, pml2e_t *e, ptr_t vaddr, void *data)
Definition do_copy.c:37
#define pmm_ref_one(thing)
Definition pmm.h:146
#define pmm_unref_one(thing)
Definition pmm.h:147
#define MOS_UNUSED(x)
Definition mos_global.h:64
pml1e_t * pml1_entry(pml1_t pml1, ptr_t vaddr)
Definition pml1.c:45
pml1_t pml2e_get_or_create_pml1(pml2e_t *pml2e)
Definition pml2.c:83
pml2e_t * pml2_entry(pml2_t pml2, ptr_t vaddr)
Definition pml2.c:73
pml2_t pml3e_get_or_create_pml2(pml3e_t *pml3e)
pml3e_t * pml3_entry(pml3_t pml3, ptr_t vaddr)
Definition pml3.c:20
pml3_t pml4e_get_or_create_pml3(pml4e_t *pml4e)
pml4e_t * pml4_entry(pml4_t pml4, ptr_t vaddr)
Definition pml4.c:21
pml3e_t pml4e_t
Definition pml_types.h:72
pml2e_t pml3e_t
Definition pml_types.h:60
#define pmlxe_destroy(pmlxe)
Definition pml_types.h:110
pml3e_t * dest_pml3e
Definition do_copy.h:16
pml4e_t * dest_pml4e
Definition do_copy.h:13
pml2e_t * dest_pml2e
Definition do_copy.h:19
pml1e_t * dest_pml1e
Definition do_copy.h:22
pte_content_t content
Definition pml_types.h:35
unsigned long long pfn_t
Definition types.h:41
unsigned long ptr_t
Definition types.h:25