aboutsummaryrefslogtreecommitdiff
path: root/npcm8xx/start.S
diff options
context:
space:
mode:
authorHavard Skinnemoen <hskinnemoen@google.com>2022-03-31 11:32:37 -0700
committerGitHub <noreply@github.com>2022-03-31 11:32:37 -0700
commit1287b6e42e839ba2ab0f06268c5b53ae60df3537 (patch)
tree524eb07d03ed40f0cf3a3d5737048e75e5088826 /npcm8xx/start.S
parent0c37a43527f0ee2b9584e7fb2fdc805e902635ac (diff)
parent1e1e1186b8a5c69527e65c1555f70943f9e4942b (diff)
downloadvbootrom-1287b6e42e839ba2ab0f06268c5b53ae60df3537.zip
vbootrom-1287b6e42e839ba2ab0f06268c5b53ae60df3537.tar.gz
vbootrom-1287b6e42e839ba2ab0f06268c5b53ae60df3537.tar.bz2
Merge pull request #2 from haowu4682/masterHEADmaster
Add basic NPCM8XX support
Diffstat (limited to 'npcm8xx/start.S')
-rw-r--r--npcm8xx/start.S146
1 files changed, 146 insertions, 0 deletions
diff --git a/npcm8xx/start.S b/npcm8xx/start.S
new file mode 100644
index 0000000..58b04da
--- /dev/null
+++ b/npcm8xx/start.S
@@ -0,0 +1,146 @@
+/*
+ * Top-level entry points to the Boot ROM. This includes:
+ * - Reset, exception and interrupt vectors.
+ * - C run-time initialization.
+ * - Secondary CPU boot code.
+ *
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define KiB (1024)
+
+#define SRAM_SIZE (256 * KiB)
+
+.section .text.vectors, "ax"
+
+.global _start
+.type _start, %function
+_start:
+b reset
+. = 0x04
+b undefined_instruction
+. = 0x08
+b software_interrupt
+. = 0x0c
+b prefetch_abort
+. = 0x10
+b data_abort
+. = 0x18
+b interrupt
+. = 0x1c
+b fast_interrupt
+
+undefined_instruction:
+mov x0, #1
+b handle_exception
+
+software_interrupt:
+mov x0, #2
+b handle_exception
+
+prefetch_abort:
+mov x0, #3
+b handle_exception
+
+data_abort:
+mov x0, #4
+b handle_exception
+
+interrupt:
+mov x0, #6
+b handle_exception
+
+fast_interrupt:
+mov x0, #7
+b handle_exception
+
+vectors_end:
+
+.text
+.align 2
+handle_exception:
+
+.global panic
+.type panic, %function
+panic:
+1: wfi
+b 1b
+.size panic, . - panic
+
+.type reset, %function
+reset:
+mov x0, #0
+// Read the CPU ID from MPIDR_EL1.
+mrs x1, MPIDR_EL1
+and x1, x1, #0x03
+cbz x1, cpu0_init
+
+// Not CPU0 -- clear the SCRPAD register and wait for it to change.
+ldr x2, scrpad_addr
+str x0, [x2]
+dsb st
+sev
+1: wfe
+ldr x3, [x2]
+cmp x3, #0
+beq 1b
+
+// SCRPAD is no longer NULL, so jump there.
+ret x3
+.size reset, . - reset
+
+.type scrpad_addr, %object
+scrpad_addr:
+.dword 0xF0800E00
+.size scrpad_addr, . - scrpad_addr
+
+.type cpu0_init, %function
+cpu0_init:
+ldr x1, sram_base_addr
+add sp, x1, #SRAM_SIZE
+
+// Load the boot image into SRAM. Returns the entry address.
+bl load_boot_image
+
+// Jump to the boot image. Panic if it returns back to us.
+ret x0
+b panic
+
+.size cpu0_init, . - cpu0_init
+
+.type sram_base_addr, %object
+sram_base_addr:
+.dword 0xFFFB0000
+.size sram_base_addr, . - sram_base_addr
+
+.type sdram_base_addr, %object
+sdram_base_addr:
+.dword 0x00000000
+.size sdram_base_addr, . - sdram_base_addr
+
+.type etext_addr, %object
+etext_addr:
+.dword _etext
+.size etext_addr, . - etext_addr
+
+.type edata_addr, %object
+edata_addr:
+.dword _edata
+.size edata_addr, . - edata_addr
+
+.type end_addr, %object
+end_addr:
+.dword _end
+.size end_addr, . - end_addr