struct os * os_create(void) { struct os *newOS; newOS = os_alloc(MAX_CPU); if (newOS == NULL) return NULL; rw_lock_init(&newOS->po_mutex); logical_mmap_init(newOS); newOS->po_state = PO_STATE_CREATED; newOS->po_lpid = atomic_add(&cur_lpid, 1); /* add to global OS hash */ lock_acquire(&hype_mutex); newOS->os_hashentry.he_key = newOS->po_lpid; ht_insert(&os_hash, &newOS->os_hashentry); lock_release(&hype_mutex); lock_init(&newOS->po_events.oe_lock); dlist_init(&newOS->po_events.oe_list); dlist_init(&newOS->po_resources); return newOS; }
/******************************************************************************* ini_alloc() Reserve zones and io buffers. ******************************************************************************/ void ini_alloc() { zone_size_t heap_size, str_size, dyn_size, trail_size, subst_size, temp_size; extern void_ptr_t os_alloc(); /* see the machine dependent file */ extern int read_config(); /* see the machine dependent file */ if(!read_config(&heap_size, &str_size, &dyn_size, &trail_size, &subst_size, &temp_size, &Max_Readbuffer, &Max_Printbuffer)) { heap_size = DEFAULTSIZE; str_size = DEFAULTSIZE; dyn_size = DEFAULTSIZE; trail_size = DEFAULTSIZE; subst_size = DEFAULTSIZE; temp_size = DEFAULTSIZE; Max_Readbuffer = BUFFSIZE; Max_Printbuffer = BUFFSIZE; } Heap_mem = os_alloc(heap_size); Heap_ptr = Heap_mem; HighHeap_ptr = Heap_mem + heap_size; Str_mem = os_alloc(str_size); Str_ptr = Str_mem; HighStr_ptr = Str_mem + str_size; Dyn_mem = (dyn_ptr_t)os_alloc(dyn_size); Dyn_ptr = Dyn_mem; HighDyn_ptr = (dyn_ptr_t)((char *)Dyn_mem + dyn_size); Trail_mem = (node_ptr_t **)os_alloc(trail_size); Trail_ptr = Trail_mem; HighTrail_ptr = (node_ptr_t **)((char *)Trail_mem + trail_size); Subst_mem = (subst_ptr_t)os_alloc(subst_size); Subst_ptr = Subst_mem; HighSubst_ptr = (subst_ptr_t)((char *)Subst_mem + subst_size); while(Subst_ptr < HighSubst_ptr) { Subst_ptr->skel = (node_ptr_t)NULL; Subst_ptr++; } Subst_ptr = Subst_mem; Temp_mem = (temp_ptr_t)os_alloc(temp_size); Temp_ptr = Temp_mem; HighTemp_ptr = (temp_ptr_t)((char *)Temp_mem + temp_size); Read_buffer = os_alloc((zone_size_t)Max_Readbuffer); Print_buffer = os_alloc((zone_size_t)Max_Printbuffer); }
static int os_alloc_create(struct target *target, struct rtos_type *ostype) { int ret = os_alloc(target, ostype); if (JIM_OK == ret) { ret = target->rtos->type->create(target); if (ret != JIM_OK) os_free(target); } return ret; }
int rtos_create(Jim_GetOptInfo *goi, struct target *target) { int x; const char *cp; struct Jim_Obj *res; if (!goi->isconfigure && goi->argc != 0) { Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "NO PARAMS"); return JIM_ERR; } os_free(target); Jim_GetOpt_String(goi, &cp, NULL); if (0 == strcmp(cp, "auto")) { /* Auto detect tries to look up all symbols for each RTOS, * and runs the RTOS driver's _detect() function when GDB * finds all symbols for any RTOS. See rtos_qsymbol(). */ target->rtos_auto_detect = true; /* rtos_qsymbol() will iterate over all RTOSes. Allocate * target->rtos here, and set it to the first RTOS type. */ return os_alloc(target, rtos_types[0]); } for (x = 0; rtos_types[x]; x++) if (0 == strcmp(cp, rtos_types[x]->name)) return os_alloc_create(target, rtos_types[x]); Jim_SetResultFormatted(goi->interp, "Unknown RTOS type %s, try one of: ", cp); res = Jim_GetResult(goi->interp); for (x = 0; rtos_types[x]; x++) Jim_AppendStrings(goi->interp, res, rtos_types[x]->name, ", ", NULL); Jim_AppendStrings(goi->interp, res, " or auto", NULL); return JIM_ERR; }
OsTaskVarType * os_alloc_new_pcb( void ) { void *h = os_alloc(sizeof(OsTaskVarType)); memset(h,0,sizeof(OsTaskVarType)); assert(h!=NULL); return h; }
// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // TBool WlanTxRateAdaptation::AppendRate( TUint8 aPolicyIndex, WHA::TRate aRate ) { OsTracePrint( KTxRateAdapt, (TUint8*) ("UMAC: WlanTxRateAdaptation::AppendRate(): aPolicyIndex: %d"), aPolicyIndex); OsTracePrint( KTxRateAdapt, (TUint8*) ("UMAC: WlanTxRateAdaptation::AppendRate(): rate: 0x%08x"), aRate); // allocate a new block for the rate SBitRate* block = static_cast<SBitRate*>(os_alloc( sizeof(SBitRate) )); if ( !block ) { // alloc failure; we cannot continue OsTracePrint( KErrorLevel, (TUint8*)("UMAC: WlanTxRateAdaptation::AppendRate(): alloc failure")); return EFalse; } block->iBitRate = aRate; block->iNext = NULL; block->iPrev = NULL; if ( !iPolicy[aPolicyIndex].iHead ) { // this is the first append iPolicy[aPolicyIndex].iHead = block; iPolicy[aPolicyIndex].iTail = iPolicy[aPolicyIndex].iHead; iPolicy[aPolicyIndex].iCurrentTxRate = block; ++iPolicy[aPolicyIndex].iNumOfRates; } else { // not the first rate to append if ( block->iBitRate > iPolicy[aPolicyIndex].iTail->iBitRate ) { // new rate bigger than the last one // append to rear iPolicy[aPolicyIndex].iTail->iNext = block; block->iPrev = iPolicy[aPolicyIndex].iTail; // new tail iPolicy[aPolicyIndex].iTail = block; ++iPolicy[aPolicyIndex].iNumOfRates; } else if( block->iBitRate < iPolicy[aPolicyIndex].iTail->iBitRate ) { // new rate smaller than the last one // insert the rate to the correct slot InsertRate( aPolicyIndex, block ); ++iPolicy[aPolicyIndex].iNumOfRates; } else { // new rate equal to the last one // this cannot happen as we are setting the rates only once // and from a rate bitmask } } OsTracePrint( KTxRateAdapt, (TUint8*) ("UMAC: WlanTxRateAdaptation::AppendRate(): num of existing rates: %d"), iPolicy[aPolicyIndex].iNumOfRates); return ETrue; }