Initial snapshot

This commit is contained in:
Mercier Pierre-Olivier 2013-02-11 22:04:30 +01:00
commit fee4dd4e6d
373 changed files with 62144 additions and 0 deletions

145
Makefile Normal file
View file

@ -0,0 +1,145 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kanetno
#
# file /home/mycure/kaneton/export/data/snapshot/Makefile
#
# created julien quintard [tue jun 26 11:27:22 2007]
# updated julien quintard [sat feb 5 12:11:16 2011]
#
#
# ---------- dependencies -----------------------------------------------------
#
-include environment/env.mk
#
# ---------- directives -------------------------------------------------------
#
.SILENT:
.PHONY: main initialize clean clear prototypes \
headers build install info
#
# ---------- variables --------------------------------------------------------
#
_PYTHON_ ?= $(KANETON_PYTHON)
_MAKE_ ?= $(MAKE)
#
# ---------- default rule -----------------------------------------------------
#
ifeq ($(_SIGNATURE_),kaneton)
PATHS = $(dir $(_COMPONENTS_))
main:
for path in $(PATHS) ; do \
if [ -f "$${path}/Makefile" ] ; then \
$(call env_launch,$${path}/Makefile,,) ; \
fi \
done
else
main \
clear \
prototypes \
headers \
build install \
info \
clean: initialize
$(_MAKE_) -f Makefile $@
endif
#
# ---------- environment ------------------------------------------------------
#
initialize:
cd environment/ && \
$(_PYTHON_) initialize.py && \
cd ..
#
# ---------- conditional ------------------------------------------------------
#
ifeq ($(_SIGNATURE_),kaneton)
#
# ---------- environment ------------------------------------------------------
#
clean:
$(call env_launch,$(_CLEAN_SCRIPT_),,)
#
# ---------- variables --------------------------------------------------------
#
SUBDIRS := boot environment kaneton \
license sample test tool \
$(PATHS)
#
# ---------- clear ------------------------------------------------------------
#
clear:
for d in $(SUBDIRS) ; do \
$(call env_launch,$${d}/Makefile,clear,) ; \
done
$(call env_purge,)
#
# ---------- prototypes -------------------------------------------------------
#
prototypes:
for d in $(SUBDIRS) ; do \
$(call env_launch,$${d}/Makefile,prototypes,) ; \
done
#
# ---------- headers ----------------------------------------------------------
#
headers:
for d in $(SUBDIRS) ; do \
$(call env_launch,$${d}/Makefile,headers,) ; \
done
#
# ---------- boot -------------------------------------------------------------
#
build:
$(call env_launch,$(_MBL_SCRIPT_),build,)
install: main
$(call env_launch,$(_MBL_SCRIPT_),install,)
#
# ---------- information ------------------------------------------------------
#
info:
$(call env_print,,,)
$(call env_print,"--- ",blue,$(ENV_OPTION_NO_NEWLINE))
$(call env_print,http://kaneton.opaak.org,,)
$(call env_print,,,)
endif

56
boot/Makefile Normal file
View file

@ -0,0 +1,56 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/boot/Makefile
#
# created julien quintard [sun jun 10 14:54:43 2007]
# updated julien quintard [fri may 1 23:55:46 2009]
#
#
# ---------- dependencies -----------------------------------------------------
#
include ../environment/env.mk
#
# ---------- directives -------------------------------------------------------
#
.PHONY: main clear prototypes headers
#
# ---------- variables --------------------------------------------------------
#
SUBDIRS := loader
#
# ---------- rules ------------------------------------------------------------
#
main:
for d in $(SUBDIRS) ; do \
$(call env_launch,$${d}/Makefile,,) ; \
done
clear:
for d in $(SUBDIRS) ; do \
$(call env_launch,$${d}/Makefile,clear,) ; \
done
$(call env_purge,)
prototypes:
for d in $(SUBDIRS) ; do \
$(call env_launch,$${d}/Makefile,prototypes,) ; \
done
headers:
for d in $(SUBDIRS) ; do \
$(call env_launch,$${d}/Makefile,headers,) ; \
done

47
boot/loader/Makefile Normal file
View file

@ -0,0 +1,47 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/boot/loader/Makefile
#
# created julien quintard [sun jun 10 14:54:43 2007]
# updated julien quintard [sat dec 18 11:15:05 2010]
#
#
# ---------- dependencies -----------------------------------------------------
#
include ../../environment/env.mk
#
# ---------- directives -------------------------------------------------------
#
.PHONY: main clear prototypes headers
#
# ---------- variables --------------------------------------------------------
#
SUBDIRS := ${_LOADER_DIR_}
#
# ---------- rules ------------------------------------------------------------
#
main:
clear:
for d in $(SUBDIRS) ; do \
$(call env_launch,$${d}/Makefile,clear,) ; \
done
$(call env_purge,)
prototypes:
headers:

View file

@ -0,0 +1,50 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane.../loader/ibm-pc.ia32/educational/Makefile
#
# created julien quintard [tue jun 12 20:34:41 2007]
# updated julien quintard [sat feb 5 11:09:53 2011]
#
#
# ---------- component --------------------------------------------------------
#
component := loader
#
# ---------- dependencies -----------------------------------------------------
#
include ../../../../environment/env.mk
#
# ---------- directives -------------------------------------------------------
#
.PHONY: main clear prototypes headers
#
# ---------- rules ------------------------------------------------------------
#
ifeq ($(behaviour),default)
main:
prototypes:
headers:
dependencies:
endif
#
# ---------- dependencies -----------------------------------------------------
#
-include ./$(_DEPENDENCY_MK_)

Binary file not shown.

41
environment/Makefile Normal file
View file

@ -0,0 +1,41 @@
##
## licence kaneton licence
##
## project kaneton
##
## file /home/buckman/kaneton/environment/Makefile
##
## created julien quintard [fri feb 11 02:59:20 2005]
## updated matthieu bucchianeri [tue jan 24 11:42:31 2006]
##
#
# ---------- dependencies -----------------------------------------------------
#
include env.mk
#
# ---------- directives -------------------------------------------------------
#
.PHONY: main initialize clean clear prototypes headers
#
# ---------- rules ------------------------------------------------------------
#
main: initialize
initialize:
$(call env_launch,$(_ENVIRONMENT_DIR_)/initialize.py,,)
clean:
$(call env_launch,$(_ENVIRONMENT_DIR_)/clean.py,,)
clear:
$(call env_purge,)
prototypes:
headers:

Binary file not shown.

138
environment/clean.py Normal file
View file

@ -0,0 +1,138 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/clean.py
#
# created julien quintard [sat dec 16 20:57:38 2006]
# updated julien quintard [mon apr 20 03:33:17 2009]
#
#
# ---------- imports ----------------------------------------------------------
#
import os
import env
#
# ---------- functions --------------------------------------------------------
#
#
# machine()
#
# this function removes the links to the machine dependent files
# and directories.
#
def machine():
env.display(env.HEADER_OK,
"removing links to machine-dependent directories",
env.OPTION_NONE)
env.remove(env._GLUE_CURRENT_, env.OPTION_NONE)
env.remove(env._ARCHITECTURE_CURRENT_, env.OPTION_NONE)
env.remove(env._PLATFORM_CURRENT_, env.OPTION_NONE)
#
# clear()
#
# this function clears the kaneton development tree.
#
def clear():
env.display(env.HEADER_OK,
"clearing the kaneton development tree",
env.OPTION_NONE)
env.launch(env._SOURCE_DIR_ + "/Makefile", "clear", env.OPTION_QUIET)
#
# boot()
#
# this function removes everything that has been generated
# for booting the kernel like images and so forth.
#
def boot():
if env.path(env._IMAGE_, env.OPTION_EXIST):
env.remove(env._IMAGE_, env.OPTION_NONE)
#
# dependencies()
#
# this function removes the kaneton dependencies.
#
def dependencies():
dependencies = None
dep = None
env.display(env.HEADER_OK,
"removing the kaneton header dependencies",
env.OPTION_NONE)
dependencies = env.search(env._SOURCE_DIR_,
env._DEPENDENCY_MK_,
env.OPTION_FILE | env.OPTION_RECURSIVE)
for dep in dependencies:
env.remove(dep, env.OPTION_NONE)
#
# clean()
#
# the function removes the generated kaneton development environment files.
#
def clean():
env.remove(env._ENV_MK_, env.OPTION_NONE)
env.remove(env._ENV_PY_, env.OPTION_NONE)
#
# main()
#
# this function initializes the development environment.
#
import sys
def main():
# display some stuff.
env.display(env.HEADER_OK,
"cleaning the kaneton development environment",
env.OPTION_NONE)
# clear the kaneton development tree.
clear()
# remove the generated boot stuff.
boot()
# uninstall the chosen machine.
machine()
# generate the kaneton dependencies.
dependencies()
# remove the environment-specific files.
clean()
# display some stuff.
env.display(env.HEADER_OK,
"environment development cleaned successfully",
env.OPTION_NONE)
#
# ---------- entry point ------------------------------------------------------
#
if __name__ == "__main__":
main()

426
environment/critical.py Normal file
View file

@ -0,0 +1,426 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/critical.py
#
# created julien quintard [fri dec 15 13:43:03 2006]
# updated julien quintard [fri dec 17 20:00:58 2010]
#
#
# ---------- imports ----------------------------------------------------------
#
import os
import sys
import re
#
# ---------- globals ----------------------------------------------------------
#
g_directories = None
g_contents = None
g_assignments = []
g_variables = {}
#
# ---------- functions --------------------------------------------------------
#
#
# error()
#
# this function displays an error and quit.
#
def error(message):
sys.stderr.write("[!] " + message)
sys.exit(42)
#
# warning()
#
# this function simply displays an error.
#
def warning(msg):
sys.stderr.write("[!] " + msg)
#
# load()
#
# this function takes an arbitray number of directories where pattern
# files could be located and load them in a single python string.
#
def load(directories, pattern):
content = ""
directory = None
includes = None
include = None
handle = None
files = None
line = None
file = None
cwd = None
for directory in directories:
if not os.path.isdir(directory):
continue
files = os.listdir(directory);
for file in files:
if not os.path.isfile(directory + "/" + file):
continue
if not re.match(pattern, file):
continue
try:
handle = open(directory + "/" + file, "r")
except IOError:
error("unable to open the file " + directory + "/" + file + ".\n")
for line in handle.readlines():
content += line
content += "\n"
includes = re.findall("(" \
"^" \
"include" \
"[ \t]*" \
"(.*)" \
"\n" \
")", content, re.MULTILINE);
for include in includes:
content = content.replace(include[0],
load([os.path.dirname(directory +
"/" +
include[1])],
"^" +
os.path.basename(directory +
"/" +
include[1]) +
"$"))
handle.close()
return content
#
# comments()
#
# this function removes the comments from the file
#
def comments():
global g_contents
comments = None
c = None
comments = re.findall("^#.*$", g_contents, re.MULTILINE);
for c in comments:
g_contents = g_contents.replace(c, "", 1)
#
# locate()
#
# this function tries to locate the variable of the given array and
# return the corresponding tuple.
#
def locate(array, variable):
var = None
for var in array:
if variable == var[0]:
return var
return None
#
# extract()
#
# this function extracts the variables assignments from the environment
# configuration files previously loaded.
#
def extract():
global g_assignments
assignments = None
assignment = None
already = None
new = None
assignments = re.findall("^" \
"[ \t]*" \
"([a-zA-Z0-9_]+)" \
"[ \t]*" \
"(\+?=)" \
"[ \t]*" \
"((?:(?:\\\\\n)|[^\n])*)" \
"\n", g_contents, re.MULTILINE);
for assignment in assignments:
# look for a previous registered assignment.
already = locate(g_assignments, assignment[0])
if already:
# if it is an assignment, just override the previous declaration.
if assignment[1] == "=":
new = (assignment[0], assignment[2])
# if it is a concatenation, override the previous one with a
# concatenation of the two values.
elif assignment[1] == "+=":
new = (assignment[0], already[1] + " " + assignment[2])
else:
error("unknown assignment token '" + assignment[1] + "' for the "
"variable '" + assignment[0] + "'.\n")
# remove and insert the new tuple.
g_assignments.remove(already)
g_assignments.append(new)
else:
if assignment[1] == "=":
# simple insert the tuple.
new = (assignment[0], assignment[2])
g_assignments.append(new)
elif assignment[1] == "+=":
error("appending to the undefined variable '" + assignment[0] +
"' is not allowed.\n")
else:
error("unknown assignment token '" + assignment[1] + "' for the "
"variable '" + assignment[0] + "'.\n")
#
# expand()
#
# this function tries to expand the given variable.
#
def expand(name, stack):
variables = None
position = None
tuple = None
value = None
var = None
# try to get the variable's value from the already expanded variables.
try:
value = g_variables[name]
return
except:
# check if the variable was declared somewhere.
tuple = locate(g_assignments, name)
if not tuple:
warning("the kaneton environment variable " + name +
" is not defined\n")
value = ""
else:
value = tuple[1]
# check recursion assignments.
try:
position = stack.index(name)
except:
pass
if position != None:
error("the kaneton environment variable " + name +
" recursively references itself.\n")
# locate, expand and replace the kaneton variables.
variables = re.findall("\$\{([^}]+)\}", value)
if variables:
for var in variables:
expand(var, stack + [name])
for var in variables:
value = value.replace("${" + var + "}", g_variables[var])
# locate, expand and replace the shell variables.
variables = re.findall("\$\(([^}]+)\)", value)
if variables:
for var in variables:
if os.getenv(var) == None:
warning("shell user variable " + var + " is not defined\n")
value = value.replace("$(" + var + ")", "")
else:
value = value.replace("$(" + var + ")", os.getenv(var))
# finally register the new variable with its expanded value.
g_variables[name] = value
#
# resolve()
#
# this function resolves the variable assignments.
def resolve():
for assignment in g_assignments:
expand(assignment[0], [])
#
# generate()
#
# this function generates the kaneton development environment files.
#
def generate(mfile, mcontent, pfile, pcontent):
mhandle = None
phandle = None
line = None
var = None
# open the make environment file.
try:
mhandle = open(mfile, "w")
except IOError:
error("unable to open the file " + mfile + ".\n")
# open the python environment file.
try:
phandle = open(pfile, "w")
except IOError:
error("unable to open the file " + pfile + ".\n")
# inject the kaneton environment configuration for the make and python
# environment.
for var in g_variables:
mhandle.write(var + " := " + g_variables[var] + "\n")
phandle.write(var + " = " + "\"" + g_variables[var] + "\"" + "\n")
# append the make environment files to the make environment file.
mhandle.write(mcontent)
# append the python environment files to the python environment file.
phandle.write(pcontent)
# close the files.
phandle.close()
mhandle.close()
#
# main()
#
# this function builds a kaneton development environment.
#
def main():
global g_directories
global g_contents
architecture = None
source_dir = None
platform = None
contents = None
machine = None
python = None
host = None
user = None
# get the shell environment variables.
user = os.getenv("KANETON_USER")
host = os.getenv("KANETON_HOST")
python = os.getenv("KANETON_PYTHON")
platform = os.getenv("KANETON_PLATFORM")
architecture = os.getenv("KANETON_ARCHITECTURE")
# check the presence of the shell environment variable.
if not (user != None and
os.path.isdir("profile/user/" + user)):
error("the shell environment variable KANETON_USER is not set " + \
"or is incorrect.\n")
if not (python != None and
os.path.isfile(python)):
error("the shell environment variable KANETON_PYTHON is not set " + \
"or is incorrect.\n")
if not (platform != None and
os.path.isdir("profile/kaneton/machine/platform/" + platform)):
error("the shell environment variable KANETON_PLATFORM is not " + \
"set or is incorrect.\n")
if not (architecture != None and
os.path.isdir("profile/kaneton/machine/architecture/" + architecture)):
error("the shell environment variable KANETON_ARCHITECTURE is " + \
"not set or is incorrect.\n")
if not (host != None and
os.path.isdir("profile/host/" + host + "." + architecture)):
error("the shell environment variable KANETON_HOST or " + \
"KANETON_ARCHITECTURE is not set or is incorrect.\n")
# set the configuration directories based on the user variables.
g_directories = ("profile/",
"profile/host/",
"profile/host/" + host + "." + architecture + "/",
"profile/boot/",
"profile/boot/" + platform + "." + architecture + "/",
"profile/kaneton/",
"profile/kaneton/core/",
"profile/kaneton/machine/",
"profile/kaneton/machine/platform/",
"profile/kaneton/machine/platform/" + platform + "/",
"profile/kaneton/machine/architecture/",
"profile/kaneton/machine/architecture/" + \
architecture + "/",
"profile/kaneton/machine/glue/",
"profile/kaneton/machine/glue/" + platform + "." + \
architecture + "/",
"profile/kaneton/library/",
"profile/kaneton/modules/",
"profile/user/",
"profile/user/" + user + "/")
# first, set a virtual kaneton variable containing the location of
# the kaneton source directory.
# this directory is expected to be relatively located at: ../
# since this script should have been launched in the environment/
# directory
cwd = os.getcwd()
os.chdir("..")
source_dir = os.getcwd()
os.chdir(cwd)
# load the content of the configuration files *.conf.
g_contents = "_SOURCE_DIR_ = " + source_dir + "\n"
g_contents += load(g_directories, "^.*\.conf$")
# removes the comments
comments()
# extract the assignments from the files.
extract()
# resolve the variables in assignments.
resolve()
# generate the development environment files.
generate("env.mk", load(g_directories, "^.*\.mk$"),
"env.py", load(g_directories, "^.*\.py$"))
#
# ---------- entry point ------------------------------------------------------
#
main()

BIN
environment/critical.pyc Normal file

Binary file not shown.

168
environment/initialize.py Normal file
View file

@ -0,0 +1,168 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/initialize.py
#
# created julien quintard [fri dec 15 13:43:03 2006]
# updated julien quintard [thu feb 10 19:24:31 2011]
#
#
# ---------- imports ----------------------------------------------------------
#
import critical
import env
import sys
import time
#
# ---------- functions --------------------------------------------------------
#
#
# warning()
#
# this function displays the current configuration.
#
def warning():
env.display(env.HEADER_NONE, "", env.OPTION_NONE)
env.display(env.HEADER_OK, "configuration:", env.OPTION_NONE)
env.display(env.HEADER_OK,
" user: " + env._USER_,
env.OPTION_NONE)
env.display(env.HEADER_OK,
" host: " + env._HOST_,
env.OPTION_NONE)
env.display(env.HEADER_OK,
" platform: " + env._PLATFORM_,
env.OPTION_NONE)
env.display(env.HEADER_OK,
" architecture: " + env._ARCHITECTURE_,
env.OPTION_NONE)
env.display(env.HEADER_NONE, "", env.OPTION_NONE)
#
# machine()
#
# this function installs the links to the glue, platform and architecture
# dependent files and directories.
def machine():
env.display(env.HEADER_OK,
"installing links to machine-dependent directories",
env.OPTION_NONE)
env.remove(env._GLUE_CURRENT_, env.OPTION_NONE)
env.link(env._GLUE_CURRENT_, env._GLUE_DIR_, env.OPTION_NONE)
env.remove(env._PLATFORM_CURRENT_, env.OPTION_NONE)
env.link(env._PLATFORM_CURRENT_, env._PLATFORM_DIR_, env.OPTION_NONE)
env.remove(env._ARCHITECTURE_CURRENT_, env.OPTION_NONE)
env.link(env._ARCHITECTURE_CURRENT_, env._ARCHITECTURE_DIR_, env.OPTION_NONE)
#
# check()
#
# this function looks for every binary the behaviour profile needs to work
# properly.
#
def check():
binaries = None
binary = None
env.display(env.HEADER_OK,
"looking for programs needed by the development environment",
env.OPTION_NONE)
binaries = env._BINARIES_.split(",")
for binary in binaries:
binary = binary.replace('\t', ' ')
binary = binary.strip()
binary = binary.split(' ')
if env.locate(binary[0], env.OPTION_NONE) != 0:
env.display(env.HEADER_ERROR,
" the program " + binary[0] + " is not present " \
"on your system",
env.OPTION_NONE)
#
# prototypes()
#
# this function generates the kaneton prototypes.
#
def prototypes():
useless = None
env.display(env.HEADER_OK,
"generating the kaneton prototypes",
env.OPTION_NONE)
env.launch(env._SOURCE_DIR_ + "/Makefile", "prototypes", env.OPTION_QUIET)
#
# headers()
#
# this function generates the kaneton header dependencies.
#
def headers():
env.display(env.HEADER_OK,
"generating the kaneton header dependencies",
env.OPTION_NONE)
env.launch(env._SOURCE_DIR_ + "/Makefile", "headers", env.OPTION_QUIET)
#
# main()
#
# this function initializes the development environment.
#
def main():
# display some stuff.
env.display(env.HEADER_OK,
"installing the kaneton development environment",
env.OPTION_NONE)
# display the current configuration and ask the user to continue.
warning()
# install the chosen machine: platform/architecture.
machine()
# check the presence of the binaries used by the behaviour profile.
check()
# generate the kaneton prototypes.
prototypes()
# generate the kaneton headers.
headers()
# display some stuff.
env.display(env.HEADER_OK,
"environment development installed successfully",
env.OPTION_NONE)
#
# ---------- entry point ------------------------------------------------------
#
if __name__ == "__main__":
main()

View file

@ -0,0 +1,76 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/profile/boot/boot.conf
#
# created julien quintard [tue may 8 11:00:40 2007]
# updated julien quintard [tue may 5 10:16:49 2009]
#
#
# ---------- information ------------------------------------------------------
#
# this file declares the default boot variables which should be overriden
# by the user profile.
#
#
# ---------- multi-bootloader -------------------------------------------------
#
_MBL_SCRIPT_ = <null>
_BOOT_MODE_ = <null>
_BOOT_DEVICE_ = <null>
#
# ---------- network ----------------------------------------------------------
#
_ADDRESS_ = <null>
#
# ---------- tftp server ------------------------------------------------------
#
_TFTP_ADDRESS_ = <null>
_TFTP_DIRECTORY_ = <null>
#
# ---------- devices ----------------------------------------------------------
#
_UDEVICE_ = <null>
_MDEVICE_ = <null>
_IMAGE_ = ${_PROFILE_USER_DIR_}/${_USER_}.img
#
# ---------- inputs ----------------------------------------------------------
#
# the inputs are additional files such as boot-time servers, configuration
# files.
#
_INPUTS_ =
#
# ---------- components -------------------------------------------------------
#
# this variable contains the list of the components to build.
#
_COMPONENT_FIRMWARE_ =
_COMPONENT_LOADER_ = ${_LOADER_}
_COMPONENT_KANETON_ = ${_KANETON_}
_COMPONENTS_ = ${_COMPONENT_FIRMWARE_} \
${_COMPONENT_LOADER_} \
${_COMPONENT_KANETON_} \
${_INPUTS_}

View file

@ -0,0 +1,23 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/profile/user/boot.desc
#
# created julien quintard [tue may 8 13:00:28 2007]
# updated julien quintard [tue jun 26 15:20:39 2007]
#
#
# ---------- information ------------------------------------------------------
#
# XXX
#
# XXX
#
# _BOOT_MODE_ = { peripheral, network, image }
# _BOOT_DEVICE = { floppy, hard-drive }

View file

@ -0,0 +1,348 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/profile/environment.conf
#
# created julien quintard [fri dec 15 13:50:15 2006]
# updated julien quintard [wed feb 9 05:33:19 2011]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains the default environment configuration including
# kaneton directories, librarires, script, tools etc. locations.
#
#
# ---------- signature --------------------------------------------------------
#
_SIGNATURE_ = kaneton
#
# ---------- shell environment variables --------------------------------------
#
_USER_ = $(KANETON_USER)
_HOST_ = $(KANETON_HOST)
_PYTHON_ = $(KANETON_PYTHON)
_PLATFORM_ = $(KANETON_PLATFORM)
_ARCHITECTURE_ = $(KANETON_ARCHITECTURE)
#
# ---------- source directory -------------------------------------------------
#
_BOOT_DIR_ = ${_SOURCE_DIR_}/boot
_CHEAT_DIR_ = ${_SOURCE_DIR_}/cheat
_CONFIGURE_DIR_ = ${_SOURCE_DIR_}/configure
_ENVIRONMENT_DIR_ = ${_SOURCE_DIR_}/environment
_EXPORT_DIR_ = ${_SOURCE_DIR_}/export
_HISTORY_DIR_ = ${_SOURCE_DIR_}/history
_KANETON_DIR_ = ${_SOURCE_DIR_}/kaneton
_LICENSE_DIR_ = ${_SOURCE_DIR_}/license
_SAMPLE_DIR_ = ${_SOURCE_DIR_}/sample
_TEST_DIR_ = ${_SOURCE_DIR_}/test
_TOOL_DIR_ = ${_SOURCE_DIR_}/tool
_TRANSCRIPT_DIR_ = ${_SOURCE_DIR_}/transcript
_VIEW_DIR_ = ${_SOURCE_DIR_}/view
#
# ---------- boot directory ---------------------------------------------------
#
_BOOT_STRAP_DIR_ = ${_BOOT_DIR_}/strap
_BOOT_LOADER_DIR_ = ${_BOOT_DIR_}/loader
_LOADER_DIR_ = ${_BOOT_LOADER_DIR_}/${_PLATFORM_}.${_ARCHITECTURE_}
#
# ---------- kaneton directory ------------------------------------------------
#
_CORE_DIR_ = ${_KANETON_DIR_}/core
_MACHINE_DIR_ = ${_KANETON_DIR_}/machine
_LIBRARY_DIR_ = ${_KANETON_DIR_}/library
_MODULES_DIR_ = ${_KANETON_DIR_}/modules
_INCLUDE_DIR_ = ${_KANETON_DIR_}/include
#
# ---------- core directory ---------------------------------------------------
#
_CORE_AS_DIR_ = ${_CORE_DIR_}/as
_CORE_CAPABILITY_DIR_ = ${_CORE_DIR_}/capability
_CORE_CLOCK_DIR_ = ${_CORE_DIR_}/clock
_CORE_CPU_DIR_ = ${_CORE_DIR_}/cpu
_CORE_EVENT_DIR_ = ${_CORE_DIR_}/event
_CORE_ID_DIR_ = ${_CORE_DIR_}/id
_CORE_INCLUDE_DIR_ = ${_CORE_DIR_}/include
_CORE_INTERFACE_DIR_ = ${_CORE_DIR_}/interface
_CORE_IO_DIR_ = ${_CORE_DIR_}/io
_CORE_KERNEL_DIR_ = ${_CORE_DIR_}/kernel
_CORE_MAP_DIR_ = ${_CORE_DIR_}/map
_CORE_MESSAGE_DIR_ = ${_CORE_DIR_}/message
_CORE_REGION_DIR_ = ${_CORE_DIR_}/region
_CORE_SCHEDULER_DIR_ = ${_CORE_DIR_}/scheduler
_CORE_SEGMENT_DIR_ = ${_CORE_DIR_}/segment
_CORE_SET_DIR_ = ${_CORE_DIR_}/set
_CORE_TASK_DIR_ = ${_CORE_DIR_}/task
_CORE_THREAD_DIR_ = ${_CORE_DIR_}/thread
_CORE_TIMER_DIR_ = ${_CORE_DIR_}/timer
#
# ---------- machine directory ------------------------------------------------
#
_MACHINE_GLUE_DIR_ = ${_MACHINE_DIR_}/glue
_MACHINE_ARCHITECTURE_DIR_ = ${_MACHINE_DIR_}/architecture
_MACHINE_PLATFORM_DIR_ = ${_MACHINE_DIR_}/platform
_MACHINE_INCLUDE_DIR_ = ${_MACHINE_DIR_}/include
#
# ---------- library directory ------------------------------------------------
#
_LIBRARY_INCLUDE_DIR_ = ${_LIBRARY_DIR_}/include
#
# ---------- modules directory ------------------------------------------------
#
_MODULES_INCLUDE_DIR_ = ${_MODULES_DIR_}/modules
#
# ---------- glue directory ---------------------------------------------------
#
_GLUE_DIR_ = ${_MACHINE_GLUE_DIR_}/${_PLATFORM_}.${_ARCHITECTURE_}
_GLUE_INCLUDE_DIR_ = ${_GLUE_DIR_}/include
#
# ---------- platform directory -----------------------------------------------
#
_PLATFORM_DIR_ = ${_MACHINE_PLATFORM_DIR_}/${_PLATFORM_}
_PLATFORM_INCLUDE_DIR_ = ${_PLATFORM_DIR_}/include
#
# ---------- architecture directory -------------------------------------------
#
_ARCHITECTURE_DIR_ = ${_MACHINE_ARCHITECTURE_DIR_}/${_ARCHITECTURE_}
_ARCHITECTURE_INCLUDE_DIR_ = ${_ARCHITECTURE_DIR_}/include
#
# ---------- kaneton library objects ------------------------------------------
#
_CORE_LO_ = ${_CORE_DIR_}/core.lo
_MACHINE_LO_ = ${_MACHINE_DIR_}/machine.lo
_LIBRARY_LO_ = ${_LIBRARY_DIR_}/library.lo
_MODULES_LO_ = ${_MODULES_DIR_}/modules.lo
_GLUE_LO_ = ${_GLUE_DIR_}/glue.lo
_ARCHITECTURE_LO_ = ${_ARCHITECTURE_DIR_}/architecture.lo
_PLATFORM_LO_ = ${_PLATFORM_DIR_}/platform.lo
#
# ---------- current selected machine -----------------------------------------
#
_GLUE_CURRENT_ = ${_MACHINE_GLUE_DIR_}/.current
_ARCHITECTURE_CURRENT_ = ${_MACHINE_ARCHITECTURE_DIR_}/.current
_PLATFORM_CURRENT_ = ${_MACHINE_PLATFORM_DIR_}/.current
#
# ---------- environment directory --------------------------------------------
#
_PROFILE_DIR_ = ${_ENVIRONMENT_DIR_}/profile
#
# ---------- profile directory ------------------------------------------------
#
_PROFILE_BOOT_DIR_ = ${_PROFILE_DIR_}/boot
_PROFILE_HOST_DIR_ = ${_PROFILE_DIR_}/host/${_HOST_}.${_ARCHITECTURE_}
_PROFILE_KANETON_DIR_ = ${_PROFILE_DIR_}/kaneton
_PROFILE_USER_DIR_ = ${_PROFILE_DIR_}/user/${_USER_}
_PROFILE_CORE_DIR_ = ${_PROFILE_KANETON_DIR_}/core
_PROFILE_LIBRARY_DIR_ = ${_PROFILE_KANETON_DIR_}/library
_PROFILE_MACHINE_DIR_ = ${_PROFILE_KANETON_DIR_}/machine
_PROFILE_MODULES_DIR_ = ${_PROFILE_KANETON_DIR_}/modules
_PROFILE_GLUE_DIR_ = ${_PROFILE_MACHINE_DIR_}/glue/${_PLATFORM_}.${_ARCHITECTURE_}
_PROFILE_PLATFORM_DIR_ = ${_PROFILE_MACHINE_DIR_}/platform/${_PLATFORM_}
_PROFILE_ARCHITECTURE_DIR_ = ${_PROFILE_MACHINE_DIR_}/architecture/${_ARCHITECTURE_}
#
# ---------- view directory ---------------------------------------------------
#
_BIBLIOGRAPHY_DIR_ = ${_VIEW_DIR_}/bibliography
_BOOK_DIR_ = ${_VIEW_DIR_}/book
_EXAM_DIR_ = ${_VIEW_DIR_}/exam
_FEEDBACK_DIR_ = ${_VIEW_DIR_}/feedback
_FIGURES_DIR_ = ${_VIEW_DIR_}/figures
_INTERNSHIP_DIR_ = ${_VIEW_DIR_}/internship
_LECTURE_DIR_ = ${_VIEW_DIR_}/lecture
_LOGO_DIR_ = ${_VIEW_DIR_}/logo
_PACKAGE_DIR_ = ${_VIEW_DIR_}/package
_PAPER_DIR_ = ${_VIEW_DIR_}/paper
_TALK_DIR_ = ${_VIEW_DIR_}/talk
_TEMPLATE_DIR_ = ${_VIEW_DIR_}/template
#
# ---------- layouts ----------------------------------------------------------
#
_LAYOUT_DIR_ = ${_GLUE_DIR_}/layout
_KERNEL_LAYOUT_ = ${_LAYOUT_DIR_}/kernel.lyt
_DRIVER_LAYOUT_ = ${_LAYOUT_DIR_}/driver.lyt
_SERVICE_LAYOUT_ = ${_LAYOUT_DIR_}/service.lyt
_GUEST_LAYOUT_ = ${_LAYOUT_DIR_}/guest.lyt
#
# ---------- tool directory ---------------------------------------------------
#
_CTC_DIR_ = ${_TOOL_DIR_}/ctc
_FIRMWARE_DIR_ = ${_TOOL_DIR_}/firmware/${_PLATFORM_}.${_ARCHITECTURE_}
_MBL_DIR_ = ${_TOOL_DIR_}/mbl
_MKP_DIR_ = ${_TOOL_DIR_}/mkp
_SCRIPT_DIR_ = ${_TOOL_DIR_}/script
#
# ---------- core library-objects ---------------------------------------------
#
_AS_LO_ = ${_CORE_AS_DIR_}/as.lo
_CAPABILITY_LO_ = ${_CORE_CAPABILITY_DIR_}/capability.lo
_CLOCK_LO_ = ${_CORE_CLOCK_DIR_}/clock.lo
_CPU_LO_ = ${_CORE_CPU_DIR_}/cpu.lo
_EVENT_LO_ = ${_CORE_EVENT_DIR_}/event.lo
_ID_LO_ = ${_CORE_ID_DIR_}/id.lo
_INTERFACE_LO_ = ${_CORE_INTERFACE_DIR_}/interface.lo
_IO_LO_ = ${_CORE_IO_DIR_}/io.lo
_KERNEL_LO_ = ${_CORE_KERNEL_DIR_}/kernel.lo
_MAP_LO_ = ${_CORE_MAP_DIR_}/map.lo
_MESSAGE_LO_ = ${_CORE_MESSAGE_DIR_}/message.lo
_REGION_LO_ = ${_CORE_REGION_DIR_}/region.lo
_SCHEDULER_LO_ = ${_CORE_SCHEDULER_DIR_}/scheduler.lo
_SEGMENT_LO_ = ${_CORE_SEGMENT_DIR_}/segment.lo
_SET_LO_ = ${_CORE_SET_DIR_}/set.lo
_TASK_LO_ = ${_CORE_TASK_DIR_}/task.lo
_THREAD_LO_ = ${_CORE_THREAD_DIR_}/thread.lo
_TIMER_LO_ = ${_CORE_TIMER_DIR_}/timer.lo
#
# ---------- binaries ---------------------------------------------------------
#
_LOADER_ = ${_LOADER_DIR_}/loader
_KANETON_ = ${_KANETON_DIR_}/kaneton
#
# ---------- environment files ------------------------------------------------
#
_ENV_MK_ = ${_ENVIRONMENT_DIR_}/env.mk
_ENV_PY_ = ${_ENVIRONMENT_DIR_}/env.py
#
# ---------- tools ------------------------------------------------------------
#
_CTC_BUILD_TOOL_ = ${_CTC_DIR_}/buildctf
_CTC_GATHER_TOOL_ = ${_CTC_DIR_}/enhashctf
_CTC_COMPARE_TOOL_ = ${_CTC_DIR_}/ctcompare
_CTC_SHOW_TOOL_ = ${_CTC_DIR_}/showkeys
_CTC_DETOK_TOOL_ = ${_CTC_DIR_}/detok
_MKP_TOOL_ = ${_MKP_DIR_}/mkp.py
_REPLAY_TOOL_ = ${_SCRIPT_DIR_}/scriptreplay.pl
#
# ---------- test -------------------------------------------------------------
#
_TEST_CLIENT_DIR_ = ${_TEST_DIR_}/client
_TEST_CONFIGURATION_DIR_ = ${_TEST_DIR_}/configuration
_TEST_ENGINE_DIR_ = ${_TEST_DIR_}/engine
_TEST_PACKAGES_DIR_ = ${_TEST_DIR_}/packages
_TEST_SERVER_DIR_ = ${_TEST_DIR_}/server
_TEST_STORE_DIR_ = ${_TEST_DIR_}/store
_TEST_SUITES_DIR_ = ${_TEST_DIR_}/suites
_TEST_TESTS_DIR_ = ${_TEST_DIR_}/tests
_TEST_UTILITIES_DIR_ = ${_TEST_DIR_}/utilities
_TEST_SUITES_DIR_ = ${_TEST_DIR_}/suites
_TEST_HOOKS_DIR_ = ${_TEST_DIR_}/hooks
_TEST_TESTS_BOOT_DIR_ = ${_TEST_TESTS_DIR_}/boot
_TEST_TESTS_KANETON_DIR_ = ${_TEST_TESTS_DIR_}/kaneton
_TEST_ENGINE_LO_ = ${_TEST_ENGINE_DIR_}/engine.lo
_TEST_STORE_CAPABILITY_DIR_ = ${_TEST_STORE_DIR_}/capability
_TEST_STORE_CERTIFICATE_DIR_ = ${_TEST_STORE_DIR_}/certificate
_TEST_STORE_CODE_DIR_ = ${_TEST_STORE_DIR_}/code
_TEST_STORE_DATABASE_DIR_ = ${_TEST_STORE_DIR_}/database
_TEST_STORE_KEY_DIR_ = ${_TEST_STORE_DIR_}/key
_TEST_STORE_REPORT_DIR_ = ${_TEST_STORE_DIR_}/report
_TEST_STORE_BUNDLE_DIR_ = ${_TEST_STORE_DIR_}/bundle/${_PLATFORM_}.${_ARCHITECTURE_}
_TEST_STORE_SNAPSHOT_DIR_ = ${_TEST_STORE_DIR_}/snapshot
_TEST_STORE_BUNDLE_BOOT_LO_ = ${_TEST_STORE_BUNDLE_DIR_}/boot.lo
_TEST_STORE_BUNDLE_KANETON_LO_ = ${_TEST_STORE_BUNDLE_DIR_}/kaneton.lo
_TEST_CLIENT_SCRIPT_ = ${_TEST_CLIENT_DIR_}/client.py
_TEST_SERVER_SCRIPT_ = ${_TEST_SERVER_DIR_}/server.py
_TEST_CAPABILITY_SCRIPT_ = ${_TEST_UTILITIES_DIR_}/capability.py
_TEST_CERTIFICATE_SCRIPT_ = ${_TEST_UTILITIES_DIR_}/certificate.py
_TEST_CODE_SCRIPT_ = ${_TEST_UTILITIES_DIR_}/code.py
_TEST_DATABASE_SCRIPT_ = ${_TEST_UTILITIES_DIR_}/database.py
_TEST_INVENTORY_SCRIPT_ = ${_TEST_UTILITIES_DIR_}/inventory.py
#
# ---------- scripts ----------------------------------------------------------
#
_INITIALIZE_SCRIPT_ = ${_ENVIRONMENT_DIR_}/initialize.py
_CLEAN_SCRIPT_ = ${_ENVIRONMENT_DIR_}/clean.py
_CONFIGURE_SCRIPT_ = ${_CONFIGURE_DIR_}/configure.py
_EXPORT_SCRIPT_ = ${_EXPORT_DIR_}/export.py
_CHEAT_SCRIPT_ = ${_CHEAT_DIR_}/cheat.py
_RECORD_SCRIPT_ = ${_TRANSCRIPT_DIR_}/record.py
_PLAY_SCRIPT_ = ${_TRANSCRIPT_DIR_}/play.py
_VIEW_SCRIPT_ = ${_VIEW_DIR_}/view.py
#
# ---------- makefile dependency file -----------------------------------------
#
_DEPENDENCY_MK_ = .dependency.mk
#
# ---------- latex dependency file --------------------------------------------
#
_DEPENDENCY_TEX_ = .dependency.tex
#
# ---------- python package directories ---------------------------------------
#
_PYTHON_INCLUDE_DIR_ = ${_ENVIRONMENT_DIR_}:${_TEST_PACKAGES_DIR_}

View file

@ -0,0 +1,113 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...ironment/profile/host/darwin/darwin.conf
#
# created julien quintard [tue may 8 13:19:52 2007]
# updated julien quintard [fri may 1 02:11:38 2009]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains the libraries, binaries, script and tools related to
# the generic darwin host sub-profile.
#
#
# ---------- includes ---------------------------------------------------------
#
_INCLUDES_ = -I${_INCLUDE_DIR_}
#
# ---------- flags ------------------------------------------------------------
#
_CC_FLAGS_ = -D___kaneton \
${_INCLUDES_} \
${_KANETON_FLAGS_} \
-fno-builtin \
-Wimplicit \
-Wparentheses \
-Wreturn-type \
-Wswitch -Wswitch-enum \
-Wunused-function \
-Wunused-variable \
-Wmissing-prototypes \
-Wmissing-declarations \
-Wall
_LD_FLAGS_ = ${_INCLUDES_}
_AS_FLAGS_ =
_CPP_FLAGS_ =
_SHELL_FLAGS_ =
_PYTHON_FLAGS_ =
_PERL_FLAGS_ =
_MAKE_FLAGS_ =
#
# ---------- binaries ---------------------------------------------------------
#
_BINARIES_ = ${_SHELL_}, ${_CC_}, ${_MAKE_}, \
${_RM_}, ${_AR_}, ${_RANLIB_}, \
${_LD_}, ${_AS_}, ${_BIBTEX_},\
${_LN_}, ${_TOUCH_}, ${_WC_}, \
${_DATE_}, ${_TAIL_}, ${_TAR_}, \
${_PDFLATEX_}, ${_CP_}, \
${_CAT_}, ${_SED_}, ${_CPP_}, \
${_MTOOLS_}, ${_MCOPY_}, \
${_XPDF_}, ${_MKTEMP_}, ${_MV_},\
${_LEX_}, ${_SCRIPT_}, \
${_PERL_}, ${_PYTHON_}, \
${_DIRNAME_}, ${_BASENAME_}, \
${_WHICH_}
_SHELL_ = bash
_CC_ = i386-elf-gcc-3.4.6
_AS_ = i386-elf-as
_MAKE_ = gmake
_RM_ = rm -f
_PURGE_ = ${_RM_} *.pyc *~ .*~ \#* .\#*
_AR_ = i386-elf-ar cq
_RANLIB_ = i386-elf-ranlib
_CD_ = cd
_LD_ = i386-elf-ld
_LN_ = ln -s -f
_TOUCH_ = touch
_WC_ = wc
_DATE_ = date -u
_TAIL_ = tail
_TAR_ = tar
_PDFLATEX_ = pdflatex
_BIBTEX_ = bibtex
_CP_ = cp
_CAT_ = cat
_SED_ = sed -r
_ECHO_ = /bin/echo
_CPP_ = i386-elf-cpp-3.4.6
_MTOOLS_ = mtools
_MCOPY_ = mcopy
_XPDF_ = open
_MKTEMP_ = mktemp
_MV_ = mv
_PWD_ = pwd
_LEX_ = lex -t
_SCRIPT_ = script
_PERL_ = perl
_PYTHON_ = python2.5
_DIRNAME_ = dirname
_BASENAME_ = basename
_WHICH_ = which
_EXIT_ = exit

View file

@ -0,0 +1,33 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/fanfwe/kane...nvironment/profile/host/darwin/darwin.desc
#
# created julien quintard [tue may 8 13:20:04 2007]
# updated francois goudal [mon aug 4 15:54:31 2008]
#
#
# ---------- information ------------------------------------------------------
#
# this file describes the darwin environment variables.
#
- variable: _SHELL_
string: Shell
type: any
description: The shell binary path
- variable: _CC_
string: C Compiler
type: any
description: The C compiler binary path
- variable: _MAKE_
string: Make
type: any
description: The make binary path

View file

@ -0,0 +1,493 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...nvironment/profile/host/darwin/darwin.mk
#
# created julien quintard [tue may 8 13:03:34 2007]
# updated julien quintard [fri aug 29 20:03:17 2008]
#
#
# ---------- information ------------------------------------------------------
#
# this file implements the remaining functions of the kaneton make interface.
#
# indeed the major generic part of the interface is already provided by the
# host profile.
#
#
# ---------- python path ------------------------------------------------------
#
export PYTHONPATH=$(shell $(_ECHO_) $${PYTHONPATH}):$(_PYTHON_INCLUDE_DIR_)
#
# ---------- functions --------------------------------------------------------
#
#
# colorize functions
#
# 1: text
# 2: options
#
define env_colorize-black
"$(1)"
endef
define env_colorize-red
"$(1)"
endef
define env_colorize-green
"$(1)"
endef
define env_colorize-yellow
"$(1)"
endef
define env_colorize-blue
"$(1)"
endef
define env_colorize-magenta
"$(1)"
endef
define env_colorize-cyan
"$(1)"
endef
define env_colorize-white
"$(1)"
endef
define env_colorize-
"$(1)"
endef
#
# perform function
#
# 1: command
#
ifeq ($(_OUTPUT_),$(_OUTPUT_VERBOSE_)) # if the user wants to display
# additional debug information
define env_perform
$(_ECHO_) " $(1)" && \
$(1)
endef
else
define env_perform
$(1)
endef
endif
#
# print functions wrapper
#
# 1: text
# 2: color
# 3: options
#
ifeq ($(_DISPLAY_),$(_DISPLAY_COLORED_)) # if the user wants to display
# the text with color
define env_print
print_options="" && \
if [ -n "$(3)" ] ; then \
if [ $$(( $(3) & $(ENV_OPTION_NO_NEWLINE) )) -ne 0 ] ; then \
print_options="$${print_options} -n" ; \
fi ; \
fi && \
$(_ECHO_) $${print_options} $(call env_colorize-$(2),$(1),)
endef
else # if not ...
define env_print
print_options="" && \
if [ -n "$(3)" ] ; then \
if [ $$(( $(3) & $(ENV_OPTION_NO_NEWLINE) )) -ne 0 ] ; then \
print_options="$${print_options} -n" ; \
fi ; \
fi && \
$(_ECHO_) $${print_options} $(1)
endef
endif
#
# change the current working directory
#
# $(1): directory
# $(2): options
#
define env_cd
cd_options="" && \
$(call env_perform, \
$(_CD_) $${cd_options} $(1))
endef
#
# returns a file contents
#
# $(1): the file
# $(2): options
#
define env_pull
$(_CAT_) $(2) $(1)
endef
#
# launch a new program/script/make etc.
#
# $(1): file
# $(2): arguments
# $(3): options
#
define env_launch
launch_options="" && \
cwd=$$($(_PWD_)) && \
directory=$$($(_DIRNAME_) $(1)) && \
file=$$($(_BASENAME_) $(1)) && \
if [ "$${directory}" != "." ] ; then \
$(call env_perform, \
$(_CD_) $${directory}) ; \
fi && \
case "$${file}" in \
*.sh) \
$(call env_perform, \
$(_SHELL_) $${launch_options} $${file} $(_SHELL_FLAGS_) $(2)) ; \
;; \
*.py) \
$(call env_perform, \
$(_PYTHON_) $${launch_options} $${file} $(_PYTHON_FLAGS_) $(2)) ; \
;; \
*.pl) \
$(call env_perform, \
$(_PERL_) $${launch_options} $${file} $(_PERL_FLAGS_) $(2)) ; \
;; \
Makefile) \
$(call env_perform, \
$(_MAKE_) $${launch_options} -f $${file} $(_MAKE_FLAGS_) ${2}) ; \
;; \
esac ; \
return=$${?} && \
if [ "$${directory}" != "." ] ; then \
$(call env_perform, \
$(_CD_) $${cwd}) ; \
fi && \
if [ $${return} -ne 0 ] ; then \
$(_EXIT_) 42 ; \
fi
endef
#
# from c file to preprocessed c file
#
# $(1): preprocessed file
# $(2): c file
# $(3): options
#
define env_preprocess
preprocess_options="" && \
$(call env_display,green,PREPROCESS,$(2), ,) && \
$(call env_perform, \
$(_CPP_) -P $(_CPP_FLAGS_) $${preprocess_options} $(2) -o $(1))
endef
#
# from c file to object file
#
# $(1): object file
# $(2): c file
# $(3): options
#
define env_compile-c
compile_c_options="" && \
$(call env_display,green,COMPILE-C,$(2), ,) && \
$(call env_perform, \
$(_CC_) $(_CC_FLAGS_) $${compile_c_options} -c $(2) -o $(1))
endef
#
# from lex file to c file
#
# $(1): c file
# $(2): lex file
# $(3): options
#
define env_lex-l
lex_l_options="" && \
$(call env_display,green,LEX-L,$(2), ,) && \
$(call env_perform, \
$(_LEX_) $${lex_l_options} $(2) > $(1))
endef
#
# from S file to object file
#
# $(1): object file
# $(2): S file
# $(3): options
#
define env_assemble-S
assemble_S_options="" && \
$(call env_display,green,ASSEMBLE-S,$(2), ,) && \
$(call env_perform, \
$(_CPP_) $(2) | $(_AS_) $(_AS_FLAGS_) $${assemble_S_options} -o $(1))
endef
#
# create a static library from object files
#
# $(1): static library file name
# $(2): object files
# $(3): options
#
define env_static-library
static_library_options="" && \
$(call env_display,magenta,STATIC-LIBRARY,$(1), ,) && \
$(call env_perform, \
$(_AR_) $${static_library_options} $(1) $(2)) && \
$(call env_perform, \
$(_RANLIB_) $${static_library_options} $(1))
endef
#
# create a dynamic library from object files, static libraries
# and/or dynamic libraries
#
# $(1): dynamic library file name
# $(2): objects files and/or libraries
# $(3): options
#
define env_dynamic-library
dynamic_library_options="" && \
$(call env_display,magenta,DYNAMIC-LIBRARY,$(1), ,) && \
$(call env_perform, \
$(_LD_) --shared $(_LD_FLAGS_) $${dynamic_library_options} \
-o $(1) $(2))
endef
#
# create an executable file from object file and/or library files
#
# $(1): executable file name
# $(2): objects files and/or libraries
# $(3): layout file
# $(4): options
#
define env_executable
executable_options="" && \
if [ -n "$(3)" ] ; then \
executable_options="$${executable_options} -T $(3)" ; \
fi && \
if [ -n "$(4)" ] ; then \
if [ $$(( $(4) & $(ENV_OPTION_NO_STANDARD) )) -ne 0 ] ; then \
executable_options="$${executable_options} -nostdinc -nostdlib" ; \
fi ; \
fi && \
$(call env_display,magenta,EXECUTABLE,$(1), ,) && \
$(call env_perform, \
$(_CC_) $(_CC_FLAGS_) $(_LD_FLAGS_) $${executable_options} -o $(1) \
$(2) "`$(_CC_) -print-libgcc-file-name`")
endef
#
# create an archive file from multiple object files
#
# note that the archive file is also an object file
#
# $(1): archive file name
# $(2): objects files and/or libraries
# $(3): options
#
define env_archive
archive_options="" && \
$(call env_display,magenta,ARCHIVE,$(1), ,) && \
$(call env_perform, \
$(_LD_) -r $(_LD_FLAGS_) $${archive_options} -o $(1) $(2))
endef
#
# remove the files
#
# $(1): files
# $(2): options
#
define env_remove
remove_options="" && \
for f in $(1) ; do \
if [ -e $${f} ] ; then \
$(call env_display,red,REMOVE,$${f}, ,) ; \
fi && \
$(call env_perform, \
$(_RM_) $${remove_options} $${f}) ; \
done
endef
#
# purge i.e clean the directory from unwanted files
#
define env_purge
$(call env_display,red,PURGE,,,) && \
$(call env_perform, \
$(_PURGE_))
endef
#
# generate prototypes from a source file
#
# $(1): file list
# $(2): options
#
define env_prototypes
prototypes_options="" && \
for f in $(1) ; do \
if [ -e $${f} ] ; then \
$(call env_display,yellow,PROTOTYPES,$${f}, ,) && \
$(call env_launch,$(_MKP_TOOL_), \
$${prototypes_options} $${f},) ; \
fi ; \
done
endef
#
# genereate header dependencies
#
# $(1): the files for which the dependencies are generated
# $(2): options
#
define env_headers
headers_options="" && \
for f in $(1) ; do \
if [ -e $${f} ] ; then \
$(call env_display,yellow,HEADERS,$$f, ,) && \
$(call env_perform, \
$(_CC_) $(_CC_FLAGS_) -M -MG $${headers_options} \
$${f} >> $(_DEPENDENCY_MK_)) ; \
fi ; \
done
endef
#
# generate a version file
#
# $(1): the version file to generate
#
define env_version
$(call env_display,yellow,VERSION,$(1), ,) && \
$(_ECHO_) -n "" > $(1) && \
$(_ECHO_) -n "const char version[] = \"$(_TITLE_)-$(_VERSION_)" >> $(1) && \
$(_ECHO_) " "$(shell LANG=C $(_DATE_))" $(USER)@$(HOSTNAME)\";" >> $(1)
endef
#
# create a link between two files
#
# $(1): link created
# $(2): destination
# $(3): options
#
define env_link
link_options="" && \
$(call env_display,cyan,LINK,$(1), ,) && \
$(call env_perform, \
$(_LN_) $${link_options} $(2) $(1))
endef
#
# compile a tex document
#
# $(1): the file name without extension
# $(2): options
#
define env_compile-tex
compile_tex_options="" && \
$(call env_display,green,COMPILE-TEX,$(1), ,) && \
$(call env_perform, \
$(_PDFLATEX_) $${compile_tex_options} $(1).tex) && \
$(call env_perform, \
$(_BIBTEX_) $(1).tex) && \
$(call env_perform, \
$(_PDFLATEX_) $${compile_tex_options} $(1).tex) ; \
$(call env_perform, \
$(_PDFLATEX_) $${compile_tex_options} $(1).tex)
endef
#
# build a document
#
# $(1): the file name without extension
# $(2): options
#
define env_document
if [ -n "$(2)" ] ; then \
if [ $$(( $(2) & $(ENV_OPTION_PRIVATE) )) -ne 0 ] ; then \
$(_ECHO_) '\def\mode{private}' > $(_DEPENDENCY_TEX_) ; \
fi ; \
fi && \
if [ ! -f $(_DEPENDENCY_TEX_) ] ; then \
$(_ECHO_) '\def\mode{public}' > $(_DEPENDENCY_TEX_) ; \
fi && \
$(call env_compile-tex,$(1),$(2))
endef
#
# launch a document viewer
#
# $(1): the file name without extension
# $(2): options
#
define env_view
$(call env_display,yellow,VIEW,$(1), ,) && \
$(call env_perform, \
$(_XPDF_) $(1).pdf)
endef
#
# ---------- component-based behaviour ----------------------------------------
#
#
# meta definitions
#
ifneq ($(call findstring,kaneton,$(components)),)
_CC_FLAGS_ += -D___kaneton$$\kernel
endif

