From b4f1ab54b36f7dc273b9a80081c019f7d6618715 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Thu, 9 Sep 2010 12:04:57 -0500 Subject: Support modules. --- src/usr/example/example.C | 28 ++++++++++++++++++++++++++++ src/usr/example/makefile | 16 ++++++++++++++++ src/usr/makefile | 9 +++++++++ 3 files changed, 53 insertions(+) create mode 100644 src/usr/example/example.C create mode 100644 src/usr/example/makefile create mode 100644 src/usr/makefile (limited to 'src/usr') diff --git a/src/usr/example/example.C b/src/usr/example/example.C new file mode 100644 index 000000000..18095ac5b --- /dev/null +++ b/src/usr/example/example.C @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +static mutex_t value = mutex_create(); + +extern "C" +void _init(void*) +{ + // Call default constructors for any static objects. + extern void (*ctor_start_address)(); + extern void (*ctor_end_address)(); + void(**ctors)() = &ctor_start_address; + while(ctors != &ctor_end_address) + { + (*ctors)(); + ctors++; + } + + printk("Here! %llx, %s\n", (uint64_t) value, VFS_ROOT); +} + +extern "C" +void _start(void*) +{ + task_end(); +} diff --git a/src/usr/example/makefile b/src/usr/example/makefile new file mode 100644 index 000000000..608aacc87 --- /dev/null +++ b/src/usr/example/makefile @@ -0,0 +1,16 @@ +ROOTPATH = ../../.. +OBJDIR = ${ROOTPATH}/obj/modules/example +IMGDIR = ${ROOTPATH}/img +EXTRACOMMONFLAGS = -fPIC + +OBJS = example.o +OBJECTS = $(addprefix ${OBJDIR}/, ${OBJS}) +LIBS = libexample.so +LIBRARIES = $(addprefix ${IMGDIR}/, ${LIBS}) + +all: ${OBJECTS} ${LIBRARIES} + +clean: + (rm -f ${OBJECTS} ${LIBRARIES} ) + +include ${ROOTPATH}/config.mk diff --git a/src/usr/makefile b/src/usr/makefile new file mode 100644 index 000000000..e6907fe8c --- /dev/null +++ b/src/usr/makefile @@ -0,0 +1,9 @@ +ROOTPATH = ../.. + +SUBDIRS = example.d + +all: ${SUBDIRS} + +clean: $(patsubst %.d,%.clean, ${SUBDIRS}) + +include ../../config.mk -- cgit v1.2.1