bcm953314p24ref.asm (6356B)
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 port) BCM953314P24REF 10 ; reference board. 11 ; To start it, use the following commands from BCM: 12 ; 13 ; led load bcm953314p24ref.hex 14 ; led auto on 15 ; led start 16 ; 17 ; The are 2 LEDs per FE port one for Link(Left) and one for activity(Right). 18 ; 19 ; There are two bits per fast Ethernet LED with the following colors: 20 ; ZERO, ZERO Black 21 ; ZERO, ONE Amber 22 ; ONE, ZERO Green 23 ; 24 ; Each chip drives only its own LEDs and needs to write them in the order: 25 ; A01, L01, A02, L02, ..., A24, L24 26 ; 27 ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED 28 ; processor does not always have access to link status. This program 29 ; assumes link status is kept current in bit 0 of RAM byte (0xa0 + portnum). 30 ; Generally, a program running on the main CPU must update these 31 ; locations on link change; see linkscan callback in 32 ; $SDK/src/appl/diag/ledproc.c. 33 ; 34 ; Current implementation: 35 ; 36 ; L01 reflects port 1 link status: 37 ; Black: no link 38 ; Amber: 10 Mb/s 39 ; Green: 100 Mb/s 40 ; Alternating green/amber: 1000 Mb/s 41 ; Very brief flashes of black at 1 Hz: half duplex 42 ; Longer periods of black: collisions in progress 43 ; 44 ; A01 reflects port 1 activity (even if port is down) 45 ; Black: idle 46 ; Green: RX (pulse extended to 1/3 sec) 47 ; Amber: TX (pulse extended to 1/3 sec, takes precedence over RX) 48 ; Green/Amber alternating at 6 Hz: both RX and TX 49 ; 50 51 TICKS EQU 1 52 SECOND_TICKS EQU (30*TICKS) 53 54 MIN_FE_PORT EQU 1 55 MAX_FE_PORT EQU 24 56 NUM_FE_PORT EQU 24 57 58 NUM_PORT EQU 24 59 60 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS 61 ; so they will be more visible. 62 ACT_EXT_TICKS EQU (SECOND_TICKS/20) 63 ; GIG_ALT_TICKS EQU (SECOND_TICKS/2) 64 ; HD_OFF_TICKS EQU (SECOND_TICKS/20) 65 ; HD_ON_TICKS EQU (SECOND_TICKS-HD_ON_TICKS) 66 TXRX_ALT_TICKS EQU (SECOND_TICKS/8) 67 68 ; 69 ; Main Update Routine 70 ; 71 ; This routine is called once per tick. 72 ; 73 74 update: 75 ld a, MIN_FE_PORT 76 77 up1: 78 port a 79 ld (PORT_NUM),a 80 81 call link_status ; Left LED for this port 82 call activity ; Right LED for this port 83 84 ld a,(PORT_NUM) 85 inc a 86 cmp a, MAX_FE_PORT+1 87 jnz up1 88 89 ; Update various timers 90 91 ld b,TXRX_ALT_COUNT 92 inc (b) 93 ld a,(b) 94 cmp a,TXRX_ALT_TICKS 95 jc up2 96 ld (b),0 97 up2: 98 99 send 96 ; 2 * 2 * 24 100 101 ; 102 ; activity 103 ; 104 ; This routine calculates the activity LED for the current port. 105 ; It extends the activity lights using timers (new activity overrides 106 ; and resets the timers). 107 ; 108 ; Inputs: (PORT_NUM) 109 ; Outputs: Two bits sent to LED stream 110 ; 111 112 activity: 113 pushst RX 114 pushst TX 115 tor 116 pop 117 jnc act1 118 119 ld b,TXRX_TIMERS ; Start TXRX LED extension timer 120 add b,(PORT_NUM) 121 ld a,ACT_EXT_TICKS 122 ld (b),a 123 124 act1: 125 ld b,TXRX_TIMERS ; Check TXRX LED extension timer 126 add b,(PORT_NUM) 127 128 dec (b) 129 jnc act2 ; TXRX active? 130 inc (b) 131 132 ld a,(PORT_NUM) 133 call get_link 134 ;pushst LINKUP 135 ;pop 136 jnc led_black 137 jmp led_amber ; No activity 138 139 act2: ; Both TX and RX active 140 ld b,(TXRX_ALT_COUNT) 141 cmp b,TXRX_ALT_TICKS/2 142 jc led_black ; Fast alternation of green/amber 143 jmp led_amber 144 145 ; 146 ; link_status 147 ; 148 ; This routine calculates the link status LED for the current port. 149 ; 150 ; Inputs: (PORT_NUM) 151 ; Outputs: Two bits sent to LED stream 152 ; Destroys: a, b 153 ; 154 155 link_status: 156 ;pushst LINKUP 157 ;pop 158 ld a,(PORT_NUM) 159 call get_link 160 jnc led_black 161 162 pushst SPEED_C ; Check for 100Mb speed 163 pop 164 jc led_amber 165 166 pushst SPEED_M ; Check for 10Mb (i.e. not 100 or 1000) 167 pop 168 jnc led_black 169 170 jmp led_green 171 172 ; 173 ; get_link 174 ; 175 ; This routine finds the link status LED for a port. 176 ; Link info is in bit 0 of the byte read from PORTDATA[port] 177 ; 178 ; Inputs: Port number in a 179 ; Outputs: Carry flag set if link is up, clear if link is down. 180 ; Destroys: a, b 181 ; 182 183 get_link: 184 ld b,PORTDATA 185 add b,a 186 ld b,(b) 187 tst b,0 188 ret 189 190 ; 191 ; led_black, led_amber, led_green 192 ; 193 ; Inputs: None 194 ; Outputs: Two bits to the LED stream indicating color 195 ; Destroys: None 196 ; 197 198 led_amber: 199 pushst ZERO 200 pack 201 pushst ONE 202 pack 203 ret 204 205 led_green: 206 pushst ONE 207 pack 208 pushst ZERO 209 pack 210 ret 211 212 led_black: 213 pushst ONE 214 pack 215 pushst ONE 216 pack 217 ret 218 219 ; 220 ; Variables (SDK software initializes LED memory from 0xa0-0xff to 0) 221 ; 222 223 TXRX_ALT_COUNT equ 0xe0 224 HD_COUNT equ 0xe1 225 GIG_ALT_COUNT equ 0xe2 226 PORT_NUM equ 0xe3 227 228 ; 229 ; Port data, which must be updated continually by main CPU's 230 ; linkscan task. See $SDK/src/appl/diag/ledproc.c for examples. 231 ; In this program, bit 0 is assumed to contain the link up/down status. 232 ; 233 234 PORTDATA equ 0xa0 ; Size 24 + 6? bytes 235 236 ; 237 ; LED extension timers 238 ; 239 240 TXRX_TIMERS equ 0xe4 ; NUM_PORT bytes C0 - DF 241 ;TX_TIMERS equ 0xe0 ; NUM_PORT bytes E0 - FF 242 243 ; 244 ; Symbolic names for the bits of the port status fields 245 ; 246 247 RX equ 0x0 ; received packet 248 TX equ 0x1 ; transmitted packet 249 COLL equ 0x2 ; collision indicator 250 SPEED_C equ 0x3 ; 100 Mbps 251 SPEED_M equ 0x4 ; 1000 Mbps 252 DUPLEX equ 0x5 ; half/full duplex 253 FLOW equ 0x6 ; flow control capable 254 LINKUP equ 0x7 ; link down/up status 255 LINKEN equ 0x8 ; link disabled/enabled status 256 ZERO equ 0xE ; always 0 257 ONE equ 0xF ; always 1