无法使用 ATAPI 读取 CD

Can not read CD using ATAPI

这是我的代码。它用十进制的 65535 填充 ATAPI_RAWDATA 数组。没有错误代码。 Secondary Error Register Port 填0。不停机,没有cpu_triple_fault。当我删除 Secondary Master CD 设备时,程序会正常停止。这些代码循环用于检测 BSY 位或其他内容。我在真实硬件中尝试了 EJECT 程序,因此该代码没有任何问题,但 ATAPIREADSECTOR 程序运行不正常。 READCD 命令或其他命令有问题吗?

var
READCD:array[0..5] of word([=10=]BE,[=10=]00,[=10=]00,[=10=]00,[=10=]01,[=10=]00);
ATAPI_RAWdata:array[0..1023] of word;
procedure ATAPI_READSECTOR(LBA:Integer;Dev:Byte);
var
i:integer;
x:word;
begin
asm
mov dx,177h
@loop1:
in al,dx
and al,10000000b
jne @loop1
mov dx,177h
@loop2:
in al,dx
and al,01000000b
je @loop2
mov dx,176h
mov al,0A0h
out dx,al
mov dx,3F6h
mov al,00001010b
out dx,al
mov dx,177h
mov al,0a0h
out dx,al
mov cx,0FFFFh
@waitloop:
loopnz @waitloop
mov dx,177h
@loop3:
in al,dx
and al,10000000b
jne @loop3
mov dx,177h
@loop4:
in al,dx
and al,00001000b
je @loop4
end;
for i:=0 to 5 do begin //SEND COMMAND
x:=READCD[i];
outw(0,x);
inb(6);
end;
inb(6);
asm
mov dx,177h
@loop5:
in al,dx
and al,10000000b
jne @loop5
end;
for i:=0 to 1023 do begin //INPUT DATA from DATA REGISTER
atapi_rawdata[i]:=inw(0);
end;
end;

我的 EJECT 程序工作正常:

var
EJECT_COM:array [0..5] of Word=([=11=]1B,[=11=]00,[=11=]02,[=11=]00,[=11=]00,[=11=]00);
procedure EJECT_CD;
var
i:integer;
x:word;
begin
asm
mov dx,177h
@loop1:
in al,dx
and al,10000000b
jne @loop1
mov dx,177h
@loop2:
in al,dx
and al,01000000b
je @loop2
mov dx,176h
mov al,0A0h
out dx,al
mov dx,3F6h
mov al,00001010b
out dx,al
mov dx,177h
mov al,0a0h
out dx,al
mov cx,0FFFFh
@waitloop:
loopnz @waitloop
mov dx,177h
@loop3:
in al,dx
and al,10000000b
jne @loop3
mov dx,177h
@loop4:
in al,dx
and al,00001000b
je @loop4
end;
for i:=0 to 5 do begin
x:=EJECT_COM[i];
outw(0,x);
inb(6);
end;
inb(6);
asm
mov dx,177h
@loop5:
in al,dx
and al,10000000b
jne @loop5
end;
end;

SCSI 命令 READ CD $BE 未使用该结构,因此使用 READ 12 $A8 SCSI COMMAND 而不是 READ CD $BE:

READCD:array[0..5] of word([=10=]A8,[=10=]00,[=10=]00,[=10=]00,[=10=]01,[=10=]00);