xref: /openbmc/qemu/tests/migration/aarch64/a-b-kernel.S (revision 1f6a638cee087b1be4f464e44a9311e19a79c50e)
1c02b3781SWei Huang#
2c02b3781SWei Huang# Copyright (c) 2018 Red Hat, Inc. and/or its affiliates
3c02b3781SWei Huang#
4c02b3781SWei Huang# Author:
5c02b3781SWei Huang#   Wei Huang <wei@redhat.com>
6c02b3781SWei Huang#
7c02b3781SWei Huang# This work is licensed under the terms of the GNU GPL, version 2 or later.
8c02b3781SWei Huang# See the COPYING file in the top-level directory.
9c02b3781SWei Huang#
10c02b3781SWei Huang# Note: Please make sure the compiler compiles the assembly code below with
11c02b3781SWei Huang# pc-relative address. Also the branch instructions should use relative
12c02b3781SWei Huang# addresses only.
13c02b3781SWei Huang
14c02b3781SWei Huang#include "../migration-test.h"
15c02b3781SWei Huang
16c02b3781SWei Huang.section .text
17c02b3781SWei Huang
18c02b3781SWei Huang        .globl  _start
19c02b3781SWei Huang
20c02b3781SWei Huang_start:
21c02b3781SWei Huang        /* disable MMU to use phys mem address */
22c02b3781SWei Huang        mrs     x0, sctlr_el1
23c02b3781SWei Huang        bic     x0, x0, #(1<<0)
24c02b3781SWei Huang        msr     sctlr_el1, x0
25c02b3781SWei Huang        isb
26c02b3781SWei Huang
27c02b3781SWei Huang        /* traverse test memory region */
28c02b3781SWei Huang        mov     x0, #ARM_TEST_MEM_START
29c02b3781SWei Huang        mov     x1, #ARM_TEST_MEM_END
30c02b3781SWei Huang
31c02b3781SWei Huang        /* output char 'A' to PL011 */
32c02b3781SWei Huang        mov     w3, 'A'
33c02b3781SWei Huang        mov     x2, #ARM_MACH_VIRT_UART
34c02b3781SWei Huang        strb    w3, [x2]
35c02b3781SWei Huang
36c02b3781SWei Huang        /* clean up memory */
37c02b3781SWei Huang        mov     w3, #0
38c02b3781SWei Huang        mov     x4, x0
39c02b3781SWei Huangclean:
40c02b3781SWei Huang        strb    w3, [x4]
41c02b3781SWei Huang        add     x4, x4, #TEST_MEM_PAGE_SIZE
42c02b3781SWei Huang        cmp     x4, x1
43c02b3781SWei Huang        ble     clean
44c02b3781SWei Huang
45c02b3781SWei Huang        /* w5 keeps a counter so we can limit the output speed */
46c02b3781SWei Huang        mov     w5, #0
47c02b3781SWei Huang
48c02b3781SWei Huang        /* main body */
49c02b3781SWei Huangmainloop:
50c02b3781SWei Huang        mov     x4, x0
51c02b3781SWei Huang
52c02b3781SWei Huanginnerloop:
53c02b3781SWei Huang        /* increment the first byte of each page by 1 */
54c02b3781SWei Huang        ldrb    w3, [x4]
55c02b3781SWei Huang        add     w3, w3, #1
56c02b3781SWei Huang        strb    w3, [x4]
57c02b3781SWei Huang
58c02b3781SWei Huang        /* make sure QEMU user space can see consistent data as MMU is off */
59c02b3781SWei Huang        dc      civac, x4
60c02b3781SWei Huang
61c02b3781SWei Huang        add     x4, x4, #TEST_MEM_PAGE_SIZE
62c02b3781SWei Huang        cmp     x4, x1
63c02b3781SWei Huang        blt     innerloop
64c02b3781SWei Huang
65c02b3781SWei Huang        add     w5, w5, #1
66*c398c761SThomas Huth        and     w5, w5, #0x1f
67c02b3781SWei Huang        cmp     w5, #0
68c02b3781SWei Huang        bne     mainloop
69c02b3781SWei Huang
70c02b3781SWei Huang        /* output char 'B' to PL011 */
71c02b3781SWei Huang        mov     w3, 'B'
72c02b3781SWei Huang        strb    w3, [x2]
73c02b3781SWei Huang
74c02b3781SWei Huang        b       mainloop
75