/[dynamips]/upstream/dynamips-0.2.7-RC1/memory.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /upstream/dynamips-0.2.7-RC1/memory.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (show annotations)
Sat Oct 6 16:23:47 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 3961 byte(s)
dynamips-0.2.7-RC1

1 /*
2 * Cisco router simulation platform.
3 * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr)
4 */
5
6 #ifndef __MEMORY_H__
7 #define __MEMORY_H__
8
9 #include <sys/types.h>
10 #include "utils.h"
11
12 /* MTS operation */
13 #define MTS_READ 0
14 #define MTS_WRITE 1
15
16 /* 0.5GB value */
17 #define MTS_SIZE_512M 0x20000000
18
19 /* MTS flag bits: D (device), ACC (memory access), C (chain) */
20 #define MTS_FLAG_BITS 4
21 #define MTS_FLAG_MASK 0x0000000fUL
22
23 /* Masks for MTS entries */
24 #define MTS_CHAIN_MASK 0x00000001
25 #define MTS_ACC_MASK 0x00000006
26 #define MTS_DEV_MASK 0x00000008
27 #define MTS_ADDR_MASK (~MTS_FLAG_MASK)
28
29 /* Device ID mask and shift, device offset mask */
30 #define MTS_DEVID_MASK 0xfc000000
31 #define MTS_DEVID_SHIFT 26
32 #define MTS_DEVOFF_MASK 0x03fffff0
33
34 /* Memory access flags */
35 #define MTS_ACC_OK 0x00000000 /* Access OK */
36 #define MTS_ACC_AE 0x00000002 /* Address Error */
37 #define MTS_ACC_T 0x00000004 /* TLB Exception */
38 #define MTS_ACC_U 0x00000006 /* Unexistent */
39
40 /* Hash table size for MTS64 (default: [shift:16,bits:12]) */
41 #define MTS64_HASH_SHIFT 12
42 #define MTS64_HASH_BITS 14
43 #define MTS64_HASH_SIZE (1 << MTS64_HASH_BITS)
44 #define MTS64_HASH_MASK (MTS64_HASH_SIZE - 1)
45
46 /* MTS64 hash on virtual addresses */
47 #define MTS64_HASH(vaddr) (((vaddr) >> MTS64_HASH_SHIFT) & MTS64_HASH_MASK)
48
49 /* Hash table size for MTS32 (default: [shift:15,bits:15]) */
50 #define MTS32_HASH_SHIFT 12
51 #define MTS32_HASH_BITS 14
52 #define MTS32_HASH_SIZE (1 << MTS32_HASH_BITS)
53 #define MTS32_HASH_MASK (MTS32_HASH_SIZE - 1)
54
55 /* MTS32 hash on virtual addresses */
56 #define MTS32_HASH(vaddr) (((vaddr) >> MTS32_HASH_SHIFT) & MTS32_HASH_MASK)
57
58 /* Number of entries per chunk */
59 #define MTS64_CHUNK_SIZE 256
60 #define MTS32_CHUNK_SIZE 256
61
62 /* MTS64: chunk definition */
63 struct mts64_chunk {
64 mts64_entry_t entry[MTS64_CHUNK_SIZE];
65 struct mts64_chunk *next;
66 u_int count;
67 };
68
69 /* MTS32: chunk definition */
70 struct mts32_chunk {
71 mts32_entry_t entry[MTS32_CHUNK_SIZE];
72 struct mts32_chunk *next;
73 u_int count;
74 };
75
76 /* Record a memory access */
77 void memlog_rec_access(cpu_gen_t *cpu,m_uint64_t vaddr,m_uint64_t data,
78 m_uint32_t op_size,m_uint32_t op_type);
79
80 /* Show the last memory accesses */
81 void memlog_dump(cpu_gen_t *cpu);
82
83 /* Update the data obtained by a read access */
84 void memlog_update_read(cpu_gen_t *cpu,m_iptr_t raddr);
85
86 /* Copy a memory block from VM physical RAM to real host */
87 void physmem_copy_from_vm(vm_instance_t *vm,void *real_buffer,
88 m_uint64_t paddr,size_t len);
89
90 /* Copy a memory block to VM physical RAM from real host */
91 void physmem_copy_to_vm(vm_instance_t *vm,void *real_buffer,
92 m_uint64_t paddr,size_t len);
93
94 /* Copy a 32-bit word from the VM physical RAM to real host */
95 m_uint32_t physmem_copy_u32_from_vm(vm_instance_t *vm,m_uint64_t paddr);
96
97 /* Copy a 32-bit word to the VM physical RAM from real host */
98 void physmem_copy_u32_to_vm(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t val);
99
100 /* Copy a 16-bit word from the VM physical RAM to real host */
101 m_uint16_t physmem_copy_u16_from_vm(vm_instance_t *vm,m_uint64_t paddr);
102
103 /* Copy a 16-bit word to the VM physical RAM from real host */
104 void physmem_copy_u16_to_vm(vm_instance_t *vm,m_uint64_t paddr,m_uint16_t val);
105
106 /* Copy a byte from the VM physical RAM to real host */
107 m_uint8_t physmem_copy_u8_from_vm(vm_instance_t *vm,m_uint64_t paddr);
108
109 /* Copy a 16-bit word to the VM physical RAM from real host */
110 void physmem_copy_u8_to_vm(vm_instance_t *vm,m_uint64_t paddr,m_uint8_t val);
111
112 /* DMA transfer operation */
113 void physmem_dma_transfer(vm_instance_t *vm,m_uint64_t src,m_uint64_t dst,
114 size_t len);
115
116 /* strlen in VM physical memory */
117 size_t physmem_strlen(vm_instance_t *vm,m_uint64_t paddr);
118
119 /* Physical memory dump (32-bit words) */
120 void physmem_dump_vm(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t u32_count);
121
122 #endif

  ViewVC Help
Powered by ViewVC 1.1.26