Annotation of tme/machine/sun/tme-sun-eeprom.pl, revision 1.1.1.1

1.1       root        1: #! /usr/pkg/bin/perl -w
                      2: 
                      3: # $Id: tme-sun-eeprom.pl,v 1.2 2005/01/14 11:44:18 fredette Exp $
                      4: 
                      5: # machine/sun/tme-sun-eeprom.pl - dumps and makes Sun EEPROM contents:
                      6: 
                      7: # Copyright (c) 2004 Matt Fredette
                      8: # All rights reserved.
                      9: #
                     10: # Redistribution and use in source and binary forms, with or without
                     11: # modification, are permitted provided that the following conditions
                     12: # are met:
                     13: # 1. Redistributions of source code must retain the above copyright
                     14: #    notice, this list of conditions and the following disclaimer.
                     15: # 2. Redistributions in binary form must reproduce the above copyright
                     16: #    notice, this list of conditions and the following disclaimer in the
                     17: #    documentation and/or other materials provided with the distribution.
                     18: # 3. All advertising materials mentioning features or use of this software
                     19: #    must display the following acknowledgement:
                     20: #      This product includes software developed by Matt Fredette.
                     21: # 4. The name of the author may not be used to endorse or promote products
                     22: #    derived from this software without specific prior written permission.
                     23: #
                     24: # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     25: # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                     26: # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
                     27: # DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
                     28: # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
                     29: # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     30: # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31: # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
                     32: # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
                     33: # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     34: # POSSIBILITY OF SUCH DAMAGE.
                     35: 
                     36: sub binary_struct {
                     37: 
                     38:     # the EEPROM definition:
                     39:     #
                     40:     <<'EOF;';
                     41: # amount of memory installed and tested, in MB:
                     42: #
                     43: 0x014 installed-#megs generic_char_dec 8
                     44: 0x015 selftest-#megs generic_char_dec 0
                     45: 
                     46: # screen resolution:
                     47: #
                     48: 0x016 screen-resolution generic_char_hex 0x00=1152x900 0x12=1024x1024 0x13=1600x1280 0x14=1440x1440 0x15=640x480 0x16=1280x1024
                     49: 0x050 screen-#columns generic_char_dec 80
                     50: 0x051 screen-#rows generic_char_dec 34
                     51: 
                     52: # the console device:
                     53: #
                     54: 0x01f console-device generic_char_hex 0x00=onboard-bwtwo 0x10=ttya 0x11=ttyb 0x12=color-fb 0x20=p4-option
                     55: 
                     56: # true if the watchdog causes a reset.
                     57: #
                     58: 0x017 watchdog-reboot? sun_eeprom_boolean false
                     59: 
                     60: # any boot device:
                     61: #
                     62: 0x018 boot-device? sun_eeprom_boolean true
                     63: 0x019 boot-device sun_eeprom_boot_device sd(0,0,0)
                     64: 
                     65: # any OEM banner and/or logo bitmap.
                     66: #
                     67: 0x020 oem-banner? sun_eeprom_boolean false
                     68: 0x068 oem-banner generic_string_buffer80
                     69: 0x18f oem-logo? sun_eeprom_boolean false
                     70: 0x290 oem-logo generic_char_hex512
                     71: 
                     72: # keyboard parameters.
                     73: #
                     74: 0x01e keyboard-type generic_char_hex 0x00=sun *=other
                     75: 0x18d keyboard-locale generic_char_hex
                     76: 0x18e keyboard-id generic_char_hex
                     77: 0x021 keyboard-click? sun_eeprom_boolean false
                     78: 
                     79: # the "diagnostic" boot device and file:
                     80: #
                     81: 0x022 diag-device sun_eeprom_boot_device le(0,0,0)
                     82: 0x028 diag-file generic_string_buffer40
                     83: 
                     84: # inverse video (white-on-black, not implemented?)
                     85: #
                     86: 0x027 inverse-video? sun_eeprom_boolean false
                     87: 
                     88: # default parameters for ttya and ttyb:
                     89: #
                     90: 0x058 ttya-mode sun_eeprom_tty_mode 9600,8,n,1,-
                     91: 0x060 ttyb-mode sun_eeprom_tty_mode 9600,8,n,1,-
                     92: 
                     93: # security mode and password (only on PROM revisions > 2.7.0).
                     94: #
                     95: 0x492 security-mode generic_char_hex 0x00=none 0x01=command 0x5e=full
                     96: 0x493 security-password generic_string_buffer8
                     97: 
                     98: # the 3/80 diagnostic "switch".
                     99: #
                    100: 0x70b diag-switch? generic_char_hex 0x06=false 0x12=true *=max
                    101: 
                    102: # any user-defined keymap:
                    103: #
                    104: 0x18c .keymap? generic_char_hex 0x00=false 0x58=true
                    105: 0x190 .keymap-uppercase generic_char_hex128
                    106: 0x210 .keymap-lowercase generic_char_hex128
                    107: 
                    108: # a short test pattern.
                    109: #
                    110: 0x0b8 .test-pattern generic_shorteb_hex 0x55aa
                    111: 
                    112: # "Factory Defined"
                    113: #
                    114: 0x000 .testarea generic_longeb_hex
                    115: 0x004 .write-count generic_shorteb_dec3
                    116: 0x00c .checksum generic_char_hex3
                    117: 0x010 last-hardware-update generic_longeb_hex
                    118: 
                    119: # make sure the EEPROM has the required length:
                    120: #
                    121: 0x7ff .padding generic_char_hex
                    122: 
                    123: EOF;
                    124: }
                    125: 
                    126: # this parses a set of sun EEPROM boolean values:
                    127: #
                    128: sub type_sun_eeprom_boolean_values {
                    129:     my ($type, $count, $values) = @_;
                    130:     if (!defined($values)) {
                    131:        $values = 'false,' x $count;
                    132:        chop($values);
                    133:        $values .= ' ';
                    134:        $values .= 'true,' x $count;
                    135:        chop($values);
                    136:     }
                    137:     split(' ', $values);
                    138: }
                    139: 
                    140: # this packs a sun EEPROM boolean value:
                    141: #
                    142: sub type_sun_eeprom_boolean_pack {
                    143:     my ($type, $count, $value) = @_;
                    144:     my ($bad, @parts);
                    145: 
                    146:     @parts = split(/,/, $value);
                    147:     foreach (@parts) {
                    148:        if ($value eq 'true') {
                    149:            $_ = 0x12;
                    150:        }
                    151:        elsif ($value eq 'false') {
                    152:            $_ = 0x00;
                    153:        }
                    154:        else {
                    155:            $bad = $_;
                    156:            $_ = 0;
                    157:        }
                    158:     }
                    159:     ($bad, pack("C$count", @parts));
                    160: }
                    161: 
                    162: # this unpacks a sun EEPROM boolean value:
                    163: #
                    164: sub type_sun_eeprom_boolean_unpack {
                    165:     my ($type, $count, $packed) = @_;
                    166:     my (@parts);
                    167: 
                    168:     @parts = unpack("C$count", $packed);
                    169:     foreach (@parts) {
                    170:        if ($_ == 0x00) {
                    171:            $_ = 'false';
                    172:        }
                    173:        else {
                    174:            $_ = 'true';
                    175:        }
                    176:     }
                    177:     join(',', @parts);
                    178: }
                    179: 
                    180: # this parses a set of sun EEPROM boot device values:
                    181: #
                    182: sub type_sun_eeprom_boot_device_values {
                    183:     my ($type, $count, $values) = @_;
                    184:     if (!defined($values)) {
                    185:        ('');
                    186:     }
                    187:     else {
                    188:        split(' ', $values);
                    189:     }
                    190: }
                    191: 
                    192: # this packs a sun EEPROM boot device value:
                    193: #
                    194: sub type_sun_eeprom_boot_device_pack {
                    195:     my ($type, $count, $value) = @_;
                    196: 
                    197:     if ($value =~ /^([a-z])([a-z])\((\d+),(\d+),(\d+)\)$/) {
                    198:        (undef, $1.$2.pack("CCC", $3 + 0, $4 + 0, $5 + 0));
                    199:     }
                    200:     else {
                    201:        ($value, undef);
                    202:     }
                    203: }
                    204: 
                    205: # this unpacks a sun EEPROM boot device value:
                    206: #
                    207: sub type_sun_eeprom_boot_device_unpack {
                    208:     my ($type, $count, $packed) = @_;
                    209:     substr($packed, 0, 2).sprintf("(%d,%d,%d)", unpack("CCC", substr($packed, 2, 3)));
                    210: }
                    211: 
                    212: # this parses a set of sun EEPROM tty mode values:
                    213: #
                    214: sub type_sun_eeprom_tty_mode_values {
                    215:     my ($type, $count, $values) = @_;
                    216:     if (!defined($values)) {
                    217:        ('');
                    218:     }
                    219:     else {
                    220:        split(' ', $values);
                    221:     }
                    222: }
                    223: 
                    224: # this packs a sun EEPROM tty mode value:
                    225: #
                    226: sub type_sun_eeprom_tty_mode_pack {
                    227:     my ($type, $count, $value) = @_;
                    228: 
                    229:     if ($value =~ /^(\d+),8,n,1,([\-h])$/) {
                    230:        (undef, pack('CnCN', ($1 == 9600 ? 0x00 : 0x12), $1, ($2 eq 'h' ? 0x00 : 0x12), 0));
                    231:     }
                    232:     else {
                    233:        ($value, undef);
                    234:     }
                    235: }
                    236: 
                    237: # this unpacks a sun EEPROM tty mode value:
                    238: #
                    239: sub type_sun_eeprom_tty_mode_unpack {
                    240:     my ($type, $count, $packed) = @_;
                    241:     my ($baud_set, $baud, $no_flow);
                    242:     ($baud_set, $baud, $no_flow) = unpack('CnC', $packed);
                    243:     unless ($baud_set) {
                    244:        $baud = 9600;
                    245:     }
                    246:     $baud.',8,n,1,'.($no_flow ? '-' : 'h');
                    247: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.