switch to autotools

This commit is contained in:
Stefan Lankes 2016-01-10 21:50:24 +01:00
parent 3cc46a34f1
commit 06d34e9b67
17 changed files with 12518 additions and 165 deletions

107
Makefile.example → Makefile.in Normal file → Executable file
View file

@ -1,34 +1,27 @@
TERM = xterm
TOPDIR = $(shell pwd)
ARCH = x86
TERM = xterm
BIT = 32
NAME = eduos
KERNDIRS = libkern kernel mm fs arch/$(ARCH)/kernel arch/$(ARCH)/mm
SUBDIRS = $(KERNDIRS)
# Set your own cross compiler tool chain prefix here
CROSSCOMPREFIX =
STACKPROT =
CC_FOR_TARGET = $(CROSSCOMPREFIX)gcc
CXX_FOR_TARGET = $(CROSSCOMPREFIX)g++
GCC_FOR_TARGET = $(CROSSCOMPREFIX)gcc
CPP_FOR_TARGET = $(CROSSCOMPREFIX)cpp
AR_FOR_TARGET = $(CROSSCOMPREFIX)ar
AS_FOR_TARGET = $(CROSSCOMPREFIX)as
LD_FOR_TARGET = $(CROSSCOMPREFIX)ld
NM_FOR_TARGET = $(CROSSCOMPREFIX)nm
OBJDUMP_FOR_TARGET = $(CROSSCOMPREFIX)objdump
OBJCOPY_FOR_TARGET = $(CROSSCOMPREFIX)objcopy
RANLIB_FOR_TARGET = $(CROSSCOMPREFIX)ranlib
STRIP_FOR_TARGET = $(CROSSCOMPREFIX)strip
READELF_FOR_TARGET = $(CROSSCOMPREFIX)readelf
MAKE = make
CC_FOR_TARGET = @CC_FOR_TARGET@
CXX_FOR_TARGET = @CXX_FOR_TARGET@
GCC_FOR_TARGET = @GCC_FOR_TARGET@
CPP_FOR_TARGET = @CPP_FOR_TARGET@
AR_FOR_TARGET = @AR_FOR_TARGET@
AS_FOR_TARGET = @AS_FOR_TARGET@
LD_FOR_TARGET = @LD_FOR_TARGET@
NM_FOR_TARGET = @NM_FOR_TARGET@
OBJDUMP_FOR_TARGET = @OBJDUMP_FOR_TARGET@
OBJCOPY_FOR_TARGET = @OBJCOPY_FOR_TARGET@
RANLIB_FOR_TARGET = @RANLIB_FOR_TARGET@
STRIP_FOR_TARGET = @STRIP_FOR_TARGET@
READELF_FOR_TARGET = @READELF_FOR_TARGET@
NASM = nasm
NASMFLAGS = -felf$(BIT) -g -i$(TOPDIR)/include/eduos/
GDB = $(CROSSCOMPREFIX)gdb
GDBFLAGS = -x debug.gdb
QEMU = qemu-system-i386
QEMUFLAGS = -smp 2 -monitor stdio \
-net nic,model=rtl8139 \
@ -39,11 +32,12 @@ QEMUDEBUGFLAGS = -monitor none -daemonize \
QEMUSERIALFLAGS = -device pci-serial,chardev=tS0 \
-chardev socket,host=localhost,port=4555,server,id=tS0
NASMFLAGS = -felf32 -g -i$(TOPDIR)/include/eduos/
INCLUDE = -I$(TOPDIR)/include -I$(TOPDIR)/arch/$(ARCH)/include
# Compiler options for final code
CFLAGS = -g -m32 -march=i586 -Wall -O2 -fno-builtin -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc $(INCLUDE) -fno-stack-protector
# Compiler options for debugging
debug debug-eclipse : CFLAGS = -g -O0 -m32 -march=i586 -Wall -fno-builtin -DWITH_FRAME_POINTER -nostdinc $(INCLUDE) -fno-stack-protector
#CFLAGS = -g -O -m32 -march=i586 -Wall -fno-builtin -DWITH_FRAME_POINTER -nostdinc $(INCLUDE) -fno-stack-protector
AR = ar
ARFLAGS = rsv
RM = rm -rf
@ -70,24 +64,21 @@ all: newlib tools $(NAME).elf
newlib:
$Q$(MAKE) ARCH=$(ARCH) BIT=$(BIT) \
LDFLAGS="$(LDFLAGS_FOR_NEWLIB)" \
CFLAGS="$(CFLAGS_FOR_NEWLIB)" \
NASMFLAGS="$(NASMFLAGS_FOR_NEWLIB)" \
CC_FOR_TARGET=$(CC_FOR_TARGET) \
CXX_FOR_TARGET=$(CXX_FOR_TARGET) \
GCC_FOR_TARGET=$(GCC_FOR_TARGET) \
AR_FOR_TARGET=$(AR_FOR_TARGET) \
AS_FOR_TARGET=$(AS_FOR_TARGET) \
LD_FOR_TARGET=$(LD_FOR_TARGET) \
NM_FOR_TARGET=$(NM_FOR_TARGET) \
OBJDUMP_FOR_TARGET=$(OBJDUMP_FOR_TARGET) \
OBJCOPY_FOR_TARGET=$(OBJCOPY_FOR_TARGET) \
RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET) \
STRIP_FOR_TARGET=$(STRIP_FOR_TARGET) \
READELF_FOR_TARGET=$(READELF_FOR_TARGET) -C newlib
tools:
$Q$(MAKE) ARCH=$(ARCH) BIT=$(BIT) CFLAGS="$(CFLAGS_FOR_TOOLS)" LDFLAGS="$(LDFLAGS_FOR_TOOLS)" -C tools
LDFLAGS="$(LDFLAGS_FOR_NEWLIB)" \
CFLAGS="$(CFLAGS_FOR_NEWLIB)" \
NASMFLAGS="$(NASMFLAGS_FOR_NEWLIB)" \
CC_FOR_TARGET=$(CC_FOR_TARGET) \
CXX_FOR_TARGET=$(CXX_FOR_TARGET) \
GCC_FOR_TARGET=$(GCC_FOR_TARGET) \
AR_FOR_TARGET=$(AR_FOR_TARGET) \
AS_FOR_TARGET=$(AS_FOR_TARGET) \
LD_FOR_TARGET=$(LD_FOR_TARGET) \
NM_FOR_TARGET=$(NM_FOR_TARGET) \
OBJDUMP_FOR_TARGET=$(OBJDUMP_FOR_TARGET) \
OBJCOPY_FOR_TARGET=$(OBJCOPY_FOR_TARGET) \
RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET) \
STRIP_FOR_TARGET=$(STRIP_FOR_TARGET) \
READELF_FOR_TARGET=$(READELF_FOR_TARGET) -C newlib
$(NAME).elf:
$Q$(LD_FOR_TARGET) $(LDFLAGS) -o $(NAME).elf $^
@ -96,14 +87,16 @@ $(NAME).elf:
@echo [OBJCOPY] $(NAME).elf
$Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $(NAME).elf
tools:
$Q$(MAKE) ARCH=$(ARCH) BIT=$(BIT) CFLAGS="$(CFLAGS_FOR_TOOLS)" LDFLAGS="$(LDFLAGS_FOR_TOOLS)" -C tools
clean:
$Q$(RM) $(NAME).elf $(NAME).sym *~
$Q$(MAKE) -C newlib clean
$Q$(MAKE) -C tools clean
@echo Cleaned.
veryclean:
$Q$(RM) $(NAME).elf $(NAME).sym *~
veryclean: clean
$Q$(RM) qemu-vlan0.pcap
$Q$(MAKE) -C newlib veryclean
$Q$(MAKE) -C tools veryclean
@ -113,19 +106,24 @@ qemu: $(NAME).elf
$(QEMU) $(QEMUFLAGS) -kernel $(NAME).elf -initrd tools/initrd.img
uart: $(NAME).elf
$(QEMU) $(QEMUFLAGS) $(QEMUSERIALFLAGS) -kernel $(NAME).elf -append uart=io:0xc110 -initrd tools/initrd.img
$(QEMU) $(QEMUFLAGS) $(QEMUSERIALFLAGS) -kernel $(NAME).elf -append uart=io:0xc110
debug: $(NAME).elf
$(TERM) -e $(GDB) $(GDBFLAGS) &
$(QEMU) $(QEMUDEBUGFLAGS) -s -S -kernel $(NAME).elf -initrd tools/initrd.img
debug-eclipse: clean $(NAME).elf
killall $(QEMU) &
( ( $(QEMU) $(QEMUDEBUGFLAGS) $(QEMUSERIALFLAGS) -s -S -kernel $(NAME).elf & ) & )
$(QEMU) $(QEMUDEBUGFLAGS) -s -S -kernel $(NAME).elf
doc:
@echo Create documentation...
@doxygen
@echo Create documentation...
test:
@echo "Nothing to test"
include/eduos/config.inc: include/eduos/config.h
@echo "; This file is generated automatically from the config.h file." > include/eduos/config.inc
@echo "; Before editing this, you should consider editing config.h." >> include/eduos/config.inc
@awk '/^#define KERNEL_STACK_SIZE/{ print "%define KERNEL_STACK_SIZE", $$3 }' include/eduos/config.h >> include/eduos/config.inc
@awk '/^#define VIDEO_MEM_ADDR/{ print "%define VIDEO_MEM_ADDR", $$3 }' include/eduos/stddef.h >> include/eduos/config.inc
%.o : %.c
@echo [CC] $@
@ -133,13 +131,6 @@ doc:
@echo [DEP] $*.dep
$Q$(CC_FOR_TARGET) -MF $*.dep -MT $*.o -MM $(CFLAGS) $<
include/eduos/config.inc: include/eduos/config.h
@echo "; This file is generated automatically from the config.h file." > include/eduos/config.inc
@echo "; Before editing this, you should consider editing config.h." >> include/eduos/config.inc
@awk '/^#define KERNEL_STACK_SIZE/{ print "%define KERNEL_STACK_SIZE", $$3 }' include/eduos/config.h >> include/eduos/config.inc
@awk '/^#define VIDEO_MEM_ADDR/{ print "%define VIDEO_MEM_ADDR", $$3 }' include/eduos/config.h >> include/eduos/config.inc
@awk '/^#define CONFIG_VGA/{ print "%define CONFIG_VGA" }' include/eduos/config.h >> include/eduos/config.inc
%.o : %.asm include/eduos/config.inc
@echo [ASM] $@
$Q$(NASM) $(NASMFLAGS) -o $@ $<
@ -148,6 +139,6 @@ include/eduos/config.inc: include/eduos/config.h
@echo [GCC-ASM] $@
$Q$(CC_FOR_TARGET) $(CFLAGS) -c -o $@ $<
.PHONY: default all clean emu gdb newlib tools
.PHONY: default all clean emu gdb newlib tools test
include $(addsuffix /Makefile,$(SUBDIRS))