View file

@ -0,0 +1,226 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...nvironment/profile/host/darwin/darwin.py
#
# created julien quintard [tue may 8 13:20:21 2007]
# updated julien quintard [tue may 5 12:10:33 2009]
#
#
# ---------- information ------------------------------------------------------
#
# this file implements the remaining functions of the kaneton python interface.
#
# note that the host profile already provides many functions. these
# functions can be overriden but you will probably just use them.
#
# in addition, the host profile already imports some packages.
#
#
# ---------- python path ------------------------------------------------------
#
pythonpath = os.getenv("PYTHONPATH")
if not pythonpath:
pythonpath = ""
os.putenv("PYTHONPATH", pythonpath + ":" + _PYTHON_INCLUDE_DIR_)
#
# ---------- functions --------------------------------------------------------
#
#
# colorize()
#
# this function returns a colorized text if the environment is configured
# to or simply the original text.
#
# note that this function implementation is based on UNIX escape sequences.
#
def colorize(text, color, options):
if _DISPLAY_ == _DISPLAY_UNCOLORED_:
return text
if options & OPTION_FLICKERING:
text = "" + text
if options & OPTION_BOLD:
text = "" + text
if color == COLOR_BLACK:
text = "" + text
elif color == COLOR_RED:
text = "" + text
elif color == COLOR_GREEN:
text = "" + text
elif color == COLOR_YELLOW:
text = "" + text
elif color == COLOR_BLUE:
text = "" + text
elif color == COLOR_MAGENTA:
text = "" + text
elif color == COLOR_CYAN:
text = "" + text
elif color == COLOR_WHITE:
text = "" + text
return text + ""
#
# launch()
#
# this function launch a new program/script/make etc.
#
def launch(file, arguments, options):
directory = None
info = None
status = 0
wd = None
if options & OPTION_QUIET:
output = " >/dev/null 2>&1"
else:
output = ""
info = os.path.split(file)
directory = info[0]
file = info[1]
if directory:
wd = cwd(OPTION_NONE)
cd(directory, OPTION_NONE)
if re.match("^.*\.sh$", file):
status = os.system(_SHELL_ + " " + file + " " + arguments + output)
elif re.match("^.*\.py$", file):
status = os.system(_PYTHON_ + " " + file + " " + arguments + output)
elif re.match("^.*\.pl$", file):
status = os.system(_PERL_ + " " + file + " " + arguments + output)
elif re.match("^Makefile$", file):
status = os.system(_MAKE_ + " -f " + file + " " + arguments + output)
else:
status = os.system(file + " " + arguments + output)
if directory:
cd(wd, OPTION_NONE)
return status
#
# pack()
#
# this function creates an archive of the given directory.
#
def pack(directory, file, options):
launch(_TAR_, "-cjf " + file + " " + directory, OPTION_NONE)
#
# unpack()
#
# this function unpackages an archive into the given (optional) directory.
#
def unpack(file, directory, options):
if directory:
launch(_TAR_, "-xjf " + file + " -C " + directory, OPTION_NONE)
else:
launch(_TAR_, "-xjf " + file, OPTION_NONE)
#
# load()
#
# this function copies a file on a device, this device can be virtual:
# an image.
#
def load(file, device, path, options):
if options == OPTION_DEVICE:
launch(_MCOPY_, "-o -n " + file + " " + device + path, OPTION_NONE)
if options == OPTION_IMAGE:
launch(_MCOPY_, "-o -n " + "-i" + device + " " +
file + " ::" + path, OPTION_NONE)
#
# record()
#
# this function runs the program recording a session.
#
def record(transcript, options):
directory = None
time = None
log = None
tmp = None
wd = None
tmp = temporary(OPTION_DIRECTORY)
directory = tmp + "/" + "transcript"
log = directory + "/" + "log"
time = directory + "/" + "time"
mkdir(directory, OPTION_NONE)
launch(_SCRIPT_, "-q -t " + log + " -c " +
_TRANSCRIPT_CMD_ + " 2> " + time, OPTION_NONE)
wd = cwd(OPTION_NONE)
cd(tmp, OPTION_NONE)
pack("transcript", wd + "/" + transcript, OPTION_NONE)
cd(wd, OPTION_NONE)
remove(tmp, OPTION_NONE)
#
# play()
#
# this function runs the program replaying a session.
#
def play(transcript, options):
directory = None
time = None
log = None
tmp = None
wd = None
tmp = temporary(OPTION_DIRECTORY)
log = tmp + "/" + "transcript/log"
time = tmp + "/" + "transcript/time"
unpack(transcript, tmp, OPTION_NONE)
launch(_SCRIPTREPLAY_TOOL_, time + " " + log, OPTION_NONE)
remove(tmp, OPTION_NONE)
#
# locate()
#
# this function tries to locate a program on the system.
#
def locate(file, options):
return launch(_WHICH_, file + " 1>/dev/null 2>/dev/null", OPTION_NONE)

