implement kmem_zalloc.

This commit is contained in:
yamt 2006-06-25 08:10:04 +00:00
parent 23fcb7c3d3
commit 8308eb1f7a
2 changed files with 22 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_kmem.c,v 1.1 2006/06/25 08:00:01 yamt Exp $ */
/* $NetBSD: subr_kmem.c,v 1.2 2006/06/25 08:10:04 yamt Exp $ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.1 2006/06/25 08:00:01 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.2 2006/06/25 08:10:04 yamt Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@ -85,6 +85,24 @@ kmem_alloc(size_t size, km_flag_t kmflags)
kmf_to_vmf(kmflags) | VM_INSTANTFIT);
}
/*
* kmem_zalloc: allocate wired memory.
*
* => must not be called from interrupt context.
*/
void *
kmem_zalloc(size_t size, km_flag_t kmflags)
{
void *p;
p = kmem_alloc(size, kmflags);
if (p != NULL) {
memset(p, 0, size);
}
return p;
}
/*
* kmem_free: free wired memory allocated by kmem_alloc.
*

View File

@ -1,4 +1,4 @@
/* $NetBSD: kmem.h,v 1.1 2006/06/25 08:00:01 yamt Exp $ */
/* $NetBSD: kmem.h,v 1.2 2006/06/25 08:10:04 yamt Exp $ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
@ -34,6 +34,7 @@
typedef unsigned int km_flag_t;
void *kmem_alloc(size_t, km_flag_t);
void *kmem_zalloc(size_t, km_flag_t);
void kmem_free(void *, size_t);
void kmem_init(void);
size_t kmem_roundup_size(size_t);