mirror of
https://github.com/retroSoC/retroSoC.git
synced 2026-11-04 22:32:36 +00:00
- Updated paths in test files to reflect new directory structure for RTL and script files. - Changed references from rtl/mini to rtl/ip and scripts/rtl where applicable. - Added a new test file for Tiny product isolation, ensuring independent ABI and bus acceptance. - Enhanced tests for memory map generation and protocol contracts for Tiny architecture. - Ensured that all tests are aligned with the latest directory structure and naming conventions.
150 lines
3.3 KiB
ArmAsm
150 lines
3.3 KiB
ArmAsm
.section .init
|
|
.global _start
|
|
.type _start,@function
|
|
|
|
#include "retrosoc/arch/riscv/system_csr.h"
|
|
#include "retrosoc/generated/memory_map.h"
|
|
|
|
_start:
|
|
#ifdef CSR_ENABLE
|
|
/* Disable Global Interrupt */
|
|
csrc CSR_MSTATUS, MSTATUS_MIE
|
|
/* Disable all interrupts controlled by CSR MIE */
|
|
csrw CSR_MIE, 0x0
|
|
/* Set Trap Entry MTVEC to trap_entry */
|
|
la t0, system_trap_entry
|
|
csrw CSR_MTVEC, t0
|
|
/* Direct Mode: All exceptions set pc to BASE */
|
|
csrc CSR_MTVEC, 0x3
|
|
#endif
|
|
#ifndef RS_SOC_TINY
|
|
# wait psram reset done
|
|
la a0, _flash_wait_start
|
|
la a1, 2000
|
|
wait_psram_reset:
|
|
lw t0, 0(a0)
|
|
addi a0, a0, 4
|
|
blt a0, a1, wait_psram_reset
|
|
|
|
#endif
|
|
|
|
# ===== Startup Stage 1 =====
|
|
# init the regfile
|
|
# zero-initialize register file
|
|
li x1, 0
|
|
# x2 (sp) is initialized by hardware
|
|
la x2, _stack_point
|
|
li x3, 0
|
|
li x4, 0
|
|
li x5, 0
|
|
li x6, 0
|
|
li x7, 0
|
|
li x8, 0
|
|
li x9, 0
|
|
li x10, 0
|
|
li x11, 0
|
|
li x12, 0
|
|
li x13, 0
|
|
li x14, 0
|
|
li x15, 0
|
|
#if ISA_RV32I || ISA_RV32IM
|
|
li x16, 0
|
|
li x17, 0
|
|
li x18, 0
|
|
li x19, 0
|
|
li x20, 0
|
|
li x21, 0
|
|
li x22, 0
|
|
li x23, 0
|
|
li x24, 0
|
|
li x25, 0
|
|
li x26, 0
|
|
li x27, 0
|
|
li x28, 0
|
|
li x29, 0
|
|
li x30, 0
|
|
li x31, 0
|
|
#endif
|
|
|
|
# ===== Startup Stage 2 =====
|
|
# Load code section from FLASH to RAM
|
|
# when code LMA is different with VMA
|
|
# test: using psram before loading
|
|
|
|
#ifndef RS_SOC_TINY
|
|
# Define the addresses
|
|
.equ GPIO_ALT_ENABLE, RS_SOC_APB4_GPIO_ADMIN_BASE + 0x34
|
|
.equ GPIO_ALT_SELECT, RS_SOC_APB4_GPIO_ADMIN_BASE + 0x38
|
|
.equ BIT_MASK, 0x3FE00000 # Bits 21 to 29 set to 1
|
|
.equ PSRAM_COMMAND, RS_SOC_APB4_PSRAM_BASE + 0x04
|
|
.equ PSRAM_STATUS, RS_SOC_APB4_PSRAM_BASE + 0x08
|
|
.equ PSRAM_INIT, 0x01
|
|
.equ PSRAM_READY, 0x20
|
|
|
|
PINMUX_PSRAM:
|
|
li t0, GPIO_ALT_ENABLE
|
|
lw t1, 0(t0)
|
|
li t2, BIT_MASK
|
|
or t1, t1, t2
|
|
sw t1, 0(t0)
|
|
li t0, GPIO_ALT_SELECT
|
|
lw t1, 0(t0)
|
|
or t1, t1, t2
|
|
sw t1, 0(t0)
|
|
PSRAM_INIT_TRG:
|
|
li t0, PSRAM_COMMAND
|
|
li t1, PSRAM_INIT
|
|
sw t1, 0(t0)
|
|
|
|
PSRAM_READY_WAIT:
|
|
li t0, PSRAM_STATUS
|
|
lw t1, 0(t0)
|
|
andi t1, t1, PSRAM_READY
|
|
beqz t1, PSRAM_READY_WAIT
|
|
|
|
#endif
|
|
|
|
app_loader_start:
|
|
la a0, _ram_lma
|
|
la a1, _ram_vma
|
|
beq a0, a1, data_loader_start # flash xip
|
|
la a2, _etext
|
|
bgeu a1, a2, data_loader_start
|
|
app_loader:
|
|
lw t0, (a0)
|
|
sw t0, (a1)
|
|
addi a0, a0, 4
|
|
addi a1, a1, 4
|
|
bltu a1, a2, app_loader
|
|
|
|
data_loader_start:
|
|
la a0, _psram_lma
|
|
la a1, _psram_vma
|
|
beq a0, a1, bss_cleaner_start
|
|
la a2, _edata
|
|
bgeu a1, a2, bss_cleaner_start
|
|
data_loader:
|
|
lw t0, (a0)
|
|
sw t0, (a1)
|
|
addi a0, a0, 4
|
|
addi a1, a1, 4
|
|
bltu a1, a2, data_loader
|
|
|
|
bss_cleaner_start:
|
|
la a0, _sbss
|
|
la a1, _ebss
|
|
bge a0, a1, main_start
|
|
bss_cleaner:
|
|
sw zero, 0(a0)
|
|
addi a0, a0, 4
|
|
blt a0, a1, bss_cleaner
|
|
|
|
main_start:
|
|
# call main
|
|
#ifdef CSR_ENABLE
|
|
call _premain_init # init irq
|
|
#endif
|
|
call main
|
|
loop:
|
|
j loop
|