Kernel 0.9.1 : BugFix in Memory manager, memory leaks...

This commit is contained in:
Rémy GIBERT 2017-10-09 07:51:32 +02:00
parent 98c99b0ad2
commit 4cae83f359
8 changed files with 69 additions and 52 deletions

Binary file not shown.

Binary file not shown.

View File

@ -324,8 +324,7 @@ BlkCnt .BS 1
BlkParams.Ptr .BS 2
BlkParams.Num .BS 2
hBuf .BS 1
DS.END
.ED
DS.END .ED
*--------------------------------------
MAN
SAVE /A2OSX.SRC/BIN/FORMAT.S

View File

@ -24,9 +24,10 @@ CS.START cld
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA CS.END-CS.START Code Length To Relocate
.DA 0 Data Segment to Allocate
.DA 0
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #16 SS
.DA #6 ZP
.DA 0
*--------------------------------------
* Relocation Table
@ -60,7 +61,7 @@ L.DevName .DA DevName
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
>SYSCALL LoadLibYA
>SYSCALL LoadLib.YA
bcs .9
sta hLIBTCPIP
clc
@ -81,7 +82,7 @@ CS.RUN >LDYA L.MSG0
jmp CS.RUN.DONE
CS.RUN.DUMPDEV sta DevID
>SYSCALL GetDevByIDA
>SYSCALL GetDevByID.A
>STYA ZPDevPtr
>STYA NetDevJmp+1
@ -259,13 +260,13 @@ CS.QUIT lda hLIBTCPIP
NetDevJmp jmp *
*--------------------------------------
CS.END
LIBTCPIP >PSTR "libtcpip.o"
LIBTCPIP >CSTR "libtcpip.o"
*--------------------------------------
MSG0 >CSTR "TCP/IP Status : "
MSG0.L >CSTR "Loaded\r\n"
MSG0.NL >CSTR "Not Loaded\r\n"
*--------------------------------------
MSG1.DEV >CSTR "\r\nDevice Configuration :\r\n DevID : $%h\r\n Device Type : %S\r\n Device Name : %S\r\n HW Address : %02h:%02h:%02h:%02h:%02h:%02h\r\n"
MSG1.DEV >CSTR "\r\nDevice Configuration :\r\n DevID : $%h\r\n Device Type : %S\r\n Device Name : %s\r\n HW Address : %02h:%02h:%02h:%02h:%02h:%02h\r\n"
MSG1.DEV.ARP >CSTR " ARP Offload : %d\r\n"
MSG1.DEV.IP >CSTR " IP Offload : %d\r\n"
MSG1.LINK >CSTR " Link Status : %s\r\n"
@ -286,6 +287,12 @@ MSG2.HOSTNAME >CSTR " Hostname : %S.%S\r\n"
hLIBTCPIP .BS 1
DevID .BS 1
DevName .BS 5
*--------------------------------------
.DUMMY
.OR 0
DS.START
DS.END .ED
*--------------------------------------
MAN
SAVE /A2OSX.SRC/BIN/IPCONFIG.S
ASM

View File

@ -246,7 +246,7 @@ CS.RUN.PRINTMEM ldy #S.MEM.LEN+1
bne .1
.11 tya
beq .2 Startig with 0...assume BIN
beq .2 Startig with 0...PrintHEX
>PUSHW ZPPTR2 String
tya Len
@ -266,6 +266,7 @@ CS.RUN.PRINTMEM ldy #S.MEM.LEN+1
.7 >SYSCALL GetMemPtr.A
>PUSHYA
>LDYA L.MSG1.BIN
.8 >SYSCALL PrintF.YA
>INC.G LINE.COUNT
@ -291,7 +292,7 @@ CS.END
MSG0 >CSTR " # Flags PID REF PTR LEN BINPATH/DATA\r\n"
MSG1.INV >CSTR "\e[7m"
MSG1 >CSTR "%03d %s %03d %03d $%H %05D "
MSG1.BIN >CSTR "{BIN:%s}\e[0m\r\n"
MSG1.BIN >CSTR "{%s}\e[0m\r\n"
MSG1.STR >CSTR "[%03d:%s]\e[0m\r\n"
MSG1.HEX >CSTR "?HEX:%h%h.%h%h.%h%h.%h%h.%h%h.%h%h.%h%h.%h%h\e[0m\r\n"
MSG2 >CSTR "\r\nAllocated hMem:%d, Total:%d\r\n"

View File

@ -22,7 +22,7 @@ CFG.Read >PUSHW L.HOSTNAME
>PUSHW L.HOSTS
>LDYA L.MSG.CFG
>SYSCALL PrintF.YA
rts
jsr CFG.Read.HOSTS
*--------------------------------------
CFG.Read.Result bcc .1

View File

