Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 3555 → Rev 3554

/kernel/branches/Kolibri-acpi/core/conf_lib-sp.inc
1,11 → 1,11
; Éste archivo debe ser editado con codificación CP866
; ste archivo debe ser editado con codificaci¢n CP866
 
ugui_mouse_speed:cp850 'velocidad del ratón',0
ugui_mouse_delay:cp850 'demora del ratón',0
ugui_mouse_speed db 'velocidad del rat¢n',0
ugui_mouse_delay db 'demora del rat¢n',0
 
udev:cp850 'disp',0
unet:cp850 'red',0
unet_active:cp850 'activa',0
unet_addr:cp850 'direc',0
unet_mask:cp850 'másc',0
unet_gate:cp850 'puer',0
udev db 'disp',0
unet db 'red',0
unet_active db 'activa',0
unet_addr db 'direc',0
unet_mask db 'm sc',0
unet_gate db 'puer',0
/kernel/branches/Kolibri-acpi/core/conf_lib.inc
72,7 → 72,54
udev_midibase db 'midibase',0
udev_midibase_def db '0x320',0
endg
;set up netvork configuration
proc set_network_conf
locals
par db 30 dup(?)
endl
pushad
 
;[net]
;active
lea eax, [par]
invoke ini.get_int, conf_fname, unet, unet_active, 0
or eax, eax
jz .do_not_set_net
mov eax, [stack_config]
and eax, 0xFFFFFF80
add eax, 3
mov [stack_config], eax
call ash_eth_enable
 
;addr
lea eax, [par]
push eax
invoke ini.get_str, conf_fname, unet, unet_addr, eax, 30, unet_def
pop eax
stdcall do_inet_adr, eax
mov [stack_ip], eax
 
;mask
lea eax, [par]
push eax
invoke ini.get_str, conf_fname, unet, unet_mask, eax, 30, unet_def
pop eax
stdcall do_inet_adr, eax
mov [subnet_mask], eax
 
;gate
lea eax, [par]
push eax
invoke ini.get_str, conf_fname, unet, unet_gate, eax, 30, unet_def
pop eax
stdcall do_inet_adr, eax
mov [gateway_ip], eax
.do_not_set_net:
popad
ret
 
 
endp
iglobal
if lang eq sp
include 'core/conf_lib-sp.inc'
117,7 → 164,7
proc strtoint_dec stdcall,strs
pushad
xor edx, edx
; поиск конца
; ¯®¨áª ª®­æ 
mov esi, [strs]
@@:
lodsb
133,7 → 180,7
dec ebx
or ebx, ebx
jz @f
imul ecx, ecx, 10; порядок
imul ecx, ecx, 10; ¯®à冷ª
jmp @b
@@:
 
/kernel/branches/Kolibri-acpi/core/dll.inc
142,11 → 142,7
cmp [edi+SRV.size], sizeof.SRV
jne .fail
 
; stdcall [edi+SRV.srv_proc], esi
mov eax, [edi+SRV.srv_proc]
test eax, eax
jz .fail
stdcall eax, esi
stdcall [edi+SRV.srv_proc], esi
ret
.fail:
xor eax, eax
178,11 → 174,7
cmp [eax+SRV.size], sizeof.SRV
jne .fail
 
; stdcall [eax+SRV.srv_proc], ecx
mov eax, [eax+SRV.srv_proc]
test eax, eax
jz .fail
stdcall eax, ecx
stdcall [eax+SRV.srv_proc], ecx
ret
.fail:
or eax, -1
221,31 → 213,9
ret
endp
 
reg_service:
xor eax, eax
mov ecx, [esp+8]
jecxz .nothing
push sizeof.SRV
push ecx
pushd [esp+12]
call reg_service_ex
.nothing:
ret 8
align 4
proc reg_service stdcall, name:dword, handler:dword
 
reg_usb_driver:
push sizeof.USBSRV
pushd [esp+12]
pushd [esp+12]
call reg_service_ex
test eax, eax
jz .nothing
mov ecx, [esp+12]
mov [eax+USBSRV.usb_func], ecx
.nothing:
ret 12
 
proc reg_service_ex stdcall, name:dword, handler:dword, srvsize:dword
 
push ebx
 
xor eax, eax
253,10 → 223,10
cmp [name], eax
je .fail
 
; cmp [handler], eax
; je .fail
cmp [handler], eax
je .fail
 
mov eax, [srvsize]
mov eax, sizeof.SRV
call malloc
test eax, eax
jz .fail
/kernel/branches/Kolibri-acpi/core/memory.inc
631,21 → 631,21
mov eax, [pf_err_code]
 
