Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2436 → Rev 2437

/kernel/branches/Kolibri-acpi/core/apic.inc
41,6 → 41,14
IOAPIC_ARB equ 0x2
IOAPIC_REDTBL equ 0x10
 
IPI_INIT equ (0x6 shl 8)
IPI_LEVEL_ASSERT equ (0x1 shl 14)
SHORTHAND_ALL_EXCL equ (0x3 shl 18)
 
CMD_IPI_INIT equ (IPI_INIT+SHORTHAND_ALL_EXCL)
 
 
 
align 4
APIC_init:
mov [irq_mode], IRQ_PIC
128,6 → 136,9
; rdmsr ; it may be replaced to
; and ax, 0xf000 ; mov eax, 0xfee00000
 
mov [acpi_lapic_base], 0xfee00000
; xchg bx, bx
 
stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW
mov [LAPIC_BASE], eax
mov esi, eax
187,19 → 198,45
 
; LAPIC timer
; pre init
mov dword[esi + APIC_timer_div], 1011b; 1
mov dword[esi + APIC_timer_init], 0xffffffff; max val
push esi
mov esi, 640 ; wait 0.64 sec
call delay_ms
pop esi
mov eax, [esi + APIC_timer_cur]; read current tick couner
xor eax, 0xffffffff ; eax = 0xffffffff - eax
shr eax, 6 ; eax /= 64; APIC ticks per 0.01 sec
; mov dword[esi + APIC_timer_div], 1011b; 1
; mov dword[esi + APIC_timer_init], 0xffffffff; max val
; push esi
; mov esi, 640 ; wait 0.64 sec
; call delay_ms
; pop esi
; mov eax, [esi + APIC_timer_cur]; read current tick couner
; xor eax, 0xffffffff ; eax = 0xffffffff - eax
; shr eax, 6 ; eax /= 64; APIC ticks per 0.01 sec
 
; Start (every 0.01 sec)
mov dword[esi + APIC_LVT_timer], 0x30020; periodic int 0x20
mov dword[esi + APIC_timer_init], eax
; mov dword[esi + APIC_LVT_timer], 0x30020; periodic int 0x20
; mov dword[esi + APIC_timer_init], eax
xchg bx, bx
 
; mov al, 0x0F
; out 0x70, al
; mov al, 0x0A
; out 0x71, al
 
; mov [OS_BASE+0x469], word (__ap_start_16) shr 4
; mov [OS_BASE+0x469], word 0
 
mov [esi+APIC_ICRH], dword 0
mov [esi+APIC_ICRL], dword 0xc4500
 
mov ecx, 1000
@@:
loop @B
 
mov [esi+APIC_ICRH], dword 0
mov [esi+APIC_ICRL], dword 0xC4600+((0x10000+__ap_start_16) shr 12)
; mov [esi+APIC_ICRL], dword 0xC4612
 
; mov [esi+APIC_ICRH], dword 0
; mov [esi+APIC_ICRL], dword CMD_IPI_INIT+IPI_LEVEL_ASSERT+16
 
 
 
ret
 
;===========================================================