k2/prg [ Modules ]
NAME
prg
FUNCTION
This module provides a facility to load PRG modules into RISC-V memory.
prg/prg_s, prg/prg_t [ Types ]
NAME
struct prg_s
prg_t
FUNCTION
The PRG format is a position-independent variation on a.out unique to the Kestrel-2EX Mantle environment. Note that this file format does not include any relocation information!
The structure of a PRG is as follows:
+--------------------+ 0 | Header | +--------------------+ 32 | Text | +--------------------+ | Read-only data | +--------------------+ text_size+32 | Read-write data | +--------------------+ data_size+text_size+32
NOTE Observe that read-only data (often, "rodata") is, for the purposes of the PRG format, considered to be part of the text segment. This may change in a future release of Mantle, as more experience with this format is obtained.
NOTE ALSO ALL SIZES must be 32-bit aligned at the minimum, 64-bit preferred.
MEMBERS
magic
This field MUST contain the value 0x0200006F,
which corresponds to JAL X0,*+32 in RISC-V machine
language. This constant is defined in PRG_MAGIC.
text_size
This 32-bit field contains the number of bytes in the
code and read-only data portions of the executable.
data_size
This 32-bit field contains the number of bytes in the
read/write portion of the executable.
bss_size
This 32-bit field contains the size of the BSS section.
This is a read/write data section which is assumed to
reside immediately following the data section, and is
assumed to be pre-initialized to zeros before the program
is run. Hence, there's no need to store this section's
data, only its size.
stack_size
This 32-bit field contains the size of the default
event procedure's stack. Like the BSS section, there is
no need to store a copy of this section in the PRG file.
Unlike BSS, there's no presumption that it is pre-init-
ialized to zeros.
prg/prgerr_e, prg/prgerr_t [ Types ]
NAME
enum prgerr_e
prgerr_t
FUNCTION
Provides an indication of what went wrong while loading a PRG file into memory.
MEMBERS
PRGLOAD_OK
No errors occured.
PRGLOAD_MEM_TRANSLATE
While loading, an attempt was made to write to a memory
location which has no corresponding reader or writer
configured. The memory map provided by the slots
parameter to prg_load is not properly configured to
cover this range of memory.
PRGLOAD_MAGIC
The header in the PRG file is malformed or obsolete.
PRGLOAD_ERR_TOO_SMALL
The header is not complete. Alternatively: there is
insufficient content in the file to cover the text and/
or data sections.
PRGLOAD_FILENAME
The file specified to prg_load() does not exist or is
not well formed.
SOURCE
typedef enum prgerr_e {
PRGLOAD_OK = 0,
PRGLOAD_MEM_TRANSLATE,
PRGLOAD_MAGIC,
PRGLOAD_ERR_TOO_SMALL,
PRGLOAD_FILENAME,
} prgerr_t;