> int memFile;
thinking it's java or some other devilry.
--
M?ns Rullg?rd
--
M?ns Rullg?rd
> > int memFile;
> Don't use mixed case variable names. The compiler might be confused
> thinking it's java or some other devilry.
> --
> M?ns Rullg?rd
>> int memFile;
> Don't use mixed case variable names. The compiler might be confused
> thinking it's java or some other devilry.
I've been using mixed case for 15 years and no C compiler has
ever had any problems with it.
--
Grant Edwards grante Yow! I wish I was a
at sex-starved manicurist
visi.com found dead in the Bronx!!
> First for DOS:
> void main(void)
> {
> unsigned char far* mem = (unsigned char far*)0xd8000000UL;
> int i;
> outp(0x300, 0xc1); // reset board
> outp(0x300, 0xc2); // stop reset, visible in memory
> mem[0] = 1;
> for(i = 0; i < 512; i++)
> printf("%02x ", mem[i]);
> }
> which works quite well (also the complete driver works).
> Then for Linux:
> int main(void)
> {
> int memFile;
> volatile unsigned char* mem;
> ioperm(0x300,1,1);
> ioperm(0x80,1,1); // For the outb_p() command
> outb_p(0xc1, 0x300);
> outb_p(0xc2, 0x300);
> memFile = open("/dev/mem", O_RDWR);
> mem = (unsigned char*)mmap(NULL, 1024, PROT_READ|PROT_WRITE,
> MAP_SHARED, memFile, 0xd8000000);
> // some error checking is here
> mem[0] = 1;
> for(i = 0; i < 512; i++)
> printf("%02x ", mem[i]);
> close(memFile);
> }
> This one only returns lots of FFs, meaning there is nothing. I'm pretty
> sure that the I/O-port operations succeed, since LEDs on the device
> display that it should be visible in memory. I think he mmapping also
> works, I successfully mmapped parts of the BIOS, or the memory of a
> PCI-SCSI-controller, and something from 0 to 3MB (the kernel?). This was
> with kernel 2.2.20 on a Pentium 90. There I also tried kernel 2.0.35 or
> something.
> More things that I tried:
> the mmap()-sequence from vga.c in the svgalib source. It consists of
> mmapping /proc/self/mem and two other mmaps. The only difference was:
> instead of getting all zeros when reading from existent memory, I
> received an error when trying to mmap() /proc/self/mem.
> opening /dev/mem and lseek to the right address to write() the one. But
> nothing changed in memory.
> One thing finally worked: I ran the DOS program, rebooted the system
> with Linux, and ran the Linux program without the reset sequnce. Then I
> could see some patterns. So reading seems to work.
> If nobody can help me, I will have to try to write a kernel module, that
> doesn't need interrupts and serves only one application. I've never
> written a driver module before, so this is going to make even more
> trouble (I guess).
> Thanks in advance
> Fabian Herb
> > int main(void)
> > {
> > int memFile;
> > volatile unsigned char* mem;
> > ioperm(0x300,1,1);
> > ioperm(0x80,1,1); // For the outb_p() command
> > outb_p(0xc1, 0x300);
> > outb_p(0xc2, 0x300);
> > memFile = open("/dev/mem", O_RDWR);
> > mem = (unsigned char*)mmap(NULL, 1024, PROT_READ|PROT_WRITE,
> > MAP_SHARED, memFile, 0xd8000000);
> > // some error checking is here
> > mem[0] = 1;
> > for(i = 0; i < 512; i++)
> > printf("%02x ", mem[i]);
> > close(memFile);
> > }
> > Don't use mixed case variable names. The compiler might be confused
> > thinking it's java or some other devilry.
> I've been using mixed case variable names, function names and whatever for
> years, and I never ever heard of a compiler that would wrongly assume code
> to be java or something just because of mixed case variable names, even
> under really weird circumstances (whatever that may be :-).
--
M?ns Rullg?rd
Hmmm... Interesting... ... ...
Back in your original posting you said,
> One thing finally worked: I ran the DOS program, rebooted the system
> with Linux, and ran the Linux program without the reset sequnce. Then
> I could see some patterns. So reading seems to work.
What is the "reset sequence" you refer to above? Apparently that
made things fail/work. I'm assuming you mean some sort of hardware
reset, like a reset button. If that's the case, it sounds like Windows
has initialized some chip (to make this work) whereas Linux is leaving
that aspect alone and trusting the "reset sequence" to leave things in
some [probably] safer but, unfortunately, inappropriate state for you.
I think your user-level device driver code is correct but it's
possible there's something else needed at its very beginning to permit
the reads from the ISA space to start working. Have you looked for any
other examples of user-space drivers for ISA devices and compared them
with yours? (I have not.)
I just noticed my Email address was incorrect in previous postings.
me directly if you wish.
1. How to write a device driver for data acquisition via ISA card
Hey everybody, I want to respond to a hardware interrupt from a data
acquisition card via ISA card. I manage to communicate with the card
throught simply I/O program. And now I would like to write a user program
with an interrupt handler.
My questions are:
1) My first step is to install the interrupt handler to the kernel. The
following is my source code. Is my structure of source code to install
interrupt handler correct? What am I missing? And what functions and header
files I need to install and service an interrupt routine?
#include <linux/sched.h>
main()
{
unsigned int CAN_irq = 9;
if (CAN_irq >= 0)
{
int result = request_irq(CAN_irq, CAN_ISR, SA_INTERRUPT, "CAN", NULL);
if (result)
{
printk(KERN_INFO "CAN card can't get assigned irq %i/n", CAN_irq);
CAN_ISR = -1;
}
return 0;
note: I also wrote CAN_ISR interrupt service routine.
2) Is there any example of device driver codes like this?
3) How to compile it? Is "gcc -O -D__KERNEL__ -o test test.c" correct?
4) Is it possible (reasonable, etc) to write a user program that uses a
hardware interrupt without writing a device driver?
For your information, I'm using RH 6.1 with gcc-2.91.66. I'm referring Linux
Device Driver by Alessandro Rubini and Linux Kernel Internal by M Beck, U
Kunitz and etc. Any other good references?
Thank you.
Regards,
Chun Seong
2. kernel 2.0.x SCSI tape problems
3. How to write a device driver for data acquisition via ISA card?
5. Unsupported ISA device doesn't appear in /devices on Solaris x86
7. Writing control codes to device through a device driver
9. How to write a 'user space' mouse driver??
10. I/O mapping from Device Driver to User space
11. Notification user-space program from driver about new device.
13. Block device driver in user space