Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1548 connectés 

  FORUM HardWare.fr
  Linux et OS Alternatifs
  Hardware

  driver tiny serial de LDD

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

driver tiny serial de LDD

n°1059913
sebchr
Posté le 12-07-2008 à 19:59:11  profilanswer
 

Bonjour,
 
j'essaie d'utiliser le driver tiny_serial donné par Linux device driver.
Il compile et se charge mais quand je fais cat > /dev/mydriver  
j'obtiens l'erreur : Erreur d'écriture.: Erreur d'entrée/sortie
 
Est ce que quelqu'un saurait trouver l'erreur dans le driver :
 

Code :
  1. /*
  2. * Tiny Serial driver
  3. *
  4. * Copyright (C) 2002-2004 Greg Kroah-Hartman (greg@kroah.com)
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, version 2 of the License.
  9. *
  10. * This driver shows how to create a minimal serial driver.  It does not rely on
  11. * any backing hardware, but creates a timer that emulates data being received
  12. * from some kind of hardware.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/errno.h>
  16. #include <linux/init.h>
  17. #include <linux/slab.h>
  18. #include <linux/tty.h>
  19. #include <linux/tty_flip.h>
  20. #include <linux/serial.h>
  21. #include <linux/serial_core.h>
  22. #include <linux/module.h>
  23. #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>"
  24. #define DRIVER_DESC "Tiny serial driver"
  25. /* Module information */
  26. MODULE_AUTHOR( DRIVER_AUTHOR );
  27. MODULE_DESCRIPTION( DRIVER_DESC );
  28. MODULE_LICENSE("GPL" );
  29. #define DELAY_TIME  HZ * 2 /* 2 seconds per character */
  30. #define TINY_DATA_CHARACTER 't'
  31. #define TINY_SERIAL_MAJOR 240 /* experimental range */
  32. #define TINY_SERIAL_MINORS 1 /* only have one minor */
  33. #define UART_NR   1 /* only use one port */
  34. #define TINY_SERIAL_NAME "ttytiny"
  35. #define MY_NAME   TINY_SERIAL_NAME
  36. static struct timer_list *timer;
  37. static void tiny_stop_tx(struct uart_port *port)
  38. {
  39. }
  40. static void tiny_stop_rx(struct uart_port *port)
  41. {
  42. }
  43. static void tiny_enable_ms(struct uart_port *port)
  44. {
  45. }
  46. static void tiny_tx_chars(struct uart_port *port)
  47. {
  48.   struct circ_buf *xmit = &port->info->xmit;
  49.   int count;
  50.   printk(KERN_INFO "tx_char\n" );
  51.   if (port->x_char) {
  52.     pr_debug("wrote %2x", port->x_char);
  53.     port->icount.tx++;
  54.     port->x_char = 0;
  55.     return;
  56.   }
  57.   if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
  58.     tiny_stop_tx(port);
  59.     return;
  60.   }
  61.   count = port->fifosize >> 1;
  62.   do {
  63.     pr_debug("wrote %2x", xmit->buf[xmit->tail]);
  64.     xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
  65.     port->icount.tx++;
  66.     if (uart_circ_empty(xmit))
  67.       break;
  68.   } while (--count > 0);
  69.   if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
  70.     uart_write_wakeup(port);
  71.   if (uart_circ_empty(xmit))
  72.     tiny_stop_tx(port);
  73. }
  74. static void tiny_start_tx(struct uart_port *port)
  75. {
  76. }
  77. static void tiny_timer(unsigned long data)
  78. {
  79.   struct uart_port *port;
  80.   struct tty_struct *tty;
  81.   port = (struct uart_port *)data;
  82.   if (!port)
  83.     return;
  84.   if (!port->info)
  85.     return;
  86.   tty = port->info->tty;
  87.   if (!tty)
  88.     return;
  89.   /* add one character to the tty port */
  90.   /* this doesn't actually push the data through unless tty->low_latency is set */
  91.   tty_insert_flip_char(tty, TINY_DATA_CHARACTER, 0);
  92.   tty_flip_buffer_push(tty);
  93.   /* resubmit the timer again */
  94.   timer->expires = jiffies + DELAY_TIME;
  95.   add_timer(timer);
  96.   /* see if we have any data to transmit */
  97.   tiny_tx_chars(port);
  98. }
  99. static unsigned int tiny_tx_empty(struct uart_port *port)
  100. {
  101.   return 0;
  102. }
  103. static unsigned int tiny_get_mctrl(struct uart_port *port)
  104. {
  105.   return 0;
  106. }
  107. static void tiny_set_mctrl(struct uart_port *port, unsigned int mctrl)
  108. {
  109. }
  110. static void tiny_break_ctl(struct uart_port *port, int break_state)
  111. {
  112. }
  113. static void tiny_set_termios(struct uart_port *port,
  114.                              struct ktermios *new, struct ktermios *old)
  115. {
  116.   int baud, quot, cflag = new->c_cflag;
  117.   /* get the byte size */
  118.   switch (cflag & CSIZE) {
  119.     case CS5:
  120.       printk(KERN_DEBUG " - data bits = 5\n" );
  121.       break;
  122.     case CS6:
  123.       printk(KERN_DEBUG " - data bits = 6\n" );
  124.       break;
  125.     case CS7:
  126.       printk(KERN_DEBUG " - data bits = 7\n" );
  127.       break;
  128.     default: // CS8
  129.       printk(KERN_DEBUG " - data bits = 8\n" );
  130.       break;
  131.   }
  132.   /* determine the parity */
  133.   if (cflag & PARENB)
  134.     if (cflag & PARODD)
  135.       pr_debug(" - parity = odd\n" );
  136.     else
  137.       pr_debug(" - parity = even\n" );
  138.   else
  139.     pr_debug(" - parity = none\n" );
  140.   /* figure out the stop bits requested */
  141.   if (cflag & CSTOPB)
  142.     pr_debug(" - stop bits = 2\n" );
  143.   else
  144.     pr_debug(" - stop bits = 1\n" );
  145.   /* figure out the flow control settings */
  146.   if (cflag & CRTSCTS)
  147.     pr_debug(" - RTS/CTS is enabled\n" );
  148.   else
  149.     pr_debug(" - RTS/CTS is disabled\n" );
  150.   /* Set baud rate */
  151.   //baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16);
  152.   //quot = uart_get_divisor(port, baud);
  153.   //UART_PUT_DIV_LO(port, (quot & 0xff));
  154.   //UART_PUT_DIV_HI(port, ((quot & 0xf00) >> 8));
  155. }
  156. static int tiny_startup(struct uart_port *port)
  157. {
  158.   /* this is the first time this port is opened */
  159.   /* do any hardware initialization needed here */
  160.   /* create our timer and submit it */
  161.   if (!timer) {
  162.     timer = kmalloc(sizeof(*timer), GFP_KERNEL);
  163.     if (!timer)
  164.       return -ENOMEM;
  165.   }
  166.   timer->data = (unsigned long)port;
  167.   timer->expires = jiffies + DELAY_TIME;
  168.   timer->function = tiny_timer;
  169.   add_timer(timer);
  170.   return 0;
  171. }
  172. static void tiny_shutdown(struct uart_port *port)
  173. {
  174.   /* The port is being closed by the last user. */
  175.   /* Do any hardware specific stuff here */
  176.   /* shut down our timer */
  177.   del_timer(timer);
  178. }
  179. static const char *tiny_type(struct uart_port *port)
  180. {
  181.   return "tinytty";
  182. }
  183. static void tiny_release_port(struct uart_port *port)
  184. {
  185. }
  186. static int tiny_request_port(struct uart_port *port)
  187. {
  188.   return 0;
  189. }
  190. static void tiny_config_port(struct uart_port *port, int flags)
  191. {
  192. }
  193. static int tiny_verify_port(struct uart_port *port, struct serial_struct *ser)
  194. {
  195.   return 0;
  196. }
  197. static struct uart_ops tiny_ops = {
  198.   .tx_empty = tiny_tx_empty,
  199.   .set_mctrl = tiny_set_mctrl,
  200.   .get_mctrl = tiny_get_mctrl,
  201.   .stop_tx = tiny_stop_tx,
  202.   .start_tx = tiny_start_tx,
  203.   .stop_rx = tiny_stop_rx,
  204.   .enable_ms = tiny_enable_ms,
  205.   .break_ctl = tiny_break_ctl,
  206.   .startup = tiny_startup,
  207.   .shutdown = tiny_shutdown,
  208.   .set_termios = tiny_set_termios,
  209.   .type  = tiny_type,
  210.   .release_port = tiny_release_port,
  211.   .request_port = tiny_request_port,
  212.   .config_port = tiny_config_port,
  213.   .verify_port = tiny_verify_port,
  214. };
  215. static struct uart_port tiny_port = {
  216.   .ops  = &tiny_ops,
  217. };
  218. static struct uart_driver tiny_reg = {
  219.   .owner  = THIS_MODULE,
  220.   .driver_name = TINY_SERIAL_NAME,
  221.   .dev_name = TINY_SERIAL_NAME,
  222.   .major  = TINY_SERIAL_MAJOR,
  223.   .minor  = TINY_SERIAL_MINORS,
  224.   .nr  = UART_NR,
  225. };
  226. static int __init tiny_init(void)
  227. {
  228.   int result;
  229.   printk(KERN_INFO "Tiny serial driver loaded\n" );
  230.   result = uart_register_driver(&tiny_reg);
  231.   if (result)
  232.     return result;
  233.   result = uart_add_one_port(&tiny_reg, &tiny_port);
  234.   if (result)
  235.     uart_unregister_driver(&tiny_reg);
  236.   return result;
  237. }
  238. module_init(tiny_init);

mood
Publicité
Posté le 12-07-2008 à 19:59:11  profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Linux et OS Alternatifs
  Hardware

  driver tiny serial de LDD

 

Sujets relatifs
Driver linuxplus de son sur mon pc meme avec nouveau driver
Intégrer un driver à une distrib linux.[Nvidia] Kernel 2.6.25 et driver Nvidia 169.12-173.08
Nouveau, un pilote libre pour les cartes graphiques NVIDIAProblème de compilation pour un driver carte wifi "config.h manquant"
Driver ATI Rage 128MO AMC VER 2.0 sortir tv videoDriver ATI Rage 128MO AMC VER 2.0
Debian Etch 2.6.18 & Marvell Yukon driver skydriver ATI
Plus de sujets relatifs à : driver tiny serial de LDD


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR