Kontroler LPT na PCI

Wszystko związane z jądrem systemowym, sterownikami, sprzętem itp.
R_Przemek
Posty: 54
Rejestracja: 12 lipca 2008, 16:02

Kontroler LPT na PCI

Post autor: R_Przemek »

Witam.

Chciałem mieć trzy niezależne porty LPT w komputerze i zamontowałem dwa dodatkowe kontrolery na PCI.
Teraz łącznie z tym na płycie głównej są ich trzy. Lecz chcąc się posłużyć, myślę, że dość znanym kodem (zamieszczam poniżej) należy odwołać się do konkretnego LPT. 1, 2 bądź 3.

I tutaj pojawiają się schody, bo gdy adresuję porty według drugiego załącznika, mogę sterować jedynie LPT1 na płycie. Pozostałe kontrolery PCI pozostają martwe.

Załącznik1:

Kod: Zaznacz cały

 //lptset.c 
#include <stdio.h> 
#include <string.h> 
#include <sys/io.h> 
#include <sys/perm.h> 

#define BASEPORT 0x378 
void help(void); 

int main(int liczba, char *parametr[]) 
{ 
if (liczba > 1) 
  { 
  //ioperm otwiera port 
  ioperm(BASEPORT,1,1); //rejestr danych 
  ioperm(BASEPORT+1,1,1); //rejestr wejscia 
  ioperm(BASEPORT+2,1,1); //rejestr statusu 
  int wynik = 2; 

  // PISZ 
  wynik = strcmp(parametr[1],"-pisz"); 
  if (wynik == 0) 
    { 
    if (liczba > 2) 
      { 
      wynik = atoi(parametr[2]); //atoi() -stringa na intrger 
      printf("Port danych ustawiono na : %Xh \n",wynik); 
      outb(wynik,BASEPORT); 
      printf("gotowe \n"); 
      return 0; 
      } 
    else 
      { 
      printf("BLAD!!\n"); 
      return 0; 
      } 
    } 
    // PISZ starus 
    wynik = strcmp(parametr[1],"-piszs"); 
    if (wynik == 0) 
    { 
    if (liczba > 2) 
      { 
      wynik = atoi(parametr[2]); //atoi() -stringa na intrger 
      printf("Port statusu ustawiono na : %Xh\n",wynik); 
      outb(wynik,BASEPORT+2); 
      printf("gotowe \n"); 
      return 0; 
      } 
    else 
      { 
      printf("BLAD!!\n"); 
      return 0; 
      } 
    } 
    //CZYTAJ 
    wynik = strcmp(parametr[1],"-czytaj"); 
    if (wynik == 0) 
      { 
      wynik = inb(BASEPORT); 
      printf("stan portu danych: %Xh\n",wynik); 
      return 0; 
      } 
    //PIN 
    wynik = strcmp(parametr[1],"-pin"); 
    if (wynik ==0) 
      { 
      wynik = inb(BASEPORT+1); 
      printf("Stan portu do odczytu : %Xh\n",wynik); 
      wynik = inb(BASEPORT+2); 
      printf("Stan portu sterujacego : %Xh\n",wynik); 
      return 0; 
      } 
    //help 
    wynik = strcmp(parametr[1],"-h"); 
    if (wynik == 0 | wynik != 0 ) 
      { 
      help(); 
      return 0; 
      } 
  } 
else help(); 
return 0; 
} 

void help(void) 
{ 
printf("\n lptset - ustawia i odczytuje wartości na porcie LPT \n\n"); 
printf("-pisz xxx pozwala włączyć poszczegóe piny w porcie LPT\n"); 
printf("-piszs xxx pozwala włączyć poszczegóe piny w porcie statusu LPT\n"); 
printf("paramet powinien być podany w formie dziesiętnej.\n"); 
printf("-czytaj   pozwala odczytać stany pinów\n"); 
printf("-pin      podaje stan portów tylko do odczytu\n"); 
printf("PROGRAM DZIALA TYLKO Z ROOT-a\n"); 
}
Załącznik 2

Kod: Zaznacz cały

