Consider to perform a target specific initialization outside the runtime package in target specific packages as proposed by n64 port:
|
// Relies on external implementations of the following target specific |
|
// functions, that must be provided by the target module via go:linkname pragma |
|
// or in assembly: |
|
// |
|
// _rt0_mips64_noos() |
|
// runtime.unhandledException() |
|
// runtime.defaultWrite(fd int, p []byte) int |
It may give us more flexibility when it comes to early hardware initialization. For example, with this approach we can probably avoid the plugin code in imxmbr.
Questions
- Does this
//go:linkname approach affects the order of package initialization if we use Go (nosplit) instead of assembly?
- Can we reduce the number of external functions to only
_rt0_GOARCH_noos and in some way force the init function in some external package to be the first one (with dependencies) executed by runtime?
- If the init approach described above doesn't work, can we reduce the number of external functions to only two. For example the second one in the form of:
func noos_defaults() map[string]any?
- Maybe only one
_rt0_GOARCH_noos function is enough to fulfill our needs?
I personally prefer 4. You can probably use DATA unhandledException set to very dumb handler that stops execution here and update it in the _rt0_GOARCH_noos to more intelligent one.
Consider to perform a target specific initialization outside the runtime package in target specific packages as proposed by n64 port:
go/src/runtime/tasker_noos_mips64.go
Lines 9 to 15 in 8df86cc
It may give us more flexibility when it comes to early hardware initialization. For example, with this approach we can probably avoid the plugin code in imxmbr.
Questions
//go:linknameapproach affects the order of package initialization if we use Go (nosplit) instead of assembly?_rt0_GOARCH_noosand in some way force theinitfunction in some external package to be the first one (with dependencies) executed by runtime?func noos_defaults() map[string]any?_rt0_GOARCH_noosfunction is enough to fulfill our needs?I personally prefer 4. You can probably use
DATA unhandledExceptionset to very dumb handler that stops execution here and update it in the_rt0_GOARCH_noosto more intelligent one.