1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=4:tabstop=4:
4 * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Basic library routines of memory manipulation routines .
25 #ifndef __LIBCFS_WINNT_CFS_MEM_H__
26 #define __LIBCFS_WINNT_CFS_MEM_H__
28 #ifndef __LIBCFS_LIBCFS_H__
29 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
34 #define CFS_PAGE_SIZE PAGE_SIZE
35 #define CFS_PAGE_SHIFT PAGE_SHIFT
36 #define CFS_PAGE_MASK (~(PAGE_SIZE - 1))
38 typedef struct cfs_page {
44 cfs_page_t *cfs_alloc_page(int flags);
45 void cfs_free_page(cfs_page_t *pg);
47 static inline void *cfs_page_address(cfs_page_t *page)
52 static inline void *cfs_kmap(cfs_page_t *page)
57 static inline void cfs_kunmap(cfs_page_t *page)
62 static inline void cfs_get_page(cfs_page_t *page)
64 atomic_inc(&page->count);
67 static inline void cfs_put_page(cfs_page_t *page)
69 atomic_dec(&page->count);
72 static inline int cfs_page_count(cfs_page_t *page)
74 return atomic_read(&page->count);
81 #define CFS_ALLOC_ATOMIC_TRY (0)
83 extern void *cfs_alloc(size_t nr_bytes, u_int32_t flags);
84 extern void cfs_free(void *addr);
86 extern void *cfs_alloc_large(size_t nr_bytes);
87 extern void cfs_free_large(void *addr);
93 #define SLAB_HWCACHE_ALIGN 0
95 /* The cache name is limited to 20 chars */
97 typedef struct cfs_mem_cache {
101 NPAGED_LOOKASIDE_LIST npll;
106 extern cfs_mem_cache_t * cfs_mem_cache_create (const char *, size_t, size_t, ulong_ptr);
107 extern int cfs_mem_cache_destroy ( cfs_mem_cache_t * );
108 extern void *cfs_mem_cache_alloc ( cfs_mem_cache_t *, int);
109 extern void cfs_mem_cache_free ( cfs_mem_cache_t *, void *);
113 * Page allocator slabs
116 extern cfs_mem_cache_t *cfs_page_t_slab;
117 extern cfs_mem_cache_t *cfs_page_p_slab;
120 #define CFS_DECL_MMSPACE
121 #define CFS_MMSPACE_OPEN do {} while(0)
122 #define CFS_MMSPACE_CLOSE do {} while(0)
125 #define mb() do {} while(0)
133 #endif /* __WINNT_CFS_MEM_H__ */