make oldconfig will rebuild these...
[linux-2.4.21-pre4.git] / include / asm-s390 / idals.h
1 /* 
2    * File...........: linux/include/asm-s390x/idals.h
3    * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4    * Bugreports.to..: <Linux390@de.ibm.com>
5    * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000a
6    
7    * History of changes
8    * 07/24/00 new file
9  */
10 #include <linux/config.h>
11 #include <asm/irq.h>
12
13 #define IDA_SIZE_LOG 11 /* 11 for 2k , 12 for 4k */
14 #define IDA_BLOCK_SIZE (1L<<IDA_SIZE_LOG)
15
16 static inline addr_t *
17 idal_alloc ( int nridaws )
18 {
19         if ( nridaws > 33 )
20                 BUG();
21         return kmalloc(nridaws * sizeof(addr_t), GFP_ATOMIC | GFP_DMA );
22 }
23
24 static inline void 
25 idal_free ( addr_t *idal )
26 {
27         kfree (idal);
28 }
29
30 #if defined(CONFIG_ARCH_S390X)
31 extern unsigned long __create_idal(unsigned long address, int count);
32 #endif
33
34 /*
35  * Function: set_normalized_cda
36  * sets the address of the data in CCW
37  * if necessary it allocates an IDAL and sets sthe appropriate flags
38  */
39 static inline int
40 set_normalized_cda(ccw1_t * ccw, unsigned long address)
41 {
42         int ret = 0;
43
44 #if defined (CONFIG_ARCH_S390X)
45         if (((address + ccw->count) >> 31) != 0) {
46                 if (ccw->flags & CCW_FLAG_IDA)
47                         BUG();
48                 address = __create_idal(address, ccw->count);
49                 if (address)
50                         ccw->flags |= CCW_FLAG_IDA;
51                 else
52                         ret = -ENOMEM;
53         }
54 #endif
55         ccw->cda = (__u32) address;
56         return ret;
57 }
58
59 /*
60  * Function: clear_normalized_cda
61  * releases any allocated IDAL related to the CCW
62  */
63 static inline void
64 clear_normalized_cda ( ccw1_t * ccw ) 
65 {
66 #if defined(CONFIG_ARCH_S390X)
67         if ( ccw -> flags & CCW_FLAG_IDA ) {
68                 idal_free ( (addr_t *)(unsigned long) (ccw -> cda ));
69                 ccw -> flags &= ~CCW_FLAG_IDA;
70         }
71 #endif
72         ccw -> cda = 0;
73 }
74