View file

@ -40,13 +40,6 @@
#ifndef __PAGE_H__
#define __PAGE_H__
/// Page offset bits
#define PAGE_BITS 12
/// The size of a single page in bytes
#define PAGE_SIZE ( 1L << PAGE_BITS)
/// Mask the page address without page map flags
#define PAGE_MASK (-1L << PAGE_BITS)
/// Total operand width in bits
#define BITS 32
/// Linear/virtual address width

View file

@ -82,17 +82,16 @@ stublet:
global cpu_init
cpu_init:
; initialize page tables
%ifdef CONFIG_VGA
push edi
mov eax, VIDEO_MEM_ADDR
and eax, 0xFFFFF000 ; page align lower half
mov edi, eax
shr edi, 10 ; (edi >> 12) * 4 (index for boot_pgt)
add edi, boot_pgt
or eax, 0x113 ; set present, global, writable and cache disable bits
mov DWORD [edi], eax
pop edi
%endif
push edi
mov eax, VIDEO_MEM_ADDR
and eax, 0xFFFFF000 ; page align lower half
mov edi, eax
shr edi, 10 ; (edi >> 12) * 4 (index for boot_pgt)
add edi, boot_pgt
or eax, 0x113 ; set present, global, writable and cache disable bits
mov DWORD [edi], eax
pop edi
push edi
mov eax, DWORD [mb_info] ; map multiboot info
and eax, 0xFFFFF000 ; page align lower half

View file

