New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get my hartid in SMP? #233
Comments
The hart ID will be passed to you in register |
@repnop Thank you for your reply, I know that I can store it in |
@repnop This is my not-so-good-looking code. /**
* Within SBI, we can't read mhartid, so I try to use `trap entry` to see who am I.
*/
PUBLIC Uint HAL_CoreGetId(void)
{
Addr trapEntry = ReadCSR(stvec);
if (trapEntry == (Addr)&TrapEntry0)
{
return 0;
}
else if (trapEntry == (Addr)&TrapEntry1)
{
return 1;
}
else if (trapEntry == (Addr)&TrapEntry2)
{
return 2;
}
else if (trapEntry == (Addr)&TrapEntry3)
{
return 3;
}
/* should never be here */
while (1);
} |
You need to save and restore all of your kernel state before switching to user-mode regardless, so storing it in |
@repnop I once considered the |
In opensbi, OS running in supervisor mode,I can't get hartid from mhartid, I just wanna a function to get hartid like
shartid
,even though it is read-only, that works! How can I do that?The text was updated successfully, but these errors were encountered: