You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.3 KiB

/*
* Copyright (c) Hisilicon Technologies Co., Ltd. 2021-2021. All rights reserved.
* Description: status update interface
* Author: Hisilicon
* Create: 2021-05-10
*/
#ifndef __DMCU_COMMON_H__
#define __DMCU_COMMON_H__
#define UADDR td_u64
#define uint64_ptr(ptr) ((td_void *)(td_uintptr_t)(ptr))
#define ptr_uint64(ptr) ((td_u64)(td_uintptr_t)(ptr))
#define dmcu_max(a, b) (((a) < (b)) ? (b) : (a))
#define dmcu_min(a, b) ((((a) > (b))) ? (b) : (a))
#define dmcu_abs(x) (((x) < 0) ? -(x) : (x))
#define dmcu_mdian(a, b, c) ((a) + (b) + (c)-dmcu_min((a), dmcu_min((b), (c))) - dmcu_max((a), dmcu_max((b), (c))))
typedef enum {
PAGE_SIZE_4K = 0,
PAGE_SIZE_16K = 1,
PAGE_SIZE_64K = 2,
PAGE_SIZE_MAX,
} os_page_size;
#define dmcu_wr_reg(base, reg, dat) \
do { \
*((volatile td_u32 *)((td_u8 *)(base) + (reg))) = (dat); \
} while (0)
#define dmcu_rd_reg(base, reg) (*((volatile td_u32 *)((td_u8 *)(base) + (reg))))
#define dmcu_check_sec_func(ret) \
do { \
if ((ret) != TD_SUCCESS) { \
printf("%s %d sec func call error\n", __func__, __LINE__); \
} \
} while (0)
#endif /* __DMCU_COMMON_H__ */