mirror of
https://github.com/Fishwaldo/opensbi.git
synced 2025-06-26 16:18:59 +00:00
include: Move bits related defines and macros to sbi_bitops.h
The right location for all bits related defines and macros is sbi_bitops.h hence this patch. With this patch, the sbi_bits.h is redundant so we remove it. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
parent
8c83fb2fc8
commit
00d332bbe7
10 changed files with 27 additions and 33 deletions
|
@ -38,7 +38,6 @@
|
||||||
#define LGREG __REG_SEL(3, 2)
|
#define LGREG __REG_SEL(3, 2)
|
||||||
|
|
||||||
#if __SIZEOF_POINTER__ == 8
|
#if __SIZEOF_POINTER__ == 8
|
||||||
#define BITS_PER_LONG 64
|
|
||||||
#ifdef __ASSEMBLY__
|
#ifdef __ASSEMBLY__
|
||||||
#define RISCV_PTR .dword
|
#define RISCV_PTR .dword
|
||||||
#define RISCV_SZPTR 8
|
#define RISCV_SZPTR 8
|
||||||
|
@ -49,7 +48,6 @@
|
||||||
#define RISCV_LGPTR "3"
|
#define RISCV_LGPTR "3"
|
||||||
#endif
|
#endif
|
||||||
#elif __SIZEOF_POINTER__ == 4
|
#elif __SIZEOF_POINTER__ == 4
|
||||||
#define BITS_PER_LONG 32
|
|
||||||
#ifdef __ASSEMBLY__
|
#ifdef __ASSEMBLY__
|
||||||
#define RISCV_PTR .word
|
#define RISCV_PTR .word
|
||||||
#define RISCV_SZPTR 4
|
#define RISCV_SZPTR 4
|
||||||
|
|
|
@ -10,8 +10,23 @@
|
||||||
#ifndef __SBI_BITOPS_H__
|
#ifndef __SBI_BITOPS_H__
|
||||||
#define __SBI_BITOPS_H__
|
#define __SBI_BITOPS_H__
|
||||||
|
|
||||||
#include <sbi/sbi_bits.h>
|
#include <sbi/sbi_types.h>
|
||||||
#include <sbi/riscv_asm.h>
|
|
||||||
|
#if __SIZEOF_POINTER__ == 8
|
||||||
|
#define BITS_PER_LONG 64
|
||||||
|
#elif __SIZEOF_POINTER__ == 4
|
||||||
|
#define BITS_PER_LONG 32
|
||||||
|
#else
|
||||||
|
#error "Unexpected __SIZEOF_POINTER__"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#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)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ffs - Find first bit set
|
* ffs - Find first bit set
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
/*
|
|
||||||
* 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
|
|
|
@ -7,11 +7,10 @@
|
||||||
* Anup Patel <anup.patel@wdc.com>
|
* Anup Patel <anup.patel@wdc.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sbi/sbi_types.h>
|
#include <sbi/sbi_bitops.h>
|
||||||
#include <sbi/riscv_asm.h>
|
#include <sbi/riscv_asm.h>
|
||||||
#include <sbi/riscv_atomic.h>
|
#include <sbi/riscv_atomic.h>
|
||||||
#include <sbi/riscv_barrier.h>
|
#include <sbi/riscv_barrier.h>
|
||||||
#include <sbi/sbi_bits.h>
|
|
||||||
|
|
||||||
long atomic_read(atomic_t *atom)
|
long atomic_read(atomic_t *atom)
|
||||||
{
|
{
|
||||||
|
@ -209,12 +208,12 @@ unsigned long atomic_raw_xchg_ulong(volatile unsigned long *ptr,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (BITS_PER_LONG == 64)
|
#if (__SIZEOF_POINTER__ == 8)
|
||||||
#define __AMO(op) "amo" #op ".d"
|
#define __AMO(op) "amo" #op ".d"
|
||||||
#elif (BITS_PER_LONG == 32)
|
#elif (__SIZEOF_POINTER__ == 4)
|
||||||
#define __AMO(op) "amo" #op ".w"
|
#define __AMO(op) "amo" #op ".w"
|
||||||
#else
|
#else
|
||||||
#error "Unexpected BITS_PER_LONG"
|
#error "Unexpected __SIZEOF_POINTER__"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define __atomic_op_bit_ord(op, mod, nr, addr, ord) \
|
#define __atomic_op_bit_ord(op, mod, nr, addr, ord) \
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include <sbi/riscv_asm.h>
|
#include <sbi/riscv_asm.h>
|
||||||
#include <sbi/riscv_encoding.h>
|
#include <sbi/riscv_encoding.h>
|
||||||
#include <sbi/sbi_bits.h>
|
#include <sbi/sbi_bitops.h>
|
||||||
#include <sbi/sbi_console.h>
|
#include <sbi/sbi_console.h>
|
||||||
#include <sbi/sbi_emulate_csr.h>
|
#include <sbi/sbi_emulate_csr.h>
|
||||||
#include <sbi/sbi_error.h>
|
#include <sbi/sbi_error.h>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <sbi/riscv_encoding.h>
|
#include <sbi/riscv_encoding.h>
|
||||||
#include <sbi/riscv_fp.h>
|
#include <sbi/riscv_fp.h>
|
||||||
#include <sbi/riscv_locks.h>
|
#include <sbi/riscv_locks.h>
|
||||||
#include <sbi/sbi_bits.h>
|
#include <sbi/sbi_bitops.h>
|
||||||
#include <sbi/sbi_console.h>
|
#include <sbi/sbi_console.h>
|
||||||
#include <sbi/sbi_error.h>
|
#include <sbi/sbi_error.h>
|
||||||
#include <sbi/sbi_hart.h>
|
#include <sbi/sbi_hart.h>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include <sbi/riscv_barrier.h>
|
#include <sbi/riscv_barrier.h>
|
||||||
#include <sbi/riscv_encoding.h>
|
#include <sbi/riscv_encoding.h>
|
||||||
#include <sbi/riscv_atomic.h>
|
#include <sbi/riscv_atomic.h>
|
||||||
#include <sbi/sbi_bits.h>
|
#include <sbi/sbi_bitops.h>
|
||||||
#include <sbi/sbi_console.h>
|
#include <sbi/sbi_console.h>
|
||||||
#include <sbi/sbi_error.h>
|
#include <sbi/sbi_error.h>
|
||||||
#include <sbi/sbi_ecall_interface.h>
|
#include <sbi/sbi_ecall_interface.h>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include <sbi/riscv_asm.h>
|
#include <sbi/riscv_asm.h>
|
||||||
#include <sbi/riscv_encoding.h>
|
#include <sbi/riscv_encoding.h>
|
||||||
#include <sbi/sbi_bits.h>
|
#include <sbi/sbi_bitops.h>
|
||||||
#include <sbi/sbi_emulate_csr.h>
|
#include <sbi/sbi_emulate_csr.h>
|
||||||
#include <sbi/sbi_error.h>
|
#include <sbi/sbi_error.h>
|
||||||
#include <sbi/sbi_illegal_insn.h>
|
#include <sbi/sbi_illegal_insn.h>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Nick Kossifidis <mick@ics.forth.gr>
|
* Nick Kossifidis <mick@ics.forth.gr>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sbi/sbi_bitops.h>
|
||||||
#include <sbi/sbi_hart.h>
|
#include <sbi/sbi_hart.h>
|
||||||
#include <sbi/sbi_hsm.h>
|
#include <sbi/sbi_hsm.h>
|
||||||
#include <sbi/sbi_platform.h>
|
#include <sbi/sbi_platform.h>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sbi/riscv_encoding.h>
|
#include <sbi/riscv_encoding.h>
|
||||||
#include <sbi/sbi_bits.h>
|
#include <sbi/sbi_bitops.h>
|
||||||
#include <sbi/sbi_hart.h>
|
#include <sbi/sbi_hart.h>
|
||||||
#include <sbi/sbi_scratch.h>
|
#include <sbi/sbi_scratch.h>
|
||||||
#include <sbi/sbi_trap.h>
|
#include <sbi/sbi_trap.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue