CD-ROM driver

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
djsilence
Member
Member
Posts: 70
Joined: Wed Oct 01, 2008 11:18 am
Location: Ukraine, Kiev
Contact:

CD-ROM driver

Post by djsilence »

Hi. I have this code given to me by Dex. (so, this post is most of all for Dex)

Code: Select all

hdbase    equ  0x1f0               	; 0x1f0 for primary device
                    			; 0x170 for secondary device
hdid    equ  0x00               	; 0x00 for master hd
                     			; 0x10 for slave hd

;---------------------------------------------------------;
; hd_read.                    ; eax = sector to read  ;
;---------------------------------------------------------;
_HddRead:
	mov	eax, [_Sector]
                   
	pushad
	push  	eax
 newhdread:
   	mov   	edx,hdbase
   	inc   	edx
   	mov   	al,0
   	out   	dx,al

   	inc   	edx
   	mov   	al, 1
   	out   	dx,al

   	inc   	edx
   	pop   	ax
   	out   	dx,al

	inc   	edx
   	shr   	ax,8
   	out   	dx,al

	inc   	edx
   	pop   	ax
   	out   	dx,al

	inc  	edx
	shr   	ax,8
	and   	al,1+2+4+8
	add   	al,hdid   
	add   	al,128+64+32
	out   	dx,al
	
	inc   	edx
	mov   	al,20h
	out   	dx,al
  hddwait:
   	in    	al,dx
   	test  	al,128
   	jnz   	hddwait

   	mov   	edi,[_HddBuffer]
   	mov   	ecx,256
   	mov   	edx,hdbase
   	cld
   	rep   	insw

   	popad
  	ret
It works great with primary device (port 0x1F0).

In my VM I have two HDD's at IDE(0:0) and IDE(0:1) and one CD-ROM device at IDE(1:0). Reading HDD's gives no problems, but reading CD-ROM(port 0x170) gives it: I do not get any halt or exceptions by I get just 0xFF values at address sector should be loaded to.

Thanks for any help.
Daniel.
Don't think a ****, but in ukrainian schools English is TOO BAD!
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: CD-ROM driver

Post by Dex »

You can not use this code to read from cd, take alook at CdPod for a simple example
http://www.dex4u.com/ASMcompo512b/CdPod.zip
User avatar
djsilence
Member
Member
Posts: 70
Joined: Wed Oct 01, 2008 11:18 am
Location: Ukraine, Kiev
Contact:

Re: CD-ROM driver

Post by djsilence »

OK, thanks!
Don't think a ****, but in ukrainian schools English is TOO BAD!
Post Reply