Changes between Initial Version and Version 1 of QuickStartUnix


Ignore:
Timestamp:
Nov 25, 2009, 2:29:27 PM (15 years ago)
Author:
becoulet
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • QuickStartUnix

    v1 v1  
     1
     2This guide explain how to run MutekH embedded in a Unix process. This is the simplest way to run MutekH as it doesn't require any hardware platform.
     3
     4== Overview ==
     5
     6The MutekH operation system is built on top of the Hexo hardware abstraction layer. It's composed of several modules and libraries.
     7
     8[[BR]][[BR]][[Image(QuickStartSoclib:mutekh_overview.gif,nolink)]][[BR]][[BR]]
     9
     10When compiled to run embedded in a Unix process, minimal hardware ressource are needed: The host processor
     11and unix process memory are used as execution platform and a simple TTY driver redirect output to the Unix terminal.
     12
     13It enables running MutekH natively on the host processor. This configuration suffer from several
     14limitations regarding available peripherals, but it is usefull to test and debug algorithms.
     15
     16[[BR]][[BR]][[Image(QuickStartSoclib:arch_emu.gif,nolink)]][[BR]][[BR]]
     17
     18== Getting the sources ==
     19
     20The example below show how to run MutekH using this configuration, it only requires to get the MutekH source code.
     21
     22The MutekH source code is fully configurable and can be tweaked to adapt hardware platform
     23and application needs. Configuration is handled by a dedicated tool which check dependencies and
     24other relationships between the large set of available configuration tokens.
     25
     26{{{
     27svn co -r 1024 https://www-asim.lip6.fr/svn/mutekh/trunk/mutekh
     28}}}
     29Source tree is organized this way:
     30{{{
     31mutekh
     32|-- arch            contains hardware platforms modules for hexo
     33|-- cpu             contains processors modules for hexo
     34|-- doc             documentation
     35|-- drivers         device and filesystem drivers
     36|-- examples        Test and example programs
     37|-- gpct            container library, available as a separate project
     38|-- hexo            Hexo hardware abstraction layer
     39|-- libc            standard C library
     40|-- libm            standard math library
     41|-- libnetwork      netwotk stack
     42|-- libpthread      posix thread library
     43|-- libvfs          virtual File System
     44|-- mutek           hardware independant kernel code
     45|-- scripts         build system scripts
     46`-- tools           some usefull tools
     47}}}
     48
     49More directories are actually available with other libraries and features.
     50
     51== Writing the example source code ==
     52
     53Note: This example is available directly from {{{examples/hello}}} directory in source tree: [source:trunk/mutekh/examples/hello]
     54
     55 - Creating a new modules directory
     56{{{
     57mkdir hello
     58cd hello
     59}}}
     60
     61 - Writing the source code in `hello.c`
     62{{{
     63#include <pthread.h>
     64
     65pthread_mutex_t m;
     66pthread_t a, b;
     67
     68void *f(void *param)
     69{
     70  while (1)
     71    {
     72      pthread_mutex_lock(&m);
     73      printf("(%i) %s", cpu_id(), param);
     74      pthread_mutex_unlock(&m);
     75      pthread_yield();
     76    }
     77}
     78int main()
     79{
     80  pthread_mutex_init(&m, NULL);
     81  pthread_create(&a, NULL, f, "Hello ");
     82  pthread_create(&b, NULL, f, "World\n");
     83}
     84}}}
     85
     86 - Writing the `Makefile`
     87{{{
     88objs = hello.o
     89}}}
     90
     91== Writing the MutekH configuration file ==
     92
     93Our configuration file is named `hello/config_emu`.
     94Details about configuration file is explained later.
     95This configuration file describe the following things:
     96 - The application license, used to check license consistency for modules in use,
     97 - The target hardware platform and processor
     98 - Use of the POSIX threads library
     99 - Use of terminal output
     100 - Declaration of a new "hello" modules
     101
     102The MutekH source code is split in modules. We now have to declare our new module to have it compiled along with the kernel by the build system. As modules may be located out of the source tree, we have to specify the module directory.
     103
     104{{{
     105# New source code module to be compiled
     106  CONFIG_MODULES examples/hello:%CONFIGPATH
     107
     108# Application license
     109  CONFIG_LICENSE_APP_LGPL
     110
     111# Platform types
     112  CONFIG_ARCH_EMU
     113  CONFIG_ARCH_EMU_LINUX
     114
     115# Processor types
     116  CONFIG_CPU_X86_EMU
     117
     118  ...
     119}}}
     120
     121The complete configuration files are available here: [source:trunk/mutekh/examples/hello/config_emu] and [source:trunk/mutekh/examples/hello/config_emu64]. You must choose the right one depending on your host operating system and architecture.
     122
     123== Compiling the application along with MutekH ==
     124
     125Simply type something like:
     126{{{
     127make CONF=examples/hello/config_emu
     128}}}
     129
     130Once the compilation process has finished, the executable binary is available:
     131{{{
     132kernel-emu-x86-emu.out
     133}}}
     134
     135== Execution ==
     136
     137Simply execute the program as a normal unix executable:
     138{{{
     139$ ./kernel-emu-x86-emu.out
     140(0) Hello (0) World
     141(0) Hello (0) World
     142(0) Hello (0) World
     143(0) Hello (0) World
     144...
     145}}}
     146
     147Other more advanced topics and guides are available from the [wiki: Main page].