static struct vsftimer_t* vsftimer_memop_alloc(void) { struct vsf_module_t *module = vsf_module_get("app"); struct vsfapp_t *app = module->ifs; return VSFPOOL_ALLOC(&app->vsftimer_pool, struct vsftimer_t); }
static void vsftimer_memop_free(struct vsftimer_t *timer) { struct vsf_module_t *module = vsf_module_get("app"); struct vsfapp_t *app = module->ifs; VSFPOOL_FREE(&app->vsftimer_pool, timer); }
// wifi static struct vsfip_buffer_t* app_bcmwifi_get_buffer(uint32_t size) { struct vsf_module_t *module = vsf_module_get("app"); struct vsfapp_t *app = module->ifs; struct vsfip_buffer_t *buffer = NULL; if (size <= sizeof(app->bcmwifi.vsfip_buffer128_mem[0])) { buffer = VSFPOOL_ALLOC(&app->bcmwifi.vsfip_buffer128_pool, struct vsfip_buffer_t); }
void* vsf_module_load(char *name, bool dead) { struct vsf_module_t *module = vsf_module_get(name); vsf_err_t (*mod_entry)(struct vsf_module_t *, struct app_hwcfg_t const *); if ((module != NULL) && module->flash->entry) { if (module->code_buff != NULL) { goto succeed; } #ifdef VSFCFG_MODULE_ALLOC_RAM if (module->flash->size > 0) { module->code_buff = vsf_bufmgr_malloc(module->flash->size); if (NULL == module->code_buff) { goto fail; } memcpy(module->code_buff, module->flash, module->flash->size); } else { module->code_buff = (uint8_t *)module->flash; } #else module->code_buff = (uint8_t *)module->flash; #endif mod_entry = (vsf_err_t (*)(struct vsf_module_t *, struct app_hwcfg_t const *)) (module->code_buff + module->flash->entry); if (mod_entry(module, &app_hwcfg)) { #ifdef VSFCFG_MODULE_ALLOC_RAM if (module->flash->size > 0) { vsf_bufmgr_free(module->code_buff); } #endif module->code_buff = NULL; goto fail; } succeed: return module->ifs; } fail: if (dead) while (1); return NULL; }
void vsf_module_unload(char *name) { struct vsf_module_t *module = vsf_module_get(name); vsf_err_t (*mod_exit)(struct vsf_module_t *); if ((module != NULL) && (module->code_buff != NULL)) { if (module->flash->exit) { mod_exit = (vsf_err_t (*)(struct vsf_module_t *)) (module->code_buff + module->flash->exit); mod_exit(module); } #ifdef VSFCFG_MODULE_ALLOC_RAM if (module->flash->size > 0) { vsf_bufmgr_free(module->code_buff); } #endif module->code_buff = NULL; } }
static struct vsfip_tcppcb_t* vsfos_vsfip_get_tcppcb(void) { struct vsf_module_t *module = vsf_module_get("vsf.os"); struct vsfos_modifs_t *ifs = (struct vsfos_modifs_t *)module->ifs; return VSFPOOL_ALLOC(&ifs->tcpip.tcppcb_pool, struct vsfip_tcppcb_t); }
static void vsfos_vsfip_release_tcppcb(struct vsfip_tcppcb_t *tcppcb) { struct vsf_module_t *module = vsf_module_get("vsf.os"); struct vsfos_modifs_t *ifs = (struct vsfos_modifs_t *)module->ifs; VSFPOOL_FREE(&ifs->tcpip.tcppcb_pool, tcppcb); }
static void vsfos_vsfip_release_buffer(struct vsfip_buffer_t *buffer) { struct vsf_module_t *module = vsf_module_get("vsf.os"); struct vsfos_modifs_t *ifs = (struct vsfos_modifs_t *)module->ifs; VSFPOOL_FREE(&ifs->tcpip.buffer_pool, buffer); }
static void vsfos_vsfip_release_socket(struct vsfip_socket_t *socket) { struct vsf_module_t *module = vsf_module_get("vsf.os"); struct vsfos_modifs_t *ifs = (struct vsfos_modifs_t *)module->ifs; VSFPOOL_FREE(&ifs->tcpip.socket_pool, socket); }
// vsfip buffer manager static struct vsfip_buffer_t* vsfos_vsfip_get_buffer(uint32_t size) { struct vsf_module_t *module = vsf_module_get("vsf.os"); struct vsfos_modifs_t *ifs = (struct vsfos_modifs_t *)module->ifs; return VSFPOOL_ALLOC(&ifs->tcpip.buffer_pool, struct vsfip_buffer_t); }
static void vsftimer_memop_free(struct vsftimer_t *timer) { struct vsf_module_t *module = vsf_module_get("vsf.os"); struct vsfos_modifs_t *ifs = (struct vsfos_modifs_t *)module->ifs; VSFPOOL_FREE(&ifs->vsftimer_pool, timer); }
static struct vsftimer_t* vsftimer_memop_alloc(void) { struct vsf_module_t *module = vsf_module_get("vsf.os"); struct vsfos_modifs_t *ifs = (struct vsfos_modifs_t *)module->ifs; return VSFPOOL_ALLOC(&ifs->vsftimer_pool, struct vsftimer_t); }
static void vsfos_vsfile_free_vfs(struct vsfile_vfsfile_t *vfsfile) { struct vsf_module_t *module = vsf_module_get("vsf.os"); struct vsfos_modifs_t *ifs = (struct vsfos_modifs_t *)module->ifs; VSFPOOL_FREE(&ifs->vfsfile_pool, vfsfile); }
// vsfile_memop struct vsfile_vfsfile_t* vsfos_vsfile_alloc_vfs(void) { struct vsf_module_t *module = vsf_module_get("vsf.os"); struct vsfos_modifs_t *ifs = (struct vsfos_modifs_t *)module->ifs; return VSFPOOL_ALLOC(&ifs->vfsfile_pool, struct vsfile_vfsfile_t); }