<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><div>Hi Members of linuxppc,</div>
<div> </div>
<div>I'm working on XUPV2P board with Virtex II Pro FPGA device.</div>
<div> </div>
<div>I written a kernel module for LED device. I got that module run
successfuly on ML403 board having Virtex 4 FPGA.I have not make any
change in my source code for XUP board, because I don't feel any change is required.</div>
<div> </div>
<div>On XUP board when I run "insmod xilinx_led.ko" command on my target board, I got following message.</div>
<div> </div>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff"># insmod xilinx_led..ko</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><b><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">Oops: kernel access of bad area, sig: 11 [#1]</font></span></b>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">PREEMPT</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">NIP: d1006190 LR: d1006188 CTR: 00000000</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">REGS: c0705db0 TRAP: 0300<span style=""> </span>Not tainted<span style=""> </span>(2.6.23xlnx)</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">MSR: 00029030 <EE,ME,IR,DR><span style=""> </span>CR: 24000024<span style=""> </span>XER: 00000000</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">DEAR: 0000004c, ESR: 00000000</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">TASK = c04c63d0[186] 'insmod' THREAD: c0704000</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">GPR00: d1006188 c0705e60 c04c63d0 00000000 000000d0 00000001 00000000 c0220ae0</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">GPR08: c006c60c 00000000 00000001 c04553f0 026f4bac 100b4260 d1003288 d1007668</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">GPR16: d1003288 d1003238 0000fff1 0000fff2 0000004c 00000000 d100762c c003e94c</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">GPR24: d1002e02 00000018 d1002000 00000019 d1000000 d1007598 d10077c8 00000000</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">NIP [d1006190] xilinx_ml403_led_setup+0x174/0x1dc [xilinx_led]</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">LR [d1006188] xilinx_ml403_led_setup+0x16c/0x1dc [xilinx_led]</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">Call Trace:</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">[c0705e60] [d1006188] <strong>xilinx_ml403_led_setup</strong>+0x16c/0x1dc [xilinx_led] <b>(unreliable)</b></font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">[c0705e90] [c0040be0] sys_init_module+0x120c/0x12f8</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">[c0705f40] [c0002c10] ret_from_syscall+0x0/0x3c</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">Instruction dump:</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">48000819 3d20d100 39297620 913f003c 93bf0040 3c800fc0 60840001 7fe3fb78</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">38a00001 48000805 813e0014 7c7f1b78 <80e9004c> 3c60d100 3c80d100 80bc77c8</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"> </span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;">Note: After above output when I execute "lsmod" command. I observed that led device is tainted.</span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"> </span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">~ # lsmod</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">Module<span style=""> </span>Size<span style=""> </span>Used by<span style=""> </span>Tainted: G</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">xilinx_led<span style=""> </span><span style=""> </span>6172<span style=""> </span>1</font></span>
</p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: Arial;"><font color="#0000ff">~ #</font></span>
</p>
<div>
<div> </div></div>
<div>What I understood from above message is that there is a problem in registering the device in function <strong><font color="#0000ff">xilinx_ml403_led_setup( ). </font></strong></div>
<div><strong></strong> </div>
<div><font color="#000000">Anyone can help me out to solve this problem?</font></div>
<div>The source code is given below. </div>
<div>Rajendra</div>
<br>
---------------------------------------Xilinx_led.c---------------------------------------------------------------<br>
#include <linux/init.h><br>
#include <linux/module.h><br>
#include <linux/kernel.h><br>
#include <linux/slab.h><br>
#include <linux/fs.h><br>
#include <linux/errno.h><br>
#include <linux/types.h><br>
#include <linux/mm.h><br>
#include <linux/cdev.h><br>
#include <linux/proc_fs.h><br>
#include <linux/fcntl.h><br>
#include <linux/ioport.h><br>
#include <linux/interrupt.h><br>
#include <linux/xilinx_devices.h><br>
#include <asm/system.h><br>
#include <asm/io.h><br>
#include <asm/uaccess.h><br>
<br>
#include "xparameters.h"<br>
#include "xio.h"<br>
#include "xgpio.h"<br>
#include "xgpio_l.h"<br>
#include "xstatus.h"<br>
<br>
#include "xbasic_types.h"<br>
/* LED constant */<br>
<br>
#define DRIVER_NAME "led"<br>
#define DRIVER_DESCRIPTION "GPIO based 4 bit led peripheral driver"<br>
#define LED_PHY_BASEADDR XPAR_LEDS_4BIT_BASEADDR<br>
#define LED_PHY_HIGHADDR XPAR_LEDS_4BIT_HIGHADDR<br>
#define LED_DEVICE_ID XPAR_LEDS_4BIT_DEVICE_ID<br>
#define LED_MAJOR 252<br>
#define LED_MINOR 1<br>
#define LEDChan 1<br>
<br>
XGpio gp_out;<br>
<br>
/* Device Structure */<br>
<br>
struct led_instance<br>
{<br>
Xuint32 phy_baseaddr;<br>
Xuint32 phy_highaddr;<br>
Xuint32 remap_size;<br>
Xuint32 virtual_baseaddr;<br>
u32 device_id;<br>
struct cdev *cdev;<br>
<br>
XGpio gpio;<br>
};<br>
<br>
struct led_instance xilinx_ml403_led;<br>
<br>
/*Open and Release method */<br>
<br>
int led_open(struct inode *inode, struct file *filp)<br>
{<br>
struct led_instance *dev;<br>
<br>
dev = container_of(inode -> i_cdev, struct led_instance, cdev);<br>
filp -> private_data = dev;<br>
return 0;<br>
}<br>
<br>
int led_release(struct inode *inode, struct file *filp)<br>
{<br>
return 0;<br>
}<br>
<br>
/* Read Method */<br>
<br>
ssize_t led_read(struct file *flip, char __user *buf, size_t count, loff_t *f_pos)<br>
{<br>
size_t retval = 0;<br>
u32 data;<br>
<br>
printk(KERN_INFO "%s: Entering\n\r", __FUNCTION__);<br>
<br>
if(*f_pos >= sizeof(data))<br>
{<br>
goto out01;<br>
}<br>
<br>
if(*f_pos + count >= sizeof(data))<br>
{<br>
count = sizeof(data) - *f_pos;<br>
}<br>
<br>
data = XGpio_DiscreteRead(&gp_out, LEDChan);<br>
printk(KERN_INFO "data = 0x%08X!\n\r", data);<br>
<br>
if(copy_to_user(buf, &data, count))<br>
{<br>
retval = -EFAULT;<br>
goto out01;<br>
}<br>
*f_pos += count;<br>
retval = count;<br>
<br>
out01: return retval;<br>
<br>
}<br>
<br>
/* Write Method */<br>
ssize_t led_write(struct file *flip, const char __user *buf, size_t count, loff_t *f_pos)<br>
{<br>
size_t retval = 0;<br>
Xuint32 data;<br>
<br>
printk(KERN_INFO "%s: Entering\n\r", __FUNCTION__);<br>
<br>
if(count < sizeof(data))<br>
{<br>
printk("argument to small!\n\r");<br>
retval = -EINVAL;<br>
goto out01;<br>
}<br>
<br>
if(*f_pos + count >= sizeof(data))<br>
{<br>
count = sizeof(data) - *f_pos;<br>
}<br>
if(copy_from_user(&data,buf, count))<br>
{<br>
retval = -EFAULT;<br>
goto out01;<br>
}<br>
XGpio_DiscreteWrite(&gp_out,LEDChan,data);<br>
*f_pos += count;<br>
retval = count;<br>
<br>
out01: return retval;<br>
}<br>
<br>
/* File Operations Structure */<br>
<br>
struct file_operations led_fops = {<br>
<br>
owner: THIS_MODULE,<br>
open: led_open,<br>
read: led_read,<br>
write: led_write,<br>
release:led_release<br>
};<br>
<br>
/* Device Registration */<br>
int xilinx_ml403_led_setup(void)<br>
{<br>
XGpio_Config xgpio_config;<br>
struct cdev *cdev=0;<br>
int retval = 0;<br>
dev_t devno;<br>
<br>
memset(&xilinx_ml403_led, 0, sizeof(struct led_instance));<br>
<br>
/* Map the control registers in */<br>
/* get baseaddress and highaddress */<br>
xilinx_ml403_led.phy_baseaddr = LED_PHY_BASEADDR;<br>
xilinx_ml403_led.remap_size = LED_PHY_HIGHADDR - LED_PHY_BASEADDR + 1;<br>
xilinx_ml403_led.device_id = LED_DEVICE_ID;<br>
<br>
if(!xilinx_ml403_led.phy_baseaddr ||
(xilinx_ml403_led.remap_size - xilinx_ml403_led.phy_baseaddr + 1 <
8))<br>
{<br>
<br>
printk(KERN_ERR "%s: Couldn't get registers resource\n\r","led");<br>
retval = -EFAULT;<br>
goto failed1;<br>
} <br>
<br>
if(!request_mem_region(xilinx_ml403_led.phy_baseaddr, xilinx_ml403_led.remap_size, DRIVER_NAME))<br>
{<br>
<br>
printk(KERN_ERR "Couldn't lock
memory region at 0x%08lX\n\r",(unsigned long)
xilinx_ml403_led.phy_baseaddr);<br>
retval = -EBUSY;<br>
goto failed2; <br>
<br>
}<br>
<br>
xilinx_ml403_led.virtual_baseaddr = ioremap(xilinx_ml403_led.phy_baseaddr, xilinx_ml403_led.remap_size);<br>
<br>
<br>
if(!xilinx_ml403_led.virtual_baseaddr)<br>
{<br>
<br>
printk(KERN_ERR "Couldn't ioremap
memory at 0x%08lX\n\r", (unsigned long) xilinx_ml403_led.phy_baseaddr);<br>
retval = -EFAULT;<br>
goto failed3;<br>
<br>
}<br>
<br>
if(XGpio_CfgInitialize(&gp_out, &xgpio_config,xilinx_ml403_led.virtual_baseaddr) != XST_SUCCESS)<br>
{<br>
printk(KERN_ERR "%s: Couldn't initialize instance.\n\r","xilinx_led");<br>
retval = -ENODEV;<br>
goto failed3;<br>
}<br>
XGpio_SetDataDirection(&gp_out, LEDChan , 0x00000000);<br>
<br>
cdev= kmalloc(sizeof(struct cdev), GFP_KERNEL);<br>
if(!cdev)<br>
{<br>
printk(KERN_ERR "%s: Couldn't allocate device private record\n\r","led");<br>
return -ENOMEM;<br>
}<br>
<br>
memset(cdev,0,sizeof(struct cdev));<br>
<br>
cdev_init(cdev,&led_fops);<br>
cdev->owner = THIS_MODULE;<br>
cdev->ops = &led_fops;<br>
devno = MKDEV(LED_MAJOR,LED_MINOR);<br>
retval = cdev_add(cdev,devno,1);<br>
<br>
xilinx_ml403_led.cdev;<br>
<br>
printk(KERN_ERR "%s at 0x%081X mapped to 0x%08X
device:%u,%u\n\r","xilinx_led",xilinx_ml403_led.phy_baseaddr,(unsigned
int) xilinx_ml403_led.virtual_baseaddr,(unsigned
int)MAJOR(xilinx_ml403_led.cdev->dev),(unsigned
int)MINOR(xilinx_ml403_led.cdev->dev));<br>
<br>
failed3:<br>
iounmap((void *) (xilinx_ml403_led.phy_baseaddr));<br>
<br>
failed2:<br>
release_mem_region(xilinx_ml403_led.phy_baseaddr,xilinx_ml403_led.remap_size);<br>
<br>
failed1:<br>
return retval;<br>
}<br>
<br>
int __init led_init(void)<br>
{<br>
int retval;<br>
retval=xilinx_ml403_led_setup();<br>
if(retval)<br>
return retval;<br>
return 0;<br>
}<br>
<br>
void __exit led_exit(void)<br>
{<br>
cdev_del(xilinx_ml403_led.cdev);<br>
<br>
iounmap((void *)(xilinx_ml403_led.virtual_baseaddr));<br>
release_mem_region(xilinx_ml403_led.phy_baseaddr,xilinx_ml403_led.remap_size);<br>
}<br>
<br>
module_init(led_init);<br>
module_exit(led_exit);<br>
<br>
MODULE_AUTHOR("SANDEEPANI - SCHOOL OF EMBEDDDED DESIGN");<br>
MODULE_DESCRIPTION(DRIVER_DESCRIPTION);<br>
MODULE_LICENSE("Dual BSD/GPL");<br>
<br>
<br>
</td></tr></table><br>
<!--3--><hr size=1></hr> Explore and discover exciting holidays and getaways with Yahoo! India Travel <a href="http://in.rd.yahoo.com/tagline_Travel_1/*http://in.travel.yahoo.com/"> Click here!</a>