sdk5650.asm (8694B)
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 5650 SDK (BCM95650K4S) 10 ; 11 ; To start it, use the following commands from BCM: 12 ; 13 ; 0:led load sdk5650.hex 14 ; *:led start 15 ; 16 ; 17 ; The BCM5650 SDK has 14 columns of 4 LEDs each, as shown below: 18 ; 19 ; L01 L03 L05 L07 L09 L11 L13 L15 L17 L19 L21 L23 LG1 LG3 20 ; A01 A03 A05 A07 A09 A11 A13 A15 A17 A19 A21 A23 AG1 LG3 21 ; L02 L04 L06 L08 L10 L12 L14 L16 L18 L20 L22 L24 LG2 LG4 22 ; A02 A04 A06 A08 A10 A12 A14 A16 A18 A20 A22 A24 AG2 LG4 23 ; 24 ; There are two bits per LED with the following colors: 25 ; ZERO, ZERO Black 26 ; ZERO, ONE Amber 27 ; ONE, ZERO Green 28 ; 29 ; The bits are shifted out in the following order: 30 ; A01, L01, ..., A24, L24, AG1, LG1, ..., AG4, LG4 31 ; 32 ; Current implementation: 33 ; 34 ; L01 reflects port 1 link status 35 ; A01 reflects port 1 activity 36 ; 37 ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED 38 ; processor does not actually have access to link status. This program 39 ; assumes link status is kept current in bit 0 of RAM byte (0x80 + portnum). 40 ; Generally, a program running on the main CPU must update these 41 ; locations on link change; see linkscan callback in 42 ; $SDK/src/appl/diag/ledproc.c. 43 ; 44 ; Current implementation: 45 ; 46 ; L01 reflects port 1 link status: 47 ; Black: no link 48 ; Amber: 10 Mb/s 49 ; Green: 100 Mb/s 50 ; Alternating green/amber: 1000 Mb/s 51 ; Very brief flashes of black at 1 Hz: half duplex 52 ; Longer periods of black: collisions in progress 53 ; 54 ; A01 reflects port 1 activity (even if port is down) 55 ; Black: idle 56 ; Green: RX (pulse extended to 1/3 sec) 57 ; Amber: TX (pulse extended to 1/3 sec, takes precedence over RX) 58 ; Green/Amber alternating at 6 Hz: both RX and TX 59 ; 60 61 MIN_FE_PORT EQU 0 62 MAX_FE_PORT EQU 23 63 NUM_FE_PORT EQU 24 64 65 MIN_GE_PORT EQU 24 66 MAX_GE_PORT EQU 27 67 NUM_GE_PORT EQU 4 68 69 MIN_PORT EQU 0 70 MAX_PORT EQU 27 71 NUM_PORT EQU 28 72 73 PACK_SRC EQU 0 74 PACK_DST EQU 128 75 PACK_BITS EQU (NUM_PORT*4) 76 PACK_FE_NUM EQU (NUM_FE_PORT/2) 77 PACK_NUM EQU (PACK_BITS/8) 78 79 CACHE_BLACK EQU 0 80 CACHE_AMBER EQU 1 81 CACHE_GREEN EQU 2 82 83 TICKS EQU 1 84 SECOND_TICKS EQU (30*TICKS) 85 86 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS 87 ; so they will be more visible. 88 89 ACT_EXT_TICKS EQU (SECOND_TICKS/3) 90 GIG_ALT_TICKS EQU (SECOND_TICKS/2) 91 HD_OFF_TICKS EQU (SECOND_TICKS/20) 92 HD_ON_TICKS EQU (SECOND_TICKS-HD_ON_TICKS) 93 TXRX_ALT_TICKS EQU (SECOND_TICKS/6) 94 95 ; 96 ; Main Update Routine 97 ; 98 ; This routine is called once per tick. 99 ; 100 101 update: 102 sub a,a ; ld a,MIN_FE_PORT (but only one instr) 103 104 up1: 105 port a 106 ld (PORT_NUM),a 107 108 call activity ; Lower LED for this port 109 call link_status ; Upper LED for this port 110 111 ; Copy from cache to pack location 112 ld a,(ACT_CACHE) 113 call uncache 114 ld a,(LINK_CACHE) 115 call uncache 116 117 ld a,(PORT_NUM) 118 inc a 119 cmp a,NUM_PORT 120 jnz up1 121 122 ; Update various timers 123 124 ld b,GIG_ALT_COUNT 125 inc (b) 126 ld a,(b) 127 cmp a,GIG_ALT_TICKS 128 jc up2 129 ld (b),0 130 up2: 131 132 ld b,HD_COUNT 133 inc (b) 134 ld a,(b) 135 cmp a,HD_ON_TICKS+HD_OFF_TICKS 136 jc up3 137 ld (b),0 138 up3: 139 140 ld b,TXRX_ALT_COUNT 141 inc (b) 142 ld a,(b) 143 cmp a,TXRX_ALT_TICKS 144 jc up4 145 ld (b),0 146 up4: 147 ; 148 ; This bit is a workaround for a bug in the 5665 LED processor. 149 ; 150 ; The pack instruction should put the data into data mem at 0x80. 151 ; However, the internal register to store this address is only 7 bits. 152 ; So the data is packed starting at address 0. 153 ; This leads to two caveats: 154 ; 155 ; 1) Port 0 data _MUST_ be consumed before the first pack instruction. 156 ; 157 ; 2) The output data must be moved from location 0 to location 128. 158 ; 159 ; 160 161 162 sub b,b ; ld b,PACK_SRC (but only one instr) 163 164 packflip: 165 ld a,(b) 166 ror a 167 ror a 168 ror a 169 ror a 170 and a,0xf 171 ld (PACKFLIP_CACHE),a 172 ld a,(b) 173 rol a 174 rol a 175 rol a 176 rol a 177 and a,0xf0 178 or a,(PACKFLIP_CACHE) 179 ld (b),a 180 181 inc b 182 cmp b,PACK_FE_NUM 183 jnz packflip 184 185 sub b,b ; ld b,PACK_SRC (but only one instr) 186 ld a,PACK_DST 187 packmove: 188 ld (a),(b) 189 inc a 190 inc b 191 cmp b,PACK_NUM 192 jnz packmove 193 194 send PACK_BITS 195 196 ; 197 ; activity 198 ; 199 ; This routine calculates the activity LED for the current port. 200 ; It extends the activity lights using timers (new activity overrides 201 ; and resets the timers). 202 ; 203 ; Inputs: (PORT_NUM) 204 ; Outputs: Two bits sent to LED stream 205 ; 206 207 activity: 208 pushst RX 209 pop 210 jnc act1 211 212 ld b,RX_TIMERS ; Start RX LED extension timer 213 add b,(PORT_NUM) 214 ld a,ACT_EXT_TICKS 215 ld (b),a 216 217 act1: 218 pushst TX 219 pop 220 jnc act2 221 222 ld b,TX_TIMERS ; Start TX LED extension timer 223 add b,(PORT_NUM) 224 ld a,ACT_EXT_TICKS 225 ld (b),a 226 227 act2: 228 ld b,TX_TIMERS ; Check TX LED extension timer 229 add b,(PORT_NUM) 230 231 dec (b) 232 jnc act3 ; TX active? 233 inc (b) 234 235 ld b,RX_TIMERS ; Check RX LED extension timer 236 add b,(PORT_NUM) 237 238 dec (b) ; Extend LED green if only RX active 239 ld a,ACT_CACHE 240 jnc led_green 241 inc (b) 242 243 jmp led_black ; No activity 244 245 act3: ; TX is active, see if RX also active 246 ld b,RX_TIMERS 247 add b,(PORT_NUM) 248 249 dec (b) ; RX also active? 250 jnc act4 251 inc (b) 252 253 ld a,ACT_CACHE 254 jmp led_amber ; Only TX active 255 256 act4: ; Both TX and RX active 257 ld b,(TXRX_ALT_COUNT) 258 cmp b,TXRX_ALT_TICKS/2 259 ld a,ACT_CACHE 260 jc led_amber ; Fast alternation of green/amber 261 jmp led_green 262 263 ; 264 ; link_status 265 ; 266 ; This routine calculates the link status LED for the current port. 267 ; 268 ; Inputs: (PORT_NUM) 269 ; Outputs: Two bits sent to LED stream 270 ; Destroys: a, b 271 ; 272 273 link_status: 274 pushst DUPLEX ; Skip blink code if full duplex 275 pop 276 jc ls1 277 278 ld a,(HD_COUNT) ; Provide blink for half duplex 279 cmp a,HD_OFF_TICKS 280 ld a,LINK_CACHE ; Cache address for led setting 281 jc led_black 282 283 ls1: 284 ld a,(PORT_NUM) ; Check for link down 285 call get_link 286 ld a,LINK_CACHE ; Cache address for led setting 287 jnc led_black 288 289 pushst COLL ; Check for collision 290 pop 291 jc 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,(GIG_ALT_COUNT) 302 cmp a,GIG_ALT_TICKS/2 303 ld a,LINK_CACHE ; Cache address for led setting 304 jc led_amber 305 306 jmp led_green 307 308 ; 309 ; get_link 310 ; 311 ; This routine finds the link status LED for a port. 312 ; Link info is in bit 0 of the byte read from PORTDATA[port] 313 ; 314 ; Inputs: Port number in a 315 ; Outputs: Carry flag set if link is up, clear if link is down. 316 ; Destroys: a, b 317 ; 318 319 get_link: 320 ld b,PORTDATA 321 add b,a 322 ld b,(b) 323 tst b,0 324 ret 325 326 ; 327 ; led_black, led_amber, led_green 328 ; 329 ; Inputs: Cache address in a 330 ; Outputs: Two bits to the LED stream indicating color 331 ; Destroys: None 332 ; 333 334 led_black: 335 ld (a),CACHE_BLACK 336 ret 337 338 led_amber: 339 ld (a),CACHE_AMBER 340 ret 341 342 led_green: 343 ld (a),CACHE_GREEN 344 ret 345 346 347 348 ; uncache 349 ; 350 ; Inputs: LED bit pair in a 351 ; Outputs: Two bits to the LED stream indicating color 352 ; Destroys: None 353 ; 354 355 uncache: 356 cmp a,CACHE_GREEN 357 jnz first_zero 358 pushst ONE 359 pack 360 jmp second_bit 361 first_zero: 362 pushst ZERO 363 pack 364 second_bit: 365 cmp a,CACHE_AMBER 366 jnz second_zero 367 pushst ONE 368 pack 369 ret 370 second_zero: 371 pushst ZERO 372 pack 373 ret 374 375 376 ; Variables (SDK software initializes LED memory from 0x80-0xff to 0) 377 ; 378 379 TXRX_ALT_COUNT equ 0xff 380 HD_COUNT equ 0xfe 381 GIG_ALT_COUNT equ 0xfd 382 PORT_NUM equ 0xfc 383 LINK_CACHE equ 0xfb 384 ACT_CACHE equ 0xfa 385 PACKFLIP_CACHE equ 0xf9 386 387 ; 388 ; Port data, which must be updated continually by main CPU's 389 ; linkscan task. See $SDK/src/appl/diag/ledproc.c for examples. 390 ; In this program, bit 0 is assumed to contain the link up/down status. 391 ; 392 393 PORTDATA equ 0xa0 ; Size 28 bytes 394 395 ; 396 ; LED extension timers 397 ; 398 399 RX_TIMERS equ 0xc0+0 ; NUM_PORT bytes 400 TX_TIMERS equ 0xc0+NUM_PORT ; NUM_PORT bytes 401 402 ; 403 ; Symbolic names for the bits of the port status fields 404 ; 405 406 RX equ 0x0 ; received packet 407 TX equ 0x1 ; transmitted packet 408 COLL equ 0x2 ; collision indicator 409 SPEED_C equ 0x3 ; 100 Mbps 410 SPEED_M equ 0x4 ; 1000 Mbps 411 DUPLEX equ 0x5 ; half/full duplex 412 FLOW equ 0x6 ; flow control capable 413 LINKUP equ 0x7 ; link down/up status 414 LINKEN equ 0x8 ; link disabled/enabled status 415 ZERO equ 0xE ; always 0 416 ONE equ 0xF ; always 1