login
Header Space

 
 

Re: VM86

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
Subject: Re: VM86
Date: Saturday, August 29, 1992 - 5:12 am

In article <1992Aug29.065940.1256@athena.mit.edu> hammond@kwhpc.caseng.com (Kevin W. Hammond) writes:

Yes, 0.97.pl2 has support for a vm86 mode: note that this is /not/ the
same as a DOS emulator, but it can be used for that.  The interface
looks like this:

        void vm86(struct vm86_struct * info);

where vm86_struct is defined in linux/vm86.h, and currently looks like
this:

        struct vm86_struct {
                struct vm86_regs regs;
                unsigned long flag;
        }

The flag value is not currently used, and I assume some additional
fields will be added eventually (a page dirty map for efficient screen
updating etc), but the above is enough for a simple DOS emulator.

The vm86() system call is pretty simple: it loads the registers with the
values in the 'regs' structure, and starts executing in vm86 mode.  It
will return to protected mode when a signal happens: when this happens
the vm86 state is saved in the info structure and the signal handler is
executed in normal 32-bit mode.  The signal handlers can then use the
vm86_struct information to see what is going on, and correcting any
errors etc. 

A simple DOS emulator would look like this (pseudo-code):

global struct vm86_struct info;

main()
{
        set up the DOS memory image at 0 - 1MB
        set up SIGSEGV and SIGILL etc signal handlers
        set up the initial regs etc in 'info'
        while (1)
                vm86(&info);
}

SIGILL_handler()
{
        read 'info' to see why we got a SIGILL - if we can
        emulate it, update 'info' and return, else exit
}

SIGSEGV_handler()
{
        see SIGILL
}

SIGALRM_handler()
{
        check the screen memory in the vm86 box, and update the real
        screen every now and then. Do any other regular house-keeping
        fn's.
}

Note that all this happens in user mode - the kernel doesn't really do
anything special about vm86 mode. And as the emulator and vm86 code is
in the same process, is should be possible to make it all relatively
efficient.

                Linus
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: VM86, Linus Benedict Torvalds, (Sat Aug 29, 5:12 am)
speck-geostationary