Blame view

tools/bddb/defs.php 16.6 KB
fe8c2806c   wdenk   Initial revision
1
2
3
  <?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?>
  <?php
  	// (C) Copyright 2001
b3b0fd552   Wolfgang Denk   Fix Murray Jensen...
4
  	// Murray Jensen <Murray.Jensen@csiro.au>
fe8c2806c   wdenk   Initial revision
5
6
7
8
  	// CSIRO Manufacturing Science and Technology, Preston Lab
  
  	// contains mysql user id and password - keep secret
  	require("config.php");
d992daf99   Wolfgang Denk   Update Hymod Boar...
9
  	if (isset($_REQUEST['logout'])) {
fe8c2806c   wdenk   Initial revision
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
  		Header("status: 401 Unauthorized");
  		Header("HTTP/1.0 401 Unauthorized");
  		Header("WWW-authenticate: basic realm=\"$bddb_label\"");
  
  		echo "<html><head><title>" .
  			"Access to '$bddb_label' Denied" .
  			"</title></head>
  ";
  		echo "<body bgcolor=#ffffff><br></br><br></br><center><h1>" .
  			"You must be an Authorised User " .
  			"to access the '$bddb_label'" .
  			"</h1>
  </center></body></html>
  ";
  		exit;
  	}
  
  	// contents of the various enumerated types - if first item is
  	// empty ('') then the enum is allowed to be null (ie "not null"
  	// is not set on the column)
  
  	// all column names in the database table
  	$columns = array(
  		'serno','ethaddr','date','batch',
  		'type','rev','location','comments',
  		'sdram0','sdram1','sdram2','sdram3',
  		'flash0','flash1','flash2','flash3',
  		'zbt0','zbt1','zbt2','zbt3','zbt4','zbt5','zbt6','zbt7',
  		'zbt8','zbt9','zbta','zbtb','zbtc','zbtd','zbte','zbtf',
  		'xlxtyp0','xlxtyp1','xlxtyp2','xlxtyp3',
  		'xlxspd0','xlxspd1','xlxspd2','xlxspd3',
  		'xlxtmp0','xlxtmp1','xlxtmp2','xlxtmp3',
  		'xlxgrd0','xlxgrd1','xlxgrd2','xlxgrd3',
  		'cputyp','cpuspd','cpmspd','busspd',
  		'hstype','hschin','hschout'
  	);
  
  	// board type
  	$type_vals = array('IO','CLP','DSP','INPUT','ALT-INPUT','DISPLAY');
d992daf99   Wolfgang Denk   Update Hymod Boar...
49
50
  	// Xilinx fpga types
  	$xlxtyp_vals = array('','XCV300E','XCV400E','XCV600E','XC2V2000','XC2V3000','XC2V4000','XC2V6000','XC2VP2','XC2VP4','XC2VP7','XC2VP20','XC2VP30','XC2VP50','XC4VFX20','XC4VFX40','XC4VFX60','XC4VFX100','XC4VFX140');
fe8c2806c   wdenk   Initial revision
51

d992daf99   Wolfgang Denk   Update Hymod Boar...
52
53
  	// Xilinx fpga speeds
  	$xlxspd_vals = array('','6','7','8','4','5','9','10','11','12');
fe8c2806c   wdenk   Initial revision
54

d992daf99   Wolfgang Denk   Update Hymod Boar...
55
  	// Xilinx fpga temperatures (commercial or industrial)
fe8c2806c   wdenk   Initial revision
56
  	$xlxtmp_vals = array('','COM','IND');
d992daf99   Wolfgang Denk   Update Hymod Boar...
57
58
  
  	// Xilinx fpga grades (normal or engineering sample)
fe8c2806c   wdenk   Initial revision
59
  	$xlxgrd_vals = array('','NORMAL','ENGSAMP');
