diff --git a/kernel/branches/Kolibri-A/trunk/bus/HT.inc b/kernel/branches/Kolibri-A/trunk/bus/HT.inc index 610770234e..e9fb8c208a 100644 --- a/kernel/branches/Kolibri-A/trunk/bus/HT.inc +++ b/kernel/branches/Kolibri-A/trunk/bus/HT.inc @@ -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 + diff --git a/kernel/branches/Kolibri-A/trunk/const.inc b/kernel/branches/Kolibri-A/trunk/const.inc index e6b4ec2c54..c7ce881b21 100644 --- a/kernel/branches/Kolibri-A/trunk/const.inc +++ b/kernel/branches/Kolibri-A/trunk/const.inc @@ -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 diff --git a/kernel/branches/Kolibri-A/trunk/core/sys32.inc b/kernel/branches/Kolibri-A/trunk/core/sys32.inc index e2f6c34eae..3eeb704e40 100644 --- a/kernel/branches/Kolibri-A/trunk/core/sys32.inc +++ b/kernel/branches/Kolibri-A/trunk/core/sys32.inc @@ -16,202 +16,203 @@ $Revision$ align 4 ;3A08 build_interrupt_table: - mov edi, idts - mov esi, sys_int - mov ecx, 0x40 - mov eax, (10001110b shl 24) + os_code - @@: movsw ;low word of code-entry - stosd ;interrupt gate type : os_code selector - movsw ;high word of code-entry - loop @b - movsd ;copy low dword of trap gate for int 0x40 - movsd ;copy high dword of trap gate for int 0x40 - lidt [esi] - ret + mov edi, idts + mov esi, sys_int + mov ecx, 0x40 + mov eax, (10001110b shl 24) + os_code + @@: movsw ;low word of code-entry + stosd ;interrupt gate type : os_code selector + movsw ;high word of code-entry + loop @b + movsd ;copy low dword of trap gate for int 0x40 + movsd ;copy high dword of trap gate for int 0x40 + lidt [esi] + ret iglobal align 4 sys_int: ;exception handlers addresses (for interrupt gate construction) - dd e0,e1,e2,e3,e4,e5,e6,except_7 ; SEE: core/fpu.inc - dd e8,e9,e10,e11,e12,e13,page_fault_exc,e15 - dd e16, e17,e18, e19 - times 12 dd unknown_interrupt ;int_20..int_31 + dd e0,e1,e2,e3,e4,e5,e6,except_7 ; SEE: core/fpu.inc + dd e8,e9,e10,e11,e12,e13,page_fault_exc,e15 + dd e16, e17,e18, e19 + times 12 dd unknown_interrupt ;int_20..int_31 ;interrupt handlers addresses (for interrupt gate construction) - dd irq0, irq_serv.irq_1, irq_serv.irq_2 - if USE_COM_IRQ - dd irq_serv.irq_3, irq_serv.irq_4 + dd irq0, irq_serv.irq_1, irq_serv.irq_2 + if USE_COM_IRQ + dd irq_serv.irq_3, irq_serv.irq_4 else - dd p_irq3, p_irq4 ;??? нестыковка + dd p_irq3, p_irq4 ;??? нестыковка end if - dd irq_serv.irq_5, p_irq6, irq_serv.irq_7 - dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 - dd irq_serv.irq_11, irq_serv.irq_12, irqD,p_irq14,p_irq15 - times 16 dd unknown_interrupt ;int_0x30..int_0x3F + dd irq_serv.irq_5, p_irq6, irq_serv.irq_7 + dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 + dd irq_serv.irq_11, irq_serv.irq_12, irqD,p_irq14,p_irq15 + times 15 dd unknown_interrupt ;int_0x30..int_0x3F + dd apic_timer_int ;int_0x40 gate trap (for directly copied) - dw i40 and 0xFFFF, os_code, 11101111b shl 8, i40 shr 16 + dw i40 and 0xFFFF, os_code, 11101111b shl 8, i40 shr 16 idtreg: ; data for LIDT instruction (!!! must be immediately below sys_int data) - dw 2*($-sys_int-4)-1 - dd idts ;0x8000B100 - dw 0 ;просто выравнивание + dw 2*($-sys_int-4)-1 + dd idts ;0x8000B100 + dw 0 ;просто выравнивание msg_fault_sel dd msg_exc_8,msg_exc_u,msg_exc_a,msg_exc_b - dd msg_exc_c,msg_exc_d,msg_exc_e + dd msg_exc_c,msg_exc_d,msg_exc_e - msg_exc_8 db "Double fault", 0 - msg_exc_u db "Undefined Exception", 0 - msg_exc_a db "Invalid TSS", 0 - msg_exc_b db "Segment not present", 0 - msg_exc_c db "Stack fault", 0 - msg_exc_d db "General protection fault", 0 - msg_exc_e db "Page fault", 0 + msg_exc_8 db "Double fault", 0 + msg_exc_u db "Undefined Exception", 0 + msg_exc_a db "Invalid TSS", 0 + msg_exc_b db "Segment not present", 0 + msg_exc_c db "Stack fault", 0 + msg_exc_d db "General protection fault", 0 + msg_exc_e db "Page fault", 0 - msg_sel_ker db "kernel", 0 - msg_sel_app db "application", 0 + msg_sel_ker db "kernel", 0 + msg_sel_app db "application", 0 endg macro save_ring3_context { - pushad + pushad } macro restore_ring3_context { - popad + popad } macro exc_wo_code [num] { e#num : - save_ring3_context - mov bl, num - jmp exc_c -} exc_wo_code 0,1,2,3,4,5,6,15,16,19 + save_ring3_context + mov bl, num + jmp exc_c +} exc_wo_code 0,1,2,3,4,5,6,15,16,19 macro exc_w_code [num] { e#num : - add esp, 4 - save_ring3_context - mov bl, num - jmp exc_c -} exc_w_code 8,9,10,11,12,13,17,18 + add esp, 4 + save_ring3_context + mov bl, num + jmp exc_c +} exc_w_code 8,9,10,11,12,13,17,18 uglobal - pf_err_code dd ? + pf_err_code dd ? endg -page_fault_exc: ; fool-proofing: if selectors damaged... - pop [ss:pf_err_code]; active to the next #PF - save_ring3_context - mov bl,14 +page_fault_exc: ; fool-proofing: if selectors damaged... + pop [ss:pf_err_code]; active to the next #PF + save_ring3_context + mov bl,14 -exc_c: ; exceptions (all but the 7th - #NM) +exc_c: ; exceptions (all but the 7th - #NM) ; the stack frame for an exception/interrupt occured in Ring3 + pushad (i.e. here) - reg_ss equ esp+0x30 - reg_esp3 equ esp+0x2C - reg_eflags equ esp+0x28 - reg_cs3 equ esp+0x24 - reg_eip equ esp+0x20 + reg_ss equ esp+0x30 + reg_esp3 equ esp+0x2C + reg_eflags equ esp+0x28 + reg_cs3 equ esp+0x24 + reg_eip equ esp+0x20 ; pushad's frame - reg_eax equ esp+0x1C - reg_ecx equ esp+0x18 - reg_edx equ esp+0x14 - reg_ebx equ esp+0x10 - reg_esp0 equ esp+0x0C - reg_ebp equ esp+0x08 - reg_esi equ esp+0x04 - reg_edi equ esp+0x00 + reg_eax equ esp+0x1C + reg_ecx equ esp+0x18 + reg_edx equ esp+0x14 + reg_ebx equ esp+0x10 + reg_esp0 equ esp+0x0C + reg_ebp equ esp+0x08 + reg_esi equ esp+0x04 + reg_edi equ esp+0x00 - Mov ds,ax,app_data ; load the correct values - mov es,ax ; to segregs - cld ; and clear DF - movzx ebx,bl + Mov ds,ax,app_data ; load the correct values + mov es,ax ; to segregs + cld ; and clear DF + movzx ebx,bl ; redirect to V86 manager? (EFLAGS & 0x20000) != 0? - test byte[reg_eflags+2],2 - jnz v86_exc_c - cmp bl,14 ; #PF - jne @f - call page_fault_handler ; SEE: core/memory.inc - @@: mov esi, [current_slot] - btr [esi+APPDATA.except_mask], ebx - jnc @f - mov eax,[esi+APPDATA.exc_handler] - test eax, eax - jnz IRetToUserHook - @@: cli - mov eax, [esi+APPDATA.debugger_slot] - test eax, eax - jnz .debug - sti + test byte[reg_eflags+2],2 + jnz v86_exc_c + cmp bl,14 ; #PF + jne @f + call page_fault_handler ; SEE: core/memory.inc + @@: mov esi, [current_slot] + btr [esi+APPDATA.except_mask], ebx + jnc @f + mov eax,[esi+APPDATA.exc_handler] + test eax, eax + jnz IRetToUserHook + @@: cli + mov eax, [esi+APPDATA.debugger_slot] + test eax, eax + jnz .debug + sti ; not debuggee => say error and terminate - call show_error_parameters ;; only ONE using, inline ??? + call show_error_parameters ;; only ONE using, inline ??? ;mov edx, [TASK_BASE] - mov [edx + TASKDATA.state], byte 4 ; terminate - jmp change_task ; stack - here it does not matter at all, SEE: core/shed.inc + mov [edx + TASKDATA.state], byte 4 ; terminate + jmp change_task ; stack - here it does not matter at all, SEE: core/shed.inc .debug: ; we are debugged process, notify debugger and suspend ourself ; eax=debugger PID - mov ecx,1 ; debug_message code=other_exception - cmp bl,1 ; #DB - jne .notify ; notify debugger and suspend ourself - mov ebx, dr6 ; debug_message data=DR6_image - xor edx, edx - mov dr6, edx - mov edx, dr7 - mov cl, not 8 - .l1: shl dl,2 - jc @f - and bl, cl - @@: sar cl,1 - jc .l1 - mov cl, 3 ; debug_message code=debug_exception + mov ecx,1 ; debug_message code=other_exception + cmp bl,1 ; #DB + jne .notify ; notify debugger and suspend ourself + mov ebx, dr6 ; debug_message data=DR6_image + xor edx, edx + mov dr6, edx + mov edx, dr7 + mov cl, not 8 + .l1: shl dl,2 + jc @f + and bl, cl + @@: sar cl,1 + jc .l1 + mov cl, 3 ; debug_message code=debug_exception .notify: - push ebx ; debug_message data - mov ebx, [TASK_BASE] - push [ebx+TASKDATA.pid] ; PID - push ecx ; debug_message code ((here: ecx==1/3)) - mov cl, 12 ; debug_message size - call debugger_notify ;; only ONE using, inline ??? SEE: core/debug.inc - add esp,12 - mov edx, [TASK_BASE] - mov byte [edx+TASKDATA.state], 1 ; suspended - call change_task ; SEE: core/shed.inc - restore_ring3_context - iretd + push ebx ; debug_message data + mov ebx, [TASK_BASE] + push [ebx+TASKDATA.pid] ; PID + push ecx ; debug_message code ((here: ecx==1/3)) + mov cl, 12 ; debug_message size + call debugger_notify ;; only ONE using, inline ??? SEE: core/debug.inc + add esp,12 + mov edx, [TASK_BASE] + mov byte [edx+TASKDATA.state], 1 ; suspended + call change_task ; SEE: core/shed.inc + restore_ring3_context + iretd IRetToUserHook: - xchg eax, [reg_eip] - sub dword[reg_esp3], 8 - mov edi, [reg_esp3] - stosd - mov [edi], ebx - restore_ring3_context + xchg eax, [reg_eip] + sub dword[reg_esp3], 8 + mov edi, [reg_esp3] + stosd + mov [edi], ebx + restore_ring3_context unknown_interrupt: - iretd + iretd ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= show_error_parameters: - mov edx,[TASK_BASE] ;not scratched below - DEBUGF 1, "K : Process - forced terminate PID: %x\n", [edx+TASKDATA.pid] - cmp bl, 0x08 - jb .l0 - cmp bl, 0x0e - jbe .l1 - .l0: mov bl, 0x09 - .l1: mov eax,[msg_fault_sel+ebx*4 - 0x08*4] - DEBUGF 1, "K : %s\n", eax - mov eax, [reg_cs3+4] - mov edi, msg_sel_app - mov ebx, [reg_esp3+4] - cmp eax, app_code - je @f - mov edi, msg_sel_ker - mov ebx, [reg_esp0+4] - @@: DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [reg_eax+4], [reg_ebx+4], [reg_ecx+4] - DEBUGF 1, "K : EDX : %x ESI : %x EDI : %x\n", [reg_edx+4], [reg_esi+4], [reg_edi+4] - DEBUGF 1, "K : EBP : %x EIP : %x ESP : %x\n", [reg_ebp+4], [reg_eip+4], ebx - DEBUGF 1, "K : Flags : %x CS : %x (%s)\n", [reg_eflags+4], eax, edi - ret + mov edx,[TASK_BASE] ;not scratched below + DEBUGF 1, "K : Process - forced terminate PID: %x\n", [edx+TASKDATA.pid] + cmp bl, 0x08 + jb .l0 + cmp bl, 0x0e + jbe .l1 + .l0: mov bl, 0x09 + .l1: mov eax,[msg_fault_sel+ebx*4 - 0x08*4] + DEBUGF 1, "K : %s\n", eax + mov eax, [reg_cs3+4] + mov edi, msg_sel_app + mov ebx, [reg_esp3+4] + cmp eax, app_code + je @f + mov edi, msg_sel_ker + mov ebx, [reg_esp0+4] + @@: DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [reg_eax+4], [reg_ebx+4], [reg_ecx+4] + DEBUGF 1, "K : EDX : %x ESI : %x EDI : %x\n", [reg_edx+4], [reg_esi+4], [reg_edi+4] + DEBUGF 1, "K : EBP : %x EIP : %x ESP : %x\n", [reg_ebp+4], [reg_eip+4], ebx + DEBUGF 1, "K : Flags : %x CS : %x (%s)\n", [reg_eflags+4], eax, edi + ret ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= restore reg_ss @@ -231,87 +232,87 @@ show_error_parameters: ; irq1 -> hid/keyboard.inc macro irqh [num] { p_irq#num : - mov edi, num - jmp irqhandler + mov edi, num + jmp irqhandler } p_irq6: - save_ring3_context - mov ax, app_data ;os_data - mov ds, ax - mov es, ax - mov edi, 6 - cmp [v86_irqhooks+edi*8], 0 - jnz v86_irq2 + save_ring3_context + mov ax, app_data ;os_data + mov ds, ax + mov es, ax + mov edi, 6 + cmp [v86_irqhooks+edi*8], 0 + jnz v86_irq2 ; call fdc_irq - call ready_for_next_irq - restore_ring3_context - iret + call ready_for_next_irq + restore_ring3_context + iret p_irq14: - save_ring3_context - mov ax, app_data ;os_data - mov ds, ax - mov es, ax - mov edi, 14 - cmp [v86_irqhooks+edi*8], 0 - jnz v86_irq2 - call [irq14_func] - call ready_for_next_irq_1 - restore_ring3_context - iret + save_ring3_context + mov ax, app_data ;os_data + mov ds, ax + mov es, ax + mov edi, 14 + cmp [v86_irqhooks+edi*8], 0 + jnz v86_irq2 + call [irq14_func] + call ready_for_next_irq_1 + restore_ring3_context + iret p_irq15: - save_ring3_context - mov ax, app_data ;os_data - mov ds, ax - mov es, ax - mov edi, 15 - cmp [v86_irqhooks+edi*8], 0 - jnz v86_irq2 - call [irq15_func] - call ready_for_next_irq_1 - restore_ring3_context - iret + save_ring3_context + mov ax, app_data ;os_data + mov ds, ax + mov es, ax + mov edi, 15 + cmp [v86_irqhooks+edi*8], 0 + jnz v86_irq2 + call [irq15_func] + call ready_for_next_irq_1 + restore_ring3_context + iret ready_for_next_irq: mov eax,5 - mov [check_idle_semaphore],eax - add eax,(0x20-0x5) - out 0x20, al - ret + mov [check_idle_semaphore],eax + add eax,(0x20-0x5) + out 0x20, al + ret ;destroy eax ready_for_next_irq_1: mov eax,5 - mov [check_idle_semaphore],eax + mov [check_idle_semaphore],eax ; mov al, 0x20 - add eax,(0x20-0x5) - out 0xa0,al - out 0x20, al - ret + add eax,(0x20-0x5) + out 0xa0,al + out 0x20, al + ret irqD: - push eax + push eax xor eax,eax - out 0xf0,al - mov al,0x20 - out 0xa0,al - out 0x20,al - pop eax - iret + out 0xf0,al + mov al,0x20 + out 0xa0,al + out 0x20,al + pop eax + iret irqh 2,3,4,5,7,8,9,10,11 irqhandler: - mov esi,edi ; 1 - shl esi,6 ; 1 + mov esi,edi ; 1 + shl esi,6 ; 1 add esi,irq00read ; 1 - shl edi,12 ; 1 + shl edi,12 ; 1 add edi,IRQ_SAVE mov ecx,16 @@ -319,37 +320,37 @@ irqhandler: dec ecx js irqover - movzx edx, word [esi] ; 2+ + movzx edx, word [esi] ; 2+ - test edx, edx ; 1 + test edx, edx ; 1 jz irqover - mov ebx, [edi] ; address of begin of buffer in edi ; + 0x0 dword - data size - mov eax, 4000 ; + 0x4 dword - data begin offset + mov ebx, [edi] ; address of begin of buffer in edi ; + 0x0 dword - data size + mov eax, 4000 ; + 0x4 dword - data begin offset cmp ebx, eax je irqfull - add ebx, [edi + 0x4] ; add data size to data begin offset - cmp ebx, eax ; if end of buffer, begin cycle again + add ebx, [edi + 0x4] ; add data size to data begin offset + cmp ebx, eax ; if end of buffer, begin cycle again jb @f xor ebx, ebx @@: add ebx, edi - movzx eax, byte[esi + 3] ; get type of data being received 1 - byte, 2 - word + movzx eax, byte[esi + 3] ; get type of data being received 1 - byte, 2 - word dec eax jz irqbyte dec eax jnz noirqword in ax,dx - cmp ebx, 3999 ; check for address odd in the end of buffer + cmp ebx, 3999 ; check for address odd in the end of buffer jne .odd mov [ebx + 0x10], ax jmp .add_size .odd: - mov [ebx + 0x10], al ; I could make mistake here :) + mov [ebx + 0x10], al ; I could make mistake here :) mov [edi + 0x10], ah .add_size: add dword [edi], 2 @@ -374,37 +375,37 @@ irqhandler: set_application_table_status: - push eax + push eax - mov eax,[CURRENT_TASK] - shl eax, 5 - add eax,CURRENT_TASK+TASKDATA.pid - mov eax,[eax] + mov eax,[CURRENT_TASK] + shl eax, 5 + add eax,CURRENT_TASK+TASKDATA.pid + mov eax,[eax] - mov [application_table_status],eax + mov [application_table_status],eax - pop eax + pop eax - ret + ret clear_application_table_status: - push eax + push eax - mov eax,[CURRENT_TASK] - shl eax, 5 - add eax,CURRENT_TASK+TASKDATA.pid - mov eax,[eax] + mov eax,[CURRENT_TASK] + shl eax, 5 + add eax,CURRENT_TASK+TASKDATA.pid + mov eax,[eax] - cmp eax,[application_table_status] - jne apptsl1 + cmp eax,[application_table_status] + jne apptsl1 xor eax,eax - mov [application_table_status],eax + mov [application_table_status],eax apptsl1: - pop eax + pop eax - ret + ret ; * eax = 64 - sysFn # ; * ebx = 1 - subFn @@ -415,138 +416,138 @@ clear_application_table_status: sys_resize_app_memory: dec ebx - jnz .no_application_mem_resize - stdcall new_mem_resize, ecx - mov [esp+32], eax + jnz .no_application_mem_resize + stdcall new_mem_resize, ecx + mov [esp+32], eax .no_application_mem_resize: - ret + ret iglobal - msg_obj_destroy db 'K : app object destroyed',13,10,0 + msg_obj_destroy db 'K : app object destroyed',13,10,0 endg ; terminate application ; param ; esi= slot -terminate: +terminate: - .slot equ esp ;locals + .slot equ esp ;locals - push esi ;save .slot + push esi ;save .slot - shl esi, 8 - cmp [SLOT_BASE+esi+APPDATA.dir_table], 0 - jne @F - pop esi - shl esi, 5 - mov [CURRENT_TASK+esi+TASKDATA.state], 9 - ret + shl esi, 8 + cmp [SLOT_BASE+esi+APPDATA.dir_table], 0 + jne @F + pop esi + shl esi, 5 + mov [CURRENT_TASK+esi+TASKDATA.state], 9 + ret @@: - cli - cmp [application_table_status],0 - je term9 - sti - call change_task - jmp @b + cli + cmp [application_table_status],0 + je term9 + sti + call change_task + jmp @b term9: - call set_application_table_status + call set_application_table_status ; if the process is in V86 mode... - mov eax, [.slot] - shl eax, 8 - mov esi, [eax+SLOT_BASE+APPDATA.pl0_stack] - add esi, RING0_STACK_SIZE - cmp [eax+SLOT_BASE+APPDATA.saved_esp0], esi - jz .nov86 + mov eax, [.slot] + shl eax, 8 + mov esi, [eax+SLOT_BASE+APPDATA.pl0_stack] + add esi, RING0_STACK_SIZE + cmp [eax+SLOT_BASE+APPDATA.saved_esp0], esi + jz .nov86 ; ...it has page directory for V86 mode - mov esi, [eax+SLOT_BASE+APPDATA.saved_esp0] - mov ecx, [esi+4] - mov [eax+SLOT_BASE+APPDATA.dir_table], ecx + mov esi, [eax+SLOT_BASE+APPDATA.saved_esp0] + mov ecx, [esi+4] + mov [eax+SLOT_BASE+APPDATA.dir_table], ecx ; ...and I/O permission map for V86 mode - mov ecx, [esi+12] - mov [eax+SLOT_BASE+APPDATA.io_map], ecx - mov ecx, [esi+8] - mov [eax+SLOT_BASE+APPDATA.io_map+4], ecx + mov ecx, [esi+12] + mov [eax+SLOT_BASE+APPDATA.io_map], ecx + mov ecx, [esi+8] + mov [eax+SLOT_BASE+APPDATA.io_map+4], ecx .nov86: - mov esi, [.slot] - shl esi,8 - add esi, SLOT_BASE+APP_OBJ_OFFSET + mov esi, [.slot] + shl esi,8 + add esi, SLOT_BASE+APP_OBJ_OFFSET @@: - mov eax, [esi+APPOBJ.fd] - test eax, eax - jz @F + mov eax, [esi+APPOBJ.fd] + test eax, eax + jz @F - cmp eax, esi - je @F + cmp eax, esi + je @F - push esi - call [eax+APPOBJ.destroy] - DEBUGF 1,"%s",msg_obj_destroy - pop esi - jmp @B + push esi + call [eax+APPOBJ.destroy] + DEBUGF 1,"%s",msg_obj_destroy + pop esi + jmp @B @@: - mov eax, [.slot] - shl eax, 8 - stdcall destroy_app_space, [SLOT_BASE+eax+APPDATA.dir_table], [SLOT_BASE+eax+APPDATA.dlls_list_ptr] + mov eax, [.slot] + shl eax, 8 + stdcall destroy_app_space, [SLOT_BASE+eax+APPDATA.dir_table], [SLOT_BASE+eax+APPDATA.dlls_list_ptr] - mov esi, [.slot] - cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 - jne @F + mov esi, [.slot] + cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 + jne @F - mov [fpu_owner],1 - mov eax, [256+SLOT_BASE+APPDATA.fpu_state] - clts - bt [cpu_caps], CAPS_SSE - jnc .no_SSE - fxrstor [eax] - jmp @F + mov [fpu_owner],1 + mov eax, [256+SLOT_BASE+APPDATA.fpu_state] + clts + bt [cpu_caps], CAPS_SSE + jnc .no_SSE + fxrstor [eax] + jmp @F .no_SSE: - fnclex - frstor [eax] + fnclex + frstor [eax] @@: - mov [KEY_COUNT],byte 0 ; empty keyboard buffer - mov [BTN_COUNT],byte 0 ; empty button buffer + mov [KEY_COUNT],byte 0 ; empty keyboard buffer + mov [BTN_COUNT],byte 0 ; empty button buffer ; remove defined hotkeys - mov eax, hotkey_list + mov eax, hotkey_list .loop: - cmp [eax+8], esi - jnz .cont - mov ecx, [eax] - jecxz @f - push dword [eax+12] - pop dword [ecx+12] + cmp [eax+8], esi + jnz .cont + mov ecx, [eax] + jecxz @f + push dword [eax+12] + pop dword [ecx+12] @@: - mov ecx, [eax+12] - push dword [eax] - pop dword [ecx] - xor ecx, ecx - mov [eax], ecx - mov [eax+4], ecx - mov [eax+8], ecx - mov [eax+12], ecx + mov ecx, [eax+12] + push dword [eax] + pop dword [ecx] + xor ecx, ecx + mov [eax], ecx + mov [eax+4], ecx + mov [eax+8], ecx + mov [eax+12], ecx .cont: - add eax, 16 - cmp eax, hotkey_list+256*16 - jb .loop + add eax, 16 + cmp eax, hotkey_list+256*16 + jb .loop ; remove hotkeys in buffer - mov eax, hotkey_buffer + mov eax, hotkey_buffer .loop2: - cmp [eax], esi - jnz .cont2 - and dword [eax+4], 0 - and dword [eax], 0 + cmp [eax], esi + jnz .cont2 + and dword [eax+4], 0 + and dword [eax], 0 .cont2: - add eax, 8 - cmp eax, hotkey_buffer+120*8 - jb .loop2 + add eax, 8 + cmp eax, hotkey_buffer+120*8 + jb .loop2 - mov ecx,esi ; remove buttons + mov ecx,esi ; remove buttons bnewba2: mov edi,[BTN_ADDR] mov eax,edi @@ -555,7 +556,7 @@ term9: inc bx bnewba: dec bx - jz bnmba + jz bnmba add eax,0x10 cmp cx,[eax] jnz bnewba @@ -604,10 +605,10 @@ term9: shl edi, 5 mov eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot] test eax, eax - jz .nodebug + jz .nodebug push 8 pop ecx - push dword [CURRENT_TASK+edi+TASKDATA.pid] ; PID + push dword [CURRENT_TASK+edi+TASKDATA.pid] ; PID push 2 call debugger_notify pop ecx @@ -615,70 +616,70 @@ term9: .nodebug: popad - mov ebx, [.slot] - shl ebx, 8 - push ebx - mov ebx,[SLOT_BASE+ebx+APPDATA.pl0_stack] + mov ebx, [.slot] + shl ebx, 8 + push ebx + mov ebx,[SLOT_BASE+ebx+APPDATA.pl0_stack] - stdcall kernel_free, ebx + stdcall kernel_free, ebx - pop ebx - mov ebx,[SLOT_BASE+ebx+APPDATA.cur_dir] - stdcall kernel_free, ebx + pop ebx + mov ebx,[SLOT_BASE+ebx+APPDATA.cur_dir] + stdcall kernel_free, ebx - mov edi, [.slot] - shl edi,8 - add edi,SLOT_BASE + mov edi, [.slot] + shl edi,8 + add edi,SLOT_BASE - mov eax, [edi+APPDATA.io_map] - cmp eax, [SLOT_BASE+256+APPDATA.io_map] - je @F - call free_page + mov eax, [edi+APPDATA.io_map] + cmp eax, [SLOT_BASE+256+APPDATA.io_map] + je @F + call free_page @@: - mov eax, [edi+APPDATA.io_map+4] - cmp eax, [SLOT_BASE+256+APPDATA.io_map+4] - je @F - call free_page + mov eax, [edi+APPDATA.io_map+4] + cmp eax, [SLOT_BASE+256+APPDATA.io_map+4] + je @F + call free_page @@: - mov eax, 0x20202020 - stosd - stosd - stosd - mov ecx,244/4 - xor eax, eax - rep stosd + mov eax, 0x20202020 + stosd + stosd + stosd + mov ecx,244/4 + xor eax, eax + rep stosd ; activate window - movzx eax, word [WIN_STACK + esi*2] - cmp eax, [TASK_COUNT] - jne .dont_activate - pushad + movzx eax, word [WIN_STACK + esi*2] + cmp eax, [TASK_COUNT] + jne .dont_activate + pushad .check_next_window: - dec eax - cmp eax, 1 - jbe .nothing_to_activate - lea esi, [WIN_POS+eax*2] - movzx edi, word [esi] ; edi = process - shl edi, 5 - cmp [CURRENT_TASK + edi + TASKDATA.state], byte 9 ; skip dead slots - je .check_next_window - add edi, window_data + dec eax + cmp eax, 1 + jbe .nothing_to_activate + lea esi, [WIN_POS+eax*2] + movzx edi, word [esi] ; edi = process + shl edi, 5 + cmp [CURRENT_TASK + edi + TASKDATA.state], byte 9 ; skip dead slots + je .check_next_window + add edi, window_data ; skip minimized windows - test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED - jnz .check_next_window - call waredraw + test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED + jnz .check_next_window + call waredraw .nothing_to_activate: - popad + popad .dont_activate: - push esi ; remove hd1 & cd & flp reservation - shl esi, 5 - mov esi, [esi+CURRENT_TASK+TASKDATA.pid] - cmp [hd1_status], esi - jnz @f - call free_hd_channel - and [hd1_status], 0 + push esi ; remove hd1 & cd & flp reservation + shl esi, 5 + mov esi, [esi+CURRENT_TASK+TASKDATA.pid] + cmp [hd1_status], esi + jnz @f + call free_hd_channel + and [hd1_status], 0 ;@@: ; cmp [cd_status], esi ; jnz @f @@ -689,11 +690,11 @@ term9: ; jnz @f ; and [flp_status], 0 @@: - pop esi - cmp [bgrlockpid], esi - jnz @f - and [bgrlockpid], 0 - and [bgrlock], 0 + pop esi + cmp [bgrlockpid], esi + jnz @f + and [bgrlockpid], 0 + and [bgrlock], 0 @@: pusha ; remove all irq reservations @@ -706,16 +707,16 @@ term9: newirqfree: cmp [edi + 4 * ebx], eax jne nofreeirq - mov [edi + 4 * ebx], edx ; remove irq reservation - mov [irq_tab + 4 * ebx], edx ; remove irq handler - mov [irq_rights + 4 * ebx], edx ; set access rights to full access + mov [edi + 4 * ebx], edx ; remove irq reservation + mov [irq_tab + 4 * ebx], edx ; remove irq handler + mov [irq_rights + 4 * ebx], edx ; set access rights to full access nofreeirq: inc ebx cmp ebx, 16 - jb newirqfree + jb newirqfree popa - pusha ; remove all port reservations + pusha ; remove all port reservations mov edx,esi shl edx, 5 add edx,CURRENT_TASK @@ -726,7 +727,7 @@ term9: mov esi,[RESERVED_PORTS] test esi,esi - jz rmpr9 + jz rmpr9 rmpr3: @@ -735,7 +736,7 @@ term9: add edi,RESERVED_PORTS cmp edx,[edi] - je rmpr4 + je rmpr4 dec esi jnz rmpr3 @@ -760,7 +761,7 @@ term9: rmpr9: popa - mov edi,esi ; do not run this process slot + mov edi,esi ; do not run this process slot shl edi, 5 mov [edi+CURRENT_TASK + TASKDATA.state],byte 9 ; debugger test - terminate all debuggees @@ -768,7 +769,7 @@ term9: mov ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot .xd0: cmp eax, [TASK_COUNT] - ja .xd1 + ja .xd1 cmp dword [ecx], esi jnz @f and dword [ecx], 0 @@ -802,13 +803,13 @@ term9: restore .slot iglobal - boot_sched_1 db 'Building gdt tss pointer',0 + boot_sched_1 db 'Building gdt tss pointer',0 ; boot_sched_2 db 'Building IDT table',0 endg build_scheduler: - mov esi,boot_sched_1 - call boot_log - ret + mov esi,boot_sched_1 + call boot_log + ret diff --git a/kernel/branches/Kolibri-A/trunk/detect/dev_hdcd.inc b/kernel/branches/Kolibri-A/trunk/detect/dev_hdcd.inc index 989677fd6e..61acfb904e 100644 --- a/kernel/branches/Kolibri-A/trunk/detect/dev_hdcd.inc +++ b/kernel/branches/Kolibri-A/trunk/detect/dev_hdcd.inc @@ -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: diff --git a/kernel/branches/Kolibri-A/trunk/kernel.asm b/kernel/branches/Kolibri-A/trunk/kernel.asm index 3024002c6f..96ac7f8b5d 100644 --- a/kernel/branches/Kolibri-A/trunk/kernel.asm +++ b/kernel/branches/Kolibri-A/trunk/kernel.asm @@ -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