Example #1
0
void
chunks_init()
{
	chunk_init(&chunk16, 16, 512);
	chunk_init(&chunk32, 32, 256);
	chunk_init(&chunk64, 64, 256);
	chunk_init(&chunk128, 128, 256);
}
Example #2
0
static BOOL SetupOtaParameters()
{
    UINT32 addr;
    UINT32 len;

    // get unzip size;
    m_ota_info.uncompressed_len = (UINT32)get_unzip_size((UINT8 *)m_ota_info.compressed_addr);

    chunk_init(m_ota_info.uncompressed_addr,m_ota_info.uncompressed_len);
    if(!get_chuck_add_len(0x04FB0100, &addr, &len))
        return FALSE;

    // find the firmware position
    m_ota_info.ota_fw_addr = m_ota_info.uncompressed_addr;
    m_ota_info.ota_fw_size = addr + len - m_ota_info.ota_fw_addr;

    // find ota.bin position.
    m_ota_info.ota_bin_addr = m_ota_info.ota_fw_addr + m_ota_info.ota_fw_size;
    m_ota_info.ota_bin_size = m_ota_info.uncompressed_len - m_ota_info.ota_fw_size;
    m_ota_info.ota_bin_sectors = m_ota_info.ota_bin_size/C_SECTOR_SIZE;
    if(len % C_SECTOR_SIZE)
        m_ota_info.ota_bin_sectors++;

    // calculate upgrade sectors.
    m_ota_info.ota_upg_addr = m_ota_info.ota_fw_addr + C_SECTOR_SIZE; //skip bootloader sector.
    m_ota_info.ota_upg_size = m_ota_info.ota_fw_size - len - C_SECTOR_SIZE;	//skip bootloader and user_db
    m_ota_info.ota_upg_sectors = m_ota_info.ota_upg_size/C_SECTOR_SIZE;
    if(m_ota_info.ota_upg_size % C_SECTOR_SIZE)
        m_ota_info.ota_upg_sectors++;


    m_ota_info.update_secotrs_index = 0;
#ifdef _BUILD_OTA_E_
    m_ota_info.update_total_sectors = m_ota_info.ota_upg_sectors + \
                                      m_ota_info.user_db_sectors;
#else
    m_ota_info.update_total_sectors = m_ota_info.ota_upg_sectors + \
                                      m_ota_info.ota_bin_sectors + m_ota_info.user_db_sectors;
#endif
    // find ota_cfg chunk.
    chunk_init(m_ota_info.ota_bin_addr,m_ota_info.ota_bin_size);
    UINT32 chid = 0x15Fa0200;
    UINT8 *p = (UINT8*)chunk_goto(&chid, 0xFFFFFFFF, 1);
    if(p)
    {
        m_ota_info.ota_bin_cfg_addr = (UINT32)p;
        ota_save_parameter(p);
    }
    return TRUE;
}
Example #3
0
BOOL ota_load_parameter()
{
	UINT32 addr;
	UINT32 len;	
    unsigned char *p = NULL;
	UINT32 m_ota_load_offset;
	BOOL ret = FALSE;
	do 
	{
		if(!find_ota_loader(&m_ota_load_offset))
			break;;

		chunk_init(m_ota_load_offset+SYS_FLASH_BASE_ADDR, 0x100000);
		
		// get user_db address
		if(!get_chuck_add_len(0x15Fa0200, &addr, &len))
			break;

		p = (UINT8 *)addr;
		MEMCPY(&m_ota_cfg, p, sizeof(m_ota_cfg));
	    
	    ota_freq = m_ota_cfg.t_node.frq;
	    ota_symb = m_ota_cfg.t_node.sym;
	    ota_pid = m_ota_cfg.pid;
		ota_pol = m_ota_cfg.t_node.pol;
		ret = TRUE;
	}while(0);

	if(!ret)
	{
		S_NODE *p_s_node = &m_ota_cfg.s_node;
		p_s_node->lnb_low = 5150;
		p_s_node->lnb_high= 5150;
		p_s_node->DiSEqC_port = 4;
	    ota_freq = 4150;
	    ota_symb = 40000;
	    ota_pid = 256;
		ota_pol = 0;
		
	}
	libc_printf("%s: p=0x%x, Freq=%d, ota_symb=%d, ota_pid=%d, ota_pol =%d\n", \
		__FUNCTION__, p, ota_freq, ota_symb, ota_pid, ota_pol);

	OSD_ChangeFocus((POBJECT_HEAD)&win_otaupg_con, 7, 0);
	CONTAINER *con = &wota_con0;
	OSD_SetAttr(con, C_ATTR_INACTIVE);
	con = &wota_con1;
	OSD_SetAttr(con, C_ATTR_INACTIVE);		
	PTEXT_FIELD pText = &wota_txt0;
	OSD_SetAttr(pText, C_ATTR_INACTIVE);
	pText = &wota_txt1;
	OSD_SetAttr(pText, C_ATTR_INACTIVE);		

	PMULTISEL pmul = &wota_num0;
	OSD_SetAttr(pmul, C_ATTR_INACTIVE);	
	pmul = &wota_num1;
	OSD_SetAttr(pmul, C_ATTR_INACTIVE);

	return ret;
}
Example #4
0
File: chunk.c Project: 5bruce/sbase
int main()
{
    char *s = "jsdhfkajsdhfksdhfksahfkhsadkfhkasdfklasdfjldsff";
    int i = 0, n = strlen(s);
    CHUNK *chunks[20480];


    for(i = 0; i < 20480; i++)
    {
        if((chunks[i] = chunk_init()))
        {
            chunk_mem(chunks[i], 65536);
            chunk_mem_fill(chunks[i], s, n);
        }
    }

    for(i = 0; i < 20480; i++)
    {
        if(chunks[i])
        {
            chunk_clean(chunks[i]);
        }
    }
    while(1)sleep(1);
    return 0;
}
void* allocator_alloc(allocator_t *allocator)
{
  pthread_mutex_lock(&allocator->lock);

  chunk_t *chunk = DLLIST_ELEMENT(allocator->alloc_chunk, chunk_t, link);
  if (!allocator->alloc_chunk || chunk_empty(chunk)) {
    dllist_link *l = allocator->chunks.head;
    for (; ; l = l->next) {
      if (!l) {
        chunk_t *c = malloc(sizeof(chunk_t));
        chunk_init(c, allocator->default_nr_blocks, allocator->block_size);
        allocator->alloc_chunk = &c->link;
        dllist_iat(&allocator->chunks, &c->link);
        allocator->chunks_count++;
        break;
      }

      chunk_t *tmp = DLLIST_ELEMENT(l, chunk_t, link);
      if (!chunk_empty(tmp)) {
        allocator->alloc_chunk = l;
        break;
      }
    }
  }

  chunk_t *tmp = DLLIST_ELEMENT(allocator->alloc_chunk, chunk_t, link);
  void *rv = chunk_alloc(tmp, allocator->block_size);

  pthread_mutex_unlock(&allocator->lock);

  return rv;
}
ssize_t chunk_manager_gen_chunk (struct chunk_manager *cm, off_t offset, size_t size, struct chunk ** ret_ch, off_t *chunk_offset) {
	LOG(INFO, "chunk_manager_gen_chunk called\n");
	assert(cm);
	assert(ret_ch);
	assert(chunk_offset);
	//All chunks are aligned by cur_chunk_mask to improve search perfomance
	//cur_chunk_size might change it's size during execution to fit changing
	//conditions like failed to map so big chunk size
	off_t poffset = offset & MASK(cm -> cur_chunk_size);
	size_t psize = ((offset + size) & MASK(cm -> cur_chunk_size)) + cm -> cur_chunk_size - poffset;

	search_chunk.offset = poffset;
	struct chunk *cur_ch = (struct chunk *)rbtree_finddata(cm -> rbtree, &search_chunk);

	/* This algorithm is optimistic: we believe, that chunk with nearest offset
	 * is the one that we want to find which is not true in every case
	 */
	//TODO: implement interval tree or structure that allows to find biggest chunk

	//off_t relative_offset = offset - cur_ch -> offset;
	//ssize_t relative_size = size;
	//LOG(DEBUG, "Found nice chunk %p\n", cur_ch);
	if (cur_ch != NULL) LOG(DEBUG, "Closest chunk is offset %lld, size %lld\n", cur_ch -> offset, cur_ch -> size);
	if (cur_ch == NULL ||
	    offset + size > cur_ch -> size + cur_ch -> offset ) {
		LOG(DEBUG, "No chunk found - making new one of size %ld\n", psize);
		struct chunk *new_chunk = chunk_manager_get_av_chunk_from_pool(cm);
		if (new_chunk == NULL)
			return -1;

		while (1){
			LOG(DEBUG, "Trying size %ld\n", cm -> cur_chunk_size);
			poffset = offset & MASK(cm -> cur_chunk_size);
			psize = ((offset + size) & MASK(cm -> cur_chunk_size)) + cm -> cur_chunk_size - poffset;

			if (!chunk_init (new_chunk, psize, poffset, cm -> fd))
				break;
			cm -> cur_chunk_size >>= 1;
			if (cm -> cur_chunk_size <= MIN_CHUNK_SIZE)
				return -1;
		}
		if (cm -> cur_chunk_size < MAX_CHUNK_SIZE){
			cm -> cur_chunk_size <<= 1;
		}
	  	/* We can make adding to rbtree O(1) if we use offset that we already
		 * found to make less tree traversals
		 */
		//LOG(DEBUG, "Adding offset %lld to rbtree\n", new_chunk -> offset);
		if (cur_ch && cur_ch -> offset == new_chunk -> offset && cur_ch -> rbnode){
			cur_ch -> rbnode -> Data = new_chunk;
			cur_ch -> rbnode = NULL;
		}else{
			new_chunk -> rbnode = rbtree_insert(cm -> rbtree, new_chunk);

		}
		*ret_ch = new_chunk;
		*chunk_offset = offset - new_chunk -> offset;
		return new_chunk -> size - offset + new_chunk -> offset;
	}else{
Example #7
0
/* (re)allocates the trash buffers. Returns 0 in case of failure. It is
 * possible to call this function multiple times if the trash size changes.
 */
static int alloc_trash_buffers(int bufsize)
{
	chunk_init(&trash, my_realloc2(trash.str, bufsize), bufsize);
	trash_size = bufsize;
	trash_buf1 = (char *)my_realloc2(trash_buf1, bufsize);
	trash_buf2 = (char *)my_realloc2(trash_buf2, bufsize);
	return trash.str && trash_buf1 && trash_buf2;
}
void allocator_expand(allocator_t *allocator, uint32_t count)
{
  chunk_t *c = malloc(sizeof(chunk_t));
  chunk_init(c, count, allocator->block_size);

  pthread_mutex_lock(&allocator->lock);

  dllist_iat(&allocator->chunks, &c->link);
  allocator->chunks_count++;

  pthread_mutex_unlock(&allocator->lock);
}
Example #9
0
/*
 * Allocate a trash chunk from the reentrant pool. The buffer starts at the
 * end of the chunk. This chunk must be freed using free_trash_chunk(). This
 * call may fail and the caller is responsible for checking that the returned
 * pointer is not NULL.
 */
struct chunk *alloc_trash_chunk(void)
{
	struct chunk *chunk;

	chunk = pool_alloc(pool_head_trash);
	if (chunk) {
		char *buf = (char *)chunk + sizeof(struct chunk);
		*buf = 0;
		chunk_init(chunk, buf, pool_head_trash->size - sizeof(struct chunk));
	}
	return chunk;
}
/*
* Returns a pre-allocated and initialized trash chunk that can be used for any
* type of conversion. Two chunks and their respective buffers are alternatively
* returned so that it is always possible to iterate data transformations without
* losing the data being transformed. The blocks are initialized to the size of
* a standard buffer, so they should be enough for everything.
*/
struct chunk *get_trash_chunk(void)
{
	char *trash_buf;

	if (trash_chunk == &trash_chunk1) {
		trash_chunk = &trash_chunk2;
		trash_buf = trash_buf2;
	}
	else {
		trash_chunk = &trash_chunk1;
		trash_buf = trash_buf1;
	}
	chunk_init(trash_chunk, trash_buf, trash_size);
	return trash_chunk;
}
Example #11
0
static chunk *chunkqueue_get_unused_chunk(chunkqueue *cq) {
	chunk *c;

	/* check if we have a unused chunk */
	if (!cq->unused) {
		c = chunk_init();
	} else {
		/* take the first element from the list (a stack) */
		c = cq->unused;
		cq->unused = c->next;
		c->next = NULL;
		cq->unused_chunks--;
	}

	return c;
}
Example #12
0
static chunk *chunkpool_get_unused_chunk(void) {
    chunk *c;

    /* check if we have an unused chunk */
    if (!chunkpool) {
        c = chunk_init();
    } else {
        /* take the first element from the list (a stack) */
        c = chunkpool;
        chunkpool = c->next;
        c->next = NULL;

        chunkpool_chunks--;
    }

    return c;
}
Example #13
0
unsigned read_chunk(FILE *source, Chunk *chunk, long MAX_CHUNK_SIZE) {
    int buf;
    chunk_init(chunk, ftell(source));
    while (chunk->length < MIN_CHUNK_SIZE) {
        if ((buf = fgetc(source))==EOF)
            return (chunk->length > 0);
        chunk_append(chunk, (char)buf);
    }
    while ((~(chunk_digest(chunk)) & MATCHMASK) || (chunk->length < MIN_CHUNK_SIZE)) {
        if ((buf = fgetc(source))==EOF)
            return (chunk->length > 0); //No more if this chunk has nothing
        chunk_append(chunk, (char)buf);
        if (chunk->length >= MAX_CHUNK_SIZE)
            return 1; //Chunk has data, but it's too big to take more
    }
    return 1;
}
Example #14
0
int web_post_uri(const char *script, const char *line, char **ret)
{
	int rc = 0;
	// int curl_code = 0;
	long http_code = -1;
	// strcpy(urle, line);
	// /* specify URL to post */
	curl_easy_setopt(curl, CURLOPT_URL, script);
	/* send all data to this function  */
	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
	/* we pass our 'chunk' struct to the callback function */
	curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
	/* some servers don't like requests that are made without a user-agent
		field, so we provide one */
	curl_easy_setopt(curl, CURLOPT_USERAGENT, USERAGENT);
	curl_easy_setopt(curl, CURLOPT_FAILONERROR, 0);
	curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
	curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 5);

	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, line);
	curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(line));

	chunk_init(&chunk);
	/* get it! */
	/* curl_code = */ curl_easy_perform(curl);
	if (!chunk.size) {
		debug(9,"Zero reply for [%.1024s]\n",line);
	}
	curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &http_code);
	if (chunk.memory && chunk.size) {
		// debug(3, "Reply size:[%d]\n", chunk.size);
		*ret = calloc(1,chunk.size+1);
		if (*ret) {
			memcpy(*ret, chunk.memory, chunk.size);
			rc = chunk.size;
		}
	}
	if (http_code != 200) {
		rc = -http_code;

	}
	chunk_free(&chunk);
	return rc;
}
Example #15
0
static BOOL SetupOtaParameters()
{
	UINT32 addr,address;
	UINT32 len, lenth;
#if 1
	UINT32 chid_key = 0x07F80100;
	UINT32 chid_db = 0x04FB0100;
	UINT32 chid = 0x01FE0101;

	m_ota_info.uncompressed_len = (UINT32)get_unzip_size((UINT8 *)m_ota_info.compressed_addr);
	chunk_init(m_ota_info.uncompressed_addr,m_ota_info.uncompressed_len);

if ((UINT8*)chunk_goto(&chid, 0xFFFFFFFF, 1) != NULL)
{
	// get unzip size;
	if(!get_chuck_add_len(0x04FB0100, &addr, &len))
	{
	      OTA_PRINTF("--------get_chuck_add_len failed -------- \n");
		return FALSE;
	}

	// find the firmware position	
	m_ota_info.ota_fw_addr = m_ota_info.uncompressed_addr;
	m_ota_info.ota_fw_size = addr + len - m_ota_info.ota_fw_addr;
		
	// find ota.bin position.
	m_ota_info.ota_bin_addr = m_ota_info.ota_fw_addr + m_ota_info.ota_fw_size;
	m_ota_info.ota_bin_size = m_ota_info.uncompressed_len - m_ota_info.ota_fw_size;
	m_ota_info.ota_bin_sectors = m_ota_info.ota_bin_size/C_SECTOR_SIZE;
	if(len % C_SECTOR_SIZE)
		m_ota_info.ota_bin_sectors++;

	// calculate upgrade sectors.
	m_ota_info.ota_upg_addr = m_ota_info.ota_fw_addr + C_SECTOR_SIZE; //skip bootloader sector.
	m_ota_info.ota_upg_size = m_ota_info.ota_fw_size - len - C_SECTOR_SIZE;	//skip bootloader and user_db
	m_ota_info.ota_upg_sectors = m_ota_info.ota_upg_size/C_SECTOR_SIZE;
	if(m_ota_info.ota_upg_size % C_SECTOR_SIZE)
		m_ota_info.ota_upg_sectors++;

	
	m_ota_info.update_secotrs_index = 0;
#ifdef _BUILD_OTA_E_
	m_ota_info.update_total_sectors = m_ota_info.ota_upg_sectors + \
		m_ota_info.user_db_sectors;
#else
	m_ota_info.update_total_sectors = m_ota_info.ota_upg_sectors + \
		m_ota_info.ota_bin_sectors + m_ota_info.user_db_sectors;
#endif
	// find ota_cfg chunk.
	chunk_init(m_ota_info.ota_bin_addr,m_ota_info.ota_bin_size);
	UINT32 chid = 0x15Fa0200;
	UINT8 *p = (UINT8*)chunk_goto(&chid, 0xFFFFFFFF, 1);
	if(p)
	{
		m_ota_info.ota_bin_cfg_addr = (UINT32)p;
		ota_save_parameter(p);
	}
	OTA_PRINTF("ota_bin_sectors1111111111 == %d \n", m_ota_info.ota_bin_sectors);
	OTA_PRINTF("ota_bin_size1111111111 == %d \n", m_ota_info.ota_bin_size);
	burning_flag = 1;
	return TRUE;

}

else  
{
//key
 if( (UINT8*)chunk_goto(&chid_key, 0xFFFFFFFF, 1) != NULL && (UINT8*)chunk_goto(&chid_db, 0xFFFFFFFF, 1) == NULL)
 	{
	m_ota_info.uncompressed_len = (UINT32)get_unzip_size((UINT8 *)m_ota_info.compressed_addr);

	chunk_init(m_ota_info.uncompressed_addr,m_ota_info.uncompressed_len);
	if(!get_chuck_add_len(0x07F80100, &addr, &len))
	{
	      OTA_PRINTF("--------get_chuck_add_len failed -------- \n");
		return FALSE;
	}

	m_ota_info.ota_fw_addr = m_ota_info.uncompressed_addr;
	m_ota_info.ota_fw_size = addr + len - m_ota_info.ota_fw_addr;

	m_ota_info.ota_upg_addr = m_ota_info.ota_fw_addr + 0*C_SECTOR_SIZE;
	m_ota_info.ota_upg_size = len;
	m_ota_info.ota_upg_sectors = 1;

	m_ota_info.update_secotrs_index = 0;
	m_ota_info.update_total_sectors = 1 ;

	api_get_chuck_addlen(0x07F80100, &addr, &len);
		m_ota_info.ota_fw_size = addr/C_SECTOR_SIZE;//now ,ota_fw_size is key block num
		
	chunk_init(m_ota_info.ota_bin_addr,m_ota_info.ota_bin_size);
	UINT32 chid = 0x15Fa0200;
	UINT8 *p = (UINT8*)chunk_goto(&chid, 0xFFFFFFFF, 1);
	if(p)
	{
		m_ota_info.ota_bin_cfg_addr = (UINT32)p;
		ota_save_parameter(p);
	}

	OTA_PRINTF("ota_fw_size == 0x%08x \n", m_ota_info.ota_fw_size);
	OTA_PRINTF("ota_upg_addr1111111111 == 0x%08x \n", m_ota_info.ota_upg_addr);

	OTA_PRINTF("ota_upg_size1111111111 == 0x%08x \n", m_ota_info.ota_upg_size);
	OTA_PRINTF("ota_upg_sectors1111111111 == %d \n", m_ota_info.ota_upg_sectors);
	burning_flag = 2;
	return TRUE;
 	}
 //db
 if( (UINT8*)chunk_goto(&chid_key, 0xFFFFFFFF, 1) == NULL && (UINT8*)chunk_goto(&chid_db, 0xFFFFFFFF, 1) != NULL)
 	{
 		//OTA_PRINTF("ttttttttttttt  \n");

		m_ota_info.uncompressed_len = (UINT32)get_unzip_size((UINT8 *)m_ota_info.compressed_addr);

		chunk_init(m_ota_info.uncompressed_addr,m_ota_info.uncompressed_len);
		if(!get_chuck_add_len(0x04FB0100, &addr, &len))
		{
			return FALSE;
		}
		OTA_PRINTF("addr == 0x%08x \n", addr);
		OTA_PRINTF("len == 0x%08x \n", len);
		m_ota_info.ota_fw_addr = m_ota_info.uncompressed_addr;
		m_ota_info.ota_fw_size = addr + len - m_ota_info.ota_fw_addr;

		m_ota_info.ota_upg_addr = m_ota_info.ota_fw_addr;
		m_ota_info.ota_upg_size = m_ota_info.ota_fw_size;
		//m_ota_info.ota_upg_size = len;
		m_ota_info.ota_upg_sectors = m_ota_info.ota_upg_size/C_SECTOR_SIZE;
		//if(m_ota_info.ota_upg_size % C_SECTOR_SIZE)
		//	m_ota_info.ota_upg_sectors++;

		m_ota_info.update_secotrs_index = 0;
		m_ota_info.update_total_sectors = m_ota_info.ota_upg_sectors ;

		chunk_init(m_ota_info.ota_bin_addr,m_ota_info.ota_bin_size);
		UINT32 chid = 0x15Fa0200;
		UINT8 *p = (UINT8*)chunk_goto(&chid, 0xFFFFFFFF, 1);
		if(p)
		{
			m_ota_info.ota_bin_cfg_addr = (UINT32)p;
			ota_save_parameter(p);
		}
		burning_2 =2;
		//OTA_PRINTF("burning_2 == %d \n", burning_2);
		OTA_PRINTF("ota_upg_addr1111111111 == 0x%08x \n", m_ota_info.ota_upg_addr);

		OTA_PRINTF("ota_upg_size1111111111 == 0x%08x \n", m_ota_info.ota_upg_size);
		OTA_PRINTF("ota_upg_sectors1111111111 == %d \n", m_ota_info.ota_upg_sectors);

		return TRUE;
 	}
 //key + db
 if( (UINT8*)chunk_goto(&chid_key, 0xFFFFFFFF, 1) != NULL && (UINT8*)chunk_goto(&chid_db, 0xFFFFFFFF, 1) != NULL)
 	{
		m_ota_info.uncompressed_len = (UINT32)get_unzip_size((UINT8 *)m_ota_info.compressed_addr);

		chunk_init(m_ota_info.uncompressed_addr,m_ota_info.uncompressed_len);
		if(!get_chuck_add_len(0x04FB0100, &addr, &len))
		{
			return FALSE;
		}
		if(!get_chuck_add_len(0x07F80100, &address, &lenth))
		{
			return FALSE;
		}

		m_ota_info.ota_fw_addr = m_ota_info.uncompressed_addr;
		m_ota_info.ota_fw_size = lenth;

		m_ota_info.ota_upg_addr = m_ota_info.ota_fw_addr;
		m_ota_info.ota_upg_size = lenth;
		m_ota_info.ota_upg_sectors = 1;
		//if(m_ota_info.ota_upg_size % C_SECTOR_SIZE)
		//	m_ota_info.ota_upg_sectors++;

		//m_ota_info.ota_fw_addr2 = m_ota_info.uncompressed_addr;
		m_ota_info.ota_fw_size2 = len;

		m_ota_info.ota_upg_addr2 = addr;
		m_ota_info.ota_upg_size2 = len;
		m_ota_info.ota_upg_sectors2 =  m_ota_info.ota_upg_size2/C_SECTOR_SIZE;
		if(m_ota_info.ota_upg_size2 % C_SECTOR_SIZE)
			m_ota_info.ota_upg_sectors2++;

		m_ota_info.update_secotrs_index = 0;
		m_ota_info.update_total_sectors = m_ota_info.ota_upg_sectors +m_ota_info.ota_upg_sectors2  ;

		api_get_chuck_addlen(0x07F80100, &address, &lenth);
		m_ota_info.ota_fw_size = address/C_SECTOR_SIZE;//now ,ota_fw_size is key block num
		
		chunk_init(m_ota_info.ota_bin_addr,m_ota_info.ota_bin_size);
		UINT32 chid = 0x15Fa0200;
		UINT8 *p = (UINT8*)chunk_goto(&chid, 0xFFFFFFFF, 1);
		if(p)
		{
			m_ota_info.ota_bin_cfg_addr = (UINT32)p;
			ota_save_parameter(p);
		}

		OTA_PRINTF("ota_fw_addr == 0x%08x \n", m_ota_info.ota_fw_addr);
		OTA_PRINTF("ota_fw_size1111111111 == 0x%08x \n", m_ota_info.ota_fw_size);
		OTA_PRINTF("ota_upg_addr1111111111 == 0x%08x \n", m_ota_info.ota_upg_addr);
		OTA_PRINTF("ota_upg_size1111111111 == 0x%08x \n", m_ota_info.ota_upg_size);
		OTA_PRINTF("ota_upg_sectors1111111111 == %d \n", m_ota_info.ota_upg_sectors);
		OTA_PRINTF("ota_upg_addr2 == 0x%08x \n", m_ota_info.ota_upg_addr2);
		OTA_PRINTF("ota_upg_size2 == 0x%08x \n", m_ota_info.ota_upg_size2);
		OTA_PRINTF("ota_upg_sectors2 == %d \n", m_ota_info.ota_upg_sectors2);
		burning_flag = 3 ;
		return TRUE;
 	}

}
#else
	// get unzip size;
	m_ota_info.uncompressed_len = (UINT32)get_unzip_size((UINT8 *)m_ota_info.compressed_addr);

	chunk_init(m_ota_info.uncompressed_addr,m_ota_info.uncompressed_len);
	if(!get_chuck_add_len(0x04FB0100, &addr, &len))
	{
	      OTA_PRINTF("--------get_chuck_add_len failed -------- \n");
		return FALSE;
	}

	// find the firmware position	
	m_ota_info.ota_fw_addr = m_ota_info.uncompressed_addr;
	m_ota_info.ota_fw_size = addr + len - m_ota_info.ota_fw_addr;
		
	// find ota.bin position.
	m_ota_info.ota_bin_addr = m_ota_info.ota_fw_addr + m_ota_info.ota_fw_size;
	m_ota_info.ota_bin_size = m_ota_info.uncompressed_len - m_ota_info.ota_fw_size;
	m_ota_info.ota_bin_sectors = m_ota_info.ota_bin_size/C_SECTOR_SIZE;
	if(len % C_SECTOR_SIZE)
		m_ota_info.ota_bin_sectors++;

	// calculate upgrade sectors.
	m_ota_info.ota_upg_addr = m_ota_info.ota_fw_addr + C_SECTOR_SIZE; //skip bootloader sector.
	m_ota_info.ota_upg_size = m_ota_info.ota_fw_size - len - C_SECTOR_SIZE;	//skip bootloader and user_db
	m_ota_info.ota_upg_sectors = m_ota_info.ota_upg_size/C_SECTOR_SIZE;
	if(m_ota_info.ota_upg_size % C_SECTOR_SIZE)
		m_ota_info.ota_upg_sectors++;

	
	m_ota_info.update_secotrs_index = 0;
#ifdef _BUILD_OTA_E_
	m_ota_info.update_total_sectors = m_ota_info.ota_upg_sectors + \
		m_ota_info.user_db_sectors;
#else
	m_ota_info.update_total_sectors = m_ota_info.ota_upg_sectors + \
		m_ota_info.ota_bin_sectors + m_ota_info.user_db_sectors;
#endif
	// find ota_cfg chunk.
	chunk_init(m_ota_info.ota_bin_addr,m_ota_info.ota_bin_size);
	UINT32 chid = 0x15Fa0200;
	UINT8 *p = (UINT8*)chunk_goto(&chid, 0xFFFFFFFF, 1);
	if(p)
	{
		m_ota_info.ota_bin_cfg_addr = (UINT32)p;
		ota_save_parameter(p);
	}
	OTA_PRINTF("ota_bin_sectors1111111111 == %d \n", m_ota_info.ota_bin_sectors);
	OTA_PRINTF("ota_bin_size1111111111 == %d \n", m_ota_info.ota_bin_size);
	return TRUE;
#endif

}
Example #16
0
BOOL ota_load_parameter()
{
	UINT32 addr;
	UINT32 len;	
    unsigned char *p = NULL;
	UINT32 m_ota_load_offset;
	BOOL ret = FALSE;	
	UINT32 ota_bin_max_size = 0x200000;

	struct sto_device *flash_dev = (struct sto_device *)dev_get_by_type(NULL, HLD_DEV_TYPE_STO);

#ifndef _CAS9_CA_ENABLE_
	do 
	{
		if(!find_ota_loader(&m_ota_load_offset))
			break;;

		if((UINT32)flash_dev->totol_size > m_ota_load_offset)
		{
			ota_bin_max_size = (UINT32)flash_dev->totol_size-m_ota_load_offset;
		}
		if(ota_bin_max_size < 0x100000)
			ota_bin_max_size = 0x100000;
		
		chunk_init(m_ota_load_offset+SYS_FLASH_BASE_ADDR, ota_bin_max_size);
		
		// get user_db address
		if(!get_chunk_add_len(0x15Fa0200, &addr, &len))
			break;

		p = (UINT8 *)addr;
		MEMCPY(&m_ota_cfg, p, sizeof(m_ota_cfg));
	    
	    ota_freq = m_ota_cfg.t_node.frq;
	    ota_symb = m_ota_cfg.t_node.sym;
	    ota_pid = m_ota_cfg.pid;
		ota_pol = m_ota_cfg.t_node.pol;
        ota_modulation= m_ota_cfg.t_node.FEC_inner; //DVBC 
		ret = TRUE;
	}while(0);
#endif

	if((ota_freq == 0) && (ota_symb == 0) && (ota_pid == 0))
	{
#if (SYS_PROJECT_FE == PROJECT_FE_DVBS || SYS_PROJECT_FE == PROJECT_FE_DVBS2)
	    ota_freq = 4150;
	    ota_symb = 40000;
	    ota_pid = 256;
		ota_pol = 0;
#else
        //DVBC setting
	    ota_freq = 5050;
	    ota_symb = 6875;
	    ota_pid = OTA_DATA_PID;
		ota_modulation = QAM64;

#endif		
	}

#if (SYS_PROJECT_FE == PROJECT_FE_DVBS || SYS_PROJECT_FE == PROJECT_FE_DVBS2)
	OSD_ChangeFocus((POBJECT_HEAD)&win_otaupg_con, 7, 0);
	CONTAINER *con = &wota_con0;
	OSD_SetAttr(con, C_ATTR_INACTIVE);
	con = &wota_con1;
	OSD_SetAttr(con, C_ATTR_INACTIVE);		
	PTEXT_FIELD pText = &wota_txt0;
	OSD_SetAttr(pText, C_ATTR_INACTIVE);
	pText = &wota_txt1;
	OSD_SetAttr(pText, C_ATTR_INACTIVE);		

	PMULTISEL pmul = &wota_num0;
	OSD_SetAttr(pmul, C_ATTR_INACTIVE);	
	pmul = &wota_num1;
	OSD_SetAttr(pmul, C_ATTR_INACTIVE);
#endif

	return ret;
}