software task switch (experimental, disabled IDE DMA, io permission

map)


git-svn-id: svn://kolibrios.org@420 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-03-19 06:28:05 +00:00
parent 5f84f102c5
commit b1101aa868
13 changed files with 252 additions and 153 deletions

View File

@ -209,6 +209,9 @@ sayerr:
jmp $ jmp $
cpugood: cpugood:
push 0
popf
sti
; set up esp ; set up esp
movzx esp, sp movzx esp, sp

View File

@ -279,19 +279,20 @@ std_application_base_address equ new_app_base
RING0_STACK_SIZE equ (0x2000 - 512) ;512 áàéò äëÿ êîíòåêñòà FPU RING0_STACK_SIZE equ (0x2000 - 512) ;512 áàéò äëÿ êîíòåêñòà FPU
REG_SS equ (RING0_STACK_SIZE-4) REG_SS equ (RING0_STACK_SIZE-4)
REG_ESP equ (RING0_STACK_SIZE-8) REG_APP_ESP equ (RING0_STACK_SIZE-8)
REG_EFLAGS equ (RING0_STACK_SIZE-12) REG_EFLAGS equ (RING0_STACK_SIZE-12)
REG_CS equ (RING0_STACK_SIZE-16) REG_CS equ (RING0_STACK_SIZE-16)
REG_EIP equ (RING0_STACK_SIZE-20) REG_EIP equ (RING0_STACK_SIZE-20)
REG_EAX equ (RING0_STACK_SIZE-24) REG_EFL_2 equ (RING0_STACK_SIZE-24)
REG_ECX equ (RING0_STACK_SIZE-28) REG_EAX equ (RING0_STACK_SIZE-28)
REG_EDX equ (RING0_STACK_SIZE-32) REG_ECX equ (RING0_STACK_SIZE-32)
REG_EBX equ (RING0_STACK_SIZE-36) REG_EDX equ (RING0_STACK_SIZE-36)
REG_ESP equ (RING0_STACK_SIZE-40) ;RING0_STACK_SIZE-20 REG_EBX equ (RING0_STACK_SIZE-40)
REG_EBP equ (RING0_STACK_SIZE-44) REG_ESP equ (RING0_STACK_SIZE-44) ;RING0_STACK_SIZE-20
REG_ESI equ (RING0_STACK_SIZE-48) REG_EBP equ (RING0_STACK_SIZE-48)
REG_EDI equ (RING0_STACK_SIZE-52) REG_ESI equ (RING0_STACK_SIZE-52)
REG_RET equ (RING0_STACK_SIZE-56) ;irq0.return REG_EDI equ (RING0_STACK_SIZE-56)
REG_RET equ (RING0_STACK_SIZE-60) ;irq0.return
PG_UNMAP equ 0x000 PG_UNMAP equ 0x000
PG_MAP equ 0x001 PG_MAP equ 0x001

View File

