Decide on the name of your component. I have called mine 'blah'
cd to the apps/ directory of Mungi and create a new directory for your app: mkdir blah
Steal the IDL file from another app, preferably a simple one such as apps/fridge. The basic template for this IDL should be:
#include "stdpax.idlh"
#include "iinit.idl"
[
cid (0x2853),
ver (1,1)
]
component CBlah {
provides IInit;
};
The 'cid' is the Component ID for this component. It needs to be unique. Unfortunately there is no way to determine used CIDs yet, apart from grep.Return to the main Mungi directory (../..) and make apps/blah/blah_cci.c. This runs the Pax compiler, which generates code stubs from the interface file we just created.
Now return to the component directory and add whatever you like to blah_cci.c. The function called on component instantiation is (in this case) cblah_iinit_setup. You will want to #include <mungi.h> at the beginning of this .c file. As an example, a "hello world" program looks like:
/* Includes */
#include <mungi.h>
#include <mlib.h>
#include "blah.idl.h"
#include "blah_cc.idl.h"
/* component functions */
/* FILL-IN: Insert component-core function implementations here. */
/* IInit interface */
int cblah_iinit_setup( cblah_t *cthis, cicap_t naming )
{
UserPrint ("Hello, World!\n");
return 0;
}
Note the inclusion of mlib.h - this contains "a bunch of library functions", including UserPrint().Now copy a subdir.mk from one of the other components and simply replace all references to the old name with the new. The subdir.mk for blah looks like:
BLAH_NAME := blah BLAH_BASE := apps/blah BLAH_SRC := $(call FN_FIND_SRC,$(BLAH_BASE)) BLAH_OBJ := $(call FN_FIND_OBJ,$(BLAH_SRC)) BLAH_LIBS := $(USER_LIBS) APP_VARS += BLAH
Due to a bug in the build system, you must now run make realclean in the toplevel Mungi directory to ensure that dependencies are created for your new component.
Modify Makefile.local in the toplevel Mungi directory to ensure that APP_SUBDIRS includes your new component. In my case, since I am using Sulima (a MIPS simulator with no device simulation), my Makefile.local line is: APP_SUBDIRS = init clocator naming blah
Modify the file conf in the toplevel Mungi directory to ensure that the component is registered. Something like load /dit/blah /components/blah will do it. If you would like an instance of your component to be created and run on startup, also do something like
mkdir /apps init /components/blah /apps/blah
Now make Mungi.