All of lore.kernel.org
 help / color / mirror / Atom feed
From: ramsdell@mitre.org (John D. Ramsdell)
To: xen-devel@lists.xensource.com
Subject: [PATCH] Integrating applications into Mini-OS
Date: 11 May 2006 12:34:49 -0400	[thread overview]
Message-ID: <ogtslngh652.fsf@divan.mitre.org> (raw)

I sent this patch directly to Gregor, and neglected to CC this list.
Sorry about that.

I'd like to make it so that there is no need to modify any Mini-OS
source files when extending it with an application.  All that is
required is a change to Makefile, and a small change to kernel.c,
printf.c, and string.c.  I have enclosed the patch.

With this patch, one could write an application in a file called, say,
app.c, and add it to the Mini-OS directory along with newlib.c and
setjmp_x86_32.S, the two files I use to adapt newlib to the Mini-OS
environment.  One would compile and link it with newlib, with the
command:

#! /bin/sh
COMP_HOME=${HOME}/opt/cross/i386-elf
CPPFLAGS="-DINIT_APP -DHAVE_LIBC"
LDLIBS="-lc -lnosys"
export PATH=${COMP_HOME}/bin:$PATH 
exec make CPPFLAGS="${CPPFLAGS}" LDLIBS="${LDLIBS}" "$@"

The patch changes Makefile so that it needs no modification to
handle an application.  It also fixes some problems with the original
Makefile.  The original defined LDFLAGS, but did not use the
definition in the linker command.  There was some odd whitespace
after the last update to OBJS, which has been removed.  I also changed
the rules for compiling C and assembler files, so they more closely
match the default rules built into GNU Make.

John

Only in xen-unstable/extras/mini-os: app.c
Only in xen-unstable/extras/mini-os: app.h
Only in xen-unstable/extras/mini-os: app.lua
Only in xen-unstable/extras/mini-os: bin2c
Only in xen-unstable/extras/mini-os: bin2c.mk
Only in xen-unstable/extras/mini-os: crmake
diff -ur oxen-unstable/extras/mini-os/kernel.c xen-unstable/extras/mini-os/kernel.c
--- oxen-unstable/extras/mini-os/kernel.c	2006-05-09 00:51:19.000000000 -0400
+++ xen-unstable/extras/mini-os/kernel.c	2006-05-09 08:18:33.000000000 -0400
@@ -38,6 +38,10 @@
 #include <xen/features.h>
 #include <xen/version.h>
 
+#if defined INIT_APP
+    void init_app(void);
+#endif
+
 /*
  * Shared page for communicating with the hypervisor.
  * Events flags go here, for example.
@@ -171,6 +175,10 @@
     /* Init XenBus from a separate thread */
     create_thread("init_xs", init_xs, NULL);
 
+#if defined INIT_APP
+    init_app();
+#endif
+
     /* Everything initialised, start idle thread */
     run_idle_thread();
 }
diff -ur oxen-unstable/extras/mini-os/lib/printf.c xen-unstable/extras/mini-os/lib/printf.c
--- oxen-unstable/extras/mini-os/lib/printf.c	2006-05-09 00:51:19.000000000 -0400
+++ xen-unstable/extras/mini-os/lib/printf.c	2006-05-09 08:33:17.000000000 -0400
@@ -54,6 +54,8 @@
  * $FreeBSD: src/sys/libkern/divdi3.c,v 1.6 1999/08/28 00:46:31 peter Exp $
  */
 
+#if !defined HAVE_LIBC
+
 #include <os.h>
 #include <types.h>
 #include <hypervisor.h>
@@ -789,4 +791,4 @@
 	return i;
 }
 
-
+#endif
Only in xen-unstable/extras/mini-os/lib: printf.c~
diff -ur oxen-unstable/extras/mini-os/lib/string.c xen-unstable/extras/mini-os/lib/string.c
--- oxen-unstable/extras/mini-os/lib/string.c	2006-05-09 00:51:19.000000000 -0400
+++ xen-unstable/extras/mini-os/lib/string.c	2006-05-09 08:33:01.000000000 -0400
@@ -18,6 +18,8 @@
  ****************************************************************************
  */
 
+#if !defined HAVE_LIBC
+
 #include <os.h>
 #include <types.h>
 #include <lib.h>
@@ -153,3 +155,5 @@
         }
         return NULL;
 }