@ -135,32 +135,32 @@ debug_getcontext:
jmp .ret jmp .ret
.ring0: .ring0:
; note that following code assumes that all interrupt/exception handlers ; note that following code assumes that all interrupt/exception handlers
; saves ring-3 context by push ds es, pushad in this order ; saves ring-3 context by pushad in this order
mov esi, [eax+TSS._esp0] mov esi, [eax+TSS._esp0]
; top of ring0 stack: ring3 stack ptr (ss+esp), iret data (cs+eip+eflags), ds, es, pushad ; top of ring0 stack: ring3 stack ptr (ss+esp), iret data (cs+eip+eflags), pushad
sub esi, 8+12+8+20h sub esi, 8+12+20h
lodsd lodsd ;edi
mov [edi+24h], eax mov [edi+24h], eax
lodsd lodsd ;esi
mov [edi+20h], eax mov [edi+20h], eax
lodsd lodsd ; ebp
mov [edi+1Ch], eax mov [edi+1Ch], eax
lodsd lodsd ;esp
lodsd lodsd ;ebx
mov [edi+14h], eax mov [edi+14h], eax
lodsd lodsd ;edx
mov [edi+10h], eax mov [edi+10h], eax
lodsd lodsd ;ecx
mov [edi+0Ch], eax mov [edi+0Ch], eax
lodsd lodsd ;eax
mov [edi+8], eax mov [edi+8], eax
add esi, 8 ;;; add esi, 8 ;ds es
lodsd lodsd ;eip
mov [edi], eax mov [edi], eax
lodsd lodsd ;cs
lodsd lodsd ;eflags
mov [edi+4], eax mov [edi+4], eax
lodsd lodsd ;esp
mov [edi+18h], eax mov [edi+18h], eax
.ret: .ret:
sti sti
@ -194,29 +194,29 @@ debug_setcontext:
jmp .stiret jmp .stiret
.ring0: .ring0:
mov edi, [eax+TSS._esp0] mov edi, [eax+TSS._esp0]
sub edi, 8+12+8+20h sub edi, 8+12+20h
mov eax, [esi+24h] mov eax, [esi+24h] ;edi
stosd stosd
mov eax, [esi+20h] mov eax, [esi+20h] ;esi
stosd stosd
mov eax, [esi+1Ch] mov eax, [esi+1Ch] ;ebp
stosd
scasd
mov eax, [esi+14h] ;ebx
stosd
mov eax, [esi+10h] ;edx
stosd
mov eax, [esi+0Ch] ;ecx
stosd
mov eax, [esi+8] ;eax
stosd
;;; add edi, 8 ;ds es
mov eax, [esi] ;eip
stosd stosd
scasd scasd
mov eax, [esi+14h] mov eax, [esi+4] ;eflags
stosd stosd
mov eax, [esi+10h] mov eax, [esi+18h] ;esp
stosd
mov eax, [esi+0Ch]
stosd
mov eax, [esi+8]
stosd
add edi, 8
mov eax, [esi]
stosd
scasd
mov eax, [esi+4]
stosd
mov eax, [esi+18h]
stosd stosd
.stiret: .stiret:
sti sti
@ -422,7 +422,7 @@ debug_exc:
; int 1 = #DB ; int 1 = #DB
save_ring3_context save_ring3_context
cld cld
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
mov eax, dr6 mov eax, dr6
@ -460,7 +460,7 @@ debug_exc:
jnz .debug jnz .debug
sti sti
; not debuggee => say error and terminate ; not debuggee => say error and terminate
add esp, 28h+4 add esp, 0x20+4
mov [error_interrupt], 1 mov [error_interrupt], 1
call show_error_parameters call show_error_parameters
mov edx, [TASK_BASE] mov edx, [TASK_BASE]

View File

@ -125,7 +125,7 @@ align 4
align 16 align 16
.main: .main:
save_ring3_context save_ring3_context
mov bx, os_data mov bx, app_data ;os_data
mov ds, bx mov ds, bx
mov es, bx mov es, bx

View File

@ -130,7 +130,7 @@ align 4
e7: ;#NM exception handler e7: ;#NM exception handler
save_ring3_context save_ring3_context
clts clts
mov ax, os_data mov ax, app_data ;
mov ds, ax mov ds, ax
mov es, ax mov es, ax
@ -183,17 +183,17 @@ except_16: ;fpu native exceptions handler
push ecx push ecx
push edx push edx
mov ebx, [ss:CURRENT_TASK] mov ebx, [CURRENT_TASK]
shl ebx, 8 shl ebx, 8
mov eax, [ss:ebx+SLOT_BASE+APPDATA.fpu_handler] mov eax, [ebx+SLOT_BASE+APPDATA.fpu_handler]
test eax, eax test eax, eax
jz .default jz .default
mov ecx, [reg_eip] mov ecx, [reg_eip]
mov edx, [reg_esp] mov edx, [reg_esp]
sub edx, 4 sub edx, 4
mov [ss:edx], ecx mov [edx], ecx
mov [reg_esp], edx mov [reg_esp], edx
mov dword [reg_eip], eax mov dword [reg_eip], eax
@ -227,17 +227,17 @@ except_19: ;sse exceptions handler
push ecx push ecx
push edx push edx
mov ebx, [ss:CURRENT_TASK] mov ebx, [CURRENT_TASK]
shl ebx, 8 shl ebx, 8
mov eax, [ss:ebx+SLOT_BASE+APPDATA.sse_handler] mov eax, [ebx+SLOT_BASE+APPDATA.sse_handler]
test eax, eax test eax, eax
jz .default jz .default
mov ecx, [reg_eip] mov ecx, [reg_eip]
mov edx, [reg_esp] mov edx, [reg_esp]
sub edx, 4 sub edx, 4
mov [ss:edx], ecx mov [edx], ecx
mov [reg_esp], edx mov [reg_esp], edx
mov dword [reg_eip], eax mov dword [reg_eip], eax

