xref: /openbmc/qemu/tests/migration/s390x/a-b-bios.c (revision c1774bdb)
1 /*
2  * S390 guest code used in migration tests
3  *
4  * Copyright 2018 Thomas Huth, Red Hat Inc.
5  *
6  * This code is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation; either version 2 of the License, or (at your
9  * option) any later version.
10  */
11 
12 #define LOADPARM_LEN 8  /* Needed for sclp.h */
13 
14 #include <libc.h>
15 #include <s390-ccw.h>
16 #include <sclp.h>
17 
18 char stack[0x8000] __attribute__((aligned(4096)));
19 
20 #define START_ADDRESS  (1024 * 1024)
21 #define END_ADDRESS    (100 * 1024 * 1024)
22 
23 void main(void)
24 {
25     unsigned long addr;
26 
27     sclp_setup();
28     sclp_print("A");
29 
30     /*
31      * Make sure all of the pages have consistent contents before incrementing
32      * the first byte below.
33      */
34     for (addr = START_ADDRESS; addr < END_ADDRESS; addr += 4096) {
35         *(volatile char *)addr = 0;
36     }
37 
38     while (1) {
39         for (addr = START_ADDRESS; addr < END_ADDRESS; addr += 4096) {
40             *(volatile char *)addr += 1;  /* Change pages */
41         }
42         sclp_print("B");
43     }
44 }
45