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

Subversion Repositories pci

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /pci/tags/rel_10/apps/sw
    from Rev 125 to Rev 154
    Reverse comparison

Rev 125 → Rev 154

/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)
/driver/spartan_kint.h
0,0 → 1,32
#include <linux/ioctl.h>
 
#define SPARTAN_IOC_NUM 'S'
#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
#define SPARTAN_IOC_CURBASE _IOR(SPARTAN_IOC_NUM, 3, base) // read current resource base address
#define SPARTAN_IOC_CURBASEMAP _IOR(SPARTAN_IOC_NUM, 4, base) // read current resource remaped base address ( 0 - not remaped)
#define SPARTAN_IOC_CURBASESIZE _IOR(SPARTAN_IOC_NUM, 5, base_size)// read current resource size
#define SPARTAN_IOC_NUMOFRES _IO(SPARTAN_IOC_NUM, 6) // read number of found resources
#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) // 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
#define SPARTAN_P_BA1_ADDR 0x114
#define SPARTAN_P_AM1_ADDR 0x118
#define SPARTAN_P_TA1_ADDR 0x11c
 
 
#define SPARTAN_W_IMG_CTRL1_ADDR 0x184
#define SPARTAN_W_BA1_ADDR 0x188
#define SPARTAN_W_AM1_ADDR 0x18C
#define SPARTAN_W_TA1_ADDR 0x190
 
#define SPARTAN_CRT_CTRL 0x000
#define SPARTAN_CRT_ADD 0x004
#define SPARTAN_CRT_PALETTE_BASE 0x400
/driver/spartan_drv.c
0,0 → 1,636
#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
// define vendor and device ID here - currently this definitions specify reference designs from insight electronic
#ifdef __SDRAM__
#define OC_PCI_VENDOR 0x1597
#define OC_PCI_DEVICE 0x0300
#endif
#ifdef __VGA__
#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 0
#endif
 
#ifdef __VGA__
#define REQUESTED_MAJOR 0
#endif
 
// if compiling module for kernel 2.4 - leave this defined
// for kernel 2.2 - comment this out
#define KERNEL_VER_24
 
#ifndef SEEK_SET
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#endif
 
// io.h needed just for kernel 2.2
#ifndef KERNEL_VER_24
#include <asm/io.h>
#endif
 
// memory mapped or IO mapped region definitions
#define SPARTAN_MEM_MAPPED 0
#define SPARTAN_IO_MAPPED 1
 
#ifdef __VGA__
#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.
static struct our_dev
{
int major ;
u32 bases[6] ;
u8 num_of_bases ;
u32 base_size[6] ;
u32 offset ;
u32 page_addr ;
u32 base_page_offset ;
int current_resource ;
int base_map[6] ;
u32 video_base ;
u32 video_vbase ;
u32 video_size ;
struct pci_dev *ppci_spartan_dev ;
} pspartan_dev ;
 
// function prototypes
int spartan_open(struct inode *inode, struct file *filp);
int spartan_release(struct inode *inode, struct file *filp);
 
ssize_t spartan_read(struct file *filp, char *buf, size_t count, loff_t *offset ) ;
ssize_t spartan_write(struct file *filp, const char *buf, size_t count, loff_t *offset) ;
int spartan_ioctl(struct inode *pnode, struct file *filp, unsigned int cmd, unsigned long arg) ;
loff_t spartan_seek(struct file *filp, loff_t offset, int what) ;
 
// file operations structure - different for kernels 2.2 and 2.4
static struct file_operations *pspartan_fops ;
static struct file_operations spartan_fops = {
#ifdef KERNEL_VER_24
NULL,
#endif
spartan_seek,
spartan_read,
spartan_write,
NULL,
NULL,
spartan_ioctl,
NULL,
spartan_open,
NULL,
spartan_release,
} ;
 
int open_mem_mapped(void) ;
 
// seek file operation function
loff_t spartan_seek(struct file *filp, loff_t offset, int origin)
{
loff_t requested_offset ;
int resource_num = pspartan_dev.current_resource ;
 
switch (origin)
{
case SEEK_CUR:requested_offset = pspartan_dev.offset + offset ; break ;
case SEEK_END:requested_offset = pspartan_dev.base_size[resource_num] + offset ; break ;
default:requested_offset = offset ; break ;
}
if ((requested_offset < 0) || (requested_offset > pspartan_dev.base_size[resource_num]))
return -EFAULT ;
 
pspartan_dev.offset = requested_offset ;
 
return requested_offset ;
}
 
