forked from Mirrors/opensbi
		
	lib: sbi: Fix coding style issues
This fixes various coding style issues found in the SBI codes. No functional changes. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
This commit is contained in:
		@@ -28,9 +28,9 @@
 | 
			
		||||
#error "Unexpected __riscv_xlen"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define PAGE_SHIFT      (12)
 | 
			
		||||
#define PAGE_SIZE       (_AC(1, UL) << PAGE_SHIFT)
 | 
			
		||||
#define PAGE_MASK       (~(PAGE_SIZE - 1))
 | 
			
		||||
#define PAGE_SHIFT	(12)
 | 
			
		||||
#define PAGE_SIZE	(_AC(1, UL) << PAGE_SHIFT)
 | 
			
		||||
#define PAGE_MASK	(~(PAGE_SIZE - 1))
 | 
			
		||||
 | 
			
		||||
#define REG_L		__REG_SEL(ld, lw)
 | 
			
		||||
#define REG_S		__REG_SEL(sd, sw)
 | 
			
		||||
 
 | 
			
		||||
@@ -215,20 +215,20 @@ static inline unsigned long __fls(unsigned long word)
 | 
			
		||||
	     (bit) = find_next_zero_bit((addr), (size), (bit) + 1))
 | 
			
		||||
 | 
			
		||||
unsigned long find_first_bit(const unsigned long *addr,
 | 
			
		||||
				    unsigned long size);
 | 
			
		||||
			     unsigned long size);
 | 
			
		||||
 | 
			
		||||
unsigned long find_first_zero_bit(const unsigned long *addr,
 | 
			
		||||
					 unsigned long size);
 | 
			
		||||
				  unsigned long size);
 | 
			
		||||
 | 
			
		||||
unsigned long find_last_bit(const unsigned long *addr,
 | 
			
		||||
				   unsigned long size);
 | 
			
		||||
			    unsigned long size);
 | 
			
		||||
 | 
			
		||||
unsigned long find_next_bit(const unsigned long *addr,
 | 
			
		||||
				   unsigned long size, unsigned long offset);
 | 
			
		||||
			    unsigned long size, unsigned long offset);
 | 
			
		||||
 | 
			
		||||
unsigned long find_next_zero_bit(const unsigned long *addr,
 | 
			
		||||
					unsigned long size,
 | 
			
		||||
					unsigned long offset);
 | 
			
		||||
				 unsigned long size,
 | 
			
		||||
				 unsigned long offset);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * __set_bit - Set a bit in memory
 | 
			
		||||
@@ -242,7 +242,7 @@ static inline void __set_bit(int nr, volatile unsigned long *addr)
 | 
			
		||||
	unsigned long mask = BIT_MASK(nr);
 | 
			
		||||
	unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
 | 
			
		||||
 | 
			
		||||
	*p  |= mask;
 | 
			
		||||
	*p |= mask;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,8 @@
 | 
			
		||||
#ifndef __SBI_CONST_H__
 | 
			
		||||
#define __SBI_CONST_H__
 | 
			
		||||
 | 
			
		||||
/* Some constant macros are used in both assembler and
 | 
			
		||||
/*
 | 
			
		||||
 * Some constant macros are used in both assembler and
 | 
			
		||||
 * C code.  Therefore we cannot annotate them always with
 | 
			
		||||
 * 'UL' and other type specifiers unilaterally.  We
 | 
			
		||||
 * use the following macros to deal with this.
 | 
			
		||||
@@ -39,8 +40,8 @@
 | 
			
		||||
#define UL(x)		(_UL(x))
 | 
			
		||||
#define ULL(x)		(_ULL(x))
 | 
			
		||||
 | 
			
		||||
#define	__STR(s)	#s
 | 
			
		||||
#define	STRINGIFY(s)	__STR(s)
 | 
			
		||||
#define __STR(s)	#s
 | 
			
		||||
#define STRINGIFY(s)	__STR(s)
 | 
			
		||||
 | 
			
		||||
/* clang-format on */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -31,11 +31,11 @@
 | 
			
		||||
/* SBI function IDs for BASE extension*/
 | 
			
		||||
#define SBI_EXT_BASE_GET_SPEC_VERSION		0x0
 | 
			
		||||
#define SBI_EXT_BASE_GET_IMP_ID			0x1
 | 
			
		||||
