gh_sdk56062_opt3.asm (3612B)
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 Greyhound SKUs: 10 ; BCM56062 Opt3 11 ; 12 ; To start it, use the following commands from BCM: 13 ; 14 ; led load gh_cascade.hex 15 ; led auto on 16 ; led start 17 ; 18 ; Assume 1 LED per port for Link. And 2 bits stream per LED. 19 ; Link-Down = Off (b'00) 20 ; Link-Up = On (b'01) 21 ; 22 ; Totally 22 ports/LEDs will be outputed. 23 ; 24 ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED 25 ; processor does not always have access to link status. This program 26 ; assumes link status is kept current in bit 0 of RAM byte (0xA0 + portnum). 27 ; Generally, a program running on the main CPU must update these 28 ; locations on link change; see linkscan callback in 29 ; $SDK/src/appl/diag/ledproc.c. 30 ; 31 32 ; 33 ; Constants 34 ; 35 NUM_PORTS equ 22 36 MIN_PORT_0 equ 2 37 MAX_PORT_0 equ 9 38 MIN_PORT_1 equ 18 39 MAX_PORT_1 equ 26 40 MIN_PORT_2 equ 30 41 MAX_PORT_2 equ 30 42 MIN_PORT_3 equ 34 43 MAX_PORT_3 equ 37 44 45 ; 46 ; LED process 47 ; 48 start: 49 ld a, MIN_PORT_0 50 51 iter_sec0: 52 cmp a, MAX_PORT_0+1 53 jnc iter_sec1 54 55 cmp a, MIN_PORT_0 56 jz iter_sec0_init 57 jc iter_sec0_init 58 jmp iter_sec0_start 59 iter_sec0_init: 60 ld a, MIN_PORT_0 61 ld b, MAX_PORT_0 62 ld (SEC_MAX), b 63 iter_sec0_start: 64 jmp iter_common 65 66 iter_sec1: 67 cmp a, MAX_PORT_1+1 68 jnc iter_sec2 69 70 cmp a, MIN_PORT_1 71 jz iter_sec1_init 72 jc iter_sec1_init 73 jmp iter_sec1_start 74 iter_sec1_init: 75 ld a, MIN_PORT_1 76 ld b, MAX_PORT_1 77 ld (SEC_MAX), b 78 iter_sec1_start: 79 jmp iter_common 80 81 iter_sec2: 82 cmp a, MAX_PORT_2+1 83 jnc iter_sec3 84 85 cmp a, MIN_PORT_2 86 jz iter_sec2_init 87 jc iter_sec2_init 88 jmp iter_sec2_start 89 iter_sec2_init: 90 ld a, MIN_PORT_2 91 ld b, MAX_PORT_2 92 ld (SEC_MAX), b 93 iter_sec2_start: 94 jmp iter_common 95 96 iter_sec3: 97 cmp a, MAX_PORT_3+1 98 jnc end 99 100 cmp a, MIN_PORT_3 101 jz iter_sec3_init 102 jc iter_sec3_init 103 jmp iter_sec3_start 104 iter_sec3_init: 105 ld a, MIN_PORT_3 106 ld b, MAX_PORT_3 107 ld (SEC_MAX), b 108 iter_sec3_start: 109 jmp iter_common 110 111 iter_common: 112 port a 113 ld (PORT_NUM), a 114 115 call get_link 116 117 ld a, (PORT_NUM) 118 inc a 119 ld b, (SEC_MAX) 120 inc b 121 cmp a, b 122 jz iter_sec0 123 jmp iter_common 124 125 end: 126 send 2*NUM_PORTS 127 128 ; 129 ; get_link 130 ; 131 ; This routine finds the link status LED for a port. 132 ; Link info is in bit 0 of the byte read from PORTDATA[port] 133 ; Inputs: (PORT_NUM) 134 ; Outputs: Carry flag set if link is up, clear if link is down. 135 ; Destroys: a, b 136 get_link: 137 ld b, PORTDATA 138 add b, (PORT_NUM) 139 ld a, (b) 140 tst a, 0 141 142 jc led_green 143 jmp led_black 144 145 ; 146 ; led_green 147 ; 148 ; Outputs: Bits to the LED stream indicating ON 149 ; 150 led_green: 151 push 0 152 pack 153 push 1 154 pack 155 ret 156 157 ; 158 ; led_black 159 ; 160 ; Outputs: Bits to the LED stream indicating OFF 161 ; 162 led_black: 163 push 0 164 pack 165 push 0 166 pack 167 ret 168 169 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0) 170 PORTDATA equ 0xA0 171 PORT_NUM equ 0xE0 172 SEC_MAX equ 0xE1 173 174 ; Symbolic names for the bits of the port status fields 175 RX equ 0x0 ; received packet 176 TX equ 0x1 ; transmitted packet 177 COLL equ 0x2 ; collision indicator 178 SPEED_C equ 0x3 ; 100 Mbps 179 SPEED_M equ 0x4 ; 1000 Mbps 180 DUPLEX equ 0x5 ; half/full duplex 181 FLOW equ 0x6 ; flow control capable 182 LINKUP equ 0x7 ; link down/up status 183 LINKEN equ 0x8 ; link disabled/enabled status 184 ZERO equ 0xE ; always 0 185 ONE equ 0xF ; always 1