浏览代码

[settings] Extend numerical setting tags to 64 bits

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 年前
父节点
当前提交
ee9897fe64
共有 3 个文件被更改,包括 26 次插入18 次删除
  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 查看文件

@@ -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 );

+ 2
- 2
src/core/settings.c 查看文件

@@ -1478,9 +1478,9 @@ struct setting * find_setting ( const char *name ) {
1478 1478
  * @v name		Name
1479 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 1482
 	char *tmp = ( ( char * ) name );
1483
-	unsigned long tag = 0;
1483
+	uint64_t tag = 0;
1484 1484
 
1485 1485
 	while ( 1 ) {
1486 1486
 		tag = ( ( tag << 8 ) | strtoul ( tmp, &tmp, 0 ) );

+ 1
- 1
src/include/ipxe/settings.h 查看文件

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

正在加载...
取消
保存