Skip to content

Commit bdcc0ba

Browse files
committed
nvmm: Port to DragonFly DragonFlyBSD#7: memory allocation
Add compat code to adapt NetBSD's kmem_alloc()/kmem_zalloc()/kmem_free().
1 parent ae77b4d commit bdcc0ba

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

sys/dev/virtual/nvmm/nvmm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ __KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.22.2.7 2020/08/29 17:00:28 martin Exp $")
5656
#include <dev/nvmm/nvmm_internal.h>
5757
#include <dev/nvmm/nvmm_ioctl.h>
5858

59+
MALLOC_DEFINE(M_NVMM, "nvmm", "NVMM data");
60+
5961
static struct nvmm_machine machines[NVMM_MAX_MACHINES];
6062
static volatile unsigned int nmachines __cacheline_aligned;
6163

sys/dev/virtual/nvmm/nvmm_compat.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <sys/param.h>
4545
#include <sys/bitops.h>
4646
#include <sys/lock.h>
47+
#include <sys/malloc.h>
4748
#include <sys/systm.h>
4849

4950
#include <machine/cpufunc.h>
@@ -262,4 +263,24 @@ typedef enum krw_t {
262263
#define rw_exit(lock) lockmgr(lock, LK_RELEASE)
263264
#define rw_write_held(lock) (lockstatus(lock, curthread) == LK_EXCLUSIVE)
264265

266+
/*
267+
* Memory allocation
268+
*/
269+
MALLOC_DECLARE(M_NVMM);
270+
enum {
271+
KM_SLEEP = M_WAITOK,
272+
KM_NOSLEEP = M_NOWAIT,
273+
};
274+
#define kmem_alloc(size, flags) \
275+
({ \
276+
KKASSERT((flags & ~(KM_SLEEP|KM_NOSLEEP)) == 0); \
277+
kmalloc(size, M_NVMM, flags); \
278+
})
279+
#define kmem_zalloc(size, flags) \
280+
({ \
281+
KKASSERT((flags & ~(KM_SLEEP|KM_NOSLEEP)) == 0); \
282+
kmalloc(size, M_NVMM, flags|M_ZERO); \
283+
})
284+
#define kmem_free(data, size) kfree(data, M_NVMM)
285+
265286
#endif /* _NVMM_COMPAT_H_ */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy