Beispiel #1
0
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Function:     emu_Flash_Release
* Inputs:       none
* Outputs:      PASS=0 (notice 0=ok here)
* Description:          Releases the flash.  
*               
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
uint16 emu_Flash_Release()
{
    int i;

#if FLASH_EMU_STATIC_MALLOC
    emu_write_mem_to_file(); 
#endif

#if FLASH_EMU_STATIC_MALLOC    
    i = 0;
    GLOB_FREE(GLOB_flash_memory[0]);
#else
    for(i=0;i<GLOB_LLD_BLOCKS*GLOB_LLD_PAGES;i++)
    {
        if (GLOB_flash_memory[i]) {
#ifdef ELDORA
            free(GLOB_flash_memory[i]);
#else
            GLOB_FREE(GLOB_flash_memory[i]);
#endif
            GLOB_flash_memory[i] = NULL;
        }
    }
#endif
    return PASS;
}
Beispiel #2
0
static void _fileglob_FreeContextLevel(fileglob* self) {
	if (self->context) {
		fileglob_context* oldContext = self->context;
#if defined(_WIN32)  &&  !defined(MINGW)
        self->curfd = NULL;
#else
        self->curattr = NULL;
#endif
        GLOB_FREE(oldContext->buf);
        GLOB_FREE(oldContext->new_beg);
        GLOB_FREE(oldContext->copy_beg);
        if (oldContext->savepath)
            GLOB_FREE(oldContext->path);
		self->context = oldContext->prev;
#if defined(_WIN32)  &&  !defined(MINGW)
		if (oldContext->handle != INVALID_HANDLE_VALUE) {
			FindClose(oldContext->handle);
		}
#else
		if (oldContext->dirp) {
			closedir(oldContext->dirp);
		}
#endif
		self->allocFunction(self->userData, oldContext, 0);
	}
}
Beispiel #3
0
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Function:     emu_Erase_Block
* Inputs:       Address
* Outputs:      PASS=0 (notice 0=ok here)
* Description:          Erase a block  
*               
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
uint16 emu_Erase_Block(BLOCKNODE block_add)
{
    uint16 status = PASS;
    int i;
    
    
    if(block_add >= GLOB_DeviceInfo.wTotalBlocks) 
    {
        status = FAIL;
    }

    if ((PASS == status) && !GLOB_flash_memory)
    {
        status = FAIL;
    }

    print("ERASING BLOCK %d\n",block_add);

#if EMU_BAD_BLOCK    
    if ( FAIL == emu_bad_block_check(block_add))
    {
	status = FAIL;
    }
#endif
    
    if (PASS == status) 
    {
        for(i=block_add*GLOB_LLD_PAGES; i<((block_add+1)*GLOB_LLD_PAGES); i++)
            if (GLOB_flash_memory[i]) {
#if FLASH_EMU_STATIC_MALLOC
            	memset((unsigned char *)(GLOB_flash_memory[i]), 0xFF,
            			GLOB_DeviceInfo.wPageSize*sizeof(unsigned char));
#else
#ifdef ELDORA
                free(GLOB_flash_memory[i]);
#else
                GLOB_FREE(GLOB_flash_memory[i]);
#endif
                GLOB_flash_memory[i] = NULL;
#endif
            }
    }
   
    return status;
}