#define	SBI_EXT_BASE_GET_IMP_VERSION		0x2
 | 
			
		||||
#define	SBI_EXT_BASE_PROBE_EXT			0x3
 | 
			
		||||
#define	SBI_EXT_BASE_GET_MVENDORID		0x4
 | 
			
		||||
#define	SBI_EXT_BASE_GET_MARCHID		0x5
 | 
			
		||||
#define	SBI_EXT_BASE_GET_MIMPID			0x6
 | 
			
		||||
#define SBI_EXT_BASE_GET_IMP_VERSION		0x2
 | 
			
		||||
#define SBI_EXT_BASE_PROBE_EXT			0x3
 | 
			
		||||
#define SBI_EXT_BASE_GET_MVENDORID		0x4
 | 
			
		||||
#define SBI_EXT_BASE_GET_MARCHID		0x5
 | 
			
		||||
#define SBI_EXT_BASE_GET_MIMPID			0x6
 | 
			
		||||
 | 
			
		||||
/* SBI function IDs for TIME extension*/
 | 
			
		||||
#define SBI_EXT_TIME_SET_TIMER			0x0
 | 
			
		||||
@@ -44,7 +44,7 @@
 | 
			
		||||
#define SBI_EXT_IPI_SEND_IPI			0x0
 | 
			
		||||
 | 
			
		||||
/* SBI function IDs for RFENCE extension*/
 | 
			
		||||
#define	SBI_EXT_RFENCE_REMOTE_FENCE_I		0x0
 | 
			
		||||
#define SBI_EXT_RFENCE_REMOTE_FENCE_I		0x0
 | 
			
		||||
#define SBI_EXT_RFENCE_REMOTE_SFENCE_VMA	0x1
 | 
			
		||||
#define SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID	0x2
 | 
			
		||||
#define SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA	0x3
 | 
			
		||||
@@ -62,11 +62,11 @@
 | 
			
		||||
#define SBI_HSM_HART_STATUS_START_PENDING	0x2
 | 
			
		||||
#define SBI_HSM_HART_STATUS_STOP_PENDING	0x3
 | 
			
		||||
 | 
			
		||||
#define SBI_SPEC_VERSION_MAJOR_OFFSET	24
 | 
			
		||||
#define SBI_SPEC_VERSION_MAJOR_MASK	0x7f
 | 
			
		||||
#define SBI_SPEC_VERSION_MINOR_MASK	0xffffff
 | 
			
		||||
#define SBI_EXT_VENDOR_START		0x09000000
 | 
			
		||||
#define SBI_EXT_VENDOR_END		0x09FFFFFF
 | 
			
		||||
#define SBI_SPEC_VERSION_MAJOR_OFFSET		24
 | 
			
		||||
#define SBI_SPEC_VERSION_MAJOR_MASK		0x7f
 | 
			
		||||
#define SBI_SPEC_VERSION_MINOR_MASK		0xffffff
 | 
			
		||||
#define SBI_EXT_VENDOR_START			0x09000000
 | 
			
		||||
#define SBI_EXT_VENDOR_END			0x09FFFFFF
 | 
			
		||||
/* clang-format on */
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -12,22 +12,22 @@
 | 
			
		||||
 | 
			
		||||
/* clang-format off */
 | 
			
		||||
 | 
			
		||||
#define SBI_OK		0
 | 
			
		||||
#define SBI_EFAIL	-1
 | 
			
		||||
#define SBI_ENOTSUPP	-2
 | 
			
		||||
#define SBI_EINVAL	-3
 | 
			
		||||
#define SBI_DENIED	-4
 | 
			
		||||
#define SBI_INVALID_ADDR -5
 | 
			
		||||
#define SBI_ENODEV	-6
 | 
			
		||||
#define SBI_ENOSYS	-7
 | 
			
		||||
#define SBI_ETIMEDOUT	-8
 | 
			
		||||
#define SBI_EIO		-9
 | 
			
		||||
#define SBI_EILL	-10
 | 
			
		||||
#define SBI_ENOSPC	-11
 | 
			
		||||
#define SBI_ENOMEM	-12
 | 
			
		||||
#define SBI_ETRAP	-13
 | 
			
		||||
#define SBI_EUNKNOWN	-14
 | 
			
		||||
#define SBI_ENOENT	-15
 | 
			
		||||
#define SBI_OK			0
 | 
			
		||||
