红联Linux门户
Linux帮助

帮帮忙 多多指教

发布时间:2007-02-10 19:25:59来源:红联作者:quecn
我要写串口的驱动,手上有《linux设备驱动程序》,没怎么看懂,大家帮帮忙!我些的框架如下:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include


#include


static struct tty_driver *serial_driver;

static void serial_close(struct tty_struct * tty, struct file * filp)
{

}

static void serial_unthrottle(struct tty_struct * tty)
{

}
static int serial_write(struct tty_struct * tty, const unsigned char *buf, int count)
{

}

static int serial_write_room(struct tty_struct *tty)
{

}

static int serial_chars_in_buffer(struct tty_struct *tty)
{

}


static int serial_set_lock(struct tty_struct *tty, int __user * arg)
{

}

static void serial_flush_buffer(struct tty_struct *tty)
{

}

static int serial_open(struct tty_struct *tty, struct file * filp)
{

}

static void serial_set_termios(struct tty_struct *tty, struct termios *old_termios)
{

}
static struct tty_operations serial_ops = {
.open = serial_open,
.close = serial_close,
.flush_buffer = serial_flush_buffer,
.chars_in_buffer = serial_chars_in_buffer,
.unthrottle = serial_unthrottle,
.set_termios = serial_set_termios,

};

static void __init serial_driver_init(void)
{

serial_driver = alloc_tty_driver();

if (!serial_driver)
{
panic("Couldn't allocate the driver");
}

serial_driver->owner = THIS_MODULE;
serial_driver->driver_name =;
serial_driver->name = ;
serial_driver->major = ;
serial_driver->minor_start =;
serial_driver->type = ;
serial_driver->subtype = ;
serial_driver->init_termios =;
serial_driver->init_termios.c_iflag =;
serial_driver->init_termios.c_oflag = ;
serial_driver->init_termios.c_cflag = ;
serial_driver->init_termios.c_lflag = ;
serial_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;

serial_driver->other = ;
serial_driver->ioctl = ;

tty_set_operations(serial_driver, &serial_ops);

if (tty_register_driver(serial_driver))
panic("Couldn't register the driver");
}

static void __exit serial_driver_exit(void)
{

}

module_init(serial_driver_init);
module_exit(serial_driver_init);
文章评论

共有 1 条评论

  1. 201.211.208.* 于 2007-07-06 00:44:57发表:

    http://4413adf80b9ac1da3585ade6a9111a82-t.lwgmrw.org 4413adf80b9ac1da3585ade6a9111a82 http://4413adf80b9ac1da3585ade6a9111a82-b1.lwgmrw.org 4413adf80b9ac1da3585ade6a9111a82 http://4413adf80b9ac1da3585ade6a9111a82-b3.lwgmrw.org 7323937625928ec2c2b389a5c949efe8