memory: render_memory_region: factor out fr constant setters
These 4 replicated lines set properties of fr that are constant over the course of the function. Factor out their repeated setting (and also guards against them being set multiple times in the loop below). Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
41a6e477fd
commit
2eb74e1a1e
13
memory.c
13
memory.c
@ -556,6 +556,11 @@ static void render_memory_region(FlatView *view,
|
|||||||
base = clip.start;
|
base = clip.start;
|
||||||
remain = clip.size;
|
remain = clip.size;
|
||||||
|
|
||||||
|
fr.mr = mr;
|
||||||
|
fr.dirty_log_mask = mr->dirty_log_mask;
|
||||||
|
fr.romd_mode = mr->romd_mode;
|
||||||
|
fr.readonly = readonly;
|
||||||
|
|
||||||
/* Render the region itself into any gaps left by the current view. */
|
/* Render the region itself into any gaps left by the current view. */
|
||||||
for (i = 0; i < view->nr && int128_nz(remain); ++i) {
|
for (i = 0; i < view->nr && int128_nz(remain); ++i) {
|
||||||
if (int128_ge(base, addrrange_end(view->ranges[i].addr))) {
|
if (int128_ge(base, addrrange_end(view->ranges[i].addr))) {
|
||||||
@ -564,12 +569,8 @@ static void render_memory_region(FlatView *view,
|
|||||||
if (int128_lt(base, view->ranges[i].addr.start)) {
|
if (int128_lt(base, view->ranges[i].addr.start)) {
|
||||||
now = int128_min(remain,
|
now = int128_min(remain,
|
||||||
int128_sub(view->ranges[i].addr.start, base));
|
int128_sub(view->ranges[i].addr.start, base));
|
||||||
fr.mr = mr;
|
|
||||||
fr.offset_in_region = offset_in_region;
|
fr.offset_in_region = offset_in_region;
|
||||||
fr.addr = addrrange_make(base, now);
|
fr.addr = addrrange_make(base, now);
|
||||||
fr.dirty_log_mask = mr->dirty_log_mask;
|
|
||||||
fr.romd_mode = mr->romd_mode;
|
|
||||||
fr.readonly = readonly;
|
|
||||||
flatview_insert(view, i, &fr);
|
flatview_insert(view, i, &fr);
|
||||||
++i;
|
++i;
|
||||||
int128_addto(&base, now);
|
int128_addto(&base, now);
|
||||||
@ -584,12 +585,8 @@ static void render_memory_region(FlatView *view,
|
|||||||
int128_subfrom(&remain, now);
|
int128_subfrom(&remain, now);
|
||||||
}
|
}
|
||||||
if (int128_nz(remain)) {
|
if (int128_nz(remain)) {
|
||||||
fr.mr = mr;
|
|
||||||
fr.offset_in_region = offset_in_region;
|
fr.offset_in_region = offset_in_region;
|
||||||
fr.addr = addrrange_make(base, remain);
|
fr.addr = addrrange_make(base, remain);
|
||||||
fr.dirty_log_mask = mr->dirty_log_mask;
|
|
||||||
fr.romd_mode = mr->romd_mode;
|
|
||||||
fr.readonly = readonly;
|
|
||||||
flatview_insert(view, i, &fr);
|
flatview_insert(view, i, &fr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user