OpenCores
URL https://opencores.org/ocsvn/pci/pci/trunk

Subversion Repositories pci

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 102 to Rev 103
    Reverse comparison

Rev 102 → Rev 103

/trunk/apps/sw/driver/pci_bridge32_test.h
0,0 → 1,82
// definition of maximum test application command length
#define MAX_COMMAND_LEN 100
#define MAX_DESCRIPTION_LEN 1000
#define NUM_OF_COMMANDS 15
 
char GSA_COMMANDS [NUM_OF_COMMANDS][MAX_COMMAND_LEN] = {
"help",
"quit",
"set_pci_region",
"write",
"read",
"target_write",
"dump",
"master_read",
"master_buf_fill",
"master_write",
"master_chk_write",
"target_chk_write",
"target_programmed_tests",
"set_wb_region",
"master_programmed_tests"
} ;
 
char GSA_COMMAND_DESCRIPTIONS [NUM_OF_COMMANDS][MAX_DESCRIPTION_LEN] = {
"Displays basic command and parameter reference.",
"Exits the program.",
"Selects one of 6 bridge pci address regions <region> for subsequent accesses.",
"Writes 32 bit word <value> to specified offset <offset> and performs read-back.",
"Reads data from the specified offset <offset>.",
"Initiates <number of transactions> write transactions with <transaction size> size. It starts from specified offset<offset>. <pattern> selects the pattern to write to on-board buffer.",
"Reads 32 words from specified offset<offset>.",
"Configures master to read data from the system memory buffer. Reads start at specified offset <offset>, using <number of transactions> read operations of size <transaction size>.",
"Fills system buffer with the specified pattern <pattern>.",
"Writes contents of device's RAM on specified offset to system memory. Writes start at specified offset <offset>, using <number of transactions> write operations of size <transaction size>.",
"Checks <size> words of data in system memory from offset <offset> against a specified pattern <pattern>.",
"Checks data in onboard buffer from offset <offset> against a specified pattern. Buffer is read with <number of transactions> transactions of size <transaction size>.",
"Performs arround 2M read/write transactions through target. Writes write pseudo random data, reads check the data.",
"Enables WISHBONE image <image[1:5]> for subsequent PCI Master accesses. The command doesn't check for implemented WB images!",
"Executes the master test program code written in the function in the pci_bridge32_test.c file!"
} ;
 
char GSA_PARAMETERS [NUM_OF_COMMANDS][MAX_COMMAND_LEN] = {
"",
"",
"<region[0:5]>",
"<offset> <value>",
"<offset>",
"<starting offset> <number of transactions> <transaction size> <pattern>",
"<offset>",
"<offset> <number of transactions> <transaction size>",
"<pattern>",
"<offset> <number of transactions> <transaction size>",
"<offset> <size> <pattern>",
"<offset> <number of transactions> <transaction size> <pattern>",
"",
"<image[1:5]>",
""
} ;
 
#define GET_CMD(i) (GSA_COMMANDS[i])
#define GET_CMD_DES(i) (GSA_COMMAND_DESCRIPTIONS[i])
#define GET_CMD_PARMS(i) (GSA_PARAMETERS[i])
 
#define SYS_BUFFER_SIZE (4096)
#define SPARTAN_BOARD_BUFFER_SIZE (1024)
 
#define TARGET_BUFFER_SIZE (1024)
 
#define MASTER_TRANS_SIZE_OFFSET (0x1000)
#define MASTER_TRANS_COUNT_OFFSET (0x1004)
#define MASTER_OP_CODE_OFFSET (0x1008)
#define MASTER_ADDR_REG_OFFSET (0x100c)
#define TARGET_BURST_TRANS_CNT_OFFSET (0x1010)
#define TARGET_TEST_SIZE_OFFSET (0x1014)
#define TARGET_TEST_START_ADR_OFFSET (0x1018)
#define TARGET_TEST_START_DATA_OFFSET (0x101C)
#define TARGET_TEST_ERR_REP_OFFSET (0x1020)
#define MASTER_NUM_OF_WB_OFFSET (0x1024)
#define MASTER_NUM_OF_PCI_OFFSET (0x1028)
#define MASTER_TEST_SIZE_OFFSET (0x102C)
#define MASTER_TEST_START_DATA_OFFSET (0x1030)
#define MASTER_TEST_DATA_ERROR_OFFSET (0x1034)
/trunk/apps/sw/driver/spartan_kint.h
1,7 → 1,7
#include <linux/ioctl.h>
 
#define SPARTAN_IOC_NUM 'S'
#define SPARTAN_IOC_MAX_NUM 10
#define SPARTAN_IOC_MAX_NUM 11
 
#define SPARTAN_IOC_CURRESGET _IO(SPARTAN_IOC_NUM, 1) // read current resource - (0 = none)
#define SPARTAN_IOC_CURRESSET _IO(SPARTAN_IOC_NUM, 2) // set current resource
12,7 → 12,8
#define SPARTAN_IOC_VIDEO_BASE _IOR(SPARTAN_IOC_NUM, 7, base) // read video buffer phyisical base address
#define SPARTAN_IOC_VIDEO_VBASE _IOR(SPARTAN_IOC_NUM, 8, base) // read video buffer virtual base address
#define SPARTAN_IOC_VIDEO_SIZE _IOR(SPARTAN_IOC_NUM, 9, base_size) // read video buffer size
#define SPARTAN_IOC_SET_VIDEO_BUFF _IO(SPARTAN_IOC_NUM, 10)
#define SPARTAN_IOC_SET_VIDEO_BUFF _IO(SPARTAN_IOC_NUM, 10) // fill video buffer
#define SPARTAN_IOC_GET_VIDEO_BUFF _IO(SPARTAN_IOC_NUM, 11) // copy video buffer to user space
 
 
#define SPARTAN_P_IMG_CTRL1_ADDR 0x110
/trunk/apps/sw/driver/spartan_drv.c
1,11 → 1,8
 
#define __KERNEL__
#define MODULE
 
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/wrapper.h>
 
#include <asm/uaccess.h>
#include <spartan_kint.h> //IOCTL definitions
19,15 → 16,20
#define OC_PCI_VENDOR 0x1895
#define OC_PCI_DEVICE 0x0001
#endif
#ifdef __OC_TEST__
#define OC_PCI_VENDOR 0x1895
#define OC_PCI_DEVICE 0x0001
#define __VGA__
#endif
 
// if someone wants specific major number assigned to spartan board - specify it here
// if 0 is used, kernel assigns it automaticaly
#ifdef __SDRAM__
#define REQUESTED_MAJOR 243
#define REQUESTED_MAJOR 0
#endif
 
#ifdef __VGA__
#define REQUESTED_MAJOR 244
#define REQUESTED_MAJOR 0
#endif
 
// if compiling module for kernel 2.4 - leave this defined
50,8 → 52,12
#define SPARTAN_IO_MAPPED 1
 
#ifdef __VGA__
#define VIDEO_SZ (640*480)
#ifdef __OC_TEST__
#define VIDEO_SZ (16384)
#else
#define VIDEO_SZ (640*480)
#endif
#endif
 
// structure for holding board information
// (6 base addresses, mapping, page etc.
236,6 → 242,12
}
 
return 0;
case SPARTAN_IOC_GET_VIDEO_BUFF:
for(i = 0; i < VIDEO_SZ; i++) {
put_user(*((char *)(pspartan_dev.video_vbase + i)), ((char *)(arg + i))) ;
}
 
return 0 ;
#endif
default:
return -EINVAL ;
309,7 → 321,9
unsigned long offset = pspartan_dev.offset ;
int resource_num = pspartan_dev.current_resource ;
int i;
int value;
unsigned int value;
unsigned int *kern_buf ;
unsigned int *kern_buf_tmp ;
 
unsigned long size = pspartan_dev.base_size[resource_num] ;
int result ;
329,15 → 343,24
if ((result = verify_area(VERIFY_WRITE, buf, actual_count)))
return result ;
kern_buf = kmalloc(actual_count, GFP_KERNEL | GFP_DMA) ;
kern_buf_tmp = kern_buf ;
if (kern_buf <= 0)
return 0 ;
memcpy_fromio(kern_buf, current_address, actual_count) ;
i = actual_count/4;
while(i--) {
value = readl(current_address);
put_user(value, ((int *)buf));
// value = readl(current_address);
value = *(kern_buf) ;
put_user(value, ((unsigned int *)buf));
buf += 4;
current_address += 4;
++kern_buf ;
// current_address += 4;
}
 
kfree(kern_buf_tmp);
pspartan_dev.offset = pspartan_dev.offset + actual_count ;
*(offset_out) = pspartan_dev.offset ;
356,6 → 379,8
int value;
unsigned long size = pspartan_dev.base_size[resource_num] ;
int result ;
int *kern_buf ;
int *kern_buf_tmp ;
if (pspartan_dev.current_resource < 0)
return -ENODEV ;
372,13 → 397,24
if ((result = verify_area(VERIFY_READ, buf, actual_count)))
return result ;
kern_buf = kmalloc(actual_count, GFP_KERNEL | GFP_DMA) ;
kern_buf_tmp = kern_buf ;
if (kern_buf <= 0)
return 0 ;
i = actual_count/4;
while(i--) {
get_user(value, ((int *)buf));
writel(value, current_address);
//writel(value, current_address);
*kern_buf = value ;
buf += 4;
current_address += 4;
//current_address += 4;
++kern_buf ;
}
 
memcpy_toio(current_address, kern_buf_tmp, actual_count) ;
kfree(kern_buf_tmp) ;
 
pspartan_dev.offset = pspartan_dev.offset + actual_count ;
*(offset_out) = pspartan_dev.offset ;
596,3 → 632,5
return ;
}
}
 
