|
请教 编写uart在2410板上运行出现的错误
[复制链接]
下面是原程序:
#include
#include
#include
#include
#include
#include
#include
#define UART_ULCON1 (*(volatile unsigned *)0x50004000) //UART 1 Line control
#define UART_UCON1 (*(volatile unsigned *)0x50004004) //UART 1 Control
#define UART_UFCON1 (*(volatile unsigned *)0x50004008) //UART 1 FIFO control
#define UART_UMCON1 (*(volatile unsigned *)0x5000400c) //UART 1 Modem control
#define UART_UTRSTAT1 (*(volatile unsigned *)0x50004010) //UART 1 Tx/Rx status
#define UART_UERSTAT1 (*(volatile unsigned *)0x50004014) //UART 1 Rx error status
#define UART_UFSTAT1 (*(volatile unsigned *)0x50004018) //UART 1 FIFO status
#define UART_UMSTAT1 (*(volatile unsigned *)0x5000401c) //UART 1 Modem status
#define UART_UBRDIV1 (*(volatile unsigned *)0x50004028) //UART 1 Baud rate divisor
#define UART_UTXH1 (*(volatile unsigned char *)0x50004020) //UART 1 Transmission Hold
#define UART_URXH1 (*(volatile unsigned char *)0x50004024) //UART 1 Receive buffer
#define WrUTXH1(ch) (*(volatile unsigned char *)0x50004020)=(unsigned char)(ch)
#define RdURXH1() (*(volatile unsigned char *)0x50004024)
#define UTXH1 (0x50004020)
#define URXH1 (0x50004024)
#define DEVICE_NAME "uart1" //设备文件名
#define BUTTON_MAJOR 220 //主设备号
static int uart1_open(struct inode *inode, struct file * file);
static int uart1_read(struct file * file, char * buff, size_t count, loff_t *ppos);
static int uart1_write( struct file *filp, const char *buff, size_t count, loff_t *offp );
static int uart1_release(struct inode *inode, struct file *filp);
static int uart1_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg );
static int uart1_open(struct inode *inode, struct file * file)
{
__raw_writel(0x05,UART_UCON1);
__raw_writel(0x03,UART_ULCON1);
printk("Kernel : open is ok......\n");
return 0;
}
static int uart1_read(struct file * file, char * buff, size_t count, loff_t *ppos)
{
int i;
unsigned char ch;
for(i = 0; i < count; i++)
{
while(!(UART_UTRSTAT1 & 0x1));
ch = UART_URXH1;
*(buff + i) = ch;
}
return strlen(buff);
}
static int uart1_write( struct file *filp, const char *buff, size_t count, loff_t *offp )
{
int i;
unsigned char ch;
for(i = 0; i < count; i++)
{
ch = *(buff + i);
while(!((UART_UTRSTAT1 & 0x2) == 0x2));
__raw_writel(ch,UART_UTXH1) ;
}
return 0;
}
static int uart1_ioctl (struct inode *inode, struct file *file, unsigned int cmd ,unsigned long arg )
{
int ret;
ret = -EINVAL;
switch(cmd)
{
case 111:
{
if(arg == 115200)
{
__raw_writel(26,UART_UBRDIV1);
ret = 0;
}
}; break;
default:
return -EINVAL;
}
printk("Kernel : in ioctl, (%d, %d)\n", cmd, arg);
return 0;
}
static int uart1_release(struct inode *inode, struct file *filp)
{
printk("release!!\n");
return 0;
}
static struct file_operations uart1_fops = {
owner: THIS_MODULE,
open: uart1_open,
ioctl: uart1_ioctl,
read: uart1_read,
write: uart1_write,
release: uart1_release
};
static int __init uart1_init(void)
{
int ret;
ret = register_chrdev(BUTTON_MAJOR, DEVICE_NAME, &uart1_fops);
if (ret < 0)
{
printk(DEVICE_NAME " can't register major number\n");
return ret;
}
printk(" init ok!......\n");
return 0;
}
static void __exit uart1_exit(void)
{
unregister_chrdev(BUTTON_MAJOR, DEVICE_NAME);
printk("bye !\n");
}
module_init(uart1_init);
module_exit(uart1_exit);
MODULE_LICENSE("GPL");
在目标板上运行出现如下的问题:
[root@(none) home]# mknod /dev/uart1 c 220 0
[root@(none) home]# insmod uart1.ko
Using uart1.ko
init ok!......
[root@(none) home]# ./utest
Unable to handle kernel paging request at virtual address 50004004
pgd = c25ac000
[50004004] *pgd=00000000
Internal error: Oops: 5 [#1]
Modules linked in: uart1 ov511 usbvideo usb_storage sd_mod
CPU: 0
PC is at uart1_open+0x14/0x48 [uart1]
LR is at chrdev_open+0x14c/0x168
pc : [] lr : [] Not tainted
sp : c2df3ed8 ip : c2df3ee8 fp : c2df3ee4
r10: 4013d180 r9 : c2df2000 r8 : c24f7a40
r7 : 00000000 r6 : 00000000 r5 : c2bda660 r4 : c3bb5680
r3 : 50004004 r2 : 80000013 r1 : c24f7a407 r0 : bf03019825AC000 DAC: 0000005Process utest (pid: 337, stack limit = 0xc2df2190)
Stack: (0xc2df3ed8 to 0xc2df4000)
3ec0: c2df3f0c c2df3ee8
3ee0: c00750e4 bf030010 00000000 c24f7a40 c2bda660 c3fc21e0 ffffffe9 c2580f4c
3f00: c2df3f30 c2df3f10 c006b338 c0074fa8 00000000 00000003 00000000 c3ee5000
3f20: c00235c4 c2df3f84 c2df3f34 c006b228 c006b23c c2580f4c c3fc21e0 00000000
3f40: c001b7c0 c2df3f78 00000101 00000001 00000000 00008680 c2df3f84 c2df3f68
3f60: c0078be0 c00574e0 befffd8c 00000001 befffd8c befffd8c c2df3fa4 c2df3f88
3f80: c006b63c c006b1f0 befffd84 4001bd80 000085a4 00000005 00000000 c2df3fa8
3fa0: c0023440 c006b604 befffd84 c002a368 00008680 00000000 befffd8c 00000000
3fc0: befffd84 4001bd80 000085a4 00000001 4013f430 00008474 4013d180 befffd54
3fe0: 00000000 befffd3c 00003c00 400e0c40 060000010 000086[] (chrdev_)[] (chrdev_open+0x0/0x168) from [] (dentry_open+0x10c/0x244) r8 = C2580F4C r7 = FFFFFFE9 r6 = C3FC21E0 r5 = C2BDA660
r4 = C24F7A40
[] (dentry_open+0x0/0x244) from [] (dfilp_open+0x48/00 r6 3 r4 = 00000000
[] (filp_open+0x0/0x4c) from [] (sys_open+0x48/0x8c)
r4 = BEFFFD8C
[] (sys_open+0x0/0x8c) from [] (ret_fast_syscall+0x0/0x2c)
r7 = 00000005 r6 = 000085A4 r5 = 4001BD80 r4 = BEFFFD84
Code: e92dd800 e24cb004 e59f3028 e59f0028 (e5932000)
Segmentation fault
[root@(none) home]#
请问各位:Unable to handle kernel paging request at virtual address 50004004
这句话的错是什么原因的呢?如何解决呢?谢谢。。。。
|
|