d992daf99   Wolfgang Denk   Update Hymod Boar...
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
  	// CPU types
  	$cputyp_vals = array('','MPC8260(HIP3)','MPC8260A(HIP4)','MPC8280(HIP7)','MPC8560');
  
  	// CPU/BUS/CPM clock speeds 
  	$clk_vals = array('','33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ','233MHZ','266MHZ','300MHZ','333MHZ','366MHZ','400MHZ','433MHZ','466MHZ','500MHZ','533MHZ','566MHZ','600MHZ','633MHZ','666MHZ','700MHZ','733MHZ','766MHZ','800MHZ','833MHZ','866MHZ','900MHZ','933MHZ','966MHZ','1000MHZ','1033MHZ','1066MHZ','1100MHZ','1133MHZ','1166MHZ','1200MHZ','1233MHZ','1266MHZ','1300MHZ','1333MHZ');
  
  	// sdram sizes (nbits array is for eeprom config file)
  	$sdram_vals = array('','32M','64M','128M','256M','512M','1G','2G','4G');
  	$sdram_nbits = array(0,25,26,27,28,29,30,31,32);
  
  	// flash sizes (nbits array is for eeprom config file)
  	$flash_vals = array('','4M','8M','16M','32M','64M','128M','256M','512M','1G');
  	$flash_nbits = array(0,22,23,24,25,26,27,28,29,30);
  
  	// zbt ram sizes (nbits array is for write into eeprom config file)
  	$zbt_vals = array('','512K','1M','2M','4M','8M','16M');
  	$zbt_nbits = array(0,19,20,21,22,23,24);
fe8c2806c   wdenk   Initial revision
77
78
  
  	// high-speed serial attributes
d992daf99   Wolfgang Denk   Update Hymod Boar...
79
80
81
  	$hstype_vals = array('','AMCC-S2064A','Xilinx-Rockets');
  	$hschin_vals = array('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16');
  	$hschout_vals = array('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16');
