10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 230Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _SYS_PX_CSR_H 280Sstevel@tonic-gate #define _SYS_PX_CSR_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate /* To read and write whole register */ 370Sstevel@tonic-gate #define CSR_XR(base, off) \ 380Sstevel@tonic-gate (*(volatile uint64_t *)((base) + ((off)))) 390Sstevel@tonic-gate 400Sstevel@tonic-gate #define CSRA_XR(base, off, index) \ 410Sstevel@tonic-gate (*(volatile uint64_t *)((base) + ((off) + ((index) * 8)))) 420Sstevel@tonic-gate 430Sstevel@tonic-gate #define CSR_XS(base, off, val) \ 440Sstevel@tonic-gate ((*(volatile uint64_t *)((base) + ((off)))) = (val)) 450Sstevel@tonic-gate 460Sstevel@tonic-gate #define CSRA_XS(base, off, index, val) \ 470Sstevel@tonic-gate ((*(volatile uint64_t *)((base) + ((off) + ((index) * 8)))) = (val)) 480Sstevel@tonic-gate 490Sstevel@tonic-gate /* To read, set and clear specific fields within a register */ 500Sstevel@tonic-gate #define CSR_FR(base, off, bit) \ 510Sstevel@tonic-gate (((*(volatile uint64_t *) ((base) + ((off)))) >> \ 520Sstevel@tonic-gate (off ## _ ## bit)) & (off ## _ ## bit ## _MASK)) 530Sstevel@tonic-gate 540Sstevel@tonic-gate #define CSRA_FR(base, off, index, bit) \ 550Sstevel@tonic-gate (((*(volatile uint64_t *) ((base) + ((off) + ((index) * 8)))) >> \ 560Sstevel@tonic-gate (off ## _ ## bit)) & (off ## _ ## bit ## _MASK)) 570Sstevel@tonic-gate 580Sstevel@tonic-gate #define CSR_FS(base, off, bit, val) \ 590Sstevel@tonic-gate ((*(volatile uint64_t *) ((base) + ((off)))) = \ 600Sstevel@tonic-gate (((*(volatile uint64_t *) ((base) + ((off)))) & \ 610Sstevel@tonic-gate ~(((uint64_t)(off ## _ ## bit ## _MASK)) << \ 620Sstevel@tonic-gate (off ## _ ## bit))) | (((uint64_t)(val)) << (off ## _ ## bit)))) 630Sstevel@tonic-gate 640Sstevel@tonic-gate #define CSRA_FS(base, off, index, bit, val) \ 650Sstevel@tonic-gate ((*(volatile uint64_t *) ((base) + ((off) + ((index) * 8)))) = \ 660Sstevel@tonic-gate (((*(volatile uint64_t *) ((base) + ((off) + ((index) * 8)))) & \ 670Sstevel@tonic-gate ~(((uint64_t)(off ## _ ## bit ## _MASK)) << \ 680Sstevel@tonic-gate (off ## _ ## bit))) | (((uint64_t)(val)) << (off ## _ ## bit)))) 690Sstevel@tonic-gate 700Sstevel@tonic-gate #define CSR_FC(base, off, bit) \ 710Sstevel@tonic-gate ((*(volatile uint64_t *) ((base) + ((off)))) = \ 720Sstevel@tonic-gate ((*(volatile uint64_t *)((base) + ((off)))) & \ 730Sstevel@tonic-gate ~(((uint64_t)(off ## _ ## bit ## _MASK)) << (off ## _ ## bit)))) 740Sstevel@tonic-gate 750Sstevel@tonic-gate #define CSRA_FC(base, off, index, bit) \ 760Sstevel@tonic-gate ((*(volatile uint64_t *) ((base) + ((off) + ((index) * 8)))) = \ 770Sstevel@tonic-gate ((*(volatile uint64_t *)((base) + ((off) + ((index) * 8)))) & \ 780Sstevel@tonic-gate ~(((uint64_t)(off ## _ ## bit ## _MASK)) << (off ## _ ## bit)))) 790Sstevel@tonic-gate 800Sstevel@tonic-gate /* To read, set and clear specific bit within a register */ 810Sstevel@tonic-gate #define CSR_BR(base, off, bit) \ 820Sstevel@tonic-gate (((*(volatile uint64_t *)((base) + ((off)))) >> \ 830Sstevel@tonic-gate (off ## _ ## bit)) & 0x1) 840Sstevel@tonic-gate 850Sstevel@tonic-gate #define CSRA_BR(base, off, index, bit) \ 860Sstevel@tonic-gate (((*(volatile uint64_t *)((base) + ((off) + ((index) * 8)))) >> \ 870Sstevel@tonic-gate (off ## _ ## bit)) & 0x1) 880Sstevel@tonic-gate 890Sstevel@tonic-gate #define CSR_BS(base, off, bit) \ 900Sstevel@tonic-gate ((*(volatile uint64_t *)((base) + ((off)))) = \ 910Sstevel@tonic-gate ((*(volatile uint64_t *)((base) + ((off)))) | \ 92*27Sjchu (1ull<<(off ## _ ## bit)))) 930Sstevel@tonic-gate 940Sstevel@tonic-gate #define CSRA_BS(base, off, index, bit) \ 950Sstevel@tonic-gate ((*(volatile uint64_t *)((base) + ((off) + ((index) * 8)))) = \ 960Sstevel@tonic-gate ((*(volatile uint64_t *)((base) + ((off) + ((index) * 8)))) | \ 97*27Sjchu (1ull<<(off ## _ ## bit)))) 980Sstevel@tonic-gate 990Sstevel@tonic-gate #define CSR_BC(base, off, bit) \ 1000Sstevel@tonic-gate ((*(volatile uint64_t *)((base) + ((off)))) = \ 1010Sstevel@tonic-gate ((*(volatile uint64_t *)((base) + ((off)))) & \ 102*27Sjchu ~(1ull<<(off ## _ ## bit)))) 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate #define CSRA_BC(base, off, index, bit) \ 1050Sstevel@tonic-gate ((*(volatile uint64_t *)((base) + ((off) + ((index) * 8)))) = \ 1060Sstevel@tonic-gate ((*(volatile uint64_t *)((base) + ((off) + ((index) * 8)))) & \ 107*27Sjchu ~(1ull<<(off ## _ ## bit)))) 108*27Sjchu 109*27Sjchu #define BIT_TST(reg, bitno) (reg & (1ull << bitno)) 110*27Sjchu #define BITMASK(bitno) (1ull << bitno) 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate #ifdef __cplusplus 1130Sstevel@tonic-gate } 1140Sstevel@tonic-gate #endif 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate #endif /* _SYS_PX_CSR_H */ 117