ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / ia64 / sn / kernel / probe.c
1 /*
2  * Platform dependent support for IO probing.
3  *
4  * This file is subject to the terms and conditions of the GNU General Public
5  * License.  See the file "COPYING" in the main directory of this archive
6  * for more details.
7  *
8  * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All rights reserved.
9  */
10
11 #include <asm/sn/sgi.h>
12 #include <asm/sn/sn_sal.h>
13
14 /**
15  * ia64_sn_probe_io_slot - test a memory location for readability
16  * @paddr: physical address to probe
17  * @size: number bytes to read (1,2,4,8)
18  * @data_ptr: address to store value read by probe (-1 returned if probe fails)
19  *
20  * This function will probe a physical address to determine if
21  * the address can be read. If reading the address causes a BUS
22  * error, an error is returned. If the probe succeeds, the contents 
23  * of the memory location is returned.
24  *
25  * Return values:
26  *  0 - probe successful
27  *  1 - probe failed (generated MCA)
28  *  2 - Bad arg
29  * <0 - PAL error
30  */
31 u64
32 ia64_sn_probe_io_slot(long paddr, long size, void *data_ptr)
33 {
34         struct ia64_sal_retval isrv;
35
36         SAL_CALL(isrv, SN_SAL_PROBE, paddr, size, 0, 0, 0, 0, 0);
37
38         if (data_ptr) {
39                 switch (size) {
40                         case 1:
41                                 *((u8*)data_ptr) = (u8)isrv.v0;
42                                 break;
43                         case 2:
44                                 *((u16*)data_ptr) = (u16)isrv.v0;
45                                 break;
46                         case 4:
47                                 *((u32*)data_ptr) = (u32)isrv.v0;
48                                 break;
49                         case 8:
50                                 *((u64*)data_ptr) = (u64)isrv.v0;
51                                 break;
52                         default:
53                                 isrv.status = 2;        
54                 }
55         }
56
57         return isrv.status;
58 }