merge kolibri_acpi #2156

git-svn-id: svn://kolibrios.org@2167 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2011-09-10 10:58:39 +00:00
parent 6252cd9a99
commit be59696270
8 changed files with 95 additions and 126 deletions

View File

@ -5,60 +5,35 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 4
pic_delay:
jmp pdl1
pdl1: ret
align 4 align 4
rerouteirqs: rerouteirqs:
cli cli
mov al,0x11 ; icw4, edge triggered mov al,0x11 ; icw4, edge triggered
out 0x20,al out 0x20,al
call pic_delay
out 0xA0,al out 0xA0,al
call pic_delay
mov al,0x20 ; generate 0x20 + mov al,0x20 ; generate 0x20 +
out 0x21,al out 0x21,al
call pic_delay
mov al,0x28 ; generate 0x28 + mov al,0x28 ; generate 0x28 +
out 0xA1,al out 0xA1,al
call pic_delay
mov al,0x04 ; slave at irq2 mov al,0x04 ; slave at irq2
out 0x21,al out 0x21,al
call pic_delay
mov al,0x02 ; at irq9 mov al,0x02 ; at irq9
out 0xA1,al out 0xA1,al
call pic_delay
mov al,0x01 ; 8086 mode mov al,0x01 ; 8086 mode
out 0x21,al out 0x21,al
call pic_delay
out 0xA1,al out 0xA1,al
call pic_delay
mov al,255 ; mask all irq's mov al,255 ; mask all irq's
out 0xA1,al out 0xA1,al
call pic_delay
out 0x21,al out 0x21,al
call pic_delay
mov ecx,0x1000
cld
picl1: call pic_delay
loop picl1
mov al,255 ; mask all irq's mov al,255 ; mask all irq's
out 0xA1,al out 0xA1,al
call pic_delay
out 0x21,al out 0x21,al
call pic_delay
ret ret

View File

