Page 1 of 1

CD-ROM driver

Posted: Sat Dec 05, 2009 6:32 pm
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.

Re: CD-ROM driver

Posted: Sun Dec 06, 2009 1:39 am
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

Re: CD-ROM driver

Posted: Sun Dec 06, 2009 4:41 am
by djsilence
OK, thanks!