cpu-defs.h 2.89 KB
Newer Older
bellard's avatar
bellard committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * common defines for all CPUs
 * 
 * Copyright (c) 2003 Fabrice Bellard
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
#ifndef CPU_DEFS_H
#define CPU_DEFS_H

#include "config.h"
#include <setjmp.h>
bellard's avatar
bellard committed
25
26
#include <inttypes.h>
#include "osdep.h"
bellard's avatar
bellard committed
27

bellard's avatar
bellard committed
28
29
30
31
#ifndef TARGET_LONG_BITS
#error TARGET_LONG_BITS must be defined before including this header
#endif

bellard's avatar
bellard committed
32
#ifndef TARGET_PHYS_ADDR_BITS 
bellard's avatar
bellard committed
33
#if TARGET_LONG_BITS >= HOST_LONG_BITS
bellard's avatar
bellard committed
34
#define TARGET_PHYS_ADDR_BITS TARGET_LONG_BITS
bellard's avatar
bellard committed
35
36
37
#else
#define TARGET_PHYS_ADDR_BITS HOST_LONG_BITS
#endif
bellard's avatar
bellard committed
38
39
#endif

bellard's avatar
bellard committed
40
41
#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)

bellard's avatar
bellard committed
42
/* target_ulong is the type of a virtual address */
bellard's avatar
bellard committed
43
44
45
#if TARGET_LONG_SIZE == 4
typedef int32_t target_long;
typedef uint32_t target_ulong;
bellard's avatar
bellard committed
46
#define TARGET_FMT_lx "%08x"
bellard's avatar
bellard committed
47
48
49
#elif TARGET_LONG_SIZE == 8
typedef int64_t target_long;
typedef uint64_t target_ulong;
bellard's avatar
bellard committed
50
#define TARGET_FMT_lx "%016llx"
bellard's avatar
bellard committed
51
52
53
54
#else
#error TARGET_LONG_SIZE undefined
#endif

bellard's avatar
bellard committed
55
/* target_phys_addr_t is the type of a physical address (its size can
bellard's avatar
bellard committed
56
57
58
59
60
   be different from 'target_ulong'). We have sizeof(target_phys_addr)
   = max(sizeof(unsigned long),
   sizeof(size_of_target_physical_address)) because we must pass a
   host pointer to memory operations in some cases */

bellard's avatar
bellard committed
61
62
63
64
65
66
67
68
#if TARGET_PHYS_ADDR_BITS == 32
typedef uint32_t target_phys_addr_t;
#elif TARGET_PHYS_ADDR_BITS == 64
typedef uint64_t target_phys_addr_t;
#else
#error TARGET_PHYS_ADDR_BITS undefined
#endif

bellard's avatar
bellard committed
69
70
71
/* address in the RAM (different from a physical address) */
typedef unsigned long ram_addr_t;

72
73
#define HOST_LONG_SIZE (HOST_LONG_BITS / 8)

74
75
76
#define EXCP_INTERRUPT 	0x10000 /* async interruption */
#define EXCP_HLT        0x10001 /* hlt instruction reached */
#define EXCP_DEBUG      0x10002 /* cpu stopped after a breakpoint or singlestep */
bellard's avatar
bellard committed
77
78
79
80
81
82

#define MAX_BREAKPOINTS 32

#define CPU_TLB_SIZE 256

typedef struct CPUTLBEntry {
bellard's avatar
bellard committed
83
84
85
86
87
88
    /* bit 31 to TARGET_PAGE_BITS : virtual address 
       bit TARGET_PAGE_BITS-1..IO_MEM_SHIFT : if non zero, memory io
                                              zone number
       bit 3                      : indicates that the entry is invalid
       bit 2..0                   : zero
    */
bellard's avatar
bellard committed
89
    target_ulong address; 
bellard's avatar
bellard committed
90
    /* addend to virtual address to get physical address */
bellard's avatar
bellard committed
91
    target_phys_addr_t addend; 
bellard's avatar
bellard committed
92
93
94
} CPUTLBEntry;

#endif