ofs_block_cache_t *alloc_obj_cache(object_info_t *obj_info, uint64_t vbn, uint32_t blk_id) { ofs_block_cache_t *cache = NULL; ASSERT(obj_info != NULL); cache = OS_MALLOC(sizeof(ofs_block_cache_t)); if (!cache) { LOG_ERROR("Allocate memory failed. size(%d)\n", (uint32_t)sizeof(ofs_block_cache_t)); return NULL; } cache->ib = OS_MALLOC(obj_info->ct->sb.block_size); if (!cache) { LOG_ERROR("Allocate memory failed. size(%d)\n", obj_info->ct->sb.block_size); OS_FREE(cache); return NULL; } SET_CACHE_EMPTY(cache); cache->vbn = vbn; insert_obj_cache(obj_info, cache); return cache; }
/* Init the timer library * Allocate memory, init free list * Return zero for success, non-zero otherwise */ int bcmseclib_init_timer_utilities_ex(int ntimers, bcmseclib_timer_mgr_t **mgrp) { int i; bcmseclib_timer_mgr_t *mgr; mgr = (bcmseclib_timer_mgr_t *) OS_MALLOC(sizeof(bcmseclib_timer_mgr_t)); if (mgr == NULL) { return (-1); } memset(mgr, 0, sizeof(bcmseclib_timer_mgr_t)); mgr->maxtimers = ntimers; mgr->timer_freelist = (bcmseclib_timer_t *) OS_MALLOC(ntimers * sizeof(bcmseclib_timer_t)); memset(mgr->timer_freelist, 0, ntimers * sizeof(bcmseclib_timer_t)); /* save, we'll need this to cleanup when we shutdown */ mgr->timer_list_mark = mgr->timer_freelist; for (i = 0; i < (ntimers-1); i++) mgr->timer_freelist[i].next = &mgr->timer_freelist[i+1]; mgr->timer_freelist[i].next = NULL; if (mgrp == NULL) { mgrp = &g_timer_mgr; } *mgrp = mgr; return 0; }
int ieee80211_power_alloc_tim_bitmap(struct ieee80211vap *vap) { u_int8_t *tim_bitmap = NULL; u_int32_t old_len = vap->iv_tim_len; //printk("[%s] entry\n",__func__); vap->iv_tim_len = howmany(vap->iv_max_aid, 8) * sizeof(u_int8_t); tim_bitmap = OS_MALLOC(vap->iv_ic->ic_osdev, vap->iv_tim_len, 0); if(!tim_bitmap) { vap->iv_tim_len = old_len; return -1; } OS_MEMZERO(tim_bitmap, vap->iv_tim_len); if (vap->iv_tim_bitmap) { OS_MEMCPY(tim_bitmap, vap->iv_tim_bitmap, vap->iv_tim_len > old_len ? old_len : vap->iv_tim_len); OS_FREE(vap->iv_tim_bitmap); } vap->iv_tim_bitmap = tim_bitmap; //printk("[%s] exits\n",__func__); return 0; }
int32_t init_container_resource(container_handle_t **ct, const char *ct_name) { container_handle_t *tmp_ct = NULL; ASSERT(ct != NULL); ASSERT(ct_name != NULL); tmp_ct = (container_handle_t *)OS_MALLOC(sizeof(container_handle_t)); if (!tmp_ct) { LOG_ERROR("Allocate memory failed. size(%d)\n", (uint32_t)sizeof(container_handle_t)); return -INDEX_ERR_ALLOCATE_MEMORY; } memset(tmp_ct, 0, sizeof(container_handle_t)); strncpy(tmp_ct->name, ct_name, OFS_NAME_SIZE); OS_RWLOCK_INIT(&tmp_ct->ct_lock); OS_RWLOCK_INIT(&tmp_ct->metadata_cache_lock); tmp_ct->ref_cnt = 1; avl_create(&tmp_ct->obj_info_list, (int (*)(const void *, const void*))compare_object1, sizeof(object_info_t), OS_OFFSET(object_info_t, entry)); avl_create(&tmp_ct->metadata_cache, (int (*)(const void *, const void*))compare_cache1, sizeof(ofs_block_cache_t), OS_OFFSET(ofs_block_cache_t, fs_entry)); avl_add(g_container_list, tmp_ct); *ct = tmp_ct; return 0; }
/** * @brief Routine to send reject frame * * @param rrm * @param rm_req * * @return on success return 0. * on failure returns -ve value. */ int rrm_send_reject(ieee80211_rrm_t rrm, struct ieee80211_action_rm_req *rm_req ) { struct ieee80211_rrmreq_info *params; struct ieee80211_measreq_ie *req; #if UMAC_SUPPORT_RRM_DEBUG wlan_if_t vap = rrm->rrm_vap; #endif RRM_FUNCTION_ENTER; req = (struct ieee80211_measreq_ie *)(&(rm_req->req_ies[0])); params = (struct ieee80211_rrmreq_info *) OS_MALLOC(rrm->rrm_osdev, sizeof(struct ieee80211_rrmreq_info), 0); if(NULL == params) return -EBUSY; params->rm_dialogtoken = rm_req->dialogtoken; params->rep_dialogtoken = req->token ; params->reject_type = req->reqtype; params->reject_mode = BIT_REFUSED; ieee80211_rrm_set_report_pending(rrm->rrm_vap,IEEE80211_MEASREQ_OTHER,(void *)params); if(rrm->pending_report) ieee80211_send_report(rrm); RRM_FUNCTION_EXIT; return EOK; }
u_int8_t *ret_byte_copied_fft_data(struct ath_softc *sc, struct ath_desc *ds, struct ath_buf *bf) { #define ALLOC_FFT_DATA_SIZE 256 struct ath_spectral *spectral=sc->sc_spectral; u_int16_t datalen = ds->ds_rxstat.rs_datalen; u_int8_t *pfft_data=NULL, *byte_ptr=NULL, bmapwt=0,maxindex=0; int i=0; pfft_data = (u_int8_t*)OS_MALLOC(sc->sc_osdev, ALLOC_FFT_DATA_SIZE, 0); if ((!pfft_data) || (datalen > spectral->spectral_data_len + 2)) return NULL; OS_MEMZERO(pfft_data, ALLOC_FFT_DATA_SIZE); for (i=0; i<datalen; i++) { byte_ptr = (u_int8_t*)(((u_int8_t*)bf->bf_vdata + i)); pfft_data[i]=((*byte_ptr) & 0xFF); } get_ht20_bmap_maxindex(sc,pfft_data,datalen,&bmapwt, &maxindex); SPECTRAL_DPRINTK(sc, ATH_DEBUG_SPECTRAL1, "%s %d HT20 bmap=%d maxindex=%d\n", __func__, __LINE__, bmapwt, maxindex); return pfft_data; #undef ALLOC_FFT_DATA_SIZE }
/* * Attach the "VAP_ATH_INFO" manager. */ ieee80211_vap_ath_info_t ieee80211_vap_ath_info_attach( wlan_if_t vap) { ieee80211_vap_ath_info_t h_mgr; if (vap->iv_vap_ath_info_handle) { IEEE80211_DPRINTF(vap, IEEE80211_MSG_VAP_ATH_INFO, "%s: Error: already attached.\n", __func__); return NULL; } /* Allocate ResMgr data structures */ h_mgr = (ieee80211_vap_ath_info_t) OS_MALLOC(vap->iv_ic->ic_osdev, sizeof(struct ieee80211_vap_ath_info), 0); if (h_mgr == NULL) { IEEE80211_DPRINTF(vap, IEEE80211_MSG_VAP_ATH_INFO, "%s : memory alloction failed. size=%d\n", __func__, sizeof(struct ieee80211_vap_ath_info)); return NULL; } OS_MEMZERO(h_mgr, sizeof(struct ieee80211_vap_ath_info)); h_mgr->vap = vap; spin_lock_init(&(h_mgr->lock)); return h_mgr; }
/* * vap attach. (VAP Module) */ void ieee80211_resmgr_vattach(ieee80211_resmgr_t resmgr, ieee80211_vap_t vap) { int retval; ieee80211_resmgr_vap_priv_t resmgr_vap; /* Allocate and store ResMgr private data in the VAP structure */ resmgr_vap = (ieee80211_resmgr_vap_priv_t) OS_MALLOC(vap->iv_ic->ic_osdev, sizeof(struct ieee80211_resmgr_vap_priv), 0); ASSERT(resmgr_vap != NULL); if (!resmgr_vap) return; OS_MEMZERO(resmgr_vap, sizeof(struct ieee80211_resmgr_vap_priv)); resmgr_vap->state = VAP_STOPPED; resmgr_vap->resmgr = resmgr; /* Setup Off-Channel Scheduler data in the ResMgr private data */ ieee80211_resmgr_oc_sched_vattach(resmgr, vap, resmgr_vap); /* Register an event handler with the VAP module */ retval = ieee80211_vap_register_event_handler(vap, ieee80211_resmgr_vap_evhandler, (void *)resmgr); ASSERT(retval == 0); ieee80211vap_set_resmgr(vap,resmgr_vap); }
void * wmi_unified_attach(ol_scn_t scn_handle, wma_wow_tx_complete_cbk func) { struct wmi_unified *wmi_handle; wmi_handle = (struct wmi_unified *)OS_MALLOC(NULL, sizeof(struct wmi_unified), GFP_ATOMIC); if (wmi_handle == NULL) { printk("allocation of wmi handle failed %zu \n", sizeof(struct wmi_unified)); return NULL; } OS_MEMZERO(wmi_handle, sizeof(struct wmi_unified)); wmi_handle->scn_handle = scn_handle; adf_os_atomic_init(&wmi_handle->pending_cmds); adf_os_atomic_init(&wmi_handle->is_target_suspended); #ifdef FEATURE_RUNTIME_PM adf_os_atomic_init(&wmi_handle->runtime_pm_inprogress); #endif adf_os_spinlock_init(&wmi_handle->eventq_lock); adf_nbuf_queue_init(&wmi_handle->event_queue); #ifdef CONFIG_CNSS cnss_init_work(&wmi_handle->rx_event_work, wmi_rx_event_work); #else INIT_WORK(&wmi_handle->rx_event_work, wmi_rx_event_work); #endif #ifdef WMI_INTERFACE_EVENT_LOGGING adf_os_spinlock_init(&wmi_handle->wmi_record_lock); #endif wmi_handle->wma_wow_tx_complete_cbk = func; return wmi_handle; }
int tx99_attach(struct ath_softc *sc) { struct ath_tx99 *tx99 = sc->sc_tx99; if (tx99 != NULL) { DPRINTF(sc, ATH_DEBUG_TX99, "%s: sc_tx99 was not NULL\n", __FUNCTION__); return EINVAL; } tx99 = (struct ath_tx99 *)OS_MALLOC(sc->sc_osdev, sizeof(struct ath_tx99), GFP_KERNEL); if (tx99 == NULL) { DPRINTF(sc, ATH_DEBUG_TX99, "%s: no memory for tx99 attach\n", __FUNCTION__); return ENOMEM; } OS_MEMZERO(tx99, sizeof(struct ath_tx99)); sc->sc_tx99 = tx99; tx99->stop = tx99_stop; tx99->start = tx99_start; tx99->tx99_state = 0; tx99->txpower = 60; tx99->txrate = 54000; tx99->txrc = 0x0c; tx99->txfreq = 2412;/* ieee channel frequency */ tx99->txmode = 0; tx99->chanmask = 7; tx99->recv = 0; tx99->htmode = 0; tx99->htext = 0; return 0; }
ieee80211_pwrsave_smps_t ieee80211_pwrsave_smps_attach(struct ieee80211vap *vap, u_int32_t smpsDynamic) { ieee80211_pwrsave_smps_t smps; osdev_t os_handle = vap->iv_ic->ic_osdev; smps = (ieee80211_pwrsave_smps_t)OS_MALLOC(os_handle,sizeof(struct ieee80211_pwrsave_smps),0); if (smps) { OS_MEMZERO(smps, sizeof(struct ieee80211_pwrsave_smps)); /* * Initialize pwrsave timer */ OS_INIT_TIMER(os_handle, &smps->ips_timer, ieee80211_pwrsave_smps_timer, smps); if (smpsDynamic && IEEE80211_HAS_DYNAMIC_SMPS_CAP(vap->iv_ic)) { ieee80211_vap_dynamic_mimo_ps_set(vap); } else { ieee80211_vap_dynamic_mimo_ps_clear(vap); } smps->ips_smPowerSaveState = IEEE80211_SM_PWRSAVE_DISABLED; smps->ips_connected = false; smps->ips_vap = vap; ieee80211_vap_register_event_handler(vap,ieee80211_pwrsave_smps_vap_event_handler,(void *)smps ); } return smps; }
int ieee80211_rrm_recv_chload_req(wlan_if_t vap, wlan_node_t ni, struct ieee80211_measreq_ie *req,u_int8_t rm_token) { struct ieee80211_chloadreq *chload; struct ieee80211_rrmreq_info *params; RRM_FUNCTION_ENTER; chload = (struct ieee80211_chloadreq *)(&req->req[0]); params = (struct ieee80211_rrmreq_info *) OS_MALLOC(vap->rrm->rrm_osdev, sizeof(struct ieee80211_rrmreq_info), 0); if(NULL == params) return -EBUSY; params->rm_dialogtoken = rm_token; params->rep_dialogtoken = req->token; params->duration = chload->mduration; params->chnum = chload->chnum; params->regclass = chload->regclass; RRM_DEBUG(vap, RRM_DEBUG_INFO, "%s : duration %d chnum %d regclass %d\n", __func__, params->duration, params->chnum, params->regclass); ieee80211_rrm_set_report_pending(vap,IEEE80211_MEASREQ_CHANNEL_LOAD_REQ,(void *)params); if (ieee80211_rrm_scan_start(vap, true) != 0) { ieee80211_rrm_free_report(vap->rrm); return -EBUSY; } RRM_FUNCTION_EXIT; return EOK; }
int ieee80211_rrm_recv_lci_req(wlan_if_t vap, wlan_node_t ni, struct ieee80211_measreq_ie *req, u_int8_t rm_token) { struct ieee80211_rrmreq_info *params; struct ieee80211_lcireq *lcireq; RRM_FUNCTION_ENTER; lcireq = (struct ieee80211_lcireq *)(&(req->req[0])); params = (struct ieee80211_rrmreq_info *) OS_MALLOC(vap->rrm->rrm_osdev, sizeof(struct ieee80211_rrmreq_info), 0); if(NULL == params) return -EBUSY; params->rm_dialogtoken = rm_token; params->rep_dialogtoken = req->token; params->location = lcireq->location; params->lat_res = lcireq->lat_res; params->long_res = lcireq->long_res; params->alt_res = lcireq->alt_res; RRM_DEBUG(vap, RRM_DEBUG_INFO, "%s : location %d lat_res %d long_res %d alt_res %d\n", __func__, params->location, params->lat_res, params->long_res, params->alt_res); ieee80211_rrm_set_report_pending(vap, IEEE80211_MEASREQ_LCI_REQ, (void *)params); if(vap->rrm->pending_report) ieee80211_send_report(vap->rrm); RRM_FUNCTION_EXIT; return EOK; }
/** * @brief Routine to accept station statistics request * * @param vap * @param ni * @param req * @param rm_token * * @return * @return on success return 0. * on failure returns -ve value. */ int ieee80211_rrm_recv_stastats_req(wlan_if_t vap, wlan_node_t ni, struct ieee80211_measreq_ie *req,u_int8_t rm_token) { struct ieee80211_rrmreq_info *params; struct ieee80211_stastatsreq *statsreq; RRM_FUNCTION_ENTER; statsreq = (struct ieee80211_stastatsreq *)(&(req->req[0])); params = (struct ieee80211_rrmreq_info *) OS_MALLOC(vap->rrm->rrm_osdev, sizeof(struct ieee80211_rrmreq_info), 0); if(NULL == params) return -EBUSY; params->rm_dialogtoken = rm_token; params->rep_dialogtoken= req->token; params->duration=statsreq->mduration; params->gid=statsreq->gid; RRM_DEBUG(vap, RRM_DEBUG_INFO, "%s : duration %d chnum %d gid %d\n", __func__, params->duration, params->chnum, params->gid); IEEE80211_ADDR_COPY(params->bssid,statsreq->dstmac); ieee80211_rrm_set_report_pending(vap,IEEE80211_MEASREQ_STA_STATS_REQ,(void *)params); if(vap->rrm->pending_report) ieee80211_send_report(vap->rrm); RRM_FUNCTION_EXIT; return EOK; }
/** * \brief Convert char string to wide-char, and send. * * \param[in] str The string. * * \warning Note that this is not a real ansi-to-wide conversion, just an extension of each * character to 16-bit. */ static void SendEp0String(const char* str) { uint8 len = strlen(str); uint8 size = 2 + (2 * len); ep0_buffer = OS_MALLOC(size); if (ep0_buffer) { uint8* pb = ep0_buffer; const char* ps = str; uint8 i; *pb++ = size; *pb++ = USB_DT_STRING; for (i = 0; i < len; i++) { *pb++ = *ps++; *pb++ = 0; } hw_usb_ep_tx_start(USB_EP_DEFAULT, ep0_buffer, MIN(size, usb_setup.length)); } else { hw_usb_ep0_stall(); } }
static __inline__ mi_node_t * mi_node_alloc(void) { mi_node_t *fn; if ((fn = (mi_node_t *)OS_MALLOC(NULL, sizeof(mi_node_t), GFP_KERNEL)) != NULL) { OS_MEMSET(fn, 0, sizeof(mi_node_t)); } return fn; }
/* * Create a Resource manager. */ ieee80211_resmgr_t ieee80211_resmgr_create(struct ieee80211com *ic, ieee80211_resmgr_mode mode) { ieee80211_resmgr_t resmgr; if (ic->ic_tsf_timer == NULL) { printk("%s: Multi-Channel Scheduler unavailable since no TSF Timer.\n", __func__); } else { ic->ic_caps_ext |= IEEE80211_CEXT_MULTICHAN; } if (ic->ic_resmgr) { printk("%s : ResMgr already exists \n", __func__); return NULL; } /* Allocate ResMgr data structures */ resmgr = (ieee80211_resmgr_t) OS_MALLOC(ic->ic_osdev, sizeof(struct ieee80211_resmgr), 0); if (resmgr == NULL) { printk("%s : ResMgr memory alloction failed\n", __func__); return NULL; } OS_MEMZERO(resmgr, sizeof(struct ieee80211_resmgr)); resmgr->ic = ic; resmgr->mode = mode; /* Initialize resource manager state machine */ if (ieee80211_resmgr_sm_create(resmgr) != EOK) { OS_FREE(resmgr); printk("%s : ieee80211_resmgr_sm_create failed \n", __func__); return NULL; } if (ic->ic_caps_ext & IEEE80211_CEXT_MULTICHAN) { if (ieee80211_resmgr_oc_scheduler_create(resmgr, OFF_CHAN_SCHED_POLICY_ROUND_ROBIN) != EOK) { OS_FREE(resmgr); printk("%s : ieee80211_resmgr_oc_scheduler_create failed \n", __func__); return NULL; } ASSERT(ic->ic_tsf_timer); } else { /* Do not support P2P */ printk("Error: %s: no Multi-chan hw caps. Disabling Off Channel scheduler.\n", __func__); } IEEE80211_RESMGR_LOCK_INIT(resmgr); spin_lock_init(&resmgr->rm_handler_lock); OS_INIT_TIMER(ic->ic_osdev, &(resmgr->scandata.canpause_timer), ieee80211_resmgr_canpause_timeout_callback, resmgr); resmgr->pm_state= IEEE80211_PWRSAVE_FULL_SLEEP; return resmgr; }
static int wlan_offchan_tx_test_offload(wlan_if_t vaphandle, void *netdev, u_int32_t chan, u_int16_t scan_requestor, u_int32_t *scan_id) { struct ieee80211vap *vap = vaphandle; struct ieee80211com *ic = vap->iv_ic; IEEE80211_SCAN_PRIORITY scan_priority; ieee80211_scan_params *scan_params; enum ieee80211_opmode opmode = wlan_vap_get_opmode(vap); int rc; scan_params = (ieee80211_scan_params *) OS_MALLOC(ic->ic_osdev, sizeof(*scan_params), GFP_KERNEL); if (scan_params == NULL) return -ENOMEM; OS_MEMZERO(scan_params,sizeof(ieee80211_scan_params)); wlan_set_default_scan_parameters(vap,scan_params,opmode,true,true,true,true,0,NULL,0); scan_params->flags = IEEE80211_SCAN_PASSIVE | IEEE80211_SCAN_ALLBANDS; /* allow off channel TX on both data and mgmt */ scan_params->flags |= IEEE80211_SCAN_OFFCHAN_MGMT_TX | IEEE80211_SCAN_OFFCHAN_DATA_TX; scan_params->type = IEEE80211_SCAN_FOREGROUND; scan_params->min_dwell_time_passive = 60; scan_params->max_dwell_time_passive = 80; scan_priority = IEEE80211_SCAN_PRIORITY_HIGH; /* channel to scan */ scan_params->num_channels = 1; scan_params->chan_list = &chan; rc = wlan_scan_register_event_handler(vap, &wlan_offchan_tx_scan_event_handler,(void *)netdev); if (rc != EOK) { IEEE80211_DPRINTF(vap, IEEE80211_MSG_ANY, "%s: wlan_scan_register_event_handler() failed handler=%08p,%08p rc=%08X\n", __func__, &wlan_offchan_tx_scan_event_handler, vap, rc); OS_FREE(scan_params); return -1; } if (wlan_scan_start(vap, scan_params, scan_requestor, scan_priority, scan_id) != 0 ) { IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, "%s: Issue a scan fail.\n", __func__); OS_FREE(scan_params); wlan_scan_unregister_event_handler(vap, &wlan_offchan_tx_scan_event_handler,(void *)netdev); return -1; } OS_FREE(scan_params); return 0; }
/** * @brief * * @param vap * @param ni * @param req * @param rm_token * * @return * @return on success return 0. * on failure returns -ve value. */ int ieee80211_rrm_recv_beacon_req(wlan_if_t vap, wlan_node_t ni, struct ieee80211_measreq_ie *req,u_int8_t rm_token) { struct ieee80211_rrmreq_info *params=NULL; struct ieee80211_beaconreq *bcnreq=NULL; RRM_FUNCTION_ENTER; bcnreq = (struct ieee80211_beaconreq *)(&(req->req[0])); params = (struct ieee80211_rrmreq_info *) OS_MALLOC(vap->rrm->rrm_osdev, sizeof(struct ieee80211_rrmreq_info), 0); if(NULL == params) return -EBUSY; params->rm_dialogtoken = rm_token; params->rep_dialogtoken= req->token; params->duration=bcnreq->duration; params->chnum = bcnreq->channum; RRM_DEBUG(vap, RRM_DEBUG_INFO, "%s : duration %d chnum %d regclass %d\n", __func__, params->duration, params->chnum, params->regclass); IEEE80211_ADDR_COPY(params->bssid,bcnreq->bssid); ieee80211_rrm_set_report_pending(vap,IEEE80211_MEASREQ_BR_TYPE,(void *)params); if(vap->rrm->rrm_last_scan == 0) { ieee80211_rrm_scan(vap, bcnreq->mode); return EOK; } else { u_int32_t last_scan_time=0,msec_current_time = 0; last_scan_time = (u_int32_t) CONVERT_SYSTEM_TIME_TO_MS(vap->rrm->rrm_last_scan); msec_current_time = (u_int32_t) CONVERT_SYSTEM_TIME_TO_MS(OS_GET_TIMESTAMP()); msec_current_time -= last_scan_time; if(msec_current_time < 60*1000) { if(vap->rrm->pending_report) ieee80211_send_report(vap->rrm); } else { ieee80211_rrm_scan(vap, bcnreq->mode); } } RRM_FUNCTION_EXIT; return EOK; }
/** * \brief Transmit data on endpoint zero. * * \param[in] data The buffer holding the data. * \param[in] size The size of the data in the buffer. * */ static void SendEp0Data(uint8* data, uint8 size) { ep0_buffer = OS_MALLOC(size); if (ep0_buffer) { memcpy(ep0_buffer, data, size); hw_usb_ep_tx_start(USB_EP_DEFAULT, ep0_buffer, size); } else { hw_usb_ep0_stall(); } }
void _ieee80211_power_vattach(struct ieee80211vap *vap, int fullsleepEnable, u_int32_t sleepTimerPwrSaveMax, u_int32_t sleepTimerPwrSave, u_int32_t sleepTimePerf, u_int32_t inactTimerPwrsaveMax, u_int32_t inactTimerPwrsave, u_int32_t inactTimerPerf, u_int32_t smpsDynamic, u_int32_t pspollEnabled) { osdev_t os_handle = vap->iv_ic->ic_osdev; vap->iv_power = (ieee80211_power_t)OS_MALLOC(os_handle,sizeof(struct ieee80211_power),0); if (!vap->iv_power) { return; } OS_MEMZERO(vap->iv_power, sizeof(struct ieee80211_power)); spin_lock_init(&vap->iv_power->pm_state_lock); switch (vap->iv_opmode) { case IEEE80211_M_HOSTAP: ieee80211_ap_power_vattach(vap); vap->iv_pwrsave_sta = NULL; vap->iv_pwrsave_smps = NULL; break; case IEEE80211_M_STA: if( (!IEEE80211_VAP_IS_WDS_ENABLED(vap)) || ( vap->iv_ic->ic_opmode == IEEE80211_M_STA ) ) { vap->iv_pwrsave_sta = ieee80211_sta_power_vattach(vap, fullsleepEnable, sleepTimerPwrSaveMax, sleepTimerPwrSave, sleepTimePerf, inactTimerPwrsaveMax, inactTimerPwrsave, inactTimerPerf, pspollEnabled); vap->iv_pwrsave_smps = ieee80211_pwrsave_smps_attach(vap,smpsDynamic); } else { vap->iv_pwrsave_sta = NULL; vap->iv_pwrsave_smps = NULL; } break; default: vap->iv_pwrsave_sta = NULL; vap->iv_pwrsave_smps = NULL; break; } ieee80211_vap_register_event_handler(vap,ieee80211_power_vap_event_handler,(void *)NULL ); ieee80211_power_arbiter_vattach(vap); }
static void add_partition_entry(const partition_entry_t *entry) { partition_t *p = (partition_t *) OS_MALLOC(sizeof(partition_t)); OS_ASSERT(p); if (p) { p->data = *entry; p->next = partitions; p->driver = NULL; p->driver_data = 0; partitions = p; } }
ble_service_t *dlgdebug_init(const ble_service_config_t *cfg) { dlgdebug_service_t *dbgs; uint16_t num_attr; att_uuid_t uuid; uint16_t cp_cpf_h; uint8_t cp_cpf_val[7]; uint8_t *p = cp_cpf_val; dbgs = OS_MALLOC(sizeof(*dbgs)); memset(dbgs, 0, sizeof(*dbgs)); dbgs->svc.read_req = handle_read_req; dbgs->svc.write_req = handle_write_req; dbgs->svc.prepare_write_req = handle_prepare_write_req; num_attr = ble_gatts_get_num_attr(0, 1, 3); ble_uuid_from_string(UUID_DLGDEBUG, &uuid); ble_gatts_add_service(&uuid, GATT_SERVICE_PRIMARY, num_attr); ble_uuid_from_string(UUID_DLGDEBUG_CP, &uuid); ble_gatts_add_characteristic(&uuid, GATT_PROP_WRITE | GATT_PROP_NOTIFY | GATT_PROP_EXTENDED | GATT_PROP_EXTENDED_RELIABLE_WRITE, ATT_PERM_WRITE, CONFIG_BLE_DLGDEBUG_MAX_CP_LEN, 0, NULL, &dbgs->cp_val_h); ble_uuid_create16(UUID_GATT_CHAR_EXT_PROPERTIES, &uuid); ble_gatts_add_descriptor(&uuid, ATT_PERM_READ, 0, 0, NULL); ble_uuid_create16(UUID_GATT_CLIENT_CHAR_CONFIGURATION, &uuid); ble_gatts_add_descriptor(&uuid, ATT_PERM_RW, sizeof(uint16_t), 0, &dbgs->cp_ccc_h); ble_uuid_create16(UUID_GATT_CHAR_PRESENTATION_FORMAT, &uuid); ble_gatts_add_descriptor(&uuid, ATT_PERM_READ, sizeof(cp_cpf_val), 0, &cp_cpf_h); ble_gatts_register_service(&dbgs->svc.start_h, &dbgs->cp_val_h, &dbgs->cp_ccc_h, &cp_cpf_h, 0); dbgs->svc.end_h = dbgs->svc.start_h + num_attr; /* Content Presentation Format for CP */ put_u8_inc(&p, 25); // Format=UTF-8 string put_u8_inc(&p, 0); // Exponent=n/a put_u16_inc(&p, 0x2700); // Unit=unitless put_u8_inc(&p, 1); // namespace put_u16_inc(&p, 0); // descriptor ble_gatts_set_value(cp_cpf_h, sizeof(cp_cpf_val), cp_cpf_val); return &dbgs->svc; }
/* Set optional application defined IEs */ int wlan_mlme_set_optie(wlan_if_t vaphandle, u_int8_t *buf, u_int16_t buflen) { struct ieee80211vap *vap = vaphandle; struct ieee80211com *ic = vap->iv_ic; int error = 0; u_int8_t *iebuf = NULL; bool alloc_iebuf = FALSE; IEEE80211_DPRINTF(vap, IEEE80211_MSG_MLME, "%s\n", __func__); if (buflen > vap->iv_opt_ie_maxlen) { /* Allocate ie buffer */ iebuf = OS_MALLOC(ic->ic_osdev, buflen, 0); if (iebuf == NULL) { error = -ENOMEM; goto exit; } alloc_iebuf = TRUE; vap->iv_opt_ie_maxlen = buflen; } else { iebuf = vap->iv_opt_ie.ie; } IEEE80211_VAP_LOCK(vap); /* Free existing buffer */ if (alloc_iebuf == TRUE && vap->iv_opt_ie.ie) { OS_FREE(vap->iv_opt_ie.ie); } vap->iv_opt_ie.ie = iebuf; vap->iv_opt_ie.length = buflen; if (buflen) { ASSERT(buf); if (buf == NULL) { IEEE80211_VAP_UNLOCK(vap); error = -EINVAL; goto exit; } /* Copy app ie contents and save pointer/length */ OS_MEMCPY(iebuf, buf, buflen); } IEEE80211_VAP_UNLOCK(vap); exit: return error; }
void * wmi_unified_attach(ol_scn_t scn_handle, osdev_t osdev) { struct wmi_unified *wmi_handle; wmi_handle = (struct wmi_unified *)OS_MALLOC(osdev, sizeof(struct wmi_unified), GFP_ATOMIC); if (wmi_handle == NULL) { printk("allocation of wmi handle failed %d \n",sizeof(struct wmi_unified)); return NULL; } OS_MEMZERO(wmi_handle, sizeof(struct wmi_unified)); wmi_handle->scn_handle = scn_handle; wmi_handle->osdev = osdev; return wmi_handle; }
void *alloc_ble_msg(uint16_t op_code, uint16_t size) { irb_ble_hdr_t *msg; /* Allocate at least the size needed for the base message */ OS_ASSERT(size >= sizeof(irb_ble_hdr_t)); msg = OS_MALLOC(size); memset(msg, 0, size); msg->op_code = op_code; msg->msg_len = size - sizeof(irb_ble_hdr_t); return msg; }
static void *alloc_evt(uint16_t evt_code, uint16_t size) { ble_evt_hdr_t *evt; /* Allocate at least the size needed for the base message */ OS_ASSERT(size >= sizeof(*evt)); evt = OS_MALLOC(size); memset(evt, 0, size); evt->evt_code = evt_code; evt->length = size - sizeof(*evt); return evt; }
int32_t ofs_read_block_pingpong(container_handle_t *ct, block_head_t *blk, uint64_t vbn, uint32_t blk_id, uint32_t alloc_size) { int32_t ret = 0; uint32_t block_size = 0; uint8_t *buf = NULL; block_head_t * tmp_obj = NULL; if ((ct == NULL) || (blk == NULL) || (alloc_size == 0)) { LOG_ERROR("Invalid parameter. ct(%p) blk(%p) alloc_size(%d)\n", ct, blk, alloc_size); return -BLOCK_ERR_PARAMETER; } block_size = ct->sb.block_size; if (block_size < alloc_size) { LOG_ERROR("size is invalid. block_size(%d) alloc_size(%d)\n", block_size, alloc_size); return -FILE_BLOCK_ERR_INVALID_OBJECT; } buf = OS_MALLOC(block_size); if (buf == NULL) { LOG_ERROR("Allocate memory failed. size(%d)\n", block_size); return -BLOCK_ERR_ALLOCATE_MEMORY; } ret = ofs_read_block(ct, buf, block_size, 0, vbn); if (ret < 0) { OS_FREE(buf); return ret; } tmp_obj = get_last_correct_block(buf, blk_id, alloc_size, block_size / alloc_size); if (!tmp_obj) { LOG_ERROR("Get invalid object. ct(%p) blk(%p) vbn(%lld)\n", ct, tmp_obj, vbn); OS_FREE(buf); return -FILE_BLOCK_ERR_INVALID_OBJECT; } ASSERT(alloc_size >= tmp_obj->real_size); memcpy(blk, tmp_obj, tmp_obj->real_size); OS_FREE(buf); return 0; }
int32_t ofs_update_block_pingpong_init(container_handle_t *ct, block_head_t *blk, uint64_t vbn) { int32_t ret = 0; int32_t ret2 = 0; uint32_t block_size = 0; uint8_t *buf = NULL; ret = check_block(ct, blk); if (ret < 0) { LOG_ERROR("Get blocksize failed. ct(%p) buf(%p) ret(%d)", ct, blk, ret); return ret; } block_size = ct->sb.block_size; buf = OS_MALLOC(block_size); if (buf == NULL) { LOG_ERROR("Allocate memory failed. size(%d)\n", block_size); return -BLOCK_ERR_ALLOCATE_MEMORY; } assemble_block(blk); memset(buf, 0, block_size); memcpy(buf + (blk->alloc_size * (blk->seq_no % (block_size / blk->alloc_size))), blk, blk->real_size); /*lint !e414 */ ret = ofs_update_block(ct, buf, block_size, 0, vbn); OS_FREE(buf); buf = NULL; ret2 = fixup_block(blk); if (ret2 < 0) { LOG_ERROR("Fixup object failed. blk(%p) ret(%d)\n", blk, ret2); return ret2; } if (ret != (int32_t)block_size) { LOG_ERROR("Update block data failed. ct(%p) blk(%p) size(%d) vbn(%lld) ret(%d)\n", ct, blk, block_size, vbn, ret); return -BLOCK_ERR_WRITE; } return 0; }
static void ieee80211_saveie(osdev_t osdev, u_int8_t **iep, const u_int8_t *ie) { u_int ielen = ie[1]+2; /* * Record information element for later use. */ if (*iep == NULL || (*iep)[1] != ie[1]) { if (*iep != NULL) OS_FREE(*iep); *iep = OS_MALLOC(osdev,ielen,0); } if (*iep != NULL) OS_MEMCPY(*iep, ie, ielen); }