cmp ebx, OS_BASE ;ebx == .err_addr
jb .user_space ;страница в памяти приложения ;
jb .user_space ;ñòðàíèöà â ïàìÿòè ïðèëîæåíèÿ ;
 
cmp ebx, page_tabs
jb .kernel_space ;страница в памяти ядра
jb .kernel_space ;ñòðàíèöà â ïàìÿòè ÿäðà
 
cmp ebx, kernel_tabs
jb .alloc;.app_tabs ;таблицы страниц приложения ;
;просто создадим одну
if 0 ;пока это просто лишнее
jb .alloc;.app_tabs ;òàáëèöû ñòðàíèö ïðèëîæåíèÿ ;
;ïðîñòî ñîçäàäèì îäíó
if 0 ;ïîêà ýòî ïðîñòî ëèøíåå
cmp ebx, LFB_BASE
jb .core_tabs ;таблицы страниц ядра
;Ошибка
jb .core_tabs ;òàáëèöû ñòðàíèö ÿäðà
;Îøèáêà
.lfb:
;область LFB
;Ошибка
;îáëàñòü LFB
;Îøèáêà
jmp .fail
end if
.core_tabs:
661,8 → 661,8
 
.user_space:
test eax, PG_MAP
jnz .err_access ;Страница присутствует
;Ошибка доступа ?
jnz .err_access ;Ñòðàíèöà ïðèñóòñòâóåò
;Îøèáêà äîñòóïà ?
 
shr ebx, 12
mov ecx, ebx
669,13 → 669,13
shr ecx, 10
mov edx, [master_tab+ecx*4]
test edx, PG_MAP
jz .fail ;таблица страниц не создана
;неверный адрес в программе
jz .fail ;òàáëèöà ñòðàíèö íå ñîçäàíà
;íåâåðíûé àäðåñ â ïðîãðàììå
 
mov eax, [page_tabs+ebx*4]
test eax, 2
jz .fail ;адрес не зарезервирован для ;
;использования. Ошибка
jz .fail ;àäðåñ íå çàðåçåðâèðîâàí äëÿ ;
;èñïîëüçîâàíèÿ. Îøèáêà
.alloc:
call alloc_page
test eax, eax
731,16 → 731,16
 
.kernel_space:
test eax, PG_MAP
jz .fail ;страница не присутствует
jz .fail ;ñòðàíèöà íå ïðèñóòñòâóåò
 
test eax, 12 ;U/S (+below)
jnz .fail ;приложение обратилось к памяти
;ядра
jnz .fail ;ïðèëîæåíèå îáðàòèëîñü ê ïàìÿòè
;ÿäðà
;test eax, 8
;jnz .fail ;установлен зарезервированный бит
;в таблицах страниц. добавлено в P4/Xeon
;jnz .fail ;óñòàíîâëåí çàðåçåðâèðîâàííûé áèò
;â òàáëèöàõ ñòðàíèö. äîáàâëåíî â P4/Xeon
 
;попытка записи в защищённую страницу ядра
;ïîïûòêà çàïèñè â çàùèù¸ííóþ ñòðàíèöó ÿäðà
 
cmp ebx, tss._io_map_0
jb .fail
1136,6 → 1136,11
mov eax, [dst_slot]
shl eax, 8
or [eax+SLOT_BASE+0xA8], dword 0x40
cmp dword [check_idle_semaphore], 20
jge .ipc_no_cis
 
mov dword [check_idle_semaphore], 5
.ipc_no_cis:
push 0
jmp .ret
.no_pid:
/kernel/branches/Kolibri-acpi/core/sys32-sp.inc
1,4 → 1,4
; Éste archivo debe ser editado con codificación CP866
; ste archivo debe ser editado con codificaci¢n CP866
 
msg_sel_ker: cp850 "núcleo", 0
msg_sel_app: cp850 "aplicación", 0
msg_sel_ker db "n£cleo", 0
msg_sel_app db "aplicaci¢n", 0
/kernel/branches/Kolibri-acpi/core/sys32.inc
61,7 → 61,7
idtreg: ; data for LIDT instruction (!!! must be immediately below sys_int data)
dw 2*($-sys_int-4)-1
dd idts ;0x8000B100
dw 0 ;просто выравнивание
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
109,19 → 109,19
pf_err_code dd ?
endg
 
