kmem_alloc_physcontig(D3) kmem_alloc_physcontig(D3)
NAME
kmem_alloc_physcontig - allocate physically contiguous memory
SYNOPSIS
#include <sys/types.h>
#include <sys/kmem.h>
#include <sys/ddi.h>
void *kmem_alloc_physcontig(size_t size, physreq_t *preqp, int flag)
Arguments
size Number of bytes to allocate.
preqp Pointer to a physreq(D4) structure.
flag Specifies whether the caller is willing to sleep
waiting for memory.
DESCRIPTION
kmem_alloc_physcontig allocates size bytes of physically
contiguous kernel memory. If flag is set to KM_SLEEP, the
caller will sleep if necessary until the specified amount of
memory is available. If flag is set to KM_NOSLEEP, the caller
will not sleep, but kmem_alloc_physcontig will return NULL if
the specified amount of memory is not immediately available.
Return Values
Upon successful completion, kmem_alloc_physcontig returns a
pointer to the allocated memory.
USAGE
The size argument must be non-zero.
The preqp argument points to a physreq structure, previously
allocated by physreq_alloc(D3). This structure is used to
define physical address alignment requirements. The memory
returned by kmem_alloc_physcontig will be physically
contiguous even if the PREQ_PHYSCONTIG bit is not set.
Drivers should call kmem_alloc_physcontig as early as
possible, preferably during driver initialization. Due to
randomization of the free page list, physically contiguous
pages might not be available after the system has run at load
for some time. This could cause kmem_alloc_physcontig to
either fail (in the KM_NOSLEEP case) or possibly wait forever
(in the KM_SLEEP case).
Copyright 1994 Novell, Inc. Page 1
kmem_alloc_physcontig(D3) kmem_alloc_physcontig(D3)
This routine should not be called from driver strategy
routines [see strategy(D2)].
Beginning with UnixWare 2.0, drivers should use
kmem_alloc_physreq(D3) and kmem_free(D3) in preference to
kmem_alloc_physcontig(D3) and kmem_free_physcontig(D3),
respectively.
Level
Initialization or Base if flag is set to KM_SLEEP.
Initialization, Base or Interrupt if flag is set to
KM_NOSLEEP.
Synchronization Constraints
May sleep if flag is set to KM_SLEEP. If KM_SLEEP is used
during Initialization before the system is fully running and
no memory is available, kmem_alloc_physcontig may generate a
panic rather than futilely waiting forever.
Driver-defined basic locks and read/write locks may be held
across calls to this function if flag is KM_NOSLEEP, but may
not be held if flag is KM_SLEEP.
Driver-defined sleep locks may be held across calls to this
function regardless of the value of flag.
REFERENCES
kmem_alloc(D3), kmem_alloc_physreq(D3), kmem_free(D3),
kmem_free_physcontig(D3), kmem_zalloc(D3),
kmem_zalloc_physreq(D3), physreq(D4), physreq_alloc(D3),
strategy(D2)
NOTICES
Portability
All processors
Applicability
ddi: 5, 5mp, 6, 6mp
kmem_alloc_physreq(D3) replaces kmem_alloc_physcontig.
Copyright 1994 Novell, Inc. Page 2