OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [linux/] [swap.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
#ifndef _LINUX_SWAP_H
2
#define _LINUX_SWAP_H
3
 
4
#define SWAP_FLAG_PREFER        0x8000  /* set if swap priority specified */
5
#define SWAP_FLAG_PRIO_MASK     0x7fff
6
#define SWAP_FLAG_PRIO_SHIFT    0
7
 
8
#define MAX_SWAPFILES 8
9
 
10
#ifdef __KERNEL__
11
 
12
#include <asm/atomic.h>
13
 
14
#define SWP_USED        1
15
#define SWP_WRITEOK     3
16
 
17
#define SWAP_CLUSTER_MAX 32
18
 
19
#define SWAP_MAP_MAX      0xfffe        /* max val of swapinfo->swap_map[n] */
20
#define SWAP_MAP_RESERVED 0xffff        /* max val of swapinfo->swap_map[n] */
21
 
22
#ifndef NO_MM
23
struct swap_info_struct {
24
        unsigned int flags;
25
        kdev_t swap_device;
26
        struct inode * swap_file;
27
        unsigned short * swap_map;
28
        unsigned char * swap_lockmap;
29
        int lowest_bit;
30
        int highest_bit;
31
        int cluster_next;
32
        int cluster_nr;
33
        int prio;                       /* swap priority */
34
        int pages;
35
        unsigned long max;
36
        int next;                       /* next entry on swap list */
37
};
38
#endif /* !NO_MM */
39
 
40
extern int nr_swap_pages;
41
extern int nr_free_pages;
42
extern atomic_t nr_async_pages;
43
extern int min_free_pages;
44
extern int free_pages_low;
45
extern int free_pages_high;
46
 
47
/* Incomplete types for prototype declarations: */
48
struct task_struct;
49
struct vm_area_struct;
50
struct sysinfo;
51
 
52
/* linux/ipc/shm.c */
53
extern int shm_swap (int, int);
54
 
55
/* linux/mm/vmscan.c */
56
extern int try_to_free_page(int, int, int);
57
 
58
/* linux/mm/page_io.c */
59
extern void rw_swap_page(int, unsigned long, char *, int);
60
#define read_swap_page(nr,buf) \
61
        rw_swap_page(READ,(nr),(buf),1)
62
#define write_swap_page(nr,buf) \
63
        rw_swap_page(WRITE,(nr),(buf),1)
64
extern void swap_after_unlock_page (unsigned long entry);
65
 
66
/* linux/mm/page_alloc.c */
67
#ifndef NO_MM
68
extern void swap_in(struct task_struct *, struct vm_area_struct *,
69
                    pte_t *, unsigned long, int);
70
#endif /* !NO_MM */
71
 
72
/* linux/mm/swap_state.c */
73
extern void show_swap_cache_info(void);
74
extern int add_to_swap_cache(unsigned long, unsigned long);
75
extern unsigned long init_swap_cache(unsigned long, unsigned long);
76
extern void swap_duplicate(unsigned long);
77
 
78
/* linux/mm/swapfile.c */
79
void si_swapinfo(struct sysinfo *);
80
#ifndef NO_MM
81
extern int nr_swapfiles;
82
extern struct swap_info_struct swap_info[];
83
unsigned long get_swap_page(void);
84
extern void swap_free(unsigned long);
85
 
86
/*
87
 * vm_ops not present page codes for shared memory.
88
 *
89
 * Will go away eventually..
90
 */
91
#define SHM_SWP_TYPE 0x40
92
 
93
/*
94
 * swap cache stuff (in linux/mm/swap_state.c)
95
 */
96
 
97
#define SWAP_CACHE_INFO
98
 
99
extern unsigned long * swap_cache;
100
 
101
#ifdef SWAP_CACHE_INFO
102
extern unsigned long swap_cache_add_total;
103
extern unsigned long swap_cache_add_success;
104
extern unsigned long swap_cache_del_total;
105
extern unsigned long swap_cache_del_success;
106
extern unsigned long swap_cache_find_total;
107
extern unsigned long swap_cache_find_success;
108
#endif
109
 
110
extern inline unsigned long in_swap_cache(unsigned long index)
111
{
112
        return swap_cache[index];
113
}
114
 
115
extern inline long find_in_swap_cache(unsigned long index)
116
{
117
        unsigned long entry;
118
 
119
#ifdef SWAP_CACHE_INFO
120
        swap_cache_find_total++;
121
#endif
122
        entry = xchg(swap_cache + index, 0);
123
#ifdef SWAP_CACHE_INFO
124
        if (entry)
125
                swap_cache_find_success++;
126
#endif  
127
        return entry;
128
}
129
 
130
extern inline int delete_from_swap_cache(unsigned long index)
131
{
132
        unsigned long entry;
133
 
134
#ifdef SWAP_CACHE_INFO
135
        swap_cache_del_total++;
136
#endif  
137
        entry = xchg(swap_cache + index, 0);
138
        if (entry)  {
139
#ifdef SWAP_CACHE_INFO
140
                swap_cache_del_success++;
141
#endif
142
                swap_free(entry);
143
                return 1;
144
        }
145
        return 0;
146
}
147
 
148
#endif /* !NO_MM */
149
 
150
 
151
#endif /* __KERNEL__*/
152
 
153
#endif /* _LINUX_SWAP_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.