1#
2# Copyright (c) 2024 IBM, Inc
3#
4# This work is licensed under the terms of the GNU GPL, version 2 or later.
5# See the COPYING file in the top-level directory.
6
7#include "../migration-test.h"
8
9.section .text
10
11.macro print ch
12	li	%r3,PPC_H_PUT_TERM_CHAR
13	li	%r4,0
14	li	%r5,1
15	li	%r6,\ch
16	sldi	%r6,%r6,56
17	sc	1
18.endm
19
20        .globl  _start
21_start:
22. = 0x100
23	/*
24	 * Enter 64-bit mode. Not necessary because the test uses 32-bit
25	 * addresses, but those constants could easily be changed and break
26	 * in 32-bit mode.
27	 */
28	mfmsr	%r9
29	li	%r10,-1
30	rldimi	%r9,%r10,63,0
31	mtmsrd	%r9
32
33        /*
34	 * Set up test memory region. Non-volatiles are used because the
35	 * hcall can clobber regs.
36	 * r20 - start address
37	 * r21 - number of pages
38	 */
39	lis	%r20,PPC_TEST_MEM_START@h
40	ori	%r20,%r20,PPC_TEST_MEM_START@l
41	lis	%r9,PPC_TEST_MEM_END@h
42	ori	%r9,%r9,PPC_TEST_MEM_END@l
43	subf	%r21,%r20,%r9
44	li	%r10,TEST_MEM_PAGE_SIZE
45	divd	%r21,%r21,%r10
46
47	print	'A'
48
49	li	%r3,0
50	mr	%r9,%r20
51	mtctr	%r21
521:	stb	%r3,0(%r9)
53	addi	%r9,%r9,TEST_MEM_PAGE_SIZE
54	bdnz	1b
55
56loop:
57	mr	%r9,%r20
58	mtctr	%r21
591:	lbz	%r3,0(%r9)
60	addi	%r3,%r3,1
61	stb	%r3,0(%r9)
62	addi	%r9,%r9,TEST_MEM_PAGE_SIZE
63	bdnz	1b
64
65	print	'B'
66	b	loop
67