Skip to contentSkip to conversation

Creative 4-speed CDROM driver

DISCUSSION [email protected] 4 participants 8 messages May 28, 2001 – May 30, 2001

lore
Share & tools
lore
#0 lore raw

Hello Kernel Hackers,

Bloody Minix doesn't have a CDROM driver for my CDROM, a Creative Quad speed. I'm dual booting between Linux and Minix. Linux uses my CDROM no problems. I am thinking a "generic" CDROM driver might fit the bill for this CDROM (the system is an old 486DX2/66, 20MB RAM, 500MB HDD + 300MB HDD, 1MB Diamond Stealth Pro Video card).

Either I can port the Linux CDROM driver to Minix or I have to write my own device driver. Can anyone help, point me to a place where hackers get the stuff they need to write device drivers? They obviously know all the details, like status codes, I/O regions etc. I am not sure if I would use DMA, but I suppose it doesn't matter all that much.

If anyone on the kernel list has written a driver for a CDROM please send me mail about how you went about it, did you approach the manufacturer for the documentation on the device, if I made a mistake could I ruin my hardware? and stuff like that.

Thanks heaps.
James Buchanan
[email protected]

#1 lore raw
Quoted 4 lines

If anyone on the kernel list has written a driver for a CDROM please send me mail about how you went about it, did you approach the manufacturer for the documentation on the device, if I made a mistake could I ruin my hardware? and stuff like that.

For IDE CD-ROM there is a standard. Its about 600 pages long but the best model is probably to implement scsi over atapi since Minix has some basic scsi code. Then you can drive all but very old ide cdrom devices as scsi

#2 lore raw

Can you explain what this meas? Fake an SCSI device and use the SCSI driver to drive my CDROM? But what about the I/O port regions of memory, and the IRQ? Aren't they different?

I am new to device drivers, I don't understand what I have to do. I know that I need to provide a service so I can mount my cdrom and use it, and that applications can read data from the /dev/cd0/whatever.file file on Minix.

I need to know what the I/O hex memory area is, what IRQ to use, etc. I also need to know what functions I have to provide, like:

open(filename, mode)
read(fd, buffer, buffersize, flags) -- how to specify number of byts to read??

In the device driver code, I need to know what commands are for the ATAPI CDROM, or how I can do it as an SCSI like you say, like 0x30 put in I/O address whatever might be to query to see if there is a CD in the drive etc etc.

This is very confusing. Would I benefit from reading the standards document you speak of? Where can I download a copy?

How do I handle asynchronous I/O with a driver for a CDROM? Do I identify each user by the file descriptor when they issue a open() call, like in subsequent calls to read() they will pass the file descriptor, and I would have say a list of structures holding the file descriptor, offset where the last read() was, and so on, if so, what fields do I put in my structures and so on?

As you can see, I am a newbie to device driver writing. ;) I am trying to learn by doing.

Unfortunately, I simply do not understand the code for device drivers that hackers have written. I don't know where to start and how to make sense of the code, to read it line by line and understand what it is doing.

I am going to take a look at the IDE CDROM driver code in Linux and see if I can modify the code to work as a device driver for Minix.

Hope you can help me here, I'm really stuck!

:-) Thanks Alan. I see that you are a prominent Linux developer and you know Linus. What device drivers have you written, or do you concentrate on the kernel proper?

Cheers mate!
James

----- Original Message -----
From: "Alan Cox" <[email protected]>
To: <[email protected]>
Cc: <[email protected]>
Sent: Monday, May 28, 2001 10:22 PM
Subject: Re: Creative 4-speed CDROM driver

Quoted 1 line
Quoted 1 line

If anyone on the kernel list has written a driver for a CDROM please

send me

Quoted 1 line
Quoted 1 line

mail about how you went about it, did you approach the manufacturer for

the

Quoted 1 line
Quoted 1 line

documentation on the device, if I made a mistake could I ruin my

hardware?

Quoted 4 lines
Quoted 1 line

and stuff like that.

For IDE CD-ROM there is a standard. Its about 600 pages long but the best model is probably to implement scsi over atapi since Minix has some basic

scsi

Quoted 4 lines

code. Then you can drive all but very old ide cdrom devices as scsi

#3 lore raw
Quoted 3 lines

Unfortunately, I simply do not understand the code for device drivers that hackers have written. I don't know where to start and how to make sense of the code, to read it line by line and understand what it is doing.

I think the minix book would be a good starting point. From the questions you are asking you are rather out of your depth. Also some basic info on ATAPI which is the protocol the CD-ROM devices use.

#4 lore raw

Where do I get this basic info on ATAPI? Will I benefit from the IDE standards document? Where can I get that?

Thanks for your help

----- Original Message -----
From: "Alan Cox" <[email protected]>
To: <[email protected]>
Cc: "Alan Cox" <[email protected]>; <[email protected]>
Sent: Monday, May 28, 2001 11:21 PM
Subject: Re: Creative 4-speed CDROM driver

Quoted 1 line
Quoted 1 line

Unfortunately, I simply do not understand the code for device drivers

that

Quoted 1 line
Quoted 1 line

hackers have written. I don't know where to start and how to make sense

of

Quoted 3 lines
Quoted 1 line

the code, to read it line by line and understand what it is doing.

I think the minix book would be a good starting point. From the questions

you

Quoted 10 lines

are asking you are rather out of your depth. Also some basic info on ATAPI which is the protocol the CD-ROM devices use.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#6 lore raw
In reply to Alan Cox

I think you've mistaken my tone :-)

I wasn't asking anyone to write the driver for me. But, I am at such a beginning position that I could pull my hair out for a year just trying to get an idea where to start, or I can ask someone. I am absolutely prepared to do the work, however I am not prepared to waste my time looking at irrelevant things or doing something that results in nothing.

What I am after is for someone to spell it out plain and clear: do this, then this, then this, whatever these things might be. (Get a book on IBM PC architecture, contact the manufacturer for a document which is called blah blah, or whatever these things are). I have all the standards documents now, and which parts to implement? You can see my problem. I am a beginner, and I am asking (I hope) fairly simple questions on where I should start, so I can cut some code and do some learning, get my device working and send the driver for everyone to download at comp.os.minix.

You see, I can't even begin to write one line of code, because I know nothing about what I am supposed to do. Sure, I know the basics, I have written toy device drivers for Linux, I know how to implement a driver for Minix, understand the main loop, handling messages from the Minix kernel, how to fill in a device structure correctly with pointers to functions that implement the device independant interface, etc. I know this stuff, that's not a problem. My problem is what is the I/O address range? Can I access it in C? Do I use DMA? When there are commands that can be implemented (set A, I'll call them) and another set of functions when the device uses the ATA Packet Interface (I'll call them set B) then which set? And the standard of ATAPI makes it clear that the Packet Interface is elsewhere, not defined in the ATAPI document.

I could go around and around in ever decreasing circles until I disappear up my own arse looking in all the wrong places and pulling my hair out. I am absolutely determined to write this driver. I will spend a year on it. Big deal. I have plenty of time. But I need someone who has done this or who knows how to do it to point me in the right direction so I can do it for myself. I am no dummy, just the URL to a document will do, I will do the actual reading and digesting the document.

Problem so far is that I didn't spell it out clearly enough that I am a beginner, and I had vague and incomprehensible emails from those who know what they are doing, assuming they are speaking to someone of equal knowledge. This I am not (although I plan to be, and can be when someone points me in the right direction.)

Thanks for writing to me. I appreciate your time very much.

James

----- Original Message -----
From: "Francois Romieu" <[email protected]>
To: <[email protected]>
Sent: Wednesday, May 30, 2001 8:40 AM
Subject: Re: Creative 4-speed CDROM driver

[email protected] <[email protected]> écrit :

Quoted 2 lines

How do you think I should go about writing this driver? So the standards documents are not the best way to go? What else is there for me to write

I've never said that. They are. I was simply outlining that drivers are written by people with *some* background in the specific field. If they don't have it, it takes them time to get it and have a satisfying driver.

It's not a 5 minutes/hours hack except maybe for someone that knows how Linux/Minix/Atapi/your specific cdrom work. IMHO such a person will be too busy now for others reasons. Thus, if you want it working, you have to invest your own time and walk the learning curve. It takes time however. See ?

--
Ueimor

#7 lore raw
In reply to Alan Cox
Quoted 4 lines · [email protected] wrote:

You see, I can't even begin to write one line of code, because I know nothing about what I am supposed to do. Sure, I know the basics, I have written toy device drivers for Linux, I know how to implement a driver for Minix, understand the main loop, handling messages from the Minix kernel,

Quoted 8 lines

how to fill in a device structure correctly with pointers to functions that implement the device independant interface, etc. I know this stuff, that's not a problem. My problem is what is the I/O address range? Can I access it in C? Do I use DMA? When there are commands that can be implemented (set A, I'll call them) and another set of functions when the device uses the ATA Packet Interface (I'll call them set B) then which set? And the standard of ATAPI makes it clear that the Packet Interface is elsewhere, not defined in the ATAPI document.

I've got some suggestions for you.
First: be humble (sorry, I don't want to offend you at all) read the LKML FAQ. the address is at the very end of this email. it would give you the pointers you want. (including books/web pages).

second: bear in mind that Linux driver structure is not like minix. minix is Micro kernel, Linux is not. therefore, there is no main loop here. you just register the required device specific operations and you will receive all open/read/write/ioctl/close requests. (pls. See the design of Unix operating system for more information).

third: look for a similar device driver implementation in kernel (well, it is learning in the hard way :-) ) .

Good luck,

Masoud