Mail Archives: djgpp/2006/03/03/14:15:12
Rod Pemberton <do_not_have AT sorry DOT bitbucket DOT cmm> wrote:
> No. But, there is a way around it. I'm not going to post the code for my
> OS, but I'll explain to you the method for DJGPP to bypass this.
> When you call exit() in your program, int 0x21, ah=4c "DPMI Unload" is
> called in PM. Then the DPMI host cleans up memory and returns to RM. When
> in RM, int 0x21, ah=4c "DOS Exit" is called by DOS to clean up after your
> program exits.
Why, oh why, should he even enter DJGPP PM?
[Lot of unecessary stuff deleted.]
> Then, the RM int 0x21 routine does the following:
> 1) disable interrupts
> 2) creates and sets up a minimal GDT with three selectors
> a) selector for PM application code using the saved base address
> b) selector for PM application data using the saved base address
> c) linear selector for interrupt routine code
> 3) set the CR0 PE bit, and switch to PM, do other Intel/AMD recommended
> stuff
> 4) restore ESP,EBP
> 5) setup DS,ES,FS,GS
> 6) far jump to reentry address (sets CS)
> Now, we've restarted our PM application:
[...]
> 3) Yeah! Our program is running again.
> 4) create better GDT in C
> 5) create IDT in C
> 6) create ISR in C with _asm() wrappers
> 7) setup keyboard & mouse, enable interrupts, etc..
> Now we're running in PM with no DPMI host. At this point everything can be
> done in C except:
> 1) special instructions lgdt,lidt,
> 2) assembly wrappers for interrupt service routines
Yes, so why bother to let DJGPP startup and shutdown stuff run?
Right,
MartinS
- Raw text -