SCO OpenServer
memget(D3oddi)
memget --
allocate contiguous memory at initialization
Synopsis
int memget(int pages);
Description
memget is used to obtain permanent,
contiguous, DMAable memory for the driver
at initialization time.
It is intended for memory that
the driver will always have and use
rather than for memory that will be used
and then released back into the kernel memory pool.
Arguments
pages-
memget( )
Amount of memory, measured in pages, to be allocated.
Use the
btoc(D3oddi)
macro to calculate the number of pages
from the number of bytes required.
Return values
If successful,
memget( )
returns the page frame number
of the first frame of memory allocated.
Note that this is for kernel virtual space.
Use the
ctob(D3oddi)
macro to translate
the return value of memget
into a kernel virtual address.
If
memget( )
cannot obtains suitable memory, it returns 0 (zero).
Usage
memget( )
always returns physically contiguous,
DMAable memory,
and should be used only when this is required.
If the driver only needs one page of memory,
use the
sptalloc(D3oddi)
function instead.
memget( )
never sleeps,
and may return having been unable
to allocate physically contiguous memory.
Context and synchronization
Initialization
context
Hardware applicability
All
Version applicability
oddi:
1, 2, 2mp, 3, 3mp, 4, 4mp, 5, 5mp, 6, 6mp
SVR5 DDI compatibility
This function is not supported for DDI drivers.
See
``Memory allocation'' in HDK Technical Reference
for a list of functions that can be used
to allocate memory in a DDI driver.
References
btoc(D3oddi),
ctob(D3oddi),
getcpages(D3oddi),
sptalloc(D3oddi)
``Memory allocation'' in HDK Technical Reference
Examples
To obtain a permanent 8KB buffer for a driver,
use code such as the following:
char my_buf_ptr;
paddr_t my_buf_phys_addr;
int my_buf_kvpfn;
my_buf_kvpfn = (memget(btoc(8192));
if (my_buf_kvpfn == 0) {
cmn_err(CE_NOTE, "My driver: memget() failed");
} else {
my_buf_ptr = (char )ctob(my_buf_kvpfn);
my_buf_phys_addr = ktop(my_buf_ptr);
}
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 5 HDK - June 2005