Forráskód Böngészése

sinclairql: have a max. 48 char buffer for job name. set the job name to the program name by default on system unit init

git-svn-id: trunk@49190 -
Károly Balogh 4 éve
szülő
commit
3280ec3220
2 módosított fájl, 65 hozzáadás és 2 törlés
  1. 13 2
      rtl/sinclairql/si_prc.pp
  2. 52 0
      rtl/sinclairql/system.pp

+ 13 - 2
rtl/sinclairql/si_prc.pp

@@ -37,8 +37,19 @@ asm
     bra   @start
     dc.l  $0
     dc.w  $4afb
-    dc.w  3
-    dc.l  $46504300   { Job name, just FPC for now }
+    dc.w  8
+    dc.l  $4650435f   { Job name buffer. FPC_PROG by default, can be overridden }
+    dc.l  $50524f47   { the startup code will inject the main program name here }
+    dc.l  $00000000   { user codes is free to use the SetQLJobName() function   }
+    dc.l  $00000000   { max. length: 48 characters }
+    dc.l  $00000000
+    dc.l  $00000000
+    dc.l  $00000000
+    dc.l  $00000000
+    dc.l  $00000000
+    dc.l  $00000000
+    dc.l  $00000000
+    dc.l  $00000000
 
 @start:
     { relocation code }

+ 52 - 0
rtl/sinclairql/system.pp

@@ -70,6 +70,9 @@ var
 
     {$endif defined(FPUSOFT)}
 
+function SetQLJobName(const s: string): longint;
+function GetQLJobName: string;
+
 
 implementation
 
@@ -190,6 +193,11 @@ begin
   randseed:=mt_rclck;
 end;
 
+
+{*****************************************************************************
+                      Platform specific custom calls
+*****************************************************************************}
+
 procedure PrintStr(ch: longint; const s: shortstring);
 begin
   io_sstrg(ch,-1,@s[1],ord(s[0]));
@@ -204,11 +212,53 @@ begin
 end;
 
 
+var
+  start_proc: byte; external name '_start'; 
+
+  { WARNING! if you change this value, make sure there's enough
+    buffer space for the job name in the startup code! }
+const
+  JOB_NAME_MAX_LEN = 48;
+
+function SetQLJobName(const s: string): longint;
+var
+  len: longint;
+begin
+  SetQLJobName:=-1;
+  if pword(@start_proc)[3] = $4afb then
+    begin
+      len:=length(s);
+      if len > JOB_NAME_MAX_LEN then
+        len:=JOB_NAME_MAX_LEN;
+      Move(s[1],pword(@start_proc)[5],len);
+      pword(@start_proc)[4]:=len;
+      SetQLJobName:=len;
+    end;
+end;
+
+function GetQLJobName: string;
+var
+  len: longint;
+begin
+  GetQLJobName:='';
+  if pword(@start_proc)[3] = $4afb then
+    begin
+      len:=pword(@start_proc)[4];
+      if len <= JOB_NAME_MAX_LEN then
+        begin
+          SetLength(GetQLJobName,len);
+          Move(pword(@start_proc)[5],GetQLJobName[1],len);
+        end;
+    end;
+end;
+
+
 {*****************************************************************************
                         System Dependent Entry code
 *****************************************************************************}
 var
   jobStackDataPtr: pointer; external name '__job_stack_data_ptr';
+  program_name: shortstring; external name '__fpc_program_name';
 
 { QL/QDOS specific startup }
 procedure SysInitQDOS;
@@ -220,6 +270,8 @@ begin
   QL_CommandLineLen:=pword(@QL_ChannelIDs[QL_ChannelIDNum])[0];
   QL_CommandLine:=@pword(@QL_ChannelIDs[QL_ChannelIDNum])[1];
 
+  SetQLJobName(program_name);
+
   stdInputHandle:=io_open('con_',Q_OPEN);
   stdOutputHandle:=stdInputHandle;
   stdErrorHandle:=stdInputHandle;