diff options
Diffstat (limited to 'utils/mcpu-melf.h')
| -rw-r--r-- | utils/mcpu-melf.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/utils/mcpu-melf.h b/utils/mcpu-melf.h new file mode 100644 index 0000000..f6c234f --- /dev/null +++ b/utils/mcpu-melf.h @@ -0,0 +1,42 @@ +#ifndef __CPU_MELF_H +#define __CPU_MELF_H + +#include <stddef.h> +#include <stdio.h> +#include <libmcpu.h> +#include <mcpu-elf.h> + +int cpu_melf_data_encoding( void ); +void cpu_melf_put16( unsigned char *p, __mpu_uint16_t v, int data ); +void cpu_melf_put32( unsigned char *p, __mpu_uint32_t v, int data ); +void cpu_melf_put64( unsigned char *p, __mpu_uint64_t v, int data ); +__mpu_uint16_t cpu_melf_get16( const unsigned char *p, int data ); +__mpu_uint32_t cpu_melf_get32( const unsigned char *p, int data ); +__mpu_uint64_t cpu_melf_get64( const unsigned char *p, int data ); + +int cpu_melf_span( size_t file_size, __mpu_uint64_t off, __mpu_uint64_t len ); +__mpu_uint64_t cpu_melf_align_up( __mpu_uint64_t v, __mpu_uint64_t align, int *overflow ); +int cpu_melf_readall( const char *path, unsigned char **data, size_t *size, + char *err, size_t errsz); +int cpu_melf_writeall( const char *path, const void *data, size_t size, + char *err, size_t errsz); + +void cpu_melf_fill_target( MElf_McpuTarget *t ); +void cpu_melf_encode_target( unsigned char out[MELF_MCPU_TARGET_SIZE], + const MElf_McpuTarget *t, int data); +int cpu_melf_decode_target( const unsigned char in[MELF_MCPU_TARGET_SIZE], + MElf_McpuTarget *t, int data); +int cpu_melf_validate_target( const MElf_McpuTarget *t, int data, + char *err, size_t errsz); + +void cpu_melf_fill_lifecycle( MElf_McpuLifecycle *l ); +void cpu_melf_encode_lifecycle( unsigned char out[MELF_MCPU_LIFECYCLE_SIZE], + const MElf_McpuLifecycle *l, int data); +int cpu_melf_decode_lifecycle( const unsigned char in[MELF_MCPU_LIFECYCLE_SIZE], + MElf_McpuLifecycle *l, int data); +int cpu_melf_validate_lifecycle( const MElf_McpuLifecycle *l, + char *err, size_t errsz); + +int cpu_melf_is_pow2( __mpu_uint64_t v ); + +#endif |
