mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
changing {} style to match majority of previous style
This commit is contained in:
parent
da6cdf014b
commit
961d929f4d
320 changed files with 5502 additions and 10485 deletions
|
@ -34,8 +34,7 @@ static const uint8_t elf_ident[] = {
|
|||
|
||||
// Turn PHDRs into flasher segments, checking for PHDR sanity and merging adjacent
|
||||
// unaligned segments if needed
|
||||
static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs, int num_phdrs)
|
||||
{
|
||||
static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs, int num_phdrs) {
|
||||
Elf32_Phdr *phdr = phdrs;
|
||||
flash_seg_t *seg;
|
||||
uint32_t last_end = 0;
|
||||
|
@ -155,8 +154,7 @@ static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs,
|
|||
}
|
||||
|
||||
// Sanity check segments and check for bootloader writes
|
||||
static int check_segs(flash_file_t *ctx, int can_write_bl)
|
||||
{
|
||||
static int check_segs(flash_file_t *ctx, int can_write_bl) {
|
||||
for (int i = 0; i < ctx->num_segs; i++) {
|
||||
flash_seg_t *seg = &ctx->segments[i];
|
||||
|
||||
|
@ -181,8 +179,7 @@ static int check_segs(flash_file_t *ctx, int can_write_bl)
|
|||
}
|
||||
|
||||
// Load an ELF file and prepare it for flashing
|
||||
int flash_load(flash_file_t *ctx, const char *name, int can_write_bl)
|
||||
{
|
||||
int flash_load(flash_file_t *ctx, const char *name, int can_write_bl) {
|
||||
FILE *fd = NULL;
|
||||
Elf32_Ehdr ehdr;
|
||||
Elf32_Phdr *phdrs = NULL;
|
||||
|
@ -203,7 +200,7 @@ int flash_load(flash_file_t *ctx, const char *name, int can_write_bl)
|
|||
goto fail;
|
||||
}
|
||||
if (memcmp(ehdr.e_ident, elf_ident, sizeof(elf_ident))
|
||||
|| le32(ehdr.e_version) != 1) {
|
||||
|| le32(ehdr.e_version) != 1) {
|
||||
fprintf(stderr, "Not an ELF file or wrong ELF type\n");
|
||||
goto fail;
|
||||
}
|
||||
|
@ -262,8 +259,7 @@ fail:
|
|||
}
|
||||
|
||||
// Get the state of the proxmark, backwards compatible
|
||||
static int get_proxmark_state(uint32_t *state)
|
||||
{
|
||||
static int get_proxmark_state(uint32_t *state) {
|
||||
UsbCommand c = {CMD_DEVICE_INFO};
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
|
@ -294,8 +290,7 @@ static int get_proxmark_state(uint32_t *state)
|
|||
}
|
||||
|
||||
// Enter the bootloader to be able to start flashing
|
||||
static int enter_bootloader(void)
|
||||
{
|
||||
static int enter_bootloader(void) {
|
||||
uint32_t state;
|
||||
|
||||
if (get_proxmark_state(&state) < 0)
|
||||
|
@ -312,7 +307,7 @@ static int enter_bootloader(void)
|
|||
memset(&c, 0, sizeof(c));
|
||||
|
||||
if ((state & DEVICE_INFO_FLAG_BOOTROM_PRESENT)
|
||||
&& (state & DEVICE_INFO_FLAG_OSIMAGE_PRESENT)) {
|
||||
&& (state & DEVICE_INFO_FLAG_OSIMAGE_PRESENT)) {
|
||||
// New style handover: Send CMD_START_FLASH, which will reset the board
|
||||
// and enter the bootrom on the next boot.
|
||||
c.cmd = CMD_START_FLASH;
|
||||
|
@ -342,8 +337,7 @@ static int enter_bootloader(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int wait_for_ack(void)
|
||||
{
|
||||
static int wait_for_ack(void) {
|
||||
UsbCommand ack;
|
||||
ReceiveCommand(&ack);
|
||||
if (ack.cmd != CMD_ACK) {
|
||||
|
@ -354,8 +348,7 @@ static int wait_for_ack(void)
|
|||
}
|
||||
|
||||
// Go into flashing mode
|
||||
int flash_start_flashing(int enable_bl_writes)
|
||||
{
|
||||
int flash_start_flashing(int enable_bl_writes) {
|
||||
uint32_t state;
|
||||
|
||||
if (enter_bootloader() < 0)
|
||||
|
@ -388,8 +381,7 @@ int flash_start_flashing(int enable_bl_writes)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int write_block(uint32_t address, uint8_t *data, uint32_t length)
|
||||
{
|
||||
static int write_block(uint32_t address, uint8_t *data, uint32_t length) {
|
||||
uint8_t block_buf[BLOCK_SIZE];
|
||||
|
||||
memset(block_buf, 0xFF, BLOCK_SIZE);
|
||||
|
@ -412,8 +404,7 @@ static int write_block(uint32_t address, uint8_t *data, uint32_t length)
|
|||
}
|
||||
|
||||
// Write a file's segments to Flash
|
||||
int flash_write(flash_file_t *ctx)
|
||||
{
|
||||
int flash_write(flash_file_t *ctx) {
|
||||
fprintf(stderr, "Writing segments for file: %s\n", ctx->filename);
|
||||
for (int i = 0; i < ctx->num_segs; i++) {
|
||||
flash_seg_t *seg = &ctx->segments[i];
|
||||
|
@ -453,8 +444,7 @@ int flash_write(flash_file_t *ctx)
|
|||
}
|
||||
|
||||
// free a file context
|
||||
void flash_free(flash_file_t *ctx)
|
||||
{
|
||||
void flash_free(flash_file_t *ctx) {
|
||||
if (!ctx)
|
||||
return;
|
||||
if (ctx->segments) {
|
||||
|
@ -467,8 +457,7 @@ void flash_free(flash_file_t *ctx)
|
|||
}
|
||||
|
||||
// just reset the unit
|
||||
int flash_stop_flashing(void)
|
||||
{
|
||||
int flash_stop_flashing(void) {
|
||||
UsbCommand c = {CMD_HARDWARE_RESET};
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue