1 /* Copyright 2014-2016 IBM Corp.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *	http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*
18  * For now it just validates that addresses passed are sane and test the
19  * wrapper that validates addresses
20  */
21 
22 #include <config.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <assert.h>
26 #include <stdarg.h>
27 #include <compiler.h>
28 #include <opal-internal.h>
29 
30 #define __TEST__
31 unsigned long top_of_ram;	/* Fake it here */
main(void)32 int main(void)
33 {
34 	unsigned long addr = 0xd000000000000000;
35 
36 	top_of_ram = 16ULL * 1024 * 1024 * 1024; /* 16 GB */
37 	assert(opal_addr_valid((void *)addr) == false);
38 
39 	addr = 0xc000000000000000;
40 	assert(opal_addr_valid((void *)addr) == true);
41 
42 	addr = 0x0;
43 	assert(opal_addr_valid((void *)addr) == true);
44 
45 	addr = ~0;
46 	assert(opal_addr_valid((void *)addr) == false);
47 
48 	addr = top_of_ram + 1;
49 	assert(opal_addr_valid((void *)addr) == false);
50 	return 0;
51 }
52