View file

@ -0,0 +1 @@
.

View file

@ -0,0 +1,33 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/fanfwe/kane...t/profile/host/darwin/ia32.ia32/ia32.conf
#
# created julien quintard [thu jun 28 21:15:33 2007]
# updated francois goudal [mon aug 4 15:57:00 2008]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains definitions specific to the ia32 target microprocessor
# architecture.
#
#
# include the darwin generic definitions
#
include ../darwin.conf
#
# microprocessor specific definitions
#
_CC_FLAGS_ += -D___kaneton$$\endian=0 \
-D___kaneton$$\wordsz=32 \
-D___kaneton$$\pagesz=4096

View file

@ -0,0 +1 @@
../darwin.desc

View file

@ -0,0 +1 @@
../darwin.mk

View file

@ -0,0 +1 @@
../darwin.py

View file

@ -0,0 +1 @@
.

View file

@ -0,0 +1,33 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/fanfwe/kane...t/profile/host/darwin/ia32.null/null.conf
#
# created julien quintard [thu jun 28 21:15:33 2007]
# updated francois goudal [mon aug 4 16:05:31 2008]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains definitions specific to the null target microprocessor
# architecture.
#
#
# include the darwin generic definitions
#
include ../darwin.conf
#
# microprocessor specific definitions
#
_CC_FLAGS_ += -D___kaneton$$\endian=0 \
-D___kaneton$$\wordsz=32 \
-D___kaneton$$\pagesz=1

View file

@ -0,0 +1 @@
../darwin.desc

View file

@ -0,0 +1 @@
../darwin.mk

View file

@ -0,0 +1 @@
../darwin.py

View file

@ -0,0 +1,33 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/profile/host/host.conf
#
# created julien quintard [tue may 8 13:03:21 2007]
# updated julien quintard [fri dec 17 20:04:01 2010]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains the default host variables. the different hosts
# should either complete or override them.
#
#
# ---------- garbage ----------------------------------------------------------
#
_GARBAGE_ = *~ .*~ \#* .\#* *.pyc *.aux \
*.log *.toc *.bbl *.blg *.nav \
*.out *.snm *.vrb *.pdf
#
# ---------- binaries ---------------------------------------------------------
#
_BINARIES_ = <null>

View file

@ -0,0 +1,18 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/profile/host/host.desc
#
# created julien quintard [tue may 8 13:03:26 2007]
# updated julien quintard [sat may 19 14:30:26 2007]
#
#
# ---------- information ------------------------------------------------------
#
# XXX
#

View file

