v86 monitor

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
intel_breaker
Member
Member
Posts: 46
Joined: Tue Jan 04, 2005 12:00 am
Location: Poland
Contact:

v86 monitor

Post by intel_breaker »

Hi guys,
I have a very weird problem. I'll try describe it:
I've written support of v86 mode in my kernel. And I have available v86_exec(char *filename) function. Anyway this function works fine, new v86 process is creating and it works on real PC/qemu/vmware. But the main goal of v86 monitor was made a support for vesa, which is support by real-mode interrupts(I mean vesa < 3.0). So I write simple
program which set 800x600x32 bits mode. So for that I've set eax on 0x4f02h and ebx on 0x115h right? then I call interrupts 0x10. And..... it works pretty good on qemu, on real PC it call "HSync out of range" on my monitor, and on vmware it didn't work:/ When I've written "it didn't work" I mean that it execute all commands(no faults) but vmware didn't switch into this mode(I know that vmware supports this mode, because visopsys works in this same mode)
Then where is a BUG?=)

Please for help.
Greg
digo_rp
Member
Member
Posts: 233
Joined: Sun Jun 05, 2005 11:00 pm

Re: v86 monitor

Post by digo_rp »

one question please, what kinda of taskswitching are you using?

software or hardware base taskswitching?

I got v86 working on hardware taskswitching. I move my kernel to sotware based and I would like to implement v86 on that too.

about "HSync out of range" you may need to change to other mode maybe 800x600x16
or 1024x768x16

try that mode cuz some of those modes aren?t available at my PC too :)
User avatar
intel_breaker
Member
Member
Posts: 46
Joined: Tue Jan 04, 2005 12:00 am
Location: Poland
Contact:

Re: v86 monitor

Post by intel_breaker »

Yeah, I use software task switching.
And "Hsync out of range" don't show on the monitor if i use this mode under real-mode:/
digo_rp
Member
Member
Posts: 233
Joined: Sun Jun 05, 2005 11:00 pm

Re: v86 monitor

Post by digo_rp »

could you tell me how do you switch to v86 mode under software taskswitching? I don?t know how to do it... please and your stack layout too, do me that favor... I can bring to you my VM86 monitor if you would...
User avatar
intel_breaker
Member
Member
Posts: 46
Joined: Tue Jan 04, 2005 12:00 am
Location: Poland
Contact:

Re: v86 monitor

Post by intel_breaker »

Here you have a v86 stack frame:

struct intr_frame {
uint32 ds;
uint32 es;

uint32 fs;
uint32 gs;

uint32 edi;
uint32 esi;
uint32 ebp;
uint32 old_esp;
uint32 ebx;
uint32 edx;
uint32 ecx;
uint32 eax;

uint32 intr_index;
uint32 intr_ecode;

uint32 eip;
uint32 cs;
uint32 flags;
uint32 esp;
uint32 ss;

/* v86 mode only */
uint32 v_es;
uint32 v_ds;
uint32 v_fs;
uint32 v_gs;
};

If u've implemented v86 in tss method u should know what put in registers;)
"v" suffixes registers are for v86 segments, normal ds,es,fs,gs are for user data segment.
cs is a code segment in v86 mode, eip is a offset in this segment, ss - stack segment in v86 mode, esp offset in this segment..
This is all.

Regards
Greg
digo_rp
Member
Member
Posts: 233
Joined: Sun Jun 05, 2005 11:00 pm

Re: v86 monitor

Post by digo_rp »

man what is wrong with that function ?
short add_v86task(char *str, word cs, word entry) {

num_of_tasks++;

memset(process[num_of_tasks].stack, 0, stack_size);

memset(process[num_of_tasks].name, 0, 20);

insertstr(process[num_of_tasks].name, str);

process[num_of_tasks].v86 = 1;

process[num_of_tasks].eflags = 0x20202L;

process[num_of_tasks].id = num_of_tasks;

process[num_of_tasks].priv = 7;

process[num_of_tasks].status = 2;

process[num_of_tasks].task_sel = 0x28;

process[num_of_tasks].kstack = (dword)&pl0_stack[num_of_tasks][stack_size];

stacksetup = cs+0xffff;

*stacksetup-- = cs; /* V86 GS */

*stacksetup-- = cs; /* V86 FS */

*stacksetup-- = cs; /* V86 DS */

*stacksetup-- = cs; /* V86 ES */
*stacksetup-- = cs; /* V86 SS */

*stacksetup-- = cs+0xffff; /* V86 ESP */

*stacksetup-- = 0x20202L | 0x4000;

*stacksetup-- = cs;

*stacksetup-- = entry;

*stacksetup-- = 0; /* EAX */

*stacksetup-- = 0; /* ECX */

*stacksetup-- = 0; /* EDX */

*stacksetup-- = 0; /* EBX */

*stacksetup-- = 0; /* EBP */

*stacksetup-- = 0; /* ESI */

*stacksetup-- = 0; /* EDI */

*stacksetup-- = cs; /* GS */

*stacksetup-- = cs; /* FS */

*stacksetup-- = cs; /* DS */

*stacksetup-- = cs; /* ES */
process[num_of_tasks].ustack = (dword)stacksetup;

multitasking = 1;

tr_atual = 0x28;

return(num_of_tasks);

}


