home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / linux / 9332 < prev    next >
Encoding:
Text File  |  1992-08-29  |  2.4 KB  |  79 lines

  1. Path: sparky!uunet!mcsun!news.funet.fi!hydra!klaava!torvalds
  2. From: torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds)
  3. Newsgroups: comp.os.linux
  4. Subject: Re: VM86
  5. Message-ID: <1992Aug29.091200.16019@klaava.Helsinki.FI>
  6. Date: 29 Aug 92 09:12:00 GMT
  7. References: <1992Aug29.065940.1256@athena.mit.edu>
  8. Organization: University of Helsinki
  9. Lines: 68
  10.  
  11. In article <1992Aug29.065940.1256@athena.mit.edu> hammond@kwhpc.caseng.com (Kevin W. Hammond) writes:
  12. >I see with patch 2 there is a vm86.h file and I recall seeing some mention
  13. >of Linux supporting a virtual 8086 mode.  Is this true and, if so, how does
  14. >one use the virtual 8086 driver?
  15.  
  16. Yes, 0.97.pl2 has support for a vm86 mode: note that this is /not/ the
  17. same as a DOS emulator, but it can be used for that.  The interface
  18. looks like this:
  19.  
  20.     void vm86(struct vm86_struct * info);
  21.  
  22. where vm86_struct is defined in linux/vm86.h, and currently looks like
  23. this:
  24.  
  25.     struct vm86_struct {
  26.         struct vm86_regs regs;
  27.         unsigned long flag;
  28.     }
  29.  
  30. The flag value is not currently used, and I assume some additional
  31. fields will be added eventually (a page dirty map for efficient screen
  32. updating etc), but the above is enough for a simple DOS emulator.
  33.  
  34. The vm86() system call is pretty simple: it loads the registers with the
  35. values in the 'regs' structure, and starts executing in vm86 mode.  It
  36. will return to protected mode when a signal happens: when this happens
  37. the vm86 state is saved in the info structure and the signal handler is
  38. executed in normal 32-bit mode.  The signal handlers can then use the
  39. vm86_struct information to see what is going on, and correcting any
  40. errors etc. 
  41.  
  42. A simple DOS emulator would look like this (pseudo-code):
  43.  
  44. global struct vm86_struct info;
  45.  
  46. main()
  47. {
  48.     set up the DOS memory image at 0 - 1MB
  49.     set up SIGSEGV and SIGILL etc signal handlers
  50.     set up the initial regs etc in 'info'
  51.     while (1)
  52.         vm86(&info);
  53. }
  54.  
  55. SIGILL_handler()
  56. {
  57.     read 'info' to see why we got a SIGILL - if we can
  58.     emulate it, update 'info' and return, else exit
  59. }
  60.  
  61. SIGSEGV_handler()
  62. {
  63.     see SIGILL
  64. }
  65.  
  66. SIGALRM_handler()
  67. {
  68.     check the screen memory in the vm86 box, and update the real
  69.     screen every now and then. Do any other regular house-keeping
  70.     fn's.
  71. }
  72.  
  73. Note that all this happens in user mode - the kernel doesn't really do
  74. anything special about vm86 mode. And as the emulator and vm86 code is
  75. in the same process, is should be possible to make it all relatively
  76. efficient.
  77.  
  78.         Linus
  79.