@ -29,8 +29,6 @@
#include <asm/io.h>
#include <asm/vga.h>
#ifdef CONFIG_VGA
/*
* These define our textpointer, our background and foreground
* colors (attributes), and x and y cursor coordinates
@ -235,5 +233,3 @@ void vga_init(void)
textmemptr = (unsigned short *)VIDEO_MEM_ADDR;
vga_clear();
}
#endif

1421
config.guess vendored Executable file

File diff suppressed because it is too large Load diff

1807
config.sub vendored Executable file

File diff suppressed because it is too large Load diff

621
config/acx.m4 Executable file
View file

@ -0,0 +1,621 @@
# Autoconf M4 include file defining utility macros for complex Canadian
# cross builds.
dnl ####
dnl # _GCC_TOPLEV_NONCANONICAL_BUILD
dnl # $build_alias or canonical $build if blank.
dnl # Used when we would use $build_alias, but empty is not OK.
AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_BUILD],
[AC_REQUIRE([AC_CANONICAL_BUILD]) []dnl
case ${build_alias} in
"") build_noncanonical=${build} ;;
*) build_noncanonical=${build_alias} ;;
esac
]) []dnl # _GCC_TOPLEV_NONCANONICAL_BUILD
dnl ####
dnl # _GCC_TOPLEV_NONCANONICAL_HOST
dnl # $host_alias, or $build_noncanonical if blank.
dnl # Used when we would use $host_alias, but empty is not OK.
AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_HOST],
[AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_BUILD]) []dnl
case ${host_alias} in
"") host_noncanonical=${build_noncanonical} ;;
*) host_noncanonical=${host_alias} ;;
esac
]) []dnl # _GCC_TOPLEV_NONCANONICAL_HOST
dnl ####
dnl # _GCC_TOPLEV_NONCANONICAL_TARGET
dnl # $target_alias or $host_noncanonical if blank.
dnl # Used when we would use $target_alias, but empty is not OK.
AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_TARGET],
[AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_HOST]) []dnl
case ${target_alias} in
"") target_noncanonical=${host_noncanonical} ;;
*) target_noncanonical=${target_alias} ;;
esac
]) []dnl # _GCC_TOPLEV_NONCANONICAL_TARGET
dnl ####
dnl # ACX_NONCANONICAL_BUILD
dnl # Like underscored version, but AC_SUBST's.
AC_DEFUN([ACX_NONCANONICAL_BUILD],
[AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_BUILD]) []dnl
AC_SUBST(build_noncanonical)
]) []dnl # ACX_NONCANONICAL_BUILD
dnl ####
dnl # ACX_NONCANONICAL_HOST
dnl # Like underscored version, but AC_SUBST's.
AC_DEFUN([ACX_NONCANONICAL_HOST],
[AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_HOST]) []dnl
AC_SUBST(host_noncanonical)
]) []dnl # ACX_NONCANONICAL_HOST
dnl ####
dnl # ACX_NONCANONICAL_TARGET
dnl # Like underscored version, but AC_SUBST's.
AC_DEFUN([ACX_NONCANONICAL_TARGET],
[AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_TARGET]) []dnl
AC_SUBST(target_noncanonical)
]) []dnl # ACX_NONCANONICAL_TARGET
dnl ####
dnl # GCC_TOPLEV_SUBDIRS
dnl # GCC & friends build 'build', 'host', and 'target' tools. These must
dnl # be separated into three well-known subdirectories of the build directory:
dnl # build_subdir, host_subdir, and target_subdir. The values are determined
dnl # here so that they can (theoretically) be changed in the future. They
dnl # were previously reproduced across many different files.
dnl #
dnl # This logic really amounts to very little with autoconf 2.13; it will
dnl # amount to a lot more with autoconf 2.5x.
AC_DEFUN([GCC_TOPLEV_SUBDIRS],
[AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_TARGET]) []dnl
AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_BUILD]) []dnl
# post-stage1 host modules use a different CC_FOR_BUILD so, in order to
# have matching libraries, they should use host libraries: Makefile.tpl
# arranges to pass --with-build-libsubdir=$(HOST_SUBDIR).
# However, they still use the build modules, because the corresponding
# host modules (e.g. bison) are only built for the host when bootstrap
# finishes. So:
# - build_subdir is where we find build modules, and never changes.
# - build_libsubdir is where we find build libraries, and can be overridden.
# Prefix 'build-' so this never conflicts with target_subdir.
build_subdir="build-${build_noncanonical}"
AC_ARG_WITH(build-libsubdir,
[ --with-build-libsubdir=[DIR] Directory where to find libraries for build system],
build_libsubdir="$withval",
build_libsubdir="$build_subdir")
# --srcdir=. covers the toplevel, while "test -d" covers the subdirectories
if ( test $srcdir = . && test -d gcc ) \
|| test -d $srcdir/../host-${host_noncanonical}; then
host_subdir="host-${host_noncanonical}"
else
host_subdir=.
fi
# No prefix.
target_subdir=${target_noncanonical}
AC_SUBST([build_libsubdir]) []dnl
AC_SUBST([build_subdir]) []dnl
AC_SUBST([host_subdir]) []dnl
AC_SUBST([target_subdir]) []dnl
]) []dnl # GCC_TOPLEV_SUBDIRS
####
# _NCN_TOOL_PREFIXES: Some stuff that oughtta be done in AC_CANONICAL_SYSTEM
# or AC_INIT.
# These demand that AC_CANONICAL_SYSTEM be called beforehand.
AC_DEFUN([_NCN_TOOL_PREFIXES],
[ncn_tool_prefix=
test -n "$host_alias" && ncn_tool_prefix=$host_alias-
ncn_target_tool_prefix=
test -n "$target_alias" && ncn_target_tool_prefix=$target_alias-
]) []dnl # _NCN_TOOL_PREFIXES
####
# NCN_STRICT_CHECK_TOOLS(variable, progs-to-check-for,[value-if-not-found],[path])
# Like plain AC_CHECK_TOOLS, but require prefix if build!=host.
AC_DEFUN([NCN_STRICT_CHECK_TOOLS],
[AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
AC_ARG_VAR([$1], [$1 for the host])
if test -n "[$]$1"; then
ac_cv_prog_$1=[$]$1
elif test -n "$ac_cv_prog_$1"; then
$1=$ac_cv_prog_$1
fi
if test -n "$ac_cv_prog_$1"; then
for ncn_progname in $2; do
AC_CHECK_PROG([$1], [${ncn_progname}], [${ncn_progname}], , [$4])
done
fi
for ncn_progname in $2; do
if test -n "$ncn_tool_prefix"; then
AC_CHECK_PROG([$1], [${ncn_tool_prefix}${ncn_progname}],
[${ncn_tool_prefix}${ncn_progname}], , [$4])
fi
if test -z "$ac_cv_prog_$1" && test $build = $host ; then
AC_CHECK_PROG([$1], [${ncn_progname}], [${ncn_progname}], , [$4])
fi
test -n "$ac_cv_prog_$1" && break
done
if test -z "$ac_cv_prog_$1" ; then
ifelse([$3],[], [set dummy $2
if test $build = $host ; then
$1="[$]2"
else
$1="${ncn_tool_prefix}[$]2"
fi], [$1="$3"])
fi
]) []dnl # NCN_STRICT_CHECK_TOOLS
####
# NCN_STRICT_CHECK_TARGET_TOOLS(variable, progs-to-check-for,[value-if-not-found],[path])
# Like CVS Autoconf AC_CHECK_TARGET_TOOLS, but require prefix if build!=target.
AC_DEFUN([NCN_STRICT_CHECK_TARGET_TOOLS],
[AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
AC_ARG_VAR([$1], patsubst([$1], [_FOR_TARGET$], [])[ for the target])
if test -n "[$]$1"; then
ac_cv_prog_$1=[$]$1
elif test -n "$ac_cv_prog_$1"; then
$1=$ac_cv_prog_$1
fi
if test -n "$ac_cv_prog_$1"; then
for ncn_progname in $2; do
AC_CHECK_PROG([$1], [${ncn_progname}], [${ncn_progname}], , [$4])
done
fi
if test -z "$ac_cv_prog_$1" && test -n "$with_build_time_tools"; then
for ncn_progname in $2; do
AC_MSG_CHECKING([for ${ncn_progname} in $with_build_time_tools])
if test -x $with_build_time_tools/${ncn_progname}; then
ac_cv_prog_$1=$with_build_time_tools/${ncn_progname}
AC_MSG_RESULT(yes)
break
else
AC_MSG_RESULT(no)
fi
done
fi
if test -z "$ac_cv_prog_$1"; then
for ncn_progname in $2; do
if test -n "$ncn_target_tool_prefix"; then
AC_CHECK_PROG([$1], [${ncn_target_tool_prefix}${ncn_progname}],
[${ncn_target_tool_prefix}${ncn_progname}], , [$4])
fi
if test -z "$ac_cv_prog_$1" && test $build = $target ; then
AC_CHECK_PROG([$1], [${ncn_progname}], [${ncn_progname}], , [$4])
fi
test -n "$ac_cv_prog_$1" && break
done
fi
if test -z "$ac_cv_prog_$1" ; then
ifelse([$3],[], [set dummy $2
if test $build = $target ; then
$1="[$]2"
else
$1="${ncn_target_tool_prefix}[$]2"
fi], [$1="$3"])
else
$1="$ac_cv_prog_$1"
fi
]) []dnl # NCN_STRICT_CHECK_TARGET_TOOLS
# Backported from Autoconf 2.5x; can go away when and if
# we switch. Put the OS path separator in $PATH_SEPARATOR.
AC_DEFUN([ACX_PATH_SEP], [
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
echo "#! /bin/sh" >conf$$.sh
echo "exit 0" >>conf$$.sh
chmod +x conf$$.sh
if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
PATH_SEPARATOR=';'
else
PATH_SEPARATOR=:
fi
rm -f conf$$.sh
fi
])
AC_DEFUN([ACX_TOOL_DIRS], [
AC_REQUIRE([ACX_PATH_SEP])
if test "x$exec_prefix" = xNONE; then
if test "x$prefix" = xNONE; then
gcc_cv_tool_prefix=$ac_default_prefix
else
gcc_cv_tool_prefix=$prefix
fi
else
gcc_cv_tool_prefix=$exec_prefix
fi
# If there is no compiler in the tree, use the PATH only. In any
# case, if there is no compiler in the tree nobody should use
# AS_FOR_TARGET and LD_FOR_TARGET.
if test x$host = x$build && test -f $srcdir/gcc/BASE-VER; then
gcc_version=`cat $srcdir/gcc/BASE-VER`
gcc_cv_tool_dirs="$gcc_cv_tool_prefix/libexec/gcc/$target_noncanonical/$gcc_version$PATH_SEPARATOR"
gcc_cv_tool_dirs="$gcc_cv_tool_dirs$gcc_cv_tool_prefix/libexec/gcc/$target_noncanonical$PATH_SEPARATOR"
gcc_cv_tool_dirs="$gcc_cv_tool_dirs/usr/lib/gcc/$target_noncanonical/$gcc_version$PATH_SEPARATOR"
gcc_cv_tool_dirs="$gcc_cv_tool_dirs/usr/lib/gcc/$target_noncanonical$PATH_SEPARATOR"
gcc_cv_tool_dirs="$gcc_cv_tool_dirs$gcc_cv_tool_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version$PATH_SEPARATOR"
gcc_cv_tool_dirs="$gcc_cv_tool_dirs$gcc_cv_tool_prefix/$target_noncanonical/bin$PATH_SEPARATOR"
else
gcc_cv_tool_dirs=
fi
if test x$build = x$target && test -n "$md_exec_prefix"; then
gcc_cv_tool_dirs="$gcc_cv_tool_dirs$md_exec_prefix$PATH_SEPARATOR"
fi
]) []dnl # ACX_TOOL_DIRS
# ACX_HAVE_GCC_FOR_TARGET
# Check if the variable GCC_FOR_TARGET really points to a GCC binary.
AC_DEFUN([ACX_HAVE_GCC_FOR_TARGET], [
cat > conftest.c << \EOF
#ifdef __GNUC__
gcc_yay;
#endif
EOF
if ($GCC_FOR_TARGET -E conftest.c | grep gcc_yay) > /dev/null 2>&1; then
have_gcc_for_target=yes
else
GCC_FOR_TARGET=${ncn_target_tool_prefix}gcc
have_gcc_for_target=no
fi
rm conftest.c
])
# ACX_CHECK_INSTALLED_TARGET_TOOL(VAR, PROG)
# Searching for installed target binutils. We need to take extra care,
# else we may find the wrong assembler, linker, etc., and lose.
#
# First try --with-build-time-tools, if specified.
#
# For build != host, we ask the installed GCC for the name of the tool it
# uses, and accept it if it is an absolute path. This is because the
# only good choice for a compiler is the same GCC version that is being
# installed (or we couldn't make target libraries), and we assume that
# on the host system we'll have not only the same GCC version, but also
# the same binutils version.
#
# For build == host, search the same directories that the installed
# compiler will search. We used to do this for the assembler, linker,
# and nm only; for simplicity of configuration, however, we extend this
# criterion to tools (such as ar and ranlib) that are never invoked by
# the compiler, to avoid mismatches.
#
# Also note we have to check MD_EXEC_PREFIX before checking the user's path
# if build == target. This makes the most sense only when bootstrapping,
# but we also do so when build != host. In this case, we hope that the
# build and host systems will have similar contents of MD_EXEC_PREFIX.
#
# If we do not find a suitable binary, then try the user's path.
AC_DEFUN([ACX_CHECK_INSTALLED_TARGET_TOOL], [
AC_REQUIRE([ACX_TOOL_DIRS])
AC_REQUIRE([ACX_HAVE_GCC_FOR_TARGET])
if test -z "$ac_cv_path_$1" ; then
if test -n "$with_build_time_tools"; then
AC_MSG_CHECKING([for $2 in $with_build_time_tools])
if test -x $with_build_time_tools/$2; then
$1=`cd $with_build_time_tools && pwd`/$2
ac_cv_path_$1=[$]$1
AC_MSG_RESULT([$ac_cv_path_$1])
else
AC_MSG_RESULT(no)
fi
elif test $build != $host && test $have_gcc_for_target = yes; then
$1=`$GCC_FOR_TARGET --print-prog-name=$2`
test [$]$1 = $2 && $1=
test -n "[$]$1" && ac_cv_path_$1=[$]$1
fi
fi
if test -z "$ac_cv_path_$1" && test -n "$gcc_cv_tool_dirs"; then
AC_PATH_PROG([$1], [$2], [], [$gcc_cv_tool_dirs])
fi
if test -z "$ac_cv_path_$1" ; then
NCN_STRICT_CHECK_TARGET_TOOLS([$1], [$2])
else
$1=$ac_cv_path_$1
fi
]) []dnl # ACX_CHECK_INSTALLED_TARGET_TOOL
###
# AC_PROG_CPP_WERROR
# Used for autoconf 2.5x to force AC_PREPROC_IFELSE to reject code which
# triggers warnings from the preprocessor. Will be in autoconf 2.58.
# For now, using this also overrides header checks to use only the
# preprocessor (matches 2.13 behavior; matching 2.58's behavior is a
# bit harder from here).
# Eventually autoconf will default to checking headers with the compiler
# instead, and we'll have to do this differently.
AC_DEFUN([AC_PROG_CPP_WERROR],
[AC_REQUIRE([AC_PROG_CPP])dnl
m4_define([AC_CHECK_HEADER],m4_defn([_AC_CHECK_HEADER_OLD]))
ac_c_preproc_warn_flag=yes])# AC_PROG_CPP_WERROR
# Test for GNAT.
# We require the gnatbind & gnatmake programs, as well as a compiler driver
# that understands Ada. We use the user's CC setting, already found, and
# possibly add $1 to the command-line parameters.
#
# Sets the shell variable have_gnat to yes or no as appropriate, and
# substitutes GNATBIND and GNATMAKE.
AC_DEFUN([ACX_PROG_GNAT],
[AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
AC_REQUIRE([AC_PROG_CC])
AC_CHECK_TOOL(GNATBIND, gnatbind, no)
AC_CHECK_TOOL(GNATMAKE, gnatmake, no)
AC_CACHE_CHECK([whether compiler driver understands Ada],
acx_cv_cc_gcc_supports_ada,
[cat >conftest.adb <<EOF
procedure conftest is begin null; end conftest;
EOF
acx_cv_cc_gcc_supports_ada=no
# There is a bug in old released versions of GCC which causes the
# driver to exit successfully when the appropriate language module
# has not been installed. This is fixed in 2.95.4, 3.0.2, and 3.1.
# Therefore we must check for the error message as well as an
# unsuccessful exit.
# Other compilers, like HP Tru64 UNIX cc, exit successfully when
# given a .adb file, but produce no object file. So we must check
# if an object file was really produced to guard against this.
errors=`(${CC} $1[]m4_ifval([$1], [ ])-c conftest.adb) 2>&1 || echo failure`
if test x"$errors" = x && test -f conftest.$ac_objext; then
acx_cv_cc_gcc_supports_ada=yes
fi
rm -f conftest.*])
if test "x$GNATBIND" != xno && test "x$GNATMAKE" != xno && test x$acx_cv_cc_gcc_supports_ada != xno; then
have_gnat=yes
else
have_gnat=no
fi
])
dnl 'make compare' can be significantly faster, if cmp itself can
dnl skip bytes instead of using tail. The test being performed is
dnl "if cmp --ignore-initial=2 t1 t2 && ! cmp --ignore-initial=1 t1 t2"
dnl but we need to sink errors and handle broken shells. We also test
dnl for the parameter format "cmp file1 file2 skip1 skip2" which is
dnl accepted by cmp on some systems.
AC_DEFUN([ACX_PROG_CMP_IGNORE_INITIAL],
[AC_CACHE_CHECK([how to compare bootstrapped objects], gcc_cv_prog_cmp_skip,
[ echo abfoo >t1
echo cdfoo >t2
gcc_cv_prog_cmp_skip='tail +16c $$f1 > tmp-foo1; tail +16c $$f2 > tmp-foo2; cmp tmp-foo1 tmp-foo2'
if cmp t1 t2 2 2 > /dev/null 2>&1; then
if cmp t1 t2 1 1 > /dev/null 2>&1; then
:
else
gcc_cv_prog_cmp_skip='cmp $$f1 $$f2 16 16'
fi
fi
if cmp --ignore-initial=2 t1 t2 > /dev/null 2>&1; then
if cmp --ignore-initial=1 t1 t2 > /dev/null 2>&1; then
:
else
gcc_cv_prog_cmp_skip='cmp --ignore-initial=16 $$f1 $$f2'
fi
fi
rm t1 t2
])
do_compare="$gcc_cv_prog_cmp_skip"
AC_SUBST(do_compare)
])
dnl See whether we can include both string.h and strings.h.
AC_DEFUN([ACX_HEADER_STRING],
[AC_CACHE_CHECK([whether string.h and strings.h may both be included],
gcc_cv_header_string,
[AC_TRY_COMPILE([#include <string.h>
#include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
if test $gcc_cv_header_string = yes; then
AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
fi
])
dnl See if stdbool.h properly defines bool and true/false.
dnl Check whether _Bool is built-in.
AC_DEFUN([ACX_HEADER_STDBOOL],
[AC_CACHE_CHECK([for working stdbool.h],
ac_cv_header_stdbool_h,
[AC_TRY_COMPILE([#include <stdbool.h>],
[bool foo = false;],
ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
if test $ac_cv_header_stdbool_h = yes; then
AC_DEFINE(HAVE_STDBOOL_H, 1,
[Define if you have a working <stdbool.h> header file.])
fi
AC_CACHE_CHECK(for built-in _Bool, gcc_cv_c__bool,
[AC_TRY_COMPILE(,
[_Bool foo;],
gcc_cv_c__bool=yes, gcc_cv_c__bool=no)
])
if test $gcc_cv_c__bool = yes; then
AC_DEFINE(HAVE__BOOL, 1, [Define if the \`_Bool' type is built-in.])
fi
])
dnl See if hard links work and if not, try to substitute $1 or simple copy.
AC_DEFUN([ACX_PROG_LN],
[AC_MSG_CHECKING(whether ln works)
AC_CACHE_VAL(acx_cv_prog_LN,
[rm -f conftestdata_t
echo >conftestdata_f
if ln conftestdata_f conftestdata_t 2>/dev/null
then
acx_cv_prog_LN=ln
else
acx_cv_prog_LN=no
fi
rm -f conftestdata_f conftestdata_t
])dnl
if test $acx_cv_prog_LN = no; then
LN="ifelse([$1],,cp,[$1])"
AC_MSG_RESULT([no, using $LN])
else
LN="$acx_cv_prog_LN"
AC_MSG_RESULT(yes)
fi
AC_SUBST(LN)dnl
])
dnl GCC_TARGET_TOOL(PROGRAM, TARGET-VAR, HOST-VAR, IN-TREE-TOOL, LANGUAGE)
AC_DEFUN([GCC_TARGET_TOOL],
[AC_MSG_CHECKING(where to find the target $1)
if test "x${build}" != "x${host}" ; then
if expr "x[$]$2" : "x/" > /dev/null; then
# We already found the complete path
ac_dir=`dirname [$]$2`
AC_MSG_RESULT(pre-installed in $ac_dir)
else
# Canadian cross, just use what we found
AC_MSG_RESULT(pre-installed)
fi
else
ifelse([$4],,,
[ok=yes
case " ${configdirs} " in
*" patsubst([$4], [/.*], []) "*) ;;
*) ok=no ;;
esac
ifelse([$5],,,
[case ,${enable_languages}, in
*,$5,*) ;;
*) ok=no ;;
esac])
if test $ok = yes; then
# An in-tree tool is available and we can use it
$2='$$r/$(HOST_SUBDIR)/$4'
AC_MSG_RESULT(just compiled)
el])if expr "x[$]$2" : "x/" > /dev/null; then
# We already found the complete path
ac_dir=`dirname [$]$2`
AC_MSG_RESULT(pre-installed in $ac_dir)
elif test "x$target" = "x$host"; then
# We can use an host tool
$2='$($3)'
AC_MSG_RESULT(host tool)
else
# We need a cross tool
AC_MSG_RESULT(pre-installed)
fi
fi
AC_SUBST($2)])
dnl Locate a program and check that its version is acceptable.
dnl ACX_PROG_CHECK_VER(var, name, version-switch,
dnl version-extract-regexp, version-glob)
AC_DEFUN([ACX_CHECK_PROG_VER],[
AC_CHECK_PROG([$1], [$2], [$2])
if test -n "[$]$1"; then
# Found it, now check the version.
AC_CACHE_CHECK([for modern $2],
[gcc_cv_prog_$2_modern],
[ac_prog_version=`eval [$]$1 $3 2>&1 |
sed -n 's/^.*patsubst([[$4]],/,\/).*$/\1/p'`
[case $ac_prog_version in
'') gcc_cv_prog_$2_modern=no;;
$5) gcc_cv_prog_$2_modern=yes;;
*) gcc_cv_prog_$2_modern=no;;
esac]
])
else
gcc_cv_prog_$2_modern=no
fi
if test $gcc_cv_prog_$2_modern = no; then
$1="${CONFIG_SHELL-/bin/sh} $ac_aux_dir/missing $2"
fi
])
dnl Support the --with-pkgversion configure option.
dnl ACX_PKGVERSION(default-pkgversion)
AC_DEFUN([ACX_PKGVERSION],[
AC_ARG_WITH(pkgversion,
AS_HELP_STRING([--with-pkgversion=PKG],
[Use PKG in the version string in place of "$1"]),
[case "$withval" in
yes) AC_MSG_ERROR([package version not specified]) ;;
no) PKGVERSION= ;;
*) PKGVERSION="($withval) " ;;
esac],
PKGVERSION="($1) "
)
AC_SUBST(PKGVERSION)
])
dnl Support the --with-bugurl configure option.
dnl ACX_BUGURL(default-bugurl)
AC_DEFUN([ACX_BUGURL],[
AC_ARG_WITH(bugurl,
AS_HELP_STRING([--with-bugurl=URL],
[Direct users to URL to report a bug]),
[case "$withval" in
yes) AC_MSG_ERROR([bug URL not specified]) ;;
no) BUGURL=
;;
*) BUGURL="$withval"
;;
esac],
BUGURL="$1"
)
case ${BUGURL} in
"")
REPORT_BUGS_TO=
REPORT_BUGS_TEXI=
;;
*)
REPORT_BUGS_TO="<$BUGURL>"
REPORT_BUGS_TEXI=@uref{`echo "$BUGURL" | sed 's/@/@@/g'`}
;;
esac;
AC_SUBST(REPORT_BUGS_TO)
AC_SUBST(REPORT_BUGS_TEXI)
])
dnl ####
dnl # ACX_CHECK_CYGWIN_CAT_WORKS
dnl # On Cygwin hosts, check that the cat command ignores
dnl # carriage returns as otherwise builds will not work.
dnl # See binutils PR 4334 for more details.
AC_DEFUN([ACX_CHECK_CYGWIN_CAT_WORKS],[
AC_MSG_CHECKING([to see if cat works as expected])
echo a >cygwin-cat-check
if test `cat cygwin-cat-check` = a ; then
rm cygwin-cat-check
AC_MSG_RESULT(yes)
else
rm cygwin-cat-check
AC_MSG_RESULT(no)
AC_MSG_ERROR([The cat command does not ignore carriage return characters.
Please either mount the build directory in binary mode or run the following
commands before running any configure script:
set -o igncr
export SHELLOPTS
])
fi
])

27
config/elf.m4 Executable file
View file

@ -0,0 +1,27 @@
dnl Copyright (C) 2010, 2011 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Paolo Bonzini.
dnl usage: ACX_ELF_TARGET_IFELSE([if-elf], [if-not-elf])
AC_DEFUN([ACX_ELF_TARGET_IFELSE], [
AC_REQUIRE([AC_CANONICAL_TARGET])
target_elf=no
case $target in
*-darwin* | *-aix* | *-cygwin* | *-mingw* | *-aout* | *-*coff* | \
*-msdosdjgpp* | *-vms* | *-wince* | *-*-pe* | \
alpha*-dec-osf* | *-interix* | hppa[[12]]*-*-hpux*)
target_elf=no
;;
*)
target_elf=yes
;;
esac
AS_IF([test $target_elf = yes], [$1], [$2])
])

7863
configure vendored Executable file

File diff suppressed because it is too large Load diff

133
configure.ac Executable file
View file

@ -0,0 +1,133 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
m4_include(config/acx.m4)
m4_include(config/elf.m4)
AC_PREREQ(2.69)
AC_INIT(eduOS, 0.1, slankes@eonerc.rwth-aachen.de, eduOS, http://rwth-os.github.io/eduOS/)
AC_CONFIG_SRCDIR(kernel/main.c)
AC_CONFIG_HEADERS(include/eduos/config.h)
# Find the build, host, and target systems.
ACX_NONCANONICAL_BUILD
ACX_NONCANONICAL_HOST
ACX_NONCANONICAL_TARGET
# Find the build, host, and target systems.
AC_CANONICAL_SYSTEM
AC_ARG_PROGRAM
m4_pattern_allow([^AS_FOR_TARGET$])dnl
m4_pattern_allow([^AS_FOR_BUILD$])dnl
# Get 'install' or 'install-sh' and its variants.
AC_PROG_INSTALL
ACX_PROG_LN
AC_PROG_LN_S
AC_PROG_SED
AC_PROG_AWK
if test "${build}" != "${host}" ; then
AR_FOR_BUILD=${AR_FOR_BUILD-ar}
AS_FOR_BUILD=${AS_FOR_BUILD-as}
CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
CXX_FOR_BUILD=${CXX_FOR_BUILD-g++}
GCJ_FOR_BUILD=${GCJ_FOR_BUILD-gcj}
GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran}
GOC_FOR_BUILD=${GOC_FOR_BUILD-gccgo}
LD_FOR_BUILD=${LD_FOR_BUILD-ld}
NM_FOR_BUILD=${NM_FOR_BUILD-nm}
RANLIB_FOR_BUILD=${RANLIB_FOR_BUILD-ranlib}
else
AR_FOR_BUILD="\$(AR)"
AS_FOR_BUILD="\$(AS)"
CC_FOR_BUILD="\$(CC)"
CXX_FOR_BUILD="\$(CXX)"
GCJ_FOR_BUILD="\$(GCJ)"
GFORTRAN_FOR_BUILD="\$(GFORTRAN)"
GOC_FOR_BUILD="\$(GOC)"
LD_FOR_BUILD="\$(LD)"
NM_FOR_BUILD="\$(NM)"
RANLIB_FOR_BUILD="\$(RANLIB)"
fi
# Checks for programs.
AC_PROG_CC
AC_PROG_CXX
m4_pattern_allow([^AS_FOR_TARGET$])dnl
m4_pattern_allow([^AS_FOR_BUILD$])dnl
# Build module lists & subconfigure args.
AC_SUBST(build_configargs)
AC_SUBST(build_configdirs)
# Host module lists & subconfigure args.
AC_SUBST(host_configargs)
AC_SUBST(configdirs)
AC_SUBST(target_configdirs)
# Target module lists & subconfigure args.
AC_SUBST(target_configargs)
NCN_STRICT_CHECK_TARGET_TOOLS(CC_FOR_TARGET, cc gcc)
NCN_STRICT_CHECK_TARGET_TOOLS(CXX_FOR_TARGET, c++ g++ cxx gxx)
NCN_STRICT_CHECK_TARGET_TOOLS(GCC_FOR_TARGET, gcc, ${CC_FOR_TARGET})
ACX_CHECK_INSTALLED_TARGET_TOOL(CPP_FOR_TARGET, cpp)
ACX_CHECK_INSTALLED_TARGET_TOOL(AR_FOR_TARGET, ar)
ACX_CHECK_INSTALLED_TARGET_TOOL(AS_FOR_TARGET, as)
ACX_CHECK_INSTALLED_TARGET_TOOL(LD_FOR_TARGET, ld)
ACX_CHECK_INSTALLED_TARGET_TOOL(LIPO_FOR_TARGET, lipo)
ACX_CHECK_INSTALLED_TARGET_TOOL(NM_FOR_TARGET, nm)
ACX_CHECK_INSTALLED_TARGET_TOOL(OBJDUMP_FOR_TARGET, objdump)
ACX_CHECK_INSTALLED_TARGET_TOOL(OBJCOPY_FOR_TARGET, objcopy)
ACX_CHECK_INSTALLED_TARGET_TOOL(RANLIB_FOR_TARGET, ranlib)
ACX_CHECK_INSTALLED_TARGET_TOOL(READELF_FOR_TARGET, readelf)
ACX_CHECK_INSTALLED_TARGET_TOOL(STRIP_FOR_TARGET, strip)
# define eduOS specific constants
AC_DEFINE(HAVE_ARCH_MEMSET, 1, Define to use machine specific version of memset)
AC_DEFINE(HAVE_ARCH_MEMCPY, 1, Define to use machine specific version of memcpy)
AC_DEFINE(HAVE_ARCH_STRLEN, 1, Define to use machine specific version of strlen)
AC_DEFINE(HAVE_ARCH_STRCPY, 1, Define to use machine specific version of strcpy)
AC_DEFINE(HAVE_ARCH_STRNCPY, 1, Define to use machine specific version of strncpy)
AC_ARG_WITH(bitmap-size, [AS_HELP_STRING([--with-bitmap-size=N], [specify the bitmap size])])
if test "x$with_bitmap_size" != x; then
AC_DEFINE_UNQUOTED(BITMAP_SIZE, $with_bitmap_size, Define the bitmap isze)
else
AC_DEFINE(BITMAP_SIZE, 4096, Define the bitmap size)
fi
AC_ARG_WITH(max-tasks, [AS_HELP_STRING([--with-max-tasks=N], [specify the maximum number of running tasks])])
if test "x$with_max_tasks" != x; then
AC_DEFINE_UNQUOTED(MAX_TASKS, $with_max_tasks, Define the maximum number of running tasks)
else
AC_DEFINE(MAX_TASKS, 16, Define the maximum number of running tasks)
fi
AC_ARG_WITH(kernel-stack-size, [AS_HELP_STRING([--with-kernel-stack-size=SIZE], [specify the size of the kernel stack])])
if test "x$with_kernel_stack_size" != x; then
AC_DEFINE_UNQUOTED(KERNEL_STACK_SIZE, $with_kernel_stack_size, Define the size of the kernel stack)
else
AC_DEFINE(KERNEL_STACK_SIZE, 8192, Define the size of the kernel stack)
fi
AC_ARG_WITH(user-stack-size, [AS_HELP_STRING([--with-user-stack-size=SIZE], [specify the size of the user stack])])
if test "x$with_user_stack_size" != x; then
AC_DEFINE_UNQUOTED(DEFAULT_STACK_SIZE, $with_user_stack_size, Define the size of the user stack)
else
AC_DEFINE(DEFAULT_STACK_SIZE, 65536, Define the size of the user stack)
fi
AC_ARG_ENABLE(uart, [AS_HELP_STRING([--enable-uart], [enable UART support])], [], [enable_uart=no])
if test "x$enable_uart" = "xyes"; then
AC_DEFINE(CONFIG_UART, 1, Enable UART support)
fi
AC_DEFINE(CONFIG_PCI, 1, Enable PCI support)
AC_CONFIG_FILES(Makefile)
AC_OUTPUT

View file

@ -1,71 +0,0 @@
/*
* Copyright (c) 2010, Stefan Lankes, RWTH Aachen University
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __CONFIG_H__
#define __CONFIG_H__
#ifdef __cplusplus
extern "C" {
#endif
#define EDUOS_VERSION "0.1"
#define MAX_TASKS 16
#define MAX_FNAME 128
#define TIMER_FREQ 100 /* in HZ */
#define CLOCK_TICK_RATE 1193182 /* 8254 chip's internal oscillator frequency */
#define VIDEO_MEM_ADDR 0xB8000 /* the video memory address */
#define CACHE_LINE 64
#define KERNEL_STACK_SIZE (8<<10) /* 8 KiB */
#define DEFAULT_STACK_SIZE (16*1024) /* 16 KiB */
#define KERNEL_SPACE (1 << 30) /* 1 GiB */
#define BITMAP_SIZE (128<<5) /* for 128 MiB of RAM */
#define KMSG_SIZE (8*1024)
#define INT_SYSCALL 0x80
#define MAILBOX_SIZE 32
#define BYTE_ORDER LITTLE_ENDIAN
#define CONFIG_VGA
#define CONFIG_PCI
//#define CONFIG_UART
#define BUILTIN_EXPECT(exp, b) __builtin_expect((exp), (b))
//#define BUILTIN_EXPECT(exp, b) (exp)
#define NORETURN __attribute__((noreturn))
#define STDCALL __attribute__((stdcall))
#define HAVE_ARCH_MEMSET
#define HAVE_ARCH_MEMCPY
#define HAVE_ARCH_STRLEN
#define HAVE_ARCH_STRCPY
#define HAVE_ARCH_STRNCPY
#ifdef __cplusplus
}
#endif
#endif

