sdk8806x.asm (4275B)
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 BCM8806x Montreal2 board. 10 ; To start it, use the following commands from BCM: 11 ; 12 ; led 0 load sdk8806x.hex 13 ; led 0 auto on 14 ; led 0 start 15 ; 16 ; The are 2 LEDs per port one for Link(Top) and one for activity(Bottom). 17 ; 18 ; Only one chip (16 LEDs) have been populated in the Montreal2 board. 19 ; 20 ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED 21 ; processor does not always have access to link status. This program 22 ; assumes link status is kept current in bit 0 of RAM byte (0xA0 + portnum). 23 ; Generally, a program running on the main CPU must update these 24 ; locations on link change; see linkscan callback in 25 ; $SDK/src/appl/diag/ledproc.c. 26 ; 27 ; When Montreal2 inband stats collection is running, the activity is not 28 ; derived from TX and RX. The Software-calculated activity is kept in the 29 ; RAM byte (0xA0 + portnum) in bits 1 & 2 30 ; 31 TICKS EQU 1 32 SECOND_TICKS EQU (30*TICKS) 33 TXRX_ALT_TICKS EQU (SECOND_TICKS/6) 34 35 MIN_PORT EQU 0 36 MAX_PORT EQU 7 37 NUM_PORT EQU 8 ;MAX_PORT+1, for comparing 38 39 40 ; 41 ; Main Update Routine 42 ; 43 ; This routine is called once per tick. 44 ; 45 46 update: 47 ld A,MIN_PORT 48 port_loop: 49 port A 50 ld (PORT_NUM),A 51 52 call link_status ; Top LED for this port 53 call chk_activity ; Bottom LED for this port 54 55 ; Debug 56 ;call led_on 57 ;call led_off 58 ; Debug 59 60 61 ld a,(PORT_NUM) 62 inc a 63 cmp a,NUM_PORT 64 jnz port_loop 65 66 ; Update various timers 67 inc (TXRX_ALT_COUNT) 68 69 send 16 70 71 ; 72 ; 73 ; 74 ; This routine calculates the activity LED for the current port. 75 ; It extends the activity lights using timers (new activity overrides 76 ; and resets the timers). 77 ; 78 ; Inputs: (PORT_NUM) 79 ; Outputs: one bit sent to LED stream 80 ; 81 82 ; Activity status LED update 83 chk_activity: 84 ld b,PORTDATA 85 add b,a 86 ld b,(b) 87 tst b,1 88 push CY ; TX 89 tst b,2 90 push CY ; RX 91 92 tor 93 pop 94 95 jnc led_off ; Always off, No Activity 96 97 ld b, (TXRX_ALT_COUNT) 98 and b, TXRX_ALT_TICKS 99 jnz led_on 100 jmp led_off ; Fast blink 101 102 ; Link status LED update 103 link_status: 104 call get_link 105 jnc led_off 106 jmp led_on 107 108 ; 109 ; get_link 110 ; 111 ; This routine finds the link status LED for a port. 112 ; Link info is in bit 0 of the byte read from PORTDATA[port] 113 ; 114 ; Inputs: Port number in a 115 ; Outputs: Carry flag set if link is up, clear if link is down. 116 ; Destroys: a, b 117 ; 118 119 get_link: 120 ld b,PORTDATA 121 add b,a 122 ld b,(b) 123 tst b,0 124 ret 125 126 127 get_link_hw: 128 port a 129 pushst LINKUP 130 pop 131 ret 132 133 led_off: 134 pushst ZERO 135 pack 136 ret 137 138 led_on: 139 pushst ONE 140 pack 141 ret 142 143 ; 144 ; Variables (SDK software initializes LED memory from 0xa0-0xff to 0) 145 ; 146 147 TXRX_ALT_COUNT equ 0xe0 148 PORT_NUM equ 0xe1 149 150 ; 151 ; Port data, which must be updated continually by main CPU's 152 ; linkscan task. See $SDK/src/appl/diag/ledproc.c for examples. 153 ; In this program, bit 0 is assumed to contain the link up/down status. 154 ; 155 156 ;Offset 0x1e00 - 0x80 157 ;LED scan chain assembly area 158 159 ;Offset 0x1e80 - 0xa0 160 PORTDATA equ 0xa0 ; Size 48 + 1 + 4 bytes 161 162 ; 163 ; Symbolic names for the bits of the port status fields 164 ; 165 166 RX equ 0x0 ; received packet 167 TX equ 0x1 ; transmitted packet 168 COLL equ 0x2 ; collision indicator 169 SPEED_C equ 0x3 ; 100 Mbps 170 SPEED_M equ 0x4 ; 1000 Mbps 171 DUPLEX equ 0x5 ; half/full duplex 172 FLOW equ 0x6 ; flow control capable 173 LINKUP equ 0x7 ; link down/up status 174 LINKEN equ 0x8 ; link disabled/enabled status 175 ZERO equ 0xE ; always 0 176 ONE equ 0xF ; always 1 177