2 |
#define CPU_M68K_H |
#define CPU_M68K_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_m68k.h,v 1.2 2005/08/14 23:44:23 debug Exp $ |
* $Id: cpu_m68k.h,v 1.14 2006/08/21 14:44:22 debug Exp $ |
32 |
*/ |
*/ |
33 |
|
|
34 |
#include "misc.h" |
#include "misc.h" |
35 |
|
|
36 |
|
|
37 |
|
/* M68K CPU types: */ |
38 |
|
struct m68k_cpu_type_def { |
39 |
|
char *name; |
40 |
|
int flags; |
41 |
|
}; |
42 |
|
|
43 |
|
#define M68K_CPU_TYPE_DEFS { \ |
44 |
|
{ "68000", 0 }, \ |
45 |
|
{ "68010", 0 }, \ |
46 |
|
{ "68020", 0 }, \ |
47 |
|
{ "68030", 0 }, \ |
48 |
|
{ "68040", 0 }, \ |
49 |
|
{ "68060", 0 }, \ |
50 |
|
{ NULL, 0 } } |
51 |
|
|
52 |
struct cpu_family; |
struct cpu_family; |
53 |
|
|
54 |
#define N_M68K_DREGS 8 |
#define N_M68K_DREGS 8 |
63 |
#define M68K_ADDR_TO_PAGENR(a) ((a) >> (M68K_IC_ENTRIES_SHIFT \ |
#define M68K_ADDR_TO_PAGENR(a) ((a) >> (M68K_IC_ENTRIES_SHIFT \ |
64 |
+ M68K_INSTR_ALIGNMENT_SHIFT)) |
+ M68K_INSTR_ALIGNMENT_SHIFT)) |
65 |
|
|
66 |
struct m68k_instr_call { |
DYNTRANS_MISC_DECLARATIONS(m68k,M68K,uint32_t) |
|
void (*f)(struct cpu *, struct m68k_instr_call *); |
|
|
size_t arg[M68K_N_IC_ARGS]; |
|
|
}; |
|
|
|
|
|
/* Translation cache struct for each physical page: */ |
|
|
struct m68k_tc_physpage { |
|
|
uint32_t next_ofs; /* or 0 for end of chain */ |
|
|
uint32_t physaddr; |
|
|
int flags; |
|
|
struct m68k_instr_call ics[M68K_IC_ENTRIES_PER_PAGE + 1]; |
|
|
}; |
|
|
|
|
67 |
|
|
68 |
#define M68K_N_VPH_ENTRIES 1048576 |
#define M68K_MAX_VPH_TLB_ENTRIES 128 |
|
|
|
|
#define M68K_MAX_VPH_TLB_ENTRIES 256 |
|
|
struct m68k_vpg_tlb_entry { |
|
|
int valid; |
|
|
int writeflag; |
|
|
int64_t timestamp; |
|
|
unsigned char *host_page; |
|
|
uint32_t vaddr_page; |
|
|
uint32_t paddr_page; |
|
|
}; |
|
69 |
|
|
70 |
|
|
71 |
struct m68k_cpu { |
struct m68k_cpu { |
72 |
|
struct m68k_cpu_type_def cpu_type; |
73 |
|
|
74 |
/* |
/* |
75 |
* General Purpose Registers: |
* General Purpose Registers: |
76 |
*/ |
*/ |
80 |
|
|
81 |
|
|
82 |
/* |
/* |
83 |
* Instruction translation cache: |
* Instruction translation cache and 32-bit virtual -> physical -> |
84 |
|
* host address translation: |
85 |
*/ |
*/ |
86 |
|
DYNTRANS_ITC(m68k) |
87 |
/* cur_ic_page is a pointer to an array of M68K_IC_ENTRIES_PER_PAGE |
VPH_TLBS(m68k,M68K) |
88 |
instruction call entries. next_ic points to the next such |
VPH32(m68k,M68K,uint32_t,uint8_t) |
|
call to be executed. */ |
|
|
struct m68k_tc_physpage *cur_physpage; |
|
|
struct m68k_instr_call *cur_ic_page; |
|
|
struct m68k_instr_call *next_ic; |
|
|
|
|
|
|
|
|
/* |
|
|
* Virtual -> physical -> host address translation: |
|
|
* |
|
|
* host_load and host_store point to arrays of M68K_N_VPH_ENTRIES |
|
|
* pointers (to host pages); phys_addr points to an array of |
|
|
* M68K_N_VPH_ENTRIES uint32_t. |
|
|
*/ |
|
|
|
|
|
struct m68k_vpg_tlb_entry vph_tlb_entry[M68K_MAX_VPH_TLB_ENTRIES]; |
|
|
unsigned char *host_load[M68K_N_VPH_ENTRIES]; |
|
|
unsigned char *host_store[M68K_N_VPH_ENTRIES]; |
|
|
uint32_t phys_addr[M68K_N_VPH_ENTRIES]; |
|
|
struct m68k_tc_physpage *phys_page[M68K_N_VPH_ENTRIES]; |
|
89 |
}; |
}; |
90 |
|
|
91 |
|
|
92 |
/* cpu_m68k.c: */ |
/* cpu_m68k.c: */ |
93 |
|
int m68k_run_instr(struct cpu *cpu); |
94 |
void m68k_update_translation_table(struct cpu *cpu, uint64_t vaddr_page, |
void m68k_update_translation_table(struct cpu *cpu, uint64_t vaddr_page, |
95 |
unsigned char *host_page, int writeflag, uint64_t paddr_page); |
unsigned char *host_page, int writeflag, uint64_t paddr_page); |
96 |
void m68k_invalidate_translation_caches_paddr(struct cpu *cpu, uint64_t paddr); |
void m68k_invalidate_translation_caches(struct cpu *cpu, uint64_t, int); |
97 |
void m68k_invalidate_code_translation_caches(struct cpu *cpu); |
void m68k_invalidate_code_translation(struct cpu *cpu, uint64_t, int); |
98 |
int m68k_memory_rw(struct cpu *cpu, struct memory *mem, uint64_t vaddr, |
int m68k_memory_rw(struct cpu *cpu, struct memory *mem, uint64_t vaddr, |
99 |
unsigned char *data, size_t len, int writeflag, int cache_flags); |
unsigned char *data, size_t len, int writeflag, int cache_flags); |
100 |
int m68k_cpu_family_init(struct cpu_family *); |
int m68k_cpu_family_init(struct cpu_family *); |