-DEPS = kbd vga io
+DEPS = kbd vga io test
PHONY = $(DEPS) clean
OUTPUT = initfs.a
INCLUDES = -I.. -I../include
io.ko: io
-$(OUTPUT): initfs.o kbd.ko vga.ko io.ko
+test.ko: test
+
+$(OUTPUT): initfs.o kbd.ko vga.ko io.ko test.ko
ar -rc $@ $^
updateinitfs:
extern const unsigned long _binary_io_size;
#endif /* FEATURE(VGA) */
+extern const char _binary_test_end[];
+extern const char _binary_test_start[];
+extern const unsigned long _binary_test_size;
+
static struct initfs_entry _ifs_entries[] = {
#if FEATURE(IO)
{
.ife_limit = (unsigned long)&_binary_vga_size
},
#endif /* FEATURE(VGA) */
+ {
+ .ife_name = "test",
+ .ife_base = &_binary_test_start,
+ .ife_limit = (unsigned long)&_binary_test_size
+ }
};
struct initfs initfs = {
--- /dev/null
+OBJECTS = main.o
+OUTPUT = test
+MODULE = test.ko
+
+INCLUDES = -I../../include -I../..
+CFLAGS = -m32 -Wall -nostdlib -nodefaultlibs -nostartfiles -ffreestanding \
+ -nostdinc -fno-builtin -fno-builtin-memcpy
+LIBS = ../../libc/libc.a
+CFLAGS += $(INCLUDES)
+
+ASFLAGS = $(CFLAGS)
+PHONY = clean
+
+all: $(MODULE)
+
+$(MODULE): $(OUTPUT)
+ ld -r --oformat=elf32-i386 -m elf_i386 -b binary -o $@ $<
+ cp $@ ../
+
+$(OUTPUT): $(OBJECTS)
+ gcc -static $(CFLAGS) -o $@ $^ $(LIBS)
+
+clean:
+ rm -f $(OBJECTS) $(OUTPUT)
+
+.PHONY: $(PHONY)
--- /dev/null
+#include <unistd.h>
+#include <crxstd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+ char buf[128];
+ int fds[2];
+ int ret_val;
+ void *abuf;
+ void *bbuf;
+ void *heap;
+
+ heap = sbrk(0);
+
+ ret_val = snprintf(buf, sizeof(buf), "Heap base: %p / 0x%08lx\n", heap, heap);
+ debug(buf, ret_val);
+
+ abuf = sbrk(2048);
+
+ ret_val = snprintf(buf, sizeof(buf), "Allocated 4096B at %p / 0x%08lx\n", abuf, abuf);
+ debug(buf, ret_val);
+
+ bbuf = malloc(4096);
+
+ ret_val = snprintf(buf, sizeof(buf), "Allocated 4096B at %p / 0x%08x\n", bbuf, buf);
+ debug(buf, ret_val);
+
+ ret_val = snprintf(buf, sizeof(buf), "Calling pipe()\n");
+ debug(buf, ret_val);
+
+ ret_val = pipe(fds);
+
+ ret_val = snprintf(buf, sizeof(buf), "pipe() returned %u\n", ret_val);
+ debug(buf, ret_val);
+
+ while(1) {
+ #if 0
+ struct cxmsg msg;
+
+ /* guaranteed to cause the process to be suspended */
+ cxrecv(PID_IO, &msg);
+ #endif
+ }
+
+ return(0);
+}