summaryrefslogtreecommitdiff
path: root/contrib/elf2dmp/addrspace.h
blob: d87f6a18c6842b0ddf9e39729b0e86cdc1834331 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright (c) 2018 Virtuozzo International GmbH
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 *
 */

#ifndef ADDRSPACE_H
#define ADDRSPACE_H

#include "qemu_elf.h"

#define PAGE_BITS 12
#define PAGE_SIZE (1ULL << PAGE_BITS)
#define PFN_MASK (~(PAGE_SIZE - 1))

#define INVALID_PA  UINT64_MAX

struct pa_block {
    uint8_t *addr;
    uint64_t paddr;
    uint64_t size;
};

struct pa_space {
    size_t block_nr;
    struct pa_block *block;
};

struct va_space {
    uint64_t dtb;
    struct pa_space *ps;
};

int pa_space_create(struct pa_space *ps, QEMU_Elf *qemu_elf);
void pa_space_destroy(struct pa_space *ps);

void va_space_create(struct va_space *vs, struct pa_space *ps, uint64_t dtb);
void va_space_set_dtb(struct va_space *vs, uint64_t dtb);
void *va_space_resolve(struct va_space *vs, uint64_t va);
int va_space_rw(struct va_space *vs, uint64_t addr,
        void *buf, size_t size, int is_write);

#endif /* ADDRSPACE_H */