From 178ccd95f97b37eee182991c30f1dd2d4fa75b03 Mon Sep 17 00:00:00 2001 From: "Marat Zakiyanov (Mario79)" Date: Wed, 26 Jun 2013 02:38:47 +0000 Subject: [PATCH] PIO LBA48 write for HDD git-svn-id: svn://kolibrios.org@3706 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/blkdev/hd_drv.inc | 102 ++++++++++++++++++++++--------- kernel/trunk/detect/dev_hdcd.inc | 6 +- kernel/trunk/kernel.asm | 18 ++---- 3 files changed, 80 insertions(+), 46 deletions(-) diff --git a/kernel/trunk/blkdev/hd_drv.inc b/kernel/trunk/blkdev/hd_drv.inc index 52209833f2..8a23656599 100644 --- a/kernel/trunk/blkdev/hd_drv.inc +++ b/kernel/trunk/blkdev/hd_drv.inc @@ -117,35 +117,37 @@ hd_read_pio: cmp eax, 0x10000000 jae .lba48 .lba28: + pushfd cli xor eax, eax mov edx, [hdbase] inc edx - out dx, al; ATAFeatures регистр "особенностей" + out dx, al ; ATA Features регистр "особенностей" inc edx inc eax - out dx, al; ATASectorCount счётчик секторов + out dx, al ; ATA Sector Counter счётчик секторов inc edx - mov eax, [esp+4] - out dx, al; ATASectorNumber регистр номера сектора + mov eax, [esp+4+4] + out dx, al ; LBA Low LBA (7:0) shr eax, 8 inc edx - out dx, al; ATACylinder номер цилиндра (младший байт) + out dx, al ; LBA Mid LBA (15:8) shr eax, 8 inc edx - out dx, al; номер цилиндра (старший байт) + out dx, al ; LBA High LBA (23:16) shr eax, 8 inc edx - and al, 1+2+4+8 + and al, 1+2+4+8 ; LBA (27:24) add al, byte [hdid] add al, 128+64+32 - out dx, al; номер головки/номер диска + out dx, al ; номер головки/номер диска inc edx - mov al, 20h - out dx, al; ATACommand регистр команд - sti + mov al, 20h ; READ SECTOR(S) + out dx, al ; ATACommand регистр команд + popfd jmp .continue .lba48: + pushfd cli xor eax, eax mov edx, [hdbase] @@ -157,7 +159,7 @@ hd_read_pio: inc eax out dx, al ; Sector Count Current Sector count (7:0) inc edx - mov eax, [esp+4] + mov eax, [esp+4+4] rol eax,8 out dx, al ; LBA Low Previous LBA (31:24) xor eax,eax ; because only 32 bit cache @@ -166,7 +168,7 @@ hd_read_pio: inc edx out dx, al ; LBA High Previous LBA (47:40) sub edx,2 - mov eax, [esp+4] + mov eax, [esp+4+4] out dx, al ; LBA Low Current LBA (7:0) shr eax, 8 inc edx @@ -181,7 +183,7 @@ hd_read_pio: inc edx mov al, 24h ; READ SECTOR(S) EXT out dx, al; ATACommand регистр команд - sti + popfd .continue: call wait_for_sector_buffer @@ -291,8 +293,6 @@ hd_write: align 4 cache_write_pio: - cmp dword[esi], 0x10000000 - jae .bad ; call disable_ide_int ; Выбрать нужный диск @@ -306,34 +306,79 @@ cache_write_pio: cmp [hd_error], 0 jne hd_write_error +; ATA with 28 or 48 bit for sector number? + mov eax, [esi] + cmp eax, 0x10000000 + jae .lba48 +.lba28: + pushfd cli xor eax, eax mov edx, [hdbase] inc edx - out dx, al + out dx, al ; ATA Features регистр "особенностей" inc edx inc eax - out dx, al + out dx, al ; ATA Sector Counter счётчик секторов inc edx mov eax, [esi] ; eax = sector to write - out dx, al + out dx, al ; LBA Low LBA (7:0) shr eax, 8 inc edx - out dx, al + out dx, al ; LBA Mid LBA (15:8) shr eax, 8 inc edx - out dx, al + out dx, al ; LBA High LBA (23:16) shr eax, 8 inc edx - and al, 1+2+4+8 + and al, 1+2+4+8 ; LBA (27:24) add al, byte [hdid] add al, 128+64+32 - out dx, al + out dx, al ; номер головки/номер диска inc edx - mov al, 30h - out dx, al - sti - + mov al, 30h ; WRITE SECTOR(S) + out dx, al ; ATACommand регистр команд + popfd + jmp .continue +.lba48: + pushfd + cli + xor eax, eax + mov edx, [hdbase] + inc edx + out dx, al ; Features Previous Reserved + out dx, al ; Features Current Reserved + inc edx + out dx, al ; Sector Count Previous Sector count (15:8) + inc eax + out dx, al ; Sector Count Current Sector count (7:0) + inc edx + mov eax, [esi] + rol eax,8 + out dx, al ; LBA Low Previous LBA (31:24) + xor eax,eax ; because only 32 bit cache + inc edx + out dx, al ; LBA Mid Previous LBA (39:32) + inc edx + out dx, al ; LBA High Previous LBA (47:40) + sub edx,2 + mov eax, [esi] + out dx, al ; LBA Low Current LBA (7:0) + shr eax, 8 + inc edx + out dx, al ; LBA Mid Current LBA (15:8) + shr eax, 8 + inc edx + out dx, al ; LBA High Current LBA (23:16) + inc edx + mov al, byte [hdid] + add al, 128+64+32 + out dx, al; номер головки/номер диска + inc edx + mov al, 34h ; WRITE SECTOR(S) EXT + out dx, al; ATACommand регистр команд + popfd +.continue: call wait_for_sector_buffer cmp [hd_error], 0 @@ -360,9 +405,6 @@ cache_write_pio: pop esi ecx ret -.bad: - inc [hd_error] - ret save_hd_wait_timeout: diff --git a/kernel/trunk/detect/dev_hdcd.inc b/kernel/trunk/detect/dev_hdcd.inc index d4042be51b..62386bf686 100644 --- a/kernel/trunk/detect/dev_hdcd.inc +++ b/kernel/trunk/detect/dev_hdcd.inc @@ -44,10 +44,8 @@ FindHDD: jmp EndFindHDD FindHDD_1: - movzx eax,word [ChannelNumber] - DEBUGF 1, "K : Channel %d ",eax - movzx eax,byte [DiskNumber] - DEBUGF 1, "Disk %d\n",eax + DEBUGF 1, "K : Channel %d ",[ChannelNumber]:2 + DEBUGF 1, "Disk %d\n",[DiskNumber]:1 call ReadHDD_ID cmp [DevErrorCode], 0 jne FindHDD_2 diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index b8e0aa16e9..3d7ca5739a 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -1046,18 +1046,12 @@ end if @@: DEBUGF 1, "K : %d CPU detected\n", eax - movzx eax,[IDE_BAR0_val] - DEBUGF 1, "K : BAR0 %x \n", eax - movzx eax,[IDE_BAR1_val] - DEBUGF 1, "K : BAR1 %x \n", eax - movzx eax,[IDE_BAR2_val] - DEBUGF 1, "K : BAR2 %x \n", eax - movzx eax,[IDE_BAR3_val] - DEBUGF 1, "K : BAR3 %x \n", eax - movzx eax,[IDEContrRegsBaseAddr] - DEBUGF 1, "K : BAR4 %x \n", eax - movzx eax,[IDEContrProgrammingInterface] - DEBUGF 1, "K : IDEContrProgrammingInterface %x \n", eax + DEBUGF 1, "K : BAR0 %x \n", [IDE_BAR0_val]:4 + DEBUGF 1, "K : BAR1 %x \n", [IDE_BAR1_val]:4 + DEBUGF 1, "K : BAR2 %x \n", [IDE_BAR2_val]:4 + DEBUGF 1, "K : BAR3 %x \n", [IDE_BAR3_val]:4 + DEBUGF 1, "K : BAR4 %x \n", [IDEContrRegsBaseAddr]:4 + DEBUGF 1, "K : IDEContrProgrammingInterface %x \n", [IDEContrProgrammingInterface]:4 ; START MULTITASKING ; A 'All set - press ESC to start' messages if need