mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-09 22:56:35 +00:00
svc: use m_ for member variables
This commit is contained in:
parent
00116450c3
commit
ce28591ab2
8 changed files with 281 additions and 280 deletions
|
@ -144,11 +144,11 @@ namespace ams::svc::codegen::impl {
|
|||
template<size_t N>
|
||||
class RegisterAllocator {
|
||||
public:
|
||||
std::array<bool, N> map;
|
||||
std::array<bool, N> m_map;
|
||||
public:
|
||||
constexpr explicit RegisterAllocator() : map() { /* ... */ }
|
||||
constexpr explicit RegisterAllocator() : m_map() { /* ... */ }
|
||||
|
||||
constexpr bool IsAllocated(size_t i) const { return this->map[i]; }
|
||||
constexpr bool IsAllocated(size_t i) const { return m_map[i]; }
|
||||
constexpr bool IsFree(size_t i) const { return !this->IsAllocated(i); }
|
||||
|
||||
constexpr void Allocate(size_t i) {
|
||||
|
@ -156,7 +156,7 @@ namespace ams::svc::codegen::impl {
|
|||
std::abort();
|
||||
}
|
||||
|
||||
this->map[i] = true;
|
||||
m_map[i] = true;
|
||||
}
|
||||
|
||||
constexpr bool TryAllocate(size_t i) {
|
||||
|
@ -164,14 +164,14 @@ namespace ams::svc::codegen::impl {
|
|||
return false;
|
||||
}
|
||||
|
||||
this->map[i] = true;
|
||||
m_map[i] = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
constexpr size_t AllocateFirstFree() {
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
if (!this->IsAllocated(i)) {
|
||||
this->map[i] = true;
|
||||
m_map[i] = true;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ namespace ams::svc::codegen::impl {
|
|||
std::abort();
|
||||
}
|
||||
|
||||
this->map[i] = false;
|
||||
m_map[i] = false;
|
||||
}
|
||||
|
||||
constexpr size_t GetRegisterCount() const {
|
||||
|
|
|
@ -26,30 +26,30 @@ namespace ams::svc::codegen::impl {
|
|||
static constexpr size_t InvalidIndex = std::numeric_limits<size_t>::max();
|
||||
public:
|
||||
/* ABI parameters. */
|
||||
Abi abi;
|
||||
Abi m_abi;
|
||||
|
||||
/* Parameter storage. */
|
||||
size_t num_parameters;
|
||||
Parameter parameters[MaxParameters];
|
||||
size_t m_num_parameters;
|
||||
Parameter m_parameters[MaxParameters];
|
||||
public:
|
||||
constexpr explicit ParameterLayout(Abi a)
|
||||
: abi(a), num_parameters(0), parameters()
|
||||
: m_abi(a), m_num_parameters(0), m_parameters()
|
||||
{ /* ... */ }
|
||||
|
||||
constexpr void AddSingle(Parameter::Identifier id, ArgumentType type, size_t ts, size_t ps, bool p, bool b, Storage s, size_t idx) {
|
||||
for (size_t i = 0; i < this->num_parameters; i++) {
|
||||
if (this->parameters[i].Is(id)) {
|
||||
this->parameters[i].AddLocation(Location(s, idx));
|
||||
for (size_t i = 0; i < m_num_parameters; i++) {
|
||||
if (m_parameters[i].Is(id)) {
|
||||
m_parameters[i].AddLocation(Location(s, idx));
|
||||
return;
|
||||
}
|
||||
}
|
||||
this->parameters[this->num_parameters++] = Parameter(id, type, ts, ps, p, b, Location(s, idx));
|
||||
m_parameters[m_num_parameters++] = Parameter(id, type, ts, ps, p, b, Location(s, idx));
|
||||
}
|
||||
|
||||
constexpr size_t Add(Parameter::Identifier id, ArgumentType type, size_t ts, size_t ps, bool p, bool b, Storage s, size_t i) {
|
||||
size_t required_registers = 0;
|
||||
|
||||
while (required_registers * this->abi.register_size < ps) {
|
||||
while (required_registers * m_abi.register_size < ps) {
|
||||
this->AddSingle(id, type, ts, ps, p, b, s, i++);
|
||||
required_registers++;
|
||||
}
|
||||
|
@ -58,8 +58,8 @@ namespace ams::svc::codegen::impl {
|
|||
}
|
||||
|
||||
constexpr bool UsesLocation(Location l) const {
|
||||
for (size_t i = 0; i < this->num_parameters; i++) {
|
||||
if (this->parameters[i].UsesLocation(l)) {
|
||||
for (size_t i = 0; i < m_num_parameters; i++) {
|
||||
if (m_parameters[i].UsesLocation(l)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -75,16 +75,16 @@ namespace ams::svc::codegen::impl {
|
|||
}
|
||||
|
||||
constexpr size_t GetNumParameters() const {
|
||||
return this->num_parameters;
|
||||
return m_num_parameters;
|
||||
}
|
||||
|
||||
constexpr Parameter GetParameter(size_t i) const {
|
||||
return this->parameters[i];
|
||||
return m_parameters[i];
|
||||
}
|
||||
|
||||
constexpr bool HasParameter(Parameter::Identifier id) const {
|
||||
for (size_t i = 0; i < this->num_parameters; i++) {
|
||||
if (this->parameters[i].Is(id)) {
|
||||
for (size_t i = 0; i < m_num_parameters; i++) {
|
||||
if (m_parameters[i].Is(id)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -92,20 +92,21 @@ namespace ams::svc::codegen::impl {
|
|||
}
|
||||
|
||||
constexpr Parameter GetParameter(Parameter::Identifier id) const {
|
||||
for (size_t i = 0; i < this->num_parameters; i++) {
|
||||
if (this->parameters[i].Is(id)) {
|
||||
return this->parameters[i];
|
||||
for (size_t i = 0; i < m_num_parameters; i++) {
|
||||
if (m_parameters[i].Is(id)) {
|
||||
return m_parameters[i];
|
||||
}
|
||||
}
|
||||
std::abort();
|
||||
|
||||
AMS_ASSUME(false);
|
||||
}
|
||||
};
|
||||
|
||||
class ProcedureLayout {
|
||||
public:
|
||||
Abi abi;
|
||||
ParameterLayout input;
|
||||
ParameterLayout output;
|
||||
Abi m_abi;
|
||||
ParameterLayout m_input;
|
||||
ParameterLayout m_output;
|
||||
private:
|
||||
template<typename AbiType, typename ArgType>
|
||||
constexpr void ProcessArgument(size_t i, size_t &NGRN, size_t &NSAA) {
|
||||
|
@ -136,19 +137,19 @@ namespace ams::svc::codegen::impl {
|
|||
const size_t registers_available = AbiType::RegisterCount - NGRN;
|
||||
if constexpr (!PassedByPointer && IsIntegralOrUserPointer<ArgType> && ArgumentTypeSize > AbiType::RegisterSize) {
|
||||
if (registers_available >= 2) {
|
||||
this->input.Add(id, Type, ArgumentTypeSize, ArgumentPassSize, PassedByPointer, IsBoolean, Storage::Register, NGRN);
|
||||
m_input.Add(id, Type, ArgumentTypeSize, ArgumentPassSize, PassedByPointer, IsBoolean, Storage::Register, NGRN);
|
||||
NGRN += 2;
|
||||
} else {
|
||||
/* Argument went on stack, so stop allocating arguments in registers. */
|
||||
NGRN = AbiType::RegisterCount;
|
||||
|
||||
NSAA += (NSAA & 1);
|
||||
this->input.Add(id, Type, ArgumentTypeSize, ArgumentPassSize, PassedByPointer, IsBoolean, Storage::Stack, NSAA);
|
||||
m_input.Add(id, Type, ArgumentTypeSize, ArgumentPassSize, PassedByPointer, IsBoolean, Storage::Stack, NSAA);
|
||||
NSAA += 2;
|
||||
}
|
||||
} else {
|
||||
if (ArgumentPassSize <= AbiType::RegisterSize * registers_available) {
|
||||
NGRN += this->input.Add(id, Type, ArgumentTypeSize, ArgumentPassSize, PassedByPointer, IsBoolean, Storage::Register, NGRN);
|
||||
NGRN += m_input.Add(id, Type, ArgumentTypeSize, ArgumentPassSize, PassedByPointer, IsBoolean, Storage::Register, NGRN);
|
||||
} else {
|
||||
/* Argument went on stack, so stop allocating arguments in registers. */
|
||||
NGRN = AbiType::RegisterCount;
|
||||
|
@ -156,12 +157,12 @@ namespace ams::svc::codegen::impl {
|
|||
/* TODO: Stack pointer alignment is only ensured for aapcs64. */
|
||||
/* What should we do here? */
|
||||
|
||||
NSAA += this->input.Add(id, Type, ArgumentTypeSize, ArgumentPassSize, PassedByPointer, IsBoolean, Storage::Stack, NSAA);
|
||||
NSAA += m_input.Add(id, Type, ArgumentTypeSize, ArgumentPassSize, PassedByPointer, IsBoolean, Storage::Stack, NSAA);
|
||||
}
|
||||
}
|
||||
}
|
||||
public:
|
||||
constexpr explicit ProcedureLayout(Abi a) : abi(a), input(a), output(a) { /* ... */ }
|
||||
constexpr explicit ProcedureLayout(Abi a) : m_abi(a), m_input(a), m_output(a) { /* ... */ }
|
||||
|
||||
template<typename AbiType, typename ReturnType, typename... ArgumentTypes>
|
||||
static constexpr ProcedureLayout Create() {
|
||||
|
@ -177,7 +178,7 @@ namespace ams::svc::codegen::impl {
|
|||
/* TODO: It's unclear how to handle the non-integral and too-large case. */
|
||||
if constexpr (!std::is_same<ReturnType, void>::value) {
|
||||
constexpr size_t ReturnTypeSize = AbiType::template Size<ReturnType>;
|
||||
layout.output.Add(Parameter::Identifier("ReturnType"), ArgumentType::Invalid, ReturnTypeSize, ReturnTypeSize, false, false /* TODO */, Storage::Register, 0);
|
||||
layout.m_output.Add(Parameter::Identifier("ReturnType"), ArgumentType::Invalid, ReturnTypeSize, ReturnTypeSize, false, false /* TODO */, Storage::Register, 0);
|
||||
static_assert(IsIntegral<ReturnType> || ReturnTypeSize <= AbiType::RegisterSize);
|
||||
}
|
||||
|
||||
|
@ -189,27 +190,27 @@ namespace ams::svc::codegen::impl {
|
|||
}
|
||||
|
||||
constexpr ParameterLayout GetInputLayout() const {
|
||||
return this->input;
|
||||
return m_input;
|
||||
}
|
||||
|
||||
constexpr ParameterLayout GetOutputLayout() const {
|
||||
return this->output;
|
||||
return m_output;
|
||||
}
|
||||
|
||||
constexpr Parameter GetParameter(Parameter::Identifier id) const {
|
||||
if (this->input.HasParameter(id)) {
|
||||
return this->input.GetParameter(id);
|
||||
if (m_input.HasParameter(id)) {
|
||||
return m_input.GetParameter(id);
|
||||
} else {
|
||||
return this->output.GetParameter(id);
|
||||
return m_output.GetParameter(id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class SvcInvocationLayout {
|
||||
public:
|
||||
Abi abi;
|
||||
ParameterLayout input;
|
||||
ParameterLayout output;
|
||||
Abi m_abi;
|
||||
ParameterLayout m_input;
|
||||
ParameterLayout m_output;
|
||||
private:
|
||||
template<typename F>
|
||||
constexpr void ForEachInputArgument(ParameterLayout param_layout, F f) {
|
||||
|
@ -296,7 +297,7 @@ namespace ams::svc::codegen::impl {
|
|||
}
|
||||
}
|
||||
public:
|
||||
constexpr explicit SvcInvocationLayout(Abi a) : abi(a), input(a), output(a) { /* ... */ }
|
||||
constexpr explicit SvcInvocationLayout(Abi a) : m_abi(a), m_input(a), m_output(a) { /* ... */ }
|
||||
|
||||
template<typename AbiType>
|
||||
static constexpr SvcInvocationLayout Create(ProcedureLayout procedure_layout) {
|
||||
|
@ -305,17 +306,17 @@ namespace ams::svc::codegen::impl {
|
|||
|
||||
/* Input first wants to map in register -> register */
|
||||
layout.ForEachInputArgument(procedure_layout.GetInputLayout(), [&](Parameter parameter) {
|
||||
AddRegisterParameter(layout.input, input_register_allocator, parameter);
|
||||
AddRegisterParameter(layout.m_input, input_register_allocator, parameter);
|
||||
});
|
||||
|
||||
/* And then input wants to map in stack -> stack */
|
||||
layout.ForEachInputArgument(procedure_layout.GetInputLayout(), [&](Parameter parameter) {
|
||||
AddStackParameter(layout.input, input_register_allocator, parameter);
|
||||
AddStackParameter(layout.m_input, input_register_allocator, parameter);
|
||||
});
|
||||
|
||||
/* And then input wants to map in indirects -> register */
|
||||
layout.ForEachInputPointerArgument(procedure_layout.GetInputLayout(), [&](Parameter parameter) {
|
||||
AddIndirectParameter<AbiType>(layout.input, input_register_allocator, parameter);
|
||||
AddIndirectParameter<AbiType>(layout.m_input, input_register_allocator, parameter);
|
||||
});
|
||||
|
||||
/* Handle the return type. */
|
||||
|
@ -327,23 +328,23 @@ namespace ams::svc::codegen::impl {
|
|||
if (return_param.GetIdentifier() != Parameter::Identifier("ReturnType")) {
|
||||
std::abort();
|
||||
}
|
||||
AddRegisterParameter(layout.output, output_register_allocator, return_param);
|
||||
AddRegisterParameter(layout.m_output, output_register_allocator, return_param);
|
||||
}
|
||||
|
||||
/* Handle other outputs. */
|
||||
layout.ForEachOutputArgument(procedure_layout.GetInputLayout(), [&](Parameter parameter) {
|
||||
AddIndirectParameter<AbiType>(layout.output, output_register_allocator, parameter);
|
||||
AddIndirectParameter<AbiType>(layout.m_output, output_register_allocator, parameter);
|
||||
});
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
constexpr ParameterLayout GetInputLayout() const {
|
||||
return this->input;
|
||||
return m_input;
|
||||
}
|
||||
|
||||
constexpr ParameterLayout GetOutputLayout() const {
|
||||
return this->output;
|
||||
return m_output;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -82,21 +82,21 @@ namespace ams::svc::codegen::impl {
|
|||
return op;
|
||||
}
|
||||
public:
|
||||
size_t num_operations;
|
||||
std::array<Operation, MaxOperations> operations;
|
||||
size_t m_num_operations;
|
||||
std::array<Operation, MaxOperations> m_operations;
|
||||
public:
|
||||
constexpr explicit MetaCode() : num_operations(0), operations() { /* ... */ }
|
||||
constexpr explicit MetaCode() : m_num_operations(0), m_operations() { /* ... */ }
|
||||
|
||||
constexpr size_t GetNumOperations() const {
|
||||
return this->num_operations;
|
||||
return m_num_operations;
|
||||
}
|
||||
|
||||
constexpr Operation GetOperation(size_t i) const {
|
||||
return this->operations[i];
|
||||
return m_operations[i];
|
||||
}
|
||||
|
||||
constexpr void AddOperation(Operation op) {
|
||||
this->operations[this->num_operations++] = op;
|
||||
m_operations[m_num_operations++] = op;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -140,102 +140,102 @@ namespace ams::svc::codegen::impl {
|
|||
private:
|
||||
using OperationKind = typename MetaCode::OperationKind;
|
||||
private:
|
||||
MetaCode meta_code;
|
||||
MetaCode m_meta_code;
|
||||
public:
|
||||
constexpr explicit MetaCodeGenerator() : meta_code() { /* ... */ }
|
||||
constexpr explicit MetaCodeGenerator() : m_meta_code() { /* ... */ }
|
||||
|
||||
constexpr MetaCode GetMetaCode() const {
|
||||
return this->meta_code;
|
||||
return m_meta_code;
|
||||
}
|
||||
|
||||
constexpr void AddOperationDirectly(MetaCode::Operation op) {
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
|
||||
template<size_t... Registers>
|
||||
constexpr void SaveRegisters() {
|
||||
constexpr auto op = MetaCode::MakeOperation<OperationKind::SaveRegisters, Registers...>();
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
|
||||
template<size_t... Registers>
|
||||
constexpr void RestoreRegisters() {
|
||||
constexpr auto op = MetaCode::MakeOperation<OperationKind::RestoreRegisters, Registers...>();
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
|
||||
template<size_t... Registers>
|
||||
constexpr void ClearRegisters() {
|
||||
constexpr auto op = MetaCode::MakeOperation<OperationKind::ClearRegisters, Registers...>();
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
|
||||
template<size_t Size>
|
||||
constexpr void AllocateStackSpace() {
|
||||
constexpr auto op = MetaCode::MakeOperation<OperationKind::AllocateStackSpace, Size>();
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
|
||||
template<size_t Size>
|
||||
constexpr void FreeStackSpace() {
|
||||
constexpr auto op = MetaCode::MakeOperation<OperationKind::FreeStackSpace, Size>();
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
|
||||
template<size_t Dst, size_t Src>
|
||||
constexpr void MoveRegister() {
|
||||
constexpr auto op = MetaCode::MakeOperation<OperationKind::MoveRegister, Dst, Src>();
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
|
||||
template<size_t Reg>
|
||||
constexpr void ConvertToBoolean() {
|
||||
constexpr auto op = MetaCode::MakeOperation<OperationKind::ConvertToBoolean, Reg>();
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
|
||||
template<size_t Reg, size_t Offset, size_t Size = 0>
|
||||
constexpr void LoadFromStack() {
|
||||
constexpr auto op = MetaCode::MakeOperation<OperationKind::LoadFromStack, Reg, Offset, Size>();
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
|
||||
template<size_t Reg0, size_t Reg1, size_t Offset, size_t Size>
|
||||
constexpr void LoadPairFromStack() {
|
||||
static_assert(Offset % Size == 0);
|
||||
constexpr auto op = MetaCode::MakeOperation<OperationKind::LoadPairFromStack, Reg0, Reg1, Offset, Size>();
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
|
||||
template<size_t Reg, size_t Offset, size_t Size = 0>
|
||||
constexpr void StoreToStack() {
|
||||
constexpr auto op = MetaCode::MakeOperation<OperationKind::StoreToStack, Reg, Offset, Size>();
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
|
||||
template<size_t Reg0, size_t Reg1, size_t Offset, size_t Size>
|
||||
constexpr void StorePairToStack() {
|
||||
static_assert(Offset % Size == 0);
|
||||
constexpr auto op = MetaCode::MakeOperation<OperationKind::StorePairToStack, Reg0, Reg1, Offset, Size>();
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
|
||||
template<size_t Dst, size_t Low, size_t High>
|
||||
constexpr void Pack() {
|
||||
constexpr auto op = MetaCode::MakeOperation<OperationKind::Pack, Dst, Low, High>();
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
|
||||
template<size_t Low, size_t High, size_t Src>
|
||||
constexpr void Unpack() {
|
||||
constexpr auto op = MetaCode::MakeOperation<OperationKind::Unpack, Low, High, Src>();
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
|
||||
template<size_t Dst, size_t Offset>
|
||||
constexpr void LoadStackAddress() {
|
||||
constexpr auto op = MetaCode::MakeOperation<OperationKind::LoadStackAddress, Dst, Offset>();
|
||||
this->meta_code.AddOperation(op);
|
||||
m_meta_code.AddOperation(op);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -28,40 +28,40 @@ namespace ams::svc::codegen::impl {
|
|||
private:
|
||||
static constexpr size_t InvalidIndex = std::numeric_limits<size_t>::max();
|
||||
public:
|
||||
Storage storage;
|
||||
size_t index;
|
||||
Storage m_storage;
|
||||
size_t m_index;
|
||||
public:
|
||||
constexpr explicit Location() : storage(Storage::Invalid), index(InvalidIndex) { /* ... */ }
|
||||
constexpr explicit Location(Storage s, size_t i) : storage(s), index(i) { /* ... */ }
|
||||
constexpr explicit Location() : m_storage(Storage::Invalid), m_index(InvalidIndex) { /* ... */ }
|
||||
constexpr explicit Location(Storage s, size_t i) : m_storage(s), m_index(i) { /* ... */ }
|
||||
|
||||
constexpr size_t GetIndex() const { return this->index; }
|
||||
constexpr Storage GetStorage() const { return this->storage; }
|
||||
constexpr size_t GetIndex() const { return m_index; }
|
||||
constexpr Storage GetStorage() const { return m_storage; }
|
||||
|
||||
constexpr bool IsValid() const {
|
||||
return this->index != InvalidIndex && this->storage != Storage::Invalid;
|
||||
return m_index != InvalidIndex && m_storage != Storage::Invalid;
|
||||
}
|
||||
|
||||
constexpr bool operator==(const Location &rhs) const {
|
||||
return this->index == rhs.index && this->storage == rhs.storage;
|
||||
return m_index == rhs.m_index && m_storage == rhs.m_storage;
|
||||
}
|
||||
|
||||
constexpr bool operator<(const Location &rhs) const {
|
||||
if (this->storage < rhs.storage) {
|
||||
if (m_storage < rhs.m_storage) {
|
||||
return true;
|
||||
} else if (this->storage > rhs.storage) {
|
||||
} else if (m_storage > rhs.m_storage) {
|
||||
return false;
|
||||
} else {
|
||||
return this->index < rhs.index;
|
||||
return m_index < rhs.m_index;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr bool operator>(const Location &rhs) const {
|
||||
if (this->storage > rhs.storage) {
|
||||
if (m_storage > rhs.m_storage) {
|
||||
return true;
|
||||
} else if (this->storage < rhs.storage) {
|
||||
} else if (m_storage < rhs.m_storage) {
|
||||
return false;
|
||||
} else {
|
||||
return this->index > rhs.index;
|
||||
return m_index > rhs.m_index;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,23 +76,23 @@ namespace ams::svc::codegen::impl {
|
|||
static constexpr size_t IdentifierLengthMax = 0x40;
|
||||
class Identifier {
|
||||
public:
|
||||
char name[IdentifierLengthMax];
|
||||
size_t index;
|
||||
char m_name[IdentifierLengthMax];
|
||||
size_t m_index;
|
||||
public:
|
||||
constexpr explicit Identifier() : name(), index() { /* ... */ }
|
||||
constexpr explicit Identifier(const char *nm, size_t idx = 0) : name(), index(idx) {
|
||||
constexpr explicit Identifier() : m_name(), m_index() { /* ... */ }
|
||||
constexpr explicit Identifier(const char *nm, size_t idx = 0) : m_name(), m_index(idx) {
|
||||
for (size_t i = 0; i < IdentifierLengthMax && nm[i]; i++) {
|
||||
this->name[i] = nm[i];
|
||||
m_name[i] = nm[i];
|
||||
}
|
||||
}
|
||||
|
||||
constexpr bool operator==(const Identifier &rhs) const {
|
||||
for (size_t i = 0; i < IdentifierLengthMax; i++) {
|
||||
if (this->name[i] != rhs.name[i]) {
|
||||
if (m_name[i] != rhs.m_name[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return this->index == rhs.index;
|
||||
return m_index == rhs.m_index;
|
||||
}
|
||||
|
||||
constexpr bool operator!=(const Identifier &rhs) const {
|
||||
|
@ -100,68 +100,68 @@ namespace ams::svc::codegen::impl {
|
|||
}
|
||||
};
|
||||
public:
|
||||
Identifier identifier;
|
||||
ArgumentType type;
|
||||
size_t type_size;
|
||||
size_t passed_size;
|
||||
bool passed_by_pointer;
|
||||
bool is_boolean;
|
||||
size_t num_locations;
|
||||
Location locations[MaxLocations];
|
||||
Identifier m_identifier;
|
||||
ArgumentType m_type;
|
||||
size_t m_type_size;
|
||||
size_t m_passed_size;
|
||||
bool m_passed_by_pointer;
|
||||
bool m_is_boolean;
|
||||
size_t m_num_locations;
|
||||
Location m_locations[MaxLocations];
|
||||
public:
|
||||
constexpr explicit Parameter()
|
||||
: identifier(), type(ArgumentType::Invalid), type_size(0), passed_size(0), passed_by_pointer(0), is_boolean(0), num_locations(0), locations()
|
||||
: m_identifier(), m_type(ArgumentType::Invalid), m_type_size(0), m_passed_size(0), m_passed_by_pointer(0), m_is_boolean(0), m_num_locations(0), m_locations()
|
||||
{ /* ... */ }
|
||||
|
||||
constexpr explicit Parameter(Identifier id, ArgumentType t, size_t ts, size_t ps, bool p, bool b, Location l)
|
||||
: identifier(id), type(t), type_size(ts), passed_size(ps), passed_by_pointer(p), is_boolean(b), num_locations(1), locations()
|
||||
: m_identifier(id), m_type(t), m_type_size(ts), m_passed_size(ps), m_passed_by_pointer(p), m_is_boolean(b), m_num_locations(1), m_locations()
|
||||
{
|
||||
this->locations[0] = l;
|
||||
m_locations[0] = l;
|
||||
}
|
||||
|
||||
constexpr Identifier GetIdentifier() const {
|
||||
return this->identifier;
|
||||
return m_identifier;
|
||||
}
|
||||
|
||||
constexpr bool Is(Identifier rhs) const {
|
||||
return this->identifier == rhs;
|
||||
return m_identifier == rhs;
|
||||
}
|
||||
|
||||
constexpr ArgumentType GetArgumentType() const {
|
||||
return this->type;
|
||||
return m_type;
|
||||
}
|
||||
|
||||
constexpr size_t GetTypeSize() const {
|
||||
return this->type_size;
|
||||
return m_type_size;
|
||||
}
|
||||
|
||||
constexpr size_t GetPassedSize() const {
|
||||
return this->passed_size;
|
||||
return m_passed_size;
|
||||
}
|
||||
|
||||
constexpr bool IsPassedByPointer() const {
|
||||
return this->passed_by_pointer;
|
||||
return m_passed_by_pointer;
|
||||
}
|
||||
|
||||
constexpr bool IsBoolean() const {
|
||||
return this->is_boolean;
|
||||
return m_is_boolean;
|
||||
}
|
||||
|
||||
constexpr size_t GetNumLocations() const {
|
||||
return this->num_locations;
|
||||
return m_num_locations;
|
||||
}
|
||||
|
||||
constexpr Location GetLocation(size_t i) const {
|
||||
return this->locations[i];
|
||||
return m_locations[i];
|
||||
}
|
||||
|
||||
constexpr void AddLocation(Location l) {
|
||||
this->locations[this->num_locations++] = l;
|
||||
m_locations[m_num_locations++] = l;
|
||||
}
|
||||
|
||||
constexpr bool UsesLocation(Location l) const {
|
||||
for (size_t i = 0; i < this->num_locations; i++) {
|
||||
if (this->locations[i] == l) {
|
||||
for (size_t i = 0; i < m_num_locations; i++) {
|
||||
if (m_locations[i] == l) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -169,19 +169,19 @@ namespace ams::svc::codegen::impl {
|
|||
}
|
||||
|
||||
constexpr bool operator==(const Parameter &rhs) const {
|
||||
if (!(this->identifier == rhs.identifier &&
|
||||
this->type == rhs.type &&
|
||||
this->type_size == rhs.type_size &&
|
||||
this->passed_size == rhs.passed_size &&
|
||||
this->passed_by_pointer == rhs.passed_by_pointer &&
|
||||
this->is_boolean == rhs.is_boolean &&
|
||||
this->num_locations == rhs.num_locations))
|
||||
if (!(m_identifier == rhs.m_identifier &&
|
||||
m_type == rhs.m_type &&
|
||||
m_type_size == rhs.m_type_size &&
|
||||
m_passed_size == rhs.m_passed_size &&
|
||||
m_passed_by_pointer == rhs.m_passed_by_pointer &&
|
||||
m_is_boolean == rhs.m_is_boolean &&
|
||||
m_num_locations == rhs.m_num_locations))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < this->num_locations; i++) {
|
||||
if (!(this->locations[i] == rhs.locations[i])) {
|
||||
for (size_t i = 0; i < m_num_locations; i++) {
|
||||
if (!(m_locations[i] == rhs.m_locations[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,48 +59,48 @@ namespace ams::svc::ipc {
|
|||
ReceiveListCountType_CountMax = 13,
|
||||
};
|
||||
private:
|
||||
util::BitPack32 header[2];
|
||||
util::BitPack32 m_header[2];
|
||||
public:
|
||||
constexpr ALWAYS_INLINE MessageHeader() : header{util::BitPack32{0}, util::BitPack32{0}} {
|
||||
this->header[0].Set<Tag>(NullTag);
|
||||
constexpr ALWAYS_INLINE MessageHeader() : m_header{util::BitPack32{0}, util::BitPack32{0}} {
|
||||
m_header[0].Set<Tag>(NullTag);
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE MessageHeader(u16 tag, bool special, s32 ptr, s32 send, s32 recv, s32 exch, s32 raw, s32 recv_list) : header{util::BitPack32{0}, util::BitPack32{0}} {
|
||||
this->header[0].Set<Tag>(tag);
|
||||
this->header[0].Set<PointerCount>(ptr);
|
||||
this->header[0].Set<SendCount>(send);
|
||||
this->header[0].Set<ReceiveCount>(recv);
|
||||
this->header[0].Set<ExchangeCount>(exch);
|
||||
constexpr ALWAYS_INLINE MessageHeader(u16 tag, bool special, s32 ptr, s32 send, s32 recv, s32 exch, s32 raw, s32 recv_list) : m_header{util::BitPack32{0}, util::BitPack32{0}} {
|
||||
m_header[0].Set<Tag>(tag);
|
||||
m_header[0].Set<PointerCount>(ptr);
|
||||
m_header[0].Set<SendCount>(send);
|
||||
m_header[0].Set<ReceiveCount>(recv);
|
||||
m_header[0].Set<ExchangeCount>(exch);
|
||||
|
||||
this->header[1].Set<RawCount>(raw);
|
||||
this->header[1].Set<ReceiveListCount>(recv_list);
|
||||
this->header[1].Set<HasSpecialHeader>(special);
|
||||
m_header[1].Set<RawCount>(raw);
|
||||
m_header[1].Set<ReceiveListCount>(recv_list);
|
||||
m_header[1].Set<HasSpecialHeader>(special);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE explicit MessageHeader(const MessageBuffer &buf) : header{util::BitPack32{0}, util::BitPack32{0}} {
|
||||
buf.Get(0, this->header, util::size(this->header));
|
||||
ALWAYS_INLINE explicit MessageHeader(const MessageBuffer &buf) : m_header{util::BitPack32{0}, util::BitPack32{0}} {
|
||||
buf.Get(0, m_header, util::size(m_header));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE explicit MessageHeader(const u32 *msg) : header{util::BitPack32{msg[0]}, util::BitPack32{msg[1]}} { /* ... */ }
|
||||
ALWAYS_INLINE explicit MessageHeader(const u32 *msg) : m_header{util::BitPack32{msg[0]}, util::BitPack32{msg[1]}} { /* ... */ }
|
||||
|
||||
constexpr ALWAYS_INLINE u16 GetTag() const {
|
||||
return this->header[0].Get<Tag>();
|
||||
return m_header[0].Get<Tag>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE s32 GetPointerCount() const {
|
||||
return this->header[0].Get<PointerCount>();
|
||||
return m_header[0].Get<PointerCount>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE s32 GetSendCount() const {
|
||||
return this->header[0].Get<SendCount>();
|
||||
return m_header[0].Get<SendCount>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE s32 GetReceiveCount() const {
|
||||
return this->header[0].Get<ReceiveCount>();
|
||||
return m_header[0].Get<ReceiveCount>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE s32 GetExchangeCount() const {
|
||||
return this->header[0].Get<ExchangeCount>();
|
||||
return m_header[0].Get<ExchangeCount>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE s32 GetMapAliasCount() const {
|
||||
|
@ -108,31 +108,31 @@ namespace ams::svc::ipc {
|
|||
}
|
||||
|
||||
constexpr ALWAYS_INLINE s32 GetRawCount() const {
|
||||
return this->header[1].Get<RawCount>();
|
||||
return m_header[1].Get<RawCount>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE s32 GetReceiveListCount() const {
|
||||
return this->header[1].Get<ReceiveListCount>();
|
||||
return m_header[1].Get<ReceiveListCount>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE s32 GetReceiveListOffset() const {
|
||||
return this->header[1].Get<ReceiveListOffset>();
|
||||
return m_header[1].Get<ReceiveListOffset>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE bool GetHasSpecialHeader() const {
|
||||
return this->header[1].Get<HasSpecialHeader>();
|
||||
return m_header[1].Get<HasSpecialHeader>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE void SetReceiveListCount(s32 recv_list) {
|
||||
this->header[1].Set<ReceiveListCount>(recv_list);
|
||||
m_header[1].Set<ReceiveListCount>(recv_list);
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE const util::BitPack32 *GetData() const {
|
||||
return this->header;
|
||||
return m_header;
|
||||
}
|
||||
|
||||
static constexpr ALWAYS_INLINE size_t GetDataSize() {
|
||||
return sizeof(header);
|
||||
return sizeof(m_header);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -143,55 +143,55 @@ namespace ams::svc::ipc {
|
|||
using CopyHandleCount = util::BitPack32::Field<HasProcessId::Next, 4, s32>;
|
||||
using MoveHandleCount = util::BitPack32::Field<CopyHandleCount::Next, 4, s32>;
|
||||
private:
|
||||
util::BitPack32 header;
|
||||
bool has_header;
|
||||
util::BitPack32 m_header;
|
||||
bool m_has_header;
|
||||
public:
|
||||
constexpr ALWAYS_INLINE explicit SpecialHeader(bool pid, s32 copy, s32 move) : header{0}, has_header(true) {
|
||||
this->header.Set<HasProcessId>(pid);
|
||||
this->header.Set<CopyHandleCount>(copy);
|
||||
this->header.Set<MoveHandleCount>(move);
|
||||
constexpr ALWAYS_INLINE explicit SpecialHeader(bool pid, s32 copy, s32 move) : m_header{0}, m_has_header(true) {
|
||||
m_header.Set<HasProcessId>(pid);
|
||||
m_header.Set<CopyHandleCount>(copy);
|
||||
m_header.Set<MoveHandleCount>(move);
|
||||
}
|
||||
|
||||
consteval explicit SpecialHeader(bool pid, s32 copy, s32 move, bool _has_header) : header{0}, has_header(_has_header) {
|
||||
this->header.Set<HasProcessId>(pid);
|
||||
this->header.Set<CopyHandleCount>(copy);
|
||||
this->header.Set<MoveHandleCount>(move);
|
||||
consteval explicit SpecialHeader(bool pid, s32 copy, s32 move, bool _has_header) : m_header{0}, m_has_header(_has_header) {
|
||||
m_header.Set<HasProcessId>(pid);
|
||||
m_header.Set<CopyHandleCount>(copy);
|
||||
m_header.Set<MoveHandleCount>(move);
|
||||
|
||||
AMS_ASSUME(this->has_header == (this->GetHasProcessId() || this->GetCopyHandleCount() > 0 || this->GetMoveHandleCount() > 0));
|
||||
AMS_ASSUME(m_has_header == (this->GetHasProcessId() || this->GetCopyHandleCount() > 0 || this->GetMoveHandleCount() > 0));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE explicit SpecialHeader(const MessageBuffer &buf, const MessageHeader &hdr) : header{0}, has_header(hdr.GetHasSpecialHeader()) {
|
||||
if (this->has_header) {
|
||||
buf.Get(MessageHeader::GetDataSize() / sizeof(util::BitPack32), std::addressof(this->header), sizeof(this->header) / sizeof(util::BitPack32));
|
||||
ALWAYS_INLINE explicit SpecialHeader(const MessageBuffer &buf, const MessageHeader &hdr) : m_header{0}, m_has_header(hdr.GetHasSpecialHeader()) {
|
||||
if (m_has_header) {
|
||||
buf.Get(MessageHeader::GetDataSize() / sizeof(util::BitPack32), std::addressof(m_header), sizeof(m_header) / sizeof(util::BitPack32));
|
||||
}
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE bool GetHasProcessId() const {
|
||||
return this->header.Get<HasProcessId>();
|
||||
return m_header.Get<HasProcessId>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE s32 GetCopyHandleCount() const {
|
||||
return this->header.Get<CopyHandleCount>();
|
||||
return m_header.Get<CopyHandleCount>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE s32 GetMoveHandleCount() const {
|
||||
return this->header.Get<MoveHandleCount>();
|
||||
return m_header.Get<MoveHandleCount>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE const util::BitPack32 *GetHeader() const {
|
||||
return std::addressof(this->header);
|
||||
return std::addressof(m_header);
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE size_t GetHeaderSize() const {
|
||||
if (this->has_header) {
|
||||
return sizeof(this->header);
|
||||
if (m_has_header) {
|
||||
return sizeof(m_header);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE size_t GetDataSize() const {
|
||||
if (this->has_header) {
|
||||
if (m_has_header) {
|
||||
return (this->GetHasProcessId() ? sizeof(u64) : 0) +
|
||||
(this->GetCopyHandleCount() * sizeof(Handle)) +
|
||||
(this->GetMoveHandleCount() * sizeof(Handle));
|
||||
|
@ -228,46 +228,46 @@ namespace ams::svc::ipc {
|
|||
return static_cast<u32>(address >> (AddressLow::Count + AddressMid::Count));
|
||||
}
|
||||
private:
|
||||
util::BitPack32 data[3];
|
||||
util::BitPack32 m_data[3];
|
||||
public:
|
||||
constexpr ALWAYS_INLINE MapAliasDescriptor() : data{util::BitPack32{0}, util::BitPack32{0}, util::BitPack32{0}} { /* ... */ }
|
||||
constexpr ALWAYS_INLINE MapAliasDescriptor() : m_data{util::BitPack32{0}, util::BitPack32{0}, util::BitPack32{0}} { /* ... */ }
|
||||
|
||||
ALWAYS_INLINE MapAliasDescriptor(const void *buffer, size_t _size, Attribute attr = Attribute_Ipc) : data{util::BitPack32{0}, util::BitPack32{0}, util::BitPack32{0}} {
|
||||
ALWAYS_INLINE MapAliasDescriptor(const void *buffer, size_t _size, Attribute attr = Attribute_Ipc) : m_data{util::BitPack32{0}, util::BitPack32{0}, util::BitPack32{0}} {
|
||||
const u64 address = reinterpret_cast<u64>(buffer);
|
||||
const u64 size = static_cast<u64>(_size);
|
||||
this->data[0] = { static_cast<u32>(size) };
|
||||
this->data[1] = { static_cast<u32>(address) };
|
||||
m_data[0] = { static_cast<u32>(size) };
|
||||
m_data[1] = { static_cast<u32>(address) };
|
||||
|
||||
this->data[2].Set<Attributes>(attr);
|
||||
this->data[2].Set<AddressMid>(GetAddressMid(address));
|
||||
this->data[2].Set<SizeHigh>(static_cast<u32>(size >> SizeLow::Count));
|
||||
this->data[2].Set<AddressHigh>(GetAddressHigh(address));
|
||||
m_data[2].Set<Attributes>(attr);
|
||||
m_data[2].Set<AddressMid>(GetAddressMid(address));
|
||||
m_data[2].Set<SizeHigh>(static_cast<u32>(size >> SizeLow::Count));
|
||||
m_data[2].Set<AddressHigh>(GetAddressHigh(address));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE MapAliasDescriptor(const MessageBuffer &buf, s32 index) : data{util::BitPack32{0}, util::BitPack32{0}, util::BitPack32{0}} {
|
||||
buf.Get(index, this->data, util::size(this->data));
|
||||
ALWAYS_INLINE MapAliasDescriptor(const MessageBuffer &buf, s32 index) : m_data{util::BitPack32{0}, util::BitPack32{0}, util::BitPack32{0}} {
|
||||
buf.Get(index, m_data, util::size(m_data));
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE uintptr_t GetAddress() const {
|
||||
const u64 address = (static_cast<u64>((this->data[2].Get<AddressHigh>() << AddressMid::Count) | this->data[2].Get<AddressMid>()) << AddressLow::Count) | this->data[1].Get<AddressLow>();
|
||||
const u64 address = (static_cast<u64>((m_data[2].Get<AddressHigh>() << AddressMid::Count) | m_data[2].Get<AddressMid>()) << AddressLow::Count) | m_data[1].Get<AddressLow>();
|
||||
return address;
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE uintptr_t GetSize() const {
|
||||
const u64 size = (static_cast<u64>(this->data[2].Get<SizeHigh>()) << SizeLow::Count) | this->data[0].Get<SizeLow>();
|
||||
const u64 size = (static_cast<u64>(m_data[2].Get<SizeHigh>()) << SizeLow::Count) | m_data[0].Get<SizeLow>();
|
||||
return size;
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE Attribute GetAttribute() const {
|
||||
return this->data[2].Get<Attributes>();
|
||||
return m_data[2].Get<Attributes>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE const util::BitPack32 *GetData() const {
|
||||
return this->data;
|
||||
return m_data;
|
||||
}
|
||||
|
||||
static constexpr ALWAYS_INLINE size_t GetDataSize() {
|
||||
return sizeof(data);
|
||||
return sizeof(m_data);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -292,44 +292,44 @@ namespace ams::svc::ipc {
|
|||
return static_cast<u32>(address >> (AddressLow::Count + AddressMid::Count));
|
||||
}
|
||||
private:
|
||||
util::BitPack32 data[2];
|
||||
util::BitPack32 m_data[2];
|
||||
public:
|
||||
constexpr ALWAYS_INLINE PointerDescriptor() : data{util::BitPack32{0}, util::BitPack32{0}} { /* ... */ }
|
||||
constexpr ALWAYS_INLINE PointerDescriptor() : m_data{util::BitPack32{0}, util::BitPack32{0}} { /* ... */ }
|
||||
|
||||
ALWAYS_INLINE PointerDescriptor(const void *buffer, size_t size, s32 index) : data{util::BitPack32{0}, util::BitPack32{0}} {
|
||||
ALWAYS_INLINE PointerDescriptor(const void *buffer, size_t size, s32 index) : m_data{util::BitPack32{0}, util::BitPack32{0}} {
|
||||
const u64 address = reinterpret_cast<u64>(buffer);
|
||||
|
||||
this->data[0].Set<Index>(index);
|
||||
this->data[0].Set<AddressHigh>(GetAddressHigh(address));
|
||||
this->data[0].Set<AddressMid>(GetAddressMid(address));
|
||||
this->data[0].Set<Size>(size);
|
||||
m_data[0].Set<Index>(index);
|
||||
m_data[0].Set<AddressHigh>(GetAddressHigh(address));
|
||||
m_data[0].Set<AddressMid>(GetAddressMid(address));
|
||||
m_data[0].Set<Size>(size);
|
||||
|
||||
this->data[1] = { static_cast<u32>(address) };
|
||||
m_data[1] = { static_cast<u32>(address) };
|
||||
}
|
||||
|
||||
ALWAYS_INLINE PointerDescriptor(const MessageBuffer &buf, s32 index) : data{util::BitPack32{0}, util::BitPack32{0}} {
|
||||
buf.Get(index, this->data, util::size(this->data));
|
||||
ALWAYS_INLINE PointerDescriptor(const MessageBuffer &buf, s32 index) : m_data{util::BitPack32{0}, util::BitPack32{0}} {
|
||||
buf.Get(index, m_data, util::size(m_data));
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE s32 GetIndex() const {
|
||||
return this->data[0].Get<Index>();
|
||||
return m_data[0].Get<Index>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE uintptr_t GetAddress() const {
|
||||
const u64 address = (static_cast<u64>((this->data[0].Get<AddressHigh>() << AddressMid::Count) | this->data[0].Get<AddressMid>()) << AddressLow::Count) | this->data[1].Get<AddressLow>();
|
||||
const u64 address = (static_cast<u64>((m_data[0].Get<AddressHigh>() << AddressMid::Count) | m_data[0].Get<AddressMid>()) << AddressLow::Count) | m_data[1].Get<AddressLow>();
|
||||
return address;
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE size_t GetSize() const {
|
||||
return this->data[0].Get<Size>();
|
||||
return m_data[0].Get<Size>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE const util::BitPack32 *GetData() const {
|
||||
return this->data;
|
||||
return m_data;
|
||||
}
|
||||
|
||||
static constexpr ALWAYS_INLINE size_t GetDataSize() {
|
||||
return sizeof(data);
|
||||
return sizeof(m_data);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -347,51 +347,51 @@ namespace ams::svc::ipc {
|
|||
return static_cast<u32>(address >> (AddressLow::Count));
|
||||
}
|
||||
private:
|
||||
util::BitPack32 data[2];
|
||||
util::BitPack32 m_data[2];
|
||||
public:
|
||||
constexpr ALWAYS_INLINE ReceiveListEntry() : data{util::BitPack32{0}, util::BitPack32{0}} { /* ... */ }
|
||||
constexpr ALWAYS_INLINE ReceiveListEntry() : m_data{util::BitPack32{0}, util::BitPack32{0}} { /* ... */ }
|
||||
|
||||
ALWAYS_INLINE ReceiveListEntry(const void *buffer, size_t size) : data{util::BitPack32{0}, util::BitPack32{0}} {
|
||||
ALWAYS_INLINE ReceiveListEntry(const void *buffer, size_t size) : m_data{util::BitPack32{0}, util::BitPack32{0}} {
|
||||
const u64 address = reinterpret_cast<u64>(buffer);
|
||||
|
||||
this->data[0] = { static_cast<u32>(address) };
|
||||
m_data[0] = { static_cast<u32>(address) };
|
||||
|
||||
this->data[1].Set<AddressHigh>(GetAddressHigh(address));
|
||||
this->data[1].Set<Size>(size);
|
||||
m_data[1].Set<AddressHigh>(GetAddressHigh(address));
|
||||
m_data[1].Set<Size>(size);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE ReceiveListEntry(u32 a, u32 b) : data{util::BitPack32{a}, util::BitPack32{b}} { /* ... */ }
|
||||
ALWAYS_INLINE ReceiveListEntry(u32 a, u32 b) : m_data{util::BitPack32{a}, util::BitPack32{b}} { /* ... */ }
|
||||
|
||||
constexpr ALWAYS_INLINE uintptr_t GetAddress() const {
|
||||
const u64 address = (static_cast<u64>(this->data[1].Get<AddressHigh>()) << AddressLow::Count) | this->data[0].Get<AddressLow>();
|
||||
const u64 address = (static_cast<u64>(m_data[1].Get<AddressHigh>()) << AddressLow::Count) | m_data[0].Get<AddressLow>();
|
||||
return address;
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE size_t GetSize() const {
|
||||
return this->data[1].Get<Size>();
|
||||
return m_data[1].Get<Size>();
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE const util::BitPack32 *GetData() const {
|
||||
return this->data;
|
||||
return m_data;
|
||||
}
|
||||
|
||||
static constexpr ALWAYS_INLINE size_t GetDataSize() {
|
||||
return sizeof(data);
|
||||
return sizeof(m_data);
|
||||
}
|
||||
};
|
||||
private:
|
||||
u32 *buffer;
|
||||
size_t size;
|
||||
u32 *m_buffer;
|
||||
size_t m_size;
|
||||
public:
|
||||
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 MessageBuffer(u32 *b, size_t sz) : m_buffer(b), m_size(sz) { /* ... */ }
|
||||
constexpr explicit ALWAYS_INLINE MessageBuffer(u32 *b) : m_buffer(b), m_size(sizeof(::ams::svc::ThreadLocalRegion::message_buffer)) { /* ... */ }
|
||||
|
||||
constexpr ALWAYS_INLINE void *GetBufferForDebug() const {
|
||||
return this->buffer;
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE size_t GetBufferSize() const {
|
||||
return this->size;
|
||||
return m_size;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void Get(s32 index, util::BitPack32 *dst, size_t count) const {
|
||||
|
@ -399,11 +399,11 @@ namespace ams::svc::ipc {
|
|||
__asm__ __volatile__("" ::: "memory");
|
||||
|
||||
/* Get the words. */
|
||||
static_assert(sizeof(*dst) == sizeof(*this->buffer));
|
||||
static_assert(sizeof(*dst) == sizeof(*m_buffer));
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wclass-memaccess"
|
||||
__builtin_memcpy(dst, this->buffer + index, count * sizeof(*dst));
|
||||
__builtin_memcpy(dst, m_buffer + index, count * sizeof(*dst));
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
|
@ -412,7 +412,7 @@ namespace ams::svc::ipc {
|
|||
__asm__ __volatile__("" ::: "memory");
|
||||
|
||||
/* Set the words. */
|
||||
__builtin_memcpy(this->buffer + index, src, count * sizeof(*src));
|
||||
__builtin_memcpy(m_buffer + index, src, count * sizeof(*src));
|
||||
|
||||
/* Ensure that this doesn't get re-ordered. */
|
||||
__asm__ __volatile__("" ::: "memory");
|
||||
|
@ -422,21 +422,21 @@ namespace ams::svc::ipc {
|
|||
|
||||
template<typename T>
|
||||
ALWAYS_INLINE const T &GetRaw(s32 index) const {
|
||||
return *reinterpret_cast<const T *>(this->buffer + index);
|
||||
return *reinterpret_cast<const T *>(m_buffer + index);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ALWAYS_INLINE s32 SetRaw(s32 index, const T &val) const {
|
||||
*reinterpret_cast<const T *>(this->buffer + index) = val;
|
||||
return index + (util::AlignUp(sizeof(val), sizeof(*this->buffer)) / sizeof(*this->buffer));
|
||||
*reinterpret_cast<const T *>(m_buffer + index) = val;
|
||||
return index + (util::AlignUp(sizeof(val), sizeof(*m_buffer)) / sizeof(*m_buffer));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void GetRawArray(s32 index, void *dst, size_t len) const {
|
||||
__builtin_memcpy(dst, this->buffer + index, len);
|
||||
__builtin_memcpy(dst, m_buffer + index, len);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void SetRawArray(s32 index, const void *src, size_t len) const {
|
||||
__builtin_memcpy(this->buffer + index, src, len);
|
||||
__builtin_memcpy(m_buffer + index, src, len);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void SetNull() const {
|
||||
|
@ -444,70 +444,70 @@ namespace ams::svc::ipc {
|
|||
}
|
||||
|
||||
ALWAYS_INLINE s32 Set(const MessageHeader &hdr) const {
|
||||
__builtin_memcpy(this->buffer, hdr.GetData(), hdr.GetDataSize());
|
||||
return hdr.GetDataSize() / sizeof(*this->buffer);
|
||||
__builtin_memcpy(m_buffer, hdr.GetData(), hdr.GetDataSize());
|
||||
return hdr.GetDataSize() / sizeof(*m_buffer);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE s32 Set(const SpecialHeader &spc) const {
|
||||
const s32 index = MessageHeader::GetDataSize() / sizeof(*this->buffer);
|
||||
__builtin_memcpy(this->buffer + index, spc.GetHeader(), spc.GetHeaderSize());
|
||||
return index + (spc.GetHeaderSize() / sizeof(*this->buffer));
|
||||
const s32 index = MessageHeader::GetDataSize() / sizeof(*m_buffer);
|
||||
__builtin_memcpy(m_buffer + index, spc.GetHeader(), spc.GetHeaderSize());
|
||||
return index + (spc.GetHeaderSize() / sizeof(*m_buffer));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE s32 SetHandle(s32 index, const ::ams::svc::Handle &hnd) const {
|
||||
static_assert(util::IsAligned(sizeof(hnd), sizeof(*this->buffer)));
|
||||
__builtin_memcpy(this->buffer + index, std::addressof(hnd), sizeof(hnd));
|
||||
return index + (sizeof(hnd) / sizeof(*this->buffer));
|
||||
static_assert(util::IsAligned(sizeof(hnd), sizeof(*m_buffer)));
|
||||
__builtin_memcpy(m_buffer + index, std::addressof(hnd), sizeof(hnd));
|
||||
return index + (sizeof(hnd) / sizeof(*m_buffer));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE s32 SetProcessId(s32 index, const u64 pid) const {
|
||||
static_assert(util::IsAligned(sizeof(pid), sizeof(*this->buffer)));
|
||||
__builtin_memcpy(this->buffer + index, std::addressof(pid), sizeof(pid));
|
||||
return index + (sizeof(pid) / sizeof(*this->buffer));
|
||||
static_assert(util::IsAligned(sizeof(pid), sizeof(*m_buffer)));
|
||||
__builtin_memcpy(m_buffer + index, std::addressof(pid), sizeof(pid));
|
||||
return index + (sizeof(pid) / sizeof(*m_buffer));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE s32 Set(s32 index, const MapAliasDescriptor &desc) const {
|
||||
__builtin_memcpy(this->buffer + index, desc.GetData(), desc.GetDataSize());
|
||||
return index + (desc.GetDataSize() / sizeof(*this->buffer));
|
||||
__builtin_memcpy(m_buffer + index, desc.GetData(), desc.GetDataSize());
|
||||
return index + (desc.GetDataSize() / sizeof(*m_buffer));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE s32 Set(s32 index, const PointerDescriptor &desc) const {
|
||||
__builtin_memcpy(this->buffer + index, desc.GetData(), desc.GetDataSize());
|
||||
return index + (desc.GetDataSize() / sizeof(*this->buffer));
|
||||
__builtin_memcpy(m_buffer + index, desc.GetData(), desc.GetDataSize());
|
||||
return index + (desc.GetDataSize() / sizeof(*m_buffer));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE s32 Set(s32 index, const ReceiveListEntry &desc) const {
|
||||
__builtin_memcpy(this->buffer + index, desc.GetData(), desc.GetDataSize());
|
||||
return index + (desc.GetDataSize() / sizeof(*this->buffer));
|
||||
__builtin_memcpy(m_buffer + index, desc.GetData(), desc.GetDataSize());
|
||||
return index + (desc.GetDataSize() / sizeof(*m_buffer));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE s32 Set(s32 index, const u32 val) const {
|
||||
static_assert(util::IsAligned(sizeof(val), sizeof(*this->buffer)));
|
||||
__builtin_memcpy(this->buffer + index, std::addressof(val), sizeof(val));
|
||||
return index + (sizeof(val) / sizeof(*this->buffer));
|
||||
static_assert(util::IsAligned(sizeof(val), sizeof(*m_buffer)));
|
||||
__builtin_memcpy(m_buffer + index, std::addressof(val), sizeof(val));
|
||||
return index + (sizeof(val) / sizeof(*m_buffer));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Result GetAsyncResult() const {
|
||||
MessageHeader hdr(this->buffer);
|
||||
MessageHeader hdr(m_buffer);
|
||||
MessageHeader null{};
|
||||
R_SUCCEED_IF(AMS_UNLIKELY((__builtin_memcmp(hdr.GetData(), null.GetData(), MessageHeader::GetDataSize()) != 0)));
|
||||
return this->buffer[MessageHeader::GetDataSize() / sizeof(*this->buffer)];
|
||||
return m_buffer[MessageHeader::GetDataSize() / sizeof(*m_buffer)];
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void SetAsyncResult(Result res) const {
|
||||
const s32 index = this->Set(MessageHeader());
|
||||
const auto value = res.GetValue();
|
||||
static_assert(util::IsAligned(sizeof(value), sizeof(*this->buffer)));
|
||||
__builtin_memcpy(this->buffer + index, std::addressof(value), sizeof(value));
|
||||
static_assert(util::IsAligned(sizeof(value), sizeof(*m_buffer)));
|
||||
__builtin_memcpy(m_buffer + index, std::addressof(value), sizeof(value));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE u32 Get32(s32 index) const {
|
||||
return this->buffer[index];
|
||||
return m_buffer[index];
|
||||
}
|
||||
|
||||
ALWAYS_INLINE u64 Get64(s32 index) const {
|
||||
u64 value;
|
||||
__builtin_memcpy(std::addressof(value), this->buffer + index, sizeof(value));
|
||||
__builtin_memcpy(std::addressof(value), m_buffer + index, sizeof(value));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -516,8 +516,8 @@ namespace ams::svc::ipc {
|
|||
}
|
||||
|
||||
ALWAYS_INLINE ams::svc::Handle GetHandle(s32 index) const {
|
||||
static_assert(sizeof(ams::svc::Handle) == sizeof(*this->buffer));
|
||||
return ::ams::svc::Handle(this->buffer[index]);
|
||||
static_assert(sizeof(ams::svc::Handle) == sizeof(*m_buffer));
|
||||
return ::ams::svc::Handle(m_buffer[index]);
|
||||
}
|
||||
|
||||
static constexpr ALWAYS_INLINE s32 GetSpecialDataIndex(const MessageHeader &hdr, const SpecialHeader &spc) {
|
||||
|
|
|
@ -211,13 +211,13 @@ namespace ams::svc::test {
|
|||
template<typename... Ts>
|
||||
struct Validator {
|
||||
private:
|
||||
std::array<bool, sizeof...(Ts)> valid;
|
||||
std::array<bool, sizeof...(Ts)> m_valid;
|
||||
public:
|
||||
constexpr Validator(Ts... args) : valid{static_cast<bool>(args)...} { /* ... */ }
|
||||
constexpr Validator(Ts... args) : m_valid{static_cast<bool>(args)...} { /* ... */ }
|
||||
|
||||
constexpr bool IsValid() const {
|
||||
for (size_t i = 0; i < sizeof...(Ts); i++) {
|
||||
if (!this->valid[i]) {
|
||||
if (!m_valid[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace ams::svc {
|
|||
static constexpr s64 TicksPerSecond = ::ams::svc::TicksPerSecond;
|
||||
static constexpr s64 GetTicksPerSecond() { return TicksPerSecond; }
|
||||
private:
|
||||
s64 tick;
|
||||
s64 m_tick;
|
||||
private:
|
||||
static constexpr s64 NanoSecondsPerSecond = TimeSpan::FromSeconds(1).GetNanoSeconds();
|
||||
|
||||
|
@ -52,19 +52,19 @@ namespace ams::svc {
|
|||
return (ts_div * tick_div) * NanoSecondsPerSecond + ts_div * tick_mod + ts_mod * tick_div + value;
|
||||
}
|
||||
public:
|
||||
constexpr explicit Tick(s64 t = 0) : tick(t) { /* ... */ }
|
||||
constexpr Tick(TimeSpan ts) : tick(ConvertTimeSpanToTickImpl(ts)) { /* ... */ }
|
||||
constexpr explicit Tick(s64 t = 0) : m_tick(t) { /* ... */ }
|
||||
constexpr Tick(TimeSpan ts) : m_tick(ConvertTimeSpanToTickImpl(ts)) { /* ... */ }
|
||||
|
||||
constexpr operator s64() const { return this->tick; }
|
||||
constexpr operator s64() const { return m_tick; }
|
||||
|
||||
/* Tick arithmetic. */
|
||||
constexpr Tick &operator+=(Tick rhs) { this->tick += rhs.tick; return *this; }
|
||||
constexpr Tick &operator-=(Tick rhs) { this->tick -= rhs.tick; return *this; }
|
||||
constexpr Tick &operator+=(Tick rhs) { m_tick += rhs.m_tick; return *this; }
|
||||
constexpr Tick &operator-=(Tick rhs) { m_tick -= rhs.m_tick; return *this; }
|
||||
constexpr Tick operator+(Tick rhs) const { Tick r(*this); return r += rhs; }
|
||||
constexpr Tick operator-(Tick rhs) const { Tick r(*this); return r -= rhs; }
|
||||
|
||||
constexpr Tick &operator+=(TimeSpan rhs) { this->tick += Tick(rhs).tick; return *this; }
|
||||
constexpr Tick &operator-=(TimeSpan rhs) { this->tick -= Tick(rhs).tick; return *this; }
|
||||
constexpr Tick &operator+=(TimeSpan rhs) { m_tick += Tick(rhs).m_tick; return *this; }
|
||||
constexpr Tick &operator-=(TimeSpan rhs) { m_tick -= Tick(rhs).m_tick; return *this; }
|
||||
constexpr Tick operator+(TimeSpan rhs) const { Tick r(*this); return r += rhs; }
|
||||
constexpr Tick operator-(TimeSpan rhs) const { Tick r(*this); return r -= rhs; }
|
||||
};
|
||||
|
|
|
@ -27,20 +27,20 @@ namespace ams::svc {
|
|||
/* Utility classes required to encode information into the type system for SVC veneers. */
|
||||
class Size {
|
||||
private:
|
||||
size_t size;
|
||||
size_t m_size;
|
||||
public:
|
||||
constexpr ALWAYS_INLINE Size(size_t s) : size(s) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE operator size_t() { return this->size; }
|
||||
constexpr ALWAYS_INLINE Size(size_t s) : m_size(s) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE operator size_t() { return m_size; }
|
||||
};
|
||||
static_assert(sizeof(Size) == sizeof(size_t));
|
||||
static_assert(std::is_trivially_destructible<Size>::value);
|
||||
|
||||
class Address {
|
||||
private:
|
||||
uintptr_t uintptr;
|
||||
uintptr_t m_uintptr;
|
||||
public:
|
||||
constexpr ALWAYS_INLINE Address(uintptr_t u) : uintptr(u) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE operator uintptr_t() { return this->uintptr; }
|
||||
constexpr ALWAYS_INLINE Address(uintptr_t u) : m_uintptr(u) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE operator uintptr_t() { return m_uintptr; }
|
||||
};
|
||||
static_assert(sizeof(Address) == sizeof(uintptr_t));
|
||||
static_assert(std::is_trivially_destructible<Address>::value);
|
||||
|
@ -57,11 +57,11 @@ namespace ams::svc {
|
|||
static_assert(std::is_pointer<T>::value);
|
||||
static constexpr bool IsInput = std::is_const<typename std::remove_pointer<T>::type>::value;
|
||||
private:
|
||||
T pointer;
|
||||
T m_pointer;
|
||||
public:
|
||||
constexpr ALWAYS_INLINE UserPointer(T p) : pointer(p) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE UserPointer(T p) : m_pointer(p) { /* ... */ }
|
||||
|
||||
constexpr ALWAYS_INLINE T GetPointerUnsafe() { return this->pointer; }
|
||||
constexpr ALWAYS_INLINE T GetPointerUnsafe() { return m_pointer; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
|
Loading…
Reference in a new issue