summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct4
-rw-r--r--modules/SConscript3
-rw-r--r--modules/foo/SConscript30
-rw-r--r--modules/foo/foo.c6
-rw-r--r--modules/foo/foo.ld25
-rw-r--r--pxelinux.cfg/default2
6 files changed, 68 insertions, 2 deletions
diff --git a/SConstruct b/SConstruct
index 14654ba..aa24516 100644
--- a/SConstruct
+++ b/SConstruct
@@ -8,10 +8,12 @@ Export('env')
env.SConscript('kernel/SConscript')
+env.SConscript('modules/SConscript')
+
env.SConscript('floppy/SConscript')
#env.Command('qemu', 'floppy/floppy.img', 'qemu -s -m 32 -fda $SOURCE')
-env.Command('qemu', 'kernel', 'qemu -s -m 32 -boot n -tftp . -bootp /pxelinux.0')
+env.Command('qemu', ['kernel', 'modules'], 'qemu -s -m 32 -boot n -tftp . -bootp /pxelinux.0')
Default('kernel')
diff --git a/modules/SConscript b/modules/SConscript
new file mode 100644
index 0000000..b8d7846
--- /dev/null
+++ b/modules/SConscript
@@ -0,0 +1,3 @@
+Import('env')
+
+env.SConscript('foo/SConscript') \ No newline at end of file
diff --git a/modules/foo/SConscript b/modules/foo/SConscript
new file mode 100644
index 0000000..a79de34
--- /dev/null
+++ b/modules/foo/SConscript
@@ -0,0 +1,30 @@
+Import('env')
+
+env = env.Clone(
+ CC = 'i386-elf-gcc',
+ CCFLAGS = '-Wall -W -nostdinc -fno-builtin -fno-hosted -ggdb -std=gnu99',
+ LINK = 'i386-elf-ld',
+ LINKFLAGS = '-nostdinc -nostdlib',
+)
+
+def kernel_bld_generator(source, target, env, for_signature):
+ link_script = None
+ for s in source:
+ if s.suffix == '.ld':
+ link_script = s
+ break
+ if not link_script:
+ Exit(1)
+ return '$LINK $LINKFLAGS -o %s -T %s %s ' % (target[0], link_script, ' '.join(str(s) for s in source if s != link_script))
+
+kernel_bld = Builder(
+ generator = kernel_bld_generator,
+ suffix = '',
+ src_suffix = '.o',
+ src_builder = 'Object',
+ target_scanner = ProgramScanner
+)
+
+env.Append(BUILDERS = {'Kernel' : kernel_bld})
+
+kernel = env.Kernel('foo', ['foo.ld', 'foo.c'])
diff --git a/modules/foo/foo.c b/modules/foo/foo.c
new file mode 100644
index 0000000..ca0961d
--- /dev/null
+++ b/modules/foo/foo.c
@@ -0,0 +1,6 @@
+void entry() {
+ while(1) {
+ //asm volatile("hlt");
+ *(short*)(0xb8888) += 1;
+ }
+}
diff --git a/modules/foo/foo.ld b/modules/foo/foo.ld
new file mode 100644
index 0000000..cea3a32
--- /dev/null
+++ b/modules/foo/foo.ld
@@ -0,0 +1,25 @@
+OUTPUT_ARCH("i386")
+OUTPUT_FORMAT("binary")
+ENTRY(entry)
+
+addr_phys = 0x0010a000;
+
+SECTIONS {
+ .text addr_phys : {
+ *(.text)
+ *(.rodata*)
+ }
+
+ . = ALIGN(0x1000);
+ .data : {
+ *(.data)
+ *(.ctors)
+ }
+
+ . = ALIGN(0x1000);
+ .bss : {
+ *(.bss)
+ *(COMMON)
+ }
+
+}
diff --git a/pxelinux.cfg/default b/pxelinux.cfg/default
index b39e4c7..37344bf 100644
--- a/pxelinux.cfg/default
+++ b/pxelinux.cfg/default
@@ -1,4 +1,4 @@
default potetmos
label potetmos
kernel mboot.c32
-append kernel/kernel
+append kernel/kernel --- modules/foo/foo