Annotation of qemu/roms/SLOF/board-js2x/slof/rtas.fs, revision 1.1.1.1

1.1       root        1: \ *****************************************************************************
                      2: \ * Copyright (c) 2004, 2008 IBM Corporation
                      3: \ * All rights reserved.
                      4: \ * This program and the accompanying materials
                      5: \ * are made available under the terms of the BSD License
                      6: \ * which accompanies this distribution, and is available at
                      7: \ * http://www.opensource.org/licenses/bsd-license.php
                      8: \ *
                      9: \ * Contributors:
                     10: \ *     IBM Corporation - initial implementation
                     11: \ ****************************************************************************/
                     12: 
                     13: #include <rtas/rtas-init.fs>
                     14: #include <rtas/rtas-cpu.fs>
                     15: #include <rtas/rtas-reboot.fs>
                     16: #include <rtas/rtas-flash.fs>
                     17: #include <rtas/rtas-vpd.fs>
                     18: 
                     19: \ for update-flash
                     20: : (get-flashside)  ( -- flashside )  rtas-get-flashside  ;
                     21: 
                     22: ' (get-flashside) to get-flashside
                     23: 
                     24: \ remember the current flashside
                     25: get-flashside to flashside? 
                     26: 
                     27: \ for update-flash
                     28: : (set-flashside)  ( flashside -- status )
                     29:    dup rtas-set-flashside =  IF  0  ELSE  -1  THEN
                     30: ;
                     31: 
                     32: ' (set-flashside) to set-flashside
                     33: 
                     34: : rtas-ibm-read-pci-config  ( size puid bus devfn off -- x )
                     35:    [ s" ibm,read-pci-config" rtas-get-token ] LITERAL rtas-cb rtas>token l!
                     36:    4 rtas-cb rtas>nargs l!
                     37:    2 rtas-cb rtas>nret l!
                     38:    swap 8 lshift or swap 10 lshift or rtas-cb rtas>args0 l!
                     39:    dup 20 rshift rtas-cb rtas>args1 l!
                     40:    ffffffff and rtas-cb rtas>args2 l!
                     41:    rtas-cb rtas>args3 l!
                     42:    enter-rtas
                     43:    rtas-cb rtas>args5 l@
                     44: ;
                     45: 
                     46: : rtas-fetch-cpus  ( mask -- status )
                     47:    [ s" rtas-fetch-slaves" rtas-get-token ] LITERAL rtas-cb rtas>token l!
                     48:    1 rtas-cb rtas>nargs l!
                     49:    1 rtas-cb rtas>nret l!
                     50:    rtas-cb rtas>args0 l!
                     51:    0 rtas-cb rtas>args1 l!
                     52:    enter-rtas
                     53:    rtas-cb rtas>args1 l@
                     54: ;
                     55: 
                     56: : rtas-stop-bootwatchdog  ( -- status )
                     57:    [ s" rtas-stop-bootwatchdog" rtas-get-token ] LITERAL rtas-cb rtas>token l!
                     58:    0 rtas-cb rtas>nargs l!
                     59:    1 rtas-cb rtas>nret l!
                     60:    enter-rtas
                     61:    rtas-cb rtas>args0 l@
                     62: ;
                     63: 
                     64: : rtas-set-bootwatchdog  ( seconds -- )
                     65:    [ s" rtas-set-bootwatchdog" rtas-get-token ] LITERAL rtas-cb rtas>token l!
                     66:    1 rtas-cb rtas>nargs l!
                     67:    0 rtas-cb rtas>nret l!
                     68:    rtas-cb rtas>args0 l!
                     69:    enter-rtas
                     70: ;
                     71: 
                     72: ' rtas-set-bootwatchdog to set-watchdog
                     73: 
                     74: : rtas-dump-flash  ( offset cnt -- )
                     75:    [ s" rtas-dump-flash" rtas-get-token ] LITERAL rtas-cb rtas>token l!
                     76:    2 rtas-cb rtas>nargs l!
                     77:    0 rtas-cb rtas>nret l!
                     78:    rtas-cb rtas>args0 l!
                     79:    rtas-cb rtas>args1 l!
                     80:    enter-rtas
                     81: ;
                     82: 
                     83: \ load-base wird in slof/fs/base.fs gesetzt... nicht überschreiben
                     84: \ 2000000 CONSTANT load-base
                     85: create blist 50 allot
                     86: blist 50 erase
                     87: 
                     88: : build-blocklist_old
                     89:    \ set version
                     90:    1 blist c!
                     91:    \ set length of block list
                     92:    50 blist 7 + c!
                     93:    \ no more block list
                     94:    0000000000000000 blist 8 + !
                     95:    \ first block
                     96:    load-base 0 + blist 10 + !
                     97:    80000 blist 18 + !
                     98:    load-base 80000 + blist 20 + !
                     99:    80000 blist 28 + !
                    100:    load-base 100000 + blist 30 + !
                    101:    80000 blist 38 + !
                    102:    load-base 180000 + blist 40 + !
                    103:    8006C blist 48 + !
                    104: ;
                    105: 
                    106: 80000 constant _block_size
                    107: 
                    108: : build-blocklist
                    109:    \ set length of block list
                    110:    \ length of flashfs at load-base is at offset 30... get it...
                    111:    load-base 30 + @
                    112:    \ calculate the number of blocks we need
                    113:    _block_size / 1 +
                    114:    \ total number of blocks is 2 (for header and block_list extension + (number of blocks for flashfs * 2 (1 for address 1 for length))
                    115:    2 * 2 + 8 * blist !
                    116:    \ set version ( in first byte only )
                    117:    1 blist c!
                    118:    \ no more block list
                    119:    0000000000000000 blist 8 + !
                    120:    \ length of flashfs at load-base is at offset 30... get it...
                    121:    load-base 30 + @
                    122:    \ i define one block to be 64K, so calculate the number of blocks we need and loop over them
                    123:    _block_size / 1 + 0 do
                    124:       load-base _block_size i * +  \ which position of load-base to store
                    125:       blist 10 +             \ at what offset of blist ( 0x8 + for header 0x8 + for extension )
                    126:       i 10 * +               \ for each loop we have done 0x10 +
                    127:       !                      \ store it
                    128:       load-base 30 + @
                    129:       _block_size i * -      \ remaining length
                    130:       dup _block_size > 
                    131:       IF                     \ is the remaining length > block size
                    132:        drop _block_size     \ then store the block size as length
                    133:       ELSE
                    134:                             \ do nothing (store remaining length)
                    135:       THEN
                    136:       blist 10 +          \ store the length at
                    137:       i 10 * +            \ correct blist offset 
                    138:       8 +                 \ + 8 (we have stored address, now the length)
                    139:       !                   \ store it
                    140:    loop
                    141: ;
                    142: 
                    143: 
                    144: 
                    145: : build-blocklist-v0_old
                    146:    \ set version
                    147:    0 blist c!
                    148:    48 blist 7 + c!
                    149:    \ first block
                    150:    load-base 0 + blist 8 + !
                    151:    80000 blist 10 + !
                    152:    load-base 80000 + blist 18 + !
                    153:    80000 blist 20 + !
                    154:    load-base 100000 + blist 28 + !
                    155:    80000 blist 30 + !
                    156:    load-base 180000 + blist 38 + !
                    157:    8006C blist 40 + !
                    158: ;
                    159: 
                    160: : build-blocklist-v0
                    161:    \ set length of block list
                    162:    \ length of flashfs at load-base is at offset 30... get it...
                    163:    load-base 30 + @
                    164:    \ calculate the number of blocks we need
                    165:    _block_size / 1 +
                    166:    \ total number of blocks is 1 (for header + (number of blocks for flashfs * 2 (1 for address 1 for length))
                    167:    2 * 1 + 8 * blist !
                    168:    \ length of flashfs at load-base is at offset 30... get it...
                    169:    load-base 30 + @
                    170:    \ i define one block to be 64K, so calculate the number of blocks we need and loop over them
                    171:    _block_size / 1 + 0 do
                    172:       load-base _block_size i * +  \ which position of load-base to store
                    173:       blist 8 +             \ at what offset of blist ( 0x8 + for header)
                    174:       i 10 * +               \ for each loop we have done 0x10 +
                    175:       !                      \ store it
                    176:       load-base 30 + @
                    177:       _block_size i * -      \ remaining length
                    178:       dup _block_size > 
                    179:       IF                     \ is the remaining length > block size
                    180:        drop _block_size     \ then store the block size as length
                    181:       ELSE
                    182:                             \ do nothing (store remaining length)
                    183:       THEN
                    184:       blist 8 +          \ store the length at
                    185:       i 10 * +            \ correct blist offset 
                    186:       8 +                 \ + 8 (we have stored address, now the length)
                    187:       !                   \ store it
                    188:    loop
                    189: ;
                    190: 
                    191: 
                    192: : yy
                    193:    build-blocklist
                    194:    blist rtas-ibm-update-flash-64-and-reboot
                    195: ;
                    196: 
                    197: : yy0
                    198:    build-blocklist-v0
                    199:    blist rtas-ibm-update-flash-64-and-reboot
                    200: ;
                    201: 
                    202: : rtas-ibm-update-flash-64  ( block-list -- status )
                    203:    [ s" ibm,update-flash-64" rtas-get-token ] LITERAL rtas-cb rtas>token l!
                    204:    2 rtas-cb rtas>nargs l!
                    205:    1 rtas-cb rtas>nret l!
                    206:    rtas-cb rtas>args0 l!
                    207:    \ special unofficial parameter: if this is set to 1, the rtas function will not check, wether
                    208:    \ we are on the perm side... this is needed for "update-flash -c" to work...
                    209:    1 rtas-cb rtas>args1 l!
                    210:    enter-rtas
                    211:    rtas-cb rtas>args2 l@
                    212: ;
                    213: 
                    214: \ for update-flash
                    215: : flash-write  ( image-address -- status)
                    216:    load-base >r to load-base build-blocklist-v0
                    217:    blist rtas-ibm-update-flash-64
                    218:    r> to load-base 0=  IF  true  ELSE  false  THEN
                    219: ;
                    220: 
                    221: : commit  1 rtas-ibm-manage-flash-image ;
                    222: : reject  0 rtas-ibm-manage-flash-image ;
                    223: 
                    224: : rtas-ibm-validate-flash-image  ( image-to-commit -- status )
                    225:    [ s" ibm,validate-flash-image" rtas-get-token ] LITERAL rtas-cb rtas>token l!
                    226:    2 rtas-cb rtas>nargs l!
                    227:    2 rtas-cb rtas>nret l!
                    228:    rtas-cb rtas>args0 l!
                    229:    enter-rtas
                    230:    rtas-cb rtas>args1 l@
                    231: ;
                    232: 
                    233: : rtas-get-blade-descr ( address size -- len status )
                    234:    [ s" rtas-get-blade-descr" rtas-get-token ] LITERAL rtas-cb rtas>token l!
                    235:    2 rtas-cb rtas>nargs l!
                    236:    2 rtas-cb rtas>nret l!
                    237:    rtas-cb rtas>args1 l!
                    238:    rtas-cb rtas>args0 l!
                    239:    enter-rtas
                    240:    rtas-cb rtas>args2 l@
                    241:    rtas-cb rtas>args3 l@
                    242: ;

unix.superglobalmegacorp.com

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