gh_sdk53401_opt3.asm (3014B)
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 ; BCM534x1 Option3 11 ; 12 ; To start it, use the following commands from BCM: 13 ; 14 ; led load gh_sdk53401_opt3.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 28 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 28 36 MIN_PORT_0 equ 2 37 MAX_PORT_0 equ 9 38 MIN_PORT_1 equ 18 39 MAX_PORT_1 equ 37 40 41 ; 42 ; LED process 43 ; 44 start: 45 ld a, MIN_PORT_0 46 47 iter_sec0: 48 cmp a, MAX_PORT_0+1 49 jnc iter_sec1 50 51 cmp a, MIN_PORT_0 52 jz iter_sec0_init 53 jc iter_sec0_init 54 jmp iter_sec0_start 55 iter_sec0_init: 56 ld a, MIN_PORT_0 57 ld b, MAX_PORT_0 58 ld (SEC_MAX), b 59 iter_sec0_start: 60 jmp iter_common 61 62 iter_sec1: 63 cmp a, MAX_PORT_1+1 64 jnc end 65 66 cmp a, MIN_PORT_1 67 jz iter_sec1_init 68 jc iter_sec1_init 69 jmp iter_sec1_start 70 iter_sec1_init: 71 ld a, MIN_PORT_1 72 ld b, MAX_PORT_1 73 ld (SEC_MAX), b 74 iter_sec1_start: 75 jmp iter_common 76 77 iter_common: 78 port a 79 ld (PORT_NUM), a 80 81 call get_link 82 83 ld a, (PORT_NUM) 84 inc a 85 ld b, (SEC_MAX) 86 inc b 87 cmp a, b 88 jz iter_sec0 89 jmp iter_common 90 91 end: 92 send 2*NUM_PORTS 93 94 ; 95 ; get_link 96 ; 97 ; This routine finds the link status LED for a port. 98 ; Link info is in bit 0 of the byte read from PORTDATA[port] 99 ; Inputs: (PORT_NUM) 100 ; Outputs: Carry flag set if link is up, clear if link is down. 101 ; Destroys: a, b 102 get_link: 103 ld b, PORTDATA 104 add b, (PORT_NUM) 105 ld a, (b) 106 tst a, 0 107 108 jc led_green 109 jmp led_black 110 111 ; 112 ; led_green 113 ; 114 ; Outputs: Bits to the LED stream indicating ON 115 ; 116 led_green: 117 push 0 118 pack 119 push 1 120 pack 121 ret 122 123 ; 124 ; led_black 125 ; 126 ; Outputs: Bits to the LED stream indicating OFF 127 ; 128 led_black: 129 push 0 130 pack 131 push 0 132 pack 133 ret 134 135 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0) 136 PORTDATA equ 0xA0 137 PORT_NUM equ 0xE0 138 SEC_MAX equ 0xE1 139 140 ; Symbolic names for the bits of the port status fields 141 RX equ 0x0 ; received packet 142 TX equ 0x1 ; transmitted packet 143 COLL equ 0x2 ; collision indicator 144 SPEED_C equ 0x3 ; 100 Mbps 145 SPEED_M equ 0x4 ; 1000 Mbps 146 DUPLEX equ 0x5 ; half/full duplex 147 FLOW equ 0x6 ; flow control capable 148 LINKUP equ 0x7 ; link down/up status 149 LINKEN equ 0x8 ; link disabled/enabled status 150 ZERO equ 0xE ; always 0 151 ONE equ 0xF ; always 1