View File

@ -1339,9 +1339,9 @@ end if
if 0 if 0
push eax push eax
push edx push edx
mov edx, 0x400 ;bocsh mov edx, 0x400 ;bochs
mov al,0xff ;bocsh mov al,0xff ;bochs
out dx, al ;bocsh out dx, al ;bochs
pop edx pop edx
pop eax pop eax
end if end if

View File

@ -5,10 +5,11 @@
align 32 align 32
irq0: irq0:
save_ring3_context pushfd
mov ax, os_data pushad
mov ds, ax mov ax, app_data ;
mov es, ax mov ds, ax
mov es, ax
inc dword [timer_ticks] inc dword [timer_ticks]
@ -20,8 +21,7 @@ irq0:
add eax,100 add eax,100
mov [next_usage_update],eax mov [next_usage_update],eax
call updatecputimes call updatecputimes
.nocounter: .nocounter:
cmp [DONT_SWITCH], byte 1 cmp [DONT_SWITCH], byte 1
jne .change_task jne .change_task
@ -31,10 +31,11 @@ irq0:
mov [DONT_SWITCH], byte 0 mov [DONT_SWITCH], byte 0
restore_ring3_context popad
iret popfd
iretd
.change_task: .change_task:
call update_counters call update_counters
call find_next_task call find_next_task
@ -49,9 +50,10 @@ irq0:
call do_change_task call do_change_task
.return: .return:
restore_ring3_context popad
iret popfd
iretd
align 4 align 4
@ -82,10 +84,9 @@ change_task:
mov [DONT_SWITCH],byte 1 mov [DONT_SWITCH],byte 1
call do_change_task call do_change_task
.return: .return:
popad popad
popfd popfd
ret ret
@ -105,7 +106,7 @@ endg
update_counters: update_counters:
mov edi, [TASK_BASE] mov edi, [TASK_BASE]
mov ebx, [edi+TASKDATA.counter_add] ; time stamp counter add mov ebx, [edi+TASKDATA.counter_add] ; time stamp counter add
call _rdtsc rdtsc
sub eax, ebx sub eax, ebx
add eax, [edi+TASKDATA.counter_sum] ; counter sum add eax, [edi+TASKDATA.counter_sum] ; counter sum
mov [edi+TASKDATA.counter_sum], eax mov [edi+TASKDATA.counter_sum], eax
@ -123,10 +124,10 @@ find_next_task:
mov edi, [TASK_BASE] mov edi, [TASK_BASE]
mov [prev_slot], ebx mov [prev_slot], ebx
.waiting_for_termination: .waiting_for_termination:
.waiting_for_reuse: .waiting_for_reuse:
.waiting_for_event: .waiting_for_event:
.suspended: .suspended:
cmp ebx, [TASK_COUNT] cmp ebx, [TASK_COUNT]
jb @f jb @f
mov edi, CURRENT_TASK mov edi, CURRENT_TASK
@ -160,28 +161,58 @@ find_next_task:
jz .waiting_for_event jz .waiting_for_event
mov [event_sched], eax mov [event_sched], eax
mov [edi+TASKDATA.state], byte 0 mov [edi+TASKDATA.state], byte 0
.noevents: .noevents:
.found: .found:
mov [CURRENT_TASK],ebx mov [CURRENT_TASK],ebx
mov [TASK_BASE],edi mov [TASK_BASE],edi
call _rdtsc rdtsc ;call _rdtsc
mov [edi+TASKDATA.counter_add],eax mov [edi+TASKDATA.counter_add],eax
mov esi, [prev_slot]
xor eax, eax xor eax, eax
cmp ebx, [prev_slot] cmp ebx, esi
sete al sete al
ret ret
; in: ebx = TSS selector index ; in: ebx = TSS selector index
;
; param
; ebx = incoming task
; esi = outcomig task
do_change_task: do_change_task:
shl ebx, 3
xor eax, eax shl ebx, 8
add ebx, tss0 add ebx, SLOT_BASE
mov [far_jump.sel], bx ; selector mov [current_slot], ebx
mov [far_jump.offs], eax ; offset shl esi, 8
jmp pword [far_jump] add esi, SLOT_BASE
mov [esi+APPDATA.saved_esp], esp
mov esp, [ebx+APPDATA.saved_esp]
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 ecx, cr0
or ecx, CR0_TS ;set task switch flag
mov cr0, ecx
inc [context_counter] ;noname & halyavin inc [context_counter] ;noname & halyavin
ret
ret
;
; shl ebx, 3
; xor eax, eax
; add ebx, tss0
; mov [far_jump.sel], bx ; selector
; mov [far_jump.offs], eax ; offset
; jmp pword [far_jump]
; inc [context_counter] ;noname & halyavin
;ret
@ -193,7 +224,7 @@ updatecputimes:
mov [idleuse],dword 0 mov [idleuse],dword 0
mov ecx, [TASK_COUNT] mov ecx, [TASK_COUNT]
mov edi, TASK_DATA mov edi, TASK_DATA
.newupdate: .newupdate:
mov ebx,[edi+TASKDATA.counter_sum] mov ebx,[edi+TASKDATA.counter_sum]
mov [edi+TASKDATA.cpu_usage],ebx mov [edi+TASKDATA.cpu_usage],ebx
mov [edi+TASKDATA.counter_sum],dword 0 mov [edi+TASKDATA.counter_sum],dword 0

