]>
Commit | Line | Data |
---|---|---|
fe8c2806 WD |
1 | <?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> |
2 | <?php | |
3 | // (C) Copyright 2001 | |
4 | // Murray Jensen <Murray.Jensen@cmst.csiro.au> | |
5 | // CSIRO Manufacturing Science and Technology, Preston Lab | |
6 | ||
7 | // contains mysql user id and password - keep secret | |
8 | require("config.php"); | |
9 | ||
10 | if (isset($logout)) { | |
11 | Header("status: 401 Unauthorized"); | |
12 | Header("HTTP/1.0 401 Unauthorized"); | |
13 | Header("WWW-authenticate: basic realm=\"$bddb_label\""); | |
14 | ||
15 | echo "<html><head><title>" . | |
16 | "Access to '$bddb_label' Denied" . | |
17 | "</title></head>\n"; | |
18 | echo "<body bgcolor=#ffffff><br></br><br></br><center><h1>" . | |
19 | "You must be an Authorised User " . | |
20 | "to access the '$bddb_label'" . | |
21 | "</h1>\n</center></body></html>\n"; | |
22 | exit; | |
23 | } | |
24 | ||
25 | // contents of the various enumerated types - if first item is | |
26 | // empty ('') then the enum is allowed to be null (ie "not null" | |
27 | // is not set on the column) | |
28 | ||
29 | // all column names in the database table | |
30 | $columns = array( | |
31 | 'serno','ethaddr','date','batch', | |
32 | 'type','rev','location','comments', | |
33 | 'sdram0','sdram1','sdram2','sdram3', | |
34 | 'flash0','flash1','flash2','flash3', | |
35 | 'zbt0','zbt1','zbt2','zbt3','zbt4','zbt5','zbt6','zbt7', | |
36 | 'zbt8','zbt9','zbta','zbtb','zbtc','zbtd','zbte','zbtf', | |
37 | 'xlxtyp0','xlxtyp1','xlxtyp2','xlxtyp3', | |
38 | 'xlxspd0','xlxspd1','xlxspd2','xlxspd3', | |
39 | 'xlxtmp0','xlxtmp1','xlxtmp2','xlxtmp3', | |
40 | 'xlxgrd0','xlxgrd1','xlxgrd2','xlxgrd3', | |
41 | 'cputyp','cpuspd','cpmspd','busspd', | |
42 | 'hstype','hschin','hschout' | |
43 | ); | |
44 | ||
45 | // board type | |
46 | $type_vals = array('IO','CLP','DSP','INPUT','ALT-INPUT','DISPLAY'); | |
47 | ||
48 | // sdram sizes (nbits array is for write into eeprom config file) | |
49 | $sdram_vals = array('','32M','64M','128M','256M'); | |
50 | $sdram_nbits = array(0,25,26,27,28); | |
51 | ||
52 | // flash sizes (nbits array is for write into eeprom config file) | |
53 | $flash_vals = array('','4M','8M','16M','32M','64M'); | |
54 | $flash_nbits = array(0,22,23,24,25,26); | |
55 | ||
56 | // zbt ram sizes (nbits array is for write into eeprom config file) | |
57 | $zbt_vals = array('','512K','1M','2M','4M'); | |
58 | $zbt_nbits = array(0,19,20,21,22); | |
59 | ||
60 | // Xilinx attributes | |
6dd652fa WD |
61 | $xlxtyp_vals = array('','XCV300E','XCV400E','XCV600E','XC2V2000','XC2V3000','XC2V4000','XC2V6000'); |
62 | $xlxspd_vals = array('','6','7','8','4','5'); | |
fe8c2806 WD |
63 | $xlxtmp_vals = array('','COM','IND'); |
64 | $xlxgrd_vals = array('','NORMAL','ENGSAMP'); | |
65 | ||
66 | // processor attributes | |
67 | $cputyp_vals = array('','MPC8260'); | |
68 | $clk_vals = array('','33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ'); | |
69 | ||
70 | // high-speed serial attributes | |
71 | $hstype_vals = array('','AMCC-S2064A'); | |
72 | $hschin_vals = array('0','1','2','3','4'); | |
73 | $hschout_vals = array('0','1','2','3','4'); | |
74 | ||
75 | // value filters - used when outputting html | |
76 | function rev_filter($num) { | |
77 | if ($num == 0) | |
78 | return "001"; | |
79 | else | |
80 | return sprintf("%03d", $num); | |
81 | } | |
82 | ||
83 | function text_filter($str) { | |
84 | return urldecode($str); | |
85 | } | |
86 | ||
87 | mt_srand(time() | getmypid()); | |
88 | ||
89 | // set up MySQL connection | |
90 | mysql_connect("", $mysql_user, $mysql_pw) || die("cannot connect"); | |
91 | mysql_select_db($mysql_db) || die("cannot select db"); | |
92 | ||
93 | // page header | |
94 | function pg_head($title) | |
95 | { | |
96 | echo "<html>\n<head>\n"; | |
97 | echo "<link rel=stylesheet href=\"bddb.css\" type=\"text/css\" title=\"style sheet\"></link>\n"; | |
98 | echo "<title>$title</title>\n"; | |
99 | echo "</head>\n"; | |
100 | echo "<body>\n"; | |
101 | echo "<center><h1>$title</h1></center>\n"; | |
102 | echo "<hr></hr>\n"; | |
103 | } | |
104 | ||
105 | // page footer | |
106 | function pg_foot() | |
107 | { | |
108 | echo "<hr></hr>\n"; | |
109 | echo "<table width=\"100%\"><tr><td align=left>\n<address>" . | |
110 | "If you have any problems, email " . | |
111 | "<a href=\"mailto:Murray.Jensen@cmst.csiro.au\">" . | |
112 | "Murray Jensen" . | |
113 | "</a></address>\n" . | |
114 | "</td><td align=right>\n" . | |
115 | "<a href=\"index.php?logout=true\">logout</a>\n" . | |
116 | "</td></tr></table>\n"; | |
117 | echo "<p><small><i>Made with " . | |
118 | "<a href=\"http://kyber.dk/phpMyBuilder/\">" . | |
119 | "Kyber phpMyBuilder</a></i></small></p>\n"; | |
120 | echo "</body>\n"; | |
121 | echo "</html>\n"; | |
122 | } | |
123 | ||
124 | // some support functions | |
125 | ||
126 | if (!function_exists('array_search')) { | |
127 | ||
128 | function array_search($needle, $haystack, $strict = false) { | |
129 | ||
130 | if (is_array($haystack) && count($haystack)) { | |
131 | ||
132 | $ntype = gettype($needle); | |
133 | ||
134 | foreach ($haystack as $key => $value) { | |
135 | ||
136 | if ($value == $needle && (!$strict || | |
137 | gettype($value) == $ntype)) | |
138 | return $key; | |
139 | } | |
140 | } | |
141 | ||
142 | return false; | |
143 | } | |
144 | } | |
145 | ||
146 | if (!function_exists('in_array')) { | |
147 | ||
148 | function in_array($needle, $haystack, $strict = false) { | |
149 | ||
150 | if (is_array($haystack) && count($haystack)) { | |
151 | ||
152 | $ntype = gettype($needle); | |
153 | ||
154 | foreach ($haystack as $key => $value) { | |
155 | ||
156 | if ($value == $needle && (!$strict || | |
157 | gettype($value) == $ntype)) | |
158 | return true; | |
159 | } | |
160 | } | |
161 | ||
162 | return false; | |
163 | } | |
164 | } | |
165 | ||
166 | function key_in_array($key, $array) { | |
167 | return in_array($key, array_keys($array), true); | |
168 | } | |
169 | ||
170 | function enum_to_index($name, $vals) { | |
171 | $index = array_search($GLOBALS[$name], $vals); | |
172 | if ($vals[0] != '') | |
173 | $index++; | |
174 | return $index; | |
175 | } | |
176 | ||
177 | // fetch a value from an array - return empty string is not present | |
178 | function get_key_value($key, $array) { | |
179 | if (key_in_array($key, $array)) | |
180 | return $array[$key]; | |
181 | else | |
182 | return ''; | |
183 | } | |
184 | ||
185 | function fprintf() { | |
186 | $n = func_num_args(); | |
187 | if ($n < 2) | |
188 | return FALSE; | |
189 | $a = func_get_args(); | |
190 | $fp = array_shift($a); | |
191 | $x = "\$s = sprintf"; | |
192 | $sep = '('; | |
193 | foreach ($a as $z) { | |
194 | $x .= "$sep'$z'"; | |
195 | $sep = ','; | |
196 | } | |
197 | $x .= ');'; | |
198 | eval($x); | |
199 | $l = strlen($s); | |
200 | $r = fwrite($fp, $s, $l); | |
201 | if ($r != $l) | |
202 | return FALSE; | |
203 | else | |
204 | return TRUE; | |
205 | } | |
206 | ||
207 | // functions to display (print) a database table and its columns | |
208 | ||
209 | function begin_table($ncols) { | |
210 | global $table_ncols; | |
211 | $table_ncols = $ncols; | |
212 | echo "<table align=center width=\"100%\"" | |
213 | . " border=1 cellpadding=4 cols=$table_ncols>\n"; | |
214 | } | |
215 | ||
216 | function begin_field($name, $span = 0) { | |
217 | global $table_ncols; | |
218 | echo "<tr valign=top>\n"; | |
219 | echo "\t<th align=center>$name</th>\n"; | |
220 | if ($span <= 0) | |
221 | $span = $table_ncols - 1; | |
222 | if ($span > 1) | |
223 | echo "\t<td colspan=$span>\n"; | |
224 | else | |
225 | echo "\t<td>\n"; | |
226 | } | |
227 | ||
228 | function cont_field($span = 1) { | |
229 | echo "\t</td>\n"; | |
230 | if ($span > 1) | |
231 | echo "\t<td colspan=$span>\n"; | |
232 | else | |
233 | echo "\t<td>\n"; | |
234 | } | |
235 | ||
236 | function end_field() { | |
237 | echo "\t</td>\n"; | |
238 | echo "</tr>\n"; | |
239 | } | |
240 | ||
241 | function end_table() { | |
242 | echo "</table>\n"; | |
243 | } | |
244 | ||
245 | function print_field($name, $array, $size = 0, $filt='') { | |
246 | ||
247 | begin_field($name); | |
248 | ||
249 | if (key_in_array($name, $array)) | |
250 | $value = $array[$name]; | |
251 | else | |
252 | $value = ''; | |
253 | ||
254 | if ($filt != '') | |
255 | $value = $filt($value); | |
256 | ||
257 | echo "\t\t<input name=$name value=\"$value\""; | |
258 | if ($size > 0) | |
259 | echo " size=$size maxlength=$size"; | |
260 | echo "></input>\n"; | |
261 | ||
262 | end_field(); | |
263 | } | |
264 | ||
265 | function print_field_multiline($name, $array, $cols, $rows, $filt='') { | |
266 | ||
267 | begin_field($name); | |
268 | ||
269 | if (key_in_array($name, $array)) | |
270 | $value = $array[$name]; | |
271 | else | |
272 | $value = ''; | |
273 | ||
274 | if ($filt != '') | |
275 | $value = $filt($value); | |
276 | ||
277 | echo "\t\t<textarea name=$name " . | |
278 | "cols=$cols rows=$rows wrap=off>\n"; | |
279 | echo "$value"; | |
280 | echo "</textarea>\n"; | |
281 | ||
282 | end_field(); | |
283 | } | |
284 | ||
285 | // print a mysql ENUM as an html RADIO INPUT | |
286 | function print_enum($name, $array, $vals, $def = -1) { | |
287 | ||
288 | begin_field($name); | |
289 | ||
290 | if (key_in_array($name, $array)) | |
291 | $chk = array_search($array[$name], $vals, FALSE); | |
292 | else | |
293 | $chk = $def; | |
294 | ||
295 | $nval = count($vals); | |
296 | ||
297 | for ($i = 0; $i < $nval; $i++) { | |
298 | ||
299 | $val = $vals[$i]; | |
300 | if ($val == '') | |
301 | $pval = "none"; | |
302 | else | |
303 | $pval = "$val"; | |
304 | ||
305 | printf("\t\t<input type=radio name=$name" | |
306 | . " value=\"$val\"%s>$pval</input>\n", | |
307 | $i == $chk ? " checked" : ""); | |
308 | } | |
309 | ||
310 | end_field(); | |
311 | } | |
312 | ||
313 | // print a group of mysql ENUMs (e.g. name0,name1,...) as an html SELECT | |
314 | function print_enum_multi($base, $array, $vals, $cnt, $defs, $grp = 0) { | |
315 | ||
316 | global $table_ncols; | |
317 | ||
318 | if ($grp <= 0) | |
319 | $grp = $cnt; | |
320 | $ncell = $cnt / $grp; | |
321 | $span = ($table_ncols - 1) / $ncell; | |
322 | ||
323 | begin_field($base, $span); | |
324 | ||
325 | $nval = count($vals); | |
326 | ||
327 | for ($i = 0; $i < $cnt; $i++) { | |
328 | ||
329 | if ($i > 0 && ($i % $grp) == 0) | |
330 | cont_field($span); | |
331 | ||
332 | $name = sprintf("%s%x", $base, $i); | |
333 | ||
334 | echo "\t\t<select name=$name>\n"; | |
335 | ||
336 | if (key_in_array($name, $array)) | |
337 | $ai = array_search($array[$name], $vals, FALSE); | |
338 | else { | |
339 | if (key_in_array($i, $defs)) | |
340 | $ai = $defs[$i]; | |
341 | else | |
342 | $ai = 0; | |
343 | } | |
344 | ||
345 | for ($j = 0; $j < $nval; $j++) { | |
346 | ||
347 | $val = $vals[$j]; | |
348 | if ($val == '') | |
349 | $pval = " "; | |
350 | else | |
351 | $pval = "$val"; | |
352 | ||
353 | printf("\t\t\t<option " . | |
354 | "value=\"%s\"%s>%s</option>\n", | |
355 | $val, | |
356 | $j == $ai ? " selected" : "", | |
357 | $pval); | |
358 | } | |
359 | ||
360 | echo "\t\t</select>\n"; | |
361 | } | |
362 | ||
363 | end_field(); | |
364 | } | |
365 | ||
366 | // functions to handle the form input | |
367 | ||
368 | // fetch all the parts of an "enum_multi" into a string suitable | |
369 | // for a MySQL query | |
370 | function gather_enum_multi_query($base, $cnt) { | |
371 | ||
372 | $retval = ''; | |
373 | ||
374 | for ($i = 0; $i < $cnt; $i++) { | |
375 | ||
376 | $name = sprintf("%s%x", $base, $i); | |
377 | ||
378 | if (isset($GLOBALS[$name])) { | |
379 | $retval .= sprintf(", %s='%s'", | |
380 | $name, $GLOBALS[$name]); | |
381 | } | |
382 | } | |
383 | ||
384 | return $retval; | |
385 | } | |
386 | ||
387 | // fetch all the parts of an "enum_multi" into a string suitable | |
388 | // for a display e.g. in an html table cell | |
389 | function gather_enum_multi_print($base, $cnt, $array) { | |
390 | ||
391 | $retval = ''; | |
392 | ||
393 | for ($i = 0; $i < $cnt; $i++) { | |
394 | ||
395 | $name = sprintf("%s%x", $base, $i); | |
396 | ||
397 | if ($array[$name] != '') { | |
398 | if ($retval != '') | |
399 | $retval .= ','; | |
400 | $retval .= $array[$name]; | |
401 | } | |
402 | } | |
403 | ||
404 | return $retval; | |
405 | } | |
406 | ||
407 | // fetch all the parts of an "enum_multi" into a string suitable | |
408 | // for writing to the eeprom data file | |
409 | function gather_enum_multi_write($base, $cnt, $vals, $xfrm = array()) { | |
410 | ||
411 | $retval = ''; | |
412 | ||
413 | for ($i = 0; $i < $cnt; $i++) { | |
414 | ||
415 | $name = sprintf("%s%x", $base, $i); | |
416 | ||
417 | if ($GLOBALS[$name] != '') { | |
418 | if ($retval != '') | |
419 | $retval .= ','; | |
420 | $index = enum_to_index($name, $vals); | |
421 | if ($xfrm != array()) | |
422 | $retval .= $xfrm[$index]; | |
423 | else | |
424 | $retval .= $index; | |
425 | } | |
426 | } | |
427 | ||
428 | return $retval; | |
429 | } | |
430 | ||
431 | // count how many parts of an "enum_multi" are actually set | |
432 | function count_enum_multi($base, $cnt) { | |
433 | ||
434 | $retval = 0; | |
435 | ||
436 | for ($i = 0; $i < $cnt; $i++) { | |
437 | ||
438 | $name = sprintf("%s%x", $base, $i); | |
439 | ||
440 | if (isset($GLOBALS[$name])) | |
441 | $retval++; | |
442 | } | |
443 | ||
444 | return $retval; | |
445 | } | |
446 | ||
447 | // ethernet address functions | |
448 | ||
449 | // generate a (possibly not unique) random vendor ethernet address | |
450 | // (setting bit 6 in the ethernet address - motorola wise i.e. bit 0 | |
451 | // is the most significant bit - means it is not an assigned ethernet | |
6dd652fa WD |
452 | // address - it is a "locally administered" address). Also, make sure |
453 | // it is NOT a multicast ethernet address (by setting bit 7 to 0). | |
454 | // e.g. the first byte of all ethernet addresses generated here will | |
455 | // have 2 in the bottom two bits (incidentally, these are the first | |
456 | // two bits transmitted on the wire, since the octets in ethernet | |
457 | // addresses are transmitted LSB first). | |
458 | ||
fe8c2806 WD |
459 | function gen_eth_addr($serno) { |
460 | ||
461 | $ethaddr_high = (mt_rand(0, 65535) & 0xfeff) | 0x0200; | |
462 | $ethaddr_low = mt_rand(0, 4294967295); | |
463 | ||
464 | return sprintf("%02lx:%02lx:%02lx:%02lx:%02lx:%02lx", | |
465 | $ethaddr_high >> 8, $ethaddr_high & 0xff, | |
466 | $ethaddr_low >> 24, ($ethaddr_low >> 16) & 0xff, | |
467 | ($ethaddr_low >> 8) & 0xff, $ethaddr_low & 0xff); | |
468 | } | |
469 | ||
470 | // check that an ethernet address is valid | |
471 | function eth_addr_is_valid($ethaddr) { | |
472 | ||
473 | $ethbytes = split(':', $ethaddr); | |
474 | ||
475 | if (count($ethbytes) != 6) | |
476 | return FALSE; | |
477 | ||
478 | for ($i = 0; $i < 6; $i++) { | |
479 | $ethbyte = $ethbytes[$i]; | |
480 | if (!ereg('^[0-9a-f][0-9a-f]$', $ethbyte)) | |
481 | return FALSE; | |
482 | } | |
483 | ||
484 | return TRUE; | |
485 | } | |
486 | ||
487 | // write a simple eeprom configuration file | |
488 | function write_eeprom_cfg_file() { | |
489 | ||
490 | global $sernos, $nsernos, $bddb_cfgdir, $numerrs, $cfgerrs; | |
491 | global $date, $batch, $type_vals, $rev; | |
492 | global $sdram_vals, $sdram_nbits; | |
493 | global $flash_vals, $flash_nbits; | |
494 | global $zbt_vals, $zbt_nbits; | |
495 | global $xlxtyp_vals, $xlxspd_vals, $xlxtmp_vals, $xlxgrd_vals; | |
496 | global $cputyp, $cputyp_vals, $clk_vals; | |
497 | global $hstype, $hstype_vals, $hschin, $hschout; | |
498 | ||
499 | $numerrs = 0; | |
500 | $cfgerrs = array(); | |
501 | ||
502 | for ($i = 0; $i < $nsernos; $i++) { | |
503 | ||
504 | $serno = sprintf("%010d", $sernos[$i]); | |
505 | ||
506 | $wfp = @fopen($bddb_cfgdir . "/$serno.cfg", "w"); | |
507 | if (!$wfp) { | |
508 | $cfgerrs[$i] = 'file create fail'; | |
509 | $numerrs++; | |
510 | continue; | |
511 | } | |
512 | set_file_buffer($wfp, 0); | |
513 | ||
514 | if (!fprintf($wfp, "serno=%d\n", $sernos[$i])) { | |
515 | $cfgerrs[$i] = 'cfg wr fail (serno)'; | |
516 | fclose($wfp); | |
517 | $numerrs++; | |
518 | continue; | |
519 | } | |
520 | ||
521 | if (!fprintf($wfp, "date=%s\n", $date)) { | |
522 | $cfgerrs[$i] = 'cfg wr fail (date)'; | |
523 | fclose($wfp); | |
524 | $numerrs++; | |
525 | continue; | |
526 | } | |
527 | ||
528 | if ($batch != '') { | |
529 | if (!fprintf($wfp, "batch=%s\n", $batch)) { | |
530 | $cfgerrs[$i] = 'cfg wr fail (batch)'; | |
531 | fclose($wfp); | |
532 | $numerrs++; | |
533 | continue; | |
534 | } | |
535 | } | |
536 | ||
537 | $typei = enum_to_index("type", $type_vals); | |
538 | if (!fprintf($wfp, "type=%d\n", $typei)) { | |
539 | $cfgerrs[$i] = 'cfg wr fail (type)'; | |
540 | fclose($wfp); | |
541 | $numerrs++; | |
542 | continue; | |
543 | } | |
544 | ||
545 | if (!fprintf($wfp, "rev=%d\n", $rev)) { | |
546 | $cfgerrs[$i] = 'cfg wr fail (rev)'; | |
547 | fclose($wfp); | |
548 | $numerrs++; | |
549 | continue; | |
550 | } | |
551 | ||
552 | $s = gather_enum_multi_write("sdram", 4, | |
553 | $sdram_vals, $sdram_nbits); | |
554 | if ($s != '') { | |
555 | $b = fprintf($wfp, "sdram=%s\n", $s); | |
556 | if (!$b) { | |
557 | $cfgerrs[$i] = 'cfg wr fail (sdram)'; | |
558 | fclose($wfp); | |
559 | $numerrs++; | |
560 | continue; | |
561 | } | |
562 | } | |
563 | ||
564 | $s = gather_enum_multi_write("flash", 4, | |
565 | $flash_vals, $flash_nbits); | |
566 | if ($s != '') { | |
567 | $b = fprintf($wfp, "flash=%s\n", $s); | |
568 | if (!$b) { | |
569 | $cfgerrs[$i] = 'cfg wr fail (flash)'; | |
570 | fclose($wfp); | |
571 | $numerrs++; | |
572 | continue; | |
573 | } | |
574 | } | |
575 | ||
576 | $s = gather_enum_multi_write("zbt", 16, | |
577 | $zbt_vals, $zbt_nbits); | |
578 | if ($s != '') { | |
579 | $b = fprintf($wfp, "zbt=%s\n", $s); | |
580 | if (!$b) { | |
581 | $cfgerrs[$i] = 'cfg wr fail (zbt)'; | |
582 | fclose($wfp); | |
583 | $numerrs++; | |
584 | continue; | |
585 | } | |
586 | } | |
587 | ||
588 | $s = gather_enum_multi_write("xlxtyp", 4, $xlxtyp_vals); | |
589 | if ($s != '') { | |
590 | $b = fprintf($wfp, "xlxtyp=%s\n", $s); | |
591 | if (!$b) { | |
592 | $cfgerrs[$i] = 'cfg wr fail (xlxtyp)'; | |
593 | fclose($wfp); | |
594 | $numerrs++; | |
595 | continue; | |
596 | } | |
597 | } | |
598 | ||
599 | $s = gather_enum_multi_write("xlxspd", 4, $xlxspd_vals); | |
600 | if ($s != '') { | |
601 | $b = fprintf($wfp, "xlxspd=%s\n", $s); | |
602 | if (!$b) { | |
603 | $cfgerrs[$i] = 'cfg wr fail (xlxspd)'; | |
604 | fclose($wfp); | |
605 | $numerrs++; | |
606 | continue; | |
607 | } | |
608 | } | |
609 | ||
610 | $s = gather_enum_multi_write("xlxtmp", 4, $xlxtmp_vals); | |
611 | if ($s != '') { | |
612 | $b = fprintf($wfp, "xlxtmp=%s\n", $s); | |
613 | if (!$b) { | |
614 | $cfgerrs[$i] = 'cfg wr fail (xlxtmp)'; | |
615 | fclose($wfp); | |
616 | $numerrs++; | |
617 | continue; | |
618 | } | |
619 | } | |
620 | ||
621 | $s = gather_enum_multi_write("xlxgrd", 4, $xlxgrd_vals); | |
622 | if ($s != '') { | |
623 | $b = fprintf($wfp, "xlxgrd=%s\n", $s); | |
624 | if (!$b) { | |
625 | $cfgerrs[$i] = 'cfg wr fail (xlxgrd)'; | |
626 | fclose($wfp); | |
627 | $numerrs++; | |
628 | continue; | |
629 | } | |
630 | } | |
631 | ||
632 | if ($cputyp != '') { | |
633 | $cputypi = enum_to_index("cputyp",$cputyp_vals); | |
634 | $cpuspdi = enum_to_index("cpuspd", $clk_vals); | |
635 | $busspdi = enum_to_index("busspd", $clk_vals); | |
636 | $cpmspdi = enum_to_index("cpmspd", $clk_vals); | |
637 | $b = fprintf($wfp, "cputyp=%d\ncpuspd=%d\n" . | |
638 | "busspd=%d\ncpmspd=%d\n", | |
639 | $cputypi, $cpuspdi, $busspdi, $cpmspdi); | |
640 | if (!$b) { | |
641 | $cfgerrs[$i] = 'cfg wr fail (cputyp)'; | |
642 | fclose($wfp); | |
643 | $numerrs++; | |
644 | continue; | |
645 | } | |
646 | } | |
647 | ||
648 | if ($hstype != '') { | |
649 | $hstypei = enum_to_index("hstype",$hstype_vals); | |
650 | $b = fprintf($wfp, "hstype=%d\n" . | |
651 | "hschin=%s\nhschout=%s\n", | |
652 | $hstypei, $hschin, $hschout); | |
653 | if (!$b) { | |
654 | $cfgerrs[$i] = 'cfg wr fail (hstype)'; | |
655 | fclose($wfp); | |
656 | $numerrs++; | |
657 | continue; | |
658 | } | |
659 | } | |
660 | ||
661 | if (!fclose($wfp)) { | |
662 | $cfgerrs[$i] = 'file cls fail'; | |
663 | $numerrs++; | |
664 | } | |
665 | } | |
666 | ||
667 | return $numerrs; | |
668 | } | |
669 | ?> |