mirror of https://github.com/ipxe/ipxe.git
[settings] Extend numerical setting tags to 64 bits
Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/49/merge
parent
2f12690455
commit
ee9897fe64
|
@ -142,28 +142,36 @@ static int memmap_settings_fetch ( struct settings *settings,
|
||||||
struct memory_map memmap;
|
struct memory_map memmap;
|
||||||
struct memory_region *region;
|
struct memory_region *region;
|
||||||
uint64_t result = 0;
|
uint64_t result = 0;
|
||||||
unsigned int i;
|
unsigned int start;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
unsigned int scale;
|
||||||
|
int include_start;
|
||||||
|
int include_length;
|
||||||
|
int ignore_nonexistent;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
DBGC ( settings, "MEMMAP start %ld count %ld %s%s%s%s scale %ld\n",
|
/* Parse settings tag */
|
||||||
MEMMAP_START ( setting->tag ), MEMMAP_COUNT ( setting->tag ),
|
start = MEMMAP_START ( setting->tag );
|
||||||
( MEMMAP_INCLUDE_START ( setting->tag ) ? "start" : "" ),
|
count = MEMMAP_COUNT ( setting->tag );
|
||||||
( ( MEMMAP_INCLUDE_START ( setting->tag ) &&
|
scale = MEMMAP_SCALE ( setting->tag );
|
||||||
MEMMAP_INCLUDE_LENGTH ( setting->tag ) ) ? "+" : "" ),
|
include_start = MEMMAP_INCLUDE_START ( setting->tag );
|
||||||
( MEMMAP_INCLUDE_LENGTH ( setting->tag ) ? "length" : "" ),
|
include_length = MEMMAP_INCLUDE_LENGTH ( setting->tag );
|
||||||
( MEMMAP_IGNORE_NONEXISTENT ( setting->tag ) ? " ignore" : "" ),
|
ignore_nonexistent = MEMMAP_IGNORE_NONEXISTENT ( setting->tag );
|
||||||
MEMMAP_SCALE ( setting->tag ) );
|
DBGC ( settings, "MEMMAP start %d count %d %s%s%s%s scale %d\n",
|
||||||
|
start, count, ( include_start ? "start" : "" ),
|
||||||
|
( ( include_start && include_length ) ? "+" : "" ),
|
||||||
|
( include_length ? "length" : "" ),
|
||||||
|
( ignore_nonexistent ? " ignore" : "" ), scale );
|
||||||
|
|
||||||
/* Fetch memory map */
|
/* Fetch memory map */
|
||||||
get_memmap ( &memmap );
|
get_memmap ( &memmap );
|
||||||
|
|
||||||
/* Extract results from memory map */
|
/* Extract results from memory map */
|
||||||
count = MEMMAP_COUNT ( setting->tag );
|
for ( i = start ; count-- ; i++ ) {
|
||||||
for ( i = MEMMAP_START ( setting->tag ) ; count-- ; i++ ) {
|
|
||||||
|
|
||||||
/* Check that region exists */
|
/* Check that region exists */
|
||||||
if ( i >= memmap.count ) {
|
if ( i >= memmap.count ) {
|
||||||
if ( MEMMAP_IGNORE_NONEXISTENT ( setting->tag ) ) {
|
if ( ignore_nonexistent ) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
DBGC ( settings, "MEMMAP region %d does not "
|
DBGC ( settings, "MEMMAP region %d does not "
|
||||||
|
@ -174,12 +182,12 @@ static int memmap_settings_fetch ( struct settings *settings,
|
||||||
|
|
||||||
/* Extract results from this region */
|
/* Extract results from this region */
|
||||||
region = &memmap.regions[i];
|
region = &memmap.regions[i];
|
||||||
if ( MEMMAP_INCLUDE_START ( setting->tag ) ) {
|
if ( include_start ) {
|
||||||
result += region->start;
|
result += region->start;
|
||||||
DBGC ( settings, "MEMMAP %d start %08llx\n",
|
DBGC ( settings, "MEMMAP %d start %08llx\n",
|
||||||
i, region->start );
|
i, region->start );
|
||||||
}
|
}
|
||||||
if ( MEMMAP_INCLUDE_LENGTH ( setting->tag ) ) {
|
if ( include_length ) {
|
||||||
result += ( region->end - region->start );
|
result += ( region->end - region->start );
|
||||||
DBGC ( settings, "MEMMAP %d length %08llx\n",
|
DBGC ( settings, "MEMMAP %d length %08llx\n",
|
||||||
i, ( region->end - region->start ) );
|
i, ( region->end - region->start ) );
|
||||||
|
@ -187,7 +195,7 @@ static int memmap_settings_fetch ( struct settings *settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scale result */
|
/* Scale result */
|
||||||
result >>= MEMMAP_SCALE ( setting->tag );
|
result >>= scale;
|
||||||
|
|
||||||
/* Return result */
|
/* Return result */
|
||||||
result = cpu_to_be64 ( result );
|
result = cpu_to_be64 ( result );
|
||||||
|
|
|
@ -1478,9 +1478,9 @@ struct setting * find_setting ( const char *name ) {
|
||||||
* @v name Name
|
* @v name Name
|
||||||
* @ret tag Tag number, or 0 if not a valid number
|
* @ret tag Tag number, or 0 if not a valid number
|
||||||
*/
|
*/
|
||||||
static unsigned long parse_setting_tag ( const char *name ) {
|
static uint64_t parse_setting_tag ( const char *name ) {
|
||||||
char *tmp = ( ( char * ) name );
|
char *tmp = ( ( char * ) name );
|
||||||
unsigned long tag = 0;
|
uint64_t tag = 0;
|
||||||
|
|
||||||
while ( 1 ) {
|
while ( 1 ) {
|
||||||
tag = ( ( tag << 8 ) | strtoul ( tmp, &tmp, 0 ) );
|
tag = ( ( tag << 8 ) | strtoul ( tmp, &tmp, 0 ) );
|
||||||
|
|
|
@ -40,7 +40,7 @@ struct setting {
|
||||||
* (such as a DHCP option number, or an SMBIOS structure and
|
* (such as a DHCP option number, or an SMBIOS structure and
|
||||||
* field number).
|
* field number).
|
||||||
*/
|
*/
|
||||||
unsigned long tag;
|
uint64_t tag;
|
||||||
/** Setting scope (or NULL)
|
/** Setting scope (or NULL)
|
||||||
*
|
*
|
||||||
* For historic reasons, a NULL scope with a non-zero tag
|
* For historic reasons, a NULL scope with a non-zero tag
|
||||||
|
|
Loading…
Reference in New Issue