View File

@ -78,13 +78,11 @@ endg
macro save_ring3_context macro save_ring3_context
{ {
push ds es
pushad pushad
} }
macro restore_ring3_context macro restore_ring3_context
{ {
popad popad
pop es ds
} }
; simply return control to interrupted process ; simply return control to interrupted process
@ -114,9 +112,9 @@ exc_wo_code 0, 1, 2, 3, 4, 5, 6, 9, 15, 18
exc_w_code 8, 10, 11, 12, 13, 14, 17 exc_w_code 8, 10, 11, 12, 13, 14, 17
exc_c: exc_c:
mov ax, os_data mov ax, app_data ;èñêëþ÷åíèå
mov ds, ax mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíè
mov es, ax mov es, ax ;â ðåãèñòðû
; test if debugging ; test if debugging
cli cli
@ -127,7 +125,7 @@ exc_c:
jnz .debug jnz .debug
sti sti
; not debuggee => say error and terminate ; not debuggee => say error and terminate
add esp, 28h add esp, 0x20 ;28h
movzx eax, bl movzx eax, bl
mov [error_interrupt], eax mov [error_interrupt], eax
call show_error_parameters call show_error_parameters
@ -242,8 +240,8 @@ macro irqh [num]
irqh 2,5,7,8,9,10,11 irqh 2,5,7,8,9,10,11
irq_c: irq_c:
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
call irqhandler call irqhandler
@ -252,7 +250,7 @@ irqh 2,5,7,8,9,10,11
p_irq6: p_irq6:
save_ring3_context save_ring3_context
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
call fdc_irq call fdc_irq
@ -262,7 +260,7 @@ p_irq6:
p_irq3: p_irq3:
save_ring3_context save_ring3_context
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
cmp [com2_mouse_detected],0 cmp [com2_mouse_detected],0
@ -278,7 +276,7 @@ p_irq3:
p_irq4: p_irq4:
save_ring3_context save_ring3_context
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
cmp [com1_mouse_detected],0 cmp [com1_mouse_detected],0
@ -294,7 +292,7 @@ p_irq4:
p_irq12: p_irq12:
save_ring3_context save_ring3_context
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
call check_mouse_data_ps2 call check_mouse_data_ps2
@ -303,7 +301,7 @@ p_irq12:
p_irq14: p_irq14:
save_ring3_context save_ring3_context
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
call [irq14_func] call [irq14_func]
@ -312,7 +310,7 @@ p_irq14:
iret iret
p_irq15: p_irq15:
save_ring3_context save_ring3_context
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax
call [irq15_func] call [irq15_func]
@ -335,7 +333,7 @@ ready_for_next_irq_1:
irqD: irqD:
save_ring3_context save_ring3_context
mov ax, os_data mov ax, app_data ;os_data
mov ds, ax mov ds, ax
mov es, ax mov es, ax