#define SBI_EFAIL		-1
 | 
			
		||||
#define SBI_ENOTSUPP		-2
 | 
			
		||||
#define SBI_EINVAL		-3
 | 
			
		||||
#define SBI_DENIED		-4
 | 
			
		||||
#define SBI_INVALID_ADDR	-5
 | 
			
		||||
#define SBI_ENODEV		-6
 | 
			
		||||
#define SBI_ENOSYS		-7
 | 
			
		||||
#define SBI_ETIMEDOUT		-8
 | 
			
		||||
#define SBI_EIO			-9
 | 
			
		||||
#define SBI_EILL		-10
 | 
			
		||||
#define SBI_ENOSPC		-11
 | 
			
		||||
#define SBI_ENOMEM		-12
 | 
			
		||||
#define SBI_ETRAP		-13
 | 
			
		||||
#define SBI_EUNKNOWN		-14
 | 
			
		||||
#define SBI_ENOENT		-15
 | 
			
		||||
#define SBI_EALREADY_STARTED	-16
 | 
			
		||||
 | 
			
		||||
/* clang-format on */
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,7 @@ int sbi_hsm_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot);
 | 
			
		||||
void __noreturn sbi_hsm_exit(struct sbi_scratch *scratch);
 | 
			
		||||
 | 
			
		||||
int sbi_hsm_hart_start(struct sbi_scratch *scratch, u32 hartid,
 | 
			
		||||
			   ulong saddr, ulong priv);
 | 
			
		||||
		       ulong saddr, ulong priv);
 | 
			
		||||
int sbi_hsm_hart_stop(struct sbi_scratch *scratch, bool exitnow);
 | 
			
		||||
int sbi_hsm_hart_get_state(struct sbi_scratch *scratch, u32 hartid);
 | 
			
		||||
int sbi_hsm_hart_state_to_status(int state);
 | 
			
		||||
 
 | 
			
		||||
