Browse Source

[Settings] Convert code in src/usr to use settings API.

tags/v0.9.4
Michael Brown 16 years ago
parent
commit
eae6ac3d0b
5 changed files with 41 additions and 10 deletions
  1. 31
    4
      src/core/settings.c
  2. 3
    0
      src/include/gpxe/settings.h
  3. 2
    1
      src/usr/aoeboot.c
  4. 3
    4
      src/usr/autoboot.c
  5. 2
    1
      src/usr/iscsiboot.c

+ 31
- 4
src/core/settings.c View File

@@ -156,16 +156,14 @@ static void reprioritise_settings ( struct settings *settings ) {
156 156
 		return;
157 157
 
158 158
 	/* Read priority, if present */
159
-	priority = 0;
160
-	fetch_int_setting ( settings, DHCP_EB_PRIORITY, &priority );
159
+	priority = fetch_intz_setting ( settings, DHCP_EB_PRIORITY );
161 160
 
162 161
 	/* Remove from siblings list */
163 162
 	list_del ( &settings->siblings );
164 163
 
165 164
 	/* Reinsert after any existing blocks which have a higher priority */
166 165
 	list_for_each_entry ( tmp, &parent->children, siblings ) {
167
-		tmp_priority = 0;
168
-		fetch_int_setting ( tmp, DHCP_EB_PRIORITY, &tmp_priority );
166
+		tmp_priority = fetch_intz_setting ( tmp, DHCP_EB_PRIORITY );
169 167
 		if ( priority > tmp_priority )
170 168
 			break;
171 169
 	}
@@ -441,6 +439,35 @@ int fetch_uint_setting ( struct settings *settings, unsigned int tag,
441 439
 	return len;
442 440
 }
443 441
 
442
+/**
443
+ * Fetch value of signed integer setting, or zero
444
+ *
445
+ * @v settings		Settings block, or NULL to search all blocks
446
+ * @v tag		Setting tag number
447
+ * @ret value		Setting value, or zero
448
+ */
449
+long fetch_intz_setting ( struct settings *settings, unsigned int tag ) {
450
+	long value = 0;
451
+
452
+	fetch_int_setting ( settings, tag, &value );
453
+	return value;
454
+}
455
+
456
+/**
457
+ * Fetch value of unsigned integer setting, or zero
458
+ *
459
+ * @v settings		Settings block, or NULL to search all blocks
460
+ * @v tag		Setting tag number
461
+ * @ret value		Setting value, or zero
462
+ */
463
+unsigned long fetch_uintz_setting ( struct settings *settings,
464
+				    unsigned int tag ) {
465
+	unsigned long value = 0;
466
+
467
+	fetch_uint_setting ( settings, tag, &value );
468
+	return value;
469
+}
470
+
444 471
 /******************************************************************************
445 472
  *
446 473
  * Named and typed setting routines

+ 3
- 0
src/include/gpxe/settings.h View File

@@ -160,6 +160,9 @@ extern int fetch_int_setting ( struct settings *settings, unsigned int tag,
160 160
 			       long *value );
161 161
 extern int fetch_uint_setting ( struct settings *settings, unsigned int tag,
162 162
 				unsigned long *value );
163
+extern long fetch_intz_setting ( struct settings *settings, unsigned int tag );
164
+extern unsigned long fetch_uintz_setting ( struct settings *settings,
165
+					   unsigned int tag );
163 166
 extern struct settings * find_settings ( const char *name );
164 167
 extern int store_typed_setting ( struct settings *settings,
165 168
 				 unsigned int tag, struct setting_type *type,

+ 2
- 1
src/usr/aoeboot.c View File

@@ -6,6 +6,7 @@
6 6
 #include <gpxe/ata.h>
7 7
 #include <gpxe/netdevice.h>
8 8
 #include <gpxe/dhcp.h>
9
+#include <gpxe/settings.h>
9 10
 #include <gpxe/abft.h>
10 11
 #include <int13.h>
11 12
 #include <usr/aoeboot.h>
@@ -55,7 +56,7 @@ int aoeboot ( const char *root_path ) {
55 56
 		container_of ( ata.backend, struct aoe_session, refcnt );
56 57
 	abft_fill_data ( aoe );
57 58
 
58
-	drive.drive = find_global_dhcp_num_option ( DHCP_EB_BIOS_DRIVE );
59
+	drive.drive = fetch_uintz_setting ( NULL, DHCP_EB_BIOS_DRIVE );
59 60
 	drive.blockdev = &ata.blockdev;
60 61
 
61 62
 	register_int13_drive ( &drive );

+ 3
- 4
src/usr/autoboot.c View File

@@ -21,6 +21,7 @@
21 21
 #include <errno.h>
22 22
 #include <gpxe/netdevice.h>
23 23
 #include <gpxe/dhcp.h>
24
+#include <gpxe/settings.h>
24 25
 #include <gpxe/image.h>
25 26
 #include <gpxe/embedded.h>
26 27
 #include <usr/ifmgmt.h>
@@ -146,16 +147,14 @@ static int netboot ( struct net_device *netdev ) {
146 147
 		return rc;
147 148
 
148 149
 	/* Try to download and boot whatever we are given as a filename */
149
-	dhcp_snprintf ( buf, sizeof ( buf ),
150
-			find_global_dhcp_option ( DHCP_BOOTFILE_NAME ) );
150
+	fetch_string_setting ( NULL, DHCP_BOOTFILE_NAME, buf, sizeof ( buf ) );
151 151
 	if ( buf[0] ) {
152 152
 		printf ( "Booting from filename \"%s\"\n", buf );
153 153
 		return boot_filename ( buf );
154 154
 	}
155 155
 	
156 156
 	/* No filename; try the root path */
157
-	dhcp_snprintf ( buf, sizeof ( buf ),
158
-			find_global_dhcp_option ( DHCP_ROOT_PATH ) );
157
+	fetch_string_setting ( NULL, DHCP_ROOT_PATH, buf, sizeof ( buf ) );
159 158
 	if ( buf[0] ) {
160 159
 		printf ( "Booting from root path \"%s\"\n", buf );
161 160
 		return boot_root_path ( buf );

+ 2
- 1
src/usr/iscsiboot.c View File

@@ -3,6 +3,7 @@
3 3
 #include <stdio.h>
4 4
 #include <gpxe/iscsi.h>
5 5
 #include <gpxe/dhcp.h>
6
+#include <gpxe/settings.h>
6 7
 #include <gpxe/netdevice.h>
7 8
 #include <gpxe/ibft.h>
8 9
 #include <int13.h>
@@ -45,7 +46,7 @@ int iscsiboot ( const char *root_path ) {
45 46
 		goto error_init;
46 47
 	}
47 48
 
48
-	drive.drive = find_global_dhcp_num_option ( DHCP_EB_BIOS_DRIVE );
49
+	drive.drive = fetch_uintz_setting ( NULL, DHCP_EB_BIOS_DRIVE );
49 50
 	drive.blockdev = &scsi.blockdev;
50 51
 
51 52
 	/* FIXME: ugly, ugly hack */

Loading…
Cancel
Save