wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 1 | <?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> |
| 2 | <?php |
| 3 | // (C) Copyright 2001 |
Wolfgang Denk | b3b0fd5 | 2005-08-12 23:20:59 +0200 | [diff] [blame] | 4 | // Murray Jensen <Murray.Jensen@csiro.au> |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 5 | // CSIRO Manufacturing Science and Technology, Preston Lab |
| 6 | |
| 7 | // doedit page (hymod_bddb / boards) |
| 8 | |
| 9 | require("defs.php"); |
| 10 | |
| 11 | pg_head("$bddb_label - Board Registration Results"); |
| 12 | |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 13 | if (isset($_REQUEST['serno'])) { |
| 14 | $serno=$_REQUEST['serno']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 15 | die("serial number must not be set ($serno) when Creating!"); |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 16 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 17 | |
| 18 | $query="update boards set"; |
| 19 | |
| 20 | list($y, $m, $d) = split("-", $date); |
| 21 | if (!checkdate($m, $d, $y) || $y < 1999) |
| 22 | die("date is invalid (input '$date', yyyy-mm-dd '$y-$m-$d')"); |
| 23 | $query.=" date='$date'"; |
| 24 | |
| 25 | if ($batch != '') { |
| 26 | if (strlen($batch) > 32) |
| 27 | die("batch field too long (>32)"); |
| 28 | $query.=", batch='$batch'"; |
| 29 | } |
| 30 | |
| 31 | if (!in_array($type, $type_vals)) |
| 32 | die("Invalid type ($type) specified"); |
| 33 | $query.=", type='$type'"; |
| 34 | |
| 35 | if (($rev = intval($rev)) <= 0 || $rev > 255) |
| 36 | die("Revision number is invalid ($rev)"); |
| 37 | $query.=sprintf(", rev=%d", $rev); |
| 38 | |
| 39 | $query.=gather_enum_multi_query("sdram", 4); |
| 40 | |
| 41 | $query.=gather_enum_multi_query("flash", 4); |
| 42 | |
| 43 | $query.=gather_enum_multi_query("zbt", 16); |
| 44 | |
| 45 | $query.=gather_enum_multi_query("xlxtyp", 4); |
| 46 | $nxlx = count_enum_multi("xlxtyp", 4); |
| 47 | |
| 48 | $query.=gather_enum_multi_query("xlxspd", 4); |
| 49 | if (count_enum_multi("xlxspd", 4) != $nxlx) |
| 50 | die("number of xilinx speeds not same as number of types"); |
| 51 | |
| 52 | $query.=gather_enum_multi_query("xlxtmp", 4); |
| 53 | if (count_enum_multi("xlxtmp", 4) != $nxlx) |
| 54 | die("number of xilinx temps. not same as number of types"); |
| 55 | |
| 56 | $query.=gather_enum_multi_query("xlxgrd", 4); |
| 57 | if (count_enum_multi("xlxgrd", 4) != $nxlx) |
| 58 | die("number of xilinx grades not same as number of types"); |
| 59 | |
| 60 | if ($cputyp == '') { |
| 61 | if ($cpuspd != '') |
| 62 | die("can't specify cpu speed if there is no cpu"); |
| 63 | if ($cpmspd != '') |
| 64 | die("can't specify cpm speed if there is no cpu"); |
| 65 | if ($busspd != '') |
| 66 | die("can't specify bus speed if there is no cpu"); |
| 67 | } |
| 68 | else { |
| 69 | $query.=", cputyp='$cputyp'"; |
| 70 | if ($cpuspd == '') |
| 71 | die("must specify cpu speed if cpu type is defined"); |
| 72 | $query.=", cpuspd='$cpuspd'"; |
| 73 | if ($cpmspd == '') |
| 74 | die("must specify cpm speed if cpu type is defined"); |
| 75 | $query.=", cpmspd='$cpmspd'"; |
| 76 | if ($busspd == '') |
| 77 | die("must specify bus speed if cpu type is defined"); |
| 78 | $query.=", busspd='$busspd'"; |
| 79 | } |
| 80 | |
| 81 | if (($hschin = intval($hschin)) < 0 || $hschin > 4) |
| 82 | die("Invalid number of hs input chans ($hschin)"); |
| 83 | if (($hschout = intval($hschout)) < 0 || $hschout > 4) |
| 84 | die("Invalid number of hs output chans ($hschout)"); |
| 85 | if ($hstype == '') { |
| 86 | if ($hschin != 0) |
| 87 | die("number of high-speed input channels must be zero" |
| 88 | . " if high-speed chip is not present"); |
| 89 | if ($hschout != 0) |
| 90 | die("number of high-speed output channels must be zero" |
| 91 | . " if high-speed chip is not present"); |
| 92 | } |
| 93 | else |
| 94 | $query.=", hstype='$hstype'"; |
| 95 | $query.=", hschin='$hschin'"; |
| 96 | $query.=", hschout='$hschout'"; |
| 97 | |
| 98 | // echo "final query = '$query'<br>\n"; |
| 99 | |
| 100 | $quant = intval($quant); |
| 101 | if ($quant <= 0) $quant = 1; |
| 102 | |
| 103 | $sernos = array(); |
| 104 | if ($geneths) |
| 105 | $ethaddrs = array(); |
| 106 | |
| 107 | $sqlerr = ''; |
| 108 | |
| 109 | while ($quant-- > 0) { |
| 110 | |
| 111 | mysql_query("insert into boards (serno) values (null)"); |
| 112 | if (mysql_errno()) { |
| 113 | $sqlerr = mysql_error(); |
| 114 | break; |
| 115 | } |
| 116 | |
| 117 | $serno = mysql_insert_id(); |
| 118 | if (!$serno) { |
| 119 | $sqlerr = "couldn't allocate new serial number"; |
| 120 | break; |
| 121 | } |
| 122 | |
| 123 | mysql_query($query . " where serno=$serno"); |
| 124 | if (mysql_errno()) { |
| 125 | $sqlerr = mysql_error(); |
| 126 | break; |
| 127 | } |
| 128 | |
| 129 | array_push($sernos, $serno); |
| 130 | |
| 131 | if ($geneths) { |
| 132 | |
| 133 | $ethaddr = gen_eth_addr($serno); |
| 134 | |
| 135 | mysql_query("update boards set ethaddr='$ethaddr'" . |
| 136 | " where serno=$serno"); |
| 137 | if (mysql_errno()) { |
| 138 | $sqlerr = mysql_error(); |
| 139 | |
| 140 | array_push($ethaddrs, |
| 141 | "<font color=#ff0000><b>" . |
| 142 | "db save fail" . |
| 143 | "</b></font>"); |
| 144 | break; |
| 145 | } |
| 146 | |
| 147 | array_push($ethaddrs, $ethaddr); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | $nsernos = count($sernos); |
| 152 | |
| 153 | if ($nsernos > 0) { |
| 154 | |
| 155 | write_eeprom_cfg_file(); |
| 156 | |
| 157 | echo "<font size=+2>\n"; |
| 158 | echo "\t<p>\n"; |
| 159 | echo "\t\tThe following board serial numbers were" |
| 160 | . " successfully allocated"; |
| 161 | if ($numerrs > 0) |
| 162 | echo " (but with $numerrs cfg file error" . |
| 163 | ($numerrs > 1 ? "s" : "") . ")"; |
| 164 | echo ":\n"; |
| 165 | echo "\t</p>\n"; |
| 166 | |
| 167 | echo "</font>\n"; |
| 168 | |
| 169 | echo "<table align=center width=\"100%\">\n"; |
| 170 | echo "<tr>\n"; |
| 171 | echo "\t<th>Serial Number</th>\n"; |
| 172 | if ($numerrs > 0) |
| 173 | echo "\t<th>Cfg File Errs</th>\n"; |
| 174 | if ($geneths) |
| 175 | echo "\t<th>Ethernet Address</th>\n"; |
| 176 | echo "</tr>\n"; |
| 177 | |
| 178 | for ($i = 0; $i < $nsernos; $i++) { |
| 179 | |
| 180 | $serno = sprintf("%010d", $sernos[$i]); |
| 181 | |
| 182 | echo "<tr>\n"; |
| 183 | |
| 184 | echo "\t<td align=center><font size=+2>" . |
| 185 | "<b>$serno</b></font></td>\n"; |
| 186 | |
| 187 | if ($numerrs > 0) { |
| 188 | if (($errstr = $cfgerrs[$i]) == '') |
| 189 | $errstr = ' '; |
| 190 | echo "\t<td align=center>" . |
| 191 | "<font size=+2 color=#ff0000><b>" . |
| 192 | $errstr . |
| 193 | "</b></font></td>\n"; |
| 194 | } |
| 195 | |
| 196 | if ($geneths) { |
| 197 | echo "\t<td align=center>" . |
| 198 | "<font size=+2 color=#00ff00><b>" . |
| 199 | $ethaddrs[$i] . |
| 200 | "</b></font></td>\n"; |
| 201 | } |
| 202 | |
| 203 | echo "</tr>\n"; |
| 204 | } |
| 205 | |
| 206 | echo "</table>\n"; |
| 207 | } |
| 208 | |
| 209 | if ($sqlerr != '') { |
| 210 | echo "\t<font size=+4>\n"; |
| 211 | echo "\t\t<p>\n"; |
| 212 | echo "\t\t\tThe following SQL error was encountered:\n"; |
| 213 | echo "\t\t</p>\n"; |
| 214 | echo "\t\t<center>\n"; |
| 215 | printf("\t\t\t<b>%s</b>\n", $sqlerr); |
| 216 | echo "\t\t</center>\n"; |
| 217 | echo "\t</font>\n"; |
| 218 | } |
| 219 | |
| 220 | ?> |
| 221 | <p> |
| 222 | <table align=center width="100%"> |
| 223 | <tr> |
| 224 | <td align=center><a href="browse.php">Go to Browse</a></td> |
| 225 | <td align=center><a href="index.php">Back to Start</a></td> |
| 226 | </tr> |
| 227 | </table> |
| 228 | <?php |
| 229 | pg_foot(); |
| 230 | ?> |