forked from KolibriOS/kolibrios
LAPIC timer interrupt test
git-svn-id: svn://kolibrios.org@3531 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
4d079770dc
commit
55496cc735
@ -157,20 +157,20 @@ fusion_pcie_init:
|
||||
.pcie_cfg_mapped:
|
||||
|
||||
create_mmio_pte:
|
||||
mov ecx, mmio_pte ; physical address
|
||||
or ecx, (PG_NOCACHE + PG_SHARED)
|
||||
mov ecx, mmio_pte ; physical address
|
||||
or ecx, (PG_NOCACHE + PG_SHARED + PG_SW)
|
||||
mov ebx, FUSION_MMIO ; linear address
|
||||
shr ebx, 20
|
||||
add ebx, (sys_pgdir - OS_BASE) ; PgDir entry @
|
||||
mov dword[ebx], ecx ; Fusion MMIO tables
|
||||
mov dword[ebx], ecx ; Fusion MMIO tables
|
||||
|
||||
; ---- short page mapping ----
|
||||
.map_apic_mmio:
|
||||
mov ecx, 0x01B ; APIC BAR
|
||||
rdmsr
|
||||
and eax, 0xFFFFF000 ; physical address
|
||||
or eax, (PG_NOCACHE + PG_SHARED)
|
||||
mov dword[mmio_pte + 0], eax
|
||||
mov ecx, 0x01B ; APIC BAR
|
||||
rdmsr
|
||||
and eax, 0xFFFFF000 ; physical address
|
||||
or eax, (PG_NOCACHE + PG_SHARED + PG_SW)
|
||||
mov dword[mmio_pte + 0], eax
|
||||
|
||||
ret ; <<< OK >>>
|
||||
|
||||
@ -298,4 +298,26 @@ sys_rdmsr:
|
||||
pop edx ecx
|
||||
ret
|
||||
|
||||
apic_timer_reset:
|
||||
xor eax, eax
|
||||
mov [apic_data+0], eax
|
||||
mov ebx, LAPIC_BAR+ 0x320
|
||||
mov eax, [ebx]
|
||||
and eax, 0xFFFEFF00
|
||||
or eax, 0x0000003F ; int vector + norestart
|
||||
mov [ebx], eax
|
||||
mov dword[apic_data + 8], 100000000
|
||||
ret
|
||||
|
||||
|
||||
apic_timer_int:
|
||||
push eax
|
||||
inc dword [apic_data + 0]
|
||||
mov eax, [apic_data + 8]
|
||||
mov dword [LAPIC_BAR + 0x380], eax ; load APICTIC
|
||||
mov dword [LAPIC_BAR + 0x0B0], 0 ; end of interrupt
|
||||
; mov dword [LAPIC_BAR + 0x420], 0x3F ; end of interrupt
|
||||
pop eax
|
||||
iretd
|
||||
|
||||
|
||||
|
@ -273,7 +273,8 @@ FONT_I equ (OS_BASE+0x005E600)
|
||||
|
||||
TMP_STACK_TOP equ 0x006C000
|
||||
|
||||
mmio_pte equ 0x006E000
|
||||
apic_data equ (OS_BASE+0x006D000)
|
||||
mmio_pte equ 0x006E000
|
||||
sys_pgdir equ (OS_BASE+0x006F000)
|
||||
|
||||
DRIVE_DATA equ (OS_BASE+0x0070000)
|
||||
@ -281,7 +282,7 @@ DRIVE_DATA equ (OS_BASE+0x0070000)
|
||||
SLOT_BASE equ (OS_BASE+0x0080000)
|
||||
|
||||
|
||||
;VGABasePtr equ (OS_BASE+0x00A0000)
|
||||
;VGABasePtr equ (OS_BASE+0x00A0000)
|
||||
|
||||
RAMDISK equ (OS_BASE+0x0100000)
|
||||
RAMDISK_FAT equ (OS_BASE+0x0280000)
|
||||
@ -321,8 +322,8 @@ HEAP_MIN_SIZE equ 0x02000000
|
||||
PCIe_CONFIG_SPACE equ 0xF0000000
|
||||
USER_DMA_BUFFER equ 0xFD000000 ; linear addr.
|
||||
USER_DMA_SIZE equ 0x00800000
|
||||
FUSION_MMIO equ 0xFD800000
|
||||
LAPIC_BAR equ 0xFD800000 ; ==
|
||||
FUSION_MMIO equ 0xFD800000
|
||||
LAPIC_BAR equ 0xFD800000 ; ==
|
||||
|
||||
page_tabs equ 0xFDC00000
|
||||
app_page_tabs equ 0xFDC00000
|
||||
@ -370,18 +371,18 @@ PG_SHARED equ 0x200
|
||||
;;;;;;;;;;;boot time variables
|
||||
|
||||
;BOOT_BPP equ 0x9000 ;byte bits per pixel
|
||||
;BOOT_SCANLINE equ 0x9001 ;word scanline length
|
||||
;BOOT_VESA_MODE equ 0x9008 ;word vesa video mode
|
||||
;BOOT_SCANLINE equ 0x9001 ;word scanline length
|
||||
;BOOT_VESA_MODE equ 0x9008 ;word vesa video mode
|
||||
;;BOOT_X_RES equ 0x900A ;word X res
|
||||
;;BOOT_Y_RES equ 0x900C ;word Y res
|
||||
;;BOOT_MOUSE_PORT equ 0x9010 ;byte mouse port - not used
|
||||
;BOOT_BANK_SW equ 0x9014 ;dword Vesa 1.2 pm bank switch
|
||||
;BOOT_BANK_SW equ 0x9014 ;dword Vesa 1.2 pm bank switch
|
||||
BOOT_LFB equ 0x9018 ;dword Vesa 2.0 LFB address
|
||||
BOOT_MTRR equ 0x901C ;byte 0 or 1 : enable MTRR graphics acceleration
|
||||
BOOT_LOG equ 0x901D ;byte not used anymore (0 or 1 : enable system log display)
|
||||
BOOT_DIRECT_LFB equ 0x901E ;byte 0 or 1 : enable direct lfb write, paging disabled
|
||||
BOOT_PCI_DATA equ 0x9020 ;8bytes pci data
|
||||
;BOOT_VRR equ 0x9030 ;byte VRR start enabled 1, 2-no
|
||||
;BOOT_VRR equ 0x9030 ;byte VRR start enabled 1, 2-no
|
||||
BOOT_IDE_BASE_ADDR equ 0x9031 ;word IDEContrRegsBaseAddr
|
||||
BOOT_MEM_AMOUNT equ 0x9034 ;dword memory amount
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,50 +18,62 @@ $Revision$
|
||||
;* ПОИСК HDD и CD *
|
||||
;****************************************************
|
||||
FindHDD:
|
||||
mov [ChannelNumber],1
|
||||
mov [DiskNumber],0
|
||||
call FindHDD_3
|
||||
mov [DiskNumber],1
|
||||
call FindHDD_3
|
||||
inc [ChannelNumber]
|
||||
mov [DiskNumber],0
|
||||
call FindHDD_3
|
||||
mov [DiskNumber],1
|
||||
call FindHDD_1
|
||||
mov [ChannelNumber],1
|
||||
mov [DiskNumber],0
|
||||
call FindHDD_3
|
||||
; mov ax,[Sector512+176]
|
||||
; mov [DRIVE_DATA+6],ax
|
||||
; mov ax,[Sector512+126]
|
||||
; mov [DRIVE_DATA+8],ax
|
||||
; mov ax,[Sector512+128]
|
||||
; mov [DRIVE_DATA+8],ax
|
||||
mov [DiskNumber],1
|
||||
call FindHDD_3
|
||||
; mov al,[Sector512+176]
|
||||
; mov [DRIVE_DATA+7],al
|
||||
inc [ChannelNumber]
|
||||
mov [DiskNumber],0
|
||||
call FindHDD_3
|
||||
; mov al,[Sector512+176]
|
||||
; mov [DRIVE_DATA+8],al
|
||||
mov [DiskNumber],1
|
||||
call FindHDD_1
|
||||
; mov al,[Sector512+176]
|
||||
; mov [DRIVE_DATA+9],al
|
||||
|
||||
jmp EndFindHDD
|
||||
jmp EndFindHDD
|
||||
|
||||
FindHDD_1:
|
||||
call ReadHDD_ID
|
||||
cmp [DevErrorCode],0
|
||||
jne FindHDD_2
|
||||
cmp [Sector512+6],word 16
|
||||
ja FindHDD_2
|
||||
cmp [Sector512+12],word 255
|
||||
ja FindHDD_2
|
||||
inc byte [DRIVE_DATA+1]
|
||||
jmp FindHDD_2_2
|
||||
call ReadHDD_ID
|
||||
cmp [DevErrorCode],0
|
||||
jne FindHDD_2
|
||||
cmp [Sector512+6],word 16
|
||||
ja FindHDD_2
|
||||
cmp [Sector512+12],word 255
|
||||
ja FindHDD_2
|
||||
inc byte [DRIVE_DATA+1]
|
||||
jmp FindHDD_2_2
|
||||
FindHDD_2:
|
||||
call DeviceReset
|
||||
cmp [DevErrorCode],0
|
||||
jne FindHDD_2_2
|
||||
call DeviceReset
|
||||
cmp [DevErrorCode],0
|
||||
;; jne FindHDD_2_2
|
||||
; call ReadCD_ID
|
||||
; cmp [DevErrorCode],0
|
||||
; jne FindHDD_2_2
|
||||
inc byte [DRIVE_DATA+1]
|
||||
inc byte [DRIVE_DATA+1]
|
||||
jne FindHDD_2_2
|
||||
inc byte [DRIVE_DATA+1]
|
||||
inc byte [DRIVE_DATA+1]
|
||||
FindHDD_2_2:
|
||||
ret
|
||||
ret
|
||||
|
||||
FindHDD_3:
|
||||
call FindHDD_1
|
||||
shl byte [DRIVE_DATA+1],2
|
||||
ret
|
||||
call FindHDD_1
|
||||
shl byte [DRIVE_DATA+1],2
|
||||
ret
|
||||
|
||||
|
||||
; Адрес считываемого сектора в режиме LBA
|
||||
uglobal
|
||||
SectorAddress DD ?
|
||||
SectorAddress DD ?
|
||||
endg
|
||||
;*************************************************
|
||||
;* ЧТЕНИЕ ИДЕНТИФИКАТОРА ЖЕСТКОГО ДИСКА *
|
||||
@ -74,43 +86,45 @@ endg
|
||||
;*************************************************
|
||||
ReadHDD_ID:
|
||||
; Задать режим CHS
|
||||
mov [ATAAddressMode],0
|
||||
mov [ATAAddressMode],0
|
||||
; Послать команду идентификации устройства
|
||||
mov [ATAFeatures],0
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0ECh
|
||||
call SendCommandToHDD
|
||||
cmp [DevErrorCode],0 ;ïðîâåðèòü êîä îøèáêè
|
||||
jne @@End ;çàêîí÷èòü, ñîõðàíèâ êîä îøèáêè
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;àäðåñ ðåãèñòðà ñîñòîÿíè
|
||||
mov ecx,0xffff
|
||||
mov [ATAFeatures],0
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0ECh
|
||||
call SendCommandToHDD
|
||||
cmp [DevErrorCode],0 ;ïðîâåðèòü êîä îøèáêè
|
||||
jne @@End ;çàêîí÷èòü, ñîõðàíèâ êîä îøèáêè
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;àäðåñ ðåãèñòðà ñîñòîÿíè
|
||||
mov ecx,0xffff
|
||||
@@WaitCompleet:
|
||||
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
|
||||
dec ecx
|
||||
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
|
||||
dec ecx
|
||||
; cmp ecx,0
|
||||
jz @@Error1 ;îøèáêà òàéì-àóòà
|
||||
; Ïðîâåðèòü ãîòîâíîñòü
|
||||
in AL,DX
|
||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||
jnz @@WaitCompleet
|
||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||
jnz @@Error6
|
||||
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
||||
jz @@WaitCompleet
|
||||
jz @@Error1 ;îøèáêà òàéì-àóòà
|
||||
; Ïðîâåðèòü ãîòîâíîñòü
|
||||
in AL,DX
|
||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||
jnz @@WaitCompleet
|
||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||
jnz @@Error6
|
||||
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
||||
jz @@WaitCompleet
|
||||
; Принять блок данных от контроллера
|
||||
mov EDI,Sector512 ;offset Sector512
|
||||
mov DX,[ATABasePortAddr] ;ðåãèñòð äàííûõ
|
||||
mov CX,256 ;÷èñëî ñ÷èòûâàåìûõ ñëîâ
|
||||
rep insw ;ïðèíÿòü áëîê äàííûõ
|
||||
; mov AX,DS
|
||||
; mov ES,AX
|
||||
mov EDI,Sector512 ;offset Sector512
|
||||
mov DX,[ATABasePortAddr] ;ðåãèñòð äàííûõ
|
||||
mov CX,256 ;÷èñëî ñ÷èòûâàåìûõ ñëîâ
|
||||
rep insw ;ïðèíÿòü áëîê äàííûõ
|
||||
ret
|
||||
; Записать код ошибки
|
||||
@@Error1:
|
||||
mov [DevErrorCode],1
|
||||
mov [DevErrorCode],1
|
||||
ret
|
||||
@@Error6:
|
||||
mov [DevErrorCode],6
|
||||
@@End: ret
|
||||
mov [DevErrorCode],6
|
||||
@@End: ret
|
||||
|
||||
|
||||
iglobal
|
||||
@ -119,19 +133,19 @@ StandardATABases DW 1F0h, 170h
|
||||
endg
|
||||
uglobal
|
||||
; Номер канала
|
||||
ChannelNumber DW ?
|
||||
ChannelNumber DW ?
|
||||
; Номер диска
|
||||
DiskNumber DB ?
|
||||
DiskNumber DB ?
|
||||
; Базовый адрес группы портов контроллера ATA
|
||||
ATABasePortAddr DW ?
|
||||
; Параметры ATA-команды
|
||||
ATAFeatures DB ? ;îñîáåííîñòè
|
||||
ATASectorCount DB ? ;êîëè÷åñòâî îáðàáàòûâàåìûõ ñåêòîðîâ
|
||||
ATAFeatures DB ? ;îñîáåííîñòè
|
||||
ATASectorCount DB ? ;êîëè÷åñòâî îáðàáàòûâàåìûõ ñåêòîðîâ
|
||||
ATASectorNumber DB ? ;номер начального сектора
|
||||
ATACylinder DW ? ;íîìåð íà÷àëüíîãî öèëèíäðà
|
||||
ATAHead DB ? ;íîìåð íà÷àëüíîé ãîëîâêè
|
||||
ATAAddressMode DB ? ;ðåæèì àäðåñàöèè (0 - CHS, 1 - LBA)
|
||||
ATACommand DB ? ;êîä êîìàíäû, ïîäëåæàùåé âûïîëíåíèþ
|
||||
ATACylinder DW ? ;íîìåð íà÷àëüíîãî öèëèíäðà
|
||||
ATAHead DB ? ;íîìåð íà÷àëüíîé ãîëîâêè
|
||||
ATAAddressMode DB ? ;ðåæèì àäðåñàöèè (0 - CHS, 1 - LBA)
|
||||
ATACommand DB ? ;êîä êîìàíäû, ïîäëåæàùåé âûïîëíåíèþ
|
||||
; Код ошибки (0 - нет ошибок, 1 - превышен допустимый
|
||||
; интервал ожидания, 2 - неверный код режима адресации,
|
||||
; 3 - неверный номер канала, 4 - неверный номер диска,
|
||||
@ -160,96 +174,102 @@ endg
|
||||
;****************************************************
|
||||
SendCommandToHDD:
|
||||
; Проверить значение кода режима
|
||||
cmp [ATAAddressMode],1
|
||||
ja @@Err2
|
||||
cmp [ATAAddressMode],1
|
||||
ja @@Err2
|
||||
; Проверить корректность номера канала
|
||||
mov BX,[ChannelNumber]
|
||||
cmp BX,1
|
||||
jb @@Err3
|
||||
cmp BX,2
|
||||
ja @@Err3
|
||||
mov BX,[ChannelNumber]
|
||||
cmp BX,1
|
||||
jb @@Err3
|
||||
cmp BX,2
|
||||
ja @@Err3
|
||||
; Установить базовый адрес
|
||||
dec BX
|
||||
shl BX,1
|
||||
movzx ebx,bx
|
||||
mov AX,[ebx+StandardATABases]
|
||||
mov [ATABasePortAddr],AX
|
||||
dec BX
|
||||
shl BX,1
|
||||
movzx ebx,bx
|
||||
mov AX,[ebx+StandardATABases]
|
||||
mov [ATABasePortAddr],AX
|
||||
; Ожидание готовности HDD к приему команды
|
||||
; Âûáðàòü íóæíûé äèñê
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,6 ;àäðåñ ðåãèñòðà ãîëîâîê
|
||||
mov AL,[DiskNumber]
|
||||
cmp AL,1 ;ïðîâåðèòü íîìåðà äèñêà
|
||||
ja @@Err4
|
||||
shl AL,4
|
||||
or AL,10100000b
|
||||
out DX,AL
|
||||
; Îæèäàòü, ïîêà äèñê íå áóäåò ãîòîâ
|
||||
inc DX
|
||||
mov ecx,0xfff
|
||||
; Âûáðàòü íóæíûé äèñê
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,6 ;àäðåñ ðåãèñòðà ãîëîâîê
|
||||
mov AL,[DiskNumber]
|
||||
cmp AL,1 ;ïðîâåðèòü íîìåðà äèñêà
|
||||
ja @@Err4
|
||||
shl AL,4
|
||||
or AL,10100000b
|
||||
out DX,AL
|
||||
; Îæèäàòü, ïîêà äèñê íå áóäåò ãîòîâ
|
||||
inc DX
|
||||
mov ecx,0xfff
|
||||
; mov eax,[timer_ticks]
|
||||
; mov [TickCounter_1],eax
|
||||
@@WaitHDReady:
|
||||
; Ïðîâåðèòü âðåìÿ îæèäàíè
|
||||
dec ecx
|
||||
jz @@Err1
|
||||
; Ïðî÷èòàòü ðåãèñòð ñîñòîÿíè
|
||||
in AL,DX
|
||||
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà BSY
|
||||
test AL,80h
|
||||
jnz @@WaitHDReady
|
||||
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà DRQ
|
||||
test AL,08h
|
||||
jnz @@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
|
||||
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà BSY
|
||||
test AL,80h
|
||||
jnz @@WaitHDReady
|
||||
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà DRQ
|
||||
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 ;ïðîâåðèòü íîìåð ãîëîâêè
|
||||
ja @@Err5
|
||||
or AL,[ATAHead]
|
||||
or AL,10100000b
|
||||
mov AH,[ATAAddressMode]
|
||||
shl AH,6
|
||||
or AL,AH
|
||||
out DX,AL
|
||||
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 ;ïðîâåðèòü íîìåð ãîëîâêè
|
||||
ja @@Err5
|
||||
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
|
||||
sti
|
||||
mov AL,[ATACommand]
|
||||
inc DX ;ðåãèñòð êîìàíä
|
||||
out DX,AL
|
||||
sti
|
||||
; Сбросить признак ошибки
|
||||
mov [DevErrorCode],0
|
||||
ret
|
||||
mov [DevErrorCode],0
|
||||
ret
|
||||
; Записать код ошибки
|
||||
@@Err1: mov [DevErrorCode],1
|
||||
ret
|
||||
@@Err2: mov [DevErrorCode],2
|
||||
ret
|
||||
@@Err3: mov [DevErrorCode],3
|
||||
ret
|
||||
@@Err4: mov [DevErrorCode],4
|
||||
ret
|
||||
@@Err5: mov [DevErrorCode],5
|
||||
@@Err1: mov [DevErrorCode],1
|
||||
ret
|
||||
@@Err2: mov [DevErrorCode],2
|
||||
ret
|
||||
@@Err3: mov [DevErrorCode],3
|
||||
ret
|
||||
@@Err4: mov [DevErrorCode],4
|
||||
ret
|
||||
@@Err5: mov [DevErrorCode],5
|
||||
; Завершение работы программы
|
||||
ret
|
||||
ret
|
||||
|
||||
if 0
|
||||
;*************************************************
|
||||
;* ЧТЕНИЕ ИДЕНТИФИКАТОРА УСТРОЙСТВА ATAPI *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
@ -261,49 +281,50 @@ if 0
|
||||
;*************************************************
|
||||
ReadCD_ID:
|
||||
; Задать режим CHS
|
||||
mov [ATAAddressMode],0
|
||||
mov [ATAAddressMode],0
|
||||
; Послать команду идентификации устройства
|
||||
mov [ATAFeatures],0
|
||||
mov [ATASectorCount],0
|
||||
mov [ATASectorNumber],0
|
||||
mov [ATACylinder],0
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0A1h
|
||||
call SendCommandToHDD
|
||||
cmp [DevErrorCode],0 ;ïðîâåðèòü êîä îøèáêè
|
||||
jne @@End_1 ;çàêîí÷èòü, ñîõðàíèâ êîä îøèáêè
|
||||
mov [ATAFeatures],0
|
||||
mov [ATASectorCount],0
|
||||
mov [ATASectorNumber],0
|
||||
mov [ATACylinder],0
|
||||
mov [ATAHead],0
|
||||
mov [ATACommand],0A1h
|
||||
call SendCommandToHDD
|
||||
cmp [DevErrorCode],0 ;ïðîâåðèòü êîä îøèáêè
|
||||
jne @@End_1 ;çàêîí÷èòü, ñîõðàíèâ êîä îøèáêè
|
||||
; Ожидать готовность данных HDD
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;ïîðò 1õ7h
|
||||
mov ecx,0xffff
|
||||
mov DX,[ATABasePortAddr]
|
||||
add DX,7 ;ïîðò 1õ7h
|
||||
mov ecx,0xffff
|
||||
@@WaitCompleet_1:
|
||||
; Ïðîâåðèòü âðåì
|
||||
dec ecx
|
||||
jz @@Error1_1 ;îøèáêà òàéì-àóòà
|
||||
; Ïðîâåðèòü ãîòîâíîñòü
|
||||
in AL,DX
|
||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||
jnz @@WaitCompleet_1
|
||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||
jnz @@Error6_1
|
||||
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
||||
jz @@WaitCompleet_1
|
||||
; Ïðîâåðèòü âðåì
|
||||
dec ecx
|
||||
; cmp ecx,0
|
||||
jz @@Error1_1 ;îøèáêà òàéì-àóòà
|
||||
; Ïðîâåðèòü ãîòîâíîñòü
|
||||
in AL,DX
|
||||
test AL,80h ;ñîñòîÿíèå ñèãíàëà BSY
|
||||
jnz @@WaitCompleet_1
|
||||
test AL,1 ;ñîñòîÿíèå ñèãíàëà ERR
|
||||
jnz @@Error6_1
|
||||
test AL,08h ;ñîñòîÿíèå ñèãíàëà DRQ
|
||||
jz @@WaitCompleet_1
|
||||
; Принять блок данных от контроллера
|
||||
mov EDI,Sector512 ;offset Sector512
|
||||
mov DX,[ATABasePortAddr] ;ïîðò 1x0h
|
||||
mov CX,256 ;÷èñëî ñ÷èòûâàåìûõ ñëîâ
|
||||
rep insw
|
||||
ret
|
||||
; mov AX,DS
|
||||
; mov ES,AX
|
||||
mov EDI,Sector512 ;offset Sector512
|
||||
mov DX,[ATABasePortAddr] ;ïîðò 1x0h
|
||||
mov CX,256 ;÷èñëî ñ÷èòûâàåìûõ ñëîâ
|
||||
rep insw
|
||||
ret
|
||||
; Записать код ошибки
|
||||
@@Error1_1:
|
||||
mov [DevErrorCode],1
|
||||
ret
|
||||
mov [DevErrorCode],1
|
||||
ret
|
||||
@@Error6_1:
|
||||
mov [DevErrorCode],6
|
||||
mov [DevErrorCode],6
|
||||
@@End_1:
|
||||
ret
|
||||
|
||||
end if
|
||||
ret
|
||||
|
||||
;*************************************************
|
||||
;* СБРОС УСТРОЙСТВА *
|
||||
@ -314,51 +335,51 @@ end if
|
||||
;*************************************************
|
||||
DeviceReset:
|
||||
; Проверить корректность номера канала
|
||||
mov BX,[ChannelNumber]
|
||||
cmp BX,1
|
||||
jb @@Err3_2
|
||||
cmp BX,2
|
||||
ja @@Err3_2
|
||||
mov BX,[ChannelNumber]
|
||||
cmp BX,1
|
||||
jb @@Err3_2
|
||||
cmp BX,2
|
||||
ja @@Err3_2
|
||||
; Установить базовый адрес
|
||||
dec BX
|
||||
shl BX,1
|
||||
movzx ebx,bx
|
||||
mov DX,[ebx+StandardATABases]
|
||||
mov [ATABasePortAddr],DX
|
||||
dec BX
|
||||
shl BX,1
|
||||
movzx ebx,bx
|
||||
mov DX,[ebx+StandardATABases]
|
||||
mov [ATABasePortAddr],DX
|
||||
; Выбрать нужный диск
|
||||
add DX,6 ;àäðåñ ðåãèñòðà ãîëîâîê
|
||||
mov AL,[DiskNumber]
|
||||
cmp AL,1 ;ïðîâåðèòü íîìåðà äèñêà
|
||||
ja @@Err4_2
|
||||
shl AL,4
|
||||
or AL,10100000b
|
||||
out DX,AL
|
||||
add DX,6 ;àäðåñ ðåãèñòðà ãîëîâîê
|
||||
mov AL,[DiskNumber]
|
||||
cmp AL,1 ;ïðîâåðèòü íîìåðà äèñêà
|
||||
ja @@Err4_2
|
||||
shl AL,4
|
||||
or AL,10100000b
|
||||
out DX,AL
|
||||
; Послать команду "Сброс"
|
||||
mov AL,08h
|
||||
inc DX ;ðåãèñòð êîìàíä
|
||||
out DX,AL
|
||||
mov ecx,0x80000
|
||||
mov AL,08h
|
||||
inc DX ;ðåãèñòð êîìàíä
|
||||
out DX,AL
|
||||
mov ecx,0x80000
|
||||
@@WaitHDReady_1:
|
||||
; Ïðîâåðèòü âðåìÿ îæèäàíè
|
||||
dec ecx
|
||||
; Ïðîâåðèòü âðåìÿ îæèäàíè
|
||||
dec ecx
|
||||
; cmp ecx,0
|
||||
je @@Err1_2 ;îøèáêà òàéì-àóòà
|
||||
; Ïðî÷èòàòü ðåãèñòð ñîñòîÿíè
|
||||
in AL,DX
|
||||
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà BSY
|
||||
test AL,80h
|
||||
jnz @@WaitHDReady_1
|
||||
je @@Err1_2 ;îøèáêà òàéì-àóòà
|
||||
; Ïðî÷èòàòü ðåãèñòð ñîñòîÿíè
|
||||
in AL,DX
|
||||
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà BSY
|
||||
test AL,80h
|
||||
jnz @@WaitHDReady_1
|
||||
; Сбросить признак ошибки
|
||||
mov [DevErrorCode],0
|
||||
ret
|
||||
mov [DevErrorCode],0
|
||||
ret
|
||||
; Обработка ошибок
|
||||
@@Err1_2: mov [DevErrorCode],1
|
||||
ret
|
||||
@@Err3_2: mov [DevErrorCode],3
|
||||
ret
|
||||
@@Err4_2: mov [DevErrorCode],4
|
||||
@@Err1_2: mov [DevErrorCode],1
|
||||
ret
|
||||
@@Err3_2: mov [DevErrorCode],3
|
||||
ret
|
||||
@@Err4_2: mov [DevErrorCode],4
|
||||
; Записать код ошибки
|
||||
ret
|
||||
ret
|
||||
|
||||
EndFindHDD:
|
||||
|
||||
|
@ -501,11 +501,11 @@ high_code:
|
||||
out 0xA1, al
|
||||
|
||||
; Enable interrupts in IDE controller
|
||||
; mov al, 0
|
||||
; mov dx, 0x3F6
|
||||
; out dx, al
|
||||
; mov dl, 0x76
|
||||
; out dx, al
|
||||
; mov al, 0
|
||||
; mov dx, 0x3F6
|
||||
; out dx, al
|
||||
; mov dl, 0x76
|
||||
; out dx, al
|
||||
|
||||
;!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
include 'detect/disks.inc'
|
||||
@ -688,7 +688,7 @@ include 'detect/disks.inc'
|
||||
; STACK AND FDC
|
||||
|
||||
call stack_init
|
||||
; call fdc_init
|
||||
; call fdc_init
|
||||
|
||||
|
||||
; LOAD DEFAULT SKIN
|
||||
@ -712,9 +712,11 @@ include 'detect/disks.inc'
|
||||
; mov esi, boot_uDMA_ok
|
||||
; call boot_log
|
||||
|
||||
call apic_timer_reset
|
||||
|
||||
; LOAD FIRST APPLICATION
|
||||
cli
|
||||
if 0
|
||||
if 0
|
||||
<<<
|
||||
cmp byte [BOOT_VAR+0x9030],1
|
||||
jne no_load_vrr_m
|
||||
@ -1992,7 +1994,7 @@ version_inf:
|
||||
version_end:
|
||||
endg
|
||||
|
||||
sys_cachetodiskette: ; << removed
|
||||
sys_cachetodiskette: ; << removed
|
||||
mov [esp + 32], ebx
|
||||
ret
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user