2025-10-03 21:09:25 +00:00
|
|
|
#ifndef RUNMEM_H
|
|
|
|
|
#define RUNMEM_H
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2025-11-03 22:23:19 +00:00
|
|
|
#ifdef ENABLE_LOGGING
|
|
|
|
|
#define LOG(...) printf(__VA_ARGS__)
|
|
|
|
|
#define BLOG(...) printf(__VA_ARGS__)
|
|
|
|
|
#elif ENABLE_BASIC_LOGGING
|
|
|
|
|
#define LOG(...)
|
|
|
|
|
#define BLOG(...) printf(__VA_ARGS__)
|
|
|
|
|
#else
|
|
|
|
|
#define LOG(...)
|
|
|
|
|
#define BLOG(...)
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-10-03 21:09:25 +00:00
|
|
|
/* Command opcodes used by the parser */
|
2025-11-03 01:14:14 +00:00
|
|
|
#define ALLOCATE_DATA 1
|
|
|
|
|
#define COPY_DATA 2
|
|
|
|
|
#define ALLOCATE_CODE 3
|
|
|
|
|
#define COPY_CODE 4
|
|
|
|
|
#define PATCH_FUNC 0x1000
|
|
|
|
|
#define PATCH_OBJECT 0x2000
|
|
|
|
|
#define PATCH_OBJECT_HI21 0x2001
|
2025-11-03 20:51:58 +00:00
|
|
|
#define PATCH_OBJECT_ABS 0x2002
|
2025-11-09 14:45:37 +00:00
|
|
|
#define PATCH_OBJECT_REL 0x2003
|
2025-11-17 08:00:23 +00:00
|
|
|
#define PATCH_OBJECT_ARM32_ABS 0x2004
|
2025-11-03 01:14:14 +00:00
|
|
|
#define ENTRY_POINT 7
|
|
|
|
|
#define RUN_PROG 64
|
|
|
|
|
#define READ_DATA 65
|
|
|
|
|
#define END_COM 256
|
|
|
|
|
#define FREE_MEMORY 257
|
|
|
|
|
#define DUMP_CODE 258
|
2025-10-03 21:09:25 +00:00
|
|
|
|
|
|
|
|
/* Memory blobs accessible by other translation units */
|
|
|
|
|
extern uint8_t *data_memory;
|
|
|
|
|
extern uint32_t data_memory_len;
|
|
|
|
|
extern uint8_t *executable_memory;
|
|
|
|
|
extern uint32_t executable_memory_len;
|
2025-10-05 21:10:38 +00:00
|
|
|
extern int data_offs;
|
2025-10-03 21:09:25 +00:00
|
|
|
|
|
|
|
|
/* Entry point type and variable */
|
|
|
|
|
typedef int (*entry_point_t)(void);
|
|
|
|
|
extern entry_point_t entr_point;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Command parser: takes a pointer to the command stream and returns
|
|
|
|
|
an error flag (0 on success according to current code) */
|
|
|
|
|
int parse_commands(uint8_t *bytes);
|
|
|
|
|
|
|
|
|
|
/* Free program and data memory */
|
|
|
|
|
void free_memory();
|
|
|
|
|
|
|
|
|
|
#endif /* RUNMEM_H */
|