fusee_cpp: implement exosphere load/configuration

This commit is contained in:
Michael Scire 2021-09-01 14:05:39 -07:00 committed by SciresM
parent 1dd0297db3
commit e0a41e9d33
8 changed files with 236 additions and 13 deletions

View file

@ -49,7 +49,7 @@ namespace ams::nxboot {
file_size = std::min(IniFileSizeMax, file_size);
/* Allocate memory for file. */
char *buffer = static_cast<char *>(AllocateMemory(util::AlignUp(file_size + 1, 0x10)));
char *buffer = static_cast<char *>(AllocateAligned(util::AlignUp(file_size + 1, 0x10), 0x10));
buffer[file_size] = '\x00';
/* Read file. */
@ -64,6 +64,7 @@ namespace ams::nxboot {
SectionName,
Key,
KvSpace,
KvSpace2,
Value,
TrailingSpace,
};
@ -120,20 +121,33 @@ namespace ams::nxboot {
} else if (c == '=') {
buffer[i] = '\x00';
val_start = buffer + i + 1;
state = State::Value;
state = State::KvSpace2;
}
break;
case State::KvSpace:
if (c == '=') {
val_start = buffer + i + 1;
state = State::Value;
state = State::KvSpace2;
} else if (!IsWhiteSpace(c)) {
return ParseIniResult_InvalidFormat;
}
break;
case State::KvSpace2:
if (c == '\n') {
buffer[i] = '\x00';
auto *entry = AllocateObject<IniKeyValueEntry>();
entry->key = key_start;
entry->value = buffer + i;
cur_sec->kv_list.push_back(*entry);
state = State::Newline;
} else if (!IsWhiteSpace(c)) {
val_start = buffer + i;
state = State::Value;
}
break;
case State::Value:
if (IsWhiteSpace(c) || c == '\n') {
buffer[i] = '\x00';