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