fe8c2806c   wdenk   Initial revision
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
  
  	// value filters - used when outputting html
  	function rev_filter($num) {
  		if ($num == 0)
  			return "001";
  		else
  			return sprintf("%03d", $num);
  	}
  
  	function text_filter($str) {
  		return urldecode($str);
  	}
  
  	mt_srand(time() | getmypid());
  
  	// set up MySQL connection
  	mysql_connect("", $mysql_user, $mysql_pw) || die("cannot connect");
  	mysql_select_db($mysql_db) || die("cannot select db");
  
  	// page header
  	function pg_head($title)
  	{
  		echo "<html>
  <head>
  ";
  		echo "<link rel=stylesheet href=\"bddb.css\" type=\"text/css\" title=\"style sheet\"></link>
  ";
  		echo "<title>$title</title>
  ";
  		echo "</head>
  ";
  		echo "<body>
  ";
  		echo "<center><h1>$title</h1></center>
  ";
  		echo "<hr></hr>
  ";
  	}
  
  	// page footer
  	function pg_foot()
  	{
  		echo "<hr></hr>
  ";
  		echo "<table width=\"100%\"><tr><td align=left>
  <address>" .
  			"If you have any problems, email " .
b3b0fd552   Wolfgang Denk   Fix Murray Jensen...
129
  			"<a href=\"mailto:Murray.Jensen@csiro.au\">" .
fe8c2806c   wdenk   Initial revision
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
  			"Murray Jensen" .
  			"</a></address>
  " .
  			"</td><td align=right>
  " .
  			"<a href=\"index.php?logout=true\">logout</a>
  " .
  			"</td></tr></table>
  ";
  		echo "<p><small><i>Made with " .
  		    "<a href=\"http://kyber.dk/phpMyBuilder/\">" .
  		    "Kyber phpMyBuilder</a></i></small></p>
  ";
  		echo "</body>
  ";
  		echo "</html>
  ";
  	}
  
  	// some support functions
  
  	if (!function_exists('array_search')) {
  
  		function array_search($needle, $haystack, $strict = false) {
  
  			if (is_array($haystack) && count($haystack)) {
  
  				$ntype = gettype($needle);
  
  				foreach ($haystack as $key => $value) {
  
  					if ($value == $needle && (!$strict ||
  					    gettype($value) == $ntype))
  						return $key;
  				}
  			}
  
  			return false;
  		}
  	}
  
  	if (!function_exists('in_array')) {
  
  		function in_array($needle, $haystack, $strict = false) {
  
  			if (is_array($haystack) && count($haystack)) {
  
  				$ntype = gettype($needle);
  
  				foreach ($haystack as $key => $value) {
  
  					if ($value == $needle && (!$strict ||
  					    gettype($value) == $ntype))
  						return true;
  				}
  			}
  
  			return false;
  		}
  	}
  
  	function key_in_array($key, $array) {
  		return in_array($key, array_keys($array), true);
  	}
  
  	function enum_to_index($name, $vals) {
  		$index = array_search($GLOBALS[$name], $vals);
  		if ($vals[0] != '')
  		        $index++;
  		return $index;
  	}
  
  	// fetch a value from an array - return empty string is not present
  	function get_key_value($key, $array) {
  		if (key_in_array($key, $array))
  			return $array[$key];
  		else
  			return '';
  	}
  
  	function fprintf() {
  		$n = func_num_args();
  		if ($n < 2)
  			return FALSE;
  		$a = func_get_args();
  		$fp = array_shift($a);
  		$x = "\$s = sprintf";
  		$sep = '(';
  		foreach ($a as $z) {
  			$x .= "$sep'$z'";
  			$sep = ',';
  		}
  		$x .= ');';
  		eval($x);
  		$l = strlen($s);
  		$r = fwrite($fp, $s, $l);
  		if ($r != $l)
  			return FALSE;
  		else
  			return TRUE;
  	}
  
  	// functions to display (print) a database table and its columns
  
  	function begin_table($ncols) {
  		global $table_ncols;
  		$table_ncols = $ncols;
  		echo "<table align=center width=\"100%\""
  			. " border=1 cellpadding=4 cols=$table_ncols>
  ";
  	}
  
  	function begin_field($name, $span = 0) {
  		global $table_ncols;
  		echo "<tr valign=top>
  ";
  		echo "\t<th align=center>$name</th>
  ";
  		if ($span <= 0)
  			$span = $table_ncols - 1;
  		if ($span > 1)
  			echo "\t<td colspan=$span>
  ";
  		else
  			echo "\t<td>
  ";
  	}
  
  	function cont_field($span = 1) {
  		echo "\t</td>
  ";
  		if ($span > 1)
  			echo "\t<td colspan=$span>
  ";
  		else
  			echo "\t<td>
  ";
  	}
  
  	function end_field() {
  		echo "\t</td>
  ";
  		echo "</tr>
  ";
  	}
  
  	function end_table() {
  		echo "</table>
  ";
  	}
  
  	function print_field($name, $array, $size = 0, $filt='') {
  
  		begin_field($name);
  
  		if (key_in_array($name, $array))
  			$value = $array[$name];
  		else
  			$value = '';
  
  		if ($filt != '')
  			$value = $filt($value);
  
  		echo "\t\t<input name=$name value=\"$value\"";
  		if ($size > 0)
  			echo " size=$size maxlength=$size";
  		echo "></input>
  ";
  
  		end_field();
  	}
  
  	function print_field_multiline($name, $array, $cols, $rows, $filt='') {
  
  		begin_field($name);
  
  		if (key_in_array($name, $array))
  			$value = $array[$name];
  		else
  			$value = '';
  
  		if ($filt != '')
  			$value = $filt($value);
  
  		echo "\t\t<textarea name=$name " .
  			"cols=$cols rows=$rows wrap=off>
  ";
  		echo "$value";
  		echo "</textarea>
  ";
  
  		end_field();
  	}
  
  	// print a mysql ENUM as an html RADIO INPUT
  	function print_enum($name, $array, $vals, $def = -1) {
  
  		begin_field($name);
  
  		if (key_in_array($name, $array))
  			$chk = array_search($array[$name], $vals, FALSE);
  		else
  			$chk = $def;
  
  		$nval = count($vals);
  
  		for ($i = 0; $i < $nval; $i++) {
  
  			$val = $vals[$i];
  			if ($val == '')
  				$pval = "none";
  			else
  				$pval = "$val";
  
  			printf("\t\t<input type=radio name=$name"
  				. " value=\"$val\"%s>$pval</input>
  ",
  				$i == $chk ? " checked" : "");
  		}
  
  		end_field();
  	}
d992daf99   Wolfgang Denk   Update Hymod Boar...
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
  	// print a mysql ENUM as an html SELECT INPUT
  	function print_enum_select($name, $array, $vals, $def = -1) {
  
  		begin_field($name);
  
  		echo "\t\t<select name=$name>
  ";
  
  		if (key_in_array($name, $array))
  			$chk = array_search($array[$name], $vals, FALSE);
  		else
  			$chk = $def;
  
  		$nval = count($vals);
  
  		for ($i = 0; $i < $nval; $i++) {
  
  			$val = $vals[$i];
  			if ($val == '')
  				$pval = "none";
  			else
  				$pval = "$val";
  
  			printf("\t\t\t<option " .
  				"value=\"%s\"%s>%s</option>
  ",
  				$val, $i == $chk ? " selected" : "", $pval);
  		}
  
  		echo "\t\t</select>
  ";
  
  		end_field();
  	}
