Date: Fri, 31 Mar 2000 15:30:49 -0500 From: Edward Gold <edgold@mindspring.com> To: "hackers@FreeBSD.ORG" <hackers@FreeBSD.ORG> Subject: I am having serious problems with ppi0, can anybody help? Message-ID: <38E50AF8.B9B279DF@mindspring.com>
next in thread | raw e-mail | index | archive | help
--------------4C38CF90EFAA1418230E361F Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I seem to be crashing my system every time I attempt to open /dev/ppi0! I get a kernel panic, and it usually explains that nexus_setup_intr is unhappy. I traced this all down to /usr/src/sys/i386/i386/nexus.c where it claims that somebody tried to setup an irq that failed to allocate. I suspected that I might have a kernel slightly out of sync with my libraries, so I did the complete cvsup, buildworld, and installworld last night. Everything seems to be operating correctly, with the exception of the ppi driver. The piece of code I was running looks like this: #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/ioctl.h> #include <sys/fcntl.h> #define PPIGDATA _IOR('P', 10, u_int8_t) #define PPIGSTATUS _IOR('P', 11, u_int8_t) #define PPIGCTRL _IOR('P', 12, u_int8_t) #define PPIGEPPD _IOR('P', 13, u_int8_t) #define PPIGECR _IOR('P', 14, u_int8_t) #define PPIGFIFO _IOR('P', 15, u_int8_t) #define PPISDATA _IOW('P', 16, u_int8_t) #define PPISSTATUS _IOW('P', 17, u_int8_t) #define PPISCTRL _IOW('P', 18, u_int8_t) #define PPISEPPD _IOW('P', 19, u_int8_t) #define PPISECR _IOW('P', 20, u_int8_t) #define PPISFIFO _IOW('P', 21, u_int8_t) #define PPIGEPPA _IOR('P', 22, u_int8_t) #define PPISEPPA _IOR('P', 23, u_int8_t) #define n(flags) (~(flags) & (flags)) /* * Parallel Port Chipset control bits. */ #define STROBE 0x01 #define AUTOFEED 0x02 #define nINIT 0x04 #define SELECTIN 0x08 #define IRQENABLE 0x10 #define PCD 0x20 #define nSTROBE n(STROBE) #define nAUTOFEED n(AUTOFEED) #define INIT n(nINIT) #define nSELECTIN n(SELECTIN) #define nPCD n(PCD) int pport_fd; main() { unsigned char data, status, ctrl; int pattern = 'A'; pport_fd = open( "/dev/ppi0", O_RDONLY ); if( pport_fd < 0 ) { fprintf( stderr, "\nFailed to open printer port! 0x%x\n", pport_fd ); exit( 1 ); } else { printf( "\nopened port\n" ); fflush( stdout ); } while( 1 ) { ioctl( pport_fd, PPIGDATA, &data ); ioctl( pport_fd, PPIGSTATUS, &status ); ioctl( pport_fd, PPIGCTRL, &ctrl ); printf("Status: 0x%.2x, Ctrl: 0x%.2x, Data: 0x%.2x\n", status, ctrl, data); sleep( 1 ); } } It explodes when it hits the open() statement. The only other clue I have is that I always find a lpd.core lying around in /, but the date is way off. Does anyone have a clue whats going on? Also, what I am really trying to do here is read a signal pin into FreeBSD somehow. Its either 0 or +5V and it doesn't have to be real-time or fast or anything but accurate. I just basically want to sample and detect whether or not a button on a custom panel is being pressed or not. We would even be willing to get the signal in through the PE, -ACK, or whatever pins. I have tried going through the /dev/joy0 interface and it doesn't seem to sense anything ( though the hardware is PC-104 stuff, so I didn't put much faith in this ). The joy device driver does detect the port and it seems to read something, but its always the same value. I don't actually have a joystick to test this, so this could actually be working but I might not be pulling the pins to ground or +5 or whatever they are supposed to be pulled to. One thing that makes me very proud of FreeBSD is that its device drivers actually did work with the sound card DSP whereas the manufacturer's drivers did not! Also, this sysem uses the M-systems Disk On Chip2000, and FreeBSD already had the support right there in the LINT file, while Linux would have required kernel and LILO patches. --------------4C38CF90EFAA1418230E361F Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <p>I seem to be crashing my system every time I attempt to open /dev/ppi0! I get a kernel panic, and it usually explains that nexus_setup_intr is unhappy. I traced this all down to /usr/src/sys/i386/i386/nexus.c where it claims that somebody tried to setup an irq that failed to allocate. I suspected that I might have a kernel slightly out of sync with my libraries, so I did the complete cvsup, buildworld, and installworld last night. Everything seems to be operating correctly, with the exception of the ppi driver. <p>The piece of code I was running looks like this: <p><tt>#include <unistd.h></tt> <br><tt>#include <stdio.h></tt> <br><tt>#include <stdlib.h></tt> <br><tt>#include <sys/ioctl.h></tt> <br><tt>#include <sys/fcntl.h></tt><tt></tt> <p><tt>#define PPIGDATA _IOR('P', 10, u_int8_t)</tt> <br><tt>#define PPIGSTATUS _IOR('P', 11, u_int8_t)</tt> <br><tt>#define PPIGCTRL _IOR('P', 12, u_int8_t)</tt> <br><tt>#define PPIGEPPD _IOR('P', 13, u_int8_t)</tt> <br><tt>#define PPIGECR _IOR('P', 14, u_int8_t)</tt> <br><tt>#define PPIGFIFO _IOR('P', 15, u_int8_t)</tt><tt></tt> <p><tt>#define PPISDATA _IOW('P', 16, u_int8_t)</tt> <br><tt>#define PPISSTATUS _IOW('P', 17, u_int8_t)</tt> <br><tt>#define PPISCTRL _IOW('P', 18, u_int8_t)</tt> <br><tt>#define PPISEPPD _IOW('P', 19, u_int8_t)</tt> <br><tt>#define PPISECR _IOW('P', 20, u_int8_t)</tt> <br><tt>#define PPISFIFO _IOW('P', 21, u_int8_t)</tt><tt></tt> <p><tt>#define PPIGEPPA _IOR('P', 22, u_int8_t)</tt> <br><tt>#define PPISEPPA _IOR('P', 23, u_int8_t)</tt> <br><tt>#define n(flags) (~(flags) & (flags))</tt><tt></tt> <p><tt>/*</tt> <br><tt> * Parallel Port Chipset control bits.</tt> <br><tt> */</tt> <br><tt>#define STROBE 0x01</tt> <br><tt>#define AUTOFEED 0x02</tt> <br><tt>#define nINIT 0x04</tt> <br><tt>#define SELECTIN 0x08</tt> <br><tt>#define IRQENABLE 0x10</tt> <br><tt>#define PCD 0x20</tt><tt></tt> <p><tt>#define nSTROBE n(STROBE)</tt> <br><tt>#define nAUTOFEED n(AUTOFEED)</tt> <br><tt>#define INIT n(nINIT)</tt> <br><tt>#define nSELECTIN n(SELECTIN)</tt> <br><tt>#define nPCD n(PCD)</tt> <br><tt></tt> <tt></tt> <p><tt>int pport_fd;</tt><tt></tt> <p><tt>main()</tt> <br><tt>{</tt> <br><tt> unsigned char data, status, ctrl;</tt> <br><tt> int pattern = 'A';</tt><tt></tt> <p><tt> pport_fd = open( "/dev/ppi0", O_RDONLY );</tt> <br><tt> if( pport_fd < 0 )</tt> <br><tt> {</tt> <br><tt> fprintf( stderr, "\nFailed to open printer port! 0x%x\n", pport_fd );</tt> <br><tt> exit( 1 );</tt> <br><tt> }</tt> <br><tt> else</tt> <br><tt> {</tt> <br><tt> printf( "\nopened port\n" ); fflush( stdout );</tt> <br><tt> }</tt><tt></tt> <p><tt> while( 1 )</tt> <br><tt> {</tt> <br><tt> ioctl( pport_fd, PPIGDATA, &data );</tt> <br><tt> ioctl( pport_fd, PPIGSTATUS, &status );</tt> <br><tt> ioctl( pport_fd, PPIGCTRL, &ctrl );</tt><tt></tt> <p><tt> printf("Status: 0x%.2x, Ctrl: 0x%.2x, Data: 0x%.2x\n", status, ctrl, data);</tt> <br><tt> sleep( 1 );</tt> <br><tt> }</tt> <br><tt>}</tt> <br><tt></tt> <p>It explodes when it hits the open() statement. The only other clue I have is that I always find a lpd.core lying around in /, but the date is way off. Does anyone have a clue whats going on? <p>Also, what I am really trying to do here is read a signal pin into FreeBSD somehow. Its either 0 or +5V and it doesn't have to be real-time or fast or anything but accurate. I just basically want to sample and detect whether or not a button on a custom panel is being pressed or not. We would even be willing to get the signal in through the PE, -ACK, or whatever pins. <p>I have tried going through the /dev/joy0 interface and it doesn't seem to sense anything ( though the hardware is PC-104 stuff, so I didn't put much faith in this ). The joy device driver does detect the port and it seems to read something, but its always the same value. I don't actually have a joystick to test this, so this could actually be working but I might not be pulling the pins to ground or +5 or whatever they are supposed to be pulled to. <p>One thing that makes me very proud of FreeBSD is that its device drivers actually did work with the sound card DSP whereas the manufacturer's drivers did not! Also, this sysem uses the M-systems Disk On Chip2000, and FreeBSD already had the support right there in the LINT file, while Linux would have required kernel and LILO patches. <br> <br> <br> </html> --------------4C38CF90EFAA1418230E361F-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?38E50AF8.B9B279DF>