From: Oleksij Rempel Date: Mon, 28 Apr 2014 10:08:31 +0000 (+0200) Subject: make sure app_start is always at the entry point X-Git-Tag: 1.4.0~6^2~13 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=c4ac9dc1dc0ffb9b79531860ecd626abfc135809;p=open-ath9k-htc-firmware.git make sure app_start is always at the entry point Add ".boot" section to the linker and make sure app_start() is always there. Till now every change in app start was cousing randome issues. Signed-off-by: Oleksij Rempel --- diff --git a/target_firmware/CMakeLists.txt b/target_firmware/CMakeLists.txt index 12ffc8b..56e486a 100644 --- a/target_firmware/CMakeLists.txt +++ b/target_firmware/CMakeLists.txt @@ -110,6 +110,8 @@ ADD_CUSTOM_COMMAND( OUTPUT fw.bin DEPENDS fw.elf COMMAND ${CMAKE_OBJCOPY} + --change-section-lma .boot-0x400000 + --change-section-vma .boot-0x400000 --change-section-lma .text-0x400000 --change-section-vma .text-0x400000 -O binary fw.elf fw.bin diff --git a/target_firmware/magpie_fw_dev/target/inc/linux/compiler.h b/target_firmware/magpie_fw_dev/target/inc/linux/compiler.h new file mode 100644 index 0000000..725ee73 --- /dev/null +++ b/target_firmware/magpie_fw_dev/target/inc/linux/compiler.h @@ -0,0 +1,107 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __SHARED_COMPILER_H +#define __SHARED_COMPILER_H + +#define __noinline __attribute__((noinline)) +#define __noreturn __attribute__((noreturn)) +#define __inline __attribute__((always_inline)) +#define __hot __attribute__((hot)) +#define __cold __attribute__((cold)) +#define __unused __attribute__((unused)) +#define __force __attribute__((force)) +#define __section(s) __attribute__((section("." # s))) +#define __aligned(a) __attribute__((aligned(a))) +#define __packed __attribute__((packed)) +#define __visible __attribute__((externally_visible)) + +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) +#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1) + +#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1) +#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) + +#define __roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) + +#define __must_be_array(a) \ + BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) +#define ARRAY_SIZE(arr) (sizeof((arr)) / sizeof((arr)[0]) + __must_be_array(arr)) + +#define BIT(b) (1 << (b)) +#define MASK(w) (BIT(w) - 1) + +#undef offsetof +#ifdef __compiler_offsetof +# define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER) +#else +# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) + +#define min(x, y) ({ \ + typeof(x) _min1 = (x); \ + typeof(y) _min2 = (y); \ + (void) (&_min1 == &_min2); \ + _min1 < _min2 ? _min1 : _min2; }) + +#define max(x, y) ({ \ + typeof(x) _max1 = (x); \ + typeof(y) _max2 = (y); \ + (void) (&_max1 == &_max2); \ + _max1 > _max2 ? _max1 : _max2; }) + +#define min_t(type, x, y) ({ \ + type __min1 = (x); \ + type __min2 = (y); \ + __min1 < __min2 ? __min1 : __min2; }) + +#define max_t(type, x, y) ({ \ + type __max1 = (x); \ + type __max2 = (y); \ + __max1 > __max2 ? __max1 : __max2; }) + + +#define container_of(ptr, type, member) ({ \ + const typeof(((type *)0)->member) * __mptr = (ptr); \ + (type *)(((unsigned long)__mptr - offsetof(type, member))); }) + +#define MAX_ERRNO 4095 + +#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO) + +static inline void *ERR_PTR(long errornr) +{ + return (void *) errornr; +} + +static inline long PTR_ERR(const void *ptr) +{ + return (long) ptr; +} + +static inline long IS_ERR(const void *ptr) +{ + return IS_ERR_VALUE((unsigned long)ptr); +} + +static inline long IS_ERR_OR_NULL(const void *ptr) +{ + return !ptr || IS_ERR_VALUE((unsigned long)ptr); +} +#endif /* __SHARED_COMPILER_H */ diff --git a/target_firmware/magpie_fw_dev/target/init/app_start.c b/target_firmware/magpie_fw_dev/target/init/app_start.c index 563d4de..9a7bbe3 100644 --- a/target_firmware/magpie_fw_dev/target/init/app_start.c +++ b/target_firmware/magpie_fw_dev/target/init/app_start.c @@ -39,6 +39,8 @@ #include "usb_defs.h" #include "init.h" +#include + // @TODO: Should define the memory region later~ #define ALLOCRAM_START ( ((unsigned int)&_fw_image_end) + 4) #define ALLOCRAM_SIZE ( SYS_RAM_SZIE - ( ALLOCRAM_START - SYS_D_RAM_REGION_0_BASE) - SYS_D_RAM_STACK_SIZE) @@ -67,7 +69,8 @@ extern a_uint32_t cmnos_milliseconds_patch(void); extern BOOLEAN bJumptoFlash; extern BOOLEAN bEepromExist; -void app_start() + +void __section(boot) __noreturn __visible app_start(void) { uint32_t rst_status; A_HOSTIF hostif; diff --git a/target_firmware/ram-k2.ld b/target_firmware/ram-k2.ld index 9f255df..e0abd57 100755 --- a/target_firmware/ram-k2.ld +++ b/target_firmware/ram-k2.ld @@ -203,6 +203,9 @@ SECTIONS /*_stack_sentry = ALIGN(0x8);*/ } >dram_seg :dram_phdr + .boot : + { *(.boot) } > iram_seg :iram_phdr + .text : { _stext = .; diff --git a/target_firmware/ram-magpie.ld b/target_firmware/ram-magpie.ld index 2cf7f30..186f96b 100755 --- a/target_firmware/ram-magpie.ld +++ b/target_firmware/ram-magpie.ld @@ -203,6 +203,9 @@ SECTIONS /*_stack_sentry = ALIGN(0x8);*/ } >dram_seg :dram_phdr + .boot : + { *(.boot) } > iram_seg :iram_phdr + .text : { _stext = .;