View File

@ -4,15 +4,14 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 32 align 16
i40: i40:
push ds es
pushad pushad
cld cld
mov ax,word os_data ; mov ax, word app_data
mov ds,ax ; mov ds, ax
mov es,ax ; mov es, ax
; load all registers in crossed order ; load all registers in crossed order
mov eax, ebx mov eax, ebx
@ -28,10 +27,8 @@ i40:
and edi,0xff and edi,0xff
call dword [servetable+edi*4] call dword [servetable+edi*4]
pop eax pop eax
; cli
popad popad
pop es ds
iretd iretd
@ -58,19 +55,18 @@ sysenter_entry:
; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP ; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP
; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app ; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app
mov esp, [ss:CURRENT_TASK] mov esp, [CURRENT_TASK]
shl esp, 8 shl esp, 8
mov esp, [ss:SLOT_BASE + esp + APPDATA.pl0_stack] mov esp, [SLOT_BASE + esp + APPDATA.pl0_stack]
add esp, RING0_STACK_SIZE ; configure ESP add esp, RING0_STACK_SIZE ; configure ESP
sti sti
;------------------ ;------------------
push ds es
pushad pushad
cld cld
mov ax, word os_data ; mov ax, word app_data
mov ds, ax ; mov ds, ax
mov es, ax ; mov es, ax
mov eax, ebx mov eax, ebx
mov ebx, ecx mov ebx, ecx
@ -85,10 +81,9 @@ sysenter_entry:
pop eax pop eax
popad popad
pop es ds
;------------------ ;------------------
mov edx, [SYSENTER_VAR] ; eip mov edx, [SYSENTER_VAR] ; eip
mov ecx, [SYSENTER_VAR + 4] ; esp mov ecx, [SYSENTER_VAR + 4] ; esp
sysexit sysexit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -109,20 +104,20 @@ syscall_entry:
; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP ; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP
; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app ; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app
mov esp, [ss:CURRENT_TASK] mov esp, [CURRENT_TASK]
shl esp, 8 shl esp, 8
mov esp, [ss:SLOT_BASE + esp + APPDATA.pl0_stack] mov esp, [SLOT_BASE + esp + APPDATA.pl0_stack]
add esp, RING0_STACK_SIZE ; configure ESP add esp, RING0_STACK_SIZE ; configure ESP
sti sti
;------------------ ;------------------
push ds es ; push ds es
pushad pushad
cld cld
mov ax, word os_data ; mov ax, word app_data
mov ds, ax ; mov ds, ax
mov es, ax ; mov es, ax
mov eax, ebx mov eax, ebx
mov ebx, ecx mov ebx, ecx
@ -137,7 +132,7 @@ syscall_entry:
pop eax pop eax
popad popad
pop es ds ; pop es ds
;------------------ ;------------------
cli cli

View File

