bcm953570k_0.asm (3194B)
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 ; This example is used for showing the serial LEDs on BCM953570K using LED bus. 9 ; 10 ; To start it, use the following commands from BCM: 11 ; 12 ; led load bcm953570k_0.hex 13 ; led auto on 14 ; led start 15 ; 16 ; Each port needs to output 4 bits stream, 17 ; bit 0: LED_0 (activity) 18 ; bit 1: LED_0 (activity) 19 ; bit 2: LED_1 (link up/down) 20 ; bit 3: LED_1 (link up/down) 21 ; 22 ; Totally 24 ports need be outputed 23 ; 24 ; In physical port view, the output order is: 25 ; 2, 3, 4 ... 25 26 ; 27 ; Link up/down info cannot be derived from LINKEN, as the LED 28 ; processor does not always have access to link status. This program 29 ; assumes link status is kept current in bit 0 of RAM byte (0xA0 + portnum). 30 ; Generally, a program running on the main CPU must update these 31 ; locations on link change; see linkscan callback in 32 ; $SDK/src/appl/diag/ledproc.c. 33 ; 34 35 ; 36 ; Constants 37 ; 38 39 START_PORT_0 equ 2 40 END_PORT_0 equ 25 41 42 ; 43 ; LED process 44 ; 45 46 start_sec0: 47 ld a, START_PORT_0 48 iter_sec0: 49 port a 50 ld (PORT_NUM), a 51 call get_activity_hw 52 53 ld a, (PORT_NUM) 54 port a 55 call get_link_hw 56 57 ld a, (PORT_NUM) 58 inc a 59 cmp a, END_PORT_0 + 1 60 jnz iter_sec0 61 62 end: 63 ; output the maximun bits for the LED bus 64 ; to avoid undesired repetitive behavior 65 send 255 66 67 ; 68 ; get_activity_hw 69 ; 70 ; This routine finds the link status LED for a port from HW. 71 ; Inputs: (PORT_NUM) 72 ; Outputs: Carry flag set if RX or TX is up, clear if link is down. 73 ; Destroys: a, b 74 75 get_activity_hw: 76 pushst RX 77 pushst TX 78 tor 79 pop 80 81 jc led_on_green 82 jmp led_off 83 84 ; 85 ; get_link_hw 86 ; 87 ; This routine finds the link status LED for a port from HW. 88 ; Inputs: (PORT_NUM) 89 ; Outputs: Carry flag set if link is up, clear if link is down. 90 ; Destroys: a, b 91 get_link_hw: 92 pushst LINKEN 93 pop 94 95 jc led_on_green 96 jmp led_off 97 98 ; 99 ; get_link_sw 100 ; 101 ; This routine finds the link status LED for a port. 102 ; Link info is in bit 0 of the byte read from PORTDATA[port] 103 ; Inputs: (PORT_NUM) 104 ; Outputs: Carry flag set if link is up, clear if link is down. 105 ; Destroys: a, b 106 get_link_sw: 107 ld b, PORTDATA 108 add b, (PORT_NUM) 109 ld a, (b) 110 tst a, 0 111 112 jc led_on_green 113 jmp led_off 114 115 ; 116 ; led_on_green 117 ; 118 ; Outputs: Bits to the LED stream indicating ON 119 ; 120 led_on_green: 121 push 1 122 pack 123 push 0 124 pack 125 ret 126 127 ; 128 ; led_off 129 ; 130 ; Outputs: Bits to the LED stream indicating OFF 131 ; 132 led_off: 133 push 0 134 pack 135 push 0 136 pack 137 ret 138 139 ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0) 140 PORTDATA equ 0xA0 141 PORT_NUM equ 0xE0 142 143 ; Symbolic names for the bits of the port status fields 144 RX equ 0x0 ; received packet 145 TX equ 0x1 ; transmitted packet 146 COLL equ 0x2 ; collision indicator 147 SPEED_C equ 0x3 ; 100 Mbps 148 SPEED_M equ 0x4 ; 1000 Mbps 149 DUPLEX equ 0x5 ; half/full duplex 150 FLOW equ 0x6 ; flow control capable 151 LINKUP equ 0x7 ; link down/up status 152 LINKEN equ 0x8 ; link disabled/enabled status 153 ZERO equ 0xE ; always 0 154 ONE equ 0xF ; always 1