home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!news.funet.fi!hydra!klaava!torvalds
- From: torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds)
- Newsgroups: comp.os.linux
- Subject: Re: VM86
- Message-ID: <1992Aug29.091200.16019@klaava.Helsinki.FI>
- Date: 29 Aug 92 09:12:00 GMT
- References: <1992Aug29.065940.1256@athena.mit.edu>
- Organization: University of Helsinki
- Lines: 68
-
- In article <1992Aug29.065940.1256@athena.mit.edu> hammond@kwhpc.caseng.com (Kevin W. Hammond) writes:
- >I see with patch 2 there is a vm86.h file and I recall seeing some mention
- >of Linux supporting a virtual 8086 mode. Is this true and, if so, how does
- >one use the virtual 8086 driver?
-
- 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
-