Embedded C interview questions - How to switch from real to protected mode?

Embedded C interview questions

How to switch from real to protected mode?

Every DOS Protected Mode Interface (DPMI) task runs on four different stacks: An application ring protected mode stack, a locked protected mode stack, a real mode stack, and a DPMI host ring 0 stack. The protected mode stack is the one the DPMI client was running on when it switched into protected mode by calling the protected mode entry point (although the client can switch to another protected mode stack if desired). The locked protected mode stack is provided by the DPMI server and is used for simulating hardware interrupts and processing real mode callbacks. The DPMI host provides the real mode stack, which is usually located in the data area provided by the client. The ring 0 stack is only accessible by the DPMI host. However, this stack may contain state information about the currently running program

There are three different ways a client can force a mode switch between protected and real mode:

  • Execute the default interrupt reflection handler 
  • Use the translation services to call real mode code 
  • Use a real mode callback to switch from real to protected mode 
  • Use the raw mode switch functions 
All mode switches except for the raw mode switches will save some information on the DOS Protected Mode Interface (DPMI) host's ring 0 stack. This means that programs should not terminate while in nested mode switches unless they are using the raw mode switching services. However, even programs that use raw mode switches should not attempt to terminate from a hardware interrupt or exception handler since the DPMI host performs automatic mode and stack switching to provide these services.

No comments:

Post a comment