Browse Source

* Changed .elf extension to .nef (Not Executable File) for intermediate file builds in the NDS compiler (used on no$gba debugger for symbol table)
* Added nds target to ppudump.pp
* Fixed rtl compilation for nds target
* Changes in prt09.as

git-svn-id: trunk@8002 -

Legolas 18 years ago
parent
commit
cdf4841517
6 changed files with 78 additions and 27 deletions
  1. 3 3
      compiler/systems/t_nds.pas
  2. 4 2
      compiler/utils/ppudump.pp
  3. 2 2
      rtl/nds/Makefile.fpc
  4. 2 5
      rtl/nds/prt09.as
  5. 1 1
      rtl/nds/sysheap.inc
  6. 66 14
      rtl/nds/system.pp

+ 3 - 3
compiler/systems/t_nds.pas

@@ -724,7 +724,7 @@ begin
   Replace(cmdstr,'$OPT',Info.ExtraOptions);
   if not(cs_link_on_target in current_settings.globalswitches) then
    begin
-    Replace(cmdstr,'$EXE',(maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename^,preName+'.elf')))));
+    Replace(cmdstr,'$EXE',(maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename^,preName+'.nef')))));
     Replace(cmdstr,'$RES',(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));
     Replace(cmdstr,'$STATIC',StaticStr);
     Replace(cmdstr,'$STRIP',StripStr);
@@ -733,7 +733,7 @@ begin
    end
   else
    begin
-    Replace(cmdstr,'$EXE',maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename^,preName+'.elf'))));
+    Replace(cmdstr,'$EXE',maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename^,preName+'.nef'))));
     Replace(cmdstr,'$RES',maybequoted(ScriptFixFileName(outputexedir+Info.ResName)));
     Replace(cmdstr,'$STATIC',StaticStr);
     Replace(cmdstr,'$STRIP',StripStr);
@@ -750,7 +750,7 @@ begin
   if success then
     begin
       success:=DoExec(FindUtil(utilsprefix + 'objcopy'), '-O binary '+ 
-        ChangeFileExt(current_module.exefilename^, preName+'.elf') + ' ' + 
+        ChangeFileExt(current_module.exefilename^, preName+'.nef') + ' ' + 
         ChangeFileExt(current_module.exefilename^, preName+target_info.exeext),
         true,false);
     end;

+ 4 - 2
compiler/utils/ppudump.pp

@@ -150,7 +150,8 @@ type
              system_ia64_win64,         { 39 }
              system_i386_wince,         { 40 }
              system_x86_6432_linux,     { 41 }
-             system_arm_gba             { 42 }
+             system_arm_gba,            { 42 }
+             system_arm_nds             { 43 }
        );
 const
   Targets : array[ttarget] of string[17]=(
@@ -196,7 +197,8 @@ const
   { 39 }  'Win64-iA64',
   { 40 }  'WinCE-i386',
   { 41 }  'Linux-x64',
-  { 42 }  'GBA-ARM'
+  { 42 }  'GBA-arm',
+  { 43 }  'NDS-arm'
   );
 begin
   if w<=ord(high(ttarget)) then

+ 2 - 2
rtl/nds/Makefile.fpc

@@ -53,7 +53,7 @@ endif
 OBJPASDIR=$(RTL)/objpas
 GRAPHDIR=$(INC)/graph
 
-[rules]
+[rules]
 .NOTPARALLEL:
 # Get the system independent include file names.
 # This will set the following variables :
@@ -91,7 +91,7 @@ cprt09$(OEXT) : cprt09.as
 # Base Units (System, strings, os-dependent-base-unit)
 #
 
-$(SYSTEMUNIT)$(PPUEXT) : $(SYSTEMUNIT).pp $(SYSDEPS)
+$(SYSTEMUNIT)$(PPUEXT) : $(SYSTEMUNIT).pp $(SYSDEPS) $(INC)/softfpu.pp
         $(COMPILER) -Us -Sg $(SYSTEMUNIT).pp $(REDIR)
 
 objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)

+ 2 - 5
rtl/nds/prt09.as

@@ -101,8 +101,8 @@ _start:
 	@-------------------------------------------------------------------------
 	@ DCache & ICache enable
 	@-------------------------------------------------------------------------
-	ldr	r0,=0b01000110
-	ldr	r0,=0x42
+	ldr	r0,=0b01000010
+
 	mcr	p15, 0, r0, c2, c0, 0
 	mcr	p15, 0, r0, c2, c0, 1
 
@@ -162,9 +162,6 @@ _start:
 	ldr	r0, =__eheap_end
 	str	r0, [r1]
 
-
-
-
 	mov	r0, #0			@ int argc
 	mov	r1, #0			@ char *argv[]
 	ldr	r3, =main

