aboutsummaryrefslogtreecommitdiff
path: root/src/ethosu_device.c
diff options
context:
space:
mode:
authorBhavik Patel <bhavik.patel@arm.com>2020-06-03 10:05:28 +0200
committerBhavik Patel <bhavik.patel@arm.com>2020-06-05 14:48:41 +0200
commit790ef36ae09f421f17c7a7aa3ae055894a8397fc (patch)
treedf78329be83b5986560f80d452891b2a080f70e4 /src/ethosu_device.c
parentb64628f0aa412ae962e0398bf8c85271f19fb117 (diff)
downloadethos-u-core-driver-790ef36ae09f421f17c7a7aa3ae055894a8397fc.tar.gz
MLBEDSW-2272 Reenable the version checker for optimizer config
Also check that the command stream address and base address are aligned to 16 bytes. Return error in case they are not correctly aligned. Change-Id: I786d03f403d02d601ee74c53d2dede85b2b0e8a0
Diffstat (limited to 'src/ethosu_device.c')
-rw-r--r--src/ethosu_device.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/ethosu_device.c b/src/ethosu_device.c
index 7ce8fad..d6360f4 100644
--- a/src/ethosu_device.c
+++ b/src/ethosu_device.c
@@ -15,15 +15,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
#include "ethosu_device.h"
-
#include "ethosu_common.h"
+
#include <assert.h>
+#include <stdbool.h>
+#include <stddef.h>
#include <stdio.h>
#define MASK_0_31_BITS 0xFFFFFFFF
#define MASK_32_47_BITS 0xFFFF00000000
+#define MASK_16_BYTE_ALIGN 0xF
#define BASEP_OFFSET 4
#define REG_OFFSET 4
#define BYTES_1KB 1024
@@ -90,6 +92,26 @@ enum ethosu_error_codes ethosu_run_command_stream(const uint8_t *cmd_stream_ptr,
ASSERT(num_base_addr <= ETHOSU_DRIVER_BASEP_INDEXES);
+ if (0 != ((ptrdiff_t)cmd_stream_ptr & MASK_16_BYTE_ALIGN))
+ {
+ LOG_ERR("Error: Command stream addr %p not aligned to 16 bytes\n", cmd_stream_ptr);
+ return ETHOSU_INVALID_PARAM;
+ }
+
+ bool base_addr_invalid = false;
+ for (int i = 0; i < num_base_addr; i++)
+ {
+ if (0 != (base_addr[i] & MASK_16_BYTE_ALIGN))
+ {
+ LOG_ERR("Error: Base addr %d: %p not aligned to 16 bytes\n", i, (void *)(base_addr[i]));
+ base_addr_invalid = true;
+ }
+ }
+ if (base_addr_invalid)
+ {
+ return ETHOSU_INVALID_PARAM;
+ }
+
qbase0 = ((uint64_t)cmd_stream_ptr) & MASK_0_31_BITS;
qbase1 = (((uint64_t)cmd_stream_ptr) & MASK_32_47_BITS) >> 32;
qsize = cms_length;