1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
5#include "mos/platform/platform.h"
6
7typedef struct
8{
9 bool present;
10 ptr_t vaddr, vaddr_end;
11 pfn_t pfn, pfn_end;
12 vm_flags flags;
13} pagetable_iter_range_t;
14
15typedef struct
16{
17 pgd_t pgd;
18
19 ptr_t start;
20 ptr_t end;
21 ptr_t vaddr;
22
23 pagetable_iter_range_t range;
24} pagetable_iter_t;
25
26/**
27 * @brief Initialize a pagetable iterator.
28 *
29 * @param it The iterator to initialize.
30 * @param pgd The page directory to iterate.
31 * @param vaddr The virtual address to start iterating from.
32 * @param end The virtual address to stop iterating at.
33 */
34void pagetable_iter_init(pagetable_iter_t *it, pgd_t pgd, ptr_t vaddr, ptr_t end);
35
36/**
37 * @brief Get the next page table range.
38 *
39 * @param it The iterator to get the next range from.
40 * @return pagetable_iter_range_t*
41 */
42pagetable_iter_range_t *pagetable_iter_next(pagetable_iter_t *it);
43