felix48.asm (9294B)
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 (48+4+2 port) BCM956102P48 10 ; To start it, use the following commands from BCM: 11 ; 12 ; *:led load felix48.hex 13 ; *:led auto on 14 ; *:led start 15 ; 16 ; The are 2 Multi color LEDs per FE port one for Link(Left) and one 17 ; for activity(Right). 18 ; The are 2 signle color LEDs per GE port one for Link(Left) and one 19 ; for activity(Right). 20 ; 21 ; There are two bits per FE LED with the following colors: 22 ; ZERO, ZERO Black 23 ; ZERO, ONE Amber 24 ; ONE, ZERO Green 25 ; 26 ; There is one bits per GE LED with the following colors: 27 ; ZERO Green 28 ; ONE Black 29 ; 30 ; There are no LEDS for HG/10G ports 31 ; 32 ; Each chip drives only its own LEDs and needs to write them in the order: 33 ; A01, L01, A02, L02, ..., A24, L24, L25, A25, L26, A26, DC, DC, DC, DC 34 ; 35 ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED 36 ; processor does not always have access to link status. This program 37 ; assumes link status is kept current in bit 0 of RAM byte (0x80 + portnum). 38 ; Generally, a program running on the main CPU must update these 39 ; locations on link change; see linkscan callback in 40 ; $SDK/src/appl/diag/ledproc.c. 41 ; 42 ; Current implementation: 43 ; 44 ; L01 reflects port 1 link status: 45 ; Black: no link 46 ; Amber: 10 Mb/s 47 ; Green: 100 Mb/s 48 ; Alternating green/amber: 1000 Mb/s 49 ; Very brief flashes of black at 1 Hz: half duplex 50 ; Longer periods of black: collisions in progress 51 ; 52 ; A01 reflects port 1 activity (even if port is down) 53 ; Black: idle 54 ; Green: RX (pulse extended to 1/3 sec) 55 ; Amber: TX (pulse extended to 1/3 sec, takes precedence over RX) 56 ; Green/Amber alternating at 6 Hz: both RX and TX 57 ; 58 ; L25-L26 reflects GE link status: 59 ; Black: no link 60 ; Green: link 61 ; A25-A26 reflects port 25-26 activity 62 ; Black: idle 63 ; Green: TX/RX Activity 64 ; Note: 65 ; To provide consistent behavior, the gigabit LED patterns match 66 ; those in sdk5605.asm. 67 ; 68 69 TICKS EQU 1 70 SECOND_TICKS EQU (30*TICKS) 71 72 MIN_FE_PORT EQU 0 73 MAX_FE_PORT EQU 23 74 NUM_FE_PORT EQU 24 75 76 MIN_GE_PORT EQU 24 77 MAX_GE_PORT EQU 25 78 NUM_GE_PORT EQU 2 79 80 MIN_HG_PORT EQU 26 81 MAX_HG_PORT EQU 27 82 NUM_HG_PORT EQU 2 83 NUM_ALL_PORT EQU 28 84 85 MIN_PORT EQU 0 86 MAX_PORT EQU 27 87 NUM_PORT EQU 28 88 89 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS 90 ; so they will be more visible. 91 92 ACT_EXT_TICKS EQU (SECOND_TICKS/3) 93 FE_ALT_TICKS EQU (SECOND_TICKS/2) 94 HD_OFF_TICKS EQU (SECOND_TICKS/20) 95 HD_ON_TICKS EQU (SECOND_TICKS-HD_ON_TICKS) 96 TXRX_ALT_TICKS EQU (SECOND_TICKS/6) 97 98 ; 99 ; Main Update Routine 100 ; 101 ; This routine is called once per tick. 102 ; 103 104 update: 105 sub a,a ; ld a,MIN_FE_PORT (but only one instr) 106 107 up1: 108 port a 109 ld (PORT_NUM),a 110 111 call activity ; Right LED for this port 112 call link_status ; Left LED for this port 113 114 ld a,(PORT_NUM) 115 inc a 116 cmp a,NUM_FE_PORT 117 jnz up1 118 119 ; Put out 4 bits for GE ports 120 up_ge1: 121 ld a, MIN_GE_PORT 122 port a 123 ld (PORT_NUM),a 124 call do_ge_port 125 126 ld a, MAX_GE_PORT 127 port a 128 ld (PORT_NUM),a 129 call do_ge_port 130 131 pushst ZERO 132 pack 133 pushst ZERO 134 pack 135 pushst ZERO 136 pack 137 pushst ZERO 138 pack 139 140 ; Update various timers 141 142 ld b,FE_ALT_COUNT 143 inc (b) 144 ld a,(b) 145 cmp a,FE_ALT_TICKS 146 jc up2 147 ld (b),0 148 up2: 149 150 ld b,HD_COUNT 151 inc (b) 152 ld a,(b) 153 cmp a,HD_ON_TICKS+HD_OFF_TICKS 154 jc up3 155 ld (b),0 156 up3: 157 158 ld b,TXRX_ALT_COUNT 159 inc (b) 160 ld a,(b) 161 cmp a,TXRX_ALT_TICKS 162 jc up4 163 ld (b),0 164 up4: 165 166 send 104 ; 2 * 2 * 26 167 168 do_ge_port: 169 call get_link 170 jnc no_link_ge 171 172 pushst ZERO 173 pack 174 jmp chk_act_ge 175 no_link_ge: 176 pushst ONE 177 pack 178 chk_act_ge: 179 pushst RX 180 pop 181 jnc act_ge_tx 182 183 pushst ZERO 184 pack 185 ret 186 act_ge_tx: 187 pushst TX 188 pop 189 jnc no_act_ge 190 191 pushst ZERO 192 pack 193 ret 194 195 no_act_ge: 196 pushst ONE 197 pack 198 ret 199 200 ; 201 ; activity 202 ; 203 ; This routine calculates the activity LED for the current port. 204 ; It extends the activity lights using timers (new activity overrides 205 ; and resets the timers). 206 ; 207 ; Inputs: (PORT_NUM) 208 ; Outputs: Two bits sent to LED stream 209 ; 210 211 activity: 212 pushst RX 213 pop 214 jnc act1 215 216 ld b,RX_TIMERS ; Start RX LED extension timer 217 add b,(PORT_NUM) 218 ld a,ACT_EXT_TICKS 219 ld (b),a 220 221 act1: 222 pushst TX 223 pop 224 jnc act2 225 226 ld b,TX_TIMERS ; Start TX LED extension timer 227 add b,(PORT_NUM) 228 ld a,ACT_EXT_TICKS 229 ld (b),a 230 231 act2: 232 ld b,TX_TIMERS ; Check TX LED extension timer 233 add b,(PORT_NUM) 234 235 dec (b) 236 jnc act3 ; TX active? 237 inc (b) 238 239 ld b,RX_TIMERS ; Check RX LED extension timer 240 add b,(PORT_NUM) 241 242 dec (b) ; Extend LED green if only RX active 243 jnc led_green 244 inc (b) 245 246 jmp led_black ; No activity 247 248 act3: ; TX is active, see if RX also active 249 ld b,RX_TIMERS 250 add b,(PORT_NUM) 251 252 dec (b) ; RX also active? 253 jnc act4 254 inc (b) 255 256 jmp led_amber ; Only TX active 257 258 act4: ; Both TX and RX active 259 ld b,(TXRX_ALT_COUNT) 260 cmp b,TXRX_ALT_TICKS/2 261 jc led_amber ; Fast alternation of green/amber 262 jmp led_green 263 264 265 ; 266 ; link_status 267 ; 268 ; This routine calculates the link status LED for the current port. 269 ; 270 ; Inputs: (PORT_NUM) 271 ; Outputs: Two bits sent to LED stream 272 ; Destroys: a, b 273 ; 274 275 link_status: 276 pushst DUPLEX ; Skip blink code if full duplex 277 pop 278 jc ls1 279 280 pushst COLL ; Check for collision in half duplex 281 pop 282 jc led_black 283 284 ld a,(HD_COUNT) ; Provide blink for half duplex 285 cmp a,HD_OFF_TICKS 286 jc led_black 287 288 ls1: 289 ld a,(PORT_NUM) ; Check for link down 290 call get_link 291 jnc led_black 292 293 pushst SPEED_C ; Check for 100Mb speed 294 pop 295 jc led_green 296 297 pushst SPEED_M ; Check for 10Mb (i.e. not 100 or 1000) 298 pop 299 jnc led_amber 300 301 ld a,(FE_ALT_COUNT) 302 cmp a,FE_ALT_TICKS/2 303 jc led_amber 304 305 jmp led_green 306 307 ; 308 ; get_link 309 ; 310 ; This routine finds the link status LED for a port. 311 ; Link info is in bit 0 of the byte read from PORTDATA[port] 312 ; 313 ; Inputs: Port number in a 314 ; Outputs: Carry flag set if link is up, clear if link is down. 315 ; Destroys: a, b 316 ; 317 318 get_link: 319 ld b,PORTDATA 320 add b,a 321 ld b,(b) 322 tst b,0 323 ret 324 325 ; 326 ; led_black, led_amber, led_green 327 ; 328 ; Inputs: None 329 ; Outputs: Two bits to the LED stream indicating color 330 ; Destroys: None 331 ; 332 333 led_black: 334 pushst ZERO 335 pack 336 pushst ZERO 337 pack 338 ret 339 340 led_amber: 341 pushst ZERO 342 pack 343 pushst ONE 344 pack 345 ret 346 347 led_green: 348 pushst ONE 349 pack 350 pushst ZERO 351 pack 352 ret 353 354 ; 355 ; Variables (SDK software initializes LED memory from 0x80-0xff to 0) 356 ; 357 358 TXRX_ALT_COUNT equ 0xe0 359 HD_COUNT equ 0xe1 360 FE_ALT_COUNT equ 0xe2 361 PORT_NUM equ 0xe3 362 363 ; 364 ; Port data, which must be updated continually by main CPU's 365 ; linkscan task. See $SDK/src/appl/diag/ledproc.c for examples. 366 ; In this program, bit 0 is assumed to contain the link up/down status. 367 ; 368 369 PORTDATA equ 0x80 ; Size 24 + 4? bytes 370 371 ; 372 ; LED extension timers 373 ; 374 375 RX_TIMERS equ 0xa0+0 ; NUM_PORT bytes 376 TX_TIMERS equ 0xa0+NUM_PORT ; NUM_PORT bytes 377 378 ; 379 ; Symbolic names for the bits of the port status fields 380 ; 381 382 RX equ 0x0 ; received packet 383 TX equ 0x1 ; transmitted packet 384 COLL equ 0x2 ; collision indicator 385 SPEED_C equ 0x3 ; 100 Mbps 386 SPEED_M equ 0x4 ; 1000 Mbps 387 DUPLEX equ 0x5 ; half/full duplex 388 FLOW equ 0x6 ; flow control capable 389 LINKUP equ 0x7 ; link down/up status 390 LINKEN equ 0x8 ; link disabled/enabled status 391 ZERO equ 0xE ; always 0 392 ONE equ 0xF ; always 1