summaryrefslogtreecommitdiff
path: root/sim/testsuite/pru/testutils.inc
blob: dfe63f331763c39e4e39cbc34a9f8057bd7fe517 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Copyright (C) 2016-2021 Free Software Foundation, Inc.
# Contributed by Dimitar Dimitrov <dimitar@dinux.eu>
#
# This file is part of the GNU simulators.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# MACRO: start
# All assembler tests should start with a call to "main_test"
	.macro start
	.text

	.global _start
_start:

	# Skip over these inlined funcs.
	jmp __main_test;

	.global __pass
	.type __pass, function
__pass:
	# Note - DRAM LMA and VMA are equal for PRU, so
	# we can afford to pass DRAM pointer directly.
	write 1, _passmsg, 5
	exit 0

	.global __fail
	.type __fail, function
__fail:
	write 1, _failmsg, 5
	exit 1

	.data
_passmsg:
	.ascii "pass\n"

_failmsg:
	.ascii "fail\n"

	.text
	.global __main_test
	.type __main_test, function
__main_test:
	.endm

# MACRO: system_call
# Make a libgloss system call
	.macro system_call nr:req, arg1=0, arg2=0, arg3=0
	ldi r1, \nr
	ldi r14, \arg1
	ldi r15, \arg2
	ldi r16, \arg3
	halt
	.endm

# MACRO: exit
# Quit the current test
	.macro exit rc:req
	system_call 1, \rc
	.endm

# MACRO: pass
# Write 'pass' to stdout via syscalls and quit;
# meant for non-OS operating environments
	.macro pass
	jmp __pass;
	.endm

# MACRO: fail
# Write 'fail' to stdout via syscalls and quit;
# meant for non-OS operating environments
	.macro fail
	jmp __fail;
	.endm

# MACRO: write
# Just like the write() C function; uses system calls
	.macro write fd:req, str:req, len:req
	system_call 5, \fd, \str, \len
	.endm

# MACRO: qbne32
# Like qbne instruction, but check a 32-bit constant value.
	.macro qbne32 label:req, op0:req, C0:req
	qbne \label, \op0\().b0, ((\C0) >> 0) & 0xff
	qbne \label, \op0\().b1, ((\C0) >> 8) & 0xff
	qbne \label, \op0\().b2, ((\C0) >> 16) & 0xff
	qbne \label, \op0\().b3, ((\C0) >> 24) & 0xff
	.endm