Merge remote-tracking branch 'spacebeaker/upstream' into update

Bypass-Presubmit-Reason: no CI sencha tests

Change-Id: I759201bf678fc8dd5f6b1f7e06f8a89078a7d4ae
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
new file mode 100644
index 0000000..8deda18
--- /dev/null
+++ b/PREUPLOAD.cfg
@@ -0,0 +1,13 @@
+# Per-project `repo upload` hook settings.
+# https://android.googlesource.com/platform/tools/repohooks
+
+[Options]
+ignore_merged_commits = true
+
+[Builtin Hooks]
+cpplint = false
+pylint3 = false
+clang_format = false
+
+[Hook Scripts]
+yapf-diff = ${REPO_ROOT}/scripts/preupload-hooks/yapf-diff.sh --bypass
diff --git a/sdk/boards/sencha.json b/sdk/boards/sencha.json
new file mode 100644
index 0000000..4c2d755
--- /dev/null
+++ b/sdk/boards/sencha.json
@@ -0,0 +1,97 @@
+{
+    "devices": {
+        "clint": {
+            "start"  : 0x2000000,
+            "length" : 0x10000
+        },
+        "plic": {
+            "start"  : 0x60000000,
+            "length" : 0x400000
+        },
+        "uart": {
+            "start": 0x54000000,
+            "end":   0x54000100
+        },
+        "i2s": {
+            "start": 0x54100000,
+            "length": 0x40
+        },
+        "ml_top_core": {
+            "start": 0x5C000000,
+            "length": 0x40
+        },
+        "ml_top_dmem": {
+            "start": 0x5A000000,
+            "length": 0x400000
+        },
+        "mailbox_smc": {
+            "start": 0x540F1000,
+            "length": 0x40
+        },
+        "shadow" : {
+            "start": 0x83000000,
+            "end":   0x83010000
+        }
+    },
+    "instruction_memory": {
+        "start": 0x80000000,
+        "end": 0x80400000
+    },
+    "heap": {
+        "start": 0x80380000,
+        "end":   0x80400000
+    },
+    "interrupts": [
+        {
+            "name": "I2sRxWatermarkInterrupt",
+            "number": 40,
+            "priority": 3
+        },
+        {
+            "name": "I2sTxWatermarkInterrupt",
+            "number": 39,
+            "priority": 3
+        },
+        {
+            "name": "I2sTxEmptyInterrupt",
+            "number": 41,
+            "priority": 3
+        },
+        {
+            "name": "MlTopFinishInterrupt",
+            "number": 34,
+            "priority": 3
+        },
+        {
+            "name": "MlTopFaultInterrupt",
+            "number": 35,
+            "priority": 3
+        },
+        {
+            "name": "MailboxWtInterrupt",
+            "number": 30,
+            "priority": 3
+        },
+        {
+            "name": "MailboxRtInterrupt",
+            "number": 31,
+            "priority": 3
+        },
+        {
+            "name": "MailboxEInterrupt",
+            "number": 32,
+            "priority": 3
+        }
+    ],
+    "defines" : [ "SENCHA" ],
+    "driver_includes" : [
+        "${sdk}/include/platform/sencha",
+        "${sdk}/include/platform/generic-riscv"
+    ],
+    "timer_hz" : 2000,
+    "tickrate_hz" : 10,
+    "revoker" : "software",
+    "stack_high_water_mark" : true,
+    "simulator" : "cheriot_sim",
+    "simulation": true
+}
diff --git a/sdk/core/scheduler/thread.h b/sdk/core/scheduler/thread.h
index e5b2961..c23423a 100644
--- a/sdk/core/scheduler/thread.h
+++ b/sdk/core/scheduler/thread.h
@@ -353,7 +353,7 @@
 		 */
 		static bool exit()
 		{
-			Debug::log("Thread exited, {} threads remaining", threadCount - 1);
+			Debug::log("Thread {} exited, {} threads remaining", current->threadId, threadCount - 1);
 			current->list_remove(&priorityList[current->priority]);
 			current->state = ThreadState::Exited;
 			return (--threadCount) == 0;
diff --git a/sdk/include/assert.h b/sdk/include/assert.h
index 5f3dd9c..4e83e5d 100644
--- a/sdk/include/assert.h
+++ b/sdk/include/assert.h
@@ -12,4 +12,8 @@
 #	define assert(x) ((x) ? (void)0 : panic())
 #endif
 
+#ifndef static_assert
+#define static_assert _Static_assert
+#endif
+
 #endif // _ASSERT_H_
diff --git a/sdk/include/platform/sencha/platform-i2s.hh b/sdk/include/platform/sencha/platform-i2s.hh
new file mode 100644
index 0000000..1bc3540
--- /dev/null
+++ b/sdk/include/platform/sencha/platform-i2s.hh
@@ -0,0 +1,17 @@
+#pragma once
+#include <compartment-macros.h>
+#include <interrupt.h>
+#include <riscvreg.h>
+
+DECLARE_AND_DEFINE_INTERRUPT_CAPABILITY(i2sRxWatermarkInterruptCapability,
+                                        InterruptName::I2sRxWatermarkInterrupt,
+                                        true,
+                                        true)
+DECLARE_AND_DEFINE_INTERRUPT_CAPABILITY(i2sTxWatermarkInterruptCapability,
+                                        InterruptName::I2sTxWatermarkInterrupt,
+                                        true,
+                                        true)
+DECLARE_AND_DEFINE_INTERRUPT_CAPABILITY(i2sTxEmptyInterruptCapability,
+                                        InterruptName::I2sTxEmptyInterrupt,
+                                        true,
+                                        true)
diff --git a/sdk/include/platform/sencha/platform-mailbox.hh b/sdk/include/platform/sencha/platform-mailbox.hh
new file mode 100644
index 0000000..fb172e5
--- /dev/null
+++ b/sdk/include/platform/sencha/platform-mailbox.hh
@@ -0,0 +1,9 @@
+#pragma once
+#include <compartment-macros.h>
+#include <interrupt.h>
+#include <riscvreg.h>
+
+DECLARE_AND_DEFINE_INTERRUPT_CAPABILITY(mailboxRtInterruptCapability,
+                                        InterruptName::MailboxRtInterrupt,
+                                        true,
+                                        true)
diff --git a/sdk/include/platform/sencha/platform-ml_top.hh b/sdk/include/platform/sencha/platform-ml_top.hh
new file mode 100644
index 0000000..cb7af3b
--- /dev/null
+++ b/sdk/include/platform/sencha/platform-ml_top.hh
@@ -0,0 +1,13 @@
+#pragma once
+#include <compartment-macros.h>
+#include <interrupt.h>
+#include <riscvreg.h>
+
+DECLARE_AND_DEFINE_INTERRUPT_CAPABILITY(mlTopFinishInterruptCapability,
+                                        InterruptName::MlTopFinishInterrupt,
+                                        true,
+                                        true)
+DECLARE_AND_DEFINE_INTERRUPT_CAPABILITY(mlTopFaultInterruptCapability,
+                                        InterruptName::MlTopFaultInterrupt,
+                                        true,
+                                        true)