/kernel/branches/flat_kernel/core/debug.inc |
---|
123,19 → 123,19 |
jnz .ret |
call get_debuggee_slot |
jc .ret |
imul eax, tss_step/32 |
add eax, tss_data |
; imul eax, tss_step/32 |
; add eax, tss_data |
mov edi, edx |
cmp [eax+TSS._cs], app_code |
jnz .ring0 |
lea esi, [eax+TSS._eip] |
shr ecx, 2 |
rep movsd |
jmp .ret |
; cmp [eax+TSS._cs], app_code |
; jnz .ring0 |
; lea esi, [eax+TSS._eip] |
; shr ecx, 2 |
; rep movsd |
; jmp .ret |
.ring0: |
; note that following code assumes that all interrupt/exception handlers |
; saves ring-3 context by pushad in this order |
mov esi, [eax+TSS._esp0] |
mov esi, [tss._esp0] |
; top of ring0 stack: ring3 stack ptr (ss+esp), iret data (cs+eip+eflags), pushad |
sub esi, 8+12+20h |
lodsd ;edi |
182,17 → 182,17 |
jnz .ret |
call get_debuggee_slot |
jc .stiret |
imul eax, tss_step/32 |
add eax, tss_data |
; imul eax, tss_step/32 |
; add eax, tss_data |
mov esi, edx |
cmp [eax+TSS._cs], app_code |
jnz .ring0 |
lea edi, [eax+TSS._eip] |
shr ecx, 2 |
rep movsd |
jmp .stiret |
; cmp [eax+TSS._cs], app_code |
; jnz .ring0 |
; lea edi, [eax+TSS._eip] |
; shr ecx, 2 |
; rep movsd |
; jmp .stiret |
.ring0: |
mov edi, [eax+TSS._esp0] |
mov edi, [tss._esp0] |
sub edi, 8+12+20h |
mov eax, [esi+24h] ;edi |
stosd |
247,8 → 247,8 |
btr dword [eax+10h], ecx ; clear L<i> bit |
test byte [eax+10h], 55h |
jnz .okret |
imul eax, ebp, tss_step/32 |
and byte [eax + tss_data + TSS._trap], not 1 |
; imul eax, ebp, tss_step/32 |
; and byte [eax + tss_data + TSS._trap], not 1 |
.okret: |
and dword [esp+36], 0 |
sti |
289,8 → 289,8 |
not edx |
and [eax+10h+2], dx |
or [eax+10h+2], bx ; set R/W and LEN fields |
imul eax, ebp, tss_step/32 |
or byte [eax + tss_data + TSS._trap], 1 |
; imul eax, ebp, tss_step/32 |
; or byte [eax + tss_data + TSS._trap], 1 |
jmp .okret |
debug_read_process_memory: |
/kernel/branches/flat_kernel/core/memory.inc |
---|
1,3 → 1,4 |
; $Revision$ |
align 4 |
proc alloc_page |
544,6 → 545,40 |
;â òàáëèöàõ ñòðàíèö. äîáàâëåíî â P4/Xeon |
;ïîïûòêà çàïèñè â çàùèù¸ííóþ ñòðàíèöó ÿäðà |
cmp ebx, tss._io_map_0 |
jb .fail |
cmp ebx, tss._io_map_0+8192 |
jae .fail |
; io permission map |
; copy-on-write protection |
call alloc_page |
and eax, eax |
jz .fail |
push eax |
stdcall map_page,[ebp-4],eax,dword PG_SW |
pop eax |
mov edi, [.err_addr] |
and edi, -4096 |
lea esi, [edi+(not tss._io_map_0)+1]; -tss._io_map_0 |
mov ebx, esi |
shr ebx, 12 |
mov edx, [current_slot] |
or eax, PG_SW |
mov [edx+APPDATA.io_map+ebx*4], eax |
add esi, [default_io_map] |
mov ecx, 4096/4 |
cld |
rep movsd |
jmp .exit |
;íå îáðàáàòûâàåì. Îøèáêà |
.core_tabs: |
/kernel/branches/flat_kernel/core/sched.inc |
---|
180,8 → 180,6 |
sete al |
ret |
; in: ebx = TSS selector index |
; |
; param |
; ebx = incoming task |
; esi = outcomig task |
197,12 → 195,18 |
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] |
mov cr3, eax |
mov ebx, [ebx+APPDATA.pl0_stack] |
add ebx, RING0_STACK_SIZE |
mov [tss_data+TSS._esp0], ebx |
mov [tss._esp0], ebx |
mov ecx, cr0 |
or ecx, CR0_TS ;set task switch flag |
mov cr0, ecx |
/kernel/branches/flat_kernel/core/sys32.inc |
---|
12,25 → 12,6 |
dw 8*0x41-1 |
dd idts+8 |
build_process_gdt_tss_pointer: |
mov ecx,tss_data |
mov edi,0 |
setgdtl2: |
mov [edi+gdts+ tss0 +0], word tss_step |
mov [edi+gdts+ tss0 +2], cx |
mov eax,ecx |
shr eax,16 |
mov [edi+gdts+ tss0 +4], al |
mov [edi+gdts+ tss0 +7], ah |
mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b |
add ecx,tss_step |
add edi,8 |
cmp edi,8*(max_processes+5) |
jbe setgdtl2 |
ret |
build_interrupt_table: |
mov edi, idts+8 |
836,11 → 817,10 |
mov esi,boot_sched_1 |
call boot_log |
call build_process_gdt_tss_pointer |
; call build_process_gdt_tss_pointer |
mov esi,boot_sched_2 |
call boot_log |
call build_interrupt_table |
; mov esi,boot_sched_2 |
; call boot_log |
ret |
/kernel/branches/flat_kernel/core/taskman.inc |
---|
454,15 → 454,6 |
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 |
923,6 → 914,12 |
mov [eax+SLOT_BASE+APPDATA.fpu_handler], 0 |
mov [eax+SLOT_BASE+APPDATA.sse_handler], 0 |
;set default io permission map |
mov [eax+SLOT_BASE+APPDATA.io_map],\ |
(tss._io_map_0-OS_BASE+PG_MAP) |
mov [eax+SLOT_BASE+APPDATA.io_map+4],\ |
(tss._io_map_1-OS_BASE+PG_MAP) |
mov esi, fpu_data |
mov ecx, 512/4 |
rep movsd |
1003,47 → 1000,10 |
mov eax,[ScreenHeight] |
mov [ecx+12],eax |
mov edi,[slot] |
imul edi,tss_step |
add edi,tss_data |
mov ecx,128/4 |
xor eax, eax |
cld |
rep stosd |
;Add IO access table - bit array of permitted ports |
not eax |
mov ecx,2048 |
rep stosd ; access to 4096*8=65536 ports |
sub edi, tss_step |
;set cr3 register in TSS of application |
mov ecx, [slot] |
shl ecx, 8 |
mov eax,[SLOT_BASE+ecx+APPDATA.dir_table] |
mov [edi+TSS._cr3],eax |
mov ebx, [pl0_stack] |
mov esi,[params] |
mov eax, [esi+0x08] ;app_eip |
mov [edi+TSS._eip],eax ;set eip in TSS |
mov eax, [esi+0x0C] ;app_esp |
mov [edi+TSS._esp],eax ;set stack in TSS |
mov [edi+TSS._eflags],dword 0x1202 |
mov [edi+TSS._cs],app_code ;selector of code segment |
mov [edi+TSS._ss],app_data |
mov [edi+TSS._ds],app_data |
mov [edi+TSS._es],app_data |
mov [edi+TSS._fs],app_data |
mov [edi+TSS._gs],graph_data ;selector of graphic segment |
mov [edi+TSS._io],word 128 |
mov [edi+TSS._ss0], os_stack |
mov ebx, [pl0_stack] |
add ebx, RING0_STACK_SIZE |
mov [edi+TSS._esp0],ebx |
lea ecx, [ebx+REG_EIP] |
xor eax, eax |
mov ebx, [pl0_stack] |
lea ecx, [ebx+REG_EIP] |
mov [ebx+REG_RET], dword irq0.return |
mov [ebx+REG_EDI], eax |
1071,17 → 1031,6 |
shl ebx, 8 |
mov [ebx+SLOT_BASE+APPDATA.saved_esp], ecx |
mov ecx, edi ;ecx - address of application TSS |
mov ebx,[slot] |
shl ebx,3 |
;set TSS descriptor |
mov [ebx+gdts+tss0+0],word tss_step ;limit (size) |
mov [ebx+gdts+tss0+2],cx ;part of offset |
shr ecx,16 |
mov [ebx+gdts+tss0+4],cl ;part of offset |
mov [ebx+gdts+tss0+7],ch ;part of offset |
mov [ebx+gdts+tss0+5],word 01010000b*256+11101001b ;system flags |
;flush keyboard and buttons queue |
mov [KEY_COUNT],byte 0 |
mov [BTN_COUNT],byte 0 |
1108,37 → 1057,6 |
mov esi,new_process_running |
call sys_msg_board_str ;output information about succefull startup |
ret |
if 0 |
; set stack frame |
xor eax, eax |
lea ecx, [ebx+REG_EIP] |
mov ebx, [pl0_stack] |
mov esi,[params] |
mov [ebx+REG_RET], dword irq0.return |
mov [ebx+REG_EDI], eax |
mov [ebx+REG_ESI], eax |
mov [ebx+REG_EBP], eax |
mov [ebx+REG_ESP], ecx ;ebx+REG_EIP |
mov [ebx+REG_EBX], eax |
mov [ebx+REG_EDX], eax |
mov [ebx+REG_ECX], eax |
mov [ebx+REG_EAX], eax |
mov [ebx+REG_EFL_2], dword 0x1002 |
mov eax, [esi+0x08] ;app_eip |
mov [ebx+REG_EIP], eax ;app_entry |
mov [ebx+REG_CS], dword app_code |
mov [ebx+REG_EFLAGS], dword 0x1202 |
mov eax, [esi+0x0C] ;app_esp |
mov [ebx+REG_ESP], eax ;app_stack |
mov [ebx+REG_SS], dword app_data |
end if |
endp |
include "debug.inc" |