2020-03-05 07:36:01 +08:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// Copyright 2019 Western Digital Corporation or its affiliates.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
2020-01-23 06:22:50 +08:00
|
|
|
|
2020-03-05 07:36:01 +08:00
|
|
|
// Assembly code for Hello World
|
|
|
|
// Not using only ALU ops for creating the string
|
2020-01-23 06:22:50 +08:00
|
|
|
|
|
|
|
|
2020-03-05 07:36:01 +08:00
|
|
|
#include "defines.h"
|
2020-01-23 06:22:50 +08:00
|
|
|
|
2020-03-05 07:36:01 +08:00
|
|
|
#define STDOUT 0xd0580000
|
2020-01-23 06:22:50 +08:00
|
|
|
|
|
|
|
|
2020-03-05 07:36:01 +08:00
|
|
|
// Code to execute
|
|
|
|
.section .text
|
|
|
|
.global _start
|
|
|
|
_start:
|
2020-01-23 06:22:50 +08:00
|
|
|
|
2020-03-05 07:36:01 +08:00
|
|
|
// Clear minstret
|
|
|
|
csrw minstret, zero
|
|
|
|
csrw minstreth, zero
|
|
|
|
|
|
|
|
// Set up MTVEC - not expecting to use it though
|
|
|
|
li x1, RV_ICCM_SADR
|
|
|
|
csrw mtvec, x1
|
|
|
|
|
|
|
|
|
|
|
|
// Enable Caches in MRAC
|
|
|
|
li x1, 0x5f555555
|
|
|
|
csrw 0x7c0, x1
|
|
|
|
|
|
|
|
// Load string from hw_data
|
|
|
|
// and write to stdout address
|
|
|
|
|
|
|
|
li x3, STDOUT
|
|
|
|
la x4, hw_data
|
|
|
|
|
|
|
|
loop:
|
|
|
|
lb x5, 0(x4)
|
|
|
|
sb x5, 0(x3)
|
|
|
|
addi x4, x4, 1
|
|
|
|
bnez x5, loop
|
|
|
|
|
|
|
|
// Write 0xff to STDOUT for TB to termiate test.
|
|
|
|
_finish:
|
|
|
|
li x3, STDOUT
|
|
|
|
addi x5, x0, 0xff
|
|
|
|
sb x5, 0(x3)
|
|
|
|
beq x0, x0, _finish
|
|
|
|
.rept 100
|
|
|
|
nop
|
|
|
|
.endr
|
|
|
|
|
|
|
|
.data
|
|
|
|
hw_data:
|
|
|
|
.ascii "----------------------------------\n"
|
|
|
|
.ascii "Hello World from SweRV EL2 @WDC !!\n"
|
|
|
|
.ascii "----------------------------------\n"
|
|
|
|
.byte 0
|