forked from Mirrors/opensbi
include: sbi: Store the hart index in struct sbi_scratch
This is a more efficient way to get the index of the current hart than calling a function to loop through the hartindex -> hartid lookup table. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:

committed by
Anup Patel

parent
4ac1818197
commit
9d7a983060
@@ -218,6 +218,8 @@ _scratch_init:
|
|||||||
#endif
|
#endif
|
||||||
REG_S a0, SBI_SCRATCH_OPTIONS_OFFSET(tp)
|
REG_S a0, SBI_SCRATCH_OPTIONS_OFFSET(tp)
|
||||||
MOV_3R a0, s0, a1, s1, a2, s2
|
MOV_3R a0, s0, a1, s1, a2, s2
|
||||||
|
/* Store hart index in scratch space */
|
||||||
|
REG_S t1, SBI_SCRATCH_HARTINDEX_OFFSET(tp)
|
||||||
/* Move to next scratch space */
|
/* Move to next scratch space */
|
||||||
add t1, t1, t2
|
add t1, t1, t2
|
||||||
blt t1, s7, _scratch_init
|
blt t1, s7, _scratch_init
|
||||||
|
@@ -42,8 +42,10 @@
|
|||||||
#define SBI_SCRATCH_TMP0_OFFSET (12 * __SIZEOF_POINTER__)
|
#define SBI_SCRATCH_TMP0_OFFSET (12 * __SIZEOF_POINTER__)
|
||||||
/** Offset of options member in sbi_scratch */
|
/** Offset of options member in sbi_scratch */
|
||||||
#define SBI_SCRATCH_OPTIONS_OFFSET (13 * __SIZEOF_POINTER__)
|
#define SBI_SCRATCH_OPTIONS_OFFSET (13 * __SIZEOF_POINTER__)
|
||||||
|
/** Offset of hartindex member in sbi_scratch */
|
||||||
|
#define SBI_SCRATCH_HARTINDEX_OFFSET (14 * __SIZEOF_POINTER__)
|
||||||
/** Offset of extra space in sbi_scratch */
|
/** Offset of extra space in sbi_scratch */
|
||||||
#define SBI_SCRATCH_EXTRA_SPACE_OFFSET (14 * __SIZEOF_POINTER__)
|
#define SBI_SCRATCH_EXTRA_SPACE_OFFSET (15 * __SIZEOF_POINTER__)
|
||||||
/** Maximum size of sbi_scratch (4KB) */
|
/** Maximum size of sbi_scratch (4KB) */
|
||||||
#define SBI_SCRATCH_SIZE (0x1000)
|
#define SBI_SCRATCH_SIZE (0x1000)
|
||||||
|
|
||||||
@@ -83,6 +85,8 @@ struct sbi_scratch {
|
|||||||
unsigned long tmp0;
|
unsigned long tmp0;
|
||||||
/** Options for OpenSBI library */
|
/** Options for OpenSBI library */
|
||||||
unsigned long options;
|
unsigned long options;
|
||||||
|
/** Index of the hart */
|
||||||
|
unsigned long hartindex;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,6 +206,10 @@ do { \
|
|||||||
= (__type)(__ptr); \
|
= (__type)(__ptr); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
/** Get the hart index of the current hart */
|
||||||
|
#define current_hartindex() \
|
||||||
|
(sbi_scratch_thishart_ptr()->hartindex)
|
||||||
|
|
||||||
/** Last HART index having a sbi_scratch pointer */
|
/** Last HART index having a sbi_scratch pointer */
|
||||||
extern u32 last_hartindex_having_scratch;
|
extern u32 last_hartindex_having_scratch;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user