zapis na HDD
hdc@atlas
hdc
Středa Březen 17 11:53:36 CET 2004
Tohle je zapis na disk v PC.
Nedavno tu probehly odkazy na popis ATAPI
rozhrani, tak si to k tomu prectete. Pomuze i
THELP. Pochopite vse.
Jinak radim odkrokovat i IT rutinu disku
v pececku.
S pozdravem Hugo KOTTAS
procedure write_disk_test (test_mode:boolean);
const
data_reg =0;
erro_reg =1;
count_reg =2;
sect_numb =3;
cyl_low =4;
cyl_high =5;
shd_reg =6;
status_reg=7;
master = 0;
slave =$10;
primary =$1f0;
secondary =$170;
size_512 =$a0;
var
h, m, s, hund : Word;
h1, m1, s1, hund1 : Word;
port_adr : word;
disk_adr : byte;
int_1 : byte;
int_2 : byte;
merev_adr : word;
begin;
if not bios then
begin
set_it_vect; /* IT rutina precte status reg a
nastavi irq_14, resp.
irq_15 na true */
irq_14 := false;
irq_15 := false;
if drive_char = 'c'
then begin /*
nastaveni IO adres */
if c_port[1] then port_adr:=$1f0
else port_adr:=$170;
if c_port[2] then disk_adr:=master
else disk_adr:=slave;
end;
if drive_char = 'd'
then begin
if d_port[1] then port_adr:=$1f0
else port_adr:=$170;
if d_port[2] then disk_adr:=master
else disk_adr:=slave;
end;
if drive_char = 'e'
then begin
if e_port[1] then port_adr:=$1f0
else port_adr:=$170;
if e_port[2] then disk_adr:=master
else disk_adr:=slave;
end;
if drive_char = 'f'
then begin
if f_port[1] then port_adr:=$1f0
else port_adr:=$170;
if f_port[2] then disk_adr:=master
else disk_adr:=slave;
end;
if port_adr=$1f0 then merev_adr:=$3f6 else merev_adr:=$376;
asm
push ax
push cx
push dx
push es
mov dx,[port_adr]
add dx,shd_reg
mov al,size_512
or al,disk_adr
out dx,al
cli
in al,0a0h
mov [int_2],al
or al,0c0h
out 0a0h,al
in al,020h
mov [int_1],al
or al,02h
out 020h,al
sti
mov dx,[port_adr]
add dx,shd_reg
mov al,size_512
or al,disk_adr
out dx,al
mov dx,[merev_adr]
mov al,8
out dx,al
mov dx,[port_adr]
add dx,shd_reg
mov al,size_512
or al,disk_adr
out dx,al
mov dx,[port_adr]
add dx,erro_reg
mov al,0
out dx,al
mov dx,[port_adr]
add dx,count_reg
mov al,1
out dx,al
mov dx,[port_adr]
add dx,sect_numb
mov al,[sector]
out dx,al
mov dx,[port_adr]
add dx,cyl_low
mov ax,[track]
out dx,al
mov dx,[port_adr]
add dx,cyl_high
mov al,ah
out dx,al
mov dx,[port_adr]
add dx,shd_reg
mov al,size_512
or al,disk_adr
or al,[head]
out dx,al
mov dx,[port_adr]
add dx,status_reg
in al,dx
mov dx,[port_adr]
add dx,status_reg
mov al,031h
out dx,al
mov cx,0ffffh
mov bx,100h
@wait_w_b:
mov dx,[port_adr]
add dx,status_reg
in al,dx
test al,8
jnz @w_b
loop @wait_w_b
dec bx
jnz @wait_w_b
@w_b:
push ds
mov si,offset buffer1
mov ax,seg buffer1
mov es,ax
mov dx,[port_adr]
mov si,offset buffer1
mov cx,100h
rep outsw
pop ds
mov dx,[port_adr]
add dx,status_reg
in al,dx
mov [error],al
mov cx,0ffffh
mov bx,100h
@wait2:
in al,dx
test al,80h
jz @ven2
loop @wait2
dec bx
jnz @wait2
@ven2:
mov dx,[port_adr]
add dx,status_reg
in al,dx
mov [status],al
mov dx,[port_adr]
add dx,erro_reg
in al,dx
mov [error],al
@konec:
cli
mov al,[int_2]
out 0a0h,al
mov al,[int_1]
out 020h,al
sti
pop es
pop dx
pop cx
pop ax
end;
-----Původní zpráva-----
Od: cechy@volny.cz <cechy@volny.cz>
Komu: Multiple recipients of list <hw-news@list.gin.cz>
Datum: 25. března 2000 20:31
Předmět: zapis na HDD
>Zdravim,
>potreboval bych primy zapis na nesystemovy HDD (muj vlastni
>filesystem) a to do jakehokoli sektoru (nejlepe LBA adresace)
>pod Win95/98. Zkousel jsem to pres ruzna INT ale slo to jen cist,
>zapisovat to nechtelo. Nejlepsi by byla komponenta do Delphi,
>nebo zdrojak v jakemkoli jazyce . To co je na netu nefunguje (vcetne
>komercne prodavane komponenty). Podotykam, ze disk nema ani partition
>tabulku. Zapisovat a cist z nej s 89C51 bylo nesrovnatelne jednodussi.
>Diky za kazdy namet.
>
>Cechy (cechy@volny.cz)
Další informace o konferenci Hw-list