OpenSBI: Added rfence extension and HartMask struct
This commit is contained in:
parent
854f65a4b3
commit
a8a7c5fdc9
6 changed files with 171 additions and 9 deletions
|
@ -13,14 +13,12 @@ namespace opensbi::ipi {
|
|||
};
|
||||
}
|
||||
|
||||
SbiRet send_ipi(
|
||||
unsigned long hart_mask,
|
||||
unsigned long hart_mask_base) {
|
||||
SbiRet send_ipi(HartMask hart_mask) {
|
||||
return ecall(
|
||||
static_cast<sbiword_t>(ExtensionId::IPI),
|
||||
static_cast<sbiword_t>(FunctionId::SEND_IPI),
|
||||
hart_mask,
|
||||
hart_mask_base);
|
||||
hart_mask.mask,
|
||||
hart_mask.base);
|
||||
}
|
||||
|
||||
} // End namespace opensbi::ipi
|
||||
|
|
116
kernel/drivers/opensbi/extensions/rfence.cpp
Normal file
116
kernel/drivers/opensbi/extensions/rfence.cpp
Normal file
|
@ -0,0 +1,116 @@
|
|||
#include "opensbi/extensions/rfence.h"
|
||||
|
||||
namespace drivers {
|
||||
namespace opensbi::rfence {
|
||||
|
||||
namespace {
|
||||
enum class ExtensionId {
|
||||
RFENCE = 0x52464E43
|
||||
};
|
||||
|
||||
enum class FunctionId {
|
||||
REMOTE_FENCE_I,
|
||||
REMOTE_SFENCE_VMA,
|
||||
REMOTE_SFENCE_VMA_ASID,
|
||||
REMOTE_HFENCE_GVMA_VMID,
|
||||
REMOTE_HFENCE_GVMA,
|
||||
REMOTE_HFENCE_VVMA_ASID,
|
||||
REMOTE_HFENCE_VVMA
|
||||
};
|
||||
}
|
||||
|
||||
SbiRet remote_fence_i(HartMask hart_mask) {
|
||||
return ecall(
|
||||
static_cast<sbiword_t>(ExtensionId::RFENCE),
|
||||
static_cast<sbiword_t>(FunctionId::REMOTE_FENCE_I),
|
||||
hart_mask.mask,
|
||||
hart_mask.base);
|
||||
}
|
||||
|
||||
SbiRet remote_sfence_vma(
|
||||
HartMask hart_mask,
|
||||
unsigned long start_addr,
|
||||
unsigned long size) {
|
||||
return ecall(
|
||||
static_cast<sbiword_t>(ExtensionId::RFENCE),
|
||||
static_cast<sbiword_t>(FunctionId::REMOTE_SFENCE_VMA),
|
||||
hart_mask.mask,
|
||||
hart_mask.base,
|
||||
start_addr,
|
||||
size);
|
||||
}
|
||||
|
||||
SbiRet remote_sfence_vma_asid(
|
||||
HartMask hart_mask,
|
||||
unsigned long start_addr,
|
||||
unsigned long size,
|
||||
unsigned long asid) {
|
||||
return ecall(
|
||||
static_cast<sbiword_t>(ExtensionId::RFENCE),
|
||||
static_cast<sbiword_t>(FunctionId::REMOTE_SFENCE_VMA_ASID),
|
||||
hart_mask.mask,
|
||||
hart_mask.base,
|
||||
start_addr,
|
||||
size,
|
||||
asid);
|
||||
}
|
||||
|
||||
SbiRet remote_hfence_gvma_vmid(
|
||||
HartMask hart_mask,
|
||||
unsigned long start_addr,
|
||||
unsigned long size,
|
||||
unsigned long vmid) {
|
||||
return ecall(
|
||||
static_cast<sbiword_t>(ExtensionId::RFENCE),
|
||||
static_cast<sbiword_t>(FunctionId::REMOTE_HFENCE_GVMA_VMID),
|
||||
hart_mask.mask,
|
||||
hart_mask.base,
|
||||
start_addr,
|
||||
size,
|
||||
vmid);
|
||||
}
|
||||
|
||||
SbiRet remote_hfence_gvma(
|
||||
HartMask hart_mask,
|
||||
unsigned long start_addr,
|
||||
unsigned long size) {
|
||||
return ecall(
|
||||
static_cast<sbiword_t>(ExtensionId::RFENCE),
|
||||
static_cast<sbiword_t>(FunctionId::REMOTE_HFENCE_GVMA),
|
||||
hart_mask.mask,
|
||||
hart_mask.base,
|
||||
start_addr,
|
||||
size);
|
||||
}
|
||||
|
||||
SbiRet remote_hfence_vvma_asid(
|
||||
HartMask hart_mask,
|
||||
unsigned long start_addr,
|
||||
unsigned long size,
|
||||
unsigned long asid) {
|
||||
return ecall(
|
||||
static_cast<sbiword_t>(ExtensionId::RFENCE),
|
||||
static_cast<sbiword_t>(FunctionId::REMOTE_HFENCE_VVMA_ASID),
|
||||
hart_mask.mask,
|
||||
hart_mask.base,
|
||||
start_addr,
|
||||
size,
|
||||
asid);
|
||||
}
|
||||
|
||||
SbiRet remote_hfence_vvma(
|
||||
HartMask hart_mask,
|
||||
unsigned long start_addr,
|
||||
unsigned long size) {
|
||||
return ecall(
|
||||
static_cast<sbiword_t>(ExtensionId::RFENCE),
|
||||
static_cast<sbiword_t>(FunctionId::REMOTE_HFENCE_VVMA),
|
||||
hart_mask.mask,
|
||||
hart_mask.base,
|
||||
start_addr,
|
||||
size);
|
||||
}
|
||||
|
||||
} // End namespace opensbi::rfence
|
||||
} // End namespace drivers
|
||||
|
|
@ -5,9 +5,7 @@
|
|||
namespace drivers {
|
||||
namespace opensbi::ipi {
|
||||
|
||||
SbiRet send_ipi(
|
||||
unsigned long hart_mask,
|
||||
unsigned long hart_mask_base);
|
||||
SbiRet send_ipi(HartMask hart_mask);
|
||||
|
||||
} // End namespace opensbi::ipi
|
||||
} // End namespace drivers
|
||||
|
|
44
kernel/drivers/opensbi/include/opensbi/extensions/rfence.h
Normal file
44
kernel/drivers/opensbi/include/opensbi/extensions/rfence.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
#pragma once
|
||||
|
||||
#include "opensbi/opensbi.h"
|
||||
|
||||
namespace drivers {
|
||||
namespace opensbi::rfence {
|
||||
|
||||
SbiRet remote_fence_i(HartMask hart_mask);
|
||||
|
||||
SbiRet remote_sfence_vma(
|
||||
HartMask hart_mask,
|
||||
unsigned long start_addr,
|
||||
unsigned long size);
|
||||
|
||||
SbiRet remote_sfence_vma_asid(
|
||||
HartMask hart_mask,
|
||||
unsigned long start_addr,
|
||||
unsigned long size,
|
||||
unsigned long asid);
|
||||
|
||||
SbiRet remote_hfence_gvma_vmid(
|
||||
HartMask hart_mask,
|
||||
unsigned long start_addr,
|
||||
unsigned long size,
|
||||
unsigned long vmid);
|
||||
|
||||
SbiRet remote_hfence_gvma(
|
||||
HartMask hart_mask,
|
||||
unsigned long start_addr,
|
||||
unsigned long size);
|
||||
|
||||
SbiRet remote_hfence_vvma_asid(
|
||||
HartMask hart_mask,
|
||||
unsigned long start_addr,
|
||||
unsigned long size,
|
||||
unsigned long asid);
|
||||
|
||||
SbiRet remote_hfence_vvma(
|
||||
HartMask hart_mask,
|
||||
unsigned long start_addr,
|
||||
unsigned long size);
|
||||
|
||||
} // End namespace opensbi::rfence
|
||||
} // End namespace drivers
|
|
@ -8,6 +8,11 @@ namespace opensbi {
|
|||
typedef unsigned long sbiword_t;
|
||||
typedef const unsigned long * hart_mask_t;
|
||||
|
||||
struct HartMask {
|
||||
unsigned long mask;
|
||||
unsigned long base;
|
||||
};
|
||||
|
||||
struct SbiRet {
|
||||
sbiword_t error;
|
||||
sbiword_t value;
|
||||
|
|
|
@ -4,7 +4,8 @@ kernel_sources += [
|
|||
'extensions/legacy.cpp',
|
||||
'extensions/base.cpp',
|
||||
'extensions/timer.cpp',
|
||||
'extensions/ipi.cpp'
|
||||
'extensions/ipi.cpp',
|
||||
'extensions/rfence.cpp'
|
||||
),
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue