aboutsummaryrefslogtreecommitdiff
path: root/tests/migration/ppc64/a-b-kernel.S
blob: 0613a8d18e1b6581479897e84196af0c03da58f6 (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
#
# Copyright (c) 2024 IBM, Inc
#
# This work is licensed under the terms of the GNU GPL, version 2 or later.
# See the COPYING file in the top-level directory.

#include "../migration-test.h"

.section .text

.macro print ch
	li	%r3,PPC_H_PUT_TERM_CHAR
	li	%r4,0
	li	%r5,1
	li	%r6,\ch
	sldi	%r6,%r6,56
	sc	1
.endm

        .globl  _start
_start:
. = 0x100
	/*
	 * Enter 64-bit mode. Not necessary because the test uses 32-bit
	 * addresses, but those constants could easily be changed and break
	 * in 32-bit mode.
	 */
	mfmsr	%r9
	li	%r10,-1
	rldimi	%r9,%r10,63,0
	mtmsrd	%r9

        /*
	 * Set up test memory region. Non-volatiles are used because the
	 * hcall can clobber regs.
	 * r20 - start address
	 * r21 - number of pages
	 */
	lis	%r20,PPC_TEST_MEM_START@h
	ori	%r20,%r20,PPC_TEST_MEM_START@l
	lis	%r9,PPC_TEST_MEM_END@h
	ori	%r9,%r9,PPC_TEST_MEM_END@l
	subf	%r21,%r20,%r9
	li	%r10,TEST_MEM_PAGE_SIZE
	divd	%r21,%r21,%r10

	print	'A'

	li	%r3,0
	mr	%r9,%r20
	mtctr	%r21
1:	stb	%r3,0(%r9)
	addi	%r9,%r9,TEST_MEM_PAGE_SIZE
	bdnz	1b

loop:
	mr	%r9,%r20
	mtctr	%r21
1:	lbz	%r3,0(%r9)
	addi	%r3,%r3,1
	stb	%r3,0(%r9)
	addi	%r9,%r9,TEST_MEM_PAGE_SIZE
	bdnz	1b

	print	'B'
	b	loop