[Settings] Convert code in src/usr to use settings API.
This commit is contained in:
parent
cf03304620
commit
eae6ac3d0b
@ -156,16 +156,14 @@ static void reprioritise_settings ( struct settings *settings ) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Read priority, if present */
|
/* Read priority, if present */
|
||||||
priority = 0;
|
priority = fetch_intz_setting ( settings, DHCP_EB_PRIORITY );
|
||||||
fetch_int_setting ( settings, DHCP_EB_PRIORITY, &priority );
|
|
||||||
|
|
||||||
/* Remove from siblings list */
|
/* Remove from siblings list */
|
||||||
list_del ( &settings->siblings );
|
list_del ( &settings->siblings );
|
||||||
|
|
||||||
/* Reinsert after any existing blocks which have a higher priority */
|
/* Reinsert after any existing blocks which have a higher priority */
|
||||||
list_for_each_entry ( tmp, &parent->children, siblings ) {
|
list_for_each_entry ( tmp, &parent->children, siblings ) {
|
||||||
tmp_priority = 0;
|
tmp_priority = fetch_intz_setting ( tmp, DHCP_EB_PRIORITY );
|
||||||
fetch_int_setting ( tmp, DHCP_EB_PRIORITY, &tmp_priority );
|
|
||||||
if ( priority > tmp_priority )
|
if ( priority > tmp_priority )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -441,6 +439,35 @@ int fetch_uint_setting ( struct settings *settings, unsigned int tag,
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch value of signed integer setting, or zero
|
||||||
|
*
|
||||||
|
* @v settings Settings block, or NULL to search all blocks
|
||||||
|
* @v tag Setting tag number
|
||||||
|
* @ret value Setting value, or zero
|
||||||
|
*/
|
||||||
|
long fetch_intz_setting ( struct settings *settings, unsigned int tag ) {
|
||||||
|
long value = 0;
|
||||||
|
|
||||||
|
fetch_int_setting ( settings, tag, &value );
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch value of unsigned integer setting, or zero
|
||||||
|
*
|
||||||
|
* @v settings Settings block, or NULL to search all blocks
|
||||||
|
* @v tag Setting tag number
|
||||||
|
* @ret value Setting value, or zero
|
||||||
|
*/
|
||||||
|
unsigned long fetch_uintz_setting ( struct settings *settings,
|
||||||
|
unsigned int tag ) {
|
||||||
|
unsigned long value = 0;
|
||||||
|
|
||||||
|
fetch_uint_setting ( settings, tag, &value );
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* Named and typed setting routines
|
* Named and typed setting routines
|
||||||
|
@ -160,6 +160,9 @@ extern int fetch_int_setting ( struct settings *settings, unsigned int tag,
|
|||||||
long *value );
|
long *value );
|
||||||
extern int fetch_uint_setting ( struct settings *settings, unsigned int tag,
|
extern int fetch_uint_setting ( struct settings *settings, unsigned int tag,
|
||||||
unsigned long *value );
|
unsigned long *value );
|
||||||
|
extern long fetch_intz_setting ( struct settings *settings, unsigned int tag );
|
||||||
|
extern unsigned long fetch_uintz_setting ( struct settings *settings,
|
||||||
|
unsigned int tag );
|
||||||
extern struct settings * find_settings ( const char *name );
|
extern struct settings * find_settings ( const char *name );
|
||||||
extern int store_typed_setting ( struct settings *settings,
|
extern int store_typed_setting ( struct settings *settings,
|
||||||
unsigned int tag, struct setting_type *type,
|
unsigned int tag, struct setting_type *type,
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <gpxe/ata.h>
|
#include <gpxe/ata.h>
|
||||||
#include <gpxe/netdevice.h>
|
#include <gpxe/netdevice.h>
|
||||||
#include <gpxe/dhcp.h>
|
#include <gpxe/dhcp.h>
|
||||||
|
#include <gpxe/settings.h>
|
||||||
#include <gpxe/abft.h>
|
#include <gpxe/abft.h>
|
||||||
#include <int13.h>
|
#include <int13.h>
|
||||||
#include <usr/aoeboot.h>
|
#include <usr/aoeboot.h>
|
||||||
@ -55,7 +56,7 @@ int aoeboot ( const char *root_path ) {
|
|||||||
container_of ( ata.backend, struct aoe_session, refcnt );
|
container_of ( ata.backend, struct aoe_session, refcnt );
|
||||||
abft_fill_data ( aoe );
|
abft_fill_data ( aoe );
|
||||||
|
|
||||||
drive.drive = find_global_dhcp_num_option ( DHCP_EB_BIOS_DRIVE );
|
drive.drive = fetch_uintz_setting ( NULL, DHCP_EB_BIOS_DRIVE );
|
||||||
drive.blockdev = &ata.blockdev;
|
drive.blockdev = &ata.blockdev;
|
||||||
|
|
||||||
register_int13_drive ( &drive );
|
register_int13_drive ( &drive );
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <gpxe/netdevice.h>
|
#include <gpxe/netdevice.h>
|
||||||
#include <gpxe/dhcp.h>
|
#include <gpxe/dhcp.h>
|
||||||
|
#include <gpxe/settings.h>
|
||||||
#include <gpxe/image.h>
|
#include <gpxe/image.h>
|
||||||
#include <gpxe/embedded.h>
|
#include <gpxe/embedded.h>
|
||||||
#include <usr/ifmgmt.h>
|
#include <usr/ifmgmt.h>
|
||||||
@ -146,16 +147,14 @@ static int netboot ( struct net_device *netdev ) {
|
|||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* Try to download and boot whatever we are given as a filename */
|
/* Try to download and boot whatever we are given as a filename */
|
||||||
dhcp_snprintf ( buf, sizeof ( buf ),
|
fetch_string_setting ( NULL, DHCP_BOOTFILE_NAME, buf, sizeof ( buf ) );
|
||||||
find_global_dhcp_option ( DHCP_BOOTFILE_NAME ) );
|
|
||||||
if ( buf[0] ) {
|
if ( buf[0] ) {
|
||||||
printf ( "Booting from filename \"%s\"\n", buf );
|
printf ( "Booting from filename \"%s\"\n", buf );
|
||||||
return boot_filename ( buf );
|
return boot_filename ( buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No filename; try the root path */
|
/* No filename; try the root path */
|
||||||
dhcp_snprintf ( buf, sizeof ( buf ),
|
fetch_string_setting ( NULL, DHCP_ROOT_PATH, buf, sizeof ( buf ) );
|
||||||
find_global_dhcp_option ( DHCP_ROOT_PATH ) );
|
|
||||||
if ( buf[0] ) {
|
if ( buf[0] ) {
|
||||||
printf ( "Booting from root path \"%s\"\n", buf );
|
printf ( "Booting from root path \"%s\"\n", buf );
|
||||||
return boot_root_path ( buf );
|
return boot_root_path ( buf );
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <gpxe/iscsi.h>
|
#include <gpxe/iscsi.h>
|
||||||
#include <gpxe/dhcp.h>
|
#include <gpxe/dhcp.h>
|
||||||
|
#include <gpxe/settings.h>
|
||||||
#include <gpxe/netdevice.h>
|
#include <gpxe/netdevice.h>
|
||||||
#include <gpxe/ibft.h>
|
#include <gpxe/ibft.h>
|
||||||
#include <int13.h>
|
#include <int13.h>
|
||||||
@ -45,7 +46,7 @@ int iscsiboot ( const char *root_path ) {
|
|||||||
goto error_init;
|
goto error_init;
|
||||||
}
|
}
|
||||||
|
|
||||||
drive.drive = find_global_dhcp_num_option ( DHCP_EB_BIOS_DRIVE );
|
drive.drive = fetch_uintz_setting ( NULL, DHCP_EB_BIOS_DRIVE );
|
||||||
drive.blockdev = &scsi.blockdev;
|
drive.blockdev = &scsi.blockdev;
|
||||||
|
|
||||||
/* FIXME: ugly, ugly hack */
|
/* FIXME: ugly, ugly hack */
|
||||||
|
Reference in New Issue
Block a user