mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 18:48:13 -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;
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
#include "proxusb.h"
|
||||
#include "flash.h"
|
||||
|
||||
static void usage(char *argv0)
|
||||
{
|
||||
static void usage(char *argv0) {
|
||||
fprintf(stderr, "Usage: %s [-b] image.elf [image.elf...]\n\n", argv0);
|
||||
fprintf(stderr, "\t-b\tEnable flashing of bootloader area (DANGEROUS)\n\n");
|
||||
fprintf(stderr, "Example: %s path/to/osimage.elf path/to/fpgaimage.elf\n", argv0);
|
||||
|
@ -22,8 +21,7 @@ static void usage(char *argv0)
|
|||
|
||||
#define MAX_FILES 4
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int main(int argc, char **argv) {
|
||||
int can_write_bl = 0;
|
||||
int num_files = 0;
|
||||
int res;
|
||||
|
|
|
@ -32,13 +32,11 @@
|
|||
# define le32(x) (x)
|
||||
#else
|
||||
|
||||
static inline uint16_t le16(uint16_t v)
|
||||
{
|
||||
static inline uint16_t le16(uint16_t v) {
|
||||
return (v >> 8) | (v << 8);
|
||||
}
|
||||
|
||||
static inline uint32_t le32(uint32_t v)
|
||||
{
|
||||
static inline uint32_t le32(uint32_t v) {
|
||||
return (le16(v) << 16) | (le16(v >> 16));
|
||||
}
|
||||
#endif // HOST_LITTLE_ENDIAN
|
||||
|
|
|
@ -20,8 +20,7 @@ static unsigned int claimed_iface = 0;
|
|||
unsigned char return_on_error = 0;
|
||||
unsigned char error_occured = 0;
|
||||
|
||||
void SendCommand(UsbCommand *c)
|
||||
{
|
||||
void SendCommand(UsbCommand *c) {
|
||||
int ret;
|
||||
|
||||
#if 0
|
||||
|
@ -49,8 +48,7 @@ void SendCommand(UsbCommand *c)
|
|||
}
|
||||
}
|
||||
|
||||
bool ReceiveCommandPoll(UsbCommand *c)
|
||||
{
|
||||
bool ReceiveCommandPoll(UsbCommand *c) {
|
||||
int ret;
|
||||
|
||||
memset(c, 0, sizeof(UsbCommand));
|
||||
|
@ -84,8 +82,7 @@ bool ReceiveCommandPoll(UsbCommand *c)
|
|||
return ret > 0;
|
||||
}
|
||||
|
||||
void ReceiveCommand(UsbCommand *c)
|
||||
{
|
||||
void ReceiveCommand(UsbCommand *c) {
|
||||
// printf("%s()\n", __FUNCTION__);
|
||||
int retval = 0;
|
||||
do {
|
||||
|
@ -95,8 +92,7 @@ void ReceiveCommand(UsbCommand *c)
|
|||
// printf("recv %x\n", c->cmd);
|
||||
}
|
||||
|
||||
usb_dev_handle *findProxmark(int verbose, unsigned int *iface)
|
||||
{
|
||||
usb_dev_handle *findProxmark(int verbose, unsigned int *iface) {
|
||||
struct usb_bus *busses, *bus;
|
||||
usb_dev_handle *handle = NULL;
|
||||
struct prox_unit units[50];
|
||||
|
@ -168,8 +164,7 @@ usb_dev_handle *findProxmark(int verbose, unsigned int *iface)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
usb_dev_handle *OpenProxmark(int verbose)
|
||||
{
|
||||
usb_dev_handle *OpenProxmark(int verbose) {
|
||||
int ret;
|
||||
usb_dev_handle *handle = NULL;
|
||||
unsigned int iface;
|
||||
|
@ -205,8 +200,7 @@ usb_dev_handle *OpenProxmark(int verbose)
|
|||
return handle;
|
||||
}
|
||||
|
||||
void CloseProxmark(void)
|
||||
{
|
||||
void CloseProxmark(void) {
|
||||
usb_release_interface(devh, claimed_iface);
|
||||
usb_close(devh);
|
||||
devh = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue