1 # x86 bootblock used in migration test
2 # repeatedly increments the first byte of each page in a 100MB
4 # Outputs an initial 'A' on serial followed by repeated 'B's
6 # Copyright (c) 2016 Red Hat, Inc. and/or its affiliates
7 # This work is licensed under the terms of the GNU GPL, version 2 or later.
8 # See the COPYING file in the top-level directory.
10 # Author: dgilbert@redhat.com
12 #include "migration-test.h"
14 #define ACPI_ENABLE 0xf1
15 #define ACPI_PORT_SMI_CMD 0xb2
16 #define ACPI_PM_BASE 0x600
17 #define PM1A_CNT_OFFSET 4
19 #define ACPI_SCI_ENABLE 0x0001
20 #define ACPI_SLEEP_TYPE 0x0400
21 #define ACPI_SLEEP_ENABLE 0x2000
22 #define SLEEP (ACPI_SCI_ENABLE + ACPI_SLEEP_TYPE + ACPI_SLEEP_ENABLE)
24 #define LOW_ADDR X86_TEST_MEM_START
25 #define HIGH_ADDR X86_TEST_MEM_END
27 /* Save the suspended status at an address that is not written in the loop. */
28 #define suspended (X86_TEST_MEM_START + 4)
35 .type start, @function
40 mov %eax,%cr0 # Protected mode enable
41 data32 ljmp $8,$0x7c20
45 # A20 enable - not sure I actually need this
50 # set up DS for the whole of RAM (needed on KVM)
55 .set TEST_MEM_START, X86_TEST_MEM_START
56 .set TEST_MEM_END, X86_TEST_MEM_END
62 # bl keeps a counter so we limit the output speed
66 mov $TEST_MEM_START,%eax
70 cmp $TEST_MEM_END,%eax
74 mov $TEST_MEM_START,%eax
78 cmp $TEST_MEM_END,%eax
89 # should this test suspend?
94 # are we waking after suspend? do not suspend again.
102 outb %al,$ACPI_PORT_SMI_CMD
108 mov $(ACPI_PM_BASE + PM1A_CNT_OFFSET),%dx
110 # not reached. The wakeup causes reset and restart at 0x7c00, and we
111 # do not save and restore registers as a real kernel would do.
114 # GDT magic from old (GPLv2) Grub startup.S
115 .p2align 2 /* force 4-byte alignment */
120 /* -- code segment --
121 * base = 0x00000000, limit = 0xFFFFF (4 KiB Granularity), present
122 * type = 32bit code execute/read, DPL = 0
125 .byte 0, 0x9A, 0xCF, 0
127 /* -- data segment --
128 * base = 0x00000000, limit 0xFFFFF (4 KiB Granularity), present
129 * type = 32 bit data read/write, DPL = 0
132 .byte 0, 0x92, 0xCF, 0
135 .word 0x27 /* limit */
138 /* test launcher can poke a 1 here to exercise suspend */
142 /* I'm a bootable disk */