@ -34,26 +34,14 @@ MemMgr.ReqFlags .EQ ZPMEMMGR+6 store requested Flags
*\--------------------------------------
K.GetMem >PULLB MemMgr.ReqFlags store requested flags
clc
>PULLA get requested size LO
bit #$0F 16 bytes aligned ?
beq .1 yes, request it
and #$F0 align on 16 bytes
adc #$10
.1 sta MemMgr.ReqSize
tay
>PULLA get requested size HI
adc #0
sta MemMgr.ReqSize+1
bit MemMgr.ReqFlags S.MEM.F.AUX ?
bpl K.GetMem.I
and #S.MEM.F.AUX
beq .1
sta SETREADAUX Aux Mem requested,switch to AUX
sta SETWRITEAUX
@ -62,7 +50,7 @@ K.GetMem >PULLB MemMgr.ReqFlags store requested flags
sta CLRREADAUX
sta CLRWRITEAUX
.9 rts
rts
*/--------------------------------------
* # GetMem0.YA
* ## In:
@ -74,7 +62,7 @@ K.GetMem >PULLB MemMgr.ReqFlags store requested flags
* CS :
* A = EC
*\--------------------------------------
K.GetMem0.YA ldx #S.MEM.F.INIT0
K.GetMem0.YA ldx #S.MEM.F.INIT0
stx MemMgr.ReqFlags
.HS 2C bit abs
*/--------------------------------------
@ -90,19 +78,20 @@ K.GetMem0.YA ldx #S.MEM.F.INIT0
*\--------------------------------------
K.GetMem.YA stz MemMgr.ReqFlags
sta MemMgr.ReqSize+1
tya
K.GetMem.I tya
bit #$0F 16 bytes aligned ?
beq .1 yes, request it
beq .10 yes, request it
and #$F0 align on 16 bytes
clc
adc #$10
bcc .1
bcc .10
inc MemMgr.ReqSize+1
.1 sta MemMgr.ReqSize
.10 sta MemMgr.ReqSize
K.GetMem.I >LDYAI MemMgr.Table
>LDYAI MemMgr.Table
>STYA ZPMemMgrSPtr
ldx #0 Current slot=0
@ -325,24 +314,30 @@ K.FreeMem.A phy
jsr K.GetMemByID.A X unmodified
lda (ZPMemMgrSPtr)
bmi .8
bmi .8 used, exit
.2 dec MemMgr.LastSlot free! get previous....
beq .3 empty list: go set MemMgr.Free=MemMgr.HiMem
ldy #S.MEM.LEN
lda (ZPMemMgrSPtr),y give back LEN bytes
clc
adc MemMgr.Free to MemMgr.Free
lda MemMgr.LastSlot
jsr K.GetMemByID.A X unmodified
lda (ZPMemMgrSPtr)
bpl .2 free again! loop
ldy #S.MEM.PTR
lda (ZPMemMgrSPtr),y set MemMgr.Free...
sta MemMgr.Free
iny
lda (ZPMemMgrSPtr),y
adc MemMgr.Free+1
sta MemMgr.Free+1
dec MemMgr.LastSlot discard last slot
bne .1 no slot left, exit
.8 ply
clc
rts
.3 >LDYA MemMgr.HiMem
>STYA MemMgr.Free
bra .8
*--------------------------------------
.9 ply discard saved Y
@ -454,9 +449,10 @@ K.GetMemByID.A sta ZPMemMgrSPtr
K.NewStr.YA >STYA .1+1
>STYA .4+1
ldy #0
stz MemMgr.ReqFlags
stz MemMgr.ReqSize+1
ldy #0
.1 lda $ffff,y
beq .2
@ -466,13 +462,11 @@ K.NewStr.YA >STYA .1+1
inc .1+2
bne .1
.2 iny
.2 iny Add one for ending 0
bne .3
inc MemMgr.ReqSize+1
.3 sty MemMgr.ReqSize
jsr K.GetMem.I
.3 jsr K.GetMem.I
bcs .9
>STYA .5+1

View File

@ -76,6 +76,9 @@ PS.CreateChild ldx #0
sec
rts
.99 plx
rts
.3 inc CORE.PSCount
.31 phx save PS inex
@ -100,6 +103,10 @@ PS.CreateChild ldx #0
plx
sta PS.Table.hMem,x
lda CORE.LastPSID Set Ownership
ldy #S.MEM.OWNERPID
sta (ZPMEMMGR),y
ldy #S.PS.PID
lda CORE.LastPSID
sta (ZPPtr3),y
@ -108,7 +115,7 @@ PS.CreateChild ldx #0
bit K.CreateProcess.Flags need to create ENV & Prefix ?
beq .6 no...
sta (ZPPtr3) Mark this PS with ENV flag
sta (ZPPtr3) Mark this PS with DUPENV flag
ldy #S.PS.hPREFIX copy hPREFIX...
lda (pPs),y
@ -116,7 +123,7 @@ PS.CreateChild ldx #0
jsr K.NewStr.YA
bcs .9
lda CORE.LastPSID Set this copy ownership
lda CORE.LastPSID Set Ownership
ldy #S.MEM.OWNERPID
sta (ZPMEMMGR),y
@ -171,9 +178,6 @@ PS.CreateChild ldx #0
sta (pPs),y
clc Exit with A=PSID
rts
.99 plx
.9 rts
*--------------------------------------
PS.CmdLine2Args >STYA ZPPtr1
@ -206,6 +210,10 @@ PS.CmdLine2Args >STYA ZPPtr1
ldy #S.PS.hARGS
sta (ZPPtr3),y
lda CORE.LastPSID Set Ownership
ldy #S.MEM.OWNERPID
sta (ZPMEMMGR),y
stz PS.CmdLine2Args.bInQuote
ldy #$ff
@ -299,6 +307,10 @@ PS.Init jsr BIN.Load.YA Y,A=filename full path
ldy #S.PS.hDS
sta (ZPPtr3),y save DS hMem in S.PS
lda CORE.LastPSID Set Ownership
ldy #S.MEM.OWNERPID
sta (ZPMEMMGR),y
.2 ldy #H.BIN.EXE.SS.SIZE
lda (ZPPtr4),y Load SS.SIZE
ldy #S.PS.Context+4
@ -323,6 +335,10 @@ PS.Init jsr BIN.Load.YA Y,A=filename full path
ldy #S.PS.hSS
sta (ZPPtr3),y save SS hMem in S.PS
lda CORE.LastPSID Set Ownership
ldy #S.MEM.OWNERPID
sta (ZPMEMMGR),y
clc
.9 rts
*--------------------------------------