+ 1 - 1
rtl/nds/sysheap.inc

@@ -23,7 +23,7 @@
 
 function SysOSAlloc(size: ptruint): pointer;
 begin
-  result := nil;//pointer($02000000);
+  result := pointer($02000000);
 end;
 
 { $define HAS_SYSOSFREE}

+ 66 - 14
rtl/nds/system.pp

@@ -18,6 +18,9 @@ unit System;
 interface
 
 {$define FPC_IS_SYSTEM}
+{ $define USE_NOTHREADMANAGER}
+{ $define HAS_MEMORYMANAGER}
+{ $undef FPC_HAS_FEATURE_TEXTIO}
 
 {$i ndsbiosh.inc}
 
@@ -27,6 +30,7 @@ interface
 {$i softfpu.pp}
 {$undef fpc_softfpu_interface}
 
+procedure InitHeapThread;
 
 const
  LineEnding = #10;
@@ -55,8 +59,18 @@ var
   argv: PPChar;
   envp: PPChar;
   errno: integer;
-  fake_heap_start: pchar; cvar;
-  fake_heap_end: pchar; cvar;
+//  fake_heap_start: ^byte; cvar;
+  fake_heap_end: ^byte; cvar; 
+//  heap_start: longint; external name 'end';
+//  heap_end: longint; external name '__eheap_end';
+  heap_start: longint; external name 'end';
+  heap_end: longint; external name 'fake_heap_end';
+//  __eheap_start: longint; cvar; external;
+//  fake_heap_end: longint; cvar; external;
+
+
+
+
 
 implementation
 
@@ -133,41 +147,79 @@ begin
 end;
 
 
+(*
 procedure InitHeap;
 begin
-{
   FillChar(freelists_fixed,sizeof(tfreelists),0);
   FillChar(freelists_free_chunk,sizeof(freelists_free_chunk),0);
 
   freelist_var:=nil;
+  {The GBA has no operating system from which we ask memory, so we
+   initialize the heap with a single block of memory.}
   freeoslistcount:=1;
-  freeoslist:=pointer($2040000);
+  //freeoslist:=pointer($023FF000);
+  freeoslist:=pointer(heap_start);
   fillchar(freeoslist^,sizeof(freeoslist^),0);
-  freeoslist^.size:=$40000;
+  //freeoslist^.size:=$00040000;//$003FF000;
+  freeoslist^.size:=heap_end-heap_start;
   fillchar(internal_status,sizeof(internal_status),0);
-}
 end;
+*)
+
+procedure InitHeap;
+var
+  loc_freelists: pfreelists;
+begin
+  { we cannot initialize the locks here yet, thread support is
+    not loaded yet }
+  loc_freelists := @freelists;
+
+  // PROVA -->
+  loc_freelists^.varlist := nil;
+  loc_freelists^.oscount := 1;
+  loc_freelists := pointer(heap_start);
 
+  fillchar(loc_freelists^, sizeof(tfreelists), 0);
+  fillchar(orphaned_freelists, sizeof(orphaned_freelists), 0);
+
+  loc_freelists^.oslist^.size := heap_end - heap_start;
+  fillchar(loc_freelists^.internal_status, sizeof(TFPCHeapStatus), 0);  
+  // <-- PROVA
+
+end;
+
+
+procedure InitHeapThread;
+var
+  loc_freelists: pfreelists;
+begin
+  loc_freelists := @freelists;
+  fillchar(loc_freelists^,sizeof(tfreelists),0);
+{$ifdef DUMP_MEM_USAGE}
+  fillchar(sizeusage,sizeof(sizeusage),0);
+  fillchar(maxsizeusage,sizeof(sizeusage),0);
+{$endif}
+end;
 
 begin
   StackLength := CheckInitialStkLen(InitialStkLen);
   ///StackBottom := Sptr - StackLength;
   StackBottom := StackTop - StackLength;
 { OS specific startup }
-  fake_heap_start := pchar(0);
-  fake_heap_end := pchar(0);
+//  fake_heap_start := pchar(0);
+//  fake_heap_end := pchar(0);
 { Set up signals handlers }
 
+  fpc_cpucodeinit;
 { Setup heap }
   InitHeap;
-  //SysInitExceptions;
+  SysInitExceptions;
 { Setup stdin, stdout and stderr }
-  //SysInitStdIO;
+  SysInitStdIO;
 { Reset IO Error }
-  InOutRes := 0;
+  InOutRes:=0;
 { Arguments }
 
-  //InitSystemThreads;
-  //initvariantmanager;
-  //initwidestringmanager;
+  InitSystemThreads;
+  initvariantmanager;
 end.