Browse Source

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

tags/v0.9.4
Michael Brown 17 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
 		return;
156
 		return;
157
 
157
 
158
 	/* Read priority, if present */
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
 	/* Remove from siblings list */
161
 	/* Remove from siblings list */
163
 	list_del ( &settings->siblings );
162
 	list_del ( &settings->siblings );
164
 
163
 
165
 	/* Reinsert after any existing blocks which have a higher priority */
164
 	/* Reinsert after any existing blocks which have a higher priority */
166
 	list_for_each_entry ( tmp, &parent->children, siblings ) {
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
 		if ( priority > tmp_priority )
167
 		if ( priority > tmp_priority )
170
 			break;
168
 			break;
171
 	}
169
 	}
441
 	return len;
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
  * Named and typed setting routines
473
  * Named and typed setting routines

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

160
 			       long *value );
160
 			       long *value );
161
 extern int fetch_uint_setting ( struct settings *settings, unsigned int tag,
161
 extern int fetch_uint_setting ( struct settings *settings, unsigned int tag,
162
 				unsigned long *value );
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
 extern struct settings * find_settings ( const char *name );
166
 extern struct settings * find_settings ( const char *name );
164
 extern int store_typed_setting ( struct settings *settings,
167
 extern int store_typed_setting ( struct settings *settings,
165
 				 unsigned int tag, struct setting_type *type,
168
 				 unsigned int tag, struct setting_type *type,

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

6
 #include <gpxe/ata.h>
6
 #include <gpxe/ata.h>
7
 #include <gpxe/netdevice.h>
7
 #include <gpxe/netdevice.h>
8
 #include <gpxe/dhcp.h>
8
 #include <gpxe/dhcp.h>
9
+#include <gpxe/settings.h>
9
 #include <gpxe/abft.h>
10
 #include <gpxe/abft.h>
10
 #include <int13.h>
11
 #include <int13.h>
11
 #include <usr/aoeboot.h>
12
 #include <usr/aoeboot.h>
55
 		container_of ( ata.backend, struct aoe_session, refcnt );
56
 		container_of ( ata.backend, struct aoe_session, refcnt );
56
 	abft_fill_data ( aoe );
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
 	drive.blockdev = &ata.blockdev;
60
 	drive.blockdev = &ata.blockdev;
60
 
61
 
61
 	register_int13_drive ( &drive );
62
 	register_int13_drive ( &drive );

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

21
 #include <errno.h>
21
 #include <errno.h>
22
 #include <gpxe/netdevice.h>
22
 #include <gpxe/netdevice.h>
23
 #include <gpxe/dhcp.h>
23
 #include <gpxe/dhcp.h>
24
+#include <gpxe/settings.h>
24
 #include <gpxe/image.h>
25
 #include <gpxe/image.h>
25
 #include <gpxe/embedded.h>
26
 #include <gpxe/embedded.h>
26
 #include <usr/ifmgmt.h>
27
 #include <usr/ifmgmt.h>
146
 		return rc;
147
 		return rc;
147
 
148
 
148
 	/* Try to download and boot whatever we are given as a filename */
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
 	if ( buf[0] ) {
151
 	if ( buf[0] ) {
152
 		printf ( "Booting from filename \"%s\"\n", buf );
152
 		printf ( "Booting from filename \"%s\"\n", buf );
153
 		return boot_filename ( buf );
153
 		return boot_filename ( buf );
154
 	}
154
 	}
155
 	
155
 	
156
 	/* No filename; try the root path */
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
 	if ( buf[0] ) {
158
 	if ( buf[0] ) {
160
 		printf ( "Booting from root path \"%s\"\n", buf );
159
 		printf ( "Booting from root path \"%s\"\n", buf );
161
 		return boot_root_path ( buf );
160
 		return boot_root_path ( buf );

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

3
 #include <stdio.h>
3
 #include <stdio.h>
4
 #include <gpxe/iscsi.h>
4
 #include <gpxe/iscsi.h>
5
 #include <gpxe/dhcp.h>
5
 #include <gpxe/dhcp.h>
6
+#include <gpxe/settings.h>
6
 #include <gpxe/netdevice.h>
7
 #include <gpxe/netdevice.h>
7
 #include <gpxe/ibft.h>
8
 #include <gpxe/ibft.h>
8
 #include <int13.h>
9
 #include <int13.h>
45
 		goto error_init;
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
 	drive.blockdev = &scsi.blockdev;
50
 	drive.blockdev = &scsi.blockdev;
50
 
51
 
51
 	/* FIXME: ugly, ugly hack */
52
 	/* FIXME: ugly, ugly hack */

Loading…
Cancel
Save