Skip to content
Snippets Groups Projects
Select Git revision
  • 3f6f1480d86bf9fc16c160d803ab1d006e3058d5
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

emulate.c

Blame
  • n_hdlc.c 27.20 KiB
    // SPDX-License-Identifier: GPL-1.0+
    /* generic HDLC line discipline for Linux
     *
     * Written by Paul Fulghum paulkf@microgate.com
     * for Microgate Corporation
     *
     * Microgate and SyncLink are registered trademarks of Microgate Corporation
     *
     * Adapted from ppp.c, written by Michael Callahan <callahan@maths.ox.ac.uk>,
     *	Al Longyear <longyear@netcom.com>,
     *	Paul Mackerras <Paul.Mackerras@cs.anu.edu.au>
     *
     * Original release 01/11/99
     *
     * This module implements the tty line discipline N_HDLC for use with
     * tty device drivers that support bit-synchronous HDLC communications.
     *
     * All HDLC data is frame oriented which means:
     *
     * 1. tty write calls represent one complete transmit frame of data
     *    The device driver should accept the complete frame or none of 
     *    the frame (busy) in the write method. Each write call should have
     *    a byte count in the range of 2-65535 bytes (2 is min HDLC frame
     *    with 1 addr byte and 1 ctrl byte). The max byte count of 65535
     *    should include any crc bytes required. For example, when using
     *    CCITT CRC32, 4 crc bytes are required, so the maximum size frame
     *    the application may transmit is limited to 65531 bytes. For CCITT
     *    CRC16, the maximum application frame size would be 65533.
     *
     *
     * 2. receive callbacks from the device driver represents
     *    one received frame. The device driver should bypass
     *    the tty flip buffer and call the line discipline receive
     *    callback directly to avoid fragmenting or concatenating
     *    multiple frames into a single receive callback.
     *
     *    The HDLC line discipline queues the receive frames in separate
     *    buffers so complete receive frames can be returned by the
     *    tty read calls.
     *
     * 3. tty read calls returns an entire frame of data or nothing.
     *    
     * 4. all send and receive data is considered raw. No processing
     *    or translation is performed by the line discipline, regardless
     *    of the tty flags
     *
     * 5. When line discipline is queried for the amount of receive
     *    data available (FIOC), 0 is returned if no data available,
     *    otherwise the count of the next available frame is returned.
     *    (instead of the sum of all received frame counts).
     *
     * These conventions allow the standard tty programming interface
     * to be used for synchronous HDLC applications when used with
     * this line discipline (or another line discipline that is frame
     * oriented such as N_PPP).
     *
     * The SyncLink driver (synclink.c) implements both asynchronous
     * (using standard line discipline N_TTY) and synchronous HDLC
     * (using N_HDLC) communications, with the latter using the above
     * conventions.
     *
     * This implementation is very basic and does not maintain
     * any statistics. The main point is to enforce the raw data
     * and frame orientation of HDLC communications.
     *
     * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
     * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES