void create_init_process() { process *p = k_malloc(sizeof(process)); p->pid = process_id; p->ppid = process_id; process_id += 1; p->timer_val =0; p->state = TASK_INTERRUPTIBLE; p->memory = NULL; p->kernel_stack = k_malloc_stack(4095); clear_registers(p->reg); p->cr3 = create_process_page_table(); p->fdtable = k_malloc(sizeof(fd_obj)*50); p->maxfd=2; //0,1,2 are reserved for stdin,stdout, and stderr respectively. p->fdtable[0].fileptr=NULL; p->fdtable[0].file_offset=0; p->fdtable[0].flags=O_RDONLY; //std input is read only p->fdtable[0].filetype='S'; //standard i/o p->fdtable[1].fileptr=NULL; p->fdtable[1].file_offset=0; p->fdtable[1].flags=O_WRONLY; //std output is write only p->fdtable[1].filetype='S'; //standard i/o tarfs_init("bin/init_process",p); //tarfs_init("bin/sbush",p); create_STACK_memory(p->memory,U_STACK); memcpy("bin/init_process",p->p_name,50); //////print("Working === %x",p->kernel_stack); //////print("Process created with id = %d ",p->pid); // run_process(p); init_process = p; }
/*test cases*/ void test_mheap_malloc_free(void) { void *block[BLK_NUM_MAX], *block_fail; for (int i = 0; i < BLK_NUM_MAX; i++) { /** * TESTPOINT: This routine provides traditional malloc() * semantics. Memory is allocated from the heap memory pool. */ block[i] = k_malloc(i); /** TESTPOINT: Address of the allocated memory if successful;*/ zassert_not_null(block[i], NULL); } block_fail = k_malloc(BLK_SIZE_MIN); /** TESTPOINT: Return NULL if fail.*/ zassert_is_null(block_fail, NULL); for (int i = 0; i < BLK_NUM_MAX; i++) { /** * TESTPOINT: This routine provides traditional free() * semantics. The memory being returned must have been allocated * from the heap memory pool. */ k_free(block[i]); } /** TESTPOINT: If ptr is NULL, no operation is performed.*/ k_free(NULL); }
mm* create_mm_object(process* p) { void* addr = k_malloc(sizeof(mm)); mm* obj = addr; obj->self_memory = (uint64_t)addr; obj->vma_count = 0; obj->vma_map = NULL; obj->heap = U_HEAP; obj->cache = (uint64_t)k_malloc(PAGE_SIZE); return obj; }
/** * @brief Starts audio recording. * @param pbuf: Main buffer pointer for the recorded data storing * @param size: Current size of the recorded buffer * @note The Right channel is start at first with synchro on start of Left channel * @retval BSP AUDIO status */ uint8_t BSP_AUDIO_IN_Record(uint16_t* pbuf, uint32_t size) { hAudioIn.pRecBuf = pbuf; hAudioIn.RecSize = size; /* Allocate hAudioIn.LeftRecBuff buffer */ #if defined(BSP_AUDIO_USE_RTOS) hAudioIn.LeftRecBuff = (int32_t *)k_malloc(size * sizeof(int32_t)); #else hAudioIn.LeftRecBuff = (int32_t *)malloc(size * sizeof(int32_t)); #endif if(hAudioIn.LeftRecBuff == NULL) { return AUDIO_ERROR; } /* Call the Media layer start function for left channel */ if(HAL_DFSDM_FilterRegularStart_DMA(&BSP_AUDIO_hDfsdmLeftFilter, (int32_t*)hAudioIn.LeftRecBuff, (hAudioIn.RecSize/DEFAULT_AUDIO_IN_CHANNEL_NBR)) != HAL_OK) { return AUDIO_ERROR; } return AUDIO_OK; }
struct taskList *addToTailTaskList(struct taskList *list, struct pcb_t *new_pcb) { struct taskList *temp = (struct taskList *)k_malloc(sizeof(struct taskList)); struct taskList *start = list; //temp->task = new_pcb; //list->prev = temp; //temp->next = list; //temp->prev = NULL; temp->next = NULL; temp->task = new_pcb; if (list == NULL) { temp->prev = NULL; list = temp; start = list; } else { while (list->next) list = list->next; temp->prev = list; list->next = temp; } return start; }
process* create_child_process(process* parent){ void *addr = k_malloc(sizeof(process)); process* child = addr; child->self_memory = (uint64_t)addr; child->pid = get_process_id(); child->ppid = parent->pid; child->timer_val = 0; child->state = TASK_INTERRUPTIBLE; child->memory = NULL; child->pp = parent; child->p_cache = 0; child->kernel_stack = k_malloc_stack(4095); clear_registers(child->reg); child->cr3 = create_user_process_table(); child->memory = create_mm_object(child); copy_vma(parent,child); copy_fdtable(parent,child); //child->fdtable = parent->fdtable; child->maxfd = parent->maxfd; copy_memory(parent,child); set_COW_bits(child,parent); child->start_exec = parent->start_exec; copy_registers(child,parent); strcpy(parent->p_name,child->p_name); child->env_set =0; refresh_cr3(); return child; }
void copy_fdtable(process* parent,process* child){ int i; fd_obj *cfd=(fd_obj *)k_malloc(sizeof(fd_obj)*50); child->fdtable=cfd; fd_obj *pfd=parent->fdtable; for(i=0;i<50;i++,cfd++,pfd++){ *cfd=*pfd; } }
process* create_process_new(process* pp,char* bin_file,int create_fd) { void *addr = k_malloc(sizeof(process)); process *p = addr; p->pid = process_id; process_id += 1; p->ppid = pp->pid; p->timer_val =0; p->state = TASK_INTERRUPTIBLE; p->memory = NULL; p->self_memory = (uint64_t)addr; p->pp= pp; clear_registers(p->reg); p->cr3 = create_user_process_table(); tarfs_init(bin_file,p); create_STACK_memory(p->memory,U_STACK); p->kernel_stack = k_malloc_stack(4095); p->env_set = 0; if(create_fd == 1) { p->fdtable = k_malloc(sizeof(fd_obj)*50); p->maxfd=2; //0,1,2 are reserved for stdin,stdout, and stderr respectively. p->fdtable[0].fileptr=NULL; p->fdtable[0].file_offset=0; p->fdtable[0].flags=O_RDONLY; //std input is read only p->fdtable[0].filetype='S'; //standard i/o p->fdtable[1].fileptr=NULL; p->fdtable[1].file_offset=0; p->fdtable[1].flags=O_WRONLY; //std output is write only p->fdtable[1].filetype='S'; //standard i/o } // uint64_t* a = (uint64_t*)p->kernel_stack; // a[0] = 24; //////print("Working === %x",p->kernel_stack); //////print("Process created with id = %d ",p->pid); // run_process(p); // //print("strlen = %d",strlen(bin_file)); // //print("bin_file = %s",bin_file); int size = strlen(bin_file); size = size > 50 ? 49:size; memcpy(bin_file,p->p_name,size); // //print("file name = %s",p->p_name); add_to_readyQ(p); return p; }
struct taskList *addToHeadTaskList(struct taskList *list, struct pcb_t *new_pcb) { struct taskList *temp = (struct taskList *)k_malloc(sizeof(struct taskList)); temp->task = new_pcb; temp->next = list; temp->prev = NULL; if(list!=NULL) list->prev = temp; return temp; }
void copy_memory(process* parent, process* child){ mm* p_obj = parent->memory; mm* c_obj = child->memory; c_obj->stack = p_obj->stack; c_obj->heap = p_obj->heap; c_obj->vma_count = p_obj->vma_count; // enable_paging(child->cr3); c_obj->cache = (uint64_t)k_malloc(PAGE_SIZE); // enable_paging(parent->cr3); }
__export_function void* _k_key_derive_simple1024 ( const char* pass, void* salt, size_t salt_bytes, uint64_t iter) { k_hash_t* h = k_hash_init(HASHSUM_SKEIN_1024, 1024); if (!h) return 0; size_t sp = strlen(pass); size_t digestbytes = k_hash_digest_bytes(h); void* inp = k_malloc(sp+digestbytes); if (!inp) { k_hash_finish(h); return 0; } void* outp = k_malloc(digestbytes); if (!outp) { k_free(inp); k_hash_finish(h); return 0; } memcpy(inp, pass, sp); memcpy(inp+sp, salt, salt_bytes); k_hash_update(h, inp, sp+digestbytes); k_hash_final(h, outp); k_free(inp); for (uint64_t i = 0; i < iter; ++i) { k_hash_reset(h); k_hash_update(h, outp, digestbytes); k_hash_final(h, outp); } k_hash_finish(h); return outp; }
// This function creates the PCB for each new process created PCB *create_pcb() { PCB *pro = NULL; pro = (PCB *) k_malloc(sizeof(PCB)); if (pro == NULL) { printf("\n Can't Allocate Memory for PCB"); return (PCB *) 0; } allTaskQ = addToTailTaskList(allTaskQ, pro); no_allQ++; return pro; }
vma* create_dup_vma(vma* vma_obj){ void *addr = k_malloc(sizeof(vma)); vma* obj = addr; obj->start_user = vma_obj->start_user; obj->start_kernel = vma_obj->start_kernel; obj->file_size = vma_obj->file_size; obj->mem_size = vma_obj->mem_size; obj->self_memory = (uint64_t)addr; obj->permission = vma_obj->permission; obj->next = NULL; obj->mem_allocated = vma_obj->mem_allocated; obj->file_backed = vma_obj->file_backed; obj->phys_addr = vma_obj->phys_addr; obj->is_stack_mem = vma_obj->is_stack_mem; return obj; }
// This code creates the VMA for each segments of the elf binary VMA *create_vma(uint64_t start_add, uint64_t size) { VMA *vm = NULL; vm = k_malloc(sizeof(VMA)); if (vm == NULL) { //exit(); printf("\n Cant allocalte memory for VMA exit now"); } vm->vma_start_add = start_add; vm->vma_end_add = (start_add + size); vm->vma_next = NULL; return vm; }
//void doExec(char* filename, char* argv, char *en[]) void doExec(char *fn) { PCB *pro; pro = running; char *filename; filename = (char*)(k_malloc((sizeof(char)*32))); strcpy(filename, fn); //printf("We will execute - %s %s\n", filename, fn); // delete all page table entries deletePageTables(); _ptcr3(pro->cr3); //printf("In Exec :: check PID=%p, cr3=%p ppid=%p\n", pro->pid, pro->cr3, pro->ppid); //char *filename2; //filename2 = filename; //read_tarfs(pro, "bin/world"); read_tarfs(pro, filename); printf("We will execute - %s\n", filename); if ((pro->u_stack = process_stack()) == NULL) { printf("\n Cant allocate memory for process User stack"); //exit(); } strcpy(pro->name, filename); pro->start_time = sec; //pro->u_stack[0] = pro->rip; pro->rsp = (uint64_t)(pro->u_stack); printf("user_stack_rsp%p",pro->rsp); tss.rsp0 = (uint64_t) &(pro->kernel_stack[255]); printf("In Execve() GDT SET\n"); __asm volatile("\ push $0x23;\ push %0;\ push $0x200;\ push $0x1B;\ push %1"::"g"(pro->u_stack),"g"(pro->rip):"memory"); __asm volatile("\ iretq;\ "); }
vma* create_vma_object(uint64_t start_user,uint64_t start_kernel,int64_t msize, int64_t fsize,int perm,int file_backed,int is_stack) { void* addr = k_malloc(sizeof(vma)); vma* obj = addr; obj->self_memory = (uint64_t)addr; obj->start_user = start_user; obj->start_kernel = start_kernel; obj->file_size = fsize; obj->mem_size = msize; obj->permission = perm; obj->next = NULL; obj->mem_allocated = 0; obj->file_backed = file_backed; obj->phys_addr = 0; obj->is_stack_mem = is_stack; // ////print("Created vma for address = %x and %x",start_user,start_kernel); return obj; }
static bool fdexpand() { /* allocate first */ if(fdt.fdarray == NULL) { fdt.fdarray = k_malloc(sizeof(ptr_t) * FD_ALLOCATE_BATCH); fdt.fdlen = FD_ALLOCATE_BATCH; return true; } /* reallocate if already allocated */ fdt.fdarray = k_realloc(fdt.fdarray, sizeof(ptr_t) * (fdt.fdlen + FD_ALLOCATE_BATCH)); if(fdt.fdarray == NULL) return false; fdt.fdlen += FD_ALLOCATE_BATCH; return true; }
bool k_vfs_mknode(const char *path, const node_t *node, uint32_t flags) { fsnode_t *fsNode, *dstNode; char fullName[FILE_FULL_PATH] = { '\0' }; if(!k_strlen(path) || !k_strlen(node->name)) return false; fsNode = k_malloc(sizeof(fsnode_t)); if(!fsNode) goto failed_exit; k_memset(fsNode, 0, sizeof(fsnode_t)); tree_link_init(&fsNode->link); list_init(&fsNode->openFiles); fsNode->node = *node; fsNode->flags = flags; if((dstNode = k_vfs_find_node_by_full_path(path)) == NULL) goto failed; /* it mast a directory */ if(!(dstNode->flags & FILE_IS_FOLDER)) goto failed; /* check if file already exist */ k_strncat(fullName, path, FILE_FULL_PATH); if(path[k_strlen(path)-1] != '/') k_strncat(fullName, "/", FILE_FULL_PATH); k_strncat(fullName, node->name, FILE_FULL_PATH); if(k_vfs_path_is_exist(fullName)) goto failed; /* add to vfs tree */ tree_add_link(&dstNode->link, &fsNode->link); return true; failed: k_free(fsNode); failed_exit: return false; }
uint32_t k_fopen(const char *path, uint32_t mode) { file_t *file = NULL; file = k_malloc(sizeof(file_t)); k_memset(file, 0, sizeof(file_t)); if(!file) return 0; if(mode & FILE_OPEN_IN_VFS) { /* get file desc in vfs */ if(!k_vfs_open_file(file, path, mode)) goto failed; } if(!file->open) goto failed; if(!file->open(path, mode, file)) goto failed; file->flags = mode; /* check next file descriptor is present */ /* if not - fd array is full, and relocation failed */ if(!fdcheck()) goto failed; /* setup next file descriptor */ fdt.fdarray[fdt.fdcounter] = file; file->fd = fdt.fdcounter; return fdt.fdcounter; failed: k_free(file); return 0; }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to a data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem, hClient; int NCode; int Id, Index, newpos; GUI_RECT r; int ItemNbr; int result; static char tmp[FILEMGR_FILE_NAME_SIZE]; switch (pMsg->MsgId) { case WM_INIT_DIALOG: pVideoList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef)); pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO)); pVideoList->ptr = 0; PlayerSettings.d32 = k_BkupRestoreParameter(CALIBRATION_VIDEOPLAYER_SETTING_BKP); /* Initialization of 'Listview' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); LISTVIEW_AddColumn(hItem, 165, "Video", GUI_TA_VCENTER | GUI_TA_LEFT); LISTVIEW_SetGridVis(hItem, 0); LISTVIEW_SetAutoScrollV(hItem, 1); LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, GUI_BLACK); LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, GUI_CYAN); hItem = BUTTON_CreateEx( 240, 202, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_STOP_BUTTON); WM_SetCallback(hItem, _cbButton_stop); hItem = BUTTON_CreateEx(92, 202, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON); WM_SetCallback(hItem, _cbButton_previous); hItem = BUTTON_CreateEx(137, 195, 50, 45, pMsg->hWin, WM_CF_SHOW, 0, ID_PLAY_BUTTON); WM_SetCallback(hItem, _cbButton_play); hItem = BUTTON_CreateEx(195, 202, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON); WM_SetCallback(hItem, _cbButton_next); hItem = BUTTON_CreateEx(47, 205, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_BUTTON); WM_SetCallback(hItem, _cbButton_repeat); hItem = BUTTON_CreateEx(315, 205, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_OPEN_BUTTON); WM_SetCallback(hItem, _cbButton_open); hItem = BUTTON_CreateEx(375, 205, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON); WM_SetCallback(hItem, _cbButton_add); hItem = BUTTON_CreateEx(440, 202, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON); WM_SetCallback(hItem, _cbButton_close); hItem = BUTTON_CreateEx(281, 172, 25, 25, pMsg->hWin, WM_CF_SHOW, 0, ID_FULL_SCREEN_BUTTON); WM_SetCallback(hItem, _cbButton_fullscreen); hClient = WM_GetClientWindow(pMsg->hWin); WM_GetClientRectEx(hClient, &r); hFrame = WM_CreateWindowAsChild(r.x0 + 5, r.y0 + 5, r.x1 - 179, r.y1 - 75, hClient, WM_CF_SHOW, _cbVideoWindow , 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGRESS_SLIDER); SLIDER_SetNumTicks(hItem, 25); hItem = WM_CreateWindowAsChild(05, 163, 275, 20, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND, _cbDrawProgressSlider, 0); WM_CreateWindowAsChild(479, 250, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); break; case WM_PAINT: DrawRect3D(05, 193, 300, 50); DrawRect3D(310, 193, 165, 50); break; case WM_TIMER: Id = WM_GetTimerId(pMsg->Data.v); if (Id == ID_PLAYLIST_TIMER) { playlist_select = 0; } break; case WM_DELETE: k_BkupSaveParameter(CALIBRATION_VIDEOPLAYER_SETTING_BKP, PlayerSettings.d32); WM_DeleteTimer(hPlaylistTimer); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { /* Notification sent by "Close Button" */ case ID_FULL_SCREEN_BUTTON: switch (NCode) { case WM_NOTIFICATION_RELEASED: if( VideoPlayer_State != VIDEO_IDLE) { _ShowFullScreen(); } break; } break; /* Notifications sent by 'Add' Button */ case ID_ADD_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_video; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add video file to playlist", 0, pFileInfo); if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Pause(hMovie); } WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".emf")) || (strstr(pFileInfo->pRoot, ".EMF"))) { if(pVideoList->ptr < FILEMGR_LIST_DEPDTH) { strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly ((char *)tmp, (char *)pFileInfo->pRoot); hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pVideoList->ptr, tmp); pVideoList->ptr++; } } WM_InvalidateWindow(hFrame); } if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Play(hMovie); } break; } break; /* Notifications sent by 'Open' Button */ case ID_OPEN_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_dir; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add a folder", 0, pFileInfo); if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Pause(hMovie); } WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { _AddEntireFolder(pFileInfo->pRoot); WM_InvalidateWindow(hFrame); } if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Play(hMovie); } break; } break; /* Notification sent by "Full Screen button" */ case ID_CLOSE_BUTTON: switch (NCode) { case WM_NOTIFICATION_RELEASED: k_free(pVideoList); k_free(pFileInfo); _StopPlay(); GUI_EndDialog(pMsg->hWin, 0); break; } break; /* Notification sent by "Play Button" */ case ID_PLAY_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: if(VideoPlayer_State == VIDEO_IDLE) { if (pVideoList->ptr > 0) { _StartPlay((char *)pVideoList->file[file_pos].name); LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos); } else { pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_video; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Open a video file", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".emf")) || (strstr(pFileInfo->pRoot, ".EMF"))) { pVideoList->ptr = 0; strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot); hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); /* Update Play list */ strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot); ItemNbr = LISTVIEW_GetNumRows(hItem); while(ItemNbr--) { LISTVIEW_DeleteRow(hItem, ItemNbr); } LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pVideoList->ptr, tmp); pVideoList->ptr++; file_pos = 0; LISTVIEW_SetSel(hItem, 0); _StartPlay((char *)pVideoList->file[file_pos].name); WM_InvalidateWindow(hFrame); } } } } else if(VideoPlayer_State == VIDEO_PLAY) { _PausePlay(); } else if(VideoPlayer_State == VIDEO_PAUSE) { _ResumePlay(); } break; } break; case ID_REPEAT_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_BUTTON); if(PlayerSettings.b.repeat == REPEAT_NONE) { PlayerSettings.b.repeat = REPEAT_ONCE; } else if(PlayerSettings.b.repeat == REPEAT_ONCE) { PlayerSettings.b.repeat = REPEAT_ALL; } else if(PlayerSettings.b.repeat == REPEAT_ALL) { PlayerSettings.b.repeat = REPEAT_NONE; } } break; case ID_STOP_BUTTON: _StopPlay(); hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_PROGRESS_SLIDER); SLIDER_SetValue(hItem, 0); WM_InvalidateWindow(hFrame); break; case ID_NEXT_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: if(file_pos < (pVideoList->ptr - 1)) { /* Play Next */ file_pos++; LISTVIEW_IncSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST)); } else if(PlayerSettings.b.repeat == REPEAT_ALL) { file_pos = 0; LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos); } if(VideoPlayer_State == VIDEO_PLAY) { _StopPlay(); _StartPlay((char *)pVideoList->file[file_pos].name); WM_InvalidateWindow(hFrame); } break; } break; case ID_PREVIOUS_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: if( pVideoList->ptr > 0) { if(file_pos > 0) { file_pos--; LISTVIEW_DecSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST)); } else if(PlayerSettings.b.repeat == REPEAT_ALL) { file_pos = (pVideoList->ptr - 1); LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos); } if(VideoPlayer_State == VIDEO_PLAY) { _StopPlay(); _StartPlay((char *)pVideoList->file[file_pos].name); WM_InvalidateWindow(hFrame); } } break; } break; /* Notifications sent by 'progress' Slider */ case ID_PROGRESS_SLIDER: if(NCode == WM_NOTIFICATION_CLICKED) { if(VideoPlayer_State != VIDEO_IDLE) { GUI_MOVIE_Pause(hMovie); hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGRESS_SLIDER); newpos = (SLIDER_GetValue(hItem) * Video_Info.NumFrames)/100; GUI_MOVIE_GotoFrame(hMovie, newpos); if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Play(hMovie); } } } break; /* Notifications sent by 'ListView' Slider */ case ID_VIDEO_LIST: if(NCode == WM_NOTIFICATION_CLICKED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); Index = LISTVIEW_GetSel(hItem); if(Index < pVideoList->ptr) { file_pos = Index; if(playlist_select == 0) { hPlaylistTimer = WM_CreateTimer(pMsg->hWin, ID_PLAYLIST_TIMER, 500, 0); playlist_select = (Index + 1); } else if(playlist_select == (Index + 1)) { WM_DeleteTimer(hPlaylistTimer); hPlaylistTimer = 0; playlist_select = 0; if(Index < pVideoList->ptr) { if(VideoPlayer_State != VIDEO_IDLE) { _StopPlay(); } _StartPlay((char *)pVideoList->file[Index].name); hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); WM_InvalidateWindow(hFrame); } } } } break; } break; default: WM_DefaultProc(pMsg); break; } }
static int dw_dma_config(struct device *dev, u32_t channel, struct dma_config *cfg) { struct dw_dma_dev_data *const dev_data = DEV_DATA(dev); struct dma_chan_data *chan_data; struct dma_block_config *cfg_blocks; u32_t cnt; u32_t m_size; u32_t tr_width; struct dw_lli2 *lli_desc; struct dw_lli2 *lli_desc_tail; if (channel >= DW_MAX_CHAN) { return -EINVAL; } __ASSERT_NO_MSG(cfg->source_data_size == cfg->dest_data_size); __ASSERT_NO_MSG(cfg->source_burst_length == cfg->dest_burst_length); if (cfg->source_data_size != BYTE && cfg->source_data_size != WORD && cfg->source_data_size != DWORD) { SYS_LOG_ERR("Invalid 'source_data_size' value"); return -EINVAL; } chan_data = &dev_data->chan[channel]; /* default channel config */ chan_data->direction = cfg->channel_direction; chan_data->cfg_lo = DW_CFG_LOW_DEF; chan_data->cfg_hi = DW_CFG_LOW_DEF; /* data_size = (2 ^ tr_width) */ tr_width = find_msb_set(cfg->source_data_size) - 1; SYS_LOG_DBG("tr_width=%d", tr_width); /* burst_size = (2 ^ msize) */ m_size = find_msb_set(cfg->source_burst_length) - 1; SYS_LOG_DBG("m_size=%d", m_size); cfg_blocks = cfg->head_block; /* Allocate space for the linked list */ chan_data->lli = (struct dw_lli2 *)k_malloc(sizeof(struct dw_lli2) * (cfg->block_count)); if (chan_data->lli == NULL) { SYS_LOG_ERR("not enough memory\n"); return -ENOMEM; } (void)memset(chan_data->lli, 0, (sizeof(struct dw_lli2) * cfg->block_count)); lli_desc = chan_data->lli; lli_desc_tail = lli_desc + cfg->block_count - 1; /* initialize descriptors */ cnt = cfg->block_count; do { lli_desc->ctrl_lo |= DW_CTLL_SRC_WIDTH(tr_width); lli_desc->ctrl_lo |= DW_CTLL_DST_WIDTH(tr_width); lli_desc->ctrl_lo |= DW_CTLL_SRC_MSIZE(m_size); lli_desc->ctrl_lo |= DW_CTLL_DST_MSIZE(m_size); /* enable interrupt */ lli_desc->ctrl_lo |= DW_CTLL_INT_EN; switch (cfg->channel_direction) { case MEMORY_TO_MEMORY: lli_desc->ctrl_lo |= DW_CTLL_FC_M2M; lli_desc->ctrl_lo |= DW_CTLL_SRC_INC | DW_CTLL_DST_INC; break; case MEMORY_TO_PERIPHERAL: lli_desc->ctrl_lo |= DW_CTLL_FC_M2P; lli_desc->ctrl_lo |= DW_CTLL_SRC_INC | DW_CTLL_DST_FIX; /* Assign a hardware handshaking interface (0-15) to the * destination of channel */ chan_data->cfg_hi |= DW_CFGH_DST_PER(cfg->dma_slot); break; case PERIPHERAL_TO_MEMORY: lli_desc->ctrl_lo |= DW_CTLL_FC_P2M; lli_desc->ctrl_lo |= DW_CTLL_SRC_FIX | DW_CTLL_DST_INC; /* Assign a hardware handshaking interface (0-15) to the * source of channel */ chan_data->cfg_hi |= DW_CFGH_SRC_PER(cfg->dma_slot); break; default: SYS_LOG_ERR("channel_direction %d is not supported", cfg->channel_direction); return -EINVAL; } lli_desc->sar = cfg_blocks->source_address; lli_desc->dar = cfg_blocks->dest_address; /* Block size */ lli_desc->ctrl_hi = DW_CFG_CLASS( dev_data->channel_data->chan[channel].class) | cfg_blocks->block_size; /* set next descriptor in list */ lli_desc->llp = (u32_t)(lli_desc + 1); lli_desc->ctrl_lo |= DW_CTLL_LLP_S_EN | DW_CTLL_LLP_D_EN; /* next descriptor */ lli_desc++; cfg_blocks = cfg_blocks->next_block; cnt--; } while (cfg_blocks && cnt); /* check if application requests circular list */ if (cfg_blocks) { /* * if the last block was pointing to another block, then * it means the application is requesting a circular list */ lli_desc_tail->llp = (u32_t)chan_data->lli; } else { lli_desc_tail->llp = 0x0; lli_desc_tail->ctrl_lo &= ~(DW_CTLL_LLP_S_EN | DW_CTLL_LLP_D_EN); } #ifdef CONFIG_DCACHE_WRITEBACK /* Flush the cache so that the descriptors are written to the memory. * If this is not done, DMA engine will read the old stale data at * that location and hence the DMA operation will not succeed. */ dcache_writeback_region(chan_data->lli, sizeof(struct dw_lli2) * cfg->block_count); #endif /* Configure a callback appropriately depending on whether the * interrupt is requested at the end of transaction completion or * at the end of each block. */ if (cfg->complete_callback_en) { chan_data->dma_blkcallback = cfg->dma_callback; } else { chan_data->dma_tfrcallback = cfg->dma_callback; } return 0; }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; GUI_RECT r; int result; int Id, NCode, Index; char tmp[FILEMGR_FILE_NAME_SIZE]; switch (pMsg->MsgId) { case WM_INIT_DIALOG: pImageList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef)); pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO)); pImageList->ptr = 0; file_pos = 0; effects = 0; ImSettings.d32 = k_BkupRestoreParameter(CALIBRATION_IMAGE_SETTINGS_BKP); if(ImSettings.b.ss_timer == 0) { ImSettings.b.ss_timer = 1; } /* Image frame initialization */ IMAGE_Enlarge = 0; hItem = WM_GetClientWindow(pMsg->hWin); WM_GetClientRectEx(hItem, &r); imFrame = WM_CreateWindowAsChild(r.x0 + 6, r.y0 + 6, r.x1 - 98, r.y1 - 78, hItem, WM_CF_SHOW, _cbImageWindow, 0); /* Buttons initialization */ hItem = BUTTON_CreateEx(47, 155, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON); WM_SetCallback(hItem, _cbButton_previous); hItem = BUTTON_CreateEx(94, 148, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_SLIDE_BUTTON); WM_SetCallback(hItem, _cbButton_play); slideshow_state = OFF; hItem = BUTTON_CreateEx(154, 155, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON); WM_SetCallback(hItem, _cbButton_next); hItem = BUTTON_CreateEx(242, 145, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON); WM_SetCallback(hItem, _cbButton_add); hItem = BUTTON_CreateEx(242, 175, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_OPEN_BUTTON); WM_SetCallback(hItem, _cbButton_open); hItem = BUTTON_CreateEx(196, 174, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_SETTINGS_BUTTON); WM_SetCallback(hItem, _cbButton_settings); hItem = BUTTON_CreateEx(10, 174, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON); WM_SetCallback(hItem, _cbButton_close); hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LIST); LISTBOX_SetBkColor(hItem, LISTBOX_CI_SEL, GUI_BLUE); LISTBOX_SetTextColor(hItem, LISTBOX_CI_SEL, GUI_WHITE); LISTBOX_SetBkColor(hItem, LISTBOX_CI_UNSEL, GUI_BLACK); LISTBOX_SetTextColor(hItem, LISTBOX_CI_UNSEL, GUI_CYAN); LISTBOX_SetAutoScrollV(hItem, 1); break; case WM_TIMER: playlist_select = 0; break; case WM_PAINT: DrawRect3D(5, 140, 222, 67); DrawRect3D(230, 140, 83, 67); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (Id) { /* Notification sent by "Button_Settings" */ case ID_SETTINGS_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: GUI_CreateDialogBox(_aSettingsDialogCreate, GUI_COUNTOF(_aSettingsDialogCreate), _cbSettingsDialog, IMAGE_hWin, 0, 0); break; } break; /* Notifications sent by 'ListView' Slider */ case ID_IMAGE_LIST: if(NCode == WM_NOTIFICATION_CLICKED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LIST); Index = LISTBOX_GetSel(hItem); if(Index < pImageList->ptr) { if(playlist_select == 0) { hPlaylistTimer = WM_CreateTimer(pMsg->hWin, ID_PLAYLIST_TIMER, 500, 0); playlist_select = (Index + 1); } else if(playlist_select == (Index + 1)) { WM_DeleteTimer(hPlaylistTimer); hPlaylistTimer = 0; playlist_select = 0; if(Index < pImageList->ptr) { file_pos = Index; if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } f_close(&Image_File); f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); } } } } break; /* Notification sent by "Button_Close" */ case ID_CLOSE_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: f_close(&Image_File); k_free(pImageList); k_free(pFileInfo); GUI_EndDialog(pMsg->hWin, 0); break; } break; /* Notification sent by "Button_Open" */ case ID_OPEN_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_dir; hItem = CHOOSEFILE_Create(pMsg->hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "add a folder", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if(pImageList->ptr == 0) { _AddEntireFolder(pFileInfo->pRoot); file_pos = 0; if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } f_open(&Image_File, (char *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); } else { _AddEntireFolder(pFileInfo->pRoot); } } break; } break; /* Notification sent by "Button_Open" */ case ID_ADD_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_img; hItem = CHOOSEFILE_Create(pMsg->hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "Add an image to playlist", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".jpg")) || (strstr(pFileInfo->pRoot, ".bmp")) || (strstr(pFileInfo->pRoot, ".JPG")) || (strstr(pFileInfo->pRoot, ".BMP"))) { strcpy((char *)pImageList->file[pImageList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly(tmp, (char *)pFileInfo->pRoot); hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST); LISTBOX_AddString(hItem, tmp); LISTBOX_SetSel(hItem, pImageList->ptr); pImageList->ptr++; file_pos = pImageList->ptr - 1; f_close(&Image_File); if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } f_open(&Image_File, (char *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); } } break; } break; /* Notification sent by "Button_SlideShow" */ case ID_SLIDE_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: if(pImageList->ptr > 1) { f_close(&Image_File); f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } WM_InvalidateWindow(imFrame); if (slideshow_state == OFF) { hTimerTime = WM_CreateTimer(imFrame, ID_SLIDER_TIMER, (ImSettings.b.ss_timer * 1000) , 0); } else if(hTimerTime != 0) { WM_DeleteTimer(hTimerTime); hTimerTime = 0; } slideshow_state = (slideshow_state == OFF ? ON : OFF); } break; } break; /* Notification sent by "Button_Next" */ case ID_NEXT_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: if(pImageList->ptr > 0) { if (file_pos < (pImageList->ptr - 1)) { file_pos++; f_close(&Image_File); } else { file_pos = 0; f_close(&Image_File); } if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST); LISTBOX_SetSel(hItem, file_pos); } break; } break; /* Notification sent by "Button_Previous" */ case ID_PREVIOUS_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: if(pImageList->ptr > 0) { if (file_pos > 0 ) { file_pos--; f_close(&Image_File); } else { file_pos = (pImageList->ptr - 1); f_close(&Image_File); } if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST); LISTBOX_SetSel(hItem, file_pos); } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id, ItemNbr; int result; int duration, volume, index; static char tmp[FILEMGR_FILE_NAME_SIZE]; switch (pMsg->MsgId) { case WM_INIT_DIALOG: pWavList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef)); pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO)); pWavList->ptr = 0; /* Initialization of 'Listview' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST); LISTVIEW_AddColumn(hItem, 132, "Track", GUI_TA_VCENTER | GUI_TA_LEFT); LISTVIEW_AddColumn(hItem, 55, "Duration", GUI_TA_VCENTER | GUI_TA_RIGHT); LISTVIEW_SetGridVis(hItem, 0); LISTVIEW_SetAutoScrollV(hItem, 1); LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, GUI_BLACK); LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, GUI_CYAN); /* Title Initialization in play list */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE_CAPTION); TEXT_SetText(hItem, "TITLE:"); TEXT_SetTextColor(hItem, GUI_CYAN); /* Title Initialization in play list */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE); TEXT_SetTextColor(hItem, GUI_CYAN); /* Duration */ hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME); TEXT_SetText(hItem, "00:00"); TEXT_SetFont(hItem, GUI_FONT_20B_1); TEXT_SetTextColor(hItem, GUI_LIGHTGRAY); /* Author initialization */ hItem = WM_GetDialogItem(pMsg->hWin, ID_AUTHOR_CAPTION); TEXT_SetText(hItem, "AUTHOR:"); TEXT_SetTextColor(hItem, GUI_CYAN); /* Author */ hItem = WM_GetDialogItem(pMsg->hWin, ID_AUTHOR); TEXT_SetText(hItem, ""); TEXT_SetTextColor(hItem, GUI_CYAN); /* Sampling Rate */ hItem = WM_GetDialogItem(pMsg->hWin, ID_SAMPLING_CAPTION); TEXT_SetText(hItem, "SAMPLING:"); TEXT_SetTextColor(hItem, GUI_CYAN); /* Sampling Rate Value */ hItem = WM_GetDialogItem(pMsg->hWin, ID_SAMPLING_VALUE); TEXT_SetText(hItem, ""); TEXT_SetTextColor(hItem, GUI_CYAN); /* Duration */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TOTAL_TIME); TEXT_SetText(hItem, "00:00"); TEXT_SetTextColor(hItem, GUI_CYAN); /* Initialization of 'WAV' Button */ hItem = WM_GetDialogItem(pMsg->hWin, ID_WAV_BUTTON); BUTTON_SetFont(hItem, GUI_FONT_24_1); /* Initialization of 'Play List' Button */ hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_LIST_BUTTON); BUTTON_SetFont(hItem, GUI_FONT_24_1); /* Initialization of 'Add' Button */ hItem = WM_GetDialogItem(pMsg->hWin, ID_ADD_BUTTON); BUTTON_SetFont(hItem, GUI_FONT_24_1); volume = AUDIOPLAYER_GetVolume(); hItem = WM_GetDialogItem(pMsg->hWin, ID_VOLUME_SLIDER); SLIDER_SetValue(hItem, volume); hItem = WM_GetDialogItem(pMsg->hWin, ID_DURATION_SLIDER); SLIDER_SetNumTicks(hItem, 25); PlayerSettings.d32 = k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_SETTING_BKP); PlayerSettings.b.mute = MUTE_OFF; PlayerSettings.b.pause = PLAY_ACTIVE; hItem = BUTTON_CreateEx(25, 100, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_BUTTON); WM_SetCallback(hItem, _cbButton_repeat); hItem = BUTTON_CreateEx(100, 95, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_MUTE_BUTTON); WM_SetCallback(hItem, _cbButton_speaker); hItem = BUTTON_CreateEx(22, 147, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_STOP_BUTTON); WM_SetCallback(hItem, _cbButton_stop); hItem = BUTTON_CreateEx(89, 147, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON); WM_SetCallback(hItem, _cbButton_previous); hItem = BUTTON_CreateEx(148, 140, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_PLAY_BUTTON); WM_SetCallback(hItem, _cbButton_play); hItem = BUTTON_CreateEx(222, 147, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON); WM_SetCallback(hItem, _cbButton_next); hItem = WM_GetClientWindow(pMsg->hWin); hItem = BUTTON_CreateEx(20, 205, 50, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_WAV_BUTTON); WM_SetCallback(hItem, _cbButton_open); hItem = BUTTON_CreateEx(80, 205, 50, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON); WM_SetCallback(hItem, _cbButton_add); hItem = BUTTON_CreateEx(235, 205, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON); WM_SetCallback(hItem, _cbButton_close); hTimerWin = WM_CreateWindowAsChild(0, 100, 10, 10, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbAudioProcess, 0); hItem = WM_CreateWindowAsChild(15, 75, 255, 20, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND, _cbDrawProgressSlider, 0); hItem = WM_CreateWindowAsChild(145, 105, 125, 20, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND, _cbDrawVolumeSlider, 0); WM_CreateWindowAsChild(479, 250, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); break; case WM_PAINT: GUI_SetBkColor(GUI_BLACK); GUI_ClearRect(15, 6, 270, 70); DrawRect3D(15, 135, 255, 60); DrawRect3D(15, 200, 255, 40); break; case WM_DELETE: AUDIOPLAYER_DeInit(); k_free(pWavList); k_free(pFileInfo); pWavList->ptr = 0; PlayerSettings.b.mute = MUTE_OFF; PlayerSettings.b.pause = PLAY_ACTIVE; k_BkupSaveParameter(CALIBRATION_AUDIOPLAYER_SETTING_BKP, PlayerSettings.d32); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { /* Notification sent by "Button_Close" */ case ID_CLOSE_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: GUI_EndDialog(pMsg->hWin, 0); break; } break; /* Notifications sent by 'Repeat' Button */ case ID_REPEAT_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_BUTTON); if(PlayerSettings.b.repeat == REPEAT_NONE) { PlayerSettings.b.repeat = REPEAT_ONCE; } else if(PlayerSettings.b.repeat == REPEAT_ONCE) { PlayerSettings.b.repeat = REPEAT_ALL; } else if(PlayerSettings.b.repeat == REPEAT_ALL) { PlayerSettings.b.repeat = REPEAT_NONE; } } break; /* Notifications sent by 'Mute' Button */ case ID_MUTE_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_MUTE_BUTTON); if(PlayerSettings.b.mute == MUTE_OFF) { AUDIOPLAYER_Mute(MUTE_ON); PlayerSettings.b.mute = MUTE_ON; } else { AUDIOPLAYER_Mute(MUTE_OFF); PlayerSettings.b.mute = MUTE_OFF; } } break; /* Notifications sent by 'Volume' Slider */ case ID_VOLUME_SLIDER: if(NCode == WM_NOTIFICATION_VALUE_CHANGED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_VOLUME_SLIDER); AUDIOPLAYER_SetVolume(SLIDER_GetValue(hItem)); if(PlayerSettings.b.mute == MUTE_ON) { AUDIOPLAYER_Mute(MUTE_OFF); PlayerSettings.b.mute = MUTE_OFF; } } break; /* Notifications sent by 'progress' Slider */ case ID_DURATION_SLIDER: if(NCode == WM_NOTIFICATION_CLICKED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_DURATION_SLIDER); AUDIOPLAYER_SetPosition(SLIDER_GetValue(hItem)); if(PlayerSettings.b.mute == MUTE_ON) { AUDIOPLAYER_Mute(MUTE_ON); } } break; /* Notifications sent by 'ListView' Slider */ case ID_WAVFILE_LIST: if(NCode == WM_NOTIFICATION_CLICKED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST); index = LISTVIEW_GetSel(hItem); if(index < pWavList->ptr) { if(playlist_select == 0) { hPlaylistTimer = WM_CreateTimer(hTimerWin, ID_PLAYLIST_TIMER, 500, 0); playlist_select = (index + 1); } else if(playlist_select == (index + 1)) { WM_DeleteTimer(hPlaylistTimer); hPlaylistTimer = 0; playlist_select = 0; if(index < pWavList->ptr) { if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { AUDIOPLAYER_Stop(); } PlayerSettings.b.pause = PLAY_ACTIVE; hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); file_pos = index; _PlayFile((char *)pWavList->file[index].name); } } } } break; /* Notifications sent by 'Play' Button */ case ID_PLAY_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { if(AUDIOPLAYER_GetState() == AUDIOPLAYER_STOP) { if(pWavList->ptr > 0) { _PlayFile((char *)pWavList->file[file_pos].name); LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos); } else { pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_audio; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Open an audio file", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".wav")) || (strstr(pFileInfo->pRoot, ".WAV"))) { if(AUDIOPLAYER_GetFileInfo(pFileInfo->pRoot, &WavInfo) == 0) { if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { /* Stop current audio sample */ AUDIOPLAYER_Stop(); } pWavList->ptr = 0; file_pos = 0; strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot); hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST); /* Update Play list */ strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot); ItemNbr = LISTVIEW_GetNumRows(hItem); while(ItemNbr--) { LISTVIEW_DeleteRow(hItem, ItemNbr); } LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp); duration = WavInfo.FileSize / WavInfo.ByteRate; sprintf((char *)tmp , "%02d:%02d", duration/60, duration%60 ); LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp); pWavList->ptr++; LISTVIEW_SetSel(hItem, 0); _PlayFile(pFileInfo->pRoot); } } } } } else if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { PlayerSettings.b.pause = (PlayerSettings.b.pause == PLAY_ACTIVE ? PAUSE_ACTIVE : PLAY_ACTIVE); if(PlayerSettings.b.pause == PAUSE_ACTIVE) { AUDIOPLAYER_Pause(); } else if(PlayerSettings.b.pause == PLAY_ACTIVE) { AUDIOPLAYER_Resume(); } } } break; /* Notifications sent by 'STOP' Button */ case ID_STOP_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { if(PlayerSettings.b.pause == PAUSE_ACTIVE) { PlayerSettings.b.pause = PLAY_ACTIVE; } AUDIOPLAYER_Stop(); hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME); TEXT_SetText(hItem, "00:00"); hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); } } break; /* Notifications sent by 'Next' Button */ case ID_NEXT_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { if( pWavList->ptr > 0) { if(file_pos < (pWavList->ptr - 1)) { file_pos++; } else if(PlayerSettings.b.repeat == REPEAT_ALL) { file_pos = 0; } LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos); if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { if(PlayerSettings.b.pause == PAUSE_ACTIVE) { PlayerSettings.b.pause = PLAY_ACTIVE; hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); } AUDIOPLAYER_Stop(); _PlayFile((char *)pWavList->file[file_pos].name); } } } break; /* Notifications sent by 'Previous' Button */ case ID_PREVIOUS_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { if( pWavList->ptr > 0) { if(file_pos > 0) { file_pos--; } else if(PlayerSettings.b.repeat == REPEAT_ALL) { file_pos = (pWavList->ptr - 1); } LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos); if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { if(PlayerSettings.b.pause == PAUSE_ACTIVE) { PlayerSettings.b.pause = PLAY_ACTIVE; hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); } AUDIOPLAYER_Stop(); _PlayFile((char *)pWavList->file[file_pos].name); } } } break; /* Notifications sent by 'Open' Button */ case ID_WAV_BUTTON: switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_dir; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add a folder", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { _AddEntireFolder(pFileInfo->pRoot); } break; } break; /* Notifications sent by 'Add' Button */ case ID_ADD_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_audio; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add to playlist", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".wav")) || (strstr(pFileInfo->pRoot, ".WAV"))) { if(pWavList->ptr < FILEMGR_LIST_DEPDTH) { strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot); hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST); if(AUDIOPLAYER_GetFileInfo(pFileInfo->pRoot, &WavInfo) == 0) { LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp); duration = WavInfo.FileSize / WavInfo.ByteRate; sprintf((char *)tmp , "%02d:%02d", duration/60, duration%60 ); LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp); pWavList->ptr++; } } } } } break; } break; default: WM_DefaultProc(pMsg); break; } }
/** * @brief Init Kernel Log * @param None * @retval None */ void k_LogInit(void) { pLOG_CacheBuffer = (uint8_t *)k_malloc(LOG_DEPTH); memset (pLOG_CacheBuffer, 0, LOG_DEPTH); LOG_IN_ptr = 0; }
/** * @brief Callback routine of dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; TREEVIEW_ITEM_Handle hTreeView; TREEVIEW_ITEM_INFO Info; GUI_PID_STATE State; switch (pMsg->MsgId) { case WM_INIT_DIALOG: pFileList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef)); pFileList->ptr = 0; hPopUp = WM_CreateWindowAsChild(0, 26, LCD_GetXSize(), LCD_GetYSize()-26, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS , _cbPopup, 0); WM_BringToBottom(hPopUp); hItem = pMsg->hWin; FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT, 0); WM_CreateWindowAsChild(240, 320, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); _RefreshBrowser(pMsg->hWin); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch (NCode) { case WM_NOTIFICATION_CHILD_DELETED: k_free(pFileList); if(hFileInfo != 0) { hFileInfo = 0; } break; case WM_NOTIFICATION_CLICKED: /* React only if released */ switch (Id) { case ID_TREEVIEW: hTreeView = TREEVIEW_GetSel(pMsg->hWinSrc); TREEVIEW_ITEM_GetInfo(hTreeView, &Info); if(Info.IsNode == 0) { GUI_TOUCH_GetState(&State); State.x += 20; if(State.x > 175) { State.x = 175; } State.y-= 50; if(State.y > 150) { State.y -= 70; } _FindFullPath(pMsg->hWinSrc, hTreeView, SelectedFileName); /* Create popup menu after touching the display */ _OpenPopup(hPopUp, _aMenuItems, GUI_COUNTOF(_aMenuItems), State.x, State.y); } break; case ID_BUTTON_REFRESH: _RefreshBrowser (pMsg->hWin); break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
__export_function void* _k_key_derive_skein_1024 ( const char* pass, void* salt, size_t salt_bytes, size_t key_bytes, uint64_t iter) { size_t passlen; size_t digestbytes; unsigned char* keyout; if (!pass || !salt || !salt_bytes || !key_bytes) return 0; passlen = strlen(pass); if (!passlen) return 0; k_hash_t* h = k_hash_init(HASHSUM_SKEIN_1024, 1024); if (!h) return 0; digestbytes = k_hash_digest_bytes(h); if (!key_bytes || (key_bytes > digestbytes)) { k_hash_finish(h); return 0; } void* inp = k_calloc(1, passlen+salt_bytes+digestbytes); if (!inp) { k_hash_finish(h); return 0; } void* outp = k_malloc(digestbytes); if (!outp) { k_free(inp); k_hash_finish(h); return 0; } memcpy(inp, pass, passlen); memcpy(inp+passlen, salt, salt_bytes); k_hash_update(h, inp, passlen+salt_bytes); k_hash_final(h, outp); k_free(inp); for (uint64_t i = 0; i < iter; ++i) { k_hash_reset(h); k_hash_update(h, outp, digestbytes); k_hash_final(h, outp); } k_hash_finish(h); keyout = malloc(key_bytes); if (!keyout) { k_free(outp); return 0; } memcpy(keyout, outp, key_bytes); k_free(outp); return keyout; }
int pool_malloc_test(void) { char *block[4]; int j; /* loop counter */ TC_PRINT("Testing k_malloc() and k_free() ...\n"); /* allocate a large block (which consumes the entire pool buffer) */ block[0] = k_malloc(150); if (block[0] == NULL) { TC_ERROR("150 byte allocation failed\n"); return TC_FAIL; } /* ensure a small block can no longer be allocated */ block[1] = k_malloc(16); if (block[1] != NULL) { TC_ERROR("16 byte allocation did not fail\n"); return TC_FAIL; } /* return the large block */ k_free(block[0]); /* allocate a small block (triggers block splitting)*/ block[0] = k_malloc(16); if (block[0] == NULL) { TC_ERROR("16 byte allocation 0 failed\n"); return TC_FAIL; } /* ensure a large block can no longer be allocated */ block[1] = k_malloc(80); if (block[1] != NULL) { TC_ERROR("80 byte allocation did not fail\n"); return TC_FAIL; } /* ensure all remaining small blocks can be allocated */ for (j = 1; j < 4; j++) { block[j] = k_malloc(16); if (block[j] == NULL) { TC_ERROR("16 byte allocation %d failed\n", j); return TC_FAIL; } } /* ensure a small block can no longer be allocated */ if (k_malloc(8) != NULL) { TC_ERROR("8 byte allocation did not fail\n"); return TC_FAIL; } /* return the small blocks to pool in a "random" order */ k_free(block[2]); k_free(block[0]); k_free(block[3]); k_free(block[1]); /* allocate large block (triggers autodefragmentation) */ block[0] = k_malloc(100); if (block[0] == NULL) { TC_ERROR("100 byte allocation failed\n"); return TC_FAIL; } /* ensure a small block can no longer be allocated */ if (k_malloc(32) != NULL) { TC_ERROR("32 byte allocation did not fail\n"); return TC_FAIL; } return TC_PASS; }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem, Hint; GUI_RECT r; int NCode, Id; uint32_t tmp_param = 0; switch (pMsg->MsgId) { case WM_INIT_DIALOG: pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO)); CameraSettings.d32 = k_BkupRestoreParameter(CALIBRATION_CAMERA_SETTING_BKP); /* Initialization of 'Image' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE); IMAGE_SetBitmap(hItem, &bmwizard); /* Initialization of 'Effects' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT); TEXT_SetFont(hItem, GUI_FONT_16B_1); /* Initialization of 'Radio' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO); RADIO_SetText(hItem, "None", 0); RADIO_SetText(hItem, "B&W", 1); RADIO_SetText(hItem, "Negative", 2); RADIO_SetText(hItem, "Antique", 3); RADIO_SetText(hItem, "Blue", 4); RADIO_SetText(hItem, "Green", 5); RADIO_SetText(hItem, "Red", 6); /* Camera frame initialization */ hItem = WM_GetClientWindow(pMsg->hWin); WM_GetClientRectEx(hItem, &r); hCameraFrame = WM_CreateWindowAsChild(r.x0 + 79, r.y0 + 49, r.x1 - 159, r.y1 - 93, hItem, WM_CF_SHOW | WM_CF_LATE_CLIP, _cbCameraWindow, 0); /* Buttons initialization */ hItem = BUTTON_CreateEx(266, 175, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_CLOSE); WM_SetCallback(hItem, _cbButton_close); hItem = BUTTON_CreateEx(256, 79, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_CAPTURE); WM_SetCallback(hItem, _cbButton_capture); hItem = BUTTON_CreateEx(266, 14, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_SETTINGS); WM_SetCallback(hItem, _cbButton_settings); _Check_DefaultPath (capture_folder); FrameAvailable = 0; break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; if(hSettings == 0) { switch(Id) { case ID_RADIO: if(NCode == WM_NOTIFICATION_VALUE_CHANGED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO); if(CAMERA_GetState() != CAMERA_ERROR) { CAMERA_SelectEffect(RADIO_GetValue(hItem)); } } break; case ID_BUTTON_CLOSE: /* Notifications sent by 'Close' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: k_free(pFileInfo); CAMERA_Stop(); GUI_EndDialog(pMsg->hWin, 0); break; } break; case ID_BUTTON_CAPTURE: /* Notifications sent by 'OK' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: /* Show Hint */ if(CAMERA_GetState() == CAMERA_OK) { Hint = WM_CreateWindowAsChild(100, 90, 120, 32, pMsg->hWin, WM_CF_SHOW , _cbHint, 0); GUI_Exec(); if(CAMERA_GetState() == CAMERA_OK) { CAMERA_SaveToFile(capture_folder); } WM_DeleteWindow(Hint); } break; } break; case ID_BUTTON_SETTINGS: /* Notifications sent by 'Settings' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: camera_disabled = 1; hSettings = GUI_CreateDialogBox(_aSettingsDialogCreate, GUI_COUNTOF(_aSettingsDialogCreate), _cbSettingsDialog, CAMERA_hWin, 0, 0); break; } break; } } break; case WM_DELETE: tmp_param = k_BkupRestoreParameter(CALIBRATION_CAMERA_SETTING_BKP); /* check if new settings have to be saved */ if(CameraSettings.d32 != tmp_param) { k_BkupSaveParameter(CALIBRATION_CAMERA_SETTING_BKP, CameraSettings.d32); } break; default: WM_DefaultProc(pMsg); break; } }