forked from KolibriOS/kolibrios
Kernel supports up to three IDE controllers, and all the devices connected to them
git-svn-id: svn://kolibrios.org@4700 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -17,44 +17,85 @@ $Revision$
|
||||
;****************************************************
|
||||
;* ПОИСК HDD и CD *
|
||||
;****************************************************
|
||||
cmp [IDEContrProgrammingInterface], 0
|
||||
cmp [ecx+IDE_DATA.ProgrammingInterface], 0
|
||||
je EndFindHDD
|
||||
|
||||
FindHDD:
|
||||
push ecx
|
||||
|
||||
xor ebx, ebx
|
||||
inc ebx
|
||||
|
||||
cmp ecx, IDE_controller_2
|
||||
jne @f
|
||||
|
||||
add bl, 5
|
||||
jmp .find
|
||||
@@:
|
||||
cmp ecx, IDE_controller_3
|
||||
jne .find
|
||||
|
||||
add bl, 10
|
||||
;--------------------------------------
|
||||
.find:
|
||||
|
||||
mov [ChannelNumber], 1
|
||||
mov [DiskNumber], 0
|
||||
call FindHDD_3
|
||||
call FindHDD_2
|
||||
|
||||
mov [DiskNumber], 1
|
||||
call FindHDD_3
|
||||
call FindHDD_2
|
||||
|
||||
inc [ChannelNumber]
|
||||
|
||||
mov [DiskNumber], 0
|
||||
call FindHDD_3
|
||||
call FindHDD_2
|
||||
|
||||
mov [DiskNumber], 1
|
||||
call FindHDD_1
|
||||
jmp EndFindHDD
|
||||
|
||||
pop ecx
|
||||
jmp EndFindHDD
|
||||
;-----------------------------------------------------------------------------
|
||||
FindHDD_2:
|
||||
call FindHDD_1
|
||||
shl byte [ebx+DRIVE_DATA], 2
|
||||
ret
|
||||
;-----------------------------------------------------------------------------
|
||||
FindHDD_1:
|
||||
DEBUGF 1, "K : Channel %d ",[ChannelNumber]:2
|
||||
DEBUGF 1, "Disk %d\n",[DiskNumber]:1
|
||||
push ebx
|
||||
call ReadHDD_ID
|
||||
pop ebx
|
||||
cmp [DevErrorCode], 0
|
||||
jne FindHDD_2
|
||||
jne .FindCD
|
||||
|
||||
cmp [Sector512+6], word 16
|
||||
ja FindHDD_2
|
||||
ja .FindCD
|
||||
|
||||
cmp [Sector512+12], word 255
|
||||
ja FindHDD_2
|
||||
inc byte [DRIVE_DATA+1]
|
||||
jmp Print_Device_Name
|
||||
FindHDD_2:
|
||||
ja .FindCD
|
||||
|
||||
inc byte [ebx+DRIVE_DATA]
|
||||
jmp .Print_Device_Name
|
||||
;--------------------------------------
|
||||
.FindCD:
|
||||
push ebx
|
||||
call DeviceReset
|
||||
pop ebx
|
||||
cmp [DevErrorCode], 0
|
||||
jne FindHDD_2_2
|
||||
jne .end
|
||||
|
||||
push ebx
|
||||
call ReadCD_ID
|
||||
pop ebx
|
||||
cmp [DevErrorCode], 0
|
||||
jne FindHDD_2_2
|
||||
inc byte [DRIVE_DATA+1]
|
||||
inc byte [DRIVE_DATA+1]
|
||||
Print_Device_Name:
|
||||
jne .end
|
||||
|
||||
add [ebx+DRIVE_DATA], byte 2
|
||||
;--------------------------------------
|
||||
.Print_Device_Name:
|
||||
pushad
|
||||
pushfd
|
||||
mov esi, Sector512+27*2
|
||||
@@ -66,33 +107,38 @@ Print_Device_Name:
|
||||
xchg ah, al
|
||||
stosw
|
||||
loop @b
|
||||
popfd
|
||||
popad
|
||||
|
||||
DEBUGF 1, "K : Dev: %s \n", dev_name
|
||||
|
||||
xor eax, eax
|
||||
mov ax, [Sector512+64*2]
|
||||
DEBUGF 1, "K : PIO mode possible modes %x\n", al
|
||||
|
||||
mov ax, [Sector512+51*2]
|
||||
mov al, ah
|
||||
call convert_Sector512_value
|
||||
DEBUGF 1, "K : PIO mode set mode %x\n", ah
|
||||
|
||||
mov ax, [Sector512+63*2]
|
||||
DEBUGF 1, "K : Multiword DMA possible modes %x\n", al
|
||||
|
||||
mov al, ah
|
||||
call convert_Sector512_value
|
||||
DEBUGF 1, "K : Multiword DMA set mode %x\n", ah
|
||||
|
||||
mov ax, [Sector512+88*2]
|
||||
DEBUGF 1, "K : Ultra DMA possible modes %x\n", al
|
||||
|
||||
mov al, ah
|
||||
call convert_Sector512_value
|
||||
DEBUGF 1, "K : Ultra DMA set mode %x\n", ah
|
||||
FindHDD_2_2:
|
||||
|
||||
popfd
|
||||
popad
|
||||
ret
|
||||
;-----------------------------------------------------------------------------
|
||||
FindHDD_3:
|
||||
call FindHDD_1
|
||||
shl byte [DRIVE_DATA+1], 2
|
||||
;--------------------------------------
|
||||
.end:
|
||||
DEBUGF 1, "K : Device not found\n"
|
||||
ret
|
||||
;-----------------------------------------------------------------------------
|
||||
convert_Sector512_value:
|
||||
@@ -112,10 +158,11 @@ convert_Sector512_value:
|
||||
;-----------------------------------------------------------------------------
|
||||
; Адрес считываемого сектора в режиме LBA
|
||||
uglobal
|
||||
SectorAddress DD ?
|
||||
SectorAddress dd ?
|
||||
dev_name:
|
||||
rb 41
|
||||
endg
|
||||
;-----------------------------------------------------------------------------
|
||||
;*************************************************
|
||||
;* ЧТЕНИЕ ИДЕНТИФИКАТОРА ЖЕСТКОГО ДИСКА *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
@@ -131,32 +178,32 @@ ReadHDD_ID:
|
||||
; Послать команду идентификации устройства
|
||||
mov [ATAFeatures], 0
|
||||
mov [ATAHead], 0
|
||||
mov [ATACommand], 0ECh
|
||||
mov [ATACommand], 0xEC
|
||||
call SendCommandToHDD
|
||||
cmp [DevErrorCode], 0;проверить код ошибки
|
||||
cmp [DevErrorCode], 0 ;проверить код ошибки
|
||||
jne @@End ;закончить, сохранив код ошибки
|
||||
mov DX, [ATABasePortAddr]
|
||||
add DX, 7 ;адрес регистра состояни
|
||||
|
||||
mov dx, [ATABasePortAddr]
|
||||
add dx, 7 ;адрес регистра состояни
|
||||
mov ecx, 0xffff
|
||||
@@WaitCompleet:
|
||||
; Проверить время выполнения команды
|
||||
dec ecx
|
||||
; cmp ecx,0
|
||||
jz @@Error1 ;ошибка тайм-аута
|
||||
; Проверить готовность
|
||||
in AL, DX
|
||||
test AL, 80h ;состояние сигнала BSY
|
||||
in al, dx
|
||||
test al, 80h ;состояние сигнала BSY
|
||||
jnz @@WaitCompleet
|
||||
test AL, 1 ;состояние сигнала ERR
|
||||
|
||||
test al, 1 ;состояние сигнала ERR
|
||||
jnz @@Error6
|
||||
test AL, 08h ;состояние сигнала DRQ
|
||||
|
||||
test al, 08h ;состояние сигнала DRQ
|
||||
jz @@WaitCompleet
|
||||
; Принять блок данных от контроллера
|
||||
; mov AX,DS
|
||||
; mov ES,AX
|
||||
mov EDI, Sector512 ;offset Sector512
|
||||
mov DX, [ATABasePortAddr];регистр данных
|
||||
mov CX, 256 ;число считываемых слов
|
||||
mov edi, Sector512
|
||||
mov dx, [ATABasePortAddr];регистр данных
|
||||
mov cx, 256 ;число считываемых слов
|
||||
rep insw ;принять блок данных
|
||||
ret
|
||||
; Записать код ошибки
|
||||
@@ -167,27 +214,24 @@ ReadHDD_ID:
|
||||
mov [DevErrorCode], 6
|
||||
@@End:
|
||||
ret
|
||||
|
||||
|
||||
iglobal
|
||||
; Стандартные базовые адреса каналов 1 и 2
|
||||
StandardATABases DW 1F0h, 170h
|
||||
endg
|
||||
;-----------------------------------------------------------------------------
|
||||
uglobal
|
||||
; Стандартные базовые адреса каналов 1 и 2
|
||||
StandardATABases dw ?, ? ; 1F0h, 170h
|
||||
; Номер канала
|
||||
ChannelNumber DW ?
|
||||
ChannelNumber dw ?
|
||||
; Номер диска
|
||||
DiskNumber DB ?
|
||||
DiskNumber db ?
|
||||
; Базовый адрес группы портов контроллера ATA
|
||||
ATABasePortAddr DW ?
|
||||
ATABasePortAddr dw ?
|
||||
; Параметры ATA-команды
|
||||
ATAFeatures DB ? ;особенности
|
||||
ATASectorCount DB ? ;количество обрабатываемых секторов
|
||||
ATASectorNumber DB ? ;номер начального сектора
|
||||
ATACylinder DW ? ;номер начального цилиндра
|
||||
ATAHead DB ? ;номер начальной головки
|
||||
ATAAddressMode DB ? ;режим адресации (0 - CHS, 1 - LBA)
|
||||
ATACommand DB ? ;код команды, подлежащей выполнению
|
||||
ATAFeatures db ? ;особенности
|
||||
ATASectorCount db ? ;количество обрабатываемых секторов
|
||||
ATASectorNumber db ? ;номер начального сектора
|
||||
ATACylinder dw ? ;номер начального цилиндра
|
||||
ATAHead db ? ;номер начальной головки
|
||||
ATAAddressMode db ? ;режим адресации (0 - CHS, 1 - LBA)
|
||||
ATACommand db ? ;код команды, подлежащей выполнению
|
||||
; Код ошибки (0 - нет ошибок, 1 - превышен допустимый
|
||||
; интервал ожидания, 2 - неверный код режима адресации,
|
||||
; 3 - неверный номер канала, 4 - неверный номер диска,
|
||||
@@ -195,6 +239,7 @@ ATACommand DB ? ;код команды, подлежащей выполне
|
||||
; команды)
|
||||
DevErrorCode dd ?
|
||||
endg
|
||||
;-----------------------------------------------------------------------------
|
||||
;****************************************************
|
||||
;* ПОСЛАТЬ КОМАНДУ ЗАДАННОМУ ДИСКУ *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
@@ -219,82 +264,78 @@ SendCommandToHDD:
|
||||
cmp [ATAAddressMode], 1
|
||||
ja @@Err2
|
||||
; Проверить корректность номера канала
|
||||
mov BX, [ChannelNumber]
|
||||
cmp BX, 1
|
||||
mov bx, [ChannelNumber]
|
||||
cmp bx, 1
|
||||
jb @@Err3
|
||||
cmp BX, 2
|
||||
|
||||
cmp bx, 2
|
||||
ja @@Err3
|
||||
; Установить базовый адрес
|
||||
dec BX
|
||||
shl BX, 1
|
||||
dec bx
|
||||
shl bx, 1
|
||||
movzx ebx, bx
|
||||
mov AX, [ebx+StandardATABases]
|
||||
mov [ATABasePortAddr], AX
|
||||
mov ax, [ebx+StandardATABases]
|
||||
mov [ATABasePortAddr], ax
|
||||
; Ожидание готовности HDD к приему команды
|
||||
; Выбрать нужный диск
|
||||
mov DX, [ATABasePortAddr]
|
||||
add DX, 6 ;адрес регистра головок
|
||||
mov AL, [DiskNumber]
|
||||
cmp AL, 1 ;проверить номера диска
|
||||
mov dx, [ATABasePortAddr]
|
||||
add dx, 6 ;адрес регистра головок
|
||||
mov al, [DiskNumber]
|
||||
cmp al, 1 ;проверить номера диска
|
||||
ja @@Err4
|
||||
shl AL, 4
|
||||
or AL, 10100000b
|
||||
out DX, AL
|
||||
|
||||
shl al, 4
|
||||
or al, 10100000b
|
||||
out dx, al
|
||||
; Ожидать, пока диск не будет готов
|
||||
inc DX
|
||||
inc dx
|
||||
mov ecx, 0xfff
|
||||
; mov eax,[timer_ticks]
|
||||
; mov [TickCounter_1],eax
|
||||
@@WaitHDReady:
|
||||
; Проверить время ожидани
|
||||
dec ecx
|
||||
; cmp ecx,0
|
||||
jz @@Err1
|
||||
; mov eax,[timer_ticks]
|
||||
; sub eax,[TickCounter_1]
|
||||
; cmp eax,300 ;ожидать 300 тиков
|
||||
; ja @@Err1 ;ошибка тайм-аута
|
||||
; Прочитать регистр состояни
|
||||
in AL, DX
|
||||
in al, dx
|
||||
; Проверить состояние сигнала BSY
|
||||
test AL, 80h
|
||||
test al, 80h
|
||||
jnz @@WaitHDReady
|
||||
; Проверить состояние сигнала DRQ
|
||||
test AL, 08h
|
||||
test al, 08h
|
||||
jnz @@WaitHDReady
|
||||
; Загрузить команду в регистры контроллера
|
||||
cli
|
||||
mov DX, [ATABasePortAddr]
|
||||
inc DX ;регистр "особенностей"
|
||||
mov AL, [ATAFeatures]
|
||||
out DX, AL
|
||||
inc DX ;счетчик секторов
|
||||
mov AL, [ATASectorCount]
|
||||
out DX, AL
|
||||
inc DX ;регистр номера сектора
|
||||
mov AL, [ATASectorNumber]
|
||||
out DX, AL
|
||||
inc DX ;номер цилиндра (младший байт)
|
||||
mov AX, [ATACylinder]
|
||||
out DX, AL
|
||||
inc DX ;номер цилиндра (старший байт)
|
||||
mov AL, AH
|
||||
out DX, AL
|
||||
inc DX ;номер головки/номер диска
|
||||
mov AL, [DiskNumber]
|
||||
shl AL, 4
|
||||
cmp [ATAHead], 0Fh;проверить номер головки
|
||||
mov dx, [ATABasePortAddr]
|
||||
inc dx ;регистр "особенностей"
|
||||
mov al, [ATAFeatures]
|
||||
out dx, AL
|
||||
inc dx ;счетчик секторов
|
||||
mov al, [ATASectorCount]
|
||||
out dx, AL
|
||||
inc dx ;регистр номера сектора
|
||||
mov al, [ATASectorNumber]
|
||||
out dx, AL
|
||||
inc dx ;номер цилиндра (младший байт)
|
||||
mov ax, [ATACylinder]
|
||||
out dx, AL
|
||||
inc dx ;номер цилиндра (старший байт)
|
||||
mov al, AH
|
||||
out dx, AL
|
||||
inc dx ;номер головки/номер диска
|
||||
mov al, [DiskNumber]
|
||||
shl al, 4
|
||||
cmp [ATAHead], 0xF ;проверить номер головки
|
||||
ja @@Err5
|
||||
or AL, [ATAHead]
|
||||
or AL, 10100000b
|
||||
mov AH, [ATAAddressMode]
|
||||
shl AH, 6
|
||||
or AL, AH
|
||||
out DX, AL
|
||||
|
||||
or al, [ATAHead]
|
||||
or al, 10100000b
|
||||
mov ah, [ATAAddressMode]
|
||||
shl ah, 6
|
||||
or al, ah
|
||||
out dx, al
|
||||
; Послать команду
|
||||
mov AL, [ATACommand]
|
||||
inc DX ;регистр команд
|
||||
out DX, AL
|
||||
mov al, [ATACommand]
|
||||
inc dx ;регистр команд
|
||||
out dx, al
|
||||
sti
|
||||
; Сбросить признак ошибки
|
||||
mov [DevErrorCode], 0
|
||||
@@ -316,7 +357,7 @@ SendCommandToHDD:
|
||||
mov [DevErrorCode], 5
|
||||
; Завершение работы программы
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
;*************************************************
|
||||
;* ЧТЕНИЕ ИДЕНТИФИКАТОРА УСТРОЙСТВА ATAPI *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
@@ -335,33 +376,32 @@ ReadCD_ID:
|
||||
mov [ATASectorNumber], 0
|
||||
mov [ATACylinder], 0
|
||||
mov [ATAHead], 0
|
||||
mov [ATACommand], 0A1h
|
||||
mov [ATACommand], 0xA1
|
||||
call SendCommandToHDD
|
||||
cmp [DevErrorCode], 0;проверить код ошибки
|
||||
jne @@End_1 ;закончить, сохранив код ошибки
|
||||
; Ожидать готовность данных HDD
|
||||
mov DX, [ATABasePortAddr]
|
||||
add DX, 7 ;порт 1х7h
|
||||
mov dx, [ATABasePortAddr]
|
||||
add dx, 7 ;порт 1х7h
|
||||
mov ecx, 0xffff
|
||||
@@WaitCompleet_1:
|
||||
; Проверить врем
|
||||
dec ecx
|
||||
; cmp ecx,0
|
||||
jz @@Error1_1 ;ошибка тайм-аута
|
||||
; Проверить готовность
|
||||
in AL, DX
|
||||
test AL, 80h ;состояние сигнала BSY
|
||||
in al, dx
|
||||
test al, 80h ;состояние сигнала BSY
|
||||
jnz @@WaitCompleet_1
|
||||
test AL, 1 ;состояние сигнала ERR
|
||||
|
||||
test al, 1 ;состояние сигнала ERR
|
||||
jnz @@Error6_1
|
||||
test AL, 08h ;состояние сигнала DRQ
|
||||
|
||||
test al, 08h ;состояние сигнала DRQ
|
||||
jz @@WaitCompleet_1
|
||||
; Принять блок данных от контроллера
|
||||
; mov AX,DS
|
||||
; mov ES,AX
|
||||
mov EDI, Sector512 ;offset Sector512
|
||||
mov DX, [ATABasePortAddr];порт 1x0h
|
||||
mov CX, 256;число считываемых слов
|
||||
mov edi, Sector512 ;offset Sector512
|
||||
mov dx, [ATABasePortAddr];порт 1x0h
|
||||
mov cx, 256;число считываемых слов
|
||||
rep insw
|
||||
ret
|
||||
; Записать код ошибки
|
||||
@@ -372,7 +412,7 @@ ReadCD_ID:
|
||||
mov [DevErrorCode], 6
|
||||
@@End_1:
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
;*************************************************
|
||||
;* СБРОС УСТРОЙСТВА *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
@@ -382,39 +422,40 @@ ReadCD_ID:
|
||||
;*************************************************
|
||||
DeviceReset:
|
||||
; Проверить корректность номера канала
|
||||
mov BX, [ChannelNumber]
|
||||
cmp BX, 1
|
||||
mov bx, [ChannelNumber]
|
||||
cmp bx, 1
|
||||
jb @@Err3_2
|
||||
cmp BX, 2
|
||||
|
||||
cmp bx, 2
|
||||
ja @@Err3_2
|
||||
; Установить базовый адрес
|
||||
dec BX
|
||||
shl BX, 1
|
||||
dec bx
|
||||
shl bx, 1
|
||||
movzx ebx, bx
|
||||
mov DX, [ebx+StandardATABases]
|
||||
mov [ATABasePortAddr], DX
|
||||
mov dx, [ebx+StandardATABases]
|
||||
mov [ATABasePortAddr], dx
|
||||
; Выбрать нужный диск
|
||||
add DX, 6 ;адрес регистра головок
|
||||
mov AL, [DiskNumber]
|
||||
cmp AL, 1 ;проверить номера диска
|
||||
add dx, 6 ;адрес регистра головок
|
||||
mov al, [DiskNumber]
|
||||
cmp al, 1 ;проверить номера диска
|
||||
ja @@Err4_2
|
||||
shl AL, 4
|
||||
or AL, 10100000b
|
||||
out DX, AL
|
||||
|
||||
shl al, 4
|
||||
or al, 10100000b
|
||||
out dx, al
|
||||
; Послать команду "Сброс"
|
||||
mov AL, 08h
|
||||
inc DX ;регистр команд
|
||||
out DX, AL
|
||||
mov al, 0x8
|
||||
inc dx ;регистр команд
|
||||
out dx, al
|
||||
mov ecx, 0x80000
|
||||
@@WaitHDReady_1:
|
||||
; Проверить время ожидани
|
||||
dec ecx
|
||||
; cmp ecx,0
|
||||
je @@Err1_2 ;ошибка тайм-аута
|
||||
; Прочитать регистр состояни
|
||||
in AL, DX
|
||||
in al, dx
|
||||
; Проверить состояние сигнала BSY
|
||||
test AL, 80h
|
||||
test al, 80h
|
||||
jnz @@WaitHDReady_1
|
||||
; Сбросить признак ошибки
|
||||
mov [DevErrorCode], 0
|
||||
@@ -430,6 +471,5 @@ DeviceReset:
|
||||
mov [DevErrorCode], 4
|
||||
; Записать код ошибки
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
EndFindHDD:
|
||||
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
$Revision$
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
pusha
|
||||
|
||||
mov eax, [pg_data.pages_free]
|
||||
@@ -20,89 +21,167 @@ $Revision$
|
||||
; check a upper size of the cache, no more than 1 Mb on the physical device
|
||||
cmp eax, 1024*1024
|
||||
jbe @f
|
||||
|
||||
mov eax, 1024*1024
|
||||
jmp .continue
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; check a lower size of the cache, not less than 128 Kb on the physical device
|
||||
cmp eax, 128*1024
|
||||
jae @f
|
||||
mov eax, 128*1024
|
||||
@@:
|
||||
.continue:
|
||||
mov [cache_ide0_size], eax
|
||||
mov [cache_ide1_size], eax
|
||||
mov [cache_ide2_size], eax
|
||||
mov [cache_ide3_size], eax
|
||||
xor eax, eax
|
||||
mov [hdd_appl_data], 1;al
|
||||
mov [cd_appl_data], 1
|
||||
jae .continue
|
||||
|
||||
test byte [DRIVE_DATA+1], 2
|
||||
je .ide2
|
||||
mov esi, cache_ide3
|
||||
call get_cache_ide
|
||||
.ide2:
|
||||
test byte [DRIVE_DATA+1], 8
|
||||
je .ide1
|
||||
mov esi, cache_ide2
|
||||
call get_cache_ide
|
||||
.ide1:
|
||||
test byte [DRIVE_DATA+1], 0x20
|
||||
je .ide0
|
||||
mov esi, cache_ide1
|
||||
call get_cache_ide
|
||||
.ide0:
|
||||
mov eax, 128*1024
|
||||
;--------------------------------------
|
||||
.continue:
|
||||
push ecx
|
||||
mov ecx, 12
|
||||
mov esi, cache_ide0+IDE_CACHE.size
|
||||
cld
|
||||
@@:
|
||||
mov [esi], eax
|
||||
add esi, sizeof.IDE_CACHE
|
||||
loop @b
|
||||
|
||||
pop ecx
|
||||
|
||||
xor eax, eax
|
||||
mov [hdd_appl_data], 1 ;al
|
||||
mov [cd_appl_data], 1
|
||||
;--------------------------------------
|
||||
test byte [DRIVE_DATA+1], 0x80
|
||||
je @f
|
||||
|
||||
mov esi, cache_ide0
|
||||
call get_cache_ide
|
||||
;--------------------------------------
|
||||
@@:
|
||||
jmp end_get_cache
|
||||
test byte [DRIVE_DATA+1], 0x20
|
||||
je @f
|
||||
|
||||
mov esi, cache_ide1
|
||||
call get_cache_ide
|
||||
;--------------------------------------
|
||||
@@:
|
||||
test byte [DRIVE_DATA+1], 8
|
||||
je @f
|
||||
|
||||
mov esi, cache_ide2
|
||||
call get_cache_ide
|
||||
;--------------------------------------
|
||||
@@:
|
||||
test byte [DRIVE_DATA+1], 2
|
||||
je @f
|
||||
|
||||
mov esi, cache_ide3
|
||||
call get_cache_ide
|
||||
;--------------------------------------
|
||||
@@:
|
||||
test byte [DRIVE_DATA+6], 0x80
|
||||
je @f
|
||||
|
||||
mov esi, cache_ide4
|
||||
call get_cache_ide
|
||||
;--------------------------------------
|
||||
@@:
|
||||
test byte [DRIVE_DATA+6], 0x20
|
||||
je @f
|
||||
|
||||
mov esi, cache_ide5
|
||||
call get_cache_ide
|
||||
;--------------------------------------
|
||||
@@:
|
||||
test byte [DRIVE_DATA+6], 8
|
||||
je @f
|
||||
|
||||
mov esi, cache_ide6
|
||||
call get_cache_ide
|
||||
;--------------------------------------
|
||||
@@:
|
||||
test byte [DRIVE_DATA+6], 2
|
||||
je @f
|
||||
|
||||
mov esi, cache_ide7
|
||||
call get_cache_ide
|
||||
;--------------------------------------
|
||||
@@:
|
||||
test byte [DRIVE_DATA+11], 0x80
|
||||
je @f
|
||||
|
||||
mov esi, cache_ide8
|
||||
call get_cache_ide
|
||||
;--------------------------------------
|
||||
@@:
|
||||
test byte [DRIVE_DATA+11], 0x20
|
||||
je @f
|
||||
|
||||
mov esi, cache_ide9
|
||||
call get_cache_ide
|
||||
;--------------------------------------
|
||||
@@:
|
||||
test byte [DRIVE_DATA+11], 8
|
||||
je @f
|
||||
|
||||
mov esi, cache_ide10
|
||||
call get_cache_ide
|
||||
;--------------------------------------
|
||||
@@:
|
||||
test byte [DRIVE_DATA+11], 2
|
||||
je end_get_cache
|
||||
|
||||
mov esi, cache_ide11
|
||||
call get_cache_ide
|
||||
|
||||
jmp end_get_cache
|
||||
;-----------------------------------------------------------------------------
|
||||
get_cache_ide:
|
||||
and [esi+cache_ide0_search_start-cache_ide0], 0
|
||||
and [esi+cache_ide0_appl_search_start-cache_ide0], 0
|
||||
and [esi+IDE_CACHE.search_start], 0
|
||||
and [esi+IDE_CACHE.appl_search_start], 0
|
||||
|
||||
push ecx
|
||||
stdcall kernel_alloc, [esi+cache_ide0_size-cache_ide0]
|
||||
mov [esi+cache_ide0_pointer-cache_ide0], eax
|
||||
DEBUGF 1, "K : IDE_CACHE.size %x\n", [esi+IDE_CACHE.size]
|
||||
stdcall kernel_alloc, [esi+IDE_CACHE.size]
|
||||
mov [esi+IDE_CACHE.pointer], eax
|
||||
pop ecx
|
||||
|
||||
mov edx, eax
|
||||
mov eax, [esi+cache_ide0_size-cache_ide0]
|
||||
mov eax, [esi+IDE_CACHE.size]
|
||||
shr eax, 3
|
||||
mov [esi+cache_ide0_system_data_size-cache_ide0], eax
|
||||
DEBUGF 1, "K : IDE_CACHE.system_data_size %x\n", eax
|
||||
mov [esi+IDE_CACHE.system_data_size], eax
|
||||
mov ebx, eax
|
||||
imul eax, 7
|
||||
mov [esi+cache_ide0_appl_data_size-cache_ide0], eax
|
||||
DEBUGF 1, "K : IDE_CACHE.appl_data_size %x\n", eax
|
||||
mov [esi+IDE_CACHE.appl_data_size], eax
|
||||
add ebx, edx
|
||||
mov [esi+cache_ide0_data_pointer-cache_ide0], ebx
|
||||
mov [esi+IDE_CACHE.data_pointer], ebx
|
||||
|
||||
.cd:
|
||||
push ecx
|
||||
mov eax, [esi+cache_ide0_system_data_size-cache_ide0]
|
||||
mov eax, [esi+IDE_CACHE.system_data_size]
|
||||
call calculate_for_cd
|
||||
add eax, [esi+cache_ide0_pointer-cache_ide0]
|
||||
mov [esi+cache_ide0_system_data-cache_ide0], eax
|
||||
mov [esi+cache_ide0_system_sad_size-cache_ide0], ecx
|
||||
add eax, [esi+IDE_CACHE.pointer]
|
||||
mov [esi+IDE_CACHE.system_data], eax
|
||||
mov [esi+IDE_CACHE.system_sad_size], ecx
|
||||
|
||||
push edi
|
||||
mov edi, [esi+cache_ide0_pointer-cache_ide0]
|
||||
mov edi, [esi+IDE_CACHE.pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
mov eax, [esi+cache_ide0_appl_data_size-cache_ide0]
|
||||
mov eax, [esi+IDE_CACHE.appl_data_size]
|
||||
call calculate_for_cd
|
||||
add eax, [esi+cache_ide0_data_pointer-cache_ide0]
|
||||
mov [esi+cache_ide0_appl_data-cache_ide0], eax
|
||||
mov [esi+cache_ide0_appl_sad_size-cache_ide0], ecx
|
||||
add eax, [esi+IDE_CACHE.data_pointer]
|
||||
mov [esi+IDE_CACHE.appl_data], eax
|
||||
mov [esi+IDE_CACHE.appl_sad_size], ecx
|
||||
|
||||
push edi
|
||||
mov edi, [esi+cache_ide0_data_pointer-cache_ide0]
|
||||
mov edi, [esi+IDE_CACHE.data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
calculate_for_cd:
|
||||
push eax
|
||||
mov ebx, eax
|
||||
@@ -116,7 +195,7 @@ calculate_for_cd:
|
||||
sub eax, ebx
|
||||
dec ecx
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
clear_ide_cache:
|
||||
push eax
|
||||
shl ecx, 1
|
||||
@@ -125,6 +204,6 @@ clear_ide_cache:
|
||||
rep stosd
|
||||
pop eax
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
end_get_cache:
|
||||
popa
|
||||
|
@@ -1,111 +1,151 @@
|
||||
;-----------------------------------------------------------------------------
|
||||
; find the IDE controller in the device list
|
||||
;-----------------------------------------------------------------------------
|
||||
mov ecx, IDE_controller_1
|
||||
mov esi, pcidev_list
|
||||
;--------------------------------------
|
||||
align 4
|
||||
.loop:
|
||||
mov esi, [esi+PCIDEV.fd]
|
||||
cmp esi, pcidev_list
|
||||
jz .done
|
||||
jz find_IDE_controller_done
|
||||
|
||||
mov eax, [esi+PCIDEV.class]
|
||||
shr eax, 4
|
||||
cmp eax, 0x01018
|
||||
jnz .loop
|
||||
;--------------------------------------
|
||||
.found:
|
||||
mov eax, [esi+PCIDEV.class]
|
||||
DEBUGF 1, 'K : IDE controller programming interface %x\n', eax
|
||||
mov [IDEContrProgrammingInterface], eax
|
||||
mov [ecx+IDE_DATA.ProgrammingInterface], eax
|
||||
|
||||
mov ah, [esi+PCIDEV.bus]
|
||||
mov al, 2
|
||||
mov bh, [esi+PCIDEV.devfn]
|
||||
;-----------------------------------------------------------------------------
|
||||
;--------------------------------------
|
||||
mov bl, 0x10
|
||||
push eax
|
||||
call pci_read_reg
|
||||
and eax, 0xFFFC
|
||||
cmp ax, 0
|
||||
je @f
|
||||
|
||||
cmp ax, 1
|
||||
jne .show_BAR0
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov ax, 0x1F0
|
||||
;--------------------------------------
|
||||
.show_BAR0:
|
||||
DEBUGF 1, 'K : BAR0 IDE base addr %x\n', ax
|
||||
mov [StandardATABases], ax
|
||||
mov [hd_address_table], eax
|
||||
mov [hd_address_table+8], eax
|
||||
mov [IDE_BAR0_val], ax
|
||||
mov [ecx+IDE_DATA.BAR0_val], ax
|
||||
pop eax
|
||||
;-----------------------------------------------------------------------------
|
||||
;--------------------------------------
|
||||
mov bl, 0x14
|
||||
push eax
|
||||
call pci_read_reg
|
||||
and eax, 0xFFFC
|
||||
cmp ax, 0
|
||||
je @f
|
||||
|
||||
cmp ax, 1
|
||||
jne .show_BAR1
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov ax, 0x3F4
|
||||
;--------------------------------------
|
||||
.show_BAR1:
|
||||
DEBUGF 1, 'K : BAR1 IDE base addr %x\n', ax
|
||||
mov [IDE_BAR1_val], ax
|
||||
mov [ecx+IDE_DATA.BAR1_val], ax
|
||||
pop eax
|
||||
;-----------------------------------------------------------------------------
|
||||
;--------------------------------------
|
||||
mov bl, 0x18
|
||||
push eax
|
||||
call pci_read_reg
|
||||
and eax, 0xFFFC
|
||||
cmp ax, 0
|
||||
je @f
|
||||
|
||||
cmp ax, 1
|
||||
jne .show_BAR2
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov ax, 0x170
|
||||
;--------------------------------------
|
||||
.show_BAR2:
|
||||
DEBUGF 1, 'K : BAR2 IDE base addr %x\n', ax
|
||||
mov [StandardATABases+2], ax
|
||||
mov [hd_address_table+16], eax
|
||||
mov [hd_address_table+24], eax
|
||||
mov [IDE_BAR2_val], ax
|
||||
mov [ecx+IDE_DATA.BAR2_val], ax
|
||||
pop eax
|
||||
;-----------------------------------------------------------------------------
|
||||
;--------------------------------------
|
||||
mov bl, 0x1C
|
||||
push eax
|
||||
call pci_read_reg
|
||||
and eax, 0xFFFC
|
||||
cmp ax, 0
|
||||
je @f
|
||||
|
||||
cmp ax, 1
|
||||
jne .show_BAR3
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov ax, 0x374
|
||||
;--------------------------------------
|
||||
.show_BAR3:
|
||||
DEBUGF 1, 'K : BAR3 IDE base addr %x\n', ax
|
||||
mov [IDE_BAR3_val], ax
|
||||
mov [ecx+IDE_DATA.BAR3_val], ax
|
||||
pop eax
|
||||
;-----------------------------------------------------------------------------
|
||||
;--------------------------------------
|
||||
mov bl, 0x20
|
||||
push eax
|
||||
call pci_read_reg
|
||||
and eax, 0xFFFC
|
||||
DEBUGF 1, 'K : BAR4 IDE controller register base addr %x\n', ax
|
||||
mov [IDEContrRegsBaseAddr], ax
|
||||
mov [ecx+IDE_DATA.RegsBaseAddres], ax
|
||||
pop eax
|
||||
;-----------------------------------------------------------------------------
|
||||
;--------------------------------------
|
||||
mov bl, 0x3C
|
||||
push eax
|
||||
call pci_read_reg
|
||||
and eax, 0xFF
|
||||
DEBUGF 1, 'K : IDE Interrupt %x\n', al
|
||||
mov [IDE_Interrupt], ax
|
||||
mov [ecx+IDE_DATA.Interrupt], ax
|
||||
pop eax
|
||||
|
||||
add ecx, sizeof.IDE_DATA
|
||||
;--------------------------------------
|
||||
jmp .loop
|
||||
;-----------------------------------------------------------------------------
|
||||
.done:
|
||||
uglobal
|
||||
align 4
|
||||
;--------------------------------------
|
||||
IDE_controller_pointer dd ?
|
||||
;--------------------------------------
|
||||
IDE_controller_1 IDE_DATA
|
||||
IDE_controller_2 IDE_DATA
|
||||
IDE_controller_3 IDE_DATA
|
||||
;--------------------------------------
|
||||
cache_ide0 IDE_CACHE
|
||||
cache_ide1 IDE_CACHE
|
||||
cache_ide2 IDE_CACHE
|
||||
cache_ide3 IDE_CACHE
|
||||
cache_ide4 IDE_CACHE
|
||||
cache_ide5 IDE_CACHE
|
||||
cache_ide6 IDE_CACHE
|
||||
cache_ide7 IDE_CACHE
|
||||
cache_ide8 IDE_CACHE
|
||||
cache_ide9 IDE_CACHE
|
||||
cache_ide10 IDE_CACHE
|
||||
cache_ide11 IDE_CACHE
|
||||
;--------------------------------------
|
||||
endg
|
||||
;-----------------------------------------------------------------------------
|
||||
; START of initialisation IDE ATA code
|
||||
;-----------------------------------------------------------------------------
|
||||
cmp [IDEContrProgrammingInterface], 0
|
||||
Init_IDE_ATA_controller:
|
||||
cmp [ecx+IDE_DATA.ProgrammingInterface], 0
|
||||
je set_interrupts_for_IDE_controllers.continue
|
||||
|
||||
mov esi, boot_disabling_ide
|
||||
@@ -117,33 +157,25 @@
|
||||
.disable_IDE_interrupt:
|
||||
; Disable interrupts in IDE controller for PIO
|
||||
mov al, 2
|
||||
mov dx, [IDE_BAR1_val] ;0x3F4
|
||||
mov dx, [ecx+IDE_DATA.BAR1_val] ;0x3F4
|
||||
add dx, 2 ;0x3F6
|
||||
out dx, al
|
||||
mov dx, [IDE_BAR3_val] ;0x374
|
||||
mov dx, [ecx+IDE_DATA.BAR3_val] ;0x374
|
||||
add dx, 2 ;0x376
|
||||
out dx, al
|
||||
@@:
|
||||
; show base variables of IDE controller
|
||||
; 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
|
||||
; DEBUGF 1, "K : IDE_Interrupt %x \n", [IDE_Interrupt]:4
|
||||
;-----------------------------------------------------------------------------
|
||||
; set current ata bases
|
||||
@@:
|
||||
mov ax, [ecx+IDE_DATA.BAR0_val]
|
||||
mov [StandardATABases], ax
|
||||
mov ax, [ecx+IDE_DATA.BAR2_val]
|
||||
mov [StandardATABases+2], ax
|
||||
|
||||
mov esi, boot_detecthdcd
|
||||
call boot_log
|
||||
include 'dev_hdcd.inc'
|
||||
mov esi, boot_getcache
|
||||
call boot_log
|
||||
include 'getcache.inc'
|
||||
mov esi, boot_detectpart
|
||||
call boot_log
|
||||
include 'sear_par.inc'
|
||||
;-----------------------------------------------------------------------------
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
|
||||
; test whether it is our interrupt?
|
||||
add dx, 2
|
||||
in al, dx
|
||||
@@ -152,6 +184,7 @@ include 'sear_par.inc'
|
||||
; clear Bus Master IDE Status register
|
||||
; clear Interrupt bit
|
||||
out dx, al
|
||||
;--------------------------------------
|
||||
@@:
|
||||
add dx, 8
|
||||
; test whether it is our interrupt?
|
||||
@@ -161,17 +194,18 @@ include 'sear_par.inc'
|
||||
; clear Bus Master IDE Status register
|
||||
; clear Interrupt bit
|
||||
out dx, al
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; read status register and remove the interrupt request
|
||||
mov dx, [IDE_BAR0_val] ;0x1F0
|
||||
mov dx, [ecx+IDE_DATA.BAR0_val] ;0x1F0
|
||||
add dx, 0x7 ;0x1F7
|
||||
in al, dx
|
||||
mov dx, [IDE_BAR2_val] ;0x170
|
||||
mov dx, [ecx+IDE_DATA.BAR2_val] ;0x170
|
||||
add dx, 0x7 ;0x177
|
||||
in al, dx
|
||||
;-----------------------------------------------------------------------------
|
||||
push eax edx
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
|
||||
xor eax, eax
|
||||
add dx, 2
|
||||
in al, dx
|
||||
@@ -182,15 +216,15 @@ include 'sear_par.inc'
|
||||
DEBUGF 1, "K : Secondary Bus Master IDE Status Register %x\n", eax
|
||||
pop edx eax
|
||||
|
||||
cmp [IDEContrRegsBaseAddr], 0
|
||||
setnz [dma_hdd]
|
||||
cmp [ecx+IDE_DATA.RegsBaseAddres], 0
|
||||
setnz [ecx+IDE_DATA.dma_hdd]
|
||||
;-----------------------------------------------------------------------------
|
||||
; set interrupts for IDE Controller
|
||||
;-----------------------------------------------------------------------------
|
||||
mov esi, boot_set_int_IDE
|
||||
call boot_log
|
||||
set_interrupts_for_IDE_controllers:
|
||||
mov eax, [IDEContrProgrammingInterface]
|
||||
mov eax, [ecx+IDE_DATA.ProgrammingInterface]
|
||||
cmp ax, 0x0180
|
||||
je .pata_ide
|
||||
|
||||
@@ -198,13 +232,16 @@ set_interrupts_for_IDE_controllers:
|
||||
jne .sata_ide
|
||||
;--------------------------------------
|
||||
.pata_ide:
|
||||
cmp [IDEContrRegsBaseAddr], 0
|
||||
cmp [ecx+IDE_DATA.RegsBaseAddres], 0
|
||||
je .end_set_interrupts
|
||||
|
||||
push ecx
|
||||
stdcall attach_int_handler, 14, IDE_irq_14_handler, 0
|
||||
DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax
|
||||
stdcall attach_int_handler, 15, IDE_irq_15_handler, 0
|
||||
DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax
|
||||
pop ecx
|
||||
|
||||
jmp .enable_IDE_interrupt
|
||||
;--------------------------------------
|
||||
.sata_ide:
|
||||
@@ -215,53 +252,93 @@ set_interrupts_for_IDE_controllers:
|
||||
jne .end_set_interrupts
|
||||
;--------------------------------------
|
||||
.sata_ide_1:
|
||||
cmp [IDEContrRegsBaseAddr], 0
|
||||
cmp [ecx+IDE_DATA.RegsBaseAddres], 0
|
||||
je .end_set_interrupts
|
||||
|
||||
mov ax, [IDE_Interrupt]
|
||||
mov ax, [ecx+IDE_DATA.Interrupt]
|
||||
movzx eax, al
|
||||
push ecx
|
||||
stdcall attach_int_handler, eax, IDE_common_irq_handler, 0
|
||||
DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:1, eax
|
||||
pop ecx
|
||||
DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [ecx+IDE_DATA.Interrupt]:1, eax
|
||||
;--------------------------------------
|
||||
.enable_IDE_interrupt:
|
||||
mov esi, boot_enabling_ide
|
||||
call boot_log
|
||||
; Enable interrupts in IDE controller for DMA
|
||||
xor ebx, ebx
|
||||
cmp ecx, IDE_controller_2
|
||||
jne @f
|
||||
|
||||
add ebx, 5
|
||||
jmp .check_DRIVE_DATA
|
||||
;--------------------------------------
|
||||
@@:
|
||||
cmp ecx, IDE_controller_3
|
||||
jne .check_DRIVE_DATA
|
||||
|
||||
add ebx, 10
|
||||
;--------------------------------------
|
||||
.check_DRIVE_DATA:
|
||||
mov al, 0
|
||||
mov ah, [DRIVE_DATA+1]
|
||||
mov ah, [ebx+DRIVE_DATA+1]
|
||||
test ah, 10100000b
|
||||
jz @f
|
||||
|
||||
DEBUGF 1, "K : IDE CH1 PIO, because ATAPI drive present\n"
|
||||
jmp .ch2_check
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov dx, [IDE_BAR1_val] ;0x3F4
|
||||
mov dx, [ecx+IDE_DATA.BAR1_val] ;0x3F4
|
||||
add dx, 2 ;0x3F6
|
||||
out dx, al
|
||||
DEBUGF 1, "K : IDE CH1 DMA enabled\n"
|
||||
;--------------------------------------
|
||||
.ch2_check:
|
||||
test ah, 1010b
|
||||
jz @f
|
||||
|
||||
DEBUGF 1, "K : IDE CH2 PIO, because ATAPI drive present\n"
|
||||
jmp .end_set_interrupts
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov dx, [IDE_BAR3_val] ;0x374
|
||||
mov dx, [ecx+IDE_DATA.BAR3_val] ;0x374
|
||||
add dx, 2 ;0x376
|
||||
out dx, al
|
||||
DEBUGF 1, "K : IDE CH2 DMA enabled\n"
|
||||
;--------------------------------------
|
||||
.end_set_interrupts:
|
||||
;-----------------------------------------------------------------------------
|
||||
cmp [dma_hdd], 0
|
||||
cmp [ecx+IDE_DATA.dma_hdd], 0
|
||||
je .print_pio
|
||||
;--------------------------------------
|
||||
.print_dma:
|
||||
DEBUGF 1, "K : IDE DMA mode\n"
|
||||
jmp .continue
|
||||
|
||||
;--------------------------------------
|
||||
.print_pio:
|
||||
DEBUGF 1, "K : IDE PIO mode\n"
|
||||
.continue:
|
||||
ret
|
||||
;-----------------------------------------------------------------------------
|
||||
; END of initialisation IDE ATA code
|
||||
;-----------------------------------------------------------------------------
|
||||
find_IDE_controller_done:
|
||||
mov ecx, IDE_controller_1
|
||||
mov [IDE_controller_pointer], ecx
|
||||
call Init_IDE_ATA_controller
|
||||
mov ecx, IDE_controller_2
|
||||
mov [IDE_controller_pointer], ecx
|
||||
call Init_IDE_ATA_controller
|
||||
mov ecx, IDE_controller_3
|
||||
mov [IDE_controller_pointer], ecx
|
||||
call Init_IDE_ATA_controller
|
||||
;-----------------------------------------------------------------------------
|
||||
mov esi, boot_getcache
|
||||
call boot_log
|
||||
include 'getcache.inc'
|
||||
;-----------------------------------------------------------------------------
|
||||
mov esi, boot_detectpart
|
||||
call boot_log
|
||||
include 'sear_par.inc'
|
||||
;-----------------------------------------------------------------------------
|
||||
|
@@ -8,63 +8,203 @@
|
||||
$Revision$
|
||||
|
||||
search_partitions:
|
||||
push ecx
|
||||
; 1. Fill missing parameters in HD_DATA structures.
|
||||
mov eax, [hd_address_table]
|
||||
mov [hd0_data.hdbase], eax ;0x1f0
|
||||
xor eax, eax
|
||||
mov edx, IDE_controller_1
|
||||
mov ax, [edx + IDE_DATA.BAR0_val]
|
||||
mov [hd0_data.hdbase], eax
|
||||
mov [hd1_data.hdbase], eax
|
||||
mov eax, [hd_address_table+16]
|
||||
mov ax, [edx + IDE_DATA.BAR2_val]
|
||||
mov [hd2_data.hdbase], eax
|
||||
mov [hd3_data.hdbase], eax
|
||||
|
||||
mov edx, IDE_controller_2
|
||||
mov ax, [edx + IDE_DATA.BAR0_val]
|
||||
mov [hd4_data.hdbase], eax
|
||||
mov [hd5_data.hdbase], eax
|
||||
mov ax, [edx + IDE_DATA.BAR2_val]
|
||||
mov [hd6_data.hdbase], eax
|
||||
mov [hd7_data.hdbase], eax
|
||||
|
||||
mov edx, IDE_controller_3
|
||||
mov ax, [edx + IDE_DATA.BAR0_val]
|
||||
mov [hd8_data.hdbase], eax
|
||||
mov [hd9_data.hdbase], eax
|
||||
mov ax, [edx + IDE_DATA.BAR2_val]
|
||||
mov [hd10_data.hdbase], eax
|
||||
mov [hd11_data.hdbase], eax
|
||||
; 2. Notify the system about /hd* disks.
|
||||
; For every existing disk, call ide_disk_add with correct parameters.
|
||||
; Generate name "hdN" on the stack; this is 4 bytes including terminating zero.
|
||||
;-----------------------------------------------------------------------------
|
||||
; 2a. /hd0: exists if mask 0x40 in [DRIVE_DATA+1] is set,
|
||||
; data: hd0_data,
|
||||
; number of partitions: [DRIVE_DATA+2]
|
||||
test [DRIVE_DATA+1], byte 0x40
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD0\n"
|
||||
push 'hd0'
|
||||
mov eax, esp ; name
|
||||
mov edx, hd0_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+2], al
|
||||
pop ecx ; restore the stack
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 2b. /hd1: exists if mask 0x10 in [DRIVE_DATA+1] is set,
|
||||
; data: hd1_data,
|
||||
; number of partitions: [DRIVE_DATA+3]
|
||||
test [DRIVE_DATA+1], byte 0x10
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD1\n"
|
||||
push 'hd1'
|
||||
mov eax, esp
|
||||
mov edx, hd1_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+3], al
|
||||
pop ecx
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 2c. /hd2: exists if mask 4 in [DRIVE_DATA+1] is set,
|
||||
; data: hd2_data,
|
||||
; number of partitions: [DRIVE_DATA+4]
|
||||
test [DRIVE_DATA+1], byte 4
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD2\n"
|
||||
push 'hd2'
|
||||
mov eax, esp
|
||||
mov edx, hd2_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+4], al
|
||||
pop ecx
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 2d. /hd3: exists if mask 1 in [DRIVE_DATA+1] is set,
|
||||
; data: hd3_data,
|
||||
; number of partitions: [DRIVE_DATA+5]
|
||||
test [DRIVE_DATA+1], byte 1
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD3\n"
|
||||
push 'hd3'
|
||||
mov eax, esp
|
||||
mov edx, hd3_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+5], al
|
||||
pop ecx
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 2e. /hd4: exists if mask 0x40 in [DRIVE_DATA+6] is set,
|
||||
; data: hd4_data,
|
||||
; number of partitions: [DRIVE_DATA+7]
|
||||
test [DRIVE_DATA+6], byte 0x40
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD4\n"
|
||||
push 'hd4'
|
||||
mov eax, esp ; name
|
||||
mov edx, hd4_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+7], al
|
||||
pop ecx
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 2f. /hd5: exists if mask 0x10 in [DRIVE_DATA+6] is set,
|
||||
; data: hd5_data,
|
||||
; number of partitions: [DRIVE_DATA+8]
|
||||
test [DRIVE_DATA+6], byte 0x10
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD5\n"
|
||||
push 'hd5'
|
||||
mov eax, esp
|
||||
mov edx, hd5_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+8], al
|
||||
pop ecx
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 2g. /hd6: exists if mask 4 in [DRIVE_DATA+6] is set,
|
||||
; data: hd6_data,
|
||||
; number of partitions: [DRIVE_DATA+9]
|
||||
test [DRIVE_DATA+6], byte 4
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD6\n"
|
||||
push 'hd6'
|
||||
mov eax, esp
|
||||
mov edx, hd6_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+9], al
|
||||
pop ecx
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 2h. /hd7: exists if mask 1 in [DRIVE_DATA+6] is set,
|
||||
; data: hd7_data,
|
||||
; number of partitions: [DRIVE_DATA+10]
|
||||
test [DRIVE_DATA+6], byte 1
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD7\n"
|
||||
push 'hd7'
|
||||
mov eax, esp
|
||||
mov edx, hd7_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+10], al
|
||||
pop ecx
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 2i. /hd8: exists if mask 0x40 in [DRIVE_DATA+11] is set,
|
||||
; data: hd8_data,
|
||||
; number of partitions: [DRIVE_DATA+12]
|
||||
test [DRIVE_DATA+11], byte 0x40
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD8\n"
|
||||
push 'hd8'
|
||||
mov eax, esp ; name
|
||||
mov edx, hd8_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+12], al
|
||||
pop ecx
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 2j. /hd9: exists if mask 0x10 in [DRIVE_DATA+11] is set,
|
||||
; data: hd9_data,
|
||||
; number of partitions: [DRIVE_DATA+13]
|
||||
test [DRIVE_DATA+11], byte 0x10
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD9\n"
|
||||
push 'hd9'
|
||||
mov eax, esp
|
||||
mov edx, hd9_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+13], al
|
||||
pop ecx
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 2k. /hd10: exists if mask 4 in [DRIVE_DATA+11] is set,
|
||||
; data: hd10_data,
|
||||
; number of partitions: [DRIVE_DATA+14]
|
||||
test [DRIVE_DATA+14], byte 4
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD10\n"
|
||||
push 'hd10'
|
||||
mov eax, esp
|
||||
mov edx, hd10_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+9], al
|
||||
pop ecx
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 2l. /hd11: exists if mask 1 in [DRIVE_DATA+11] is set,
|
||||
; data: hd11_data,
|
||||
; number of partitions: [DRIVE_DATA+15]
|
||||
test [DRIVE_DATA+11], byte 1
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD11\n"
|
||||
push 'hd11'
|
||||
mov eax, esp
|
||||
mov edx, hd11_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+15], al
|
||||
pop ecx
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 3. Notify the system about /bd* disks.
|
||||
; 3a. Check whether there are BIOS disks. If no, skip step 3.
|
||||
@@ -114,11 +254,12 @@ endg
|
||||
jnz .bdloop
|
||||
pop ecx ecx ; restore stack after name
|
||||
.nobd:
|
||||
DEBUGF 1, "K : jmp end_search_partitions\n"
|
||||
jmp end_search_partitions
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; Helper procedure for search_partitions, adds one IDE disk.
|
||||
; For compatibility, number of partitions for IDE disks is kept in a separate variable,
|
||||
; so the procedure returns number of partitions.
|
||||
; For compatibility, number of partitions for IDE disks is kept in a separate
|
||||
; variable, so the procedure returns number of partitions.
|
||||
; eax -> name, edx -> disk data
|
||||
proc ide_disk_add
|
||||
stdcall disk_add, ide_callbacks, eax, edx, 0
|
||||
@@ -134,6 +275,6 @@ proc ide_disk_add
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
end_search_partitions:
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
end_search_partitions:
|
||||
pop ecx
|
||||
|
Reference in New Issue
Block a user