
foo/
Makefile foo.c src/ ALPHA_SPIN/ encap_foo.s
-----------
foo/src
Foo.i3 Foo.m3 m3makefile
-----------
foo/ALPHA_SPIN
FooUser.s extend_foo.c foo.rc and the module object files
This example is for the domain library, which uses SIEG to generate a syscall interface. That means modules in this extension import the Sieg domain, which in turn needs UserSpaceThreads.
overridepath = [ THISTREE , FULLTREE ]
DomainImport("SpinPublic","kernel","spincore",overridepath)
DomainImport("SpinTrusted","kernel","spincore",overridepath)
DomainImport("Sieg","user","sieg",overridepath)
DomainImport("UserSpaceThread","user/thread","threadcore",overridepath)
Package("DomainLib")
implementation("DomainLib")
sieg_extension("DomainLib")
Extension({})
Several files are produced by the m3makefile in the ALPHA_SPIN subdir.
The CAM application is just downloads its extension and then print it did so. cam.c is written from scratch by the user.
main(int argc, char **argv)
{
cam_extension(); /* <- generated in ALPHA_SPIN/extend_cam.c */
printf("cam loaded\n");
}
Extension Makefiles follow a common form. This sample is for cam where
cam_domain is the resulting application program. cam.c uses dlib for
the printf and the domain library to load the extension.
The 'extension' target will run m3build if the extensions were touched.
THISTREE:=$(shell cd ../..; pwd) include $(THISTREE)/make.conf vpath %.a $(THISTREE)/user/lib:$(FULLTREE)/user/lib vpath crt0.o $(THISTREE)/user/lib:$(FULLTREE)/user/lib all: extension cam_domain cam_domain: crt0.o cam.o extend_cam.o encap_cam.o libdomain.a libc.a $(LD) $(LDFLAGS) -o $@ $^ extension: m3sources # make.extension has the rule to build m3sources install: all cp cam_domain $(THISTREE)/user/bin clean: rm -rf ALPHA_SPIN include ../make.extension
Several files are produced by gmake
Static extensions are encapsulated into open arrays by the encap script just as for applications. The mkextender script in start/src generates Encap modules that dynamically links the open arrays produced by encap.
At boottime, the main bodies of the encap modules queue an Init function with the BootEncap module. The BootEncap module main body forks a thread that will run all those Init procedures once scheduling starts. The Encap modules are ordered by importing all the Encaps that are to run before it. The Init procedures are run serially.
Each extension has a script generated by the compiler that will load and link it into the kernel. This is ALPHA_SPIN/foo.rc. Those scripts are series of "domain" commands that you can also use at the shell prompt. Use "domain check foo" to look for unresolved symbols.
!> script ~/spin/user/sync/rwlock/ALPHA_SPIN/rwlock.rc rwlock .......... 39 KB link complete. rwlock run M3 main bodies. >>> extension loaded: 10 new units, 589 total units
!>script ~/spin/user/scripts/exec.rc !>script ~/spin/user/cam/osf.cam.rc !>exec ~/spin/user/bin/cam_domain