Browse Source

* first compilable version

git-svn-id: trunk@12614 -
florian 16 years ago
parent
commit
5f9b82d38b
1 changed files with 56 additions and 35 deletions
  1. 56 35
      rtl/embedded/arm/lpc21x4.pp

+ 56 - 35
rtl/embedded/arm/lpc21x4.pp

@@ -31,7 +31,7 @@ unit lpc21x4;
       // VECTDATA_FIQ  {   __TODO }
       // VECTDATA_FIQ  {   __TODO }
 
 
     type
     type
-      BITS32 = bitpacked array[0..31] of 0..1;
+      TBitvector32 = bitpacked array[0..31] of 0..1;
 
 
 
 
     {##############################################################################
     {##############################################################################
@@ -350,36 +350,39 @@ unit lpc21x4;
       MAM_MAMMAP        : DWord absolute $E01FC040;
       MAM_MAMMAP        : DWord absolute $E01FC040;
 
 
     var
     var
-      Undefined_Handler
+      Undefined_Handler,
       SWI_Handler,
       SWI_Handler,
       Prefetch_Handler,
       Prefetch_Handler,
       Abort_Handler,
       Abort_Handler,
       FIQ_Handler : pointer;
       FIQ_Handler : pointer;
 
 
-    procedure InitPLL(m : 1..32;p : 1..8);
-    procedure PLLFeed;
-    function GetProcessorClock : DWord;
+    type
+      tm = 1..32;
+      tp = 1..8;
 
 
+    procedure InitPLL(m : tm;p : tp);
+    procedure PLLFeed;
+    function GetProcessorClock(CrystalFrequency : DWord) : DWord;
 
 
   implementation
   implementation
 
 
     procedure PLLFeed;
     procedure PLLFeed;
       begin
       begin
-        SCB_PLLFEED:=$aa
-        SCB_PLLFEED:=$55
+        SCB_PLLFEED:=$aa;
+        SCB_PLLFEED:=$55;
       end;
       end;
 
 
 
 
     function GetProcessorClock(CrystalFrequency : DWord) : DWord;
     function GetProcessorClock(CrystalFrequency : DWord) : DWord;
       begin
       begin
         if (TBitvector32(SCB_PLLSTAT)[8] and 1)<>0 then
         if (TBitvector32(SCB_PLLSTAT)[8] and 1)<>0 then
-          Result:=((SCB_PLLSTAT and $f)+1)*CrystalFrequency;
+          GetProcessorClock:=((SCB_PLLSTAT and $f)+1)*CrystalFrequency
         else
         else
-          Result:=CrystalFrequency;
+          GetProcessorClock:=CrystalFrequency;
       end;
       end;
 
 
 
 
-    procedure InitPLL(m : 1..32;p : 1..8);
+    procedure InitPLL(m : tm;p : tp);
       begin
       begin
         case p of
         case p of
           1: p:=0;
           1: p:=0;
@@ -410,35 +413,51 @@ unit lpc21x4;
         PLLFeed;
         PLLFeed;
       end;
       end;
 
 
+
+procedure PASCALMAIN; external name 'PASCALMAIN';
+
 begin
 begin
   asm
   asm
     // code derived from phillips appnote 10254
     // code derived from phillips appnote 10254
     .init
     .init
-Entry:
-    ldr pc, _start
-    ldr pc, Undefined_Addr
-    ldr pc, SWI_Addr
-    ldr pc, Prefetch_Addr
-    ldr pc, Abort_Addr
+    ldr pc, .Lstart
+    ldr pc, .LUndefined_Addr
+    ldr pc, .LSWI_Addr
+    ldr pc, .LPrefetch_Addr
+    ldr pc, .LAbort_Addr
 
 
     // signature
     // signature
     nop
     nop
     ldr pc, [PC, #-0xFF0] // load irq vector from vic
     ldr pc, [PC, #-0xFF0] // load irq vector from vic
-    ldr pc, FIQ_Addr
-Undefined_Addr:
-    ldr
+    ldr pc, .LFIQ_Addr
+.LUndefined_Addr:
+    ldr r0,.L1
+    ldr pc,[r0]
+.LSWI_Addr:
+    ldr r0,.L2
+    ldr pc,[r0]
+.LPrefetch_Addr:
+    ldr r0,.L3
+    ldr pc,[r0]
+.LAbort_Addr:
+    ldr r0,.L4
+    ldr pc,[r0]
+.LFIQ_Addr:
+    ldr r0,.L5
+    ldr pc,[r0]
 .L1:
 .L1:
-    .word     Un
-SWI_Handler:
-    B         SWI_Handler
-Prefetch_Handler:
-    B         Prefetch_Handler
-Abort_Handler:
-    B         Abort_Handler
-FIQ_Handler:
-    B         FIQ_Handler
-_start:
-    {
+    .word     Undefined_Handler
+.L2:
+    .word     SWI_Handler
+.L3:
+    .word     Prefetch_Handler
+.L4:
+    .word     Abort_Handler
+.L5:
+    .word     FIQ_Handler
+
+.Lstart:
+    (*
       Set SP for Supervisor mode. Depending upon
       Set SP for Supervisor mode. Depending upon
       the stack the application needs this value
       the stack the application needs this value
       needs to be set.
       needs to be set.
@@ -446,10 +465,10 @@ _start:
       but if this point is entered by any
       but if this point is entered by any
       other means than reset, the stack pointer
       other means than reset, the stack pointer
       needs to be set explicity
       needs to be set explicity
-    }
+    *)
     // LDR SP,=0x40001000
     // LDR SP,=0x40001000
 
 
-    {
+    (*
       Setting up SP for IRQ and FIQ mode.
       Setting up SP for IRQ and FIQ mode.
       Change mode before setting each one
       Change mode before setting each one
       move back again to Supervisor mode
       move back again to Supervisor mode
@@ -458,12 +477,12 @@ _start:
       counter The stack pointers must be
       counter The stack pointers must be
       initialized for interrupts to be
       initialized for interrupts to be
       used later.
       used later.
-    }
+    *)
 
 
-    {
+    (*
       setup for fiq and irq interrupt stacks to run
       setup for fiq and irq interrupt stacks to run
       below current stack by 1000.
       below current stack by 1000.
-    }
+    *)
     mov r0, sp         // copy current stack pointer
     mov r0, sp         // copy current stack pointer
     sub r0, r0, #1000  // make irq stack pointer
     sub r0, r0, #1000  // make irq stack pointer
     sub r1, r0, #1000  // make fiq stack pointer
     sub r1, r0, #1000  // make fiq stack pointer
@@ -474,5 +493,7 @@ _start:
     msr cpsr_c, #0x13  // supervisor mode F,I enabled
     msr cpsr_c, #0x13  // supervisor mode F,I enabled
 
 
     bl PASCALMAIN
     bl PASCALMAIN
+    .text
   end;
   end;
+
 end.
 end.