Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2217 → Rev 2216

/kernel/branches/Kolibri-acpi/core/apic.inc
42,7 → 42,6
IOAPIC_ARB equ 0x2
IOAPIC_REDTBL equ 0x10
 
align 4
APIC_init:
mov dword[APIC], 0
 
63,7 → 62,6
movzx eax, al
cmp al, IRQ_RESERVED
jbe @f
 
mov al, IRQ_RESERVED
@@:
mov [IRQ_COUNT], eax
71,8 → 69,7
; Reroute IOAPIC & mask all interrupts
xor ecx, ecx
mov eax, IOAPIC_REDTBL
@@:
mov ebx, eax
@@: mov ebx, eax
call IOAPIC_read
mov ah, 0x09 ; Delivery Mode: Lowest Priority, Destination Mode: Logical
mov al, cl
80,7 → 77,6
or eax, 0x10000 ; Mask Interrupt
cmp ecx, 16
jb .set
 
or eax, 0xa000 ;<<< level-triggered active-low for IRQ16+
.set:
xchg eax, ebx
107,8 → 103,6
 
; mov dword[irq_type_to_set], IRQ_TYPE_APIC
 
.no_apic:
 
;init handlers table
 
mov ecx, IRQ_RESERVED
122,6 → 116,7
mov ecx, 47
mov eax, irqh_pool+IRQH.sizeof
mov [next_irqh], irqh_pool
 
@@:
mov [eax-IRQH.sizeof], eax
add eax, IRQH.sizeof
129,6 → 124,7
 
mov [eax-IRQH.sizeof], dword 0
 
.no_apic:
ret
 
;===========================================================
150,6 → 146,7
or eax, 0xf0000000
mov [esi + APIC_DFR], eax
 
 
; Program Logical Destination Register.
mov eax, [esi + APIC_LDR]
;and eax, 0xff000000
164,16 → 161,12
 
; Flush the queue
mov edx, 0
.nxt2:
mov ecx, 32
.nxt2: mov ecx, 32
mov eax, [esi + APIC_ISR + edx]
.nxt:
shr eax, 1
.nxt: shr eax, 1
jnc @f
mov dword [esi + APIC_EOI], 0 ; EOI
@@:
loop .nxt
 
@@: loop .nxt
add edx, 0x10
cmp edx, 0x170
jbe .nxt2
213,8 → 206,8
; Start (every 0.01 sec)
mov dword[esi + APIC_LVT_timer], 0x30020 ; periodic int 0x20
mov dword[esi + APIC_timer_init], eax
 
ret
 
;===========================================================
; IOAPIC implementation
align 4
227,7 → 220,6
mov eax, [esi + 0x10]
pop esi
ret
 
align 4
IOAPIC_write:
; in : EAX - IOAPIC register
246,27 → 238,41
cli
mov al,0x11 ; icw4, edge triggered
out 0x20,al
call pic_delay
out 0xA0,al
call pic_delay
 
mov al,0x20 ; generate 0x20 +
out 0x21,al
call pic_delay
mov al,0x28 ; generate 0x28 +
out 0xA1,al
call pic_delay
 
mov al,0x04 ; slave at irq2
out 0x21,al
call pic_delay
mov al,0x02 ; at irq9
out 0xA1,al
call pic_delay
 
mov al,0x01 ; 8086 mode
out 0x21,al
call pic_delay
out 0xA1,al
call pic_delay
 
call IRQ_mask_all
cli
; mov dword[irq_type_to_set], IRQ_TYPE_PIC
ret
 
; -----------------------------------------
pic_delay:
jmp pdl1
pdl1: ret
 
; -----------------------------------------
; TIMER SET TO 1/100 S
PIT_init:
mov al,0x34 ; set to 100Hz
313,12 → 319,14
out 0x21, al
out 0xA1, al
mov ecx,0x1000
cld
@@: call pic_delay
loop @b
ret
.APIC:
mov ecx, [IRQ_COUNT]
mov eax, 0x10
@@:
mov ebx, eax
@@: mov ebx, eax
call IOAPIC_read
or eax, 0x10000 ; bit 16
xchg eax, ebx
327,7 → 335,6
inc eax
loop @b
ret
 
; -----------------------------------------
; End Of Interrupt
; cl - IRQ number
335,7 → 342,6
irq_eoi: ; __fastcall
test dword[APIC], 0xffffffff
jnz .APIC
 
cmp cl, 8
mov al, 0x20
jb @f
356,11 → 362,9
mov ebx, [irq_line]
test dword[APIC], 0xffffffff
jnz .APIC
 
mov edx, 0x21
cmp ebx, 8
jb @F
 
mov edx, 0xA1
sub ebx,8
@@:
/kernel/branches/Kolibri-acpi/core/memory.inc
171,14 → 171,9
push ebx
push edi
mov eax, [size]
add eax, [base]
add eax, 4095
and eax, -4096
mov ecx, [base]
and ecx, -4096
sub eax, ecx
mov [size], eax
 
stdcall alloc_kernel_space, eax
test eax, eax
jz .fail
194,7 → 189,9
or edx, [flags]
@@:
mov [page_tabs+eax*4], edx
; push eax
invlpg [ebx]
; pop eax
inc eax
add ebx, edi
add edx, edi