mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00

Add OPENSBI_EXTERNAL_SBI_TYPES macro to allow external definitions of data types and common macros. Also move some common definitions from sbi_bits.h to sbi_types.h. Signed-off-by: Abner Chang <abner.chang@hpe.com> Cc: Leif Lindholm <leif.lindholm@linaro.org> Reviewed-by: Anup Patel <anup.patel@wdc.com>
20 lines
515 B
C
20 lines
515 B
C
/*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*
|
|
* Copyright (c) 2019 Western Digital Corporation or its affiliates.
|
|
*
|
|
* Authors:
|
|
* Anup Patel <anup.patel@wdc.com>
|
|
*/
|
|
|
|
#ifndef __SBI_BITS_H__
|
|
#define __SBI_BITS_H__
|
|
|
|
#define EXTRACT_FIELD(val, which) (((val) & (which)) / ((which) & ~((which)-1)))
|
|
#define INSERT_FIELD(val, which, fieldval) \
|
|
(((val) & ~(which)) | ((fieldval) * ((which) & ~((which)-1))))
|
|
|
|
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
|
|
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
|
|
#endif
|