diff options
Diffstat (limited to 'tools/bddb')
-rw-r--r-- | tools/bddb/README | 116 | ||||
-rw-r--r-- | tools/bddb/brlog.php | 106 | ||||
-rw-r--r-- | tools/bddb/browse.php | 130 | ||||
-rw-r--r-- | tools/bddb/config.php | 16 | ||||
-rw-r--r-- | tools/bddb/create_tables.sql | 90 | ||||
-rw-r--r-- | tools/bddb/defs.php | 663 | ||||
-rw-r--r-- | tools/bddb/dodelete.php | 64 | ||||
-rw-r--r-- | tools/bddb/dodellog.php | 55 | ||||
-rw-r--r-- | tools/bddb/doedit.php | 170 | ||||
-rw-r--r-- | tools/bddb/doedlog.php | 66 | ||||
-rw-r--r-- | tools/bddb/donew.php | 228 | ||||
-rw-r--r-- | tools/bddb/donewlog.php | 76 | ||||
-rw-r--r-- | tools/bddb/edit.php | 131 | ||||
-rw-r--r-- | tools/bddb/edlog.php | 81 | ||||
-rw-r--r-- | tools/bddb/execute.php | 37 | ||||
-rw-r--r-- | tools/bddb/index.php | 38 | ||||
-rw-r--r-- | tools/bddb/new.php | 121 | ||||
-rw-r--r-- | tools/bddb/newlog.php | 48 |
18 files changed, 2236 insertions, 0 deletions
diff --git a/tools/bddb/README b/tools/bddb/README new file mode 100644 index 00000000000..778e41c1da8 --- /dev/null +++ b/tools/bddb/README @@ -0,0 +1,116 @@ +Hymod Board Database + +(C) Copyright 2001 +Murray Jensen <Murray.Jensen@cmst.csiro.au> +CSIRO Manufacturing Science and Technology, Preston Lab + +25-Jun-01 + +This stuff is a set of PHP/MySQL scripts to implement a custom board +database. It will need *extensive* hacking to modify it to keep the +information about your custom boards that you want, however it is a good +starting point. + +How it is used: + + 1. a board has gone through all the hardware testing etc and is + ready to have the flash programmed for the first time - first you + go to a web page and fill in information about the board in a form + to register it in a database + + 2. the web stuff allocates a (unique) serial number and (optionally) + a (locally administered) ethernet address and stores the information + in a database using the serial number as the key (can do whole + batches of boards in one go and/or use a previously registered board + as defaults for the new board(s)) + + 3. it then creates a file in the tftp area of a server somewhere + containing the board information in a simple text format (one + per serial number) + + 4. all hymod boards have an i2c eeprom, and when U-Boot sees that + the eeprom is unitialised, it prompts for a serial number and + ethernet address (if not set), then transfers the file created + in step 3 from the server and initialises the eeprom from its + contents + +What this means is you can't boot the board until you have allocated a serial +number, but you don't have to type it all twice - you do it once on the web +and the board then finds the info it needs to initialise its eeprom. The +other side of the coin is the reading of the eeprom and how it gets passed +to Linux (or another O/S). + +To see how this is all done for the hymod boards look at the code in the +"board/hymod" directory and in the file "include/asm/hymod.h". Hymod boards +can have a mezzanine card which also have an eeprom that needs allocating, +the same process is used for these as well - just a different i2c address. + +Other forms provide the following functions: + + - browsing the board database + - editing board information (one at a time) + - maintaining/browsing a (simple) per board event log + +You will need: MySQL (I use version 3.23.7-alpha), PHP4 (with MySQL +support enabled) and a web server (I use Apache 1.3.x). + +I originally started by using phpMyBuilder (http://kyber.dk/phpMyBuilder) +but it soon got far more complicated than that could handle (but I left +the copyright messages in there anyway). Most of the code resides in the +common defs.php file, which shouldn't need much alteration - all the work +will be in shaping the front-end php files to your liking. + +Here's a quick summary of what needs doing to use it for your boards: + +1. get phpMyAdmin (http://phpwizard.net/projects/phpMyAdmin/) - it's an + invaluable tool for this sort of stuff (this step is optional of course) + +2. edit "bddb.css" to your taste, if you could be bothered - I have no + idea what is in there or what it does - I copied it from somewhere else + ("user.css" from the phpMyEdit (http://phpmyedit.sourcerforge.net) package, + I think) - I figure one day I'll see what sort of things I can change + in there. + +3. create a mysql database - call it whatever you like + +4. edit "create_tables.sql" and modify the "boards" table schema to + reflect the information you want to keep about your boards. It may or + may not be easier to do this and the next step in phpMyAdmin. Check out + the MySQL documentation at http://www.mysql.com/doc/ in particular the + column types at http://www.mysql.com/doc/C/o/Column_types.html - Note + there is only support for a few data types: + + int - presented as an html text input + char/text - presented as an html text input + date - presented as an html text input + enum - presented as an html radio input + + I also have what I call "enum_multi" which is a set of enums with the + same name, but suffixed with a number e.g. fred0, fred1, fred2. These + are presented as a number of html select's with a single label "fred" + this is useful for board characteristics that have multiple items of + the same type e.g. multiple banks of sdram. + +5. use the "create_tables.sql" file to create the "boards" table in the + database e.g. mysql dbname < create_tables.sql + +6. create a user and password for the web server to log into the MySQL + database with; give this user select, insert and update privileges + to the database created in 3 (and delete, if you want the "delete" + functions in the edit forms to work- I have this turned off). phpMyAdmin + helps in this step. + +7. edit "config.php" and set the variables: $mysql_user, $mysql_pw, $mysql_db, + $bddb_cfgdir and $bddb_label - keep the contents of this file secret - it + contains the web servers username and password (the three $mysql_* vars + are set from the previous step) + +8. edit "defs.php" and a. adjust the various enum value arrays and b. edit + the function "pg_foot()" to remove my email address :-) + +9. do major hacking on the following files: browse.php, doedit.php, donew.php, + edit.php and new.php to reflect your database schema - fortunately the + hacking is fairly straight-forward, but it is boring and time-consuming. + +These notes were written rather hastily - if you find any obvious problems +please let me know. diff --git a/tools/bddb/brlog.php b/tools/bddb/brlog.php new file mode 100644 index 00000000000..6e98c9c4813 --- /dev/null +++ b/tools/bddb/brlog.php @@ -0,0 +1,106 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + // list page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Browse Board Log"); + + if (!isset($serno) || $serno == 0) + die("serial number not specified!"); + + function print_cell($str) { + if ($str == '') + $str = ' '; + echo "\t<td>$str</td>\n"; + } +?> +<table align=center border=1 cellpadding=10> +<tr> +<th>serno / edit</th> +<th>ethaddr</th> +<th>date</th> +<th>batch</th> +<th>type</th> +<th>rev</th> +<th>location</th> +</tr> +<?php + $r=mysql_query("select * from boards where serno=$serno"); + + while($row=mysql_fetch_array($r)){ + foreach ($columns as $key) { + if (!key_in_array($key, $row)) + $row[$key] = ''; + } + + echo "<tr>\n"; + print_cell("<a href=\"edit.php?serno=$row[serno]\">$row[serno]</a>"); + print_cell($row['ethaddr']); + print_cell($row['date']); + print_cell($row['batch']); + print_cell($row['type']); + print_cell($row['rev']); + print_cell($row['location']); + echo "</tr>\n"; + } + + mysql_free_result($r); +?> +</table> +<hr></hr> +<p></p> +<?php + $limit=abs(isset($limit)?$limit:20); + $offset=abs(isset($offset)?$offset:0); + $lr=mysql_query("select count(*) as n from log where serno=$serno"); + $lrow=mysql_fetch_array($lr); + if($lrow['n']>$limit){ + $preoffset=max(0,$offset-$limit); + $postoffset=$offset+$limit; + echo "<table width=\"100%\">\n<tr align=center>\n"; + printf("<td><%sa href=\"%s?serno=$serno&offset=%d\"><img border=0 alt=\"<\" src=\"/icons/left.gif\"></a></td>\n", $offset>0?"":"no", $PHP_SELF, $preoffset); + printf("<td><%sa href=\"%s?serno=$serno&offset=%d\"><img border=0 alt=\">\" src=\"/icons/right.gif\"></a></td>\n", $postoffset<$lrow['n']?"":"no", $PHP_SELF, $postoffset); + echo "</tr>\n</table>\n"; + } + mysql_free_result($lr); +?> +<table width="100%" border=1 cellpadding=10> +<tr valign=top> +<th>logno / edit</th> +<th>date</th> +<th width="70%">details</th> +</tr> +<?php + $r=mysql_query("select * from log where serno=$serno order by logno limit $offset,$limit"); + + while($row=mysql_fetch_array($r)){ + echo "<tr>\n"; + print_cell("<a href=\"edlog.php?serno=$row[serno]&logno=$row[logno]\">$row[logno]</a>"); + print_cell($row['date']); + print_cell("<pre>" . urldecode($row['details']) . "</pre>"); + echo "</tr>\n"; + } + + mysql_free_result($r); +?> +</table> +<hr></hr> +<p></p> +<table width="100%"> +<tr> + <td align=center> + <a href="newlog.php?serno=<?php echo "$serno"; ?>">Add to Log</a> + </td> + <td align=center> + <a href="index.php">Back to Start</a> + </td> +</tr> +</table> +<?php + pg_foot(); +?> diff --git a/tools/bddb/browse.php b/tools/bddb/browse.php new file mode 100644 index 00000000000..b7cd5089510 --- /dev/null +++ b/tools/bddb/browse.php @@ -0,0 +1,130 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + // list page (hymod_bddb / boards) + + require("defs.php"); + + if (!isset($verbose)) + $verbose = 0; + + if (!isset($serno)) + $serno = 0; + + pg_head("$bddb_label - Browse database" . ($verbose?" (verbose)":"")); +?> +<p></p> +<?php + if ($serno == 0) { + $limit=abs(isset($limit)?$limit:20); + $offset=abs(isset($offset)?$offset:0); + $lr=mysql_query("select count(*) as n from boards"); + $lrow=mysql_fetch_array($lr); + if($lrow['n']>$limit){ + $preoffset=max(0,$offset-$limit); + $postoffset=$offset+$limit; + echo "<table width=\"100%\">\n<tr align=center>\n"; + printf("<td><%sa href=\"%s?offset=%d\"><img border=0 alt=\"<\" src=\"/icons/left.gif\"></a></td>\n", $offset>0?"":"no", $PHP_SELF, $preoffset); + printf("<td><%sa href=\"%s?offset=%d\"><img border=0 alt=\">\" src=\"/icons/right.gif\"></a></td>\n", $postoffset<$lrow['n']?"":"no", $PHP_SELF, $postoffset); + echo "</tr>\n</table>\n"; + } + mysql_free_result($lr); + } +?> +<table align=center border=1 cellpadding=10> +<tr> +<th></th> +<th>serno / edit</th> +<th>ethaddr</th> +<th>date</th> +<th>batch</th> +<th>type</th> +<th>rev</th> +<th>location</th> +<?php + if ($verbose) { + echo "<th>comments</th>\n"; + echo "<th>sdram</th>\n"; + echo "<th>flash</th>\n"; + echo "<th>zbt</th>\n"; + echo "<th>xlxtyp</th>\n"; + echo "<th>xlxspd</th>\n"; + echo "<th>xlxtmp</th>\n"; + echo "<th>xlxgrd</th>\n"; + echo "<th>cputyp</th>\n"; + echo "<th>cpuspd</th>\n"; + echo "<th>cpmspd</th>\n"; + echo "<th>busspd</th>\n"; + echo "<th>hstype</th>\n"; + echo "<th>hschin</th>\n"; + echo "<th>hschout</th>\n"; + } +?> +</tr> +<?php + if ($serno == 0) + $r=mysql_query("select * from boards order by serno limit $offset,$limit"); + else + $r=mysql_query("select * from boards where serno=$serno"); + + function print_cell($str) { + if ($str == '') + $str = ' '; + echo "\t<td>$str</td>\n"; + } + + while($row=mysql_fetch_array($r)){ + foreach ($columns as $key) { + if (!key_in_array($key, $row)) + $row[$key] = ''; + } + + echo "<tr>\n"; + print_cell("<a href=\"brlog.php?serno=$row[serno]\">Log</a>"); + print_cell("<a href=\"edit.php?serno=$row[serno]\">$row[serno]</a>"); + print_cell($row['ethaddr']); + print_cell($row['date']); + print_cell($row['batch']); + print_cell($row['type']); + print_cell($row['rev']); + print_cell($row['location']); + if ($verbose) { + print_cell("<pre>\n" . urldecode($row['comments']) . + "\n\t</pre>"); + print_cell(gather_enum_multi_print("sdram", 4, $row)); + print_cell(gather_enum_multi_print("flash", 4, $row)); + print_cell(gather_enum_multi_print("zbt", 16, $row)); + print_cell(gather_enum_multi_print("xlxtyp", 4, $row)); + print_cell(gather_enum_multi_print("xlxspd", 4, $row)); + print_cell(gather_enum_multi_print("xlxtmp", 4, $row)); + print_cell(gather_enum_multi_print("xlxgrd", 4, $row)); + print_cell($row['cputyp']); + print_cell($row['cpuspd']); + print_cell($row['cpmspd']); + print_cell($row['busspd']); + print_cell($row['hstype']); + print_cell($row['hschin']); + print_cell($row['hschout']); + } + echo "</tr>\n"; + } +?> +</table> +<p></p> +<table width="100%"> +<tr> + <td align=center><?php + if ($verbose) + echo "<a href=\"browse.php?verbose=0\">Terse Listing</a>"; + else + echo "<a href=\"browse.php?verbose=1\">Verbose Listing</a>"; + ?></td> + <td align=center><a href="index.php">Back to Start</a></td> +</tr> +</table> +<?php + pg_foot(); +?> diff --git a/tools/bddb/config.php b/tools/bddb/config.php new file mode 100644 index 00000000000..8d54993c586 --- /dev/null +++ b/tools/bddb/config.php @@ -0,0 +1,16 @@ +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + // mysql database access info + $mysql_user="fred"; + $mysql_pw="apassword"; + $mysql_db="mydbname"; + + // where to put the eeprom config files + $bddb_cfgdir = '/tftpboot/bddb'; + + // what this database is called + $bddb_label = 'Hymod Board Database'; +?> diff --git a/tools/bddb/create_tables.sql b/tools/bddb/create_tables.sql new file mode 100644 index 00000000000..aa007c16c8b --- /dev/null +++ b/tools/bddb/create_tables.sql @@ -0,0 +1,90 @@ +# phpMyAdmin MySQL-Dump +# http://phpwizard.net/phpMyAdmin/ +# +# Host: localhost Database : hymod_bddb + +# (C) Copyright 2001 +# Murray Jensen <Murray.Jensen@cmst.csiro.au> +# CSIRO Manufacturing Science and Technology, Preston Lab + +# -------------------------------------------------------- +# +# Table structure for table 'boards' +# + +DROP TABLE IF EXISTS boards; +CREATE TABLE boards ( + serno int(10) unsigned zerofill NOT NULL auto_increment, + ethaddr char(17), + date date NOT NULL, + batch char(32), + type enum('IO','CLP','DSP','INPUT','ALT-INPUT','DISPLAY') NOT NULL, + rev tinyint(3) unsigned zerofill NOT NULL, + location char(64), + comments text, + sdram0 enum('32M','64M','128M','256M'), + sdram1 enum('32M','64M','128M','256M'), + sdram2 enum('32M','64M','128M','256M'), + sdram3 enum('32M','64M','128M','256M'), + flash0 enum('4M','8M','16M','32M','64M'), + flash1 enum('4M','8M','16M','32M','64M'), + flash2 enum('4M','8M','16M','32M','64M'), + flash3 enum('4M','8M','16M','32M','64M'), + zbt0 enum('512K','1M','2M','4M'), + zbt1 enum('512K','1M','2M','4M'), + zbt2 enum('512K','1M','2M','4M'), + zbt3 enum('512K','1M','2M','4M'), + zbt4 enum('512K','1M','2M','4M'), + zbt5 enum('512K','1M','2M','4M'), + zbt6 enum('512K','1M','2M','4M'), + zbt7 enum('512K','1M','2M','4M'), + zbt8 enum('512K','1M','2M','4M'), + zbt9 enum('512K','1M','2M','4M'), + zbta enum('512K','1M','2M','4M'), + zbtb enum('512K','1M','2M','4M'), + zbtc enum('512K','1M','2M','4M'), + zbtd enum('512K','1M','2M','4M'), + zbte enum('512K','1M','2M','4M'), + zbtf enum('512K','1M','2M','4M'), + xlxtyp0 enum('XCV300E','XCV400E','XCV600E'), + xlxtyp1 enum('XCV300E','XCV400E','XCV600E'), + xlxtyp2 enum('XCV300E','XCV400E','XCV600E'), + xlxtyp3 enum('XCV300E','XCV400E','XCV600E'), + xlxspd0 enum('6','7','8'), + xlxspd1 enum('6','7','8'), + xlxspd2 enum('6','7','8'), + xlxspd3 enum('6','7','8'), + xlxtmp0 enum('COM','IND'), + xlxtmp1 enum('COM','IND'), + xlxtmp2 enum('COM','IND'), + xlxtmp3 enum('COM','IND'), + xlxgrd0 enum('NORMAL','ENGSAMP'), + xlxgrd1 enum('NORMAL','ENGSAMP'), + xlxgrd2 enum('NORMAL','ENGSAMP'), + xlxgrd3 enum('NORMAL','ENGSAMP'), + cputyp enum('MPC8260'), + cpuspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ'), + cpmspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ'), + busspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ'), + hstype enum('AMCC-S2064A'), + hschin enum('0','1','2','3','4'), + hschout enum('0','1','2','3','4'), + PRIMARY KEY (serno), + KEY serno (serno), + UNIQUE serno_2 (serno) +); + +# +# Table structure for table 'log' +# + +DROP TABLE IF EXISTS log; +CREATE TABLE log ( + logno int(10) unsigned zerofill NOT NULL auto_increment, + serno int(10) unsigned zerofill NOT NULL, + date date NOT NULL, + details text NOT NULL, + PRIMARY KEY (logno), + KEY logno (logno, serno, date), + UNIQUE logno_2 (logno) +); diff --git a/tools/bddb/defs.php b/tools/bddb/defs.php new file mode 100644 index 00000000000..0393dbda644 --- /dev/null +++ b/tools/bddb/defs.php @@ -0,0 +1,663 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + // contains mysql user id and password - keep secret + require("config.php"); + + if (isset($logout)) { + 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>\n"; + echo "<body bgcolor=#ffffff><br></br><br></br><center><h1>" . + "You must be an Authorised User " . + "to access the '$bddb_label'" . + "</h1>\n</center></body></html>\n"; + 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'); + + // sdram sizes (nbits array is for write into eeprom config file) + $sdram_vals = array('','32M','64M','128M','256M'); + $sdram_nbits = array(0,25,26,27,28); + + // flash sizes (nbits array is for write into eeprom config file) + $flash_vals = array('','4M','8M','16M','32M','64M'); + $flash_nbits = array(0,22,23,24,25,26); + + // zbt ram sizes (nbits array is for write into eeprom config file) + $zbt_vals = array('','512K','1M','2M','4M'); + $zbt_nbits = array(0,19,20,21,22); + + // Xilinx attributes + $xlxtyp_vals = array('','XCV300E','XCV400E','XCV600E'); + $xlxspd_vals = array('','6','7','8'); + $xlxtmp_vals = array('','COM','IND'); + $xlxgrd_vals = array('','NORMAL','ENGSAMP'); + + // processor attributes + $cputyp_vals = array('','MPC8260'); + $clk_vals = array('','33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ'); + + // high-speed serial attributes + $hstype_vals = array('','AMCC-S2064A'); + $hschin_vals = array('0','1','2','3','4'); + $hschout_vals = array('0','1','2','3','4'); + + // 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>\n<head>\n"; + echo "<link rel=stylesheet href=\"bddb.css\" type=\"text/css\" title=\"style sheet\"></link>\n"; + echo "<title>$title</title>\n"; + echo "</head>\n"; + echo "<body>\n"; + echo "<center><h1>$title</h1></center>\n"; + echo "<hr></hr>\n"; + } + + // page footer + function pg_foot() + { + echo "<hr></hr>\n"; + echo "<table width=\"100%\"><tr><td align=left>\n<address>" . + "If you have any problems, email " . + "<a href=\"mailto:Murray.Jensen@cmst.csiro.au\">" . + "Murray Jensen" . + "</a></address>\n" . + "</td><td align=right>\n" . + "<a href=\"index.php?logout=true\">logout</a>\n" . + "</td></tr></table>\n"; + echo "<p><small><i>Made with " . + "<a href=\"http://kyber.dk/phpMyBuilder/\">" . + "Kyber phpMyBuilder</a></i></small></p>\n"; + echo "</body>\n"; + echo "</html>\n"; + } + + // 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>\n"; + } + + function begin_field($name, $span = 0) { + global $table_ncols; + echo "<tr valign=top>\n"; + echo "\t<th align=center>$name</th>\n"; + if ($span <= 0) + $span = $table_ncols - 1; + if ($span > 1) + echo "\t<td colspan=$span>\n"; + else + echo "\t<td>\n"; + } + + function cont_field($span = 1) { + echo "\t</td>\n"; + if ($span > 1) + echo "\t<td colspan=$span>\n"; + else + echo "\t<td>\n"; + } + + function end_field() { + echo "\t</td>\n"; + echo "</tr>\n"; + } + + function end_table() { + echo "</table>\n"; + } + + 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>\n"; + + 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>\n"; + echo "$value"; + echo "</textarea>\n"; + + 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>\n", + $i == $chk ? " checked" : ""); + } + + end_field(); + } + + // 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>\n"; + + 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 = " "; + else + $pval = "$val"; + + printf("\t\t\t<option " . + "value=\"%s\"%s>%s</option>\n", + $val, + $j == $ai ? " selected" : "", + $pval); + } + + echo "\t\t</select>\n"; + } + + 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); + + if (isset($GLOBALS[$name])) { + $retval .= sprintf(", %s='%s'", + $name, $GLOBALS[$name]); + } + } + + 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); + + if (isset($GLOBALS[$name])) + $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 + // address). Also, make sure it is NOT a multicast ethernet address. + function gen_eth_addr($serno) { + + $ethaddr_high = (mt_rand(0, 65535) & 0xfeff) | 0x0200; + $ethaddr_low = mt_rand(0, 4294967295); + + return sprintf("%02lx:%02lx:%02lx:%02lx:%02lx:%02lx", + $ethaddr_high >> 8, $ethaddr_high & 0xff, + $ethaddr_low >> 24, ($ethaddr_low >> 16) & 0xff, + ($ethaddr_low >> 8) & 0xff, $ethaddr_low & 0xff); + } + + // 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\n", $sernos[$i])) { + $cfgerrs[$i] = 'cfg wr fail (serno)'; + fclose($wfp); + $numerrs++; + continue; + } + + if (!fprintf($wfp, "date=%s\n", $date)) { + $cfgerrs[$i] = 'cfg wr fail (date)'; + fclose($wfp); + $numerrs++; + continue; + } + + if ($batch != '') { + if (!fprintf($wfp, "batch=%s\n", $batch)) { + $cfgerrs[$i] = 'cfg wr fail (batch)'; + fclose($wfp); + $numerrs++; + continue; + } + } + + $typei = enum_to_index("type", $type_vals); + if (!fprintf($wfp, "type=%d\n", $typei)) { + $cfgerrs[$i] = 'cfg wr fail (type)'; + fclose($wfp); + $numerrs++; + continue; + } + + if (!fprintf($wfp, "rev=%d\n", $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\n", $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\n", $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\n", $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\n", $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\n", $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\n", $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\n", $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\ncpuspd=%d\n" . + "busspd=%d\ncpmspd=%d\n", + $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\n" . + "hschin=%s\nhschout=%s\n", + $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; + } +?> diff --git a/tools/bddb/dodelete.php b/tools/bddb/dodelete.php new file mode 100644 index 00000000000..839ad8cf107 --- /dev/null +++ b/tools/bddb/dodelete.php @@ -0,0 +1,64 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + // dodelete page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Delete Board Results"); + + if (!($serno=intval($serno))) + die("the board serial number was not specified"); + + mysql_query("delete from boards where serno=$serno"); + + if(mysql_errno()) { + $errstr = mysql_error(); + echo "\t<font size=+4>\n"; + echo "\t\t<p>\n"; + echo "\t\t\tThe following error was encountered:\n"; + echo "\t\t</p>\n"; + echo "\t\t<center>\n"; + printf("\t\t\t<b>%s</b>\n", $errstr); + echo "\t\t</center>\n"; + echo "\t</font>\n"; + } + else { + echo "\t<font size=+2>\n"; + echo "\t\t<p>\n"; + echo "\t\t\tThe board with serial number <b>$serno</b> was" + . " successfully deleted\n"; + mysql_query("delete from log where serno=$serno"); + if (mysql_errno()) { + $errstr = mysql_error(); + echo "\t\t\t<font size=+4>\n"; + echo "\t\t\t\t<p>\n"; + echo "\t\t\t\t\tBut the following error occurred " . + "when deleting the log entries:\n"; + echo "\t\t\t\t</p>\n"; + echo "\t\t\t\t<center>\n"; + printf("\t\t\t\t\t<b>%s</b>\n", $errstr); + echo "\t\t\t\t</center>\n"; + echo "\t\t\t</font>\n"; + } + echo "\t\t</p>\n"; + echo "\t</font>\n"; + } +?> +<p> +<table width="100%"> +<tr> + <td align=center> + <a href="browse.php">Back to Browse</a> + </td> + <td align=center> + <a href="index.php">Back to Start</a> + </td> +</tr> +</table> +<?php + pg_foot(); +?> diff --git a/tools/bddb/dodellog.php b/tools/bddb/dodellog.php new file mode 100644 index 00000000000..d5822c5fd19 --- /dev/null +++ b/tools/bddb/dodellog.php @@ -0,0 +1,55 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + // dodelete page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Delete Log Entry Results"); + + if (!($serno=intval($serno))) + die("the board serial number was not specified"); + + if (!isset($logno) || $logno == 0) + die("the log entry number not specified!"); + + mysql_query("delete from log where serno=$serno and logno=$logno"); + + if(mysql_errno()) { + $errstr = mysql_error(); + echo "\t<font size=+4>\n"; + echo "\t\t<p>\n"; + echo "\t\t\tThe following error was encountered:\n"; + echo "\t\t</p>\n"; + echo "\t\t<center>\n"; + printf("\t\t\t<b>%s</b>\n", $errstr); + echo "\t\t</center>\n"; + echo "\t</font>\n"; + } + else { + echo "\t<font size=+2>\n"; + echo "\t\t<p>\n"; + echo "\t\t\tThe log entry with log number <b>$logno</b>\n"; + echo "\t\t\tand serial number <b>$serno</b> "; + echo "was successfully deleted\n"; + echo "\t\t</p>\n"; + echo "\t</font>\n"; + } +?> +<p> +<table width="100%"> +<tr> + <td align=center> + <a href="brlog.php?serno=<?php echo "$serno"; ?>">Back to Log</a> + </td> + <td align=center> + <a href="index.php">Back to Start</a> + </td> +</tr> +</table> +<?php + pg_foot(); +?> diff --git a/tools/bddb/doedit.php b/tools/bddb/doedit.php new file mode 100644 index 00000000000..110ecf39fee --- /dev/null +++ b/tools/bddb/doedit.php @@ -0,0 +1,170 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + // doedit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Edit Board Results"); + + if ($serno == 0) + die("the board serial number was not specified"); + + $query="update boards set"; + + if (isset($ethaddr)) { + if (!eth_addr_is_valid($ethaddr)) + die("ethaddr is invalid ('$ethaddr')"); + $query.=" ethaddr='$ethaddr',"; + } + + if (isset($date)) { + list($y, $m, $d) = split("-", $date); + if (!checkdate($m, $d, $y) || $y < 1999) + die("date is invalid (input '$date', " . + "yyyy-mm-dd '$y-$m-$d')"); + $query.=" date='$date'"; + } + + if (isset($batch)) { + if (strlen($batch) > 32) + die("batch field too long (>32)"); + $query.=", batch='$batch'"; + } + + if (isset($type)) { + if (!in_array($type, $type_vals)) + die("Invalid type ($type) specified"); + $query.=", type='$type'"; + } + + if (isset($rev)) { + if (($rev = intval($rev)) <= 0 || $rev > 255) + die("Revision number is invalid ($rev)"); + $query.=sprintf(", rev=%d", $rev); + } + + if (isset($location)) { + if (strlen($location) > 64) + die("location field too long (>64)"); + $query.=", location='$location'"; + } + + if (isset($comments)) + $query.=", comments='" . rawurlencode($comments) . "'"; + + $query.=gather_enum_multi_query("sdram", 4); + + $query.=gather_enum_multi_query("flash", 4); + + $query.=gather_enum_multi_query("zbt", 16); + + $query.=gather_enum_multi_query("xlxtyp", 4); + $nxlx = count_enum_multi("xlxtyp", 4); + + $query.=gather_enum_multi_query("xlxspd", 4); + if (count_enum_multi("xlxspd", 4) != $nxlx) + die("number of xilinx speeds not same as number of types"); + + $query.=gather_enum_multi_query("xlxtmp", 4); + if (count_enum_multi("xlxtmp", 4) != $nxlx) + die("number of xilinx temps. not same as number of types"); + + $query.=gather_enum_multi_query("xlxgrd", 4); + if (count_enum_multi("xlxgrd", 4) != $nxlx) + die("number of xilinx grades not same as number of types"); + + if (isset($cputyp)) { + $query.=", cputyp='$cputyp'"; + if ($cpuspd == '') + die("must specify cpu speed if cpu type is defined"); + $query.=", cpuspd='$cpuspd'"; + if ($cpmspd == '') + die("must specify cpm speed if cpu type is defined"); + $query.=", cpmspd='$cpmspd'"; + if ($busspd == '') + die("must specify bus speed if cpu type is defined"); + $query.=", busspd='$busspd'"; + } + else { + if (isset($cpuspd)) + die("can't specify cpu speed if there is no cpu"); + if (isset($cpmspd)) + die("can't specify cpm speed if there is no cpu"); + if (isset($busspd)) + die("can't specify bus speed if there is no cpu"); + } + + if (isset($hschin)) { + if (($hschin = intval($hschin)) < 0 || $hschin > 4) + die("Invalid number of hs input chans ($hschin)"); + } + else + $hschin = 0; + if (isset($hschout)) { + if (($hschout = intval($hschout)) < 0 || $hschout > 4) + die("Invalid number of hs output chans ($hschout)"); + } + else + $hschout = 0; + if (isset($hstype)) + $query.=", hstype='$hstype'"; + else { + if ($hschin != 0) + die("number of high-speed input channels must be zero" + . " if high-speed chip is not present"); + if ($hschout != 0) + die("number of high-speed output channels must be zero" + . " if high-speed chip is not present"); + } + $query.=", hschin='$hschin'"; + $query.=", hschout='$hschout'"; + + $query.=" where serno=$serno"; + + mysql_query($query); + if(mysql_errno()) { + $errstr = mysql_error(); + echo "\t<font size=+4>\n"; + echo "\t\t<p>\n"; + echo "\t\t\tThe following error was encountered:\n"; + echo "\t\t</p>\n"; + echo "\t\t<center>\n"; + printf("\t\t\t<b>%s</b>\n", $errstr); + echo "\t\t</center>\n"; + echo "\t</font>\n"; + } + else { + $sernos = array($serno); + $nsernos = 1; + + write_eeprom_cfg_file(); + + echo "\t<font size=+2>\n"; + echo "\t\t<p>\n"; + echo "\t\t\tThe board with serial number <b>$serno</b> was" + . " successfully updated"; + if ($numerrs > 0) { + $errstr = $cfgerrs[0]; + echo "<br>\n\t\t\t"; + echo "(but the cfg file update failed: $errstr)"; + } + echo "\n"; + echo "\t\t</p>\n"; + echo "\t</font>\n"; + } + +?> +<p> +<table align=center width="100%"> +<tr> + <td align=center><a href="browse.php">Back to Browse</a></td> + <td align=center><a href="index.php">Back to Start</a></td> +</tr> +</table> +<?php + pg_foot(); +?> diff --git a/tools/bddb/doedlog.php b/tools/bddb/doedlog.php new file mode 100644 index 00000000000..db27c37eb93 --- /dev/null +++ b/tools/bddb/doedlog.php @@ -0,0 +1,66 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + // doedit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Edit Log Entry Results"); + + if ($serno == 0) + die("the board serial number was not specified"); + + if (!isset($logno) || $logno == 0) + die("log number not specified!"); + + $query="update log set"; + + if (isset($date)) { + list($y, $m, $d) = split("-", $date); + if (!checkdate($m, $d, $y) || $y < 1999) + die("date is invalid (input '$date', " . + "yyyy-mm-dd '$y-$m-$d')"); + $query.=" date='$date'"; + } + + if (isset($details)) + $query.=", details='" . rawurlencode($details) . "'"; + + $query.=" where serno=$serno and logno=$logno"; + + mysql_query($query); + if(mysql_errno()) { + $errstr = mysql_error(); + echo "\t<font size=+4>\n"; + echo "\t\t<p>\n"; + echo "\t\t\tThe following error was encountered:\n"; + echo "\t\t</p>\n"; + echo "\t\t<center>\n"; + printf("\t\t\t<b>%s</b>\n", $errstr); + echo "\t\t</center>\n"; + echo "\t</font>\n"; + } + else { + echo "\t<font size=+2>\n"; + echo "\t\t<p>\n"; + echo "\t\t\tThe log entry with log number <b>$logno</b> and\n"; + echo "\t\t\tserial number <b>$serno</b> "; + echo "was successfully updated\n"; + echo "\t\t</p>\n"; + echo "\t</font>\n"; + } + +?> +<p> +<table align=center width="100%"> +<tr> + <td align=center><a href="brlog.php?serno=<?php echo "$serno"; ?>">Back to Log</a></td> + <td align=center><a href="index.php">Back to Start</a></td> +</tr> +</table> +<?php + pg_foot(); +?> diff --git a/tools/bddb/donew.php b/tools/bddb/donew.php new file mode 100644 index 00000000000..0f6e0d75ece --- /dev/null +++ b/tools/bddb/donew.php @@ -0,0 +1,228 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + // doedit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Board Registration Results"); + + if (($serno=intval($serno)) != 0) + die("serial number must not be set ($serno) when Creating!"); + + $query="update boards set"; + + list($y, $m, $d) = split("-", $date); + if (!checkdate($m, $d, $y) || $y < 1999) + die("date is invalid (input '$date', yyyy-mm-dd '$y-$m-$d')"); + $query.=" date='$date'"; + + if ($batch != '') { + if (strlen($batch) > 32) + die("batch field too long (>32)"); + $query.=", batch='$batch'"; + } + + if (!in_array($type, $type_vals)) + die("Invalid type ($type) specified"); + $query.=", type='$type'"; + + if (($rev = intval($rev)) <= 0 || $rev > 255) + die("Revision number is invalid ($rev)"); + $query.=sprintf(", rev=%d", $rev); + + $query.=gather_enum_multi_query("sdram", 4); + + $query.=gather_enum_multi_query("flash", 4); + + $query.=gather_enum_multi_query("zbt", 16); + + $query.=gather_enum_multi_query("xlxtyp", 4); + $nxlx = count_enum_multi("xlxtyp", 4); + + $query.=gather_enum_multi_query("xlxspd", 4); + if (count_enum_multi("xlxspd", 4) != $nxlx) + die("number of xilinx speeds not same as number of types"); + + $query.=gather_enum_multi_query("xlxtmp", 4); + if (count_enum_multi("xlxtmp", 4) != $nxlx) + die("number of xilinx temps. not same as number of types"); + + $query.=gather_enum_multi_query("xlxgrd", 4); + if (count_enum_multi("xlxgrd", 4) != $nxlx) + die("number of xilinx grades not same as number of types"); + + if ($cputyp == '') { + if ($cpuspd != '') + die("can't specify cpu speed if there is no cpu"); + if ($cpmspd != '') + die("can't specify cpm speed if there is no cpu"); + if ($busspd != '') + die("can't specify bus speed if there is no cpu"); + } + else { + $query.=", cputyp='$cputyp'"; + if ($cpuspd == '') + die("must specify cpu speed if cpu type is defined"); + $query.=", cpuspd='$cpuspd'"; + if ($cpmspd == '') + die("must specify cpm speed if cpu type is defined"); + $query.=", cpmspd='$cpmspd'"; + if ($busspd == '') + die("must specify bus speed if cpu type is defined"); + $query.=", busspd='$busspd'"; + } + + if (($hschin = intval($hschin)) < 0 || $hschin > 4) + die("Invalid number of hs input chans ($hschin)"); + if (($hschout = intval($hschout)) < 0 || $hschout > 4) + die("Invalid number of hs output chans ($hschout)"); + if ($hstype == '') { + if ($hschin != 0) + die("number of high-speed input channels must be zero" + . " if high-speed chip is not present"); + if ($hschout != 0) + die("number of high-speed output channels must be zero" + . " if high-speed chip is not present"); + } + else + $query.=", hstype='$hstype'"; + $query.=", hschin='$hschin'"; + $query.=", hschout='$hschout'"; + + // echo "final query = '$query'<br>\n"; + + $quant = intval($quant); + if ($quant <= 0) $quant = 1; + + $sernos = array(); + if ($geneths) + $ethaddrs = array(); + + $sqlerr = ''; + + while ($quant-- > 0) { + + mysql_query("insert into boards (serno) values (null)"); + if (mysql_errno()) { + $sqlerr = mysql_error(); + break; + } + + $serno = mysql_insert_id(); + if (!$serno) { + $sqlerr = "couldn't allocate new serial number"; + break; + } + + mysql_query($query . " where serno=$serno"); + if (mysql_errno()) { + $sqlerr = mysql_error(); + break; + } + + array_push($sernos, $serno); + + if ($geneths) { + + $ethaddr = gen_eth_addr($serno); + + mysql_query("update boards set ethaddr='$ethaddr'" . + " where serno=$serno"); + if (mysql_errno()) { + $sqlerr = mysql_error(); + + array_push($ethaddrs, + "<font color=#ff0000><b>" . + "db save fail" . + "</b></font>"); + break; + } + + array_push($ethaddrs, $ethaddr); + } + } + + $nsernos = count($sernos); + + if ($nsernos > 0) { + + write_eeprom_cfg_file(); + + echo "<font size=+2>\n"; + echo "\t<p>\n"; + echo "\t\tThe following board serial numbers were" + . " successfully allocated"; + if ($numerrs > 0) + echo " (but with $numerrs cfg file error" . + ($numerrs > 1 ? "s" : "") . ")"; + echo ":\n"; + echo "\t</p>\n"; + + echo "</font>\n"; + + echo "<table align=center width=\"100%\">\n"; + echo "<tr>\n"; + echo "\t<th>Serial Number</th>\n"; + if ($numerrs > 0) + echo "\t<th>Cfg File Errs</th>\n"; + if ($geneths) + echo "\t<th>Ethernet Address</th>\n"; + echo "</tr>\n"; + + for ($i = 0; $i < $nsernos; $i++) { + + $serno = sprintf("%010d", $sernos[$i]); + + echo "<tr>\n"; + + echo "\t<td align=center><font size=+2>" . + "<b>$serno</b></font></td>\n"; + + if ($numerrs > 0) { + if (($errstr = $cfgerrs[$i]) == '') + $errstr = ' '; + echo "\t<td align=center>" . + "<font size=+2 color=#ff0000><b>" . + $errstr . + "</b></font></td>\n"; + } + + if ($geneths) { + echo "\t<td align=center>" . + "<font size=+2 color=#00ff00><b>" . + $ethaddrs[$i] . + "</b></font></td>\n"; + } + + echo "</tr>\n"; + } + + echo "</table>\n"; + } + + if ($sqlerr != '') { + echo "\t<font size=+4>\n"; + echo "\t\t<p>\n"; + echo "\t\t\tThe following SQL error was encountered:\n"; + echo "\t\t</p>\n"; + echo "\t\t<center>\n"; + printf("\t\t\t<b>%s</b>\n", $sqlerr); + echo "\t\t</center>\n"; + echo "\t</font>\n"; + } + +?> +<p> +<table align=center width="100%"> +<tr> + <td align=center><a href="browse.php">Go to Browse</a></td> + <td align=center><a href="index.php">Back to Start</a></td> +</tr> +</table> +<?php + pg_foot(); +?> diff --git a/tools/bddb/donewlog.php b/tools/bddb/donewlog.php new file mode 100644 index 00000000000..b00de955bc5 --- /dev/null +++ b/tools/bddb/donewlog.php @@ -0,0 +1,76 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + // doedit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Add Log Entry Results"); + + if ($serno == 0) + die("serial number not specified!"); + + if (isset($logno)) + die("log number must not be set ($logno) when Creating!"); + + $query="update log set serno=$serno"; + + list($y, $m, $d) = split("-", $date); + if (!checkdate($m, $d, $y) || $y < 1999) + die("date is invalid (input '$date', yyyy-mm-dd '$y-$m-$d')"); + $query.=", date='$date'"; + + if (isset($details)) + $query.=", details='" . rawurlencode($details) . "'"; + + // echo "final query = '$query'<br>\n"; + + $sqlerr = ''; + + mysql_query("insert into log (logno) values (null)"); + if (mysql_errno()) + $sqlerr = mysql_error(); + else { + $logno = mysql_insert_id(); + if (!$logno) + $sqlerr = "couldn't allocate new serial number"; + else { + mysql_query($query . " where logno=$logno"); + if (mysql_errno()) + $sqlerr = mysql_error(); + } + } + + if ($sqlerr == '') { + echo "<font size=+2>\n"; + echo "\t<p>\n"; + echo "\t\tA log entry with log number '$logno' was " . + "added to the board with serial number '$serno'\n"; + echo "\t</p>\n"; + echo "</font>\n"; + } + else { + echo "\t<font size=+4>\n"; + echo "\t\t<p>\n"; + echo "\t\t\tThe following SQL error was encountered:\n"; + echo "\t\t</p>\n"; + echo "\t\t<center>\n"; + printf("\t\t\t<b>%s</b>\n", $sqlerr); + echo "\t\t</center>\n"; + echo "\t</font>\n"; + } + +?> +<p></p> +<table width="100%"> +<tr> + <td align=center><a href="brlog.php?serno=<?php echo "$serno"; ?>">Go to Browse</a></td> + <td align=center><a href="index.php">Back to Start</a></td> +</tr> +</table> +<?php + pg_foot(); +?> diff --git a/tools/bddb/edit.php b/tools/bddb/edit.php new file mode 100644 index 00000000000..f7d48307980 --- /dev/null +++ b/tools/bddb/edit.php @@ -0,0 +1,131 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + // edit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Edit Board Registration"); + + if ($serno == 0) + die("serial number not specified!"); + + $pserno = sprintf("%010d", $serno); + + echo "<center><b><font size=+2>"; + echo "Board Serial Number: $pserno"; + echo "</font></b></center>\n"; + +?> +<p> +<form action=doedit.php method=POST> +<?php + echo "<input type=hidden name=serno value=$serno>\n"; + + $r=mysql_query("select * from boards where serno=$serno"); + $row=mysql_fetch_array($r); + if(!$row) die("no record of serial number '$serno' in database"); + + begin_table(5); + + // ethaddr char(17) + print_field("ethaddr", $row, 17); + + // date date + print_field("date", $row); + + // batch char(32) + print_field("batch", $row, 32); + + // type enum('IO','CLP','DSP','INPUT','ALT-INPUT','DISPLAY') + print_enum("type", $row, $type_vals); + + // rev tinyint(3) unsigned zerofill + print_field("rev", $row, 3, 'rev_filter'); + + // location char(64) + print_field("location", $row, 64); + + // comments text + print_field_multiline("comments", $row, 60, 10, 'text_filter'); + + // sdram[0-3] enum('32M','64M','128M','256M') + print_enum_multi("sdram", $row, $sdram_vals, 4, array()); + + // flash[0-3] enum('4M','8M','16M','32M','64M') + print_enum_multi("flash", $row, $flash_vals, 4, array()); + + // zbt[0-f] enum('512K','1M','2M','4M') + print_enum_multi("zbt", $row, $zbt_vals, 16, array()); + + // xlxtyp[0-3] enum('XCV300E','XCV400E','XCV600E') + print_enum_multi("xlxtyp", $row, $xlxtyp_vals, 4, array(), 1); + + // xlxspd[0-3] enum('6','7','8') + print_enum_multi("xlxspd", $row, $xlxspd_vals, 4, array(), 1); + + // xlxtmp[0-3] enum('COM','IND') + print_enum_multi("xlxtmp", $row, $xlxtmp_vals, 4, array(), 1); + + // xlxgrd[0-3] enum('NORMAL','ENGSAMP') + print_enum_multi("xlxgrd", $row, $xlxgrd_vals, 4, array(), 1); + + // cputyp enum('MPC8260') + print_enum("cputyp", $row, $cputyp_vals); + + // cpuspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ') + print_enum("cpuspd", $row, $clk_vals); + + // cpmspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ') + print_enum("cpmspd", $row, $clk_vals); + + // busspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ') + print_enum("busspd", $row, $clk_vals); + + // hstype enum('AMCC-S2064A') + print_enum("hstype", $row, $hstype_vals); + + // hschin enum('0','1','2','3','4') + print_enum("hschin", $row, $hschin_vals); + + // hschout enum('0','1','2','3','4') + print_enum("hschout", $row, $hschout_vals); + + end_table(); + + echo "<p>\n"; + echo "<center><b>"; + echo "<font color=#ff0000>WARNING: NO UNDO ON DELETE!</font>"; + echo "<br></br>\n"; + echo "<tt>[ <a href=\"dodelete.php?serno=$serno\">delete</a> ]</tt>"; + echo "</b></center>\n"; + echo "</p>\n"; +?> +<p> +<table align=center width="100%"> +<tr> + <td align=center> + <input type=submit value=Edit> + </td> + <td> + + </td> + <td align=center> + <input type=reset value=Reset> + </td> + <td> + + </td> + <td align=center> + <a href="index.php">Back to Start</a> + </td> +</tr> +</table> +</p> +</form> +<?php + pg_foot(); +?> diff --git a/tools/bddb/edlog.php b/tools/bddb/edlog.php new file mode 100644 index 00000000000..f819b46a0de --- /dev/null +++ b/tools/bddb/edlog.php @@ -0,0 +1,81 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + // edit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Edit Board Log Entry"); + + if ($serno == 0) + die("serial number not specified!"); + + if (!isset($logno) || $logno == 0) + die("log number not specified!"); + + $pserno = sprintf("%010d", $serno); + $plogno = sprintf("%010d", $logno); + + echo "<center><b><font size=+2>"; + echo "Board Serial Number: $pserno, Log Number: $plogno"; + echo "</font></b></center>\n"; + +?> +<p> +<form action=doedlog.php method=POST> +<?php + echo "<input type=hidden name=serno value=$serno>\n"; + echo "<input type=hidden name=logno value=$logno>\n"; + + $r=mysql_query("select * from log where serno=$serno and logno=$logno"); + $row=mysql_fetch_array($r); + if(!$row) + die("no record of log entry with serial number '$serno' " . + "and log number '$logno' in database"); + + begin_table(3); + + // date date + print_field("date", $row); + + // details text + print_field_multiline("details", $row, 60, 10, 'text_filter'); + + end_table(); + + echo "<p>\n"; + echo "<center><b>"; + echo "<font color=#ff0000>WARNING: NO UNDO ON DELETE!</font>"; + echo "<br></br>\n"; + echo "<tt>[ <a href=\"dodellog.php?serno=$serno&logno=$logno\">delete</a> ]</tt>"; + echo "</b></center>\n"; + echo "</p>\n"; +?> +<p> +<table align=center width="100%"> +<tr> + <td align=center> + <input type=submit value=Edit> + </td> + <td> + + </td> + <td align=center> + <input type=reset value=Reset> + </td> + <td> + + </td> + <td align=center> + <a href="index.php">Back to Start</a> + </td> +</tr> +</table> +</p> +</form> +<?php + pg_foot(); +?> diff --git a/tools/bddb/execute.php b/tools/bddb/execute.php new file mode 100644 index 00000000000..7adcfec2018 --- /dev/null +++ b/tools/bddb/execute.php @@ -0,0 +1,37 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + if (!isset($serno)) + $serno = 0; + else + $serno = intval($serno); + + if (!isset($submit)) + $submit = "[NOT SET]"; + + switch ($submit) { + + case "New": + require("new.php"); + break; + + case "Edit": + require("edit.php"); + break; + + case "Browse": + require("browse.php"); + break; + + case "Log": + require("brlog.php"); + break; + + default: + require("badsubmit.php"); + break; + } +?> diff --git a/tools/bddb/index.php b/tools/bddb/index.php new file mode 100644 index 00000000000..9d6c7f59963 --- /dev/null +++ b/tools/bddb/index.php @@ -0,0 +1,38 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + require("defs.php"); + pg_head("$bddb_label"); +?> +<font size="+4"> + <form action=execute.php method=POST> + <table width="100%" cellspacing=10 cellpadding=10> + <tr> + <td align=center> + <input type=submit name=submit value="New"></input> + </td> + <td align=center> + <input type=submit name=submit value="Edit"></input> + </td> + <td align=center> + <input type=submit name=submit value="Browse"></input> + </td> + <td align=center> + <input type=submit name=submit value="Log"></input> + </td> + </tr> + <tr> + <td align=center colspan=4> + <b>Serial Number:</b> + <input type=text name=serno size=10 maxsize=10 value=""></input> + </td> + </tr> + </table> + </form> +</font> +<?php + pg_foot(); +?> diff --git a/tools/bddb/new.php b/tools/bddb/new.php new file mode 100644 index 00000000000..889c6ae6a54 --- /dev/null +++ b/tools/bddb/new.php @@ -0,0 +1,121 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + // edit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - New Board Registration"); +?> +<form action=donew.php method=POST> +<p></p> +<?php + // if a serial number was supplied, fetch the record + // and use its contents as defaults + if ($serno != 0) { + $r=mysql_query("select * from boards where serno=$serno"); + $row=mysql_fetch_array($r); + if(!$row)die("no record of serial number '$serno' in database"); + } + else + $row = array(); + + echo "<input type=hidden name=serno value=0>\n"; + + begin_table(5); + + // date date + print_field("date", array('date' => date("Y-m-d"))); + + // batch char(32) + print_field("batch", $row, 32); + + // type enum('IO','CLP','DSP','INPUT','ALT-INPUT','DISPLAY') + print_enum("type", $row, $type_vals, 0); + + // rev tinyint(3) unsigned zerofill + print_field("rev", $row, 3, 'rev_filter'); + + // sdram[0-3] enum('32M','64M','128M','256M') + print_enum_multi("sdram", $row, $sdram_vals, 4, array(2)); + + // flash[0-3] enum('4M','8M','16M','32M','64M') + print_enum_multi("flash", $row, $flash_vals, 4, array(2)); + + // zbt[0-f] enum('512K','1M','2M','4M') + print_enum_multi("zbt", $row, $zbt_vals, 16, array(2, 2)); + + // xlxtyp[0-3] enum('XCV300E','XCV400E','XCV600E') + print_enum_multi("xlxtyp", $row, $xlxtyp_vals, 4, array(1), 1); + + // xlxspd[0-3] enum('6','7','8') + print_enum_multi("xlxspd", $row, $xlxspd_vals, 4, array(1), 1); + + // xlxtmp[0-3] enum('COM','IND') + print_enum_multi("xlxtmp", $row, $xlxtmp_vals, 4, array(1), 1); + + // xlxgrd[0-3] enum('NORMAL','ENGSAMP') + print_enum_multi("xlxgrd", $row, $xlxgrd_vals, 4, array(1), 1); + + // cputyp enum('MPC8260') + print_enum("cputyp", $row, $cputyp_vals, 1); + + // cpuspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ') + print_enum("cpuspd", $row, $clk_vals, 4); + + // cpmspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ') + print_enum("cpmspd", $row, $clk_vals, 4); + + // busspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ') + print_enum("busspd", $row, $clk_vals, 2); + + // hstype enum('AMCC-S2064A') + print_enum("hstype", $row, $hstype_vals, 1); + + // hschin enum('0','1','2','3','4') + print_enum("hschin", $row, $hschin_vals, 4); + + // hschout enum('0','1','2','3','4') + print_enum("hschout", $row, $hschout_vals, 4); + + end_table(); +?> +<p></p> +<table width="100%"> +<tr> + <td align=center colspan=3> + Allocate + <input type=text name=quant size=2 maxlength=2 value=" 1"> + board serial number(s) + </td> +</tr> +<tr> + <td align=center colspan=3> + <input type=checkbox name=geneths checked> + Generate Ethernet Address(es) + </td> +</tr> +<tr> + <td colspan=3> + + </td> +</tr> +<tr> + <td align=center> + <input type=submit value="Register Board"> + </td> + <td> + + </td> + <td align=center> + <input type=reset value="Reset Form Contents"> + </td> +</tr> +</table> +</form> +<?php + pg_foot(); +?> diff --git a/tools/bddb/newlog.php b/tools/bddb/newlog.php new file mode 100644 index 00000000000..5ec42ac289f --- /dev/null +++ b/tools/bddb/newlog.php @@ -0,0 +1,48 @@ +<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> +<?php + // (C) Copyright 2001 + // Murray Jensen <Murray.Jensen@cmst.csiro.au> + // CSIRO Manufacturing Science and Technology, Preston Lab + + // edit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - New Log Entry"); + + if ($serno == 0) + die("serial number not specified!"); + + if (isset($logno)) + die("log number must not be specified when adding!"); +?> +<form action=donewlog.php method=POST> +<p></p> +<?php + echo "<input type=hidden name=serno value=$serno>\n"; + + begin_table(3); + + // date date + print_field("date", array('date' => date("Y-m-d"))); + + // details text + print_field_multiline("details", array(), 60, 10, 'text_filter'); + + end_table(); +?> +<p></p> +<table width="100%"> +<tr> + <td align=center> + <input type=submit value="Add Log Entry"> + </td> + <td align=center> + <input type=reset value="Reset Form Contents"> + </td> +</tr> +</table> +</form> +<?php + pg_foot(); +?> |