soc/riscv: Refactor the code for coding style. [1/4]

PD#SWPL-68240

Problem:
Refactor the code for coding style

Solution:
Refactor the code for coding style

Verify:
N/A

Change-Id: Ice836fb01287a444f9c5a2301609b60ac3edf3a2
Signed-off-by: xiaohu.huang <xiaohu.huang@amlogic.com>
diff --git a/n200_func.c b/n200_func.c
index 7decc50..492b624 100644
--- a/n200_func.c
+++ b/n200_func.c
@@ -13,80 +13,85 @@
 #include "register.h"
 #include "common.h"
 #include "n200_timer.h"
+#include "gcc_compiler_attributes.h"
 #include "riscv_encoding.h"
 
 // Configure PMP to make all the address space accesable and executable
-void pmp_open_all_space(void){
-    // Config entry0 addr to all 1s to make the range cover all space
-    asm volatile ("li x6, 0xffffffff":::"x6");
-    asm volatile ("csrw pmpaddr0, x6":::);
-    // Config entry0 cfg to make it NAPOT address mode, and R/W/X okay
-    asm volatile ("li x6, 0x7f":::"x6");
-    asm volatile ("csrw pmpcfg0, x6":::);
+void pmp_open_all_space(void)
+{
+	// Config entry0 addr to all 1s to make the range cover all space
+	asm volatile("li x6, 0xffffffff" ::: "x6");
+	asm volatile("csrw pmpaddr0, x6" :::);
+	// Config entry0 cfg to make it NAPOT address mode, and R/W/X okay
+	asm volatile("li x6, 0x7f" ::: "x6");
+	asm volatile("csrw pmpcfg0, x6" :::);
 }
 
-void switch_m2u_mode(void){
-    clear_csr (mstatus,MSTATUS_MPP);
-    //printf("\nIn the m2u function, the mstatus is 0x%x\n", read_csr(mstatus));
-    //printf("\nIn the m2u function, the mepc is 0x%x\n", read_csr(mepc));
-    asm volatile ("la x6, 1f    ":::"x6");
-    asm volatile ("csrw mepc, x6":::);
-    asm volatile ("mret":::);
-    asm volatile ("1:":::);
+void switch_m2u_mode(void)
+{
+	clear_csr(mstatus, MSTATUS_MPP);
+	//printf("\nIn the m2u function, the mstatus is 0x%x\n", read_csr(mstatus));
+	//printf("\nIn the m2u function, the mepc is 0x%x\n", read_csr(mepc));
+	asm volatile("la x6, 1f    " ::: "x6");
+	asm volatile("csrw mepc, x6" :::);
+	asm volatile("mret" :::);
+	asm volatile("1:" :::);
 }
 
 uint32_t mtime_lo(void)
 {
 #ifdef configSOC_TIMER_AS_TICK
-    return *(volatile uint32_t *)TIMERE_LOW_REG;
+	return *(volatile uint32_t *)TIMERE_LOW_REG;
 #else
-    return *(volatile uint32_t *)(TIMER_CTRL_ADDR + TIMER_MTIME);
+	return *(volatile uint32_t *)(TIMER_CTRL_ADDR + TIMER_MTIME);
 #endif
 }
 
-
 uint32_t mtime_hi(void)
 {
 #ifdef configSOC_TIMER_AS_TICK
-    return *(volatile uint32_t *)TIMERE_HIG_REG;
+	return *(volatile uint32_t *)TIMERE_HIG_REG;
 #else
-    return *(volatile uint32_t *)(TIMER_CTRL_ADDR + TIMER_MTIME + 4);
+	return *(volatile uint32_t *)(TIMER_CTRL_ADDR + TIMER_MTIME + 4);
 #endif
 }
 
 uint64_t get_timer_value(void)
 {
-  while (1) {
-    uint32_t hi = mtime_hi();
-    uint32_t lo = mtime_lo();
-    if (hi == mtime_hi())
-      return ((uint64_t)hi << 32) | lo;
-  }
+	while (1) {
+		uint32_t hi = mtime_hi();
+		uint32_t lo = mtime_lo();
+
+		if (hi == mtime_hi())
+			return ((uint64_t)hi << 32) | lo;
+	}
 }
 
 uint32_t get_timer_freq(void)
 {
-  return TIMER_FREQ;
+	return TIMER_FREQ;
 }
 
 uint64_t get_instret_value(void)
 {
-  while (1) {
-    uint32_t hi = read_csr(minstreth);
-    uint32_t lo = read_csr(minstret);
-    if (hi == read_csr(minstreth))
-      return ((uint64_t)hi << 32) | lo;
-  }
+	while (1) {
+		uint32_t hi = read_csr(minstreth);
+		uint32_t lo = read_csr(minstret);
+
+		if (hi == read_csr(minstreth))
+			return ((uint64_t)hi << 32) | lo;
+	}
 }
 
 uint64_t get_cycle_value(void)
 {
-  while (1) {
-    uint32_t hi = read_csr(mcycleh);
-    uint32_t lo = read_csr(mcycle);
-    if (hi == read_csr(mcycleh))
-      return ((uint64_t)hi << 32) | lo;
-  }
+	while (1) {
+		uint32_t hi = read_csr(mcycleh);
+		uint32_t lo = read_csr(mcycle);
+
+		if (hi == read_csr(mcycleh))
+			return ((uint64_t)hi << 32) | lo;
+	}
 }
 
 unsigned long interrupt_status_get(void)
@@ -106,39 +111,39 @@
 
 #ifndef CONFIG_N200_REVA
 
-uint32_t __attribute__((noinline)) measure_cpu_freq(size_t n)
+uint32_t __noinline measure_cpu_freq(size_t n)
 {
-  uint32_t start_mtime, delta_mtime;
-  uint32_t mtime_freq = get_timer_freq();
+	uint32_t start_mtime, delta_mtime;
+	uint32_t mtime_freq = get_timer_freq();
+	// Don't start measuruing until we see an mtime tick
+	uint32_t tmp = mtime_lo();
 
-  // Don't start measuruing until we see an mtime tick
-  uint32_t tmp = mtime_lo();
-  do {
-    start_mtime = mtime_lo();
-  } while (start_mtime == tmp);
+	do {
+		start_mtime = mtime_lo();
+	} while (start_mtime == tmp);
 
-  uint32_t start_mcycle = read_csr(mcycle);
+	uint32_t start_mcycle = read_csr(mcycle);
 
-  do {
-    delta_mtime = mtime_lo() - start_mtime;
-  } while (delta_mtime < n);
+	do {
+		delta_mtime = mtime_lo() - start_mtime;
+	} while (delta_mtime < n);
 
-  uint32_t delta_mcycle = read_csr(mcycle) - start_mcycle;
+	uint32_t delta_mcycle = read_csr(mcycle) - start_mcycle;
 
-  return (delta_mcycle / delta_mtime) * mtime_freq
-         + ((delta_mcycle % delta_mtime) * mtime_freq) / delta_mtime;
+	return (delta_mcycle / delta_mtime) * mtime_freq +
+	       ((delta_mcycle % delta_mtime) * mtime_freq) / delta_mtime;
 }
 
 uint32_t get_cpu_freq(void)
 {
-  uint32_t cpu_freq;
+	uint32_t cpu_freq;
 
-  // warm up
-  measure_cpu_freq(1);
-  // measure for real
-  cpu_freq = measure_cpu_freq(100);
+	// warm up
+	measure_cpu_freq(1);
+	// measure for real
+	cpu_freq = measure_cpu_freq(100);
 
-  return cpu_freq;
+	return cpu_freq;
 }
 
 unsigned int xPortIsIsrContext(void)