Fix sceKernelAvailableDirectMemorySize

also corrected names
This commit is contained in:
Pavel 2023-02-14 19:04:26 +03:00
parent 40b55bbf81
commit a1fc249baf
2 changed files with 37 additions and 18 deletions

View File

@ -93,10 +93,10 @@ type
Function Alloc(Size,Align:QWORD;mtype:Byte;var AdrOut:QWORD):Integer;
Function Query(Offset:QWORD;next:Boolean;var ROut:TDirectAdrNode):Integer;
Function QueryMType(Offset:QWORD;var ROut:TDirectAdrNode):Integer;
Function CheckedAvailable(ss,se,Align:QWORD;var AdrOut,SizeOut:QWORD):Integer;
Function CheckedAlloc(Offset,Size:QWORD):Integer;
Function CheckedMMap(Offset,Size:QWORD):Integer;
Function CheckedRelease(Offset,Size:QWORD):Integer;
Function QueryAvailable(ss,se,Align:QWORD;var AdrOut,SizeOut:QWORD):Integer;
Function CheckAlloc(Offset,Size:QWORD):Integer;
Function CheckMMap(Offset,Size:QWORD):Integer;
Function CheckRelease(Offset,Size:QWORD):Integer;
Function Release(Offset,Size:QWORD):Integer;
Function mmap_addr(Offset,Size:QWORD;addr:Pointer;mtype:Integer=-1):Integer;
Function mmap_type(Offset,Size:QWORD;mtype:Integer):Integer;
@ -525,17 +525,26 @@ begin
ROut:=key;
end;
Function TDirectManager.CheckedAvailable(ss,se,Align:QWORD;var AdrOut,SizeOut:QWORD):Integer;
Function TDirectManager.QueryAvailable(ss,se,Align:QWORD;var AdrOut,SizeOut:QWORD):Integer;
var
It:TFreePoolNodeSet.Iterator;
key:TDirectAdrNode;
Offset:QWORD;
Size:QWORD;
Size :QWORD;
r:record
Offset:QWORD;
Size :QWORD;
end;
begin
Result:=ENOMEM;
if (ss<Flo) or (ss>Fhi) then Exit(EINVAL);
if (se<Flo) or (se<ss) then Exit(EINVAL);
r.Size :=0;
r.Offset:=0;
key:=Default(TDirectAdrNode);
key.Offset:=ss;
@ -547,21 +556,31 @@ begin
if key.IsFree then
begin
Offset:=System.Align(Max(key.Offset,ss),Align);
if (se>=Offset) then
begin
Size:=key.Size-(Offset-key.Offset);
AdrOut :=Offset;
SizeOut:=Size;
Exit(0);
if (Size>r.Size) then
begin
r.Size :=Size;
r.Offset:=Offset;
end;
Result:=0; //mark
end;
end;
It.Next
It.Next;
end;
if (Result=0) then //found
begin
AdrOut :=r.Offset;
SizeOut:=r.Size;
end;
end;
Function TDirectManager.CheckedAlloc(Offset,Size:QWORD):Integer;
Function TDirectManager.CheckAlloc(Offset,Size:QWORD):Integer;
var
It:TAllcPoolNodeSet.Iterator;
key:TDirectAdrNode;
@ -595,7 +614,7 @@ begin
end;
end;
Function TDirectManager.CheckedMMap(Offset,Size:QWORD):Integer;
Function TDirectManager.CheckMMap(Offset,Size:QWORD):Integer;
var
It:TAllcPoolNodeSet.Iterator;
key:TDirectAdrNode;
@ -633,7 +652,7 @@ begin
end;
end;
Function TDirectManager.CheckedRelease(Offset,Size:QWORD):Integer;
Function TDirectManager.CheckRelease(Offset,Size:QWORD):Integer;
var
It:TAllcPoolNodeSet.Iterator;
key:TDirectAdrNode;

View File

@ -580,7 +580,7 @@ begin
_sig_lock;
MLOCK;
Result:=DirectManager.CheckedAvailable(searchStart,searchEnd,alignment,FAdrOut,FSizeOut);
Result:=DirectManager.QueryAvailable(searchStart,searchEnd,alignment,FAdrOut,FSizeOut);
MUNLOCK;
_sig_unlock;
@ -676,7 +676,7 @@ begin
_sig_lock;
MLOCK;
Result:=DirectManager.CheckedRelease(start,len);
Result:=DirectManager.CheckRelease(start,len);
if (Result=0) then
begin
Result:=DirectManager.Release(start,len);
@ -874,7 +874,7 @@ begin
begin
if (fd=0) then //direct (psevdo dmem fd=0)
begin
Result:=DirectManager.CheckedMMap(offset,len);
Result:=DirectManager.CheckMMap(offset,len);
if (Result=0) then
begin
@ -932,7 +932,7 @@ begin
_sig_lock;
MLOCK;
Result:=DirectManager.CheckedMMap(physicalAddr,length);
Result:=DirectManager.CheckMMap(physicalAddr,length);
if (Result=0) then
begin