Avoid tripping on opposite-endian sysconfig/fex blobs.

This commit is contained in:
jakllsch 2017-03-08 17:06:35 +00:00
parent 98b12bdd4b
commit d68ee6e41f
1 changed files with 11 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: awin_sysconfig.c,v 1.2 2015/10/25 20:46:46 bouyer Exp $ */
/* $NetBSD: awin_sysconfig.c,v 1.3 2017/03/08 17:06:35 jakllsch Exp $ */
/*-
* Copyright (c) 2014 Jared D. McNeill <jmcneill@invisible.ca>
@ -29,7 +29,7 @@
#include "opt_allwinner.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: awin_sysconfig.c,v 1.2 2015/10/25 20:46:46 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: awin_sysconfig.c,v 1.3 2017/03/08 17:06:35 jakllsch Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@ -90,6 +90,8 @@ static bool awin_sysconfig_parse(const char *, const char *,
bool
awin_sysconfig_init(void)
{
struct awin_sysconfig_head head;
if (get_bootconf_option(boot_args, "sysconfig",
BOOTOPT_TYPE_HEXINT, &awin_sysconfig_base) == 0) {
return false;
@ -102,6 +104,13 @@ awin_sysconfig_init(void)
(awin_sysconfig_base + KERNEL_BASE_VOFFSET);
memcpy(awin_sysconfig, sysconfig, AWIN_SYSCONFIG_SIZE);
memcpy(&head, &awin_sysconfig[0], sizeof(head));
if (head.count >= 0x01000000) {
printf("%s(): 0x%x entries in sysconfig, ignoring.\n",
__func__, head.count);
return false;
}
return true;
}