Esempio n. 1
0
int GET_NEW_PAGE(int mode, int mapping_index, int32_t* ppn)
{
	empty_block_entry* curr_empty_block;

	curr_empty_block = GET_EMPTY_BLOCK(mode, mapping_index);

	/* If the flash memory has no empty block,
                Get empty block from the other flash memories */
        if(mode == VICTIM_INCHIP && curr_empty_block == NULL){
                /* Try again */
                curr_empty_block = GET_EMPTY_BLOCK(VICTIM_OVERALL, mapping_index);
        }

	if(curr_empty_block == NULL){
		printf("ERROR[%s] fail\n", __FUNCTION__);
		return FAIL;
	}

	*ppn = curr_empty_block->phy_flash_nb*BLOCK_NB*PAGE_NB \
	       + curr_empty_block->phy_block_nb*PAGE_NB \
	       + curr_empty_block->curr_phy_page_nb;

	curr_empty_block->curr_phy_page_nb += 1;

	return SUCCESS;
}
Esempio n. 2
0
int GET_NEW_PAGE(IDEState *s, int mode, int mapping_index, int32_t *ppn)
{
    SSDState *ssd = &(s->ssd);
    SSDConf *ssdconf = &(ssd->param);

    empty_block_entry *curr_empty_block;

    curr_empty_block = GET_EMPTY_BLOCK(s, mode, mapping_index);

    /* If the flash memory has no empty block,
       Get empty block from the other flash memories */
    if (mode == VICTIM_INCHIP && curr_empty_block == NULL) {
        /* Try again */
        curr_empty_block = GET_EMPTY_BLOCK(s, VICTIM_OVERALL, mapping_index);
    }

    if (curr_empty_block == NULL) {
        printf("ERROR[%s] fail\n", __FUNCTION__);
        return FAIL;
    }

    *ppn = curr_empty_block->phy_flash_nb * ssdconf->block_nb * ssdconf->page_nb \
           + curr_empty_block->phy_block_nb * ssdconf->page_nb \
           + curr_empty_block->curr_phy_page_nb;

    curr_empty_block->curr_phy_page_nb += 1;

    return SUCCESS;
}
Esempio n. 3
0
int GET_NEW_PAGE(int mode, int mapping_index, int32_t* ppn)
{
	empty_block_entry* curr_empty_block;

	curr_empty_block = GET_EMPTY_BLOCK(mode, mapping_index);

	if(curr_empty_block == NULL){
		printf("ERROR[%s] fail\n",__FUNCTION__);
		return FAIL;
	}

	*ppn = curr_empty_block->phy_flash_nb*BLOCK_NB*PAGE_NB \
	       + curr_empty_block->phy_block_nb*PAGE_NB \
	       + curr_empty_block->curr_phy_page_nb;

	curr_empty_block->curr_phy_page_nb += 1;

	return SUCCESS;
}