fe8c2806c   wdenk   Initial revision
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
  	// print a group of mysql ENUMs (e.g. name0,name1,...) as an html SELECT
  	function print_enum_multi($base, $array, $vals, $cnt, $defs, $grp = 0) {
  
  		global $table_ncols;
  
  		if ($grp <= 0)
  			$grp = $cnt;
  		$ncell = $cnt / $grp;
  		$span = ($table_ncols - 1) / $ncell;
  
  		begin_field($base, $span);
  
  		$nval = count($vals);
  
  		for ($i = 0; $i < $cnt; $i++) {
  
  			if ($i > 0 && ($i % $grp) == 0)
  				cont_field($span);
  
  			$name = sprintf("%s%x", $base, $i);
  
  			echo "\t\t<select name=$name>
  ";
  
  			if (key_in_array($name, $array))
  				$ai = array_search($array[$name], $vals, FALSE);
  			else {
  				if (key_in_array($i, $defs))
  					$ai = $defs[$i];
  				else
  					$ai = 0;
  			}
  
  			for ($j = 0; $j < $nval; $j++) {
  
  				$val = $vals[$j];
  				if ($val == '')
  					$pval = "&nbsp;";
  				else
  					$pval = "$val";
  
  				printf("\t\t\t<option " .
  					"value=\"%s\"%s>%s</option>
  ",
  					$val,
  					$j == $ai ? " selected" : "",
  					$pval);
  			}
  
  			echo "\t\t</select>
  ";
  		}
  
  		end_field();
  	}
  
  	// functions to handle the form input
  
  	// fetch all the parts of an "enum_multi" into a string suitable
  	// for a MySQL query
  	function gather_enum_multi_query($base, $cnt) {
  
  		$retval = '';
  
  		for ($i = 0; $i < $cnt; $i++) {
  
  			$name = sprintf("%s%x", $base, $i);
d992daf99   Wolfgang Denk   Update Hymod Boar...
453
  			if (isset($_REQUEST[$name])) {
fe8c2806c   wdenk   Initial revision
454
  				$retval .= sprintf(", %s='%s'",
d992daf99   Wolfgang Denk   Update Hymod Boar...
455
  					$name, $_REQUEST[$name]);
fe8c2806c   wdenk   Initial revision
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
  			}
  		}
  
  		return $retval;
  	}
  
  	// fetch all the parts of an "enum_multi" into a string suitable
  	// for a display e.g. in an html table cell
  	function gather_enum_multi_print($base, $cnt, $array) {
  
  		$retval = '';
  
  		for ($i = 0; $i < $cnt; $i++) {
  
  			$name = sprintf("%s%x", $base, $i);
  
  			if ($array[$name] != '') {
  				if ($retval != '')
  					$retval .= ',';
  				$retval .= $array[$name];
  			}
  		}
  
  		return $retval;
  	}
  
  	// fetch all the parts of an "enum_multi" into a string suitable
  	// for writing to the eeprom data file
  	function gather_enum_multi_write($base, $cnt, $vals, $xfrm = array()) {
  
  		$retval = '';
  
  		for ($i = 0; $i < $cnt; $i++) {
  
  			$name = sprintf("%s%x", $base, $i);
  
  			if ($GLOBALS[$name] != '') {
  				if ($retval != '')
  					$retval .= ',';
  				$index = enum_to_index($name, $vals);
  				if ($xfrm != array())
  					$retval .= $xfrm[$index];
  				else
  					$retval .= $index;
  			}
  		}
  
  		return $retval;
  	}
  
  	// count how many parts of an "enum_multi" are actually set
  	function count_enum_multi($base, $cnt) {
  
  		$retval = 0;
  
  		for ($i = 0; $i < $cnt; $i++) {
  
  			$name = sprintf("%s%x", $base, $i);
d992daf99   Wolfgang Denk   Update Hymod Boar...
514
  			if (isset($_REQUEST[$name]))
fe8c2806c   wdenk   Initial revision
515
516
517
518
519
520
521
522
523
524
525
  				$retval++;
  		}
  
  		return $retval;
  	}
  
  	// ethernet address functions
  
  	// generate a (possibly not unique) random vendor ethernet address
  	// (setting bit 6 in the ethernet address - motorola wise i.e. bit 0
  	// is the most significant bit - means it is not an assigned ethernet
