int main(int argc, char *argv[]) { poolid_t mempool; void *ptrSrc, *ptrDest; coprocessor_request_block *ptrCrb; coprocessor_status_block *ptrCsb; int i, result, j, z, remaining; unsigned long long rndnumber = 0; Rngu rngfrc; init_cop_mempool(); mempool = create_cop_allocation_pool(30); /* 30 pages of 4k currently */ ptrCrb = malloc_from_pool(mempool, sizeof(coprocessor_request_block), 128); memset(ptrCrb, 0x0, sizeof(coprocessor_request_block)); ptrCrb->ccwu.value = 0; ptrCrb->ccwu.ccw.coprocessor_type = 0x01; /* shouldn't exist */ ptrCrb->ccwu.ccw.function_request_code = 0x00; ptrCrb->source_bytes = 0; ptrCrb->ptrSD = (unsigned long long)malloc_from_pool(mempool, 64, 64); ptrCrb->ptrTD = (unsigned long long)malloc_from_pool(mempool, 8, 64); ptrCrb->ptrCSB = (unsigned long long)malloc_from_pool(mempool, sizeof (coprocessor_status_block), 64); ptrCsb = (coprocessor_status_block *) ptrCrb->ptrCSB; memset(ptrCsb, 0x0, sizeof(coprocessor_status_block)); printf("about to dispatch\n"); ptrCsb->residual_byte_count = 0; result = dispatch_to_coprocessor(ptrCrb, ptrCrb->ccwu.value); if (result != 0) { printf("test returned RC = %d should return ??\n ", result); } free_to_pool((void *)ptrCrb->ptrSD); free_to_pool((void *)ptrCrb->ptrTD); free_to_pool((void *)ptrCrb->ptrCSB); release_allocation_pool(mempool); }
//從內存池 申請 object element_type * construct() { dark::thread::scoped_mutex_lock lock(_mutex); element_type * const ret = malloc_from_pool(); if (ret == 0) return ret; try { new (ret) element_type(); } catch (...) { free_to_pool(ret); throw; } return ret; }
element_type * construct(const T0 & a0,const T1 & a1,const T2 & a2,const T3 & a3,const T4 & a4,const T5 & a5,const T6 & a6,const T7 & a7,const T8 & a8,const T9 & a9) { dark::thread::scoped_mutex_lock lock(_mutex); element_type * const ret = malloc_from_pool(); if (ret == 0) return ret; try { new (ret) element_type(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9); } catch (...) { free_to_pool(ret); throw; } return ret; }
element_type * construct(const T0 & a0,const T1 & a1,const T2 & a2,const T3 & a3) { dark::thread::scoped_mutex_lock lock(_mutex); element_type * const ret = malloc_from_pool(); if (ret == 0) return ret; try { new (ret) element_type(a0,a1,a2,a3); } catch (...) { free_to_pool(ret); throw; } return ret; }