52
include/eduos/config.h.in Normal file
View file

@ -0,0 +1,52 @@
/* include/eduos/config.h.in. Generated from configure.ac by autoheader. */
/* Define the bitmap size */
#undef BITMAP_SIZE
/* Enable PCI support */
#undef CONFIG_PCI
/* Enable UART support */
#undef CONFIG_UART
/* Define the size of the user stack */
#undef DEFAULT_STACK_SIZE
/* Define to use machine specific version of memcpy */
#undef HAVE_ARCH_MEMCPY
/* Define to use machine specific version of memset */
#undef HAVE_ARCH_MEMSET
/* Define to use machine specific version of strcpy */
#undef HAVE_ARCH_STRCPY
/* Define to use machine specific version of strlen */
#undef HAVE_ARCH_STRLEN
/* Define to use machine specific version of strncpy */
#undef HAVE_ARCH_STRNCPY
/* Define the size of the kernel stack */
#undef KERNEL_STACK_SIZE
/* Define the maximum number of running tasks */
#undef MAX_TASKS
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION

View file

@ -41,11 +41,41 @@
extern "C" {
#endif
#define MAX_FNAME 128
#define TIMER_FREQ 100 /* in HZ */
#define CLOCK_TICK_RATE 1193182 /* 8254 chip's internal oscillator frequency */
#define VIDEO_MEM_ADDR 0xB8000 // the video memora address
#define CACHE_LINE 64
#define KERNEL_SPACE (1 << 30) /* 1 GiB */
#define KMSG_SIZE (8*1024)
#define INT_SYSCALL 0x80
#define MAILBOX_SIZE 32
#define WITH_PCI_NAMES
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define BYTE_ORDER BIG_ENDIAN
#else
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#ifdef __GNUC__
#define BUILTIN_EXPECT(exp, b) __builtin_expect((exp), (b))
#else
#define BUILTIN_EXPECT(exp, b) (exp)
#endif
#define NORETURN __attribute__((noreturn))
#define STDCALL __attribute__((stdcall))
#define NULL ((void*) 0)
/// represents a task identifier
typedef unsigned int tid_t;
#define PAGE_SHIFT 12
#define PAGE_BITS PAGE_SHIFT
#define PAGE_SIZE (1 << PAGE_SHIFT)
#define PAGE_MASK ~(PAGE_SIZE - 1)
#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
struct task;
/// pointer to the current (running) task
extern struct task* current_task;

501
install-sh Executable file
View file

@ -0,0 +1,501 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2013-12-25.23; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
tab=' '
nl='
'
IFS=" $tab$nl"
# Set DOITPROG to "echo" to test this script.
doit=${DOITPROG-}
doit_exec=${doit:-exec}
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
is_target_a_directory=possibly
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t)
is_target_a_directory=always
dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
# We allow the use of options -d and -T together, by making -d
# take the precedence; this is for compatibility with GNU install.
if test -n "$dir_arg"; then
if test -n "$dst_arg"; then
echo "$0: target directory not allowed when installing a directory." >&2
exit 1
fi
fi
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
if test $# -gt 1 || test "$is_target_a_directory" = always; then
if test ! -d "$dst_arg"; then
echo "$0: $dst_arg: Is not a directory." >&2
exit 1
fi
fi
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
dstdir=`dirname "$dst"`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
oIFS=$IFS
IFS=/
set -f
set fnord $dstdir
shift
set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

