Skip to content

Implement some runtime initialization outside the runtime #9

Description

@michalderkacz

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

  1. Does this //go:linkname approach affects the order of package initialization if we use Go (nosplit) instead of assembly?
  2. 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?
  3. 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?
  4. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions