most Basic ATA/ATAPI Driver
most Basic ATA/ATAPI Driver
hello everyone, i just want to read some sectors from a cd-rom drive the easyest way, does anyone have a simple driver or a simple tutorial? i've looked at a lot of drivers and they are more than i need.
thx
thx
You can take a look at my code for CdPod, its got a basic ATAPI driver, it does not have a read function, but you just need to send the right commands etc.
http://www.dex4u.com/cdpod/cdpod.zip
Note: to fit it in 512bytes, the address were hard coded in, you may need to change theres.
http://www.dex4u.com/cdpod/cdpod.zip
Note: to fit it in 512bytes, the address were hard coded in, you may need to change theres.
Last edited by Dex on Thu Jan 04, 2007 6:10 pm, edited 2 times in total.
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
@Dex, You like assuming everyone uses pure ASM..
You might want to peek at one of the OSDev members projects..
Or just look at these sites
http://www.ata-atapi.com/
http://www.t13.org/
You might want to peek at one of the OSDev members projects..
Or just look at these sites
http://www.ata-atapi.com/
http://www.t13.org/
Last edited by Brynet-Inc on Thu Jan 04, 2007 6:21 pm, edited 1 time in total.
I dunno, if you can't figure out that out and in are the same as outp and inp in C, then I don't think you should be doing OS dev . Code supplied in asm is as good as any in my books, especially for something low level like atapi interfacing, as it's mostly in's and out's, it shouldn't be to hard to figure out what's going on. Anyways, those sites you listed are also good places to look, just wanted to point out that pure ASM isn't a bad thing, and if someone can't understand assembly, they might not want to do to much OS dev until they understand more about the hardware and low level stuff like assembly. could you imagine writing an entire OS without assembly? You couldn't install a timer interrupt, or any other interrupt for that matter, nor could you setup a GDT or paging, forget virtual memory, you can't handle the page fault interrupt. Of course you could get grub to set some of this up for you, but still no multi-tasking, or any such stuff .Brynet-Inc wrote:@Dex, You like assuming everyone uses pure ASM..
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Alright, Back down sparky..Ready4Dis wrote:I dunno, if you can't figure out that out and in are the same as outp and inp in C, then I don't think you should be doing OS dev . Code supplied in asm is as good as any in my books, especially for something low level like atapi interfacing, as it's mostly in's and out's, it shouldn't be to hard to figure out what's going on. Anyways, those sites you listed are also good places to look, just wanted to point out that pure ASM isn't a bad thing, and if someone can't understand assembly, they might not want to do to much OS dev until they understand more about the hardware and low level stuff like assembly. could you imagine writing an entire OS without assembly? You couldn't install a timer interrupt, or any other interrupt for that matter, nor could you setup a GDT or paging, forget virtual memory, you can't handle the page fault interrupt. Of course you could get grub to set some of this up for you, but still no multi-tasking, or any such stuff .
I was saying in a convenience sense, Can be a bit annoying to see a large uncommented assembly-mess compared to a fairly decent implementation in C.
I'm not writing an OS... I just like bothering people like you who are
Yeah, I know, hence the smileys/winks, just like giving people a hard time that like to give others a hard time .Brynet-Inc wrote:Alright, Back down sparky..Ready4Dis wrote:I dunno, if you can't figure out that out and in are the same as outp and inp in C, then I don't think you should be doing OS dev . Code supplied in asm is as good as any in my books, especially for something low level like atapi interfacing, as it's mostly in's and out's, it shouldn't be to hard to figure out what's going on. Anyways, those sites you listed are also good places to look, just wanted to point out that pure ASM isn't a bad thing, and if someone can't understand assembly, they might not want to do to much OS dev until they understand more about the hardware and low level stuff like assembly. could you imagine writing an entire OS without assembly? You couldn't install a timer interrupt, or any other interrupt for that matter, nor could you setup a GDT or paging, forget virtual memory, you can't handle the page fault interrupt. Of course you could get grub to set some of this up for you, but still no multi-tasking, or any such stuff .
I was saying in a convenience sense, Can be a bit annoying to see a large uncommented assembly-mess compared to a fairly decent implementation in C.
I'm not writing an OS... I just like bothering people like you who are
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
He probably isn't, and even if he is it shouldn't be a problem. IMO Assembly can be easier to read than C, if its documented properly. If one can understand what the code does then it doesnt matter in which language it is written. A good documenter may even be able to make brainfuck understandable for me. Putting up links to poorly commented sources is a Don't unless there isn't anything else to be found. (try reading the video card drivers in the X.org sources)Brynet-Inc wrote:@Dex, You like assuming everyone uses pure ASM..
Now, lets stop this off-topic discussion before we end up with antother locked topic
- mathematician
- Member
- Posts: 437
- Joined: Fri Dec 15, 2006 5:26 pm
- Location: Church Stretton Uk
Here's how it works, to do anything with the CD, you need to send it a command, These command's are in the form of 12 byte packets, now what packet you send does differant things.
Now one of the first and most important parts of any ATAPI driver is
"Send_Atapi_Packet", as with out it you can do nothing.
That what in the code, but in that example it sends command play cd or stop playing cd.
You need to look up ATAPI commands for things like "Read_disk"
Heres what you will find:
Now one of the first and most important parts of any ATAPI driver is
"Send_Atapi_Packet", as with out it you can do nothing.
That what in the code, but in that example it sends command play cd or stop playing cd.
You need to look up ATAPI commands for things like "Read_disk"
Heres what you will find:
Code: Select all
PacketBuffer:
db 28h ; Operation Code
db 0 ; Byte 1- Reserved
dd 10000000h ; Logical Block Address (16= ISO9660 Primary Volume Descriptor)
db 0 ; Byte 6 - Reserved
dw 0100h ; Transfer Lengt (1 sector)
db 3 dup(0) ; Byte 9 to 11 are Reserved