Re: [Freedos-kernel] Re: [Freedos-cvs] kernel/kernel intwrap.asm,NONE,1.1.2.1

2005-11-20 Thread Arkady V.Belousov
Hi!

20-Ноя-2005 13:50 [EMAIL PROTECTED] (Kenneth J. Davis) wrote to
freedos-kernel@lists.sourceforge.net:

>>>int13iret:
>>>inc sp  ; clean up stack
>>>inc sp
>>>sti ; ensure int's are renabled
>>>retf 2  ; return to caller leaving flags asis
>>  I don't think that this is right way, because caller may disable
>> interrupts for own purposes, whereas here interrupts enabled.
KJD> I'm not sure what is correct here,

 I suggest, only returned ZF/CF should be copied to existing value on
stack. For example:

int13iret:
pushax
lahf
pushbp
mov bp,sp
and byte [bp+10],not 0C1h ; 10=bp+ax+...+cs:ip
and ah,0C1h ; remain only SF/ZF/CF flags
or  byte [bp+10],ah ; pass to caller SF/ZF/CF from INT13
pop bp
pop ax
add sp,2
iret

KJD> but I suppose it should simply leave
KJD> the flag as the user had it (I think I added this after reading a note
KJD> somewhere in RBIL about a bug in earlier BIOSes that failed to do this).





---
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
___
Freedos-kernel mailing list
Freedos-kernel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-kernel


Re: [Freedos-kernel] Re: [Freedos-cvs] kernel/kernel intwrap.asm,NONE,1.1.2.1

2005-11-20 Thread Kenneth J. Davis

Arkady V.Belousov wrote:


Hi!

20-Ноя-2005 16:57 [EMAIL PROTECTED] (Kenneth Davis) wrote to
[EMAIL PROTECTED]:



--- NEW FILE: intwrap.asm ---
reloc_call_int13_handler:
   cli ; disable other interrupts for now



 INT instruction already disables IFlag.



   stc ; force error unless BIOS clears



 ?! This is issue of caller to set or reset CFlag.



   push dx ; store BIOS drive # for error handling usage
   push ds ; get segment of kernel DATA
   mov  ds, [cs:_DGROUP_]
   pushf   ; simulate int call so returns back here (flags+cs:ip on
stack)
   call far [ds:_UserInt13]



 Bug!!! Here DS register is garbaged, whereas it used by some functions
(for example, INT13/42).


good catch, I rewrote this section several times until I finally tracked 
down my problem was my usual init-time variables don't match run-time 
variables [address wise, though the compiler thinks they do, so the 
UserInt13 initialized wasn't the one used] unless special care is taken. 
 Earlier versions had a different path for ah < 17h versus ah > 17h, 
which I need to re-add (as the error values returned do not make sense 
for most functions ah > 17h, but even if not returned, still within same 
error code group for those less; that or just change it to check on 
int13/16h )






   pop  ds  ; restore ds
   jc   int13err   ; test if error, if not return to caller
int13iret:
   inc sp  ; clean up stack
   inc sp




   sti ; ensure int's are renabled
   retf 2  ; return to caller leaving flags asis



 I don't think that this is right way, because caller may disable
interrupts for own purposes, whereas here interrupts enabled.


I'm not sure what is correct here, but I suppose it should simply leave 
the flag as the user had it (I think I added this after reading a note 
somewhere in RBIL about a bug in earlier BIOSes that failed to do this).






int13wrap:
%IF XCPU < 186
   push ax ; preserve registers, setup stack frame
   push bp
   mov  bp, sp
   mov  ax, 13h; want to push 0x13 onto stack
   xchg ax, [bp+2] ; so restore pushed ax value and put 0x13 on stack
   pop  bp ; clean up stack frame (leaving just 0x13 pushed on stack)



pushbp
pushbp
mov bp,sp
mov word [bp+2],13h
pop bp



I like it, cleaner and removes the easy to overlook restoration of ax


Thanks for reviewing these patches,
Jeremy





---
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_idv28&alloc_id845&op=click
___
Freedos-kernel mailing list
Freedos-kernel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-kernel


[Freedos-kernel] Re: [Freedos-cvs] kernel/kernel intwrap.asm,NONE,1.1.2.1

2005-11-20 Thread Arkady V.Belousov
Hi!

20-Ноя-2005 16:57 [EMAIL PROTECTED] (Kenneth Davis) wrote to
[EMAIL PROTECTED]:

> --- NEW FILE: intwrap.asm ---
> reloc_call_int13_handler:
> cli ; disable other interrupts for now

 INT instruction already disables IFlag.

> stc ; force error unless BIOS clears

 ?! This is issue of caller to set or reset CFlag.

> push dx ; store BIOS drive # for error handling usage
> push ds ; get segment of kernel DATA
> mov  ds, [cs:_DGROUP_]
> pushf   ; simulate int call so returns back here (flags+cs:ip on
> stack)
> call far [ds:_UserInt13]

 Bug!!! Here DS register is garbaged, whereas it used by some functions
(for example, INT13/42).

> pop  ds  ; restore ds
> jc   int13err   ; test if error, if not return to caller
> int13iret:
> inc sp  ; clean up stack
> inc sp

> sti ; ensure int's are renabled
> retf 2  ; return to caller leaving flags asis

 I don't think that this is right way, because caller may disable
interrupts for own purposes, whereas here interrupts enabled.

> int13wrap:
> %IF XCPU < 186
> push ax ; preserve registers, setup stack frame
> push bp
> mov  bp, sp
> mov  ax, 13h; want to push 0x13 onto stack
> xchg ax, [bp+2] ; so restore pushed ax value and put 0x13 on stack
> pop  bp ; clean up stack frame (leaving just 0x13 pushed on stack)

pushbp
pushbp
mov bp,sp
mov word [bp+2],13h
pop bp





---
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
___
Freedos-kernel mailing list
Freedos-kernel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-kernel