@ -1011,6 +1011,8 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov ebx,[slot] mov ebx,[slot]
mov eax,ebx mov eax,ebx
shl ebx,5 shl ebx,5
lea ecx,[draw_data+ebx] ;ecx - pointer to draw data
; set window state to 'normal' (non-minimized/maximized/rolled-up) state ; set window state to 'normal' (non-minimized/maximized/rolled-up) state
mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL
mov [ebx+window_data+WDATA.fl_redraw], 1 mov [ebx+window_data+WDATA.fl_redraw], 1
@ -1023,8 +1025,6 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov eax,[process_number] mov eax,[process_number]
mov [ebx+4],eax ;set PID mov [ebx+4],eax ;set PID
mov ecx,ebx
add ecx,(draw_data-CURRENT_TASK) ;ecx - pointer to draw data
;set draw data to full screen ;set draw data to full screen
mov [ecx+0],dword 0 mov [ecx+0],dword 0
@ -1058,7 +1058,7 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov [edi+TSS._eip],eax ;set eip in TSS mov [edi+TSS._eip],eax ;set eip in TSS
mov eax, [esi+0x0C] ;app_esp mov eax, [esi+0x0C] ;app_esp
mov [edi+TSS._esp],eax ;set stack in TSS mov [edi+TSS._esp],eax ;set stack in TSS
mov [edi+TSS._eflags],dword 0x3202 mov [edi+TSS._eflags],dword 0x1202
mov [edi+TSS._cs],app_code ;selector of code segment mov [edi+TSS._cs],app_code ;selector of code segment
mov [edi+TSS._ss],app_data mov [edi+TSS._ss],app_data
@ -1067,11 +1067,41 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov [edi+TSS._fs],app_data mov [edi+TSS._fs],app_data
mov [edi+TSS._gs],graph_data ;selector of graphic segment mov [edi+TSS._gs],graph_data ;selector of graphic segment
mov [edi+TSS._io],word 128 mov [edi+TSS._io],word 128
mov [edi+TSS._ss0], os_data mov [edi+TSS._ss0], os_stack
mov ebx, [pl0_stack] mov ebx, [pl0_stack]
add ebx, RING0_STACK_SIZE add ebx, RING0_STACK_SIZE
mov [edi+TSS._esp0],ebx mov [edi+TSS._esp0],ebx
xor eax, eax
mov ebx, [pl0_stack]
lea ecx, [ebx+REG_EIP]
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_APP_ESP], eax ;app_stack
mov [ebx+REG_SS], dword app_data
lea ecx, [ebx+REG_RET]
mov ebx, [slot]
shl ebx, 8
mov [ebx+SLOT_BASE+APPDATA.saved_esp], ecx
mov ecx, edi ;ecx - address of application TSS mov ecx, edi ;ecx - address of application TSS
mov ebx,[slot] mov ebx,[slot]
shl ebx,3 shl ebx,3
@ -1109,6 +1139,37 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov esi,new_process_running mov esi,new_process_running
call sys_msg_board_str ;output information about succefull startup call sys_msg_board_str ;output information about succefull startup
ret 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 endp
include "debug.inc" include "debug.inc"

View File

@ -245,7 +245,7 @@ event_start rd 1
event_end rd 1 event_end rd 1
event_uid rd 1 event_uid rd 1
sys_page_map rd 1 sys_page_map rd 1
os_stack rd 1 os_stack_seg rd 1
srv.fd rd 1 srv.fd rd 1
srv.bk rd 1 srv.bk rd 1
@ -279,6 +279,7 @@ tmp_task_ptab rd 1
LFBSize rd 1 LFBSize rd 1
stall_mcs rd 1 stall_mcs rd 1
current_slot rd 1
; status ; status
hd1_status rd 1 ; 0 - free : other - pid hd1_status rd 1 ; 0 - free : other - pid

View File

