summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Memory.S89
1 files changed, 55 insertions, 34 deletions
diff --git a/Memory.S b/Memory.S
index ae6b75c..b7fe41b 100644
--- a/Memory.S
+++ b/Memory.S
@@ -13,7 +13,7 @@
** 27-Nov-89 CHW Fast-Memory added **
** 30-Jul-90 CHW Chip allocation for AllocFastMem() works now **
** 18-Sep-90 CHW Chip allocation for AllocFastMem() really works **
-** 20-Nov-90 CHH NoMemHandler eingebaut ** **
+** 20-Nov-90 CHH NoMemHandler eingebaut **
** **
**************************************************************************
@@ -64,19 +64,23 @@ DoInitMem: move.l a0,mh_Lower(a1)
*** D0: Amount, gibt D0: Adresse oder ruft AllocChipMem() auf
AllocFastMemFunc:
- movem.l d1-d2/a0-a3,-(SP)
+ IFD DEBUG
+ bsr CheckMemFunc
+ ENDC
+ movem.l d1-d3/a0-a3,-(SP)
move.l d0,d1 ; Amount retten
tst.l meb_FastMRHeader+mh_Free(a6) ; Fast RAM vorhanden ?
beq.s ChipEntry ; nein --->
lea meb_FastMRHeader(a6),a0 ; The MemoryRegionHeader
+ SMSG <"AllocFastMem(%ld), free=%ld">,d1,mh_Free(a0)
bsr DoAlloc ; Speicher holen
bne.s 1$ ; OK --->
move.l d1,d0 ; Amount
bra.s ChipEntry ; ---> CHIP RAM holen
1$:
- movem.l (SP)+,d1-d2/a0-a3
+ movem.l (SP)+,d1-d3/a0-a3
rts
***************************************************************************
@@ -85,35 +89,38 @@ AllocFastMemFunc:
*** Wenn nicht genuegen Speicher vorhanden ist, wird ein evt.
*** vorhandener Handler angesprungen
-AllocMemFunc: movem.l d1-d2/a0-a3,-(SP)
+AllocMemFunc:
+ IFD DEBUG
+ bsr CheckMemFunc
+ ENDC
+ movem.l d1-d3/a0-a3,-(SP)
move.l d0,d1 ; Amount retten
-ChipEntry: move.l d0,ActAmount
+ChipEntry: move.l d0,d3
lea meb_ChipMRHeader(a6),a0 ; The MemoryRegionHeader
- bsr DoAlloc ; --->
- movem.l (SP)+,d1-d2/a0-a3
+ SMSG <"AllocChipMem(%ld), free=%ld">,d1,mh_Free(a0)
+ bsr DoAlloc
+ movem.l (SP)+,d1-d3/a0-a3
;; tst.l d0
beq.s .NotEnough ; nicht genug --->
rts
.NotEnough: movem.l d1-d7/a0-a6,-(SP)
- move.l ActAmount,d1
+ move.l d3,d1 ; Amount
bsr MyNoMemHandler
tst.w d0
beq .MemAlert
movem.l (SP)+,d1-d7/a0-a6
- move.l ActAmount,d0
+ move.l d3,d0
bra AllocMemFunc
.MemAlert: movem.l (SP)+,d1-d7/a0-a6
- move.l d1,d0 ; Amount für MSG
- lea meb_ChipMRHeader(a6),a0 ; MemoryRegionHeader für MSG
- move.l meb_ChipMRHeader+mh_Free(a6),d7 ; Free für MSG
- movea.l (SP)+,a5 ; PC für MSG
- lea AvailMemFunc,a1
- MSG <'AllocMem: No mem, D0=amount, D7=free, A0=MRH, A1=AvailFunc A5=PC'>
+ lea meb_ChipMRHeader(a6),a0 ; MemoryRegionHeader für SMSG
+ movea.l (SP)+,a1 ; PC für SMSG
+ SMSG <"AllocMem: Can't allocate %ld bytes, free=%ld, MRH=$%08lx, PC=$%08lx">,d1,mh_Free(a0),a0,a1
jmp meb_ColdReboot(a6)
+
***************************************************************************
*** D0: Amount, A0: MRH gibt D0: Adresse oder 0, rettet keine Regs!
@@ -124,8 +131,6 @@ DoAlloc: tst.l d0 ; 0 Bytes reservieren ?
addq.l #7,d0
andi.b #$f8,d0 ; Bytezahl modulo 8 aufrunden
jsr meb_Disable(a6)
- ;; cmp.l mh_Free(a0),d0 ; Amount > freier Speicher ?
- ;; bhi .NotEnoughMemory ; ja ---> Guru
lea mh_First(a0),a2 ; Zeiger auf 1. freien Chunk
.AllocLoop: move.l (a2),d2 ; Link zum nächsten Chunk
@@ -151,7 +156,7 @@ DoAlloc: tst.l d0 ; 0 Bytes reservieren ?
move.l d0,(a1)+ ; Grösse für FreeMem eintragen
move.l a1,d0 ; Allozierter Bereich
.AllocEnd:
- jsr meb_Enable(a6) ; versabbert CCR!
+ jsr meb_Enable(a6) ; versabbert CCR!
tst.l d0
rts
@@ -159,11 +164,16 @@ DoAlloc: tst.l d0 ; 0 Bytes reservieren ?
moveq.l #0,d0
bra.s .AllocEnd
-.AllocError: movem.l (SP)+,d1-d2/a0-a3
- movea.l (SP)+,a5
- MSG <'AllocMem: Got request for 0 bytes, A0=MRH, A5=PC'>
+.AllocError:
+ IFD DEBUG
+ addq.w #4,SP ; back to Alloc(Fast)?MemFunc
+ movem.l (SP)+,d1-d2/a0-a3 ; discard saved regs
+ movea.l (SP)+,a5 ; PC of caller
+ SMSG <"AllocMem: Got request for 0 bytes, PC=$%08lx">,a5
+ ENDC
jmp meb_ColdReboot(a6)
+
**************************************************************************
*** FAST-Speicher reservieren und löschen
@@ -259,7 +269,7 @@ FreeMemFunc: movem.l d0-d2/a0-a2,-(SP)
.FreeError: movem.l (SP)+,d0-d2/a0-a2
movea.l (SP)+,a5
- MSG <'FreeMem: MemList corrupt, A0=MRH, A5=PC'>
+ SMSG <"FreeMem: MemList corrupt, MRH=$%08lx, PC=$%08lx">,a0,a5
jmp meb_ColdReboot(a6)
***************************************************************************
@@ -267,13 +277,13 @@ FreeMemFunc: movem.l d0-d2/a0-a2,-(SP)
CheckMemFunc: movem.l d0-d1/a0-a1,-(SP)
jsr meb_Disable(a6)
- lea meb_ChipMRHeader(a6),a0 ; The MemoryRegionHeader
- bsr.s CheckMemList
+ lea meb_ChipMRHeader(a6),a0
+ bsr.s CheckMemList ; CHIP RAM testen
tst.l meb_FastMRHeader+mh_First(a6) ; FAST RAM vorhanden ?
beq.s 1$
lea meb_FastMRHeader(a6),a0
- bsr.s CheckMemList
+ bsr.s CheckMemList ; FAST RAM testen
1$:
jsr meb_Enable(a6)
movem.l (SP)+,d0-d1/a0-a1
@@ -281,25 +291,37 @@ CheckMemFunc: movem.l d0-d1/a0-a1,-(SP)
*** Speicherliste (A0) testen, Message falls korrupt
-CheckMemList: moveq.l #0,d1 ; Free-Count löschen
- lea mh_First(a0),a1 ; Zeiger auf 1. freien Chunk
-
-.CheckLoop: move.l mc_Next(a1),d0 ; Link zum nächsten Chunk
+CheckMemList:
+ IFD VERBOSE
+ SMSG <"CheckMemList: mh_Lower=$%08lx, mh_Upper=$%08lx, mh_Free=%ld">,mh_Lower(a0),mh_Upper(a0),mh_Free(a0)
+ ENDC
+ moveq.l #0,d1 ; Free-Count löschen
+ movea.l mh_First(a0),a1 ; 1. freier Chunk
+
+.CheckLoop:
+ IFD VERBOSE
+ SMSG <" Chunk $%08lx: %ld bytes, mc_Next=$%08lx">,a1,mc_Bytes(a1),mc_Next(a1)
+ ENDC
+ add.l mc_Bytes(a1),d1 ; FreeCount += bytes
+ move.l mc_Next(a1),d0 ; Link zum nächsten Chunk
beq.s 1$ ; Ende der Liste --->
cmp.l a1,d0 ; Next < actual ?
bls.s .CheckError ; ja ---> Error
movea.l d0,a1
- add.l mc_Bytes(a1),d1 ; FreeCount += bytes
bra.s .CheckLoop
1$:
cmp.l mh_Free(a0),d1 ; FreeCount richtig ?
bne.s .CheckError
+ IFD VERBOSE
+ SMSG <" Memory List OK!">
+ ENDC
rts
-.CheckError: move.l mh_Free(a0),d0 ; Soll-Wert
- MSG <'CheckMem: List corrupt, D0=soll, D1=ist, A0=MRH, A1=Chunk'>
+.CheckError:
+ SMSG <"CheckMem: List corrupt, soll=%ld, ist=%ld, MRH=$%08lx">,mh_Free(a0),d1,a0
jmp meb_ColdReboot(a6)
+
**************************************************************************
*** Speicher schnell kopieren, WORD-aligned, Länge % 4 = 0
@@ -370,6 +392,7 @@ l27a:
*** Speicher löschen, A0 : Adresse, D0 : Länge in Bytes ( <=1MB! )
ClearMemFunc: movem.l d0-d2/a0,-(SP)
+ SMSG <"ClearMem: %ld bytes at $%08lx">,d0,a0
moveq.l #0,d2 ; Lösch-Register
move.l a0,d1
btst #0,d1 ; Adresse gerade ?
@@ -411,6 +434,4 @@ AvailFastMemFunc:
rts
-ActAmount: ds.l 1
-
END