File: /usr/src/linux/arch/ia64/sn/sn1/probe.c

1     /*
2      * Platform dependent support for IO probing.
3      *
4      * Copyright (C) 2000   Silicon Graphics
5      * Copyright (C) 2000   Jack Steiner (steiner@sgi.com)
6      */
7     
8     #include <asm/sn/sn_sal.h>
9     
10     /*
11      * ia64_sn_probe_io_slot
12      *	This function will probe a physical address to determine if
13      *	the address can be read. If reading the address causes a BUS
14      *	error, an error is returned. If the probe succeeds, the contents 
15      *	of the memory location is returned.
16      *
17      *   Calling sequence:
18      *		ia64_probe_io_slot(paddr, size, data_ptr)
19      *
20      *   Input:
21      *	paddr		Physical address to probe
22      *	size		Number bytes to read (1,2,4,8)
23      *	data_ptr	Address to store value read by probe
24      *		          (-1 returned if probe fails)
25      *
26      *   Output:
27      *	Status
28      *		 0 - probe successful
29      *		 1 - probe failed (generated MCA)
30      *		 2 - Bad arg
31      *		<0 - PAL error
32      */
33     
34     
35     u64
36     ia64_sn_probe_io_slot(long paddr, long size, void *data_ptr)
37     {
38     	struct ia64_sal_retval isrv;
39     
40     	SAL_CALL(isrv, SN_SAL_PROBE, paddr, size, 0, 0, 0, 0, 0);
41     
42     	if (data_ptr) {
43     		switch (size) {
44     			case 1:
45     				*((u8*)data_ptr) = (u8)isrv.v0;
46     				break;
47     			case 2:
48     				*((u16*)data_ptr) = (u16)isrv.v0;
49     				break;
50     			case 4:
51     				*((u32*)data_ptr) = (u32)isrv.v0;
52     				break;
53     			case 8:
54     				*((u64*)data_ptr) = (u64)isrv.v0;
55     				break;
56     			default:
57     				isrv.status = 2;	
58     		}
59     	}
60     
61     	return isrv.status;
62     }
63