#pragma once
#include <cstddef>
#include <cstdint>
namespace risc0 {
#define MEM_REGION(name, start, len) \
constexpr size_t kMem##name##Start = start; \
constexpr size_t kMem##name##End = start + len; \
constexpr size_t kMem##name##Len = len;
constexpr size_t kMemBits = 20;
constexpr size_t kMemSize = (1 << kMemBits) * 4;
constexpr size_t k256KB = 0x00040000;
constexpr size_t k512KB = 0x00080000;
constexpr size_t k1MB = 0x00100000;
MEM_REGION(Stack, 0x00000000, k256KB)
MEM_REGION(Data, 0x00040000, k256KB)
MEM_REGION(Heap, 0x00080000, k1MB)
MEM_REGION(Input, 0x00180000, k256KB)
MEM_REGION(GPIO, 0x001C0000, k256KB)
MEM_REGION(Prog, 0x00200000, k1MB)
MEM_REGION(SHA, 0x00300000, k256KB)
MEM_REGION(WOM, 0x00340000, k256KB * 2)
MEM_REGION(Output, 0x00340000, k256KB)
MEM_REGION(Commit, 0x00380000, k256KB)
#define PTR_TO(type, name) reinterpret_cast<type*>(kMem##name##Start);
struct ShaDescriptor {
uint32_t typeAndCount;
uint32_t idx;
uint32_t source;
uint32_t digest;
};
inline uint32_t* GPIO_InputBase() {
return reinterpret_cast<uint32_t*>(kMemInputStart);
}
inline uint32_t* GPIO_OutputBase() {
return reinterpret_cast<uint32_t*>(kMemOutputStart);
}
inline uint32_t* GPIO_CommitBase() {
return reinterpret_cast<uint32_t*>(kMemCommitStart);
}
}