@@ -25,23 +25,26 @@ struct sbi_ipi_event_ops {
 | 
			
		||||
	/** Name of the IPI event operations */
 | 
			
		||||
	char name[32];
 | 
			
		||||
 | 
			
		||||
	/** Update callback to save/enqueue data for remote HART
 | 
			
		||||
	 *  Note: This is an optional callback and it is called just before
 | 
			
		||||
	 *  triggering IPI to remote HART.
 | 
			
		||||
	/**
 | 
			
		||||
	 * Update callback to save/enqueue data for remote HART
 | 
			
		||||
	 * Note: This is an optional callback and it is called just before
 | 
			
		||||
	 * triggering IPI to remote HART.
 | 
			
		||||
	 */
 | 
			
		||||
	int (* update)(struct sbi_scratch *scratch,
 | 
			
		||||
			struct sbi_scratch *remote_scratch,
 | 
			
		||||
			u32 remote_hartid, void *data);
 | 
			
		||||
 | 
			
		||||
	/** Sync callback to wait for remote HART
 | 
			
		||||
	 *  Note: This is an optional callback and it is called just after
 | 
			
		||||
	 *  triggering IPI to remote HART.
 | 
			
		||||
	/**
 | 
			
		||||
	 * Sync callback to wait for remote HART
 | 
			
		||||
	 * Note: This is an optional callback and it is called just after
 | 
			
		||||
	 * triggering IPI to remote HART.
 | 
			
		||||
	 */
 | 
			
		||||
	void (* sync)(struct sbi_scratch *scratch);
 | 
			
		||||
 | 
			
		||||
	/** Process callback to handle IPI event
 | 
			
		||||
	 *  Note: This is a mandatory callback and it is called on the
 | 
			
		||||
	 *  remote HART after IPI is triggered.
 | 
			
		||||
	/**
 | 
			
		||||
	 * Process callback to handle IPI event
 | 
			
		||||
	 * Note: This is a mandatory callback and it is called on the
 | 
			
		||||
	 * remote HART after IPI is triggered.
 | 
			
		||||
	 */
 | 
			
		||||
	void (* process)(struct sbi_scratch *scratch);
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -10,9 +10,10 @@
 | 
			
		||||
#ifndef __SBI_PLATFORM_H__
 | 
			
		||||
#define __SBI_PLATFORM_H__
 | 
			
		||||
 | 
			
		||||
/** OpenSBI 32-bit platform version with:
 | 
			
		||||
 *  1. upper 16-bits as major number
 | 
			
		||||
 *  2. lower 16-bits as minor number
 | 
			
		||||
/**
 | 
			
		||||
 * OpenSBI 32-bit platform version with:
 | 
			
		||||
 * 1. upper 16-bits as major number
 | 
			
		||||
 * 2. lower 16-bits as minor number
 | 
			
		||||
 */
 | 
			
		||||
#define SBI_PLATFORM_VERSION(Major, Minor) ((Major << 16) | Minor)
 | 
			
		||||
 | 
			
		||||
@@ -81,12 +82,14 @@ struct sbi_platform_operations {
 | 
			
		||||
	/** Platform final exit */
 | 
			
		||||
	void (*final_exit)(void);
 | 
			
		||||
 | 
			
		||||
	/** For platforms that do not implement misa, non-standard
 | 
			
		||||
	/**
 | 
			
		||||
	 * For platforms that do not implement misa, non-standard
 | 
			
		||||
	 * methods are needed to determine cpu extension.
 | 
			
		||||
	 */
 | 
			
		||||
	int (*misa_check_extension)(char ext);
 | 
			
		||||
 | 
			
		||||
	/** For platforms that do not implement misa, non-standard
 | 
			
		||||
	/**
 | 
			
		||||
	 * For platforms that do not implement misa, non-standard
 | 
			
		||||
	 * methods are needed to get MXL field of misa.
 | 
			
		||||
	 */
 | 
			
		||||
	int (*misa_get_xlen)(void);
 | 
			
		||||
@@ -138,8 +141,8 @@ struct sbi_platform_operations {
 | 
			
		||||
	/** Bringup the given hart from previous stage **/
 | 
			
		||||
	int (*hart_start)(u32 hartid, ulong saddr, ulong priv);
 | 
			
		||||
	/**
 | 
			
		||||
	 *  Stop the current hart from running. This call doesn't expect to
 | 
			
		||||
	 *  return if success.
 | 
			
		||||
	 * Stop the current hart from running. This call doesn't expect to
 | 
			
		||||
	 * return if success.
 | 
			
		||||
	 */
 | 
			
		||||
	int (*hart_stop)(void);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -85,7 +85,8 @@ enum sbi_scratch_options {
 | 
			
		||||
#define sbi_scratch_thishart_arg1_ptr() \
 | 
			
		||||
	((void *)(sbi_scratch_thishart_ptr()->next_arg1))
 | 
			
		||||
 | 
			
		||||
/** Allocate from extra space in sbi_scratch
 | 
			
		||||
/**
 | 
			
		||||
 * Allocate from extra space in sbi_scratch
 | 
			
		||||
 *
 | 
			
		||||
 * @return zero on failure and non-zero (>= SBI_SCRATCH_EXTRA_SPACE_OFFSET)
 | 
			
		||||
 * on success
 | 
			
		||||
 
 | 
			
		||||
@@ -89,7 +89,8 @@ typedef unsigned long		physical_size_t;
 | 
			
		||||
/* clang-format on */
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
/* OPENSBI_EXTERNAL_SBI_TYPES could be defined in CFLAGS for using the
 | 
			
		||||
/*
 | 
			
		||||
 * OPENSBI_EXTERNAL_SBI_TYPES could be defined in CFLAGS for using the
 | 
			
		||||
 * external definitions of data types and common macros.
 | 
			
		||||
 * OPENSBI_EXTERNAL_SBI_TYPES is the file name to external header file,
 | 
			
		||||
 * the external build system should address the additional include
 | 
			
		||||
 
 | 
			
		||||
@@ -14,9 +14,9 @@
 | 
			
		||||
#define OPENSBI_VERSION_MINOR 6
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *  OpenSBI 32-bit version with:
 | 
			
		||||
 *  1. upper 16-bits as major number
 | 
			
		||||
 *  2. lower 16-bits as minor number
 | 
			
		||||
 * OpenSBI 32-bit version with:
 | 
			
		||||
 * 1. upper 16-bits as major number
 | 
			
		||||
 * 2. lower 16-bits as minor number
 | 
			
		||||
 */
 | 
			
		||||
#define OPENSBI_VERSION ((OPENSBI_VERSION_MAJOR << 16) | \
 | 
			
		||||
			 (OPENSBI_VERSION_MINOR))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user