+
+#endif
Only in xen-unstable/extras/mini-os/lib: string.c~
diff -ur oxen-unstable/extras/mini-os/Makefile xen-unstable/extras/mini-os/Makefile
--- oxen-unstable/extras/mini-os/Makefile	2006-05-09 00:51:18.000000000 -0400
+++ xen-unstable/extras/mini-os/Makefile	2006-05-09 08:03:47.000000000 -0400
@@ -6,18 +6,23 @@
 override TARGET_ARCH     := $(XEN_TARGET_ARCH)
 
 # NB. '-Wcast-qual' is nasty, so I omitted it.
-CFLAGS := -fno-builtin -Wall -Werror -Iinclude/ -Wredundant-decls -Wno-format
+CFLAGS := -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format
 CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline
 
+override CPPFLAGS := -Iinclude $(CPPFLAGS)
+ASFLAGS = -D__ASSEMBLY__
+
+LDFLAGS := -N -T minios-$(TARGET_ARCH).lds
+
 ifeq ($(TARGET_ARCH),x86_32)
 CFLAGS += -m32 -march=i686
-LDFLAGS := -m elf_i386
+LDFLAGS += -m elf_i386
 endif
 
 ifeq ($(TARGET_ARCH),x86_64)
 CFLAGS += -m64 -mno-red-zone -fpic -fno-reorder-blocks
 CFLAGS += -fno-asynchronous-unwind-tables
-LDFLAGS := -m elf_x86_64
+LDFLAGS += -m elf_x86_64
 endif
 
 ifeq ($(debug),y)
@@ -28,12 +33,12 @@
 
 TARGET := mini-os
 
-OBJS := $(TARGET_ARCH).o
+OBJS := $(patsubst %.S,%.o,$(wildcard *$(TARGET_ARCH).S))
 OBJS += $(patsubst %.c,%.o,$(wildcard *.c))
 OBJS += $(patsubst %.c,%.o,$(wildcard lib/*.c))
 OBJS += $(patsubst %.c,%.o,$(wildcard xenbus/*.c))
 OBJS += $(patsubst %.c,%.o,$(wildcard console/*.c))
-										   
+
 HDRS := $(wildcard include/*.h)
 HDRS += $(wildcard include/xen/*.h)
 
@@ -45,7 +50,7 @@
 	[ -e include/xen ] || ln -sf ../../../xen/include/public include/xen
 
 $(TARGET): links $(OBJS)
-	$(LD) -N -T minios-$(TARGET_ARCH).lds $(OBJS) -o $@.elf
+	$(LD) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $@.elf
 	gzip -f -9 -c $@.elf >$@.gz
 
 .PHONY: clean
@@ -55,10 +60,10 @@
 	find . -type l | xargs rm -f
 
 %.o: %.c $(HDRS) Makefile
-	$(CC) $(CFLAGS) -c $< -o $@
+	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
 
 %.o: %.S $(HDRS) Makefile
-	$(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $@
+	$(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@
 
 define all_sources
      ( find . -follow -name SCCS -prune -o -name '*.[chS]' -print )
Only in xen-unstable/extras/mini-os: newlib.c
Only in xen-unstable/extras/mini-os: setjmp_x86_32.S

             reply	other threads:[~2006-05-11 16:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-11 16:34 John D. Ramsdell [this message]
2006-05-15 12:18 ` [PATCH] Integrating applications into Mini-OS Jacob Gorm Hansen
2006-05-15 12:46   ` Ian Campbell
2006-05-15 13:08     ` Jacob Gorm Hansen
2006-05-15 13:20       ` Jacob Gorm Hansen
     [not found]       ` <ogtpsifqtkz.fsf@divan.mitre.org>
2006-05-15 14:40         ` Jacob Gorm Hansen
2006-05-15 14:45           ` John D. Ramsdell
2006-05-15 15:09           ` John D. Ramsdell
2006-05-15 15:15             ` Jacob Gorm Hansen
2006-05-15 13:45   ` John D. Ramsdell
  -- strict thread matches above, loose matches on Subject: below --
2006-05-15 13:33 Puthiyaparambil, Aravindh
2006-05-15 14:12 ` Jacob Gorm Hansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ogtslngh652.fsf@divan.mitre.org \
    --to=ramsdell@mitre.org \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.