mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 12:21:18 +00:00
kern: further codegen tweaks
This commit is contained in:
parent
4aa18b06e8
commit
1e643f7ab0
7 changed files with 35 additions and 35 deletions
|
@ -53,7 +53,7 @@ namespace ams::kern {
|
|||
|
||||
void Dump();
|
||||
private:
|
||||
bool IsSignaledImpl() const;
|
||||
ALWAYS_INLINE bool IsSignaledImpl() const;
|
||||
void CleanupRequests();
|
||||
};
|
||||
|
||||
|
|
|
@ -54,12 +54,12 @@ namespace ams::kern::svc {
|
|||
public:
|
||||
using T = typename std::remove_const<typename std::remove_pointer<_T>::type>::type;
|
||||
public:
|
||||
static Result CopyFromUserspace(void *dst, const void *src, size_t size) {
|
||||
static ALWAYS_INLINE Result CopyFromUserspace(void *dst, const void *src, size_t size) {
|
||||
R_UNLESS(UserspaceAccess::CopyMemoryFromUser(dst, src, size), svc::ResultInvalidPointer());
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
static Result CopyToUserspace(void *dst, const void *src, size_t size) {
|
||||
static ALWAYS_INLINE Result CopyToUserspace(void *dst, const void *src, size_t size) {
|
||||
R_UNLESS(UserspaceAccess::CopyMemoryToUser(dst, src, size), svc::ResultInvalidPointer());
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -70,12 +70,12 @@ namespace ams::kern::svc {
|
|||
public:
|
||||
using T = typename std::remove_const<typename std::remove_pointer<_T>::type>::type;
|
||||
public:
|
||||
static Result CopyFromUserspace(void *dst, const void *src, size_t size) {
|
||||
static ALWAYS_INLINE Result CopyFromUserspace(void *dst, const void *src, size_t size) {
|
||||
R_UNLESS(UserspaceAccess::CopyMemoryFromUserAligned32Bit(dst, src, size), svc::ResultInvalidPointer());
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
static Result CopyToUserspace(void *dst, const void *src, size_t size) {
|
||||
static ALWAYS_INLINE Result CopyToUserspace(void *dst, const void *src, size_t size) {
|
||||
R_UNLESS(UserspaceAccess::CopyMemoryToUserAligned32Bit(dst, src, size), svc::ResultInvalidPointer());
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -86,12 +86,12 @@ namespace ams::kern::svc {
|
|||
public:
|
||||
using T = typename std::remove_const<typename std::remove_pointer<_T>::type>::type;
|
||||
public:
|
||||
static Result CopyFromUserspace(void *dst, const void *src, size_t size) {
|
||||
static ALWAYS_INLINE Result CopyFromUserspace(void *dst, const void *src, size_t size) {
|
||||
R_UNLESS(UserspaceAccess::CopyMemoryFromUserAligned64Bit(dst, src, size), svc::ResultInvalidPointer());
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
static Result CopyToUserspace(void *dst, const void *src, size_t size) {
|
||||
static ALWAYS_INLINE Result CopyToUserspace(void *dst, const void *src, size_t size) {
|
||||
R_UNLESS(UserspaceAccess::CopyMemoryToUserAligned64Bit(dst, src, size), svc::ResultInvalidPointer());
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -110,26 +110,26 @@ namespace ams::kern::svc {
|
|||
private:
|
||||
CT *m_ptr;
|
||||
private:
|
||||
Result CopyToImpl(void *p, size_t size) const {
|
||||
ALWAYS_INLINE Result CopyToImpl(void *p, size_t size) const {
|
||||
return Traits::CopyFromUserspace(p, m_ptr, size);
|
||||
}
|
||||
|
||||
Result CopyFromImpl(const void *p, size_t size) const {
|
||||
ALWAYS_INLINE Result CopyFromImpl(const void *p, size_t size) const {
|
||||
return Traits::CopyToUserspace(m_ptr, p, size);
|
||||
}
|
||||
protected:
|
||||
Result CopyTo(T *p) const { return this->CopyToImpl(p, sizeof(*p)); }
|
||||
Result CopyFrom(const T *p) const { return this->CopyFromImpl(p, sizeof(*p)); }
|
||||
ALWAYS_INLINE Result CopyTo(T *p) const { return this->CopyToImpl(p, sizeof(*p)); }
|
||||
ALWAYS_INLINE Result CopyFrom(const T *p) const { return this->CopyFromImpl(p, sizeof(*p)); }
|
||||
|
||||
Result CopyArrayElementTo(T *p, size_t index) const { return Traits::CopyFromUserspace(p, m_ptr + index, sizeof(*p)); }
|
||||
Result CopyArrayElementFrom(const T *p, size_t index) const { return Traits::CopyToUserspace(m_ptr + index, p, sizeof(*p)); }
|
||||
ALWAYS_INLINE Result CopyArrayElementTo(T *p, size_t index) const { return Traits::CopyFromUserspace(p, m_ptr + index, sizeof(*p)); }
|
||||
ALWAYS_INLINE Result CopyArrayElementFrom(const T *p, size_t index) const { return Traits::CopyToUserspace(m_ptr + index, p, sizeof(*p)); }
|
||||
|
||||
Result CopyArrayTo(T *arr, size_t count) const { return this->CopyToImpl(arr, sizeof(*arr) * count); }
|
||||
Result CopyArrayFrom(const T *arr, size_t count) const { return this->CopyFromImpl(arr, sizeof(*arr) * count); }
|
||||
ALWAYS_INLINE Result CopyArrayTo(T *arr, size_t count) const { return this->CopyToImpl(arr, sizeof(*arr) * count); }
|
||||
ALWAYS_INLINE Result CopyArrayFrom(const T *arr, size_t count) const { return this->CopyFromImpl(arr, sizeof(*arr) * count); }
|
||||
|
||||
constexpr bool IsNull() const { return m_ptr == nullptr; }
|
||||
constexpr ALWAYS_INLINE bool IsNull() const { return m_ptr == nullptr; }
|
||||
|
||||
constexpr CT *GetUnsafePointer() const { return m_ptr; }
|
||||
constexpr ALWAYS_INLINE CT *GetUnsafePointer() const { return m_ptr; }
|
||||
};
|
||||
|
||||
template<>
|
||||
|
@ -142,19 +142,19 @@ namespace ams::kern::svc {
|
|||
private:
|
||||
const char *ptr;
|
||||
protected:
|
||||
Result CopyStringTo(char *dst, size_t size) const {
|
||||
ALWAYS_INLINE Result CopyStringTo(char *dst, size_t size) const {
|
||||
static_assert(sizeof(char) == 1);
|
||||
R_UNLESS(UserspaceAccess::CopyStringFromUser(dst, this->ptr, size) > 0, svc::ResultInvalidPointer());
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result CopyArrayElementTo(char *dst, size_t index) const {
|
||||
ALWAYS_INLINE Result CopyArrayElementTo(char *dst, size_t index) const {
|
||||
return Traits::CopyFromUserspace(dst, this->ptr + index, sizeof(*dst));
|
||||
}
|
||||
|
||||
constexpr bool IsNull() const { return this->ptr == nullptr; }
|
||||
constexpr ALWAYS_INLINE bool IsNull() const { return this->ptr == nullptr; }
|
||||
|
||||
constexpr const char *GetUnsafePointer() const { return this->ptr; }
|
||||
constexpr ALWAYS_INLINE const char *GetUnsafePointer() const { return this->ptr; }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -583,15 +583,15 @@ namespace ams::kern::board::nintendo::nx {
|
|||
constinit KMemoryControllerInterruptTask g_mc_interrupt_task;
|
||||
|
||||
/* Memory controller utilities. */
|
||||
void SmmuSynchronizationBarrier() {
|
||||
ALWAYS_INLINE void SmmuSynchronizationBarrier() {
|
||||
ReadMcRegister(MC_SMMU_CONFIG);
|
||||
}
|
||||
|
||||
void InvalidatePtc() {
|
||||
ALWAYS_INLINE void InvalidatePtc() {
|
||||
WriteMcRegister(MC_SMMU_PTC_FLUSH_0, 0);
|
||||
}
|
||||
|
||||
void InvalidatePtc(KPhysicalAddress address) {
|
||||
ALWAYS_INLINE void InvalidatePtc(KPhysicalAddress address) {
|
||||
WriteMcRegister(MC_SMMU_PTC_FLUSH_1, (static_cast<u64>(GetInteger(address)) >> 32));
|
||||
WriteMcRegister(MC_SMMU_PTC_FLUSH_0, (GetInteger(address) & 0xFFFFFFF0u) | 1u);
|
||||
}
|
||||
|
@ -606,15 +606,15 @@ namespace ams::kern::board::nintendo::nx {
|
|||
return ((match_asid ? 1u : 0u) << 31) | ((asid & 0x7F) << 24) | (((address & 0xFFC00000u) >> DevicePageBits)) | (match);
|
||||
}
|
||||
|
||||
void InvalidateTlb() {
|
||||
ALWAYS_INLINE void InvalidateTlb() {
|
||||
return WriteMcRegister(MC_SMMU_TLB_FLUSH, EncodeTlbFlushValue(false, 0, 0, TlbFlushVaMatch_All));
|
||||
}
|
||||
|
||||
void InvalidateTlb(u8 asid) {
|
||||
ALWAYS_INLINE void InvalidateTlb(u8 asid) {
|
||||
return WriteMcRegister(MC_SMMU_TLB_FLUSH, EncodeTlbFlushValue(true, asid, 0, TlbFlushVaMatch_All));
|
||||
}
|
||||
|
||||
void InvalidateTlbSection(u8 asid, KDeviceVirtualAddress address) {
|
||||
ALWAYS_INLINE void InvalidateTlbSection(u8 asid, KDeviceVirtualAddress address) {
|
||||
return WriteMcRegister(MC_SMMU_TLB_FLUSH, EncodeTlbFlushValue(true, asid, address, TlbFlushVaMatch_Section));
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace ams::kern {
|
|||
uintptr_t m_msg_buffer_end;
|
||||
uintptr_t m_msg_buffer_space_end;
|
||||
public:
|
||||
static constexpr int GetEntryCount(const ipc::MessageBuffer::MessageHeader &header) {
|
||||
static constexpr ALWAYS_INLINE int GetEntryCount(const ipc::MessageBuffer::MessageHeader &header) {
|
||||
const auto count = header.GetReceiveListCount();
|
||||
switch (count) {
|
||||
case ipc::MessageBuffer::MessageHeader::ReceiveListCountType_None:
|
||||
|
@ -82,7 +82,7 @@ namespace ams::kern {
|
|||
}
|
||||
}
|
||||
|
||||
constexpr bool IsIndex() const {
|
||||
constexpr ALWAYS_INLINE bool IsIndex() const {
|
||||
return m_recv_list_count > ipc::MessageBuffer::MessageHeader::ReceiveListCountType_CountOffset;
|
||||
}
|
||||
|
||||
|
|
|
@ -375,8 +375,8 @@ namespace ams::svc::ipc {
|
|||
u32 *buffer;
|
||||
size_t size;
|
||||
public:
|
||||
constexpr MessageBuffer(u32 *b, size_t sz) : buffer(b), size(sz) { /* ... */ }
|
||||
constexpr explicit MessageBuffer(u32 *b) : buffer(b), size(sizeof(::ams::svc::ThreadLocalRegion::message_buffer)) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE MessageBuffer(u32 *b, size_t sz) : buffer(b), size(sz) { /* ... */ }
|
||||
constexpr explicit ALWAYS_INLINE MessageBuffer(u32 *b) : buffer(b), size(sizeof(::ams::svc::ThreadLocalRegion::message_buffer)) { /* ... */ }
|
||||
|
||||
constexpr ALWAYS_INLINE size_t GetBufferSize() const {
|
||||
return this->size;
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace ams::util {
|
|||
IntrusiveListNode *prev;
|
||||
IntrusiveListNode *next;
|
||||
public:
|
||||
constexpr IntrusiveListNode() : prev(this), next(this) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE IntrusiveListNode() : prev(this), next(this) { /* ... */ }
|
||||
|
||||
constexpr ALWAYS_INLINE bool IsLinked() const {
|
||||
return this->next != this;
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace ams::util {
|
|||
template<class, class, class>
|
||||
friend class IntrusiveRedBlackTree;
|
||||
public:
|
||||
constexpr IntrusiveRedBlackTreeNode() : entry() { /* ... */}
|
||||
constexpr ALWAYS_INLINE IntrusiveRedBlackTreeNode() : entry() { /* ... */}
|
||||
};
|
||||
static_assert(std::is_literal_type<IntrusiveRedBlackTreeNode>::value);
|
||||
|
||||
|
@ -355,11 +355,11 @@ namespace ams::util {
|
|||
/* Generate static implementations for comparison operations for IntrusiveRedBlackTreeRoot. */
|
||||
RB_GENERATE_WITH_COMPARE_STATIC(IntrusiveRedBlackTreeRootWithCompare, IntrusiveRedBlackTreeNode, entry, CompareImpl, LightCompareImpl);
|
||||
private:
|
||||
static int CompareImpl(const IntrusiveRedBlackTreeNode *lhs, const IntrusiveRedBlackTreeNode *rhs) {
|
||||
static ALWAYS_INLINE int CompareImpl(const IntrusiveRedBlackTreeNode *lhs, const IntrusiveRedBlackTreeNode *rhs) {
|
||||
return Comparator::Compare(*Traits::GetParent(lhs), *Traits::GetParent(rhs));
|
||||
}
|
||||
|
||||
static int LightCompareImpl(const void *elm, const IntrusiveRedBlackTreeNode *rhs) {
|
||||
static ALWAYS_INLINE int LightCompareImpl(const void *elm, const IntrusiveRedBlackTreeNode *rhs) {
|
||||
return Comparator::Compare(*static_cast<const_light_pointer>(elm), *Traits::GetParent(rhs));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue