^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Basic assembly code to read BHRB entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright 2013 Anshuman Khandual, IBM Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <asm/ppc_asm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <asm/ppc-opcode.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) .text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) .balign 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /* r3 = n (where n = [0-31])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * The maximum number of BHRB entries supported with PPC_MFBHRBE instruction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * is 1024. We have limited number of table entries here as POWER8 implements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * 32 BHRB entries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /* .global read_bhrb */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) _GLOBAL(read_bhrb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) cmpldi r3,31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) bgt 1f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) ld r4,bhrb_table@got(r2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) sldi r3,r3,3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) add r3,r4,r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) mtctr r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) bctr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 1: li r3,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define MFBHRB_TABLE1(n) PPC_MFBHRBE(R3,n); blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define MFBHRB_TABLE2(n) MFBHRB_TABLE1(n); MFBHRB_TABLE1(n+1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define MFBHRB_TABLE4(n) MFBHRB_TABLE2(n); MFBHRB_TABLE2(n+2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define MFBHRB_TABLE8(n) MFBHRB_TABLE4(n); MFBHRB_TABLE4(n+4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define MFBHRB_TABLE16(n) MFBHRB_TABLE8(n); MFBHRB_TABLE8(n+8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define MFBHRB_TABLE32(n) MFBHRB_TABLE16(n); MFBHRB_TABLE16(n+16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) bhrb_table:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) MFBHRB_TABLE32(0)