2 |
#define CPU_AVR_H |
#define CPU_AVR_H |
3 |
|
|
4 |
/* |
/* |
5 |
* Copyright (C) 2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2005-2006 Anders Gavare. All rights reserved. |
6 |
* |
* |
7 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
8 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
28 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
29 |
* |
* |
30 |
* |
* |
31 |
* $Id: cpu_avr.h,v 1.4 2005/09/17 22:34:53 debug Exp $ |
* $Id: cpu_avr.h,v 1.14 2006/02/09 22:40:27 debug Exp $ |
32 |
*/ |
*/ |
33 |
|
|
34 |
#include "misc.h" |
#include "misc.h" |
38 |
|
|
39 |
#define N_AVR_REGS 32 |
#define N_AVR_REGS 32 |
40 |
|
|
41 |
#define AVR_N_IC_ARGS 2 |
#define AVR_N_IC_ARGS 3 |
42 |
#define AVR_INSTR_ALIGNMENT_SHIFT 1 |
#define AVR_INSTR_ALIGNMENT_SHIFT 1 |
43 |
#define AVR_IC_ENTRIES_SHIFT 11 |
#define AVR_IC_ENTRIES_SHIFT 11 |
44 |
#define AVR_IC_ENTRIES_PER_PAGE (1 << AVR_IC_ENTRIES_SHIFT) |
#define AVR_IC_ENTRIES_PER_PAGE (1 << AVR_IC_ENTRIES_SHIFT) |
47 |
#define AVR_ADDR_TO_PAGENR(a) ((a) >> (AVR_IC_ENTRIES_SHIFT \ |
#define AVR_ADDR_TO_PAGENR(a) ((a) >> (AVR_IC_ENTRIES_SHIFT \ |
48 |
+ AVR_INSTR_ALIGNMENT_SHIFT)) |
+ AVR_INSTR_ALIGNMENT_SHIFT)) |
49 |
|
|
50 |
struct avr_instr_call { |
DYNTRANS_MISC_DECLARATIONS(avr,AVR,uint64_t) |
|
void (*f)(struct cpu *, struct avr_instr_call *); |
|
|
size_t arg[AVR_N_IC_ARGS]; |
|
|
}; |
|
|
|
|
|
/* Translation cache struct for each physical page: */ |
|
|
struct avr_tc_physpage { |
|
|
uint32_t next_ofs; /* or 0 for end of chain */ |
|
|
uint32_t physaddr; |
|
|
int flags; |
|
|
struct avr_instr_call ics[AVR_IC_ENTRIES_PER_PAGE + 1]; |
|
|
}; |
|
51 |
|
|
52 |
|
#define AVR_MAX_VPH_TLB_ENTRIES 128 |
|
#define AVR_N_VPH_ENTRIES 1048576 |
|
|
|
|
|
#define AVR_MAX_VPH_TLB_ENTRIES 256 |
|
|
struct avr_vpg_tlb_entry { |
|
|
int valid; |
|
|
int writeflag; |
|
|
int64_t timestamp; |
|
|
unsigned char *host_page; |
|
|
uint32_t vaddr_page; |
|
|
uint32_t paddr_page; |
|
|
}; |
|
53 |
|
|
54 |
|
|
55 |
#define SREG_NAMES "cznvshti" |
#define SREG_NAMES "cznvshti" |
87 |
/* |
/* |
88 |
* Instruction translation cache: |
* Instruction translation cache: |
89 |
*/ |
*/ |
90 |
|
DYNTRANS_ITC(avr) |
|
/* cur_ic_page is a pointer to an array of AVR_IC_ENTRIES_PER_PAGE |
|
|
instruction call entries. next_ic points to the next such |
|
|
call to be executed. */ |
|
|
struct avr_tc_physpage *cur_physpage; |
|
|
struct avr_instr_call *cur_ic_page; |
|
|
struct avr_instr_call *next_ic; |
|
|
|
|
91 |
|
|
92 |
/* |
/* |
93 |
* Virtual -> physical -> host address translation: |
* 32-bit virtual -> physical -> host address translation: |
94 |
* |
* |
95 |
* host_load and host_store point to arrays of AVR_N_VPH_ENTRIES |
* (All 32 bits are not really needed on AVRs.) |
|
* pointers (to host pages); phys_addr points to an array of |
|
|
* AVR_N_VPH_ENTRIES uint32_t. |
|
96 |
*/ |
*/ |
97 |
|
VPH_TLBS(avr,AVR) |
98 |
struct avr_vpg_tlb_entry vph_tlb_entry[AVR_MAX_VPH_TLB_ENTRIES]; |
VPH32(avr,AVR,uint32_t,uint8_t) |
|
unsigned char *host_load[AVR_N_VPH_ENTRIES]; |
|
|
unsigned char *host_store[AVR_N_VPH_ENTRIES]; |
|
|
uint32_t phys_addr[AVR_N_VPH_ENTRIES]; |
|
|
struct avr_tc_physpage *phys_page[AVR_N_VPH_ENTRIES]; |
|
99 |
}; |
}; |
100 |
|
|
101 |
|
|
102 |
/* cpu_avr.c: */ |
/* cpu_avr.c: */ |
103 |
void avr_update_translation_table(struct cpu *cpu, uint64_t vaddr_page, |
void avr_update_translation_table(struct cpu *cpu, uint64_t vaddr_page, |
104 |
unsigned char *host_page, int writeflag, uint64_t paddr_page); |
unsigned char *host_page, int writeflag, uint64_t paddr_page); |
105 |
void avr_invalidate_translation_caches_paddr(struct cpu *cpu, uint64_t, int); |
void avr_invalidate_translation_caches(struct cpu *cpu, uint64_t, int); |
106 |
void avr_invalidate_code_translation(struct cpu *cpu, uint64_t, int); |
void avr_invalidate_code_translation(struct cpu *cpu, uint64_t, int); |
107 |
int avr_memory_rw(struct cpu *cpu, struct memory *mem, uint64_t vaddr, |
int avr_memory_rw(struct cpu *cpu, struct memory *mem, uint64_t vaddr, |
108 |
unsigned char *data, size_t len, int writeflag, int cache_flags); |
unsigned char *data, size_t len, int writeflag, int cache_flags); |