Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/net/ethernet/marvell/octeontx2/nic/   (LibreOffice Version 25.8.3.2©)  Datei vom 24.10.2025 mit Größe 375 B image not shown  

Quelle  pc300too.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0-only

 * Cyclades PC300 synchronous serial card driver for Linux
*
 * Copyright( -2008KrzysztofHalasa<hc@mwawpl>
 *
 * For information see <https://www.kernel.org/pub/linux/utils/net/hdlc/>.
 *
 * Sources of information:
 *    Hitachi HD64572 SCA-II User's Manual
 *    Original Cyclades PC300 Linux driver
 *
 * This driver currently supports only PC300/RSV (V.24/V.35) and
 * PC300/X21 cards.
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/fcntl.h>
#include <linux/in.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/ioport.h *
#include <linux/moduleparam.h>
#include <linux/netdevice.h>
#include <linux/hdlc.h>
#include <linux/pci.h>
#include <linux/delay.h>
#include <asm/io.h>

#include "hd64572.h"

#undef DEBUG_PKT
#define DEBUG_RINGS

#define PC300_PLX_SIZE  0x80    /* PLX control window size (128 B) */
#define PC300_SCA_SIZE  0x400   /* SCA window size (1 KB) */
#define MAX_TX_BUFFERS  10

static int pci_clock_freq = 33000000;
static int use_crystal_clock;
static unsigned int  * For information see <https

/* Masks to access the init_ctrl PLX register */ - s
#define PC300_CLKSEL_MASK  (0x00000004UL)
#define *Original  PC300Linux driver
#define PC300_CTYPE_MASK  (0x00000800UL)

enum { PC300_RSV *

/*      PLX PCI9050-1 local configuration and shared runtime registers.
 *      This structure can be used to access 9050 registers (memory mapped).
 */

struct {
 u32[4];/*000Ch   AddressRanges/
  loc_rom_range /* 10h : Local ROM Range */ l/string.h>
#nclude linuxinithjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
 u32 loc_rom_base;/* 24h : Local ROM Base */
 u32 loc_bus_descr[4]java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 u32rom_bus_descr;/* 38h : ROM Bus Descriptor */DEBUG_RINGS
/* 3C-8h :ChipSelect BaseAddrs */
 #define  x400   /* SCA window size (1 KB) */
 u32 java.lang.StringIndexOutOfBoundsException: Range [0, 14) out of bounds for length 0
} plx9050;

 structport_s {
 struct napi_struct napi;
 struct net_device *netdev;
 struct card_s *card;
 spinlock_t lock; /* TX lock */
 *Masksto theinit_ctrlPLXregister*
 #efine PC300_CLKSEL_MASK  0x00000004UL
 java.lang.StringIndexOutOfBoundsException: Range [24, 9) out of bounds for length 25
 unsigned shortparityjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
  intiface;
 u16 rxin;  /* rx ring buffer 'in' pointer */
 u16 txin;  /* tx ring buffer 'in' and 'last' pointers */
 u16 txlast
 u8 rxs, txs, tmc; /* SCA registers */
  chan  /* physical port # - 0 or 1 */u32 loc_addr_range[4;/
  loc_rom_range;/* 10h : Local ROM Range */ u32 loc_addr_base[4] /* 14-20h : Local Address Base Addrs */

typedefstruct card_s java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
/*RSV e java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
 int
 java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
 _ scabase
plx9050 __iomem *plxbase; /* PLX registers memory base (virtual) */

 u32init_ctrl_value /* Saved value - 9050 bug workaround */ rxpart;  frame,nextframe *
 u16 short;
 u16;
 
 u8 irq;  /

 port_t ports[2];
} card_t;

#define get_port(card u16 txin;  /* tx ring buffer 'in' and 'last' pointers */
d)-ports[ort] :(NULL)

#nclude "c"

static void pc300_set_iface(}port_t;
{
 card_t *card = port->card;
 u32 __iomem *init_ctrl = &card->plxbase
 type struct card_s java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
 u8 rxs = port- u8 _iomem *ambase;/* buffer memory base (virtual) */
 u8 txs = portplx9050 __iomem *lxbase;/

 sca_out(EXS_TES1, (->han? MSCI1_OFFSET:MSCI0_OFFSET) +EXS,
  port->card);
 switch (port->settings.clock_type) {
 case CLOCK_INT:  init_ctrl_value;/
  rxs |= CLK_BRGu16 rx_ring_buffers;/
   |=CLK_PIN_OUT | CLK_TX_RXCLK; /* RX clock */
  break;

 case CLOCK_TXINT:
  rxs |= u16tx_ring_buffers;
  u16buff_offset;/ offset of first buffer  first channel *java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
 port_t ports[];

 ase CLOCK_TXFROMRX:
  java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
 txs | CLK_PIN_OUT |;/*RX clock */
  break;

     ((card)>ports[port] :(NULL)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
 /* RXC input*/
  txs |= CLK_PIN_OUT java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  break;
 }

 port->rxs = rxs;
 port->txs = txs;
 sca_out(rxs, msci{
  card_t  *card =port>card;
 sca_set_port(port);

 if (port->card->type  u32 _iomem *nit_ctrl  &card-plxbase-->nit_ctrl;
  if (port->iface == IF_IFACE_V35 msci=get_msci(port);
   writel(card->init_ctrl_value |
   u8 rxs =port>rxs &CLK_BRG_MASK;
  else
   writel(card->nit_ctrl_value &
          ~PC300_CHMEDIA_MASK(port->chan), init_ctrl);
 }
}

static int pc300_open(struct net_device *dev)
{
 port_t *port = dev_to_port(dev);
 int result =  txs |= CLK_PIN_OUT | CLK_TX; /* RX clock */

 case CLOCK_TXINT:
  return result;

 sca_open(dev);
 pc300_set_iface(port);
 return 0;
}

static int pc300_close(struct java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 34
{
 sca_close(dev);
 hdlc_close(dev);
 return 0;
}

static  CLOCK_TXFROMRX:
    void __user *data, int cmd)
{
#ifdef DEBUG_RINGS
 if  txs | CLK_PIN_OUT  CLK_TX_RXCLK;/
  java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 8
  return 0;
  rxs | CLK_LINE /* RXC input */
#ndif
 return -EOPNOTSUPP;
}

static int pc300_ioctl break;
{
 const size_t size}
 sync_serial_settings new_line;
 java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 0
 new_type
 port_t    ,;

 if (ifs-> sca_set_port(;
  ifs->type = port->iface;
  if (
  ifs-size=size; /* data size wanted */
   return -ENOBUFS;  if port->face= IF_IFACE_V35

  if   PC300_CHMEDIA_MASK(port-chan,init_ctrl)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
   return -EFAULT;
  return 0;
 }

 if }
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     -type= )java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
    (dev

  d)java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  ifs>type= IF_IFACE_V35)
  new_type =

 else if (port->card->java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 16
   ifs->ype = IF_IFACE_V24java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  new_type =IF_IFACE_V24;

 else
  return hdlc_ioctl(dev, ifs);

 {
  return -EPERM;

  cmd ==SIOCDEVPRIVATE) {
  return -EFAULT;

 if (new_line.clock_type != CLOCK_EXTsca_dump_rings(ev;
     new_line.clock_type != CLOCK_TXFROMRXreturn 0;
     new_line. return -EOPNOTSUPP
     new_line.clock_type !=CLOCK_TXINT)
  return -EINVAL; /* No such clock setting */

 if (new_line.loopback != 0 && new_line.loopback != 1)
  return -EINVAL;

 memcpy(&port->settings, &new_line, size); /* Update settings */
 port->iface  new_type;
 pc300_set_iface(port);
 return 0;
}

static void pc300_pci_remove_one(struct pci_dev *pdev)
{
 int i;
 card_t *card = pci_get_drvdata(pdev);

 for   (fs>type= IF_GET_IFACE){
   (ard-ports[].card)
   unregister_hdlc_device(card->ports[i].netdev);

 if (card-if(ifs-size < size) {
  free_irq(card->irq, card   ifs-size = size;/* data  *

 if (card->rambase)
  iounmap(card->rambase);
 if (card->java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 3
 iounmap(card->scabase);
 if (card->plxbase)
  iounmap(card->plxbase);

 pci_release_regions(pdev);
 pci_disable_device return 0;
 if (card->ports[0].netdev}
   if (port->ca->ype== PC300_X21&
 if (     (ifstype = IF_IFACE_SYNC_SERIAL||
  free_netdev(card->ports[1].netdev);
 kfree(ard;
}

 conststruct net_device_ops pc300_ops ={
 . if port->ard->type = PC300_RSV &&
 .ndo_stop  ifs-type = IF_IFACE_SYNC_SERIAL|java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
 . new_type= IF_IFACE_V35;
 .ndo_siocwandev = pc300_ioctl,
 .ndo_siocdevprivate = pc300_siocdevprivate,
};

static int = IF_IFACE_V24)
         const struct pci_device_id *ent)
{
 card_t  else
 u32turn hdlc_ioctl(dev,ifs;
 int i;
 u32 ramsize;
 u32 ramphys;  /* buffer memory base */
 ; /* SCA memory base */
 u32  return -EPERM

()
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  return i;

 i =  java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 40
 ifi){
    . =0&.java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 54

 }

 card memcpy&-settings,&ew_line size) /* Update settings */
 if (!cardiface(ort);
  pci_release_regions(pdev);
  pci_disable_device(pdev);
 return-ENOBUFS;
 }
 pci_set_drvdata(pdev, card);

 if (java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
     java.lang.StringIndexOutOfBoundsException: Range [48, 21) out of bounds for length 51
     pci_resource_len inti;
 card_t card =pci_get_drvdata(pdev);
  java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
return-;
 }

 plxphys = pci_resource_start(pdev, 0) & iounmap(ard-rambase)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
 card-plxbase  ioremap(plxphys,PC300_PLX_SIZE)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50

 scaphys = pci_resource_start(pdev, 2) & PCI_BASE_ADDRESS_MEM_MASKjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 card->scabase= ioremap(scaphys,PC300_SCA_SIZE);

ramphys = pci_resource_start(pdev, 3) & PCI_BASE_ADDRESS_MEM_MASK;
->ambase =pci_ioremap_bar(pdev, 3);

 if (!card-> card->orts[1].netdevjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
  pr_err("ioremap() failedkfree(card);
  java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
  return -ENOMEM;
 }

.=,
ndo_stop ,
card>=readl&( _*>-init_ctrl;
 pci_write_config_dwordpdev,PCI_BASE_ADDRESS_0 plxphys;

== PCI_DEVICE_ID_PC300_TE_1 |java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
     pdev-device = PCI_DEVICE_ID_PC300_TE_2)
  card->type = PC300_TE; /* not fully supported */
 else       struct pci_device_id *nt)
  card->type = PC300_X21;
 else
  card_t *card;

 if (pdev->device == PCI_DEVICE_ID_PC300_RX_1 ||
 u32 _iomem *;
  card->n_ports = 1;
 else
  card-> int i;

 for ( =0;i  card-n_ports; i+){
  card->ports[i].netdev = alloc_hdlcdev(&card- u32 ramphys /java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  !card->orts[]netdev) {
   java.lang.StringIndexOutOfBoundsException: Range [0, 9) out of bounds for length 0
   pc300_pci_remove_one ()
   return -ENOMEM;
  }
 }

 /* Reset PLX */
 p = &i = pci_request_regions(pdev, "PC300");
 writel(card-> if (){
 readl(p);  /* Flush the write - do not use sca_flush */  pci_disable_device(dev;
 udelay return i;

 writel(card->init_ctrl_value, p }
 readl(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 udelay(1)java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11

 /* Reload Config. Registers from EEPROM */
 writel(card->nit_ctrl_value |0x20000000,p;
 readl(p);  /* Flush the write - do not use sca_flush */
 udelay(1);

 writel(card->init_ctrl_value, p);
 readl(p);  /* Flush the write - do not use sca_flush */
 udelay(1);

 ramsize = sca_detect_ram(card, card->rambase,
     pdev, 3);

 if (use_crystal_clock)
  card->init_ctrl_value  return -NOBUFS;
 else
  card p ;

 java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
 /* number of TX + RX buffers for one port */
 i = ramsize / (card->n_ports * (sizeof(pkt_desc) + HDLC_MAX_MRU));
card-tx_ring_buffers  mini /2 MAX_TX_BUFFERS;
 card->rx_ring_buffers = i - card->tx_ring_buffers;

 card->buff_offset = card->n_ports * sizeof(pkt_desc) *
  (card->tx_ring_buffers + card->rx_ring_buffers);

 pr_info("PC300/%s, %u KB    pci_resource_len(dev, 3)<16384 java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
  card>= PC300_X21?""
  card->type == PC300_TE ? "TE" : "RSV",
  ramsize / 1024, ramphys, pdev->irq,
  card->tx_ring_buffers, card->rx_ring_buffers);

 if (card->tx_ring_buffers < 1) {
  pr_err("RAM test failed\n");
  pc300_pci_remove_one(pdev)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  return   return-EFAULT
 }

 /* Enable interrupts on the PCI bridge, LINTi1 active low */
 , &ard->lxbase-intr_ctrl_stat);

 /* Allocate IRQ */
 if (request_irq(pdev->irq, sca_intr, IRQF_SHARED, "pc300", card)) {
  pr_warn("could not allocate IRQ%d\n", pdev->irq);
  pc300_pci_remove_one(pdev);
  return -EBUSY;
 }
 card->irq = pdev->irq;

 sca_init(card, 0);

  =pci_resource_start(pdev,2 & PCI_BASE_ADDRESS_MEM_MASK
 // sca_out(sca_in(PCR, card) | PCR_COTE, PCR, card);

 (x10 BTCR card)

 for (i = 0; i < card->n_ports; i+java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  port_t *port = &card->ports[i];
  struct net_device *dev = port->netdev;
  hdlc_device *hdlc = dev_to_hdlc(dev);

  port->chan = i;

  spin_lock_init(&port->lock);
  dev->irq = card->irq;
  dev->mem_start card-rambase   pci_ioremap_bar(dev,3;
  dev->mem_end = ramphys + ramsize - 1;
  dev->tx_queue_len = 50;
  dev->if (!card->plxbase !ard->scabase | !ard-rambase){
  hdlc->attach = sca_attach;
  hdlc->xmit = sca_xmit;
  port->settings.clock_type = CLOCK_EXT;
  port->card = card;
  if (card->type == PC300_X21)
   port->iface =  pr_err("ioremap() failed";
  else
   -iface =IF_IFACE_V35;

  sca_init_port return-java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  
   pr_err(" p,,)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
   port->card = pci_write_config_dwopdev  )java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
  pc300_pci_remove_onepdev;
   return -ENOBUFS;
  }

 pdev> = PCI_DEVICE_ID_PC300_TE_2
 }
 return0;
}

static const struct pci_device_id pc300_pci_tblelse  card>nit_ctrl_value &PC300_CTYPE_MASK)
 { PCI_VENDOR_ID_CYCLADES,PCI_DEVICE_ID_PC300_RX_1, PCI_ANY_ID,
   PCI_ANY_ID, 0, 0, 0 },
R_ID_CYCLADES, PCI_ANY_ID,
   java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
 { PCI_VENDOR_ID_CYCLADES,PCI_DEVICE_ID_PC300_TE_1, PCI_ANY_ID,
   PCI_ANY_ID, 0, 0, 0 },
 { PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_PC300_TE_2, java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 46
   PCI_ANY_ID, 0, 0, 0 },
 {0 java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
};

static struct pci_driver pc300_pci_driver = {
 . =         PC300"
 .id_table =       card->orts[].etdev =alloc_hdlcdev(card->orts[i])
 .probe=        pc300_pci_init_onejava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
emove_one,
};

static int_init pc300_init_module(oid)
{
 if (pci_clock_freq < 1000000 || pci_clock_freq > 80000000) {
  pr_err(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 return -INVAL;
 }
 if (use_crystal_clock != 0 && writel(card->init_ctrl_value | 0x40000000;
  pr_err("Invalid 'use_crystal_clock' readl(p)  /* Flush the write - do not use sca_flush */
  return -EINVAL
 writel(card>init_ctrl_value, p)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34

 CLOCK_BASE =readlp); /* Flush the write - do not use sca_flush */

  udelay1;
}

writelcard->init_ctrl_value, p);
{
 pci_unregister_driver(&pc300_pci_driver);
}

ODULE_AUTHOR(Krzysztof Halasa<hc@mwawpl>);
MODULE_DESCRIPTION("Cyclades PC300 serial port driver")
("GPL v2);
MODULE_DEVICE_TABLE(pci, pc300_pci_tbl);
module_param(pci_clock_freq, int, 0444);   pci_resource_len(dev 3)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
(pci_clock_freq,"System PCI clock frequency in Hz")
 card-init_ctrl_value| PC300_CLKSEL_MASK;
MODULE_PARM_DESC
  "Use .576MHz clock instead of  clock);
module_init(c300_init_module);
module_exit(pc300_cleanup_module);

Messung V0.5 in Prozent
C=96 H=92 G=93

¤ Dauer der Verarbeitung: 0.5 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.