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
45
46
47
#ifndef ULM_VMEM_H
#define ULM_VMEM_H

#include <stddef.h>
#include <stdint.h>

#include "alu.h"

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

/*
 * Implements the VMEM part specified here:
 **/
#include "../ulm0/hdw_vmem.h"

// allow the debugger to look at single bytes
uint8_t ulm_vmemPeek(uint64_t addr);

struct SegmentNode
{
    uint64_t offset, size;
    struct SegmentNode *next;
};

const struct SegmentNode *ulm_vmemGetSegmentList();
void ulm_vmemGetSegment(uint64_t addr, uint64_t *segOffset, uint64_t *segSize);
void ulm_vmemSegmentPrint(void);

// sweep clean: release all allocated memory
void ulm_vmemClear();

// for fetching an instruction
void ulm_fetch32(uint64_t addr, uint32_t *val);

uint8_t ulm_fetch8(uint64_t addr);
void ulm_store8(uint64_t addr, uint8_t val);

void ulm_printVMemMapped();
void ulm_printVMem(uint64_t begin, uint64_t end, size_t chunkSize);

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus

#endif // ULM_VMEM_H