// ioctl for device
// currently just a few operations are supported here - defined in spartan_kint.h header
int spartan_ioctl(struct inode *pnode, struct file *filp, unsigned int cmd, unsigned long arg)
{
int error = 0;
int size = _IOC_SIZE(cmd) ;
unsigned long base ;
unsigned long base_size ;
int i;
 
if (_IOC_TYPE(cmd) != SPARTAN_IOC_NUM) return -EINVAL ;
if (_IOC_NR(cmd) > SPARTAN_IOC_MAX_NUM) return -EINVAL ;
 
// Writes through pointers not allowed - writes only through argument
if (_IOC_DIR(cmd) & _IOC_WRITE) return -EINVAL ;
else if (_IOC_DIR(cmd) & _IOC_READ)
error = verify_area(VERIFY_WRITE, (void *) arg, size) ;
if (error)
return error ;
 
switch (cmd){
case SPARTAN_IOC_CURRESGET:
// current resource - they start at 1
return (pspartan_dev.current_resource + 1) ;
case SPARTAN_IOC_CURRESSET:
// check if resource is in a range of implemented resources
if (arg < 0 )
return -EINVAL ;
 
// unmap previous resource if it was mapped
if (pspartan_dev.current_resource >= 0)
{
iounmap((void *)pspartan_dev.page_addr) ;
}
 
if (arg == 0)
{
// previous resource unmaped - that's all
pspartan_dev.current_resource = -1 ;
return 0 ;
}
 
if (pspartan_dev.num_of_bases < arg)
return -ENODEV ;
 
// IO mapped not supported yet
if (pspartan_dev.base_map[arg] == SPARTAN_IO_MAPPED)
{
// set current resource to none, since it was unmapped
pspartan_dev.current_resource = -1 ;
return -ENODEV ;
}
pspartan_dev.current_resource= (int)(arg-1) ;
// remap new resource
if ( (error = open_mem_mapped()) )
{
pspartan_dev.current_resource = -1 ;
return error ;
}
return 0 ;
case SPARTAN_IOC_CURBASE:
// check if any resource is currently activated
if (pspartan_dev.current_resource>=0)
base = pspartan_dev.bases[pspartan_dev.current_resource] ;
else
base = 0x00000000 ;
*(unsigned long *)arg = base ;
return 0 ;
case SPARTAN_IOC_CURBASEMAP:
// check if any resource is currently activated
if (pspartan_dev.current_resource>=0)
base = pspartan_dev.page_addr ;
else
base = 0x00000000 ;
*(unsigned long *)arg = base ;
 
return 0 ;
case SPARTAN_IOC_CURBASESIZE:
// check if any resource is currently activated
if (pspartan_dev.current_resource>=0)
base_size = pspartan_dev.base_size[pspartan_dev.current_resource] ;
else
base_size = 0x00000000 ;
*(unsigned long *)arg = base_size ;
return 0 ;
case SPARTAN_IOC_NUMOFRES:
return (pspartan_dev.num_of_bases) ;
#ifdef __VGA__
case SPARTAN_IOC_VIDEO_BASE:
*((unsigned long *)arg) = pspartan_dev.video_base;
put_user(pspartan_dev.video_base, ((unsigned long *)arg));
return 0 ;
 
case SPARTAN_IOC_VIDEO_VBASE:
*(unsigned long *)arg = pspartan_dev.video_vbase;
put_user(pspartan_dev.video_vbase, ((unsigned long *)arg));
return 0 ;
case SPARTAN_IOC_VIDEO_SIZE:
*(unsigned long *)arg = pspartan_dev.video_size;
put_user(pspartan_dev.video_size, ((unsigned long *)arg));
return 0;
 
case SPARTAN_IOC_SET_VIDEO_BUFF:
for(i = 0; i < VIDEO_SZ; i++) {
get_user(*((char *)(pspartan_dev.video_vbase + i)), ((char *)(arg + i)));
}
 
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 ;
}
}
 