@ -19,7 +19,7 @@ max_processes equ 255
tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4
os_data equ os_data_l-gdts ; GDTs os_stack equ os_data_l-gdts ; GDTs
os_code equ os_code_l-gdts os_code equ os_code_l-gdts
graph_data equ 3+graph_data_l-gdts graph_data equ 3+graph_data_l-gdts
tss0 equ tss0_l-gdts tss0 equ tss0_l-gdts
@ -151,7 +151,7 @@ org $+0x10000
align 4 align 4
B32: B32:
mov ax,os_data ; Selector for os mov ax,os_stack ; Selector for os
mov ds,ax mov ds,ax
mov es,ax mov es,ax
mov fs,ax mov fs,ax
@ -214,14 +214,16 @@ org OS_BASE+$
align 4 align 4
high_code: high_code:
mov ax,os_data mov ax,os_stack
mov ds,ax mov bx,app_data
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax mov ss,ax
add esp, OS_BASE add esp, OS_BASE
mov ds,bx
mov es,bx
mov fs,bx
mov gs,bx
mov dword [sys_pgdir], 0 mov dword [sys_pgdir], 0
mov dword [sys_pgdir+4], 0 mov dword [sys_pgdir+4], 0
mov dword [sys_pgdir+8], 0 mov dword [sys_pgdir+8], 0
@ -369,7 +371,9 @@ high_code:
call init_kernel_heap call init_kernel_heap
stdcall kernel_alloc, 0x2000 stdcall kernel_alloc, 0x2000
mov [os_stack], eax mov [os_stack_seg], eax
lea esp, [eax+RING0_STACK_SIZE]
mov [LFBSize], 0x800000 mov [LFBSize], 0x800000
call init_mtrr call init_mtrr
@ -552,7 +556,7 @@ include 'vmodeld.inc'
mov dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I' mov dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I'
mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE ' mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE '
mov edi, [os_stack] mov edi, [os_stack_seg]
mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi
add edi, 0x2000-512 add edi, 0x2000-512
mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi
@ -583,21 +587,21 @@ include 'vmodeld.inc'
cld cld
rep stosd rep stosd
mov edi,tss_data+tss_step mov edi,tss_data
mov [edi+TSS._ss0], os_data mov [edi+TSS._ss0], os_stack
mov eax,cr3 mov eax,cr3
mov [edi+TSS._cr3],eax mov [edi+TSS._cr3],eax
mov [edi+TSS._eip],osloop mov [edi+TSS._eip],osloop
mov [edi+TSS._eflags],dword 0x11202 ; sti and resume mov [edi+TSS._eflags],dword 0x1202 ; sti and resume
mov eax, [os_stack] mov eax, [os_stack_seg]
add eax, 0x2000-512 add eax, 0x2000-512
mov [edi+TSS._esp], eax mov [edi+TSS._esp], eax
mov [edi+TSS._cs],os_code mov [edi+TSS._cs],os_code
mov [edi+TSS._ss],os_data mov [edi+TSS._ss],os_stack ;os_stack
mov [edi+TSS._ds],os_data mov [edi+TSS._ds],app_data ;os_data
mov [edi+TSS._es],os_data mov [edi+TSS._es],app_data ;os_data
mov [edi+TSS._fs],os_data mov [edi+TSS._fs],app_data ;os_data
mov [edi+TSS._gs],os_data mov [edi+TSS._gs],app_data ;os_data
mov ax,tss0 mov ax,tss0
ltr ax ltr ax
@ -717,7 +721,7 @@ first_app_found:
mov esi,boot_tasking mov esi,boot_tasking
call boot_log call boot_log
; mov [ENABLE_TASKSWITCH],byte 1 ; multitasking enabled ; mov [ENABLE_TASKSWITCH],byte 1 ; multitasking enabled
; UNMASK ALL IRQ'S ; UNMASK ALL IRQ'S
@ -743,11 +747,15 @@ first_app_found:
; mov [dma_hdd],1 ; mov [dma_hdd],1
cmp [IDEContrRegsBaseAddr], 0 cmp [IDEContrRegsBaseAddr], 0
setnz [dma_hdd] ; setnz [dma_hdd]
stdcall init_uart_service, DRV_ENTRY stdcall init_uart_service, DRV_ENTRY
sti sti
call change_task
jmp osloop
jmp $ ; wait here for timer to take control jmp $ ; wait here for timer to take control
; Fly :) ; Fly :)

View File

@ -184,8 +184,9 @@ struc APPDATA
.bk_ev dd ? ;+52 .bk_ev dd ? ;+52
.fd_obj dd ? ;+56 .fd_obj dd ? ;+56
.bk_obj dd ? ;+60 .bk_obj dd ? ;+60
.saved_esp dd ? ;+64
db 64 dup(?) ;+64 db 60 dup(?) ;+68
.wnd_shape dd ? ;+128 .wnd_shape dd ? ;+128
.wnd_shape_scale dd ? ;+132 .wnd_shape_scale dd ? ;+132