Page 1 of 1

int 0x15 ah=0x87 make my PC do strange things

Posted: Fri Feb 06, 2009 6:34 am
by RedEagle
Hi
I want to copy the whole floppy disc to RAM in Realmode (like MenuetOS does it). Some years ago I wrote such a programm. Now, after an rewrite of my kernel, I want to use this tool again. Because of some speedproblems (It took ~10 minutes on one of my PCs to load the fd :D) I modified it a bit.
If I run it with bochs everything works fine. On my test-PC the programm loades the floppy to RAM without problems. But After switching to PM I detected a Problem: If I write data to 0x00500000 and above, I overwrite the data at 0x0040000. Evereything I write to 0x00400000++ gets copied(?) to 0x00500000.

a testcode:

Code: Select all

DWORD *ptr1 = (DWORD*)0x00400000;
DWORD *ptr2 = (DWORD*)0x00500000;
*ptr1 = 0xDEADBEEF;
//POINT 1
*ptr2 = 0x10007357;
//POINT 2
At point 1, I find 0xdeadbeef at 0x00(4/5)00000, than, at point 2, I find 10007357 (Just on the real PC)

The copy-tool copies the read sectors from 0x00A000 to 0x100000

my move-descriptor

Code: Select all

  var_movedesc:
  db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; used by BIOS
  db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; used by BIOS
;  db 0x02,0x00                               ; source segment length
;                                             ; (2*cx-1 or greater)
  db 0xFF,0xFF         ; MeOS
  db 0x00,0xA0,0x00    ; 00A000 24-bit linear source address 
  db 0x93,             ; source segment access rights (93h)
  db 0x00,0x00         ;
;  db 0x02,0x00         ; destination segment length
;                       ; (2*cx-1 or greater)
  db 0xFF,0xFF         ; MeOS
  db 0x00,0x00,0x10    ; 100000 24-bit linear destination address
  db 0x93              ; destination segment access rights (93h)
  db 0x00,0x00         ;
  db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; used by BIOS
  db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; used by BIOS

  db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; MeOS
  db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; MeOS

Code: Select all

memcpy:
    push bx
    push cx
    push dx
    push es
    
    mov  cx, 0x1200         ; angabe in WORDs => 0x200 Byte * 18 => 18 Sektor
    mov  si, var_movedesc ; Offsetadresse
     mov  ax, 0x1000        ; Segmentadresse
     mov  es, ax
    xor  al, al
    mov  ah, 0x87           ; Copy Extended memory             ; thx to all MenuetOS Developer,
    int  0x15               ; move
    or   ah, ah             ; ah == 0?
    jz  mc_finish
   
    ; Fehler beim Kopieren
    push si
    mov si, log_error2
    call [BAPI_LOG]
    pop si
    
    jmp mc_efinish

    mc_efinish:
      mov ah, 1 ; Fehler melden
    
    mc_finish:
    
    pop es
    pop dx
    pop cx
    pop bx
ret
What have I done wrong?

Re: int 0x15 ah=0x87 make my PC do strange things

Posted: Fri Feb 06, 2009 7:00 am
by Brendan
RedEagle wrote:Evereything I write to 0x00400000++ gets copied(?) to 0x00500000.
In that case I'd assume that the BIOS doesn't enable A20.
RedEagle wrote:What have I done wrong?
I'd be tempted not to use the BIOS functions - they're usually painfully slow, and at times it's difficult to know exactly what they do.... ;)


Cheers,

Brendan

Re: int 0x15 ah=0x87 make my PC do strange things

Posted: Fri Feb 06, 2009 7:39 am
by RedEagle
omg, you'r right :shock:
I enable the A20gate befor I call the copy-tool but the BIOS disabled it after the int 0x15-call #-o

Thank you, for your help