ARM Cortex-M Microcontroller startup files

Timo Sintonen via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 30 23:57:07 PDT 2015


On Thursday, 30 April 2015 at 11:30:33 UTC, Mike wrote:

>
> Starting from zero appeals to my way of thinking.  I've made 
> several attempts at this both on the PC and for 
> microcontrollers, so please allow me to offer my thoughts on 
> the idea:
>
> While this may seem simple to achieve, I think it will raise a 
> few questions that will need answering.
>
> * Can ModuleInfo be leveraged, without introducing overhead, to 
> call module constructors and static constructors?  They might 
> be useful for hardware initialization.

I think we should omit moduleinfo totally and so we can not have 
module constructors. I think pointers to static constructors are 
available in a certain section that I have not in my link script. 
Adding this section should make them available.

> * Is dynamic memory allocation a requirement of D, or a library 
> feature?
We should agree whether we are making only yet another C compiler 
or do we want the D compiler. The ability to use object oriented 
features was the reason I started with D. I think we do npot need 
full gc but I want to create objects at least at start. they will 
live trough the program so I have no need to delete then.
I think it is possible to have the memory and object management 
things as set of files that may optionally compiled in or left 
out.  There must be better and smaller malloc programs than the 
one I use now.

> * Does D need the C runtime, or can it init on its own?
We should not depend on any libc. If we need anything from libc 
we must require/provide a multilib libc set that has been 
compiled with the correct compiler flags.

> * Should the C standard library bindings be part of the 
> runtime, or exist as an external Deimos library?  Either way 
> they can still be used by the runtime, I'm just suggesting that 
> they should be encapsulated.
The bindings do not take space in the library but what are we 
doing with bindings if we do not have libc? I think it would be 
better to have a separate libc port project that contains the 
library and bindings.

> * What will be done about TypeInfo for now?  It's causing me 
> some serious code-bloat problems.  See 
> http://forum.dlang.org/post/quemhwpgijwmqtpxukiv@forum.dlang.org
I hope the compiler devs can tell us if it is possible to remove 
typeinfo totally and what language features we will lose then.

> * Is data and bss initialization part of  the runtime, or 
> delegated to toolchain, silicon, and BSP vendors?

In C the data initialization is made before main. The copying is 
target independent but may depend on build environment, like what 
symbols the linker script provides. There is no general rule if 
any hardware specific init is needed at this point, before or 
after.
One thing that has not been mentioned yet is that D is using TLS 
by default. Tdata and tbss can be combined to global data and 
bss. However, it is not hard to make śeparate sections for them 
and be prepared to multithreaded system.



More information about the Digitalmars-d mailing list