Exemple #1
0
int
flash_hwr_init(void)
{
    struct FLASH_query data, *qp;
    extern char flash_query, flash_query_end;
    typedef int code_fun(unsigned char *);
    code_fun *_flash_query;
    int code_len, stat, num_regions, region_size;

    // Copy 'program' code to RAM for execution
    code_len = (unsigned long)&flash_query_end - (unsigned long)&flash_query;
    _flash_query = (code_fun *)flash_info.work_space;
    memcpy(_flash_query, &flash_query, code_len);

    HAL_DCACHE_SYNC();             // Should guarantee this code will run
    HAL_ICACHE_INVALIDATE_ALL();   // is also required to avoid old contents
    stat = (*_flash_query)(&data);

    qp = &data;
    if (/*(qp->manuf_code == FLASH_Intel_code) && */
        (strncmp(qp->id, "QRY", 3) == 0)) {
        num_regions = _si(qp->num_regions)+1;
        region_size = _si(qp->region_size)*256;

        flash_info.block_size = region_size*2;   // Pairs of chips in parallel
        flash_info.blocks = num_regions*2;	 // and pairs of chips in serial
        flash_info.start = (void *)0x9c000000;
        flash_info.end = (void *)0x9e000000;
        return FLASH_ERR_OK;
    } else {
        (*flash_info.pf)("Can't identify FLASH, sorry\n");
        diag_dump_buf(data, sizeof(data));
        return FLASH_ERR_HWR;
    }
}
int
flash_hwr_init(void)
{
    struct FLASH_query data, *qp;
    extern char flash_query, flash_query_end;
    typedef int code_fun(unsigned char *);
    code_fun *_flash_query;
    int code_len, stat, num_regions, region_size, icache_isenabled;

    // Copy 'program' code to RAM for execution
    code_len = (unsigned long)&flash_query_end - (unsigned long)&flash_query;
    _flash_query = (code_fun *)flash_info.work_space;
    memcpy(_flash_query, &flash_query, code_len);
    HAL_ICACHE_IS_ENABLED(icache_isenabled);
    HAL_DCACHE_SYNC();  // Should guarantee this code will run
    HAL_ICACHE_DISABLE(); // is also required to avoid old contents

    memset(&data,0,sizeof(data));
    stat = (*_flash_query)((void*)&data);
    if (icache_isenabled)
        HAL_ICACHE_ENABLE();

    qp = &data;
    if (/*(qp->manuf_code == FLASH_Intel_code) && */
        (strncmp(qp->id, "QRY", 3) == 0)) {
        num_regions = _si(qp->num_regions)+1;
        region_size = _si(qp->region_size)*256;

        flash_info.block_size = region_size;
        flash_info.blocks = num_regions;
        flash_info.start = (void *)0x00000000;
        flash_info.end = (void *)(0x00000000+(num_regions*region_size));
        return FLASH_ERR_OK;
    } else {
	(*flash_info.pf)("Can't identify FLASH sorry\n");
        diag_dump_buf(data, sizeof(data));
        return FLASH_ERR_HWR;
    }
}
Exemple #3
0
int main ( int argc, char * * argv ) {
	rdfstore * me;
	DBT key, data, data1;
	int i;
	int test;
		
	test = -1234568;

	memset(&key, 0, sizeof(key));
        memset(&data, 0, sizeof(data));
        memset(&data1, 0, sizeof(data1));

	rdfstore_connect( &me, "cooltest", 0, 0, 0, 0, NULL,0,NULL,NULL,NULL,NULL );

	/* store */
        key.data = "memyselfI";
        key.size = sizeof("memyselfI");
        data.data = "Albe";
        data.size = strlen("Albe")+1;

	if( (rdfstore_flat_store_store( me->model, key, data )) != 0 )
		printf("Cannot store %s = %d\n",_sp(key),_si(data));

	if(rdfstore_flat_store_exists( me->model, key ) == 0 ) {
		printf("Ok key %s does exist\n",_sp(key));
	} else {
		printf("Ok key %s does NOT exist\n",_sp(key));
	};

	/* fetch */
	if( (rdfstore_flat_store_fetch( me->model, key, &data1 )) != 0 ) {
		printf("Cannot fetch %s \n",_sp(key));
	} else {
		RDFSTORE_FREE( data1.data ) ;
		};

	printf("Fetched '%s'\n",_sp(data1));

        key.data = "you";
        key.size = sizeof("you");
        data.data = "Albe";
        data.size = strlen("Albe")+1;

	if( (rdfstore_flat_store_store( me->model, key, data )) != 0 )
		printf("Cannot store %s = %d\n",_sp(key),_si(data));

        key.data = "counter";
        key.size = sizeof("counter");
        data.data = "0";
        data.size = strlen("0")+1;

	if( (rdfstore_flat_store_store( me->model, key, data )) != 0 )
		printf("Cannot store %s = %d\n",_sp(key),_si(data));

	/* fetch */
	if( (rdfstore_flat_store_fetch( me->model, key, &data1 )) != 0 ) {
		printf("Cannot fetch %s \n",_sp(key));
	} else {
		RDFSTORE_FREE( data1.data ) ;
		};

	printf("Fetched '%s'\n",_sp(data1));

	for ( i = 0; i <10000 ; i++ ) {
		/* inc */
		if( (rdfstore_flat_store_inc( me->model, key, &data1 )) != 0 ) {
			printf("Cannot inc %s \n",_sp(key));
		} else {
			RDFSTORE_FREE( data1.data ) ;
			};
	};

	/* fetch */
	if( (rdfstore_flat_store_fetch( me->model, key, &data1 )) != 0 ) {
		printf("Cannot fetch %s \n",_sp(key));
	} else {
		RDFSTORE_FREE( data1.data ) ;
		};

	printf("Fetched '%s'\n",_sp(data1));

	for ( i = 0; i <9999 ; i++ ) {
		/* dec */
		if( (rdfstore_flat_store_dec( me->model, key, &data1 )) != 0 ) {
			printf("Cannot dec %s \n",_sp(key));
		} else {
			RDFSTORE_FREE( data1.data ) ;
			};
	};

	/* NOTE: garbage collection of first and next is not done here */
	/* first */
	if( (rdfstore_flat_store_first( me->model, &data1 )) != 0 ) {
		printf("Cannot first \n");
		};

	/* next */
	while (rdfstore_flat_store_next( me->model, data1, &data ) == 0 ) {
		printf("GOT %s\n",_sp(data));
	};

	if(rdfstore_flat_store_exists( me->model, key ) == 0 ) {
		printf("Ok key %s does exist\n",_sp(key));
	} else {
		printf("Ok key %s does NOT exist\n",_sp(key));
	};

	/* delete */
	if( rdfstore_flat_store_delete ( me->model, key ) != 0 )
		printf("Cannot delete %s \n",_sp(key));

	if( rdfstore_flat_store_clear ( me->model ) != 0 )
		printf("Cannot clear \n");

        key.data = "you";
        key.size = sizeof("you");
	if(rdfstore_flat_store_exists( me->model, key ) == 0 ) {
		printf("Ok key %s does exist\n",_sp(key));
	} else {
		printf("Ok key %s does NOT exist\n",_sp(key));
	};

	if( rdfstore_flat_store_sync ( me->model ) != 0 )
		printf("Cannot sync \n");

	rdfstore_disconnect( me );

	return 0;
};
Exemple #4
0
int
flash_hwr_init(void)
{
    struct FLASH_query data, *qp;
    int num_regions, region_size, buffer_size;

    flash_dev_query(&data);
    qp = &data;
    if ( ((qp->manuf_code == FLASH_Intel_code) || 
          (qp->manuf_code == FLASH_STMicro_code))
#ifdef CYGOPT_FLASH_IS_BOOTBLOCK
         // device types go as follows: 0x90 for 16-bits, 0xD0 for 8-bits,
         // plus 0 or 1 for -T (Top Boot) or -B (Bottom Boot)
         //     [FIXME: whatever that means :FIXME]
         // [I think it means the boot blocks are top/bottom of addr space]
         // plus the following size codes:
         //    0: 16Mbit    2:  8Mbit    4:  4Mbit
         //    6: 32Mbit    8: 64Mbit
#if 16 == CYGNUM_FLASH_WIDTH         
         && (0x90 == (0xF0 & qp->device_code)) // 16-bit devices
#elif 8 == CYGNUM_FLASH_WIDTH
         && (0xD0 == (0xF0 & qp->device_code)) // 8-bit devices
#else
         && 0
#error Only understand 16 and 8-bit bootblock flash types
#endif
        ) {
        int lookup[] = { 16, 8, 4, 32, 64 };
#define BLOCKSIZE (0x10000)
        region_size = BLOCKSIZE;
        num_regions = qp->device_code & 0x0F;
        num_regions >>= 1;
        if ( num_regions > 4 )
            goto flash_type_unknown;
        num_regions = lookup[num_regions];
        num_regions *= 1024 * 1024;     // to bits
        num_regions /= 8;               // to bytes
        num_regions /= BLOCKSIZE;       // to blocks
        buffer_size = 0;
#else // CYGOPT_FLASH_IS_BOOTBLOCK
         && (strncmp(qp->id, "QRY", 3) == 0)) {
        num_regions = _si(qp->num_regions)+1;
        region_size = _si(qp->region_size)*256;       
        if (_si(qp->buffer_size)) {
            buffer_size = CYGNUM_FLASH_DEVICES << _si(qp->buffer_size);
        } else {
            buffer_size = 0;
        }
#endif // Not CYGOPT_FLASH_IS_BOOTBLOCK

        flash_info.block_size = region_size*CYGNUM_FLASH_DEVICES;
        flash_info.buffer_size = buffer_size;
        flash_info.blocks = num_regions;
        flash_info.start = (void *)CYGNUM_FLASH_BASE;
        flash_info.end = (void *)(CYGNUM_FLASH_BASE +
                        (num_regions*region_size*CYGNUM_FLASH_DEVICES));
#ifdef CYGNUM_FLASH_BASE_MASK
        // Then this gives us a maximum size for the (visible) device.
        // This is to cope with oversize devices fitted, with some high
        // address lines ignored.
        if ( ((unsigned int)flash_info.start & CYGNUM_FLASH_BASE_MASK) !=
             (((unsigned int)flash_info.end - 1) & CYGNUM_FLASH_BASE_MASK ) ) {
            // then the size of the device appears to span >1 device-worth!
            unsigned int x;
            x = (~(CYGNUM_FLASH_BASE_MASK)) + 1; // expected device size
            x += (unsigned int)flash_info.start;
            if ( x < (unsigned int)flash_info.end ) { // 2nd sanity check
                (*flash_info.pf)("\nFLASH: Oversized device!  End addr %p changed to %p\n",
                       flash_info.end, (void *)x );
                flash_info.end = (void *)x;
                // Also adjust the block count else unlock crashes!
                x = ((cyg_uint8 *)flash_info.end - (cyg_uint8 *)flash_info.start)
                    / flash_info.block_size;
                flash_info.blocks = x;
            }
        }
#endif // CYGNUM_FLASH_BASE_MASK

        return FLASH_ERR_OK;
    }
#ifdef CYGOPT_FLASH_IS_BOOTBLOCK
 flash_type_unknown:
#endif
    (*flash_info.pf)("Can't identify FLASH, sorry, man %x, dev %x, id [%4s] \n",
           qp->manuf_code, qp->device_code, qp->id );
    diag_dump_buf(qp, sizeof(data));
    return FLASH_ERR_HWR;
}
Exemple #5
0
int
flash_hwr_init(void)
{
    struct FLASH_query data, *qp;
    extern char flash_query[], flash_query_end[];
    typedef int code_fun(unsigned char *);
    code_fun *_flash_query;
    int code_len, stat, num_regions, region_size, buffer_size;
    int icache_on, dcache_on;

    HAL_DCACHE_IS_ENABLED(dcache_on);
    HAL_ICACHE_IS_ENABLED(icache_on);

    // Copy 'program' code to RAM for execution
    code_len = (unsigned long)&flash_query_end - (unsigned long)&flash_query;
    _flash_query = (code_fun *)flash_info.work_space;
    memcpy(_flash_query, &flash_query, code_len);
    if (dcache_on) {
        HAL_DCACHE_SYNC();  // Should guarantee this code will run
    }
    if (icache_on) {
        HAL_ICACHE_DISABLE(); // is also required to avoid old contents
    }

    stat = (*_flash_query)((unsigned char *)&data);
    if (icache_on) {
        HAL_ICACHE_ENABLE();
    }

    qp = &data;
    if ( (qp->manuf_code == FLASH_Intel_code)
#ifdef CYGOPT_FLASH_IS_BOOTBLOCK
         // device types go as follows: 0x90 for 16-bits, 0xD0 for 8-bits,
         // plus 0 or 1 for -T (Top Boot) or -B (Bottom Boot)
         //     [FIXME: whatever that means :FIXME]
         // [I think it means the boot blocks are top/bottom of addr space]
         // plus the following size codes:
         //    0: 16Mbit    2:  8Mbit    4:  4Mbit
         //    6: 32Mbit    8: 64Mbit
#if 16 == CYGNUM_FLASH_WIDTH         
         && (0x90 == (0xF0 & qp->device_code)) // 16-bit devices
#elif 8 == CYGNUM_FLASH_WIDTH
         && (0xD0 == (0xF0 & qp->device_code)) // 8-bit devices
#else
         && 0
#error Only understand 16 and 8-bit bootblock flash types
#endif
        ) {
        int lookup[] = { 16, 8, 4, 32, 64 };
#define BLOCKSIZE (0x10000)
        region_size = BLOCKSIZE;
        num_regions = qp->device_code & 0x0F;
        num_regions >>= 1;
        if ( num_regions > 4 )
            goto flash_type_unknown;
        num_regions = lookup[num_regions];
        num_regions *= 1024 * 1024;     // to bits
        num_regions /= 8;               // to bytes
        num_regions /= BLOCKSIZE;       // to blocks
        buffer_size = 0;
#else // CYGOPT_FLASH_IS_BOOTBLOCK
         && (strncmp(qp->id, "QRY", 3) == 0)) {
        num_regions = _si(qp->num_regions)+1;
        region_size = _si(qp->region_size)*256;       
        if (_si(qp->buffer_size)) {
            buffer_size = CYGNUM_FLASH_DEVICES << _si(qp->buffer_size);
        } else {
            buffer_size = 0;
        }
#endif // Not CYGOPT_FLASH_IS_BOOTBLOCK

        flash_info.block_size = region_size*CYGNUM_FLASH_DEVICES;
        flash_info.buffer_size = buffer_size;
        flash_info.blocks = num_regions;
        flash_info.start = (void *)CYGNUM_FLASH_BASE;
        flash_info.end = (void *)(CYGNUM_FLASH_BASE +
                        (num_regions*region_size*CYGNUM_FLASH_DEVICES));
#ifdef CYGNUM_FLASH_BASE_MASK
        // Then this gives us a maximum size for the (visible) device.
        // This is to cope with oversize devices fitted, with some high
        // address lines ignored.
        if ( ((unsigned int)flash_info.start & CYGNUM_FLASH_BASE_MASK) !=
             (((unsigned int)flash_info.end - 1) & CYGNUM_FLASH_BASE_MASK ) ) {
            // then the size of the device appears to span >1 device-worth!
            unsigned int x;
            x = (~(CYGNUM_FLASH_BASE_MASK)) + 1; // expected device size
            x += (unsigned int)flash_info.start;
            if ( x < (unsigned int)flash_info.end ) { // 2nd sanity check
                (*flash_info.pf)("\nFLASH: Oversized device!  End addr %p changed to %p\n",
                       flash_info.end, (void *)x );
                flash_info.end = (void *)x;
                // Also adjust the block count else unlock crashes!
                x = ((cyg_uint8 *)flash_info.end - (cyg_uint8 *)flash_info.start)
                    / flash_info.block_size;
                flash_info.blocks = x;
            }
        }
#endif // CYGNUM_FLASH_BASE_MASK

        return FLASH_ERR_OK;
    }
#ifdef CYGOPT_FLASH_IS_BOOTBLOCK
 flash_type_unknown:
#endif
    (*flash_info.pf)("Can't identify FLASH, sorry, man %x, dev %x, id [%4s] stat %x\n",
           qp->manuf_code, qp->device_code, qp->id, stat );
    diag_dump_buf(qp, sizeof(data));
    return FLASH_ERR_HWR;
}