2022-12-03 12:07:44 +08:00
|
|
|
/*
|
2024-09-02 18:02:15 +08:00
|
|
|
* Copyright (c) 2006-2024, RT-Thread Development Team
|
2022-12-03 12:07:44 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2021-01-30 lizhirui first version
|
2024-09-02 18:02:15 +08:00
|
|
|
* 2024-08-28 RT-Thread Fit into rv64ilp32 ABI
|
2022-12-03 12:07:44 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __RISCV_H__
|
|
|
|
#define __RISCV_H__
|
|
|
|
|
|
|
|
#include <encoding.h>
|
|
|
|
|
2024-09-02 18:02:15 +08:00
|
|
|
/* using unsigned long long for the case of rv64ilp32 */
|
|
|
|
#define __SIZE(bit) (1ULL << (bit))
|
|
|
|
#define __MASK(bit) (__SIZE(bit) - 1ULL)
|
|
|
|
|
2022-12-03 12:07:44 +08:00
|
|
|
#define __UMASK(bit) (~(__MASK(bit)))
|
|
|
|
#define __MASKVALUE(value,maskvalue) ((value) & (maskvalue))
|
|
|
|
#define __UMASKVALUE(value,maskvalue) ((value) & (~(maskvalue)))
|
2024-09-02 18:02:15 +08:00
|
|
|
#define __CHECKUPBOUND(value,bit_count) (!(((rt_ubase_t)value) & (~__MASK(bit_count))))
|
|
|
|
#define __CHECKALIGN(value,start_bit) (!(((rt_ubase_t)value) & (__MASK(start_bit))))
|
2022-12-03 12:07:44 +08:00
|
|
|
|
|
|
|
#define __PARTBIT(value,start_bit,length) (((value) >> (start_bit)) & __MASK(length))
|
|
|
|
|
|
|
|
#define __ALIGNUP(value,bit) (((value) + __MASK(bit)) & __UMASK(bit))
|
|
|
|
#define __ALIGNDOWN(value,bit) ((value) & __UMASK(bit))
|
|
|
|
|
|
|
|
#endif
|