From 2fa3090dd2812607104630c00862e2a0dcfacda1 Mon Sep 17 00:00:00 2001 From: Serge Bazanski <serge@bazanski.pl> Date: Mon, 29 Jul 2019 21:55:52 +0200 Subject: [PATCH] appease annoyatron --- epicardium/l0der/l0der.c | 23 +++++++----- hw-tests/dual-core/main.c | 79 +++++++++++++++++++++------------------ 2 files changed, 56 insertions(+), 46 deletions(-) diff --git a/epicardium/l0der/l0der.c b/epicardium/l0der/l0der.c index 3874c186..808dc01f 100644 --- a/epicardium/l0der/l0der.c +++ b/epicardium/l0der/l0der.c @@ -59,9 +59,10 @@ static int _read_elf_header(int fd, Elf32_Ehdr *hdr) { int res; - epic_file_seek(fd, 0, SEEK_SET); + epic_file_seek(fd, 0, SEEK_SET); - if ((res = epic_file_read(fd, hdr, sizeof(Elf32_Ehdr))) != sizeof(Elf32_Ehdr)) { + if ((res = epic_file_read(fd, hdr, sizeof(Elf32_Ehdr))) != + sizeof(Elf32_Ehdr)) { LOG_ERR("l0der", "_read_elf_header: read failed: %d", res); return res; } @@ -119,7 +120,7 @@ static int _seek_and_read(int fd, uint32_t address, void *data, size_t count) } if ((res = epic_file_read(fd, data, count)) != count) { - LOG_ERR("l0der","_seek_and_read: could not read: %d", res); + LOG_ERR("l0der", "_seek_and_read: could not read: %d", res); return res; } @@ -327,9 +328,9 @@ static int _load_segment(int fd, struct _pie_load_info *li, Elf32_Phdr *phdr) /* * Parse dynamic symbol sections. */ -static int -_parse_dynamic_symbols(int fd, int size, struct _pie_load_info *li, Elf32_Ehdr *hdr) -{ +static int _parse_dynamic_symbols( + int fd, int size, struct _pie_load_info *li, Elf32_Ehdr *hdr +) { int res; Elf32_Shdr shdr; Elf32_Sym sym; @@ -368,7 +369,7 @@ _parse_dynamic_symbols(int fd, int size, struct _pie_load_info *li, Elf32_Ehdr * for (int j = 0; j < sym_count; j++) { if ((res = epic_file_read( fd, &sym, sizeof(Elf32_Sym))) != - sizeof(Elf32_Sym)) { + sizeof(Elf32_Sym)) { LOG_ERR("l0der", "__parse_dynamic_symbols: symbol read failed: %d", res); @@ -401,7 +402,8 @@ _parse_dynamic_symbols(int fd, int size, struct _pie_load_info *li, Elf32_Ehdr * * the only one used when making 'standard' PIE binaries on RAM. However, other * kinds might have to be implemented in the future. */ -static int _run_relocations(int fd, int size, struct _pie_load_info *li, Elf32_Ehdr *hdr) +static int +_run_relocations(int fd, int size, struct _pie_load_info *li, Elf32_Ehdr *hdr) { int res; Elf32_Shdr shdr; @@ -448,7 +450,7 @@ static int _run_relocations(int fd, int size, struct _pie_load_info *li, Elf32_E for (int j = 0; j < reloc_count; j++) { if ((res = epic_file_read( fd, &rel, sizeof(Elf32_Rel))) != - sizeof(Elf32_Rel)) { + sizeof(Elf32_Rel)) { LOG_ERR("l0der", "_run_relocations: relocation read failed: %d", res); @@ -510,7 +512,8 @@ static int _run_relocations(int fd, int size, struct _pie_load_info *li, Elf32_E /* * Load a l0dable PIE binary. */ -static int _load_pie(int fd, int size, Elf32_Ehdr *hdr, struct l0dable_info *info) +static int +_load_pie(int fd, int size, Elf32_Ehdr *hdr, struct l0dable_info *info) { int res; struct _pie_load_info li = { 0 }; diff --git a/hw-tests/dual-core/main.c b/hw-tests/dual-core/main.c index bee6db9f..ca91f9d6 100644 --- a/hw-tests/dual-core/main.c +++ b/hw-tests/dual-core/main.c @@ -18,40 +18,47 @@ int main(void) { - card10_init(); - card10_diag(); - - Paint_DrawImage(Heart, 0, 0, 160, 80); - LCD_Update(); - - for(int i=0; i<11; i++) { - leds_set_dim(i, 1); - } - - int h = 0; - - // Release core1 - core1_start((void *)0x10080000); - - while (1) { - #define NUM 15 - for(int i=0; i<NUM; i++) { - if(i < 12) { - leds_set_hsv(i, (h + 360/NUM * i) % 360, 1., 1./8); - } else { - leds_set_hsv(i, (h + 360/NUM * i) % 360, 1., 1.); - } - } - - leds_update(); - TMR_Delay(MXC_TMR0, MSEC(10), 0); - h++; - - // Send a txev using `sev` every once in a while to wake up core1 - // and let it do something - if (h % 100 == 0) { - printf("core0: Triggering core1 using SEV ...\n"); - __asm volatile("sev"); - } - } + card10_init(); + card10_diag(); + + Paint_DrawImage(Heart, 0, 0, 160, 80); + LCD_Update(); + + for (int i = 0; i < 11; i++) { + leds_set_dim(i, 1); + } + + int h = 0; + + // Release core1 + core1_start((void *)0x10080000); + + while (1) { +#define NUM 15 + for (int i = 0; i < NUM; i++) { + if (i < 12) { + leds_set_hsv( + i, + (h + 360 / NUM * i) % 360, + 1., + 1. / 8 + ); + } else { + leds_set_hsv( + i, (h + 360 / NUM * i) % 360, 1., 1. + ); + } + } + + leds_update(); + TMR_Delay(MXC_TMR0, MSEC(10), 0); + h++; + + // Send a txev using `sev` every once in a while to wake up core1 + // and let it do something + if (h % 100 == 0) { + printf("core0: Triggering core1 using SEV ...\n"); + __asm volatile("sev"); + } + } } -- GitLab