X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fopenwrt.git;a=blobdiff_plain;f=target%2Flinux%2Far71xx%2Ffiles%2Farch%2Fmips%2Fath79%2Frouterboot.c;fp=target%2Flinux%2Far71xx%2Ffiles%2Farch%2Fmips%2Fath79%2Frouterboot.c;h=1cb1f9d4ebdf3702897c7ee09e2f2e7d83afa876;hp=3c6f9aaeb371133087e5b5f9a5848e7348142aeb;hb=144cfb65a478a57ae0c551df27ee6d152b644799;hpb=2c5a5d87363791b7f6221de8fff0ade3be21c0ea diff --git a/target/linux/ar71xx/files/arch/mips/ath79/routerboot.c b/target/linux/ar71xx/files/arch/mips/ath79/routerboot.c index 3c6f9aaeb3..1cb1f9d4eb 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/routerboot.c +++ b/target/linux/ar71xx/files/arch/mips/ath79/routerboot.c @@ -29,6 +29,26 @@ static u16 get_u16(void *buf) return (u16) p[1] + ((u16) p[0] << 8); } +__init int +routerboot_find_magic(u8 *buf, unsigned int buflen, u32 *offset, bool hard) +{ + u32 magic_ref = hard ? RB_MAGIC_HARD : RB_MAGIC_SOFT; + u32 magic; + u32 cur = *offset; + + while (cur < buflen) { + magic = get_u32(buf + cur); + if (magic == magic_ref) { + *offset = cur; + return 0; + } + + cur += 0x1000; + } + + return -ENOENT; +} + __init int routerboot_find_tag(u8 *buf, unsigned int buflen, u16 tag_id, u8 **tag_data, u16 *tag_len)