mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-25 07:41:42 +01:00
include: Simplify HART id to scratch macro
This patch simplify HART id to scratch macro as follows: 1. Remove current "scratch" pointer argument because now we use HART id to scratch table 2. Rename sbi_hart_id_to_scratch() to sbi_hartid_to_scratch() to have macro name consistent with the name of callback in struct sbi_scratch Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
@@ -110,7 +110,7 @@ void sbi_scratch_free_offset(unsigned long offset);
|
|||||||
extern struct sbi_scratch *hartid_to_scratch_table[];
|
extern struct sbi_scratch *hartid_to_scratch_table[];
|
||||||
|
|
||||||
/** Get sbi_scratch from HART id */
|
/** Get sbi_scratch from HART id */
|
||||||
#define sbi_hart_id_to_scratch(__scratch, __hartid) \
|
#define sbi_hartid_to_scratch(__hartid) \
|
||||||
hartid_to_scratch_table[__hartid]
|
hartid_to_scratch_table[__hartid]
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -59,7 +59,7 @@ int sbi_hsm_hart_get_state(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
{
|
{
|
||||||
struct sbi_hsm_data *hdata;
|
struct sbi_hsm_data *hdata;
|
||||||
|
|
||||||
scratch = sbi_hart_id_to_scratch(scratch, hartid);
|
scratch = sbi_hartid_to_scratch(hartid);
|
||||||
hdata = sbi_scratch_offset_ptr(scratch, hart_data_offset);
|
hdata = sbi_scratch_offset_ptr(scratch, hart_data_offset);
|
||||||
|
|
||||||
return atomic_read(&hdata->state);
|
return atomic_read(&hdata->state);
|
||||||
@@ -163,7 +163,7 @@ int sbi_hsm_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot)
|
|||||||
|
|
||||||
/* Initialize hart state data for every hart */
|
/* Initialize hart state data for every hart */
|
||||||
for (i = 0; i < hart_count; i++) {
|
for (i = 0; i < hart_count; i++) {
|
||||||
rscratch = sbi_hart_id_to_scratch(scratch, i);
|
rscratch = sbi_hartid_to_scratch(i);
|
||||||
hdata = sbi_scratch_offset_ptr(rscratch,
|
hdata = sbi_scratch_offset_ptr(rscratch,
|
||||||
hart_data_offset);
|
hart_data_offset);
|
||||||
ATOMIC_INIT(&hdata->state,
|
ATOMIC_INIT(&hdata->state,
|
||||||
@@ -215,7 +215,7 @@ int sbi_hsm_hart_start(struct sbi_scratch *scratch, u32 hartid,
|
|||||||
unsigned int hstate;
|
unsigned int hstate;
|
||||||
int rc;
|
int rc;
|
||||||
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
||||||
struct sbi_scratch *rscratch = sbi_hart_id_to_scratch(scratch, hartid);
|
struct sbi_scratch *rscratch = sbi_hartid_to_scratch(hartid);
|
||||||
struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(rscratch,
|
struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(rscratch,
|
||||||
hart_data_offset);
|
hart_data_offset);
|
||||||
|
|
||||||
|
@@ -304,7 +304,7 @@ unsigned long sbi_init_count(u32 hartid)
|
|||||||
!init_count_offset)
|
!init_count_offset)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
scratch = sbi_hart_id_to_scratch(sbi_scratch_thishart_ptr(), hartid);
|
scratch = sbi_hartid_to_scratch(hartid);
|
||||||
init_count = sbi_scratch_offset_ptr(scratch, init_count_offset);
|
init_count = sbi_scratch_offset_ptr(scratch, init_count_offset);
|
||||||
|
|
||||||
return *init_count;
|
return *init_count;
|
||||||
|
@@ -45,7 +45,7 @@ static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartid,
|
|||||||
* Set IPI type on remote hart's scratch area and
|
* Set IPI type on remote hart's scratch area and
|
||||||
* trigger the interrupt
|
* trigger the interrupt
|
||||||
*/
|
*/
|
||||||
remote_scratch = sbi_hart_id_to_scratch(scratch, remote_hartid);
|
remote_scratch = sbi_hartid_to_scratch(remote_hartid);
|
||||||
ipi_data = sbi_scratch_offset_ptr(remote_scratch, ipi_data_off);
|
ipi_data = sbi_scratch_offset_ptr(remote_scratch, ipi_data_off);
|
||||||
|
|
||||||
if (ipi_ops->update) {
|
if (ipi_ops->update) {
|
||||||
|
@@ -71,7 +71,7 @@ done:
|
|||||||
scratch = sbi_scratch_thishart_ptr();
|
scratch = sbi_scratch_thishart_ptr();
|
||||||
plat = sbi_platform_ptr(scratch);
|
plat = sbi_platform_ptr(scratch);
|
||||||
for (i = 0; i < sbi_platform_hart_count(plat); i++) {
|
for (i = 0; i < sbi_platform_hart_count(plat); i++) {
|
||||||
rscratch = sbi_hart_id_to_scratch(scratch, i);
|
rscratch = sbi_hartid_to_scratch(i);
|
||||||
ptr = sbi_scratch_offset_ptr(rscratch, ret);
|
ptr = sbi_scratch_offset_ptr(rscratch, ret);
|
||||||
sbi_memset(ptr, 0, size);
|
sbi_memset(ptr, 0, size);
|
||||||
}
|
}
|
||||||
|
@@ -197,7 +197,7 @@ static void sbi_tlb_entry_process(struct sbi_scratch *scratch,
|
|||||||
sbi_tlb_local_flush(tinfo);
|
sbi_tlb_local_flush(tinfo);
|
||||||
|
|
||||||
sbi_hartmask_for_each_hart(rhartid, &tinfo->smask) {
|
sbi_hartmask_for_each_hart(rhartid, &tinfo->smask) {
|
||||||
rscratch = sbi_hart_id_to_scratch(scratch, rhartid);
|
rscratch = sbi_hartid_to_scratch(rhartid);
|
||||||
rtlb_sync = sbi_scratch_offset_ptr(rscratch, tlb_sync_off);
|
rtlb_sync = sbi_scratch_offset_ptr(rscratch, tlb_sync_off);
|
||||||
while (atomic_raw_xchg_ulong(rtlb_sync, 1)) ;
|
while (atomic_raw_xchg_ulong(rtlb_sync, 1)) ;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user