Statistics
| Branch: | Revision:

root / cpu-defs.h @ 0443eaf6

History | View | Annotate | Download (2.9 kB)

1 ab93bbe2 bellard
/*
2 ab93bbe2 bellard
 * common defines for all CPUs
3 ab93bbe2 bellard
 * 
4 ab93bbe2 bellard
 * Copyright (c) 2003 Fabrice Bellard
5 ab93bbe2 bellard
 *
6 ab93bbe2 bellard
 * This library is free software; you can redistribute it and/or
7 ab93bbe2 bellard
 * modify it under the terms of the GNU Lesser General Public
8 ab93bbe2 bellard
 * License as published by the Free Software Foundation; either
9 ab93bbe2 bellard
 * version 2 of the License, or (at your option) any later version.
10 ab93bbe2 bellard
 *
11 ab93bbe2 bellard
 * This library is distributed in the hope that it will be useful,
12 ab93bbe2 bellard
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ab93bbe2 bellard
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 ab93bbe2 bellard
 * Lesser General Public License for more details.
15 ab93bbe2 bellard
 *
16 ab93bbe2 bellard
 * You should have received a copy of the GNU Lesser General Public
17 ab93bbe2 bellard
 * License along with this library; if not, write to the Free Software
18 ab93bbe2 bellard
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 ab93bbe2 bellard
 */
20 ab93bbe2 bellard
#ifndef CPU_DEFS_H
21 ab93bbe2 bellard
#define CPU_DEFS_H
22 ab93bbe2 bellard
23 ab93bbe2 bellard
#include "config.h"
24 ab93bbe2 bellard
#include <setjmp.h>
25 ed1c0bcb bellard
#include <inttypes.h>
26 ed1c0bcb bellard
#include "osdep.h"
27 ab93bbe2 bellard
28 35b66fc4 bellard
#ifndef TARGET_LONG_BITS
29 35b66fc4 bellard
#error TARGET_LONG_BITS must be defined before including this header
30 35b66fc4 bellard
#endif
31 35b66fc4 bellard
32 4f2ac237 bellard
#if defined(__alpha__) || defined (__ia64__) || defined(__x86_64__)
33 4f2ac237 bellard
#define HOST_LONG_BITS 64
34 4f2ac237 bellard
#else
35 4f2ac237 bellard
#define HOST_LONG_BITS 32
36 4f2ac237 bellard
#endif
37 4f2ac237 bellard
38 ab6d960f bellard
#ifndef TARGET_PHYS_ADDR_BITS 
39 4f2ac237 bellard
#if TARGET_LONG_BITS >= HOST_LONG_BITS
40 ab6d960f bellard
#define TARGET_PHYS_ADDR_BITS TARGET_LONG_BITS
41 4f2ac237 bellard
#else
42 4f2ac237 bellard
#define TARGET_PHYS_ADDR_BITS HOST_LONG_BITS
43 4f2ac237 bellard
#endif
44 ab6d960f bellard
#endif
45 ab6d960f bellard
46 35b66fc4 bellard
#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)
47 35b66fc4 bellard
48 ab6d960f bellard
/* target_ulong is the type of a virtual address */
49 35b66fc4 bellard
#if TARGET_LONG_SIZE == 4
50 35b66fc4 bellard
typedef int32_t target_long;
51 35b66fc4 bellard
typedef uint32_t target_ulong;
52 c27004ec bellard
#define TARGET_FMT_lx "%08x"
53 35b66fc4 bellard
#elif TARGET_LONG_SIZE == 8
54 35b66fc4 bellard
typedef int64_t target_long;
55 35b66fc4 bellard
typedef uint64_t target_ulong;
56 c27004ec bellard
#define TARGET_FMT_lx "%016llx"
57 35b66fc4 bellard
#else
58 35b66fc4 bellard
#error TARGET_LONG_SIZE undefined
59 35b66fc4 bellard
#endif
60 35b66fc4 bellard
61 ab6d960f bellard
/* target_phys_addr_t is the type of a physical address (its size can
62 4f2ac237 bellard
   be different from 'target_ulong'). We have sizeof(target_phys_addr)
63 4f2ac237 bellard
   = max(sizeof(unsigned long),
64 4f2ac237 bellard
   sizeof(size_of_target_physical_address)) because we must pass a
65 4f2ac237 bellard
   host pointer to memory operations in some cases */
66 4f2ac237 bellard
67 ab6d960f bellard
#if TARGET_PHYS_ADDR_BITS == 32
68 ab6d960f bellard
typedef uint32_t target_phys_addr_t;
69 ab6d960f bellard
#elif TARGET_PHYS_ADDR_BITS == 64
70 ab6d960f bellard
typedef uint64_t target_phys_addr_t;
71 ab6d960f bellard
#else
72 ab6d960f bellard
#error TARGET_PHYS_ADDR_BITS undefined
73 ab6d960f bellard
#endif
74 ab6d960f bellard
75 f193c797 bellard
#define HOST_LONG_SIZE (HOST_LONG_BITS / 8)
76 f193c797 bellard
77 ab93bbe2 bellard
#define EXCP_INTERRUPT         256 /* async interruption */
78 ab93bbe2 bellard
#define EXCP_HLT        257 /* hlt instruction reached */
79 ab93bbe2 bellard
#define EXCP_DEBUG      258 /* cpu stopped after a breakpoint or singlestep */
80 ab93bbe2 bellard
81 ab93bbe2 bellard
#define MAX_BREAKPOINTS 32
82 ab93bbe2 bellard
83 ab93bbe2 bellard
#define CPU_TLB_SIZE 256
84 ab93bbe2 bellard
85 ab93bbe2 bellard
typedef struct CPUTLBEntry {
86 db8d7466 bellard
    /* bit 31 to TARGET_PAGE_BITS : virtual address 
87 db8d7466 bellard
       bit TARGET_PAGE_BITS-1..IO_MEM_SHIFT : if non zero, memory io
88 db8d7466 bellard
                                              zone number
89 db8d7466 bellard
       bit 3                      : indicates that the entry is invalid
90 db8d7466 bellard
       bit 2..0                   : zero
91 db8d7466 bellard
    */
92 4f2ac237 bellard
    target_ulong address; 
93 db8d7466 bellard
    /* addend to virtual address to get physical address */
94 4f2ac237 bellard
    target_phys_addr_t addend; 
95 ab93bbe2 bellard
} CPUTLBEntry;
96 ab93bbe2 bellard
97 ab93bbe2 bellard
#endif