forked from KolibriOS/kolibrios
sync with trunk
git-svn-id: svn://kolibrios.org@1198 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
9c06d10fb3
commit
6507cc5019
@ -681,6 +681,7 @@ EjectMedium:
|
||||
;* ChannelNumber - íîìåð êàíàëà; *
|
||||
;* DiskNumber - íîìåð äèñêà íà êàíàëå. *
|
||||
;*************************************************
|
||||
align 4
|
||||
check_ATAPI_device_event:
|
||||
pusha
|
||||
mov eax,[timer_ticks]
|
||||
|
@ -282,6 +282,7 @@ save_timer_fdd_motor:
|
||||
;*****************************************
|
||||
;* 闲温判世 抢呐衅嗜 论仕拮磐冗 涛椅欣 *
|
||||
;*****************************************
|
||||
align 4
|
||||
check_fdd_motor_status:
|
||||
cmp [fdd_motor_status],0
|
||||
je end_check_fdd_motor_status_1
|
||||
|
@ -815,9 +815,12 @@ end if
|
||||
dec al
|
||||
mov [boot_dev], al
|
||||
|
||||
; GET MEMORY MAP
|
||||
include 'detect/biosmem.inc'
|
||||
|
||||
; READ DISKETTE TO MEMORY
|
||||
|
||||
; cmp [boot_dev],0
|
||||
cmp [boot_dev],0
|
||||
jne no_sys_on_floppy
|
||||
mov si,diskload
|
||||
call print
|
||||
|
@ -104,7 +104,7 @@ _rs db 186,'
|
||||
_bt db 186,' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ',13,10,0
|
||||
|
||||
remark1 db "Default values were selected to match most of configurations, but not all.",0
|
||||
remark2 db "If you have LCD-monitor, disable VRR in the item [c] - you do not need it.",0
|
||||
remark2 db "If you have CRT-monitor, enable VRR in the item [c].",0
|
||||
remark3 db "If the system does not boot, try to disable the item [b].",0
|
||||
remarks dw remark1, remark2, remark3
|
||||
num_remarks = 3
|
||||
|
@ -109,7 +109,7 @@ save_quest db "J
|
||||
loader_block_error db "Alglaaduri andmed vigased, ei saa jätkata. Peatatud.",0
|
||||
|
||||
remark1 db "Default values were selected to match most of configurations, but not all.",0
|
||||
remark2 db "If you have LCD-monitor, disable VRR in the item [c] - you do not need it.",0
|
||||
remark2 db "If you have CRT-monitor, enable VRR in the item [c].",0
|
||||
remark3 db "If the system does not boot, try to disable the item [b].",0
|
||||
remarks dw remark1, remark2, remark3
|
||||
num_remarks = 3
|
||||
|
@ -114,7 +114,7 @@ save_quest db "Aktuelle Einstellungen speichern? [y/n]: ",0
|
||||
loader_block_error db "Bootloader Daten ungueltig, Kann nicht fortfahren. Angehalten.",0
|
||||
|
||||
remark1 db "Default values were selected to match most of configurations, but not all.",0
|
||||
remark2 db "If you have LCD-monitor, disable VRR in the item [c] - you do not need it.",0
|
||||
remark2 db "If you have CRT-monitor, enable VRR in the item [c].",0
|
||||
remark3 db "If the system does not boot, try to disable the item [b].",0
|
||||
remarks dw remark1, remark2, remark3
|
||||
num_remarks = 3
|
||||
|
@ -85,7 +85,7 @@ _bt db 186,'
|
||||
|
||||
|
||||
remark1 db "‡ ç¥¨ï ¯® 㬮«ç ¨î ¢ë¡à ë ¤«ï 㤮¡á⢠¡®«ìè¨á⢠, ® ¥ ¢á¥å.",0
|
||||
remark2 db "…᫨ ã ‚ á LCD-¬®¨â®à, ®âª«îç¨â¥ VRR ¢ ¯ãªâ¥ [c] - ® ‚ ¬ ¥ 㦥.",0
|
||||
remark2 db "…᫨ ã ‚ á <EFBFBD>‹’-¬®¨â®à, ¢ª«îç¨â¥ VRR ¢ ¯ãªâ¥ [c].",0
|
||||
remark3 db "…᫨ ã ‚ á ¥ £à㧨âáï á¨á⥬ , ¯®¯à®¡ã©â¥ ®âª«îç¨âì ¯ãªâ [b].",0
|
||||
remarks dw remark1, remark2, remark3
|
||||
num_remarks = 3
|
||||
|
@ -1,5 +1,5 @@
|
||||
@echo off
|
||||
|
||||
cls
|
||||
set languages=en ru ge et
|
||||
set drivers=sound sis infinity ensoniq ps2mouse com_mouse uart ati2d vmode
|
||||
set targets=all kernel drivers skins clean
|
||||
@ -74,6 +74,33 @@ goto :eof
|
||||
)
|
||||
cd ..
|
||||
move bin\drivers\vmode.obj bin\drivers\vmode.mdr
|
||||
|
||||
|
||||
kpack >nul 2>&1
|
||||
|
||||
if %errorlevel%==9009 goto :Error_KpackFailed
|
||||
|
||||
echo *
|
||||
echo ##############################################
|
||||
echo *
|
||||
echo Kpack KolibriOS drivers?
|
||||
echo *
|
||||
|
||||
set /P res=[y/n]?
|
||||
|
||||
if "%res%"=="y" (
|
||||
|
||||
echo *
|
||||
echo Compressing system
|
||||
|
||||
echo *
|
||||
for %%a in (bin\drivers\*.obj) do (
|
||||
echo ================== kpack %%a
|
||||
kpack %%a
|
||||
if not %errorlevel%==0 goto :Error_KpackFailed
|
||||
)
|
||||
|
||||
)
|
||||
goto :eof
|
||||
|
||||
|
||||
@ -95,11 +122,21 @@ goto :Exit_OK
|
||||
|
||||
:Error_FasmFailed
|
||||
echo error: fasm execution failed
|
||||
erase lang.inc
|
||||
erase lang.inc >nul 2>&1
|
||||
echo.
|
||||
pause
|
||||
exit 1
|
||||
|
||||
:Error_KpackFailed
|
||||
echo *** NOTICE ***
|
||||
echo If you want to pack all applications you may
|
||||
echo place "kpack" in accessible directory or system %PATH%.
|
||||
echo You can get this tool from KolibriOS distribution kit.
|
||||
pause
|
||||
exit 1
|
||||
|
||||
:Exit_OK
|
||||
echo all operations has been done
|
||||
echo.
|
||||
echo all operations have been done
|
||||
pause
|
||||
exit 0
|
||||
|
@ -186,7 +186,7 @@ TSS_SIZE equ (128+8192)
|
||||
|
||||
OS_BASE equ 0x80000000
|
||||
|
||||
window_data equ OS_BASE
|
||||
window_data equ (OS_BASE+0x0001000)
|
||||
|
||||
CURRENT_TASK equ (OS_BASE+0x0003000)
|
||||
TASK_COUNT equ (OS_BASE+0x0003004)
|
||||
@ -331,7 +331,7 @@ LFB_BASE equ 0xFE000000
|
||||
|
||||
new_app_base equ 0;
|
||||
|
||||
twdw equ 0x3000 ;(CURRENT_TASK-window_data)
|
||||
twdw equ 0x2000 ;(CURRENT_TASK-window_data)
|
||||
|
||||
std_application_base_address equ new_app_base
|
||||
RING0_STACK_SIZE equ (0x2000 - 512) ;512 áàéò äëÿ êîíòåêñòà FPU
|
||||
@ -469,8 +469,9 @@ struc EVENT
|
||||
.state dd ? ;internal flags
|
||||
.code dd ?
|
||||
rd 5
|
||||
.size = $ - .magic
|
||||
.codesize = $ - .code
|
||||
}
|
||||
EVENT_SIZE equ 52
|
||||
|
||||
virtual at 0
|
||||
EVENT EVENT
|
||||
@ -687,4 +688,3 @@ end virtual
|
||||
virtual at 0
|
||||
CSYM COFF_SYM
|
||||
end virtual
|
||||
|
||||
|
@ -414,62 +414,3 @@ debugger_notify:
|
||||
or byte [SLOT_BASE+eax+APPDATA.event_mask+1], 1 ; set flag 100h
|
||||
.ret:
|
||||
ret
|
||||
|
||||
debug_exc:
|
||||
test byte [esp+8+2], 2
|
||||
jnz v86_debug_exc
|
||||
; int 1 = #DB
|
||||
save_ring3_context
|
||||
cld
|
||||
mov ax, app_data ;os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov eax, dr6
|
||||
push eax
|
||||
xor eax, eax
|
||||
mov dr6, eax
|
||||
; test if debugging
|
||||
cli
|
||||
mov eax, [current_slot]
|
||||
mov eax, [eax+APPDATA.debugger_slot]
|
||||
test eax, eax
|
||||
jnz .debug
|
||||
sti
|
||||
; not debuggee => say error and terminate
|
||||
add esp, 0x20+4
|
||||
mov [error_interrupt], 1
|
||||
call show_error_parameters
|
||||
mov edx, [TASK_BASE]
|
||||
mov byte [edx+TASKDATA.state], 4
|
||||
jmp change_task
|
||||
.debug:
|
||||
; we are debugged process, notify debugger and suspend ourself
|
||||
; eax=debugger PID
|
||||
pop edx
|
||||
mov ebx, dr7
|
||||
mov cl, not 1
|
||||
.l1:
|
||||
test bl, 1
|
||||
jnz @f
|
||||
and dl, cl
|
||||
@@:
|
||||
shr ebx, 2
|
||||
add cl, cl
|
||||
inc ecx
|
||||
cmp cl, not 10h
|
||||
jnz .l1
|
||||
push edx ; DR6 image
|
||||
mov ecx, [TASK_BASE]
|
||||
push dword [ecx+TASKDATA.pid] ; PID
|
||||
push 12
|
||||
pop ecx
|
||||
push 3 ; 3 = debug exception
|
||||
call debugger_notify
|
||||
pop ecx
|
||||
pop ecx
|
||||
pop ecx
|
||||
mov edx, [TASK_BASE]
|
||||
mov byte [edx+TASKDATA.state], 1 ; suspended
|
||||
call change_task
|
||||
restore_ring3_context
|
||||
iretd
|
||||
|
@ -131,11 +131,11 @@ kernel_export:
|
||||
dd szGetPid , get_pid
|
||||
dd szCreateObject , create_kernel_object
|
||||
dd szDestroyObject , destroy_kernel_object
|
||||
dd szCreateEvent , create_event
|
||||
dd szRaiseEvent , raise_event
|
||||
dd szWaitEvent , wait_event
|
||||
dd szDestroyEvent , destroy_event
|
||||
dd szClearEvent , clear_event
|
||||
dd szCreateEvent , create_event ;see EVENT.inc for specification
|
||||
dd szRaiseEvent , raise_event ;see EVENT.inc for specification
|
||||
dd szWaitEvent , wait_event ;see EVENT.inc for specification
|
||||
dd szDestroyEvent , destroy_event ;see EVENT.inc for specification
|
||||
dd szClearEvent , clear_event ;see EVENT.inc for specification
|
||||
|
||||
dd szLoadCursor , load_cursor ;stdcall
|
||||
|
||||
@ -148,7 +148,7 @@ kernel_export:
|
||||
dd szSysMsgBoardChar , sys_msg_board
|
||||
dd szGetCurrentTask , get_curr_task
|
||||
dd szLoadFile , load_file ;retval eax, ebx
|
||||
dd szSendEvent , send_event
|
||||
dd szSendEvent , send_event ;see EVENT.inc for specification
|
||||
dd szSetMouseData , set_mouse_data ;stdcall
|
||||
dd szSleep , delay_ms
|
||||
dd szGetTimerTicks , get_timer_ticks
|
||||
@ -170,4 +170,3 @@ exp_lfb:
|
||||
dd 0 ;terminator, must be zero
|
||||
|
||||
endg
|
||||
|
||||
|
@ -142,7 +142,7 @@ fpu_restore:
|
||||
ret
|
||||
|
||||
align 4
|
||||
e7: ;#NM exception handler
|
||||
except_7: ;#NM exception handler
|
||||
save_ring3_context
|
||||
clts
|
||||
mov ax, app_data ;
|
||||
@ -181,108 +181,3 @@ e7: ;#NM exception handler
|
||||
iglobal
|
||||
fpu_owner dd 0
|
||||
endg
|
||||
|
||||
reg_eip equ ebp+4
|
||||
reg_cs equ ebp+8
|
||||
reg_eflags equ ebp+12
|
||||
reg_esp equ ebp+16
|
||||
reg_ss equ ebp+20
|
||||
|
||||
align 4
|
||||
except_16: ;fpu native exceptions handler
|
||||
test byte [esp+8+2], 2
|
||||
jnz v86_except_16
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
push eax
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
|
||||
mov ebx, [CURRENT_TASK]
|
||||
shl ebx, 8
|
||||
|
||||
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_handler]
|
||||
test eax, eax
|
||||
jz .default
|
||||
|
||||
mov ecx, [reg_eip]
|
||||
mov edx, [reg_esp]
|
||||
sub edx, 4
|
||||
mov [edx], ecx
|
||||
mov [reg_esp], edx
|
||||
mov dword [reg_eip], eax
|
||||
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
|
||||
leave
|
||||
iretd
|
||||
|
||||
.default:
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
leave
|
||||
|
||||
save_ring3_context ;debugger support
|
||||
|
||||
mov bl, 16
|
||||
jmp exc_c
|
||||
|
||||
align 4
|
||||
except_19: ;sse exceptions handler
|
||||
test byte [esp+8+2], 2
|
||||
jnz v86_except_19
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
push eax
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
|
||||
mov ebx, [current_slot]
|
||||
|
||||
mov eax, [ebx+APPDATA.sse_handler]
|
||||
test eax, eax
|
||||
jz .default
|
||||
|
||||
mov ecx, [reg_eip]
|
||||
mov edx, [reg_esp]
|
||||
sub edx, 4
|
||||
mov [edx], ecx
|
||||
mov [reg_esp], edx
|
||||
mov dword [reg_eip], eax
|
||||
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
|
||||
leave
|
||||
iretd
|
||||
|
||||
.default:
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
leave
|
||||
|
||||
save_ring3_context ;debugger support
|
||||
|
||||
mov bl, 19
|
||||
jmp exc_c
|
||||
|
||||
restore reg_eip
|
||||
restore reg_cs
|
||||
restore reg_eflags
|
||||
restore reg_esp
|
||||
restore reg_ss
|
||||
|
||||
|
||||
|
@ -91,7 +91,7 @@ macro remove_from_used op
|
||||
align 4
|
||||
proc init_kernel_heap
|
||||
|
||||
mov ecx, 64/4
|
||||
mov ecx, 64
|
||||
mov edi, mem_block_list
|
||||
xor eax, eax
|
||||
cld
|
||||
@ -138,8 +138,9 @@ proc init_kernel_heap
|
||||
mov [ebx+list_bk], eax
|
||||
mov [ebx+block_base], HEAP_BASE+4096*MEM_BLOCK_SIZE
|
||||
|
||||
mov ecx, [MEM_AMOUNT]
|
||||
sub ecx, (HEAP_BASE - OS_BASE + 4096*MEM_BLOCK_SIZE)
|
||||
mov ecx, [pg_data.kernel_pages]
|
||||
shl ecx, 12
|
||||
sub ecx, HEAP_BASE+4096*MEM_BLOCK_SIZE
|
||||
mov [heap_size], ecx
|
||||
mov [heap_free], ecx
|
||||
mov [ebx+block_size], ecx
|
||||
@ -152,7 +153,7 @@ proc init_kernel_heap
|
||||
mov byte [mem_block_map], 0xFC
|
||||
and [heap_mutex], 0
|
||||
mov [heap_blocks], 4095
|
||||
mov [free_blocks], 4095
|
||||
mov [free_blocks], 4094
|
||||
ret
|
||||
endp
|
||||
|
||||
|
@ -453,7 +453,7 @@ proc new_mem_resize stdcall, new_size:dword
|
||||
@@:
|
||||
call alloc_page
|
||||
test eax, eax
|
||||
jz .exit
|
||||
jz .exit_pop
|
||||
|
||||
stdcall map_page_table, edi, eax
|
||||
|
||||
@ -491,6 +491,9 @@ proc new_mem_resize stdcall, new_size:dword
|
||||
jb @B
|
||||
|
||||
jmp .update_size
|
||||
.exit_pop:
|
||||
pop edi
|
||||
pop esi
|
||||
.exit:
|
||||
xor eax, eax
|
||||
inc eax
|
||||
@ -544,23 +547,15 @@ get_pg_addr:
|
||||
|
||||
|
||||
align 4
|
||||
; Now it is called from core/sys32::exc_c (see stack frame there)
|
||||
proc page_fault_handler
|
||||
|
||||
test byte [esp+12+2], 2
|
||||
jnz v86_page_fault
|
||||
|
||||
.err_code equ ebp+32
|
||||
.err_addr equ ebp-4
|
||||
|
||||
pushad
|
||||
push ebx ;save exception number (#PF)
|
||||
mov ebp, esp
|
||||
mov eax, cr2
|
||||
push eax
|
||||
|
||||
mov ax, app_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov ebx, cr2
|
||||
push ebx ;that is locals: .err_addr = cr2
|
||||
inc [pg_data.pages_faults]
|
||||
|
||||
; push eax
|
||||
@ -571,10 +566,9 @@ proc page_fault_handler
|
||||
; pop edx
|
||||
; pop eax
|
||||
|
||||
mov ebx, [.err_addr]
|
||||
mov eax, [.err_code]
|
||||
mov eax, [pf_err_code]
|
||||
|
||||
cmp ebx, OS_BASE
|
||||
cmp ebx, OS_BASE ;ebx == .err_addr
|
||||
jb .user_space ;ñòðàíèöà â ïàìÿòè ïðèëîæåíèÿ ;
|
||||
|
||||
cmp ebx, page_tabs
|
||||
@ -583,7 +577,7 @@ proc page_fault_handler
|
||||
cmp ebx, kernel_tabs
|
||||
jb .alloc;.app_tabs ;òàáëèöû ñòðàíèö ïðèëîæåíèÿ ;
|
||||
;ïðîñòî ñîçäàäèì îäíó
|
||||
|
||||
if 0 ;ïîêà ýòî ïðîñòî ëèøíåå
|
||||
cmp ebx, LFB_BASE
|
||||
jb .core_tabs ;òàáëèöû ñòðàíèö ÿäðà
|
||||
;Îøèáêà
|
||||
@ -591,8 +585,13 @@ proc page_fault_handler
|
||||
;îáëàñòü LFB
|
||||
;Îøèáêà
|
||||
jmp .fail
|
||||
end if
|
||||
.core_tabs:
|
||||
.fail: ;simply return to caller
|
||||
mov esp, ebp
|
||||
pop ebx ;restore exception number (#PF)
|
||||
ret
|
||||
|
||||
align 4
|
||||
.user_space:
|
||||
test eax, PG_MAP
|
||||
jnz .err_access ;Ñòðàíèöà ïðèñóòñòâóåò
|
||||
@ -615,33 +614,32 @@ align 4
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
stdcall map_page,[ebp-4],eax,dword PG_UW
|
||||
stdcall map_page,[.err_addr],eax,dword PG_UW
|
||||
|
||||
mov edi, [ebp-4]
|
||||
mov edi, [.err_addr]
|
||||
and edi, 0xFFFFF000
|
||||
mov ecx, 1024
|
||||
xor eax, eax
|
||||
cld
|
||||
;cld ;caller is duty for this
|
||||
rep stosd
|
||||
.exit:
|
||||
mov esp, ebp
|
||||
popad
|
||||
add esp, 4
|
||||
.exit: ;iret with repeat fault instruction
|
||||
add esp,12 ;clear in stack: locals(.err_addr) + #PF + ret_to_caller
|
||||
restore_ring3_context
|
||||
iretd
|
||||
|
||||
.err_access:
|
||||
.err_access = .fail
|
||||
;íèêîãäà íå ïðîèñõîäèò
|
||||
jmp .fail
|
||||
;jmp .fail
|
||||
|
||||
.kernel_space:
|
||||
test eax, PG_MAP
|
||||
jz .fail ;ñòðàíèöà íå ïðèñóòñòâóåò
|
||||
|
||||
test eax, 4 ;U/S
|
||||
test eax,12 ;U/S (+below)
|
||||
jnz .fail ;ïðèëîæåíèå îáðàòèëîñü ê ïàìÿòè
|
||||
;ÿäðà
|
||||
test eax, 8
|
||||
jnz .fail ;óñòàíîâëåí çàðåçåðâèðîâàííûé áèò
|
||||
;test eax, 8
|
||||
;jnz .fail ;óñòàíîâëåí çàðåçåðâèðîâàííûé áèò
|
||||
;â òàáëèöàõ ñòðàíèö. äîáàâëåíî â P4/Xeon
|
||||
|
||||
;ïîïûòêà çàïèñè â çàùèù¸ííóþ ñòðàíèöó ÿäðà
|
||||
@ -660,7 +658,7 @@ align 4
|
||||
jz .fail
|
||||
|
||||
push eax
|
||||
stdcall map_page,[ebp-4],eax,dword PG_SW
|
||||
stdcall map_page,[.err_addr],eax,dword PG_SW
|
||||
pop eax
|
||||
mov edi, [.err_addr]
|
||||
and edi, -4096
|
||||
@ -674,26 +672,9 @@ align 4
|
||||
|
||||
add esi, [default_io_map]
|
||||
mov ecx, 4096/4
|
||||
cld
|
||||
;cld ;caller is duty for this
|
||||
rep movsd
|
||||
jmp .exit
|
||||
|
||||
|
||||
;íå îáðàáàòûâàåì. Îøèáêà
|
||||
|
||||
.core_tabs:
|
||||
.fail:
|
||||
mov esp, ebp
|
||||
popad
|
||||
add esp, 4
|
||||
|
||||
; iretd
|
||||
|
||||
save_ring3_context ;debugger support
|
||||
|
||||
mov bl, 14
|
||||
jmp exc_c
|
||||
iretd
|
||||
endp
|
||||
|
||||
align 4
|
||||
@ -983,29 +964,29 @@ endp
|
||||
align 4
|
||||
sysfn_meminfo:
|
||||
|
||||
; add ebx, new_app_base
|
||||
cmp ebx, OS_BASE
|
||||
; add ecx, new_app_base
|
||||
cmp ecx, OS_BASE
|
||||
jae .fail
|
||||
|
||||
mov eax, [pg_data.pages_count]
|
||||
mov [ebx], eax
|
||||
mov [ecx], eax
|
||||
shl eax, 12
|
||||
mov [esp+36], eax
|
||||
mov ecx, [pg_data.pages_free]
|
||||
mov [ebx+4], ecx
|
||||
mov edx, [pg_data.pages_faults]
|
||||
mov [ebx+8], edx
|
||||
mov esi, [heap_size]
|
||||
mov [ebx+12], esi
|
||||
mov edi, [heap_free]
|
||||
mov [ebx+16], edi
|
||||
mov [esp+32], eax
|
||||
mov eax, [pg_data.pages_free]
|
||||
mov [ecx+4], eax
|
||||
mov eax, [pg_data.pages_faults]
|
||||
mov [ecx+8], eax
|
||||
mov eax, [heap_size]
|
||||
mov [ecx+12], eax
|
||||
mov eax, [heap_free]
|
||||
mov [ecx+16], eax
|
||||
mov eax, [heap_blocks]
|
||||
mov [ebx+20], eax
|
||||
mov ecx, [free_blocks]
|
||||
mov [ebx+24], ecx
|
||||
mov [ecx+20], eax
|
||||
mov eax, [free_blocks]
|
||||
mov [ecx+24], eax
|
||||
ret
|
||||
.fail:
|
||||
mov dword [esp+36], -1
|
||||
mov dword [esp+32], -1
|
||||
ret
|
||||
|
||||
align 4
|
||||
@ -1014,15 +995,17 @@ f68call:
|
||||
dd f68.12
|
||||
dd f68.13
|
||||
dd f68.14
|
||||
dd f68.15
|
||||
dd f68.fail ;moved to f68.24
|
||||
dd f68.16
|
||||
dd f68.17
|
||||
dd f68.18
|
||||
dd f68.fail ;moved to f68.25
|
||||
dd f68.19
|
||||
dd f68.20
|
||||
dd f68.21
|
||||
dd f68.22
|
||||
dd f68.23
|
||||
dd f68.24
|
||||
dd f68.25
|
||||
|
||||
align 4
|
||||
f68:
|
||||
@ -1032,7 +1015,7 @@ f68:
|
||||
cmp eax, 11
|
||||
jb .fail
|
||||
|
||||
cmp eax, 23
|
||||
cmp eax, 25
|
||||
ja .fail
|
||||
|
||||
jmp dword [f68call+eax*4-11*4]
|
||||
@ -1051,14 +1034,16 @@ f68:
|
||||
.14:
|
||||
cmp ebx, OS_BASE
|
||||
jae .fail
|
||||
stdcall get_event_ex, ebx, ecx
|
||||
mov edi,ebx
|
||||
call get_event_ex
|
||||
mov [esp+36], eax
|
||||
ret
|
||||
.15:
|
||||
mov ecx, [current_slot]
|
||||
mov eax, [ecx+APPDATA.fpu_handler]
|
||||
mov [ecx+APPDATA.fpu_handler], ebx
|
||||
mov [esp+36], eax
|
||||
.24:
|
||||
mov eax, [current_slot]
|
||||
xchg ebx, [eax+APPDATA.exc_handler]
|
||||
xchg ecx, [eax+APPDATA.except_mask]
|
||||
mov [esp+36], ebx ; reg_eax+8
|
||||
mov [esp+24], ecx ; reg_ebx+8
|
||||
ret
|
||||
.16:
|
||||
test ebx, ebx
|
||||
@ -1072,12 +1057,15 @@ f68:
|
||||
call srv_handlerEx ;ebx
|
||||
mov [esp+36], eax
|
||||
ret
|
||||
.18:
|
||||
mov ecx, [current_slot]
|
||||
mov eax, [ecx+APPDATA.sse_handler]
|
||||
mov [ecx+APPDATA.sse_handler], ebx
|
||||
mov [esp+36], eax
|
||||
ret
|
||||
.25:
|
||||
cmp ebx,32
|
||||
jae .fail
|
||||
mov eax, [current_slot]
|
||||
btr [eax+APPDATA.except_mask],ebx
|
||||
setc byte[esp+36]
|
||||
jecxz @f
|
||||
bts [eax+APPDATA.except_mask],ebx
|
||||
@@: ret
|
||||
.19:
|
||||
cmp ebx, OS_BASE
|
||||
jae .fail
|
||||
@ -1318,6 +1306,3 @@ proc create_ring_buffer stdcall, size:dword, flags:dword
|
||||
.fail:
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
|
||||
|
@ -16,74 +16,35 @@ $Revision: 907 $
|
||||
align 32
|
||||
irq0:
|
||||
pushad
|
||||
mov ax, app_data ;
|
||||
mov ds, ax
|
||||
Mov ds, ax, app_data
|
||||
mov es, ax
|
||||
|
||||
; cmp dword[CURRENT_TASK], 1
|
||||
; jnz @f
|
||||
; mov eax, [esp + 32]
|
||||
; cmp eax, idle_loop + 1
|
||||
; jz @f
|
||||
; DEBUGF 1, "K : OOOPS! EAX = 0x%x\n", eax
|
||||
; @@:
|
||||
|
||||
inc dword [timer_ticks]
|
||||
|
||||
inc [timer_ticks]
|
||||
mov eax, [timer_ticks]
|
||||
call playNote ; <<<--- Speaker driver
|
||||
|
||||
cmp eax,[next_usage_update]
|
||||
sub eax,[next_usage_update]
|
||||
cmp eax,100
|
||||
jb .nocounter
|
||||
add eax,100
|
||||
mov [next_usage_update],eax
|
||||
add [next_usage_update],100
|
||||
call updatecputimes
|
||||
.nocounter:
|
||||
cmp [DONT_SWITCH], byte 1
|
||||
jne .change_task
|
||||
|
||||
mov al,0x20 ; send End Of Interrupt signal
|
||||
mov dx,0x20
|
||||
out dx,al
|
||||
|
||||
mov [DONT_SWITCH], byte 0
|
||||
|
||||
popad
|
||||
iretd
|
||||
|
||||
.change_task:
|
||||
call update_counters
|
||||
|
||||
out 0x20,al
|
||||
btr dword[DONT_SWITCH], 0
|
||||
jc .return
|
||||
call find_next_task
|
||||
mov ecx, eax
|
||||
|
||||
mov al,0x20 ; send End Of Interrupt signal
|
||||
mov dx,0x20
|
||||
out dx,al
|
||||
|
||||
test ecx, ecx ; if there is only one running process
|
||||
jnz .return
|
||||
|
||||
jz .return ; if there is only one running process
|
||||
call do_change_task
|
||||
|
||||
.return:
|
||||
popad
|
||||
; popfd
|
||||
iretd
|
||||
|
||||
|
||||
align 4
|
||||
change_task:
|
||||
|
||||
pushfd
|
||||
cli
|
||||
pushad
|
||||
|
||||
call update_counters
|
||||
|
||||
if 0
|
||||
|
||||
; \begin{Mario79}
|
||||
; \begin{Mario79} ; <- must be refractoried, if used...
|
||||
cmp [dma_task_switched], 1
|
||||
jne .find_next_task
|
||||
mov [dma_task_switched], 0
|
||||
@ -96,195 +57,152 @@ if 0
|
||||
jmp @f
|
||||
.find_next_task:
|
||||
; \end{Mario79}
|
||||
|
||||
end if
|
||||
|
||||
call find_next_task
|
||||
test eax, eax ; the same task -> skip switch
|
||||
jnz .return
|
||||
@@:
|
||||
mov [DONT_SWITCH],byte 1
|
||||
jz .return ; the same task -> skip switch
|
||||
@@: mov byte[DONT_SWITCH], 1
|
||||
call do_change_task
|
||||
|
||||
.return:
|
||||
popad
|
||||
popfd
|
||||
ret
|
||||
|
||||
|
||||
uglobal
|
||||
align 4
|
||||
far_jump:
|
||||
.offs dd ?
|
||||
.sel dw ?
|
||||
context_counter dd ? ;noname & halyavin
|
||||
next_usage_update dd ?
|
||||
timer_ticks dd ?
|
||||
prev_slot dd ?
|
||||
event_sched dd ?
|
||||
; far_jump:
|
||||
; .offs dd ?
|
||||
; .sel dw ?
|
||||
context_counter dd 0 ;noname & halyavin
|
||||
next_usage_update dd 0
|
||||
timer_ticks dd 0
|
||||
; prev_slot dd ?
|
||||
; event_sched dd ?
|
||||
endg
|
||||
|
||||
|
||||
align 4
|
||||
update_counters:
|
||||
mov edi, [TASK_BASE]
|
||||
mov ebx, [edi+TASKDATA.counter_add] ; time stamp counter add
|
||||
rdtsc
|
||||
sub eax, ebx
|
||||
add eax, [edi+TASKDATA.counter_sum] ; counter sum
|
||||
mov [edi+TASKDATA.counter_sum], eax
|
||||
sub eax, [edi+TASKDATA.counter_add] ; time stamp counter add
|
||||
add [edi+TASKDATA.counter_sum], eax ; counter sum
|
||||
ret
|
||||
|
||||
|
||||
; Find next task to execute
|
||||
; result: ebx = number of the selected task
|
||||
; eax = 1 if the task is the same
|
||||
; edi = address of the data for the task in ebx
|
||||
; [0x3000] = ebx and [0x3010] = edi
|
||||
; corrupts other regs
|
||||
find_next_task:
|
||||
mov ebx, [CURRENT_TASK]
|
||||
mov edi, [TASK_BASE]
|
||||
mov [prev_slot], ebx
|
||||
|
||||
.waiting_for_termination:
|
||||
.waiting_for_reuse:
|
||||
.waiting_for_event:
|
||||
.suspended:
|
||||
cmp ebx, [TASK_COUNT]
|
||||
jb @f
|
||||
mov edi, CURRENT_TASK
|
||||
xor ebx, ebx
|
||||
@@:
|
||||
|
||||
add edi,0x20
|
||||
inc ebx
|
||||
|
||||
mov al, byte [edi+TASKDATA.state]
|
||||
test al, al
|
||||
jz .found
|
||||
cmp al, 1
|
||||
jz .suspended
|
||||
cmp al, 2
|
||||
jz .suspended
|
||||
cmp al, 3
|
||||
je .waiting_for_termination
|
||||
cmp al, 4
|
||||
je .waiting_for_termination
|
||||
cmp al, 9
|
||||
je .waiting_for_reuse
|
||||
|
||||
mov [CURRENT_TASK],ebx
|
||||
mov [TASK_BASE],edi
|
||||
|
||||
cmp al, 5
|
||||
jne .noevents
|
||||
call get_event_for_app
|
||||
test eax, eax
|
||||
jnz @f
|
||||
mov eax, ebx
|
||||
shl eax, 8
|
||||
mov eax, [SLOT_BASE + APPDATA.wait_timeout + eax]
|
||||
cmp eax, [timer_ticks]
|
||||
jae .waiting_for_event
|
||||
xor eax, eax
|
||||
@@:
|
||||
mov [event_sched], eax
|
||||
mov [edi+TASKDATA.state], byte 0
|
||||
.noevents:
|
||||
.found:
|
||||
mov [CURRENT_TASK],ebx
|
||||
mov [TASK_BASE],edi
|
||||
rdtsc ;call _rdtsc
|
||||
mov [edi+TASKDATA.counter_add],eax
|
||||
|
||||
mov esi, [prev_slot]
|
||||
xor eax, eax
|
||||
cmp ebx, esi
|
||||
sete al
|
||||
ret
|
||||
|
||||
; param
|
||||
; ebx = incoming task
|
||||
; esi = outcomig task
|
||||
|
||||
do_change_task:
|
||||
|
||||
shl ebx, 8
|
||||
add ebx, SLOT_BASE
|
||||
mov [current_slot], ebx
|
||||
|
||||
shl esi, 8
|
||||
add esi, SLOT_BASE
|
||||
|
||||
mov [esi+APPDATA.saved_esp], esp
|
||||
mov esp, [ebx+APPDATA.saved_esp]
|
||||
|
||||
; set thread io map
|
||||
|
||||
mov ecx, [ebx+APPDATA.io_map]
|
||||
mov edx, [ebx+APPDATA.io_map+4]
|
||||
mov dword [page_tabs+((tss._io_map_0 and -4096) shr 10)], ecx
|
||||
mov dword [page_tabs+((tss._io_map_1 and -4096) shr 10)], edx
|
||||
|
||||
mov eax, [ebx+APPDATA.dir_table]
|
||||
cmp eax, [esi+APPDATA.dir_table]
|
||||
je @F
|
||||
mov cr3, eax
|
||||
@@:
|
||||
mov eax, [ebx+APPDATA.saved_esp0]
|
||||
mov [tss._esp0], eax
|
||||
mov ax, graph_data
|
||||
mov gs, ax
|
||||
|
||||
mov eax, [CURRENT_TASK]
|
||||
cmp eax, [fpu_owner]
|
||||
clts ;clear a task switch flag
|
||||
je @F
|
||||
;and set it again if the owner
|
||||
mov ecx, cr0 ;of a fpu has changed
|
||||
or ecx, CR0_TS
|
||||
mov cr0, ecx
|
||||
@@:
|
||||
inc [context_counter] ;noname & halyavin
|
||||
test [ebx+APPDATA.dbg_state], 1
|
||||
jnz @F
|
||||
ret
|
||||
@@:
|
||||
mov eax, [ebx+APPDATA.dbg_regs.dr0]
|
||||
mov dr0, eax
|
||||
mov eax, [ebx+APPDATA.dbg_regs.dr1]
|
||||
mov dr1, eax
|
||||
mov eax, [ebx+APPDATA.dbg_regs.dr2]
|
||||
mov dr2, eax
|
||||
mov eax, [ebx+APPDATA.dbg_regs.dr3]
|
||||
mov dr3, eax
|
||||
xor eax, eax
|
||||
mov dr6, eax
|
||||
mov eax, [ebx+APPDATA.dbg_regs.dr7]
|
||||
mov dr7, eax
|
||||
ret
|
||||
|
||||
align 4
|
||||
updatecputimes:
|
||||
|
||||
mov eax,[idleuse]
|
||||
xor eax,eax
|
||||
xchg eax,[idleuse]
|
||||
mov [idleusesec],eax
|
||||
mov [idleuse],dword 0
|
||||
mov ecx, [TASK_COUNT]
|
||||
mov edi, TASK_DATA
|
||||
.newupdate:
|
||||
mov ebx,[edi+TASKDATA.counter_sum]
|
||||
mov [edi+TASKDATA.cpu_usage],ebx
|
||||
mov [edi+TASKDATA.counter_sum],dword 0
|
||||
xor eax,eax
|
||||
xchg eax,[edi+TASKDATA.counter_sum]
|
||||
mov [edi+TASKDATA.cpu_usage],eax
|
||||
add edi,0x20
|
||||
dec ecx
|
||||
jnz .newupdate
|
||||
|
||||
loop .newupdate
|
||||
ret
|
||||
|
||||
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:
|
||||
;param:
|
||||
; ebx = address of the APPDATA for incoming task (new)
|
||||
;warning:
|
||||
; [CURRENT_TASK] and [TASK_BASE] must be changed before (e.g. in find_next_task)
|
||||
; [current_slot] is the outcoming (old), and set here to a new value (ebx)
|
||||
;scratched: eax,ecx,esi
|
||||
mov esi,ebx
|
||||
xchg esi,[current_slot]
|
||||
; set new stack after saving old
|
||||
mov [esi+APPDATA.saved_esp], esp
|
||||
mov esp, [ebx+APPDATA.saved_esp]
|
||||
; set new thread io-map
|
||||
Mov dword [page_tabs+((tss._io_map_0 and -4096) shr 10)],eax,[ebx+APPDATA.io_map]
|
||||
Mov dword [page_tabs+((tss._io_map_1 and -4096) shr 10)],eax,[ebx+APPDATA.io_map+4]
|
||||
; set new thread memory-map
|
||||
mov ecx, APPDATA.dir_table
|
||||
mov eax, [ebx+ecx] ;offset>0x7F
|
||||
cmp eax, [esi+ecx] ;offset>0x7F
|
||||
je @f
|
||||
mov cr3, eax
|
||||
@@: ; set tss.esp0
|
||||
Mov [tss._esp0],eax,[ebx+APPDATA.saved_esp0]
|
||||
; set gs selector unconditionally
|
||||
Mov gs,ax,graph_data
|
||||
; set CR0.TS
|
||||
cmp bh, byte[fpu_owner] ;bh == incoming task (new)
|
||||
clts ;clear a task switch flag
|
||||
je @f
|
||||
mov eax, cr0 ;and set it again if the owner
|
||||
or eax, CR0_TS ;of a fpu has changed
|
||||
mov cr0, eax
|
||||
@@: ; set context_counter (only for user pleasure ???)
|
||||
inc [context_counter] ;noname & halyavin
|
||||
; set debug-registers, if it's necessary
|
||||
test byte[ebx+APPDATA.dbg_state], 1
|
||||
jz @f
|
||||
xor eax, eax
|
||||
mov dr6, eax
|
||||
lea esi,[ebx+ecx+APPDATA.dbg_regs-APPDATA.dir_table] ;offset>0x7F
|
||||
cld
|
||||
macro lodsReg [reg] {
|
||||
lodsd
|
||||
mov reg,eax
|
||||
} lodsReg dr0, dr1, dr2, dr3, dr7
|
||||
purge lodsReg
|
||||
@@: ret
|
||||
;end.
|
||||
|
||||
if 0
|
||||
|
||||
|
||||
struc TIMER
|
||||
{
|
||||
.next dd ?
|
||||
@ -293,14 +211,6 @@ struc TIMER
|
||||
.arg dd ?
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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)
|
||||
@ -310,7 +220,6 @@ NR_SCHED_QUEUES 16 ; MUST equal IDLE_PRIORYTY + 1
|
||||
|
||||
rdy_head rd 16
|
||||
|
||||
|
||||
align 4
|
||||
pick_task:
|
||||
|
||||
@ -330,7 +239,6 @@ pick_task:
|
||||
inc eax
|
||||
jmp .pick
|
||||
|
||||
|
||||
; param
|
||||
; eax= task
|
||||
;
|
||||
@ -338,7 +246,6 @@ pick_task:
|
||||
; eax= task
|
||||
; ebx= queue
|
||||
; ecx= front if 1 or back if 0
|
||||
|
||||
align 4
|
||||
shed:
|
||||
cmp [eax+.tics_left], 0 ;signed compare
|
||||
@ -356,7 +263,6 @@ shed:
|
||||
|
||||
; param
|
||||
; eax= task
|
||||
|
||||
align 4
|
||||
enqueue:
|
||||
call shed ;eax
|
||||
@ -385,4 +291,3 @@ enqueue:
|
||||
ret
|
||||
|
||||
end if
|
||||
|
||||
|
@ -14,212 +14,227 @@
|
||||
$Revision: 982 $
|
||||
|
||||
|
||||
align 4
|
||||
idtreg:
|
||||
dw 8*0x41-1
|
||||
dd idts+8
|
||||
|
||||
align 4 ;3A08
|
||||
build_interrupt_table:
|
||||
|
||||
mov edi, idts+8
|
||||
mov edi, idts
|
||||
mov esi, sys_int
|
||||
mov ecx, 0x40
|
||||
@@:
|
||||
lodsd
|
||||
mov [edi], ax ; lower part of offset
|
||||
mov [edi+2], word os_code ; segment selector
|
||||
mov ax, word 10001110b shl 8 ; type: interrupt gate
|
||||
mov [edi+4], eax
|
||||
add edi, 8
|
||||
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
|
||||
|
||||
;mov edi,8*0x40+idts+8
|
||||
mov dword [edi], (i40 and 0xFFFF) or (os_code shl 16)
|
||||
mov dword [edi+4], (11101111b shl 8) or (i40 and 0xFFFF0000)
|
||||
; type: trap gate
|
||||
movsd ;copy low dword of trap gate for int 0x40
|
||||
movsd ;copy high dword of trap gate for int 0x40
|
||||
lidt [esi]
|
||||
ret
|
||||
|
||||
iglobal
|
||||
|
||||
msg_sel_ker db "kernel", 0
|
||||
msg_sel_app db "application", 0
|
||||
|
||||
align 4
|
||||
sys_int:
|
||||
dd e0,debug_exc,e2,e3
|
||||
dd e4,e5,e6,e7
|
||||
dd e8,e9,e10,e11
|
||||
dd e12,e13,page_fault_handler,e15
|
||||
|
||||
dd except_16, e17,e18, except_19
|
||||
times 12 dd unknown_interrupt
|
||||
;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
|
||||
|
||||
;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
|
||||
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
|
||||
|
||||
times 16 dd unknown_interrupt
|
||||
;int_0x40 gate trap (for directly copied)
|
||||
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 ;ïðîñòî âûðàâíèâàíèå
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
dd i40
|
||||
endg
|
||||
|
||||
macro save_ring3_context
|
||||
{
|
||||
macro save_ring3_context {
|
||||
pushad
|
||||
}
|
||||
macro restore_ring3_context
|
||||
{
|
||||
macro restore_ring3_context {
|
||||
popad
|
||||
}
|
||||
|
||||
; simply return control to interrupted process
|
||||
unknown_interrupt:
|
||||
iret
|
||||
|
||||
macro exc_wo_code [num]
|
||||
{
|
||||
forward
|
||||
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
|
||||
|
||||
macro exc_w_code [num]
|
||||
{
|
||||
forward
|
||||
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
|
||||
|
||||
exc_wo_code 0, 2, 3, 4, 5, 6, 9, 15, 18
|
||||
exc_w_code 8, 10, 11, 12, 13, 14, 17
|
||||
|
||||
exc_c:
|
||||
mov ax, app_data ;èñêëþ÷åíèå
|
||||
mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíè
|
||||
mov es, ax ;â ðåãèñòðû
|
||||
uglobal
|
||||
pf_err_code dd ?
|
||||
endg
|
||||
|
||||
page_fault_exc: ; äóðàêîóñòî÷èâîñòü: ñåëåêòîðû èñïîð÷åíû...
|
||||
pop [ss:pf_err_code]; äåéñòâèòåëüíî äî ñëåäóþùåãî #PF
|
||||
save_ring3_context
|
||||
mov bl,14
|
||||
|
||||
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
|
||||
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 ; çàãðóçèì ïðàâèëüíûå çíà÷åíèÿ
|
||||
mov es,ax ; â ñåãìåíòíûå ðåãèñòðû
|
||||
cld ; è ïðèâîäèì DF ê ñòàíäàðòó
|
||||
movzx ebx,bl
|
||||
; redirect to V86 manager? (EFLAGS & 0x20000) != 0?
|
||||
test byte [esp+20h+8+2], 2
|
||||
test byte[reg_eflags+2],2
|
||||
jnz v86_exc_c
|
||||
|
||||
; test if debugging
|
||||
cli
|
||||
mov eax, [current_slot]
|
||||
mov eax, [eax+APPDATA.debugger_slot]
|
||||
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
|
||||
movzx eax, bl
|
||||
mov [error_interrupt], eax
|
||||
call show_error_parameters
|
||||
add esp, 0x20
|
||||
mov edx, [TASK_BASE]
|
||||
mov [edx + TASKDATA.state], byte 4
|
||||
|
||||
jmp change_task
|
||||
|
||||
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
|
||||
.debug:
|
||||
; we are debugged process, notify debugger and suspend ourself
|
||||
; eax=debugger PID
|
||||
cld
|
||||
movzx ecx, bl
|
||||
push ecx
|
||||
mov ecx, [TASK_BASE]
|
||||
push dword [ecx+TASKDATA.pid] ; PID of current process
|
||||
push 12
|
||||
pop ecx
|
||||
push 1 ; 1=exception
|
||||
call debugger_notify
|
||||
pop ecx
|
||||
pop ecx
|
||||
pop ecx
|
||||
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
|
||||
call change_task ; SEE: core/shed.inc
|
||||
restore_ring3_context
|
||||
iretd
|
||||
|
||||
iglobal
|
||||
hexletters db '0123456789ABCDEF'
|
||||
error_interrupt dd -1
|
||||
endg
|
||||
IRetToUserHook:
|
||||
xchg eax, [reg_eip]
|
||||
sub dword[reg_esp3], 8
|
||||
mov edi, [reg_esp3]
|
||||
stosd
|
||||
mov [edi], ebx
|
||||
restore_ring3_context
|
||||
unknown_interrupt:
|
||||
iretd
|
||||
|
||||
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
show_error_parameters:
|
||||
mov eax,[CURRENT_TASK]
|
||||
shl eax, 5
|
||||
DEBUGF 1, "K : Process - forced terminate PID: %x\n", [CURRENT_TASK + TASKDATA.pid + eax]
|
||||
mov eax, [error_interrupt]
|
||||
cmp al, 0x08
|
||||
jne @f
|
||||
DEBUGF 1, "K : Double fault\n"
|
||||
jmp defined_error
|
||||
@@:
|
||||
cmp al, 0x0a
|
||||
jne @f
|
||||
DEBUGF 1, "K : Invalid TSS\n"
|
||||
jmp defined_error
|
||||
@@:
|
||||
cmp al, 0x0b
|
||||
jne @f
|
||||
DEBUGF 1, "K : Segment not present\n"
|
||||
jmp defined_error
|
||||
@@:
|
||||
cmp al, 0x0c
|
||||
jne @f
|
||||
DEBUGF 1, "K : Stack fault\n"
|
||||
jmp defined_error
|
||||
@@:
|
||||
cmp al, 0x0d
|
||||
jne @f
|
||||
DEBUGF 1, "K : General protection fault\n"
|
||||
jmp defined_error
|
||||
@@:
|
||||
cmp al, 0x0e
|
||||
jne @f
|
||||
DEBUGF 1, "K : Page fault\n"
|
||||
jmp defined_error
|
||||
@@:
|
||||
DEBUGF 1, "K : Undefined Exception\n"
|
||||
defined_error:
|
||||
DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [esp + 0x20], [esp - 12 + 0x20], [esp - 4 + 0x20]
|
||||
DEBUGF 1, "K : EDX : %x ESI : %x EDI : %x\n", [esp - 8 + 0x20], [esp - 24 + 0x20], [esp - 28 + 0x20]
|
||||
DEBUGF 1, "K : EBP : %x EIP : %x ", [esp - 20 + 0x20], [esp + 4 + 0x20]
|
||||
|
||||
mov eax, [esp + 8 + 0x20]
|
||||
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, [esp + 16 + 0x20]
|
||||
mov ebx, [reg_esp3+4]
|
||||
cmp eax, app_code
|
||||
je @f
|
||||
mov edi, msg_sel_ker
|
||||
mov ebx, [esp - 16 + 0x20]
|
||||
@@:
|
||||
DEBUGF 1, "ESP : %x\nK : Flags : %x CS : %x (%s)\n", ebx, [esp + 12 + 0x20], eax, edi
|
||||
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
|
||||
restore reg_esp3
|
||||
restore reg_eflags
|
||||
restore reg_cs
|
||||
restore reg_eip
|
||||
restore reg_eax
|
||||
restore reg_ecx
|
||||
restore reg_edx
|
||||
restore reg_ebx
|
||||
restore reg_esp0
|
||||
restore reg_ebp
|
||||
restore reg_esi
|
||||
restore reg_edi
|
||||
|
||||
; irq1 -> hid/keyboard.inc
|
||||
macro irqh [num]
|
||||
{
|
||||
forward
|
||||
macro irqh [num] {
|
||||
p_irq#num :
|
||||
mov edi, num
|
||||
jmp irqhandler
|
||||
}
|
||||
|
||||
irqh 2,3,4,5,7,8,9,10,11
|
||||
|
||||
|
||||
p_irq6:
|
||||
@ -277,26 +292,18 @@ ready_for_next_irq_1:
|
||||
ret
|
||||
|
||||
irqD:
|
||||
save_ring3_context
|
||||
mov ax, app_data ;os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov dx,0xf0
|
||||
push eax
|
||||
mov al,0
|
||||
out dx,al
|
||||
|
||||
mov dx,0xa0
|
||||
out 0xf0,al
|
||||
mov al,0x20
|
||||
out dx,al
|
||||
mov dx,0x20
|
||||
out dx,al
|
||||
|
||||
restore_ring3_context
|
||||
|
||||
out 0xa0,al
|
||||
out 0x20,al
|
||||
pop eax
|
||||
iret
|
||||
|
||||
|
||||
irqh 2,3,4,5,7,8,9,10,11
|
||||
|
||||
irqhandler:
|
||||
|
||||
mov esi,edi ; 1
|
||||
@ -421,8 +428,8 @@ sys_threads:
|
||||
jmp new_sys_threads
|
||||
|
||||
iglobal
|
||||
process_terminating db 'K : Process - terminating',13,10,0
|
||||
process_terminated db 'K : Process - done',13,10,0
|
||||
; process_terminating db 'K : Process - terminating',13,10,0
|
||||
; process_terminated db 'K : Process - done',13,10,0
|
||||
msg_obj_destroy db 'K : destroy app object',13,10,0
|
||||
endg
|
||||
|
||||
@ -445,7 +452,6 @@ terminate: ; terminate application
|
||||
@@:
|
||||
;mov esi,process_terminating
|
||||
;call sys_msg_board_str
|
||||
DEBUGF 1,"%s",process_terminating
|
||||
@@:
|
||||
cli
|
||||
cmp [application_table_status],0
|
||||
@ -805,7 +811,6 @@ term9:
|
||||
mov [application_table_status],0
|
||||
;mov esi,process_terminated
|
||||
;call sys_msg_board_str
|
||||
DEBUGF 1,"%s",process_terminated
|
||||
add esp, 4
|
||||
ret
|
||||
restore .slot
|
||||
|
@ -16,27 +16,11 @@ cross_order:
|
||||
mov ecx, edx
|
||||
mov edx, esi
|
||||
mov esi, edi
|
||||
mov edi, [esp+28 + 4]
|
||||
and edi,0xff
|
||||
movzx edi, byte[esp+28 + 4]
|
||||
call dword [servetable+edi*4]
|
||||
ret
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; SYSTEM CALL ENTRY ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
align 16
|
||||
i40:
|
||||
pushad
|
||||
cld
|
||||
movzx eax, al
|
||||
call dword [servetable2 + eax * 4]
|
||||
popad
|
||||
iretd
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; SYSENTER ENTRY ;;
|
||||
@ -68,6 +52,21 @@ sysenter_entry:
|
||||
pop edx
|
||||
sysexit
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; SYSTEM CALL ENTRY ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
align 16
|
||||
i40:
|
||||
pushad
|
||||
cld
|
||||
movzx eax, al
|
||||
call dword [servetable2 + eax * 4]
|
||||
popad
|
||||
iretd
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; SYSCALL ENTRY ;;
|
||||
@ -95,6 +94,7 @@ syscall_entry:
|
||||
mov ecx, [ss:esp+4]
|
||||
pop esp
|
||||
sysret
|
||||
|
||||
iglobal
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; SYSTEM FUNCTIONS TABLE ;;
|
||||
@ -175,7 +175,6 @@ iglobal
|
||||
dd sys_debug_services ; 69-Debug
|
||||
dd file_system_lfn ; 70-Common file system interface, version 2
|
||||
dd syscall_windowsettings ; 71-Window settings
|
||||
dd sys_sendwindowmsg ; 72-Send window message
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@ -256,7 +255,7 @@ iglobal
|
||||
dd cross_order ; 69-Debug
|
||||
dd cross_order ; 70-Common file system interface, version 2
|
||||
dd cross_order ; 71-Window settings
|
||||
dd cross_order ; 72-Send window message
|
||||
dd sys_sendwindowmsg ; 72-Send window message
|
||||
dd sys_network ; 73-Network stack
|
||||
dd sys_socket ; 74-Sockets
|
||||
dd sys_protocols ; 75-Protocols
|
||||
|
@ -140,7 +140,6 @@ proc fs_execute
|
||||
|
||||
;mov esi, new_process_loading
|
||||
;call sys_msg_board_str ; write message to message board
|
||||
DEBUGF 1,"%s",new_process_loading
|
||||
|
||||
.wait_lock:
|
||||
cmp [application_table_status],0
|
||||
@ -850,7 +849,6 @@ proc new_sys_threads
|
||||
|
||||
;mov esi,new_process_loading
|
||||
;call sys_msg_board_str
|
||||
DEBUGF 1,"%s",new_process_loading
|
||||
.wait_lock:
|
||||
cmp [application_table_status],0
|
||||
je .get_lock
|
||||
@ -905,7 +903,6 @@ proc new_sys_threads
|
||||
|
||||
;mov esi,new_process_running
|
||||
;call sys_msg_board_str ;output information about succefull startup
|
||||
DEBUGF 1,"%s",new_process_running
|
||||
|
||||
mov [application_table_status],0 ;unlock application_table_status mutex
|
||||
mov eax,[process_number] ;set result
|
||||
@ -921,18 +918,15 @@ endp
|
||||
|
||||
align 4
|
||||
wait_mutex:
|
||||
;;Maxis use atomic bts for mutex 4.4.2009
|
||||
push eax
|
||||
push ebx
|
||||
.do_wait:
|
||||
cmp dword [ebx],0
|
||||
je .get_lock
|
||||
bts dword [ebx],0
|
||||
jnc .locked
|
||||
call change_task
|
||||
jmp .do_wait
|
||||
.get_lock:
|
||||
mov eax, 1
|
||||
xchg eax, [ebx]
|
||||
test eax, eax
|
||||
jnz .do_wait
|
||||
.locked:
|
||||
pop ebx
|
||||
pop eax
|
||||
ret
|
||||
@ -961,8 +955,8 @@ proc set_app_params stdcall,slot:dword, params:dword,\
|
||||
|
||||
shl eax, 8
|
||||
mov [eax+SLOT_BASE+APPDATA.fpu_state], edi
|
||||
mov [eax+SLOT_BASE+APPDATA.fpu_handler], 0
|
||||
mov [eax+SLOT_BASE+APPDATA.sse_handler], 0
|
||||
mov [eax+SLOT_BASE+APPDATA.exc_handler], 0
|
||||
mov [eax+SLOT_BASE+APPDATA.except_mask], 0
|
||||
|
||||
;set default io permission map
|
||||
mov [eax+SLOT_BASE+APPDATA.io_map],\
|
||||
@ -1104,7 +1098,6 @@ proc set_app_params stdcall,slot:dword, params:dword,\
|
||||
mov [CURRENT_TASK+ebx+TASKDATA.state], cl
|
||||
;mov esi,new_process_running
|
||||
;call sys_msg_board_str ;output information about succefull startup
|
||||
DEBUGF 1,"%s",new_process_running
|
||||
ret
|
||||
endp
|
||||
|
||||
|
@ -351,27 +351,6 @@ endg
|
||||
; a protected-mode interrupt handler (typically the general-protection
|
||||
; exception handler, which in turn calls the virtual 8086-mode monitor).
|
||||
|
||||
v86_debug_exc:
|
||||
pushad
|
||||
xor eax, eax
|
||||
mov dr6, eax
|
||||
mov bl, 1
|
||||
jmp v86_exc_c
|
||||
|
||||
v86_page_fault:
|
||||
add esp, 4
|
||||
pushad
|
||||
mov bl, 14
|
||||
jmp v86_exc_c
|
||||
|
||||
v86_except_16:
|
||||
pushad
|
||||
mov bl, 16
|
||||
jmp v86_exc_c
|
||||
v86_except_19:
|
||||
pushad
|
||||
mov bl, 19
|
||||
|
||||
iglobal
|
||||
v86_exc_str1 db 'V86 : unexpected exception ',0
|
||||
v86_exc_str2 db ' at ',0
|
||||
@ -387,11 +366,12 @@ v86_irqerr db 'V86 : IRQ already hooked',13,10,0
|
||||
endg
|
||||
|
||||
v86_exc_c:
|
||||
mov ax, app_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
; Did we all that we have wanted to do?
|
||||
mov eax, [esp+v86_regs.size+10h+18h]
|
||||
cmp bl,1
|
||||
jne @f
|
||||
xor eax, eax
|
||||
mov dr6, eax
|
||||
@@: mov eax, [esp+v86_regs.size+10h+18h]
|
||||
cmp word [esp+v86_regs.eip], ax
|
||||
jnz @f
|
||||
shr eax, 16
|
||||
@ -945,12 +925,11 @@ v86_irq2:
|
||||
mov cx, [eax*4+2]
|
||||
mov word [esi-v86_regs.size+v86_regs.cs], cx
|
||||
and byte [esi-v86_regs.size+v86_regs.eflags+1], not 3
|
||||
push ebx
|
||||
call update_counters
|
||||
pop ebx
|
||||
sub ebx, SLOT_BASE
|
||||
shr ebx, 8
|
||||
mov esi, [CURRENT_TASK]
|
||||
lea edi, [ebx + 0x100000000 - SLOT_BASE]
|
||||
shr edi, 3
|
||||
add edi, TASK_DATA
|
||||
call find_next_task.found
|
||||
call do_change_task
|
||||
popad
|
||||
iretd
|
||||
|
@ -63,6 +63,7 @@ keymap_alt:
|
||||
boot_setostask db 'Setting OS task',0
|
||||
boot_allirqs db 'Unmasking all IRQs',0
|
||||
boot_tsc db 'Reading TSC',0
|
||||
boot_cpufreq db 'CPU frequency is ',' ',' MHz',0
|
||||
boot_pal_ega db 'Setting EGA/CGA 320x200 palette',0
|
||||
boot_pal_vga db 'Setting VGA 640x480 palette',0
|
||||
boot_failed db 'Failed to start first app',0
|
||||
@ -71,8 +72,8 @@ if preboot_blogesc
|
||||
boot_tasking db 'All set - press ESC to start',0
|
||||
end if
|
||||
|
||||
new_process_loading db 'K : New Process - loading',13,10,0
|
||||
new_process_running db 'K : New Process - done',13,10,0
|
||||
;new_process_loading db 'K : New Process - loading',13,10,0
|
||||
;new_process_running db 'K : New Process - done',13,10,0
|
||||
start_not_enough_memory db 'K : New Process - not enough memory',13,10,0
|
||||
|
||||
msg_unresolved db 'unresolved ',0
|
||||
@ -89,7 +90,7 @@ AMD_str db "AuthenticAMD",0
|
||||
;szInfinity db 'INFINITY',0
|
||||
szHwMouse db 'ATI2D',0
|
||||
szPS2MDriver db 'PS2MOUSE',0
|
||||
szCOM_MDriver db 'COM_MOUSE',0
|
||||
;szCOM_MDriver db 'COM_MOUSE',0
|
||||
szUSB db 'USB',0
|
||||
szAtiHW db '/rd/1/drivers/ati2d.drv',0
|
||||
|
||||
@ -291,7 +292,6 @@ irq15read rd 16
|
||||
irq_tab rd 16
|
||||
|
||||
mem_block_map rb 512
|
||||
event_map rb 64
|
||||
mem_block_list rd 64
|
||||
large_block_list rd 31
|
||||
mem_block_mask rd 2
|
||||
@ -314,10 +314,6 @@ mst MEM_STATE
|
||||
|
||||
page_start rd 1
|
||||
page_end rd 1
|
||||
events rd 1
|
||||
event_start rd 1
|
||||
event_end rd 1
|
||||
event_uid rd 1
|
||||
sys_page_map rd 1
|
||||
os_stack_seg rd 1
|
||||
|
||||
@ -402,7 +398,7 @@ MouseTickCounter rd 1
|
||||
|
||||
img_background rd 1
|
||||
mem_BACKGROUND rd 1
|
||||
wraw_bacground_select rb 1
|
||||
static_background_data rd 1
|
||||
|
||||
cache_ide0:
|
||||
cache_ide0_pointer rd 1
|
||||
@ -470,4 +466,3 @@ BiosDiskCaches rb 80h*(cache_ide1-cache_ide0)
|
||||
BiosDiskPartitions rd 80h
|
||||
|
||||
IncludeUGlobals
|
||||
|
||||
|
43
kernel/branches/net/detect/biosmem.inc
Normal file
43
kernel/branches/net/detect/biosmem.inc
Normal file
@ -0,0 +1,43 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2009. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
; Query physical memory map from BIOS.
|
||||
; diamond, 2009
|
||||
|
||||
push ds
|
||||
; first call to fn E820
|
||||
mov eax, 0xE820
|
||||
xor ebx, ebx
|
||||
mov es, bx
|
||||
mov ds, bx
|
||||
mov di, 0x9104
|
||||
mov [di-4], ebx ; no blocks yet
|
||||
mov ecx, 20
|
||||
mov edx, 0x534D4150
|
||||
int 15h
|
||||
jc no_E820
|
||||
cmp eax, 0x534D4150
|
||||
jnz no_E820
|
||||
e820_mem_loop:
|
||||
cmp byte [di+16], 1 ; ignore non-free areas
|
||||
jnz e820_mem_next
|
||||
inc byte [0x9100]
|
||||
add di, 20
|
||||
e820_mem_next:
|
||||
; consequent calls to fn E820
|
||||
test ebx, ebx
|
||||
jz e820_test_done
|
||||
cmp byte [0x9100], 32
|
||||
jae e820_test_done
|
||||
mov eax, 0xE820
|
||||
int 15h
|
||||
jc e820_test_done
|
||||
jmp e820_mem_loop
|
||||
no_E820:
|
||||
; let's hope for mem_test from init.inc
|
||||
e820_test_done:
|
||||
pop ds
|
@ -70,15 +70,26 @@ $Revision: 750 $
|
||||
jz .endbd
|
||||
mov esi,BiosDiskCaches
|
||||
.loopbd:
|
||||
cmp byte [BiosDisksData+ecx*4+2],-1
|
||||
jnz .contbd
|
||||
push ecx
|
||||
movsx ecx,byte [BiosDisksData+ecx*4+2]
|
||||
inc ecx
|
||||
jz .getbd
|
||||
add ecx,ecx
|
||||
movzx eax,byte [DRIVE_DATA+1]
|
||||
shl eax,cl
|
||||
and ah,3
|
||||
cmp ah,1
|
||||
jz .contbd
|
||||
pop ecx
|
||||
mov byte [BiosDisksData+ecx*4+2], -1
|
||||
push ecx
|
||||
.getbd:
|
||||
mov eax,[cache_ide0_size]
|
||||
mov [esi+cache_ide0_size-cache_ide0],eax
|
||||
push ecx
|
||||
mov cl,1
|
||||
call get_cache_ide
|
||||
pop ecx
|
||||
.contbd:
|
||||
pop ecx
|
||||
add esi,cache_ide1-cache_ide0
|
||||
inc ecx
|
||||
cmp ecx,[NumBiosDisks]
|
||||
|
@ -22,7 +22,7 @@ sb_dma_num equ 5 ;default values for SB16, may be overrided by autodetect
|
||||
|
||||
small_buffer equ 32768
|
||||
full_buffer equ 65536
|
||||
sb_buffer_size equ full_buffer
|
||||
sb_buffer_size equ small_buffer ; FIX ring buffer overlapped events issue; full_buffer
|
||||
|
||||
__supported_buffer_sizes fix <small_buffer, full_buffer>
|
||||
|
||||
|
@ -201,7 +201,6 @@ macro DEBUGH_N _sign,_num,_hex {
|
||||
if ~_hex eq ax
|
||||
movzx eax,_hex
|
||||
end if
|
||||
shl eax,16
|
||||
if (_num eq)
|
||||
mov edx,4
|
||||
end if
|
||||
@ -209,7 +208,6 @@ macro DEBUGH_N _sign,_num,_hex {
|
||||
if ~_hex eq al
|
||||
movzx eax,_hex
|
||||
end if
|
||||
shl eax,24
|
||||
if (_num eq)
|
||||
mov edx,2
|
||||
end if
|
||||
|
@ -1062,14 +1062,6 @@ fs_HdRead:
|
||||
mov eax, ERROR_ACCESS_DENIED
|
||||
ret
|
||||
|
||||
.noaccess_3:
|
||||
add esp,4
|
||||
.noaccess_1:
|
||||
add esp,4
|
||||
.noaccess_4:
|
||||
add esp,4*5
|
||||
jmp .noaccess_2
|
||||
|
||||
@@:
|
||||
call hd_find_lfn
|
||||
jnc .found
|
||||
@ -1133,9 +1125,9 @@ fs_HdRead:
|
||||
push ebx
|
||||
mov ebx, edx
|
||||
call hd_read
|
||||
pop ebx
|
||||
cmp [hd_error],0
|
||||
jne .noaccess_1
|
||||
pop ebx
|
||||
add edx, 512
|
||||
sub ecx, 512
|
||||
jmp .skip
|
||||
@ -1144,11 +1136,10 @@ fs_HdRead:
|
||||
push eax ebx
|
||||
mov ebx, buffer
|
||||
call hd_read
|
||||
cmp [hd_error],0
|
||||
jne .noaccess_3
|
||||
|
||||
mov eax, ebx
|
||||
pop ebx
|
||||
cmp [hd_error],0
|
||||
jne .noaccess_3
|
||||
add eax, ebx
|
||||
push ecx
|
||||
add ecx, ebx
|
||||
@ -1171,9 +1162,14 @@ fs_HdRead:
|
||||
mov eax, [cluster_tmp]
|
||||
call get_FAT
|
||||
cmp [hd_error],0
|
||||
jne .noaccess_4
|
||||
jne .noaccess_1
|
||||
|
||||
jmp .new_cluster
|
||||
.noaccess_3:
|
||||
pop eax
|
||||
.noaccess_1:
|
||||
pop eax
|
||||
push 11
|
||||
.done:
|
||||
mov ebx, edx
|
||||
pop eax edx ecx edi
|
||||
|
@ -383,9 +383,13 @@ boot_read_ok:
|
||||
mov [FAT_START],eax ; fat_start = partition_start + reserved
|
||||
|
||||
movzx eax,byte [ebx+0xd] ; sectors per cluster
|
||||
test eax,eax
|
||||
jz problem_fat_dec_count
|
||||
mov [SECTORS_PER_CLUSTER],eax
|
||||
|
||||
movzx ecx,word [ebx+0xb] ; bytes per sector
|
||||
cmp ecx,0x200
|
||||
jnz problem_fat_dec_count
|
||||
mov [BYTES_PER_SECTOR],ecx
|
||||
|
||||
movzx eax,word [ebx+0x11] ; count of rootdir entries (=0 fat32)
|
||||
|
@ -423,7 +423,7 @@ negativebutton:
|
||||
;
|
||||
; first at 0x10
|
||||
|
||||
|
||||
align 4
|
||||
checkbuttons:
|
||||
|
||||
cmp [BTN_DOWN],byte 0 ; mouse buttons pressed
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1166,10 +1166,10 @@ restore_minimized_window:
|
||||
ret
|
||||
|
||||
|
||||
iglobal
|
||||
window_moving db 'K : Window - move/resize',13,10,0
|
||||
window_moved db 'K : Window - done',13,10,0
|
||||
endg
|
||||
;iglobal
|
||||
; window_moving db 'K : Window - move/resize',13,10,0
|
||||
; window_moved db 'K : Window - done',13,10,0
|
||||
;endg
|
||||
|
||||
; check window touch
|
||||
align 4
|
||||
@ -1316,10 +1316,10 @@ endg
|
||||
|
||||
.continue:
|
||||
|
||||
push esi
|
||||
mov esi, window_moving
|
||||
call sys_msg_board_str
|
||||
pop esi
|
||||
; push esi
|
||||
; mov esi, window_moving
|
||||
; call sys_msg_board_str
|
||||
; pop esi
|
||||
|
||||
mov ecx, [timer_ticks] ; double-click ?
|
||||
mov edx, ecx
|
||||
@ -1684,8 +1684,8 @@ endg
|
||||
mov [MOUSE_BACKGROUND],byte 0 ; no mouse under
|
||||
mov [MOUSE_DOWN],byte 0 ; react to mouse up/down
|
||||
|
||||
mov esi,window_moved
|
||||
call sys_msg_board_str
|
||||
; mov esi,window_moved
|
||||
; call sys_msg_board_str
|
||||
|
||||
popad
|
||||
|
||||
|
@ -14,6 +14,9 @@ MEM_UC equ 0 ;uncached memory
|
||||
|
||||
align 4
|
||||
proc mem_test
|
||||
; if we have BIOS with fn E820, skip the test
|
||||
cmp dword [BOOT_VAR-OS_BASE + 0x9100], 0
|
||||
jnz .ret
|
||||
|
||||
mov eax, cr0
|
||||
and eax, not (CR0_CD+CR0_NW)
|
||||
@ -29,37 +32,91 @@ proc mem_test
|
||||
cmp dword [edi], 'TEST'
|
||||
xchg ebx, dword [edi]
|
||||
je @b
|
||||
mov [MEM_AMOUNT-OS_BASE], edi
|
||||
|
||||
and eax, not (CR0_CD+CR0_NW) ;enable caching
|
||||
mov cr0, eax
|
||||
mov eax, edi
|
||||
inc dword [BOOT_VAR-OS_BASE + 0x9100]
|
||||
xor eax, eax
|
||||
mov [BOOT_VAR-OS_BASE + 0x9104], eax
|
||||
mov [BOOT_VAR-OS_BASE + 0x9108], eax
|
||||
mov [BOOT_VAR-OS_BASE + 0x910C], edi
|
||||
mov [BOOT_VAR-OS_BASE + 0x9110], eax
|
||||
.ret:
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc init_mem
|
||||
mov eax, [MEM_AMOUNT-OS_BASE]
|
||||
mov [pg_data.mem_amount-OS_BASE], eax
|
||||
|
||||
shr eax, 12
|
||||
; calculate maximum allocatable address and number of allocatable pages
|
||||
mov edi, BOOT_VAR-OS_BASE + 0x9104
|
||||
mov ecx, [edi-4]
|
||||
xor esi, esi ; esi will hold total amount of memory
|
||||
xor edx, edx ; edx will hold maximum allocatable address
|
||||
.calcmax:
|
||||
; round all to pages
|
||||
mov eax, [edi]
|
||||
test eax, 0xFFF
|
||||
jz @f
|
||||
neg eax
|
||||
and eax, 0xFFF
|
||||
add [edi], eax
|
||||
adc dword [edi+4], 0
|
||||
sub [edi+8], eax
|
||||
sbb dword [edi+12], 0
|
||||
jc .unusable
|
||||
@@:
|
||||
and dword [edi+8], not 0xFFF
|
||||
jz .unusable
|
||||
; ignore memory after 4 Gb
|
||||
cmp dword [edi+4], 0
|
||||
jnz .unusable
|
||||
mov eax, [edi]
|
||||
cmp dword [edi+12], 0
|
||||
jnz .overflow
|
||||
add eax, [edi+8]
|
||||
jnc @f
|
||||
.overflow:
|
||||
mov eax, 0xFFFFF000
|
||||
@@:
|
||||
cmp edx, eax
|
||||
jae @f
|
||||
mov edx, eax
|
||||
mov [pg_data.pages_count-OS_BASE], eax
|
||||
shr eax, 3
|
||||
mov [pg_data.pagemap_size-OS_BASE], eax
|
||||
@@:
|
||||
sub eax, [edi]
|
||||
mov [edi+8], eax
|
||||
add esi, eax
|
||||
jmp .usable
|
||||
.unusable:
|
||||
and dword [edi+8], 0
|
||||
.usable:
|
||||
add edi, 20
|
||||
loop .calcmax
|
||||
.calculated:
|
||||
mov [MEM_AMOUNT-OS_BASE], esi
|
||||
mov [pg_data.mem_amount-OS_BASE], esi
|
||||
shr esi, 12
|
||||
mov [pg_data.pages_count-OS_BASE], esi
|
||||
|
||||
add eax, (sys_pgmap-OS_BASE)+4095
|
||||
and eax, not 4095
|
||||
mov [tmp_page_tabs], eax
|
||||
shr edx, 12
|
||||
add edx, 31
|
||||
and edx, not 31
|
||||
shr edx, 3
|
||||
mov [pg_data.pagemap_size-OS_BASE], edx
|
||||
|
||||
add edx, (sys_pgmap-OS_BASE)+4095
|
||||
and edx, not 4095
|
||||
mov [tmp_page_tabs], edx
|
||||
|
||||
mov edx, esi
|
||||
and edx, -1024
|
||||
cmp edx, (OS_BASE/4096)
|
||||
jbe @F
|
||||
mov edx, (OS_BASE/4096)
|
||||
jmp .set
|
||||
@@:
|
||||
cmp edx, (HEAP_MIN_SIZE/4096)
|
||||
cmp edx, (HEAP_BASE+HEAP_MIN_SIZE)/4096
|
||||
jae .set
|
||||
mov edx, (HEAP_MIN_SIZE/4096)
|
||||
mov edx, (HEAP_BASE+HEAP_MIN_SIZE)/4096
|
||||
.set:
|
||||
mov [pg_data.kernel_pages-OS_BASE], edx
|
||||
shr edx, 10
|
||||
@ -130,14 +187,63 @@ endp
|
||||
|
||||
align 4
|
||||
proc init_page_map
|
||||
|
||||
; mark all memory as unavailable
|
||||
mov edi, sys_pgmap-OS_BASE
|
||||
mov ecx, [pg_data.pagemap_size-OS_BASE]
|
||||
shr ecx, 2
|
||||
or eax, -1
|
||||
xor eax, eax
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
; scan through memory map and mark free areas as available
|
||||
mov ebx, BOOT_VAR-OS_BASE + 0x9104
|
||||
mov edx, [ebx-4]
|
||||
.scanmap:
|
||||
mov ecx, [ebx+8]
|
||||
shr ecx, 12 ; ecx = number of pages
|
||||
jz .next
|
||||
mov edi, [ebx]
|
||||
shr edi, 12 ; edi = first page
|
||||
mov eax, edi
|
||||
neg eax
|
||||
shr edi, 5
|
||||
add edi, sys_pgmap-OS_BASE
|
||||
and eax, 31
|
||||
jz .startok
|
||||
sub ecx, eax
|
||||
jbe .onedword
|
||||
push ecx
|
||||
mov ecx, eax
|
||||
xor eax, eax
|
||||
inc eax
|
||||
shl eax, cl
|
||||
dec eax
|
||||
or [edi], eax
|
||||
add edi, 4
|
||||
pop ecx
|
||||
.startok:
|
||||
push ecx
|
||||
shr ecx, 5
|
||||
or eax, -1
|
||||
rep stosd
|
||||
pop ecx
|
||||
and ecx, 31
|
||||
not eax
|
||||
shl eax, cl
|
||||
or [edi], eax
|
||||
jmp .next
|
||||
.onedword:
|
||||
add ecx, eax
|
||||
@@:
|
||||
dec eax
|
||||
bts [edi], eax
|
||||
loop @b
|
||||
.next:
|
||||
add ebx, 20
|
||||
dec edx
|
||||
jnz .scanmap
|
||||
|
||||
; mark kernel memory as allocated (unavailable)
|
||||
mov ecx, [tmp_page_tabs]
|
||||
mov edx, [pg_data.pages_count-OS_BASE]
|
||||
shr ecx, 12
|
||||
@ -155,7 +261,7 @@ proc init_page_map
|
||||
mov ecx, ebx
|
||||
and ecx, 31
|
||||
shl eax, cl
|
||||
mov [edi], eax
|
||||
and [edi], eax
|
||||
add edi, OS_BASE
|
||||
mov [page_start-OS_BASE], edi;
|
||||
|
||||
|
@ -61,7 +61,8 @@ $Revision: 1025 $
|
||||
|
||||
USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices
|
||||
|
||||
debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used, comment this line out to disable
|
||||
; Enabling the next line will enable serial output console
|
||||
;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
|
||||
|
||||
include "proc32.inc"
|
||||
include "kglobals.inc"
|
||||
@ -237,8 +238,8 @@ B32:
|
||||
mov edi,0x2F0000
|
||||
mov ecx,0x10000 / 4
|
||||
rep movsd
|
||||
xor edi, edi
|
||||
mov ecx,0x10000 / 4
|
||||
mov edi,0x1000
|
||||
mov ecx,0xf000 / 4
|
||||
rep stosd
|
||||
|
||||
call test_cpu
|
||||
@ -453,8 +454,8 @@ high_code:
|
||||
|
||||
; LOAD IDT
|
||||
|
||||
call build_interrupt_table
|
||||
lidt [idtreg]
|
||||
call build_interrupt_table ;lidt is executed
|
||||
;lidt [idtreg]
|
||||
|
||||
call init_kernel_heap
|
||||
stdcall kernel_alloc, RING0_STACK_SIZE+512
|
||||
@ -548,9 +549,8 @@ high_code:
|
||||
mov [BgrDrawMode],eax
|
||||
mov [BgrDataWidth],eax
|
||||
mov [BgrDataHeight],eax
|
||||
mov [mem_BACKGROUND],4095
|
||||
stdcall kernel_alloc, [mem_BACKGROUND]
|
||||
mov [img_background], eax
|
||||
mov [mem_BACKGROUND], 4
|
||||
mov [img_background], static_background_data
|
||||
|
||||
mov [SLOT_BASE + 256 + APPDATA.dir_table], sys_pgdir - OS_BASE
|
||||
|
||||
@ -674,8 +674,8 @@ no_lib_load:
|
||||
|
||||
xor eax, eax
|
||||
mov dword [SLOT_BASE+APPDATA.fpu_state], fpu_data
|
||||
mov dword [SLOT_BASE+APPDATA.fpu_handler], eax
|
||||
mov dword [SLOT_BASE+APPDATA.sse_handler], eax
|
||||
mov dword [SLOT_BASE+APPDATA.exc_handler], eax
|
||||
mov dword [SLOT_BASE+APPDATA.except_mask], eax
|
||||
|
||||
; name for OS/IDLE process
|
||||
|
||||
@ -696,8 +696,8 @@ no_lib_load:
|
||||
cld
|
||||
rep movsd
|
||||
|
||||
mov dword [SLOT_BASE+256+APPDATA.fpu_handler], eax
|
||||
mov dword [SLOT_BASE+256+APPDATA.sse_handler], eax
|
||||
mov dword [SLOT_BASE+256+APPDATA.exc_handler], eax
|
||||
mov dword [SLOT_BASE+256+APPDATA.except_mask], eax
|
||||
|
||||
mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET
|
||||
mov dword [SLOT_BASE+256+APPDATA.fd_obj], ebx
|
||||
@ -724,18 +724,35 @@ no_lib_load:
|
||||
mov esi,boot_tsc
|
||||
call boot_log
|
||||
cli
|
||||
call _rdtsc
|
||||
rdtsc ;call _rdtsc
|
||||
mov ecx,eax
|
||||
mov esi,250 ; wait 1/4 a second
|
||||
call delay_ms
|
||||
call _rdtsc
|
||||
rdtsc ;call _rdtsc
|
||||
sti
|
||||
sub eax,ecx
|
||||
shl eax,2
|
||||
mov [CPU_FREQ],eax ; save tsc / sec
|
||||
mov ebx, 1000000
|
||||
div ebx
|
||||
mov [stall_mcs], eax
|
||||
; mov ebx, 1000000
|
||||
; div ebx
|
||||
; ¢®®¡é¥-â® ¯à®¨§¢®¤¨â¥«ì®áâì ¢ ¤ ®¬ ª®ªà¥â®¬ ¬¥áâ¥
|
||||
; ᮢ¥à襮 ¥ªà¨â¨ç , ® çâ®¡ë § âªãâì «î¡¨â¥«¥©
|
||||
; ®¯â¨¬¨§¨àãîé¨å ª®¬¯¨«ïâ®à®¢ Ÿ‚“...
|
||||
mov edx, 2251799814
|
||||
mul edx
|
||||
shr edx, 19
|
||||
mov [stall_mcs], edx
|
||||
; PRINT CPU FREQUENCY
|
||||
mov esi, boot_cpufreq
|
||||
call boot_log
|
||||
|
||||
mov ebx, edx
|
||||
movzx ecx, word [boot_y]
|
||||
add ecx, (10+17*6) shl 16 - 10 ; 'CPU frequency is '
|
||||
mov edx, 0xFFFFFF
|
||||
mov edi, 1
|
||||
mov eax, 0x00040000
|
||||
call display_number_force
|
||||
|
||||
; SET VARIABLES
|
||||
|
||||
@ -745,7 +762,7 @@ no_lib_load:
|
||||
|
||||
;call detect_devices
|
||||
stdcall load_driver, szPS2MDriver
|
||||
stdcall load_driver, szCOM_MDriver
|
||||
; stdcall load_driver, szCOM_MDriver
|
||||
|
||||
mov esi,boot_setmouse
|
||||
call boot_log
|
||||
@ -789,8 +806,6 @@ no_lib_load:
|
||||
stdcall map_page,tss._io_map_1,\
|
||||
(tss._io_map_1-OS_BASE), PG_MAP
|
||||
|
||||
mov ax,[OS_BASE+0x10000+bx_from_load]
|
||||
|
||||
|
||||
; LOAD FIRST APPLICATION
|
||||
cli
|
||||
@ -989,55 +1004,27 @@ osloop:
|
||||
; MAIN OS LOOP END ;
|
||||
; ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
align 4
|
||||
checkidle:
|
||||
pushad
|
||||
|
||||
cmp [check_idle_semaphore],0
|
||||
jne no_idle_state
|
||||
|
||||
call change_task
|
||||
mov eax,[idlemem]
|
||||
mov ebx,[timer_ticks] ;[0xfdf0]
|
||||
cmp eax,ebx
|
||||
jnz idle_exit
|
||||
call _rdtsc
|
||||
mov ecx,eax
|
||||
jmp idle_loop_entry
|
||||
idle_loop:
|
||||
cmp eax,[idlemem] ; eax == [timer_ticks]
|
||||
jne idle_exit
|
||||
rdtsc ;call _rdtsc
|
||||
mov ecx,eax
|
||||
hlt
|
||||
cmp [check_idle_semaphore],0
|
||||
jne idle_loop_exit
|
||||
mov eax,[timer_ticks] ;[0xfdf0]
|
||||
cmp ebx,eax
|
||||
jz idle_loop
|
||||
idle_loop_exit:
|
||||
mov [idlemem],eax
|
||||
call _rdtsc
|
||||
rdtsc ;call _rdtsc
|
||||
sub eax,ecx
|
||||
mov ebx,[idleuse]
|
||||
add ebx,eax
|
||||
mov [idleuse],ebx
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
idle_exit:
|
||||
|
||||
mov ebx,[timer_ticks] ;[0xfdf0]
|
||||
mov [idlemem],ebx
|
||||
call change_task
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
no_idle_state:
|
||||
|
||||
add [idleuse],eax
|
||||
idle_loop_entry:
|
||||
mov eax,[timer_ticks] ; eax = [timer_ticks]
|
||||
cmp [check_idle_semaphore],0
|
||||
je idle_loop
|
||||
dec [check_idle_semaphore]
|
||||
|
||||
mov ebx,[timer_ticks] ;[0xfdf0]
|
||||
mov [idlemem],ebx
|
||||
call change_task
|
||||
|
||||
idle_exit:
|
||||
mov [idlemem],eax ; eax == [timer_ticks]
|
||||
popad
|
||||
ret
|
||||
|
||||
@ -1146,7 +1133,6 @@ set_variables:
|
||||
mov [BTN_ADDR],dword BUTTON_INFO ; address of button list
|
||||
|
||||
;!! IP 04.02.2005:
|
||||
mov [next_usage_update], 100
|
||||
mov byte [DONT_SWITCH], 0 ; change task if possible
|
||||
|
||||
ret
|
||||
@ -1306,6 +1292,7 @@ display_number_force:
|
||||
xor edx,edx
|
||||
call division_64_bits
|
||||
div ebx
|
||||
hexletters = __fdo_hexdigits
|
||||
add edx,hexletters
|
||||
mov dl,[edx]
|
||||
mov [edi],dl
|
||||
@ -2261,8 +2248,9 @@ sys_cachetodiskette:
|
||||
|
||||
uglobal
|
||||
; bgrchanged dd 0x0
|
||||
bgrlock db 0
|
||||
align 4
|
||||
bgrlockpid dd 0
|
||||
bgrlock db 0
|
||||
endg
|
||||
|
||||
sys_background:
|
||||
@ -2274,10 +2262,9 @@ sys_background:
|
||||
cmp edx,0
|
||||
je sbgrr
|
||||
@@:
|
||||
mov al, 1
|
||||
xchg [bgrlock], al
|
||||
test al, al
|
||||
jz @f
|
||||
;;Maxis use atomic bts for mutexes 4.4.2009
|
||||
bts dword [bgrlock], 0
|
||||
jnc @f
|
||||
call change_task
|
||||
jmp @b
|
||||
@@:
|
||||
@ -2287,7 +2274,11 @@ sys_background:
|
||||
|
||||
pushad
|
||||
; return memory for old background
|
||||
stdcall kernel_free, [img_background]
|
||||
mov eax, [img_background]
|
||||
cmp eax, static_background_data
|
||||
jz @f
|
||||
stdcall kernel_free, eax
|
||||
@@:
|
||||
; calculate RAW size
|
||||
xor eax,eax
|
||||
inc eax
|
||||
@ -2306,9 +2297,18 @@ sys_background:
|
||||
; get memory for new background
|
||||
stdcall kernel_alloc, eax
|
||||
test eax, eax
|
||||
jz .exit_mem
|
||||
jz .memfailed
|
||||
mov [img_background], eax
|
||||
.exit_mem:
|
||||
jmp .exit
|
||||
.memfailed:
|
||||
; revert to static monotone data
|
||||
mov [img_background], static_background_data
|
||||
xor eax, eax
|
||||
inc eax
|
||||
mov [BgrDataWidth], eax
|
||||
mov [BgrDataHeight], eax
|
||||
mov [mem_BACKGROUND], 4
|
||||
.exit:
|
||||
popad
|
||||
mov [bgrlock], 0
|
||||
|
||||
@ -2320,20 +2320,25 @@ nosb1:
|
||||
cmp ebx,2 ; SET PIXEL
|
||||
jnz nosb2
|
||||
|
||||
mov eax, [img_background]
|
||||
test ecx, ecx
|
||||
jz @f
|
||||
cmp eax, static_background_data
|
||||
jz .ret
|
||||
@@:
|
||||
mov ebx, [mem_BACKGROUND]
|
||||
add ebx, 4095
|
||||
and ebx, -4096
|
||||
sub ebx, 4
|
||||
cmp ecx, ebx
|
||||
ja @F
|
||||
ja .ret
|
||||
|
||||
mov eax,[img_background]
|
||||
mov ebx,[eax+ecx]
|
||||
and ebx,0xFF000000 ;255*256*256*256
|
||||
and edx,0x00FFFFFF ;255*256*256+255*256+255
|
||||
add edx,ebx
|
||||
mov [eax+ecx],edx
|
||||
@@:
|
||||
.ret:
|
||||
ret
|
||||
nosb2:
|
||||
|
||||
@ -2363,6 +2368,13 @@ draw_background_temp:
|
||||
|
||||
cmp ebx,5 ; BLOCK MOVE TO BGR
|
||||
jnz nosb5
|
||||
cmp [img_background], static_background_data
|
||||
jnz @f
|
||||
test edx, edx
|
||||
jnz .fin
|
||||
cmp esi, 4
|
||||
ja .fin
|
||||
@@:
|
||||
; bughere
|
||||
mov eax, ecx
|
||||
mov ebx, edx
|
||||
@ -2375,16 +2387,17 @@ draw_background_temp:
|
||||
|
||||
cmp ebx, 6
|
||||
jnz nosb6
|
||||
;;Maxis use atomic bts for mutex 4.4.2009
|
||||
@@:
|
||||
mov al, 1
|
||||
xchg [bgrlock], al
|
||||
test al, al
|
||||
jz @f
|
||||
bts dword [bgrlock], 0
|
||||
jnc @f
|
||||
call change_task
|
||||
jmp @b
|
||||
@@:
|
||||
mov eax, [CURRENT_TASK]
|
||||
mov [bgrlockpid], eax
|
||||
cmp [img_background], static_background_data
|
||||
jz .nomem
|
||||
stdcall user_alloc, [mem_BACKGROUND]
|
||||
mov [esp+32], eax
|
||||
test eax, eax
|
||||
@ -2485,19 +2498,24 @@ nogb1:
|
||||
cmp eax,2 ; PIXEL
|
||||
jnz nogb2
|
||||
|
||||
mov eax, [img_background]
|
||||
test ebx, ebx
|
||||
jz @f
|
||||
cmp eax, static_background_data
|
||||
jz .ret
|
||||
@@:
|
||||
mov ecx, [mem_BACKGROUND]
|
||||
add ecx, 4095
|
||||
and ecx, -4096
|
||||
sub ecx, 4
|
||||
cmp ebx, ecx
|
||||
ja @F
|
||||
ja .ret
|
||||
|
||||
mov eax,[img_background]
|
||||
mov eax,[ebx+eax]
|
||||
|
||||
and eax, 0xFFFFFF
|
||||
mov [esp+36],eax
|
||||
@@:
|
||||
.ret:
|
||||
ret
|
||||
nogb2:
|
||||
|
||||
@ -3083,8 +3101,6 @@ sys_set_window:
|
||||
|
||||
call check_window_position
|
||||
|
||||
call set_window_clientbox
|
||||
|
||||
push ecx esi edi ; save for window fullscreen/resize
|
||||
;mov esi,edi
|
||||
|
||||
@ -3133,6 +3149,8 @@ sys_set_window:
|
||||
mov [BTN_COUNT],byte 0 ; empty button buffer
|
||||
|
||||
newd:
|
||||
call set_window_clientbox
|
||||
|
||||
mov [edi+WDATA.fl_redraw],byte 0 ; no redraw
|
||||
mov edx,edi
|
||||
|
||||
@ -3649,14 +3667,6 @@ redrawscreen:
|
||||
|
||||
calculatebackground: ; background
|
||||
|
||||
; all black
|
||||
|
||||
mov edi, [img_background] ;IMG_BACKGROUND ; set background to black
|
||||
xor eax, eax
|
||||
mov ecx, 1023 ;0x0fff00 / 4
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
mov edi,display_data ; set os to use all pixels
|
||||
mov eax,0x01010101
|
||||
mov ecx,1280*1024 / 4
|
||||
@ -3705,7 +3715,9 @@ delay_ms: ; delay in 1/1000 sec
|
||||
|
||||
set_app_param:
|
||||
mov edi, [TASK_BASE]
|
||||
mov eax, [edi + TASKDATA.event_mask]
|
||||
mov [edi + TASKDATA.event_mask], ebx
|
||||
mov [esp+32], eax
|
||||
ret
|
||||
|
||||
|
||||
@ -4648,7 +4660,7 @@ setmouse: ; set mousepicture -pointer
|
||||
|
||||
ret
|
||||
|
||||
|
||||
if used _rdtsc
|
||||
_rdtsc:
|
||||
bt [cpu_caps], CAPS_TSC
|
||||
jnc ret_rdtsc
|
||||
@ -4658,6 +4670,7 @@ _rdtsc:
|
||||
mov edx,0xffffffff
|
||||
mov eax,0xffffffff
|
||||
ret
|
||||
end if
|
||||
|
||||
rerouteirqs:
|
||||
|
||||
@ -5350,7 +5363,7 @@ align 4
|
||||
sys_apm:
|
||||
cmp word [apm_vf], 0 ; Check APM BIOS enable
|
||||
jne @f
|
||||
or [esp + 56], byte 1 ; error
|
||||
or [esp + 48], byte 1 ; error
|
||||
mov [esp + 36], dword 8 ; 32-bit protected-mode interface not supported
|
||||
ret
|
||||
|
||||
@ -5360,7 +5373,7 @@ sys_apm:
|
||||
|
||||
cmp al, 3
|
||||
ja @f
|
||||
and [esp + 56], byte 0xfe ; emulate func 0..3 as func 0
|
||||
and [esp + 48], byte 0xfe ; emulate func 0..3 as func 0
|
||||
mov eax, [apm_vf]
|
||||
mov [esp + 36], eax
|
||||
shr eax, 16
|
||||
@ -5390,8 +5403,8 @@ sys_apm:
|
||||
mov [esp + 32], ecx
|
||||
mov [esp + 36], eax
|
||||
setc al
|
||||
and [esp + 56], byte 0xfe
|
||||
or [esp + 56], al
|
||||
and [esp + 48], byte 0xfe
|
||||
or [esp + 48], al
|
||||
|
||||
|
||||
ret
|
||||
@ -5443,7 +5456,7 @@ yes_shutdown_param:
|
||||
out 0x21, al
|
||||
out 0xA1, al
|
||||
|
||||
if 1
|
||||
if 0
|
||||
mov word [OS_BASE+0x467+0],pr_mode_exit
|
||||
mov word [OS_BASE+0x467+2],0x1000
|
||||
|
||||
@ -5456,6 +5469,7 @@ if 1
|
||||
out 0x64,al
|
||||
|
||||
hlt
|
||||
jmp $-1
|
||||
|
||||
else
|
||||
cmp byte [OS_BASE + 0x9030], 2
|
||||
@ -5507,6 +5521,72 @@ else
|
||||
jmp no_acpi_power_off
|
||||
.fadt_found:
|
||||
; ebx is linear address of FADT
|
||||
mov edi, [ebx+40] ; physical address of the DSDT
|
||||
lea eax, [ebp+4000h]
|
||||
stdcall map_page, eax, edi, PG_MAP
|
||||
lea eax, [ebp+5000h]
|
||||
lea esi, [edi+0x1000]
|
||||
stdcall map_page, eax, esi, PG_MAP
|
||||
and esi, 0xFFF
|
||||
sub edi, esi
|
||||
cmp dword [esi+ebp+4000h], 'DSDT'
|
||||
jnz no_acpi_power_off
|
||||
mov eax, [esi+ebp+4004h] ; DSDT length
|
||||
sub eax, 36+4
|
||||
jbe no_acpi_power_off
|
||||
add esi, 36
|
||||
.scan_dsdt:
|
||||
cmp dword [esi+ebp+4000h], '_S5_'
|
||||
jnz .scan_dsdt_cont
|
||||
cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode
|
||||
jnz .scan_dsdt_cont
|
||||
mov dl, [esi+ebp+4000h+6]
|
||||
cmp dl, 4 ; _S5_ package must contain 4 bytes
|
||||
; ...in theory; in practice, VirtualBox has 2 bytes
|
||||
ja .scan_dsdt_cont
|
||||
cmp dl, 1
|
||||
jb .scan_dsdt_cont
|
||||
lea esi, [esi+ebp+4000h+7]
|
||||
xor ecx, ecx
|
||||
cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx
|
||||
jz @f
|
||||
cmp byte [esi], 0xA
|
||||
jnz no_acpi_power_off
|
||||
inc esi
|
||||
mov cl, [esi]
|
||||
@@:
|
||||
inc esi
|
||||
cmp dl, 2
|
||||
jb @f
|
||||
cmp byte [esi], 0
|
||||
jz @f
|
||||
cmp byte [esi], 0xA
|
||||
jnz no_acpi_power_off
|
||||
inc esi
|
||||
mov ch, [esi]
|
||||
@@:
|
||||
jmp do_acpi_power_off
|
||||
.scan_dsdt_cont:
|
||||
inc esi
|
||||
cmp esi, 0x1000
|
||||
jb @f
|
||||
sub esi, 0x1000
|
||||
add edi, 0x1000
|
||||
push eax
|
||||
lea eax, [ebp+4000h]
|
||||
stdcall map_page, eax, edi, PG_MAP
|
||||
push PG_MAP
|
||||
lea eax, [edi+1000h]
|
||||
push eax
|
||||
lea eax, [ebp+5000h]
|
||||
push eax
|
||||
stdcall map_page
|
||||
pop eax
|
||||
@@:
|
||||
dec eax
|
||||
jnz .scan_dsdt
|
||||
jmp no_acpi_power_off
|
||||
do_acpi_power_off:
|
||||
mov edx, [ebx+48]
|
||||
test edx, edx
|
||||
jz .nosmi
|
||||
@ -5518,17 +5598,20 @@ else
|
||||
test al, 1
|
||||
jz @b
|
||||
.nosmi:
|
||||
and cx, 0x0707
|
||||
shl cx, 2
|
||||
or cx, 0x2020
|
||||
mov edx, [ebx+64]
|
||||
in ax, dx
|
||||
and ax, 203h
|
||||
or ax, 3C00h
|
||||
or ah, cl
|
||||
out dx, ax
|
||||
mov edx, [ebx+68]
|
||||
test edx, edx
|
||||
jz @f
|
||||
in ax, dx
|
||||
and ax, 203h
|
||||
or ax, 3C00h
|
||||
or ah, ch
|
||||
out dx, ax
|
||||
@@:
|
||||
jmp $
|
||||
@ -5547,6 +5630,7 @@ no_acpi_power_off:
|
||||
out 0x64,al
|
||||
|
||||
hlt
|
||||
jmp $-1
|
||||
|
||||
scan_rsdp:
|
||||
add eax, OS_BASE
|
||||
@ -5578,4 +5662,3 @@ __REV__ = __REV
|
||||
|
||||
uglobals_size = $ - endofcode
|
||||
diff16 "end of kernel code",0,$
|
||||
|
||||
|
@ -121,9 +121,9 @@ struc APPDATA
|
||||
db 5 dup(?)
|
||||
|
||||
.fpu_state dd ? ;+16
|
||||
.ev_count dd ? ;+20
|
||||
.fpu_handler dd ? ;+24
|
||||
.sse_handler dd ? ;+28
|
||||
.ev_count_ dd ? ;unused ;+20
|
||||
.exc_handler dd ? ;+24
|
||||
.except_mask dd ? ;+28
|
||||
.pl0_stack dd ? ;unused ;+32
|
||||
.heap_base dd ? ;+36
|
||||
.heap_top dd ? ;+40
|
||||
@ -138,8 +138,10 @@ struc APPDATA
|
||||
.cur_dir dd ? ;+80
|
||||
.wait_timeout dd ? ;+84
|
||||
.saved_esp0 dd ? ;+88
|
||||
|
||||
db 36 dup(?) ;+92
|
||||
.wait_begin dd ? ;+92 +++
|
||||
.wait_test dd ? ;+96 +++
|
||||
.wait_param dd ? ;+100 +++
|
||||
db 24 dup(?) ;+104
|
||||
|
||||
.wnd_shape dd ? ;+128
|
||||
.wnd_shape_scale dd ? ;+132
|
||||
|
@ -98,3 +98,9 @@ if ~ f eq
|
||||
end if
|
||||
}
|
||||
; \end{diamond}[29.09.2006]
|
||||
|
||||
macro Mov op1,op2,op3 ; op1 = op2 = op3
|
||||
{
|
||||
mov op2,op3
|
||||
mov op1,op2
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
FASM=fasm
|
||||
FLAGS=-m 65536
|
||||
languages=en|ru|ge|et
|
||||
drivers_src=sound sis infinity ensoniq ps2mouse uart ati2d vmode
|
||||
drivers_src=sound sis infinity uart ati2d vmode com_mouse
|
||||
skins_src=default
|
||||
|
||||
.PHONY: all kernel drivers skins clean
|
||||
|
@ -23,12 +23,17 @@
|
||||
; 0x9046 - word - flags
|
||||
; 0:907F byte number of BIOS hard disks
|
||||
; 0:9080 Nbytes BIOS hard disks
|
||||
; 0:9100 word available physical memory map: number of blocks
|
||||
; 0:9104 available physical memory map: blocks
|
||||
;
|
||||
; Runtime:
|
||||
;
|
||||
; 0x00000000 -> 0x7FFFFFFF application 2Gb
|
||||
|
||||
; 0x80000000 -> 1FFF window_data - 256 entries
|
||||
; 0x80000000 -> 0FFF physical page zero - do not write
|
||||
; (used by int 13h in some configurations)
|
||||
;
|
||||
; 0x80001000 -> 2FFF window_data - 256 entries
|
||||
;
|
||||
; 0000 dword x start
|
||||
; 0004 dword y start
|
||||
@ -39,8 +44,6 @@
|
||||
; 0018 dword color of frames
|
||||
; 001C dword window flags, +30 = window drawn, +31 redraw flag
|
||||
;
|
||||
; 2000 -> 2FFF free
|
||||
;
|
||||
; 3000 -> 4FFF task list - 256 entries
|
||||
;
|
||||
; 00 dword process count
|
||||
@ -70,9 +73,9 @@
|
||||
;
|
||||
; A400 -> B0FF free
|
||||
|
||||
; B100 -> B2FF IDT
|
||||
; B100 -> B307 IDT for int_0x00..int_0x40
|
||||
|
||||
; B300 -> BFFF free
|
||||
; B308 -> BFFF free
|
||||
|
||||
; C000 -> C3FF window stack C000 no of windows - all in words
|
||||
; C402 -> C7FF window position in stack
|
||||
|
@ -113,7 +113,7 @@ palette320x200:
|
||||
loop palnew
|
||||
|
||||
ret
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
novesachecksum dd 0x0
|
||||
EGA_counter db 0
|
||||
@ -123,7 +123,7 @@ uglobal
|
||||
temp:
|
||||
.cx dd 0
|
||||
endg
|
||||
|
||||
align 4
|
||||
checkVga_N13:
|
||||
|
||||
cmp [SCR_MODE],dword 0x13
|
||||
|
Loading…
Reference in New Issue
Block a user