@ -46,15 +46,67 @@ macro calc_index op
@@: @@:
} }
macro remove_from_used op align 4
{ md:
mov edx, [op+list_fd] .add_to_used:
mov ecx, [op+list_bk] mov eax, [esi+block_base]
mov [edx+list_bk], ecx mov ebx, [esi+block_base]
mov [ecx+list_fd], edx shr ebx, 6
mov [op+list_fd], 0 add eax, ebx
mov [op+list_bk], 0 shr ebx, 6
} add eax, ebx
shr eax, 12
and eax, 63
inc [mem_hash_cnt+eax*4]
lea ecx, [mem_used_list+eax*8]
list_add esi, ecx
mov [esi+block_flags], USED_BLOCK
mov eax, [esi+block_size]
sub [heap_free], eax
ret
align 4
.find_used:
mov ecx, eax
mov ebx, eax
shr ebx, 6
add ecx, ebx
shr ebx, 6
add ecx, ebx
shr ecx, 12
and ecx, 63
lea ebx, [mem_used_list+ecx*8]
mov esi, ebx
.next:
mov esi, [esi+list_fd]
cmp esi, ebx
je .fail
cmp eax, [esi+block_base]
jne .next
ret
.fail:
xor esi, esi
ret
align 4
.del_from_used:
call .find_used
test esi, esi
jz .done
cmp [esi+block_flags], USED_BLOCK
jne .fatal
dec [mem_hash_cnt+ecx*4]
list_del esi
.done:
ret
.fatal: ;FIXME panic here
xor esi, esi
ret
;Initial heap state ;Initial heap state
; ;
@ -74,9 +126,13 @@ proc init_kernel_heap
stosd stosd
loop @B loop @B
mov eax, mem_used.fd mov ecx, 64
mov [mem_used.fd], eax mov edi, mem_used_list
mov [mem_used.bk], eax @@:
mov eax, edi
stosd
stosd
loop @B
stdcall alloc_pages, dword 32 stdcall alloc_pages, dword 32
mov ecx, 32 mov ecx, 32
@ -139,7 +195,6 @@ proc init_kernel_heap
mov [eax-MEM_BLOCK.sizeof], dword 0 mov [eax-MEM_BLOCK.sizeof], dword 0
mov ecx, heap_mutex mov ecx, heap_mutex
call mutex_init call mutex_init
mov [heap_blocks], 4094 mov [heap_blocks], 4094
@ -279,7 +334,7 @@ proc alloc_kernel_space stdcall, size:dword
mov eax, [edi+block_size] mov eax, [edi+block_size]
calc_index eax calc_index eax
cmp eax, [block_ind] cmp eax, [block_ind]
je .m_eq_ind je .add_used
list_del edi list_del edi
@ -292,17 +347,10 @@ proc alloc_kernel_space stdcall, size:dword
bts [mem_block_mask], eax bts [mem_block_mask], eax
lea edx, [mem_block_list+eax*8] ;edx= list head lea edx, [mem_block_list+eax*8] ;edx= list head
list_add edi, edx list_add edi, edx
.m_eq_ind: .add_used:
mov ecx, mem_used.fd
mov edx, [ecx+list_fd] call md.add_to_used
mov [esi+list_fd], edx
mov [esi+list_bk], ecx
mov [ecx+list_fd], esi
mov [edx+list_bk], esi
mov [esi+block_flags], USED_BLOCK
mov ebx, [size]
sub [heap_free], ebx
mov ecx, heap_mutex mov ecx, heap_mutex
call mutex_unlock call mutex_unlock
mov eax, [esi+block_base] mov eax, [esi+block_base]
@ -310,6 +358,7 @@ proc alloc_kernel_space stdcall, size:dword
pop esi pop esi
pop ebx pop ebx
ret ret
.m_eq_size: .m_eq_size:
list_del edi list_del edi
lea edx, [mem_block_list+ebx*8] lea edx, [mem_block_list+ebx*8]
@ -317,23 +366,8 @@ proc alloc_kernel_space stdcall, size:dword
jnz @f jnz @f
btr [mem_block_mask], ebx btr [mem_block_mask], ebx
@@: @@:
mov ecx, mem_used.fd mov esi, edi
mov edx, [ecx+list_fd] jmp .add_used
mov [edi+list_fd], edx
mov [edi+list_bk], ecx
mov [ecx+list_fd], edi
mov [edx+list_bk], edi
mov [edi+block_flags], USED_BLOCK
mov ebx, [size]
sub [heap_free], ebx
mov ecx, heap_mutex
call mutex_unlock
mov eax, [edi+block_base]
pop edi
pop esi
pop ebx
ret
.error_unlock: .error_unlock:
mov ecx, heap_mutex mov ecx, heap_mutex
@ -353,18 +387,10 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword
call mutex_lock call mutex_lock
mov eax, [base] mov eax, [base]
mov esi, [mem_used.fd]
@@:
cmp esi, mem_used.fd
je .fail
cmp [esi+block_base], eax call md.del_from_used
je .found test esi, esi
mov esi, [esi+list_fd] jz .fail
jmp @b
.found:
cmp [esi+block_flags], USED_BLOCK
jne .fail
mov eax, [esi+block_size] mov eax, [esi+block_size]
add [heap_free], eax add [heap_free], eax
@ -395,8 +421,6 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword
cmp [edi+block_flags], FREE_BLOCK cmp [edi+block_flags], FREE_BLOCK
jne .insert jne .insert
remove_from_used esi
mov edx, [esi+block_next] mov edx, [esi+block_next]
mov [edi+block_next], edx mov [edi+block_next], edx
mov [edx+block_prev], edi mov [edx+block_prev], edi
@ -433,7 +457,6 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword
not eax not eax
ret ret
.insert: .insert:
remove_from_used esi
mov [esi+block_flags], FREE_BLOCK mov [esi+block_flags], FREE_BLOCK
mov eax, [esi+block_size] mov eax, [esi+block_size]
calc_index eax calc_index eax
@ -523,22 +546,16 @@ endp
align 4 align 4
proc kernel_free stdcall, base:dword proc kernel_free stdcall, base:dword
push ebx esi push ebx esi
mov ecx, heap_mutex mov ecx, heap_mutex
call mutex_lock call mutex_lock
mov eax, [base] mov eax, [base]
mov esi, [mem_used.fd] call md.find_used
@@:
cmp esi, mem_used.fd
je .fail
cmp [esi+block_base], eax mov ecx, heap_mutex
je .found
mov esi, [esi+list_fd]
jmp @b
.found:
cmp [esi+block_flags], USED_BLOCK cmp [esi+block_flags], USED_BLOCK
jne .fail jne .fail

View File

