Skip to content

Commit

Permalink
Fix simulator from merge
Browse files Browse the repository at this point in the history
  • Loading branch information
danngreen committed Feb 21, 2024
1 parent c757b43 commit 1c90002
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
1 change: 0 additions & 1 deletion firmware/src/fw_update/updater_proxy.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "updater_proxy.hh"
#include "fw_update/ram_buffer.hh" //must be exactly this, or else simulator build picks wrong file
#include "fw_update/update_path.hh"
#include "manifest_parse.hh"
#include "pr_dbg.hh"
Expand Down
2 changes: 1 addition & 1 deletion firmware/src/fw_update/updater_proxy.hh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include "fw_update/ram_buffer.hh" //path must be exactly this, or else simulator build picks wrong file
#include "patch_file/file_storage_proxy.hh"
#include "ram_buffer.hh"
#include "update_file.hh"
#include <cstdint>
#include <string>
Expand Down
1 change: 1 addition & 0 deletions simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ add_executable(
${FWDIR}/src/fw_update/updater_proxy.cc
${SHARED}/patch_convert/ryml/ryml_serial.cc
${SHARED}/patch_convert/yaml_to_patch.cc
${SHARED}/patch_convert/patch_to_yaml.cc
${FACEPLATE_ARTWORK_SOURCES}
${COMP_ARTWORK_SOURCES}
${SLS_SOURCES})
Expand Down
32 changes: 26 additions & 6 deletions simulator/stubs/fw_update/ram_buffer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,32 @@ inline std::span<uint8_t> get_ram_buffer() {
return buffer;
}

inline std::span<uint8_t> get_ram_buffer_client() {
return get_ram_buffer().first(5 * 1024 * 1024);
}
class OneTimeArenaAllocator {
public:
OneTimeArenaAllocator(std::span<uint8_t> arena_)
: arena(arena_)
, offset(0) {
}

inline std::span<uint8_t> get_ram_buffer_server() {
return get_ram_buffer().last(get_ram_buffer().size() - 5 * 1024 * 1024);
}
uint8_t *allocate(std::size_t size) {
auto bytesRemaining = arena.size() - offset;
if (bytesRemaining > size) {
auto result = &arena[offset];
offset += size;

return result;
} else {
return nullptr;
}
}

void reset() {
offset = 0;
}

private:
std::span<uint8_t> arena;
std::size_t offset;
};

} // namespace MetaModule
5 changes: 1 addition & 4 deletions simulator/stubs/patch_file/file_storage_proxy.hh
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,9 @@ public:
}

[[nodiscard]] bool request_file_flash(IntercoreStorageMessage::FlashTarget target,
std::string_view filename,
Volume vol,
std::span<uint8_t> buffer,
uint32_t address,
uint32_t length,
uint32_t *bytes_processed) {
//TODO
return true;
}

Expand Down

0 comments on commit 1c90002

Please sign in to comment.