Interval *search_interval(Interval *root, uint32_t start, uint32_t count) { Interval *current, *test; Interval i; i.low = start; i.high = start + count - 1; current = root; while (current && !check_overlap(current, &i)) { if (current->low > i.low) { current = current->left_child; } else { current = current->right_child; } } /* Make sure we really are returning the first (lowest) matching interval. */ if (current) { for (test = prev_interval(current); test != NULL && check_overlap(test, &i); test = prev_interval(test)) { /* We found a lower interval that also matches the search parameters. */ current = test; } } return current; }
void analyze_loop() { int i, j, k, l; std::vector<struct access_t> *current_loop_2; int full_loop_size = full_loop.size(); int current_loop_size; int current_loop_size_2; int vector_max_size = full_loop_size; printf("[Analysis] Loop size : %d\n",vector_max_size); for(i=1; i<full_loop_size; i++){ //all iterations in the loop except the first current_loop = full_loop[i]; current_loop_size = current_loop->size(); for(j=0; j<current_loop_size; j++){ //all access_t for the current loop iteration for(k=i-1; k>=0; k--){ //look for dependencies in previous iterations current_loop_2 = full_loop[k]; current_loop_size_2 = current_loop_2->size(); for(l=0; l<current_loop_size_2; l++){ //check all access_t in iteration k if((*current_loop)[j].type == WR){ //every previous acces can be a problem if(check_overlap((*current_loop)[j].start, (*current_loop)[j].end, (*current_loop_2)[l].start, (*current_loop_2)[l].end) ){ if(vector_max_size > (i-k)) vector_max_size = i-k; if(vector_max_size == 1) goto end; } } else if((*current_loop_2)[l].type == WR){ //check only for RAW dependencies if(check_overlap((*current_loop)[j].start, (*current_loop)[j].end, (*current_loop_2)[l].start, (*current_loop_2)[l].end) ){ if(vector_max_size > (i-k)) vector_max_size = i-k; if(vector_max_size == 1) goto end; } } } } } } end: printf("[Analysis] Possible Vector Size : %d\n",vector_max_size); if(vector_max_size == 1) printf("[Analysis] All iterations are dependant with each other\n"); if(vector_max_size == full_loop_size) printf("[Analysis] All iterations are independant from each other\n"); printf("\n"); clean_full_loop(); return; }
inline void subview_cube<eT>::operator/= (const subview_cube<eT>& x_in) { arma_extra_debug_sigprint(); const bool overlap = check_overlap(x_in); Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0; const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x_in.aux_col2, x_in.aux_slice2) : 0; const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in; subview_cube<eT>& t = *this; arma_debug_assert_same_size(t, x, "element-wise cube division"); const u32 t_n_rows = t.n_rows; const u32 t_n_cols = t.n_cols; const u32 t_n_slices = t.n_slices; for(u32 slice = 0; slice < t_n_slices; ++slice) { for(u32 col = 0; col < t_n_cols; ++col) { arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows ); } } if(overlap) { delete tmp_subview_cube; delete tmp_cube; } }
inline void subview_cube<eT>::operator/= (const subview_cube<eT>& x) { arma_extra_debug_sigprint(); if(check_overlap(x)) { const Cube<eT> tmp(x); (*this).operator/=(tmp); return; } subview_cube<eT>& t = *this; arma_debug_assert_same_size(t, x, "element-wise division"); const uword t_n_rows = t.n_rows; const uword t_n_cols = t.n_cols; const uword t_n_slices = t.n_slices; for(uword slice = 0; slice < t_n_slices; ++slice) { for(uword col = 0; col < t_n_cols; ++col) { arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows ); } } }
virtual bool no_overlap(particle_shape_type const& s, particle_id_type const& ignore1, particle_id_type const& ignore2) const { boost::scoped_ptr<particle_id_pair_and_distance_list> overlapped( check_overlap(s, ignore1, ignore2)); return (!overlapped || ::size(*overlapped) == 0); }
inline void subview_field<oT>::operator= (const subview_field<oT>& x_in) { arma_extra_debug_sigprint(); const bool overlap = check_overlap(x_in); field<oT>* tmp_field = overlap ? new field<oT>(x_in.f) : 0; const subview_field<oT>* tmp_subview = overlap ? new subview_field<oT>(*tmp_field, x_in.aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 0; const subview_field<oT>& x = overlap ? (*tmp_subview) : x_in; subview_field<oT>& t = *this; arma_debug_check( (t.n_rows != x.n_rows) || (t.n_cols != x.n_cols), "incompatible field dimensions"); for(u32 col=0; col<t.n_cols; ++col) { for(u32 row=0; row<t.n_rows; ++row) { t.at(row,col) = x.at(row,col); } } if(overlap) { delete tmp_subview; delete tmp_field; } }
int insert_interval(Interval **root, Interval *node) { Interval *current; if (*root == NULL) { *root = node; return INTERVAL_SUCCESS; } current = *root; while (1) { if (check_overlap(current, node)) { return INTERVAL_OVERLAP; } if (node->low < current->low) { if (current->left_child == NULL) { current->left_child = node; node->parent = current; break; } else { current = current->left_child; } } else { if (current->right_child == NULL) { current->right_child = node; node->parent = current; break; } else { current = current->right_child; } } } return INTERVAL_SUCCESS; }
virtual bool no_overlap(particle_shape_type const& s) const { boost::scoped_ptr<particle_id_pair_and_distance_list> overlapped( check_overlap(s)); // boost::scoped_ptr<particle_id_pair_and_distance_list> overlapped( // check_overlap<particle_shape_type>(s)); return (!overlapped || ::size(*overlapped) == 0); }
/*! * @brief ブロックを落下させる * * ブロックの重なりも検出する。 * @see check_overlap() */ static void drop_block(void) { if (!check_overlap(x, y + 1)) { /* 重なりがなければ移動 */ move_block(x, y + 1); } else { /* 重なりがあれば壁にする */ lock_block(); create_block(); show_field(field, MY_FIELD_X); } }
static int msm_pmem_table_add(struct hlist_head *ptype, struct msm_pmem_info *info) { struct file *file; unsigned long paddr; #ifdef CONFIG_ANDROID_PMEM unsigned long kvstart; int rc; #endif unsigned long len; struct msm_pmem_region *region; #ifdef CONFIG_ANDROID_PMEM rc = get_pmem_file(info->fd, &paddr, &kvstart, &len, &file); if (rc < 0) { pr_err("%s: get_pmem_file fd %d error %d\n", __func__, info->fd, rc); return rc; } if (!info->len) info->len = len; rc = check_pmem_info(info, len); if (rc < 0) return rc; #else paddr = 0; file = NULL; #endif paddr += info->offset; len = info->len; if (check_overlap(ptype, paddr, len) < 0) return -EINVAL; CDBG("%s: type %d, active flag %d, paddr 0x%lx, vaddr 0x%lx\n", __func__, info->type, info->active, paddr, (unsigned long)info->vaddr); region = kmalloc(sizeof(struct msm_pmem_region), GFP_KERNEL); if (!region) return -ENOMEM; INIT_HLIST_NODE(®ion->list); region->paddr = paddr; region->len = len; region->file = file; memcpy(®ion->info, info, sizeof(region->info)); D("%s Adding region to list with type %d\n", __func__, region->info.type); D("%s pmem_stats address is 0x%p\n", __func__, ptype); hlist_add_head(&(region->list), ptype); return 0; }
static int io_workqueue_fn(struct submit_worker *sw, struct workqueue_work *work) { struct io_u *io_u = container_of(work, struct io_u, work); const enum fio_ddir ddir = io_u->ddir; struct thread_data *td = sw->priv; int ret, error; if (td->o.serialize_overlap) check_overlap(io_u); dprint(FD_RATE, "io_u %p queued by %u\n", io_u, gettid()); io_u_set(td, io_u, IO_U_F_NO_FILE_PUT); td->cur_depth++; do { ret = td_io_queue(td, io_u); if (ret != FIO_Q_BUSY) break; ret = io_u_queued_complete(td, 1); if (ret > 0) td->cur_depth -= ret; else if (ret < 0) break; io_u_clear(td, io_u, IO_U_F_FLIGHT); } while (1); dprint(FD_RATE, "io_u %p ret %d by %u\n", io_u, ret, gettid()); error = io_queue_event(td, io_u, &ret, ddir, NULL, 0, NULL); if (ret == FIO_Q_COMPLETED) td->cur_depth--; else if (ret == FIO_Q_QUEUED) { unsigned int min_evts; if (td->o.iodepth == 1) min_evts = 1; else min_evts = 0; ret = io_u_queued_complete(td, min_evts); if (ret > 0) td->cur_depth -= ret; } if (error || td->error) pthread_cond_signal(&td->parent->free_cond); return 0; }
VIOAPI void change_ptr_alloc_check( void *old_ptr, void *new_ptr, size_t n_bytes, VIO_STR source_file, int line_number ) { VIO_STR orig_source; int orig_line; int sequence_number; skip_entry *entry; update_struct update_ptrs; if( alloc_checking_enabled() ) { check_initialized_alloc_list( &alloc_list ); if( n_bytes == 0 ) { print_source_location( source_file, line_number, -1 ); print_error( ": VIO_Realloc called with zero size.\n" ); abort_if_allowed(); } else if( !remove_ptr_from_alloc_list( &alloc_list, old_ptr, &orig_source, &orig_line, &sequence_number ) ) { print_source_location( source_file, line_number, -1 ); print_error( ": Tried to realloc a pointer not already alloced.\n"); abort_if_allowed(); } else { (void) find_pointer_position( &alloc_list, new_ptr, &update_ptrs ); if( check_overlap( &alloc_list, &update_ptrs, new_ptr, n_bytes, &entry ) ) { print_source_location( source_file, line_number, -1 ); print_error( ": VIO_Realloc returned a pointer overlapping an existing block:\n"); print_source_location( entry->source_file, entry->line_number, entry->sequence_number ); print_error( "\n" ); abort_if_allowed(); } else insert_ptr_in_alloc_list( &alloc_list, &update_ptrs, new_ptr, n_bytes, orig_source, orig_line, sequence_number ); } } }
/* * Process the legacy image - basically copy it into the required location if * necessary. Image compression is not (yet) supported. */ static int bootm_load_os(bootm_header_t *bootm_header_p) { image_info_t* pos = &bootm_header_p->os; /* Just to cache it. */ uint8_t comp = pos->comp; uint8_t *load_buf = (uint8_t *)pos->load; uint8_t *image_buf = (uint8_t *)pos->image_start; uint32_t image_len = pos->image_len; switch (comp) { case IH_COMP_NONE: pos->actual_size = image_len; if (load_buf == image_buf) break; /* No relocation needed. */ if (check_overlap(load_buf, load_buf + image_len, image_buf, image_buf + image_len) || check_overlap(load_buf, load_buf + image_len, &_start, &_end)) { printf("%s:%d - Overlap trying to relocate the kernel\n", __func__, __LINE__); return BOOTM_ERR_OVERLAP; } printf(" relocating legacy kernel to %p ... ", load_buf); memcpy(load_buf, image_buf, image_len); printf("done!\n"); break; default: printf("Usupported compression type %d\n", comp); return BOOTM_ERR_UNIMPLEMENTED; } printf("OK\n"); return 0; }
VIOAPI void record_ptr_alloc_check( void *ptr, size_t n_bytes, VIO_STR source_file, int line_number ) { update_struct update_ptrs; skip_entry *entry; if( alloc_checking_enabled() ) { check_initialized_alloc_list( &alloc_list ); if( n_bytes == 0 ) { print_source_location( source_file, line_number, -1 ); print_error( ": Alloc called with zero size.\n" ); abort_if_allowed(); } else if( ptr == (void *) 0 ) { print_source_location( source_file, line_number, -1 ); print_error( ": Alloc returned a NIL pointer.\n" ); abort_if_allowed(); } else { (void) find_pointer_position( &alloc_list, ptr, &update_ptrs ); if( check_overlap( &alloc_list, &update_ptrs, ptr, n_bytes, &entry)) { print_source_location( source_file, line_number, -1 ); print_error( ": Alloc returned a pointer overlapping an existing block:\n" ); print_source_location( entry->source_file, entry->line_number, entry->sequence_number ); print_error( "\n" ); abort_if_allowed(); } else insert_ptr_in_alloc_list( &alloc_list, &update_ptrs, ptr, n_bytes, source_file, line_number, get_current_sequence_number() ); } } }
/*! * @brief ブロックを回転させる * @return 回転できなかったとき1を、回転できたとき0を返す。 */ static uchar turn_block(turn_drct_e direction) { static uchar temp[BLOCK_HEIGHT][BLOCK_WIDTH]; /*ブロックを一時保存するための配列 */ uint i; for (i = 0; i < BLOCK_HEIGHT; i++) { uint j; for (j = 0; j < BLOCK_WIDTH; j++) { temp[i][j] = block[i][j]; } } /* ブロックを回転 */ if (direction == RIGHT) { /* 右回りに回転 */ for (i = 0; i < BLOCK_HEIGHT; i++) { uint j; for (j = 0; j < BLOCK_WIDTH; j++) { block[i][j] = temp[(BLOCK_WIDTH - 1) - j][i]; } } } else { /* 左回りに回転 */ for (i = 0; i < BLOCK_HEIGHT; i++) { uint j; for (j = 0; j < BLOCK_WIDTH; j++) { block[i][j] = temp[j][(BLOCK_WIDTH - 1) - i]; } } } /* 重なってるブロックが出てしまったらブロックを回転前に戻して中止 */ if (check_overlap(x, y)) { for (i = 0; i < BLOCK_HEIGHT; i++) { uint j; for (j = 0; j < BLOCK_WIDTH; j++) { block[i][j] = temp[i][j]; } } return FALSE; } /* 一旦フィールドからブロック消して回転後のブロックを再表示 */ for (i = 0; i < BLOCK_HEIGHT; i++) { uint j; for (j = 0; j < BLOCK_WIDTH; j++) { field[y + i][x + j] -= temp[i][j]; field[y + i][x + j] += block[i][j]; } } show_field(field, MY_FIELD_X); return TRUE; }
// calcArea // As is the case with most theorems for polygons, this formula // does not work for complex polygons (i.e., one with overlapping // lines). Currently this is expected behavior. Let's fix this - // either by disallowing complex polygons, forcing a brute force // area computation, or by adding in intersect points to make the // calculation work in all cases. double regCalcAreaPolygon( regShape* shape ) { // We brute force the area computation for complex polygons if (check_overlap(shape)) { return reg_calc_area_complex_polygon(shape); } double area = 0.0; long ii; // last point is already there // eqn is 0.5*sum( x_i*y+i_1 - x_i+1*y_i) for (ii=0;ii<(shape->nPoints -1);ii++) { area += ((shape->xpos[ii]*shape->ypos[ii+1]) - (shape->xpos[ii+1]*shape->ypos[ii]) ); } area /= 2.0; return fabs(area); }
/*! * @brief キー入力に応じてブロックを処理 * * キー操作により、ブロックの操作を行う * ブロックの移動方法はviエディタに似せた */ static void control_block(void) { switch (getch()) { /* ----- vi風 ----- */ case 'l': if (!check_overlap(x + 1, y)) { move_block(x + 1, y); } break; case 'h': if (!check_overlap(x - 1, y)) { move_block(x - 1, y); } break; case 'j': if (!check_overlap(x, y + 1)) { move_block(x, y + 1); } break; /* ----- Emacs風 ----- */ case CTRL_F: if (!check_overlap(x + 1, y)) { move_block(x + 1, y); } break; case CTRL_B: if (!check_overlap(x - 1, y)) { move_block(x - 1, y); } break; case CTRL_N: if (!check_overlap(x, y + 1)) { move_block(x, y + 1); } break; /* ----- ブロックの回転 ----- */ case 'a': turn_block(RIGHT); break; case 's': turn_block(LEFT); break; case ' ': turn_block(RIGHT); break; } }
inline void subview_cube<eT>::operator/= (const subview_cube<eT>& x_in) { arma_extra_debug_sigprint(); const bool overlap = check_overlap(x_in); Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0; const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x_in.aux_col2, x_in.aux_slice2) : 0; const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in; subview_cube<eT>& t = *this; arma_debug_assert_same_size(t, x, "element-wise cube division"); for(u32 slice = 0; slice < t.n_slices; ++slice) { for(u32 col = 0; col < t.n_cols; ++col) { eT* t_coldata = t.slice_colptr(slice,col); const eT* x_coldata = x.slice_colptr(slice,col); for(u32 row = 0; row < t.n_rows; ++row) { t_coldata[row] /= x_coldata[row]; } } } if(overlap) { delete tmp_subview_cube; delete tmp_cube; } }
vma_t *vma_alloc(vma_t *vma_head, uint64_t start, uint64_t length) { vma_t *vma_tmp = NULL; int overlap = 0; int found = 0; while (1) { overlap = 0; for (vma_tmp = vma_head; vma_tmp != vma_head; vma_tmp = vma_tmp->next) if (check_overlap(start, start+length, vma_tmp->vm_start, vma_tmp->vm_end)) { mm_db("Overlap at (%x, %x) (%x, %x)\n", start, start+length, vma_tmp->vm_start, vma_tmp->vm_end); overlap = 1; break; } if (overlap) { start += __PAGE_SIZE; if (start + length > USTACK_BOTTOM) break; continue; } found = 1; break; } if (!found) return NULL; vma_tmp = (vma_t *)get_object(objcache_vma_head); vma_tmp->vm_start = start; vma_tmp->vm_end = start + length; return vma_tmp; }
virtual particle_id_pair_and_distance_list* check_overlap(particle_shape_type const& s) const { return check_overlap(s, array_gen<particle_id_type>()); }
/* BIN * --- * Input parameters: * dataCol - the column with the channel data * numChans - number of channels in groupCol and qualCol * binLow - array of lower group boundaries * binHigh - array of higher group boundaries * numBins - number of binLow-binHigh group pairs * groupCol - the GROUPING column * qualCol - the QUALITY column * tabStops - array giving channels with tabs or stops */ int grp_do_bin(double *dataCol, long numChans, double *binLow, double *binHigh, long numBins, short *groupCol, short *qualCol, short *tabStops, dsErrList *errList, short partialBin, int isColReal){ long ii, jj, binLength, counter, tempLow, tempHigh, chanHigh; short isComplete; double maxVal, dataHigh; int tmpVar = 0; int isAscending = 0; /* Check for obviously bad inputs */ if(!dataCol || (numChans <= 0) || !binLow || !binHigh || (numBins < 0) || !groupCol || !qualCol || !tabStops){ if(errList) dsErrAdd(errList, dsDMGROUPBADPARAMERR, Accumulation, Generic); else err_msg("ERROR: At least one input parameter has an " "invalid value.\n"); return(GRP_ERROR); } /* Check for monotonically increasing or decreasing data */ if (check_increasing(dataCol, numChans) == 0) { isAscending = 1; } else { if ( check_decreasing(dataCol, numChans) != 0 ) { if(errList) dsErrAdd(errList, dsDMGROUPBADDATAORDERERR, Accumulation, Generic); else err_msg("ERROR: Data column is not increasing/decreasing.\n"); return(GRP_ERROR); } } if (isAscending) { dataHigh = dataCol[numChans - 1]; maxVal = binHigh[numBins - 1]; } else { dataHigh = dataCol[0]; maxVal = binLow[0]; } chanHigh = upper_bound(maxVal, dataCol, numChans, isAscending, isColReal, errList); /* Check if any bins overlap */ if(check_overlap(binLow, binHigh, numBins)){ if(errList) dsErrAdd(errList, dsDMGROUPOVERLAPBINSPECERR, Accumulation, Generic); else err_msg("ERROR: At least two bins in binspec overlap.\n"); return(GRP_ERROR); } /* Go through all binLow-binHigh pairs */ for(ii = 0; ii < numBins; ii++){ tempLow = lower_bound(binLow[ii], dataCol, numChans, isAscending, errList); tempHigh = upper_bound(binHigh[ii], dataCol, numChans, isAscending, isColReal, errList); if (!isAscending) { tmpVar = tempLow; tempLow = tempHigh; tempHigh = tmpVar; } if((tempLow == GRP_ERROR) || (tempHigh == GRP_ERROR)) continue; /* return(GRP_ERROR); */ /* If there are no data within the pair, skip to next pair */ if((tempHigh - tempLow) < 0) continue; binLength = tempHigh - tempLow; if(binLow[ii] > dataHigh){ if(errList) dsErrAdd(errList, dsDMGROUPINVALIDBINERR, Accumulation, Generic); else err_msg("ERROR: A bin boundary is invalid.\nMake " "sure the binspec fits within the bounds " "of the data.\n"); return(GRP_ERROR); } isComplete = GRP_TRUE; /* Check for a complete group */ for(jj = tempLow; jj <= tempHigh; jj++){ if ( (jj > chanHigh) || tabStops[jj] ) { isComplete = GRP_FALSE; break; } } /* If it's the last group, and partialBin is TRUE, then it's not complete. */ if( (partialBin && (ii == (numBins - 1))) || ((!isAscending) && (binLength < (numBins-1))) ) isComplete = GRP_FALSE; counter = 0; /* Create group - good or bad */ for(jj = tempLow; jj <= tempHigh; jj++){ /* Are we in a tab or stop? */ if(tabStops[jj]){ counter = 0; } /* Are we at the end of the table? */ else if(jj == (numChans - 1)){ /* Is this a single-element group? */ if(counter == 0){ if(isComplete){ groupCol[jj] = GRP_BEGIN; qualCol[jj] = GRP_GOOD; break; } else{ groupCol[jj] = GRP_BEGIN; qualCol[jj] = GRP_POOR; break; } } /* Does this complete the group? */ if(isComplete){ groupCol[jj] = GRP_MIDDLE; qualCol[jj] = GRP_GOOD; break; } else{ groupCol[jj] = GRP_MIDDLE; qualCol[jj] = GRP_POOR; break; } } /* Are we at the beginning of a group? */ else if(counter == 0){ if(isComplete){ groupCol[jj] = GRP_BEGIN; qualCol[jj] = GRP_GOOD; counter++; } else{ groupCol[jj] = GRP_BEGIN; qualCol[jj] = GRP_POOR; counter++; } } /* We must be in the middle of a group */ else{ if(isComplete){ groupCol[jj] = GRP_MIDDLE; qualCol[jj] = GRP_GOOD; counter++; } else{ groupCol[jj] = GRP_MIDDLE; qualCol[jj] = GRP_POOR; counter++; } } } /* end for(jj) */ } /* end for(ii) */ return(GRP_SUCCESS); }
static int msm_pmem_table_add(struct hlist_head *ptype, struct msm_pmem_info *info, struct ion_client *client, int domain_num) { unsigned long paddr; #ifndef CONFIG_MSM_MULTIMEDIA_USE_ION unsigned long kvstart; struct file *file; #endif int rc = -ENOMEM; unsigned long len; struct msm_pmem_region *region; region = kmalloc(sizeof(struct msm_pmem_region), GFP_KERNEL); if (!region) goto out; #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION region->handle = ion_import_dma_buf(client, info->fd); if (IS_ERR_OR_NULL(region->handle)) goto out1; if (ion_map_iommu(client, region->handle, domain_num, 0, SZ_4K, 0, &paddr, &len, 0, 0) < 0) goto out2; // pr_err("%s: IOMMU mapped address is 0x%x\n", __func__, (unsigned int)paddr); // #else paddr = 0; file = NULL; kvstart = 0; #endif if (!info->len) info->len = len; paddr += info->offset; len = info->len; if (check_overlap(ptype, paddr, len) < 0) { rc = -EINVAL; goto out3; } CDBG("%s: type %d, active flag %d, paddr 0x%lx, vaddr 0x%lx\n", __func__, info->type, info->active, paddr, (unsigned long)info->vaddr); INIT_HLIST_NODE(®ion->list); region->paddr = paddr; region->len = len; memcpy(®ion->info, info, sizeof(region->info)); D("%s Adding region to list with type %d\n", __func__, region->info.type); D("%s pmem_stats address is 0x%p\n", __func__, ptype); hlist_add_head(&(region->list), ptype); return 0; out3: #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION ion_unmap_iommu(client, region->handle, domain_num, 0); #endif #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION out2: ion_free(client, region->handle); #endif out1: kfree(region); out: return rc; }
void mail_params_init() { static const CONFIG_STR_TABLE first_str_defaults[] = { VAR_SYSLOG_FACILITY, DEF_SYSLOG_FACILITY, &var_syslog_facility, 1, 0, VAR_INET_PROTOCOLS, DEF_INET_PROTOCOLS, &var_inet_protocols, 0, 0, VAR_MULTI_CONF_DIRS, DEF_MULTI_CONF_DIRS, &var_multi_conf_dirs, 0, 0, /* multi_instance_wrapper may have dependencies but not dependents. */ VAR_MULTI_GROUP, DEF_MULTI_GROUP, &var_multi_group, 0, 0, VAR_MULTI_NAME, DEF_MULTI_NAME, &var_multi_name, 0, 0, 0, }; static const CONFIG_BOOL_TABLE first_bool_defaults[] = { /* read and process the following before opening tables. */ VAR_DAEMON_OPEN_FATAL, DEF_DAEMON_OPEN_FATAL, &var_daemon_open_fatal, 0, }; static const CONFIG_STR_FN_TABLE function_str_defaults[] = { VAR_MYHOSTNAME, check_myhostname, &var_myhostname, 1, 0, VAR_MYDOMAIN, check_mydomainname, &var_mydomain, 1, 0, 0, }; static const CONFIG_STR_TABLE other_str_defaults[] = { VAR_MAIL_NAME, DEF_MAIL_NAME, &var_mail_name, 1, 0, VAR_SYSLOG_NAME, DEF_SYSLOG_NAME, &var_syslog_name, 1, 0, VAR_MAIL_OWNER, DEF_MAIL_OWNER, &var_mail_owner, 1, 0, VAR_SGID_GROUP, DEF_SGID_GROUP, &var_sgid_group, 1, 0, VAR_MYDEST, DEF_MYDEST, &var_mydest, 0, 0, VAR_MYORIGIN, DEF_MYORIGIN, &var_myorigin, 1, 0, VAR_RELAYHOST, DEF_RELAYHOST, &var_relayhost, 0, 0, VAR_DAEMON_DIR, DEF_DAEMON_DIR, &var_daemon_dir, 1, 0, VAR_DATA_DIR, DEF_DATA_DIR, &var_data_dir, 1, 0, VAR_COMMAND_DIR, DEF_COMMAND_DIR, &var_command_dir, 1, 0, VAR_QUEUE_DIR, DEF_QUEUE_DIR, &var_queue_dir, 1, 0, VAR_PID_DIR, DEF_PID_DIR, &var_pid_dir, 1, 0, VAR_INET_INTERFACES, DEF_INET_INTERFACES, &var_inet_interfaces, 0, 0, VAR_PROXY_INTERFACES, DEF_PROXY_INTERFACES, &var_proxy_interfaces, 0, 0, VAR_DOUBLE_BOUNCE, DEF_DOUBLE_BOUNCE, &var_double_bounce_sender, 1, 0, VAR_DEFAULT_PRIVS, DEF_DEFAULT_PRIVS, &var_default_privs, 1, 0, VAR_ALIAS_DB_MAP, DEF_ALIAS_DB_MAP, &var_alias_db_map, 0, 0, VAR_MAIL_RELEASE, DEF_MAIL_RELEASE, &var_mail_release, 1, 0, VAR_MAIL_VERSION, DEF_MAIL_VERSION, &var_mail_version, 1, 0, VAR_DB_TYPE, DEF_DB_TYPE, &var_db_type, 1, 0, VAR_HASH_QUEUE_NAMES, DEF_HASH_QUEUE_NAMES, &var_hash_queue_names, 1, 0, VAR_RCPT_DELIM, DEF_RCPT_DELIM, &var_rcpt_delim, 0, 0, VAR_RELAY_DOMAINS, DEF_RELAY_DOMAINS, &var_relay_domains, 0, 0, VAR_FFLUSH_DOMAINS, DEF_FFLUSH_DOMAINS, &var_fflush_domains, 0, 0, VAR_EXPORT_ENVIRON, DEF_EXPORT_ENVIRON, &var_export_environ, 0, 0, VAR_IMPORT_ENVIRON, DEF_IMPORT_ENVIRON, &var_import_environ, 0, 0, VAR_MYNETWORKS_STYLE, DEF_MYNETWORKS_STYLE, &var_mynetworks_style, 1, 0, VAR_DEBUG_PEER_LIST, DEF_DEBUG_PEER_LIST, &var_debug_peer_list, 0, 0, VAR_VERP_DELIMS, DEF_VERP_DELIMS, &var_verp_delims, 2, 2, VAR_VERP_FILTER, DEF_VERP_FILTER, &var_verp_filter, 1, 0, VAR_PAR_DOM_MATCH, DEF_PAR_DOM_MATCH, &var_par_dom_match, 0, 0, VAR_CONFIG_DIRS, DEF_CONFIG_DIRS, &var_config_dirs, 0, 0, VAR_BOUNCE_SERVICE, DEF_BOUNCE_SERVICE, &var_bounce_service, 1, 0, VAR_CLEANUP_SERVICE, DEF_CLEANUP_SERVICE, &var_cleanup_service, 1, 0, VAR_DEFER_SERVICE, DEF_DEFER_SERVICE, &var_defer_service, 1, 0, VAR_PICKUP_SERVICE, DEF_PICKUP_SERVICE, &var_pickup_service, 1, 0, VAR_QUEUE_SERVICE, DEF_QUEUE_SERVICE, &var_queue_service, 1, 0, VAR_REWRITE_SERVICE, DEF_REWRITE_SERVICE, &var_rewrite_service, 1, 0, VAR_SHOWQ_SERVICE, DEF_SHOWQ_SERVICE, &var_showq_service, 1, 0, VAR_ERROR_SERVICE, DEF_ERROR_SERVICE, &var_error_service, 1, 0, VAR_FLUSH_SERVICE, DEF_FLUSH_SERVICE, &var_flush_service, 1, 0, VAR_VERIFY_SERVICE, DEF_VERIFY_SERVICE, &var_verify_service, 1, 0, VAR_TRACE_SERVICE, DEF_TRACE_SERVICE, &var_trace_service, 1, 0, VAR_PROXYMAP_SERVICE, DEF_PROXYMAP_SERVICE, &var_proxymap_service, 1, 0, VAR_PROXYWRITE_SERVICE, DEF_PROXYWRITE_SERVICE, &var_proxywrite_service, 1, 0, VAR_INT_FILT_CLASSES, DEF_INT_FILT_CLASSES, &var_int_filt_classes, 0, 0, /* multi_instance_wrapper may have dependencies but not dependents. */ VAR_MULTI_WRAPPER, DEF_MULTI_WRAPPER, &var_multi_wrapper, 0, 0, 0, }; static const CONFIG_STR_FN_TABLE function_str_defaults_2[] = { VAR_MYNETWORKS, mynetworks, &var_mynetworks, 0, 0, 0, }; static const CONFIG_INT_TABLE other_int_defaults[] = { VAR_PROC_LIMIT, DEF_PROC_LIMIT, &var_proc_limit, 1, 0, VAR_MAX_USE, DEF_MAX_USE, &var_use_limit, 1, 0, VAR_DONT_REMOVE, DEF_DONT_REMOVE, &var_dont_remove, 0, 0, VAR_LINE_LIMIT, DEF_LINE_LIMIT, &var_line_limit, 512, 0, VAR_HASH_QUEUE_DEPTH, DEF_HASH_QUEUE_DEPTH, &var_hash_queue_depth, 1, 0, VAR_FORK_TRIES, DEF_FORK_TRIES, &var_fork_tries, 1, 0, VAR_FLOCK_TRIES, DEF_FLOCK_TRIES, &var_flock_tries, 1, 0, VAR_DEBUG_PEER_LEVEL, DEF_DEBUG_PEER_LEVEL, &var_debug_peer_level, 1, 0, VAR_FAULT_INJ_CODE, DEF_FAULT_INJ_CODE, &var_fault_inj_code, 0, 0, VAR_DB_CREATE_BUF, DEF_DB_CREATE_BUF, &var_db_create_buf, 1, 0, VAR_DB_READ_BUF, DEF_DB_READ_BUF, &var_db_read_buf, 1, 0, VAR_HEADER_LIMIT, DEF_HEADER_LIMIT, &var_header_limit, 1, 0, VAR_TOKEN_LIMIT, DEF_TOKEN_LIMIT, &var_token_limit, 1, 0, VAR_MIME_MAXDEPTH, DEF_MIME_MAXDEPTH, &var_mime_maxdepth, 1, 0, VAR_MIME_BOUND_LEN, DEF_MIME_BOUND_LEN, &var_mime_bound_len, 1, 0, VAR_DELAY_MAX_RES, DEF_DELAY_MAX_RES, &var_delay_max_res, MIN_DELAY_MAX_RES, MAX_DELAY_MAX_RES, VAR_INET_WINDOW, DEF_INET_WINDOW, &var_inet_windowsize, 0, 0, 0, }; static const CONFIG_LONG_TABLE long_defaults[] = { VAR_MESSAGE_LIMIT, DEF_MESSAGE_LIMIT, &var_message_limit, 0, 0, VAR_LMDB_MAP_SIZE, DEF_LMDB_MAP_SIZE, &var_lmdb_map_size, 1, 0, 0, }; static const CONFIG_TIME_TABLE time_defaults[] = { VAR_EVENT_DRAIN, DEF_EVENT_DRAIN, &var_event_drain, 1, 0, VAR_MAX_IDLE, DEF_MAX_IDLE, &var_idle_limit, 1, 0, VAR_IPC_TIMEOUT, DEF_IPC_TIMEOUT, &var_ipc_timeout, 1, 0, VAR_IPC_IDLE, DEF_IPC_IDLE, &var_ipc_idle_limit, 1, 0, VAR_IPC_TTL, DEF_IPC_TTL, &var_ipc_ttl_limit, 1, 0, VAR_TRIGGER_TIMEOUT, DEF_TRIGGER_TIMEOUT, &var_trigger_timeout, 1, 0, VAR_FORK_DELAY, DEF_FORK_DELAY, &var_fork_delay, 1, 0, VAR_FLOCK_DELAY, DEF_FLOCK_DELAY, &var_flock_delay, 1, 0, VAR_FLOCK_STALE, DEF_FLOCK_STALE, &var_flock_stale, 1, 0, VAR_DAEMON_TIMEOUT, DEF_DAEMON_TIMEOUT, &var_daemon_timeout, 1, 0, VAR_IN_FLOW_DELAY, DEF_IN_FLOW_DELAY, &var_in_flow_delay, 0, 10, 0, }; static const CONFIG_BOOL_TABLE bool_defaults[] = { VAR_DISABLE_DNS, DEF_DISABLE_DNS, &var_disable_dns, VAR_SOFT_BOUNCE, DEF_SOFT_BOUNCE, &var_soft_bounce, VAR_OWNREQ_SPECIAL, DEF_OWNREQ_SPECIAL, &var_ownreq_special, VAR_STRICT_8BITMIME, DEF_STRICT_8BITMIME, &var_strict_8bitmime, VAR_STRICT_7BIT_HDRS, DEF_STRICT_7BIT_HDRS, &var_strict_7bit_hdrs, VAR_STRICT_8BIT_BODY, DEF_STRICT_8BIT_BODY, &var_strict_8bit_body, VAR_STRICT_ENCODING, DEF_STRICT_ENCODING, &var_strict_encoding, VAR_DISABLE_MIME_INPUT, DEF_DISABLE_MIME_INPUT, &var_disable_mime_input, VAR_DISABLE_MIME_OCONV, DEF_DISABLE_MIME_OCONV, &var_disable_mime_oconv, VAR_VERIFY_NEG_CACHE, DEF_VERIFY_NEG_CACHE, &var_verify_neg_cache, VAR_OLDLOG_COMPAT, DEF_OLDLOG_COMPAT, &var_oldlog_compat, VAR_HELPFUL_WARNINGS, DEF_HELPFUL_WARNINGS, &var_helpful_warnings, VAR_CYRUS_SASL_AUTHZID, DEF_CYRUS_SASL_AUTHZID, &var_cyrus_sasl_authzid, VAR_MULTI_ENABLE, DEF_MULTI_ENABLE, &var_multi_enable, VAR_LONG_QUEUE_IDS, DEF_LONG_QUEUE_IDS, &var_long_queue_ids, 0, }; const char *cp; INET_PROTO_INFO *proto_info; /* * Extract syslog_facility early, so that from here on all errors are * logged with the proper facility. */ get_mail_conf_str_table(first_str_defaults); if (!msg_syslog_facility(var_syslog_facility)) msg_fatal("file %s/%s: parameter %s: unrecognized value: %s", var_config_dir, MAIN_CONF_FILE, VAR_SYSLOG_FACILITY, var_syslog_facility); /* * Should daemons terminate after table open error, or should they * continue execution with reduced functionality? */ get_mail_conf_bool_table(first_bool_defaults); if (var_daemon_open_fatal) dict_allow_surrogate = 0; /* * What protocols should we attempt to support? The result is stored in * the global inet_proto_table variable. */ proto_info = inet_proto_init(VAR_INET_PROTOCOLS, var_inet_protocols); /* * Variables whose defaults are determined at runtime. Some sites use * short hostnames in the host table; some sites name their system after * the domain. */ get_mail_conf_str_fn_table(function_str_defaults); if (!valid_hostname(var_myhostname, DO_GRIPE)) msg_fatal("file %s/%s: parameter %s: bad parameter value: %s", var_config_dir, MAIN_CONF_FILE, VAR_MYHOSTNAME, var_myhostname); if (!valid_hostname(var_mydomain, DO_GRIPE)) msg_fatal("file %s/%s: parameter %s: bad parameter value: %s", var_config_dir, MAIN_CONF_FILE, VAR_MYDOMAIN, var_mydomain); /* * Variables that are needed by almost every program. * * XXX Reading the myorigin value from file is originally a Debian Linux * feature. This code is not enabled by default because of problems: 1) * it re-implements its own parameter syntax checks, and 2) it does not * implement $name expansions. */ get_mail_conf_str_table(other_str_defaults); #ifdef MYORIGIN_FROM_FILE if (*var_myorigin == '/') { char *origin = read_param_from_file(var_myorigin); if (*origin == 0) msg_fatal("%s file %s is empty", VAR_MYORIGIN, var_myorigin); myfree(var_myorigin); /* FIX 20070501 */ var_myorigin = origin; } #endif get_mail_conf_int_table(other_int_defaults); get_mail_conf_long_table(long_defaults); get_mail_conf_bool_table(bool_defaults); get_mail_conf_time_table(time_defaults); check_default_privs(); check_mail_owner(); check_sgid_group(); check_overlap(); #ifdef HAS_DB dict_db_cache_size = var_db_read_buf; #endif #ifdef HAS_LMDB dict_lmdb_map_size = var_lmdb_map_size; #endif inet_windowsize = var_inet_windowsize; /* * Variables whose defaults are determined at runtime, after other * variables have been set. This dependency is admittedly a bit tricky. * XXX Perhaps we should just register variables, and let the evaluator * figure out in what order to evaluate things. */ get_mail_conf_str_fn_table(function_str_defaults_2); /* * FIX 200412 The IPv6 patch did not call own_inet_addr_list() before * entering the chroot jail on Linux IPv6 systems. Linux has the IPv6 * interface list in /proc, which is not available after chrooting. */ (void) own_inet_addr_list(); /* * The PID variable cannot be set from the configuration file!! */ set_mail_conf_int(VAR_PID, var_pid = getpid()); /* * Neither can the start time variable. It isn't even visible. */ time(&var_starttime); /* * Export the syslog name so children can inherit and use it before they * have initialized. */ if ((cp = safe_getenv(CONF_ENV_LOGTAG)) == 0 || strcmp(cp, var_syslog_name) != 0) if (setenv(CONF_ENV_LOGTAG, var_syslog_name, 1) < 0) msg_fatal("setenv %s %s: %m", CONF_ENV_LOGTAG, var_syslog_name); /* * I have seen this happen just too often. */ if (strcasecmp(var_myhostname, var_relayhost) == 0) msg_fatal("%s and %s parameter settings must not be identical: %s", VAR_MYHOSTNAME, VAR_RELAYHOST, var_myhostname); /* * XXX These should be caught by a proper parameter parsing algorithm. */ if (var_myorigin[strcspn(var_myorigin, ", \t\r\n")]) msg_fatal("%s parameter setting must not contain multiple values: %s", VAR_MYORIGIN, var_myorigin); if (var_relayhost[strcspn(var_relayhost, ", \t\r\n")]) msg_fatal("%s parameter setting must not contain multiple values: %s", VAR_RELAYHOST, var_relayhost); /* * One more sanity check. */ if ((cp = verp_delims_verify(var_verp_delims)) != 0) msg_fatal("file %s/%s: parameters %s and %s: %s", var_config_dir, MAIN_CONF_FILE, VAR_VERP_DELIMS, VAR_VERP_FILTER, cp); }
virtual particle_id_pair_and_distance_list* check_overlap(particle_shape_type const& s, particle_id_type const& ignore1, particle_id_type const& ignore2) const { return check_overlap(s, array_gen(ignore1, ignore2)); }
/* evolve position of particles by semi-implicit predictor-corrector * INPUT * t : current time * BDimp : struct BD_imp * x[nm*3] : positions of particles at t = t0 * q[nm*4] : quaternions of particles at t = t0 (only for FT and FTS) * if NULL is given, just ignored. * dt : time step (scaled by a/U) * OUTPUT * x[nm*3] : updated positions of particles at t = t0 + dt * q[nm*4] : quaternions of particles at t = t0 + dt * (only if q[] is given for FT and FTS) * returned value : the integrated time duration */ double BD_evolve_imp_PC (double t, struct BD_imp *BDimp, double *x, double *q, double dt) { double dt_local = dt; struct overlap ol; /** * update BD_imp data */ BD_evolve_imp_PC_REDO: // set sys->shear_shift if necessary // at the predictor step stokes_set_shear_shift (BDimp->BD->sys, t, BDimp->BD->t0, BDimp->BD->s0); BD_imp_set_xq (BDimp, x, q); BD_evolve_imp_PC_REDO_scale: if (dt_local != BDimp->dt) { BD_imp_set_dt (BDimp, dt_local); } // set the predictor in BDimp->uP[] and BDimp->qP[] BD_imp_set_P (BDimp); /* dt-ajustment process -- overlap check */ if (BDimp->BD->sys->rmin == 0.0 // if rmin is defined, skip overlap check && check_overlap (BDimp->BD->sys, BDimp->xP, BDimp->BD->rmin, &ol) > 0) { //dt_local = reset_dt_by_ol (BDimp->BD->sys, dt_local, x, &ol); dt_local *= 0.5; if (dt_local < BDimp->BD->dt_lim) { // just reject the random force z[] /* BD->pos is still set by the initial config x[] */ fprintf (stderr, "# imp_PC: overlap in the predictor step. " "dt = %e > %e => reconstruct FB\n", dt_local, BDimp->BD->dt_lim); // reset dt to the original step dt_local = dt; goto BD_evolve_imp_PC_REDO; } else { //fact = BD_params_get_fact (BD, dt_local); /* adjustment of BDimp->fact is done by BD_imp_set_dt() above * just after the BD_evolve_JGdP_REDO_scale */ fprintf (stderr, "# imp_PC: overlap in the predictor step. " "dt = %e > %e => reconstruct FB\n", dt_local, BDimp->BD->dt_lim); goto BD_evolve_imp_PC_REDO_scale; } } /** * solve the nonlinear equations */ if (BDimp->solver == 0) // GSL-MULTIROOT { BD_imp_GSL_MULTIROOT_wrap (BDimp, x, q); } else if (BDimp->solver == 1) // NITSOL { BD_imp_NITSOL_wrap (BDimp, x, q); } else // fastSI { fprintf (stderr, "# BD_evolve_imp_PC: invalid solver %d\n", BDimp->solver); } /* dt-ajustment process -- overlap check */ if (BDimp->BD->sys->rmin == 0.0 // if rmin is defined, skip overlap check && check_overlap (BDimp->BD->sys, x, BDimp->BD->rmin, &ol) > 0) { //dt_local = reset_dt_by_ol (BDimp->BD->sys, dt_local, x, &ol); dt_local *= 0.5; if (dt_local < BDimp->BD->dt_lim) { // just reject the random force z[] /* BD->pos is still set by the initial config x[] */ fprintf (stderr, "# imp_PC: overlap in the corrector step. " "dt = %e > %e => reconstruct FB\n", dt_local, BDimp->BD->dt_lim); // reset dt to the original step dt_local = dt; goto BD_evolve_imp_PC_REDO; } else { //fact = BD_params_get_fact (BD, dt_local); /* adjustment of BDimp->fact is done by BD_imp_set_dt() above * just after the BD_evolve_JGdP_REDO_scale */ fprintf (stderr, "# imp_PC: overlap in the corrector step. " "dt = %e > %e => reconstruct FB\n", dt_local, BDimp->BD->dt_lim); goto BD_evolve_imp_PC_REDO_scale; } } return (dt_local); }
static int msm_pmem_table_add(struct hlist_head *ptype, struct msm_pmem_info *info, struct ion_client *client) { unsigned long paddr; #ifndef CONFIG_MSM_MULTIMEDIA_USE_ION unsigned long kvstart; struct file *file; #endif int rc = -ENOMEM; unsigned long len; struct msm_pmem_region *region; region = kmalloc(sizeof(struct msm_pmem_region), GFP_KERNEL); if (!region) goto out; #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION region->handle = ion_import_fd(client, info->fd); if (IS_ERR_OR_NULL(region->handle)) goto out1; if (ion_map_iommu(client, region->handle, CAMERA_DOMAIN, GEN_POOL, SZ_4K, 0, &paddr, &len, UNCACHED, 0) < 0) goto out2; #elif CONFIG_ANDROID_PMEM rc = get_pmem_file(info->fd, &paddr, &kvstart, &len, &file); if (rc < 0) { pr_err("%s: get_pmem_file fd %d error %d\n", __func__, info->fd, rc); goto out1; } region->file = file; #else paddr = 0; file = NULL; kvstart = 0; #endif if (!info->len) info->len = len; rc = check_pmem_info(info, len); if (rc < 0) goto out3; paddr += info->offset; len = info->len; if (check_overlap(ptype, paddr, len) < 0) { rc = -EINVAL; goto out3; } CDBG("%s: type %d, active flag %d, paddr 0x%lx, vaddr 0x%lx\n", __func__, info->type, info->active, paddr, (unsigned long)info->vaddr); INIT_HLIST_NODE(®ion->list); region->paddr = paddr; region->len = len; memcpy(®ion->info, info, sizeof(region->info)); D("%s Adding region to list with type %d\n", __func__, region->info.type); D("%s pmem_stats address is 0x%p\n", __func__, ptype); hlist_add_head(&(region->list), ptype); return 0; out3: #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION ion_unmap_iommu(client, region->handle, CAMERA_DOMAIN, GEN_POOL); #endif #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION out2: ion_free(client, region->handle); #elif CONFIG_ANDROID_PMEM put_pmem_file(region->file); #endif out1: kfree(region); out: return rc; }
void bootstrap(void) { version_print(); ofw_memmap(&bootinfo.memmap); void *bootinfo_pa = ofw_translate(&bootinfo); void *real_mode_pa = ofw_translate(&real_mode); void *loader_address_pa = ofw_translate((void *) LOADER_ADDRESS); printf("\nMemory statistics (total %llu MB)\n", bootinfo.memmap.total >> 20); printf(" %p|%p: real mode trampoline\n", &real_mode, real_mode_pa); printf(" %p|%p: boot info structure\n", &bootinfo, bootinfo_pa); printf(" %p|%p: kernel entry point\n", (void *) PA2KA(BOOT_OFFSET), (void *) BOOT_OFFSET); printf(" %p|%p: loader entry point\n", (void *) LOADER_ADDRESS, loader_address_pa); size_t i; for (i = 0; i < COMPONENTS; i++) printf(" %p|%p: %s image (%zu/%zu bytes)\n", components[i].start, ofw_translate(components[i].start), components[i].name, components[i].inflated, components[i].size); size_t dest[COMPONENTS]; size_t top = 0; size_t cnt = 0; bootinfo.taskmap.cnt = 0; for (i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) { top = ALIGN_UP(top, PAGE_SIZE); if (i > 0) { bootinfo.taskmap.tasks[bootinfo.taskmap.cnt].addr = (void *) PA2KA(top); bootinfo.taskmap.tasks[bootinfo.taskmap.cnt].size = components[i].inflated; str_cpy(bootinfo.taskmap.tasks[bootinfo.taskmap.cnt].name, BOOTINFO_TASK_NAME_BUFLEN, components[i].name); bootinfo.taskmap.cnt++; } dest[i] = top; top += components[i].inflated; cnt++; } void *balloc_base; void *balloc_base_pa; ofw_alloc("boot allocator area", &balloc_base, &balloc_base_pa, BALLOC_MAX_SIZE, loader_address_pa); printf(" %p|%p: boot allocator area\n", balloc_base, balloc_base_pa); void *inflate_base; void *inflate_base_pa; ofw_alloc("inflate area", &inflate_base, &inflate_base_pa, top, loader_address_pa); printf(" %p|%p: inflate area\n", inflate_base, inflate_base_pa); uintptr_t balloc_start = ALIGN_UP(top, PAGE_SIZE); size_t pages = (balloc_start + ALIGN_UP(BALLOC_MAX_SIZE, PAGE_SIZE)) >> PAGE_WIDTH; void *transtable; void *transtable_pa; ofw_alloc("translate table", &transtable, &transtable_pa, pages * sizeof(void *), loader_address_pa); printf(" %p|%p: translate table\n", transtable, transtable_pa); check_overlap("boot allocator area", balloc_base_pa, pages); check_overlap("inflate area", inflate_base_pa, pages); check_overlap("translate table", transtable_pa, pages); printf("\nInflating components ... "); for (i = cnt; i > 0; i--) { printf("%s ", components[i - 1].name); int err = inflate(components[i - 1].start, components[i - 1].size, inflate_base + dest[i - 1], components[i - 1].inflated); if (err != EOK) { printf("\n%s: Inflating error %d, halting.\n", components[i - 1].name, err); halt(); } } printf(".\n"); printf("Setting up boot allocator ...\n"); balloc_init(&bootinfo.ballocs, balloc_base, PA2KA(balloc_start), BALLOC_MAX_SIZE); printf("Setting up screens ...\n"); ofw_setup_screens(); printf("Canonizing OpenFirmware device tree ...\n"); bootinfo.ofw_root = ofw_tree_build(); printf("Setting up translate table ...\n"); for (i = 0; i < pages; i++) { uintptr_t off = i << PAGE_WIDTH; void *phys; if (off < balloc_start) phys = ofw_translate(inflate_base + off); else phys = ofw_translate(balloc_base + off - balloc_start); ((void **) transtable)[i] = phys; } printf("Booting the kernel...\n"); jump_to_kernel(bootinfo_pa, transtable_pa, pages, real_mode_pa); }