diff --git a/gui/cfg_edit.lfm b/gui/cfg_edit.lfm index 41126f11..f9b24957 100644 --- a/gui/cfg_edit.lfm +++ b/gui/cfg_edit.lfm @@ -1,7 +1,7 @@ object frmCfgEditor: TfrmCfgEditor - Left = 298 + Left = 407 Height = 323 - Top = 125 + Top = 214 Width = 400 Caption = 'Config Editor' ClientHeight = 323 @@ -13,11 +13,11 @@ object frmCfgEditor: TfrmCfgEditor Height = 274 Top = 0 Width = 397 - ActivePage = Tab_MainInfo + ActivePage = Tab_JIT Align = alCustom Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Bottom = 10 - TabIndex = 0 + TabIndex = 2 TabOrder = 0 object Tab_MainInfo: TTabSheet Caption = 'Main' @@ -161,6 +161,78 @@ object frmCfgEditor: TfrmCfgEditor TabOrder = 4 end end + object Tab_JIT: TTabSheet + Caption = 'JIT' + ClientHeight = 246 + ClientWidth = 389 + object Edt_JITInfo_print_asm: TCheckBox + AnchorSideLeft.Control = Tab_JIT + AnchorSideTop.Control = Tab_JIT + AnchorSideRight.Control = Tab_JIT + AnchorSideRight.Side = asrBottom + Left = 10 + Height = 19 + Top = 10 + Width = 369 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 10 + BorderSpacing.Top = 10 + BorderSpacing.Right = 10 + Caption = 'print asm code' + TabOrder = 0 + end + object Edt_JITInfo_debug_info: TCheckBox + AnchorSideLeft.Control = Tab_JIT + AnchorSideTop.Control = Edt_JITInfo_print_asm + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Tab_JIT + AnchorSideRight.Side = asrBottom + Left = 10 + Height = 19 + Top = 39 + Width = 369 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 10 + BorderSpacing.Top = 10 + BorderSpacing.Right = 10 + Caption = 'Inline debug info' + TabOrder = 1 + end + object Edt_JITInfo_relative_analize: TCheckBox + AnchorSideLeft.Control = Tab_JIT + AnchorSideTop.Control = Edt_JITInfo_debug_info + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Tab_JIT + AnchorSideRight.Side = asrBottom + Left = 10 + Height = 19 + Top = 68 + Width = 369 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 10 + BorderSpacing.Top = 10 + BorderSpacing.Right = 10 + Caption = 'Try relative analize' + TabOrder = 2 + end + object Edt_JITInfo_memory_guard: TCheckBox + AnchorSideLeft.Control = Tab_JIT + AnchorSideTop.Control = Edt_JITInfo_relative_analize + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Tab_JIT + AnchorSideRight.Side = asrBottom + Left = 10 + Height = 19 + Top = 97 + Width = 369 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 10 + BorderSpacing.Top = 10 + BorderSpacing.Right = 10 + Caption = 'Guest memory guard' + TabOrder = 3 + end + end end object BtnCancel: TButton AnchorSideLeft.Control = Owner diff --git a/gui/cfg_edit.pas b/gui/cfg_edit.pas index f1bcfb35..29feb359 100644 --- a/gui/cfg_edit.pas +++ b/gui/cfg_edit.pas @@ -18,14 +18,19 @@ type BtnCancel: TButton; BtnOk: TButton; Edt_BootparamInfo_halt_on_exit: TCheckBox; + Edt_JITInfo_debug_info: TCheckBox; + Edt_JITInfo_relative_analize: TCheckBox; + Edt_JITInfo_print_asm: TCheckBox; Edt_BootparamInfo_print_guest_syscall: TCheckBox; Edt_BootparamInfo_print_pmap: TCheckBox; Edt_BootparamInfo_print_jit_preload: TCheckBox; + Edt_JITInfo_memory_guard: TCheckBox; Edt_MainInfo_fork_proc: TCheckBox; Edt_MainInfo_LogFile: TEdit; Edt_BootparamInfo_neo: TCheckBox; EditPages: TPageControl; Label1: TLabel; + Tab_JIT: TTabSheet; Tab_MainInfo: TTabSheet; Tab_BootparamInfo: TTabSheet; procedure BtnCancelClick(Sender: TObject); @@ -37,7 +42,7 @@ type private public - FMainConfigInfo:TMainConfigInfo; + FConfigInfo:TConfigInfo; end; var @@ -206,7 +211,7 @@ var begin EditPages.ActivePageIndex:=0; - i:=FMainConfigInfo.GetPropertyIterator; + i:=FConfigInfo.GetPropertyIterator; try while (i.GetProperty<>nil) do begin @@ -217,7 +222,7 @@ begin tkClass: begin - obj:=p.GetValue(FMainConfigInfo).AsObject; + obj:=p.GetValue(FConfigInfo).AsObject; if (obj<>nil) then if obj.InheritsFrom(TAbstractInfo) then @@ -244,7 +249,7 @@ var p:TRttiProperty; obj:TObject; begin - i:=FMainConfigInfo.GetPropertyIterator; + i:=FConfigInfo.GetPropertyIterator; try while (i.GetProperty<>nil) do begin @@ -255,7 +260,7 @@ begin tkClass: begin - obj:=p.GetValue(FMainConfigInfo).AsObject; + obj:=p.GetValue(FConfigInfo).AsObject; if (obj<>nil) then if obj.InheritsFrom(TAbstractInfo) then diff --git a/gui/game_edit.lfm b/gui/game_edit.lfm index 7442256e..c3613b8a 100644 --- a/gui/game_edit.lfm +++ b/gui/game_edit.lfm @@ -1,7 +1,7 @@ object frmGameEditor: TfrmGameEditor - Left = 778 + Left = 693 Height = 319 - Top = 146 + Top = 166 Width = 397 Caption = 'Game editor' ClientHeight = 319 diff --git a/gui/game_info.pas b/gui/game_info.pas index 5c924115..85b459db 100644 --- a/gui/game_info.pas +++ b/gui/game_info.pas @@ -52,6 +52,21 @@ type property print_jit_preload :Boolean read Fprint_jit_preload write Fprint_jit_preload ; end; + TJITInfo=class(TAbstractInfo) + private + Fprint_asm :Boolean; + Fdebug_info :Boolean; + Frelative_analize:Boolean; + Fmemory_guard :Boolean; + published + property print_asm :Boolean read Fprint_asm write Fprint_asm ; + property debug_info :Boolean read Fdebug_info write Fdebug_info ; + property relative_analize:Boolean read Frelative_analize write Frelative_analize; + property memory_guard :Boolean read Fmemory_guard write Fmemory_guard ; + public + Constructor Create; override; + end; + TMainInfo=class(TAbstractInfo) private FLogFile :RawByteString; @@ -63,13 +78,15 @@ type Constructor Create; override; end; - TMainConfigInfo=class(TAbstractInfo) + TConfigInfo=class(TAbstractInfo) private FMainInfo :TMainInfo; FBootParamInfo:TBootParamInfo; + FJITInfo :TJITInfo; published - property MainInfo :TMainInfo read FMainInfo write FMainInfo; + property MainInfo :TMainInfo read FMainInfo write FMainInfo; property BootParamInfo:TBootParamInfo read FBootParamInfo write FBootParamInfo; + property JITInfo :TJITInfo read FJITInfo write FJITInfo; end; TGameInfo=class(TAbstractInfo) @@ -109,9 +126,22 @@ type FMountList:TMountList; FLock :Boolean; public - Constructor Create; override; + Constructor Create; override; Destructor Destroy; override; - Procedure Serialize(Stream:TStream); override; + Procedure Serialize (Stream:TStream); override; + Procedure Deserialize(Stream:TStream); override; + end; + + TGameStartupInfo=class(TAbstractInfo) + public + FReader :Boolean; + FPipe :THandle; + FConfInfo:TConfigInfo; + FGameItem:TGameItem; + public + Constructor Create(Reader:Boolean); reintroduce; + Destructor Destroy; override; + Procedure Serialize (Stream:TStream); override; Procedure Deserialize(Stream:TStream); override; end; @@ -349,7 +379,6 @@ begin obj.Free; end; - p.SetValue(Self,TObject(nil)); end; i.Next; @@ -455,6 +484,12 @@ begin end; end; +Constructor TJITInfo.Create; +begin + inherited; + Frelative_analize:=True; +end; + Constructor TMainInfo.Create; begin inherited; @@ -483,7 +518,6 @@ begin inherited; FGameInfo :=TGameInfo .Create; FMountList:=TMountList.Create; - inherited; end; Destructor TGameItem.Destroy; @@ -493,6 +527,8 @@ begin inherited; end; +// + Procedure TGameItem.Serialize(Stream:TStream); begin FGameInfo .Serialize(Stream); @@ -505,6 +541,44 @@ begin FMountList.Deserialize(Stream); end; +// + +Constructor TGameStartupInfo.Create(Reader:Boolean); +begin + inherited Create; + FReader:=Reader; + if FReader then + begin + FConfInfo:=TConfigInfo.Create; + FGameItem:=TGameItem.Create; + end; +end; + +Destructor TGameStartupInfo.Destroy; +begin + if FReader then + begin + FreeAndNil(FConfInfo); + FreeAndNil(FGameItem); + end; + inherited; +end; + +Procedure TGameStartupInfo.Serialize(Stream:TStream); +begin + Stream.Write(FPipe,SizeOf(THandle)); + FConfInfo.Serialize(Stream); + FGameItem.Serialize(Stream); +end; + +Procedure TGameStartupInfo.Deserialize(Stream:TStream); +begin + FPipe:=0; + Stream.Read(FPipe,SizeOf(THandle)); + FConfInfo.Deserialize(Stream); + FGameItem.Deserialize(Stream); +end; + end. diff --git a/gui/game_run.pas b/gui/game_run.pas index 26877baa..1c527880 100644 --- a/gui/game_run.pas +++ b/gui/game_run.pas @@ -21,7 +21,8 @@ type hOutput:THandle; hError :THandle; - fork_proc:Boolean; + FConfInfo:TConfigInfo; + FGameItem:TGameItem; end; TGameProcessSimple=class(TGameProcess) @@ -31,7 +32,7 @@ type Destructor Destroy; override; end; -function run_item(const cfg:TGameRunConfig;Item:TGameItem):TGameProcess; +function run_item(const cfg:TGameRunConfig):TGameProcess; implementation @@ -51,6 +52,9 @@ uses md_game_process, + kern_jit, + kern_jit_ctx, + dev_dce, display_soft, @@ -61,6 +65,8 @@ uses ps4_libSceMbus, ps4_libSceDialogs, ps4_libSceAvSetting, + //ps4_libSceDiscMap, + //ps4_libSceNpManager, //internal libs kern_rtld, @@ -109,13 +115,35 @@ begin //debug_tty.t_update :=@WakeMainThread; end; -procedure prepare(Item:TGameItem); SysV_ABI_CDecl; +procedure load_config(ConfInfo:TConfigInfo); +begin + sys_bootparam.set_neo_mode(ConfInfo.BootParamInfo.Neo); + + sys_bootparam.p_halt_on_exit :=ConfInfo.BootParamInfo.halt_on_exit; + sys_bootparam.p_print_guest_syscall:=ConfInfo.BootParamInfo.print_guest_syscall; + sys_bootparam.p_print_pmap :=ConfInfo.BootParamInfo.print_pmap; + sys_bootparam.p_print_jit_preload :=ConfInfo.BootParamInfo.print_jit_preload; + + // + + kern_jit.print_asm :=ConfInfo.JITInfo.print_asm; + kern_jit.debug_info:=ConfInfo.JITInfo.debug_info; + + kern_jit_ctx.jit_relative_analize:=ConfInfo.JITInfo.relative_analize; + kern_jit_ctx.jit_memory_guard :=ConfInfo.JITInfo.memory_guard; + + // + +end; + +procedure prepare(GameStartupInfo:TGameStartupInfo); SysV_ABI_CDecl; var td:p_kthread; err:Integer; len:Integer; exec:array[0..PATH_MAX] of Char; argv:array[0..1] of PChar; + Item:TGameItem; begin //re_init_tty; //init_tty:=@re_init_tty; @@ -123,6 +151,8 @@ begin //init all sys_init; + load_config(GameStartupInfo.FConfInfo); + if (p_host_ipc<>nil) then begin THostIpcConnect(p_host_ipc).thread_new; @@ -134,6 +164,8 @@ begin dev_dce.dce_interface:=display_soft.TDisplayHandleSoft; + Item:=GameStartupInfo.FGameItem; + g_appinfo.mmap_flags:=1; //is_big_app ??? g_appinfo.CUSANAME:=Item.FGameInfo.TitleId; //g_appinfo.hasParamSfo @@ -190,10 +222,14 @@ begin td:=curkthread; td^.td_pflags:=td^.td_pflags and (not TDP_KTHREAD); + // + FreeAndNil(GameStartupInfo); + // + err:=main_execve(argv[0],@argv[0],nil); if (err<>0) then begin - print_error_td('error execve "'+Item.FGameInfo.Exec+'" code='+IntToStr(err)); + print_error_td('error execve "'+exec+'" code='+IntToStr(err)); end; // @@ -229,14 +265,14 @@ var kipc:THostIpcPipeKERN; mem:TPCharStream; - Item:TGameItem; + GameStartupInfo:TGameStartupInfo; begin + //while not IsDebuggerPresent do sleep(100); + mem:=TPCharStream.Create(data,size); - mem.Read(pipefd,SizeOf(THandle)); - - Item:=TGameItem.Create; - Item.Deserialize(mem); + GameStartupInfo:=TGameStartupInfo.Create(True); + GameStartupInfo.Deserialize(mem); mem.Free; @@ -245,6 +281,7 @@ begin parent:=md_pidfd_open(md_getppid); + pipefd:=GameStartupInfo.FPipe; pipefd:=md_pidfd_getfd(parent,pipefd); kipc:=THostIpcPipeKERN.Create; @@ -253,13 +290,13 @@ begin p_host_ipc:=kipc; td:=nil; - r:=kthread_add(@prepare,Item,@td,0,'[main]'); + r:=kthread_add(@prepare,GameStartupInfo,@td,0,'[main]'); Assert(r=0); msleep_td(0); end; -function run_item(const cfg:TGameRunConfig;Item:TGameItem):TGameProcess; +function run_item(const cfg:TGameRunConfig):TGameProcess; var r:Integer; @@ -274,19 +311,24 @@ var s_kern_ipc:THostIpcSimpleKERN; s_mgui_ipc:THostIpcSimpleMGUI; + GameStartupInfo:TGameStartupInfo; mem:TMemoryStream; begin Result:=nil; + GameStartupInfo:=TGameStartupInfo.Create(False); + GameStartupInfo.FConfInfo:=cfg.FConfInfo; + GameStartupInfo.FGameItem:=cfg.FGameItem; + SetStdHandle(STD_OUTPUT_HANDLE,cfg.hOutput); SetStdHandle(STD_ERROR_HANDLE ,cfg.hError ); fork_info:=Default(t_fork_proc); - if cfg.fork_proc then + if cfg.FConfInfo.MainInfo.fork_proc then begin Result:=TGameProcessPipe.Create; - Result.g_fork:=cfg.fork_proc; + Result.g_fork:=True; with TGameProcessPipe(Result) do begin @@ -303,9 +345,9 @@ begin mem:=TMemoryStream.Create; - mem.Write(kern2mgui[1],SizeOf(THandle)); - - Item.Serialize(mem); + GameStartupInfo.FPipe:=kern2mgui[1]; + GameStartupInfo.Serialize(mem); + FreeAndNil(GameStartupInfo); fork_info.hInput :=GetStdHandle(STD_INPUT_HANDLE); fork_info.hOutput:=cfg.hOutput; @@ -321,7 +363,7 @@ begin end else begin Result:=TGameProcessSimple.Create; - Result.g_fork:=cfg.fork_proc; + Result.g_fork:=False; with TGameProcessSimple(Result) do begin @@ -337,7 +379,7 @@ begin p_host_ipc:=s_kern_ipc; Ftd:=nil; - r:=kthread_add(@prepare,Item,@Ftd,0,'[main]'); + r:=kthread_add(@prepare,GameStartupInfo,@Ftd,0,'[main]'); fork_info.fork_pid:=GetProcessID; end; diff --git a/gui/main.lfm b/gui/main.lfm index fcdb13fb..07a24027 100644 --- a/gui/main.lfm +++ b/gui/main.lfm @@ -1,7 +1,7 @@ object frmMain: TfrmMain - Left = 342 + Left = 305 Height = 343 - Top = 294 + Top = 335 Width = 623 Caption = 'fpPS4' ClientHeight = 343 diff --git a/gui/main.pas b/gui/main.pas index c0d4c28f..f7d84723 100644 --- a/gui/main.pas +++ b/gui/main.pas @@ -83,7 +83,7 @@ type FIniFile:TIniFile; - FMainConfigInfo:TMainConfigInfo; + FConfigInfo:TConfigInfo; FAddHandle:THandle; FGetHandle:THandle; @@ -267,7 +267,7 @@ begin IpcHandler.Form:=Self; //main - FMainConfigInfo.MainInfo.ReadIni(FIniFile,'main'); + FConfigInfo.MainInfo.ReadIni(FIniFile,'main'); //main //games @@ -387,13 +387,13 @@ procedure TfrmMain.FormCreate(Sender: TObject); var r:RawByteString; begin - FMainConfigInfo:=TMainConfigInfo.Create; + FConfigInfo:=TConfigInfo.Create; FIniFile:=TIniFile.Create('fpps4.ini'); ReadIniFile; - OpenLog(FMainConfigInfo.MainInfo.LogFile); + OpenLog(FConfigInfo.MainInfo.LogFile); if (Application.Tag<>0) then begin @@ -609,7 +609,7 @@ begin if (frmCfgEditor=nil) then begin frmCfgEditor:=TfrmCfgEditor.Create(Self); - frmCfgEditor.FMainConfigInfo:=FMainConfigInfo; + frmCfgEditor.FConfigInfo:=FConfigInfo; end; frmCfgEditor.FormInit; @@ -651,11 +651,12 @@ begin cfg.hOutput:=FAddHandle; cfg.hError :=FAddHandle; - cfg.fork_proc:=FMainConfigInfo.MainInfo.fork_proc; + cfg.FConfInfo:=FConfigInfo; + cfg.FGameItem:=Item; if Item.FLock then Exit; - FGameProcess:=run_item(cfg,Item); + FGameProcess:=run_item(cfg); if (FGameProcess<>nil) then begin diff --git a/sys/kern/kern_dmem.pas b/sys/kern/kern_dmem.pas index 1b1a827c..940adca2 100644 --- a/sys/kern/kern_dmem.pas +++ b/sys/kern/kern_dmem.pas @@ -240,8 +240,12 @@ begin dmap:=dmem_maps[default_pool_id]; - //eflags = flags & MAP_NO_COALESCE | 0x20000 | 0x80000 - cow:=(flags and MAP_NO_COALESCE) or MAP_COW_UNK; + //entry->eflags = flags & 0x400000 | 0x20000 | 0x80000 + //0x400000 -> MAP_ENTRY_NO_COALESCE -> MAP_NO_COALESCE + //0x20000 -> not simplify ??? + //0x80000 -> ??? + + cow:=(flags and MAP_NO_COALESCE); vm_map_lock(map); diff --git a/sys/vm/vm_map.pas b/sys/vm/vm_map.pas index 89145db3..408f1064 100644 --- a/sys/vm/vm_map.pas +++ b/sys/vm/vm_map.pas @@ -110,7 +110,7 @@ const MAP_ENTRY_VN_WRITECNT =$10000; // writeable vnode mapping - //0x20000 + //0x20000 not simplify ??? //0x40000 //0x80000 @@ -138,7 +138,7 @@ const MAP_ACC_NO_CHARGE =$8000; MAP_COW_SYSTEM =$10000; - MAP_COW_UNK =$20000; + MAP_COW_NO_BUDGET =$20000; MAP_COW_KERNEL =$40000; MAP_COW_NO_COALESCE =$400000; @@ -1033,7 +1033,7 @@ begin protoeflags:=0; charge_prev_obj:=FALSE; - protoeflags:=protoeflags or (cow and (MAP_COW_NO_COALESCE or MAP_COW_UNK)); + protoeflags:=protoeflags or (cow and (MAP_COW_NO_COALESCE or MAP_COW_NO_BUDGET)); if ((cow and MAP_COPY_ON_WRITE)<>0) then begin @@ -1085,7 +1085,7 @@ charged: //budget if (max=0) or - ((cow and MAP_COW_UNK)<>0) or + ((cow and MAP_COW_NO_BUDGET)<>0) or (p_proc.p_budget_ptype=-1) then begin // @@ -1488,7 +1488,7 @@ var obj:vm_map_object; sdk_5:Boolean; begin - if ((entry^.eflags and (MAP_ENTRY_IS_SUB_MAP or MAP_COW_UNK or MAP_ENTRY_IN_TRANSITION))<>0) or + if ((entry^.eflags and (MAP_ENTRY_IS_SUB_MAP or $20000 or MAP_ENTRY_IN_TRANSITION))<>0) or (entry^.inheritance=VM_INHERIT_HOLE) then begin Exit; diff --git a/sys/vm/vm_mmap.pas b/sys/vm/vm_mmap.pas index 90225da0..1e4644f2 100644 --- a/sys/vm/vm_mmap.pas +++ b/sys/vm/vm_mmap.pas @@ -484,7 +484,7 @@ begin if (handle_type=OBJT_BLOCKPOOL) then begin - docow:=docow or (MAP_COW_UNK or MAP_COW_NO_COALESCE); + docow:=docow or (MAP_COW_NO_BUDGET or MAP_COW_NO_COALESCE); end else begin docow:=docow or (flags and MAP_NO_COALESCE);