// helper function for memory remaping
int open_mem_mapped(void)
{
int resource_num = pspartan_dev.current_resource ;
unsigned long num_of_pages = 0 ;
unsigned long base = pspartan_dev.bases[resource_num] ;
unsigned long size = pspartan_dev.base_size[resource_num] ;
 
if (!(num_of_pages = (unsigned long)(size/PAGE_SIZE))) ;
num_of_pages++ ;
 
pspartan_dev.base_page_offset = base & ~PAGE_MASK ;
 
if ((pspartan_dev.base_page_offset + size) < (num_of_pages*PAGE_SIZE))
num_of_pages++ ;
// remap memory mapped space
pspartan_dev.page_addr = (unsigned long)ioremap(base & PAGE_MASK, num_of_pages * PAGE_SIZE) ;
if (pspartan_dev.page_addr == 0x00000000)
return -ENOMEM ;
return 0 ;
}
 
// add io mapped resource handler here
int open_io_mapped( void )
{
return 0 ;
}
 
// open file operation function
int spartan_open(struct inode *inode, struct file *filp)
{
if (MOD_IN_USE)
return -EBUSY ;
 
pspartan_fops = &spartan_fops ;
filp->f_op = pspartan_fops ;
pspartan_dev.offset = 0 ;
pspartan_dev.current_resource = -1 ;
MOD_INC_USE_COUNT ;
return 0 ;
}
// release - called by close on file descriptor
int spartan_release(struct inode *inode, struct file *filp)
{
// unmap any remaped pages
if (pspartan_dev.current_resource >= 0)
iounmap((void *)pspartan_dev.page_addr) ;
 
pspartan_dev.current_resource = -1 ;
 
MOD_DEC_USE_COUNT ;
return 0 ;
}
 
// memory mapped resource read function
ssize_t spartan_read(struct file *filp, char *buf, size_t count, loff_t *offset_out )
{
unsigned long current_address = pspartan_dev.page_addr + pspartan_dev.base_page_offset + pspartan_dev.offset ;
unsigned long actual_count ;
unsigned long offset = pspartan_dev.offset ;
int resource_num = pspartan_dev.current_resource ;
int i;
unsigned int value;
unsigned int *kern_buf ;
unsigned int *kern_buf_tmp ;
 
unsigned long size = pspartan_dev.base_size[resource_num] ;
int result ;
 
if (pspartan_dev.current_resource < 0)
return -ENODEV ;
if (offset == size)
return 0 ;
if ( (offset + count) > size )
actual_count = size - offset ;
else
actual_count = count ;
// verify range if it is OK to copy from
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);
value = *(kern_buf) ;
put_user(value, ((unsigned int *)buf));
buf += 4;
++kern_buf ;
// current_address += 4;
}
 
kfree(kern_buf_tmp);
pspartan_dev.offset = pspartan_dev.offset + actual_count ;
*(offset_out) = pspartan_dev.offset ;
return actual_count ;
}
 
// memory mapped resource write function
ssize_t spartan_write(struct file *filp, const char *buf, size_t count, loff_t *offset_out)
{
unsigned long current_address = pspartan_dev.page_addr + pspartan_dev.base_page_offset + pspartan_dev.offset ;
unsigned long actual_count ;
unsigned long offset = pspartan_dev.offset ;
int resource_num = pspartan_dev.current_resource ;
int i;
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 ;
 
if (offset == size)
return 0 ;
if ( (offset + count) > size )
actual_count = size - offset ;
else
actual_count = count ;
// verify range if it is OK to copy from
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);
*kern_buf = value ;
buf += 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 ;
return actual_count ;
}
 