MODULE_LICENSE("GPL") ;
/trunk/apps/sw/driver/pci_bridge32_test
0,0 → 1,183
+  +¨¬°´¸¼ÀÄÈ Ì +Ð Ô ØÜàU‰åƒìè9èÏèš'ÉÃÿ5 ÿ%¤ÿ%¨héàÿÿÿÿ%¬héÐÿÿÿÿ%°héÀÿÿÿÿ%´hé°ÿÿÿÿ%¸h é ÿÿÿÿ%¼h(éÿÿÿÿ%Àh0é€ÿÿÿÿ%Äh8épÿÿÿÿ%Èh@é`ÿÿÿÿ%ÌhHéPÿÿÿÿ%ÐhPé@ÿÿÿÿ%ÔhXé0ÿÿÿÿ%Øh`é ÿÿÿÿ%Ühhéÿÿÿÿ%àhpéÿÿÿ1í^‰áƒäðPTRh€¬h„QVh°†è7ÿÿÿô‰öU‰åSPè[þ‘‹ƒH…ÀtÿЋ]üÉÉöU‰åƒì‹LÐ…ÒuI‹HЋ…Àtt&B£HÐÿ‹HЋ +…Éuê¸è„…Àtƒì hÀèœþÿÿƒÄ¸£LЉì]ÃvU‰åƒì‰ì]öU¸¸„‰åƒì…ÀtƒìhhÀè'þÿÿƒÄ‰ì]ô&U‰åƒì‰ì]öU‰å숃ìjhÀ¬è€þÿÿƒÄ‰À£ ƒ= -ƒì hͬè0þÿÿƒÄƒì h­è þÿÿƒÄ¡ ‰Àé ƒì hE­èþÿÿƒÄƒì h€­èóýÿÿƒÄèçfÇEòƒ}~Eƒìh¬­‹E ƒÀÿ0è*þÿÿƒÄ‰À‰Eôƒ}ôuƒì‹E ƒÀÿ0hÀ­è§ýÿÿƒÄë‰öfÇEòfƒ}òtAƒìÿuôjf…xÿÿÿPè]ýÿÿƒÄ‰À…ÀufÇEòë6ƒì…xÿÿÿPhä­èXýÿÿƒÄëvƒìÿ5jf…xÿÿÿPèýÿÿƒÄƒì …xÿÿÿPè;ƒÄ‰À…Àt +ƒÄ‰À…À„Tƒì jèRƒÄéB‰öƒìjÿuèƒÄ‰À…À„&ƒì jè$ƒÄéƒì ÿuè)ƒÄ‰À…À„üƒì jèúƒÄéê‰öƒìjÿuèÃĉÀ…À„΃ì j è̃Ä鼃ì ÿuèIƒÄ‰À…À„¤ƒì j +ƒÄ¸ÉÃvU‰åƒì‹EˆEÿƒìhSÿ5 è‘õÿÿƒÄ‰À‰Eøƒ}øƒì h`±è&õÿÿƒÄ¸ÿÿÿÿ骀}ÿvƒì h±èõÿÿƒÄ¸ÿÿÿÿ鉶Eÿ9Eø7ƒì¶EÿPh ±èÝôÿÿƒÄƒì‹EøHPÿuøhÀ±èÅôÿÿƒÄ¸ÿÿÿÿëLvƒì¶Eÿ@PhSÿ5 èïôÿÿƒÄ‰À‰Eøƒ}øtƒì¶EÿPh²èôÿÿƒÄ¸ÿÿÿÿë¸ÉÃU‰åƒìƒìhSÿ5 è£ôÿÿƒÄ‰ÀH‰ÀÉÃU‰åƒìƒì EøPEôPh@h;²ÿuèeôÿÿƒÄ ‰À‰Eüƒ}ütƒì h ¯è +ôÿÿƒÄ¸ÿÿÿÿéÕƒì ÿuôèŃĉÀ…Àt ƒìÿuôh`²èØóÿÿƒÄ¸é£vƒì ÿuøèUƒÄ‰À…Àtƒì h–²è§óÿÿƒÄ¸ëuƒì ÿuôèeƒÄ‰À…ÀtƒìÿuôhÀ²èxóÿÿƒÄ¸ëF‰öƒì EôPèlƒÄ‰À…Àtƒì hû²èJóÿÿƒÄ¸ëƒìÿuôh³è0óÿÿƒÄ¸ÉÉöU‰åƒìEôPh@h³ÿuèHóÿÿƒÄ‰À‰Eüƒ}ütƒì h ¯èíòÿÿƒÄ¸ÿÿÿÿëwvƒì ÿuô詃ĉÀ…Àtƒìÿuôh@³è¼òÿÿƒÄ¸ëF‰öƒì EøP调ĉÀ…Àtƒì hv³èŽòÿÿƒÄ¸ëƒìÿuøh³ètòÿÿƒÄ¸ÉÉöU‰åƒìƒìjU‰ÐPÿ5 èüñÿÿƒÄ‰À‰Eüƒ}üt +è¿íÿÿ‰À‰ÀëÉÉöU‰å쨅dÿÿÿPh@h³ÿuèbíÿÿƒÄ‰À‰Eôƒ}ôtƒì h@µèíÿÿƒÄ¸ÿÿÿÿé'‰öƒì ÿµdÿÿÿè¾úÿÿƒÄ‰À…Àt!ƒìÿµdÿÿÿh@³èÎìÿÿƒÄ¸éîƒìh€…hÿÿÿPÿ5 è&íÿÿƒÄ‰À=€tƒìj h µè‹ìÿÿƒÄ¸é«‰öƒìEðPhS€ÿ5 èµìÿÿƒÄÇEôvƒ}ô~ëhƒì‹…dÿÿÿ‹Uð‹Eô‰ÀÁàPhßµè,ìÿÿƒÄƒì ‹Eôÿ´…tÿÿÿ‹Eôÿ´…pÿÿÿ‹Eôÿ´…lÿÿÿ‹Eôÿ´…hÿÿÿhéµèôëÿÿƒÄ Eôƒ둃ì hç­èÛëÿÿƒÄ¸ÉÃU‰åƒìƒìEôPEøPEüPh@h¶ÿuèéëÿÿƒÄ ‰Àƒøtƒì h`®è’ëÿÿƒÄ¸ÿÿÿÿëI‹Eø‰Â¯Uô‹EüÁè=vƒì h ¶èbëÿÿƒÄ¸ëÿu ÿuüÿuôÿuøè߃ĸÉÃU‰åì@‹EˆE÷ƒì ¶E÷PèüÿÿƒÄ‰À‰…è¿ÿÿÇEð‰ö}ðÿ~ëIƒì¶E÷P‹Eð‰ÀÁàPü…è¿ÿÿ‰Àÿ4èÙüÿÿƒÄ‰Á‹Eð‰À……è¿ÿÿ‰À‰ Eðÿ뮉öƒì…è¿ÿÿPh +véþ‰öƒì hèŸòÿÿƒÄ‰À…Àtƒì h¹èµäÿÿƒÄ¸é¥ƒ}üv2ƒì hè-òÿÿƒÄ‰À…ÀtLƒì h@¹èäÿÿƒÄ¸éo‰öƒì hèûñÿÿƒÄ‰À…Àtƒì h@¹èMäÿÿƒÄ¸é=jjhjètòÿÿƒÄ‰À…Àtƒì h€¹èäÿÿƒÄ¸é +ÞÿÿƒÄ¸é•ƒì hèÇëÿÿƒÄ‰À…Àtƒì hkºèÝÝÿÿƒÄ¸éeƒì jè^ëÿÿƒÄ‰À…Àtƒì hà¼è°ÝÿÿƒÄ¸é8vƒ}üuvƒì h@½èÝÿÿƒÄƒì jèTëÿÿƒÄ‰À…Àtƒì hkºèjÝÿÿƒÄ¸éòƒì jèÂîÿÿƒÄ‰ÀPèßêÿÿƒÄ‰À…Àtƒì h@»è1ÝÿÿƒÄ¸é¹ÇEøƒ}øv +EüÿéÔüÿÿƒìjjhèóÿÿƒÄƒì h¦½èëÜÿÿƒÄEøÿëÅÇEøƒì h$è êÿÿƒÄ‰À…Àtƒì hkºè¶ÜÿÿƒÄ¸é>ƒì EøPè¨êÿÿƒÄ‰À…Àtƒì hÀ»è†ÜÿÿƒÄ¸é‹EüH‰ÀÁà 9Eøt2ƒì hÀ½è]ÜÿÿƒÄƒìÿuø‹EüH‰ÀÁà Phõ½è@ÜÿÿƒÄëvƒìÿuøh ¾è(ÜÿÿƒÄƒì h(èìéÿÿƒÄ‰À…Àtƒì hkºèÜÿÿƒÄ¸éŠÇEøƒì EøPèíéÿÿƒÄ‰À…Àtƒì hÀºèËÛÿÿƒÄ¸ëV‹EüH‰ÀÁà 9Eøt2ƒì h`¾è¥ÛÿÿƒÄƒìÿuø‹EüH‰ÀÁà Phõ½èˆÛÿÿƒÄëvƒì h ¾èsÛÿÿƒÄ¸ÉÃU‰åƒìƒìEüPhS€ÿ5 è›ÛÿÿƒÄƒì h èéÿÿƒÄ‰À…Àtƒì hkºè%ÛÿÿƒÄ¸é=ƒì ‹EEüPè¡èÿÿƒÄ‰À…Àtƒì hà¾èóÚÿÿƒÄ¸é ‰öƒì hè«èÿÿƒÄ‰À…Àtƒì hkºèÁÚÿÿƒÄ¸éÙƒì ÿuèAèÿÿƒÄ‰À…Àtƒì h ¿è“ÚÿÿƒÄ¸é«‰öƒì hèKèÿÿƒÄ‰À…Àtƒì hkºèaÚÿÿƒÄ¸éyƒì ÿu èáçÿÿƒÄ‰À…Àtƒì h`¿è3ÚÿÿƒÄ¸éK‰öƒì hèëçÿÿƒÄ‰À…Àtƒì hkºèÚÿÿƒÄ¸éƒì ÿuèçÿÿƒÄ‰À…Àtƒì hà¼èÓÙÿÿƒÄ¸éë‰ö‹E‰EøÇEôvƒ}ø„ªƒ}ôcvéŸvÇEð‹Eø‰Â¯U ‰ÐÁàÐ…ÐÁà9Eðrë EðÿëÕƒì hè/çÿÿƒÄ‰À…Àtƒì hkºèEÙÿÿƒÄ¸ë`vƒì EøPè8çÿÿƒÄ‰À…Àtƒì h›¿èÙÿÿƒÄ¸ë1EôÿéNÿÿÿ‰ö}ô uƒì hÀ¿èêØÿÿƒÄ¸ë¸ÉÃU‰åSƒì¡Œ»Œƒøÿtv¼'ƒëÿЋƒøÿuôX[]ÃU‰åƒì‰ì]öU‰åSRè[ÃkvègÙÿÿ‹]üÉÃ/dev/spartan +Spartan device not found! + +The /dev/spartan device must exist with appropriate module loaded! + +PCI Bridge Test Application + +Type help for list of available commands + +r +Cannot open file %s in read mode! +%s + +pci> + +Error: Unknown command! + +$‰8‰D‰p‰œ‰ȉô‰ ŠLŠxŠ¤ŠЊôŠ‹4‹%s %s +: %s + +%s %u +Error: Wrong command, parameter or number of parameters! + +Note: Selected region's base address 0x%x + +Note: Selected region's size %d +%s %d +Error: Invalid command, parameter or number of parameters! + +Error: Invalid WB image selected! + +Error: Failed to activate pci region 0 - configuration image! + +Error: Failed to write one of the WB address mask registers! + +Error: Failed to write one of the WB address mask registers!. + +Error: Failed to write selected WB base address register! + +Error: Failed to write WB base address register!. + +Error: Failed to write selected WB address mask register! + +Error: Failed to write selected WB address mask register!. + +Error: Error accessing device! + +Error: Invalid region! + +Error: You selected region %u +Driver reports only %u [0:%u] regions available! + +Error: Driver reported failure to intialize resource %u! +%s %x %x +Error: Write failed. Couldn't write to offset 0x%x! + +Error: Write failed. + +Error: Read-back failed. Couldn't read from offset 0x%x! + +Error: Read-back failed. + +0x%08x +%s %x +Error: Read failed. Couldn't read from offset 0x%x! + +Error: Read failed. + +Error: Seek failed! + +Error: Write test failed. Transaction number %d couldn't finish %d writes through target! + +Error: Check data failed. Transaction number %d couldn't finish %d reads through target! + +Error: Value on offset 0x%x not as expected! + +Expected value: 0x%x +Actual value: 0x%x +°–¸–À–ä–ì–ô–@—l—¤—´—¼—Ä— +Error: Wrong command, parameter or invalid number of parameters! + +Error: Read failed. Couldn't finish %d reads through target! + +0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x%s %x %u %u +Error: Size of data from specifed offset crosses system buffer boundary! + +Error: Invalid pattern selected! + +Error: words of data from specified offset cross system buffer boundary! + +Error: Data on offset 0x%x wrong! +Expected data 0x%08x, actual 0x%08x! +%s %x %u %u %u +Error: Size of write transfers exceeds the buffer size! + +Error: Specified number of writes from specified offset will exceede Target buffer size! + +Error: Wrong command, parameter or number of parameters. + +Error: Specified number of writes from specified offset will cross Target buffer boundary! +Error: Couldn't get target image base address!Error: Seek failed!Error: Write to register failed!Error: Write through target failed!Error: Write failed!Error: Read failed!Error: Value in the error status register not as expected!Error: read failed!Error: Test application detected an error! +Error: Seek error! + +Error: Write to register failed + +Error: Read from register failed + +Error: Transaction counter clear operation not OK! + +Error: Write to register failed! + +Error: Read from master number of transactions failed! + +Error: Read from register failed! + +Note: The following error is produced intentionally, to test software/hardware functionality! + +Error: Test application detected an error in the data sequence on the PCI Master side of the bridge! + +Error: Unable to write master number of transactions register! + +Note: The following two errors are produced intentionally, to test software/hardware functionality! +juhu +Error: Number of WISHBONE transactions unexpected! +Expected %u, actual %u + +Note: %u WISHBONE Slave write transfers reported succesfull! + +Error: Number of PCI transactions unexpected! +Note: %u PCI Master write transfers reported succesfull! + +Error: Unable to write master address register! + +Error: Unable to write master opcode register! + +Error: Unable to write master transaction size register! + +Error: Read failed! + +Error: The requested master operation is not beeing processed. Is at least one wb image enabled? +€¬(ð‚À +Á œx„„þÿÿo؃ÿÿÿoðÿÿo²ƒÿÿÿÿÿÿÿÿľ„΄Þ„î„þ„…….…>…N…^…n…~…Ž…ž…¢ƒdÔ…dÔ…9<H€r€Œ€»€ó€0€€Ò€ý€,€V€€™€´€Õ€€1€V€€€©‚¢¢ ‚cV$‚ï[L‚b‚y‚¢¢¢‚ØƀǢڀ ñ€!€"€#3€%K€&a€1x€2€3§€4À€5Ø€6ñ€8 €9"€;B€=X€>n€?„€@š€A±€BÉ€C߀Dö€E €F$€G;€HT€Ii€NÏ€Qç€R€S€T9€UU€Vm€X…€[Ÿ€^·€eÍ€hç€l €q €r5 €uP €vm €yˆ €z¥ €}½ €€Ö €ƒñ €„ +€‡& +€Š@ +‚Ë”t +‚Fœ +€¢Ò +€^€Ù€lù€tM€yn€ö€†4€Œ¢¢‚ +L€b€8¢w‚Š‚b‚¢œ‚¢É€K¢¢L€€#Ô‚ç‚5ÁLÂwŠ‚Âœ¢Âø€×€€H8€Kg€L˜€UË€Z€^?€aw€b¯€\€€û€r€­¢¢–€5 €7!€89€9S€:¢m dÔ…init.c/usr/src/build/87998-i386/BUILD/glibc-2.2.5/csu/gcc2_compiled.int:t(0,1)=r(0,1);-2147483648;2147483647;char:t(0,2)=r(0,2);0;127;long int:t(0,3)=r(0,3);-2147483648;2147483647;unsigned int:t(0,4)=r(0,4);0000000000000;0037777777777;long unsigned int:t(0,5)=r(0,5);0000000000000;0037777777777;long long int:t(0,6)=@s64;r(0,6);01000000000000000000000;0777777777777777777777;long long unsigned int:t(0,7)=@s64;r(0,7);0000000000000;01777777777777777777777;short int:t(0,8)=@s16;r(0,8);-32768;32767;short unsigned int:t(0,9)=@s16;r(0,9);0;65535;signed char:t(0,10)=@s8;r(0,10);-128;127;unsigned char:t(0,11)=@s8;r(0,11);0;255;float:t(0,12)=r(0,1);4;0;double:t(0,13)=r(0,1);8;0;long double:t(0,14)=r(0,1);12;0;complex int:t(0,15)=s8real:(0,1),0,32;imag:(0,1),32,32;;complex float:t(0,16)=r(0,16);8;0;complex double:t(0,17)=r(0,17);16;0;complex long double:t(0,18)=r(0,18);24;0;__builtin_va_list:t(0,19)=*(0,20)=(0,20)../include/libc-symbols.h/usr/src/build/87998-i386/BUILD/glibc-2.2.5/build-i386-linux/config.h../sysdeps/gnu/_G_config.h../sysdeps/unix/sysv/linux/bits/types.h../include/features.h../include/sys/cdefs.h../misc/sys/cdefs.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.hsize_t:t(8,1)=(0,4)__u_char:t(4,1)=(0,11)__u_short:t(4,2)=(0,9)__u_int:t(4,3)=(0,4)__u_long:t(4,4)=(0,5)__u_quad_t:t(4,5)=(0,7)__quad_t:t(4,6)=(0,6)__int8_t:t(4,7)=(0,10)__uint8_t:t(4,8)=(0,11)__int16_t:t(4,9)=(0,8)__uint16_t:t(4,10)=(0,9)__int32_t:t(4,11)=(0,1)__uint32_t:t(4,12)=(0,4)__int64_t:t(4,13)=(0,6)__uint64_t:t(4,14)=(0,7)__qaddr_t:t(4,15)=(4,16)=*(4,6)__dev_t:t(4,17)=(4,5)__uid_t:t(4,18)=(4,3)__gid_t:t(4,19)=(4,3)__ino_t:t(4,20)=(4,4)__mode_t:t(4,21)=(4,3)__nlink_t:t(4,22)=(4,3)__off_t:t(4,23)=(0,3)__loff_t:t(4,24)=(4,6)__pid_t:t(4,25)=(0,1)__ssize_t:t(4,26)=(0,1)__rlim_t:t(4,27)=(4,4)__rlim64_t:t(4,28)=(4,5)__id_t:t(4,29)=(4,3)__fsid_t:t(4,30)=(4,31)=s8__val:(4,32)=ar(4,33)=r(4,33);0000000000000;0037777777777;;0;1;(0,1),0,64;;__daddr_t:t(4,34)=(0,1)__caddr_t:t(4,35)=(4,36)=*(0,2)__time_t:t(4,37)=(0,3)__useconds_t:t(4,38)=(0,4)__suseconds_t:t(4,39)=(0,3)__swblk_t:t(4,40)=(0,3)__clock_t:t(4,41)=(0,3)__clockid_t:t(4,42)=(0,1)__timer_t:t(4,43)=(0,1)__key_t:t(4,44)=(0,1)__ipc_pid_t:t(4,45)=(0,9)__blksize_t:t(4,46)=(0,3)__blkcnt_t:t(4,47)=(0,3)__blkcnt64_t:t(4,48)=(4,6)__fsblkcnt_t:t(4,49)=(4,4)__fsblkcnt64_t:t(4,50)=(4,5)__fsfilcnt_t:t(4,51)=(4,4)__fsfilcnt64_t:t(4,52)=(4,5)__ino64_t:t(4,53)=(4,5)__off64_t:t(4,54)=(4,24)__t_scalar_t:t(4,55)=(0,3)__t_uscalar_t:t(4,56)=(0,5)__intptr_t:t(4,57)=(0,1)__socklen_t:t(4,58)=(0,4)../linuxthreads/sysdeps/pthread/bits/pthreadtypes.h../sysdeps/unix/sysv/linux/bits/sched.h__sched_param:T(10,1)=s4__sched_priority:(0,1),0,32;;_pthread_fastlock:T(9,1)=s8__status:(0,3),0,32;__spinlock:(0,1),32,32;;_pthread_descr:t(9,2)=(9,3)=*(9,4)=xs_pthread_descr_struct:__pthread_attr_s:T(9,5)=s36__detachstate:(0,1),0,32;__schedpolicy:(0,1),32,32;__schedparam:(10,1),64,32;__inheritsched:(0,1),96,32;__scope:(0,1),128,32;__guardsize:(8,1),160,32;__stackaddr_set:(0,1),192,32;__stackaddr:(0,19),224,32;__stacksize:(8,1),256,32;;pthread_attr_t:t(9,6)=(9,5)pthread_cond_t:t(9,7)=(9,8)=s12__c_lock:(9,1),0,64;__c_waiting:(9,2),64,32;;pthread_condattr_t:t(9,9)=(9,10)=s4__dummy:(0,1),0,32;;pthread_key_t:t(9,11)=(0,4)pthread_mutex_t:t(9,12)=(9,13)=s24__m_reserved:(0,1),0,32;__m_count:(0,1),32,32;__m_owner:(9,2),64,32;__m_kind:(0,1),96,32;__m_lock:(9,1),128,64;;pthread_mutexattr_t:t(9,14)=(9,15)=s4__mutexkind:(0,1),0,32;;pthread_once_t:t(9,16)=(0,1)_pthread_rwlock_t:T(9,17)=s32__rw_lock:(9,1),0,64;__rw_readers:(0,1),64,32;__rw_writer:(9,2),96,32;__rw_read_waiting:(9,2),128,32;__rw_write_waiting:(9,2),160,32;__rw_kind:(0,1),192,32;__rw_pshared:(0,1),224,32;;pthread_rwlock_t:t(9,18)=(9,17)pthread_rwlockattr_t:t(9,19)=(9,20)=s8__lockkind:(0,1),0,32;__pshared:(0,1),32,32;;pthread_spinlock_t:t(9,21)=(0,1)pthread_barrier_t:t(9,22)=(9,23)=s20__ba_lock:(9,1),0,64;__ba_required:(0,1),64,32;__ba_present:(0,1),96,32;__ba_waiting:(9,2),128,32;;pthread_barrierattr_t:t(9,24)=(9,25)=s4__pshared:(0,1),0,32;;pthread_t:t(9,26)=(0,5)wchar_t:t(11,1)=(0,3)wint_t:t(11,2)=(0,4)../include/wchar.h../wcsmbs/wchar.h../sysdeps/unix/sysv/linux/i386/bits/wchar.h__mbstate_t:t(13,1)=(13,2)=s8__count:(0,1),0,32;__value:(13,3)=u4__wch:(11,2),0,32;__wchb:(13,4)=ar(4,33);0;3;(0,2),0,32;;,32,32;;_G_fpos_t:t(3,1)=(3,2)=s12__pos:(4,23),0,32;__state:(13,1),32,64;;_G_fpos64_t:t(3,3)=(3,4)=s16__pos:(4,54),0,64;__state:(13,1),64,64;;../include/gconv.h../iconv/gconv.h :T(17,1)=e__GCONV_OK:0,__GCONV_NOCONV:1,__GCONV_NODB:2,__GCONV_NOMEM:3,__GCONV_EMPTY_INPUT:4,__GCONV_FULL_OUTPUT:5,__GCONV_ILLEGAL_INPUT:6,__GCONV_INCOMPLETE_INPUT:7,__GCONV_ILLEGAL_DESCRIPTOR:8,__GCONV_INTERNAL_ERROR:9,; :T(17,2)=e__GCONV_IS_LAST:1,__GCONV_IGNORE_ERRORS:2,;__gconv_fct:t(17,3)=(17,4)=*(17,5)=f(0,1)__gconv_init_fct:t(17,6)=(17,7)=*(17,8)=f(0,1)__gconv_end_fct:t(17,9)=(17,10)=*(17,11)=f(0,20)__gconv_trans_fct:t(17,12)=(17,13)=*(17,14)=f(0,1)__gconv_trans_context_fct:t(17,15)=(17,16)=*(17,17)=f(0,1)__gconv_trans_query_fct:t(17,18)=(17,19)=*(17,20)=f(0,1)__gconv_trans_init_fct:t(17,21)=(17,22)=*(17,23)=f(0,1)__gconv_trans_end_fct:t(17,24)=(17,25)=*(17,26)=f(0,20)__gconv_trans_data:T(17,27)=s20__trans_fct:(17,12),0,32;__trans_context_fct:(17,15),32,32;__trans_end_fct:(17,24),64,32;__data:(0,19),96,32;__next:(17,28)=*(17,27),128,32;;__gconv_step:T(17,29)=s56__shlib_handle:(17,30)=*(17,31)=xs__gconv_loaded_object:,0,32;__modname:(17,32)=*(0,2),32,32;__counter:(0,1),64,32;__from_name:(4,36),96,32;__to_name:(4,36),128,32;__fct:(17,3),160,32;__init_fct:(17,6),192,32;__end_fct:(17,9),224,32;__min_needed_from:(0,1),256,32;__max_needed_from:(0,1),288,32;__min_needed_to:(0,1),320,32;__max_needed_to:(0,1),352,32;__stateful:(0,1),384,32;__data:(0,19),416,32;;__gconv_step_data:T(17,33)=s36__outbuf:(17,34)=*(0,11),0,32;__outbufend:(17,34),32,32;__flags:(0,1),64,32;__invocation_counter:(0,1),96,32;__internal_use:(0,1),128,32;__statep:(17,35)=*(13,1),160,32;__state:(13,1),192,64;__trans:(17,28),256,32;;__gconv_info:T(17,36)=s8__nsteps:(8,1),0,32;__steps:(17,37)=*(17,29),32,32;__data:(17,38)=ar(4,33);0;-1;(17,33),64,0;;__gconv_t:t(17,39)=(17,40)=*(17,36)_G_iconv_t:t(3,5)=(3,6)=u44__cd:(17,36),0,64;__combined:(3,7)=s44__cd:(17,36),0,64;__data:(17,33),64,288;;,0,352;;_G_int16_t:t(3,8)=(0,8)_G_int32_t:t(3,9)=(0,1)_G_uint16_t:t(3,10)=(0,9)_G_uint32_t:t(3,11)=(0,4)_IO_stdin_used:G(0,1)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.3 2.96-110)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.3 2.96-110)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.3 2.96-110)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.3 2.96-110)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.3 2.96-110)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.3 2.96-110)01.0101.0101.0101.0101.0101.01.symtab.strtab.shstrtab.interp.note.ABI-tag.hash.dynsym.dynstr.gnu.version.gnu.version_r.rel.dyn.rel.plt.init.text.fini.rodata.data.eh_frame.dynamic.ctors.dtors.got.bss.stab.stabstr.comment.noteô€ô# 1((˜7 ÀÀ0?ð‚ðÁGÿÿÿo²ƒ²&Tþÿÿo؃Ø0c „l „x u„p¨„¨{°…°Ð&€¬€,‡ ¬ ,  @Ð@@€F •ÀÀ†ŸÄĆȨŒŒ‡¯””‡¶œœ‡L»ˆ¨ Àˆ¤ ƤƒÏ'©JØqªxéªÞP°: à·çô€(Àð‚²ƒ؃„„ „ + ¬@ÐÀÄŒ”œñÿñÿÔ… "Ô… 2ñÿ† =HÐA”OLÐ[† qÀ„`† ˜p† ¤ † ¯PнŒ2ñÿ@¬ Ë@¬ á¤p¬ ¯Àî˜ûÀñÿ€¬ ñÿ°†  (Ä1¸„•"RÈ„@cØ„%u ¬|¬›– ‘£— ®@e¹\“[ É`ÐÜÖðŒÅ ê„ +¨ñÿh…@#¼5F°© SH™“ ax… rÐ" |ô‘º …¤¬”ì’7 œ@Щ4žé ¸ˆ…Ș…@Ø init.cinitfini.cgcc2_compiled.call_gmon_startcrtstuff.cp.0__DTOR_LIST__completed.1__do_global_dtors_aux__EH_FRAME_BEGIN__fini_dummyobject.2frame_dummyinit_dummyforce_to_data__CTOR_LIST____do_global_ctors_aux__CTOR_END____DTOR_END____FRAME_END__pci_bridge32_test.cspartan_fd_DYNAMIC__register_frame_info@@GLIBC_2.0write@@GLIBC_2.0strcmp@@GLIBC_2.0_fp_hwsp_master_check_datacmd_master_slide_window_testunused_strsp_target_writeGSA_COMMANDScmd_enable_wb_image_initGSA_PARAMETERS__deregister_frame_info@@GLIBC_2.0cmd_master_fillsp_writecmd_master_chksp_set_regioncmd_target_write_startfgets@@GLIBC_2.0sp_get_pci_regioncmd_helpGSA_COMMAND_DESCRIPTIONScmd_select_regionsp_get_next_valmaster_buffer_fill__bss_startsp_readcmd_target_slide_window_testmain__libc_start_main@@GLIBC_2.0sp_get_first_valcmd_burst_readdata_startsp_target_check_dataprintf@@GLIBC_2.0_finilseek@@GLIBC_2.0srand@@GLIBC_2.0open@@GLIBC_2.0promptexecute_commandsscanf@@GLIBC_2.0_edata_GLOBAL_OFFSET_TABLE__endioctl@@GLIBC_2.0guint_random_seedstdin@@GLIBC_2.0sp_master_docmd_master_dofopen@@GLIBC_2.1cmd_writecmd_read_IO_stdin_usedsp_seek__data_startcmd_target_chkrand@@GLIBC_2.0read@@GLIBC_2.0__gmon_start__ \ No newline at end of file
trunk/apps/sw/driver/pci_bridge32_test Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/apps/sw/driver/pci_bridge32_test.c =================================================================== --- trunk/apps/sw/driver/pci_bridge32_test.c (nonexistent) +++ trunk/apps/sw/driver/pci_bridge32_test.c (revision 103) @@ -0,0 +1,1282 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define WALKING_ONES 0 +#define WALKING_ZEROS 1 +#define INVERTED_ADDRESS 2 +#define ALL_ZEROS 3 +#define ALL_ONES 4 +#define PSEUDO_RANDOM 5 + +#define MAX_PATTERN 5 + +unsigned int guint_random_seed = 1 ; + +void prompt(void) ; +int execute_command(char *command) ; +void cmd_help (int command_num) ; +int cmd_select_region (char *command_str) ; +int sp_set_region(unsigned char region) ; +int sp_write (unsigned int value) ; +int sp_read(unsigned int *value) ; +int cmd_write (char *command_str) ; +int cmd_read (char *command_str) ; +int cmd_burst_read(char *command_str) ; +int cmd_target_write(char *command_str) ; +int cmd_master_do(char *command_str, unsigned int opcode) ; +#define cmd_master_write(command_str) cmd_master_do(command_str, 0x00000001) +#define cmd_master_read(command_str) cmd_master_do(command_str, 0x00000000) +int cmd_master_fill(char *command_str) ; +int cmd_target_slide_window_test (void) ; +int cmd_master_slide_window_test (void) ; +int cmd_enable_wb_image (char *command_str) ; +void master_buffer_fill(unsigned char pattern) ; +int cmd_master_chk(char *command_str) ; +int cmd_target_chk(char *command_str) ; +int sp_target_write(unsigned int num_of_transactions, unsigned int transaction_size, unsigned int starting_offset, unsigned char pattern) ; +int sp_target_check_data(unsigned int num_of_transactions, unsigned int transaction_size, unsigned int starting_offset, unsigned char pattern) ; +int sp_master_check_data(unsigned int size, unsigned int offset, unsigned char pattern) ; +int sp_master_do(unsigned int num_of_transactions, unsigned int transaction_size, unsigned int starting_offset, unsigned int opcode) ; +#define sp_master_write(num_of_transactions, transaction_size, starting_offset) sp_master_do(num_of_transactions, transaction_size, starting_offset, 0x00000001) +#define sp_master_read(num_of_transactions, transaction_size, starting_offset) sp_master_do(num_of_transactions, transaction_size, starting_offset, 0x00000000) +int sp_get_pci_region (void) ; +unsigned int sp_get_first_val(unsigned char pattern) ; +unsigned int sp_get_next_val(unsigned int cur_val, unsigned char pattern) ; + +int spartan_fd ; + +char unused_str [MAX_COMMAND_LEN + 1] ; + +int main(int argc, char* argv[]) +{ + FILE* cmd_file_fd ; + + unsigned short use_cmd_file ; + + char current_command [MAX_COMMAND_LEN + 2] ; + + spartan_fd = open("/dev/spartan", O_RDWR) ; + + if (spartan_fd <= 0) { + printf("\nSpartan device not found!\n") ; + printf("\nThe /dev/spartan device must exist with appropriate module loaded!\n") ; + return spartan_fd ; + } + + printf("\nPCI Bridge Test Application\n") ; + printf("\nType help for list of available commands\n\n"); + prompt() ; + + use_cmd_file = 0 ; + + if (argc > 1) { + + // command line argument is input file name - open the file + cmd_file_fd = fopen(argv[1], "r") ; + if (cmd_file_fd <= 0) { + printf("\nCannot open file %s in read mode!\n", argv[1]) ; + } + else + use_cmd_file = 1 ; + } + + while (1) { + + if (use_cmd_file) + if (fgets(current_command, MAX_COMMAND_LEN + 2, cmd_file_fd) == NULL) + use_cmd_file = 0 ; + else + printf ("%s", current_command) ; + else + fgets(current_command, MAX_COMMAND_LEN + 2, stdin) ; + + if (execute_command(current_command)) { + return 0 ; + } + prompt() ; + } + + printf("\n") ; + return 0 ; +} + +void prompt (void) { + printf("\npci> ") ; +} + +int execute_command (char *command) { + int i = 0 ; + char command_wo_param [MAX_COMMAND_LEN + 1] ; + int result ; + + if (!(strcmp("\n", command))) return 0 ; + + result = sscanf(command, "%s", command_wo_param) ; + + if (result == EOF) return 0 ; + + if (result != 1) return 0 ; + + while ((i < NUM_OF_COMMANDS) & (strcmp(GET_CMD(i), command_wo_param))) { + ++i ; + } + + switch (i) { + case 0 : cmd_help(-1); break ; + case 1 : return 1 ; + case 2 : if (cmd_select_region (command)) cmd_help( 2) ; break ; + case 3 : if (cmd_write (command)) cmd_help( 3) ; break ; + case 4 : if (cmd_read (command)) cmd_help( 4) ; break ; + case 5 : if (cmd_target_write (command)) cmd_help( 5) ; break ; + case 6 : if (cmd_burst_read (command)) cmd_help( 6) ; break ; + case 7 : if (cmd_master_read (command)) cmd_help( 7) ; break ; + case 8 : if (cmd_master_fill (command)) cmd_help( 8) ; break ; + case 9 : if (cmd_master_write (command)) cmd_help( 9) ; break ; + case 10: if (cmd_master_chk (command)) cmd_help(10) ; break ; + case 11: if (cmd_target_chk (command)) cmd_help(11) ; break ; + case 12: if (cmd_target_slide_window_test()) cmd_help(12) ; break ; + case 13: if (cmd_enable_wb_image (command)) cmd_help(13) ; break ; + case 14: if (cmd_master_slide_window_test()) cmd_help(14) ; break ; + default: printf("\n\nError: Unknown command!\n\n") ; + } + + return 0 ; +} + +void cmd_help (int command_num) { + int i, start, end ; + + if (command_num >= 0) start = end = command_num ; + else { start = 0 ; end = NUM_OF_COMMANDS - 1; } + + for (i = start ; i <= end ; ++i) { + printf("%s %s\n: %s\n\n", GET_CMD(i), GET_CMD_PARMS(i), GET_CMD_DES(i)) ; + } +} + +int cmd_select_region (char *command_str) { + int result ; + unsigned char sel_region ; + unsigned int base ; + unsigned int base_size ; + + result = sscanf(command_str, "%s %u", unused_str, &sel_region) ; + + if (result != 2) { + printf("\nError: Wrong command, parameter or number of parameters!\n") ; + return -1 ; + } + + result = sp_set_region (sel_region) ; + + if (result) return 0 ; + + result = ioctl(spartan_fd, SPARTAN_IOC_CURBASE, &base) ; + printf("\nNote: Selected region's base address 0x%x\n", base) ; + + result = ioctl(spartan_fd, SPARTAN_IOC_CURBASESIZE, &base_size) ; + printf("\nNote: Selected region's size %d\n", base_size) ; + + return 0 ; +} + +int cmd_enable_wb_image (char *command_str) { + + // store current selected pci image number + int current_pci_region = sp_get_pci_region() ; + unsigned int region ; + unsigned int i ; + unsigned int base ; + + + // check the parameter passed with the command + if (sscanf(command_str, "%s %d", unused_str, ®ion) != 2) { + printf("\nError: Invalid command, parameter or number of parameters!\n") ; + return -1; + } + + if ((region > 5) | (!region)) { + printf("\nError: Invalid WB image selected!\n") ; + return -1 ; + } + + // activate region 0 - configuration space + if (sp_set_region(0)) { + printf("\nError: Failed to activate pci region 0 - configuration image!\n") ; + return 0 ; + } + + // first disable all wb images! + for ( i = 0x18C ; i <= 0x1CC ; i = i + 0x10 ) { + if (sp_seek(i)) { + printf("\nError: Failed to write one of the WB address mask registers!\n") ; + if (current_pci_region >= 0) sp_set_region(current_pci_region) ; + return 0 ; + } + + if (sp_write(0x00000000)) { + printf("\nError: Failed to write one of the WB address mask registers!.\n") ; + if (current_pci_region >= 0) sp_set_region(current_pci_region) ; + return 0 ; + } + } + + // get base address of the system memory buffer + ioctl(spartan_fd, SPARTAN_IOC_VIDEO_BASE, &base) ; + + i = 0x178 + 0x10 * region ; + + if (sp_seek(i)) { + printf("\nError: Failed to write selected WB base address register!\n") ; + if (current_pci_region >= 0) sp_set_region(current_pci_region) ; + return 0 ; + } + + if (sp_write(base)) { + printf("\nError: Failed to write WB base address register!.\n") ; + if (current_pci_region >= 0) sp_set_region(current_pci_region) ; + return 0 ; + } + + // write address mask register with all ones. + i = 0x17C + 0x10 * region ; + + if (sp_seek(i)) { + printf("\nError: Failed to write selected WB address mask register!\n") ; + if (current_pci_region >= 0) sp_set_region(current_pci_region) ; + return 0 ; + } + + if (sp_write(0xFFFFFFFF)) { + printf("\nError: Failed to write selected WB address mask register!.\n") ; + if (current_pci_region >= 0) sp_set_region(current_pci_region) ; + return 0 ; + } + + if (current_pci_region >= 0) sp_set_region(current_pci_region) ; + + return 0 ; +} + +int sp_set_region(unsigned char region) { + int result = ioctl(spartan_fd, SPARTAN_IOC_NUMOFRES) ; + + if (result <= 0) { + printf("\nError: Error accessing device!\n") ; + return -1 ; + } + + if (region > 5 ) { + printf("\nError: Invalid region!\n") ; + return -1 ; + } + + if (result <= region) { + printf("\nError: You selected region %u\n", region) ; + printf("Driver reports only %u [0:%u] regions available!\n", result, result - 1) ; + return -1 ; + } + + result = ioctl(spartan_fd, SPARTAN_IOC_CURRESSET, region + 1) ; + + if (result) { + printf("\nError: Driver reported failure to intialize resource %u!\n", region) ; + return -1; + } + + return 0 ; +} + +int sp_get_pci_region (void) { + return (ioctl(spartan_fd, SPARTAN_IOC_CURRESGET) - 1) ; +} + +int cmd_write (char *command_str) { + int result ; + unsigned int value ; + unsigned int offset ; + + result = sscanf(command_str, "%s %x %x", unused_str, &offset, &value) ; + if (result != 3) { + printf("\nError: Invalid command, parameter or number of parameters!\n") ; + return -1; + } + + if (sp_seek(offset)) { + printf("\nError: Write failed. Couldn't write to offset 0x%x!\n", offset) ; + return 0 ; + } + + if (sp_write(value)) { + printf("\nError: Write failed.\n") ; + return 0 ; + } + + if (sp_seek(offset)) { + printf("\nError: Read-back failed. Couldn't read from offset 0x%x!\n", offset) ; + return 0 ; + } + + if (sp_read(&offset)) { + printf("\nError: Read-back failed.\n") ; + return 0; + } + + printf("\n0x%08x\n", offset) ; + + return 0 ; +} + +int cmd_read (char *command_str) { + int result ; + unsigned int value ; + unsigned int offset ; + + result = sscanf(command_str, "%s %x", unused_str, &offset) ; + if (result != 2) { + printf("\nError: Invalid command, parameter or number of parameters!\n") ; + return -1 ; + } + + if (sp_seek(offset)) { + printf("\nError: Read failed. Couldn't read from offset 0x%x!\n", offset) ; + return 0 ; + } + + if (sp_read(&value)) { + printf("\nError: Read failed.\n") ; + return 0 ; + } + + printf("\n0x%08x\n", value) ; + + return 0 ; +} + +int sp_write (unsigned int value) { + int result = write(spartan_fd, &value, 4) ; + if (result != 4) + return -1 ; + else + return 0 ; +} + +int sp_seek (unsigned int offset) { + int result = lseek(spartan_fd, offset, SEEK_SET) ; + if (result != offset) + return -1 ; + else + return 0 ; +} + +int sp_read (unsigned int *value) { + + int result = read(spartan_fd, (char *) value, 4) ; + + if (result != 4) + return -1 ; + else + return 0 ; +} + +int sp_target_write(unsigned int num_of_transactions, unsigned int transaction_size, unsigned int starting_offset, unsigned char pattern) { + unsigned int buffer[SPARTAN_BOARD_BUFFER_SIZE] ; + + int i ; + + buffer[0] = sp_get_first_val(pattern) ; + + for (i = 1; i < SPARTAN_BOARD_BUFFER_SIZE ; i++) { + buffer[i] = sp_get_next_val(buffer[i-1], pattern) ; + } + + if (sp_seek(starting_offset*4)) { + printf("\nError: Seek failed!\n") ; + return -1 ; + } + + for (i = 0 ; i < num_of_transactions ; ++i) { + if ((write(spartan_fd, buffer + (i*transaction_size) + starting_offset, transaction_size*4)) != (transaction_size*4)) { + printf("\nError: Write test failed. Transaction number %d couldn't finish %d writes through target!\n", i, transaction_size) ; + return -1 ; + } + } + + return 0 ; +} + +int sp_target_check_data(unsigned int num_of_transactions, unsigned int transaction_size, unsigned int starting_offset, unsigned char pattern) { + unsigned int buffer[SPARTAN_BOARD_BUFFER_SIZE] ; + unsigned int expected_value ; + + int i ; + int j ; + + expected_value = sp_get_first_val(pattern) ; + + for (i = 1 ; i <= starting_offset ; ++i) { + expected_value = sp_get_next_val(expected_value, pattern) ; + } + + if (sp_seek(starting_offset * 4)) { + printf("\nError: Seek failed!\n") ; + return -1 ; + } + + for (i = 0 ; i < num_of_transactions ; ++i) { + + if ((read(spartan_fd, buffer, transaction_size*4)) != (transaction_size*4)) { + printf("\nError: Check data failed. Transaction number %d couldn't finish %d reads through target!\n", i, transaction_size) ; + return -1 ; + } + + for (j = 0 ; j < transaction_size ; ++j) { + if ((*(buffer + j)) != (expected_value)) { + printf("\nError: Value on offset 0x%x not as expected!\n", ((i*transaction_size*4) + (j * 4) + starting_offset * 4)) ; + printf("\nExpected value: 0x%x\nActual value: 0x%x\n", expected_value, (*(buffer + j))) ; + return 0 ; + } + + expected_value = sp_get_next_val(expected_value, pattern) ; + } + } + return 0 ; +} + +unsigned int sp_get_first_val(unsigned char pattern) { + unsigned int base ; + + switch (pattern) { + case WALKING_ONES : return 0x00000001 ; break ; + case WALKING_ZEROS : return 0xFFFFFFFE ; break ; + case INVERTED_ADDRESS: ioctl(spartan_fd, SPARTAN_IOC_CURBASE, &base) ; return ~base ; break ; + case ALL_ZEROS : return 0x00000000 ; break ; + case ALL_ONES : return 0xFFFFFFFF ; break ; + case PSEUDO_RANDOM : srand(guint_random_seed) ; return rand() ; break ; + } +} + +unsigned int sp_get_next_val(unsigned int cur_val, unsigned char pattern) { + unsigned int new_val ; + switch (pattern) { + case WALKING_ONES : new_val = cur_val << 1 ; if (new_val == 0) return (sp_get_first_val(pattern)); else return new_val; break ; + case WALKING_ZEROS : new_val = ~cur_val ; new_val = new_val << 1 ; if (new_val == 0) return (sp_get_first_val(pattern)); else return ~new_val ; break ; + case INVERTED_ADDRESS: return ~((~cur_val) + 4) ; break ; + case ALL_ZEROS : return 0x00000000 ; break ; + case ALL_ONES : return 0xFFFFFFFF ; break ; + case PSEUDO_RANDOM : return rand() ; break ; + } +} + +int cmd_burst_read (char *command_str) { + int result ; + unsigned int base ; + unsigned int buf [32] ; + unsigned int offset ; + + result = sscanf(command_str, "%s %x", unused_str, &offset) ; + + if (result != 2) { + printf("\nError: Wrong command, parameter or invalid number of parameters!\n") ; + return -1 ; + } + + if (sp_seek(offset)) { + printf("\nError: Read failed. Couldn't read from offset 0x%x!\n", offset) ; + return 0 ; + } + + if ((read(spartan_fd, buf, 32*4)) != (32*4)) { + printf("\nError: Read failed. Couldn't finish %d reads through target!\n", 32) ; + return 0 ; + } + + ioctl(spartan_fd, SPARTAN_IOC_CURBASE, &base) ; + + for (result = 0 ; result < 32 ; result = result + 4) { + printf("\n0x%08x: ", base + offset + result * 4) ; + printf("0x%08x 0x%08x 0x%08x 0x%08x", *(buf + result), *(buf + result + 1), *(buf + result + 2), *(buf + result + 3)) ; + } + + printf("\n") ; + return 0 ; +} + +int cmd_master_do (char *command_str, unsigned int opcode) { + unsigned int offset ; + unsigned int num_of_trans ; + unsigned int trans_size ; + + if (sscanf(command_str, "%s %x %u %u", unused_str, &offset, &num_of_trans, &trans_size) != 4) { + printf("\nError: Wrong command, parameter or number of parameters!\n") ; + return -1 ; + } + + if (((num_of_trans * trans_size) + (offset/4)) > SYS_BUFFER_SIZE) { + printf("\nError: Size of data from specifed offset crosses system buffer boundary!\n") ; + return 0 ; + } + + sp_master_do(num_of_trans, trans_size, offset, opcode) ; + + return 0 ; +} + +void master_buffer_fill(unsigned char pattern) { + int i ; + unsigned int buf[SYS_BUFFER_SIZE] ; + + buf[0] = sp_get_first_val(pattern) ; + for (i = 1 ; i < SYS_BUFFER_SIZE ; ++i) { + buf[i] = sp_get_next_val(buf[i-1], pattern) ; + } + + ioctl(spartan_fd, SPARTAN_IOC_SET_VIDEO_BUFF, buf) ; +} + +int cmd_master_fill (char *command_str) { + unsigned int pattern ; + + if ((sscanf(command_str, "%s %u", unused_str, &pattern)) != 2) { + printf("\nError: Invalid command, parameter or number of parameters!\n") ; + return -1; + } + + if (pattern > MAX_PATTERN) { + printf("\nError: Invalid pattern selected!\n") ; + return 0 ; + } + + master_buffer_fill(pattern) ; + + return 0 ; +} + +int cmd_master_chk(char *command_str) { + unsigned int pattern ; + unsigned int cur_val ; + unsigned int offset ; + unsigned int size ; + unsigned int buf[SYS_BUFFER_SIZE] ; + int i ; + + if ((sscanf(command_str, "%s %x %u %u", unused_str, &offset, &size, &pattern)) != 4) { + printf("\nError: Wrong command, parameter or number of parameters!\n") ; + return -1 ; + } + + if (pattern > MAX_PATTERN) { + printf("\nError: Invalid pattern selected!\n") ; + return 0 ; + } + + if ((offset/4 + size) > SYS_BUFFER_SIZE) { + printf("\nError: words of data from specified offset cross system buffer boundary!\n") ; + return 0 ; + } + + sp_master_check_data(size, offset, pattern) ; + + return 0 ; +} + +int sp_master_check_data(unsigned int size, unsigned int offset, unsigned char pattern) { + unsigned int cur_val = 0xDEADDEAD ; + unsigned int buf[SYS_BUFFER_SIZE] ; + int i ; + int error_detected = 0 ; + + ioctl(spartan_fd, SPARTAN_IOC_GET_VIDEO_BUFF, buf) ; + + i = 0 ; + + for (i = 0 ; i < offset/4 ; ++i) { + if (i % SPARTAN_BOARD_BUFFER_SIZE) + cur_val = sp_get_next_val(cur_val, pattern) ; + else + cur_val = sp_get_first_val(pattern) ; + } + + for(; i < (offset/4 + size); ++i) { + if (i % SPARTAN_BOARD_BUFFER_SIZE) + cur_val = sp_get_next_val(cur_val, pattern) ; + else + cur_val = sp_get_first_val(pattern) ; + + if (cur_val != buf[i]) { + error_detected = 1 ; + printf("\nError: Data on offset 0x%x wrong!\n", i*4) ; + printf("Expected data 0x%08x, actual 0x%08x!\n", cur_val, buf[i]) ; + } + } + + return error_detected ; +} + +int cmd_target_write(char *command_str) { + int result ; + unsigned int num_of_trans ; + unsigned int trans_size ; + unsigned int pattern ; + unsigned int starting_offset ; + + result = sscanf(command_str, "%s %x %u %u %u", unused_str, &starting_offset, &num_of_trans, &trans_size, &pattern ) ; + + if (result != 5) { + printf("\nError: Wrong command, parameter or number of parameters!\n") ; + return -1 ; + } + + if ((trans_size * num_of_trans) > SPARTAN_BOARD_BUFFER_SIZE) { + printf("\nError: Size of write transfers exceeds the buffer size!\n") ; + return 0 ; + } + + if (((starting_offset/4) + (trans_size * num_of_trans)) > SPARTAN_BOARD_BUFFER_SIZE) { + printf("\nError: Specified number of writes from specified offset will exceede Target buffer size!\n") ; + return 0 ; + } + + if (pattern > MAX_PATTERN) { + printf("\nError: Invalid pattern selected!\n") ; + return 0 ; + } + + sp_target_write(num_of_trans, trans_size, starting_offset / 4, pattern) ; + + return 0 ; +} + +int cmd_target_chk (char *command_str) { + unsigned int num_of_trans ; + unsigned int trans_size ; + unsigned int pattern ; + unsigned int starting_offset ; + + if (sscanf(command_str, "%s %x %u %u %u", unused_str, &starting_offset, &num_of_trans, &trans_size, &pattern) != 5) { + printf("\nError: Wrong command, parameter or number of parameters.\n") ; + return -1 ; + } + + if ((trans_size * num_of_trans) > SPARTAN_BOARD_BUFFER_SIZE) { + printf("\nError: Size of write transfers exceeds the buffer size!\n") ; + return 0 ; + } + + if (((starting_offset/4) + (trans_size * num_of_trans)) > SPARTAN_BOARD_BUFFER_SIZE) { + printf("\nError: Specified number of writes from specified offset will cross Target buffer boundary!\n") ; + return 0 ; + } + + if (pattern > MAX_PATTERN) { + printf("\nError: Invalid pattern selected!\n") ; + return 0 ; + } + + sp_target_check_data(num_of_trans, trans_size, starting_offset / 4, pattern) ; + + return 0 ; +} + +int cmd_target_slide_window_test (void) { + unsigned int i, j ; + unsigned int base ; + + +/* for ( i = 1 ; i <= SPARTAN_BOARD_BUFFER_SIZE ; ++i ) { + for ( j = 0 ; j + i <= SPARTAN_BOARD_BUFFER_SIZE ; ++j) { + + guint_random_seed = guint_random_seed + 1 ; + + // clear on board buffer + sp_target_write(1, SPARTAN_BOARD_BUFFER_SIZE, 0x0, ALL_ZEROS) ; + + sp_target_write(1, i, j, PSEUDO_RANDOM) ; + + // if j > 0 check the buffer before written data + if (j) { + sp_target_check_data(1, j, 0x0, ALL_ZEROS) ; + } + + // if write didn't finish at the buffer boundary - check the data after written data + if ((j + i) < SPARTAN_BOARD_BUFFER_SIZE) { + sp_target_check_data(1, (SPARTAN_BOARD_BUFFER_SIZE - j - i), j + i, ALL_ZEROS) ; + } + + // check the written data + sp_target_check_data(1, i, j, PSEUDO_RANDOM) ; + } + } + + // clear the board buffer + sp_target_write(1, SPARTAN_BOARD_BUFFER_SIZE, 0x0, ALL_ZEROS) ; + + for ( i = 1 ; i <= SPARTAN_BOARD_BUFFER_SIZE ; ++i) { + + // reset random seed + guint_random_seed = 1 ; + + for (j = 0 ; ((j + 1) * i) <= SPARTAN_BOARD_BUFFER_SIZE ; ++j) { + sp_target_write(1, i, (j * i), PSEUDO_RANDOM) ; + guint_random_seed = guint_random_seed + 1 ; + } + + // check if there is any room left in the buffer + if ((j * i) != SPARTAN_BOARD_BUFFER_SIZE) { + // write the remainder of the data to the onboard buffer + sp_target_write(1, SPARTAN_BOARD_BUFFER_SIZE - (j * i), (j * i), PSEUDO_RANDOM) ; + } + + // now check the written data - read transactions the same as write transactions + // reset random seed + guint_random_seed = 1 ; + + for (j = 0 ; ((j + 1) * i) <= SPARTAN_BOARD_BUFFER_SIZE ; ++j) { + sp_target_check_data(1, i, (j * i), PSEUDO_RANDOM) ; + guint_random_seed = guint_random_seed + 1 ; + } + + // check the end of buffer + if ((j * i) != SPARTAN_BOARD_BUFFER_SIZE) { + // check the remainder of the data in the onboard buffer + sp_target_check_data(1, SPARTAN_BOARD_BUFFER_SIZE - (j * i), (j * i), PSEUDO_RANDOM) ; + } + } + +*/ + +/* // fill system buffer + master_buffer_fill(PSEUDO_RANDOM) ; + + // instruct the master to fill the onboard buffer with reads! + sp_master_read(1, SPARTAN_BOARD_BUFFER_SIZE, 0x0) ; + + // check the data in on board buffer + sp_target_check_data(1, SPARTAN_BOARD_BUFFER_SIZE, 0x0, PSEUDO_RANDOM) ; + + // clear the master buffer + master_buffer_fill(ALL_ZEROS) ; + + // perform one whole board buffer write through master, to setup all registers + sp_master_write(1, SPARTAN_BOARD_BUFFER_SIZE, 0x0) ; + + // check the data in buffer + sp_master_check_data(SPARTAN_BOARD_BUFFER_SIZE, 0x0, PSEUDO_RANDOM) ; + + // if system buffer is larget than board buffer, check the data in the remainder of the system buffer + if (SPARTAN_BOARD_BUFFER_SIZE < SYS_BUFFER_SIZE) + sp_master_check_data(SYS_BUFFER_SIZE - SPARTAN_BOARD_BUFFER_SIZE, SPARTAN_BOARD_BUFFER_SIZE * 4, ALL_ZEROS) ; + + ++guint_random_seed ; + + for (i = 1 ; i <= 10000000 ; ++i) { + master_buffer_fill(ALL_ZEROS) ; + + sp_target_write(1, SPARTAN_BOARD_BUFFER_SIZE, 0x0, PSEUDO_RANDOM) ; + + // instruct master to write the data out + sp_seek(MASTER_TRANS_COUNT_OFFSET) ; + sp_write(0x1) ; + + ++guint_random_seed ; + + // do another write through target + sp_target_write(1, SPARTAN_BOARD_BUFFER_SIZE, 0x0, PSEUDO_RANDOM) ; + + --guint_random_seed ; + // check the previous data written by master + sp_master_check_data(SPARTAN_BOARD_BUFFER_SIZE, 0x0, PSEUDO_RANDOM) ; + + // if system buffer is larget than board buffer, check the data in the remainder of the system buffer + if (SPARTAN_BOARD_BUFFER_SIZE < SYS_BUFFER_SIZE) + sp_master_check_data(SYS_BUFFER_SIZE - SPARTAN_BOARD_BUFFER_SIZE, SPARTAN_BOARD_BUFFER_SIZE * 4, ALL_ZEROS) ; + + ++guint_random_seed ; + } +*/ + + // setup the slave registers + ioctl(spartan_fd, SPARTAN_IOC_CURBASE, &base) ; + if (!base) { + printf("Error: Couldn't get target image base address!") ; + return 0 ; + } + + if (sp_seek(TARGET_TEST_START_ADR_OFFSET)) { + printf("Error: Seek failed!") ; + return 0 ; + } + + if (sp_write(base)) { + printf("Error: Write to register failed!") ; + return 0 ; + } + + if (sp_seek(TARGET_TEST_START_DATA_OFFSET)) { + printf("Error: Seek failed!") ; + return 0 ; + } + + if (sp_write(sp_get_first_val(WALKING_ZEROS))) { + printf("Error: Write to register failed!") ; + return 0 ; + } + + + for (i = 1 ; i <= 200000 ; ++i) { + // setup the target test size register + if (sp_seek(TARGET_TEST_SIZE_OFFSET)) { + printf("Error: Seek failed!") ; + return 0 ; + } + + if (i > 1) { + if (sp_write(SPARTAN_BOARD_BUFFER_SIZE)) { + printf("Error: Write to register failed!") ; + return 0 ; + } + } else { + if (sp_write(SPARTAN_BOARD_BUFFER_SIZE + 1)) { + printf("Error: Write to register failed!") ; + return 0 ; + } + } + + if (sp_target_write(1, SPARTAN_BOARD_BUFFER_SIZE, 0x0, WALKING_ZEROS)) { + printf("Error: Write through target failed!") ; + return 0 ; + } + + if (i < 2) { + if (sp_target_write(1, 1, 0x8, WALKING_ONES)) { + printf("Error: Write failed!") ; + return 0 ; + } + } + + // previously the error was produced intentionally - now check if the error status is still set + if (i == 2) { + if (sp_seek(TARGET_TEST_ERR_REP_OFFSET)) { + printf("Error: Seek failed!") ; + return 0 ; + } + + if (sp_read(&base)) { + printf("Error: Read failed!") ; + return 0 ; + } + + if (base != 3) { + printf("Error: Value in the error status register not as expected!") ; + return 0 ; + } + + if (sp_seek(TARGET_TEST_ERR_REP_OFFSET)) { + printf("Error: Seek failed!") ; + return 0 ; + } + + if (sp_write(0xFFFFFFFF)) { + printf("Error: Write failed!") ; + return 0 ; + } + } + } + + + if (sp_seek(TARGET_TEST_ERR_REP_OFFSET)) { + printf("Error: Seek failed!") ; + return 0 ; + } + + if (sp_read(&base)) { + printf("Error: read failed!") ; + return 0 ; + } + + if (base) { + printf("Error: Test application detected an error!") ; + + if (sp_seek(TARGET_TEST_ERR_REP_OFFSET)) { + printf("Error: Seek failed!") ; + return 0 ; + } + + if (sp_write(0)) { + printf("Error: Write to register failed!") ; + return 0 ; + } + + return 0 ; + } + return 0 ; +} + +int cmd_master_slide_window_test (void) { + unsigned int i, j ; + +/* for (i = 1 ; i <= SPARTAN_BOARD_BUFFER_SIZE ; ++i) { + for (j = 0 ; j + i <= SYS_BUFFER_SIZE ; ++j ) { + guint_random_seed = guint_random_seed + 1 ; + + // fill the system memory buffer with random data + master_buffer_fill(PSEUDO_RANDOM) ; + + // clear the on board buffer + sp_target_write(1, SPARTAN_BOARD_BUFFER_SIZE, 0x0, ALL_ZEROS) ; + + if (sp_master_read((j % 2) ? 1 : SPARTAN_BOARD_BUFFER_SIZE, (j % 2) ? SPARTAN_BOARD_BUFFER_SIZE : 1, 0x0)) + return 0 ; + + // all of the master reads are finished + // clear the system buffer + master_buffer_fill(ALL_ZEROS) ; + + if (sp_master_write(1, i, j * 4)) + return 0 ; + + // write is done - check the data + sp_master_check_data(i, j * 4, PSEUDO_RANDOM) ; + + if (j) { + sp_master_check_data(j, 0, ALL_ZEROS) ; + } + + if ( j + i < SYS_BUFFER_SIZE) { + sp_master_check_data(SYS_BUFFER_SIZE - i - j, (i + j) * 4, ALL_ZEROS) ; + } + } + } +*/ + sp_target_write(1, SPARTAN_BOARD_BUFFER_SIZE, 0x0, WALKING_ONES) ; + sp_target_check_data(1, SPARTAN_BOARD_BUFFER_SIZE, 0x0, WALKING_ONES) ; + master_buffer_fill(ALL_ZEROS) ; + sp_master_write(SYS_BUFFER_SIZE / SPARTAN_BOARD_BUFFER_SIZE, SPARTAN_BOARD_BUFFER_SIZE, 0x0) ; + sp_master_check_data(SYS_BUFFER_SIZE, 0x0, WALKING_ONES) ; + + // clear the master transaction counters + if (sp_seek(MASTER_NUM_OF_WB_OFFSET)) { + printf("\nError: Seek error!\n") ; + return 0 ; + } + + if (sp_write(0xFFFFFFFF)) { + printf("\nError: Write to register failed\n") ; + return 0 ; + } + + if (sp_seek(MASTER_NUM_OF_WB_OFFSET)) { + printf("\nError: Seek error!\n") ; + return 0 ; + } + + if (sp_read(&i)) { + printf("\nError: Read from register failed\n") ; + return 0 ; + } + + if (i != 0) { + printf("\nError: Transaction counter clear operation not OK!\n") ; + return 0 ; + } + + if (sp_seek(MASTER_NUM_OF_PCI_OFFSET)) { + printf("\nError: Seek error!\n") ; + return 0 ; + } + + if (sp_read(&j)) { + printf("\nError: Read from register failed\n") ; + return 0 ; + } + + if (j != 0) { + printf("\nError: Transaction counter clear operation not OK!\n") ; + return 0 ; + } + + + +// if (SPARTAN_BOARD_BUFFER_SIZE < SYS_BUFFER_SIZE) +// sp_master_check_data(SYS_BUFFER_SIZE - SPARTAN_BOARD_BUFFER_SIZE, SPARTAN_BOARD_BUFFER_SIZE * 4, ALL_ZEROS) ; + + for (i = 1 ; i <= 1 ; i = ++i) { + + if (i == 1) { + if (sp_seek(0)) { + printf("\nError: Seek error!\n") ; + return 0 ; + } + + if (sp_write(sp_get_first_val(WALKING_ZEROS))) { + printf("\nError: Write to register failed!\n") ; + return 0 ; + } + } + + if (sp_seek(MASTER_TRANS_COUNT_OFFSET)) { + printf("\nError: Seek error!\n") ; + return 0 ; + } + + if (sp_read(&j)) { + printf("\nError: Read from master number of transactions failed!\n") ; + return 0 ; + } + + if (j == 0) { + + if (sp_seek(MASTER_TEST_DATA_ERROR_OFFSET)) { + printf("\nError: Seek failed!\n") ; + return 0 ; + } + + if (sp_read(&j)) { + printf("\nError: Read from register failed!\n") ; + return 0 ; + } + + if (i == 1) { + printf("\nNote: The following error is produced intentionally, to test software/hardware functionality!\n") ; + } + + if (j) { + printf("\nError: Test application detected an error in the data sequence on the PCI Master side of the bridge!\n") ; + } + + if (sp_seek(MASTER_TEST_START_DATA_OFFSET)) { + printf("\nError: Seek failed!\n") ; + return 0 ; + } + + if (sp_write(sp_get_first_val(WALKING_ONES))) { + printf("\nError: Write to register failed!\n") ; + return 0 ; + } + + if (sp_seek(MASTER_TEST_SIZE_OFFSET)) { + printf("\nError: Seek failed!\n") ; + return 0 ; + } + + if (sp_write(SYS_BUFFER_SIZE)) { + printf("\nError: Write to register failed!\n") ; + return 0 ; + } + + if (sp_seek(MASTER_TRANS_COUNT_OFFSET)) { + printf("\nError: Seek error!\n") ; + return 0 ; + } + + if (sp_write(SYS_BUFFER_SIZE / SPARTAN_BOARD_BUFFER_SIZE)) { + printf("\nError: Unable to write master number of transactions register!\n") ; + return 0 ; + } + } + + if (i == 1) { + printf("\nNote: The following two errors are produced intentionally, to test software/hardware functionality!\n") ; + + if (sp_seek(0)) { + printf("\nError: Seek error!\n") ; + return 0 ; + } + + if (sp_write(sp_get_first_val(WALKING_ONES))) { + printf("\nError: Write to register failed!\n") ; + return 0 ; + } + } + + for (j = 1 ; j <= (SYS_BUFFER_SIZE / SPARTAN_BOARD_BUFFER_SIZE) * 2 ; ++j) { + sp_master_check_data(SYS_BUFFER_SIZE, 0x0, WALKING_ONES) ; + printf("juhu") ; + } + +// if (SPARTAN_BOARD_BUFFER_SIZE < SYS_BUFFER_SIZE) +// sp_master_check_data(SYS_BUFFER_SIZE - SPARTAN_BOARD_BUFFER_SIZE, SPARTAN_BOARD_BUFFER_SIZE * 4, ALL_ZEROS) ; + +// master_buffer_fill(ALL_ZEROS) ; + } + + j = 0 ; + + // read and clear the master transaction counters + if (sp_seek(MASTER_NUM_OF_WB_OFFSET)) { + printf("\nError: Seek error!\n") ; + return 0 ; + } + + if (sp_read(&j)) { + printf("\nError: Read from register failed!\n") ; + return 0 ; + } + + if (j != ((i-1)*SYS_BUFFER_SIZE)) { + printf("\nError: Number of WISHBONE transactions unexpected!\n") ; + printf("Expected %u, actual %u\n", (i-1)*SYS_BUFFER_SIZE, j) ; + } else { + printf("\nNote: %u WISHBONE Slave write transfers reported succesfull!\n", j) ; + } + + if (sp_seek(MASTER_NUM_OF_PCI_OFFSET)) { + printf("\nError: Seek error!\n") ; + return 0 ; + } + + j = 0 ; + + if (sp_read(&j)) { + printf("\nError: Read from register failed\n") ; + return 0 ; + } + + if (j != ((i-1)*SYS_BUFFER_SIZE)) { + printf("\nError: Number of PCI transactions unexpected!\n") ; + printf("Expected %u, actual %u\n", (i-1)*SYS_BUFFER_SIZE, j) ; + } else { + printf("Note: %u PCI Master write transfers reported succesfull!\n") ; + } + + // clear the counters +/* if (sp_seek(MASTER_NUM_OF_WB_OFFSET)) { + printf("\nError: Seek error!\n") ; + return 0 ; + } + + if (sp_write(0xFFFFFFFF)) { + printf("\nError: Write to register failed!\n") ; + return 0 ; + } +*/ + + // perform a read and write tests with variable size and number of transactions. + // i represents transaction size, j represents number of transactions +/* for (i = 1 ; i <= SPARTAN_BOARD_BUFFER_SIZE ; ++i) { + for (j = 1 ; j * i <= SPARTAN_BOARD_BUFFER_SIZE ; ++j) { + + guint_random_seed = guint_random_seed + 1 ; + + // clear the onboard buffer + sp_target_write(1, SPARTAN_BOARD_BUFFER_SIZE, 0x0, (i % 2) ? ALL_ZEROS : ALL_ONES) ; + + master_buffer_fill(PSEUDO_RANDOM) ; + + if ( sp_master_read( j, i, ( SPARTAN_BOARD_BUFFER_SIZE - i * j ) * 4) ) return 0 ; + + // check the data in system buffer by writing it through pci master + master_buffer_fill((i % 2) ? ALL_ONES : ALL_ZEROS) ; + + if ( sp_master_write( 1, SPARTAN_BOARD_BUFFER_SIZE, 0x0)) return 0 ; + + // check the data that was not read in on lower offsets + if (i*j < SPARTAN_BOARD_BUFFER_SIZE) { + // check the data in the begining of the buffer, which was not read + if (sp_master_check_data(SPARTAN_BOARD_BUFFER_SIZE - i * j, 0x0, (i % 2) ? ALL_ZEROS : ALL_ONES)) { + printf("\nError during Master read test detected!\n") ; + printf("Read test properties: number of transactions %d, transaction sizes %d\n", j, i) ; + printf("Checking the data in onboard buffer\n") ; + sp_target_check_data(1, SPARTAN_BOARD_BUFFER_SIZE - i * j, 0x0, (i % 2) ? ALL_ZEROS : ALL_ONES) ; + printf("Check done!\n") ; + } + } + + // check the data that was read + if (sp_master_check_data(i*j, ( SPARTAN_BOARD_BUFFER_SIZE - ( i * j ) ) * 4, PSEUDO_RANDOM)) { + printf("\nError during Master read test detected!\n") ; + printf("Read test properties: number of transactions %d, transaction sizes %d\n", j, i) ; + printf("Checking the data in onboard buffer\n") ; + sp_target_check_data(1, i*j, SPARTAN_BOARD_BUFFER_SIZE - i * j, PSEUDO_RANDOM ) ; + printf("Check done!\n") ; + } + + } + } +*/ + return 0 ; +} + +int sp_master_do(unsigned int num_of_transactions, unsigned int transaction_size, unsigned int starting_offset, unsigned int opcode) { + unsigned int base ; + unsigned int transactions_left ; + unsigned int deadlock_cnt ; + unsigned int wait ; + + ioctl(spartan_fd, SPARTAN_IOC_VIDEO_BASE, &base) ; + + if (sp_seek(MASTER_ADDR_REG_OFFSET)) { + printf("\nError: Seek error!\n") ; + return 1 ; + } + + if (sp_write(base + starting_offset)) { + printf("\nError: Unable to write master address register!\n") ; + return 1; + } + + if (sp_seek(MASTER_OP_CODE_OFFSET)) { + printf("\nError: Seek error!\n") ; + return 1 ; + } + + if (sp_write(opcode)) { + printf("\nError: Unable to write master opcode register!\n") ; + return 1 ; + } + + if (sp_seek(MASTER_TRANS_SIZE_OFFSET)) { + printf("\nError: Seek error!\n") ; + return 1 ; + } + + if (sp_write(transaction_size)) { + printf("\nError: Unable to write master transaction size register!\n") ; + return 1 ; + } + + if (sp_seek(MASTER_TRANS_COUNT_OFFSET)) { + printf("\nError: Seek error!\n") ; + return 1 ; + } + + if (sp_write(num_of_transactions)) { + printf("\nError: Unable to write master number of transactions register!\n") ; + return 1 ; + } + + transactions_left = num_of_transactions ; + deadlock_cnt = 0 ; + while (transactions_left && (deadlock_cnt < 100)) { + + // suspend the polling of remaining transactions, until minimum required time has passed, or for small writes for 1 us. + for (wait = 0 ; wait < (transactions_left * transaction_size * 100) ; ++wait) ; + + if (sp_seek(MASTER_TRANS_COUNT_OFFSET)) { + printf("\nError: Seek error!\n") ; + return 1 ; + } + + if (sp_read(&transactions_left)) { + printf("\nError: Read failed!\n") ; + return 1 ; + } + + ++deadlock_cnt ; + } + + if (deadlock_cnt == 0x00200000) { + printf("\nError: The requested master operation is not beeing processed. Is at least one wb image enabled?\n") ; + return 1 ; + } + return 0 ; +} Index: trunk/apps/sw/driver/Makefile =================================================================== --- trunk/apps/sw/driver/Makefile (revision 102) +++ trunk/apps/sw/driver/Makefile (revision 103) @@ -1,6 +1,15 @@ spartan_fb.o: spartan_drv.c - gcc -D__KERNEL__ -DMODULE -D__VGA__ -I. -c -O2 -o spspartan_fb.o spartan_drv.c + gcc -D__KERNEL__ -DMODULE -D__VGA__ -I. -I/usr/src/linux-2.4/include/ -c -O2 -o spartan_fb.o spartan_drv.c slide: slide.c gcc -O2 -I. -o slide slide.c +spartan.o: spartan_drv.c + gcc -D__KERNEL__ -DMODULE -D__OC_TEST__ -I. -I/usr/src/linux-2.4/include/ -c -O2 -o spartan.o spartan_drv.c + +test_app: pci_bridge32_test.c + gcc -I. -o pci_bridge32_test pci_bridge32_test.c + +test: spartan_drv.c pci_bridge32_test.c + gcc -D__KERNEL__ -DMODULE -D__OC_TEST__ -I. -I/usr/src/linux-2.4/include/ -c -O2 -o spartan.o spartan_drv.c + gcc -I. -o pci_bridge32_test pci_bridge32_test.c

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.