28 lines
No EOL
611 B
C
28 lines
No EOL
611 B
C
/*
|
|
This code is part of the EIPA Platform
|
|
|
|
This code contains the implementations of all functions related to saving EIPA target code to an EIPA image
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
|
|
int save_img(char *out_path, __uint32_t *target_code){
|
|
FILE *out_file = fopen(out_path, "wb");
|
|
if(out_file == NULL) return EIO;
|
|
|
|
// Count instructions
|
|
unsigned int count = 0;
|
|
while(target_code[count]!=0)
|
|
{
|
|
count++;
|
|
}
|
|
|
|
if (fwrite(target_code, sizeof(target_code), count, out_file) != count)
|
|
{
|
|
// Couldn't save the image
|
|
return EIO;
|
|
}
|
|
return 0;
|
|
|
|
} |