6dd652fa4   wdenk   Patches by Murray...
526
527
528
529
530
531
  	// address - it is a "locally administered" address). Also, make sure
  	// it is NOT a multicast ethernet address (by setting bit 7 to 0).
  	// e.g. the first byte of all ethernet addresses generated here will
  	// have 2 in the bottom two bits (incidentally, these are the first
  	// two bits transmitted on the wire, since the octets in ethernet
  	// addresses are transmitted LSB first).
fe8c2806c   wdenk   Initial revision
532
  	function gen_eth_addr($serno) {
d992daf99   Wolfgang Denk   Update Hymod Boar...
533
534
535
  		$ethaddr_hgh = (mt_rand(0, 65535) & 0xfeff) | 0x0200;
  		$ethaddr_mid = mt_rand(0, 65535);
  		$ethaddr_low = mt_rand(0, 65535);
fe8c2806c   wdenk   Initial revision
536
537
  
  		return sprintf("%02lx:%02lx:%02lx:%02lx:%02lx:%02lx",
d992daf99   Wolfgang Denk   Update Hymod Boar...
538
539
540
  			$ethaddr_hgh >> 8, $ethaddr_hgh & 0xff,
  			$ethaddr_mid >> 8, $ethaddr_mid & 0xff,
  			$ethaddr_low >> 8, $ethaddr_low & 0xff);
fe8c2806c   wdenk   Initial revision
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
  	}
  
  	// check that an ethernet address is valid
  	function eth_addr_is_valid($ethaddr) {
  
  		$ethbytes = split(':', $ethaddr);
  
  		if (count($ethbytes) != 6)
  			return FALSE;
  
  		for ($i = 0; $i < 6; $i++) {
  			$ethbyte = $ethbytes[$i];
  			if (!ereg('^[0-9a-f][0-9a-f]$', $ethbyte))
  				return FALSE;
  		}
  
  		return TRUE;
  	}
  
  	// write a simple eeprom configuration file
  	function write_eeprom_cfg_file() {
  
  		global $sernos, $nsernos, $bddb_cfgdir, $numerrs, $cfgerrs;
  		global $date, $batch, $type_vals, $rev;
  		global $sdram_vals, $sdram_nbits;
  		global $flash_vals, $flash_nbits;
  		global $zbt_vals, $zbt_nbits;
  		global $xlxtyp_vals, $xlxspd_vals, $xlxtmp_vals, $xlxgrd_vals;
  		global $cputyp, $cputyp_vals, $clk_vals;
  		global $hstype, $hstype_vals, $hschin, $hschout;
  
  		$numerrs = 0;
  		$cfgerrs = array();
  
  		for ($i = 0; $i < $nsernos; $i++) {
  
  			$serno = sprintf("%010d", $sernos[$i]);
  
  			$wfp = @fopen($bddb_cfgdir . "/$serno.cfg", "w");
  			if (!$wfp) {
  				$cfgerrs[$i] = 'file create fail';
  				$numerrs++;
  				continue;
  			}
  			set_file_buffer($wfp, 0);
  
  			if (!fprintf($wfp, "serno=%d
  ", $sernos[$i])) {
  				$cfgerrs[$i] = 'cfg wr fail (serno)';
  				fclose($wfp);
  				$numerrs++;
  				continue;
  			}
  
  			if (!fprintf($wfp, "date=%s
  ", $date)) {
  				$cfgerrs[$i] = 'cfg wr fail (date)';
  				fclose($wfp);
  				$numerrs++;
  				continue;
  			}
  
  			if ($batch != '') {
  				if (!fprintf($wfp, "batch=%s
  ", $batch)) {
  					$cfgerrs[$i] = 'cfg wr fail (batch)';
  					fclose($wfp);
  					$numerrs++;
  					continue;
  				}
  			}
  
  			$typei = enum_to_index("type", $type_vals);
  			if (!fprintf($wfp, "type=%d
  ", $typei)) {
  				$cfgerrs[$i] = 'cfg wr fail (type)';
  				fclose($wfp);
  				$numerrs++;
  				continue;
  			}
  
  			if (!fprintf($wfp, "rev=%d
  ", $rev)) {
  				$cfgerrs[$i] = 'cfg wr fail (rev)';
  				fclose($wfp);
  				$numerrs++;
  				continue;
  			}
  
  			$s = gather_enum_multi_write("sdram", 4,
  				$sdram_vals, $sdram_nbits);
  			if ($s != '') {
  				$b = fprintf($wfp, "sdram=%s
  ", $s);
  				if (!$b) {
  					$cfgerrs[$i] = 'cfg wr fail (sdram)';
  					fclose($wfp);
  					$numerrs++;
  					continue;
  				}
  			}
  
  			$s = gather_enum_multi_write("flash", 4,
  				$flash_vals, $flash_nbits);
  			if ($s != '') {
  				$b = fprintf($wfp, "flash=%s
  ", $s);
  				if (!$b) {
  					$cfgerrs[$i] = 'cfg wr fail (flash)';
  					fclose($wfp);
  					$numerrs++;
  					continue;
  				}
  			}
  
  			$s = gather_enum_multi_write("zbt", 16,
  				$zbt_vals, $zbt_nbits);
  			if ($s != '') {
  				$b = fprintf($wfp, "zbt=%s
  ", $s);
  				if (!$b) {
  					$cfgerrs[$i] = 'cfg wr fail (zbt)';
  					fclose($wfp);
  					$numerrs++;
  					continue;
  				}
  			}
  
  			$s = gather_enum_multi_write("xlxtyp", 4, $xlxtyp_vals);
  			if ($s != '') {
  				$b = fprintf($wfp, "xlxtyp=%s
  ", $s);
  				if (!$b) {
  					$cfgerrs[$i] = 'cfg wr fail (xlxtyp)';
  					fclose($wfp);
  					$numerrs++;
  					continue;
  				}
  			}
  
  			$s = gather_enum_multi_write("xlxspd", 4, $xlxspd_vals);
  			if ($s != '') {
  				$b = fprintf($wfp, "xlxspd=%s
  ", $s);
  				if (!$b) {
  					$cfgerrs[$i] = 'cfg wr fail (xlxspd)';
  					fclose($wfp);
  					$numerrs++;
  					continue;
  				}
  			}
  
  			$s = gather_enum_multi_write("xlxtmp", 4, $xlxtmp_vals);
  			if ($s != '') {
  				$b = fprintf($wfp, "xlxtmp=%s
  ", $s);
  				if (!$b) {
  					$cfgerrs[$i] = 'cfg wr fail (xlxtmp)';
  					fclose($wfp);
  					$numerrs++;
  					continue;
  				}
  			}
  
  			$s = gather_enum_multi_write("xlxgrd", 4, $xlxgrd_vals);
  			if ($s != '') {
  				$b = fprintf($wfp, "xlxgrd=%s
  ", $s);
  				if (!$b) {
  					$cfgerrs[$i] = 'cfg wr fail (xlxgrd)';
  					fclose($wfp);
  					$numerrs++;
  					continue;
  				}
  			}
  
  			if ($cputyp != '') {
  				$cputypi = enum_to_index("cputyp",$cputyp_vals);
  				$cpuspdi = enum_to_index("cpuspd", $clk_vals);
  				$busspdi = enum_to_index("busspd", $clk_vals);
  				$cpmspdi = enum_to_index("cpmspd", $clk_vals);
  				$b = fprintf($wfp, "cputyp=%d
  cpuspd=%d
  " .
  					"busspd=%d
  cpmspd=%d
  ",
  					$cputypi, $cpuspdi, $busspdi, $cpmspdi);
  				if (!$b) {
  					$cfgerrs[$i] = 'cfg wr fail (cputyp)';
  					fclose($wfp);
  					$numerrs++;
  					continue;
  				}
  			}
  
  			if ($hstype != '') {
  				$hstypei = enum_to_index("hstype",$hstype_vals);
  				$b = fprintf($wfp, "hstype=%d
  " .
  					"hschin=%s
  hschout=%s
  ",
  					$hstypei, $hschin, $hschout);
  				if (!$b) {
  					$cfgerrs[$i] = 'cfg wr fail (hstype)';
  					fclose($wfp);
  					$numerrs++;
  					continue;
  				}
  			}
  
  			if (!fclose($wfp)) {
  				$cfgerrs[$i] = 'file cls fail';
  				$numerrs++;
  			}
  		}
  
  		return $numerrs;
  	}
  ?>