1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#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
|