From e449a2473ea4d3593797b86d66ed28721ef069ac Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Thu, 22 Mar 2007 12:01:05 +0000 Subject: [PATCH] optimization git-svn-id: svn://kolibrios.org@427 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/flat_kernel/const.inc | 53 ++++ kernel/branches/flat_kernel/core/debug.inc | 10 +- kernel/branches/flat_kernel/core/dll.inc | 79 +++++- kernel/branches/flat_kernel/core/fpu.inc | 5 +- kernel/branches/flat_kernel/core/heap.inc | 50 ++-- kernel/branches/flat_kernel/core/memory.inc | 77 ++---- kernel/branches/flat_kernel/core/sched.inc | 90 +++++- kernel/branches/flat_kernel/core/sys32.inc | 5 +- kernel/branches/flat_kernel/core/syscall.inc | 12 +- kernel/branches/flat_kernel/core/taskman.inc | 57 +--- kernel/branches/flat_kernel/gui/button.inc | 29 +- kernel/branches/flat_kernel/gui/event.inc | 50 ++-- kernel/branches/flat_kernel/gui/window.inc | 15 +- kernel/branches/flat_kernel/kernel.asm | 81 +++--- kernel/branches/flat_kernel/memmap.inc | 256 +++++++++++++++++- kernel/branches/flat_kernel/video/cursors.inc | 17 +- 16 files changed, 626 insertions(+), 260 deletions(-) diff --git a/kernel/branches/flat_kernel/const.inc b/kernel/branches/flat_kernel/const.inc index c5b605bd81..37fd049eb7 100644 --- a/kernel/branches/flat_kernel/const.inc +++ b/kernel/branches/flat_kernel/const.inc @@ -134,6 +134,45 @@ SSE_FZ equ 0x8000 SSE_INIT equ (SSE_IM+SSE_DM+SSE_ZM+SSE_OM+SSE_UM+SSE_PM) + +struc TSS +{ + ._back rw 2 + ._esp0 rd 1 + ._ss0 rw 2 + ._esp1 rd 1 + ._ss1 rw 2 + ._esp2 rd 1 + ._ss2 rw 2 + ._cr3 rd 1 + ._eip rd 1 + ._eflags rd 1 + ._eax rd 1 + ._ecx rd 1 + ._edx rd 1 + ._ebx rd 1 + ._esp rd 1 + ._ebp rd 1 + ._esi rd 1 + ._edi rd 1 + ._es rw 2 + ._cs rw 2 + ._ss rw 2 + ._ds rw 2 + ._fs rw 2 + ._gs rw 2 + ._ldt rw 2 + ._trap rw 1 + ._io rw 1 + rb 24 + ._io_map_0 rb 4096 + ._io_map_1 rb 4096 +} + +virtual at 0 + TSS TSS +end virtual + OS_BASE equ 0x80000000 window_data equ OS_BASE @@ -339,6 +378,20 @@ EVENT_EXTENDED equ 0x00000200 EV_INTR equ 1 +struc THR_DATA +{ + rb (8192-512) + .pl0_stack: + .fpu_state rb 512 + .pdbr rb 4096 +} + +THR_DATA_SIZE equ 4096*3 + +virtual at (OS_BASE-THR_DATA_SIZE) + thr_data THR_DATA +end virtual + struc SYS_VARS { .bpp dd ? .scanline dd ? diff --git a/kernel/branches/flat_kernel/core/debug.inc b/kernel/branches/flat_kernel/core/debug.inc index 39fc5e5191..0ae2405b1d 100644 --- a/kernel/branches/flat_kernel/core/debug.inc +++ b/kernel/branches/flat_kernel/core/debug.inc @@ -19,9 +19,8 @@ sys_debug_services_table: debug_set_event_data: ; in: ebx = pointer ; destroys eax - mov eax, [CURRENT_TASK] - shl eax, 8 - mov [eax+SLOT_BASE+APPDATA.dbg_event_mem], ebx + mov eax, [current_slot] + mov [eax+APPDATA.dbg_event_mem], ebx ret get_debuggee_slot: @@ -453,9 +452,8 @@ debug_exc: mov dr6, eax ; test if debugging cli - mov eax, [CURRENT_TASK] - shl eax, 8 - mov eax, [SLOT_BASE+eax+APPDATA.debugger_slot] + mov eax, [current_slot] + mov eax, [eax+APPDATA.debugger_slot] test eax, eax jnz .debug sti diff --git a/kernel/branches/flat_kernel/core/dll.inc b/kernel/branches/flat_kernel/core/dll.inc index bf5038c8da..c12724c7a1 100644 --- a/kernel/branches/flat_kernel/core/dll.inc +++ b/kernel/branches/flat_kernel/core/dll.inc @@ -152,14 +152,13 @@ align 4 proc get_notify stdcall, p_ev:dword .wait: - mov ebx,[CURRENT_TASK] - shl ebx,8 - test dword [ebx+SLOT_BASE+0xA8],EVENT_NOTIFY + mov ebx,[current_slot] + test dword [ebx+APPDATA.event_mask],EVENT_NOTIFY jz @f - and dword [ebx+SLOT_BASE+0xA8], not EVENT_NOTIFY + and dword [ebx+APPDATA.event_mask], not EVENT_NOTIFY mov edi, [p_ev] mov dword [edi], EV_INTR - mov eax, [ebx+SLOT_BASE+APPDATA.event] + mov eax, [ebx+APPDATA.event] mov dword [edi+4], eax ret @@: @@ -994,9 +993,8 @@ create_kernel_object: test eax, eax jz .fail - mov ecx,[CURRENT_TASK] - shl ecx,8 - add ecx, SLOT_BASE+APP_OBJ_OFFSET + mov ecx,[current_slot] + add ecx, APP_OBJ_OFFSET pushfd cli @@ -1036,3 +1034,68 @@ destroy_kernel_object: ret + +if 0 + +irq: + +.irq0: + pusfd + pushad + push IRQ_0 + jmp .master +.irq_1: + pusfd + pushad + push IRQ_1 + jmp .master + +.master: + mov ax, app_data + mov ds, eax + mov es, eax + mov ebx, [esp+4] ;IRQ_xx + mov eax, [irq_handlers+ebx+4] + call intr_handler + mov ecx, [esp+4] + cmp [irq_actids+ecx*4], 0 + je @F + in al, 0x21 + bts eax, ecx + out 0x21, al + mov al, 0x20 + out 0x20, al + jmp .restart + +.slave: + mov ax, app_data + mov ds, eax + mov es, eax + mov ebx, [esp+4] ;IRQ_xx + mov eax, [irq_handlers+ebx+4] + call intr_handler + mov ecx, [esp+4] + sub ecx, 8 + cmp [irq_actids+ecx*4], 0 + je @F + in al, 0xA1 + bts eax, ecx + out 0xA1, al + mov al, 0x20 + out 0xA0, al + out 0x20, al +.restart: + mov ebx, [next_slot] + test ebx, ebx + jz @F + mov [next_task],0 + mov esi, [prev_slot] + call do_change_task + add esp, 4 + iretd + +end if + + + + diff --git a/kernel/branches/flat_kernel/core/fpu.inc b/kernel/branches/flat_kernel/core/fpu.inc index 8674ce7d1f..97409ef548 100644 --- a/kernel/branches/flat_kernel/core/fpu.inc +++ b/kernel/branches/flat_kernel/core/fpu.inc @@ -227,10 +227,9 @@ except_19: ;sse exceptions handler push ecx push edx - mov ebx, [CURRENT_TASK] - shl ebx, 8 + mov ebx, [current_slot] - mov eax, [ebx+SLOT_BASE+APPDATA.sse_handler] + mov eax, [ebx+APPDATA.sse_handler] test eax, eax jz .default diff --git a/kernel/branches/flat_kernel/core/heap.inc b/kernel/branches/flat_kernel/core/heap.inc index d5e34c12d2..89f40196b5 100644 --- a/kernel/branches/flat_kernel/core/heap.inc +++ b/kernel/branches/flat_kernel/core/heap.inc @@ -614,22 +614,21 @@ HEAP_TOP equ 0x5FC00000 align 4 proc init_heap - mov ebx,[CURRENT_TASK] - shl ebx,8 - mov eax, [SLOT_BASE+APPDATA.heap_top+ebx] + mov ebx,[current_slot] + mov eax, [ebx+APPDATA.heap_top] test eax, eax jz @F - sub eax,[SLOT_BASE+APPDATA.heap_base+ebx] + sub eax,[ebx+APPDATA.heap_base] sub eax, 4096 ret @@: - mov esi, [SLOT_BASE+APPDATA.mem_size+ebx] + mov esi, [ebx+APPDATA.mem_size] add esi, 4095 and esi, not 4095 - mov [SLOT_BASE+APPDATA.mem_size+ebx], esi + mov [ebx+APPDATA.mem_size], esi mov eax, HEAP_TOP - mov [SLOT_BASE+APPDATA.heap_base+ebx], esi - mov [SLOT_BASE+APPDATA.heap_top+ebx], eax + mov [ebx+APPDATA.heap_base], esi + mov [ebx+APPDATA.heap_top], eax sub eax, esi ; add esi, new_app_base @@ -651,12 +650,9 @@ proc user_alloc stdcall, alloc_size:dword add ecx, (4095+4096) and ecx, not 4095 - mov ebx, [CURRENT_TASK] - shl ebx, 8 - mov esi, dword [ebx+SLOT_BASE+APPDATA.heap_base]; heap_base - mov edi, dword [ebx+SLOT_BASE+APPDATA.heap_top]; heap_top - ; add esi, new_app_base - ; add edi, new_app_base + mov ebx, [current_slot] + mov esi, dword [ebx+APPDATA.heap_base] ; heap_base + mov edi, dword [ebx+APPDATA.heap_top] ; heap_top l_0: cmp esi, edi jae m_exit @@ -677,7 +673,6 @@ l_0: or eax, FREE_BLOCK shr edx, 12 mov [page_tabs+edx*4], eax - @@: or ecx, USED_BLOCK mov [page_tabs+ebx*4], ecx @@ -690,17 +685,15 @@ l_0: dec ecx jnz @B - mov edx, [CURRENT_TASK] - shl edx, 8 - mov ebx, [alloc_size] - add ebx, 0xFFF - and ebx, not 0xFFF - add ebx, [SLOT_BASE+APPDATA.mem_size+edx] - call update_mem_size + mov edx, [current_slot] + mov ebx, [alloc_size] + add ebx, 0xFFF + and ebx, not 0xFFF + add ebx, [edx+APPDATA.mem_size] + call update_mem_size mov eax, esi add eax, 4096 - ; sub eax, new_app_base ret m_next: add esi, eax @@ -750,15 +743,12 @@ proc user_free stdcall, base:dword dec ecx jnz .release .not_used: - mov edx, [CURRENT_TASK] - shl edx, 8 - mov esi, dword [edx+SLOT_BASE+APPDATA.heap_base]; heap_base - mov edi, dword [edx+SLOT_BASE+APPDATA.heap_top]; heap_top - sub ebx, [edx+SLOT_BASE+APPDATA.mem_size] + mov edx, [current_slot] + mov esi, dword [edx+APPDATA.heap_base] + mov edi, dword [edx+APPDATA.heap_top] + sub ebx, [edx+APPDATA.mem_size] neg ebx call update_mem_size - ; add esi, new_app_base - ; add edi, new_app_base shr esi, 12 shr edi, 12 @@: diff --git a/kernel/branches/flat_kernel/core/memory.inc b/kernel/branches/flat_kernel/core/memory.inc index c8d2c95756..34e70ed30a 100644 --- a/kernel/branches/flat_kernel/core/memory.inc +++ b/kernel/branches/flat_kernel/core/memory.inc @@ -303,12 +303,11 @@ proc new_mem_resize stdcall, new_size:dword and edi,not 4095 mov [new_size], edi - mov edx,[CURRENT_TASK] - shl edx,8 - cmp [SLOT_BASE+APPDATA.heap_base+edx],0 + mov edx,[current_slot] + cmp [edx+APPDATA.heap_base],0 jne .exit - mov esi, [SLOT_BASE+APPDATA.mem_size+edx] + mov esi, [edx+APPDATA.mem_size] add esi, 4095 and esi, not 4095 @@ -332,16 +331,13 @@ proc new_mem_resize stdcall, new_size:dword jb @B .update_size: - mov ebx, [new_size] - call update_mem_size + mov ebx, [new_size] + call update_mem_size xor eax, eax dec [pg_data.pg_mutex] ret - .expand: - ; add edi, new_app_base - ; add esi, new_app_base push esi push edi @@ -405,14 +401,14 @@ proc new_mem_resize stdcall, new_size:dword endp update_mem_size: -; in: edx = slot shl 8 +; in: edx = slot base ; ebx = new memory size ; destroys eax,ecx,edx - mov [SLOT_BASE+APPDATA.mem_size+edx],ebx + mov [APPDATA.mem_size+edx],ebx ;search threads and update ;application memory size infomation - mov ecx,[SLOT_BASE+APPDATA.dir_table+edx] + mov ecx,[APPDATA.dir_table+edx] mov eax,2 .search_threads: @@ -456,38 +452,35 @@ proc page_fault_handler .err_addr equ ebp-4 pushad - -; push eax -; push edx -; mov edx, 0x400 ;bocsh -; mov al,0xff ;bocsh -; out dx, al ;bocsh -; pop edx -; pop eax - mov ebp, esp mov eax, cr2 push eax - push ds - push es - mov ax, 0x10 + mov ax, app_data mov ds, ax mov es, ax inc [pg_data.pages_faults] + push eax + push edx + mov edx, 0x400 ;bochs + mov al,0xff ;bochs + out dx, al ;bochs + pop edx + pop eax + mov ebx, [.err_addr] mov eax, [.err_code] cmp ebx, OS_BASE - jb .user_space ;страница в памяти приложени + jb .user_space ;страница в памяти приложения ; cmp ebx, page_tabs jb .kernel_space ;страница в памяти ядра cmp ebx, kernel_tabs - jb .alloc;.app_tabs ;таблицы страниц приложени + jb .alloc;.app_tabs ;таблицы страниц приложения ; ;просто создадим одну cmp ebx, LFB_BASE @@ -514,7 +507,7 @@ align 4 mov eax, [page_tabs+ebx*4] test eax, 2 - jz .fail ;адрес не зарезервирован дл + jz .fail ;адрес не зарезервирован для ; ;использования. Ошибка .alloc: call alloc_page @@ -530,8 +523,6 @@ align 4 cld rep stosd .exit: - pop es - pop ds mov esp, ebp popad add esp, 4 @@ -557,8 +548,6 @@ align 4 .core_tabs: .fail: - pop es - pop ds mov esp, ebp popad add esp, 4 @@ -729,15 +718,12 @@ sys_IPC: align 4 proc set_ipc_buff - mov eax,[CURRENT_TASK] - shl eax,8 - add eax, SLOT_BASE + mov eax,[current_slot] pushf cli - mov [eax+0xA0],ebx ;set fields in extended information area - mov [eax+0xA4],ecx + mov [eax+APPDATA.ipc_start],ebx ;set fields in extended information area + mov [eax+APPDATA.ipc_size],ecx - ; add ebx, new_app_base add ecx, ebx add ecx, 4095 and ecx, not 4095 @@ -914,14 +900,12 @@ new_services: @@: cmp eax, 13 ja @f - ; add ebx, new_app_base stdcall user_free, ebx mov [esp+36], eax ret @@: cmp eax, 14 ja @f - ; add ebx, new_app_base cmp ebx, OS_BASE jae .fail stdcall get_event_ex, ebx, ecx @@ -930,10 +914,9 @@ new_services: @@: cmp eax, 15 ja @f - mov ecx, [CURRENT_TASK] - shl ecx, 8 - mov eax, [ecx+SLOT_BASE+APPDATA.fpu_handler] - mov [ecx+SLOT_BASE+APPDATA.fpu_handler], ebx + mov ecx, [current_slot] + mov eax, [ecx+APPDATA.fpu_handler] + mov [ecx+APPDATA.fpu_handler], ebx mov [esp+36], eax ret @@: @@ -942,7 +925,6 @@ new_services: test ebx, ebx jz .fail - ; add ebx, new_app_base cmp ebx, OS_BASE jae .fail stdcall get_service, ebx @@ -957,10 +939,9 @@ new_services: @@: cmp eax, 18 ja @f - mov ecx, [CURRENT_TASK] - shl ecx, 8 - mov eax, [ecx+SLOT_BASE+APPDATA.sse_handler] - mov [ecx+SLOT_BASE+APPDATA.sse_handler], ebx + mov ecx, [current_slot] + mov eax, [ecx+APPDATA.sse_handler] + mov [ecx+APPDATA.sse_handler], ebx mov [esp+36], eax ret @@: diff --git a/kernel/branches/flat_kernel/core/sched.inc b/kernel/branches/flat_kernel/core/sched.inc index db71bd21d4..89f57d4af1 100644 --- a/kernel/branches/flat_kernel/core/sched.inc +++ b/kernel/branches/flat_kernel/core/sched.inc @@ -138,7 +138,7 @@ find_next_task: jb @f mov edi, CURRENT_TASK xor ebx, ebx - @@: +@@: add edi,0x20 inc ebx @@ -237,3 +237,91 @@ updatecputimes: jnz .newupdate ret + +if 0 + +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 + +rdy_head rd 16 + + +align 4 +pick_task: + + xor eax, eax +.pick: + mov ebx, [rdy_head+eax*4] + test ebx, ebx + jz .next + + mov [next_task], ebx + test [ebx+flags.billable] + jz @F + mov [bill_task], ebx +@@: + ret +.next: + inc eax + jmp .pick + + +; param +; eax= task +; +; retval +; eax= task +; ebx= queue +; ecx= front if 1 or back if 0 + +align 4 +shed: + cmp [eax+.tics_left], 0 ;signed compare + mov ebx, [eax+.priority] + setg ecx + jg @F + + mov edx, [eax+.tics_quantum] + mov [eax+.ticks_left], edx + cmp ebx, (IDLE_PRIORITY-1) + je @F + inc ebx +@@: + ret + +; param +; eax= task + +align 4 +enqueue: + call shed ;eax + cmp [rdy_head+ebx*4],0 + jnz @F + + mov [rdy_head+ebx*4], eax + mov [rdy_tail+ebx*4], eax + mov [eax+.next_ready], 0 + jmp .pick +@@: + test ecx, ecx + jz .back + + mov ecx, [rdy_head+ebx*4] + mov [eax+.next_ready], ecx + mov [rdy_head+ebx*4], eax + jmp .pick +.back: + mov ecx, [rdy_tail+ebx*4] + mov [ecx+.next_ready], eax + mov [rdy_tail+ebx*4], eax + mov [eax+.next_ready], 0 +.pick: + call pick_proc ;select next task + ret + +end if + diff --git a/kernel/branches/flat_kernel/core/sys32.inc b/kernel/branches/flat_kernel/core/sys32.inc index 2863767847..6291bf2d91 100644 --- a/kernel/branches/flat_kernel/core/sys32.inc +++ b/kernel/branches/flat_kernel/core/sys32.inc @@ -118,9 +118,8 @@ exc_c: ; test if debugging cli - mov eax, [CURRENT_TASK] - shl eax, 8 - mov eax, [SLOT_BASE+eax+APPDATA.debugger_slot] + mov eax, [current_slot] + mov eax, [eax+APPDATA.debugger_slot] test eax, eax jnz .debug sti diff --git a/kernel/branches/flat_kernel/core/syscall.inc b/kernel/branches/flat_kernel/core/syscall.inc index 57190b102b..b68b8e165c 100644 --- a/kernel/branches/flat_kernel/core/syscall.inc +++ b/kernel/branches/flat_kernel/core/syscall.inc @@ -55,9 +55,8 @@ sysenter_entry: ; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP ; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app - mov esp, [CURRENT_TASK] - shl esp, 8 - mov esp, [SLOT_BASE + esp + APPDATA.pl0_stack] + mov esp, [current_slot] + mov esp, [esp + APPDATA.pl0_stack] add esp, RING0_STACK_SIZE ; configure ESP sti ;------------------ @@ -104,14 +103,12 @@ syscall_entry: ; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP ; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app - mov esp, [CURRENT_TASK] - shl esp, 8 - mov esp, [SLOT_BASE + esp + APPDATA.pl0_stack] + mov esp, [current_slot] + mov esp, [esp + APPDATA.pl0_stack] add esp, RING0_STACK_SIZE ; configure ESP sti ;------------------ -; push ds es pushad cld @@ -132,7 +129,6 @@ syscall_entry: pop eax popad - ; pop es ds ;------------------ cli diff --git a/kernel/branches/flat_kernel/core/taskman.inc b/kernel/branches/flat_kernel/core/taskman.inc index a0ada62544..60017bc0b7 100644 --- a/kernel/branches/flat_kernel/core/taskman.inc +++ b/kernel/branches/flat_kernel/core/taskman.inc @@ -21,40 +21,6 @@ struc APP_HEADER_01 .i_icon dd ? ;+32 } -struc TSS -{ - ._back rw 2 - ._esp0 rd 1 - ._ss0 rw 2 - ._esp1 rd 1 - ._ss1 rw 2 - ._esp2 rd 1 - ._ss2 rw 2 - ._cr3 rd 1 - ._eip rd 1 - ._eflags rd 1 - ._eax rd 1 - ._ecx rd 1 - ._edx rd 1 - ._ebx rd 1 - ._esp rd 1 - ._ebp rd 1 - ._esi rd 1 - ._edi rd 1 - ._es rw 2 - ._cs rw 2 - ._ss rw 2 - ._ds rw 2 - ._fs rw 2 - ._gs rw 2 - ._ldt rw 2 - ._trap rw 1 - ._io rw 1 -} - -virtual at 0 - TSS TSS -end virtual struc APP_PARAMS { .app_cmdline ;0x00 @@ -484,14 +450,19 @@ endp align 4 set_cr3: - mov esi, [CURRENT_TASK] - mov ebx, esi - shl esi,8 - mov [SLOT_BASE+esi+0xB8],eax - imul ebx,tss_step - add ebx,tss_data - mov [ebx+28], eax + + mov ebx, [current_slot] + mov [ebx+APPDATA.dir_table], eax mov cr3, eax + +; mov esi, [CURRENT_TASK] +; mov ebx, esi +; shl esi,8 +; mov [SLOT_BASE+esi+0xB8],eax +; imul ebx,tss_step +; add ebx,tss_data +; mov [ebx+28], eax +; mov cr3, eax ret align 4 @@ -864,9 +835,7 @@ proc new_sys_threads mov [slot], eax - mov esi,[CURRENT_TASK] - shl esi,8 - add esi,SLOT_BASE + mov esi,[current_slot] mov ebx,esi ;ebx=esi - pointer to extended information about current thread mov edi, eax diff --git a/kernel/branches/flat_kernel/gui/button.inc b/kernel/branches/flat_kernel/gui/button.inc index 3608919d86..daffb42e85 100644 --- a/kernel/branches/flat_kernel/gui/button.inc +++ b/kernel/branches/flat_kernel/gui/button.inc @@ -164,16 +164,15 @@ button_dececx: sys_button: push edi - mov edi,[CURRENT_TASK] - shl edi,8 + mov edi,[current_slot] rol eax,16 - add ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] + add ax,word[edi+APPDATA.wnd_clientbox.left] rol eax,16 rol ebx,16 - add bx,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] + add bx,word[edi+APPDATA.wnd_clientbox.top] rol ebx,16 pop edi - .forced: +.forced: test ecx,0x80000000 jnz remove_button @@ -220,7 +219,7 @@ sys_button: pop edx and edx, 0xFFFF - .newline: +.newline: call button_dececx push edi xor edi, edi @@ -233,7 +232,7 @@ sys_button: call drawbuttonframes - button_no_draw: +button_no_draw: and ecx,0xffff @@ -268,7 +267,7 @@ sys_button: mov bx,[esp+8+0] mov [eax],bx - noaddbutt: +noaddbutt: pop edx pop ecx @@ -284,14 +283,14 @@ remove_button: and ecx,0x7fffffff - rnewba2: +rnewba2: mov edi,[BTN_ADDR] mov eax,edi movzx ebx,word [edi] inc bx - rnewba: +rnewba: dec bx jz rnmba @@ -317,7 +316,7 @@ remove_button: jmp rnewba2 - rnmba: +rnmba: ret @@ -328,17 +327,17 @@ find_pressed_button_frames: movzx ebx,word [eax+0] shl ebx,5 add ebx,window_data - mov ecx, [ebx+ WDATA.box.left] ; window x start + mov ecx, [ebx+ WDATA.box.left] ; window x start movzx edx,word [eax+4] ; button x start add ecx,edx push ecx - mov dx,[eax+6] ; button x size + mov dx,[eax+6] ; button x size add cx,dx mov esi,ecx inc esi - mov ecx, [ebx+WDATA.box.top] ; window y start - mov dx,[eax+8] ; button y start + mov ecx, [ebx+WDATA.box.top] ; window y start + mov dx,[eax+8] ; button y start add ecx,edx mov ebx,ecx mov dx,[eax+10] ; button y size diff --git a/kernel/branches/flat_kernel/gui/event.inc b/kernel/branches/flat_kernel/gui/event.inc index f3a1e6e023..c3c99dc1d9 100644 --- a/kernel/branches/flat_kernel/gui/event.inc +++ b/kernel/branches/flat_kernel/gui/event.inc @@ -114,9 +114,8 @@ create_event: cld rep movsd @@: - mov ecx, [CURRENT_TASK] - shl ecx,8 - add ecx, SLOT_BASE+APP_OBJ_OFFSET + mov ecx, [current_slot] + add ecx, APP_OBJ_OFFSET pushfd cli @@ -217,12 +216,11 @@ align 4 proc get_event_ex stdcall, p_ev:dword, timeout:dword .wait: - mov edx,[CURRENT_TASK] - shl edx,8 + mov edx,[current_slot] ; cmp [SLOT_BASE+edx+APPDATA.ev_count], 0 ; je .switch - add edx, SLOT_BASE+APP_EV_OFFSET + add edx, APP_EV_OFFSET mov eax, [edx+APPOBJ.fd] cmp eax, edx @@ -300,9 +298,7 @@ wait_event: test [eax+EVENT.state], MANUAL_RESET jnz .done - mov edx,[CURRENT_TASK] - shl edx,8 - add edx, SLOT_BASE + mov edx,[current_slot] pushfd cli ;remove event from events @@ -575,15 +571,14 @@ get_event_for_app: ;mov edi,[TASK_BASE] ; mouse event test [edi+TASKDATA.event_mask],dword 00100000b jz no_mouse_event - mov eax,[CURRENT_TASK] - shl eax,8 - test [eax+SLOT_BASE+APPDATA.event_mask],dword 00100000b + mov eax,[current_slot] + test [eax+APPDATA.event_mask],dword 00100000b jz no_mouse_event - and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-00100000b + and [eax+APPDATA.event_mask],dword 0xffffffff-00100000b popad mov eax,6 ret - no_mouse_event: +no_mouse_event: ;mov edi,[TASK_BASE] ; DESKTOP BACKGROUND REDRAW @@ -594,42 +589,39 @@ get_event_for_app: popad mov eax,5 ret - no_eventoccur5: +no_eventoccur5: ;mov edi,[TASK_BASE] ; IPC test [edi+TASKDATA.event_mask],dword 01000000b jz no_ipc - mov eax,[CURRENT_TASK] - shl eax,8 - test [eax+SLOT_BASE+APPDATA.event_mask],dword 01000000b + mov eax,[current_slot] + test [eax+APPDATA.event_mask],dword 01000000b jz no_ipc - and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-01000000b + and [eax+APPDATA.event_mask],dword 0xffffffff-01000000b popad mov eax,7 ret - no_ipc: +no_ipc: ;mov edi,[TASK_BASE] ; STACK test [edi+TASKDATA.event_mask],dword 10000000b jz no_stack_event - mov eax,[CURRENT_TASK] - shl eax,8 - test [eax+SLOT_BASE+APPDATA.event_mask],dword 10000000b + mov eax,[current_slot] + test [eax+APPDATA.event_mask],dword 10000000b jz no_stack_event - and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-10000000b + and [eax+APPDATA.event_mask],dword 0xffffffff-10000000b popad mov eax,8 ret - no_stack_event: +no_stack_event: test byte [edi+TASKDATA.event_mask+1], 1 ; DEBUG jz .test_IRQ - mov eax, [CURRENT_TASK] - shl eax, 8 - test byte [eax+SLOT_BASE+APPDATA.event_mask+1], byte 1 + mov eax, [current_slot] + test byte [eax+APPDATA.event_mask+1], byte 1 jz .test_IRQ - and byte [eax+SLOT_BASE+APPDATA.event_mask+1], not 1 + and byte [eax+APPDATA.event_mask+1], not 1 popad mov eax, 9 ret diff --git a/kernel/branches/flat_kernel/gui/window.inc b/kernel/branches/flat_kernel/gui/window.inc index c58138e4b9..6fea3a4dfc 100644 --- a/kernel/branches/flat_kernel/gui/window.inc +++ b/kernel/branches/flat_kernel/gui/window.inc @@ -1773,18 +1773,15 @@ random_shaped_window: test eax, eax jne rsw_no_address - mov eax,[CURRENT_TASK] - shl eax,8 - - mov [eax+SLOT_BASE+APPDATA.wnd_shape],ebx - rsw_no_address: + mov eax,[current_slot] + mov [eax+APPDATA.wnd_shape],ebx +rsw_no_address: cmp eax,1 jne rsw_no_scale - mov eax,[CURRENT_TASK] - shl eax,8 - mov byte [eax+SLOT_BASE+APPDATA.wnd_shape_scale], bl - rsw_no_scale: + mov eax,[current_slot] + mov byte [eax+APPDATA.wnd_shape_scale], bl +rsw_no_scale: ret diff --git a/kernel/branches/flat_kernel/kernel.asm b/kernel/branches/flat_kernel/kernel.asm index acf2cb4ef0..8a6ba41d22 100644 --- a/kernel/branches/flat_kernel/kernel.asm +++ b/kernel/branches/flat_kernel/kernel.asm @@ -424,6 +424,12 @@ high_code: mov [graph_data_l+4],al mov [graph_data_l+7],ah + + mov [CURRENT_TASK],dword 1 + mov [TASK_COUNT],dword 1 + mov [TASK_BASE],dword TASK_DATA + mov [current_slot], SLOT_BASE+256 + ;!!!!!!!!!!!!!!!!!!!!!!!!!! include 'detect/disks.inc' ;!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -446,10 +452,6 @@ include 'vmodeld.inc' ; LOAD FONTS I and II - mov [CURRENT_TASK],dword 1 - mov [TASK_COUNT],dword 1 - mov [TASK_BASE],dword TASK_DATA - mov esi,char xor ebx,ebx mov ecx,2560 @@ -577,6 +579,7 @@ include 'vmodeld.inc' ; task list mov [CURRENT_TASK],dword 1 mov [TASK_COUNT],dword 1 + mov [current_slot], SLOT_BASE+256 mov [TASK_DATA+TASKDATA.wnd_number], 1 ; on screen number mov [TASK_DATA+TASKDATA.pid], 1 ; process id number mov [TASK_DATA+TASKDATA.mem_start], 0 ; process base address @@ -3986,11 +3989,10 @@ sys_putimage: .exit: ret @@: - mov edi,[CURRENT_TASK] - shl edi,8 - add dx,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] + mov edi,[current_slot] + add dx,word[edi+APPDATA.wnd_clientbox.top] rol edx,16 - add dx,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] + add dx,word[edi+APPDATA.wnd_clientbox.left] rol edx,16 .forced: push ebp esi 0 @@ -4089,12 +4091,11 @@ putimage_get32bpp: ; edi color __sys_drawbar: - mov esi,[CURRENT_TASK] - shl esi,8 - add eax,[esi+SLOT_BASE+APPDATA.wnd_clientbox.left] - add ecx,[esi+SLOT_BASE+APPDATA.wnd_clientbox.left] - add ebx,[esi+SLOT_BASE+APPDATA.wnd_clientbox.top] - add edx,[esi+SLOT_BASE+APPDATA.wnd_clientbox.top] + mov esi,[current_slot] + add eax,[esi+APPDATA.wnd_clientbox.left] + add ecx,[esi+APPDATA.wnd_clientbox.left] + add ebx,[esi+APPDATA.wnd_clientbox.top] + add edx,[esi+APPDATA.wnd_clientbox.top] .forced: inc [mouse_pause] ; call [disable_mouse] @@ -4623,10 +4624,9 @@ syscall_setpixel: ; SetPixel mov edx,[TASK_BASE] add eax,[edx-twdw+WDATA.box.left] add ebx,[edx-twdw+WDATA.box.top] - mov edi,[CURRENT_TASK] - shl edi,8 - add eax,[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] - add ebx,[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] + mov edi,[current_slot] + add eax,[edi+APPDATA.wnd_clientbox.left] + add ebx,[edi+APPDATA.wnd_clientbox.top] xor edi,edi ; no force ; mov edi,1 call [disable_mouse] @@ -4636,20 +4636,19 @@ align 4 syscall_writetext: ; WriteText - mov edi,[TASK_BASE] - mov ebp,[edi-twdw+WDATA.box.left] - push esi - mov esi,[CURRENT_TASK] - shl esi,8 - add ebp,[esi+SLOT_BASE+APPDATA.wnd_clientbox.left] - shl ebp,16 - add ebp,[edi-twdw+WDATA.box.top] - add bp,word[esi+SLOT_BASE+APPDATA.wnd_clientbox.top] - pop esi - add ecx,[edi+TASKDATA.mem_start] - add eax,ebp - xor edi,edi - jmp dtext + mov edi,[TASK_BASE] + mov ebp,[edi-twdw+WDATA.box.left] + push esi + mov esi,[current_slot] + add ebp,[esi+APPDATA.wnd_clientbox.left] + shl ebp,16 + add ebp,[edi-twdw+WDATA.box.top] + add bp,word[esi+APPDATA.wnd_clientbox.top] + pop esi + add ecx,[edi+TASKDATA.mem_start] + add eax,ebp + xor edi,edi + jmp dtext align 4 @@ -4679,10 +4678,9 @@ syscall_drawrect: ; DrawRect shr eax,16 movzx edx,bx shr ebx,16 - mov esi,[CURRENT_TASK] - shl esi,8 - add eax,[esi+SLOT_BASE+APPDATA.wnd_clientbox.left] - add ebx,[esi+SLOT_BASE+APPDATA.wnd_clientbox.top] + mov esi,[current_slot] + add eax,[esi+APPDATA.wnd_clientbox.left] + add ebx,[esi+APPDATA.wnd_clientbox.top] add ecx,eax add edx,ebx jmp [drawbar] @@ -4761,17 +4759,16 @@ syscall_drawline: ; DrawLine mov edi,[TASK_BASE] movzx edx,word[edi-twdw+WDATA.box.left] mov ebp,edx - mov esi,[CURRENT_TASK] - shl esi,8 - add ebp,[esi+SLOT_BASE+APPDATA.wnd_clientbox.left] - add dx,word[esi+SLOT_BASE+APPDATA.wnd_clientbox.left] + mov esi,[current_slot] + add ebp,[esi+APPDATA.wnd_clientbox.left] + add dx,word[esi+APPDATA.wnd_clientbox.left] shl edx,16 add ebp,edx movzx edx,word[edi-twdw+WDATA.box.top] add eax,ebp mov ebp,edx - add ebp,[esi+SLOT_BASE+APPDATA.wnd_clientbox.top] - add dx,word[esi+SLOT_BASE+APPDATA.wnd_clientbox.top] + add ebp,[esi+APPDATA.wnd_clientbox.top] + add dx,word[esi+APPDATA.wnd_clientbox.top] shl edx,16 xor edi,edi add edx,ebp diff --git a/kernel/branches/flat_kernel/memmap.inc b/kernel/branches/flat_kernel/memmap.inc index 83dfb8a140..d274dded31 100644 --- a/kernel/branches/flat_kernel/memmap.inc +++ b/kernel/branches/flat_kernel/memmap.inc @@ -134,10 +134,10 @@ ; 0x80080000 -> 8FFFF additional app info, in 256 byte steps - 256 entries ; ; 00 11db name of app running -; 10 dword pointer to fpu save area -; 14 dword event count -; 18 dword user fpu exceptoins handler -; 1c dword user sse exceptions handler +; 0x10 dword pointer to fpu save area +; 0x14 dword event count +; 0x18 dword user fpu exceptoins handler +; 0x1c dword user sse exceptions handler ; 20 dword PL0 stack base ; 24 dword user heap base ; 28 dword user heap top @@ -234,4 +234,252 @@ ; 0xFE000000 -> 0xFE7FFFFF application available LFB 8Mb ; 0xFE800000 -> 0xFFFFFFFF kernel LFB part 24 Mb +if 0 + +Эта бадяга с копирайтами уже задолбала. Приходится делать всё самому +Вот проект заголовков. + +Для сравнения я брал исходники MeOS 079p1 + +Если файл попал в один из списков ошибочно, укажите. + +Список разработчиков ядра KolibriOS взят из последнего дистрибутива. +Если кого-то забыли, укажите + +Через две недели я проставлю заголовки на все перечисленные файлы. + +kernel.asm + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. +;; PROGRAMMING: +;; Иван Поддубный +;; Марат Закиянов (Mario79) +;; VaStaNi +;; Trans +;; Михаил Семеняко (mike.dld) +;; Сергей Кузьмин (Wildwest) +;; Халявин Андрей (halyavin) +;; Михаил Лисовин (Mihasik) +;; Андрей Игнатьев (andrew_programmer) +;; NoName +;; Евгений Гречников (Diamond) +;; Михайлов Илья (Ghost) +;; Сергей Семёнов (Serge) +;; Johnny_B +;; +;; Data in this file was originally part of MenuetOS project which is +;; distributed under the terms of GNU GPL. It is modified and redistributed as +;; part of KolibriOS project under the terms of GNU GPL. +;; +;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa +;; PROGRAMMING: +;; +;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi +;; - main os coding/design +;; Jan-Michael Brummer, BUZZ2@gmx.de +;; Felix Kaiser, info@felix-kaiser.de +;; Paolo Minazzi, paolo.minazzi@inwind.it +;; quickcode@mail.ru +;; Alexey, kgaz@crosswinds.net +;; Juan M. Caravaca, bitrider@wanadoo.es +;; kristol@nic.fi +;; Mike Hibbett, mikeh@oceanfree.net +;; Lasse Kuusijarvi, kuusijar@lut.fi +;; Jarek Pelczar, jarekp3@wp.pl +;; +;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY +;; WARRANTY. No author or distributor accepts responsibility to anyone for the +;; consequences of using it or for whether it serves any particular purpose or +;; works at all, unless he says so in writing. Refer to the GNU General Public +;; License (the "GPL") for full details. +; +;; Everyone is granted permission to copy, modify and redistribute KolibriOS, +;; but only under the conditions described in the GPL. A copy of this license +;; is supposed to have been given to you along with KolibriOS so you can know +;; your rights and responsibilities. It should be in a file named COPYING. +;; Among other things, the copyright notice and this notice must be preserved +;; on all copies. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + + +На этих файлах уже стоят различные копирайты +Будет добавлен копирайт KolibriOS Team + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. +;; +;; Distributed under terms of the GNU General Public License +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +fdo.inc +kernel16.inc +kernel32.inc +vmodeld.inc +vmodeint.inc + +blkdev/cd_drv.inc +blkdev/flp_drv.inc +blkdev/hd_drv.inc +blkdev/rd.inc + +boot/shutdown.inc + +bus/pci/pci16.inc +bus/pci/pci32.inc + +core/sync.inc +core/sys32.inc + +detect/commouse.inc +detect/dev_fd.inc +detect/dev_hdcd.inc +detect/sear_par.inc + +fs/fat12.inc +fs/fat32.inc +fs/fs.inc +fs/fs_lfn.inc +fs/part_set.inc + +network/icmp.inc +network/ip.inc +network/queue.inc +network/socket.inc +network/stack.inc +network/tcp.inc +network/udp.inc + +network/eth_drv/arp.inc +network/eth_drv/ethernet.inc +network/eth_drv/drivers/3c59x.inc +network/eth_drv/drivers/i8255x.inc +network/eth_drv/drivers/pcnet32.inc +network/eth_drv/drivers/rtl8029.inc +network/eth_drv/drivers/rtl8139.inc +network/eth_drv/drivers/rtl8169.inc +network/eth_drv/drivers/sis900.inc + +sound/playnote.inc + +video/vesa12.inc +video/vesa20.inc +video/vga.inc + + +Файлы без копирайтов с кодом из МеОС +Будут добавлены копирайты KolibriOS Team и +Menuet OS Team + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. +;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa +;; +;; Distributed under terms of the GNU General Public License +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +blkdev/cdrom.inc +blkdev/fdc.inc + +boot/bootcode.inc + +core/sched.inc + +gui/button.inc +gui/event.inc +gui/mouse.inc +gui/window.inc + +hid/keyboard.inc + +sound/sb16.inc + + +Фалы с копирайтом только KolibriOS Team + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. +;; +;; Distributed under terms of the GNU General Public License +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +kglobals.inc +unpacker.inc +const.inc + +blkdev/rdsave.inc + +boot/preboot.inc +boot/rdload.inc + +core/debug.inc +core/dll.inc +core/exports.inc +core/fpu.inc +core/heap.inc +core/malloc.inc +core/memory.inc +core/syscall.inc +core/taskman.inc + +detect/disks.inc +detect/ps2mouse.inc + +docs/apm.txt +docs/sysfuncr.txt +docs/sysfuncs.txt + +drivers/ati2d.asm +drivers/ensoniq.asm +drivers/infinity.asm +drivers/mixer.asm +drivers/sceletone.asm +drivers/sis.asm +drivers/sound.asm +drivers/codec.inc +drivers/imports.inc +drivers/main.inc +drivers/mix_mmx.inc +drivers/mix_sse2.inc + +fs/iso9660.inc +fs/ntfs.inc + +gui/font.inc +gui/skincode.inc +gui/skindata.inc + +hid/m_com1.inc +hid/m_com2.inc +hid/m_ps2.inc +hid/mousedrv.inc +hid/set_dtc.inc + +network/eth_drv/pci.inc + +skin/default.asm +skin/me_skin.inc + +video/cursors.inc + + +файлы которые можно оставить без копирайта + +memmap.inc + +boot/booteng.inc +boot/bootet.inc +boot/bootge.inc +boot/bootru.inc +boot/et.inc +boot/ru.inc + +end if diff --git a/kernel/branches/flat_kernel/video/cursors.inc b/kernel/branches/flat_kernel/video/cursors.inc index 78826037f7..4bd792010c 100644 --- a/kernel/branches/flat_kernel/video/cursors.inc +++ b/kernel/branches/flat_kernel/video/cursors.inc @@ -267,15 +267,13 @@ proc set_cursor stdcall, hcursor:dword jne .fail ; cmp [eax+CURSOR.size], CURSOR_SIZE ; jne .fail - mov ebx, [CURRENT_TASK] - shl ebx, 8 - xchg eax, [ebx+SLOT_BASE+APPDATA.cursor] + mov ebx, [current_slot] + xchg eax, [ebx+APPDATA.cursor] ret .fail: mov eax, [def_cursor] - mov ebx, [CURRENT_TASK] - shl ebx, 8 - xchg eax, [ebx+SLOT_BASE+APPDATA.cursor] + mov ebx, [current_slot] + xchg eax, [ebx+APPDATA.cursor] ret endp @@ -398,12 +396,11 @@ proc delete_cursor stdcall, hcursor:dword cmp ebx, [esi+CURSOR.pid] jne .fail - mov ebx, [CURRENT_TASK] - shl ebx, 8 - cmp esi, [ebx+SLOT_BASE+APPDATA.cursor] + mov ebx, [current_slot] + cmp esi, [ebx+APPDATA.cursor] jne @F mov eax, [def_cursor] - mov [ebx+SLOT_BASE+APPDATA.cursor], eax + mov [ebx+APPDATA.cursor], eax @@: mov eax, [hcursor] call [eax+APPOBJ.destroy]