magnum_sdk.asm (6902B)
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 Magnum program for the 5650 reference board (BCM95650R24) 10 ; 11 ; To start it, use the following commands from BCM: 12 ; 13 ; 0:led load tuc24_ref.hex 14 ; *:led start 15 ; 16 ; 17 ; The BCM5650 reference board has 12 columns of 4 LEDs each, as shown below: 18 ; 19 ; L02 L04 L06 L08 L10 L12 L14 L16 L18 L20 L22 L24 L26 L28 20 ; A02 A04 A06 A08 A10 A12 A14 A16 A18 A20 A22 A24 A26 A28 21 ; L01 L03 L05 L07 L09 L11 L13 L15 L17 L19 L21 L23 L25 L27 22 ; A01 A03 A05 A07 A09 A11 A13 A15 A17 A19 A21 A23 A25 A27 23 ; 24 ; For the FE ports, there are two bits per LED with the following colors: 25 ; ZERO, ZERO Black 26 ; ZERO, ONE Amber 27 ; ONE, ZERO Green 28 ; 29 ; 30 ; The bits are shifted out in the following order: 31 ; A02, L02, A01, L01,..., A28, L28, A27, L27 32 ; 33 ; Current implementation: 34 ; 35 ; L01 reflects port 1 link status 36 ; A01 reflects port 1 activity 37 ; 38 ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED 39 ; processor does not actually have access to link status. This program 40 ; assumes link status is kept current in bit 0 of RAM byte (0xC0 + portnum). 41 ; Generally, a program running on the main CPU must update these 42 ; locations on link change; see linkscan callback in 43 ; $SDK/src/appl/diag/ledproc.c. 44 ; 45 ; Current implementation: 46 ; 47 ; L01 reflects port 1 link status: 48 ; Black: no link 49 ; Amber: 10 Mb/s 50 ; Green: 100 Mb/s 51 ; Alternating green/amber: 1000 Mb/s 52 ; Very brief flashes of black at 1 Hz: half duplex 53 ; Longer periods of black: collisions in progress 54 ; 55 ; A01 reflects port 1 activity (even if port is down) 56 ; Black: idle 57 ; Green: RX (pulse extended to 1/3 sec) 58 ; Amber: TX (pulse extended to 1/3 sec, takes precedence over RX) 59 ; Green/Amber alternating at 6 Hz: both RX and TX 60 ; 61 ; 62 ; This program is adapted from the tuc24_ref.asm program. Many of the 63 ; obscure workarounds for the Tucana LED proc bug have been removed. 64 ; 65 66 MIN_FE_PORT EQU 0 67 MAX_FE_PORT EQU 23 68 NUM_FE_PORT EQU 24 69 70 MIN_GE_PORT EQU 24 71 MAX_GE_PORT EQU 27 72 NUM_GE_PORT EQU 4 73 74 MIN_PORT EQU 0 75 MAX_PORT EQU 27 76 NUM_PORT EQU 28 77 78 PACK_BITS EQU ((NUM_FE_PORT*4) + (NUM_GE_PORT*4)) 79 PACK_NUM EQU (PACK_BITS/8) 80 81 TICKS EQU 1 82 SECOND_TICKS EQU (30*TICKS) 83 84 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS 85 ; so they will be more visible. 86 87 ACT_EXT_TICKS EQU (SECOND_TICKS/3) 88 GIG_ALT_TICKS EQU (SECOND_TICKS/2) 89 HD_OFF_TICKS EQU (SECOND_TICKS/20) 90 HD_ON_TICKS EQU (SECOND_TICKS-HD_ON_TICKS) 91 TXRX_ALT_TICKS EQU (SECOND_TICKS/6) 92 93 ; 94 ; Main Update Routine 95 ; 96 ; This routine is called once per tick. 97 ; 98 99 update: 100 sub a,a ; ld a,MIN_FE_PORT (but only one instr) 101 102 up1: 103 ld (PORT_NUM_CACHE),a; Store linear port number 104 cmp a,MIN_GE_PORT 105 jnc st_port 106 107 xor a,0x1 ; For FE, do ports 1,0,3,2,etc. 108 st_port: 109 ld (PORT_NUM),a ; Port for subroutines 110 111 port a 112 call activity ; Lower LED for this port 113 call link_status ; Upper LED for this port 114 ld a,(PORT_NUM_CACHE); Retrieve linear port number 115 inc a 116 cmp a,NUM_PORT 117 jnz up1 118 119 ; Update various timers 120 121 ld b,GIG_ALT_COUNT 122 inc (b) 123 ld a,(b) 124 cmp a,GIG_ALT_TICKS 125 jc up2 126 ld (b),0 127 up2: 128 129 ld b,HD_COUNT 130 inc (b) 131 ld a,(b) 132 cmp a,HD_ON_TICKS+HD_OFF_TICKS 133 jc up3 134 ld (b),0 135 up3: 136 137 ld b,TXRX_ALT_COUNT 138 inc (b) 139 ld a,(b) 140 cmp a,TXRX_ALT_TICKS 141 jc up4 142 ld (b),0 143 up4: 144 ; 145 146 ; No need to move data anymore 147 send PACK_BITS 148 149 ; 150 ; activity 151 ; 152 ; This routine calculates the activity LED for the current port. 153 ; It extends the activity lights using timers (new activity overrides 154 ; and resets the timers). 155 ; 156 ; Inputs: (PORT_NUM) 157 ; Outputs: Two bits sent to LED stream 158 ; 159 160 activity: 161 pushst RX 162 pop 163 jnc act1 164 165 ld b,RX_TIMERS ; Start RX LED extension timer 166 add b,(PORT_NUM) 167 ld a,ACT_EXT_TICKS 168 ld (b),a 169 170 act1: 171 pushst TX 172 pop 173 jnc act2 174 175 ld b,TX_TIMERS ; Start TX LED extension timer 176 add b,(PORT_NUM) 177 ld a,ACT_EXT_TICKS 178 ld (b),a 179 180 act2: 181 ld b,TX_TIMERS ; Check TX LED extension timer 182 add b,(PORT_NUM) 183 184 dec (b) 185 jnc act3 ; TX active? 186 inc (b) 187 188 ld b,RX_TIMERS ; Check RX LED extension timer 189 add b,(PORT_NUM) 190 191 dec (b) ; Extend LED green if only RX active 192 jnc led_green 193 inc (b) 194 195 jmp led_black ; No activity 196 197 act3: ; TX is active, see if RX also active 198 ld b,RX_TIMERS 199 add b,(PORT_NUM) 200 201 dec (b) ; RX also active? 202 jnc act4 203 inc (b) 204 205 jmp led_amber ; Only TX active 206 207 act4: ; Both TX and RX active 208 ld b,(TXRX_ALT_COUNT) 209 cmp b,TXRX_ALT_TICKS/2 210 jc led_amber ; Fast alternation of green/amber 211 jmp led_green 212 213 ; 214 ; link_status 215 ; 216 ; This routine calculates the link status LED for the current port. 217 ; 218 ; Inputs: (PORT_NUM) 219 ; Outputs: Two bits sent to LED stream 220 ; Destroys: a, b 221 ; 222 223 link_status: 224 pushst DUPLEX ; Skip blink code if full duplex 225 pop 226 jc ls1 227 228 ld a,(HD_COUNT) ; Provide blink for half duplex 229 cmp a,HD_OFF_TICKS 230 jc led_black 231 232 ls1: 233 ld a,(PORT_NUM) ; Check for link down 234 call get_link 235 jnc led_black 236 237 pushst COLL ; Check for collision 238 pop 239 jc led_black 240 241 pushst SPEED_C ; Check for 100Mb speed 242 pop 243 jc led_green 244 245 pushst SPEED_M ; Check for 10Mb (i.e. not 100 or 1000) 246 pop 247 jnc led_amber 248 249 ld a,(GIG_ALT_COUNT) 250 cmp a,GIG_ALT_TICKS/2 251 jc led_amber 252 253 jmp led_green 254 255 256 ; 257 ; get_link 258 ; 259 ; This routine finds the link status LED for a port. 260 ; Link info is in bit 0 of the byte read from PORTDATA[port] 261 ; 262 ; Inputs: Port number in a 263 ; Outputs: Carry flag set if link is up, clear if link is down. 264 ; Destroys: a, b 265 ; 266 267 get_link: 268 ld b,PORTDATA 269 add b,a 270 ld b,(b) 271 tst b,0 272 ret 273 274 ; 275 ; led_black, led_amber, led_green 276 ; 277 ; Inputs: None 278 ; Outputs: Two bits to the LED stream indicating color 279 ; Destroys: None 280 ; 281 282 led_black: 283 pushst ONE 284 pack 285 pushst ONE 286 pack 287 ret 288 289 led_amber: 290 pushst ZERO 291 pack 292 pushst ONE 293 pack 294 ret 295 296 led_green: 297 pushst ONE 298 pack 299 pushst ZERO 300 pack 301 ret 302 303 304 305 ; Variables (SDK software initializes LED memory from 0x80-0xff to 0) 306 ; 307 308 TXRX_ALT_COUNT equ 0xff 309 HD_COUNT equ 0xfe 310 GIG_ALT_COUNT equ 0xfd 311 PORT_NUM equ 0xfc 312 PORT_NUM_CACHE equ 0xfb 313 314 ; 315 ; Port data, which must be updated continually by main CPU's 316 ; linkscan task. See $SDK/src/appl/diag/ledproc.c for examples. 317 ; In this program, bit 0 is assumed to contain the link up/down status. 318 ; 319 320 PORTDATA equ 0xa0 ; Size 28 bytes 321 322 ; 323 ; LED extension timers 324 ; 325 326 RX_TIMERS equ 0xc0+0 ; NUM_PORT bytes 327 TX_TIMERS equ 0xc0+NUM_PORT ; NUM_PORT bytes 328 329 ; 330 ; Symbolic names for the bits of the port status fields 331 ; 332 333 RX equ 0x0 ; received packet 334 TX equ 0x1 ; transmitted packet 335 COLL equ 0x2 ; collision indicator 336 SPEED_C equ 0x3 ; 100 Mbps 337 SPEED_M equ 0x4 ; 1000 Mbps 338 DUPLEX equ 0x5 ; half/full duplex 339 FLOW equ 0x6 ; flow control capable 340 LINKUP equ 0x7 ; link down/up status 341 LINKEN equ 0x8 ; link disabled/enabled status 342 ZERO equ 0xE ; always 0 343 ONE equ 0xF ; always 1