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 ) 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
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