@ -314,6 +314,7 @@ __exports:
pci_write16, 'PciWrite16', \ ; stdcall pci_write16, 'PciWrite16', \ ; stdcall
pci_write32, 'PciWrite32', \ ; stdcall pci_write32, 'PciWrite32', \ ; stdcall
\ \
get_pid, 'GetPid', \
get_service, 'GetService', \ ; get_service, 'GetService', \ ;
reg_service, 'RegService', \ ; stdcall reg_service, 'RegService', \ ; stdcall
attach_int_handler, 'AttachIntHandler', \ ; stdcall attach_int_handler, 'AttachIntHandler', \ ; stdcall

View File

@ -27,7 +27,7 @@ irq0:
add [next_usage_update],100 add [next_usage_update],100
call updatecputimes call updatecputimes
.nocounter: .nocounter:
xor ecx, ecx xor ecx, ecx ; send End Of Interrupt signal
call irq_eoi call irq_eoi
btr dword[DONT_SWITCH], 0 btr dword[DONT_SWITCH], 0
jc .return jc .return

View File

@ -120,8 +120,9 @@ exc_c: ;
reg_esi equ esp+0x04 reg_esi equ esp+0x04
reg_edi equ esp+0x00 reg_edi equ esp+0x00
Mov ds,ax,app_data ; загрузим правильные значени mov ax, app_data ;исключение
mov es,ax ; в сегментные регистры mov ds, ax ;загрузим правильные значения
mov es, ax ;в регистры
cld ; è ïðèâîäèì DF ê ñòàíäàðòó cld ; è ïðèâîäèì DF ê ñòàíäàðòó
movzx ebx,bl movzx ebx,bl
; redirect to V86 manager? (EFLAGS & 0x20000) != 0? ; redirect to V86 manager? (EFLAGS & 0x20000) != 0?

View File

@ -805,7 +805,6 @@ end if
mov dword [SLOT_BASE+ecx+APPDATA.io_map], ebx mov dword [SLOT_BASE+ecx+APPDATA.io_map], ebx
mov dword [page_tabs + (tss._io_map_0 shr 10)], ebx mov dword [page_tabs + (tss._io_map_0 shr 10)], ebx
mov cr3, eax mov cr3, eax
; mov [irq_tab+5*4], 0
sti sti
popad popad

View File

@ -298,21 +298,19 @@ cur_saved_data rb 4096
fpu_data: rb 512 fpu_data: rb 512
mem_block_list rd 64*2 mem_block_list rd 64*2
mem_block_mask rd 2 mem_used_list rd 64*2
mem_used.fd rd 1
mem_used.bk rd 1
mem_hash_cnt rd 64 mem_hash_cnt rd 64
next_memblock rd 1
heap_mutex MUTEX heap_mutex MUTEX
heap_size rd 1 heap_size rd 1
heap_free rd 1 heap_free rd 1
heap_blocks rd 1 heap_blocks rd 1
free_blocks rd 1 free_blocks rd 1
mem_block_mask rd 2
next_memblock rd 1
mst MEM_STATE mst MEM_STATE
page_start rd 1 page_start rd 1

View File

@ -922,7 +922,7 @@ first_app_found:
and al,00000010b and al,00000010b
loopnz @b loopnz @b
; mov al, 0xED ; svetodiody - only for testing! ; mov al, 0xED ; Keyboard LEDs - only for testing!
; call kb_write ; call kb_write
; call kb_read ; call kb_read
; mov al, 111b ; mov al, 111b
@ -992,27 +992,6 @@ if preboot_blogesc
jne .bll1 jne .bll1
end if end if
; mov [ENABLE_TASKSWITCH],byte 1 ; multitasking enabled
; UNMASK ALL IRQ'S
; mov esi,boot_allirqs
; call boot_log
;
; cli ;guarantee forbidance of interrupts.
; mov al,0 ; unmask all irq's
; out 0xA1,al
; out 0x21,al
;
; mov ecx,32
;
; ready_for_irqs:
;
; mov al,0x20 ; ready for irqs
; out 0x20,al
; out 0xa0,al
;
; loop ready_for_irqs ; flush the queue
stdcall attach_int_handler, 1, irq1, 0 stdcall attach_int_handler, 1, irq1, 0
@ -1158,8 +1137,9 @@ endg
set_variables: set_variables:
mov ecx,0x100 ; flush port 0x60 mov ecx,0x16 ; flush port 0x60
.fl60: in al,0x60 .fl60:
in al,0x60
loop .fl60 loop .fl60
push eax push eax
@ -4126,8 +4106,6 @@ _rdtsc:
ret ret
end if end if
sys_msg_board_str: sys_msg_board_str:
pushad pushad