View file

@ -102,7 +102,7 @@ int main(void)
irq_enable();
system_calibration();
kprintf("This is eduOS %s Build %u, %u\n", EDUOS_VERSION, &__BUILD_DATE, &__BUILD_TIME);
kprintf("This is %s Build %u, %u\n", PACKAGE_STRING, &__BUILD_DATE, &__BUILD_TIME);
kprintf("Kernel starts at %p and ends at %p\n", &kernel_start, &kernel_end);
kprintf("Processor frequency: %u MHz\n", get_cpu_frequency());
kprintf("Total memory: %lu KiB\n", atomic_int32_read(&total_pages) * PAGE_SIZE / 1024);

View file

@ -34,9 +34,7 @@
#include <asm/atomic.h>
#include <asm/processor.h>
#include <asm/multiboot.h>
#ifdef CONFIG_VGA
#include <asm/vga.h>
#endif
#ifdef CONFIG_UART
#include <asm/uart.h>
#endif
@ -45,10 +43,10 @@
#define VGA_EARLY_PRINT 0x01
#define UART_EARLY_PRINT 0x02
#ifdef CONFIG_VGA
static uint32_t early_print = VGA_EARLY_PRINT;
#ifdef CONFIG_UART
static uint32_t early_print = UART_EARLY_PRINT;
#else
static uint32_t early_print = NO_EARLY_PRINT;
static uint32_t early_print = VGA_EARLY_PRINT;
#endif
static spinlock_irqsave_t olock = SPINLOCK_IRQSAVE_INIT;
static atomic_int32_t kmsg_counter = ATOMIC_INIT(0);
@ -152,9 +150,7 @@ int kmsg_init(vfs_node_t * node, const char *name)
int koutput_init(void)
{
#ifdef CONFIG_VGA
vga_init();
#endif
#ifdef CONFIG_UART
if (mb_info && (mb_info->flags & MULTIBOOT_INFO_CMDLINE))
if (!uart_early_init((char*) mb_info->cmdline))
@ -174,10 +170,8 @@ int kputchar(int c)
pos = atomic_int32_inc(&kmsg_counter);
kmessages[pos % KMSG_SIZE] = (unsigned char) c;
#ifdef CONFIG_VGA
if (early_print & VGA_EARLY_PRINT)
vga_putchar(c);
#endif
#ifdef CONFIG_UART
if (early_print & UART_EARLY_PRINT)
uart_putchar(c);
@ -199,10 +193,8 @@ int kputs(const char *str)
for(i=0; i<len; i++) {
pos = atomic_int32_inc(&kmsg_counter);
kmessages[pos % KMSG_SIZE] = str[i];
#ifdef CONFIG_VGA
if (early_print & VGA_EARLY_PRINT)
vga_putchar(str[i]);
#endif
#ifdef CONFIG_UART
if (early_print & UART_EARLY_PRINT)
uart_putchar(str[i]);

View file

@ -63,12 +63,10 @@ int vma_init(void)
if (BUILTIN_EXPECT(ret, 0))
goto out;
#ifdef CONFIG_VGA
// add VGA video memory
ret = vma_add(VIDEO_MEM_ADDR, VIDEO_MEM_ADDR + PAGE_SIZE, VMA_READ|VMA_WRITE);
if (BUILTIN_EXPECT(ret, 0))
goto out;
#endif
// add Multiboot structures as modules
if (mb_info) {