Skip to content

Commit 206910b

Browse files
committed
exec/ram_addr.h: New header to match upstream.
This moves some ram_addr_t declarations to a new header to match upstream. Later patches will modify the code itself. Change-Id: Iff9936c97c5d4fba51b645c6d533958e621f14f4
1 parent 8608806 commit 206910b

File tree

13 files changed

+104
-66
lines changed

13 files changed

+104
-66
lines changed

arch_init.c

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "migration/qemu-file.h"
4242
#include "net/net.h"
4343
#include "exec/gdbstub.h"
44+
#include "exec/ram_addr.h"
4445
#include "hw/i386/smbios.h"
4546

4647
#ifdef TARGET_SPARC

cputlb.c

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "cpu.h"
2222
#include "exec/exec-all.h"
2323
#include "exec/cputlb.h"
24+
#include "exec/ram_addr.h"
2425

2526
/* statistics */
2627
int tlb_flush_count;

exec.c

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "sysemu/kvm.h"
4545
#include "exec/cputlb.h"
4646
#include "exec/hax.h"
47+
#include "exec/ram_addr.h"
4748
#include "qemu/timer.h"
4849
#if defined(CONFIG_USER_ONLY)
4950
#include <qemu.h>

hw/android/android_arm.c

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "android/globals.h"
2020
#include "audio/audio.h"
2121
#include "hw/arm/arm.h"
22+
#include "exec/ram_addr.h"
2223
#include "ui/console.h"
2324
#include "sysemu/blockdev.h"
2425
#include "hw/android/goldfish/pipe.h"

hw/android/android_mips.c

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "hw/android/goldfish/pipe.h"
2121
#include "android/globals.h"
2222
#include "audio/audio.h"
23+
#include "exec/ram_addr.h"
2324
#include "sysemu/blockdev.h"
2425

2526
#include "android/utils/debug.h"

hw/android/goldfish/fb.c

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "android/android.h"
1515
#include "android/utils/debug.h"
1616
#include "android/utils/duff.h"
17+
#include "exec/ram_addr.h"
1718
#include "hw/android/goldfish/device.h"
1819
#include "hw/hw.h"
1920
#include "ui/console.h"

hw/android/goldfish/pipe.c

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "hw/android/goldfish/pipe.h"
1515
#include "hw/android/goldfish/device.h"
1616
#include "hw/android/goldfish/vmem.h"
17+
#include "exec/ram_addr.h"
1718
#include "qemu/timer.h"
1819

1920
#define DEBUG 0

hw/arm/armv7m.c

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "hw/sysbus.h"
1111
#include "hw/arm/arm.h"
12+
#include "exec/ram_addr.h"
1213
#include "sysemu/sysemu.h"
1314

1415
/* Bitbanded IO. Each word corresponds to a single bit. */

hw/i386/pc.c

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "hw/i386/pc.h"
2626
#include "hw/loader.h"
2727
#include "hw/pci/pci.h"
28+
#include "exec/ram_addr.h"
2829
#include "block/block.h"
2930
#include "sysemu/sysemu.h"
3031
#include "sysemu/blockdev.h"

include/exec/cpu-all.h

-53
Original file line numberDiff line numberDiff line change
@@ -498,60 +498,8 @@ extern int mem_prealloc;
498498
#define CODE_DIRTY_FLAG 0x02
499499
#define MIGRATION_DIRTY_FLAG 0x08
500500

501-
/* read dirty bit (return 0 or 1) */
502-
static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)
503-
{
504-
return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] == 0xff;
505-
}
506-
507-
static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr)
508-
{
509-
return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS];
510-
}
511-
512-
static inline int cpu_physical_memory_get_dirty(ram_addr_t addr,
513-
int dirty_flags)
514-
{
515-
return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] & dirty_flags;
516-
}
517-
518-
static inline void cpu_physical_memory_set_dirty(ram_addr_t addr)
519-
{
520-
ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] = 0xff;
521-
}
522-
523-
static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr,
524-
int dirty_flags)
525-
{
526-
return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags;
527-
}
528-
529-
static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
530-
int length,
531-
int dirty_flags)
532-
{
533-
int i, mask, len;
534-
uint8_t *p;
535-
536-
len = length >> TARGET_PAGE_BITS;
537-
mask = ~dirty_flags;
538-
p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
539-
for (i = 0; i < len; i++) {
540-
p[i] &= mask;
541-
}
542-
}
543-
544-
void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
545-
int dirty_flags);
546501
void cpu_tlb_update_dirty(CPUArchState *env);
547502

548-
int cpu_physical_memory_set_dirty_tracking(int enable);
549-
550-
int cpu_physical_memory_get_dirty_tracking(void);
551-
552-
int cpu_physical_sync_dirty_bitmap(hwaddr start_addr,
553-
hwaddr end_addr);
554-
555503
void dump_exec_info(FILE *f,
556504
int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
557505

@@ -566,7 +514,6 @@ void qemu_unregister_coalesced_mmio(hwaddr addr, ram_addr_t size);
566514

567515
void qemu_flush_coalesced_mmio_buffer(void);
568516

569-
570517
/* profiling */
571518
#ifdef CONFIG_PROFILER
572519
static inline int64_t profile_getclock(void)

include/exec/cpu-common.h

-13
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,6 @@ static inline void cpu_register_physical_memory(hwaddr start_addr,
8181
}
8282

8383
ram_addr_t cpu_get_physical_page_desc(hwaddr addr);
84-
ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name,
85-
ram_addr_t size, void *host);
86-
ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size);
87-
void qemu_ram_free(ram_addr_t addr);
88-
void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
89-
/* This should only be used for ram local to a device. */
90-
void *qemu_get_ram_ptr(ram_addr_t addr);
91-
/* Same but slower, to use for migration, where the order of
92-
* RAMBlocks must not change. */
93-
void *qemu_safe_ram_ptr(ram_addr_t addr);
94-
/* This should not be used by devices. */
95-
int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr);
96-
ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr);
9784

9885
int cpu_register_io_memory(CPUReadMemoryFunc * const *mem_read,
9986
CPUWriteMemoryFunc * const *mem_write,

include/exec/ram_addr.h

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Declarations for cpu physical memory functions
3+
*
4+
* Copyright 2011 Red Hat, Inc. and/or its affiliates
5+
*
6+
* Authors:
7+
* Avi Kivity <[email protected]>
8+
*
9+
* This work is licensed under the terms of the GNU GPL, version 2 or
10+
* later. See the COPYING file in the top-level directory.
11+
*
12+
*/
13+
14+
/*
15+
* This header is for use by exec.c and memory.c ONLY. Do not include it.
16+
* The functions declared here will be removed soon.
17+
*/
18+
19+
#ifndef RAM_ADDR_H
20+
#define RAM_ADDR_H
21+
22+
#ifndef CONFIG_USER_ONLY
23+
#include "hw/xen/xen.h"
24+
25+
ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name,
26+
ram_addr_t size, void *host);
27+
ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size);
28+
/* This should only be used for ram local to a device. */
29+
void *qemu_get_ram_ptr(ram_addr_t addr);
30+
/* This should only be used for ram local to a device. */
31+
/* Same but slower, to use for migration, where the order of
32+
* RAMBlocks must not change. */
33+
void *qemu_safe_ram_ptr(ram_addr_t addr);
34+
/* This should not be used by devices. */
35+
int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr);
36+
void qemu_ram_free(ram_addr_t addr);
37+
void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
38+
ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr);
39+
40+
static inline int cpu_physical_memory_get_dirty(ram_addr_t addr,
41+
int dirty_flags)
42+
{
43+
return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] & dirty_flags;
44+
}
45+
46+
static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr)
47+
{
48+
return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS];
49+
}
50+
51+
/* read dirty bit (return 0 or 1) */
52+
static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)
53+
{
54+
return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] == 0xff;
55+
}
56+
57+
static inline void cpu_physical_memory_set_dirty(ram_addr_t addr)
58+
{
59+
ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] = 0xff;
60+
}
61+
62+
static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr,
63+
int dirty_flags)
64+
{
65+
return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags;
66+
}
67+
68+
static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
69+
int length,
70+
int dirty_flags)
71+
{
72+
int i, mask, len;
73+
uint8_t *p;
74+
75+
len = length >> TARGET_PAGE_BITS;
76+
mask = ~dirty_flags;
77+
p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
78+
for (i = 0; i < len; i++) {
79+
p[i] &= mask;
80+
}
81+
}
82+
83+
int cpu_physical_memory_set_dirty_tracking(int enable);
84+
85+
int cpu_physical_memory_get_dirty_tracking(void);
86+
87+
int cpu_physical_sync_dirty_bitmap(hwaddr start_addr,
88+
hwaddr end_addr);
89+
90+
void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
91+
int dirty_flags);
92+
93+
#endif
94+
#endif

kvm-all.c

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "hw/hw.h"
2727
#include "android/kvm.h"
2828
#include "exec/gdbstub.h"
29+
#include "exec/ram_addr.h"
2930
#include "sysemu/kvm.h"
3031

3132
/* KVM uses PAGE_SIZE in it's definition of COALESCED_MMIO_MAX */

0 commit comments

Comments
 (0)