由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Linux版 - 哪位用过tty_flip_buffer_push()? (转载)
相关主题
并口驱动的一个问题 (转载)still can not install debian normally on dockstar
Micro-SD card 驱动程序SOS: Ubuntu开机进不去GUI,也进不去TTY
求助本版牛人Kernel ioctl call
copy_from_user() 是怎么知道缓存长度的?INIT_WORK从Linux kernel 2.6.20后改了?
现在的 linux 后台进程太多了急问:linux 2.6 里,如何从inode得到ext2_inode_info?
默认启动X11的问题dma一次只能传16kb,
Linux: Linux TTY维护者Alan Cox退出,称“我已经受够了” [ZZ]有没有什么网络函数能够
一个ssh 诡异的问题print out task_struct contents
相关话题的讨论汇总
话题: tiny话题: tty话题: timer话题: struct话题: st
进入Linux版参与讨论
1 (共1页)
i**p
发帖数: 902
1
【 以下文字转载自 Programming 讨论区 】
发信人: isup (No), 信区: Programming
标 题: 哪位用过tty_flip_buffer_push()?
发信站: BBS 未名空间站 (Sun Jun 15 17:43:46 2014, 美东)
I am trying to run tiny_tty in LDD3. When I use "cat /dev/ttty0" to read
from it, there is no output and the command is blocked.
Checking the trace, I notice both tty_insert_flip_char() and tty_flip_buffer
_push() are called. However, the data is not sent to the user by tty core.
Instead, it is sent back to the tiny_tty driver's tiny_write() callback
function. What is wrong there?
The kernel version is 2.6.32-61-generic.
static void tiny_timer(unsigned long timer_data)
{
struct tiny_serial *tiny = (struct tiny_serial *)timer_data;
struct tty_struct *tty_st_p;
struct tty_port *port;
int i;
char data[1] = {TINY_DATA_CHARACTER};
int data_size = 1;
if (!tiny)
return;
tty_st_p = tiny->tty_tse_p;
if (!tty_buffer_request_room(tty_st_p, 1))
tty_flip_buffer_push(tty_st_p);
tty_insert_flip_char(tty_st_p, 'H', TTY_NORMAL);
tty_flip_buffer_push(tty_st_p);
printk(KERN_INFO "tiny_timer() tty_flip_buffer_push()n");
/* resubmit the timer again */
tiny->timer->expires = jiffies + DELAY_TIME;
add_timer(tiny->timer);
}
static int tiny_open(struct tty_struct *tty_st_p, struct file *file)
{
struct tiny_serial *tiny;
struct timer_list *timer;
int index;
/* initialize the pointer in case something fails */
tty_st_p->driver_data = NULL;
/* get the serial object associated with this tty pointer */
index = tty_st_p->index;
tiny = tiny_table[index];
if (tiny == NULL) {
/* first time accessing this device, let's create it */
tiny = kmalloc(sizeof(*tiny), GFP_KERNEL);
if (!tiny)
return -ENOMEM;
sema_init(&tiny->sem, 1);
tiny->open_count = 0;
tiny->timer = NULL;
tiny_table[index] = tiny;
}
down(&tiny->sem);
/* save our structure within the tty structure */
tty_st_p->driver_data = tiny;
tiny->tty_tse_p = tty_st_p;
++tiny->open_count;
if (tiny->open_count == 1) {
/* this is the first time this port is opened */
/* do any hardware initialization needed here */
/* create our timer and submit it */
if (!tiny->timer) {
timer = kmalloc(sizeof(*timer), GFP_KERNEL);
if (!timer) {
up(&tiny->sem);
return -ENOMEM;
}
tiny->timer = timer;
init_timer(tiny->timer);
}
tiny->timer->data = (unsigned long )tiny;
tiny->timer->expires = jiffies + DELAY_TIME;
tiny->timer->function = tiny_timer;
printk(KERN_INFO, "tiny_open()n");
add_timer(tiny->timer);
}
up(&tiny->sem);
return 0;
}
static int tiny_write(struct tty_struct *tty_st_p,
const unsigned char *buffer, int count)
{
struct tiny_serial *tiny = tty_st_p->driver_data;
int i;
int retval = -EINVAL;
if (!tiny)
return -ENODEV;
down(&tiny->sem);
if (!tiny->open_count)
/* port was not opened */
goto exit;
/* fake sending the data out a hardware port by
* writing it to the kernel debug log.
*/
printk(KERN_DEBUG "%s - ", __FUNCTION__);
for (i = 0; i < count; ++i)
printk("%02x ", buffer[i]);
printk("n");
retval = count;
exit:
up(&tiny->sem);
return retval;
}
1 (共1页)
进入Linux版参与讨论
相关主题
print out task_struct contents现在的 linux 后台进程太多了
How to register linux network driver ?默认启动X11的问题
定义linked list最后一行什么意思? (转载)Linux: Linux TTY维护者Alan Cox退出,称“我已经受够了” [ZZ]
弱弱的问个内核遍历当前进程的子进程的一小段程序一个ssh 诡异的问题
并口驱动的一个问题 (转载)still can not install debian normally on dockstar
Micro-SD card 驱动程序SOS: Ubuntu开机进不去GUI,也进不去TTY
求助本版牛人Kernel ioctl call
copy_from_user() 是怎么知道缓存长度的?INIT_WORK从Linux kernel 2.6.20后改了?
相关话题的讨论汇总
话题: tiny话题: tty话题: timer话题: struct话题: st