I just registered to the forum, and I'd first like to introduce myself:
My name is Matti B?ckman and I am 21 year old university student from Finland. I have been doing hobby os development for quite some time, so I finally feel I might have something to contribute:
I'm currently writing an user mode vm86mm for my OS because I don't want to include the monitor into a microkernel.
Since the kernel support required is pretty minimal, I thought maybe someone else would be intrested in using my program.
It is not yet suitable for releasing, but soon.. soon..
Anyway using the monitor is simple:
monitor_main.cc
Code: Select all
extern int start_16bit;
extern int end_16bit;
int main()
{
vm86regs regs;
memset(®s, 0, sizeof(regs));
vm86create(64); // 64k mem for virtual machine
// the memory is now mapped at 0 - 64k,
// real mode vectors are copied into place
// in real code we will load the binary from a file
char *p = (char*)(regs.cs<<4)+regs.eip;
int length = (unsigned int)&end_16bit;
length -= (unsigned int)&start_16bit;
memcpy(p, &start_16bit, length);
printf("entering vm86\n");
while (1)
{
if(!vm86run(®s))
break; // returns 0 if cannot continue
// the regs struct now contains updated values
// analyse the reason for stopping and emulate
// the correct instructions here
if (p[(regs.cs<<4)+regs.eip] == ASM_INT3)
break; // the breakpoint asm instruction is just one byte
// and it should not exist in any real program,
// so i think it is safe to use as an end marker
// TODO: add analysis here
}
printf("vm86 finished\n");
vm86destroy(); // unmap vm86 memory, release internal
// kernel structure (backup for pmode regs)
return 0;
}
blah.asm
Code: Select all
[bits 16]
[section .text]
[global start_16bit]
[global end_16bit]
start_16bit:
mov ax, cs
inc ax
mov ss, ax
mov ax, 0xffe
mov sp, ax
int3 ; terminate
end_16bit:
Please tell me what you think of this.
I'll write more when I manage to find some free time.