X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Message-ID: <4408940f$0$488$cc7c7865@news.luth.se> From: Martin Str|mberg Subject: Re: djgpp for kernel dev. Newsgroups: comp.os.msdos.djgpp References: <4404EB6F DOT D050DB39 AT compuserve DOT de> <200603011425 DOT k21EPHCE005449 AT envy DOT delorie DOT com> User-Agent: tin/1.4.6-20020816 ("Aerials") (UNIX) (NetBSD/1.6Q (alpha)) Date: 03 Mar 2006 19:07:59 GMT Lines: 45 NNTP-Posting-Host: speedy.ludd.ltu.se X-Trace: 1141412879 news.luth.se 488 130.240.16.13 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Rod Pemberton 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