openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

gh_sdk53403_opt2.asm (3310B)


      1 ;
      2 ;
      3 ;
      4 ; This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      5 ; 
      6 ; Copyright 2007-2019 Broadcom Inc. All rights reserved.
      7 ;
      8 ;
      9 ; This is the default program for Greyhound SKUs:
     10 ;       BCM53404 Opt2
     11 ;
     12 ; To start it, use the following commands from BCM:
     13 ;
     14 ;       led load gh_cascade.hex
     15 ;       led auto on
     16 ;       led start
     17 ;
     18 ; Assume 1 LED per port for Link. And 2 bits stream per LED.
     19 ;       Link-Down = Off (b'00)
     20 ;       Link-Up = On (b'01)
     21 ;
     22 ; Totally 11 ports/LEDs will be outputed.
     23 ;
     24 ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED
     25 ; processor does not always have access to link status.  This program
     26 ; assumes link status is kept current in bit 0 of RAM byte (0xA0 + portnum).
     27 ; Generally, a program running on the main CPU must update these
     28 ; locations on link change; see linkscan callback in
     29 ; $SDK/src/appl/diag/ledproc.c.
     30 ;
     31 
     32 ;
     33 ; Constants
     34 ;
     35 NUM_PORTS   equ 11
     36 MIN_PORT_0 equ 2
     37 MAX_PORT_0 equ 2
     38 MIN_PORT_1 equ 18
     39 MAX_PORT_1 equ 24
     40 MIN_PORT_2 equ 26
     41 MAX_PORT_2 equ 28
     42 
     43 ;
     44 ; LED process
     45 ;
     46 start:
     47     ld  a, MIN_PORT_0
     48 
     49 iter_sec0:
     50     cmp a, MAX_PORT_0+1
     51     jnc  iter_sec1
     52 
     53     cmp a, MIN_PORT_0
     54     jz  iter_sec0_init
     55     jc  iter_sec0_init
     56     jmp iter_sec0_start
     57 iter_sec0_init:
     58     ld  a, MIN_PORT_0
     59     ld  b, MAX_PORT_0
     60     ld  (SEC_MAX), b
     61 iter_sec0_start:
     62     jmp iter_common
     63 
     64 iter_sec1:
     65     cmp a, MAX_PORT_1+1
     66     jnc  iter_sec2
     67 
     68     cmp a, MIN_PORT_1
     69     jz  iter_sec1_init
     70     jc  iter_sec1_init
     71     jmp iter_sec1_start
     72 iter_sec1_init:
     73     ld  a, MIN_PORT_1
     74     ld  b, MAX_PORT_1
     75     ld  (SEC_MAX), b
     76 iter_sec1_start:
     77     jmp iter_common
     78 
     79 iter_sec2:
     80     cmp a, MAX_PORT_2+1
     81     jnc  end
     82 
     83     cmp a, MIN_PORT_2
     84     jz  iter_sec2_init
     85     jc  iter_sec2_init
     86     jmp iter_sec2_start
     87 iter_sec2_init:
     88     ld  a, MIN_PORT_2
     89     ld  b, MAX_PORT_2
     90     ld  (SEC_MAX), b
     91 iter_sec2_start:
     92     jmp iter_common
     93 
     94 iter_common:
     95     port    a
     96     ld  (PORT_NUM), a
     97 
     98     call    get_link
     99 
    100     ld  a, (PORT_NUM)
    101     inc a
    102     ld b, (SEC_MAX)
    103     inc b
    104     cmp a, b
    105     jz iter_sec0
    106     jmp iter_common
    107 
    108 end:
    109     send    2*NUM_PORTS
    110 
    111 ;
    112 ; get_link
    113 ;
    114 ;  This routine finds the link status LED for a port.
    115 ;  Link info is in bit 0 of the byte read from PORTDATA[port]
    116 ;  Inputs: (PORT_NUM)
    117 ;  Outputs: Carry flag set if link is up, clear if link is down.
    118 ;  Destroys: a, b
    119 get_link:
    120     ld  b, PORTDATA
    121     add b, (PORT_NUM)
    122     ld  a, (b)
    123     tst a, 0
    124 
    125     jc led_green
    126     jmp led_black
    127 
    128 ;
    129 ; led_green
    130 ;
    131 ;  Outputs: Bits to the LED stream indicating ON
    132 ;
    133 led_green:
    134     push 0
    135     pack
    136     push 1
    137     pack
    138     ret
    139 
    140 ;
    141 ; led_black
    142 ;
    143 ;  Outputs: Bits to the LED stream indicating OFF
    144 ;
    145 led_black:
    146     push 0
    147     pack
    148     push 0
    149     pack
    150     ret
    151 
    152 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0)
    153 PORTDATA    equ 0xA0
    154 PORT_NUM    equ 0xE0
    155 SEC_MAX equ 0xE1
    156 
    157 ; Symbolic names for the bits of the port status fields
    158 RX      equ 0x0 ; received packet
    159 TX      equ 0x1 ; transmitted packet
    160 COLL    equ 0x2 ; collision indicator
    161 SPEED_C equ 0x3 ; 100 Mbps
    162 SPEED_M equ 0x4 ; 1000 Mbps
    163 DUPLEX  equ 0x5 ; half/full duplex
    164 FLOW    equ 0x6 ; flow control capable
    165 LINKUP  equ 0x7 ; link down/up status
    166 LINKEN  equ 0x8 ; link disabled/enabled status
    167 ZERO    equ 0xE ; always 0
    168 ONE     equ 0xF ; always 1