page_fault_exc: ; дуракоусточивость: селекторы испорчены...
pop [ss:pf_err_code]; действительно до следующего #PF
page_fault_exc: ; äóðàêîóñòî÷èâîñòü: ñåëåêòîðû èñïîð÷åíû...
pop [ss:pf_err_code]; äåéñòâèòåëüíî äî ñëåäóþùåãî #PF
save_ring3_context
mov bl, 14
 
exc_c: ; исключения (все, кроме 7-го - #NM)
; Фрэйм стека при исключении/прерывании из 3-го кольца + pushad (т.е., именно здесь)
exc_c: ; èñêëþ÷åíèÿ (âñå, êðîìå 7-ãî - #NM)
; Ôðýéì ñòåêà ïðè èñêëþ÷åíèè/ïðåðûâàíèè èç 3-ãî êîëüöà + pushad (ò.å., èìåííî çäåñü)
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
; ýòî ôðýéì îò pushad
reg_eax equ esp+0x1C
reg_ecx equ esp+0x18
reg_edx equ esp+0x14
131,10 → 131,10
reg_esi equ esp+0x04
reg_edi equ esp+0x00
 
mov ax, app_data ;исключение
mov ds, ax ;загрузим правильные значения
mov es, ax ;в регистры
cld ; и приводим DF к стандарту
mov ax, app_data ;èñêëþ÷åíèå
mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíèÿ
mov es, ax ;â ðåãèñòðû
cld ; è ïðèâîäèì DF ê ñòàíäàðòó
movzx ebx, bl
; redirect to V86 manager? (EFLAGS & 0x20000) != 0?
test byte[reg_eflags+2], 2
159,7 → 159,6
call show_error_parameters ;; only ONE using, inline ???
;mov edx, [TASK_BASE]
mov [edx + TASKDATA.state], byte 4 ; terminate
call wakeup_osloop
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
262,10 → 261,8
 
 
align 4
lock_application_table:
push eax ecx edx
mov ecx, application_table_mutex
call mutex_lock
set_application_table_status:
push eax
 
mov eax, [CURRENT_TASK]
shl eax, 5
272,30 → 269,37
add eax, CURRENT_TASK+TASKDATA.pid
mov eax, [eax]
 
mov [application_table_owner], eax
mov [application_table_status], eax
 
pop edx ecx eax
pop eax
 
ret
 
align 4
unlock_application_table:
push eax ecx edx
clear_application_table_status:
push eax
 
mov [application_table_owner], 0
mov ecx, application_table_mutex
call mutex_unlock
mov eax, [CURRENT_TASK]
shl eax, 5
add eax, CURRENT_TASK+TASKDATA.pid
mov eax, [eax]
 
pop edx ecx eax
cmp eax, [application_table_status]
jne apptsl1
xor eax, eax
mov [application_table_status], eax
apptsl1:
 
pop eax
 
ret
 
; * eax = 64 - номер функции
; * ebx = 1 - единственная подфункция
; * ecx = новый размер памяти
;Возвращаемое значение:
; * eax = 0 - успешно
; * eax = 1 - недостаточно памяти
; * eax = 64 - íîìåð ôóíêöèè
; * ebx = 1 - åäèíñòâåííàÿ ïîäôóíêöèÿ
; * ecx = íîâûé ðàçìåð ïàìÿòè
;Âîçâðàùàåìîå çíà÷åíèå:
; * eax = 0 - óñïåøíî
; * eax = 1 - íåäîñòàòî÷íî ïàìÿòè
 
align 4
sys_resize_app_memory:
334,11 → 338,17
mov [CURRENT_TASK+esi+TASKDATA.state], 9
ret
@@:
lea edx, [SLOT_BASE+esi]
call scheduler_remove_thread
;mov esi,process_terminating
;call sys_msg_board_str
call lock_application_table
@@:
cli
cmp [application_table_status], 0
je term9
sti
call change_task
jmp @b
term9:
call set_application_table_status
 
; if the process is in V86 mode...
mov eax, [.slot]
381,11 → 391,11
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 = 2
cmp [fpu_owner], esi ; if user fpu last -> fpu user = 1
jne @F
 
mov [fpu_owner], 2
mov eax, [256*2+SLOT_BASE+APPDATA.fpu_state]
mov [fpu_owner], 1
mov eax, [256+SLOT_BASE+APPDATA.fpu_state]
clts
bt [cpu_caps], CAPS_SSE
jnc .no_SSE
675,7 → 685,10
xor esi, esi
call redrawscreen
 
call unlock_application_table
mov [MOUSE_BACKGROUND], byte 0; no mouse background
mov [DONT_DRAW_MOUSE], byte 0; draw mouse
 
and [application_table_status], 0
;mov esi,process_terminated
;call sys_msg_board_str
add esp, 4
682,6 → 695,17
ret
restore .slot
 
;iglobal
;if lang eq ru
; boot_sched_1 db '‘®§¤ ­¨¥ GDT TSS 㪠§ â¥«ï',0
; boot_sched_2 db '‘®§¤ ­¨¥ IDT â ¡«¨æë',0
;else
; boot_sched_1 db 'Building gdt tss pointer',0
; boot_sched_2 db 'Building IDT table',0
;end if
;endg
 
 
;build_scheduler:
; mov esi, boot_sched_1
; call boot_log
/kernel/branches/Kolibri-acpi/core/syscall.inc
29,7 → 29,7
 
align 32
sysenter_entry:
; Настраиваем стек
; Íàñòðàèâàåì ñòåê
mov esp, [ss:tss._esp0]
sti
push ebp ; save app esp + 4
47,7 → 47,7
call unprotect_from_terminate
popad
;------------------
xchg ecx, [ss:esp] ; в вершин стека - app ecx, ecx - app esp + 4
xchg ecx, [ss:esp] ; â âåðøèí ñòåêà - app ecx, ecx - app esp + 4
sub ecx, 4
xchg edx, [ecx] ; edx - return point, & save original edx
push edx
112,11 → 112,11
 
align 4
servetable:
dd socket ; 53-Socket interface
dd 0
dd 0
dd 0
dd 0
dd 0
dd file_system ; 58-Common file system interface
dd 0
dd 0
182,8 → 182,8
dd sys_apm ; 49-Advanced Power Management (APM)
dd syscall_set_window_shape ; 50-Window shape & scale
dd syscall_threads ; 51-Threads
dd undefined_syscall ; 52-Stack driver status
dd undefined_syscall ; 53-Socket interface
dd stack_driver_stat ; 52-Stack driver status
dd cross_order ; 53-Socket interface
dd undefined_syscall ; 54-reserved
dd sound_interface ; 55-Sound interface
dd undefined_syscall ; 56-reserved
204,9 → 204,9
dd syscall_window_settings ; 71-Window settings
dd sys_sendwindowmsg ; 72-Send window message
dd blit_32 ; 73-blitter;
dd sys_network ; 74-reserved for new stack
dd sys_socket ; 75-reserved for new stack
dd sys_protocols ; 76-reserved for new stack
dd undefined_syscall ; 74-reserved for new stack
dd undefined_syscall ; 75-reserved for new stack
dd undefined_syscall ; 76-reserved for new stack
times 255 - ( ($-servetable2) /4 ) dd undefined_syscall
dd sys_end ; -1-end application
 
/kernel/branches/Kolibri-acpi/core/taskman.inc
90,7 → 90,7
stdcall set_cursor, [def_cursor_clock]
mov [handle], eax
mov [redrawmouse_unconditional], 1
call wakeup_osloop
call __sys_draw_pointer
popad
@@:
mov [flags], edx
152,8 → 152,20
test eax, eax
jz .err_hdr
 
call lock_application_table
.wait_lock:
cmp [application_table_status], 0
je .get_lock
call change_task
jmp .wait_lock
 
.get_lock:
mov eax, 1
xchg eax, [application_table_status]
test eax, eax
jnz .wait_lock
 
call set_application_table_status
 
call get_new_process_place
test eax, eax
mov esi, -0x20 ; too many processes
234,8 → 246,9
mov eax, [save_cr3]
call set_cr3
 
xor ebx, ebx
mov [application_table_status], ebx;unlock application_table_status mutex
mov eax, [process_number];set result
call unlock_application_table
 
jmp .final
 
246,7 → 259,8
.err_hdr:
stdcall kernel_free, [file_base]
.err_file:
call unlock_application_table
xor eax, eax
mov [application_table_status], eax
mov eax, esi
.final:
cmp [SCR_MODE], word 0x13
254,7 → 268,7
pushad
stdcall set_cursor, [handle]
mov [redrawmouse_unconditional], 1
call wakeup_osloop
call __sys_draw_pointer
popad
@@:
ret
536,7 → 550,7
 
xor edx, edx
push edx
mov eax, 0x1
mov eax, 0x2
mov ebx, [pg_dir]
.loop:
;eax = current slot of process
884,8 → 898,20
mov [app_path], eax
;mov esi,new_process_loading
;call sys_msg_board_str
call lock_application_table
.wait_lock:
cmp [application_table_status], 0
je .get_lock
call change_task
jmp .wait_lock
 
.get_lock:
mov eax, 1
xchg eax, [application_table_status]
test eax, eax
jnz .wait_lock
 
call set_application_table_status
 
call get_new_process_place
test eax, eax
jz .failed
941,13 → 967,14
 
;mov esi,new_process_running
;call sys_msg_board_str ;output information about succefull startup
xor eax, eax
mov [application_table_status], eax ;unlock application_table_status mutex
mov eax, [process_number] ;set result
call unlock_application_table
ret
.failed:
xor eax, eax
.failed1:
call unlock_application_table
mov [application_table_status], eax
dec eax ;-1
ret
endp
1121,7 → 1148,6
mov eax, [esi+0x08] ;app_eip
mov [ebx+REG_EIP], eax;app_entry
mov [ebx+REG_CS], dword app_code
mov ecx, USER_PRIORITY
mov eax, [CURRENT_TASK]
shl eax, 8 ; created by kernel?
cmp [SLOT_BASE+eax+APPDATA.dir_table], sys_pgdir - OS_BASE
1129,7 → 1155,6
cmp [app_path], 0 ; it is a thread?
jnz @f
mov [ebx+REG_CS], dword os_code ; kernel thread
mov ecx, MAX_PRIORITY
@@:
mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF
 
1137,22 → 1162,20
mov [ebx+REG_APP_ESP], eax;app_stack
mov [ebx+REG_SS], dword app_data
 
lea edx, [ebx+REG_RET]
lea ecx, [ebx+REG_RET]
mov ebx, [slot]
shl ebx, 5
mov [ebx*8+SLOT_BASE+APPDATA.saved_esp], edx
mov [ebx*8+SLOT_BASE+APPDATA.saved_esp], ecx
 
xor edx, edx; process state - running
xor ecx, ecx; process state - running
; set if debuggee
test byte [flags], 1
jz .no_debug
inc edx ; process state - suspended
inc ecx ; process state - suspended
mov eax, [CURRENT_TASK]
mov [SLOT_BASE+ebx*8+APPDATA.debugger_slot], eax
.no_debug:
mov [CURRENT_TASK+ebx+TASKDATA.state], dl
lea edx, [SLOT_BASE+ebx*8]
call scheduler_add_thread
mov [CURRENT_TASK+ebx+TASKDATA.state], cl
;mov esi,new_process_running
;call sys_msg_board_str ;output information about succefull startup
ret
/kernel/branches/Kolibri-acpi/core/v86.inc
178,7 → 178,7
; esi=handle
; out: eax=V86 address, para-aligned (0x10 multiple)
; destroys: nothing
; недописана!!!
; ­¥¤®¯¨á ­ !!!
;v86_alloc:
; push ebx ecx edx edi
; lea ebx, [esi+V86_machine.mutex]
377,8 → 377,8
jnz .nogp
; Otherwise we can safely access byte at CS:IP
; (because it is #GP, not #PF handler)
; Если бы мы могли схлопотать исключение только из-за чтения байтов кода,
; мы бы его уже схлопотали и это было бы не #GP
; …᫨ ¡ë ¬ë ¬®£«¨ áå«®¯®â âì ¨áª«î祭¨¥ ⮫쪮 ¨§-§  ç⥭¨ï ¡ ©â®¢ ª®¤ ,
; ¬ë ¡ë ¥£® 㦥 áå«®¯®â «¨ ¨ íâ® ¡ë«® ¡ë ­¥ #GP
movzx esi, word [esp+v86_regs.cs]
shl esi, 4
add esi, [esp+v86_regs.eip]
/kernel/branches/Kolibri-acpi/core/exports.inc
95,18 → 95,7
szTimerHS db 'TimerHS',0
szCancelTimerHS db 'CancelTimerHS',0
 
szRegUSBDriver db 'RegUSBDriver',0
szUSBOpenPipe db 'USBOpenPipe',0
szUSBClosePipe db 'USBClosePipe',0
szUSBNormalTransferAsync db 'USBNormalTransferAsync',0
szUSBControlTransferAsync db 'USBControlTransferAsync',0
 
szNetRegDev db 'NetRegDev',0
szNetUnRegDev db 'NetUnRegDev',0
szNetPtrToNum db 'NetPtrToNum',0
szNetLinkChanged db 'NetLinkChanged',0
szEth_input db 'Eth_input',0
 
align 16
kernel_export:
dd szRegService , reg_service
191,18 → 180,6
dd szTimerHS , timer_hs
dd szCancelTimerHS , cancel_timer_hs
 
dd szRegUSBDriver , reg_usb_driver
dd szUSBOpenPipe , usb_open_pipe
dd szUSBClosePipe , usb_close_pipe
dd szUSBNormalTransferAsync, usb_normal_transfer_async
dd szUSBControlTransferAsync, usb_control_async
 
dd szNetRegDev , NET_add_device
dd szNetUnRegDev , NET_remove_device
dd szNetPtrToNum , NET_ptr_to_num
dd szNetLinkChanged , NET_link_changed
dd szEth_input , ETH_input
 
exp_lfb:
dd szLFBAddress , 0
dd 0 ;terminator, must be zero
/kernel/branches/Kolibri-acpi/core/fpu.inc
179,5 → 179,5
iret
 
iglobal
fpu_owner dd 2
fpu_owner dd 0
endg
/kernel/branches/Kolibri-acpi/core/irq.inc
66,7 → 66,8
test edx, edx
jz .err
 
spin_lock_irqsave IrqsList
pushfd
cli
 
;allocate handler
 
83,7 → 84,6
mov eax, [user_data]
mov [ecx+IRQH.handler], edx
mov [ecx+IRQH.data], eax
and [ecx+IRQH.num_ints], 0
 
lea edx, [irqh_tab+ebx*8]
list_add_tail ecx, edx ;clobber eax
90,7 → 90,7
stdcall enable_irq, ebx
 
.fail:
spin_unlock_irqrestore IrqsList
popfd
.err:
pop ebx
mov eax, [.irqh]
188,7 → 188,7
 
push [ebx+IRQH.data]
call [ebx+IRQH.handler]
pop ecx
add esp, 4
 
pop esi
pop edi
197,7 → 197,6
test eax, eax
jz .next
 
inc [ebx+IRQH.num_ints]
btr [irq_active_set], ebp
jmp .next
 
205,70 → 204,9
btr [irq_active_set], ebp
jnc .exit
 
; There is at least one configuration with one device which generates IRQ
; that is not the same as it should be according to PCI config space.
; For that device, the handler is registered at wrong IRQ.
; As a workaround, when nobody acknowledges the generated IRQ,
; try to ask all other registered handlers; if some handler acknowledges
; the IRQ this time, relink it to the current IRQ list.
; To make this more reliable, for every handler keep number of times
; that it has acknowledged an IRQ, and assume that handlers with at least one
; acknowledged IRQ are registered properly.
; Note: this still isn't 100% correct, because two IRQs can fire simultaneously,
; the better way would be to find the correct IRQ, but I don't know how to do
; this in that case.
; Also, [fdc_irq_func], [irq14_func], [irq15_func] could process interrupt
; but do not return whether they did it, so just ignore IRQs 6, 14, 15.
cmp ebp, 6
jz .fail
cmp ebp, 14
jz .fail
cmp ebp, 15
jz .fail
push ebp
xor ebp, ebp
.try_other_irqs:
cmp ebp, [esp]
jz .try_next_irq
cmp ebp, 1
jz .try_next_irq
cmp ebp, 12
jz .try_next_irq
lea esi, [irqh_tab+ebp*8]
mov ebx, esi
.try_next_handler:
mov ebx, [ebx+IRQH.list.next]
cmp ebx, esi
je .try_next_irq
cmp [ebx+IRQH.num_ints], 0
jne .try_next_handler
; keyboard handler acknowledges everything
push [ebx+IRQH.data]
call [ebx+IRQH.handler]
pop ecx
test eax, eax
jz .try_next_handler
 
.found_in_wrong_list:
DEBUGF 1,'K : warning: relinking handler from IRQ%d to IRQ%d\n',\
ebp, [esp]
pop ebp
spin_lock_irqsave IrqsList
list_del ebx
lea edx, [irqh_tab+ebp*8]
list_add_tail ebx, edx
spin_unlock_irqrestore IrqsList
jmp .exit
 
.try_next_irq:
inc ebp
cmp ebp, 16
jb .try_other_irqs
pop ebp
 
.fail:
inc [irq_failed+ebp*4]
.exit:
mov [check_idle_semaphore], 5
 
mov ecx, ebp
call irq_eoi
/kernel/branches/Kolibri-acpi/core/sched.inc
29,8 → 29,8
.nocounter:
xor ecx, ecx ; send End Of Interrupt signal
call irq_eoi
; btr dword[DONT_SWITCH], 0
; jc .return
btr dword[DONT_SWITCH], 0
jc .return
call find_next_task
jz .return ; if there is only one running process
call do_change_task
61,7 → 61,7
call find_next_task
jz .return ; the same task -> skip switch
@@:
; mov byte[DONT_SWITCH], 1
mov byte[DONT_SWITCH], 1
call do_change_task
.return:
popad
89,6 → 89,9
ret
align 4
updatecputimes:
xor eax, eax
xchg eax, [idleuse]
mov [idleusesec], eax
mov ecx, [TASK_COUNT]
mov edi, TASK_DATA
.newupdate:
99,8 → 102,58
loop .newupdate
ret
 
;TODO: Надо бы убрать использование do_change_task из V86...
; и после этого перенести обработку TASKDATA.counter_add/sum в do_change_task
align 4
find_next_task:
;info:
; Find next task to execute
;retval:
; ebx = address of the APPDATA for the selected task (slot-base)
; esi = previous slot-base ([current_slot] at the begin)
; edi = address of the TASKDATA for the selected task
; ZF = 1 if the task is the same
;warning:
; [CURRENT_TASK] = bh , [TASK_BASE] = edi -- as result
; [current_slot] is not set to new value (ebx)!!!
;scratched: eax,ecx
call update_counters ; edi := [TASK_BASE]
Mov esi, ebx, [current_slot]
.loop:
cmp bh, [TASK_COUNT]
jb @f
xor bh, bh
mov edi, CURRENT_TASK
@@:
inc bh ; ebx += APPDATA.size
add edi, 0x20; edi += TASKDATA.size
mov al, [edi+TASKDATA.state]
test al, al
jz .found ; state == 0
cmp al, 5
jne .loop ; state == 1,2,3,4,9
; state == 5
pushad ; more freedom for [APPDATA.wait_test]
call [ebx+APPDATA.wait_test]
mov [esp+28], eax
popad
or eax, eax
jnz @f
; testing for timeout
mov ecx, [timer_ticks]
sub ecx, [ebx+APPDATA.wait_begin]
cmp ecx, [ebx+APPDATA.wait_timeout]
jb .loop
@@:
mov [ebx+APPDATA.wait_param], eax ; retval for wait
mov [edi+TASKDATA.state], 0
.found:
mov [CURRENT_TASK], bh
mov [TASK_BASE], edi
rdtsc ;call _rdtsc
mov [edi+TASKDATA.counter_add], eax; for next using update_counters
cmp ebx, esi ;esi - previous slot-base
ret
;TODO: Íàäî áû óáðàòü èñïîëüçîâàíèå do_change_task èç V86...
; è ïîñëå ýòîãî ïåðåíåñòè îáðàáîòêó TASKDATA.counter_add/sum â do_change_task
 
align 4
do_change_task:
252,143 → 305,6
 
purge MUTEX_WAITER
 
MAX_PRIORITY = 0 ; highest, used for kernel tasks
USER_PRIORITY = 1 ; default
IDLE_PRIORITY = 2 ; lowest, only IDLE thread goes here
NR_SCHED_QUEUES = 3 ; MUST equal IDLE_PRIORYTY + 1
 
uglobal
; [scheduler_current + i*4] = zero if there are no threads with priority i,
; pointer to APPDATA of the current thread with priority i otherwise.
align 4
scheduler_current rd NR_SCHED_QUEUES
endg
 
; Add the given thread to the given priority list for the scheduler.
; in: edx -> APPDATA, ecx = priority
proc scheduler_add_thread
; 1. Acquire the lock.
spin_lock_irqsave SchedulerLock
; 2. Store the priority in APPDATA structure.
mov [edx+APPDATA.priority], ecx
; 3. There are two different cases: the given list is empty or not empty.
; In first case, go to 6. Otherwise, advance to 4.
mov eax, [scheduler_current+ecx*4]
test eax, eax
jz .new_list
; 4. Insert the new item immediately before the current item.
mov ecx, [eax+APPDATA.in_schedule.prev]
mov [edx+APPDATA.in_schedule.next], eax
mov [edx+APPDATA.in_schedule.prev], ecx
mov [eax+APPDATA.in_schedule.prev], edx
mov [ecx+APPDATA.in_schedule.next], edx
; 5. Release the lock and return.
spin_unlock_irqrestore SchedulerLock
ret
.new_list:
; 6. Initialize the list with one item and make it the current item.
mov [edx+APPDATA.in_schedule.next], edx
mov [edx+APPDATA.in_schedule.prev], edx
mov [scheduler_current+ecx*4], edx
; 7. Release the lock and return.
spin_unlock_irqrestore SchedulerLock
ret
endp
 
; Remove the given thread from the corresponding priority list for the scheduler.
; in: edx -> APPDATA
proc scheduler_remove_thread
; 1. Acquire the lock.
spin_lock_irqsave SchedulerLock
; 2. Remove the item from the corresponding list.
mov eax, [edx+APPDATA.in_schedule.next]
mov ecx, [edx+APPDATA.in_schedule.prev]
mov [eax+APPDATA.in_schedule.prev], ecx
mov [ecx+APPDATA.in_schedule.next], eax
; 3. If the given thread is the current item in the list,
; advance the current item.
; 3a. Check whether the given thread is the current item;
; if no, skip the rest of this step.
mov ecx, [edx+APPDATA.priority]
cmp [scheduler_current+ecx*4], edx
jnz .return
; 3b. Set the current item to eax; step 2 has set eax = next item.
mov [scheduler_current+ecx*4], eax
; 3c. If there were only one item in the list, zero the current item.
cmp eax, edx
jnz .return
mov [scheduler_current+ecx*4], 0
.return:
; 4. Release the lock and return.
spin_unlock_irqrestore SchedulerLock
ret
endp
 
;info:
; Find next task to execute
;retval:
; ebx = address of the APPDATA for the selected task (slot-base)
; edi = address of the TASKDATA for the selected task
; ZF = 1 if the task is the same
;warning:
; [CURRENT_TASK] = bh , [TASK_BASE] = edi -- as result
; [current_slot] is not set to new value (ebx)!!!
;scratched: eax,ecx
proc find_next_task
call update_counters
spin_lock_irqsave SchedulerLock
xor ecx, ecx
.priority_loop:
mov ebx, [scheduler_current+ecx*4]
test ebx, ebx
jz .priority_next
.task_loop:
mov ebx, [ebx+APPDATA.in_schedule.next]
mov edi, ebx
shr edi, 3
add edi, CURRENT_TASK - (SLOT_BASE shr 3)
mov al, [edi+TASKDATA.state]
test al, al
jz .task_found ; state == 0
cmp al, 5
jne .task_next ; state == 1,2,3,4,9
; state == 5
pushad ; more freedom for [APPDATA.wait_test]
call [ebx+APPDATA.wait_test]
mov [esp+28], eax
popad
or eax, eax
jnz @f
; testing for timeout
mov eax, [timer_ticks]
sub eax, [ebx+APPDATA.wait_begin]
cmp eax, [ebx+APPDATA.wait_timeout]
jb .task_next
xor eax, eax
@@:
mov [ebx+APPDATA.wait_param], eax ; retval for wait
mov [edi+TASKDATA.state], 0
.task_found:
mov [scheduler_current+ecx*4], ebx
spin_unlock_irqrestore SchedulerLock
.found:
mov [CURRENT_TASK], bh
mov [TASK_BASE], edi
rdtsc ;call _rdtsc
mov [edi+TASKDATA.counter_add], eax; for next using update_counters
cmp ebx, [current_slot]
ret
.task_next:
cmp ebx, [scheduler_current+ecx*4]
jnz .task_loop
.priority_next:
inc ecx
cmp ecx, NR_SCHED_QUEUES
jb .priority_loop
hlt
jmp $-1
endp
 
if 0
 
struc TIMER
400,6 → 316,13
}
 
 
MAX_PROIRITY 0 ; highest, used for kernel tasks
MAX_USER_PRIORITY 0 ; highest priority for user processes
USER_PRIORITY 7 ; default (should correspond to nice 0)
MIN_USER_PRIORITY 14 ; minimum priority for user processes
IDLE_PRIORITY 15 ; lowest, only IDLE process goes here
NR_SCHED_QUEUES 16 ; MUST equal IDLE_PRIORYTY + 1
 
uglobal
rdy_head rd 16
endg
/kernel/branches/Kolibri-acpi/core/timers.inc
203,28 → 203,3
call unlock_timer_list
; 4. Return.
ret
 
; This is a simplified version of check_timers that does not call anything,
; just checks whether check_timers should do something.
proc check_timers_has_work?
pushf
cli
mov eax, [timer_list+TIMER.Next]
.loop:
cmp eax, timer_list
jz .done_nowork
mov edx, [timer_ticks]
sub edx, [eax+TIMER.Time]
jns .done_haswork
mov eax, [eax+TIMER.Next]
jmp .loop
.done_nowork:
popf
xor eax, eax
ret
.done_haswork:
popf
xor eax, eax
inc eax
ret
endp