/kernel/branches/flat_kernel/core/debug.inc |
---|
19,9 → 19,8 |
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 |
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 |
/kernel/branches/flat_kernel/core/dll.inc |
---|
152,14 → 152,13 |
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 |
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 |
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 |
/kernel/branches/flat_kernel/core/fpu.inc |
---|
227,10 → 227,9 |
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 |
/kernel/branches/flat_kernel/core/heap.inc |
---|
614,22 → 614,21 |
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 |
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 |
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 |
dec ecx |
jnz @B |
mov edx, [CURRENT_TASK] |
shl edx, 8 |
mov edx, [current_slot] |
mov ebx, [alloc_size] |
add ebx, 0xFFF |
and ebx, not 0xFFF |
add ebx, [SLOT_BASE+APPDATA.mem_size+edx] |
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 |
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 |
@@: |
/kernel/branches/flat_kernel/core/memory.inc |
---|
303,12 → 303,11 |
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 |
338,10 → 337,7 |
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 |
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 |
.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 |
mov eax, [page_tabs+ebx*4] |
test eax, 2 |
jz .fail ;àäðåñ íå çàðåçåðâèðîâàí äë |
jz .fail ;àäðåñ íå çàðåçåðâèðîâàí äëÿ ; |
;èñïîëüçîâàíèÿ. Îøèáêà |
.alloc: |
call alloc_page |
530,8 → 523,6 |
cld |
rep stosd |
.exit: |
pop es |
pop ds |
mov esp, ebp |
popad |
add esp, 4 |
557,8 → 548,6 |
.core_tabs: |
.fail: |
pop es |
pop ds |
mov esp, ebp |
popad |
add esp, 4 |
729,15 → 718,12 |
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,7 → 900,6 |
@@: |
cmp eax, 13 |
ja @f |
; add ebx, new_app_base |
stdcall user_free, ebx |
mov [esp+36], eax |
ret |
921,7 → 906,6 |
@@: |
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 |
@@: |
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 |
test ebx, ebx |
jz .fail |
; add ebx, new_app_base |
cmp ebx, OS_BASE |
jae .fail |
stdcall get_service, ebx |
957,10 → 939,9 |
@@: |
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 |
@@: |
/kernel/branches/flat_kernel/core/sched.inc |
---|
237,3 → 237,91 |
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 |
/kernel/branches/flat_kernel/core/sys32.inc |
---|
118,9 → 118,8 |
; 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 |
/kernel/branches/flat_kernel/core/syscall.inc |
---|
55,9 → 55,8 |
; 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 |
; 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 |
pop eax |
popad |
; pop es ds |
;------------------ |
cli |
/kernel/branches/flat_kernel/core/taskman.inc |
---|
21,41 → 21,7 |
.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 |
.app_path ;0x04 |
484,14 → 450,19 |
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 |
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 |