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

sdk56334.asm (4973B)


      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 the (24 GE + 4 XE/HG port) BCM56334 SDKs.
     10 ; To start it, use the following commands from BCM:
     11 ;
     12 ;       led load sdk56334.hex
     13 ;       led auto on
     14 ;       led start
     15 ;
     16 ; Assume 2 LEDs per port one for Link(Left) and one for activity(Right).
     17 ;
     18 ; There is one bit per Ethernet LED with the following colors:
     19 ;       ONE 		Black
     20 ;       ZERO        Green
     21 ;
     22 ; Each chip drives only its own LEDs and needs to write them in the order:
     23 ;       A05/L05,L06/A06,A07/L07,L08/A08,A01/L01,L02/A02,A03/L03,L04/A04
     24 ;
     25 ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED
     26 ; processor does not always have access to link status.  This program
     27 ; assumes link status is kept current in bit 0 of RAM byte (0xA0 + portnum).
     28 ; Generally, a program running on the main CPU must update these
     29 ; locations on link change; see linkscan callback in
     30 ; $SDK/src/appl/diag/ledproc.c.
     31 ;
     32 
     33 MIN_GE_PORT     EQU      2
     34 
     35 MAX_XE_PORT     EQU     29
     36 
     37 NUM_PORT        EQU     28
     38 
     39 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS
     40 ; so they will be more visible.
     41 TICKS           EQU     1
     42 SECOND_TICKS    EQU     (30*TICKS)
     43 ACT_EXT_TICKS   EQU     (SECOND_TICKS/3)
     44 TXRX_ALT_TICKS  EQU     (SECOND_TICKS/6)
     45 
     46 ;
     47 ; Main Update Routine
     48 ;
     49 ;  This routine is called once per tick.
     50 ;
     51 update:
     52         ld      a, MIN_GE_PORT
     53 
     54 up1:
     55         port    a
     56         ld      (PORT_NUM),a
     57 
     58         call    link_status     ; Left LED for this port
     59         call    activity        ; Right LED for this port
     60 
     61         ld      a,(PORT_NUM)
     62         inc     a
     63         cmp     a, MAX_XE_PORT+1
     64         jnz     up1
     65 
     66         ; Update various timers
     67 
     68         ld      b,TXRX_ALT_COUNT
     69         inc     (b)
     70         ld      a,(b)
     71         cmp     a,TXRX_ALT_TICKS
     72         jc      up2
     73         ld      (b),0
     74 up2:
     75 
     76         send    NUM_PORT*2
     77 
     78 ;
     79 ; activity
     80 ;
     81 ;  This routine calculates the activity LED for the current port.
     82 ;  It extends the activity lights using timers (new activity overrides
     83 ;  and resets the timers).
     84 ;
     85 ;  Inputs: (PORT_NUM)
     86 ;  Outputs: Two bits sent to LED stream
     87 ;
     88 
     89 activity:
     90         pushst  RX
     91         pushst  TX
     92         tor
     93         pop
     94         jnc     act1
     95 
     96         ld      b,TXRX_TIMERS     ; Start TXRX LED extension timer
     97         add     b,(PORT_NUM)
     98         ld      a,ACT_EXT_TICKS
     99         ld      (b),a
    100 
    101 act1:
    102         ld      b,TXRX_TIMERS     ; Check TXRX LED extension timer
    103         add     b,(PORT_NUM)
    104 
    105         dec     (b)
    106         jnc     act2            ; TXRX active?
    107         inc     (b)
    108 
    109         jmp     led_black       ; No activity
    110 
    111 act2:                           ; Both TX and RX active
    112         ld      b,(TXRX_ALT_COUNT)
    113         cmp     b,TXRX_ALT_TICKS/2
    114         jc      led_green       ; Fast alternation of green/amber
    115         jmp     led_black
    116 
    117 ;
    118 ; link_status
    119 ;
    120 ;  This routine calculates the link status LED for the current port.
    121 ;
    122 ;  Inputs: (PORT_NUM)
    123 ;  Outputs: Two bits sent to LED stream
    124 ;  Destroys: a, b
    125 ;
    126 
    127 link_status:
    128         ld      a,(PORT_NUM)
    129 	    call    get_link
    130         jnc     led_black
    131         jmp     led_green
    132 
    133 ;
    134 ; get_link
    135 ;
    136 ;  This routine finds the link status LED for a port.
    137 ;  Link info is in bit 0 of the byte read from PORTDATA[port]
    138 ;
    139 ;  Inputs: Port number in a
    140 ;  Outputs: Carry flag set if link is up, clear if link is down.
    141 ;  Destroys: a, b
    142 ;
    143 
    144 get_link:
    145         ld      b,PORTDATA
    146         add     b,a
    147         ld      b,(b)
    148         tst     b,0
    149         ret
    150 
    151 ;
    152 ; led_black, led_green
    153 ;
    154 ;  Inputs: None
    155 ;  Outputs: one bit  to the LED stream indicating color
    156 ;  Destroys: None
    157 ;
    158 
    159 led_black:
    160         pushst  ONE
    161         pack
    162         ret
    163 
    164 led_green:
    165         pushst  ZERO
    166         pack
    167         ret
    168 
    169 ;
    170 ; Variables (SDK software initializes LED memory from 0xa0-0xff to 0)
    171 ;
    172 
    173 TXRX_ALT_COUNT  equ     0xe0
    174 PORT_NUM        equ     0xe1
    175 TXRX_TIMERS     equ     0xe2
    176 ;
    177 ; Port data, which must be updated continually by main CPU's
    178 ; linkscan task.  See $SDK/src/appl/diag/ledproc.c for examples.
    179 ; In this program, bit 0 is assumed to contain the link up/down status.
    180 ;
    181 
    182 ;Offset 0x1e00 - 0x80
    183 ;LED scan chain assembly area
    184 
    185 ;Offset 0x1e80 - 0xa0
    186 PORTDATA        equ     0xa0    ; Size 48 + 1 + 4 bytes
    187 
    188 ;
    189 ; Symbolic names for the bits of the port status fields
    190 ;
    191 
    192 RX              equ     0x0     ; received packet
    193 TX              equ     0x1     ; transmitted packet
    194 COLL            equ     0x2     ; collision indicator
    195 SPEED_C         equ     0x3     ; 100 Mbps
    196 SPEED_M         equ     0x4     ; 1000 Mbps
    197 DUPLEX          equ     0x5     ; half/full duplex
    198 FLOW            equ     0x6     ; flow control capable
    199 LINKUP          equ     0x7     ; link down/up status
    200 LINKEN          equ     0x8     ; link disabled/enabled status
    201 ZERO            equ     0xE     ; always 0
    202 ONE             equ     0xF     ; always 1