|
@@ -142,28 +142,36 @@ static int memmap_settings_fetch ( struct settings *settings,
|
142
|
142
|
struct memory_map memmap;
|
143
|
143
|
struct memory_region *region;
|
144
|
144
|
uint64_t result = 0;
|
145
|
|
- unsigned int i;
|
|
145
|
+ unsigned int start;
|
146
|
146
|
unsigned int count;
|
|
147
|
+ unsigned int scale;
|
|
148
|
+ int include_start;
|
|
149
|
+ int include_length;
|
|
150
|
+ int ignore_nonexistent;
|
|
151
|
+ unsigned int i;
|
147
|
152
|
|
148
|
|
- DBGC ( settings, "MEMMAP start %ld count %ld %s%s%s%s scale %ld\n",
|
149
|
|
- MEMMAP_START ( setting->tag ), MEMMAP_COUNT ( setting->tag ),
|
150
|
|
- ( MEMMAP_INCLUDE_START ( setting->tag ) ? "start" : "" ),
|
151
|
|
- ( ( MEMMAP_INCLUDE_START ( setting->tag ) &&
|
152
|
|
- MEMMAP_INCLUDE_LENGTH ( setting->tag ) ) ? "+" : "" ),
|
153
|
|
- ( MEMMAP_INCLUDE_LENGTH ( setting->tag ) ? "length" : "" ),
|
154
|
|
- ( MEMMAP_IGNORE_NONEXISTENT ( setting->tag ) ? " ignore" : "" ),
|
155
|
|
- MEMMAP_SCALE ( setting->tag ) );
|
|
153
|
+ /* Parse settings tag */
|
|
154
|
+ start = MEMMAP_START ( setting->tag );
|
|
155
|
+ count = MEMMAP_COUNT ( setting->tag );
|
|
156
|
+ scale = MEMMAP_SCALE ( setting->tag );
|
|
157
|
+ include_start = MEMMAP_INCLUDE_START ( setting->tag );
|
|
158
|
+ include_length = MEMMAP_INCLUDE_LENGTH ( setting->tag );
|
|
159
|
+ ignore_nonexistent = MEMMAP_IGNORE_NONEXISTENT ( setting->tag );
|
|
160
|
+ DBGC ( settings, "MEMMAP start %d count %d %s%s%s%s scale %d\n",
|
|
161
|
+ start, count, ( include_start ? "start" : "" ),
|
|
162
|
+ ( ( include_start && include_length ) ? "+" : "" ),
|
|
163
|
+ ( include_length ? "length" : "" ),
|
|
164
|
+ ( ignore_nonexistent ? " ignore" : "" ), scale );
|
156
|
165
|
|
157
|
166
|
/* Fetch memory map */
|
158
|
167
|
get_memmap ( &memmap );
|
159
|
168
|
|
160
|
169
|
/* Extract results from memory map */
|
161
|
|
- count = MEMMAP_COUNT ( setting->tag );
|
162
|
|
- for ( i = MEMMAP_START ( setting->tag ) ; count-- ; i++ ) {
|
|
170
|
+ for ( i = start ; count-- ; i++ ) {
|
163
|
171
|
|
164
|
172
|
/* Check that region exists */
|
165
|
173
|
if ( i >= memmap.count ) {
|
166
|
|
- if ( MEMMAP_IGNORE_NONEXISTENT ( setting->tag ) ) {
|
|
174
|
+ if ( ignore_nonexistent ) {
|
167
|
175
|
continue;
|
168
|
176
|
} else {
|
169
|
177
|
DBGC ( settings, "MEMMAP region %d does not "
|
|
@@ -174,12 +182,12 @@ static int memmap_settings_fetch ( struct settings *settings,
|
174
|
182
|
|
175
|
183
|
/* Extract results from this region */
|
176
|
184
|
region = &memmap.regions[i];
|
177
|
|
- if ( MEMMAP_INCLUDE_START ( setting->tag ) ) {
|
|
185
|
+ if ( include_start ) {
|
178
|
186
|
result += region->start;
|
179
|
187
|
DBGC ( settings, "MEMMAP %d start %08llx\n",
|
180
|
188
|
i, region->start );
|
181
|
189
|
}
|
182
|
|
- if ( MEMMAP_INCLUDE_LENGTH ( setting->tag ) ) {
|
|
190
|
+ if ( include_length ) {
|
183
|
191
|
result += ( region->end - region->start );
|
184
|
192
|
DBGC ( settings, "MEMMAP %d length %08llx\n",
|
185
|
193
|
i, ( region->end - region->start ) );
|
|
@@ -187,7 +195,7 @@ static int memmap_settings_fetch ( struct settings *settings,
|
187
|
195
|
}
|
188
|
196
|
|
189
|
197
|
/* Scale result */
|
190
|
|
- result >>= MEMMAP_SCALE ( setting->tag );
|
|
198
|
+ result >>= scale;
|
191
|
199
|
|
192
|
200
|
/* Return result */
|
193
|
201
|
result = cpu_to_be64 ( result );
|