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_sdk56063.asm (3908B)


      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 ;       BCM56063
     11 ;
     12 ; To start it, use the following commands from BCM:
     13 ;
     14 ;       led load gh_sdk56063.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 20 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 20
     36 MIN_PORT_0 equ 2
     37 MAX_PORT_0 equ 17
     38 MIN_PORT_1 equ 26
     39 MAX_PORT_1 equ 26
     40 MIN_PORT_2 equ 28
     41 MAX_PORT_2 equ 28
     42 MIN_PORT_3 equ 30
     43 MAX_PORT_3 equ 30
     44 MIN_PORT_4 equ 32
     45 MAX_PORT_4 equ 32
     46 
     47 ;
     48 ; LED process
     49 ;
     50 start:
     51     ld  a, MIN_PORT_0
     52 
     53 iter_sec0:
     54     cmp a, MAX_PORT_0+1
     55     jnc  iter_sec1
     56 
     57     cmp a, MIN_PORT_0
     58     jz  iter_sec0_init
     59     jc  iter_sec0_init
     60     jmp iter_sec0_start
     61 iter_sec0_init:
     62     ld  a, MIN_PORT_0
     63     ld  b, MAX_PORT_0
     64     ld  (SEC_MAX), b
     65 iter_sec0_start:
     66     jmp iter_common
     67 
     68 iter_sec1:
     69     cmp a, MAX_PORT_1+1
     70     jnc  iter_sec2
     71 
     72     cmp a, MIN_PORT_1
     73     jz  iter_sec1_init
     74     jc  iter_sec1_init
     75     jmp iter_sec1_start
     76 iter_sec1_init:
     77     ld  a, MIN_PORT_1
     78     ld  b, MAX_PORT_1
     79     ld  (SEC_MAX), b
     80 iter_sec1_start:
     81     jmp iter_common
     82 
     83 iter_sec2:
     84     cmp a, MAX_PORT_2+1
     85     jnc  iter_sec3
     86 
     87     cmp a, MIN_PORT_2
     88     jz  iter_sec2_init
     89     jc  iter_sec2_init
     90     jmp iter_sec2_start
     91 iter_sec2_init:
     92     ld  a, MIN_PORT_2
     93     ld  b, MAX_PORT_2
     94     ld  (SEC_MAX), b
     95 iter_sec2_start:
     96     jmp iter_common
     97 
     98 iter_sec3:
     99     cmp a, MAX_PORT_3+1
    100     jnc  iter_sec4
    101 
    102     cmp a, MIN_PORT_3
    103     jz  iter_sec3_init
    104     jc  iter_sec3_init
    105     jmp iter_sec3_start
    106 iter_sec3_init:
    107     ld  a, MIN_PORT_3
    108     ld  b, MAX_PORT_3
    109     ld  (SEC_MAX), b
    110 iter_sec3_start:
    111     jmp iter_common
    112 
    113 iter_sec4:
    114     cmp a, MAX_PORT_4+1
    115     jnc  end
    116 
    117     cmp a, MIN_PORT_4
    118     jz  iter_sec4_init
    119     jc  iter_sec4_init
    120     jmp iter_sec4_start
    121 iter_sec4_init:
    122     ld  a, MIN_PORT_4
    123     ld  b, MAX_PORT_4
    124     ld  (SEC_MAX), b
    125 iter_sec4_start:
    126     jmp iter_common
    127 
    128 iter_common:
    129     port    a
    130     ld  (PORT_NUM), a
    131 
    132     call    get_link
    133 
    134     ld  a, (PORT_NUM)
    135     inc a
    136     ld b, (SEC_MAX)
    137     inc b
    138     cmp a, b
    139     jz iter_sec0
    140     jmp iter_common
    141 
    142 end:
    143 	send    2*NUM_PORTS
    144 
    145 ;
    146 ; get_link
    147 ;
    148 ;  This routine finds the link status LED for a port.
    149 ;  Link info is in bit 0 of the byte read from PORTDATA[port]
    150 ;  Inputs: (PORT_NUM)
    151 ;  Outputs: Carry flag set if link is up, clear if link is down.
    152 ;  Destroys: a, b
    153 get_link:
    154     ld  b, PORTDATA
    155     add b, (PORT_NUM)
    156     ld  a, (b)
    157     tst a, 0
    158 
    159     jc led_green
    160     jmp led_black
    161 
    162 ;
    163 ; led_green
    164 ;
    165 ;  Outputs: Bits to the LED stream indicating ON
    166 ;
    167 led_green:
    168     push 0
    169     pack
    170     push 1
    171     pack
    172     ret
    173 
    174 ;
    175 ; led_black
    176 ;
    177 ;  Outputs: Bits to the LED stream indicating OFF
    178 ;
    179 led_black:
    180     push 0
    181     pack
    182     push 0
    183     pack
    184     ret
    185 
    186 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0)
    187 PORTDATA    equ 0xA0
    188 PORT_NUM    equ 0xE0
    189 SEC_MAX equ 0xE1
    190 
    191 ; Symbolic names for the bits of the port status fields
    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