2 |
#define CPU_SH_H |
#define CPU_SH_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_sh.h,v 1.10 2005/11/16 21:15:19 debug Exp $ |
* $Id: cpu_sh.h,v 1.17 2006/07/16 13:32:28 debug Exp $ |
32 |
*/ |
*/ |
33 |
|
|
34 |
#include "misc.h" |
#include "misc.h" |
46 |
#define SH_ADDR_TO_PAGENR(a) ((a) >> (SH_IC_ENTRIES_SHIFT \ |
#define SH_ADDR_TO_PAGENR(a) ((a) >> (SH_IC_ENTRIES_SHIFT \ |
47 |
+ SH_INSTR_ALIGNMENT_SHIFT)) |
+ SH_INSTR_ALIGNMENT_SHIFT)) |
48 |
|
|
49 |
struct sh_instr_call { |
#define SH_L2N 17 |
50 |
void (*f)(struct cpu *, struct sh_instr_call *); |
#define SH_L3N 18 |
|
size_t arg[SH_N_IC_ARGS]; |
|
|
}; |
|
51 |
|
|
52 |
/* Translation cache struct for each physical page: */ |
DYNTRANS_MISC_DECLARATIONS(sh,SH,uint64_t) |
53 |
struct sh_tc_physpage { |
DYNTRANS_MISC64_DECLARATIONS(sh,SH,uint8_t) |
|
struct sh_instr_call ics[SH_IC_ENTRIES_PER_PAGE + 1]; |
|
|
uint32_t next_ofs; /* or 0 for end of chain */ |
|
|
int flags; |
|
|
uint64_t physaddr; |
|
|
}; |
|
54 |
|
|
55 |
#define SH_N_VPH_ENTRIES 1048576 |
#define SH_MAX_VPH_TLB_ENTRIES 128 |
56 |
|
|
|
#define SH_MAX_VPH_TLB_ENTRIES 256 |
|
|
struct sh_vpg_tlb_entry { |
|
|
uint8_t valid; |
|
|
uint8_t writeflag; |
|
|
int64_t timestamp; |
|
|
uint64_t vaddr_page; |
|
|
uint64_t paddr_page; |
|
|
unsigned char *host_page; |
|
|
}; |
|
57 |
|
|
58 |
struct sh_cpu { |
struct sh_cpu { |
59 |
int bits; |
int bits; |
63 |
|
|
64 |
|
|
65 |
/* |
/* |
66 |
* Instruction translation cache: |
* Instruction translation cache and Virtual->Physical->Host |
67 |
*/ |
* address translation: |
|
|
|
|
/* cur_ic_page is a pointer to an array of SH_IC_ENTRIES_PER_PAGE |
|
|
instruction call entries. next_ic points to the next such |
|
|
call to be executed. */ |
|
|
struct sh_tc_physpage *cur_physpage; |
|
|
struct sh_instr_call *cur_ic_page; |
|
|
struct sh_instr_call *next_ic; |
|
|
|
|
|
void (*combination_check)(struct cpu *, |
|
|
struct sh_instr_call *, int low_addr); |
|
|
|
|
|
/* |
|
|
* Virtual -> physical -> host address translation: |
|
|
* |
|
|
* host_load and host_store point to arrays of SH_N_VPH_ENTRIES |
|
|
* pointers (to host pages); phys_addr points to an array of |
|
|
* SH_N_VPH_ENTRIES uint32_t. |
|
68 |
*/ |
*/ |
69 |
|
DYNTRANS_ITC(sh) |
70 |
struct sh_vpg_tlb_entry vph_tlb_entry[SH_MAX_VPH_TLB_ENTRIES]; |
VPH_TLBS(sh,SH) |
71 |
unsigned char *host_load[SH_N_VPH_ENTRIES]; |
VPH32(sh,SH,uint64_t,uint8_t) |
72 |
unsigned char *host_store[SH_N_VPH_ENTRIES]; |
VPH64(sh,SH,uint8_t) |
|
uint32_t phys_addr[SH_N_VPH_ENTRIES]; |
|
|
struct sh_tc_physpage *phys_page[SH_N_VPH_ENTRIES]; |
|
|
|
|
|
uint32_t phystranslation[SH_N_VPH_ENTRIES/32]; |
|
|
uint8_t vaddr_to_tlbindex[SH_N_VPH_ENTRIES]; |
|
73 |
}; |
}; |
74 |
|
|
75 |
|
|
76 |
/* cpu_sh.c: */ |
/* cpu_sh.c: */ |
77 |
|
int sh_run_instr(struct cpu *cpu); |
78 |
void sh_update_translation_table(struct cpu *cpu, uint64_t vaddr_page, |
void sh_update_translation_table(struct cpu *cpu, uint64_t vaddr_page, |
79 |
unsigned char *host_page, int writeflag, uint64_t paddr_page); |
unsigned char *host_page, int writeflag, uint64_t paddr_page); |
80 |
void sh_invalidate_translation_caches(struct cpu *cpu, uint64_t, int); |
void sh_invalidate_translation_caches(struct cpu *cpu, uint64_t, int); |
81 |
void sh_invalidate_code_translation(struct cpu *cpu, uint64_t, int); |
void sh_invalidate_code_translation(struct cpu *cpu, uint64_t, int); |
82 |
|
int sh32_run_instr(struct cpu *cpu); |
83 |
void sh32_update_translation_table(struct cpu *cpu, uint64_t vaddr_page, |
void sh32_update_translation_table(struct cpu *cpu, uint64_t vaddr_page, |
84 |
unsigned char *host_page, int writeflag, uint64_t paddr_page); |
unsigned char *host_page, int writeflag, uint64_t paddr_page); |
85 |
void sh32_invalidate_translation_caches(struct cpu *cpu, uint64_t, int); |
void sh32_invalidate_translation_caches(struct cpu *cpu, uint64_t, int); |
86 |
void sh32_invalidate_code_translation(struct cpu *cpu, uint64_t, int); |
void sh32_invalidate_code_translation(struct cpu *cpu, uint64_t, int); |
87 |
|
void sh_init_64bit_dummy_tables(struct cpu *cpu); |
88 |
int sh_memory_rw(struct cpu *cpu, struct memory *mem, uint64_t vaddr, |
int sh_memory_rw(struct cpu *cpu, struct memory *mem, uint64_t vaddr, |
89 |
unsigned char *data, size_t len, int writeflag, int cache_flags); |
unsigned char *data, size_t len, int writeflag, int cache_flags); |
90 |
int sh_cpu_family_init(struct cpu_family *); |
int sh_cpu_family_init(struct cpu_family *); |