// initialization function - different for 2.2 and 2.4 kernel because of different pci_dev structure
int init_module(void)
{
int result ;
u32 base_address ;
unsigned long size ;
unsigned short num_of_bases ;
u16 wvalue ;
struct pci_dev *ppci_spartan_dev = NULL ;
struct resource spartan_resource ;
struct page *page;
int sz ;
 
if(!pci_present())
{
printk("<1> Kernel reports no PCI bus support!\n " );
return -ENODEV;
}
 
if((ppci_spartan_dev = pci_find_device(OC_PCI_VENDOR, OC_PCI_DEVICE, ppci_spartan_dev))==NULL )
{
printk("<1> Device not found!\n " );
return -ENODEV ;
}
pspartan_dev.ppci_spartan_dev = ppci_spartan_dev ;
 
#ifdef KERNEL_VER_24
//printk("<1> Board found at address 0x%08X\n", ppci_spartan_dev->resource[0].start) ;
// copy implemented base addresses to private structure
 
spartan_resource = ppci_spartan_dev->resource[0] ;
base_address = spartan_resource.start ;
printk("<1> First base address register found at %08X \n ", base_address );
num_of_bases = 0 ;
while ((base_address != 0x00000000) && (num_of_bases < 6))
{
pspartan_dev.bases[num_of_bases] = spartan_resource.start ;
pspartan_dev.base_size[num_of_bases] = spartan_resource.end - spartan_resource.start + 1 ;
// check if resource is IO mapped
if (spartan_resource.flags & IORESOURCE_IO)
pspartan_dev.base_map[num_of_bases] = SPARTAN_IO_MAPPED ;
else
pspartan_dev.base_map[num_of_bases] = SPARTAN_MEM_MAPPED ;
 
num_of_bases++ ;
spartan_resource = ppci_spartan_dev->resource[num_of_bases] ;
base_address = spartan_resource.start ;
}
 
result = pci_read_config_word(ppci_spartan_dev, PCI_COMMAND, &wvalue) ;
if (result < 0)
{
printk("<1> Read from command register failed! \n " );
return result ;
}
 
result = pci_write_config_word(ppci_spartan_dev, PCI_COMMAND, wvalue | PCI_COMMAND_MEMORY | PCI_COMMAND_IO) ;
if (result < 0)
{
printk("<1>Write to command register failed! \n " );
return result ;
}
#else
 
printk("<1> Board found at address 0x%08X\n", ppci_spartan_dev->base_address[0]);
 
// now go through base addresses of development board
// and see what size they are - first disable devices response
result = pci_read_config_word(ppci_spartan_dev, PCI_COMMAND, &wvalue) ;
if (result < 0)
{
printk("<1> Read from command register failed! \n " );
return result ;
}
 
// write masked config value back to command register to
// disable devices response! mask value
result = pci_write_config_word(ppci_spartan_dev, PCI_COMMAND, wvalue & ~PCI_COMMAND_IO & ~PCI_COMMAND_MEMORY) ;
 
if (result < 0)
{
printk("<1>Write to command register failed! \n " );
return result ;
}
 
// write to base address registers and read back until all 0s are read
base_address = ppci_spartan_dev->base_address[0] ;
num_of_bases = 0 ;
while ((base_address != 0x00000000) && (num_of_bases < 6))
{
// copy non-zero base address to private structure
pspartan_dev.bases[num_of_bases] = ppci_spartan_dev->base_address[num_of_bases] ;
 
// write to current register
result = pci_write_config_dword(ppci_spartan_dev, PCI_BASE_ADDRESS_0 + (num_of_bases * 4), 0xFFFFFFFF) ;
if (result < 0)
{
printk("<1>Write to BAR%d failed! \n ", num_of_bases);
return result ;
}
result = pci_read_config_dword(ppci_spartan_dev, PCI_BASE_ADDRESS_0 + (num_of_bases * 4), &base_address) ;
if (result < 0)
{
printk("<1>Read from BAR%d failed! \n ", num_of_bases);
return result ;
}
 
// calculate size of this base address register's range
size = 0xFFFFFFFF - base_address ;
// store size in structure
pspartan_dev.base_size[num_of_bases] = size + 1;
// set base address back to original value
base_address = pspartan_dev.bases[num_of_bases] ;
 
// now write original base address back to this register
result = pci_write_config_dword(ppci_spartan_dev, PCI_BASE_ADDRESS_0 + (num_of_bases * 4), base_address) ;
 
if (result < 0)
{
printk("<1>Write to BAR%d failed! \n ", num_of_bases);
return result ;
}
num_of_bases++ ;
// read new base address
base_address = ppci_spartan_dev->base_address[num_of_bases] ;
}
// write original value back to command register!
result = pci_write_config_word(ppci_spartan_dev, PCI_COMMAND, wvalue) ;
if (result < 0)
{
printk("<1>Write to command register failed! \n " );
return result ;
}
#endif
if (num_of_bases < 1)
printk("<1>No implemented base address registers found! \n ") ;
 
pspartan_dev.current_resource = - 1 ;
 
// store number of bases in structure
pspartan_dev.num_of_bases = num_of_bases ;
 
// display information about all base addresses found in this procedure
for (num_of_bases = 0; num_of_bases < pspartan_dev.num_of_bases; num_of_bases++)
{
printk("<1>BAR%d range from %08X to %08X \n ", num_of_bases, pspartan_dev.bases[num_of_bases], pspartan_dev.bases[num_of_bases] + pspartan_dev.base_size[num_of_bases]);
}
#ifdef __VGA__
for (sz = 0, size = PAGE_SIZE; size < VIDEO_SZ; sz++, size <<= 1);
pspartan_dev.video_vbase = __get_free_pages(GFP_KERNEL, sz);
 
if (pspartan_dev.video_vbase == 0) {
printk(KERN_ERR "spartan: abort, cannot allocate video memory\n");
return -EIO;
}
 
pspartan_dev.video_size = PAGE_SIZE * (1 << sz);
pspartan_dev.video_base = virt_to_bus(pspartan_dev.video_vbase);
 
for (page = virt_to_page(pspartan_dev.video_vbase); page <= virt_to_page(pspartan_dev.video_vbase + pspartan_dev.video_size - 1); page++)
mem_map_reserve(page);
 
printk(KERN_INFO "spartan: framebuffer at 0x%lx (phy 0x%lx), mapped to 0x%p, size %dk\n",
pspartan_dev.video_base, virt_to_phys(pspartan_dev.video_vbase), pspartan_dev.video_vbase, pspartan_dev.video_size/1024);
#endif
 
result = register_chrdev(REQUESTED_MAJOR, "spartan", &spartan_fops) ;
if (result < 0)
{
printk(KERN_WARNING "spartan: can't get major number %d\n",REQUESTED_MAJOR) ;
return result ;
}
printk("<1> Major number for spartan is %d \n", result );
pspartan_dev.major = result ;
 
return 0 ;
}
 
