[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Unidentified subject!



> Can you explain me what is the meaning of the number
> 1076 involved in the sentence.
> 
> if ($dev == '1076')

Look in the "**" line below:

  # cat ~/bin/vscom 
  #!/usr/bin/perl -w

  $state = 0;
  open( PCI, "/proc/pci") || die("cannot open /proc/pci");
  while (<PCI>) {
      if (m/Bus.*, device.*, function/) { $state = 0; next; }
**    if (m/Vendor id=10b5\. Device id=([0-9a-f]+)/) { $state = 1; $dev = $1; next; }
      if ($state == 1 && m/IRQ (\d+)/) { $irq = $1; next; }
      if ($state == 1 && m,I/O at (0x[0-9a-f]+),) { $state = 2; $io1 = $1; next; }
      if ($state == 2 && m,I/O at (0x[0-9a-f]+),) { $state = 3; $io2 = $1; next; }
      if ($state == 3 && m,I/O at (0x[0-9a-f]+),) { $state = 4; $io3 = $1; last; }
  }
  close(PCI);

  print( "dev $dev, irq $irq, io $io1, $io2, $io3\n" );
  $io = hex($io2);
  if ($dev == '1076') {
      for ($ix = 0; $ix < 8; $ix++ ) {
	  $num = 4 + $ix;
	  $str = sprintf("%#04x", $io);

	  $cmd = "setserial /dev/ttyS$num port $str irq $irq uart 16550A baud_base 921600 ^fourport spd_normal";
	  print "$cmd\n"; system $cmd;

	  $cmd = "stty -F /dev/ttyS$num crtscts -ixon";
	  print "$cmd\n"; system $cmd;

	  #$a = 64 + $num;
	  #$cmd = "mknod /dev/ttyS$num c 4 $a";
	  #system "chown root:dialout /dev/ttyS$num";
	  #system "chmod 666 /dev/ttyS$num";

	  $io += 8;
      }
      $cmd = "setserial /dev/ttyS4 set_multiport port1 $io3 mask1 0xff match1 0xff";
      print "$cmd\n"; system $cmd;
  }
  system "setserial -gb /dev/ttyS? /dev/ttyS[1-9]?"

It is the pci device number:

 $ lspci 
 ...
 00:14.0 Serial controller: PLX Technology, Inc. VScom 800 8 port serial adaptor (rev 02)
 ...
 $ lspci -s 00:14.0 -n
 00:14.0 Class 0700: 10b5:1076 (rev 02)

It also shows up in:

 $ find . -type f -name \*.h | xargs grep 1076
 ./include/linux/pci_ids.h:#define PCI_DEVICE_ID_PLX_SPCOM800    0x1076
 ...

and:

 $ egrep -B2  '[[:space:]]1076' /usr/share/misc/pci.ids 
 10b5  PLX Technology, Inc.
        0001  i960 PCI bus interface
        1076  VScom 800 8 port serial adaptor

The script don't work with e.g. 2.4.22, since todays kernels apparently
gives you text, not numbers:

  $ cat /proc/pci 
  ...
    Bus  0, device  20, function  0:
      Serial controller: PLX Technology, Inc. VScom 800 8 port serial adaptor (rev 2).
	IRQ 12.
	Non-prefetchable 32 bit memory at 0xe4000000 [0xe400007f].
	I/O at 0xdc00 [0xdc7f].
	I/O at 0xe000 [0xe03f].
	I/O at 0xe400 [0xe407].
  ...

and it could be rewritten using lspci instead:

 $ lspci -d 10b5:1076 -vn
 00:14.0 Class 0700: 10b5:1076 (rev 02)
	 Subsystem: 10b5:1076
	 Flags: medium devsel, IRQ 12
	 Memory at e4000000 (32-bit, non-prefetchable) [size=128]
	 I/O ports at dc00 [size=128]
	 I/O ports at e000 [size=64]
	 I/O ports at e400 [size=8]
	 Expansion ROM at <unassigned> [disabled] [size=2K]

Regards,
/Karl

-----------------------------------------------------------------------
Karl Hammar                    Aspö Data               karl@aspodata.se
Lilla Aspö 2340                                                Networks
S-742 94 Östhammar          +46  173 140 57                   Computers
Sweden                     +46  70 511 97 84                 Consulting
-----------------------------------------------------------------------




Reply to: