memory.h 853 字节
Newer Older
Z
Zihao Yu 已提交
1 2 3 4 5
#ifndef __MEMORY_H__
#define __MEMORY_H__

#include "common.h"

6
#define PMEM_SIZE (128 * 1024 * 1024)
Z
Zihao Yu 已提交
7 8
extern uint8_t pmem[];

Z
Zihao Yu 已提交
9
#define IMAGE_START 0x0
Z
Zihao Yu 已提交
10

Z
Zihao Yu 已提交
11 12 13 14 15
/* convert the guest physical address in the guest program to host virtual address in NEMU */
#define guest_to_host(p) ((void *)(pmem + (unsigned)p))
/* convert the host virtual address in NEMU to guest physical address in the guest program */
#define host_to_guest(p) ((paddr_t)((void *)p - (void *)pmem))

16 17
void register_pmem(paddr_t base);

Z
Zihao Yu 已提交
18 19
word_t isa_vaddr_read(vaddr_t, int);
void isa_vaddr_write(vaddr_t, word_t, int);
20 21 22 23

#define vaddr_read isa_vaddr_read
#define vaddr_write isa_vaddr_write

Z
Zihao Yu 已提交
24 25
word_t paddr_read(paddr_t, int);
void paddr_write(paddr_t, word_t, int);
Z
Zihao Yu 已提交
26

27 28 29 30
#define PAGE_SIZE         4096
#define PAGE_MASK         (PAGE_SIZE - 1)
#define PG_ALIGN __attribute((aligned(PAGE_SIZE)))

Z
Zihao Yu 已提交
31
#endif