Explorar el Código

[settings] Extend numerical setting tags to 64 bits

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown hace 7 años
padre
commit
ee9897fe64
Se han modificado 3 ficheros con 26 adiciones y 18 borrados
  1. 23
    15
      src/core/memmap_settings.c
  2. 2
    2
      src/core/settings.c
  3. 1
    1
      src/include/ipxe/settings.h

+ 23
- 15
src/core/memmap_settings.c Ver fichero

142
 	struct memory_map memmap;
142
 	struct memory_map memmap;
143
 	struct memory_region *region;
143
 	struct memory_region *region;
144
 	uint64_t result = 0;
144
 	uint64_t result = 0;
145
-	unsigned int i;
145
+	unsigned int start;
146
 	unsigned int count;
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
 	/* Fetch memory map */
166
 	/* Fetch memory map */
158
 	get_memmap ( &memmap );
167
 	get_memmap ( &memmap );
159
 
168
 
160
 	/* Extract results from memory map */
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
 		/* Check that region exists */
172
 		/* Check that region exists */
165
 		if ( i >= memmap.count ) {
173
 		if ( i >= memmap.count ) {
166
-			if ( MEMMAP_IGNORE_NONEXISTENT ( setting->tag ) ) {
174
+			if ( ignore_nonexistent ) {
167
 				continue;
175
 				continue;
168
 			} else {
176
 			} else {
169
 				DBGC ( settings, "MEMMAP region %d does not "
177
 				DBGC ( settings, "MEMMAP region %d does not "
174
 
182
 
175
 		/* Extract results from this region */
183
 		/* Extract results from this region */
176
 		region = &memmap.regions[i];
184
 		region = &memmap.regions[i];
177
-		if ( MEMMAP_INCLUDE_START ( setting->tag ) ) {
185
+		if ( include_start ) {
178
 			result += region->start;
186
 			result += region->start;
179
 			DBGC ( settings, "MEMMAP %d start %08llx\n",
187
 			DBGC ( settings, "MEMMAP %d start %08llx\n",
180
 			       i, region->start );
188
 			       i, region->start );
181
 		}
189
 		}
182
-		if ( MEMMAP_INCLUDE_LENGTH ( setting->tag ) ) {
190
+		if ( include_length ) {
183
 			result += ( region->end - region->start );
191
 			result += ( region->end - region->start );
184
 			DBGC ( settings, "MEMMAP %d length %08llx\n",
192
 			DBGC ( settings, "MEMMAP %d length %08llx\n",
185
 			       i, ( region->end - region->start ) );
193
 			       i, ( region->end - region->start ) );
187
 	}
195
 	}
188
 
196
 
189
 	/* Scale result */
197
 	/* Scale result */
190
-	result >>= MEMMAP_SCALE ( setting->tag );
198
+	result >>= scale;
191
 
199
 
192
 	/* Return result */
200
 	/* Return result */
193
 	result = cpu_to_be64 ( result );
201
 	result = cpu_to_be64 ( result );

+ 2
- 2
src/core/settings.c Ver fichero

1478
  * @v name		Name
1478
  * @v name		Name
1479
  * @ret tag		Tag number, or 0 if not a valid number
1479
  * @ret tag		Tag number, or 0 if not a valid number
1480
  */
1480
  */
1481
-static unsigned long parse_setting_tag ( const char *name ) {
1481
+static uint64_t parse_setting_tag ( const char *name ) {
1482
 	char *tmp = ( ( char * ) name );
1482
 	char *tmp = ( ( char * ) name );
1483
-	unsigned long tag = 0;
1483
+	uint64_t tag = 0;
1484
 
1484
 
1485
 	while ( 1 ) {
1485
 	while ( 1 ) {
1486
 		tag = ( ( tag << 8 ) | strtoul ( tmp, &tmp, 0 ) );
1486
 		tag = ( ( tag << 8 ) | strtoul ( tmp, &tmp, 0 ) );

+ 1
- 1
src/include/ipxe/settings.h Ver fichero

40
 	 * (such as a DHCP option number, or an SMBIOS structure and
40
 	 * (such as a DHCP option number, or an SMBIOS structure and
41
 	 * field number).
41
 	 * field number).
42
 	 */
42
 	 */
43
-	unsigned long tag;
43
+	uint64_t tag;
44
 	/** Setting scope (or NULL)
44
 	/** Setting scope (or NULL)
45
 	 *
45
 	 *
46
 	 * For historic reasons, a NULL scope with a non-zero tag
46
 	 * For historic reasons, a NULL scope with a non-zero tag

Loading…
Cancelar
Guardar