@ -0,0 +1,214 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton.STABLE/environment/profile/host/host.mk
#
# created julien quintard [tue may 8 13:03:34 2007]
# updated julien quintard [mon nov 29 10:18:58 2010]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains generic stuff about the implementation of the kaneton
# make interface. there are few functions here because make was not designed
# in a portable way.
#
#
# ---------- directives -------------------------------------------------------
#
.SILENT:
#
# ---------- options ----------------------------------------------------------
#
ENV_HEADER_NONE = 0
ENV_HEADER_OK = 1
ENV_HEADER_ERROR = 2
ENV_HEADER_INTERACTIVE = 4
ENV_COLOR_NONE = 0
ENV_COLOR_RED = 1
ENV_COLOR_GREEN = 2
ENV_COLOR_YELLOW = 3
ENV_COLOR_BLUE = 4
ENV_COLOR_WHITE = 5
ENV_OPTION_NONE = 0
ENV_OPTION_NO_NEWLINE = 1
ENV_OPTION_FLICKERING = 2
ENV_OPTION_NO_STANDARD = 1
ENV_OPTION_STANDARD = 2
ENV_OPTION_PRIVATE = 1
#
# ---------- default rule -----------------------------------------------------
#
# this rule is invoked when a Makefile is called without specifying a
# rule name.
#
# this rule is intended to check whether the configured environment files
# are up-to-date. if not, this rule re-builds the configured environment files.
#
ENV_DEPENDENCIES := $(wildcard \
$(_PROFILE_DIR_)/*.conf \
$(_PROFILE_DIR_)/host/*.conf \
$(_PROFILE_DIR_)/host/*.mk \
$(_PROFILE_DIR_)/host/*.py \
$(_PROFILE_HOST_DIR_)/*.conf \
$(_PROFILE_HOST_DIR_)/*.mk \
$(_PROFILE_HOST_DIR_)/*.py \
$(_PROFILE_DIR_)/kaneton/*.conf \
$(_PROFILE_DIR_)/kaneton/*.py \
$(_PROFILE_DIR_)/kaneton/*.mk \
$(_PROFILE_LIBRARY_DIR_)/*.conf \
$(_PROFILE_LIBRARY_DIR_)/*.mk \
$(_PROFILE_LIBRARY_DIR_)/*.py \
$(_PROFILE_MODULES_DIR_)/*.conf \
$(_PROFILE_MODULES_DIR_)/*.mk \
$(_PROFILE_MODULES_DIR_)/*.py \
$(_PROFILE_MACHINE_DIR_)/*.conf \
$(_PROFILE_MACHINE_DIR_)/*.mk \
$(_PROFILE_MACHINE_DIR_)/*.py \
$(_PROFILE_PLATFORM_DIR_)/*.conf \
$(_PROFILE_PLATFORM_DIR_)/*.mk \
$(_PROFILE_PLATFORM_DIR_)/*.py \
$(_PROFILE_ARCHITECTURE_DIR_)/*.conf \
$(_PROFILE_ARCHITECTURE_DIR_)/*.mk \
$(_PROFILE_ARCHITECTURE_DIR_)/*.py \
$(_PROFILE_GLUE_DIR_)/*.conf \
$(_PROFILE_GLUE_DIR_)/*.mk \
$(_PROFILE_GLUE_DIR_)/*.py \
$(_PROFILE_CORE_DIR_)/*.conf \
$(_PROFILE_CORE_DIR_)/*.mk \
$(_PROFILE_CORE_DIR_)/*.py \
$(_PROFILE_DIR_)/user/*.conf \
$(_PROFILE_DIR_)/user/*.mk \
$(_PROFILE_DIR_)/user/*.py \
$(_PROFILE_USER_DIR_)/*.conf \
$(_PROFILE_USER_DIR_)/*.mk \
$(_PROFILE_USER_DIR_)/*.py)
_: $(_ENV_MK_) $(_ENV_PY_)
$(call env_launch,Makefile,main,)
$(_ENV_MK_) $(_ENV_PY): \
$(ENV_DEPENDENCIES)
$(call env_launch,$(_ENVIRONMENT_DIR_)/Makefile,initialize,)
#
# ---------- traps ------------------------------------------------------------
#
%.o: %.S
$(call env_assemble-S,$@,$<,)
%.o: %.c
$(call env_compile-c,$@,$<,)
%.c: %.l
$(call env_lex-l,$@,$<,)
#
# ---------- functions --------------------------------------------------------
#
#
# display functions
#
# 1: action
# 2: file
# 3: identation
# 4: options
#
define env_display-red
$(call env_print,[,blue,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,$(1),red,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,],blue,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,$(3)$(2),,)
endef
define env_display-green
$(call env_print,[,blue,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,$(1),green,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,],blue,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,$(3)$(2),,)
endef
define env_display-yellow
$(call env_print,[,blue,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,$(1),yellow,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,],blue,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,$(3)$(2),,)
endef
define env_display-magenta
$(call env_print,[,blue,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,$(1),magenta,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,],blue,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,$(3)$(2),,)
endef
define env_display-cyan
$(call env_print,[,blue,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,$(1),cyan,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,],blue,$(ENV_OPTION_NO_NEWLINE)) && \
$(call env_print,$(3)$(2),,)
endef
#
# display wrapper
#
# $(1): color
# $(2): action
# $(3): file
# $(4): indentation
# $(5): options
#
define env_display
$(call env_display-$(1),$(2),$(3),$(4),$(5))
endef
#
# ---------- information ------------------------------------------------------
#
directory := $(CURDIR)
#
# ---------- component-based behaviour ----------------------------------------
#
#
# behaviour
#
behaviour := default
#
# components
#
ifeq ($(call findstring,$(component),$(components)),)
components += $(component)
endif
export components
#
# ---------- cc flags ---------------------------------------------------------
#
_CC_FLAGS_ += $(foreach m,$(_MODULES_),-DMODULE_$(m))

View file

@ -0,0 +1,382 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/profile/host/host.py
#
# created julien quintard [tue may 8 13:03:40 2007]
# updated julien quintard [mon mar 7 16:36:27 2011]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains generic stuff about the python interface including
# options and general functions.
#
# since the python scripting language was designed to provide portable
# operations, the following operations are considered as generic, making
# work easier for host sub-profiles.
#
#
# ---------- imports ----------------------------------------------------------
#
import os
import re
import sys
import tempfile
import shutil
import time
#
# ---------- options ----------------------------------------------------------
#
HEADER_NONE = 0
HEADER_OK = 1
HEADER_ERROR = 2
HEADER_INTERACTIVE = 4
COLOR_NONE = 0
COLOR_BLACK = 1
COLOR_RED = 2
COLOR_GREEN = 3
COLOR_YELLOW = 4
COLOR_BLUE = 5
COLOR_MAGENTA = 6
COLOR_CYAN = 7
COLOR_WHITE = 8
OPTION_NONE = 0
OPTION_QUIET = 1
OPTION_NO_NEWLINE = 1
OPTION_FLICKERING = 2
OPTION_BOLD = 4
OPTION_FILE = 1
OPTION_DIRECTORY = 2
OPTION_LINK = 4
OPTION_RECURSIVE = 8
OPTION_EXIST = 16
OPTION_HIDDEN = 32
OPTION_ALL = OPTION_FILE | OPTION_DIRECTORY | OPTION_LINK
OPTION_DEVICE = 1
OPTION_IMAGE = 2
OPTION_CURRENT_DIRECTORY = 1
#
# ---------- functions --------------------------------------------------------
#
#
# display()
#
# this function prints a kaneton message.
#
def display(header, text, options):
if header == HEADER_NONE:
sys.stdout.write(colorize(text, COLOR_NONE, OPTION_NONE))
elif header == HEADER_OK:
sys.stdout.write(colorize("[", COLOR_BLUE, OPTION_BOLD))
sys.stdout.write(colorize("+", COLOR_GREEN, OPTION_BOLD))
sys.stdout.write(colorize("]", COLOR_BLUE, OPTION_BOLD))
sys.stdout.write(" ")
sys.stdout.write(colorize(text, COLOR_NONE, OPTION_NONE))
elif header == HEADER_ERROR:
sys.stdout.write(colorize("[", COLOR_BLUE, OPTION_BOLD))
sys.stdout.write(colorize("!", COLOR_RED, OPTION_BOLD))
sys.stdout.write(colorize("]", COLOR_BLUE, OPTION_BOLD))
sys.stdout.write(" ")
sys.stdout.write(colorize(text, COLOR_NONE, OPTION_NONE))
elif header == HEADER_INTERACTIVE:
sys.stdout.write(colorize("[", COLOR_BLUE, OPTION_BOLD))
sys.stdout.write(colorize("?",
COLOR_YELLOW,
OPTION_FLICKERING | OPTION_BOLD))
sys.stdout.write(colorize("]", COLOR_BLUE, OPTION_BOLD))
sys.stdout.write(" ")
sys.stdout.write(colorize(text, COLOR_NONE, OPTION_NONE))
if not options & OPTION_NO_NEWLINE:
sys.stdout.write("\n")
#
# pull()
#
# this function reads the content of a single file.
#
def pull(file, options):
handle = None
line = None
if not os.path.exists(file):
return None
try:
handle = open(file, "r")
except IOError:
return None
content = ""
for line in handle.readlines():
content += line
handle.close()
return content
#
# push()
#
# this function writes the content of a single file.
#
def push(file, content, options):
handle = None
handle = open(file, "w")
handle.write(content)
handle.close()
#
# temporary()
#
# this function provides an easy way to create a temporary file or directory.
#
def temporary(options):
location = None
if options == OPTION_FILE:
tuple = tempfile.mkstemp()
os.close(tuple[0])
location = tuple[1]
elif options == OPTION_DIRECTORY:
location = tempfile.mkdtemp()
return location
#
# cwd()
#
# this function returns the current working directory.
#
def cwd(options):
return os.getcwd()
#
# input()
#
# this function waits for an input.
#
def input(options):
return input()
#
# copy()
#
# this function copies a file or a directory.
#
def copy(source, destination, options):
if os.path.isdir(source):
shutil.copytree(source, destination, True)
else:
shutil.copy2(source, destination)
#
# move()
#
# this function moves a file or a directory.
#
def move(source, destination, options):
copy(source, destination, options)
remove(source, options)
#
# link()
#
# this function builds a link name source to the file destination.
#
def link(source, destination, options):
os.symlink(destination, source)
#
# remove()
#
# this function removes the targets.
#
def remove(target, options):
entries = None
entry = None
if os.path.isfile(target) or os.path.islink(target):
os.unlink(target)
if os.path.isdir(target):
entries = os.listdir(target)
for entry in entries:
remove(target + "/" + entry, OPTION_NONE)
os.rmdir(target)
#
# list()
#
# this function lists the entries of a directory.
#
def list(directory, options):
elements = []
entries = None
entry = None
entries = os.listdir(directory)
for entry in entries:
if not (options & OPTION_HIDDEN) and \
(entry[0:1] == "."):
continue
if (options & OPTION_LINK) and \
(os.path.islink(directory + "/" + entry)):
elements += [ entry ]
if (options & OPTION_FILE) and \
(os.path.isfile(directory + "/" + entry)) and \
(not os.path.islink(directory + "/" + entry)):
elements += [ entry ]
if (options & OPTION_DIRECTORY) and \
(os.path.isdir(directory + "/" + entry)) and \
(not os.path.islink(directory + "/" + entry)):
elements += [ entry ]
return elements
#
# cd()
#
# this function changes the current working directory.
#
def cd(directory, options):
os.chdir(directory)
#
# search()
#
# this function searches for file names matching the given pattern.
#
def search(directory, pattern, options):
elements = []
entries = None
entry = None
entries = os.listdir(directory)
for entry in entries:
if (options & OPTION_FILE) and \
(os.path.isfile(directory + "/" + entry)) and \
(re.search(pattern, entry)):
elements += [ directory + "/" + entry ]
if (os.path.isdir(directory + "/" + entry)):
if (options & OPTION_DIRECTORY) and \
(re.search(pattern, entry)):
elements += [ directory + "/" + entry ]
if (options & OPTION_RECURSIVE) and \
(not os.path.islink(directory + "/" + entry)):
elements += search(directory + "/" + entry, pattern, options)
return elements
#
# mkdir()
#
# this function creates a directory.
#
def mkdir(directory, options):
path = None
steps = None
step = None
steps = directory.strip("/").split("/")
for step in steps:
if not path:
path = "/" + step
else:
path = path + "/" + step
if not os.path.exists(path):
os.mkdir(path)
#
# stamp()
#
# this function returns the current formatted date.
#
def stamp(options):
return time.strftime("%Y%m%d")
#
# path()
#
# this function returns information on a path: file, directory etc.
#
def path(path, options):
if options == OPTION_FILE:
return os.path.basename(path)
if options == OPTION_DIRECTORY:
return os.path.dirname(path)
if options == OPTION_EXIST:
return os.path.exists(path)
return None
#
# info()
#
# this function returns information on the system.
#
def info(options):
if (options & OPTION_CURRENT_DIRECTORY):
return os.path.curdir

View file

@ -0,0 +1 @@
.

View file

@ -0,0 +1 @@
../linux.conf

View file

@ -0,0 +1 @@
../linux.desc

View file

@ -0,0 +1 @@
../linux.mk

View file

@ -0,0 +1 @@
../linux.py

View file

@ -0,0 +1 @@
.

View file

@ -0,0 +1,137 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...ofile/host/linux/ia32.mips64/mips64.conf
#
# created julien quintard [thu jun 28 21:15:33 2007]
# updated julien quintard [fri may 1 23:54:21 2009]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains definitions specific to the mips64 target microprocessor
# architecture.
#
#
# include the linux generic definitions
#
_INCLUDES_ = -I${_INCLUDE_DIR_}
#
# ---------- flags ------------------------------------------------------------
#
_CC_FLAGS_ = -D___kaneton \
${_INCLUDES_} \
${_KANETON_FLAGS_} \
-fno-builtin \
-Wimplicit \
-Wparentheses \
-Wreturn-type \
-Wswitch -Wswitch-enum \
-Wunused-function \
-Wunused-variable \
-Wmissing-prototypes \
-Wmissing-declarations \
-Wall -W -std=c99 \
-mabi=64 \
-G 0 \
-march=mips64 \
-EL \
-mgp64 \
-mfp64 \
-mlong64 \
-DMIPS64_DEPENDENT \
-DMIPS64_DEV
_LD_FLAGS_ = --warn-unresolved-symbols \
--oformat=elf64-littlemips
_ASM_FLAGS_ = -mabi=64 \
-G 0 \
-march=mips64 \
-EL \
-mgp64 \
-mfp64
_CPP_FLAGS_ =
_SHELL_FLAGS_ =
_PYTHON_FLAGS_ =
_PERL_FLAGS_ =
_MAKE_FLAGS_ =
#
# ---------- binaries ---------------------------------------------------------
#
_BINARIES_ = ${_SHELL_}, ${_CC_}, ${_MAKE_}, \
${_RM_}, ${_AR_}, ${_RANLIB_}, \
${_LD_}, ${_AS_}, ${_BIBTEX_},\
${_LN_}, ${_TOUCH_}, ${_WC_}, \
${_DATE_}, ${_TAIL_}, ${_TAR_}, \
${_PDFLATEX_}, ${_CP_}, \
${_CAT_}, ${_SED_}, ${_CPP_}, \
${_MTOOLS_}, ${_MCOPY_}, \
${_XPDF_}, ${_MKTEMP_}, ${_MV_},\
${_LEX_}, ${_SCRIPT_}, \
${_PERL_}, ${_PYTHON_}, \
${_DIRNAME_}, ${_BASENAME_}, \
${_WHICH_}
_SHELL_ = bash
_CC_ = mips64-gcc
_AS_ = mips64-as
_OBJCOPY_ = mips64-objcopy
_MAKE_ = gmake
_RM_ = rm -f
_PURGE_ = ${_RM_} *.pyc *~ .*~ \#* .\#*
_AR_ = mips64-ar cq
_RANLIB_ = mips64-ranlib
_CD_ = cd
_LD_ = mips64-ld
_LN_ = ln -s -f
_TOUCH_ = touch
_WC_ = wc
_DATE_ = date -u
_TAIL_ = tail
_TAR_ = tar
_PDFLATEX_ = pdflatex
_BIBTEX_ = bibtex
_CP_ = cp
_CAT_ = cat
_SED_ = sed -r
_ECHO_ = echo
_CPP_ = mips64-cpp
_MTOOLS_ = mtools
_MCOPY_ = mcopy
_XPDF_ = xpdf
_MKTEMP_ = mktemp
_MV_ = mv
_PWD_ = pwd
_LEX_ = lex -t
_SCRIPT_ = script
_PERL_ = perl
_PYTHON_ = python
_DIRNAME_ = dirname
_BASENAME_ = basename
_WHICH_ = which
_EXIT_ = exit
#
# microprocessor specific definitions
#
_CC_FLAGS_ += -D___kaneton$$\endian=1 \
-D___kaneton$$\wordsz=64 \
-D___kaneton$$\pagesz=4096

View file

@ -0,0 +1,33 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...nvironment/profile/host/linux/linux.desc
#
# created julien quintard [tue may 8 13:20:04 2007]
# updated julien quintard [tue may 29 16:37:31 2007]
#
#
# ---------- information ------------------------------------------------------
#
# this file describes the linux environment variables.
#
- variable: _SHELL_
string: Shell
type: any
description: The shell binary path
- variable: _CC_
string: C Compiler
type: any
description: The C compiler binary path
- variable: _MAKE_
string: Make
type: any
description: The make binary path

View file

@ -0,0 +1,23 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/enguerrand/...profile/host/linux/ia32.mips64/mips64.mk
#
# created julien quintard [tue may 8 13:03:34 2007]
# updated enguerrand raymond [sun may 17 09:36:48 2009]
#
#
# ---------- information ------------------------------------------------------
#
# this file implements the remaining functions of the kaneton make interface.
#
# indeed the major generic part of the interface is already provided by the
# host profile.
#
include ../linux.mk

View file

@ -0,0 +1,219 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/enguerrand/...profile/host/linux/ia32.mips64/mips64.py
#
# created julien quintard [tue may 8 13:20:21 2007]
# updated enguerrand raymond [fri apr 17 20:59:36 2009]
#
#
# ---------- information ------------------------------------------------------
#
# this file implements the remaining functions of the kaneton python interface.
#
# note that the host profile already provides many functions. these
# functions can be overriden but you will probably just use them.
#
# in addition, the host profile already imports some packages.
#
#
# ---------- python path ------------------------------------------------------
#
pythonpath = os.getenv("PYTHONPATH")
if not pythonpath:
pythonpath = ""
os.putenv("PYTHONPATH", pythonpath + ":" + _PYTHON_INCLUDE_DIR_)
#
# ---------- functions --------------------------------------------------------
#
#
# colorize()
#
# this function returns a colorized text if the environment is configured
# to or simply the original text.
#
# note that this function implementation is based on UNIX escape sequences.
#
def colorize(text, color, options):
if _DISPLAY_ == _DISPLAY_UNCOLORED_:
return text
if options & OPTION_FLICKERING:
text = "" + text + ""
if color == COLOR_BLACK:
text = "" + text + ""
elif color == COLOR_RED:
text = "" + text + ""
elif color == COLOR_GREEN:
text = "" + text + ""
elif color == COLOR_YELLOW:
text = "" + text + ""
elif color == COLOR_BLUE:
text = "" + text + ""
elif color == COLOR_MAGENTA:
text = "" + text + ""
elif color == COLOR_CYAN:
text = "" + text + ""
elif color == COLOR_WHITE:
text = "" + text + ""
return text
#
# launch()
#
# this function launch a new program/script/make etc.
#
def launch(file, arguments, options):
directory = None
info = None
status = 0
wd = None
info = os.path.split(file)
directory = info[0]
file = info[1]
if directory:
wd = cwd(OPTION_NONE)
cd(directory, OPTION_NONE)
if re.match("^.*\.sh$", file):
status = os.system(_SHELL_ + " " + file + " " + arguments)
elif re.match("^.*\.py$", file):
status = os.system(_PYTHON_ + " " + file + " " + arguments)
elif re.match("^.*\.pl$", file):
status = os.system(_PERL_ + " " + file + " " + arguments)
elif re.match("^Makefile$", file):
status = os.system(_MAKE_ + " -f " + file + " " + arguments)
else:
status = os.system(file + " " + arguments)
if directory:
cd(wd, OPTION_NONE)
return status
#
# pack()
#
# this function creates an archive of the given directory.
#
def pack(directory, file, options):
launch(_TAR_, "-cjf " + file + " " + directory, OPTION_NONE)
#
# unpack()
#
# this function unpackages an archive into the given (optional) directory.
#
def unpack(file, directory, options):
if directory:
launch(_TAR_, "-xjf " + file + " -C " + directory, OPTION_NONE)
else:
launch(_TAR_, "-xjf " + file, OPTION_NONE)
#
# load()
#
# this function copies a file on a device, this device can be virtual:
# an image.
#
def load(file, device, path, options):
if options == OPTION_DEVICE:
launch(_MCOPY_, "-o -n " + file + " " + device + path, OPTION_NONE)
if options == OPTION_IMAGE:
launch(_MCOPY_, "-o -n " + "-i" + device + " " +
file + " ::" + path, OPTION_NONE)
#
# record()
#
# this function runs the program recording a session.
#
def record(transcript, options):
directory = None
time = None
log = None
tmp = None
wd = None
tmp = temporary(OPTION_DIRECTORY)
directory = tmp + "/" + "transcript"
log = directory + "/" + "log"
time = directory + "/" + "time"
mkdir(directory, OPTION_NONE)
launch(_SCRIPT_, "-q -t " + log + " -c " +
_TRANSCRIPT_CMD_ + " 2> " + time, OPTION_NONE)
wd = cwd(OPTION_NONE)
cd(tmp, OPTION_NONE)
pack("transcript", wd + "/" + transcript, OPTION_NONE)
cd(wd, OPTION_NONE)
remove(tmp, OPTION_NONE)
#
# play()
#
# this function runs the program replaying a session.
#
def play(transcript, options):
directory = None
time = None
log = None
tmp = None
wd = None
tmp = temporary(OPTION_DIRECTORY)
log = tmp + "/" + "transcript/log"
time = tmp + "/" + "transcript/time"
unpack(transcript, tmp, OPTION_NONE)
launch(_SCRIPTREPLAY_TOOL_, time + " " + log, OPTION_NONE)
remove(tmp, OPTION_NONE)
#
# locate()
#
# this function tries to locate a program on the system.
#
def locate(file, options):
return launch(_WHICH_, file + " 1>/dev/null 2>/dev/null", OPTION_NONE)

View file

@ -0,0 +1,48 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/enguerrand/...t/profile/host/linux/ia32.mips64/util.py
#
# created enguerrand raymond [fri apr 17 20:59:04 2009]
# updated enguerrand raymond [fri apr 17 21:00:47 2009]
#
#
# ---------- information ------------------------------------------------------
#
# this file implements some useful functions used for mips compilation, build
# and installation.
#
#
# binary_extract()
#
# this function extracts given sections (section names separate by space)
# from elf to put in binary
#
def binary_extract(elf, sections, binary):
section_list = sections.split()
cmd_option = "-S"
for section in section_list:
cmd_option += " -j " + section
cmd_option += " --output-target binary " + elf + " " + binary
launch(_OBJCOPY_, cmd_option, "")
#
# concat_file()
#
# this function concatenates file a the result file end
#
def concat_file(file, result):
os.system(_CAT_ + " " + file + " >> " + result)

View file

@ -0,0 +1,33 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...t/profile/host/linux/ia32.null/null.conf
#
# created julien quintard [thu jun 28 21:15:33 2007]
# updated julien quintard [wed mar 26 23:37:31 2008]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains definitions specific to the null target microprocessor
# architecture.
#
#
# include the linux generic definitions
#
include ../linux.conf
#
# microprocessor specific definitions
#
_CC_FLAGS_ += -D___kaneton$$\endian=0 \
-D___kaneton$$\wordsz=32 \
-D___kaneton$$\pagesz=1

View file

@ -0,0 +1 @@
../linux.desc

View file

@ -0,0 +1 @@
../linux.mk

View file

@ -0,0 +1 @@
../linux.py

View file

@ -0,0 +1,113 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...nvironment/profile/host/linux/linux.conf
#
# created julien quintard [tue may 8 13:19:52 2007]
# updated julien quintard [mon feb 7 10:36:01 2011]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains the libraries, binaries, script and tools related to
# the generic linux host sub-profile.
#
#
# ---------- includes ---------------------------------------------------------
#
_INCLUDES_ = -I${_INCLUDE_DIR_}
#
# ---------- flags ------------------------------------------------------------
#
_CC_FLAGS_ = ${_INCLUDES_} \
${_KANETON_FLAGS_} \
-fno-builtin \
-fno-stack-protector \
-Wimplicit \
-Wparentheses \
-Wreturn-type \
-Wswitch -Wswitch-enum \
-Wunused-function \
-Wunused-variable \
-Wmissing-prototypes \
-Wmissing-declarations \
-Wall
_LD_FLAGS_ = ${_INCLUDES_}
_ASM_FLAGS_ =
_CPP_FLAGS_ =
_SHELL_FLAGS_ =
_PYTHON_FLAGS_ =
_PERL_FLAGS_ =
_MAKE_FLAGS_ =
#
# ---------- binaries ---------------------------------------------------------
#
_BINARIES_ = ${_SHELL_}, ${_CC_}, ${_MAKE_}, \
${_RM_}, ${_AR_}, ${_RANLIB_}, \
${_LD_}, ${_AS_}, ${_BIBTEX_},\
${_LN_}, ${_TOUCH_}, ${_WC_}, \
${_DATE_}, ${_TAIL_}, ${_TAR_}, \
${_PDFLATEX_}, ${_CP_}, \
${_CAT_}, ${_SED_}, ${_CPP_}, \
${_MTOOLS_}, ${_MCOPY_}, \
${_XPDF_}, ${_MKTEMP_}, ${_MV_},\
${_LEX_}, ${_SCRIPT_}, \
${_PERL_}, ${_PYTHON_}, \
${_DIRNAME_}, ${_BASENAME_}, \
${_WHICH_}
_SHELL_ = bash
_CC_ = gcc
_AS_ = as
_MAKE_ = make
_RM_ = rm -f
_PURGE_ = ${_RM_} ${_GARBAGE_}
_AR_ = ar cq
_RANLIB_ = ranlib
_CD_ = cd
_LD_ = ld
_LN_ = ln -s -f
_TOUCH_ = touch
_WC_ = wc
_DATE_ = date -u
_TAIL_ = tail
_TAR_ = tar
_PDFLATEX_ = pdflatex
_BIBTEX_ = bibtex
_CP_ = cp
_CAT_ = cat
_SED_ = sed -r
_ECHO_ = echo
_CPP_ = cpp
_MTOOLS_ = mtools
_MCOPY_ = mcopy
_XPDF_ = xpdf
_MKTEMP_ = mktemp
_MV_ = mv
_PWD_ = pwd
_LEX_ = lex -t
_SCRIPT_ = script
_PERL_ = perl
_PYTHON_ = python
_DIRNAME_ = dirname
_BASENAME_ = basename
_WHICH_ = which
_EXIT_ = exit

View file

@ -0,0 +1,33 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...nvironment/profile/host/linux/linux.desc
#
# created julien quintard [tue may 8 13:20:04 2007]
# updated julien quintard [tue may 29 16:37:31 2007]
#
#
# ---------- information ------------------------------------------------------
#
# this file describes the linux environment variables.
#
- variable: _SHELL_
string: Shell
type: any
description: The shell binary path
- variable: _CC_
string: C Compiler
type: any
description: The C compiler binary path
- variable: _MAKE_
string: Make
type: any
description: The make binary path

View file

@ -0,0 +1,507 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane.../environment/profile/host/linux/linux.mk
#
# created julien quintard [tue may 8 13:03:34 2007]
# updated julien quintard [sun dec 5 00:02:41 2010]
#
#
# ---------- information ------------------------------------------------------
#
# this file implements the remaining functions of the kaneton make interface.
#
# indeed the major generic part of the interface is already provided by the
# host profile.
#
#
# ---------- lang -------------------------------------------------------------
#
# incorrect locales may prevent the system from compiling properly.
#
# the following forces the LANG environment variable to US.
#
export LANG=US
#
# ---------- python path ------------------------------------------------------
#
export PYTHONPATH=$(shell $(_ECHO_) $${PYTHONPATH}):$(_PYTHON_INCLUDE_DIR_)
#
# ---------- functions --------------------------------------------------------
#
#
# colorize functions
#
# 1: text
# 2: options
#
define env_colorize-black
"$(1)"
endef
define env_colorize-red
"$(1)"
endef
define env_colorize-green
"$(1)"
endef
define env_colorize-yellow
"$(1)"
endef
define env_colorize-blue
"$(1)"
endef
define env_colorize-magenta
"$(1)"
endef
define env_colorize-cyan
"$(1)"
endef
define env_colorize-white
"$(1)"
endef
define env_colorize-
"$(1)"
endef
#
# perform function
#
# 1: command
#
ifeq ($(_OUTPUT_),$(_OUTPUT_VERBOSE_)) # if the user wants to display
# additional debug information
define env_perform
$(_ECHO_) " $(1)" && \
$(1)
endef
else
define env_perform
$(1)
endef
endif
#
# print functions wrapper
#
# 1: text
# 2: color
# 3: options
#
ifeq ($(_DISPLAY_),$(_DISPLAY_COLORED_)) # if the user wants to display
# the text with color
define env_print
print_options="" && \
if [ -n "$(3)" ] ; then \
if [ $$(( $(3) & $(ENV_OPTION_NO_NEWLINE) )) -ne 0 ] ; then \
print_options="$${print_options} -n" ; \
fi ; \
fi && \
$(_ECHO_) $${print_options} $(call env_colorize-$(2),$(1),)
endef
else # if not ...
define env_print
print_options="" && \
if [ -n "$(3)" ] ; then \
if [ $$(( $(3) & $(ENV_OPTION_NO_NEWLINE) )) -ne 0 ] ; then \
print_options="$${print_options} -n" ; \
fi ; \
fi && \
$(_ECHO_) $${print_options} "$(1)"
endef
endif
#
# change the current working directory
#
# $(1): directory
# $(2): options
#
define env_cd
cd_options="" && \
$(call env_perform, \
$(_CD_) $${cd_options} $(1))
endef
#
# returns a file contents
#
# $(1): the file
# $(2): options
#
define env_pull
$(_CAT_) $(2) $(1)
endef
#
# launch a new program/script/make etc.
#
# $(1): file
# $(2): arguments
# $(3): options
#
define env_launch
launch_options="" && \
cwd=$$($(_PWD_)) && \
directory=$$($(_DIRNAME_) $(1)) && \
file=$$($(_BASENAME_) $(1)) && \
if [ "$${directory}" != "." ] ; then \
$(call env_perform, \
$(_CD_) $${directory}) ; \
fi && \
case "$${file}" in \
*.sh) \
$(call env_perform, \
$(_SHELL_) $${launch_options} $${file} $(_SHELL_FLAGS_) $(2)) ; \
;; \
*.py) \
$(call env_perform, \
$(_PYTHON_) $${launch_options} $${file} $(_PYTHON_FLAGS_) $(2)) ; \
;; \
*.pl) \
$(call env_perform, \
$(_PERL_) $${launch_options} $${file} $(_PERL_FLAGS_) $(2)) ; \
;; \
Makefile) \
$(call env_perform, \
$(_MAKE_) $${launch_options} -f $${file} $(_MAKE_FLAGS_) ${2}) ; \
;; \
esac ; \
return=$${?} && \
if [ "$${directory}" != "." ] ; then \
$(call env_perform, \
$(_CD_) $${cwd}) ; \
fi && \
if [ $${return} -ne 0 ] ; then \
$(_EXIT_) 42 ; \
fi
endef
#
# from c file to preprocessed c file
#
# $(1): preprocessed file
# $(2): c file
# $(3): options
#
define env_preprocess
preprocess_options="" && \
$(call env_display,green,PREPROCESS,$(2), ,) && \
$(call env_perform, \
$(_CPP_) -P $(_CPP_FLAGS_) $${preprocess_options} $(2) -o $(1))
endef
#
# from c file to object file
#
# $(1): object file
# $(2): c file
# $(3): options
#
define env_compile-c
compile_c_options="" && \
$(call env_display,green,COMPILE-C,$(2), ,) && \
$(call env_perform, \
$(_CC_) $(_CC_FLAGS_) $${compile_c_options} -c $(2) -o $(1))
endef
#
# from lex file to c file
#
# $(1): c file
# $(2): lex file
# $(3): options
#
define env_lex-l
lex_l_options="" && \
$(call env_display,green,LEX-L,$(2), ,) && \
$(call env_perform, \
$(_LEX_) $${lex_l_options} $(2) > $(1))
endef
#
# from S file to object file
#
# $(1): object file
# $(2): S file
# $(3): options
#
define env_assemble-S
assemble_S_options="" && \
$(call env_display,green,ASSEMBLE-S,$(2), ,) && \
$(call env_perform, \
$(_CPP_) $(2) | $(_AS_) $(_ASM_FLAGS_) $${assemble_S_options} -o $(1))
endef
#
# create a static library from object files
#
# $(1): static library file name
# $(2): object files
# $(3): options
#
define env_static-library
static_library_options="" && \
$(call env_display,magenta,STATIC-LIBRARY,$(1), ,) && \
$(call env_perform, \
$(_AR_) $${static_library_options} $(1) $(2)) && \
$(call env_perform, \
$(_RANLIB_) $${static_library_options} $(1))
endef
#
# create a dynamic library from object files, static libraries
# and/or dynamic libraries
#
# $(1): dynamic library file name
# $(2): objects files and/or libraries
# $(3): options
#
define env_dynamic-library
dynamic_library_options="" && \
$(call env_display,magenta,DYNAMIC-LIBRARY,$(1), ,) && \
$(call env_perform, \
$(_LD_) --shared $(_LD_FLAGS_) $${dynamic_library_options} \
-o $(1) $(2))
endef
#
# create an executable file from object file and/or library files
#
# $(1): executable file name
# $(2): objects files and/or libraries
# $(3): layout file
# $(4): options
#
define env_executable
executable_options="" && \
if [ -n "$(3)" ] ; then \
executable_options="$${executable_options} -T $(3)" ; \
fi && \
if [ -n "$(4)" ] ; then \
if [ $$(( $(4) & $(ENV_OPTION_NO_STANDARD) )) -ne 0 ] ; then \
executable_options="$${executable_options} -nostdinc -nostdlib" ; \
fi ; \
fi && \
$(call env_display,magenta,EXECUTABLE,$(1), ,) && \
$(call env_perform, \
$(_CC_) $(_CC_FLAGS_) $(_LD_FLAGS_) $${executable_options} -o $(1) \
$(2) "`$(_CC_) -print-libgcc-file-name`")
endef
#
# create an archive file from multiple object files
#
# note that the archive file is also an object file
#
# $(1): archive file name
# $(2): objects files and/or libraries
# $(3): options
#
define env_archive
archive_options="" && \
$(call env_display,magenta,ARCHIVE,$(1), ,) && \
$(call env_perform, \
$(_LD_) -r $(_LD_FLAGS_) $${archive_options} -o $(1) $(2))
endef
#
# remove the files
#
# $(1): files
# $(2): options
#
define env_remove
remove_options="" && \
for f in $(1) ; do \
if [ -e $${f} ] ; then \
$(call env_display,red,REMOVE,$${f}, ,) ; \
fi && \
$(call env_perform, \
$(_RM_) $${remove_options} $${f}) ; \
done
endef
#
# purge i.e clean the directory from unwanted files
#
define env_purge
$(call env_display,red,PURGE,,,) && \
$(call env_perform, \
$(_PURGE_))
endef
#
# generate prototypes from a source file
#
# $(1): file list
# $(2): options
#
define env_prototypes
prototypes_options="" && \
for f in $(1) ; do \
if [ -e $${f} ] ; then \
$(call env_display,yellow,PROTOTYPES,$${f}, ,) && \
$(call env_launch,$(_MKP_TOOL_), \
$${prototypes_options} $${f},) ; \
fi ; \
done
endef
#
# genereate header dependencies
#
# $(1): the files for which the dependencies are generated
# $(2): options
#
define env_headers
headers_options="" && \
for f in $(1) ; do \
if [ -e $${f} ] ; then \
$(call env_display,yellow,HEADERS,$$f, ,) && \
$(call env_perform, \
$(_CC_) $(_CC_FLAGS_) -M -MG $${headers_options} \
$${f} >> $(_DEPENDENCY_MK_)) ; \
fi ; \
done
endef
#
# generate a version file
#
# $(1): the version file to generate
#
define env_version
$(call env_display,yellow,VERSION,$(1), ,) && \
$(_ECHO_) -n "" > $(1) && \
$(_ECHO_) -n "const char version[] = \"$(_TITLE_)-$(_VERSION_)" >> $(1) && \
$(_ECHO_) " "$(shell $(_DATE_))" $(USER)@$(HOSTNAME)\";" >> $(1)
endef
#
# create a link between two files
#
# $(1): link created
# $(2): destination
# $(3): options
#
define env_link
link_options="" && \
$(call env_display,cyan,LINK,$(1), ,) && \
$(call env_perform, \
$(_LN_) $${link_options} $(2) $(1))
endef
#
# compile a tex document
#
# $(1): the file name without extension
# $(2): options
#
define env_compile-tex
compile_tex_options="" && \
$(call env_display,green,COMPILE-TEX,$(1), ,) && \
$(call env_perform, \
$(_PDFLATEX_) $${compile_tex_options} $(1)) && \
$(call env_perform, \
$(_PDFLATEX_) $${compile_tex_options} $(1)) && \
$(call env_perform, \
$(_BIBTEX_) $(1)) && \
$(call env_perform, \
$(_BIBTEX_) $(1)) && \
$(call env_perform, \
$(_PDFLATEX_) $${compile_tex_options} $(1)) ; \
$(call env_perform, \
$(_PDFLATEX_) $${compile_tex_options} $(1))
endef
#
# build a document
#
# $(1): the file name without extension
# $(2): options
#
define env_document
$(call env_remove,$(_DEPENDENCY_TEX_),) && \
if [ -n "$(2)" ] ; then \
if [ $$(( $(2) & $(ENV_OPTION_PRIVATE) )) -ne 0 ] ; then \
$(_ECHO_) '\def\mode{private}' > $(_DEPENDENCY_TEX_) ; \
fi ; \
fi && \
if [ ! -f $(_DEPENDENCY_TEX_) ] ; then \
$(_ECHO_) '\def\mode{public}' > $(_DEPENDENCY_TEX_) ; \
fi && \
$(call env_compile-tex,$(1),$(2))
endef
#
# launch a document viewer
#
# $(1): the file name without extension
# $(2): options
#
define env_view
$(call env_display,yellow,VIEW,$(1), ,) && \
$(call env_perform, \
$(_XPDF_) $(1).pdf)
endef
#
# ---------- component-based behaviour ----------------------------------------
#
#
# kaneton
#
ifneq ($(call findstring,kaneton,$(components)),)
_CC_FLAGS_ += -D___kaneton$$\kernel
endif

View file

@ -0,0 +1,239 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/profile/host/linux/linux.py
#
# created julien quintard [tue may 8 13:20:21 2007]
# updated julien quintard [sat mar 5 09:13:35 2011]
#
#
# ---------- information ------------------------------------------------------
#
# this file implements the remaining functions of the kaneton python interface.
#
# note that the host profile already provides many functions. these
# functions can be overriden but you will probably just use them.
#
# in addition, the host profile already imports some packages.
#
#
# ---------- lang -------------------------------------------------------------
#
# incorrect locales may prevent the system from compiling properly.
#
# the following forces the LANG environment variable to US.
#
os.putenv("LANG", "US")
#
# ---------- python path ------------------------------------------------------
#
_pythonpath_ = os.getenv("PYTHONPATH")
if not _pythonpath_:
os.putenv("PYTHONPATH", _PYTHON_INCLUDE_DIR_)
else:
os.putenv("PYTHONPATH", _pythonpath_ + ":" + _PYTHON_INCLUDE_DIR_)
#
# ---------- functions --------------------------------------------------------
#
#
# colorize()
#
# this function returns a colorized text if the environment is configured
# to or simply the original text.
#
# note that this function implementation is based on UNIX escape sequences.
#
def colorize(text, color, options):
if _DISPLAY_ == _DISPLAY_UNCOLORED_:
return text
if options & OPTION_FLICKERING:
text = "" + text
if options & OPTION_BOLD:
text = "" + text
if color == COLOR_BLACK:
text = "" + text
elif color == COLOR_RED:
text = "" + text
elif color == COLOR_GREEN:
text = "" + text
elif color == COLOR_YELLOW:
text = "" + text
elif color == COLOR_BLUE:
text = "" + text
elif color == COLOR_MAGENTA:
text = "" + text
elif color == COLOR_CYAN:
text = "" + text
elif color == COLOR_WHITE:
text = "" + text
return text + ""
#
# launch()
#
# this function launch a new program/script/make etc.
#
def launch(file, arguments, options):
directory = None
info = None
status = 0
wd = None
if options & OPTION_QUIET:
output = " >/dev/null 2>&1"
else:
output = ""
info = os.path.split(file)
directory = info[0]
file = info[1]
if directory:
wd = cwd(OPTION_NONE)
cd(directory, OPTION_NONE)
if re.match("^.*\.sh$", file):
status = os.system(_SHELL_ + " " + file + " " + arguments + output)
elif re.match("^.*\.py$", file):
status = os.system(_PYTHON_ + " " + file + " " + arguments + output)
elif re.match("^.*\.pl$", file):
status = os.system(_PERL_ + " " + file + " " + arguments + output)
elif re.match("^Makefile$", file):
status = os.system(_MAKE_ + " -f " + file + " " + arguments + output)
else:
if directory:
file = "./" + file
status = os.system(file + " " + arguments + output)
if directory:
cd(wd, OPTION_NONE)
return status
#
# pack()
#
# this function creates an archive of the given directory.
#
def pack(directory, file, options):
launch(_TAR_, "-cjf " + file + " " + directory, OPTION_NONE)
#
# unpack()
#
# this function unpackages an archive into the given (optional) directory.
#
def unpack(file, directory, options):
if directory:
launch(_TAR_, "-xjf " + file + " -C " + directory, OPTION_NONE)
else:
launch(_TAR_, "-xjf " + file, OPTION_NONE)
#
# load()
#
# this function copies a file on a device, this device can be virtual:
# an image.
#
def load(file, device, path, options):
if options == OPTION_DEVICE:
return launch(_MCOPY_, "-o -n " + file + " " + device + path,
OPTION_NONE)
elif options == OPTION_IMAGE:
return launch(_MCOPY_, "-o -n " + "-i" + device + " " +
file + " ::" + path, OPTION_NONE)
#
# record()
#
# this function runs the program recording a session.
#
def record(transcript, options):
directory = None
time = None
log = None
tmp = None
wd = None
tmp = temporary(OPTION_DIRECTORY)
directory = tmp + "/" + "transcript"
log = directory + "/" + "log"
time = directory + "/" + "time"
mkdir(directory, OPTION_NONE)
launch(_SCRIPT_, "-q -t " + log + " -c " +
_TRANSCRIPT_CMD_ + " 2> " + time, OPTION_NONE)
wd = cwd(OPTION_NONE)
cd(tmp, OPTION_NONE)
pack("transcript", wd + "/" + transcript, OPTION_NONE)
cd(wd, OPTION_NONE)
remove(tmp, OPTION_NONE)
#
# play()
#
# this function runs the program replaying a session.
#
def play(transcript, options):
directory = None
time = None
log = None
tmp = None
wd = None
tmp = temporary(OPTION_DIRECTORY)
log = tmp + "/" + "transcript/log"
time = tmp + "/" + "transcript/time"
unpack(transcript, tmp, OPTION_NONE)
launch(_REPLAY_TOOL_, time + " " + log, OPTION_NONE)
remove(tmp, OPTION_NONE)
#
# locate()
#
# this function tries to locate a program on the system.
#
def locate(file, options):
return launch(_WHICH_, file + " 1>/dev/null 2>/dev/null", OPTION_NONE)

View file

@ -0,0 +1,152 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...vironment/profile/kaneton/core/core.conf
#
# created julien quintard [tue may 8 13:42:57 2007]
# updated julien quintard [sun nov 28 19:36:43 2010]
#
#
# ---------- information ------------------------------------------------------
#
# these variables are core-dependent are used to parameterise the kernel.
#
#
# ---------- flags ------------------------------------------------------------
#
_CORE_FLAGS_ = ${_AS_FLAGS_} \
${_CAPABILITY_FLAGS_} \
${_CPU_FLAGS_} \
${_EVENT_FLAGS_} \
${_ID_FLAGS_} \
${_INTERFACE_FLAGS_} \
${_IO_FLAGS_} \
${_KERNEL_FLAGS_} \
${_MAP_FLAGS_} \
${_MESSAGE_FLAGS_} \
${_REGION_FLAGS_} \
${_SCHEDULER_FLAGS_} \
${_SEGMENT_FLAGS_} \
${_SET_FLAGS_} \
${_TASK_FLAGS_} \
${_THREAD_FLAGS_} \
${_TIME_FLAGS_}
#
# ---------- as manager -------------------------------------------------------
#
_AS_FLAGS_ =
#
# ---------- capability manager -----------------------------------------------
#
_CAPABILITY_FLAGS_ =
#
# ---------- cpu manager ------------------------------------------------------
#
_CPU_FLAGS_ =
#
# ---------- event manager ----------------------------------------------------
#
_EVENT_FLAGS_ =
#
# ---------- id manager -------------------------------------------------------
#
_ID_FLAGS_ =
#
# ---------- interface manager ------------------------------------------------
#
_INTERFACE_FLAGS_ =
#
# ---------- io manager -------------------------------------------------------
#
_IO_FLAGS_ =
#
# ---------- kernel manager ---------------------------------------------------
#
_KERNEL_FLAGS_ =
#
# ---------- map manager ------------------------------------------------------
#
_MAP_FLAGS_ =
#
# ---------- message manager --------------------------------------------------
#
_MESSAGE_FLAGS_ =
#
# ---------- region manager ---------------------------------------------------
#
_REGION_FLAGS_ = ${_REGION_ALGORITHM_} \
${_REGION_FIT_}
_REGION_ALGORITHM_ = -DREGION_ALGORITHM=REGION_ALGORITHM_FIT
_REGION_FIT_ = -DREGION_FIT=FIT_FIRST
#
# ---------- scheduler manager ------------------------------------------------
#
_SCHEDULER_FLAGS_ = ${_SCHEDULER_ALGORITHM_}
_SCHEDULER_ALGORITHM_ = -DSCHEDULER_ALGORITHM=SCHEDULER_ALGORITHM_MFQ
#
# ---------- segment manager --------------------------------------------------
#
_SEGMENT_FLAGS_ = ${_SEGMENT_ALGORITHM_} \
${_SEGMENT_FIT_}
_SEGMENT_ALGORITHM_ = -DSEGMENT_ALGORITHM=SEGMENT_ALGORITHM_FIT
_SEGMENT_FIT_ = -DSEGMENT_FIT=FIT_FIRST
#
# ---------- set manager ------------------------------------------------------
#
_SET_FLAGS_ =
#
# ---------- task manager -----------------------------------------------------
#
_TASK_FLAGS_ =
#
# ---------- thread manager ---------------------------------------------------
#
_THREAD_FLAGS_ =
#
# ---------- time manager -----------------------------------------------------
#
_TIME_FLAGS_ =

View file

@ -0,0 +1,26 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...vironment/profile/kaneton/core/core.desc
#
# created julien quintard [tue may 8 13:43:36 2007]
# updated julien quintard [thu may 31 21:49:29 2007]
#
#
# ---------- information ------------------------------------------------------
#
# this files contains the core variable descriptions.
#
- variable: _SEGMENT_LOOKUP_ALGORITHM_
string: Segment Manager Algorithm
type: set
values:
First Fit: -DSEGMENT_LOOKUP_ALGORITHM=FIT_FIRST
Best Fit: -DSEGMENT_LOOKUP_ALGORITHM=FIT_BEST
description: Specify the type of algorithm to use.

View file

@ -0,0 +1,34 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...environment/profile/kaneton/kaneton.conf
#
# created julien quintard [tue may 8 13:26:13 2007]
# updated julien quintard [sat feb 5 12:17:24 2011]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains general kaneton microkernel configuration variables.
#
#
# ---------- general ----------------------------------------------------------
#
_TITLE_ = kaneton
_VERSION_ = 0.7
#
# ---------- flags ------------------------------------------------------------
#
_KANETON_FLAGS_ = ${_CORE_FLAGS_} \
${_MACHINE_FLAGS_} \
${_LIBRARY_FLAGS_} \
${_MODULES_FLAGS_}

View file

@ -0,0 +1,12 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/profile/kaneton/kaneton.desc
#
# created julien quintard [tue may 8 13:42:18 2007]
# updated julien quintard [tue may 8 13:42:18 2007]
#

View file

@ -0,0 +1,24 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...ent/profile/kaneton/library/library.conf
#
# created julien quintard [fri may 1 20:05:33 2009]
# updated julien quintard [fri may 1 20:05:55 2009]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains the configuration of the in-kernel library.
#
#
# ---------- flags ------------------------------------------------------------
#
_LIBRARY_FLAGS_ =

View file

@ -0,0 +1,12 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...ent/profile/kaneton/library/library.desc
#
# created julien quintard [fri may 1 20:06:04 2009]
# updated julien quintard [fri may 1 20:06:05 2009]
#

View file

@ -0,0 +1,24 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...ent/profile/kaneton/machine/machine.conf
#
# created julien quintard [fri may 1 19:37:15 2009]
# updated julien quintard [fri may 1 19:37:48 2009]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains the machine configuration such as flags etc.
#
#
# ---------- flags ------------------------------------------------------------
#
_MACHINE_FLAGS_ =

View file

@ -0,0 +1,12 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...ent/profile/kaneton/machine/machine.desc
#
# created julien quintard [fri may 1 19:38:08 2009]
# updated julien quintard [fri may 1 19:38:08 2009]
#

View file

@ -0,0 +1,12 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/enguerrand/...achine/platform/qemu-mips/qemu-mips.conf
#
# created enguerrand raymond [sat apr 11 01:29:35 2009]
# updated enguerrand raymond [tue may 12 00:48:19 2009]
#

View file

@ -0,0 +1,64 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...ent/profile/kaneton/modules/modules.conf
#
# created julien quintard [fri may 1 19:28:05 2009]
# updated julien quintard [sun dec 5 00:59:12 2010]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains information related to kaneton static modules.
#
#
# ---------- modules ----------------------------------------------------------
#
_MODULES_ = console report
#
# ---------- flags ------------------------------------------------------------
#
_MODULES_FLAGS_ = ${_MODULE_CONSOLE_FLAGS_} \
${_MODULE_FORWARD_FLAGS_} \
${_MODULE_TEST_FLAGS_} \
${_MODULE_BUNDLE_FLAGS_} \
${_MODULE_REPORT_FLAGS_}
#
# ---------- console ----------------------------------------------------------
#
_MODULE_CONSOLE_FLAGS_ =
#
# ---------- forward ----------------------------------------------------------
#
_MODULE_FORWARD_FLAGS_ =
#
# ---------- test -------------------------------------------------------------
#
_MODULE_TEST_FLAGS_ =
#
# ---------- bundle -----------------------------------------------------------
#
_MODULE_BUNDLE_FLAGS_ =
#
# ---------- report -----------------------------------------------------------
#
_MODULE_REPORT_FLAGS_ =

View file

@ -0,0 +1,12 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...ent/profile/kaneton/modules/modules.desc
#
# created julien quintard [fri may 1 19:36:15 2009]
# updated julien quintard [fri may 1 19:36:15 2009]
#

View file

@ -0,0 +1,39 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane...ironment/profile/user/sample/sample.conf
#
# created julien quintard [sat jun 9 22:40:33 2007]
# updated julien quintard [thu mar 3 18:18:10 2011]
#
#
# ---------- information ------------------------------------------------------
#
# a sample of the user configuration file.
#
#
# ---------- boot stuff -------------------------------------------------------
#
_MBL_SCRIPT_ = ${_MBL_DIR_}/grub/grub.py
_BOOT_MODE_ = image
_BOOT_DEVICE_ = floppy
#
# ---------- environment ------------------------------------------------------
#
_OUTPUT_ = ${_OUTPUT_VERBOSE_}
#
# ---------- inputs -----------------------------------------------------------
#
#_INPUTS_ += ${_SAMPLE_DIR_}/chiche/chiche

View file

@ -0,0 +1,33 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/profile/user/test/test.conf
#
# created julien quintard [thu apr 16 04:29:52 2009]
# updated julien quintard [sat dec 18 21:24:24 2010]
#
#
# ---------- boot -------------------------------------------------------------
#
_MBL_SCRIPT_ = ${_MBL_DIR_}/grub/grub.py
_BOOT_MODE_ = image
_BOOT_DEVICE_ = floppy
#
# ---------- modules ----------------------------------------------------------
#
_MODULES_ += bundle test
#
# ---------- display ----------------------------------------------------------
#
_DISPLAY_ = ${_DISPLAY_UNCOLORED_}

View file

@ -0,0 +1,65 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/profile/user/user.conf
#
# created julien quintard [tue may 8 10:47:42 2007]
# updated julien quintard [sat may 7 14:13:14 2011]
#
#
# ---------- information ------------------------------------------------------
#
# this file defines the default user profile environment variables.
#
#
# ---------- display ----------------------------------------------------------
#
_DISPLAY_UNCOLORED_ = 1
_DISPLAY_COLORED_ = 2
_DISPLAY_ = ${_DISPLAY_COLORED_}
#
# ---------- output -----------------------------------------------------------
#
_OUTPUT_PRETTY_ = 1
_OUTPUT_VERBOSE_ = 2
_OUTPUT_ = ${_OUTPUT_PRETTY_}
#
# ---------- cheat ------------------------------------------------------------
#
_CHEAT_FILTER_ = configure \
environment \
license \
tool \
transcript
#
# ---------- transcript -------------------------------------------------------
#
_TRANSCRIPT_CMD_ = ${_SHELL_}
#
# ---------- test -------------------------------------------------------------
#
_TEST_SERVER_ = https://test.opaak.org:8421
_TEST_CAPABILITY_ = ${_PROFILE_USER_DIR_}/${_USER_}.cap
_TEST_PLATFORM_ = ${_PLATFORM_}
_TEST_ARCHITECTURE_ = ${_ARCHITECTURE_}
_TEST_NAME_ = <null>
_TEST_EMAIL_ = <null>

View file

@ -0,0 +1,26 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton/environment/profile/user/user.desc
#
# created julien quintard [fri may 25 09:36:30 2007]
# updated julien quintard [thu may 31 21:49:03 2007]
#
#
# ---------- information ------------------------------------------------------
#
# this file contains the description of the user variables.
#
- variable: _DISPLAY_
string: Display Colorization
type: set
values:
Uncolored: ${_DISPLAY_UNCOLORED_}
Colored: ${_DISPLAY_COLORED_}
description: Activate or not the colorization of the environment messages.

53
export/Makefile Normal file
View file

@ -0,0 +1,53 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kaneton.STABLE/export/Makefile
#
# created julien quintard [sun jun 10 14:53:00 2007]
# updated julien quintard [tue nov 23 22:28:16 2010]
#
#
# ---------- dependencies -----------------------------------------------------
#
include ../environment/env.mk
#
# ---------- directives -------------------------------------------------------
#
.PHONY: main export- export clear prototypes headers
#
# ---------- variables --------------------------------------------------------
#
SUBDIRS := modules
#
# ---------- rules ------------------------------------------------------------
#
main:
export- export:
$(call env_launch,$(_EXPORT_SCRIPT_),$*,)
export-%:
$(call env_launch,$(_EXPORT_SCRIPT_),$*,)
clear:
for d in $(SUBDIRS) ; do \
$(call env_launch,$${d}/Makefile,clear,) ; \
done
$(call env_purge)
prototypes:
headers:

View file

@ -0,0 +1,146 @@
#
# ---------- information ------------------------------------------------------
#
# this set of operation removes all the unecessary components such as the
# cheat/, test/, history/ etc. directories.
#
# note that the root Makefile is also replaced in order to consier the
# new environment.
#
#
# directories
#
-
operation: fremove
path: TODO
-
operation: fremove
path: README
-
operation: fremove
path: cheat
-
operation: fremove
path: check
-
operation: fremove
path: configure
-
operation: fremove
path: history
-
operation: fremove
path: transcript
-
operation: fremove
path: view
-
operation: freplace
src: export/data/snapshot/Makefile
dst: Makefile
#
# test
#
-
operation: fremove
path: test/configuration
-
operation: fremove
path: test/engine
-
operation: fremove
path: test/environments
-
operation: fremove
path: test/hooks
-
operation: fremove
path: test/images
-
operation: fremove
path: test/robot
-
operation: fremove
path: test/scripts
-
operation: fremove
path: test/server
-
operation: fremove
path: test/stages
-
operation: fremove
path: test/store
-
operation: fremove
path: test/suites
-
operation: fremove
path: test/tests
-
operation: fremove
path: test/utilities
-
operation: freplace
src: export/data/snapshot/test/Makefile
dst: test/Makefile
#
# tools
#
-
operation: fremove
path: tool/ctc
-
operation: fremove
path: tool/firmware
-
operation: fremove
path: tool/forest
-
operation: fremove
path: tool/interface
-
operation: fremove
path: tool/mbl/octaneload
-
operation: fremove
path: tool/mbl/qemu-mips
-
operation: fremove
path: tool/script
-
operation: freplace
src: export/data/snapshot/tool/Makefile
dst: tool/Makefile

View file

@ -0,0 +1,23 @@
#
# ---------- information ------------------------------------------------------
#
# this set of operation removes all the exported kaneton implementations.
#
-
operation: fremove
path: export/output/snapshot.tar.bz2
-
operation: fremove
path: export/output/test:contributor.tar.bz2
-
operation: fremove
path: export/output/test:robot.tar.bz2
-
operation: fremove
path: export/output/test:student.tar.bz2

View file

@ -0,0 +1,68 @@
#
# ---------- information ------------------------------------------------------
#
# this set of operation removes every profile so that only the ibm-pc.ia32
# machine remains.
#
#
# architectures/platforms
#
-
operation: fremove
path: boot/loader/null.null
-
operation: fremove
path: boot/loader/qemu-mips.mips64
-
operation: fremove
path: kaneton/machine/architecture/mips64
-
operation: fremove
path: kaneton/machine/architecture/null
-
operation: fremove
path: kaneton/machine/architecture/ultrasparc
-
operation: fremove
path: kaneton/machine/glue/null.null
-
operation: fremove
path: kaneton/machine/glue/octane.mips64
-
operation: fremove
path: kaneton/machine/glue/qemu-mips.mips64
-
operation: fremove
path: kaneton/machine/platform/null
-
operation: fremove
path: kaneton/machine/platform/octane
-
operation: fremove
path: kaneton/machine/platform/qemu-mips
-
operation: fremove
path: kaneton/machine/platform/sun4u
#
# optimised
#
-
operation: fremove
path: kaneton/machine/glue/ibm-pc.ia32/optimised
-
operation: fremove
path: kaneton/machine/architecture/ia32/optimised

View file

@ -0,0 +1,31 @@
#
# ---------- information ------------------------------------------------------
#
# this set of operations removes parts of the source code in order for
# students to undertake the k0 project.
#
#
# boot
#
-
operation: fremove
path: boot/strap
-
operation: fremove
path: boot/loader/ibm-pc.ia32
-
operation: mkdir
path: boot/loader/ibm-pc.ia32/educational
-
operation: freplace
src: export/data/snapshot/boot/loader/ibm-pc.ia32/educational/Makefile
dst: boot/loader/ibm-pc.ia32/educational/Makefile
-
operation: freplace
src: export/data/snapshot/boot/loader/ibm-pc.ia32/educational/loader
dst: boot/loader/ibm-pc.ia32/educational/loader

View file

@ -0,0 +1,52 @@
#
# ---------- information ------------------------------------------------------
#
# this set of operations removes parts of the source code in order for
# students to undertake the k1 project.
#
#
# glue
#
-
operation: freplace
src: export/data/snapshot/kaneton/machine/glue/ibm-pc.ia32/educational/event.c
dst: kaneton/machine/glue/ibm-pc.ia32/educational/event.c
-
operation: freplace
src: export/data/snapshot/kaneton/machine/glue/ibm-pc.ia32/educational/include/event.h
dst: kaneton/machine/glue/ibm-pc.ia32/educational/include/event.h
#
# architecture
#
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/handler.c
dst: kaneton/machine/architecture/ia32/educational/handler.c
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/include/handler.h
dst: kaneton/machine/architecture/ia32/educational/include/handler.h
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/idt.c
dst: kaneton/machine/architecture/ia32/educational/idt.c
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/include/idt.h
dst: kaneton/machine/architecture/ia32/educational/include/idt.h
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/environment.c
dst: kaneton/machine/architecture/ia32/educational/environment.c
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/context.c
dst: kaneton/machine/architecture/ia32/educational/context.c

View file

@ -0,0 +1,62 @@
#
# ---------- information ------------------------------------------------------
#
# this set of operations removes parts of the source code in order for
# students to undertake the k2 project.
#
#
# glue
#
-
operation: freplace
src: export/data/snapshot/kaneton/machine/glue/ibm-pc.ia32/educational/as.c
dst: kaneton/machine/glue/ibm-pc.ia32/educational/as.c
-
operation: freplace
src: export/data/snapshot/kaneton/machine/glue/ibm-pc.ia32/educational/include/as.h
dst: kaneton/machine/glue/ibm-pc.ia32/educational/include/as.h
-
operation: freplace
src: export/data/snapshot/kaneton/machine/glue/ibm-pc.ia32/educational/region.c
dst: kaneton/machine/glue/ibm-pc.ia32/educational/region.c
#
# architecture
#
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/environment.c
dst: kaneton/machine/architecture/ia32/educational/environment.c
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/pd.c
dst: kaneton/machine/architecture/ia32/educational/pd.c
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/include/pd.h
dst: kaneton/machine/architecture/ia32/educational/include/pd.h
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/pt.c
dst: kaneton/machine/architecture/ia32/educational/pt.c
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/include/pt.h
dst: kaneton/machine/architecture/ia32/educational/include/pt.h
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/paging.c
dst: kaneton/machine/architecture/ia32/educational/paging.c
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/include/paging.h
dst: kaneton/machine/architecture/ia32/educational/include/paging.h

View file

@ -0,0 +1,40 @@
#
# ---------- information ------------------------------------------------------
#
# this set of operations removes parts of the source code in order for
# students to undertake the k3 project.
#
#
# core
#
-
operation: freplace
src: export/data/snapshot/kaneton/core/scheduler/scheduler-mfq.c
dst: kaneton/core/scheduler/scheduler-mfq.c
-
operation: freplace
src: export/data/snapshot/kaneton/core/include/scheduler.h
dst: kaneton/core/include/scheduler.h
#
# glue
#
-
operation: freplace
src: export/data/snapshot/kaneton/machine/glue/ibm-pc.ia32/educational/scheduler.c
dst: kaneton/machine/glue/ibm-pc.ia32/educational/scheduler.c
#
# architecture
#
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/context.c
dst: kaneton/machine/architecture/ia32/educational/context.c
-
operation: freplace
src: export/data/snapshot/kaneton/machine/architecture/ia32/educational/include/context.h
dst: kaneton/machine/architecture/ia32/educational/include/context.h

View file

@ -0,0 +1,8 @@
#
# ---------- information ------------------------------------------------------
#
# this set of operations removes parts of the source code in order for
# students to undertake the k4 project.
#
[]

View file

@ -0,0 +1,33 @@
#
# ---------- information ------------------------------------------------------
#
# this set of operation removes all the versioning-system-specific information.
#
#
# subversion
#
-
operation: fremovepattern
pattern: \.svn
#
# cvs
#
-
operation: fremovepattern
pattern: CVS
#
# git
#
-
operation: fremovepattern
pattern: \.git
#
# mercurial
#
-
operation: fremovepattern
pattern: \.hg

View file

@ -0,0 +1,29 @@
#
# ---------- information ------------------------------------------------------
#
# this set of operation removes the unecessary users so that only 'sample'
# remains.
#
#
# users
#
-
operation: fremove
path: environment/profile/user/enguerrand.raymond
-
operation: fremove
path: environment/profile/user/francois.goudal
-
operation: fremove
path: environment/profile/user/jean.guyader
-
operation: fremove
path: environment/profile/user/julien.quintard
-
operation: fremove
path: environment/profile/user/robot

View file

@ -0,0 +1,29 @@
#
# ---------- information ------------------------------------------------------
#
# this set of operation removes the unecessary users so that only 'test'
# remains.
#
#
# users
#
-
operation: fremove
path: environment/profile/user/enguerrand.raymond
-
operation: fremove
path: environment/profile/user/francois.goudal
-
operation: fremove
path: environment/profile/user/jean.guyader
-
operation: fremove
path: environment/profile/user/julien.quintard
-
operation: fremove
path: environment/profile/user/sample

View file

@ -0,0 +1,55 @@
#
# ---------- information ------------------------------------------------------
#
# this behaviour is used in order to create a kaneton snapshot for students.
#
-
operation: svnexport
-
operation: import
filename: sets/sweep
-
operation: import
filename: sets/k0
-
operation: import
filename: sets/k1
-
operation: import
filename: sets/k2
-
operation: import
filename: sets/k3
-
operation: import
filename: sets/k4
-
operation: import
filename: sets/chop
-
operation: import
filename: sets/ibm-pc.ia32
-
operation: import
filename: sets/user:sample
-
operation: import
filename: sets/export
-
operation: initenv
-
operation: tarball
filename: snapshot

View file

@ -0,0 +1,36 @@
#
# ---------- information ------------------------------------------------------
#
# this behaviour is used in order to create a kaneton snapshot contributors
# to invoke the test system.
#
-
operation: localexport
-
operation: initenv
-
operation: import
filename: sets/sweep
-
operation: import
filename: sets/chop
-
operation: import
filename: sets/ibm-pc.ia32
-
operation: import
filename: sets/export
-
operation: fremove
path: export/output/test:contributor.tar.bz2
-
operation: tarball
filename: test:contributor

View file

@ -0,0 +1,40 @@
#
# ---------- information ------------------------------------------------------
#
# this behaviour is used in order to create a kaneton snapshot students
# to invoke the test system.
#
-
operation: localexport
-
operation: initenv
-
operation: import
filename: sets/sweep
-
operation: import
filename: sets/chop
-
operation: import
filename: sets/ibm-pc.ia32
-
operation: import
filename: sets/user:test
-
operation: import
filename: sets/export
-
operation: fremove
path: export/output/test:group.tar.bz2
-
operation: tarball
filename: test:group

View file

@ -0,0 +1,40 @@
#
# ---------- information ------------------------------------------------------
#
# this behaviour is used in order to create a kaneton snapshot students
# to invoke the test system.
#
-
operation: localexport
-
operation: initenv
-
operation: import
filename: sets/sweep
-
operation: import
filename: sets/chop
-
operation: import
filename: sets/ibm-pc.ia32
-
operation: import
filename: sets/user:test
-
operation: import
filename: sets/export
-
operation: fremove
path: export/output/test:student.tar.bz2
-
operation: tarball
filename: test:student

View file

@ -0,0 +1,145 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kanetno
#
# file /home/mycure/kaneton/export/data/snapshot/Makefile
#
# created julien quintard [tue jun 26 11:27:22 2007]
# updated julien quintard [sat feb 5 12:11:16 2011]
#
#
# ---------- dependencies -----------------------------------------------------
#
-include environment/env.mk
#
# ---------- directives -------------------------------------------------------
#
.SILENT:
.PHONY: main initialize clean clear prototypes \
headers build install info
#
# ---------- variables --------------------------------------------------------
#
_PYTHON_ ?= $(KANETON_PYTHON)
_MAKE_ ?= $(MAKE)
#
# ---------- default rule -----------------------------------------------------
#
ifeq ($(_SIGNATURE_),kaneton)
PATHS = $(dir $(_COMPONENTS_))
main:
for path in $(PATHS) ; do \
if [ -f "$${path}/Makefile" ] ; then \
$(call env_launch,$${path}/Makefile,,) ; \
fi \
done
else
main \
clear \
prototypes \
headers \
build install \
info \
clean: initialize
$(_MAKE_) -f Makefile $@
endif
#
# ---------- environment ------------------------------------------------------
#
initialize:
cd environment/ && \
$(_PYTHON_) initialize.py && \
cd ..
#
# ---------- conditional ------------------------------------------------------
#
ifeq ($(_SIGNATURE_),kaneton)
#
# ---------- environment ------------------------------------------------------
#
clean:
$(call env_launch,$(_CLEAN_SCRIPT_),,)
#
# ---------- variables --------------------------------------------------------
#
SUBDIRS := boot environment kaneton \
license sample test tool \
$(PATHS)
#
# ---------- clear ------------------------------------------------------------
#
clear:
for d in $(SUBDIRS) ; do \
$(call env_launch,$${d}/Makefile,clear,) ; \
done
$(call env_purge,)
#
# ---------- prototypes -------------------------------------------------------
#
prototypes:
for d in $(SUBDIRS) ; do \
$(call env_launch,$${d}/Makefile,prototypes,) ; \
done
#
# ---------- headers ----------------------------------------------------------
#
headers:
for d in $(SUBDIRS) ; do \
$(call env_launch,$${d}/Makefile,headers,) ; \
done
#
# ---------- boot -------------------------------------------------------------
#
build:
$(call env_launch,$(_MBL_SCRIPT_),build,)
install: main
$(call env_launch,$(_MBL_SCRIPT_),install,)
#
# ---------- information ------------------------------------------------------
#
info:
$(call env_print,,,)
$(call env_print,"--- ",blue,$(ENV_OPTION_NO_NEWLINE))
$(call env_print,http://kaneton.opaak.org,,)
$(call env_print,,,)
endif

View file

@ -0,0 +1,50 @@
#
# ---------- header -----------------------------------------------------------
#
# project kaneton
#
# license kaneton
#
# file /home/mycure/kane.../loader/ibm-pc.ia32/educational/Makefile
#
# created julien quintard [tue jun 12 20:34:41 2007]
# updated julien quintard [sat feb 5 11:09:53 2011]
#
#
# ---------- component --------------------------------------------------------
#
component := loader
#
# ---------- dependencies -----------------------------------------------------
#
include ../../../../environment/env.mk
#
# ---------- directives -------------------------------------------------------
#
.PHONY: main clear prototypes headers
#
# ---------- rules ------------------------------------------------------------
#
ifeq ($(behaviour),default)
main:
prototypes:
headers:
dependencies:
endif
#
# ---------- dependencies -----------------------------------------------------
#
-include ./$(_DEPENDENCY_MK_)

View file

@ -0,0 +1,290 @@
/*
* ---------- header ----------------------------------------------------------
*
* project kaneton
*
* license kaneton
*
* file /home/mycure/kane...kaneton/kaneton/core/include/scheduler.h
*
* created julien quintard [wed jun 6 13:44:48 2007]
* updated julien quintard [sat feb 5 16:59:18 2011]
*/
#ifndef CORE_SCHEDULER_H
#define CORE_SCHEDULER_H 1
/*
* ---------- dependencies ----------------------------------------------------
*/
#include <core/types.h>
#include <core/error.h>
#include <core/id.h>
#include <machine/machine.h>
/*
* ---------- algorithms ------------------------------------------------------
*/
/*
* the supported scheduler algorithms.
*/
#define SCHEDULER_ALGORITHM_MFQ (1 << 0)
/*
* ---------- macros ----------------------------------------------------------
*/
/*
* the scheduler state either started or stopped.
*/
#define SCHEDULER_STATE_START 1
#define SCHEDULER_STATE_STOP 2
/*
* initial value for the scheduler quantum in milliseconds.
*/
#define SCHEDULER_QUANTUM TIMER_DELAY
/*
* the number of priorities i.e the number of queues.
*/
#define SCHEDULER_NPRIORITIES 60
/*
* timeslice bounds.
*/
#define SCHEDULER_TIMESLICE_HIGH 250
#define SCHEDULER_TIMESLICE_LOW 10
/*
* the timeslice granularity.
*/
#define SCHEDULER_GRANULARITY _scheduler.quantum
/*
* scheduling priorities.
*/
#define SCHEDULER_PRIORITY_HIGH SCHEDULER_NPRIORITIES - 1
#define SCHEDULER_PRIORITY_LOW 0
/*
* ---------- macro functions -------------------------------------------------
*/
/*
* this macro-function computes the thread's high precision character
* by taking into account both the task's and thread's priorities.
*/
#define SCHEDULER_CHARACTER(_id_) \
( \
{ \
o_task* _task_; \
o_thread* _thread_; \
\
assert(thread_get((_id_), &_thread_) == ERROR_OK); \
assert(task_get(_thread_->task, &_task_) == ERROR_OK); \
\
((_task_->priority - TASK_PRIORITY_BACKGROUND_LOW) * \
(_thread_->priority - THREAD_PRIORITY_LOW)); \
} \
)
/*
* this macro-function computes the priority for a giver thread. this
* is a low precision measurement of a thread's priority which is used
* for locating the proper scheduling queue.
*
* indeed, while the character lies in a large range, it is then
* reduced within the range [SCHEDULER_PRIORITY_LOW, SCHEDULER_PRIORITY_HIGH].
*/
#define SCHEDULER_PRIORITY(_thread_) \
( \
{ \
t_priority _character_; \
\
_character_ = SCHEDULER_CHARACTER((_thread_)); \
\
SCHEDULER_PRIORITY_LOW + \
((_character_ * \
(SCHEDULER_PRIORITY_HIGH - SCHEDULER_PRIORITY_LOW)) / \
((TASK_PRIORITY_KERNEL_HIGH - TASK_PRIORITY_BACKGROUND_LOW) * \
(THREAD_PRIORITY_HIGH - THREAD_PRIORITY_LOW))); \
} \
)
/*
* this macro-function takes a number of milliseconds and turns it
* into a valid timeslice according to the scheduler quantum.
*
* for example, with a quantum of 25ms and a given number of 264 milliseconds,
* this macro-function would return 275ms, the upper rounded number.
*/
#define SCHEDULER_SCALE(_timeslice_) \
((((_timeslice_) % SCHEDULER_GRANULARITY) != 0) ? \
(((_timeslice_) + SCHEDULER_GRANULARITY) - \
(_timeslice_) % SCHEDULER_GRANULARITY) \
: (_timeslice_))
/*
* this macro-function computes the timeslice given by the kernel to a
* thread based on its character.
*
* the character basically returns task->priority * thread->priority.
*
* this number is then turned into a timeslice i.e within the timeslice
* range [SCHEDULER_TIMESLICE_LOW, SCHEDULER_TIMESLICE_HIGH].
*
* finally, the timeslice is scaled i.e rounded up in order to fit the
* scheduling unit known as the quantum.
*/
#define SCHEDULER_TIMESLICE(_thread_) \
( \
{ \
t_priority _character_; \
t_timeslice _timeslice_; \
\
_character_ = SCHEDULER_CHARACTER((_thread_)); \
\
_timeslice_ = \
SCHEDULER_TIMESLICE_LOW + \
((_character_ * \
(SCHEDULER_TIMESLICE_HIGH - SCHEDULER_TIMESLICE_LOW)) / \
((TASK_PRIORITY_KERNEL_HIGH - TASK_PRIORITY_BACKGROUND_LOW) * \
(THREAD_PRIORITY_HIGH - THREAD_PRIORITY_LOW))); \
\
SCHEDULER_SCALE(_timeslice_); \
} \
)
/*
* ---------- types -----------------------------------------------------------
*/
/*
* the scheduler object which managers thread candidates for a
* given CPU specified by _cpu_.
*
* the _thread_ attribute represents the currently scheduled thread
* which operates at the priority _priority_. this thread stil has
* _timeslice_ milliseconds of execution time before a context switch
* occurs.
*
* the _state_ attribute represents the scheduler's current state, either
* started or stopped.
*/
typedef struct
{
i_cpu cpu;
i_thread thread;
t_timeslice timeslice;
t_priority priority;
/* FIXME[code to complete] */
t_state state;
machine_data(o_scheduler);
} o_scheduler;
/*
* the scheduler manager's structure which contains the quantum _quantum_
* i.e the smaller unit of execution time, the idle thread's identifier _idle_
* and the sets of schedulers, one scheduler per CPU.
*/
typedef struct
{
t_quantum quantum;
i_thread idle;
i_set schedulers;
machine_data(m_scheduler);
} m_scheduler;
/*
* the scheduler dispatcher.
*/
typedef struct
{
t_error (*scheduler_show)(i_cpu,
mt_margin);
t_error (*scheduler_dump)(void);
t_error (*scheduler_start)(i_cpu);
t_error (*scheduler_stop)(i_cpu);
t_error (*scheduler_quantum)(t_quantum);
t_error (*scheduler_yield)(void);
t_error (*scheduler_elect)(void);
t_error (*scheduler_add)(i_thread);
t_error (*scheduler_remove)(i_thread);
t_error (*scheduler_update)(i_thread);
t_error (*scheduler_initialize)(void);
t_error (*scheduler_clean)(void);
} d_scheduler;
/*
* ---------- prototypes ------------------------------------------------------
*
* ../../core/scheduler/scheduler-mfq.c
*/
/*
* ../../core/scheduler/scheduler-mfq.c
*/
t_error scheduler_show(i_cpu id,
mt_margin margin);
t_error scheduler_dump(void);
t_error scheduler_start(i_cpu id);
t_error scheduler_stop(i_cpu id);
t_error scheduler_quantum(t_quantum quantum);
t_error scheduler_yield(void);
t_error scheduler_elect(void);
t_error scheduler_add(i_thread id);
t_error scheduler_remove(i_thread id);
t_error scheduler_update(i_thread id);
t_error scheduler_exist(i_cpu id);
t_error scheduler_get(i_cpu id,
o_scheduler** object);
t_error scheduler_current(o_scheduler** scheduler);
t_error scheduler_initialize(void);
t_error scheduler_clean(void);
/*
* eop
*/
#endif

View file

@ -0,0 +1,463 @@
/*
* ---------- header ----------------------------------------------------------
*
* project kaneton
*
* license kaneton
*
* file /home/mycure/Down...n/kaneton/core/scheduler/scheduler-mfq.c
*
* created matthieu bucchianeri [sat jun 3 22:36:59 2006]
* updated julien quintard [mon apr 11 13:23:09 2011]
*/
/*
* ---------- information -----------------------------------------------------
*
* the scheduler manager provides functionalities for managing the
* execution of the tasks and their threads on the possibly multiple CPUs
* of the computer.
*
* note that tasks are not scheduled. indeed, the active entity is the
* thread. therefore, adding a thread to the scheduler makes it a candidate
* for future election.
*
* the core function is the scheduler_elect() function which chooses
* the next thread to execute, though the current thread may be selected
* to continue its execution.
*/
#if (SCHEDULER_ALGORITHM == SCHEDULER_ALGORITHM_MFQ)
/*
* ---------- includes --------------------------------------------------------
*/
#include <kaneton.h>
/*
* include the machine-specific definitions required by the core.
*/
machine_include(scheduler);
/*
* ---------- externs ---------------------------------------------------------
*/
/*
* the kernel manager.
*/
extern m_kernel _kernel;
/*
* the cpu manager.
*/
extern m_cpu _cpu;
/*
* ---------- globals ---------------------------------------------------------
*/
/*
* the scheduler manager.
*/
m_scheduler _scheduler;
/*
* ---------- functions -------------------------------------------------------
*/
/*
* this function starts the given scheduler.
*
* steps:
*
* 1) retrieve the scheduler object.
* 2) change the scheduler's state.
* 3) call the machine.
*/
t_error scheduler_start(i_cpu id)
{
o_scheduler* scheduler;
/*
* 1)
*/
if (scheduler_get(id, &scheduler) != ERROR_OK)
CORE_ESCAPE("unable to retrieve the scheduler object");
/*
* 2)
*/
scheduler->state = SCHEDULER_STATE_START;
/*
* 3)
*/
if (machine_call(scheduler, start, id) != ERROR_OK)
CORE_ESCAPE("an error occured in the machine");
CORE_LEAVE();
}
/*
* this function stops the given scheduler.
*
* steps:
*
* 1) retrieve the scheduler object.
* 2) change the scheduler's state.
* 3) call the machine.
*/
t_error scheduler_stop(i_cpu id)
{
o_scheduler* scheduler;
/*
* 1)
*/
if (scheduler_get(id, &scheduler) != ERROR_OK)
CORE_ESCAPE("unable to retrieve the scheduler object");
/*
* 2)
*/
scheduler->state = SCHEDULER_STATE_STOP;
/*
* 3)
*/
if (machine_call(scheduler, stop, id) != ERROR_OK)
CORE_ESCAPE("an error occured in the machine");
CORE_LEAVE();
}
/*
* this function modifies the quantum.
*/
t_error scheduler_quantum(t_quantum quantum)
{
/* FIXME[code to complete] */
CORE_LEAVE();
}
/*
* this function enables the current thread to voluntarily relinquish its
* execution, hence permitting another thread to be scheduled immediately
* on this CPU.
*/
t_error scheduler_yield(void)
{
/* FIXME[code to complete] */
CORE_LEAVE();
}
/*
* this function elects the future thread to execute, taking care to
* save the currently executing one, should both the task and thread be
* still in a running state.
*
* note that this function may elect the already running thread if
* (i) it has not expired and (ii) there is no thread with a higher priority
* in the active list.
*
* finally, this function may detect that the scheduler has been stopped.
* should this occur, the elected thread is saved and the original kernel
* thread is specially scheduled, hence returning to its initial state.
*/
t_error scheduler_elect(void)
{
/* FIXME[code to complete] */
CORE_LEAVE();
}
/*
* this function adds a thread to the scheduler.
*/
t_error scheduler_add(i_thread id)
{
/* FIXME[code to complete] */
CORE_LEAVE();
}
/*
* this function removes a thread from the scheduler.
*/
t_error scheduler_remove(i_thread id)
{
/* FIXME[code to complete] */
CORE_LEAVE();
}
/*
* this function updates a thread from the scheduler after its priority
* has changed.
*
* note that the easiest way could seem to be to remove then add the
* thread, in which case it would be added to its proper queue depending
* on its new priority. unfortunately this solution would make the thread
* lose its remaining timeslices. besides, if the thread to remove is the
* currently scheduled thread, removing it would incurr a yield. in this
* case, the thread would no longer be scheduled and would therefore not
* have the chance to add itself back to the scheduler.
*/
t_error scheduler_update(i_thread id)
{
/* FIXME[code to complete] */
CORE_LEAVE();
}
/*
* this function returns true if the scheduler for the given CPU identifier
* exists.
*/
t_error scheduler_exist(i_cpu id)
{
if (set_exist(_scheduler.schedulers, id) != ERROR_TRUE)
CORE_FALSE();
CORE_TRUE();
}
/*
* this function retrives the scheduler for the given CPU.
*
* steps:
*
* 0) verify the arguments.
* 1) retrieve the object from the set of schedulers.
*/
t_error scheduler_get(i_cpu id,
o_scheduler** object)
{
/*
* 0)
*/
if (object == NULL)
CORE_ESCAPE("the 'object' argument is null");
/*
* 1)
*/
if (set_get(_scheduler.schedulers, id, (void**)object) != ERROR_OK)
CORE_ESCAPE("unable to retrieve the object from the set of schedulers");
CORE_LEAVE();
}
/*
* this function returns the scheduler object for the current CPU.
*
* steps:
*
* 0) verify the arguments.
* 1) retrieve the current CPU identifier.
* 2) retrieve the current scheduler object.
*/
t_error scheduler_current(o_scheduler** scheduler)
{
i_cpu cpu;
/*
* 0)
*/
if (scheduler == NULL)
CORE_ESCAPE("the 'scheduler' argument is null");
/*
* 1)
*/
if (cpu_current(&cpu) != ERROR_OK)
CORE_ESCAPE("unable to retrieve the current CPU object");
/*
* 2)
*/
if (set_get(_scheduler.schedulers, cpu, (void**)scheduler) != ERROR_OK)
CORE_ESCAPE("unable to retrieve the scheduler from the set");
CORE_LEAVE();
}
/*
* this function initializes the scheduler manager.
*
* steps:
*
* 1) display a message.
* 2) initialize the manager's structure.
* 3) initialize the quantum.
* 4) retrieve the number of CPUs.
* 5) reserve the set of schedulers.
* 6) go through the CPUs.
* a) retrieve the CPU object.
* b) build the scheduler object.
* g) add the scheduler to the set of schedulers.
* 7) retrieve the currently running scheduler.
* 8) set the scheduler's current thread as being the kernel thread.
* 9) call the machine.
*/
t_error scheduler_initialize(void)
{
o_scheduler* scheduler;
t_setsz ncpus;
s_iterator it;
t_state st;
o_cpu* o;
/*
* 1)
*/
module_call(console, message,
'+', "initializing the scheduler manager\n");
/*
* 2)
*/
memset(&_scheduler, 0x0, sizeof (m_scheduler));
/*
* 3)
*/
_scheduler.quantum = SCHEDULER_QUANTUM;
/*
* 4)
*/
if (set_size(_cpu.cpus, &ncpus) != ERROR_OK)
CORE_ESCAPE("unable to retrieve the number of active CPUs");
/*
* 5)
*/
if (set_reserve(array,
SET_OPTION_ALLOCATE,
ncpus,
sizeof (o_scheduler),
&_scheduler.schedulers) != ERROR_OK)
CORE_ESCAPE("unable to reserve a set for the schedulers");
/*
* 6)
*/
set_foreach(SET_OPTION_FORWARD, _cpu.cpus, &it, st)
{
o_scheduler scheduler;
/*
* a)
*/
if (set_object(_cpu.cpus, it, (void**)&o) != ERROR_OK)
CORE_ESCAPE("unable to retrieve the CPU object");
/*
* b)
*/
scheduler.cpu = o->id;
scheduler.thread = ID_UNUSED;
scheduler.timeslice = _scheduler.quantum;
scheduler.priority = 0;
scheduler.state = SCHEDULER_STATE_STOP;
/*
* g)
*/
if (set_append(_scheduler.schedulers, &scheduler) != ERROR_OK)
CORE_ESCAPE("unable to append the CPU's scheduler to the set");
}
/*
* 7)
*/
if (scheduler_current(&scheduler) != ERROR_OK)
CORE_ESCAPE("unable to retrieve the current CPU's scheduler");
/*
* 8)
*/
scheduler->thread = _kernel.thread;
/*
* 9)
*/
if (machine_call(scheduler, initialize) != ERROR_OK)
CORE_ESCAPE("an error occured in the machine");
CORE_LEAVE();
}
/*
* this function just reinitializes the scheduler manager.
*
* steps:
*
* 1) display a message.
* 2) call the machine.
*/
t_error scheduler_clean(void)
{
/*
* 1)
*/
module_call(console, message,
'+', "cleaning the scheduler manager\n");
/*
* 2)
*/
if (machine_call(scheduler, clean) != ERROR_OK)
CORE_ESCAPE("an error occured in the machine");
CORE_LEAVE();
}
#endif

View file

@ -0,0 +1,704 @@
/*
* ---------- header ----------------------------------------------------------
*
* project kaneton
*
* license kaneton
*
* file /home/mycure/kane.../architecture/ia32/educational/context.c
*
* created renaud voltz [tue apr 4 03:08:03 2006]
* updated julien quintard [mon feb 7 15:53:52 2011]
*/
/*
* ---------- information -----------------------------------------------------
*
* this file contains functions related to the IA32 context management.
*
* the ia32/educational implementation makes use of a single TSS - Task
* State Segment which describes the currently executing context.
*
* the context switch mechanism consists in saving the currently executing
* thread's state and loading the future's. note however that the CPU
* performs some saving/restoring automatically.
*
* basically, things go as follows. a task is running, say in CPL3 i.e a guest
* task. when the timer interrupt occurs, for example, the privilege changes
* from CPL3 to CPL0. the CPU, noticing this change in privilege saves some
* of the thread's context---SS, ESP, EFLAGS, CS, EIP and possible an error
* code---on a special stack referred to as the thread's pile i.e a stack
* specifically used whenever the privilege changes. note that, should no
* change in privilege occur, the registers would be stored on the thread's
* current stack.
*
* at this point, the processor executes the handler shell (cf handler.c)
* which pre-handles an interrupt depending on its nature: exception, IRQ etc.
* besides, the handler shell calls the ARCHITECTURE_CONTEXT_SAVE()
* macro-function which is at the heart of the context switching mechanism.
*
* once the interrupt has been treated, the ARCHITECTURE_CONTEXT_RESTORE()
* macro-function restores the necessary. finally, the 'iret' instruction
* is called. the CPU noticing that a privilege change had occured, restores
* the thread's context by fetching the registers it pushed from the
* thread's pile (or from the thread's stack if the privilege had not changed).
*
* the whole context switch mechanism therefore relies on interrupts. more
* precisely the idea for context switching from a thread A to a thread B
* is to (i) save the thread A's context but this is done naturally when
* A gets interrupted and (ii) change the TSS so that thread B gets referenced,
* hence making the CPU think B got interrupted (instead of A). therefore,
* when returning from the interrupt, the CPU will restore B's context
* rather than A's. this is how A got interrupted, its context saved
* and B's execution got resumed.
*/
/*
* ---------- includes --------------------------------------------------------
*/
#include <kaneton.h>
/*
* ---------- externs ---------------------------------------------------------
*/
/*
* the architecture manager.
*/
extern am _architecture;
/*
* ---------- externs ---------------------------------------------------------
*/
/*
* kernel manager.
*/
extern m_kernel _kernel;
/*
* thread manager.
*/
extern m_thread _thread;
/*
* ---------- functions -------------------------------------------------------
*/
/*
* this function dumps the given context.
*/
t_error architecture_context_dump(as_context context)
{
module_call(console, message,
'#',
"context: ds(0x%x) edi(0x%x) esi(0x%x) ebp(0x%x) _esp(0x%x)\n",
context.ds & 0xffff,
context.edi,
context.esi,
context.ebp,
context._esp);
module_call(console, message,
'#',
" ebx(0x%x) edx(0x%x) ecx(0x%x) eax(0x%x) error(0x%x)\n",
context.ebx,
context.edx,
context.ecx,
context.eax,
context.error);
module_call(console, message,
'#',
" eip(0x%x) cs(0x%x) eflags(0x%x) esp(0x%x) ss(0x%x)\n",
context.eip,
context.cs & 0xffff,
context.eflags,
context.esp,
context.ss & 0xffff);
MACHINE_LEAVE();
}
/*
* this function builds the given context, initializes its attributes.
*
* steps:
*
* 1) retrieve the thread and task objects.
* 2) depending on the thread's task class.
* A) if this thread is a kernel thread i.e a ring0 thread, this means
* that its context will be saved on its stack. besides, since no change
* in privilege will occur when interrupted, there is no need for a
* pile...
* a) set the pile attributes to zero.
* B) otherwise...
* a) set the thread's pile size.
* b) allocate a pile for the thread i.e a stack which is used by the
* processor to store the context whenever the execution privilege
* changes; for example whenever a guest task running in CP3 is
* interrupted by the timer.
* c) set the pile pointer to the end since IA32 stacks grow towards
* the lower addresses.
* 3) initialize the IA32 context's registers to zero.
* 4) initialize the eflags by activating the first bit (mandatory) but
* also the IF flags to that maskable interrupts get triggered. besides,
* allow driver tasks to perform I/O operations by setting the
* appropriate IOPL.
* 5) set the context's segment selectors according to the task's class.
* 6) complete the thread's initial IA32 context by setting ESP and EIP.
* 7) set the static stack pointer to the end since stacks grow towards
* the lower addresses.
* 8) depending on the thread's task class.
* A) if the thread is a kernel thread, set the initial context's position
* on the stack. indeed, let's recall that ring0 thread's contexts
* are stored on their stack since no change in privilege occurs.
* B) otherwise, set its position on the thread's pile i.e special kernel
* stack.
* 9) finally set the thread's initial IA32 context. note that this step
* is ignored for the kernel thread. indeed, this thread is the one
* setting up the whole kernel. once the scheduler is started, an interrupt
* will be triggered hence interrupting the running thread i.e the kernel
* thread, hence saving its context. since this special thread will always
* start with its context being saved, there is no need to do it now.
* on the contrary, the other threads will begin with their context being
* restored in order to be scheduled for the first time.
*/
t_error architecture_context_build(i_thread id)
{
o_task* task;
o_thread* thread;
as_context ctx;
/*
* 1)
*/
if (thread_get(id, &thread) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the thread object");
if (task_get(thread->task, &task) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the task object");
/*
* 2)
*/
if (task->class == TASK_CLASS_KERNEL)
{
/*
* A)
*/
/*
* a)
*/
thread->machine.pile.base = 0x0;
thread->machine.pile.size = 0x0;
thread->machine.pile.pointer = 0x0;
}
else
{
/*
* B)
*/
/*
* a)
*/
thread->machine.pile.size = ARCHITECTURE_HANDLER_PILE_SIZE;
/*
* b)
*/
if (map_reserve(task->as,
MAP_OPTION_NONE,
thread->machine.pile.size,
PERMISSION_READ | PERMISSION_WRITE,
&thread->machine.pile.base) != ERROR_OK)
MACHINE_ESCAPE("unable to reserve a map for the thread's pile");
/*
* c)
*/
thread->machine.pile.pointer =
thread->machine.pile.base + thread->machine.pile.size - 16;
}
/*
* 3)
*/
memset(&ctx, 0x0, sizeof (as_context));
/*
* 4)
*/
ctx.eflags =
ARCHITECTURE_REGISTER_EFLAGS_01 |
ARCHITECTURE_REGISTER_EFLAGS_IF;
if (task->class == TASK_CLASS_DRIVER)
{
ctx.eflags |=
ARCHITECTURE_REGISTER_EFLAGS_IOPL_SET(ARCHITECTURE_PRIVILEGE_DRIVER);
}
/*
* 5)
*/
switch (task->class)
{
case TASK_CLASS_KERNEL:
{
ctx.cs = _thread.machine.selectors.kernel.cs;
ctx.ds = _thread.machine.selectors.kernel.ds;
ctx.ss = _thread.machine.selectors.kernel.ds;
break;
}
case TASK_CLASS_DRIVER:
{
ctx.cs = _thread.machine.selectors.driver.cs;
ctx.ds = _thread.machine.selectors.driver.ds;
ctx.ss = _thread.machine.selectors.driver.ds;
break;
}
case TASK_CLASS_SERVICE:
{
ctx.cs = _thread.machine.selectors.service.cs;
ctx.ds = _thread.machine.selectors.service.ds;
ctx.ss = _thread.machine.selectors.service.ds;
break;
}
case TASK_CLASS_GUEST:
{
ctx.cs = _thread.machine.selectors.guest.cs;
ctx.ds = _thread.machine.selectors.guest.ds;
ctx.ss = _thread.machine.selectors.guest.ds;
break;
}
}
/*
* 6)
*/
ctx.esp = thread->stack.base + thread->stack.size - 16;
ctx.eip = thread->entry;
/*
* 7)
*/
thread->machine.stack.pointer = thread->stack.base + thread->stack.size - 16;
/*
* 8)
*/
if (task->class == TASK_CLASS_KERNEL)
{
/*
* A)
*/
thread->machine.context =
thread->machine.stack.pointer - sizeof (as_context);
}
else
{
/*
* B)
*/
thread->machine.context =
thread->machine.pile.pointer - sizeof (as_context);
}
/*
* 9)
*/
if (thread->id != _kernel.thread)
{
if (architecture_context_set(thread->id, &ctx) != ERROR_OK)
MACHINE_ESCAPE("unable to set the context");
}
MACHINE_LEAVE();
}
/*
* this function destroys a thread's context.
*
* steps:
*
* 1) retrieve the thread and task object.
* 2) if the thread has a pile---i.e is not a kernel thread---release it.
*/
t_error architecture_context_destroy(i_thread id)
{
o_task* task;
o_thread* thread;
/*
* 1)
*/
if (thread_get(id, &thread) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the thread object");
if (task_get(thread->task, &task) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the task object");
/*
* 2)
*/
if (task->class != TASK_CLASS_KERNEL)
{
if (map_release(task->as,
thread->machine.pile.base) != ERROR_OK)
MACHINE_ESCAPE("unable to release the thread's pile");
}
MACHINE_LEAVE();
}
/*
* this function sets up the context switch mechanism.
*
* steps:
*
* 1) retrieve the kernel address space object.
* 2) reserve the KIS - Kernel Interrupt Stack and set its pointer to
* the end since stacks grow towards low addresses. note that this
* special stack resides within the kernel, as its name indicates, and
* is used to handle interrupts.
* 3) reserve a memory area for the TSS.
* 4) build the initial TSS.
* 5) update the TSS in order to represent the currently executing thread.
* since the current thread is the kernel thread, which runs in ring0,
* no ring0 stack needs to be provided, hence SS0 and ESP0 are ignored.
* 6) activate the TSS.
* 7) retrieve the segment selectors associated with the
* kernel/driver/service/guest code/data segments. these segment selectors
* will be used whenever a thread of the associated task class will
* be created.
*/
t_error architecture_context_setup(void)
{
as_tss* tss;
o_as* as;
/*
* 1)
*/
if (as_get(_kernel.as, &as) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the address space object");
/*
* 2)
*/
_architecture.kernel.kis.size = ARCHITECTURE_HANDLER_KIS_SIZE;
if (map_reserve(_kernel.as,
MAP_OPTION_SYSTEM,
_architecture.kernel.kis.size,
PERMISSION_READ | PERMISSION_WRITE,
&_architecture.kernel.kis.base) != ERROR_OK)
MACHINE_ESCAPE("unable to reserve the TSS memory area");
_architecture.kernel.kis.pointer =
_architecture.kernel.kis.base + (_architecture.kernel.kis.size - 16);
/*
* 3)
*/
if (map_reserve(_kernel.as,
MAP_OPTION_SYSTEM,
ARCHITECTURE_TSS_SIZE,
PERMISSION_READ | PERMISSION_WRITE,
&_thread.machine.tss) != ERROR_OK)
MACHINE_ESCAPE("unable to reserve the TSS memory area");
/*
* 4)
*/
if (architecture_tss_build(_thread.machine.tss, &tss) != ERROR_OK)
MACHINE_ESCAPE("unable to build the initial TSS");
/*
* 5)
*/
if (architecture_tss_update(tss,
ARCHITECTURE_TSS_SS0_NULL,
ARCHITECTURE_TSS_ESP0_NULL,
ARCHITECTURE_TSS_IO) != ERROR_OK)
MACHINE_ESCAPE("unable to build the TSS");
/*
* 6)
*/
if (architecture_tss_activate(tss) != ERROR_OK)
MACHINE_ESCAPE("unable to activate the system's TSS");
/*
* 7)
*/
if (architecture_gdt_selector(
ARCHITECTURE_GDT_INDEX_KERNEL_CODE,
ARCHITECTURE_PRIVILEGE_KERNEL,
&_thread.machine.selectors.kernel.cs) != ERROR_OK)
MACHINE_ESCAPE("unable to build the kernel code segment selector");
if (architecture_gdt_selector(
ARCHITECTURE_GDT_INDEX_KERNEL_DATA,
ARCHITECTURE_PRIVILEGE_KERNEL,
&_thread.machine.selectors.kernel.ds) != ERROR_OK)
MACHINE_ESCAPE("unable to build the kernel data segment selector");
if (architecture_gdt_selector(
ARCHITECTURE_GDT_INDEX_DRIVER_CODE,
ARCHITECTURE_PRIVILEGE_DRIVER,
&_thread.machine.selectors.driver.cs) != ERROR_OK)
MACHINE_ESCAPE("unable to build the driver code segment selector");
if (architecture_gdt_selector(
ARCHITECTURE_GDT_INDEX_DRIVER_DATA,
ARCHITECTURE_PRIVILEGE_DRIVER,
&_thread.machine.selectors.driver.ds) != ERROR_OK)
MACHINE_ESCAPE("unable to build the driver data segment selector");
if (architecture_gdt_selector(
ARCHITECTURE_GDT_INDEX_SERVICE_CODE,
ARCHITECTURE_PRIVILEGE_SERVICE,
&_thread.machine.selectors.service.cs) != ERROR_OK)
MACHINE_ESCAPE("unable to build the service code segment selector");
if (architecture_gdt_selector(
ARCHITECTURE_GDT_INDEX_SERVICE_DATA,
ARCHITECTURE_PRIVILEGE_SERVICE,
&_thread.machine.selectors.service.ds) != ERROR_OK)
MACHINE_ESCAPE("unable to build the service data segment selector");
if (architecture_gdt_selector(
ARCHITECTURE_GDT_INDEX_GUEST_CODE,
ARCHITECTURE_PRIVILEGE_GUEST,
&_thread.machine.selectors.guest.cs) != ERROR_OK)
MACHINE_ESCAPE("unable to build the guest code segment selector");
if (architecture_gdt_selector(
ARCHITECTURE_GDT_INDEX_GUEST_DATA,
ARCHITECTURE_PRIVILEGE_GUEST,
&_thread.machine.selectors.guest.ds) != ERROR_OK)
MACHINE_ESCAPE("unable to build the guest data segment selector");
MACHINE_LEAVE();
}
/*
* this function switches execution to the specified thread.
*/
t_error architecture_context_switch(i_thread current,
i_thread future)
{
/* FIXME[code to complete] */
MACHINE_LEAVE();
}
/*
* this function pushes the given arguments on a thread's stack. this way,
* the thread will be able to access these values at startup.
*
* steps:
*
* 1) retrieve the thread and task objects.
* 2) retrieve the thread's context.
* 3) update the thread's stack pointer by decreasing it since the
* arguments are going to be stored at the top of it.
* 4) write the arguments to the thread's stack.
* 5) update the thread's context.
*/
t_error architecture_context_arguments(i_thread id,
void* arguments,
t_vsize size)
{
s_thread_context context;
o_thread* thread;
o_task* task;
/*
* 1)
*/
if (thread_get(id, &thread) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the thread object");
if (task_get(thread->task, &task) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the task object");
/*
* 2)
*/
if (thread_store(thread->id, &context) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the thread context");
/*
* 3)
*/
context.sp -= size;
/*
* 4)
*/
if (as_write(task->as, arguments, size, context.sp) != ERROR_OK)
MACHINE_ESCAPE("unable to store the arguments on the thread's stack");
/*
* 5)
*/
if (thread_load(thread->id, context) != ERROR_OK)
MACHINE_ESCAPE("unable to update the thread context");
MACHINE_LEAVE();
}
/*
* this function retrieves the IA32 context of the given thread.
*
* note that the interrupted task's context has been stored in its
* pile, i.e ring0 stack (excepts for kernels threads). since the pile is
* only mapped in the task's address space, this function, running in the
* kernel environment, cannot access it directly. therefore, the as_read()
* function is used to temporarily map the necessary pages in the kernel
* address space.
*
* steps:
*
* 0) verify the arguments.
* 1) retrieve the thread and task objects.
* 2) read the thread's context from its pile.
*/
t_error architecture_context_get(i_thread id,
as_context* context)
{
o_thread* thread;
o_task* task;
/*
* 0)
*/
if (context == NULL)
MACHINE_ESCAPE("the 'context' argument is null");
/*
* 1)
*/
if (thread_get(id, &thread) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the thread object");
if (task_get(thread->task, &task) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the task object");
/*
* 2)
*/
if (as_read(task->as,
thread->machine.context,
sizeof (as_context),
context) != ERROR_OK)
MACHINE_ESCAPE("unable to read the thread's IA32 context");
MACHINE_LEAVE();
}
/*
* this function updates the context of a given thread.
*
* note that the interrupted task's context has been stored in its
* pile, i.e ring0 stack (except for kernel threads). since the pile is
* only mapped in the task's address space, this function, running in the
* kernel environment, cannot access it directly. therefore, the as_write()
* function is used to temporarily map the necessary pages in the kernel
* address space.
*
* steps:
*
* 0) verify the arguments.
* 1) retrieve the thread and task objects.
* 2) update the thread's context stored in its pile by writing its address
* space.
*/
t_error architecture_context_set(i_thread id,
as_context* context)
{
o_thread* thread;
o_task* task;
/*
* 0)
*/
if (context == NULL)
MACHINE_ESCAPE("the 'context' argument is null");
/*
* 1)
*/
if (thread_get(id, &thread) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the thread object");
if (task_get(thread->task, &task) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the task object");
/*
* 2)
*/
if (as_write(task->as,
context,
sizeof (as_context),
thread->machine.context) != ERROR_OK)
MACHINE_ESCAPE("unable to write the thread's IA32 context");
MACHINE_LEAVE();
}

View file

@ -0,0 +1,444 @@
/*
* ---------- header ----------------------------------------------------------
*
* project kaneton
*
* license kaneton
*
* file /home/mycure/kane...hitecture/ia32/educational/environment.c
*
* created julien quintard [thu jan 13 23:13:50 2011]
* updated julien quintard [tue apr 12 07:40:26 2011]
*/
/*
* ---------- information -----------------------------------------------------
*
* this file contains functions for initializing the environments of a
* task, especially regarding its address space.
*
* note that the kernel is treated separately from the servers i.e drivers,
* services and guests.
*
* [XXX:improvement] in the server initialization, needless to map the kernel
* code and stack. instead the handler shells should be
* mapped i.e the .handler section.
*/
/*
* ---------- includes --------------------------------------------------------
*/
#include <kaneton.h>
/*
* ---------- externs ---------------------------------------------------------
*/
/*
* the init structure.
*/
extern s_init* _init;
/*
* the kernel manager.
*/
extern m_kernel _kernel;
/*
* the thread manager.
*/
extern m_thread _thread;
/*
* the segment manager.
*/
extern m_segment _segment;
/*
* the architecture manager.
*/
extern am _architecture;
/*
* ---------- functions -------------------------------------------------------
*/
/*
* this function initializes the kernel's environment.
*
* steps:
*
* 1) retrieve the address space objec.
* 2) set the kernel address space's page directory by importing the
* page directory set up by the boot loader.
* 3) generate the PDBR - Page Directory Base Register, also known as
* the CR3, based on the kernel page directory's physical address and
* some flags.
* 4) set the page directory virtual address as being an identity mapping
* of the physical address. this is how the boot loader set things up.
* 5) set the current page directory as being the kernel's one by updating
* the microprocessor CR3 register.
* 6) update the kernel page directory---which is assumed to have been mapped
* by the boot loader through the identity mapping technique---in order
* to set up the mirroring entry. this entry wastes the last 4MB
* of memory and are used for accessing the kernel page directory and
* tables without mapping anything, hence preventing infinite loops.
* note that the entry references the page directory itself, making the
* page directory act as a page table whenever accessed through the
* mirror page directory entry.
* 7) the last 4MB of virtual memory are not accessible since the mirroring
* page directory entry and the referenced page table's entries---the
* page directory itself---are used for the mirroring mechanism. these
* 4MB are wasted and must therefore not be reservable or the kernel may
* end up overwritten the mirroring entries. a region covering the last
* 4MB of virtual memory is therefore injected.
* note that the region injected references an ID_UNUSED-identified
* segment in order to avoid having to reserve a 4MB segment. this is
* possible because region_inject() does not check if the referenced
* segment identifer is valid.
* 8) this step consists in cleaning the page directory set up by the boot
* loader, now used by the kernel, by unmapping any page which is not
* related to the fundamental regions provided by the boot loader.
* go through all the pre-reserved regions provided by the bootloader plus
* one. this additional iteration is required in order to clean the
* mapped pages from the last region to the end of the virtual address
* space.
* a) compute the page directory and table end indexes for the given
* region. note that for the extra iteration, the end indexes are
* set to their maximum so that every page table entry of every page
* directory entry following the last region is cleaned.
* b) go through the involved page directory entries.
* i) if the page directory entry does not reference a page table or
* is used as the mirroring entry, leave it. otherwise...
* #1) retrieve the page table referenced by the page directory entry.
* note that the boot loader relied on the identity mapping technique
* for its paging set up. identity mapping is therefore used to
* retrieve the page table virtual address.
* #2) go through the page table's involved entries.
* #a) if the page table entry is used, delete the reference as
* this mapping must not be very important since not related to
* the pre-reserved regions provided by the boot loader.
* c) if the treated region is not the extra one, compute the next
* page directory and table start indexes as starting right after
* the end of the region i.e address + size.
* 9) flush the whole TLB, resetting all the address translations.
* 10) register the kernel PDBR as being the PDBR on which to switch whenever
* an interrupt occurs.
*/
t_error architecture_environment_kernel(i_as id)
{
i_region useless;
at_cr3 pdbr;
o_as* as;
o_region* r;
/*
* 1)
*/
if (as_get(id, &as) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the address space object");
/*
* 2)
*/
as->machine.pd = _init->machine.pd;
/*
* 3)
*/
if (architecture_paging_pdbr(as->machine.pd,
ARCHITECTURE_REGISTER_CR3_PCE |
ARCHITECTURE_REGISTER_CR3_PWB,
&pdbr) != ERROR_OK)
MACHINE_ESCAPE("unable to build the CR3 register's content");
/*
* 5)
*/
/* FIXME[make the page directory provided by the boot loader the system's
current page directory by updating the necessary IA32 hardware
structure and possibly storing the value in a globally accessible
variable such as a manager] */
/*
* 6)
*/
/* FIXME[create the mirroring entry by adding the page directory's
address] */
/*
* 7)
*/
if ((r = malloc(sizeof (o_region))) == NULL)
MACHINE_ESCAPE("unable to allocate memory for the region object");
r->address = ARCHITECTURE_PAGING_ADDRESS(ARCHITECTURE_PD_MIRROR, 0);
r->segment = ID_UNUSED;
r->offset = 0x0;
r->size = ARCHITECTURE_PT_SIZE * ___kaneton$pagesz;
r->options = REGION_OPTION_NONE;
if (region_inject(as->id, r, &useless) != ERROR_OK)
MACHINE_ESCAPE("unable to inject the mirroring region");
/*
* 8)
*/
/* FIXME[go through the registered regions and remove the
page table entries which do not correspond to these
regions. this is necessary because the boot loader
mapped an awful lot of pages which must now be cleaned]
pde.start = 0;
pte.start = 0;
for (i = 0; i < (_init->nregions + 1); i++)
{
if (i != _init->nregions)
{
pde.end = ARCHITECTURE_PD_INDEX(_init->regions[i].address);
pte.end = ARCHITECTURE_PT_INDEX(_init->regions[i].address);
}
else
{
pde.end = ARCHITECTURE_PD_SIZE - 1;
pte.end = ARCHITECTURE_PT_SIZE;
}
for (pde.index = pde.start;
pde.index <= pde.end;
pde.index++)
{
if ((pde.index != ARCHITECTURE_PD_MIRROR) &&
(pd[pde.index] & ARCHITECTURE_PDE_PRESENT))
{
pt = (at_pt)ARCHITECTURE_PDE_ADDRESS(pd[pde.index]);
for (pte.index = (pde.index == pde.start ? pte.start : 0);
pte.index < (pde.index == pde.end ?
pte.end : ARCHITECTURE_PT_SIZE);
pte.index++)
{
if (pt[pte.index] & ARCHITECTURE_PTE_PRESENT)
{
if (architecture_pt_delete(pt, pte.index) != ERROR_OK)
MACHINE_ESCAPE("unable to delete the page "
"table entry");
}
}
}
}
if (i != _init->nregions)
{
pde.start = ARCHITECTURE_PD_INDEX(_init->regions[i].address +
_init->regions[i].size);
pte.start = ARCHITECTURE_PT_INDEX(_init->regions[i].address +
_init->regions[i].size);
}
}
*/
/*
* 9)
*/
if (architecture_tlb_flush() != ERROR_OK)
MACHINE_ESCAPE("unable to flush the TLB");
/*
* 10)
*/
_architecture.kernel.pdbr = pdbr;
MACHINE_LEAVE();
}
/*
* this function sets up the environment of a server i.e drivers, services
* and guests.
*
* steps:
*
* 1) retrieve the address space object.
* 2) reserve a system segment.
* 3) use this segment for the given address space's page directory.
* 4) map the page directory, initialize it and unmap it.
* 5) locate the segment containing the system's TSS and map it in
* the given address space. note that the TSS is mapped at the same
* virtual address as in the kernel.
* 6) locate the segment containing the system's GDT and map it in the
* given address space, again at the same virtual address as the kernel's.
* 7) locate the segment containing the system's IDT and map it in the
* given address space, again at the same virtual address as the kernel's.
* 8) locate the segment containing the kernel code and map it in the given
* address space. note that the identity mapping technique is used here.
* 9) locate the segment containing the kernel stack and map it in the given
* address space, note that the identity mapping technique is used here.
*/
t_error architecture_environment_server(i_as id)
{
i_segment segment;
i_region region;
o_as* as;
o_region* r;
o_segment* s;
/*
* 1)
*/
if (as_get(id, &as) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the address space object");
/*
* 2)
*/
if (segment_reserve(as->id,
___kaneton$pagesz,
PERMISSION_READ | PERMISSION_WRITE,
SEGMENT_OPTION_SYSTEM,
&segment) != ERROR_OK)
MACHINE_ESCAPE("unable to reserve a segment");
if (segment_get(segment, &s) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the segment object");
/*
* 3)
*/
as->machine.pd = s->address;
/*
* 4)
*/
/* FIXME[map the server's page directory, initialize it and
unmap it] */
/*
* 5)
*/
if (region_locate(_kernel.as,
_thread.machine.tss,
&region) == ERROR_FALSE)
MACHINE_ESCAPE("unable to locate the region in which the TSS lies");
if (region_get(_kernel.as, region, &r) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the region object");
if (region_reserve(as->id,
r->segment,
0x0,
REGION_OPTION_FORCE |
REGION_OPTION_NONE,
_thread.machine.tss,
r->size,
&region) != ERROR_OK)
MACHINE_ESCAPE("unable to reserve the region mapping the TSS");
/*
* 6)
*/
if (region_locate(_kernel.as,
(t_vaddr)_segment.machine.gdt.table,
&region) == ERROR_FALSE)
MACHINE_ESCAPE("unable to locate the region in which the GDT lies");
if (region_get(_kernel.as, region, &r) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the region object");
if (region_reserve(as->id,
r->segment,
0x0,
REGION_OPTION_FORCE |
REGION_OPTION_NONE,
(t_vaddr)_segment.machine.gdt.table,
___kaneton$pagesz,
&region) != ERROR_OK)
MACHINE_ESCAPE("unable to reserve the region mapping the GDT");
/*
* 7)
*/
/* FIXME[reserve a region for the system's IDT very much as for
the GDT above] */
/*
* 8)
*/
/* XXX
if (region_reserve(asid,
_init->kcode,
LINKER_SYMBOL(_handler_begin) - _init->kcode,
REGION_OPTION_FORCE | REGION_OPTION_PRIVILEGED,
LINKER_SYMBOL(_handler_begin),
LINKER_SYMBOL(_handler_end) -
LINKER_SYMBOL(_handler_begin),
&reg) != ERROR_OK)
if (region_reserve(asid,
_init->kcode,
LINKER_SYMBOL(_handler_data_begin) - _init->kcode,
REGION_OPTION_FORCE | REGION_OPTION_PRIVILEGED,
LINKER_SYMBOL(_handler_data_begin),
LINKER_SYMBOL(_handler_data_end) -
LINKER_SYMBOL(_handler_data_begin),
&reg) != ERROR_OK)
*/
if (segment_locate(_init->kcode, &segment) == ERROR_FALSE)
MACHINE_ESCAPE("unable to locate the segment which contains the "
"kernel code");
if (region_reserve(as->id,
segment,
0x0,
REGION_OPTION_FORCE,
(t_vaddr)_init->kcode,
(t_vsize)_init->kcodesz,
&region) != ERROR_OK)
MACHINE_ESCAPE("unable to reserve the region mapping the kernel code");
/*
* 9)
*/
if (segment_locate(_init->kstack,
&segment) == ERROR_FALSE)
MACHINE_ESCAPE("unable to locate the segment which contains the "
"kernel stack");
if (region_reserve(as->id,
segment,
0x0,
REGION_OPTION_FORCE,
(t_vaddr)_init->kstack,
(t_vsize)_init->kstacksz,
&region) != ERROR_OK)
MACHINE_ESCAPE("unable to reserve the region mapping the kernel stack");
MACHINE_LEAVE();
}

View file

@ -0,0 +1,24 @@
/*
* ---------- header ----------------------------------------------------------
*
* project kaneton
*
* license kaneton
*
* file /home/mycure/kane.../architecture/ia32/educational/handler.c
*
* created renaud voltz [thu feb 23 10:49:43 2006]
* updated julien quintard [mon apr 11 13:44:48 2011]
*/
/*
* ---------- includes --------------------------------------------------------
*/
#include <kaneton.h>
/*
* ---------- functions -------------------------------------------------------
*/
/* FIXME[complete if necessary] */

View file

@ -0,0 +1,34 @@
/*
* ---------- header ----------------------------------------------------------
*
* project kaneton
*
* license kaneton
*
* file /home/mycure/kane...hine/architecture/ia32/educational/idt.c
*
* created renaud voltz [sun feb 12 02:02:19 2006]
* updated julien quintard [mon apr 11 13:44:56 2011]
*/
/*
* ---------- information -----------------------------------------------------
*
* this file provides functionalities for managing the IDT - Interrupt
* Descriptor Table.
*
* for more information regarding the handlers triggered through the IDT,
* please have a look at the handler.c file.
*/
/*
* ---------- includes --------------------------------------------------------
*/
#include <kaneton.h>
/*
* ---------- functions -------------------------------------------------------
*/
/* FIXME[complete if necessary] */

View file

@ -0,0 +1,117 @@
/*
* ---------- header ----------------------------------------------------------
*
* project kaneton
*
* license kaneton
*
* file /home/mycure/kane...cture/ia32/educational/include/context.h
*
* created renaud voltz [tue apr 4 22:01:00 2006]
* updated julien quintard [mon feb 7 16:19:17 2011]
*/
#ifndef ARCHITECTURE_CONTEXT_H
#define ARCHITECTURE_CONTEXT_H 1
/*
* ---------- macro functions -------------------------------------------------
*/
/*
* this macro-function saves the context of the thread which had just
* been interrupted.
*
* note that at this point, the stack in use is the thread's pile i.e ring0
* stack; except for the kernel threads since there is no change in privilege.
*/
#define ARCHITECTURE_CONTEXT_SAVE() \
/* FIXME[code to complete] */
/*
* this macro-function restores the context of the thread whose PDBR and pile
* are referenced in _architecture.thread. as such, the whole ia32/educational
* context switch mechanism relies on the simple fact that changing
* the _architecture structure and returning from the interrupt will make
* the thread's context restored and its execution resumed.
*
* note that at this point, the environment is composed of the kernel PDBR
* and the KIS - Kernel Interrupt Stack.
*/
#define ARCHITECTURE_CONTEXT_RESTORE() \
/* FIXME[code to complete] */
/*
* ---------- dependencies ----------------------------------------------------
*/
#include <core/types.h>
/*
* ---------- types -----------------------------------------------------------
*/
/*
* this structure represents the IA32 context.
*/
typedef struct
{
t_reg32 ds;
t_reg32 edi;
t_reg32 esi;
t_reg32 ebp;
t_reg32 _esp;
t_reg32 ebx;
t_reg32 edx;
t_reg32 ecx;
t_reg32 eax;
t_reg32 error;
t_reg32 eip;
t_reg32 cs;
t_reg32 eflags;
t_reg32 esp;
t_reg32 ss;
} __attribute__ ((packed)) as_context;
/*
* ---------- prototypes ------------------------------------------------------
*
* ../context.c
*/
/*
* ../context.c
*/
t_error architecture_context_dump(as_context context);
t_error architecture_context_build(i_thread id);
t_error architecture_context_destroy(i_thread id);
t_error architecture_context_setup(void);
t_error architecture_context_locate(void);
t_error architecture_context_switch(i_thread current,
i_thread future);
t_error architecture_context_arguments(i_thread id,
void* arguments,
t_vsize size);
t_error architecture_context_get(i_thread id,
as_context* context);
t_error architecture_context_set(i_thread id,
as_context* context);
/*
* eop
*/
#endif

View file

@ -0,0 +1,56 @@
/*
* ---------- header ----------------------------------------------------------
*
* project kaneton
*
* license kaneton
*
* file /home/mycure/kane...cture/ia32/educational/include/handler.h
*
* created renaud voltz [fri feb 17 16:48:22 2006]
* updated julien quintard [mon apr 11 13:45:51 2011]
*/
#ifndef ARCHITECTURE_HANDLER_H
#define ARCHITECTURE_HANDLER_H 1
/*
* ---------- macros ----------------------------------------------------------
*/
/*
* this macro represents the number of handlers the system must set up,
* for the exceptions, IRQs, IPIs and syscalls.
*/
#define ARCHITECTURE_HANDLER_SIZE ARCHITECTURE_IDT_EXCEPTION_SIZE + \
ARCHITECTURE_IDT_IRQ_SIZE + \
ARCHITECTURE_IDT_IPI_SIZE + \
ARCHITECTURE_IDT_SYSCALL_SIZE
/*
* this macro defines the size of a thread's pile i.e the stack used whenever
* a privilege change occurs.
*/
#define ARCHITECTURE_HANDLER_PILE_SIZE ___kaneton$pagesz
/*
* this macro defines the size of the KIS - Kernel Interrupt Stack. this is
* the stack which is used, within the kernel environment, for treating
* interrupts.
*/
#define ARCHITECTURE_HANDLER_KIS_SIZE 2 * ___kaneton$pagesz
/*
* ---------- prototypes ------------------------------------------------------
*
* ../handler.c
*/
/*
* eop
*/
#endif

View file

@ -0,0 +1,121 @@
/*
* ---------- header ----------------------------------------------------------
*
* project kaneton
*
* license kaneton
*
* file /home/mycure/kane...hitecture/ia32/educational/include/idt.h
*
* created renaud voltz [fri feb 10 16:36:20 2006]
* updated julien quintard [mon apr 11 13:45:20 2011]
*/
#ifndef ARCHITECTURE_IDT_H
#define ARCHITECTURE_IDT_H 1
/*
* ---------- macros ----------------------------------------------------------
*/
/*
* these macros define the base entry and the number of entries for the
* several types of gate: IRQ, exception, IPI or syscall.
*
* note that 200 syscalls could be set up but the kernel limits itself
* to ten which is enough for a microkernel.
*/
#define ARCHITECTURE_IDT_EXCEPTION_BASE 0
#define ARCHITECTURE_IDT_EXCEPTION_SIZE 32
#define ARCHITECTURE_IDT_IRQ_BASE 32
#define ARCHITECTURE_IDT_IRQ_SIZE 16
#define ARCHITECTURE_IDT_IPI_BASE 48
#define ARCHITECTURE_IDT_IPI_SIZE 8
#define ARCHITECTURE_IDT_SYSCALL_BASE 56
#define ARCHITECTURE_IDT_SYSCALL_SIZE 10
/*
* these macro define some of the exception handler sources.
*/
#define ARCHITECTURE_IDT_EXCEPTION_DE \
ARCHITECTURE_IDT_EXCEPTION_BASE + 0
#define ARCHITECTURE_IDT_EXCEPTION_DB \
ARCHITECTURE_IDT_EXCEPTION_BASE + 1
#define ARCHITECTURE_IDT_EXCEPTION_BP \
ARCHITECTURE_IDT_EXCEPTION_BASE + 3
#define ARCHITECTURE_IDT_EXCEPTION_OF \
ARCHITECTURE_IDT_EXCEPTION_BASE + 4
#define ARCHITECTURE_IDT_EXCEPTION_BR \
ARCHITECTURE_IDT_EXCEPTION_BASE + 5
#define ARCHITECTURE_IDT_EXCEPTION_UD \
ARCHITECTURE_IDT_EXCEPTION_BASE + 6
#define ARCHITECTURE_IDT_EXCEPTION_NM \
ARCHITECTURE_IDT_EXCEPTION_BASE + 7
#define ARCHITECTURE_IDT_EXCEPTION_DF \
ARCHITECTURE_IDT_EXCEPTION_BASE + 8
#define ARCHITECTURE_IDT_EXCEPTION_TS \
ARCHITECTURE_IDT_EXCEPTION_BASE + 10
#define ARCHITECTURE_IDT_EXCEPTION_NP \
ARCHITECTURE_IDT_EXCEPTION_BASE + 11
#define ARCHITECTURE_IDT_EXCEPTION_SS \
ARCHITECTURE_IDT_EXCEPTION_BASE + 12
#define ARCHITECTURE_IDT_EXCEPTION_GP \
ARCHITECTURE_IDT_EXCEPTION_BASE + 13
#define ARCHITECTURE_IDT_EXCEPTION_PF \
ARCHITECTURE_IDT_EXCEPTION_BASE + 14
#define ARCHITECTURE_IDT_EXCEPTION_MF \
ARCHITECTURE_IDT_EXCEPTION_BASE + 16
#define ARCHITECTURE_IDT_EXCEPTION_AC \
ARCHITECTURE_IDT_EXCEPTION_BASE + 17
#define ARCHITECTURE_IDT_EXCEPTION_MC \
ARCHITECTURE_IDT_EXCEPTION_BASE + 18
#define ARCHITECTURE_IDT_EXCEPTION_XM \
ARCHITECTURE_IDT_EXCEPTION_BASE + 19
/*
* these macro define some of the IRQ handler sources.
*/
#define ARCHITECTURE_IDT_IRQ_PIT \
ARCHITECTURE_IDT_IRQ_BASE + 0
#define ARCHITECTURE_IDT_IRQ_KEYBOARD \
ARCHITECTURE_IDT_IRQ_BASE + 1
#define ARCHITECTURE_IDT_IRQ_CASCADE \
ARCHITECTURE_IDT_IRQ_BASE + 2
#define ARCHITECTURE_IDT_IRQ_COM2 \
ARCHITECTURE_IDT_IRQ_BASE + 3
#define ARCHITECTURE_IDT_IRQ_COM1 \
ARCHITECTURE_IDT_IRQ_BASE + 4
#define ARCHITECTURE_IDT_IRQ_FLOPPY \
ARCHITECTURE_IDT_IRQ_BASE + 6
#define ARCHITECTURE_IDT_IRQ_SPURIOUS \
ARCHITECTURE_IDT_IRQ_BASE + 7
#define ARCHITECTURE_IDT_IRQ_RTC \
ARCHITECTURE_IDT_IRQ_BASE + 8
#define ARCHITECTURE_IDT_IRQ_ATA1 \
ARCHITECTURE_IDT_IRQ_BASE + 14
#define ARCHITECTURE_IDT_IRQ_ATA2 \
ARCHITECTURE_IDT_IRQ_BASE + 15
/*
* ---------- dependencies ----------------------------------------------------
*/
#include <core/types.h>
/*
* ---------- prototypes ------------------------------------------------------
*
* ../idt.c
*/
/*
* eop
*/
#endif

View file

@ -0,0 +1,83 @@
/*
* ---------- header ----------------------------------------------------------
*
* project kaneton
*
* license kaneton
*
* file /home/mycure/kane...ecture/ia32/educational/include/paging.h
*
* created julien quintard [fri feb 11 03:04:40 2005]
* updated julien quintard [mon apr 11 13:48:17 2011]
*/
#ifndef ARCHITECTURE_PAGING_H
#define ARCHITECTURE_PAGING_H 1
/*
* ---------- macro-functions -------------------------------------------------
*/
/*
* computes a virtual address according to the given directory and table
* entries.
*/
#define ARCHITECTURE_PAGING_ADDRESS(_pdei_, _ptei_) \
(t_vaddr)(((_pdei_) << 22) | ((_ptei_) << 12))
/*
* ---------- dependencies ----------------------------------------------------
*/
#include <core/types.h>
#include <architecture/register.h>
/*
* ---------- prototypes ------------------------------------------------------
*
* ../paging.c
*/
/*
* ../paging.c
*/
t_error architecture_paging_pdbr(t_paddr pd,
t_flags flags,
at_cr3* pdbr);
t_error architecture_paging_map(i_as id,
i_segment segment,
t_paddr offset,
t_options options,
t_vaddr address,
t_vsize size);
t_error architecture_paging_unmap(i_as id,
t_vaddr address,
t_vsize size);
t_error architecture_paging_read(i_segment id,
t_paddr offset,
void* buffer,
t_psize size);
t_error architecture_paging_write(i_segment id,
t_paddr offset,
const void* buffer,
t_psize size);
t_error architecture_paging_copy(i_region dst,
t_paddr to,
i_region src,
t_paddr from,
t_psize size);
/*
* eop
*/
#endif

View file

@ -0,0 +1,49 @@
/*
* ---------- header ----------------------------------------------------------
*
* project kaneton
*
* license kaneton
*
* file /home/mycure/Down...chitecture/ia32/educational/include/pd.h
*
* created julien quintard [mon jan 10 09:05:19 2011]
* updated julien quintard [mon apr 11 13:20:03 2011]
*/
#ifndef ARCHITECTURE_PD_H
#define ARCHITECTURE_PD_H 1
/*
* ---------- macros ----------------------------------------------------------
*/
/*
* this value defines the page directory entry which acts as the mirror
* entry i.e the entry referencing the page directory itself.
*/
#define ARCHITECTURE_PD_MIRROR 1023
/*
* ---------- dependencies ----------------------------------------------------
*/
#include <architecture/types.h>
/*
* ---------- prototypes ------------------------------------------------------
*
* ../pd.c
*/
/*
* ../pd.c
*/
/*
* eop
*/
#endif

View file

@ -0,0 +1,48 @@
/*
* ---------- header ----------------------------------------------------------
*
* project kaneton
*
* license kaneton
*
* file /home/mycure/Down...chitecture/ia32/educational/include/pt.h
*
* created julien quintard [mon jan 10 09:31:37 2011]
* updated julien quintard [mon apr 11 13:21:04 2011]
*/
#ifndef ARCHITECTURE_PT_H
#define ARCHITECTURE_PT_H 1
/*
* ---------- macros ----------------------------------------------------------
*/
/*
* defines the number entries composing a page table.
*/
#define ARCHITECTURE_PT_SIZE 1024
/*
* ---------- dependencies ----------------------------------------------------
*/
#include <architecture/types.h>
/*
* ---------- prototypes ------------------------------------------------------
*
* ../pt.c
*/
/*
* ../pt.c
*/
/*
* eop
*/
#endif

View file

@ -0,0 +1,545 @@
/*
* ---------- header ----------------------------------------------------------
*
* project kaneton
*
* license kaneton
*
* file /home/mycure/kane...e/architecture/ia32/educational/paging.c
*
* created matthieu bucchianeri [tue dec 20 13:45:05 2005]
* updated julien quintard [tue apr 12 07:34:31 2011]
*/
/*
* ---------- information -----------------------------------------------------
*
* this file provides basic paging functionalities.
*
* note that the ia32/educational implementation makes use of the mirroring
* technique. this technique is used to prevent the kernel from looping
* infinitely whenever trying to map a page table for instance. indeed,
* whenever a page table must be mapped, a virtual memory area is picked.
* this memory area must be mapped by creating a mapping in the page
* directory/table hierarchical structure. in order to do so, the kernel page
* directory and the kernel page table referencing the given area must
* also be mapped. should not this be the case, the referencing page table,
* for example, should be mapped by creating a mapping etc. there is an
* obvious infinite loop occuring here where every page table which has
* to be mapped implies another page table to reference it, hence to be
* mapped as well.
*
* in order to prevent this infinite loop, the kernel relies on the
* mirroring technique. this mechanism consists in setting up a kernel
* page directory entry as acting as a special loopback. for example, the
* last page directory entry, i.e pd[1023], will not reference another page
* table as it is the case for the other page directory entries but the
* page directory itself. this way, the page directory, whenever the
* mirroring page directory entry is used, is considered by the microprocessor
* as page table and its entries as page tables entries.
*
* the following schema depicts this organization:
*
* pd @ 0x011e2000
* pde 0 references 0x011e3000
* pt @ 0x011e3000
* pte 0 not present
* pte 1 references 0x00001000
* pte 2 references 0x00002000
* pte 3 references 0x00003000
* pte 4 references 0x00004000
* ...
* pde 2 not present
* pde 3 not present
* pde 4 references 0x011e4000
* pt @ 0x011e4000
* pte 0 references 0x01000000
* pte 1 references 0x01001000
* pte 2 references 0x01002000
* ...
* pde 1023 references 0x011e2000 (the page directory itself)
* pt @ 0x011e2000 (the page directory acts as a page table)
* pte 0 references 0x011e3000 (the first page table: pde 0)
* pte 4 references 0x011e4000 (the second page table: pde 1)
* pte 1023 references 0x011e2000 (the page directory: pde 1023)
*
* this technique---assuming the kernel page directory is mapped, but this is
* quite obvious---enables the kernel to modify any page directory/table
* without mapping any intermediate page table. indeed, the kernel only needs
* to reference the page table it wishes to modify through its mirrored
* page directory entry.
*
* this technique implies that the last page directory entry is reserved
* for the mirroring mechanism. therefore, the last 4MB of virtual memory
* must be locked for that purpose meaning that 4MB of memory are wasted.
*
* finally, the reader should have understood that the mirroring mechanism
* only applies to the kernel tables. indeed, other address spaces'
* page directories and tables can be mapped normally since, should
* a kernel table need to be mapped to access another non-kernel table, it
* will be through the mirroring mechanism.
*/
/*
* ---------- includes --------------------------------------------------------
*/
#include <kaneton.h>
/*
* ---------- externs ---------------------------------------------------------
*/
/*
* the kernel manager.
*/
extern m_kernel _kernel;
/*
* ---------- functions -------------------------------------------------------
*/
/*
* this function generates the CR3 register's content so that to be
* overwritten, hence referencing another page directory structure.
*
* note that the CR3 register is also referred to as the PDBR - Page Directory
* Base Register as it contains the address of the page directory in use.
*
* steps:
*
* 0) verify the arguments.
* 1) generate the CR3 register's content.
*/
t_error architecture_paging_pdbr(t_paddr pd,
t_flags flags,
at_cr3* pdbr)
{
/*
* 0)
*/
if (pdbr == NULL)
MACHINE_ESCAPE("the 'pdbr' argument is null");
/*
* 1)
*/
*pdbr = (pd & 0xfffff000) | flags;
MACHINE_LEAVE();
}
/*
* this function maps a portion of the given segment to the given virtual
* address.
*/
t_error architecture_paging_map(i_as id,
i_segment segment,
t_paddr offset,
t_options options,
t_vaddr address,
t_vsize size)
{
/* FIXME[code to complete] */
MACHINE_LEAVE();
}
/*
* this function unmaps the mappings associated with the given address and
* size.
*/
t_error architecture_paging_unmap(i_as id,
t_vaddr address,
t_vsize size)
{
/* FIXME[code to complete] */
MACHINE_LEAVE();
}
/*
* this function reads data from a given segment by temporarily mapping
* the necessary pages.
*
* note that this function supports non-aligned addresses and sizes.
*
* steps:
*
* 0) verify the arguments.
* 1) retrieve the segment object.
* 2) compute the aligned segment offset along with the non-aligned shift.
* 3) compute the last aligned page boundary.
* 4) reserve a region for the involved pages.
* 5) retrieve the region object.
* 6) copy data from the mapped region into the given buffer.
* 7) release the region.
*/
t_error architecture_paging_read(i_segment id,
t_paddr offset,
void* buffer,
t_psize size)
{
t_paddr shift;
i_region region;
t_paddr end;
o_segment* o;
o_region* r;
/*
* 0)
*/
if (buffer == NULL)
MACHINE_ESCAPE("the 'buffer' argument is null");
/*
* 1)
*/
if (segment_get(id, &o) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the segment object");
/*
* 2)
*/
if (offset % ___kaneton$pagesz)
{
shift = offset - (offset & ~(___kaneton$pagesz - 1));
offset = offset & ~(___kaneton$pagesz - 1);
}
else
{
shift = 0;
}
/*
* 3)
*/
end = offset + shift + size;
if (end % ___kaneton$pagesz)
end = (end & ~(___kaneton$pagesz - 1)) + ___kaneton$pagesz;
/*
* 4)
*/
if (region_reserve(_kernel.as,
id,
offset,
REGION_OPTION_NONE,
0x0,
end - offset,
&region) != ERROR_OK)
MACHINE_ESCAPE("unable to reserve a region");
/*
* 5)
*/
if (region_get(_kernel.as, region, &r) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the region object");
/*
* 6)
*/
memcpy(buffer, (void*)r->address + shift, size);
/*
* 7)
*/
if (region_release(_kernel.as, region) != ERROR_OK)
MACHINE_ESCAPE("unable to release the region");
MACHINE_LEAVE();
}
/*
* this function writes data to a given segment by temporarily mapping
* the necessary pages.
*
* note that this function supports non-aligned addresses and sizes.
*
* steps:
*
* 0) verify the arguments.
* 1) retrieve the segment object.
* 2) compute the aligned segment offset along with the non-aligned shift.
* 3) compute the last aligned page boundary.
* 4) reserve a region for the involved pages.
* 5) retrieve the region object.
* 6) copy data from the given buffer to the mapped region.
* 7) release the region.
*/
t_error architecture_paging_write(i_segment id,
t_paddr offset,
const void* buffer,
t_psize size)
{
t_paddr shift;
i_region region;
t_paddr end;
o_segment* o;
o_region* r;
/*
* 0)
*/
if (buffer == NULL)
MACHINE_ESCAPE("the 'buffer' argument is null");
/*
* 1)
*/
if (segment_get(id, &o) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the segment object");
/*
* 2)
*/
if (offset % ___kaneton$pagesz)
{
shift = offset - (offset & ~(___kaneton$pagesz - 1));
offset = offset & ~(___kaneton$pagesz - 1);
}
else
{
shift = 0;
}
/*
* 3)
*/
end = offset + shift + size;
if (end % ___kaneton$pagesz)
end = (end & ~(___kaneton$pagesz - 1)) + ___kaneton$pagesz;
/*
* 4)
*/
if (region_reserve(_kernel.as,
id,
offset,
REGION_OPTION_NONE,
0x0,
end - offset,
&region) != ERROR_OK)
MACHINE_ESCAPE("unable to reserve a region");
/*
* 5)
*/
if (region_get(_kernel.as, region, &r) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the region object");
/*
* 6)
*/
memcpy((void*)r->address + shift, buffer, size);
/*
* 7)
*/
if (region_release(_kernel.as, region) != ERROR_OK)
MACHINE_ESCAPE("unable to release the region");
MACHINE_LEAVE();
}
/*
* this function copies data from a segment to another by temporarily
* mapping the necessary pages.
*
* note that this function supports non-aligned addresses and sizes.
*
* steps:
*
* 1) retrieve the segment objects.
* 2) compute the source aligned offset and non-aligned shift.
* 3) compute the source last aligned page boundary.
* 4) map the source pages through a region reservation.
* 5) retrieve the reserved region.
* 6) compute the destination aligned offset and non-aligned shift.
* 7) compute the destination last aligned page boundary.
* 8) map the destination pages through a region reservation.
* 9) retrieve the reserved region.
* 10) copy from the source mapped region to the destination mapped region.
* 11) release the reserved regions.
*/
t_error architecture_paging_copy(i_region dst,
t_paddr to,
i_region src,
t_paddr from,
t_psize size)
{
struct
{
struct
{
o_segment* object;
} segment;
struct
{
i_region id;
o_region* object;
} region;
t_paddr shift;
} source;
struct
{
struct
{
o_segment* object;
} segment;
struct
{
i_region id;
o_region* object;
} region;
t_paddr shift;
} destination;
t_paddr end;
/*
* 1)
*/
if (segment_get(dst, &destination.segment.object) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the segment object");
if (segment_get(src, &source.segment.object) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the segment object");
/*
* 2)
*/
if (from % ___kaneton$pagesz)
{
source.shift = from - (from & ~(___kaneton$pagesz - 1));
from = from & ~(___kaneton$pagesz - 1);
}
else
{
source.shift = 0;
}
/*
* 3)
*/
end = from + source.shift + size;
if (end % ___kaneton$pagesz)
end = (end & ~(___kaneton$pagesz - 1)) + ___kaneton$pagesz;
/*
* 4)
*/
if (region_reserve(_kernel.as,
src,
from,
REGION_OPTION_NONE,
0x0,
end - from,
&source.region.id) != ERROR_OK)
MACHINE_ESCAPE("unable to reserve a region");
/*
* 5)
*/
if (region_get(_kernel.as,
source.region.id,
&source.region.object) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the region object");
/*
* 6)
*/
if (to % ___kaneton$pagesz)
{
destination.shift = to - (to & ~(___kaneton$pagesz - 1));
to = to & ~(___kaneton$pagesz - 1);
}
else
{
destination.shift = 0;
}
/*
* 7)
*/
end = to + destination.shift + size;
if (end % ___kaneton$pagesz)
end = (end & ~(___kaneton$pagesz - 1)) + ___kaneton$pagesz;
/*
* 8)
*/
if (region_reserve(_kernel.as,
dst,
to,
REGION_OPTION_NONE,
0x0,
end - to,
&destination.region.id) != ERROR_OK)
MACHINE_ESCAPE("unable to reserve a region");
/*
* 9)
*/
if (region_get(_kernel.as,
destination.region.id,
&destination.region.object) != ERROR_OK)
MACHINE_ESCAPE("unable to retrieve the region object");
/*
* 10)
*/
memcpy((void*)destination.region.object->address + destination.shift,
(void*)source.region.object->address + source.shift,
size);
/*
* 11)
*/
if (region_release(_kernel.as, source.region.id) != ERROR_OK)
MACHINE_ESCAPE("unable to release the region");
if (region_release(_kernel.as, destination.region.id) != ERROR_OK)
MACHINE_ESCAPE("unable to release the region");
MACHINE_LEAVE();
}

View file

@ -0,0 +1,30 @@
/*
* ---------- header ----------------------------------------------------------
*
* project kaneton
*
* license kaneton
*
* file /home/mycure/kane...chine/architecture/ia32/educational/pd.c
*
* created matthieu bucchianeri [tue dec 20 19:56:20 2005]
* updated julien quintard [mon apr 11 13:45:04 2011]
*/
/*
* ---------- information -----------------------------------------------------
*
* this file contains functions for managing PDs - Page Directories.
*/
/*
* ---------- includes --------------------------------------------------------
*/
#include <kaneton.h>
/*
* ---------- functions -------------------------------------------------------
*/
/* FIXME[complete if necessary] */

Some files were not shown because too many files have changed in this diff Show more