本文整理汇总了C++中create_area函数的典型用法代码示例。如果您正苦于以下问题:C++ create_area函数的具体用法?C++ create_area怎么用?C++ create_area使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_area函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: create_area
StorageArea* Storage::create_area( ConfigElem& elem )
{
const char* rest = elem.rest();
if (rest && rest[0])
{
return create_area( rest );
}
else
{
string name = elem.remove_string( "NAME" );
return create_area( name );
}
}
开发者ID:alucardxlx,项目名称:polserver-zulu,代码行数:13,代码来源:storage.cpp
示例2: BWindowScreen
NWindowScreen::NWindowScreen(status_t *ret)
: BWindowScreen("Example", B_8_BIT_640x480, ret), width(639), height(479), COLORS(256)
{
PRINT(("WindowScreen ctor.\n"));
thread_is_locked = true;
tid = 0;
if(*ret == B_OK)
{
PRINT(("creating blocking sem and save_buffer area.\n"));
// this semaphore controls the access to the WindowScreen
sem = create_sem(0,"WindowScreen Access");
// this area is used to save the whole framebuffer when
// switching workspaces. (better than malloc()).
area = create_area("save", (void**)&save_buffer, B_ANY_ADDRESS, 640*480, B_NO_LOCK, B_READ_AREA|B_WRITE_AREA);
// exit if an error occured.
if((sem < B_OK) || (area < B_OK))
{
PRINT(("create_area() or create_sem() failed\n"));
*ret = B_ERROR;
}
else
{
PRINT(("calling Show().\n"));
Show(); // let's go. See you in ScreenConnected.
}
}
else
{
PRINT(("BWindowScreen base class ctor returned failure\n"));
be_app->PostMessage(B_QUIT_REQUESTED);
}
// set the frame rate
set_frame_rate(30.);
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:34,代码来源:particlesII.cpp
示例3: MM_AllocateSharedMemory
LM_STATUS
MM_AllocateSharedMemory(PLM_DEVICE_BLOCK pDevice, LM_UINT32 BlockSize,
PLM_VOID *pMemoryBlockVirt, PLM_PHYSICAL_ADDRESS pMemoryBlockPhy,
LM_BOOL cached /* we ignore this */)
{
struct be_b57_dev *dev;
void *pvirt = NULL;
area_id area_desc;
physical_entry entry;
dev = (struct be_b57_dev *)(pDevice);
area_desc = dev->lockmem_list[dev->lockmem_list_num++] = create_area("broadcom_shared_mem",
&pvirt, B_ANY_KERNEL_ADDRESS, ROUND_UP_TO_PAGE(BlockSize),
B_CONTIGUOUS, 0);
if (area_desc < B_OK)
return LM_STATUS_FAILURE;
memset(pvirt, 0, BlockSize);
*pMemoryBlockVirt = (PLM_VOID) pvirt;
get_memory_map(pvirt,BlockSize,&entry,1);
pMemoryBlockPhy->Low = (uint32)entry.address;
pMemoryBlockPhy->High = (uint32)(entry.address >> 32);
/* We only support 32 bit */
return LM_STATUS_SUCCESS;
}
开发者ID:luciang,项目名称:haiku,代码行数:28,代码来源:b57um.c
示例4: init_heap
static void init_heap( CacheHeap_s *psHeap )
{
char *pPtr;
uint32 nBufSize;
uint32 nMaxBufSize = g_sSysBase.ex_nTotalPageCount * PAGE_SIZE;
int nCnt = 0;
if ( nMaxBufSize > 1024 * 1024 * 128 )
{
nMaxBufSize = 1024 * 1024 * 128;
}
retry:
psHeap->ch_nSize = 4096 * 10;
psHeap->ch_nUsedBlocks = 0;
atomic_add( &g_sSysBase.ex_nBlockCacheSize, psHeap->ch_nSize );
psHeap->ch_hAreaID = create_area( "bcache_1024", &psHeap->ch_pAddress, psHeap->ch_nSize, nMaxBufSize, AREA_FULL_ACCESS | AREA_KERNEL, AREA_FULL_LOCK );
if ( psHeap->ch_hAreaID < 0 )
{
if ( psHeap->ch_hAreaID == -ENOADDRSPC && nMaxBufSize > psHeap->ch_nSize * 2 )
{
nMaxBufSize >>= 1;
goto retry;
}
panic( "init_heap() failed to create area for %d size blocks\n", psHeap->ch_nBlockSize );
}
开发者ID:rickcaudill,项目名称:Pyro,代码行数:27,代码来源:bcalloc.c
示例5: create_element
/**********************************************************************
create_element (ElementStruct element, int issueHour,
char *eleStr, char *errorStr)
This function takes information contained in the
element structure and creates the string indicating the element
type and calls create_area for each area of this type.
Input Parameters:
element ElementStruct
hour int issuance hour of gamet
Output Parameters:
elementString char string of type and information on each area
errorStr char concatenated string of errors occurred while
creating area string
Functions Called:
element_string
create_area
add_area_errors
**********************************************************************/
void create_element (ElementStruct element, int hour,
char *elementString, char *errors)
{
char aString[256];
char estr[64];
int j;
int retCode;
/* Initial check */
if (element.type >= MAX_ELEMENTS) {
if (strlen(errors) == (size_t)0) {
sprintf(estr, "Unexpected Element Type.");
strcpy (errors, estr);
}
else {
sprintf (estr, "; Unexpected Element Type.");
strcat(errors, estr);
}
/* encountered error, set type to no type */
element.type = no_element_type;
}
sprintf (elementString, "\n%s: ", element_string (element.type));
/* For each area in an element, create the string */
for (j = 0; j < element.numAreas; j++) {
aString[0] = '\0';
retCode = AREA_NO_ERROR;
create_area(element.area[j], hour, j, element.type, &retCode, aString);
/* check for errors */
if (retCode != AREA_NO_ERROR)
add_area_errors (retCode, element.type, j, errors);
/* put a period between areas */
if (j < element.numAreas - 1)
strcat(aString, ". ");
strcat (elementString, aString);
}
}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:54,代码来源:gamet.c
示例6: merge_areas
void merge_areas(object_t *merged, object_t *source) {
int i;
for (i = 0; i < source->areas->length; ++i) {
area_t *source_area = source->areas->items[i];
area_t *merged_area = get_area_by_name(merged, source_area->name);
if (merged_area == NULL) {
merged_area = create_area(source_area->name);
list_add(merged->areas, merged_area);
}
uint64_t new_address = merged_area->data_length;
relocate_area(source_area, new_address, true);
append_to_area(merged_area, source_area->data, source_area->data_length);
list_cat(merged_area->symbols, source_area->symbols);
list_cat(merged_area->late_immediates, source_area->late_immediates);
// NOTE: I know this is not very good SoC
metadata_t *new_functions = get_area_metadata(source_area, "scas.functions");
metadata_t *old_functions = get_area_metadata(merged_area, "scas.functions");
if (new_functions) {
list_t *decoded = decode_function_metadata(source_area, new_functions->value, new_functions->value_length);
list_t *merged;
if (old_functions) {
merged = decode_function_metadata(source_area, old_functions->value, old_functions->value_length);
} else {
merged = create_list();
}
list_cat(merged, decoded);
uint64_t len;
char *merged_metadata = encode_function_metadata(merged, &len);
set_area_metadata(merged_area, "scas.functions", merged_metadata, len);
}
list_cat(merged_area->source_map, source_area->source_map);
}
}
开发者ID:cacciatc,项目名称:scas,代码行数:34,代码来源:merge.c
示例7: scsi_alloc_dma_buffer_sg_orig
static bool
scsi_alloc_dma_buffer_sg_orig(dma_buffer *buffer, size_t size)
{
// free old list first
scsi_free_dma_buffer_sg_orig(buffer);
size = (size * sizeof(physical_entry) + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
buffer->sg_orig = create_area("S/G to original data",
(void **)&buffer->sg_list_orig,
B_ANY_KERNEL_ADDRESS, size,
B_NO_LOCK, 0);
if (buffer->sg_orig < 0) {
SHOW_ERROR(2, "Cannot S/G list buffer to original data of %" B_PRIuSIZE
" bytes", size);
return false;
}
buffer->sg_count_max_orig = size / sizeof(physical_entry);
SHOW_INFO(3, "Got up to %" B_PRIuSIZE " S/G entries to original data",
buffer->sg_count_max_orig);
return true;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:25,代码来源:dma_buffer.cpp
示例8: acpi_os_map_memory
void __iomem *
acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
{
area_id area;
unsigned long base = (unsigned long)phys;
void *addr = NULL;
unsigned long length = size;
if (!acpi_gbl_permanent_mmap)
return NULL;
area = create_area( "acpi_memory", &addr, PAGE_ALIGN( length ) + PAGE_SIZE, PAGE_ALIGN( length ) + PAGE_SIZE,
AREA_ANY_ADDRESS|AREA_KERNEL, AREA_FULL_LOCK );
if( area < 0 )
{
printk( "acpi_os_map_memory() could not create area with size 0x%x\n", (uint)size );
return NULL;
}
if( remap_area( area, (void*)( base & PAGE_MASK ) ) < 0 )
{
printk( "acpi_os_map_memory() could not remap area to 0x%x\n", (uint)phys );
return NULL;
}
//printk( "acpi_os_map_memory() remapped 0x%x to 0x%x size 0x%x\n", (uint)base, (uint)addr, (uint)length );
base = (unsigned long)addr + ( base - ( base & PAGE_MASK ) );
return (void*)base;
}
开发者ID:PyroOS,项目名称:Pyro,代码行数:32,代码来源:osl.c
示例9: time_faults
void time_faults()
{
const int FAULT_PAGES = 100;
char *addr;
int area = create_area("fault area", (void**) &addr, 0, FAULT_PAGES
* PAGE_SIZE, AREA_NOT_WIRED, USER_READ | USER_WRITE);
bigtime_t start = system_time();
char *c = addr;
for (int i = 0; i < FAULT_PAGES; i++) {
*c = 0;
c += PAGE_SIZE;
}
bigtime_t time1 = system_time() - start;
start = system_time();
c = addr;
for (int i = 0; i < FAULT_PAGES; i++) {
*c = 0;
c += PAGE_SIZE;
}
bigtime_t time2 = system_time() - start;
printf("\n%d pages. fault time %Ldus (%Ldus per fault) no fault time %Ldus (%Ldus per fault)\n",
FAULT_PAGES, time1, time1 / FAULT_PAGES, time2, time2 / FAULT_PAGES);
delete_area(area);
}
开发者ID:FFalcon,项目名称:jbushOS,代码行数:28,代码来源:test_vm.cpp
示例10: alloc_mem
area_id
alloc_mem(void **phy, void **log, size_t size, const char *name)
{
physical_entry pe;
void * logadr;
area_id areaid;
status_t rv;
TRACE("allocating %#08X bytes for %s\n", (int)size, name);
size = round_to_pagesize(size);
areaid = create_area(name, &logadr, B_ANY_KERNEL_ADDRESS, size,
B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA);
if (areaid < B_OK) {
TRACE("couldn't allocate area %s\n",name);
return B_ERROR;
}
rv = get_memory_map(logadr,size,&pe,1);
if (rv < B_OK) {
delete_area(areaid);
TRACE("couldn't map %s\n",name);
return B_ERROR;
}
memset(logadr,0,size);
if (log)
*log = logadr;
if (phy)
*phy = pe.address;
TRACE("area = %d, size = %#08X, log = %#08X, phy = %#08X\n", (int)areaid, (int)size, (int)logadr, (int)pe.address);
return areaid;
}
开发者ID:mmanley,项目名称:Antares,代码行数:31,代码来源:util.c
示例11: alloc_contiguous
area_id
alloc_contiguous(void **virt, void **phy, size_t size, uint32 protection,
const char *name)
{
physical_entry pe;
void * virtadr;
area_id areaid;
status_t rv;
TRACE("allocating %ld bytes for %s\n", size, name);
size = round_to_pagesize(size);
areaid = create_area(name, &virtadr, B_ANY_KERNEL_ADDRESS, size,
B_CONTIGUOUS, protection);
if (areaid < B_OK) {
ERROR("couldn't allocate area %s\n", name);
return B_ERROR;
}
rv = get_memory_map(virtadr, size, &pe, 1);
if (rv < B_OK) {
delete_area(areaid);
ERROR("couldn't get mapping for %s\n", name);
return B_ERROR;
}
memset(virtadr, 0, size);
if (virt)
*virt = virtadr;
if (phy)
*phy = pe.address;
TRACE("area = %ld, size = %ld, virt = %p, phy = %p\n", areaid, size, virtadr, pe.address);
return areaid;
}
开发者ID:mmanley,项目名称:Antares,代码行数:32,代码来源:util.c
示例12: alloc_mem
area_id
alloc_mem(void **virt, void **phy, size_t size, uint32 protection,
const char *name)
{
// TODO: phy should be phys_addr_t*!
physical_entry pe;
void * virtadr;
area_id areaid;
status_t rv;
TRACE("allocating %ld bytes for %s\n", size, name);
size = ROUNDUP(size, B_PAGE_SIZE);
areaid = create_area(name, &virtadr, B_ANY_KERNEL_ADDRESS, size,
B_32_BIT_CONTIGUOUS, protection);
// TODO: The rest of the code doesn't deal correctly with physical
// addresses > 4 GB, so we have to force 32 bit addresses here.
if (areaid < B_OK) {
TRACE("couldn't allocate area %s\n", name);
return B_ERROR;
}
rv = get_memory_map(virtadr, size, &pe, 1);
if (rv < B_OK) {
delete_area(areaid);
TRACE("couldn't map %s\n", name);
return B_ERROR;
}
if (virt)
*virt = virtadr;
if (phy)
*phy = (void*)(addr_t)pe.address;
TRACE("area = %ld, size = %ld, virt = %p, phy = %p\n", areaid, size, virtadr, pe.address);
return areaid;
}
开发者ID:luciang,项目名称:haiku,代码行数:34,代码来源:util.c
示例13: TRACE
area_id
Stack::AllocateArea(void **logicalAddress, void **physicalAddress, size_t size,
const char *name)
{
TRACE("allocating %ld bytes for %s\n", size, name);
void *logAddress;
size = (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
area_id area = create_area(name, &logAddress, B_ANY_KERNEL_ADDRESS, size,
B_CONTIGUOUS, 0);
if (area < B_OK) {
TRACE_ERROR("couldn't allocate area %s\n", name);
return B_ERROR;
}
physical_entry physicalEntry;
status_t result = get_memory_map(logAddress, size, &physicalEntry, 1);
if (result < B_OK) {
delete_area(area);
TRACE_ERROR("couldn't map area %s\n", name);
return B_ERROR;
}
memset(logAddress, 0, size);
if (logicalAddress)
*logicalAddress = logAddress;
if (physicalAddress)
*physicalAddress = physicalEntry.address;
TRACE("area = %ld, size = %ld, log = %p, phy = %p\n",
area, size, logAddress, physicalEntry.address);
return area;
}
开发者ID:mmanley,项目名称:Antares,代码行数:35,代码来源:Stack.cpp
示例14: create_mode_list
/*! Create a list of display_modes to pass back to the caller.
*/
status_t
create_mode_list(void)
{
size_t max_size;
uint32 i, j, pix_clk_range;
const display_mode *src;
display_mode *dst, low, high;
color_space spaces[4] = {B_RGB32_LITTLE, B_RGB16_LITTLE, B_RGB15_LITTLE, B_CMAP8};
/* figure out how big the list could be, and adjust up to nearest multiple of B_PAGE_SIZE */
max_size = (((MODE_COUNT * 4) * sizeof(display_mode)) + (B_PAGE_SIZE-1)) & ~(B_PAGE_SIZE-1);
/* create an area to hold the info */
si->mode_area = my_mode_list_area = create_area("NV accelerant mode info",
(void **)&my_mode_list, B_ANY_ADDRESS, max_size, B_NO_LOCK,
B_READ_AREA | B_WRITE_AREA);
if (my_mode_list_area < B_OK)
return my_mode_list_area;
/* walk through our predefined list and see which modes fit this device */
src = mode_list;
dst = my_mode_list;
si->mode_count = 0;
for (i = 0; i < MODE_COUNT; i++) {
/* set ranges for acceptable values */
low = high = *src;
/* range is 6.25% of default clock: arbitrarily picked */
pix_clk_range = low.timing.pixel_clock >> 5;
low.timing.pixel_clock -= pix_clk_range;
high.timing.pixel_clock += pix_clk_range;
/* 'some cards need wider virtual widths for certain modes':
* Not true. They might need a wider pitch, but this is _not_ reflected in
* virtual_width, but in fbc.bytes_per_row. */
//So disable next line:
//high.virtual_width = 4096;
/* do it once for each depth we want to support */
for (j = 0; j < (sizeof(spaces) / sizeof(color_space)); j++) {
/* set target values */
*dst = *src;
/* poke the specific space */
dst->space = low.space = high.space = spaces[j];
/* ask for a compatible mode */
/* We have to check for B_OK, because otherwise the pix_clk_range
* won't be taken into account!! */
//So don't do this:
//if (PROPOSE_DISPLAY_MODE(dst, &low, &high) != B_ERROR) {
//Instead, do this:
if (PROPOSE_DISPLAY_MODE(dst, &low, &high) == B_OK) {
/* count it, and move on to next mode */
dst++;
si->mode_count++;
}
}
/* advance to next mode */
src++;
}
return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:61,代码来源:ProposeDisplayMode.c
示例15: TORRENT_ASSERT
char* page_aligned_allocator::malloc(page_aligned_allocator::size_type bytes)
{
TORRENT_ASSERT(bytes > 0);
// just sanity check (this needs to be pretty high
// for cases where the cache size is several gigabytes)
TORRENT_ASSERT(bytes < 0x30000000);
TORRENT_ASSERT(int(bytes) >= page_size());
#ifdef TORRENT_DEBUG_BUFFERS
const int page = page_size();
const int num_pages = (bytes + (page-1)) / page + 2;
const int orig_bytes = bytes;
bytes = num_pages * page;
#endif
char* ret;
#if TORRENT_USE_POSIX_MEMALIGN
if (posix_memalign(reinterpret_cast<void**>(&ret), page_size(), bytes)
!= 0) ret = NULL;
#elif TORRENT_USE_MEMALIGN
ret = static_cast<char*>(memalign(page_size(), bytes));
#elif defined TORRENT_WINDOWS
ret = static_cast<char*>(_aligned_malloc(bytes, page_size()));
#elif defined TORRENT_BEOS
area_id id = create_area("", &ret, B_ANY_ADDRESS
, (bytes + page_size() - 1) & (page_size()-1), B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
if (id < B_OK) return NULL;
ret = static_cast<char*>(ret);
#else
ret = static_cast<char*>(valloc(size_t(bytes)));
#endif
if (ret == NULL) return NULL;
#ifdef TORRENT_DEBUG_BUFFERS
// make the two surrounding pages non-readable and -writable
alloc_header* h = (alloc_header*)ret;
h->size = orig_bytes;
h->magic = 0x1337;
print_backtrace(h->stack, sizeof(h->stack));
#ifdef TORRENT_WINDOWS
#define mprotect(buf, size, prot) VirtualProtect(buf, size, prot, NULL)
#define PROT_READ PAGE_READONLY
#endif
mprotect(ret, page, PROT_READ);
mprotect(ret + (num_pages-1) * page, page, PROT_READ);
#ifdef TORRENT_WINDOWS
#undef mprotect
#undef PROT_READ
#endif
// fprintf(stderr, "malloc: %p head: %p tail: %p size: %d\n", ret + page, ret, ret + page + bytes, int(bytes));
return ret + page;
#endif // TORRENT_DEBUG_BUFFERS
return ret;
}
开发者ID:randy-waterhouse,项目名称:libtorrent,代码行数:58,代码来源:allocator.cpp
示例16: contigmalloc
void *
contigmalloc(int size, int p1, int p2, int p3, int p4, int p5, int p6)
{
void *adr;
if (create_area("contigmalloc", &adr, B_ANY_KERNEL_ADDRESS, size,
B_CONTIGUOUS, 0) < B_OK)
return NULL;
return adr;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:9,代码来源:if_em_osdep.c
示例17: createGARTBuffer
static status_t createGARTBuffer( GART_info *gart, size_t size )
{
physical_entry map[1];
void *unaligned_addr, *aligned_phys;
SHOW_FLOW0( 3, "" );
gart->buffer.size = size = (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
// we allocate an contiguous area having twice the size
// to be able to find an aligned, contiguous range within it;
// the graphics card doesn't care, but the CPU cannot
// make an arbitrary area WC'ed, at least elder ones
// question: is this necessary for a PCI GART because of bus snooping?
gart->buffer.unaligned_area = create_area( "Radeon PCI GART buffer",
&unaligned_addr, B_ANY_KERNEL_ADDRESS,
2 * size, B_CONTIGUOUS/*B_FULL_LOCK*/, B_READ_AREA | B_WRITE_AREA | B_USER_CLONEABLE_AREA );
// TODO: Physical aligning can be done without waste using the
// private create_area_etc().
if (gart->buffer.unaligned_area < 0) {
SHOW_ERROR( 1, "cannot create PCI GART buffer (%s)",
strerror( gart->buffer.unaligned_area ));
return gart->buffer.unaligned_area;
}
get_memory_map( unaligned_addr, B_PAGE_SIZE, map, 1 );
aligned_phys =
(void **)((map[0].address + size - 1) & ~(size - 1));
SHOW_FLOW( 3, "aligned_phys=%p", aligned_phys );
gart->buffer.area = map_physical_memory( "Radeon aligned PCI GART buffer",
(addr_t)aligned_phys,
size, B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,
B_READ_AREA | B_WRITE_AREA, &gart->buffer.ptr );
if( gart->buffer.area < 0 ) {
SHOW_ERROR0( 3, "cannot map buffer with WC" );
gart->buffer.area = map_physical_memory( "Radeon aligned PCI GART buffer",
(addr_t)aligned_phys,
size, B_ANY_KERNEL_BLOCK_ADDRESS,
B_READ_AREA | B_WRITE_AREA, &gart->buffer.ptr );
}
if( gart->buffer.area < 0 ) {
SHOW_ERROR0( 1, "cannot map GART buffer" );
delete_area( gart->buffer.unaligned_area );
gart->buffer.unaligned_area = -1;
return gart->buffer.area;
}
memset( gart->buffer.ptr, 0, size );
return B_OK;
}
开发者ID:luciang,项目名称:haiku,代码行数:56,代码来源:PCI_GART.c
示例18: area_malloc
void *
area_malloc(size_t size)
{
void *p;
size = ROUNDUP(size, B_PAGE_SIZE);
if (create_area("area_malloc", &p, B_ANY_KERNEL_ADDRESS, size, B_FULL_LOCK, 0) < 0)
return 0;
return p;
}
开发者ID:mmanley,项目名称:Antares,代码行数:10,代码来源:util.c
示例19: test_gart
void
test_gart()
{
addr_t apertureBase;
aperture_id aperture = sGART->map_aperture(0, 0, 0, 0, &apertureBase);
printf("Map Aperture: %ld, base %lx\n", aperture, apertureBase);
aperture_info info;
sGART->get_aperture_info(aperture, &info);
printf("Aperture: base %lx, physical base %lx, size %ld, reserved %ld\n",
info.base, info.physical_base, info.size, info.reserved_size);
addr_t base[5], physical[5];
allocate(aperture, 2 * B_PAGE_SIZE, 0, 0, base[0], physical[0]);
allocate(aperture, 4 * B_PAGE_SIZE, 0, B_APERTURE_NON_RESERVED, base[1], physical[1]);
allocate(aperture, 1 * B_PAGE_SIZE, 0, B_APERTURE_NEED_PHYSICAL, base[2], physical[2]);
sGART->deallocate_memory(aperture, base[2]);
allocate(aperture, 1 * B_PAGE_SIZE, 4 * B_PAGE_SIZE, 0, base[2], physical[2]);
sGART->deallocate_memory(aperture, base[1]);
allocate(aperture, 5 * B_PAGE_SIZE, 0, 0, base[1], physical[1]);
sGART->deallocate_memory(aperture, base[2]);
sGART->deallocate_memory(aperture, base[0]);
if (sGART->deallocate_memory(aperture, 0x12345) == B_OK)
debugger("Non-allocated succeeded to be freed!\n");
void *buffer = memalign(3 * B_PAGE_SIZE, B_PAGE_SIZE);
status_t status = sGART->bind_aperture(aperture, -1, (addr_t)buffer,
3 * B_PAGE_SIZE, 0, false, 0, &base[3]);
if (status < B_OK)
printf("binding memory failed: %s\n", strerror(status));
allocate(aperture, 25 * B_PAGE_SIZE, 0, 0, base[0], physical[0]);
// will fail
allocate(aperture, 4 * B_PAGE_SIZE, 0, 0, base[0], physical[0]);
void *address;
area_id area = create_area("test", &address, B_ANY_ADDRESS, 2 * B_PAGE_SIZE,
B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
printf("Area %ld, address %p\n", area, address);
status = sGART->bind_aperture(aperture, area, 0, 0, 0, false, 0, &base[4]);
if (status < B_OK)
printf("binding area failed: %s\n", strerror(status));
sGART->unbind_aperture(aperture, base[3]);
sGART->unbind_aperture(aperture, base[4]);
// sGART->deallocate_memory(aperture, base[0]);
free(buffer);
delete_area(area);
sGART->unmap_aperture(aperture);
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:55,代码来源:gart_tester.cpp
示例20: main
int
main(int argc, char *argv[])
{
if (argc != 3) {
printf("%s [size (MB)] [count]\n", argv[0]);
return 0;
}
uint32 size = atoi(argv[1]) * MEGABYTE;
uint32 count = atoi(argv[2]);
printf("Creating and using memory that is %d MB, %d times...\n",
size / MEGABYTE, count);
int i = 0;
for (i = 0; i < count; i++) {
srand(time(NULL));
int32 random = (rand() % 16) + 1;
int32 randomBlock = (B_PAGE_SIZE * random) + random;
printf("Round %d: Creating.. ", i);
void* location = NULL;
#ifdef USE_AREA
area_id area = create_area("Test Memory", &location, B_ANY_ADDRESS, size,
B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
#else
location = (void*)malloc(size);
void* mallocLocation = location;
#endif
if (!location) {
printf("FAIL!\n");
continue;
}
printf("Created(%016p).. ", location);
printf("Exercising.. ");
addr_t pos = 0;
while (pos < size - randomBlock) {
uint32 data = randomBlock / random;
memset(location, data, randomBlock);
location += randomBlock;
pos += randomBlock;
}
printf("Erasing.. ");
#ifdef USE_AREA
delete_area(area);
#else
free(mallocLocation);
#endif
printf("OK!\n");
}
return 0;
}
开发者ID:kallisti5,项目名称:haikuStress,代码行数:55,代码来源:memeater.c
注:本文中的create_area函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论