this is my irq.inc

_irq00:

pusha
push gs

push fs

push ds

push es

mov al, 0x20
out 0x20, al


mov [_OldTaskESP], esp



call _timer_handler



mov esp, [_NewTaskESP]



; mov eax, [_Task_CR3]

; mov cr3, eax



mov eax, cr0

or eax, 0x8 ; Set TS flag to use x87.fxsave with

mov cr0, eax ; device not available



pop es

pop ds

pop fs

pop gs

popa
iret

could you help me ?

I can't get v86 working
User avatar
intel_breaker
Member
Member
Posts: 46
Joined: Tue Jan 04, 2005 12:00 am
Location: Poland
Contact:

Re: v86 monitor

Post by intel_breaker »

Ok, could you tell me what are effects of using this function and say with what parametrs do you call it?
digo_rp
Member
Member
Posts: 233
Joined: Sun Jun 05, 2005 11:00 pm

Re: v86 monitor

Post by digo_rp »

add_v86task(char *str, word cs, word entry)
an example:

first I load a program from floppy into memory

v86load("test.com", 0x10000);

0x10000 is the memory below the first MB
then I call
add_v86task("teste", 0x1000, 0);
0x1000 is code segment and 0 is the eip value
digo_rp
Member
Member
Posts: 233
Joined: Sun Jun 05, 2005 11:00 pm

Re: v86 monitor

Post by digo_rp »

with this function I got unhandled opcode 0
digo_rp
Member
Member
Posts: 233
Joined: Sun Jun 05, 2005 11:00 pm

Re: v86 monitor

Post by digo_rp »

how is your irq00 handler, that you use to switch tasks

please help me,
blackcatcoder
Member
Member
Posts: 132
Joined: Wed Nov 03, 2004 12:00 am
Location: Austria
Contact:

Re: v86 monitor

Post by blackcatcoder »

what happens ??

do you get an exception ??

do you have set up an gdt selector for the tss entry ?
User avatar
intel_breaker
Member
Member
Posts: 46
Joined: Tue Jan 04, 2005 12:00 am
Location: Poland
Contact:

Re: v86 monitor

Post by intel_breaker »

I use this code to swtich to next context, where "dp" is a process to which i want to switch, and dp->arch_frame is a stack pointer where we actually have intr_frame.

asm("movl %0, %%eax\n"
"movl %%eax, %%cr3\n"
"movl %1, %%esp\n"
"popl %%ds\n"
"popl %%es\n"
"popl %%fs\n"
"popl %%gs\n"
"popal\n"
"addl $8, %%esp\n"
"iretl" :: "r" (dp->done_cr3), "m" (dp->arch_frame));
digo_rp
Member
Member
Posts: 233
Joined: Sun Jun 05, 2005 11:00 pm

Re: v86 monitor

Post by digo_rp »

I have one tss, I setup a gdt entrie, but I don't know how to setup up. I only use 2 fields of it. ss0 and esp to use ring0-to ring3 I only want v86 to use vesa too...
User avatar
intel_breaker
Member
Member
Posts: 46
Joined: Tue Jan 04, 2005 12:00 am
Location: Poland
Contact:

Re: v86 monitor

Post by intel_breaker »

In my case the problem is solved. V86 works fine on real PC too(it was a problem with coprocesor:P while i was scheduling v86 task;)
I use one tss too, and i'm using its esp0 and ss0 fileds too.
Maybe you should dump a memory where is your 16 bits code? It can help you
digo_rp
Member
Member
Posts: 233
Joined: Sun Jun 05, 2005 11:00 pm

Re: v86 monitor

Post by digo_rp »

I'm using a simple program like displaying ASCII at corner of monitor... simple. just some mov's no ints
Post Reply