On Sat, 24 Jul 2004, Eduardo Casino wrote:

> El sáb, 24-07-2004 a las 13:50, Bart Oldeman escribió:
> 
> > It's a difficult question. Essentially there are two ways we can go:
> > 1. if the kernel very carefully minimizes stack usage on the code path 
> >    taken and NLSFUNC itself only uses a couple bytes of stack in between 
> >    it's possible to just do it.
> > or
> > 2. nlsfunc would have to copy anything in between ss:sp and ss:920
> >    (_disk_api_tos, that's the top of the stack used here in any DOS >= 
> >     4.0) to a temp area (max 384 bytes), set sp to 920, and with that call 
> >     DOS. Then after the call adjust the stack pointer, then swap it back,
> >     then return.
> 
> Just curious, what about a 3rd possibility: implement the 2f12xx calls
> as documented in RBIL? For example, 2f1228: "sets user stack frame
> pointer to dummy buffer, moves BP to AX, performs LSEEK, and restores
> frame pointer". (This is the "what", my problem is "how" :)

The user stack frame pointer is poined to by a global variable "user_r" 
in the FreeDOS kernel. It points to the user stack which is yet another 
stack. It sits in the SDA at
264h    DWORD   pointer to stack frame containing user registers on INT 21

What normally happens is that:
1. user calls int21/ah=42
2. registers are pushed on the stack (entry.asm)
3. ss:sp stored in user_r
4. ss:sp moves to DOS stack
5. DOS does the lseek using the values pushed in 2.
6. DOS updates the registers on the user stack

Essentially the RBIL comments says that, in MSDOS, 2f1228 changes user_r 
to point to a dummy place, moves the value of BP to the "AX"-slot in the 
dummy user_r stack, calls steps 4-6, restores user_r, and returns.

In FreeDOS that would mean something like this:

  case 0x28:
    old_user_r = user_r;
    user_r = &tempplace;
    user_r->AX = r.BP;
    int21_service(user_r);
    user_r = old_user_r;
    break;

This has nothing to do with switching kernel stacks, in fact if FreeDOS 
would do things this way (instead of calling DosSeek directly) it would 
use even more stack space.

This all goes to say that RBIL is a strange place, sometimes it doesn't 
report much at all (about error codes for instance), and sometimes it 
reports about such obscure implementation details.

Bart



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idG21&alloc_id040&op=click
_______________________________________________
Freedos-kernel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel

Reply via email to