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