// celanup - unregister device
void cleanup_module(void)
{
int result ;
int size, sz;
 
#ifdef __VGA__
for (sz = 0, size = PAGE_SIZE; size < VIDEO_SZ; sz++, size <<= 1);
free_pages(pspartan_dev.video_vbase, sz);
#endif
result = unregister_chrdev(pspartan_dev.major, "spartan") ;
if (result < 0)
{
printk("<1> spartan device with major number %d unregistration failed \n", pspartan_dev.major);
return ;
}
else
{
printk("<1> spartan device with major number %d unregistered succesfully \n", pspartan_dev.major);
return ;
}
}
 
MODULE_LICENSE("GPL") ;
/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
driver/pci_bridge32_test Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: driver/pci_bridge32_test.c =================================================================== --- driver/pci_bridge32_test.c (nonexistent) +++ driver/pci_bridge32_test.c (revision 154) @@ -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: driver/Makefile =================================================================== --- driver/Makefile (nonexistent) +++ driver/Makefile (revision 154) @@ -0,0 +1,15 @@ +spartan_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 Index: driver/fb/spartan_fb.c =================================================================== --- driver/fb/spartan_fb.c (nonexistent) +++ driver/fb/spartan_fb.c (revision 154) @@ -0,0 +1,774 @@ +/* + * framebuffer driver for VBE 2.0 compliant graphic boards + * + * switching to graphics mode happens at boot time (while + * running in real mode, see arch/i386/video.S). + * + * (c) 1998 Gerd Knorr + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include
driver/fb/spartan_fb.o Property changes : Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: driver/fb/startx =================================================================== --- driver/fb/startx (nonexistent) +++ driver/fb/startx (revision 154) @@ -0,0 +1,81 @@ +#!/bin/sh +# $XConsortium: startx.cpp,v 1.4 91/08/22 11:41:29 rws Exp $ +# $XFree86: xc/programs/xinit/startx.cpp,v 3.2 1998/12/20 11:58:22 dawes Exp $ +# +# This is just a sample implementation of a slightly less primitive +# interface than xinit. It looks for user .xinitrc and .xserverrc +# files, then system xinitrc and xserverrc files, else lets xinit choose +# its default. The system xinitrc should probably do things like check +# for .Xresources files and merge them in, startup up a window manager, +# and pop a clock and serveral xterms. +# +# Site administrators are STRONGLY urged to write nicer versions. +# + +bindir=BINDIR + +userclientrc=$HOME/.xinitrc +userserverrc=$HOME/.xserverrc +sysclientrc=$HOME/delete/xinitrc +sysserverrc=/etc/X11/xinit/xserverrc +clientargs="" +serverargs="" + +if [ -f $userclientrc ]; then + clientargs=$userclientrc +else if [ -f $sysclientrc ]; then + clientargs=$sysclientrc +fi +fi + +if [ -f $userserverrc ]; then + serverargs=$userserverrc +else if [ -f $sysserverrc ]; then + serverargs=$sysserverrc +fi +fi + +display=:1 +#server=/usr/X11R6/bin/XF86_FBDev +server=/usr/X11R6/bin/XFree86 +#server=/home/simons/X11R6.5.1/bin/XFree86 +whoseargs="client" +while [ "x$1" != "x" ]; do + case "$1" in + /''*|\.*) if [ "$whoseargs" = "client" ]; then + if [ "x$clientargs" = x ]; then + clientargs="$1" + else + clientargs="$clientargs $1" + fi + else + if [ "x$serverargs" = x ]; then + serverargs="$1" + else + serverargs="$serverargs $1" + fi + fi ;; + --) whoseargs="server" ;; + *) if [ "$whoseargs" = "client" ]; then + clientargs="$clientargs $1" + else + case "$1" in + :[0-9]) display="$1" + ;; + *) serverargs="$serverargs $1" + ;; + esac + fi ;; + esac + shift +done + +# set up default Xauth info for this machine +mcookie=`mcookie` +serverargs="$serverargs -xf86config ./XF86Config-fb -auth $HOME/.Xauthority" +xauth add $display . $mcookie +xauth add `hostname -f`$display . $mcookie +xinit $clientargs -- $server $display $serverargs + +# various machines need special cleaning up, +# which should be done here Index: driver/fb/XF86Config-fb =================================================================== --- driver/fb/XF86Config-fb (nonexistent) +++ driver/fb/XF86Config-fb (revision 154) @@ -0,0 +1,77 @@ +# XFree86 4.0 configuration generated by Xconfigurator + +Section "ServerLayout" + Identifier "XFree86 Configured" + Screen 0 "Screen0" 0 0 + InputDevice "Mouse0" "CorePointer" + InputDevice "Keyboard0" "CoreKeyboard" +EndSection + +# By default, Red Hat Linux 6.0 and later use xfs + +Section "Files" + FontPath "unix/:7100" +EndSection + +# This loads all the modules... + +Section "Module" + Load "GLcore" + Load "dbe" + Load "dri" + Load "extmod" + Load "glx" + Load "pex5" + Load "record" + Load "xie" + Load "v4l" +EndSection + +Section "InputDevice" + Identifier "Keyboard0" + Driver "keyboard" + Option "XkbLayout" "us" +EndSection + +Section "InputDevice" + Identifier "Mouse0" + Driver "mouse" + Option "Device" "/dev/mouse" + Option "Protocol" "MouseManPlusPS/2" + Option "Emulate3Buttons" "off" + Option "ZAxisMapping" "4 5" +EndSection + +Section "Monitor" + Identifier "Iiyama A201HT, VisionMaster Pro 510" + VendorName "Unknown" + ModelName "Unknown" + HorizSync 30.0-130.0 + VertRefresh 50.0-160.0 +EndSection + +Section "Device" + Identifier "spartan" + Driver "fbdev" + Option "UseFBDev" + Option "fbdev" "/dev/fb1" + Option "ShadowFB" "off" +EndSection + +Section "Screen" + Identifier "Screen0" + Device "spartan" + Monitor "Iiyama A201HT, VisionMaster Pro 510" + DefaultDepth 8 + Subsection "Display" + Depth 8 + Modes "default" + EndSubSection + Subsection "Display" + Depth 8 + Modes "default" + EndSubSection +EndSection + +Section "DRI" +EndSection Index: driver/fb/spartan_kint.h =================================================================== --- driver/fb/spartan_kint.h (nonexistent) +++ driver/fb/spartan_kint.h (revision 154) @@ -0,0 +1,31 @@ +#include + +#define SPARTAN_IOC_NUM 'S' +#define SPARTAN_IOC_MAX_NUM 6 + +#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 +#define SPARTAN_IOC_CURBASE _IOR(SPARTAN_IOC_NUM, 3, base) // read current resource base address +#define SPARTAN_IOC_CURBASEMAP _IOR(SPARTAN_IOC_NUM, 4, base) // read current resource remaped base address ( 0 - not remaped) +#define SPARTAN_IOC_CURBASESIZE _IOR(SPARTAN_IOC_NUM, 5, base_size)// read current resource size +#define SPARTAN_IOC_NUMOFRES _IO(SPARTAN_IOC_NUM, 6) // read number of found resources +#define SPARTAN_IOC_VIDEO_BASE _IO(SPARTAN_IOC_NUM, 7) // read video buffer phyisical base address +#define SPARTAN_IOC_VIDEO_VBASE _IO(SPARTAN_IOC_NUM, 8) // read video buffer virtual base address +#define SPARTAN_IOC_VIDEO_SIZE _IO(SPARTAN_IOC_NUM, 9) // read video buffer size +#define SPARTAN_IOC_SET_VIDEO_BUFF _IO(SPARTAN_IOC_NUM, 10) + + +#define SPARTAN_P_IMG_CTRL1_ADDR 0x110 +#define SPARTAN_P_BA1_ADDR 0x114 +#define SPARTAN_P_AM1_ADDR 0x118 +#define SPARTAN_P_TA1_ADDR 0x11c + + +#define SPARTAN_W_IMG_CTRL1_ADDR 0x184 +#define SPARTAN_W_BA1_ADDR 0x188 +#define SPARTAN_W_AM1_ADDR 0x18C +#define SPARTAN_W_TA1_ADDR 0x190 + +#define SPARTAN_CRT_CTRL 0x000 +#define SPARTAN_CRT_ADDR 0x004 +#define SPARTAN_CRT_PALETTE_BASE 0x400 Index: driver/fb/Makefile =================================================================== --- driver/fb/Makefile (nonexistent) +++ driver/fb/Makefile (revision 154) @@ -0,0 +1,11 @@ +LINUX_SRC = /usr/src/linux + +spartan_fb.o: spartan_fb.c + gcc -D__KERNEL__ -DMODULE -I$(LINUX_SRC)/include -I. -O2 -c -o spartan_fb.o spartan_fb.c + +install: + insmod spartan_fb.o + +unisntall: + rmmod spartan_fb + Index: driver/slide.c =================================================================== --- driver/slide.c (nonexistent) +++ driver/slide.c (revision 154) @@ -0,0 +1,85 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +int main() +{ + int result ; + int fd ; + int i = 0; + char buff[640*480] ; + int palette[256] ; + int c; + unsigned long value ; + + fd = open("/dev/spartan", O_RDWR) ; + + if (fd < 0) { + printf("Error: Opening device /dev/spartan\n"); + return fd ; + } + + while (i < 54) { + c = getchar(); + if (c == EOF) + error("Early end-of-file."); + if ((i == 0) && (c != 0x42)) + error("Not BMP format."); + if ((i == 1) && (c != 0x4d)) + error("Not BMP format."); + if ((i == 2) && (c != 0x38)) + error("Not 8-bit BMP format."); + if ((i == 10) && (c != 0x36)) + error("Not limited to 64 colors (6 bits)."); + if ((i == 11) && (c != 0x01)) + error("Not limited to 64 colors (6 bits)."); + if ((i == 18) && (c != 0x80)) + error("Not 640 pixels horizontal resolution."); + if ((i == 19) && (c != 0x02)) + error("Not 640 pixels horizontal resolution."); + if ((i == 22) && (c != 0xe0)) + error("Not 480 pixels vertical resolution."); + if ((i == 23) && (c != 0x01)) + error("Not 480 pixels vertical resolution."); + i++; + } + + // activate resource 2 + value = 0x00000002 ; + result = ioctl(fd, SPARTAN_IOC_CURRESSET, value) ; + + /* Set palette */ + lseek(fd, SPARTAN_CRT_PALETTE_BASE, 0); + + while (i < 310) { + if (c == EOF) + error("Early end-of-file."); + + palette[(i - 54)/4] = ((getchar() >> 4) << 12) | ((getchar() >> 4) << 8) | ((getchar() >> 4) << 4); + +printf("%.4x\n", palette[(i - 54)/4]); + getchar(); + i+=4; + } + + while (i < 307510) { + buff[sizeof(buff) - (i - 310)] = (char)getchar(); + i++; + } + + if(write(fd, palette, 0x400) != 0x400) { + printf("Error writing device /dev/spartan\n"); + return -1; + } + + ioctl(fd, SPARTAN_IOC_SET_VIDEO_BUFF, buff) ; + + close(fd); + return 0; +} + Index: driver/sdram_test.c =================================================================== --- driver/sdram_test.c (nonexistent) +++ driver/sdram_test.c (revision 154) @@ -0,0 +1,120 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +int main() +{ + int result ; + int fd ; + unsigned long *buf ; + unsigned long value ; + unsigned long base ; + unsigned long base_size ; + + fd = open("/dev/spartan", O_RDWR) ; + + if (fd < 0) + return fd ; + + buf = (void *)malloc(4) ; + + if (buf == NULL) + return -1 ; + + // probe driver + result = ioctl(fd, SPARTAN_IOC_CURRESGET) ; + + if (result > 0) + printf("Driver reports enabled resource although it was not enabled through ioctl yet\n!") ; + + result = ioctl(fd, SPARTAN_IOC_NUMOFRES) ; + if (result != 2) + printf("SDRAM reference design implements 2 BARs, driver reported %d!\n", result) ; + + result = ioctl(fd, SPARTAN_IOC_CURBASE, &base) ; + if (base) + printf("Driver reports base address resource selected although it was not yet initialized!\n") ; + + result = ioctl(fd, SPARTAN_IOC_CURBASEMAP, &base) ; + + if (base) + printf("Driver reports base address remaped although it was not yet initialized!\n") ; + + result = ioctl(fd, SPARTAN_IOC_CURBASESIZE, &base_size) ; + if (base_size) + printf("Driver reports base address range non-zero although it was not yet initialized!\n") ; + + // activate resource 1 + value = 0x00000001 ; + result = ioctl(fd, SPARTAN_IOC_CURRESSET, value) ; + + if (result) + printf("Driver reported failure to intialize resource 1 !\n") ; + + // activate resource 2 + value = 0x00000002 ; + result = ioctl(fd, SPARTAN_IOC_CURRESSET, value) ; + + if (result) + printf("Driver reported failure to intialize resource 2!\n") ; + + // check if ioctl returns any meaningful values! + result = ioctl(fd, SPARTAN_IOC_CURRESGET) ; + + if (result != 2) + printf("Resource 2 was enabled, driver reports resurce %d active!\n", result) ; + + result = ioctl(fd, SPARTAN_IOC_CURBASE, &base) ; + if (!base) + printf("Driver should report non-zero base address when resource is selected!\n") ; + else + printf("Driver reports SDRAM at address %X\n", base) ; + + result = ioctl(fd, SPARTAN_IOC_CURBASEMAP, &base) ; + + if (!base) + printf("Driver reports zero page base address although resource 2 is supposed to be enabled!\n") ; + else + printf("Driver reports SDRAM at remaped address %X\n", base) ; + + result = ioctl(fd, SPARTAN_IOC_CURBASESIZE, &base_size) ; + if (!base_size) + printf("Driver reports zero base address range although resource is supposed to be enabled\n") ; + else + printf("Driver reports SDRAM size %li\n", base_size) ; + + value = 0x00000001 ; + *(buf) = value ; + while ((result = write(fd, buf, 4)) > 0) + { + value = value + 1 ; + *(buf) = value ; + } + + printf("%li writes succesfull!\n", value-1) ; + + // go back to start of image + value = lseek(fd, 0, 0) ; + if (result != 0) + { + printf("Seek didn't reset offset to 0i\n") ; + return -1 ; + } + value = 0x00000001 ; + while ((result = read(fd, buf, 4)) > 0) + { + if (value != *buf) + printf("Expected value was %X, actually read value was %X\n", value, *buf) ; + + value = value + 1 ; + } + + printf("%li reads done!\n", value-1) ; + close(fd) ; + return result ; +} Index: driver/README.txt =================================================================== --- driver/README.txt (nonexistent) +++ driver/README.txt (revision 154) @@ -0,0 +1,20 @@ +Files provided in this directory are intended for +PCI development purposes. Kernel interface provides +some basic functionality for accessing PCI memory mapped +resources on single device. Modules have been tested +on Linux kernels 2.2 and 2.4, inserted with modutils version 2.4.6-1 for i386 +IO resources as well as interrupts or DMA (mastership) +are not supported by this interface yet - they will probably be when +PCI bridge development is finished. +sdram_test.c source and binary is a little program that tests driver response +with Insight's Spartan-II PCI development kit with SDRAM reference design +loaded. + +I have compiled modules with +gcc -D__KERNEL__ -DMODULE -c -O and it worked fine - if it doesn't for you, don't ask me why, because I'm not Linux guru + +I have inserted modules with +insmod -f spartan_drv-2.*.o and it also worked, nonetheless insmod was complaining about versions + +Have fun, + Miha Dolenc \ No newline at end of file Index: driver/sdram_test =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: driver/sdram_test =================================================================== --- driver/sdram_test (nonexistent) +++ driver/sdram_test (revision 154)
driver/sdram_test Property changes : Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property

powered by: WebSVN 2.1.0

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