Re: RE : [fpc-pascal] Variable alignment in arm-embedded

2012-06-08 Thread Koenraad Lelong

On 08-06-12 06:45, Ludo Brands wrote:


Handcrafted alignment:

var
   ReservedBlock:array[0..$1FF] of byte;
   IntVectors:pointer;
begin
   IntVectors:=pointer((ptruint(@ReservedBlock[0])+$100) and not $ff);
End;

Or dynamic:

Var
   pReservedBlock,IntVectors:pointer;
begin
   Getmem(pReservedBlock,$200);
   IntVectors:=pointer((ptruint(pReservedBlock)+$100) and not $ff);
End;


Thanks Ludo,

I'll take that as a starting point. I hope I will not need the "lost" 
256 bytes in the future.
I can replace the IntVectors-pointer with a pointer to a record of 
pointers, isn't it ? That way I have a clearer view of what vectors I'm 
working with.


TIntVectorTable = record of
NMI_Handler,
HardFault_Handler,
MemManage_Handler,
BusFault_Handler,
UsageFault_Handler,
SWI_Handler,
DebugMonitor_Handler,
PendingSV_Handler,
Systick_Handler,
(* STM32 specific Interrupt Numbers *)
WWDG_Handler,
PVD_Handler,
...
USBWakeUp_Handler : pointer;
end {TIntVectors};

var
 IntVectors : ^TIntVectorTable;
 ReservedBlock:array[0..$FF+SizeOf(TIntVectorTable)] of byte;

procedure SystickProc; interrupt;

begin
...
end;

begin
  IntVectors:=pointer((ptruint(@ReservedBlock[0])+$100) and not $ff);
  IntVectors^.SystickHandler:=@SystickProc;
...
end.

Koenraad
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


RE : RE : [fpc-pascal] Variable alignment in arm-embedded

2012-06-08 Thread Ludo Brands
> Thanks Ludo,
> 
> I'll take that as a starting point. I hope I will not need the "lost" 
> 256 bytes in the future.

I could be wrong but AFAIK if the compiler would do the alignment, the loss
can also be up to 255 bytes. Here you lose 256 bytes in all cases. 

> I can replace the IntVectors-pointer with a pointer to a record of 
> pointers, isn't it ? That way I have a clearer view of what 
> vectors I'm 
> working with.
> 

Yes, of course.

Ludo

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: RE : RE : [fpc-pascal] Variable alignment in arm-embedded

2012-06-08 Thread Jeppe Græsdal Johansen

Den 08-06-2012 14:28, Ludo Brands skrev:

Thanks Ludo,

I'll take that as a starting point. I hope I will not need the "lost"
256 bytes in the future.

I could be wrong but AFAIK if the compiler would do the alignment, the loss
can also be up to 255 bytes. Here you lose 256 bytes in all cases.
Yes, but this would allow the linker to place other stuff there which 
fits in less than 255 bytes.


Wasting 255 bytes is a lot on systems that only has a few kilobytes of 
RAM. I wonder if the restriction of 32 bytes on the align directive 
could just be removed, or will we need some sort of linker script changes?

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal