1 /******************************************************************************
2  * Copyright (c) 2004, 2008 IBM Corporation
main(void)3  * All rights reserved.
4  * This program and the accompanying materials
5  * are made available under the terms of the BSD License
6  * which accompanies this distribution, and is available at
7  * http://www.opensource.org/licenses/bsd-license.php
8  *
9  * Contributors:
10  *     IBM Corporation - initial implementation
11  *****************************************************************************/
12 
13 #include <stdint.h>
14 #include <rtas.h>
15 #include <of.h>
16 #include <pci.h>
17 #include <string.h>
18 #include <kernel.h>
19 #include <cpu.h>
20 #include <cache.h>
21 
22 unsigned int read_io(void *addr, size_t sz)
23 {
24 	unsigned int ret;
25 
26 	switch (sz) {
27 	case 1:
28 		ret = ci_read_8(addr);
29 		break;
30 	case 2:
31 		ret = ci_read_16(addr);
32 		break;
33 	case 4:
34 		ret = ci_read_32(addr);
35 		break;
36 	default:
37 		ret = 0;
38 	}
39 
40 	return ret;
41 }
42 
43 int write_io(void *addr, unsigned int value, size_t sz)
44 {
45 	switch (sz) {
46 	case 1:
47 		ci_write_8(addr, value);
48 		break;
49 	case 2:
50 		ci_write_16(addr, value);
51 		break;
52 	case 4:
53 		ci_write_32(addr, value);
54 		break;
55 	default:
56 		return -1;
57 	}
58 
59 	return 0;
60 }
61