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