aboutsummaryrefslogtreecommitdiff
path: root/sim/ppc/vm.h
blob: 335b0bc2eeca532a1235369489c49d4c07509c0d (plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*  This file is part of the program psim.

    Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
    */


#ifndef _VM_H_
#define _VM_H_

#ifndef INLINE_VM
#define INLINE_VM
#endif

typedef struct _vm vm;
typedef struct _vm_data_map vm_data_map;
typedef struct _vm_instruction_map vm_instruction_map;


/* each PowerPC requires two virtual memory maps */

INLINE_VM vm *vm_create
(core *memory);

INLINE_VM vm_data_map *vm_create_data_map
(vm *memory);

INLINE_VM vm_instruction_map *vm_create_instruction_map
(vm *memory);


/* address translation, if the translation is invalid
   these will not return */

INLINE_VM unsigned_word vm_real_data_addr
(vm_data_map *data_map,
 unsigned_word ea,
 int is_read,
 cpu *processor,
 unsigned_word cia);

INLINE_VM unsigned_word vm_real_instruction_addr
(vm_instruction_map *instruction_map,
 cpu *processor,
 unsigned_word cia);


/* block transfers */

INLINE_VM int vm_data_map_read_buffer
(vm_data_map *data_map,
 void *target,
 unsigned_word addr,
 unsigned len,
 transfer_mode mode);

INLINE_VM int vm_data_map_write_buffer
(vm_data_map *data_map,
 const void *source,
 unsigned_word addr,
 unsigned len,
 transfer_mode mode,
 int violate_read_only_section);


/* fetch the next instruction from memory */

INLINE_VM instruction_word vm_instruction_map_read
(vm_instruction_map *instruction_map,
 cpu *processor,
 unsigned_word cia);


/* read data from memory */

#define DECLARE_VM_DATA_MAP_READ_N(N) \
INLINE_VM unsigned_##N vm_data_map_read_##N \
(vm_data_map *map, \
 unsigned_word ea, \
 cpu *processor, \
 unsigned_word cia);

DECLARE_VM_DATA_MAP_READ_N(1)
DECLARE_VM_DATA_MAP_READ_N(2)
DECLARE_VM_DATA_MAP_READ_N(4)
DECLARE_VM_DATA_MAP_READ_N(8)


/* write data to memory */

#define DECLARE_VM_DATA_MAP_WRITE_N(N) \
INLINE_VM void vm_data_map_write_##N \
(vm_data_map *map, \
 unsigned_word addr, \
 unsigned_##N val, \
 cpu *processor, \
 unsigned_word cia);

DECLARE_VM_DATA_MAP_WRITE_N(1)
DECLARE_VM_DATA_MAP_WRITE_N(2)
DECLARE_VM_DATA_MAP_WRITE_N(4)
DECLARE_VM_DATA_MAP_WRITE_N(8)


/* update vm data structures due to a synchronization point */

INLINE_VM void vm_synchronize_context
(vm *memory,
 spreg *sprs,
 sreg *srs,
 msreg msr);

#endif