forked from KolibriOS/kolibrios
Fix for IDE devices:
1) Restore broken HD load for ramdisk image 2) Check of support UDMA mode for disk devices before initialization channel of IDE controller git-svn-id: svn://kolibrios.org@4772 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
25f4ced5a9
commit
354e32e7f3
@ -9,10 +9,10 @@ $Revision$
|
|||||||
|
|
||||||
|
|
||||||
read_ramdisk:
|
read_ramdisk:
|
||||||
; READ RAMDISK IMAGE FROM HD
|
; READ RAMDISK IMAGE FROM HD (only for IDE0, IDE1, IDE2, IDE3)
|
||||||
|
|
||||||
cmp [boot_dev+OS_BASE+0x10000], 1
|
cmp [boot_dev+OS_BASE+0x10000], 1
|
||||||
jne no_sys_on_hd
|
jne no_sys_on_hd.1
|
||||||
|
|
||||||
xor ebp, ebp
|
xor ebp, ebp
|
||||||
.hd_loop:
|
.hd_loop:
|
||||||
@ -69,9 +69,19 @@ read_ramdisk:
|
|||||||
jb .hd_loop
|
jb .hd_loop
|
||||||
jmp no_sys_on_hd
|
jmp no_sys_on_hd
|
||||||
.yes:
|
.yes:
|
||||||
|
DEBUGF 1, "K : RD found: %s\n", read_image_fsinfo.name
|
||||||
pop edi esi eax
|
pop edi esi eax
|
||||||
jmp yes_sys_on_hd
|
|
||||||
|
|
||||||
|
call register_ramdisk
|
||||||
|
jmp yes_sys_on_hd
|
||||||
|
;-----------------------------------------------------------------------------
|
||||||
|
; Register ramdisk file system
|
||||||
|
register_ramdisk:
|
||||||
|
mov esi, boot_initramdisk
|
||||||
|
call boot_log
|
||||||
|
call ramdisk_init
|
||||||
|
ret
|
||||||
|
;-----------------------------------------------------------------------------
|
||||||
iglobal
|
iglobal
|
||||||
align 4
|
align 4
|
||||||
read_image_fsinfo:
|
read_image_fsinfo:
|
||||||
@ -79,7 +89,7 @@ read_image_fsinfo:
|
|||||||
dq 0 ; offset: zero
|
dq 0 ; offset: zero
|
||||||
dd 1474560 ; size
|
dd 1474560 ; size
|
||||||
dd RAMDISK ; buffer
|
dd RAMDISK ; buffer
|
||||||
db '/hd'
|
.name db '/hd'
|
||||||
.name_digit db '0'
|
.name_digit db '0'
|
||||||
db '/'
|
db '/'
|
||||||
.partition:
|
.partition:
|
||||||
@ -99,6 +109,8 @@ read_image:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
no_sys_on_hd:
|
no_sys_on_hd:
|
||||||
|
DEBUGF 1, "K : RD not found\n"
|
||||||
|
.1:
|
||||||
; test_to_format_ram_disk (need if not using ram disk)
|
; test_to_format_ram_disk (need if not using ram disk)
|
||||||
cmp [boot_dev+OS_BASE+0x10000], 3
|
cmp [boot_dev+OS_BASE+0x10000], 3
|
||||||
jne not_format_ram_disk
|
jne not_format_ram_disk
|
||||||
|
@ -65,9 +65,9 @@ FindHDD_2:
|
|||||||
FindHDD_1:
|
FindHDD_1:
|
||||||
DEBUGF 1, "K : Channel %d ",[ChannelNumber]:2
|
DEBUGF 1, "K : Channel %d ",[ChannelNumber]:2
|
||||||
DEBUGF 1, "Disk %d\n",[DiskNumber]:1
|
DEBUGF 1, "Disk %d\n",[DiskNumber]:1
|
||||||
push ebx
|
push ebx ecx
|
||||||
call ReadHDD_ID
|
call ReadHDD_ID
|
||||||
pop ebx
|
pop ecx ebx
|
||||||
cmp [DevErrorCode], 0
|
cmp [DevErrorCode], 0
|
||||||
jne .FindCD
|
jne .FindCD
|
||||||
|
|
||||||
@ -81,15 +81,15 @@ FindHDD_1:
|
|||||||
jmp .Print_Device_Name
|
jmp .Print_Device_Name
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
.FindCD:
|
.FindCD:
|
||||||
push ebx
|
push ebx ecx
|
||||||
call DeviceReset
|
call DeviceReset
|
||||||
pop ebx
|
pop ecx ebx
|
||||||
cmp [DevErrorCode], 0
|
cmp [DevErrorCode], 0
|
||||||
jne .end
|
jne .end
|
||||||
|
|
||||||
push ebx
|
push ebx ecx
|
||||||
call ReadCD_ID
|
call ReadCD_ID
|
||||||
pop ebx
|
pop ecx ebx
|
||||||
cmp [DevErrorCode], 0
|
cmp [DevErrorCode], 0
|
||||||
jne .end
|
jne .end
|
||||||
|
|
||||||
@ -98,10 +98,22 @@ FindHDD_1:
|
|||||||
.Print_Device_Name:
|
.Print_Device_Name:
|
||||||
pushad
|
pushad
|
||||||
pushfd
|
pushfd
|
||||||
|
|
||||||
|
xor ebx, ebx
|
||||||
|
mov bx, [ChannelNumber]
|
||||||
|
dec ebx
|
||||||
|
shl ebx, 1
|
||||||
|
add bl, [DiskNumber]
|
||||||
|
shl ebx, 1
|
||||||
|
|
||||||
|
call calculate_IDE_device_values_storage
|
||||||
|
;--------------------------------------
|
||||||
|
.copy_dev_name:
|
||||||
mov esi, Sector512+27*2
|
mov esi, Sector512+27*2
|
||||||
mov edi, dev_name
|
mov edi, dev_name
|
||||||
mov ecx, 20
|
mov ecx, 20
|
||||||
cld
|
cld
|
||||||
|
;--------------------------------------
|
||||||
@@:
|
@@:
|
||||||
lodsw
|
lodsw
|
||||||
xchg ah, al
|
xchg ah, al
|
||||||
@ -112,12 +124,12 @@ FindHDD_1:
|
|||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov ax, [Sector512+64*2]
|
mov ax, [Sector512+64*2]
|
||||||
DEBUGF 1, "K : PIO mode possible modes %x\n", al
|
DEBUGF 1, "K : PIO possible modes %x\n", al
|
||||||
|
|
||||||
mov ax, [Sector512+51*2]
|
mov ax, [Sector512+51*2]
|
||||||
mov al, ah
|
mov al, ah
|
||||||
call convert_Sector512_value
|
call convert_Sector512_value
|
||||||
DEBUGF 1, "K : PIO mode set mode %x\n", ah
|
DEBUGF 1, "K : PIO set mode %x\n", ah
|
||||||
|
|
||||||
mov ax, [Sector512+63*2]
|
mov ax, [Sector512+63*2]
|
||||||
DEBUGF 1, "K : Multiword DMA possible modes %x\n", al
|
DEBUGF 1, "K : Multiword DMA possible modes %x\n", al
|
||||||
@ -129,10 +141,14 @@ FindHDD_1:
|
|||||||
mov ax, [Sector512+88*2]
|
mov ax, [Sector512+88*2]
|
||||||
DEBUGF 1, "K : Ultra DMA possible modes %x\n", al
|
DEBUGF 1, "K : Ultra DMA possible modes %x\n", al
|
||||||
|
|
||||||
|
mov [ebx+IDE_DEVICE.UDMA_possible_modes], al
|
||||||
|
|
||||||
mov al, ah
|
mov al, ah
|
||||||
call convert_Sector512_value
|
call convert_Sector512_value
|
||||||
DEBUGF 1, "K : Ultra DMA set mode %x\n", ah
|
DEBUGF 1, "K : Ultra DMA set mode %x\n", ah
|
||||||
|
|
||||||
|
mov [ebx+IDE_DEVICE.UDMA_set_mode], ah
|
||||||
|
|
||||||
popfd
|
popfd
|
||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
@ -141,9 +157,30 @@ FindHDD_1:
|
|||||||
DEBUGF 1, "K : Device not found\n"
|
DEBUGF 1, "K : Device not found\n"
|
||||||
ret
|
ret
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
|
calculate_IDE_device_values_storage:
|
||||||
|
cmp ecx, IDE_controller_1
|
||||||
|
jne @f
|
||||||
|
|
||||||
|
add ebx, IDE_device_1
|
||||||
|
jmp .exit
|
||||||
|
;--------------------------------------
|
||||||
|
@@:
|
||||||
|
cmp ecx, IDE_controller_2
|
||||||
|
jne @f
|
||||||
|
|
||||||
|
add ebx, IDE_device_2
|
||||||
|
jmp .exit
|
||||||
|
;--------------------------------------
|
||||||
|
@@:
|
||||||
|
add ebx, IDE_device_3
|
||||||
|
;--------------------------------------
|
||||||
|
.exit:
|
||||||
|
ret
|
||||||
|
;-----------------------------------------------------------------------------
|
||||||
convert_Sector512_value:
|
convert_Sector512_value:
|
||||||
mov ecx, 8
|
mov ecx, 8
|
||||||
xor ah, ah
|
xor ah, ah
|
||||||
|
;--------------------------------------
|
||||||
@@:
|
@@:
|
||||||
test al, 1b
|
test al, 1b
|
||||||
jnz .end
|
jnz .end
|
||||||
@ -153,6 +190,7 @@ convert_Sector512_value:
|
|||||||
loop @b
|
loop @b
|
||||||
|
|
||||||
xor ah, ah
|
xor ah, ah
|
||||||
|
;--------------------------------------
|
||||||
.end:
|
.end:
|
||||||
ret
|
ret
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
|
@ -140,6 +140,10 @@ cache_ide9 IDE_CACHE
|
|||||||
cache_ide10 IDE_CACHE
|
cache_ide10 IDE_CACHE
|
||||||
cache_ide11 IDE_CACHE
|
cache_ide11 IDE_CACHE
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
|
IDE_device_1 rd 2
|
||||||
|
IDE_device_2 rd 2
|
||||||
|
IDE_device_3 rd 2
|
||||||
|
;--------------------------------------
|
||||||
endg
|
endg
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
; START of initialisation IDE ATA code
|
; START of initialisation IDE ATA code
|
||||||
@ -295,13 +299,51 @@ Init_IDE_ATA_controller_2:
|
|||||||
.check_DRIVE_DATA:
|
.check_DRIVE_DATA:
|
||||||
mov al, 0
|
mov al, 0
|
||||||
mov ah, [ebx+DRIVE_DATA+1]
|
mov ah, [ebx+DRIVE_DATA+1]
|
||||||
test ah, 10100000b
|
test ah, 10100000b ; check for ATAPI devices
|
||||||
|
jz @f
|
||||||
|
;--------------------------------------
|
||||||
|
.ch1_pio_set_ATAPI:
|
||||||
|
DEBUGF 1, "K : IDE CH1 PIO, because ATAPI drive present\n"
|
||||||
|
jmp .ch1_pio_set_for_all
|
||||||
|
;--------------------------------------
|
||||||
|
.ch1_pio_set_no_devices:
|
||||||
|
DEBUGF 1, "K : IDE CH1 PIO because no devices\n"
|
||||||
|
jmp .ch1_pio_set_for_all
|
||||||
|
;-------------------------------------
|
||||||
|
.ch1_pio_set:
|
||||||
|
DEBUGF 1, "K : IDE CH1 PIO because device not support UDMA\n"
|
||||||
|
;-------------------------------------
|
||||||
|
.ch1_pio_set_for_all:
|
||||||
|
mov [ecx+IDE_DATA.dma_hdd_channel_1], al
|
||||||
|
jmp .ch2_check
|
||||||
|
;--------------------------------------
|
||||||
|
@@:
|
||||||
|
xor ebx, ebx
|
||||||
|
call calculate_IDE_device_values_storage
|
||||||
|
|
||||||
|
test ah, 1010000b
|
||||||
|
jz .ch1_pio_set_no_devices
|
||||||
|
|
||||||
|
test ah, 1000000b
|
||||||
jz @f
|
jz @f
|
||||||
|
|
||||||
DEBUGF 1, "K : IDE CH1 PIO, because ATAPI drive present\n"
|
cmp [ebx+IDE_DEVICE.UDMA_possible_modes], al
|
||||||
mov [ecx+IDE_DATA.dma_hdd_channel_1], byte 0
|
je .ch1_pio_set
|
||||||
|
|
||||||
jmp .ch2_check
|
cmp [ebx+IDE_DEVICE.UDMA_set_mode], al
|
||||||
|
je .ch1_pio_set
|
||||||
|
;--------------------------------------
|
||||||
|
@@:
|
||||||
|
test ah, 10000b
|
||||||
|
jz @f
|
||||||
|
|
||||||
|
add ebx, 2
|
||||||
|
|
||||||
|
cmp [ebx+IDE_DEVICE.UDMA_possible_modes], al
|
||||||
|
je .ch1_pio_set
|
||||||
|
|
||||||
|
cmp [ebx+IDE_DEVICE.UDMA_set_mode], al
|
||||||
|
je .ch1_pio_set
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
@@:
|
@@:
|
||||||
mov dx, [ecx+IDE_DATA.BAR1_val] ;0x3F4
|
mov dx, [ecx+IDE_DATA.BAR1_val] ;0x3F4
|
||||||
@ -311,13 +353,51 @@ Init_IDE_ATA_controller_2:
|
|||||||
mov [ecx+IDE_DATA.dma_hdd_channel_1], byte 1
|
mov [ecx+IDE_DATA.dma_hdd_channel_1], byte 1
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
.ch2_check:
|
.ch2_check:
|
||||||
test ah, 1010b
|
test ah, 1010b ; check for ATAPI devices
|
||||||
|
jz @f
|
||||||
|
;--------------------------------------
|
||||||
|
.ch2_pio_set_ATAPI:
|
||||||
|
DEBUGF 1, "K : IDE CH2 PIO, because ATAPI drive present\n"
|
||||||
|
jmp .ch2_pio_set_for_all
|
||||||
|
;--------------------------------------
|
||||||
|
.ch2_pio_set_no_devices:
|
||||||
|
DEBUGF 1, "K : IDE CH2 PIO because no devices\n"
|
||||||
|
jmp .ch2_pio_set_for_all
|
||||||
|
;--------------------------------------
|
||||||
|
.ch2_pio_set:
|
||||||
|
DEBUGF 1, "K : IDE CH2 PIO because device not support UDMA\n"
|
||||||
|
;--------------------------------------
|
||||||
|
.ch2_pio_set_for_all:
|
||||||
|
mov [ecx+IDE_DATA.dma_hdd_channel_2], al
|
||||||
|
jmp .end_set_interrupts
|
||||||
|
;--------------------------------------
|
||||||
|
@@:
|
||||||
|
mov ebx, 4
|
||||||
|
call calculate_IDE_device_values_storage
|
||||||
|
|
||||||
|
test ah, 101b
|
||||||
|
jz .ch2_pio_set_no_devices
|
||||||
|
|
||||||
|
test ah, 100b
|
||||||
jz @f
|
jz @f
|
||||||
|
|
||||||
DEBUGF 1, "K : IDE CH2 PIO, because ATAPI drive present\n"
|
cmp [ebx+IDE_DEVICE.UDMA_possible_modes], al
|
||||||
mov [ecx+IDE_DATA.dma_hdd_channel_2], byte 0
|
je .ch2_pio_set
|
||||||
|
|
||||||
jmp .end_set_interrupts
|
cmp [ebx+IDE_DEVICE.UDMA_set_mode], al
|
||||||
|
je .ch2_pio_set
|
||||||
|
;--------------------------------------
|
||||||
|
@@:
|
||||||
|
test ah, 1b
|
||||||
|
jz @f
|
||||||
|
|
||||||
|
add ebx, 2
|
||||||
|
|
||||||
|
cmp [ebx+IDE_DEVICE.UDMA_possible_modes], al
|
||||||
|
je .ch2_pio_set
|
||||||
|
|
||||||
|
cmp [ebx+IDE_DEVICE.UDMA_set_mode], al
|
||||||
|
je .ch2_pio_set
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
@@:
|
@@:
|
||||||
mov dx, [ecx+IDE_DATA.BAR3_val] ;0x374
|
mov dx, [ecx+IDE_DATA.BAR3_val] ;0x374
|
||||||
@ -349,6 +429,16 @@ include 'getcache.inc'
|
|||||||
mov esi, boot_detectpart
|
mov esi, boot_detectpart
|
||||||
call boot_log
|
call boot_log
|
||||||
include 'sear_par.inc'
|
include 'sear_par.inc'
|
||||||
|
;-----------------------------------------------------------------------------
|
||||||
|
mov esi, boot_init_sys
|
||||||
|
call boot_log
|
||||||
|
call Parser_params
|
||||||
|
|
||||||
|
if ~ defined extended_primary_loader
|
||||||
|
; ramdisk image should be loaded by extended primary loader if it exists
|
||||||
|
; READ RAMDISK IMAGE FROM HD
|
||||||
|
include '../boot/rdload.inc'
|
||||||
|
end if
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
mov ecx, IDE_controller_1
|
mov ecx, IDE_controller_1
|
||||||
mov [IDE_controller_pointer], ecx
|
mov [IDE_controller_pointer], ecx
|
||||||
|
@ -699,10 +699,12 @@ no_mode_0x12:
|
|||||||
call PIT_init
|
call PIT_init
|
||||||
|
|
||||||
; Register ramdisk file system
|
; Register ramdisk file system
|
||||||
mov esi, boot_initramdisk
|
cmp [boot_dev+OS_BASE+0x10000], 1
|
||||||
call boot_log
|
je @f
|
||||||
call ramdisk_init
|
|
||||||
|
|
||||||
|
call register_ramdisk
|
||||||
|
;--------------------------------------
|
||||||
|
@@:
|
||||||
mov esi, boot_initapic
|
mov esi, boot_initapic
|
||||||
call boot_log
|
call boot_log
|
||||||
; Try to Initialize APIC
|
; Try to Initialize APIC
|
||||||
@ -787,19 +789,6 @@ include 'detect/dev_fd.inc'
|
|||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
include 'detect/init_ata.inc'
|
include 'detect/init_ata.inc'
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
mov esi, boot_init_sys
|
|
||||||
call boot_log
|
|
||||||
call Parser_params
|
|
||||||
|
|
||||||
if ~ defined extended_primary_loader
|
|
||||||
; ramdisk image should be loaded by extended primary loader if it exists
|
|
||||||
; READ RAMDISK IMAGE FROM HD
|
|
||||||
|
|
||||||
;!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
include 'boot/rdload.inc'
|
|
||||||
;!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
end if
|
|
||||||
|
|
||||||
if 0
|
if 0
|
||||||
mov ax, [OS_BASE+0x10000+bx_from_load]
|
mov ax, [OS_BASE+0x10000+bx_from_load]
|
||||||
cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba}
|
cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba}
|
||||||
|
@ -178,6 +178,11 @@ struct IDE_CACHE
|
|||||||
appl_search_start dd ?
|
appl_search_start dd ?
|
||||||
ends
|
ends
|
||||||
|
|
||||||
|
struct IDE_DEVICE
|
||||||
|
UDMA_possible_modes db ?
|
||||||
|
UDMA_set_mode db ?
|
||||||
|
ends
|
||||||
|
|
||||||
; Core functions
|
; Core functions
|
||||||
include "core/sync.inc" ; macros for synhronization objects
|
include "core/sync.inc" ; macros for synhronization objects
|
||||||
include "core/sys32.inc" ; process management
|
include "core/sys32.inc" ; process management
|
||||||
|
Loading…
Reference in New Issue
Block a user