[TABLE="width: 90%"]
[TR]
[/TR]
[TR]
[TD]0040:0008[/TD]
[TD]słowo[/TD]
[TD]adres bazowy LPT1[/TD]
[TD][B]378[/B][/TD]
[TD]3BC[/TD]
[/TR]
[TR]
[TD]0040:000A[/TD]
[TD]słowo[/TD]
[TD]adres bazowy LPT2[/TD]
[TD][B]278[/B][/TD]
[TD]378[/TD]
[/TR]
[TR]
[TD]0040:000C[/TD]
[TD]słowo[/TD]
[TD]adres bazowy LPT3[/TD]
[TD][B]3BC[/B][/TD]
[TD]278[/TD]
[/TR]
[TR]
[TD]0040:000E[/TD]
[TD]słowo[/TD]
[TD]adres bazowy LPT4[/TD]
[TD][B]2BC[/B][/TD]
[TD]2BC[/TD]
[/TR]
[/TABLE]
Zamieszczam linki, którymi posługiwałem się pisząc temat:
http://vlab.pjwstk.edu.pl/~vlabdemo/io/lpt/lpt.htmlhttp://www.elektroda.pl/rtvforum/topic851694.htmlPlus:
http://dhost.info/ky3orr/index.php?dzia ... _portu_lpt
fnmirk
Senior Member
Posty: 8324
Rejestracja: 03 grudnia 2007, 06:37

Post autor: fnmirk »

I co w związku z tym chcesz zrobić?

Przeczytaj i uzupełnij informacje:
http://debian.linux.pl/threads/12771-Za ... #post81406
I nie udziwniaj ich.
R_Przemek
Posty: 54
Rejestracja: 12 lipca 2008, 16:02

Post autor: R_Przemek »

Kod: Zaznacz cały

Linux ster 2.6.32-5-686 #1 SMP Mon Jun 13 04:13:06 UTC 2011 i686 GNU/Linux

Kod: Zaznacz cały

i386

Kod: Zaznacz cały

00:00.0 Host bridge: VIA Technologies, Inc. P4M266 Host Bridge
	Subsystem: VIA Technologies, Inc. P4M266 Host Bridge
	Kernel driver in use: agpgart-via
00:01.0 PCI bridge: VIA Technologies, Inc. VT8633 [Apollo Pro266 AGP]
00:08.0 Communication controller: NetMos Technology PCI 1 port parallel adapter (rev 01)
	Subsystem: LSI Logic / Symbios Logic Device 0010
	Kernel driver in use: parport_pc
00:0a.0 Communication controller: NetMos Technology PCI 1 port parallel adapter (rev 01)
	Subsystem: LSI Logic / Symbios Logic Device 0010
	Kernel driver in use: parport_pc
00:10.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
	Subsystem: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller
	Kernel driver in use: uhci_hcd
00:10.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
	Subsystem: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller
	Kernel driver in use: uhci_hcd
00:10.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
	Subsystem: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller
	Kernel driver in use: uhci_hcd
00:10.3 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 82)
	Subsystem: VIA Technologies, Inc. USB 2.0
	Kernel driver in use: ehci_hcd
00:11.0 ISA bridge: VIA Technologies, Inc. VT8235 ISA Bridge
	Subsystem: VIA Technologies, Inc. VT8235 ISA Bridge
00:11.1 IDE interface: VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT823x/A/C PIPC Bus Master IDE (rev 06)
	Subsystem: VIA Technologies, Inc. VT82C586/B/VT82C686/A/B/VT8233/A/C/VT8235 PIPC Bus Master IDE
	Kernel driver in use: pata_via
00:12.0 Ethernet controller: VIA Technologies, Inc. VT6102 [Rhine-II] (rev 74)
	Kernel driver in use: via-rhine
01:00.0 VGA compatible controller: S3 Inc. VT8375 [ProSavage8 KM266/KL266]
	Subsystem: S3 Inc. VT8375 [ProSavage8 KM266/KL266]

Kod: Zaznacz cały

00:00.0 Host bridge: VIA Technologies, Inc. P4M266 Host Bridge
00:01.0 PCI bridge: VIA Technologies, Inc. VT8633 [Apollo Pro266 AGP]
00:08.0 Communication controller: NetMos Technology PCI 1 port parallel adapter (rev 01)
00:0a.0 Communication controller: NetMos Technology PCI 1 port parallel adapter (rev 01)
00:10.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.3 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 82)
00:11.0 ISA bridge: VIA Technologies, Inc. VT8235 ISA Bridge
00:11.1 IDE interface: VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT823x/A/C PIPC Bus Master IDE (rev 06)
00:12.0 Ethernet controller: VIA Technologies, Inc. VT6102 [Rhine-II] (rev 74)
01:00.0 VGA compatible controller: S3 Inc. VT8375 [ProSavage8 KM266/KL266]
ODPOWIEDZ