├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── COPYING ├── README.md ├── TODO ├── applications ├── CMakeLists.txt └── eash │ ├── CMakeLists.txt │ ├── asm │ └── upcalls.S │ ├── banner.c │ ├── commands.h │ ├── drivers_ctl.c │ ├── drivers_ctl.h │ ├── env_ctl.c │ ├── env_ctl.h │ ├── fs_ctl.c │ ├── fs_ctl.h │ ├── handlers.c │ ├── init.lds │ ├── input_ctl.c │ ├── input_ctl.h │ ├── main.c │ ├── mm_ctl.c │ ├── mm_ctl.h │ ├── os_ctl.c │ ├── os_ctl.h │ ├── parser.c │ ├── parser.h │ ├── performance_ctl.c │ ├── performance_ctl.h │ ├── segments_ctl.c │ ├── segments_ctl.h │ ├── shell.c │ ├── shell.h │ ├── terminal_ctl.c │ ├── terminal_ctl.h │ ├── upcalls.h │ ├── upcalls_ctl.c │ ├── upcalls_ctl.h │ ├── video_ctl.c │ └── video_ctl.h ├── build.sh ├── clean_up_cmake_files.sh ├── cmake ├── Common.cmake ├── DoxygenTarget.cmake ├── GetGitRevisionDescription.cmake ├── GetGitRevisionDescription.cmake.in └── PackageConfigurator.cmake ├── doc ├── kernel │ ├── boot_examour_deplacement_memoire.txt │ ├── eacg.txt │ ├── env_manager │ ├── examour_components │ ├── examour_modeling.gaphor │ ├── exception_irq_forwarding │ ├── first_env_launching │ ├── gdt_layout │ ├── general_thoughts_on_the_architecture │ ├── improvment_idea_with_pagination │ ├── ipc_model │ ├── memory_manager │ ├── modelisation │ │ └── modelisation_noyau.gaphor │ ├── paged_memory_model │ ├── prologue_epilogue_overview │ ├── segmented_memory_model │ ├── source_tree_organisation │ ├── syscall_generator │ ├── syscall_prototypes │ ├── timeslice_manager │ ├── user_level_syscall │ └── x86_kernel_components └── presentations │ ├── A_general_overview_of_the_examour_architecture.odt │ ├── C_macro_based_algorithmic_framework.odt │ ├── an_in_depth_in_a_microkernel_based_libos_on_examour.odt │ ├── an_in_depth_in_a_virtualization_server_on_examour.odt │ ├── docs_technique_examour │ ├── dynamic_library_in_examour.odt │ ├── examour.txt │ ├── examour_core.odg │ ├── examour_design.xmi │ ├── security_in_the_examour_exokernel.odt │ ├── shared_memory_in_examour.odt │ ├── sketch │ ├── env_components.svg │ ├── event_components.svg │ ├── event_manager_subcomponents.svg │ ├── intercomponent_interactions.svg │ ├── main_components.svg │ ├── memory_components.svg │ ├── symbol_table.fig │ ├── symbol_table.svg │ ├── uKernel_ExAmour_components.svg │ ├── uKernel_ExAmour_components_interactions.svg │ └── ukernel_libos_interfaces.txt │ ├── template.ott │ ├── the_examour_driver_model.odt │ ├── the_examour_io_model.odt │ ├── the_examour_memory_model.odt │ └── the_examour_scheduling_model.odt ├── drivers ├── CMakeLists.txt ├── documentation │ ├── doc_pilotes.txt │ ├── doc_pilotes_logiciel.txt │ └── doc_pilotes_materiel.txt ├── fs │ ├── CMakeLists.txt │ ├── tgfs │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ ├── buckets.h │ │ │ ├── malloc.h │ │ │ ├── malloc_init.h │ │ │ ├── powers.h │ │ │ └── tgfs.h │ │ ├── malloc.c │ │ ├── malloc_init.c │ │ ├── powers.c │ │ ├── test_suites.c │ │ └── tgfs.c │ └── vfat │ │ ├── CMakeLists.txt │ │ └── fat32.c ├── input │ ├── CMakeLists.txt │ └── kbd │ │ ├── CMakeLists.txt │ │ ├── asm │ │ └── kbd.S │ │ ├── kbd.c │ │ └── kbd.h ├── mm │ ├── CMakeLists.txt │ ├── segment │ │ ├── CMakeLists.txt │ │ ├── asm │ │ │ └── segment.S │ │ ├── segmentmm.c │ │ └── segmentmm.h │ └── slab │ │ ├── CMakeLists.txt │ │ ├── README │ │ ├── slab.h │ │ ├── slab_cache.c │ │ ├── slab_cache.h │ │ ├── slab_types.h │ │ ├── vmm.c │ │ └── vmm.h ├── rt │ ├── CMakeLists.txt │ ├── README │ └── c │ │ ├── CMakeLists.txt │ │ ├── asm │ │ ├── crt.S │ │ └── start.S │ │ ├── crt.h │ │ └── env.lds └── video │ ├── CMakeLists.txt │ ├── vesa │ ├── CMakeLists.txt │ ├── asm │ │ └── fb.S │ └── vesa.h │ └── vga │ ├── CMakeLists.txt │ ├── vga.c │ └── vga.h ├── grub.cfg ├── kernel ├── CMakeLists.txt ├── include │ ├── CMakeLists.txt │ └── examour │ │ ├── CMakeLists.txt │ │ └── version.h.in └── src │ ├── CMakeLists.txt │ └── arch │ └── x86_64 │ ├── asm │ ├── boot32.s │ └── boot64.s │ ├── kmain.c │ └── linkmap.lds ├── launch_vm.sh ├── libs ├── libc │ ├── CMakeLists.txt │ ├── include │ │ ├── CMakeLists.txt │ │ ├── arch │ │ │ └── x86_64 │ │ │ │ └── bits │ │ │ │ ├── alltypes.h │ │ │ │ └── stdarg.h │ │ ├── errno.h │ │ ├── stdarg.h │ │ ├── stdbool.h │ │ ├── stddef.h │ │ ├── stdint.h │ │ ├── string.h │ │ └── version.h.in │ └── src │ │ ├── CMakeLists.txt │ │ └── string │ │ ├── Makefile.am │ │ ├── memchr.c │ │ ├── memcmp.c │ │ ├── memcpy.c │ │ ├── memmove.c │ │ ├── memset.c │ │ ├── strcat.c │ │ ├── strchr.c │ │ ├── strcmp.c │ │ ├── strcoll.c │ │ ├── strcpy.c │ │ ├── strcspn.c │ │ ├── strerror.c │ │ ├── strlen.c │ │ ├── strncat.c │ │ ├── strncmp.c │ │ ├── strncpy.c │ │ ├── strnlen.c │ │ ├── strpbrk.c │ │ ├── strrchr.c │ │ ├── strspn.c │ │ ├── strstr.c │ │ ├── strtok.c │ │ └── strxfrm.c └── libslds │ ├── CMakeLists.txt │ ├── include │ ├── CMakeLists.txt │ └── libslds │ │ ├── CMakeLists.txt │ │ ├── common.h │ │ ├── hash.h │ │ ├── list.h │ │ ├── tree.h │ │ ├── tree │ │ ├── binary │ │ │ ├── aa_tree.h │ │ │ ├── bst_tree.h │ │ │ ├── dsw_algorihm.h │ │ │ ├── ebst_tree.h │ │ │ ├── kd_tree.h │ │ │ ├── left_child_right_sibling_tree.h │ │ │ ├── radix_tree.h │ │ │ ├── randomized_btree.h │ │ │ ├── redblack_tree.h │ │ │ ├── scapegoat_tree.h │ │ │ ├── splay_tree.h │ │ │ ├── t_tree.h │ │ │ ├── threaded_btree.h │ │ │ ├── treap.h │ │ │ └── weight_balanced_tree.h │ │ └── nary │ │ │ ├── 234_tree.h │ │ │ ├── 23_tree.h │ │ │ ├── ab_tree.h │ │ │ ├── b_tree.h │ │ │ ├── bplus_tree.h │ │ │ ├── bsharp_tree.h │ │ │ ├── bstar_tree.h │ │ │ ├── common.h │ │ │ ├── fusion_tree.h │ │ │ ├── gist_tree.h │ │ │ ├── hilbert_rtree.h │ │ │ ├── nary_tree.h │ │ │ ├── oc_tree.h │ │ │ ├── quad_tree.h │ │ │ ├── r_tree.h │ │ │ ├── rplus_tree.h │ │ │ ├── rstar_tree.h │ │ │ ├── ternary_tree.h │ │ │ ├── top_tree.h │ │ │ ├── tpyramid_tree.h │ │ │ ├── trie_tree.h │ │ │ └── ub_tree.h │ │ └── version.h.in │ └── src │ ├── CMakeLists.txt │ ├── hash │ ├── hash.c │ ├── integer_hashing.c │ └── string_hashing.c │ ├── list │ ├── clist.c │ ├── dlist.c │ └── slist.c │ └── tree │ ├── binary │ ├── aa_tree.c │ ├── avl_rotation.c │ ├── bst_tree.c │ ├── ebst_tree.c │ ├── include │ │ ├── avl_rotation.h │ │ └── dsw_algor.cm.h │ ├── kd_tree.c │ ├── left_child_right_sibling_tree.c │ ├── radix_tree.c │ ├── randomized_btree.c │ ├── redblack_tree.c │ ├── scapegoat_tree.c │ ├── splay_tree.c │ ├── t_tree.c │ ├── treap.c │ └── weight_balanced_tree.c │ └── nary │ ├── 234_tree.c │ ├── 23_tree.c │ ├── ab_tree.c │ ├── b_tree.c │ ├── bplus_tree.c │ ├── bstar_tree.c │ ├── common.c │ ├── fusion_tree.c │ ├── gist_tree.c │ ├── hilbert_rtree.c │ ├── include │ └── bsharp_tree.h │ ├── nary_tree.c │ ├── oc_tree.c │ ├── quad_tree.c │ ├── r_tree.c │ ├── rplus_tree.c │ ├── rstar_tree.c │ ├── ternary_tree.c │ ├── top_tree.c │ ├── tpyramid_tree.c │ ├── trie_tree.c │ └── ub_tree.c └── mk_base_image.sh /.gitignore: -------------------------------------------------------------------------------- 1 | ## CMake 2 | CMakeCache.txt 3 | CMakeFiles 4 | CMakeScripts 5 | Makefile 6 | cmake_install.cmake 7 | install_manifest.txt 8 | 9 | ## C 10 | # Object files 11 | *.o 12 | *.ko 13 | *.obj 14 | *.elf 15 | 16 | # Precompiled Headers 17 | *.gch 18 | *.pch 19 | 20 | # Libraries 21 | *.lib 22 | *.a 23 | *.la 24 | *.lo 25 | 26 | # Shared objects (inc. Windows DLLs) 27 | *.dll 28 | *.so 29 | *.so.* 30 | *.dylib 31 | 32 | # Executables 33 | *.exe 34 | *.out 35 | *.app 36 | *.i*86 37 | *.x86_64 38 | *.hex 39 | 40 | # Debug files 41 | *.dSYM/ 42 | 43 | ## Global 44 | *~ 45 | .DS_Store 46 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "kernel/libs/libslds"] 2 | path = kernel/libs/libslds 3 | url = git://github.com/remysaissy/libslds.git 4 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | 3 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) 4 | 5 | # CMake useful variables 6 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") 7 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") 8 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") 9 | 10 | # Define common flags to all projects 11 | set(CMAKE_C_FLAGS "-std=c99 -nostdinc -nostdlib -ffreestanding") 12 | 13 | add_subdirectory(libs/libc) 14 | add_subdirectory(libs/libslds) 15 | add_subdirectory(kernel) 16 | #add_subdirectory(drivers) 17 | #add_subdirectory(applications) 18 | 19 | add_dependencies(examour c slds) 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ** How to setup the environnement ** 2 | 3 | Prerequisites: 4 | - tcc cvs version 5 | - gcc 4.xx 6 | - binutils 2.17 7 | - gnu make 8 | - bochs 2.2.6 or later 9 | - grub 0.95 or later 10 | - mtools 11 | - qemu 12 | - bximage 13 | 14 | @Installing Tcc 15 | Tcc is located http://fabrice.bellard.free.fr/tcc. The cvs version (at the time of the writing of this document, it is located on savannah) must be used. The 0.9.23 won't work since segment registers support is missing and few other stuffs. 16 | A tcc binary, compiled on a gnu/linux x86-32 bits platform is available in the toolkit directory of the present sources. To use it, you can do the following: 17 | #cp toolkit/tcc /usr/local/bin/tcc 18 | #chown root.root /usr/local/bin/tcc 19 | #chmod 755 /usr/local/bin/tcc 20 | 21 | @ How to install the environment 22 | Go in build_tools and type ./install.sh 23 | Go back in the base directory. 24 | 25 | @ How to compile the kernel and the init env. 26 | Type make in the base directory 27 | 28 | @ How to launch the kernel 29 | - with bochs 30 | ./launch.sh 31 | - with qemu 32 | ./launch.sh qemu 33 | 34 | @ How to compile and create drivers 35 | Go in the drivers directory and have a look at the Makefile, 36 | it contains the available drivers and you have to add your entries 37 | to take yours in account. 38 | 39 | @How to compile a new init env 40 | Change the value of the INIT variable in the .config file at the root of the repository. By default, it points to apps/eash. 41 | 42 | 43 | Enjoy. 44 | 45 | 46 | -- 47 | Remy SAISSY 48 | December 18th, 2006 49 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | ** ExAmour's global TODO ** 2 | 3 | NEED TO BE UPDATED. 4 | [ ] security module 5 | [-] basic caps 6 | [ ] on creation upcalls locking 7 | [ ] dynamically reconfigurable timer 8 | [-] per I/O per environment io access 9 | [-] ring3 upcalls 10 | [ ] dynamic libraries 11 | [-] timeslice based scheduler 12 | [ ] slab based kmalloc/kfree 13 | [ ] reentrant interupt stack 14 | [ ] env_{create,delete,yield} fully functionnal 15 | [ ] technical documentation 16 | [ ] Compiling the kernel 17 | [ ] Compiling the drivers 18 | [ ] Organization of the source tree 19 | [ ] How to write your own ExAmour's component 20 | [ ] ExAmour's driver programming 21 | [ ] ExAmour's environment programming 22 | 23 | 24 | 25 | NEW VERSION 26 | [ ] Continues eash 27 | [ ] Performance tests 28 | [ ] kernel memory allocator 29 | [ ] kernel env allocator 30 | [ ] Upcalls speed 31 | [ ] User env informations 32 | [ ] Env upcalls segment dump 33 | [ ] Env status segment dump 34 | [ ] I/O allocator 35 | [ ] Allocates an I/O 36 | [ ] Revoke an I/O 37 | [ ] Upcalls allocator 38 | [ ] Attach an upcall 39 | [ ] Modify/detech an upcall 40 | [ ] os::driver submenus 41 | [ ] os::driver::fs 42 | [ ] os::driver::mm 43 | [ ] os::driver::kbd 44 | [ ] os::driver::video 45 | [ ] os::driver::pci 46 | [ ] os::driver::event 47 | [ ] os::driver::io 48 | [ ] Continues ExAmour v0.2 49 | [ ] Finish the new memory allocator 50 | [ ] Improve interrupt routines mechanism 51 | [ ] Improve env management 52 | [ ] Add env_yield 53 | [ ] Add event forgery 54 | -------------------------------------------------------------------------------- /applications/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(eash) -------------------------------------------------------------------------------- /applications/eash/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(eash) -------------------------------------------------------------------------------- /applications/eash/asm/upcalls.S: -------------------------------------------------------------------------------- 1 | /* 2 | ** This file is part of ExAmour 3 | 4 | ** Copyright (C) Remy Saissy 5 | ** ExAmour is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | 10 | ** ExAmour is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /* I must care about the argument of the predicate. */ 21 | /* Presently, the argument is pushed on the stack before the call */ 22 | /* but strangely access to its members is made through ds... Everything */ 23 | /* is on the stack however. */ 24 | 25 | .globl _zerodiv 26 | _zerodiv: 27 | push 8(%esp) 28 | call zerodiv 29 | add $4, %esp 30 | lret 31 | 32 | .globl _prologue 33 | _prologue: 34 | push 8(%esp) 35 | call prologue 36 | add $4, %esp 37 | lret 38 | 39 | .globl _epilogue 40 | _epilogue: 41 | push 8(%esp) 42 | call epilogue 43 | add $4, %esp 44 | lret 45 | 46 | .globl _segment_outofbound 47 | _segment_outofbound: 48 | push 8(%esp) 49 | call segment_outofbound 50 | add $4, %esp 51 | lret 52 | 53 | -------------------------------------------------------------------------------- /applications/eash/banner.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ExAmour 3 | 4 | * Copyright (C) Remy Saissy 5 | * ExAmour is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * ExAmour is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | const char const *examour_banner = 21 | "\n" 22 | " ..,,,.. \\--= The ExAmour project =--/\n" 23 | " ._\\\\\\?\\:<:/;!:S>:<\\\\..\n" 24 | " ,,v:??)\\|<::\\\\$\\::>:-S:$//%%%?\\\\\n" 25 | " ..$?\\\\:!>\\$??./'?%:.'$::|?:S|/'':|/S-, Pascal BERTRAND\n" 26 | " ,&'<-:::,<./?:?'~\\|r \\^/ '<<.p??///<-&> Franck CHEVALLEREAU\n" 27 | " ~?: ?|\\\\\\\\::`%.:\\: >:./|T/:Z?:S$|? :^<. Thibaud GUERIN\n" 28 | " v<&'(:?:\\>;^/.::\\'\\|S:|%\\://;/,?S>>Ji?-|.&i' Charles TRON DE BOUCHONY\n" 31 | " :/+.<-:!~Z$:/<:-|. ./:\\:. .::::-\\:<::\n" 32 | " `|\\ ::\\Z:|.\\\\?/::\\<\\:S/||-?|>\\:: ,?\"\n" 33 | " `\\? :<:.;.'',?-,'::-::`::.::/: ,>'\n" 34 | " :-;+:`:>:+?:\\'.\\/,:>:-;i|'/:.'\n" 35 | " -\\:\\:-:\\?:-:,:\\:-??-/->?\\> Web: http://www.examour.eu\n" 36 | " `\\`%%:`|,\\%:::\\:!-:S:%&:|$]:&%:-\n" 40 | " `?\\`&$|Z/?P.'\n" 41 | " `?\\L|R,+\n" 42 | " `,}|\\/\n" 43 | " ``\n"; 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /applications/eash/commands.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __COMMANDS_H__ 21 | #define __COMMANDS_H__ 22 | 23 | #include 24 | 25 | #include "parser.h" 26 | 27 | extern const command_t const drivers_subcommands[]; 28 | 29 | extern const command_t const env_subcommands[]; 30 | 31 | extern const command_t const fs_subcommands[]; 32 | 33 | extern const command_t const input_subcommands[]; 34 | 35 | extern const command_t const mm_subcommands[]; 36 | 37 | extern const command_t const os_subcommands[]; 38 | 39 | extern const command_t const performance_subcommands[]; 40 | 41 | extern const command_t const segments_subcommands[]; 42 | 43 | extern const command_t const terminal_subcommands[]; 44 | 45 | extern const command_t const upcalls_subcommands[]; 46 | 47 | extern const command_t const video_subcommands[]; 48 | 49 | /* Useful command flags. */ 50 | /* Any command prefixed by the keyword 'no' negate the command. */ 51 | bool is_negation; 52 | 53 | 54 | #endif /* __COMMANDS_H__ */ 55 | -------------------------------------------------------------------------------- /applications/eash/drivers_ctl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | #include "commands.h" 23 | #include "drivers_ctl.h" 24 | 25 | const command_t const drivers_subcommands[] = 26 | { 27 | {"help", "?", "Help of the drivers subcommands.", NULL, do_drivers_help}, 28 | {"fs", NULL, "Filesystems features.", fs_subcommands, NULL}, 29 | {"input", NULL, "Input commands.", input_subcommands, NULL}, 30 | {"video", NULL, "Video commands.", video_subcommands, NULL}, 31 | {NULL, NULL, NULL, NULL, NULL}, 32 | }; 33 | 34 | int do_drivers_help(void) 35 | { 36 | puts("Drivers subcommands list:\n"); 37 | list_commands(drivers_subcommands); 38 | return (0); 39 | } 40 | -------------------------------------------------------------------------------- /applications/eash/drivers_ctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __DRIVERS_H__ 21 | #define __DRIVERS_H__ 22 | 23 | int do_drivers_help(void); 24 | 25 | #endif /* __DRIVERS_H__ */ 26 | -------------------------------------------------------------------------------- /applications/eash/env_ctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __ENV_CTL_H__ 21 | #define __ENV_CTL_H__ 22 | 23 | int do_env_help(void); 24 | 25 | int do_env_status_dump(void); 26 | 27 | int do_env_upcalls_dump(void); 28 | 29 | #endif /* __ENV_CTL_H__ */ 30 | -------------------------------------------------------------------------------- /applications/eash/fs_ctl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | /* #include */ 22 | 23 | #include "commands.h" 24 | #include "fs_ctl.h" 25 | 26 | const command_t const fs_subcommands[] = 27 | { 28 | {"help", "?", "Help of the filesystems subcommands.", NULL, do_fs_help}, 29 | /* {"tgfs_testsuite", "tgfs", "Run the tgfs test suite.", NULL, do_tgfs}, */ 30 | {NULL, NULL, NULL, NULL, NULL} 31 | }; 32 | 33 | int do_fs_help(void) 34 | { 35 | puts("Filesystems commands list:\n"); 36 | list_commands(fs_subcommands); 37 | return (0); 38 | } 39 | 40 | int do_tgfs(void) 41 | { 42 | puts("Not compiled in.\n"); 43 | /* tgfs_test_suite(); */ 44 | return (0); 45 | } 46 | -------------------------------------------------------------------------------- /applications/eash/fs_ctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __FS_CTL_H__ 21 | #define __FS_CTL_H__ 22 | 23 | int do_fs_help(void); 24 | 25 | int do_fs_tgfs(void); 26 | 27 | #endif /* __FS_CTL_H__ */ 28 | -------------------------------------------------------------------------------- /applications/eash/handlers.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ExAmour 3 | 4 | * Copyright (C) Remy Saissy 5 | * ExAmour is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * ExAmour is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | /** 26 | * \warning The arg pointer is ok but the code must force a ss:offset 27 | * access since the generated code rely on data/stack overlapping 28 | * which is not the case here. 29 | */ 30 | 31 | void prologue(kevent_cpu_context_t *arg) 32 | { 33 | puts("Prologue called!\n"); 34 | } 35 | 36 | void epilogue(kevent_cpu_context_t *arg) 37 | { 38 | puts("Epilogue called!\n"); 39 | } 40 | 41 | void zerodiv(kevent_cpu_context_t *arg) 42 | { 43 | printf("division by zero catched!\n"); 44 | while (1); 45 | } 46 | 47 | void segment_outofbound(kevent_cpu_context_t *arg) 48 | { 49 | puts("Segment out of bounds, buffer overflow exploitation attempt?!\n"); 50 | while (1); 51 | } 52 | -------------------------------------------------------------------------------- /applications/eash/init.lds: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of exAmour 3 | 4 | Copyright (C) Remy Saissy 5 | exAmour is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | exAmour is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | OUTPUT_FORMAT("binary") 21 | OUTPUT_ARCH("i386") 22 | ENTRY(_start) 23 | 24 | SECTIONS 25 | { 26 | . = 0; 27 | data_start = .; 28 | .text : 29 | { 30 | ../../libos/libc/klibc/arch/i386/crt0.o(.text*) 31 | *(.text*) 32 | } 33 | 34 | 35 | .data SIZEOF(.text) + ADDR(.text) : 36 | { 37 | *(.data*) 38 | } 39 | 40 | 41 | .rodata SIZEOF(.data) + ADDR(.data) : 42 | { 43 | *(.rodata*) 44 | } 45 | 46 | .bss SIZEOF(.rodata) + ADDR(.rodata) : 47 | { 48 | *(.bss*) 49 | } 50 | 51 | data_end = .; 52 | 53 | /DISCARD/ : 54 | { 55 | *(.note*) 56 | *(.indent) 57 | *(.comment) 58 | *(.stab) 59 | *(.stabstr) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /applications/eash/input_ctl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "commands.h" 27 | #include "input_ctl.h" 28 | 29 | const command_t const input_subcommands[] = 30 | { 31 | {"help", "?", "Help of the input subcommands.", NULL, do_input_help}, 32 | {"list_keymap", "lkmap", " Print the available keyboard maps.", NULL, do_input_list_keymap}, 33 | {"set_keymap", "skmap", " Set a keyboard map", NULL, do_input_set_keymap}, 34 | {NULL, NULL, NULL, NULL} 35 | }; 36 | 37 | int do_input_help(void) 38 | { 39 | puts("Input commands list:\n"); 40 | list_commands(input_subcommands); 41 | return (0); 42 | } 43 | 44 | int do_input_list_keymap(void) 45 | { 46 | kbd_list_keymap(); 47 | return (0); 48 | } 49 | 50 | int do_input_set_keymap(void) 51 | { 52 | char *arg; 53 | 54 | arg = parse_next_arg(); 55 | kbd_set_kbd_map(arg); 56 | return (0); 57 | } 58 | -------------------------------------------------------------------------------- /applications/eash/input_ctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __INPUT_CTL_H__ 21 | #define __INPUT_CTL_H__ 22 | 23 | int do_input_help(void); 24 | 25 | int do_input_list_keymap(void); 26 | 27 | int do_input_set_keymap(void); 28 | 29 | #endif /* __INPUT_CTL_H__ */ 30 | -------------------------------------------------------------------------------- /applications/eash/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** This file is part of exAmour 3 | 4 | ** Copyright (C) Remy Saissy 5 | ** exAmour is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | 10 | ** exAmour is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "shell.h" 27 | 28 | int main(void) 29 | { 30 | vga_init(); 31 | kbd_init(); 32 | cls(); 33 | run_shell(); 34 | return (0); 35 | } 36 | -------------------------------------------------------------------------------- /applications/eash/mm_ctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __MM_CTL_H__ 21 | #define __MM_CTL_H__ 22 | 23 | int do_mm_echo(void); 24 | 25 | int do_mm_help(void); 26 | 27 | int do_mm_alloc(void); 28 | 29 | int do_mm_free(void); 30 | 31 | int do_mm_read(void); 32 | 33 | int do_mm_write(void); 34 | 35 | int do_mm_dump(void); 36 | 37 | #endif /* __MM_CTL_H__ */ 38 | -------------------------------------------------------------------------------- /applications/eash/os_ctl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "upcalls.h" 24 | 25 | #include "commands.h" 26 | #include "os_ctl.h" 27 | 28 | const command_t const os_subcommands[] = 29 | { 30 | {"help", "?", "Help of the operating system subcommands.", NULL, do_os_help}, 31 | {"drivers", NULL, "Operating system's drivers control.", drivers_subcommands, NULL}, 32 | {"mm", NULL, "Memory commands.", mm_subcommands, NULL}, 33 | {"segment", NULL, "Memory segments and registers.", segments_subcommands, NULL}, 34 | {"upcalls", NULL, "Upcall functionalities.", upcalls_subcommands, NULL}, 35 | {"heap_buffer_overflow", "hbof", "Attempt to exploit a heap buffer overflow", NULL, do_os_hbof}, 36 | {"stack_buffer_overflow", "sbof", "Attempt to exploit a stack buffer overflow", NULL, do_os_sbof}, 37 | {NULL, NULL, NULL, NULL, NULL} 38 | }; 39 | 40 | static char shellcode[2] = "\xeb\xfe"; 41 | 42 | void segment_outofbound(kevent_cpu_context_t *arg); 43 | 44 | int do_os_help(void) 45 | { 46 | puts("OS commands list:\n"); 47 | list_commands(os_subcommands); 48 | return (0); 49 | } 50 | 51 | int do_os_hbof(void) 52 | { 53 | void (*f)(); 54 | 55 | puts("Atempt to exploit a data buffer overflow...\n"); 56 | f = (void *)shellcode; 57 | f(); 58 | puts("Exploitation failed!\n"); 59 | return (0); 60 | } 61 | 62 | int do_os_sbof(void) 63 | { 64 | char sbof[2] = "\xeb\xfe"; 65 | void (*f)(); 66 | 67 | puts("Attempt to exploit a stack buffer overflow...\n"); 68 | set_exception_handler(5, (paddr_t)_segment_outofbound); 69 | f = (void *)sbof; 70 | f(); 71 | unset_exception_handler(5); 72 | puts("Exploitation failed!\n"); 73 | return (0); 74 | } 75 | -------------------------------------------------------------------------------- /applications/eash/os_ctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __OS_CTL_H__ 21 | #define __OS_CTL_H__ 22 | 23 | int do_os_help(void); 24 | 25 | int do_os_hbof(void); 26 | 27 | int do_os_sbof(void); 28 | 29 | #endif /* __OS_CTL_H__ */ 30 | -------------------------------------------------------------------------------- /applications/eash/parser.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ExAmour 3 | 4 | * Copyright (C) Remy Saissy 5 | * ExAmour is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * ExAmour is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | #include 23 | 24 | #include "parser.h" 25 | 26 | static char *unparsed_string = NULL; 27 | static char *current_begin = NULL; 28 | static char *current_end = NULL; 29 | 30 | void begin_parse(char *arg) 31 | { 32 | unparsed_string = arg; 33 | current_begin = NULL; 34 | current_end = arg; 35 | } 36 | 37 | void end_parse(void) 38 | { 39 | unparsed_string = NULL; 40 | current_begin = NULL; 41 | current_end = NULL; 42 | } 43 | 44 | char *parse_next_arg(void) 45 | { 46 | char *s; 47 | 48 | s = NULL; 49 | current_begin = current_end; 50 | if (current_begin != NULL && *current_begin) 51 | { 52 | while (*current_begin && 53 | (*current_begin == ' ' || 54 | *current_begin == '\t' || 55 | *current_begin == '\n')) 56 | current_begin++; 57 | if (current_begin) 58 | { 59 | s = current_begin; 60 | current_end = current_begin; 61 | while (*current_end && 62 | *current_end != ' ' 63 | && *current_end != '\t' 64 | && *current_end != '\n') 65 | current_end++; 66 | if (*current_end) 67 | *current_end++ = '\0'; 68 | } 69 | } 70 | return (s); 71 | } 72 | 73 | void list_commands(const command_t const *_commands) 74 | { 75 | int j; 76 | 77 | for (j = 0; _commands[j].id != NULL; j++) 78 | { 79 | if (_commands[j].id != NULL) 80 | puts(_commands[j].id); 81 | if (_commands[j].alias != NULL) 82 | { 83 | puts(" ("); 84 | puts(_commands[j].alias); 85 | puts("):\t"); 86 | } 87 | if (_commands[j].desc != NULL) 88 | { 89 | puts(":\t"); 90 | puts(_commands[j].desc); 91 | } 92 | putchar('\n'); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /applications/eash/parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ExAmour 3 | 4 | * Copyright (C) Remy Saissy 5 | * ExAmour is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * ExAmour is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __PARSER_H__ 21 | #define __PARSER_H__ 22 | 23 | typedef struct command_s 24 | { 25 | const char *id; 26 | const char *alias; 27 | const char *desc; 28 | const struct command_s const *subcommands; 29 | int (*command)(void); 30 | 31 | } command_t; 32 | 33 | void begin_parse(char *arg); 34 | 35 | void end_parse(void); 36 | 37 | char *parse_next_arg(void); 38 | 39 | void list_commands(const command_t const *_command); 40 | 41 | 42 | #endif /* __PARSER_H__ */ 43 | -------------------------------------------------------------------------------- /applications/eash/performance_ctl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "commands.h" 24 | #include "performance_ctl.h" 25 | 26 | const command_t const performance_subcommands[] = 27 | { 28 | {"help", "?", "Help of the performance monitoring subcommands.", NULL, do_performance_help}, 29 | {"timestamp", "ts", "Get the timestamp.", NULL, do_performance_get_timestamp}, 30 | {NULL, NULL, NULL, NULL, NULL}, 31 | }; 32 | 33 | int do_performance_help(void) 34 | { 35 | puts("Performance commands list:\n"); 36 | list_commands(performance_subcommands); 37 | return (0); 38 | } 39 | 40 | int do_performance_get_timestamp(void) 41 | { 42 | uint64_t ts; 43 | 44 | ts = 0; 45 | read_timestamp(&ts); 46 | printf("Timestamp: %u\n", ts); 47 | return (0); 48 | } 49 | -------------------------------------------------------------------------------- /applications/eash/performance_ctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __PERFORMANCE_CTL_H__ 21 | #define __PERFORMANCE_CTL_H__ 22 | 23 | int do_performance_help(void); 24 | 25 | int do_performance_get_timestamp(void); 26 | 27 | #endif /* __PERFORMANCE_CTL_H__ */ 28 | -------------------------------------------------------------------------------- /applications/eash/segments_ctl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "commands.h" 24 | #include "segments_ctl.h" 25 | 26 | const command_t const segments_subcommands[] = 27 | { 28 | {"help", "?", "Help of the segments subcommands.", NULL, do_segments_help}, 29 | {NULL, NULL, NULL, NULL, NULL} 30 | }; 31 | 32 | int do_segments_help(void) 33 | { 34 | puts("Segments commands list:\n"); 35 | list_commands(segments_subcommands); 36 | return (0); 37 | } 38 | 39 | int do_segments_cs_ctl(void) 40 | { 41 | return (0); 42 | } 43 | 44 | int do_segments_ss_ctl(void) 45 | { 46 | return (0); 47 | } 48 | 49 | int do_segments_ds_ctl(void) 50 | { 51 | return (0); 52 | } 53 | 54 | int do_segments_es_ctl(void) 55 | { 56 | return (0); 57 | } 58 | 59 | int do_segments_fs_ctl(void) 60 | { 61 | return (0); 62 | } 63 | 64 | int do_segments_gs_ctl(void) 65 | { 66 | return (0); 67 | } 68 | 69 | int do_segments_get_sp(void) 70 | { 71 | return (0); 72 | } 73 | 74 | int do_segments_get_pc(void) 75 | { 76 | return (0); 77 | } 78 | -------------------------------------------------------------------------------- /applications/eash/segments_ctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __SEGMENTS_CTL_H__ 21 | #define __SEGMENTS_CTL_H__ 22 | 23 | int do_segments_help(void); 24 | 25 | int do_segments_cs_ctl(void); 26 | 27 | int do_segments_ss_ctl(void); 28 | 29 | int do_segments_ds_ctl(void); 30 | 31 | int do_segments_es_ctl(void); 32 | 33 | int do_segments_fs_ctl(void); 34 | 35 | int do_segments_gs_ctl(void); 36 | 37 | int do_segments_get_sp(void); 38 | 39 | int do_segments_get_pc(void); 40 | 41 | #endif /* __SEGMENTS_CTL_H__ */ 42 | -------------------------------------------------------------------------------- /applications/eash/shell.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ExAmour 3 | 4 | * Copyright (C) Remy Saissy 5 | * ExAmour is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * ExAmour is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "commands.h" 26 | #include "shell.h" 27 | 28 | static const command_t const commands[] = 29 | { 30 | {"help", "?", "\t\t\t The command list.", NULL, do_help}, 31 | {"version", "v", "\t\t Print the version.", NULL, do_version}, 32 | {"os", NULL, "Operating system features control.", os_subcommands, NULL}, 33 | {"terminal", "term", "Terminal control.", terminal_subcommands, NULL}, 34 | {"env", NULL, "Environment control.", env_subcommands, NULL}, 35 | {"performance", "perf", "Performance control.", performance_subcommands, NULL}, 36 | {NULL, NULL, NULL, NULL, NULL} 37 | }; 38 | 39 | static char buff[255]; 40 | 41 | int do_version(void) 42 | { 43 | puts("eash, the ExAmour Shell. v0.1.\n"); 44 | return (0); 45 | } 46 | 47 | int do_help(void) 48 | { 49 | puts("Command list:\n"); 50 | list_commands(commands); 51 | return (0); 52 | } 53 | 54 | int command_exec(char *cmd) 55 | { 56 | int i; 57 | char *arg; 58 | const command_t const *current_commands; 59 | 60 | begin_parse(cmd); 61 | current_commands = commands; 62 | is_negation = false; 63 | while (1) 64 | { 65 | arg = parse_next_arg(); 66 | if (arg == NULL) 67 | break; 68 | if (!strcmp("no", arg)) 69 | { 70 | /* This is a negation of the command. */ 71 | is_negation = true; 72 | continue; 73 | } 74 | for (i = 0; current_commands[i].id != NULL; i++) 75 | { 76 | if ((current_commands[i].id != NULL && !strcmp(current_commands[i].id, arg)) || 77 | (current_commands[i].alias != NULL && !strcmp(current_commands[i].alias, arg))) 78 | { 79 | if ((void *)current_commands[i].command != NULL) 80 | return (current_commands[i].command()); 81 | else 82 | current_commands = current_commands[i].subcommands; 83 | break; 84 | } 85 | } 86 | } 87 | return (-1); 88 | } 89 | 90 | void run_shell(void) 91 | { 92 | int cnt; 93 | 94 | while (1) 95 | { 96 | puts("eash$> "); 97 | while ((cnt = kbd_read(buff, 254)) <= 0) 98 | ; 99 | buff[--cnt] = 0; 100 | if (*buff) 101 | if (command_exec(buff) == -1) 102 | puts("Command not found.\n"); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /applications/eash/shell.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** This file is part of exAmour 3 | 4 | ** Copyright (C) Remy Saissy 5 | ** exAmour is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | 10 | ** exAmour is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef __SHELL_H__ 21 | #define __SHELL_H__ 22 | 23 | 24 | #ifndef __ASM__ 25 | 26 | void run_shell(void); 27 | 28 | /* callbacks. */ 29 | 30 | int do_version(void); 31 | 32 | int do_help(void); 33 | 34 | #endif /* __ASM__ */ 35 | 36 | #endif /* __SHELL_H__ */ 37 | -------------------------------------------------------------------------------- /applications/eash/terminal_ctl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "commands.h" 24 | #include "terminal_ctl.h" 25 | 26 | extern const char const *examour_banner; 27 | 28 | const command_t const terminal_subcommands[] = 29 | { 30 | {"help", "?", "Help of the terminal subcommands.", NULL, do_terminal_help}, 31 | {"clear_screen", "cls", " Clear the screen", NULL, do_terminal_cls}, 32 | {"echo", "e", " Print a string on the screen.", NULL, do_terminal_print}, 33 | {"banner", "b", " Print the banner of the project.", NULL, do_terminal_banner}, 34 | {NULL, NULL, NULL, NULL, NULL}, 35 | }; 36 | 37 | int do_terminal_help(void) 38 | { 39 | puts("Terminal subcommands list:\n"); 40 | list_commands(terminal_subcommands); 41 | return (0); 42 | } 43 | 44 | int do_terminal_banner(void) 45 | { 46 | char *arg; 47 | 48 | arg = parse_next_arg(); 49 | puts(examour_banner); 50 | return (0); 51 | } 52 | 53 | int do_terminal_print(void) 54 | { 55 | char *arg; 56 | 57 | while ((arg = parse_next_arg())) 58 | printf("%s \n", arg); 59 | return (0); 60 | } 61 | 62 | int do_terminal_cls(void) 63 | { 64 | cls(); 65 | return (0); 66 | } 67 | -------------------------------------------------------------------------------- /applications/eash/terminal_ctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __TERMINAL_H__ 21 | #define __TERMINAL_H__ 22 | 23 | int do_terminal_help(void); 24 | 25 | int do_terminal_cls(void); 26 | 27 | int do_terminal_print(void); 28 | 29 | int do_terminal_banner(void); 30 | 31 | #endif /* __TERMINAL_H__ */ 32 | -------------------------------------------------------------------------------- /applications/eash/upcalls.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ExAmour 3 | 4 | * Copyright (C) Remy Saissy 5 | * ExAmour is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * ExAmour is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __UPCALLS_H__ 21 | #define __UPCALLS_H__ 22 | 23 | 24 | #ifndef __ASM__ 25 | 26 | void _zerodiv(void); 27 | 28 | void _prologue(void); 29 | 30 | void _epilogue(void); 31 | 32 | void _segment_outofbound(void); 33 | 34 | #endif /* __ASM__ */ 35 | 36 | #endif /* __UPCALLS_H__ */ 37 | -------------------------------------------------------------------------------- /applications/eash/upcalls_ctl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "upcalls.h" 24 | #include "commands.h" 25 | #include "upcalls_ctl.h" 26 | 27 | const command_t const upcalls_subcommands[] = 28 | { 29 | {"help", "?", "Help of upcalls subcommands.", NULL, do_upcalls_help}, 30 | {"epilogue_ctl", "ectl", "Control a basic epilogue.", NULL, do_upcalls_epilogue_ctl}, 31 | {"prologue_ctl", "pctl", "Control a basic prologue.", NULL, do_upcalls_prologue_ctl}, 32 | {"exception_ctl", "exctl", "Control exceptions. param: [raise]", NULL, do_upcalls_exception_ctl}, 33 | {NULL, NULL, NULL, NULL, NULL} 34 | }; 35 | 36 | /* static const char *exception_name[] = */ 37 | /* { */ 38 | /* "EXCEPTION_DIVIDE_ERROR", */ 39 | /* "EXCEPTION_DEBUG", */ 40 | /* "EXCEPTION_NMI_INTR", */ 41 | /* "EXCEPTION_BREAKPOINT", */ 42 | /* "EXCEPTION_OVERFLOW", */ 43 | /* "EXCEPTION_BOUND_EXCEED", */ 44 | /* "EXCEPTION_INVL_OPCODE", */ 45 | /* "EXCEPTION_DEV_NOT_AVL", */ 46 | /* "EXCEPTION_DOUBLE_FAULT", */ 47 | /* "EXCEPTION_COP_SEG_OVERRUN", */ 48 | /* "EXCEPTION_INVL_TSS", */ 49 | /* "EXCEPTION_SEGMENT_NOT_PRESENT", */ 50 | /* "EXCEPTION_STACK_FAULT", */ 51 | /* "EXCEPTION_GENERAL_PROTECTION", */ 52 | /* "EXCEPTION_PAGE_FAULT", */ 53 | /* "EXCEPTION_UNUSED", */ 54 | /* "EXCEPTION_FPU_ERROR", */ 55 | /* "EXCEPTION_ALIGNMENT_CHECK", */ 56 | /* "EXCEPTION_MACHINE_CHECK", */ 57 | /* "EXCEPTION_SIMD_FPU" */ 58 | /* }; */ 59 | 60 | int do_upcalls_help(void) 61 | { 62 | puts("Upcalls commands list:\n"); 63 | list_commands(upcalls_subcommands); 64 | return (0); 65 | } 66 | 67 | int do_upcalls_exception_ctl(void) 68 | { 69 | if (is_negation == false) 70 | { 71 | set_exception_handler(EXCEPTION_INVL_OPCODE, (paddr_t)_segment_outofbound); 72 | } 73 | else 74 | { 75 | unset_exception_handler(EXCEPTION_INVL_OPCODE); 76 | } 77 | return (0); 78 | } 79 | 80 | int do_upcalls_prologue_ctl(void) 81 | { 82 | if (is_negation == false) 83 | set_prologue((paddr_t)_prologue); 84 | else 85 | unset_prologue(); 86 | return (0); 87 | } 88 | 89 | int do_upcalls_epilogue_ctl(void) 90 | { 91 | if (is_negation == false) 92 | set_epilogue((paddr_t)_epilogue); 93 | else 94 | unset_epilogue(); 95 | return (0); 96 | } 97 | 98 | /* int do_upcalls_zerodiv(void) */ 99 | /* { */ 100 | /* int i; */ 101 | /* int y; */ 102 | 103 | /* set_exception_handler(EXCEPTION_DIVIDE_ERROR, (paddr_t)_zerodiv); */ 104 | /* i = 42; */ 105 | /* y = 0; */ 106 | /* y = i/y; */ 107 | /* unset_exception_handler(EXCEPTION_DIVIDE_ERROR); */ 108 | /* return (0); */ 109 | /* } */ 110 | -------------------------------------------------------------------------------- /applications/eash/upcalls_ctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __UPCALLS_CTL_H__ 21 | #define __UPCALLS_CTL_H__ 22 | 23 | int do_upcalls_help(void); 24 | 25 | int do_upcalls_prologue_ctl(void); 26 | 27 | int do_upcalls_epilogue_ctl(void); 28 | 29 | int do_upcalls_exception_ctl(void); 30 | 31 | #endif /* __UPCALLS_CTL_H__ */ 32 | -------------------------------------------------------------------------------- /applications/eash/video_ctl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "commands.h" 27 | #include "video_ctl.h" 28 | 29 | const command_t const video_subcommands[] = 30 | { 31 | {"help", "?", "Help of the video subcommands.", NULL, do_video_help}, 32 | {"list_fg_colors", "lfgc", "List available foreground colors", NULL, do_video_list_fg_colors}, 33 | {"set_fg_color", "sfgc", " Set a font color", NULL, do_video_set_fg_color}, 34 | {"list_bg_colors", "lbgc", "List available background colors", NULL, do_video_list_bg_colors}, 35 | {"set_bg_color", "sbgc", " Set a background color", NULL, do_video_set_bg_color}, 36 | {NULL, NULL, NULL, NULL, NULL}, 37 | }; 38 | 39 | int do_video_help(void) 40 | { 41 | puts("Video commands:\n"); 42 | list_commands(video_subcommands); 43 | return (0); 44 | } 45 | 46 | int do_video_set_bg_color(void) 47 | { 48 | char *arg; 49 | 50 | arg = parse_next_arg(); 51 | set_background_color(arg); 52 | return (0); 53 | } 54 | 55 | int do_video_list_bg_colors(void) 56 | { 57 | list_bg_colors(); 58 | return (0); 59 | } 60 | 61 | int do_video_set_fg_color(void) 62 | { 63 | char *arg; 64 | 65 | arg = parse_next_arg(); 66 | set_foreground_color(arg); 67 | return (0); 68 | } 69 | 70 | int do_video_list_fg_colors(void) 71 | { 72 | list_fg_colors(); 73 | return (0); 74 | } 75 | -------------------------------------------------------------------------------- /applications/eash/video_ctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of eash 3 | 4 | * Copyright (C) Remy Saissy 5 | * eash is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * eash is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __VIDEO_CTL_H__ 21 | #define __VIDEO_CTL_H__ 22 | 23 | int do_video_help(void); 24 | 25 | int do_video_list_fg_colors(void); 26 | 27 | int do_video_set_fg_color(void); 28 | 29 | int do_video_list_bg_colors(void); 30 | 31 | int do_video_set_bg_color(void); 32 | 33 | 34 | #endif /* __VIDEO_CTL_H__ */ 35 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir build 4 | cd build 5 | cmake .. 6 | -------------------------------------------------------------------------------- /clean_up_cmake_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | find . -name 'CMakeCache.txt' -exec rm -rf {} \; 4 | find . -name 'CMakeFiles' -exec rm -rf {} \; 5 | find . -name 'CMakeScripts' -exec rm -rf {} \; 6 | find . -name 'Makefile' -exec rm -rf {} \; 7 | find . -name 'cmake_install.cmake' -exec rm -rf {} \; 8 | find . -name 'install_manifest.txt' -exec rm -rf {} \; 9 | -------------------------------------------------------------------------------- /cmake/Common.cmake: -------------------------------------------------------------------------------- 1 | # Function to link between sub-projects 2 | function(add_dependent_subproject subproject_name) 3 | #if (NOT TARGET ${subproject_name}) # target unknown 4 | if(NOT PROJECT_${subproject_name}) # var unknown because we build only this subproject, ProjA must have been built AND installed 5 | find_package(${subproject_name} CONFIG REQUIRED) 6 | else () # we know the target thus we are doing a build from the top directory 7 | include_directories(../${subproject_name}/include) 8 | endif () 9 | endfunction(add_dependent_subproject) 10 | 11 | # Make sure we tell the topdir CMakeLists that we exist (if build from topdir) 12 | get_directory_property(hasParent PARENT_DIRECTORY) 13 | if(hasParent) 14 | set(PROJECT_${PROJECT_NAME} true PARENT_SCOPE) 15 | endif() -------------------------------------------------------------------------------- /cmake/DoxygenTarget.cmake: -------------------------------------------------------------------------------- 1 | function(PrepareDocTarget) 2 | 3 | # Configure the doxygen config file with current settings: 4 | configure_file(documentation-config.doxygen.in ${CMAKE_CURRENT_BINARY_DIR}/documentation-config.doxygen @ONLY) 5 | 6 | # Set the name of the target : "doc" if it doesn't already exist and "doc" if it does. 7 | # This way we make sure to have a single "doc" target. Either it is the one of the top directory or 8 | # it is the one of the subproject that we are compiling alone. 9 | set(DOC_TARGET_NAME "doc") 10 | if(TARGET doc) 11 | set(DOC_TARGET_NAME "doc${PROJECT_NAME}") 12 | endif() 13 | 14 | add_custom_target(${DOC_TARGET_NAME} ${TARGET_ALL} 15 | ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/documentation-config.doxygen 16 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 17 | COMMENT "Generating API documentation using doxygen" VERBATIM) 18 | 19 | make_directory(${CMAKE_CURRENT_BINARY_DIR}/html) # needed for install 20 | 21 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/${PROJECT_NAME}-${VERSION_MAJOR} COMPONENT doc) 22 | 23 | endfunction() -------------------------------------------------------------------------------- /cmake/GetGitRevisionDescription.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Internal file for GetGitRevisionDescription.cmake 3 | # 4 | # Requires CMake 2.6 or newer (uses the 'function' command) 5 | # 6 | # Original Author: 7 | # 2009-2010 Ryan Pavlik 8 | # http://academic.cleardefinition.com 9 | # Iowa State University HCI Graduate Program/VRAC 10 | # 11 | # Copyright Iowa State University 2009-2010. 12 | # Distributed under the Boost Software License, Version 1.0. 13 | # (See accompanying file LICENSE_1_0.txt or copy at 14 | # http://www.boost.org/LICENSE_1_0.txt) 15 | 16 | set(HEAD_HASH) 17 | 18 | file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) 19 | 20 | string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) 21 | if(HEAD_CONTENTS MATCHES "ref") 22 | # named branch 23 | string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") 24 | if(EXISTS "@GIT_DIR@/${HEAD_REF}") 25 | configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 26 | else() 27 | configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) 28 | file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) 29 | if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") 30 | set(HEAD_HASH "${CMAKE_MATCH_1}") 31 | endif() 32 | endif() 33 | else() 34 | # detached HEAD 35 | configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) 36 | endif() 37 | 38 | if(NOT HEAD_HASH) 39 | file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) 40 | string(STRIP "${HEAD_HASH}" HEAD_HASH) 41 | endif() 42 | -------------------------------------------------------------------------------- /cmake/PackageConfigurator.cmake: -------------------------------------------------------------------------------- 1 | # Create package-config files : 2 | # - ConfigVersion.cmake 3 | # - Config.cmake 4 | # They are installed in lib/cmake/. 5 | # 6 | # Required variables : 7 | # - VERSION 8 | # - PROJECT_NAME 9 | # 10 | 11 | # Include needed for 'write_basic_package_version_file' 12 | include(CMakePackageConfigHelpers) 13 | 14 | write_basic_package_version_file( 15 | "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake" 16 | VERSION ${VERSION} 17 | COMPATIBILITY AnyNewerVersion 18 | ) 19 | 20 | configure_file(cmake/${PROJECT_NAME}Config.cmake 21 | "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake" 22 | COPYONLY 23 | ) 24 | 25 | set(ConfigPackageLocation lib/cmake/${PROJECT_NAME}) 26 | 27 | install( 28 | EXPORT ${PROJECT_NAME}Targets 29 | DESTINATION ${ConfigPackageLocation} 30 | ) 31 | 32 | install( 33 | FILES 34 | cmake/${PROJECT_NAME}Config.cmake 35 | "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake" 36 | DESTINATION ${ConfigPackageLocation} 37 | COMPONENT devel 38 | ) -------------------------------------------------------------------------------- /doc/kernel/boot_examour_deplacement_memoire.txt: -------------------------------------------------------------------------------- 1 | ** deplacement du noyau dans la memoire ** 2 | 3 | Quelque que soit le modele memoire employer. 4 | 5 | L'environnement de bootstrap connait la taille des structures de 6 | donnees qui gerent l'allocation memoire aussi est il capable de 7 | determiner precisement combien d'octets seront requis en memoire pour 8 | la gerer. 9 | 10 | L'idee ici est d'avoir un systeme relativement flexible pour booter le 11 | kernel et son process init via un process de bootstrap qui s'occupera 12 | de la partie dependante du bootloader, de la detection de la quantite 13 | de memoire... enfin des conneries qui peuvent etre degagees de l'image 14 | du noyau mais qui doivent etre realisee au moment du boot. 15 | 16 | Initialement, le bootloader va donc charger le bootstrap. Ce dernier 17 | va commencer par determiner quelles sont les capacites de la machine 18 | au niveau memoire. 19 | Comprendre qu'il va verifier que la pagination est presente, detecter 20 | la quantite de memoire physique et enfin determiner combien de place 21 | sera necessaire pour stocker les structures de donnees de la gestion 22 | memoire. 23 | Ensuite il va preparer la memoire pour lancer le kernel a savoir que 24 | si la pagination est dispo, il va l'installer et l'activer histoire de 25 | lancer l'image du noyau deja positionnee en memoire virtuelle haute 26 | (3.5GB). 27 | 28 | Le process bootstrap est charge de reserver l'espace memoire pour la 29 | gestion des structures de donnees cela veut dire qu'il va faire 30 | plusieurs choses : 31 | - Reserver l'espace pour le futur noyau a partir de 1MB. 32 | - copier respectivement le noyau et le process init a la suite l'un 33 | de l'autre juste apres cet espace memoire. 34 | - allouer des pages memoire pour lui a[pres tout cela. Ces pages 35 | seront utilisees pour mapper le kernel en memoire haute. le process 36 | init lui n'est pas mapper, ce sera au noyau de faire ce qu'il veut 37 | avec son adresse physique. 38 | 39 | Normalement le process bootstrap se trouve au debut de l'espace 40 | reserver pour la gestion memoire donc il n'est recouvert que lorsque 41 | le noyau configure sa memoire. 42 | 43 | Une fois ce minimum fait le process bootstrap peut faire un call sur 44 | le process du noyau qu'il a mapper a 3.5GB. 45 | Le noyau ne doit jamais rendre la main a son main. Il doit commencer 46 | par installer sa gdt, initialiser sa memoire (recouvrement du process 47 | bootstrap) et switcher vers ses propres pages avec ses propres 48 | structures fraichement allouees. 49 | Une fois ceci de fait libre au noyau de charger son idt et de mapper 50 | son process init ou il le souhaite. 51 | 52 | Apres la vie suit son cours... 53 | 54 | J'espere que ce systeme ne sera pas trop lent ni trop redondant (bien 55 | qu'il le soit deja un peu). Mais ca me semble etre un bon moyen de 56 | gerer un demarrage propre et les detections ne servant qu'une fois 57 | peuvent etre degagee dans un process qui est detruit apres d'ou une 58 | image du noyau plus petite et donc une consommation memoire et une 59 | complexite reduites. 60 | 61 | Remy Saissy, le 8 Juin 2006 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /doc/kernel/examour_components: -------------------------------------------------------------------------------- 1 | ** exAmour's kernel components ** 2 | 3 | The exAmour kernel is splitted in three parts. 4 | - event 5 | - mm 6 | - env 7 | 8 | This document provides an overview of each component. 9 | For further informations, please refers to the relevant subdirectory. 10 | 11 | @ The event component 12 | 13 | The event component is responsible of events handling. 14 | Events in exAmour can be: 15 | - 16 | 17 | 18 | @ The mm component 19 | 20 | 21 | 22 | @ The env component 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /doc/kernel/exception_irq_forwarding: -------------------------------------------------------------------------------- 1 | ** Exception and irq forwarding ** 2 | 3 | In exAmour, the exceptions and irqs are forwarded to a user handler 4 | as soon as possible and when the user env specified one. 5 | However some exceptions are critical and then take advantage of a 6 | special treatment. 7 | 8 | Fault and abort exceptions that can be handled by a user env 9 | are forwarded and if none has been specified, they are handled 10 | by the kernel. 11 | An example of that kind of exception is the general protection 12 | fault on intel architecture. 13 | 14 | Fault and abort exceptions that cannot be handled by a user env 15 | are directly handled by the kernel. 16 | An example of that kind of exception is the double fault on intel 17 | architecture which can lead to a reboot of the machine if not 18 | handled correctly. 19 | 20 | Exception and irq forwarding flow chart: 21 | 22 | event (exception or interruption) kernel user env 23 | | the kernel is signaled of an 24 | | event in the execution flow 25 | |--------------------------------->| 26 | | after saving the 27 | | critical informations 28 | | of the env, the handler 29 | | is called 30 | |--------------------------------->| 31 | | 32 | once handled, control is returned| 33 | back to the kernel | 34 | |<---------------------------------| 35 | kernel ack the handling and | 36 | continue normal execution flow | 37 | |<---------------------------------| 38 | 39 | In case of no user env handler, kernel env handler is called. 40 | 41 | -------------------------------------------------------------------------------- /doc/kernel/first_env_launching: -------------------------------------------------------------------------------- 1 | ** exAmour's first environment launching ** 2 | 3 | @ Layout of an env: 4 | 5 | .code 6 | [code of the env] 7 | .bss 8 | .data 9 | .rodata 10 | ... 11 | [data of the env] 12 | .uenv_init_memory_map 13 | [memory map informations and code] 14 | The symbol's name is: 15 | bool __init_memory_map(examour_env_section_t *sections, 16 | int n_sections, 17 | kevent_cpu_context_t *start_ctx, 18 | ldtr_t *mem_context) 19 | __attribute__((__section__(".uenv_code"))); 20 | This symbol's job is to install the memory model of the 21 | new env. (see env_manager) 22 | 23 | @ The launching flow chart: 24 | 25 | kernel current_env (shell) new_env 26 | | sys_env_create() | 27 | |<-----------------------------| 28 | | 29 | |allocate its stuffs. 30 | |(stack0, esp0, ...) 31 | | 32 | | _init_memory_map() 33 | |--------------------------------------------->| setup its 34 | | memory model, 35 | | and its start 36 | |<---------------------------------------------| time context. 37 | | 38 | |schedule the new env (grants 100ms timeslice) 39 | | 40 | | return to the current_env 41 | |----------------------------->| 42 | 43 | 44 | @ During the very first milliseconds of execution of an env: 45 | 46 | kernel new_env 47 | | gives cpu to the env 48 | |------------------------------->| 49 | | 50 | sys_set_permission_map() | setup its permission map 51 | |<-------------------------------| 52 | | 53 | | updates the permission map 54 | | of the env. 55 | | 56 | |------------------------------->| continue its normal execution flow 57 | -------------------------------------------------------------------------------- /doc/kernel/gdt_layout: -------------------------------------------------------------------------------- 1 | ** GDT layout ** 2 | 3 | The layout of the GDT of exAmour is as follow: 4 | 5 | GDT: 6 | [GDT_SEG_NULL {0}] = null descriptor 7 | [GDT_SEG_KCODE {1}] = kernel code, read only, 0-4GB 8 | [GDT_SEG_KDATA {2}] = kernel data, read write, 0-4GB 9 | [GDT_SEG_LDT {3}] = local descriptor entry. ring 3. (cpu#0) 10 | [GDT_SEG_TSS {4}] = 32bit TSS entry. (cpu#0) 11 | -------------------------------------------------------------------------------- /doc/kernel/general_thoughts_on_the_architecture: -------------------------------------------------------------------------------- 1 | ** Thoughts on exAmour's architecture ** 2 | 3 | @ The most basic piece, the environment. 4 | In exAmour, everything is part of an environment, even the kernel itself. 5 | An environment is therefore the most important concept to understand how 6 | the system runs. 7 | 8 | Here is a scheme of an environment in order to understand its position in the 9 | system. 10 | 11 | 12 | +-----------------------------------------------+ 13 | | |Environment| | 14 | | +-----------+ | 15 | | +-------+ --> code | 16 | | |Process| --> stack | 17 | | +-------+ --> data | 18 | | | 19 | | +-------------------------------------------+ | 20 | | | |LibOS| | | 21 | | | +-----+ | | 22 | | | +--------------+ +-----------------+ | | 23 | | | |event handlers| |prologue/epilogue| | | 24 | | | +--------------+ +-----------------+ | | 25 | | | | | 26 | | | +-------+ --> code +---------------+ | | 27 | | | |Drivers| --> stack |Threads,mm, ...| | | 28 | | | +-------+ --> data +---------------+ | | 29 | | | | | 30 | | +-------------------------------------------+ | 31 | | | 32 | +-----------------------------------------------+ 33 | 34 | - The kernel, an environment ? 35 | The kernel is an environment but it is somewhat particular. 36 | - The kernel is the env0 means its eid is 0. 37 | - env0 is never scheduled 38 | - env0 runs in both ring0 and ring1 39 | - env0 drivers are hardware drivers (others are software drivers) 40 | - env0 event handlers are used on critical event and sometimes 41 | on an event unhandled by the current env. 42 | 43 | - an env is identified by what we call an eid (eid_t). 44 | An eid is a 32 bits unsigned integer. 45 | 46 | 47 | @ About the multi segmentation 48 | 49 | + Each env has its own ldt 50 | + For every env 51 | - code is in ldt 52 | - the stack is in ldt 53 | - private datas are in ldt 54 | - public (readonly) datas are in the gdt 55 | + For every driver 56 | - code is in gdt 57 | - stack is in ldt (possibly several ldts, one per driver instantiation) 58 | - private datas are in ldt (same as for stack) 59 | - public datas (readonly) are in the gdt 60 | 61 | @ Dynamic code execution 62 | Which segment ? 63 | - a specific code and a stack segments could be allocated to handle it. 64 | They would be in env0's ldt. 65 | PROBLEM: a memcpy for every execution would be too painful from a performances 66 | standpoint and using the env0's ldt avoids use of the running env ldt. 67 | SOLUTIONS: 68 | - static allocation in the gdt 69 | - dynamically promote the dynamically compiled code buffer to a segment 70 | in the gdt or in running env's ldt. 71 | The second solution appears to be the good one. 72 | 73 | @ Syscall arguments 74 | PROBLEM: if the kernel protects the others envs from itself by well bounded ldt's segments 75 | it raises the need of another mechanism to handle syscall parameters. 76 | SOLUTION: (temporary) the kernel ldt's segments cover the whole memory space and syscall 77 | arguments have to be linear memory address. 78 | - (to be explored) use up to two registers to store up to four segment selectors. 79 | It means that the kernel syscalls are limited to 4 arguments. 80 | 81 | TODO: explore the performance/security deal involved with those choices. 82 | -------------------------------------------------------------------------------- /doc/kernel/improvment_idea_with_pagination: -------------------------------------------------------------------------------- 1 | ** Improvment idea with pagination ** 2 | 3 | This idea doesn't aim to improve the velocity and probably not 4 | the security of the system but it should not decrease the security so 5 | maybe it is not so bad. 6 | 7 | The point is to use the multisegmented model as planned and to add the pagination. 8 | The pagination is one 4gb flat address space for every environment so the problem 9 | we currently have with gcc can be delayed. 10 | 11 | Advantages of the pagination : 12 | - easier environment programmation with common compiler 13 | - ease dynamic library management 14 | 15 | Disadvantages of the pagination with multi segmentation : 16 | - slower because the multi segmentation still remains and we have two chain of checks instead of one 17 | - use of several segments (gdt and ldt) harder so one of the advantages of the segmentation 18 | is lost. 19 | 20 | On the other hand, the multisegmentation is kept and the pagination mapping is let to userspace 21 | which let the processor level controls to remove the risk of exploiting overflows. 22 | -------------------------------------------------------------------------------- /doc/kernel/ipc_model: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/kernel/ipc_model -------------------------------------------------------------------------------- /doc/kernel/memory_manager: -------------------------------------------------------------------------------- 1 | ** exAmour's memory manager ** 2 | 3 | On x86, the exAmour's memory manager is split in two parts. 4 | 5 | @ The physical memory manager 6 | This component is in charge of allocating the physical memory blocks. 7 | It is not intented to be used directly. 8 | 9 | @ The Paging and Local descriptor managers 10 | Those components rely on the physical memory manager to service 11 | memory manipulation requests. 12 | They are intented to be used directly. 13 | 14 | Flow diagram 15 | 16 | 0 17 | -|- 18 | / \ Paging or LDT Physical memory 19 | manager manager 20 | 21 | |memory 22 | |allocation----->| 23 | |request |alloc granted, ask the 24 | | |------------------------------->| 25 | | | physical layer for blocks. | 26 | | | | 27 | | | new blocks or false | 28 | | |<-------------------------------| 29 | | request result | 30 | |<---------------| 31 | or false -------------------------------------------------------------------------------- /doc/kernel/paged_memory_model: -------------------------------------------------------------------------------- 1 | ** Paged memory model ** 2 | 3 | The paged memory in exAmour is organized as follow: 4 | 5 | 0x0 3.5gb 4gb 6 | +-----------------------------------------------+-----------------------+ 7 | | userspace | kernelspace | 8 | | | | 9 | | | | 10 | +-----------------------------------------------+-----------------------+ 11 | 12 | Start address of the kernel space is represented by the macro PAGE_OFFSET 13 | and its index in the pde by the macro PAGE_IDX 14 | 15 | For 3.5GB PAGE_OFFSET == 0xe0000000 16 | and PAGE_IDX == 896 17 | 18 | The data mapped at PAGE_OFFSET are the first 4MB of physical memory which means : 19 | 20 | Below 1MB : Bios and bootloader specific data. Among it is the temporary stack of 21 | the bootstrap process. 22 | From 1MB: 23 | - Space for memory managment structures reserved by the bootstrap process. 24 | - The kernel binary image 25 | - The init binary image. 26 | 27 | If you are looking for the bootstrap process binary image, it is typically located 28 | at the beginning of the space reserved for memory managment. (yes once booted he can die) 29 | 30 | 31 | -- 32 | Rémy Saissy 33 | June, 12nd 2006 34 | -------------------------------------------------------------------------------- /doc/kernel/prologue_epilogue_overview: -------------------------------------------------------------------------------- 1 | ** exAmour's prologue/epilogue ** 2 | 3 | The prologue and the epilogue is a way to defer non critical process 4 | context saving and restoring to the userspace. 5 | It is intended to provide a greater efficiency, flexibility and to 6 | speedup the context switch process. 7 | 8 | In exAmour, both the prologue and the epilogue are optionnal. 9 | Indeed, the kernel automatically saves the segment selector registers 10 | and the general purpose registers, therefore, a process which need a 11 | prologue and an epilogue will typically need either to modify the 12 | values the latter or to save/restore other informations. 13 | 14 | It is important to note that during a prologue/epilogue, the env is 15 | executed with its segment selectors and its allocated stack0. 16 | -------------------------------------------------------------------------------- /doc/kernel/segmented_memory_model: -------------------------------------------------------------------------------- 1 | ** exAmour's segmented memory model ** 2 | 3 | exAmour is a kernel which largely relies on the userspace env to 4 | manage the resources. 5 | The memory segments are included and therefore the present document 6 | only expose the forwared kernel information of the segmented model. 7 | 8 | It is important to note that general and readonly kernel informations 9 | are GDT segments (please see gdt_layout for further informations) 10 | while per env informations and write access informations are in the 11 | LDT of each env. 12 | 13 | @ The LDT: 14 | Each env in exAmour has to allocate an LDT, even if the env do not 15 | intend to use segmented memory model. 16 | An LDT is created during _init_memory_map (see env_manager and 17 | first_env_launching) through the sys_ldt_create() syscall. 18 | 19 | By default, the two first entries of the ldt are statically allocated by 20 | the kernel. 21 | - LDT[0] is the ldt itself. 22 | - LDT[1] is the kernel part of the running environnement. 23 | It is actually the env's kernel stack which contains all the 24 | env's kernel mapping. 25 | Both are read only data mapping. 26 | 27 | @ The GDT 28 | Data common to everybody in the system are mapped in the gdt at 29 | GDT_SEG_UEXPORTED index. 30 | Those data are read only mapping and provides every env general purpose 31 | informations about the kernel state and stat, the hardware, the drivers, ... 32 | But no informations about the running envs since our privacy contract is 33 | very strict on this point. 34 | 35 | /* TODO: layout of the UEXPORTED mapping. */ -------------------------------------------------------------------------------- /doc/kernel/syscall_generator: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/kernel/syscall_generator -------------------------------------------------------------------------------- /doc/kernel/syscall_prototypes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/kernel/syscall_prototypes -------------------------------------------------------------------------------- /doc/kernel/timeslice_manager: -------------------------------------------------------------------------------- 1 | ** exAmour's timeslice manager ** 2 | 3 | The timeslice manager is the kernel env's subcomponent responsible 4 | of the environments scheduling. 5 | It is a flexible way that allow exAmour to defer scheduling policies 6 | to userspace on a per env basis. 7 | 8 | @ How to use: 9 | The ability to request a timeslice do not depends on the 10 | env'permission map. 11 | We consider this ability like breathing for humans. 12 | 13 | The timeslice manager userspace API is as follow: 14 | 15 | bool timeslice_add(unsigned int amount); 16 | 17 | where amount is expressed in timer ticks and must evolved 18 | sooner to be expressed in milliseconds. 19 | 20 | At creation time, every env is granted by 100 units. 21 | After, it is up to the env to request by himself for its 22 | timeslices. 23 | 24 | One important thing is that events forwarded to userspace 25 | are timeslices consuming. If no time remains, nothing 26 | will be forwarded. 27 | 28 | 29 | @ Env scheduling flow chart: 30 | 31 | Env Kernel Env's kernel mapping 32 | | 33 | | check the remaining time in its private kernel mapping 34 | |------------------------------------------------------->| 35 | | | 36 | | The total cputime is returned | 37 | |<-------------------------------------------------------| 38 | | 39 | | Too little cpu time remains 40 | | the env requests more through 41 | | sys_timeslice_add() 42 | |------------------------------->| 43 | | | 44 | | The kernel updates the cputime | 45 | | allocated for the env | 46 | |<-------------------------------| 47 | -------------------------------------------------------------------------------- /doc/kernel/user_level_syscall: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/kernel/user_level_syscall -------------------------------------------------------------------------------- /doc/presentations/A_general_overview_of_the_examour_architecture.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/presentations/A_general_overview_of_the_examour_architecture.odt -------------------------------------------------------------------------------- /doc/presentations/C_macro_based_algorithmic_framework.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/presentations/C_macro_based_algorithmic_framework.odt -------------------------------------------------------------------------------- /doc/presentations/an_in_depth_in_a_microkernel_based_libos_on_examour.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/presentations/an_in_depth_in_a_microkernel_based_libos_on_examour.odt -------------------------------------------------------------------------------- /doc/presentations/an_in_depth_in_a_virtualization_server_on_examour.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/presentations/an_in_depth_in_a_virtualization_server_on_examour.odt -------------------------------------------------------------------------------- /doc/presentations/docs_technique_examour: -------------------------------------------------------------------------------- 1 | ** Liste des documentations techniques ** 2 | 3 | [X] ExAmour's C macro based algorithmic framework 4 | [ ] X86 segmented memory support in gcc 5 | [ ] Genesis 6 | [ ] The segment registers patch 7 | [ ] The far addressing patch 8 | [X] A general Overview of the ExAmour's architecture 9 | [X] The ExAmour's memory model 10 | [X] The ExAmour's scheduling model 11 | [X] The ExAmour's I/O model 12 | [ ] Security in the ExAmour's exokernel 13 | [ ] The ExAmour's driver model 14 | [ ] Dynamic library loading in ExAmour 15 | [ ] Shared memory in ExAmour 16 | [ ] An in depth in a microkernel based libOS on ExAmour 17 | [ ] An in depth in a virtualization server on ExAmour 18 | -------------------------------------------------------------------------------- /doc/presentations/dynamic_library_in_examour.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/presentations/dynamic_library_in_examour.odt -------------------------------------------------------------------------------- /doc/presentations/examour.txt: -------------------------------------------------------------------------------- 1 | 2 | ..,,,.. \--= The ExAmour project =--/ 3 | ._\\\?\:<:/;!:S>:<\\.. 4 | ,,v:??)\|<::\\$\::>:-S:$//%%%?\\ 5 | ..$?\\:!>\$??./'?%:.'$::|?:S|/'':|/S-, Pascal BERTRAND 6 | ,&'<-:::,<./?:?'~\|r \^/ '<<.p??///<-&> Franck CHEVALLEREAU 7 | ~?: ?|\\\\::`%.:\: >:./|T/:Z?:S$|? :^<. Thibaud GUERIN 8 | v<&'(:?:\>;^/.::\'\|S:|%\://;/,?S>>Ji?-|.&i' Charles TRON DE BOUCHONY 11 | :/+.<-:!~Z$:/<:-|. ./:\:. .::::-\:<:: 12 | `|\ ::\Z:|.\\?/::\<\:S/||-?|>\:: ,?" 13 | `\? :<:.;.'',?-,'::-::`::.::/: ,>' 14 | :-;+:`:>:+?:\'.\/,:>:-;i|'/:.' 15 | -\:\:-:\?:-:,:\:-??-/->?\> Web: http://www.examour.eu 16 | `\`%%:`|,\%:::\:!-:S:%&:|$]:&%:- 20 | `?\`&$|Z/?P.' 21 | `?\L|R,+ 22 | `,}|\/ 23 | `` 24 | 25 | 26 | -------------------------------------------------------------------------------- /doc/presentations/examour_core.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/presentations/examour_core.odg -------------------------------------------------------------------------------- /doc/presentations/security_in_the_examour_exokernel.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/presentations/security_in_the_examour_exokernel.odt -------------------------------------------------------------------------------- /doc/presentations/shared_memory_in_examour.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/presentations/shared_memory_in_examour.odt -------------------------------------------------------------------------------- /doc/presentations/sketch/intercomponent_interactions.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 20 | 36 | 38 | 39 | 41 | image/svg+xml 42 | 44 | 45 | 46 | 47 | 51 | 58 | ExAmour's symbol table 68 | 75 | Entity 85 | 86 | 87 | -------------------------------------------------------------------------------- /doc/presentations/sketch/symbol_table.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.5-alpha5 2 | Landscape 3 | Center 4 | Metric 5 | A4 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 11 | 1665 1125 2295 1125 2295 1665 1665 1665 1665 1125 12 | 2 4 0 1 0 7 50 -1 -1 0.000 0 0 7 0 0 5 13 | 2295 2475 2295 1890 1665 1890 1665 2475 2295 2475 14 | 4 0 0 50 -1 0 12 0.0000 4 180 2430 3465 450 ExAmour's sckteches symbols\001 15 | 4 0 0 50 -1 0 12 0.0000 4 180 510 2475 1350 Entity\001 16 | 4 0 0 50 -1 0 12 0.0000 4 180 795 2520 2115 Subentity\001 17 | -------------------------------------------------------------------------------- /doc/presentations/sketch/symbol_table.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 12 | 14 | 21 | ExAmour's symbol table 30 | 37 | Entity 46 | 47 | 48 | -------------------------------------------------------------------------------- /doc/presentations/sketch/ukernel_libos_interfaces.txt: -------------------------------------------------------------------------------- 1 | ** ExAmour's uKernel LibOS interfaces ** 2 | 3 | SUMMARY: 4 | - Events classification 5 | - Thread specific distribution 6 | - Global distribution 7 | - Events list 8 | - TM events 9 | - Generated by threads 10 | - Generated by TM 11 | - SM events 12 | - Generated by threads 13 | - Generated by SM 14 | - EM events 15 | - Generated by threads 16 | - Query events 17 | - Message format 18 | 19 | @ Events classification 20 | 21 | - Thread specific distribution 22 | - To the running thread 23 | - Exceptions 24 | 25 | - To non running threads 26 | - Registered event Predicates (for userspace drivers events) 27 | 28 | - Global distribution 29 | - SM events 30 | - TM events 31 | - Interruptions 32 | - User defined events 33 | 34 | During events forwarding, the local computer takes precedence over the network. 35 | Anyway, to be distributed, an event has to be embeded into a network packet event 36 | in order to be handled by the network driver thread. 37 | 38 | @ Events list 39 | - TM events 40 | - Generated by threads 41 | - create_thread 42 | - delete_thread 43 | - yield 44 | - set_revoke_timeslice 45 | - request_timeslice 46 | 47 | - Generated by TM 48 | - revoke_timeslice 49 | 50 | - SM events 51 | - Generated by threads 52 | - create_segment 53 | - delete_segment 54 | - set_revoke_segment 55 | 56 | - Generated by SM 57 | - revoke_segment 58 | 59 | - EM events 60 | - Generated by threads 61 | - want_interrupt 62 | - want_event 63 | - want_exception 64 | - got_interrupt 65 | - got_event 66 | - got_exception 67 | 68 | - Query events 69 | - who_is_there 70 | - i_am_here 71 | - bye_bye 72 | 73 | 74 | @ Message format 75 | Encoding is little endian. 76 | Bit 0-1: Message category 77 | [0] TM 78 | [1] SM 79 | [2] EM 80 | [3] Query 81 | Bit 2-8: Message id: 82 | - TM 83 | [0] create_thread 84 | [1] delete_thread 85 | [2] yield 86 | [3] set_revoke_timeslice 87 | [4] request_timeslice 88 | [5] revoke_timeslice 89 | - SM 90 | [0] create_segment 91 | [1] delete_segment 92 | [2] set_revoke_segment 93 | [3] revoke_segment 94 | - EM 95 | [0] want_interrupt 96 | [1] want_event 97 | [2] want_exception 98 | [3] got_interrupt 99 | [4] got_event 100 | [5] got_exception 101 | [5] create_event 102 | [6] delete_event 103 | [7] forget_event 104 | 105 | TODO: Where are the I/O? How to manage efficiently execption forwarding? 106 | How to create user defined event? 107 | 108 | - Query 109 | [0] who_is_there 110 | [1] i_am_here 111 | [2] bye_bye 112 | TODO: Who can emit Query events? Who can answer to such events? 113 | 114 | -------------------------------------------------------------------------------- /doc/presentations/template.ott: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/presentations/template.ott -------------------------------------------------------------------------------- /doc/presentations/the_examour_driver_model.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/presentations/the_examour_driver_model.odt -------------------------------------------------------------------------------- /doc/presentations/the_examour_io_model.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/presentations/the_examour_io_model.odt -------------------------------------------------------------------------------- /doc/presentations/the_examour_memory_model.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/presentations/the_examour_memory_model.odt -------------------------------------------------------------------------------- /doc/presentations/the_examour_scheduling_model.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/doc/presentations/the_examour_scheduling_model.odt -------------------------------------------------------------------------------- /drivers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(fs) 2 | add_subdirectory(input) 3 | add_subdirectory(mm) 4 | add_subdirectory(rt) 5 | add_subdirectory(video) 6 | -------------------------------------------------------------------------------- /drivers/documentation/doc_pilotes.txt: -------------------------------------------------------------------------------- 1 | Ce document est relatif : 2 | aux pilotes d'ExAmour 3 | 4 | 5 | SOMMAIRE 6 | -------- 7 | 8 | 1) Les 2 types de pilotes d'ExAmour 9 | 10 | 2) Les caracteristiques communes des 2 types de pilotes 11 | 12 | 3) selection de pilote 13 | 14 | 15 | 16 | 17 | 1) LES 2 TYPES DE PILOTES D'EXAMOUR 18 | ----------------------------------- 19 | 20 | Pour des raisons techniques et de securite 2 types de pilotes ont 21 | etes defini pour ExAmour, les pilote logiciels et les pilotes materiels. 22 | La difference principale etant que les pilotes logiciels ne necessite 23 | pas un acces direct au materiel (integre ou peripherique). 24 | 25 | 26 | 2) LES CARACTERISTIQUES COMMUNES DES 2 TYPES DE PILOTES 27 | ------------------------------------------------------- 28 | 29 | On suppose que le noyau fait les tests standard de verification de 30 | securite/permissions d'acces, ... en fonction des authorisations 31 | accordees aux environnements/logiciels/pilotes appelants. 32 | Les pilotes materiels, tout comme les pilotes logiciel, sont 33 | differencies entre eux par une signature a 3 champs : 34 | - taille du 3eme champs (en octets) (permettant de sauter facilement au 35 | prochain pilote dans la liste) 36 | - champ de controle CRC (base sur le binaire) permettant de verifier 37 | l'integrite du pilote, sur 4 octects 38 | - champ d'identification du pilote (chaque otect representant un niveau 39 | de precision, l'octect 0 etant le plus generique). 40 | La valeur des octects du champ d'identification seront numerotees 41 | de 1 a 255 par incrementation de 1 (ex : 1 PCI, 2 ISA, ...) 42 | le 0 etant reserve comme delimiteur/valeur d'erreur. 43 | 44 | La redondance de champs de controle/identification permet de 45 | limiter les problemes de collision de CRC (double verification) 46 | ainsi que les recherches "a l'aveugle" lors de recherche de 47 | fontionalites plutot que d'un pilote precis. 48 | 49 | 50 | Le noyau se charge de generer 2 listes de signatures de pilote 51 | (logiciel/materiel) qu'il connait et peut mettre a disposition des 52 | autres entites du systeme. 53 | Ces listes sont accessibles (en lecture uniquement) par les 54 | logiciels/pilotes/environnements lors du fonctionnement du systeme. 55 | Ces listes seront mises a jour en cas d'ajout/suppression de 56 | pilotes et les entites du systeme le souhaitant seront notifiees de 57 | ces modifications (par interuption/appel systeme, ... point a definir). 58 | 59 | La capacite sera (de)activee par le positionnement d'un indicateur 60 | a la creation de l'entite ou lors du fonctionnement du systeme par 61 | l'intermediaire d'appels systeme (a definir egalement). 62 | 63 | 64 | 65 | 3) SELECTION DE PILOTE 66 | ---------------------- 67 | 68 | Pour selectionner un pilote qu'il souhaite utiliser, un 69 | environnement/processus/librairie recherche dans la liste de signature 70 | de pilote de ce type mise a sa disposition par le noyau lui aura mis a 71 | disposition (par mapage dans une zone en lecture seule de son espace 72 | memoire). 73 | Une fois la selection faite, l'entitee appelante fait appel au pilote. 74 | 75 | Voir : 76 | - Utilisation de pilote materiel (doc_pilotes_materiel.txt) 77 | - Utilisation de pilote logiciel (doc_pilotes_logiciel.txt) 78 | -------------------------------------------------------------------------------- /drivers/documentation/doc_pilotes_logiciel.txt: -------------------------------------------------------------------------------- 1 | Ce document est relatif : 2 | aux pilotes logiciel d'ExAmour 3 | 4 | 5 | SOMMAIRE 6 | -------- 7 | 8 | 1) Caracteristiques 9 | 10 | 2) Methode de classement/differenciation 11 | 12 | 3) Utilisation des pilotes logiciel 13 | 14 | 15 | 16 | 1) CARACTERISTIQUES 17 | ------------------- 18 | 19 | Les pilotes logiciel sont definis par les caracteristiques suivantes : 20 | - ils peuvent etre embarque/assimile a une librairie, chargee ou non au 21 | lancement du programme (si ce n'est pas le cas le programme doit etre 22 | en mesure de la charger). 23 | - ils ne necessitent pas d'acces DIRECT aux fonctionnalites materielles 24 | (ex : lecture sur les disques, envois sur la carte reseau, ...) 25 | 26 | La liste (non exaustive) qui suit represente des types de pilote 27 | classes dans cette categorie : 28 | - protocoles reseau (TCP, ICMP, ...), 29 | - systemes de fichiers (NFTS, FAT, ...), 30 | - gestion de l'affichage (des fenetres, des caracteres, ...) 31 | 32 | 33 | 34 | 35 | 2) METHODE DE CLASSEMENT/DIFFERENCIATION 36 | ---------------------------------------- 37 | 38 | La liste de correspondance : 39 | type de pilote/valeur du champ d'identification 40 | est fournie par le fichier swdrv.h situee dans les sources du noyau. 41 | 42 | La listes des pilotes logiciel charges est cree au fur et a mesure 43 | de l'execution et du chargement de ceux-ci par le noyau. 44 | 45 | 46 | 47 | 3) UTILISATION DES PILOTES LOGICIEL 48 | ----------------------------------- 49 | 50 | Note: on nommera ici EA l'Entitee Appelante 51 | 52 | Lorsque l'EA souhaite utiliser un pilote logiciel, celle-ci 53 | recherche dans la liste des pilotes logiciels charge si l'un d'eux 54 | correspond a ses besoins. 55 | Si aucun correspond l'EA fournit une fonction recuperation, 56 | celle-ci contient les informations du pilote logiciel dont elle 57 | souhaite le chargement. 58 | Ces informations sont en general l'adresse de chargement sur un 59 | peripherique donne. 60 | Cette fonction est executee par le noyau. 61 | Le pilote est alors charge et un droit d'acces est donne a l'EA. 62 | 63 | Le noyau va egalement stoquer la signature du pilote dans la liste des 64 | pilotes charges celui-ci pourra donc etre utilise par d'autres entites 65 | par la suite. 66 | 67 | Une fois le pilote charge dans l'espace accessible par l'EA, celle-ci 68 | fait appel directement aux fonctions du pilote. 69 | 70 | 71 | -------------------------------------------------------------------------------- /drivers/fs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(tgfs) 2 | add_subdirectory(vfat) 3 | -------------------------------------------------------------------------------- /drivers/fs/tgfs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(tgfs) -------------------------------------------------------------------------------- /drivers/fs/tgfs/include/buckets.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** buckets.h for malloc in /u/ept2/malver_l 3 | ** 4 | ** Made by laurent malvert 5 | ** Login 6 | ** 7 | ** Started on Mon Mar 1 18:25:09 2004 laurent malvert 8 | ** Last update Thu May 25 18:29:38 2006 Thibaud_GUERIN 9 | */ 10 | 11 | #ifndef __BUCKETS_H__ 12 | # define __BUCKETS_H__ 13 | 14 | /** 15 | * \brief bucket structure 16 | * \param p block size 17 | * \param next next bucket 18 | */ 19 | typedef struct u_block_descriptor 20 | { 21 | unsigned long p; /* blocksize power of 2 */ 22 | struct u_block_descriptor *next; /* next block pointer */ 23 | } t_block_descriptor; 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /drivers/fs/tgfs/include/malloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** malloc.h for malloc in /u/ept2/malver_l 3 | ** 4 | ** Made by laurent malvert 5 | ** Login 6 | ** 7 | ** Started on Mon Mar 1 10:18:04 2004 laurent malvert 8 | * Last update Sun Feb 4 17:40:51 2007 remy 9 | */ 10 | 11 | #ifndef __MALLOC_H__ 12 | # define __MALLOC_H__ 13 | 14 | #include 15 | #include 16 | 17 | /** 18 | * set the number of buckets (= number of processor's bits) 19 | */ 20 | # define PROC_TYPE 32 21 | # define PROC_TYPE2 (PROC_TYPE - 1) 22 | # define PROC_TYPE3 (PROC_TYPE + 1) 23 | 24 | extern ldt_t my_seg[1]; 25 | #include "buckets.h" 26 | 27 | 28 | t_block_descriptor *get_memory(size_t size); 29 | void *umalloc(size_t size); 30 | void *ucalloc(size_t number, size_t size); 31 | void set_start(/* char *func */); 32 | void *urealloc(void *ptr, size_t size); 33 | void *free_n_malloc(char *cnew, char *cptr); 34 | void *collapse_create(unsigned int power, size_t size); 35 | void ufree(void *ptr); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /drivers/fs/tgfs/include/malloc_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** malloc_init.h for in /home/guth/WORKS/PFE/svn/exAmour/kernel/src/tgfs 3 | ** 4 | ** Made by Thibaud_GUERIN 5 | ** Login 6 | ** 7 | ** Started on Thu May 25 18:24:17 2006 Thibaud_GUERIN 8 | ** Last update Thu May 25 18:25:05 2006 Thibaud_GUERIN 9 | */ 10 | 11 | #ifndef __INIT_H__ 12 | # define __INIT_H__ 13 | 14 | /** 15 | * unused options for now 16 | */ 17 | 18 | /* # define OPT { return (1); } */ 19 | /* # define SET_J { gl_opt[1] = 1; gl_opt[3] = 1; OPT; } */ 20 | /* # define SET_Z { gl_opt[7] = 1; SET_J; } */ 21 | /* # define UNSET_J { gl_opt[1] = 0; gl_opt[3] = 0; OPT; } */ 22 | /* # define UNSET_Z { gl_opt[7] = 0; UNSET_J; } */ 23 | /* # define MALLOC_OPTIONS 19 */ 24 | 25 | 26 | 27 | int setting_options(char *ptr, unsigned int i); 28 | int disabling_options(char *ptr, unsigned int i, int flag); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /drivers/fs/tgfs/include/powers.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** powers.h for malloc in /u/ept2/malver_l 3 | ** 4 | ** Made by laurent malvert 5 | ** Login 6 | ** 7 | ** Started on Tue Mar 2 00:49:51 2004 laurent malvert 8 | ** Last update Thu May 25 18:23:52 2006 Thibaud_GUERIN 9 | */ 10 | 11 | #ifndef __POWERS_H__ 12 | # define __POWERS_H__ 13 | 14 | /** 15 | * macro to count powers of 2 at compile time (save time on exec) 16 | */ 17 | # define P2(x) (gl_powers[(x)][2]) 18 | 19 | void powers_of_two(void); 20 | unsigned int r_p2_power(unsigned long value); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /drivers/fs/tgfs/malloc_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** options.c for malloc in /u/ept2/malver_l 3 | ** 4 | ** Made by laurent malvert 5 | ** Login 6 | ** 7 | ** Started on Tue Mar 2 00:38:39 2004 laurent malvert 8 | * Last update Sun Feb 4 19:21:58 2007 remy 9 | */ 10 | 11 | /* #include */ 12 | /* #include */ 13 | 14 | #include "include/buckets.h" 15 | #include "include/malloc_init.h" 16 | #include "include/malloc.h" 17 | #include "include/powers.h" 18 | #include 19 | 20 | t_block_descriptor *gl_start = NULL; 21 | /* t_block_descriptor gl_start[409600] = {0, }; */ 22 | int gl_start_brk = 0; 23 | extern t_block_descriptor *gl_buckets[PROC_TYPE]; 24 | 25 | extern int base_addr; 26 | 27 | 28 | t_block_descriptor MY_SPACE[40960] = {0, }; 29 | 30 | 31 | 32 | 33 | 34 | t_block_descriptor *get_memory(size_t size) 35 | { 36 | static size_t idx = 0; 37 | 38 | idx += size; 39 | return ((t_block_descriptor *)((gl_start) + idx)); 40 | } 41 | 42 | 43 | void set_start(char *func) 44 | { 45 | if (!gl_start_brk) 46 | { 47 | gl_start_brk = 1; 48 | /* gl_start = (t_block_descriptor *)MY_SPACE; ////////////////// HERE */ 49 | gl_start = MY_SPACE; ////////////////// HERE 50 | powers_of_two(); 51 | memset(gl_buckets, 0, PROC_TYPE); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /drivers/fs/tgfs/powers.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** powers.c for malloc in /u/ept2/malver_l 3 | ** 4 | ** Made by laurent malvert 5 | ** Login 6 | ** 7 | ** Started on Tue Mar 2 00:46:49 2004 laurent malvert 8 | * Last update Sun Feb 4 19:07:56 2007 remy 9 | */ 10 | 11 | #include "include/malloc.h" 12 | #include "include/powers.h" 13 | 14 | unsigned long gl_powers[PROC_TYPE][4] = {0, }; 15 | 16 | 17 | /** 18 | * malloc's helper functions 19 | */ 20 | void powers_of_two(void) 21 | { 22 | /* register unsigned int i; */ 23 | 24 | gl_powers[0][0] = 0; 25 | gl_powers[0][1] = 0; 26 | gl_powers[0][2] = 1; 27 | gl_powers[1][0] = 1; 28 | gl_powers[1][1] = 1; 29 | gl_powers[1][2] = 2; 30 | 31 | /* for (i = PROC_TYPE2; i > 1; i--) */ 32 | /* { */ 33 | /* gl_powers[i][0] = i; */ 34 | /* gl_powers[i][1] = 2 << (i - 2); */ 35 | /* gl_powers[i][2] = 2 << (i - 1); */ 36 | /* } */ 37 | 38 | unsigned int i = PROC_TYPE2; 39 | 40 | for (; i > 1; i--) 41 | { 42 | gl_powers[i][0] = i; 43 | gl_powers[i][1] = 2 << (i - 2); 44 | gl_powers[i][2] = 2 << (i - 1); 45 | } 46 | } 47 | 48 | 49 | 50 | unsigned int r_p2_power(unsigned long value) 51 | { 52 | /* register unsigned int i; */ 53 | 54 | /* for (i = PROC_TYPE2; i > 2; i -= 4) */ 55 | /* { /\* stops at 3 because of struct *\/ */ 56 | /* if ((value > gl_powers[i][1]) && (value <= gl_powers[i][2])) */ 57 | /* return (gl_powers[i][0]); */ 58 | /* if ((value > gl_powers[i - 1][1]) && (value <= gl_powers[i - 1][2])) */ 59 | /* return (gl_powers[i - 1][0]); */ 60 | /* if ((value > gl_powers[i - 2][1]) && (value <= gl_powers[i - 2][2])) */ 61 | /* return (gl_powers[i - 2][0]); */ 62 | /* if ((value > gl_powers[i - 3][1]) && (value <= gl_powers[i - 3][2])) */ 63 | /* return (gl_powers[i - 3][0]); */ 64 | /* } */ 65 | 66 | unsigned int i; 67 | 68 | for (i = PROC_TYPE2; i > 2; i -= 4) 69 | { /* stops at 3 because of struct */ 70 | if ((value > gl_powers[i][1]) && (value <= gl_powers[i][2])) 71 | return (gl_powers[i][0]); 72 | if ((value > gl_powers[i - 1][1]) && (value <= gl_powers[i - 1][2])) 73 | return (gl_powers[i - 1][0]); 74 | if ((value > gl_powers[i - 2][1]) && (value <= gl_powers[i - 2][2])) 75 | return (gl_powers[i - 2][0]); 76 | if ((value > gl_powers[i - 3][1]) && (value <= gl_powers[i - 3][2])) 77 | { 78 | /* printf("%i %i %i\n", gl_powers[i - 3][1], */ 79 | /* gl_powers[i - 3][2], gl_powers[i - 3][0]); */ 80 | /* printf("%i\n", value); */ 81 | return (gl_powers[i - 3][0]); 82 | } 83 | } 84 | return (0); 85 | } 86 | -------------------------------------------------------------------------------- /drivers/fs/vfat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(vfat) -------------------------------------------------------------------------------- /drivers/fs/vfat/fat32.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remysaissy/examour-exokernel/4a2be3da3ff136d00257b99e6dd7c95395d36fcd/drivers/fs/vfat/fat32.c -------------------------------------------------------------------------------- /drivers/input/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(kbd) -------------------------------------------------------------------------------- /drivers/input/kbd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(kbd) -------------------------------------------------------------------------------- /drivers/input/kbd/asm/kbd.S: -------------------------------------------------------------------------------- 1 | /* 2 | ** This file is part of ExAmour 3 | 4 | ** Copyright (C) Remy Saissy 5 | ** ExAmour is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | 10 | ** ExAmour is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include "../kbd.h" 22 | 23 | .text 24 | 25 | .globl kbd_init 26 | kbd_init: 27 | movl $0, kbd_off 28 | movl $0, kbd_usize 29 | movl $1, %ebx 30 | movl %cs, %ecx 31 | movl $kbd_handler, %edx 32 | int $(SYS_base_event_syscalls+SYS_event_register) 33 | ret 34 | 35 | .globl kbd_handler 36 | kbd_handler: 37 | xorl %eax, %eax 38 | movw $0x60, %dx 39 | inb %dx, %al 40 | pushl %eax 41 | call kbd_add_char 42 | addl $4, %esp 43 | lret 44 | 45 | -------------------------------------------------------------------------------- /drivers/input/kbd/kbd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ExAmour 3 | 4 | * Copyright (C) Remy Saissy 5 | * ExAmour is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * ExAmour is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __KBD_H__ 21 | #define __KBD_H__ 22 | 23 | /** 24 | * \brief The size in bytes of the keyboard input buffer. 25 | */ 26 | #define KBD_INPUT_BUFFER_SIZE 255 27 | 28 | #ifndef __ASM__ 29 | 30 | #include 31 | 32 | 33 | typedef struct kbd_map_table_s 34 | { 35 | const char *id; 36 | const char *desc; 37 | const char **locase; 38 | const char **upcase; 39 | 40 | } kbd_map_table_t; 41 | 42 | /** 43 | * \brief Initialize the keyboard driver. 44 | */ 45 | void kbd_init(void); 46 | 47 | 48 | /** 49 | * \brief List available keymaps. 50 | */ 51 | void kbd_list_keymap(void); 52 | 53 | /** 54 | * \param id Id of the the new map table. 55 | * \return 0 on failure, non zero value otherwise. 56 | * \brief Change the translation table. 57 | */ 58 | int kbd_set_kbd_map(const char *id); 59 | 60 | /** 61 | * \param buf Buffer to be filled. 62 | * \param size The size in bytes of the buffer. 63 | * \return Number of bytes filled in buf. 64 | * \brief Get the last size characters typed. 65 | */ 66 | int kbd_read(char *buf, size_t size); 67 | 68 | /* /\** */ 69 | /* * *\param c Character to be added. */ 70 | /* * \brief Add a character in the buffer. */ 71 | /* *\/ */ 72 | /* void kbd_add_char(int c); */ 73 | 74 | #endif /* __ASM__ */ 75 | 76 | #endif /* __KBD_H__ */ 77 | -------------------------------------------------------------------------------- /drivers/mm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(segment) 2 | add_subdirectory(slab) 3 | -------------------------------------------------------------------------------- /drivers/mm/segment/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(segment-mm) 2 | -------------------------------------------------------------------------------- /drivers/mm/segment/asm/segment.S: -------------------------------------------------------------------------------- 1 | /* 2 | ** This file is part of ExAmour 3 | 4 | ** Copyright (C) Remy Saissy 5 | ** ExAmour is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | 10 | ** ExAmour is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | .text 23 | 24 | /* 25 | * 4(%esp) amount 26 | */ 27 | .globl _segmentmm_init 28 | _segmentmm_init: 29 | push %ebx 30 | push %ecx 31 | push %edx 32 | push %esi 33 | xor %ebx,%ebx 34 | mov $(SEGMENT_TYPE_DATA_RW|SEGMENT_PRIV_3|SEGMENT_32BITS),%ecx 35 | mov $(PADDR_ERROR),%edx 36 | mov 20(%esp),%esi 37 | int $(SYS_base_mm_syscalls+SYS_ldt_add_entry) 38 | pop %esi 39 | pop %edx 40 | pop %ecx 41 | pop %ebx 42 | ret 43 | 44 | /* 45 | * 12(%esp) size 46 | * 8(%esp) src 47 | * 4(%esp) dst_sel 48 | */ 49 | .globl _copy_to_buffer 50 | _copy_to_buffer: 51 | /* Save the registers. */ 52 | subl $12, %esp 53 | movl %ecx, 8(%esp) 54 | movl %edi, 4(%esp) 55 | movl %es, %eax 56 | movl %eax, (%esp) 57 | 58 | /* 59 | * 24(%esp) size 60 | * 20(%esp) src 61 | * 16(%esp) dst_sel 62 | */ 63 | 64 | movl 16(%esp), %eax 65 | movl %eax, %es 66 | 67 | /* Reset the buffer. */ 68 | movl 24(%esp), %ecx 69 | shl $1, %ecx 70 | movl 20(%esp), %esi 71 | shl $1, %esi 72 | xorl %edi, %edi 73 | cld 74 | rep 75 | movsl 76 | 77 | /* Restore the registers. */ 78 | movl 8(%esp), %ecx 79 | movl 4(%esp), %edi 80 | movl (%esp), %eax 81 | movl %eax, %es 82 | addl $12, %esp 83 | ret 84 | 85 | 86 | -------------------------------------------------------------------------------- /drivers/mm/segment/segmentmm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ExAmour 3 | 4 | * Copyright (C) Remy Saissy 5 | * ExAmour is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * ExAmour is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __SEGMENTMM_H__ 21 | #define __SEGMENTMM_H__ 22 | 23 | #ifndef __ASM__ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | bool segmentmm_init(size_t amount); 30 | 31 | uint32_t _segmentmm_init(size_t amount); 32 | 33 | void _copy_to_buffer(uint32_t new_data_sel, uint32_t src, size_t size); 34 | 35 | 36 | void *malloc(size_t size); 37 | 38 | void *calloc(size_t nmemb, size_t size); 39 | 40 | void free(void *p); 41 | 42 | char *strdup(const char *s); 43 | 44 | #endif /* __ASM__ */ 45 | 46 | #endif /* __SEGMENT_H__ */ 47 | -------------------------------------------------------------------------------- /drivers/mm/slab/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(slab-mm) 2 | -------------------------------------------------------------------------------- /drivers/mm/slab/README: -------------------------------------------------------------------------------- 1 | ** Slab allocator ** 2 | 3 | This directory contains code for a slab allocator. 4 | Even though this code targets to run in the libOS part 5 | of the ExAmour kernel, it doesn't stick to ExAmour and 6 | can be used in libOS. 7 | 8 | ExAmour's queue.h is used for cache and slabs management. -------------------------------------------------------------------------------- /drivers/mm/slab/slab.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** This file is part of exAmour 3 | 4 | ** Copyright (C) Remy Saissy 5 | ** exAmour is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | 10 | ** exAmour is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /** 21 | * This header contains the declaration of the slab manager for the 22 | * slab allocator's memory manager. 23 | * Without precision, the page size is 4kb. 24 | */ 25 | 26 | 27 | #ifndef __SLAB_H__ 28 | #define __SLAB_H__ 29 | 30 | #ifndef __ASM__ 31 | 32 | #include 33 | #include 34 | #include "slab_types.h" /* can be removed if you already have the types within. */ 35 | 36 | struct free_slab_object_s 37 | { 38 | clist_t object_list; /** list of free objects. */ 39 | 40 | }; 41 | 42 | /** 43 | * A slab. 44 | */ 45 | struct slab_s 46 | { 47 | clist_t slab_list; /** list of slabs. */ 48 | uint32_t free_cnt; /** number of free objects. */ 49 | struct free_slab_object_s *free_obj; /** list of free objects. */ 50 | uint32_t first_obj; /** memory address of the beginning of the slab. */ 51 | /* vaddr_t range; /\** memory range of the slab. *\/ */ 52 | /* void *cache; /\** cache of the slab. *\/ */ 53 | 54 | }; 55 | 56 | #endif /* !__ASM__ */ 57 | 58 | #endif /* __SLAB_H__ */ 59 | 60 | -------------------------------------------------------------------------------- /drivers/mm/slab/slab_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** This file is part of ExAmour 3 | 4 | ** Copyright (C) Remy Saissy 5 | ** ExAmour is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | 10 | ** ExAmour is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __SLAB_TYPES_H__ 21 | #define __SLAB_TYPES_H__ 22 | 23 | /* 24 | * This header is can be removed if your application have already defined 25 | * the types within. 26 | */ 27 | 28 | #ifndef __ASM__ 29 | 30 | #include 31 | 32 | typedef uint32_t vaddr_t; 33 | 34 | #define VADDR_ERROR (int)-1 35 | 36 | #endif /* !__ASM__ */ 37 | 38 | 39 | #endif /* __SLAB_TYPES__ */ 40 | -------------------------------------------------------------------------------- /drivers/rt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(c) -------------------------------------------------------------------------------- /drivers/rt/README: -------------------------------------------------------------------------------- 1 | ** Notes about language specific runtimes ** 2 | 3 | Languages runtime are object files that are expected to be linked against every application 4 | compiled for the ExAmour platform. 5 | A language runtime object file provides a basic set of functionalities that are recognized to be 6 | useful for all applications. 7 | In ExAmour, a language runtime provides the following functionalities in a language specific fashion: 8 | 9 | - syscalls wrappers; 10 | - prologue/epilogue upcall control; 11 | - other upcalls control; 12 | - memory mapped information control functions; 13 | - entry point/exit point functions; 14 | - // TODO others will be added as event and env support will evolve. 15 | 16 | UPDATE: August, 29th 2007. 17 | The rt is no longer needed for C language. Please use libos/libc/klibc/ instead. 18 | -------------------------------------------------------------------------------- /drivers/rt/c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(crt) -------------------------------------------------------------------------------- /drivers/rt/c/asm/start.S: -------------------------------------------------------------------------------- 1 | /* 2 | ** This file is part of ExAmour 3 | 4 | ** Copyright (C) Remy Saissy 5 | ** ExAmour is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | 10 | ** ExAmour is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | .text 21 | 22 | .globl __start 23 | .globl _start 24 | .globl start 25 | __start: 26 | _start: 27 | start: 28 | call main 29 | push $0 30 | call exit 31 | 32 | -------------------------------------------------------------------------------- /drivers/rt/c/env.lds: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of exAmour 3 | 4 | Copyright (C) Remy Saissy 5 | exAmour is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | exAmour is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | OUTPUT_FORMAT("binary") 21 | OUTPUT_ARCH("i386") 22 | ENTRY(_start) 23 | 24 | SECTIONS 25 | { 26 | . = 0; 27 | 28 | .text : 29 | { 30 | start = .; 31 | _start = .; 32 | __start = .; 33 | *(.text*) 34 | etext = .; 35 | } 36 | 37 | 38 | .data SIZEOF(.text) + ADDR(.text) : 39 | { 40 | *(.data*) 41 | edata = .; 42 | } 43 | 44 | 45 | .rodata SIZEOF(.data) + ADDR(.data) : 46 | { 47 | *(.rodata*) 48 | erodata = .; 49 | } 50 | 51 | .bss SIZEOF(.rodata) + ADDR(.rodata) : 52 | { 53 | *(.bss*) 54 | ebss = .; 55 | } 56 | 57 | /DISCARD/ : 58 | { 59 | *(.note*) 60 | *(.indent) 61 | *(.comment) 62 | *(.stab) 63 | *(.stabstr) 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /drivers/video/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(vesa) 2 | add_subdirectory(vga) 3 | -------------------------------------------------------------------------------- /drivers/video/vesa/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(vesa) 2 | -------------------------------------------------------------------------------- /drivers/video/vesa/asm/fb.S: -------------------------------------------------------------------------------- 1 | /* 2 | ** This file is part of ExAmour 3 | 4 | ** Copyright (C) Remy Saissy 5 | ** ExAmour is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | 10 | ** ExAmour is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /** Basic framebuffer driver */ 21 | 22 | #include 23 | 24 | .text 25 | 26 | /* success: eax == 1 */ 27 | /* failure: eax == 0 */ 28 | .globl vesa_init 29 | vesa_init: 30 | pushl %ebx 31 | pushl %ecx 32 | pushl %edx 33 | pushl %esi 34 | movl $0x10000, %esi 35 | movl $0xa0000, %edx 36 | movl $(SEGMENT_TYPE_DATA_RW|SEGMENT_PRIV_3|SEGMENT_32BITS), %ecx 37 | movl $0, %ebx 38 | int $(SYS_base_mm_syscalls+SYS_ldt_add_entry) 39 | 40 | cmpl $-1, %eax 41 | je 1f 42 | 43 | /* Create the selector. */ 44 | shl $3, %eax 45 | orl $7, %eax 46 | movl %eax, vesa_selector 47 | movl $1, %eax 48 | 49 | 1: 50 | popl %esi 51 | popl %edx 52 | popl %ecx 53 | popl %ebx 54 | ret 55 | 56 | .globl vesa_cls 57 | vesa_cls: 58 | pushl %es 59 | pushl %edi 60 | pushl %ecx 61 | 62 | movl vesa_selector, %eax 63 | movl %eax, %es 64 | 65 | xorl %edi, %edi 66 | movl $(640*480), %ecx 67 | shr $2, %ecx 68 | movl $0, %eax 69 | rep stosl 70 | popl %ecx 71 | popl %edi 72 | popl %es 73 | ret 74 | 75 | 76 | /* 77 | * putpixel(int x, int y, int color) 78 | * on the stack we have: 79 | * 12(%esp) -> color 80 | * 8(%esp) -> y 81 | * 4(%esp) -> x 82 | * Colors vary from 0 (black) ... to 255 (white) 83 | */ 84 | .globl vesa_putpixel 85 | vesa_putpixel: 86 | pushl %fs 87 | pushl %edi 88 | 89 | movl vesa_selector, %eax 90 | movl %eax, %fs 91 | 92 | /* 93 | * 20(%esp) -> color 94 | * 16(%esp) -> y 95 | * 12(%esp) -> x 96 | */ 97 | movl 16(%esp), %edi /* setup y. */ 98 | movl $640, %eax 99 | mul %edi 100 | movl %eax, %edi 101 | addl 12(%esp), %edi /* setup x. */ 102 | movl 20(%esp), %eax /* setup the color. */ 103 | movb %al, %fs:(%edi) 104 | 105 | popl %edi 106 | popl %fs 107 | ret 108 | 109 | 110 | .data 111 | vesa_selector: 112 | .long 0 113 | 114 | -------------------------------------------------------------------------------- /drivers/video/vesa/vesa.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ExAmour 3 | 4 | * Copyright (C) Remy Saissy 5 | * ExAmour is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * ExAmour is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __VESA_H__ 21 | #define __VESA_H__ 22 | 23 | #ifndef __ASM__ 24 | 25 | #include 26 | #include 27 | 28 | bool vesa_init(void); 29 | 30 | void vesa_cls(void); 31 | 32 | void vesa_putpixel(uint32_t x, uint32_t y, uint32_t color); 33 | 34 | 35 | #endif /* __ASM__ */ 36 | 37 | #endif /* __VESA_H__ */ 38 | -------------------------------------------------------------------------------- /drivers/video/vga/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(vga) -------------------------------------------------------------------------------- /drivers/video/vga/vga.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ExAmour 3 | 4 | * Copyright (C) Remy Saissy 5 | * ExAmour is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * ExAmour is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __VGA_H__ 21 | #define __VGA_H__ 22 | 23 | #include 24 | 25 | /** 26 | * \brief The number of columns in a terminal. 27 | * \todo Used in the builtin video output driver. Must be removed. 28 | */ 29 | #define COLUMNS 80 30 | 31 | /** 32 | * \brief The number of lines in a terminal. 33 | * \todo Used in the builtin video output driver. Must be removed. 34 | */ 35 | #define ROWS 25 36 | 37 | /** 38 | * \brief Number of space of a tabulation. 39 | */ 40 | #define TABULATION_SIZE 4 41 | 42 | #ifndef __ASM__ 43 | 44 | #include 45 | #include 46 | #include 47 | 48 | typedef struct vga_color_s 49 | { 50 | const char *id; 51 | int value; 52 | 53 | } vga_color_t; 54 | 55 | /** Transforms the argument in string. (call STR(x)) */ 56 | #define _STR(x) #x 57 | /** Transforms the argument in string. */ 58 | #define STR(x) _STR(x) 59 | 60 | /** 61 | * \return true on success, false otherwise. 62 | * \brief Initialize the vga capability. 63 | */ 64 | bool vga_init(void); 65 | 66 | /** 67 | * \param s The string to print 68 | * \return the number of written bytes. 69 | * \brief Prints a given string to the standard output 70 | */ 71 | int puts(const char *s); 72 | 73 | /** 74 | * \param c The character to print 75 | * \return The number of written bytes. 76 | * \brief Prints a given character to the standard output 77 | */ 78 | int putchar(int c); 79 | 80 | /** 81 | * \brief Clear the output 82 | */ 83 | void cls(void); 84 | 85 | /** 86 | * \param n The long value to convert in a string 87 | * \param base_sz The numeric base to use for conversion 88 | * \brief Converts a long value into its string representation 89 | * according to a numeric base 90 | */ 91 | void ltoa(long n, long base_sz); 92 | 93 | /** 94 | * \param n The short value to convert in a string 95 | * \param base_sz The numeric base to use for conversion 96 | * \brief Converts a short value into its string representation 97 | * according to a numeric base 98 | */ 99 | void htoa(short n, long base_sz); 100 | 101 | /** 102 | * \param fmt The format string 103 | * \return The number of bytes written 104 | * \brief Prints on the standard output a string formatted using 105 | * special directives and variable parameter list. 106 | */ 107 | int printf(char *fmt, ...); 108 | 109 | void list_bg_colors(void); 110 | 111 | int set_background_color(char *id); 112 | 113 | void list_fg_colors(void); 114 | 115 | int set_foreground_color(char *id); 116 | 117 | #endif /* !__ASM__ */ 118 | 119 | #endif /* !__VGA_H__ */ 120 | -------------------------------------------------------------------------------- /grub.cfg: -------------------------------------------------------------------------------- 1 | set timeout=15 2 | set default=0 3 | 4 | menuentry "Examour" { 5 | multiboot /boot/kernel.bin 6 | boot 7 | } 8 | 9 | -------------------------------------------------------------------------------- /kernel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(examour) 3 | 4 | # Versioning 5 | set(VERSION_MAJOR "0") 6 | set(VERSION_MINOR "0") 7 | set(VERSION_PATCH "0") 8 | set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) 9 | 10 | include(Common) 11 | 12 | ## Git (and its revision) 13 | find_package(Git QUIET) # if we don't find git or FindGit.cmake is not on the system we ignore it. 14 | ## GetGitRevisionDescription module to retreive branch and revision information from Git 15 | ## Starting with Git 1.9 the module will be part of official cMake distribution, until then it has to be 16 | ## part of the application 17 | ## The Git module will trigger a reconfiguration for each pull that will bring a new revision on the local repository 18 | set (VCS_REVISION "-1") 19 | if(GIT_FOUND) 20 | include(GetGitRevisionDescription) 21 | get_git_head_revision(GIT_REFSPEC GIT_SHA1) 22 | message(STATUS "GIT branch ${GIT_REFSPEC}") 23 | message(STATUS "GIT revision ${GIT_SHA1}") 24 | set (VCS_REVISION ${GIT_SHA1}) 25 | endif() 26 | 27 | set(c_INCLUDE_DIRS 28 | "${CMAKE_SOURCE_DIR}/libs/libc/include" 29 | "${CMAKE_SOURCE_DIR}/libs/libc/include/arch/i386" 30 | "${CMAKE_BINARY_DIR}/libs/libc/include") 31 | 32 | set(c_LIB "${CMAKE_BINARY_DIR}/lib/libc.a") 33 | 34 | set(slds_INCLUDE_DIRS 35 | "${CMAKE_SOURCE_DIR}/libs/libslds/include" 36 | "${CMAKE_BINARY_DIR}/libs/libslds/include") 37 | 38 | set(slds_LIB "${CMAKE_BINARY_DIR}/lib/libslds.a") 39 | 40 | # This sets the include directory for the reference project. This is the -I flag in gcc. 41 | # All the includes should be in this variable To add new directories to the include path, 42 | # just add them in this list (after a space), or add an include_directories statement in a 43 | # subdirectory's CMakeLists. 44 | 45 | include_directories( 46 | ${PROJECT_SOURCE_DIR}/include 47 | ${PROJECT_BINARY_DIR}/include 48 | ${c_INCLUDE_DIRS} 49 | ${slds_INCLUDE_DIRS} 50 | ) 51 | 52 | #enable_testing() 53 | add_subdirectory(include) 54 | add_subdirectory(src) 55 | #add_subdirectory(doc) 56 | #add_subdirectory(test) 57 | -------------------------------------------------------------------------------- /kernel/include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(examour) 2 | -------------------------------------------------------------------------------- /kernel/include/examour/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file("version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version.h" @ONLY) 2 | -------------------------------------------------------------------------------- /kernel/include/examour/version.h.in: -------------------------------------------------------------------------------- 1 | #ifndef @PROJECT_NAME@_VERSION_H 2 | #define @PROJECT_NAME@_VERSION_H 3 | 4 | /* The current major version. */ 5 | #define @PROJECT_NAME@_VERSION_MAJOR @VERSION_MAJOR@ 6 | 7 | /* The current minor version. */ 8 | #define @PROJECT_NAME@_VERSION_MINOR @VERSION_MINOR@ 9 | 10 | /* The current patch level. */ 11 | #define @PROJECT_NAME@_VERSION_PATCH @VERSION_PATCH@ 12 | 13 | /* full version string. */ 14 | #define @PROJECT_NAME@_VERSION_STRING "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@" 15 | 16 | /* The current git revision. */ 17 | #define @PROJECT_NAME@_VCS_REVISION "@VCS_REVISION@" 18 | 19 | /* True if the current version is newer than the given one. */ 20 | #define @PROJECT_NAME@_VERSION_GT(MAJOR, MINOR, PATCH) \ 21 | ((@PROJECT_NAME@_VERSION_MAJOR > MAJOR) || \ 22 | (@PROJECT_NAME@_VERSION_MAJOR == \ 23 | MAJOR&&(@PROJECT_NAME@_VERSION_MINOR > MINOR || (@PROJECT_NAME@_VERSION_MINOR == MINOR&& @PROJECT_NAME@_VERSION_PATCH > PATCH)))) 24 | 25 | /* True if the current version is equal or newer to the given. */ 26 | #define @PROJECT_NAME@_VERSION_GE(MAJOR, MINOR, PATCH) \ 27 | ((@PROJECT_NAME@_VERSION_MAJOR > MAJOR) || \ 28 | (@PROJECT_NAME@_VERSION_MAJOR == \ 29 | MAJOR&&(@PROJECT_NAME@_VERSION_MINOR > MINOR || (@PROJECT_NAME@_VERSION_MINOR == MINOR&& @PROJECT_NAME@_VERSION_PATCH >= PATCH)))) 30 | 31 | /* True if the current version is older than the given one. */ 32 | #define @PROJECT_NAME@_VERSION_LT(MAJOR, MINOR, PATCH) \ 33 | ((@PROJECT_NAME@_VERSION_MAJOR < MAJOR) || \ 34 | (@PROJECT_NAME@_VERSION_MAJOR == \ 35 | MAJOR&&(@PROJECT_NAME@_VERSION_MINOR < MINOR || (@PROJECT_NAME@_VERSION_MINOR == MINOR&& @PROJECT_NAME@_VERSION_PATCH < PATCH)))) 36 | 37 | /* True if the current version is older or equal to the given. */ 38 | #define @PROJECT_NAME@_VERSION_LE(MAJOR, MINOR, PATCH) \ 39 | ((@PROJECT_NAME@_VERSION_MAJOR < MAJOR) || \ 40 | (@PROJECT_NAME@_VERSION_MAJOR == \ 41 | MAJOR&&(@PROJECT_NAME@_VERSION_MINOR < MINOR || (@PROJECT_NAME@_VERSION_MINOR == MINOR&& @PROJECT_NAME@_VERSION_PATCH <= PATCH)))) 42 | 43 | #endif /* @PROJECT_NAME@_VERSION_H */ 44 | 45 | -------------------------------------------------------------------------------- /kernel/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE APP_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/../include/examour/*.h") 2 | set(VERSION_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/../include/examour/version.h") 3 | 4 | file(GLOB_RECURSE APP_SOURCES 5 | "${CMAKE_CURRENT_SOURCE_DIR}/arch/x86_64/asm/*.s" 6 | "${CMAKE_CURRENT_SOURCE_DIR}/arch/x86_64/*.c" 7 | ) 8 | 9 | enable_language(ASM) 10 | set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS "s;S") 11 | set(ASM_OPTIONS "-x assembler-with-cpp -D__ASM__") 12 | set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} ${ASM_OPTIONS}") 13 | set(LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/arch/x86_64/linkmap.lds") 14 | 15 | # Define the application 16 | add_executable(${PROJECT_NAME} ${APP_SOURCES}) 17 | set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m64" LINK_FLAGS "-m64 -T ${LINKER_SCRIPT}") 18 | 19 | target_link_libraries(${PROJECT_NAME} ${c_LIB} ${slds_LIB}) 20 | 21 | # Set the build version. It will be used in the name of the lib, with corresponding 22 | # symlinks created. SOVERSION could also be specified for api version. 23 | set_target_properties(${PROJECT_NAME} PROPERTIES 24 | VERSION ${VERSION} # ${VERSION} was defined in the main CMakeLists. 25 | FRAMEWORK FALSE 26 | PUBLIC_HEADER "${APP_HEADERS} ${VERSION_HEADERS}" # specify the public headers 27 | ) 28 | -------------------------------------------------------------------------------- /kernel/src/arch/x86_64/asm/boot32.s: -------------------------------------------------------------------------------- 1 | /* 2 | ** This file is part of exAmour 3 | 4 | ** Copyright (C) Remy Saissy 5 | ** exAmour is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | 10 | ** exAmour is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | .set ALIGN, 1<<0 /* align loaded modules on page boundaries */ 21 | .set MEMINFO, 1<<1 /* provide memory map */ 22 | .set FLAGS, ALIGN | MEMINFO /* this is the Multiboot 'flag' field */ 23 | .set MAGIC, 0x1BADB002 /* 'magic number' lets bootloader find the header */ 24 | .set CHECKSUM, -(MAGIC + FLAGS) /* checksum of above, to prove we are multiboot */ 25 | 26 | 27 | .section .multiboot 28 | .code32 29 | .align 4 30 | multiboot_header: 31 | .long MAGIC 32 | .long FLAGS 33 | .long CHECKSUM 34 | 35 | .section .text.boot32 36 | .code32 37 | _start32: 38 | /* 32bits to 64 bits mode. */ 39 | jmp _start64 40 | 41 | -------------------------------------------------------------------------------- /kernel/src/arch/x86_64/asm/boot64.s: -------------------------------------------------------------------------------- 1 | /* 2 | ** This file is part of exAmour 3 | 4 | ** Copyright (C) Remy Saissy 5 | ** exAmour is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | 10 | ** exAmour is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | .section .bootstrap_stack, "aw", @nobits 21 | stack_bottom: 22 | .skip 16384 23 | stack_top: 24 | 25 | .section .text 26 | .global _start64 27 | .type _start64, @function 28 | _start64: 29 | movl $stack_top, %esp 30 | call kmain 31 | cli 32 | hlt 33 | hang: 34 | jmp hang 35 | .size _start64, . - _start64 36 | -------------------------------------------------------------------------------- /kernel/src/arch/x86_64/linkmap.lds: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of exAmour 3 | 4 | Copyright (C) Remy Saissy 5 | exAmour is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | exAmour is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | ENTRY(_start32) 21 | 22 | SECTIONS 23 | { 24 | 25 | . = 0x00007E00; /* Conventional memory. End of kernel is at 0x0007FFFF (480kib max). */ 26 | 27 | .boot32 : 28 | { 29 | *(.multiboot) 30 | *(.text.boot32) 31 | } 32 | 33 | .text BLOCK(4K) : ALIGN(4K) 34 | { 35 | *(.text) 36 | } 37 | 38 | .note.gnu.build-id BLOCK(4K) : ALIGN(4K) 39 | { 40 | *(.note.gnu.build-id) 41 | } 42 | 43 | .rodata BLOCK(4K) : ALIGN(4K) 44 | { 45 | *(.rodata) 46 | } 47 | 48 | .data BLOCK(4K) : ALIGN(4K) 49 | { 50 | *(.data) 51 | } 52 | 53 | .bss BLOCK(4K) : ALIGN(4K) 54 | { 55 | *(COMMON) 56 | *(.bss) 57 | *(.bootstrap_stack) 58 | } 59 | 60 | /DISCARD/ : 61 | { 62 | *(".text.inlined*") 63 | *(.comment) 64 | *(.eh_frame) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /launch_vm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Kernel image 4 | KERNEL_IMAGE=root.img 5 | 6 | # Map the partitions from the image file 7 | kpartx -av ${KERNEL_IMAGE} 8 | 9 | # sleep a sec, wait for kpartx to create the device nodes 10 | sleep 1 11 | 12 | # Make the mount-point 13 | mkdir -p tmp/p1 14 | 15 | # Mount the filesystem via loopback 16 | mount /dev/mapper/loop0p1 tmp/p1 17 | 18 | # Copy in the files from the staging directory 19 | cp -fv bin/examour tmp/p1/boot/kernel.bin 20 | 21 | # Unmount the loopback 22 | umount tmp/p1 23 | 24 | # Unmap the image 25 | kpartx -d ${KERNEL_IMAGE} 26 | 27 | qemu-system-i386 -m 32 -hda root.img 28 | -------------------------------------------------------------------------------- /libs/libc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(c) 3 | 4 | # Versioning 5 | set(VERSION_MAJOR "0") 6 | set(VERSION_MINOR "0") 7 | set(VERSION_PATCH "0") 8 | set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) 9 | 10 | include(Common) 11 | 12 | ## Git (and its revision) 13 | find_package(Git QUIET) # if we don't find git or FindGit.cmake is not on the system we ignore it. 14 | ## GetGitRevisionDescription module to retreive branch and revision information from Git 15 | ## Starting with Git 1.9 the module will be part of official cMake distribution, until then it has to be 16 | ## part of the application 17 | ## The Git module will trigger a reconfiguration for each pull that will bring a new revision on the local repository 18 | set (VCS_REVISION "-1") 19 | if(GIT_FOUND) 20 | include(GetGitRevisionDescription) 21 | get_git_head_revision(GIT_REFSPEC GIT_SHA1) 22 | message(STATUS "GIT branch ${GIT_REFSPEC}") 23 | message(STATUS "GIT revision ${GIT_SHA1}") 24 | set (VCS_REVISION ${GIT_SHA1}) 25 | endif() 26 | 27 | # This sets the include directory for the reference project. This is the -I flag in gcc. 28 | # All the includes should be in this variable To add new directories to the include path, 29 | # just add them in this list (after a space), or add an include_directories statement in a 30 | # subdirectory's CMakeLists. 31 | 32 | include_directories( 33 | ${PROJECT_SOURCE_DIR}/include 34 | ${PROJECT_SOURCE_DIR}/include/arch/i386 35 | ${PROJECT_BINARY_DIR}/include # add the binary tree to the search path so that we will find version.h 36 | ) 37 | 38 | #enable_testing() 39 | add_subdirectory(include) 40 | add_subdirectory(src) 41 | #add_subdirectory(doc) 42 | #add_subdirectory(test) 43 | -------------------------------------------------------------------------------- /libs/libc/include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file("version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version.h" @ONLY) -------------------------------------------------------------------------------- /libs/libc/include/arch/x86_64/bits/stdarg.h: -------------------------------------------------------------------------------- 1 | #define va_start(v,l) __builtin_va_start(v,l) 2 | #define va_end(v) __builtin_va_end(v) 3 | #define va_arg(v,l) __builtin_va_arg(v,l) 4 | #define va_copy(d,s) __builtin_va_copy(d,s) 5 | -------------------------------------------------------------------------------- /libs/libc/include/errno.h: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifndef _ERRNO_H 4 | #define _ERRNO_H 5 | 6 | /** 7 | * @file 8 | * 9 | * - Errors. 10 | * 11 | * @see http://libc11.org/errno/ 12 | */ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #define EDOM 1 19 | #define EILSEQ 2 20 | #define ERANGE 3 21 | 22 | extern int errno; 23 | 24 | #ifdef __cplusplus 25 | } /* extern "C" */ 26 | #endif 27 | 28 | #endif /* _ERRNO_H */ 29 | -------------------------------------------------------------------------------- /libs/libc/include/stdarg.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDARG_H 2 | #define _STDARG_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define __NEED_va_list 9 | 10 | #include 11 | 12 | #if __GNUC__ >= 3 13 | #define va_start(v,l) __builtin_va_start(v,l) 14 | #define va_end(v) __builtin_va_end(v) 15 | #define va_arg(v,l) __builtin_va_arg(v,l) 16 | #define va_copy(d,s) __builtin_va_copy(d,s) 17 | #else 18 | #include 19 | #endif 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /libs/libc/include/stdbool.h: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifndef _STDBOOL_H 4 | #define _STDBOOL_H 5 | 6 | /** 7 | * @file 8 | * 9 | * - Boolean type and values. 10 | * 11 | * @see http://libc11.org/stdbool/ 12 | */ 13 | 14 | #ifndef __cplusplus 15 | #define bool _Bool 16 | #define true 1 17 | #define false 0 18 | #endif 19 | 20 | #define __bool_true_false_are_defined 1 21 | 22 | #endif /* _STDBOOL_H */ 23 | -------------------------------------------------------------------------------- /libs/libc/include/stddef.h: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifndef _STDDEF_H 4 | #define _STDDEF_H 5 | 6 | /** 7 | * @file 8 | * 9 | * - C11 7.19: Common definitions. 10 | * 11 | * @see http://libc11.org/stddef/ 12 | */ 13 | 14 | /** 15 | * The signed integer type of the result of subtracting two pointers. 16 | */ 17 | typedef signed long ptrdiff_t; 18 | 19 | /** 20 | * The unsigned integer type of the result of the `sizeof` operator. 21 | */ 22 | typedef unsigned long size_t; 23 | 24 | /** 25 | * An object type whose alignment is as great as is supported by the 26 | * implementation in all contexts. 27 | */ 28 | typedef struct { long long __ll; long double __ld; } max_align_t; 29 | 30 | /** 31 | * An integer type whose range of values can represent distinct codes for 32 | * all members of the largest extended character set specified among the 33 | * supported locales. 34 | */ 35 | typedef int wchar_t; 36 | 37 | /** 38 | * Null pointer constant. 39 | */ 40 | #define NULL ((void*)0) 41 | 42 | /** 43 | * The offset in bytes to the structure member from the beginning of its 44 | * structure. 45 | */ 46 | #define offsetof(type, member) __builtin_offsetof(type, member) 47 | 48 | #endif /* _STDDEF_H */ 49 | -------------------------------------------------------------------------------- /libs/libc/include/string.h: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifndef _STRING_H 4 | #define _STRING_H 5 | 6 | /** 7 | * @file 8 | * 9 | * - String handling. 10 | * 11 | * @see http://libc11.org/string/ 12 | */ 13 | 14 | #include /* for NULL and size_t */ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /** 21 | * C11 7.24.5.1 22 | */ 23 | void* memchr(const void* s, int c, size_t n); 24 | 25 | /** 26 | * C11 7.24.4.1 27 | */ 28 | int memcmp(const void* s1, const void* s2, size_t n); 29 | 30 | /** 31 | * C11 7.24.2.1 32 | */ 33 | void* memcpy(void* restrict s1, const void* restrict s2, size_t n); 34 | 35 | /** 36 | * C11 7.24.2.2 37 | */ 38 | void* memmove(void* s1, const void* s2, size_t n); 39 | 40 | /** 41 | * C11 7.24.6.1 42 | */ 43 | void* memset(void* s, int c, size_t n); 44 | 45 | /** 46 | * C11 7.24.3.1 47 | */ 48 | char* strcat(char* restrict s1, const char* restrict s2); 49 | 50 | /** 51 | * C11 7.24.5.2 52 | */ 53 | char* strchr(const char* s, int c); 54 | 55 | /** 56 | * C11 7.24.4.2 57 | */ 58 | int strcmp(const char* s1, const char* s2); 59 | 60 | /** 61 | * C11 7.24.4.3 62 | */ 63 | int strcoll(const char* s1, const char* s2); 64 | 65 | /** 66 | * C11 7.24.2.3 67 | */ 68 | char* strcpy(char* restrict s1, const char* restrict s2); 69 | 70 | /** 71 | * C11 7.24.5.3 72 | */ 73 | size_t strcspn(const char* s1, const char* s2); 74 | 75 | /** 76 | * C11 7.24.6.2 77 | */ 78 | char* strerror(int errnum); 79 | 80 | /** 81 | * C11 7.24.6.3 82 | */ 83 | size_t strlen(const char* s); 84 | 85 | /** 86 | * C11 7.24.3.2 87 | */ 88 | char* strncat(char* restrict s1, const char* restrict s2, size_t n); 89 | 90 | /** 91 | * C11 7.24.4.4 92 | */ 93 | int strncmp(const char* s1, const char* s2, size_t n); 94 | 95 | /** 96 | * C11 7.24.2.4 97 | */ 98 | char* strncpy(char* restrict s1, const char* restrict s2, size_t n); 99 | 100 | #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809L 101 | /** 102 | * POSIX.1-2008 103 | */ 104 | size_t strnlen(const char* s, size_t maxlen); 105 | #endif 106 | 107 | /** 108 | * C11 7.24.5.4 109 | */ 110 | char* strpbrk(const char* s1, const char* s2); 111 | 112 | /** 113 | * C11 7.24.5.5 114 | */ 115 | char* strrchr(const char* s, int c); 116 | 117 | /** 118 | * C11 7.24.5.6 119 | */ 120 | size_t strspn(const char* s1, const char* s2); 121 | 122 | /** 123 | * C11 7.24.5.7 124 | */ 125 | char* strstr(const char* s1, const char* s2); 126 | 127 | /** 128 | * C11 7.24.5.8 129 | */ 130 | char* strtok(char* restrict s1, const char* restrict s2); 131 | 132 | /** 133 | * C11 7.24.4.5 134 | */ 135 | size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n); 136 | 137 | #ifdef __cplusplus 138 | } /* extern "C" */ 139 | #endif 140 | 141 | #endif /* _STRING_H */ 142 | -------------------------------------------------------------------------------- /libs/libc/include/version.h.in: -------------------------------------------------------------------------------- 1 | #ifndef @PROJECT_NAME@_VERSION_H 2 | #define @PROJECT_NAME@_VERSION_H 3 | 4 | /* The current major version. */ 5 | #define @PROJECT_NAME@_VERSION_MAJOR @VERSION_MAJOR@ 6 | 7 | /* The current minor version. */ 8 | #define @PROJECT_NAME@_VERSION_MINOR @VERSION_MINOR@ 9 | 10 | /* The current patch level. */ 11 | #define @PROJECT_NAME@_VERSION_PATCH @VERSION_PATCH@ 12 | 13 | /* full version string. */ 14 | #define @PROJECT_NAME@_VERSION_STRING "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@" 15 | 16 | /* The current git revision. */ 17 | #define @PROJECT_NAME@_VCS_REVISION "@VCS_REVISION@" 18 | 19 | /* True if the current version is newer than the given one. */ 20 | #define HELLO_VERSION_GT(MAJOR, MINOR, PATCH) \ 21 | ((@PROJECT_NAME@_VERSION_MAJOR > MAJOR) || \ 22 | (@PROJECT_NAME@_VERSION_MAJOR == \ 23 | MAJOR&&(@PROJECT_NAME@_VERSION_MINOR > MINOR || (@PROJECT_NAME@_VERSION_MINOR == MINOR&& @PROJECT_NAME@_VERSION_PATCH > PATCH)))) 24 | 25 | /* True if the current version is equal or newer to the given. */ 26 | #define @PROJECT_NAME@_VERSION_GE(MAJOR, MINOR, PATCH) \ 27 | ((@PROJECT_NAME@_VERSION_MAJOR > MAJOR) || \ 28 | (@PROJECT_NAME@_VERSION_MAJOR == \ 29 | MAJOR&&(@PROJECT_NAME@_VERSION_MINOR > MINOR || (@PROJECT_NAME@_VERSION_MINOR == MINOR&& @PROJECT_NAME@_VERSION_PATCH >= PATCH)))) 30 | 31 | /* True if the current version is older than the given one. */ 32 | #define @PROJECT_NAME@_VERSION_LT(MAJOR, MINOR, PATCH) \ 33 | ((@PROJECT_NAME@_VERSION_MAJOR < MAJOR) || \ 34 | (@PROJECT_NAME@_VERSION_MAJOR == \ 35 | MAJOR&&(@PROJECT_NAME@_VERSION_MINOR < MINOR || (@PROJECT_NAME@_VERSION_MINOR == MINOR&& @PROJECT_NAME@_VERSION_PATCH < PATCH)))) 36 | 37 | /* True if the current version is older or equal to the given. */ 38 | #define @PROJECT_NAME@_VERSION_LE(MAJOR, MINOR, PATCH) \ 39 | ((@PROJECT_NAME@_VERSION_MAJOR < MAJOR) || \ 40 | (@PROJECT_NAME@_VERSION_MAJOR == \ 41 | MAJOR&&(@PROJECT_NAME@_VERSION_MINOR < MINOR || (@PROJECT_NAME@_VERSION_MINOR == MINOR&& @PROJECT_NAME@_VERSION_PATCH <= PATCH)))) 42 | 43 | #endif /* @PROJECT_NAME@_VERSION_H */ 44 | 45 | -------------------------------------------------------------------------------- /libs/libc/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE LIB_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/../include/*.h") 2 | set(VERSION_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/../include/version.h") 3 | 4 | file(GLOB_RECURSE LIB_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../src/*.c") 5 | 6 | # Define the library 7 | add_library(${PROJECT_NAME} STATIC ${LIB_SOURCES}) 8 | set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m64" LINK_FLAGS "-m64") 9 | 10 | # Set the build version. It will be used in the name of the lib, with corresponding 11 | # symlinks created. SOVERSION could also be specified for api version. 12 | set_target_properties(${PROJECT_NAME} PROPERTIES 13 | VERSION ${VERSION} # ${VERSION} was defined in the main CMakeLists. 14 | FRAMEWORK FALSE 15 | PUBLIC_HEADER "${LIB_HEADERS} ${VERSION_HEADERS}" # specify the public headers 16 | ) 17 | -------------------------------------------------------------------------------- /libs/libc/src/string/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libcstring.la 2 | 3 | libcstring_la_SOURCES = \ 4 | memchr.c \ 5 | memcmp.c \ 6 | memcpy.c \ 7 | memmove.c \ 8 | memset.c \ 9 | strcat.c \ 10 | strchr.c \ 11 | strcmp.c \ 12 | strcoll.c \ 13 | strcpy.c \ 14 | strcspn.c \ 15 | strerror.c \ 16 | strlen.c \ 17 | strncat.c \ 18 | strncmp.c \ 19 | strncpy.c \ 20 | strnlen.c \ 21 | strpbrk.c \ 22 | strrchr.c \ 23 | strspn.c \ 24 | strstr.c \ 25 | strtok.c \ 26 | strxfrm.c 27 | -------------------------------------------------------------------------------- /libs/libc/src/string/memchr.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for NULL, size_t, memchr() */ 8 | 9 | /** 10 | * @date 2013-05-24 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/memchr.html 13 | */ 14 | void* 15 | memchr(const void* s, 16 | int c, 17 | size_t n) { 18 | 19 | return (void)s, (void)c, (void)n, NULL; // TODO 20 | } 21 | -------------------------------------------------------------------------------- /libs/libc/src/string/memcmp.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for size_t, memcmp() */ 8 | 9 | /** 10 | * @date 2013-05-24 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/memcmp.html 13 | */ 14 | int 15 | memcmp(const void* const s1, 16 | const void* const s2, 17 | size_t n) { 18 | 19 | const unsigned char* p1 = s1; 20 | const unsigned char* p2 = s2; 21 | 22 | while (n--) { 23 | const int r = *p1++ - *p2++; 24 | if (r) { 25 | return r; 26 | } 27 | } 28 | 29 | return 0; /* s1 is identical to s2 */ 30 | } 31 | -------------------------------------------------------------------------------- /libs/libc/src/string/memcpy.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for NULL, size_t, memcpy() */ 8 | 9 | /** 10 | * @date 2013-05-24 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/memcpy.html 13 | */ 14 | void* 15 | memcpy(void* restrict s1, 16 | const void* restrict s2, 17 | size_t n) { 18 | 19 | return (void)s1, (void)s2, (void)n, NULL; // TODO 20 | } 21 | -------------------------------------------------------------------------------- /libs/libc/src/string/memmove.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for NULL, size_t, memmove() */ 8 | 9 | /** 10 | * @date 2013-05-24 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/memmove.html 13 | */ 14 | void* 15 | memmove(void* s1, 16 | const void* s2, 17 | size_t n) { 18 | 19 | return (void)s1, (void)s2, (void)n, NULL; // TODO 20 | } 21 | -------------------------------------------------------------------------------- /libs/libc/src/string/memset.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for size_t, memset() */ 8 | 9 | /** 10 | * @date 2013-05-24 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/memset.html 13 | */ 14 | void* 15 | memset(void* const s, 16 | const int c, 17 | size_t n) { 18 | 19 | const unsigned char b = (unsigned char)c; 20 | 21 | unsigned char* p = (unsigned char*)s; 22 | while (n--) { 23 | *p++ = b; 24 | } 25 | 26 | return s; 27 | } 28 | -------------------------------------------------------------------------------- /libs/libc/src/string/strcat.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for NULL, strcat() */ 8 | 9 | /** 10 | * @date 2014-11-23 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strcat.html 13 | */ 14 | char* 15 | strcat(char* restrict s1, 16 | const char* restrict s2) { 17 | 18 | return (void)s1, (void)s2, NULL; // TODO 19 | } 20 | -------------------------------------------------------------------------------- /libs/libc/src/string/strchr.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for NULL, strchr() */ 8 | 9 | /** 10 | * @date 2014-11-23 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strchr.html 13 | */ 14 | char* 15 | strchr(const char* s, 16 | const int c) { 17 | 18 | while (*s != '\0' && *s != (char)c) { 19 | s++; 20 | } 21 | 22 | return (*s != '\0' || c == '\0') ? (char*)s : NULL; 23 | } 24 | -------------------------------------------------------------------------------- /libs/libc/src/string/strcmp.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for strcmp() */ 8 | 9 | /** 10 | * @date 2013-05-24 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strcmp.html 13 | */ 14 | int 15 | strcmp(const char* const s1, 16 | const char* const s2) { 17 | 18 | const unsigned char* p1 = (unsigned char*)s1; 19 | const unsigned char* p2 = (unsigned char*)s2; 20 | 21 | while (*p1 != '\0' && *p1 == *p2) { 22 | p1++, p2++; 23 | } 24 | 25 | return *p1 - *p2; 26 | } 27 | -------------------------------------------------------------------------------- /libs/libc/src/string/strcoll.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for strcmp(), strcoll() */ 8 | 9 | /** 10 | * @date 2014-11-23 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strcoll.html 13 | */ 14 | int 15 | strcoll(const char* const s1, 16 | const char* const s2) { 17 | 18 | return strcmp(s1, s2); 19 | } 20 | -------------------------------------------------------------------------------- /libs/libc/src/string/strcpy.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for NULL, strcpy() */ 8 | 9 | /** 10 | * @date 2014-11-23 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strcpy.html 13 | */ 14 | char* 15 | strcpy(char* restrict s1, 16 | const char* restrict s2) { 17 | 18 | return (void)s1, (void)s2, NULL; // TODO 19 | } 20 | -------------------------------------------------------------------------------- /libs/libc/src/string/strcspn.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for NULL, size_t, strchr(), strcspn() */ 8 | 9 | /** 10 | * @date 2014-11-23 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strcspn.html 13 | */ 14 | size_t 15 | strcspn(const char* s1, 16 | const char* const s2) { 17 | 18 | size_t result = 0; 19 | 20 | while (*s1 != '\0' && strchr(s2, *s1) == NULL) { 21 | s1++, result++; 22 | } 23 | 24 | return result; 25 | } 26 | -------------------------------------------------------------------------------- /libs/libc/src/string/strerror.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for E* */ 8 | #include /* for NULL, strerror() */ 9 | 10 | /** 11 | * @date 2014-11-23 12 | * @author Arto Bendiken 13 | * @see http://libc11.org/string/strerror.html 14 | */ 15 | char* 16 | strerror(int errnum) { 17 | switch (errnum) { 18 | case EDOM: return "Numerical argument out of domain"; 19 | case EILSEQ: return "Illegal byte sequence"; 20 | case ERANGE: return "Result too large"; 21 | default: return "Unknown error"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /libs/libc/src/string/strlen.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for size_t, strlen() */ 8 | 9 | /** 10 | * @date 2013-06-11 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strlen.html 13 | */ 14 | size_t 15 | strlen(const char* const s) { 16 | 17 | const char* p = s; 18 | while (*p++ != '\0') { 19 | /* no-op */ 20 | } 21 | return p - s; 22 | } 23 | -------------------------------------------------------------------------------- /libs/libc/src/string/strncat.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for NULL, size_t, strncat() */ 8 | 9 | /** 10 | * @date 2014-11-23 11 | * @author Vlad Gluhovsky 12 | * @see http://libc11.org/string/strncat.html 13 | */ 14 | char* 15 | strncat(char* restrict s1, 16 | const char* restrict s2, 17 | size_t n) { 18 | 19 | size_t i = 0, j = 0; 20 | while (s1[i++]) 21 | ; 22 | 23 | while (j < n && s2[j]) 24 | s1[i++] = s2[j++]; 25 | 26 | s1[i] = 0; 27 | 28 | return s1; 29 | } 30 | -------------------------------------------------------------------------------- /libs/libc/src/string/strncmp.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for size_t, strncmp() */ 8 | 9 | /** 10 | * @date 2013-05-24 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strncmp.html 13 | */ 14 | int 15 | strncmp(const char* const s1, 16 | const char* const s2, 17 | const size_t n) { 18 | 19 | return (void)s1, (void)s2, (void)n, -1; // TODO 20 | } 21 | -------------------------------------------------------------------------------- /libs/libc/src/string/strncpy.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for NULL, size_t, strncpy() */ 8 | 9 | /** 10 | * @date 2014-11-23 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strncpy.html 13 | */ 14 | char* 15 | strncpy(char* restrict s1, 16 | const char* restrict s2, 17 | size_t n) { 18 | 19 | return (void)s1, (void)s2, (void)n, NULL; // TODO 20 | } 21 | -------------------------------------------------------------------------------- /libs/libc/src/string/strnlen.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for size_t, strnlen() */ 8 | 9 | /** 10 | * @date 2013-05-26 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strnlen.html 13 | */ 14 | size_t 15 | strnlen(const char* const s, 16 | const size_t maxlen) { 17 | 18 | return (void)s, (void)maxlen, 0; // TODO 19 | } 20 | -------------------------------------------------------------------------------- /libs/libc/src/string/strpbrk.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for NULL, strchr(), strpbrk() */ 8 | 9 | /** 10 | * @date 2014-11-23 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strpbrk.html 13 | */ 14 | char* 15 | strpbrk(const char* s1, 16 | const char* const s2) { 17 | 18 | while (*s1 != '\0' && strchr(s2, *s1) == NULL) { 19 | s1++; 20 | } 21 | 22 | return (*s1 != '\0') ? (char*)s1 : NULL; 23 | } 24 | -------------------------------------------------------------------------------- /libs/libc/src/string/strrchr.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for NULL, strrchr() */ 8 | 9 | /** 10 | * @date 2014-11-23 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strrchr.html 13 | */ 14 | char* 15 | strrchr(const char* s, 16 | const int c) { 17 | 18 | const char* p = NULL; 19 | 20 | while (*s != '\0') { 21 | if (*s == (char)c) { 22 | p = s; 23 | } 24 | s++; 25 | } 26 | 27 | return (char*)p; 28 | } 29 | -------------------------------------------------------------------------------- /libs/libc/src/string/strspn.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for NULL, size_t, strchr(), strspn() */ 8 | 9 | /** 10 | * @date 2014-11-23 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strspn.html 13 | */ 14 | size_t 15 | strspn(const char* s1, 16 | const char* const s2) { 17 | 18 | size_t result = 0; 19 | 20 | while (*s1 != '\0' && strchr(s2, *s1) != NULL) { 21 | s1++, result++; 22 | } 23 | 24 | return result; 25 | } 26 | -------------------------------------------------------------------------------- /libs/libc/src/string/strstr.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for NULL, strstr() */ 8 | 9 | /** 10 | * @date 2014-11-23 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strstr.html 13 | */ 14 | char* 15 | strstr(const char* s1, 16 | const char* s2) { 17 | 18 | return (void)s1, (void)s2, NULL; // TODO 19 | } 20 | -------------------------------------------------------------------------------- /libs/libc/src/string/strtok.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for NULL, strtok() */ 8 | 9 | /** 10 | * @date 2014-11-23 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strtok.html 13 | */ 14 | char* 15 | strtok(char* restrict s1, 16 | const char* restrict s2) { 17 | 18 | return (void)s1, (void)s2, NULL; // TODO 19 | } 20 | -------------------------------------------------------------------------------- /libs/libc/src/string/strxfrm.c: -------------------------------------------------------------------------------- 1 | /* This is free and unencumbered software released into the public domain. */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | #include /* for size_t, strxfrm() */ 8 | 9 | /** 10 | * @date 2014-11-23 11 | * @author Arto Bendiken 12 | * @see http://libc11.org/string/strxfrm.html 13 | */ 14 | size_t 15 | strxfrm(char* restrict s1, 16 | const char* restrict s2, 17 | size_t n) { 18 | 19 | return (void)s1, (void)s2, (void)n, 0; // TODO 20 | } 21 | -------------------------------------------------------------------------------- /libs/libslds/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(slds) 3 | 4 | # Versioning 5 | set(VERSION_MAJOR "0") 6 | set(VERSION_MINOR "0") 7 | set(VERSION_PATCH "0") 8 | set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) 9 | 10 | include(Common) 11 | 12 | ## Git (and its revision) 13 | find_package(Git QUIET) # if we don't find git or FindGit.cmake is not on the system we ignore it. 14 | ## GetGitRevisionDescription module to retreive branch and revision information from Git 15 | ## Starting with Git 1.9 the module will be part of official cMake distribution, until then it has to be 16 | ## part of the application 17 | ## The Git module will trigger a reconfiguration for each pull that will bring a new revision on the local repository 18 | set (VCS_REVISION "-1") 19 | if(GIT_FOUND) 20 | include(GetGitRevisionDescription) 21 | get_git_head_revision(GIT_REFSPEC GIT_SHA1) 22 | message(STATUS "GIT branch ${GIT_REFSPEC}") 23 | message(STATUS "GIT revision ${GIT_SHA1}") 24 | set (VCS_REVISION ${GIT_SHA1}) 25 | endif() 26 | 27 | set(c_INCLUDE_DIRS 28 | "${CMAKE_SOURCE_DIR}/libs/libc/include" 29 | "${CMAKE_BINARY_DIR}/libs/libc/include") 30 | 31 | # This sets the include directory for the reference project. This is the -I flag in gcc. 32 | # All the includes should be in this variable To add new directories to the include path, 33 | # just add them in this list (after a space), or add an include_directories statement in a 34 | # subdirectory's CMakeLists. 35 | 36 | include_directories( 37 | ${PROJECT_SOURCE_DIR}/include 38 | ${PROJECT_BINARY_DIR}/include # add the binary tree to the search path so that we will find Version.h 39 | ${c_INCLUDE_DIRS} 40 | ) 41 | 42 | #enable_testing() 43 | add_subdirectory(include) 44 | add_subdirectory(src) 45 | #add_subdirectory(doc) 46 | #add_subdirectory(test) 47 | -------------------------------------------------------------------------------- /libs/libslds/include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(libslds) 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file("version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/libslds/version.h" @ONLY) 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libslds 3 | 4 | * Copyright (C) Remy Saissy 5 | * libslds is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * libslds is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __LIBSLDS_COMMON_H__ 21 | #define __LIBSLDS_COMMON_H__ 22 | 23 | /** 24 | * This header contains code common to all kind of data structures in the library. 25 | */ 26 | 27 | #ifndef typeof 28 | #define typeof(x) __typeof__(x) 29 | #endif 30 | 31 | #ifndef offsetof 32 | #define offsetof(tp, member) __builtin_offsetof(tp, member) 33 | #endif 34 | 35 | 36 | /* Data structures macros. */ 37 | 38 | #ifdef GET_FIELD 39 | #undef GET_FIELD 40 | #endif 41 | /** 42 | * Get a field of a data structure. The field is expressed by the member name. 43 | */ 44 | #define GET_FIELD(st, m, t) ((t *)(((char *)(st)) + (m))) 45 | 46 | #endif /* __LIBSLDS_COMMON_H__ */ 47 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libslds 3 | 4 | * Copyright (C) Remy Saissy 5 | * libslds is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * libslds is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __LIBSLDS_TREE_H__ 21 | #define __LIBSLDS_TREE_H__ 22 | 23 | /* This is the generic header for trees. */ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "common.h" 30 | 31 | #include "tree/binary/bst_tree.h" 32 | #include "tree/binary/ebst_tree.h" 33 | #include "tree/binary/splay_tree.h" 34 | #include "tree/binary/redblack_tree.h" 35 | 36 | #include "tree/nary/common.h" 37 | #include "tree/nary/nary_tree.h" 38 | 39 | #endif /* __LIBSLDS_TREE_H__ */ 40 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/binary/aa_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements AA-trees. http://en.wikipedia.org/wiki/AA_tree 2 | #ifndef AATREE_H_ 3 | #define AATREE_H_ 4 | 5 | #endif /*AATREE_H_*/ 6 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/binary/dsw_algorihm.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the DSW algorithm. Useful for balancing binary trees. http://en.wikipedia.org/wiki/DSW_algorithm 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/binary/kd_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the kd-tree. http://en.wikipedia.org/wiki/Kd-tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/binary/left_child_right_sibling_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the left child right sibling tree. http://en.wikipedia.org/wiki/Left_child-right_sibling_binary_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/binary/radix_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the radix tree. http://en.wikipedia.org/wiki/Radix_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/binary/randomized_btree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the randomized btree. http://en.wikipedia.org/wiki/Randomized_binary_search_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/binary/scapegoat_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the scapegoat tree. http://en.wikipedia.org/wiki/Scapegoat_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/binary/t_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements t-tree. http://en.wikipedia.org/wiki/T-tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/binary/threaded_btree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements threaded binary trees. http://en.wikipedia.org/wiki/Threaded_binary_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/binary/treap.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the treap tree. http://en.wikipedia.org/wiki/Treap 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/binary/weight_balanced_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the weight balanced tree. http://en.wikipedia.org/wiki/Weight-balanced_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/234_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements 2-3-4 tree. http://en.wikipedia.org/wiki/2-3-4_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/23_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements 23trees. http://en.wikipedia.org/wiki/2-3_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/ab_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements (a,b) tree. http://en.wikipedia.org/wiki/(a%2Cb)_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/b_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: Implement B-trees. http://en.wikipedia.org/wiki/B-tree 2 | 3 | #ifndef BTREE_H_ 4 | #define BTREE_H_ 5 | 6 | #endif /*BTREE_H_*/ 7 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/bplus_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements b+ trees. http://en.wikipedia.org/wiki/B%2B_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/bsharp_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements a b# tree. http://en.wikipedia.org/wiki/B_sharp_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/bstar_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements b* trees. http://en.wikipedia.org/wiki/B*-tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libslds 3 | 4 | * Copyright (C) Remy Saissy 5 | * libslds is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * libslds is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __LIBSLDS_TREE_H__ 21 | #error "Direct inclusion not allowed. Please include tree.h instead." 22 | #endif 23 | 24 | #ifndef __LIBSLDS_NARY_TREE_COMMON_H__ 25 | #define __LIBSLDS_NARY_TREE_COMMON_H__ 26 | 27 | /* 28 | * This header provides code common to all nary trees. 29 | */ 30 | 31 | /* Data type. */ 32 | 33 | /* Methods */ 34 | 35 | 36 | #endif /* __LIBSLDS_NARY_TREE_COMMON_H__ */ 37 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/fusion_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the fusion tree. http://en.wikipedia.org/wiki/Fusion_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/gist_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the gist tree. http://en.wikipedia.org/wiki/GiST 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/hilbert_rtree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the Hilbert r-tree. http://en.wikipedia.org/wiki/Hilbert_R-tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/oc_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the octree. http://en.wikipedia.org/wiki/Octree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/quad_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements te quad tree. http://en.wikipedia.org/wiki/Quadtree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/r_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements r-tree. http://en.wikipedia.org/wiki/R-tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/rplus_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the R+ tree. http://en.wikipedia.org/wiki/R%2B_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/rstar_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements a R* tree. http://en.wikipedia.org/wiki/R*_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/ternary_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the ternary tree. http://en.wikipedia.org/wiki/Ternary_search_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/top_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements a top tree. http://en.wikipedia.org/wiki/Top_Trees 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/tpyramid_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements a t-pyramid tree. http://en.wikipedia.org/wiki/Randomized_binary_search_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/trie_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements a trie tree. http://en.wikipedia.org/wiki/Trie 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/tree/nary/ub_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements ub trees. http://en.wikipedia.org/wiki/UB-tree 2 | -------------------------------------------------------------------------------- /libs/libslds/include/libslds/version.h.in: -------------------------------------------------------------------------------- 1 | #ifndef @PROJECT_NAME@_VERSION_H 2 | #define @PROJECT_NAME@_VERSION_H 3 | 4 | /* The current major version. */ 5 | #define @PROJECT_NAME@_VERSION_MAJOR @VERSION_MAJOR@ 6 | 7 | /* The current minor version. */ 8 | #define @PROJECT_NAME@_VERSION_MINOR @VERSION_MINOR@ 9 | 10 | /* The current patch level. */ 11 | #define @PROJECT_NAME@_VERSION_PATCH @VERSION_PATCH@ 12 | 13 | /* full version string. */ 14 | #define @PROJECT_NAME@_VERSION_STRING "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@" 15 | 16 | /* The current git revision. */ 17 | #define @PROJECT_NAME@_VCS_REVISION "@VCS_REVISION@" 18 | 19 | /* True if the current version is newer than the given one. */ 20 | #define HELLO_VERSION_GT(MAJOR, MINOR, PATCH) \ 21 | ((@PROJECT_NAME@_VERSION_MAJOR > MAJOR) || \ 22 | (@PROJECT_NAME@_VERSION_MAJOR == \ 23 | MAJOR&&(@PROJECT_NAME@_VERSION_MINOR > MINOR || (@PROJECT_NAME@_VERSION_MINOR == MINOR&& @PROJECT_NAME@_VERSION_PATCH > PATCH)))) 24 | 25 | /* True if the current version is equal or newer to the given. */ 26 | #define @PROJECT_NAME@_VERSION_GE(MAJOR, MINOR, PATCH) \ 27 | ((@PROJECT_NAME@_VERSION_MAJOR > MAJOR) || \ 28 | (@PROJECT_NAME@_VERSION_MAJOR == \ 29 | MAJOR&&(@PROJECT_NAME@_VERSION_MINOR > MINOR || (@PROJECT_NAME@_VERSION_MINOR == MINOR&& @PROJECT_NAME@_VERSION_PATCH >= PATCH)))) 30 | 31 | /* True if the current version is older than the given one. */ 32 | #define @PROJECT_NAME@_VERSION_LT(MAJOR, MINOR, PATCH) \ 33 | ((@PROJECT_NAME@_VERSION_MAJOR < MAJOR) || \ 34 | (@PROJECT_NAME@_VERSION_MAJOR == \ 35 | MAJOR&&(@PROJECT_NAME@_VERSION_MINOR < MINOR || (@PROJECT_NAME@_VERSION_MINOR == MINOR&& @PROJECT_NAME@_VERSION_PATCH < PATCH)))) 36 | 37 | /* True if the current version is older or equal to the given. */ 38 | #define @PROJECT_NAME@_VERSION_LE(MAJOR, MINOR, PATCH) \ 39 | ((@PROJECT_NAME@_VERSION_MAJOR < MAJOR) || \ 40 | (@PROJECT_NAME@_VERSION_MAJOR == \ 41 | MAJOR&&(@PROJECT_NAME@_VERSION_MINOR < MINOR || (@PROJECT_NAME@_VERSION_MINOR == MINOR&& @PROJECT_NAME@_VERSION_PATCH <= PATCH)))) 42 | 43 | #endif /* @PROJECT_NAME@_VERSION_H */ 44 | 45 | -------------------------------------------------------------------------------- /libs/libslds/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE LIB_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/../include/*.h") 2 | set(VERSION_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/../include/version.h") 3 | 4 | file(GLOB_RECURSE LIB_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../src/*.c") 5 | 6 | # Define the library 7 | add_library(${PROJECT_NAME} STATIC ${LIB_SOURCES}) 8 | set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m64" LINK_FLAGS "-m64") 9 | 10 | # Set the build version. It will be used in the name of the lib, with corresponding 11 | # symlinks created. SOVERSION could also be specified for api version. 12 | set_target_properties(${PROJECT_NAME} PROPERTIES 13 | VERSION ${VERSION} # ${VERSION} was defined in the main CMakeLists. 14 | FRAMEWORK FALSE 15 | PUBLIC_HEADER "${LIB_HEADERS} ${VERSION_HEADERS}" # specify the public headers 16 | ) 17 | -------------------------------------------------------------------------------- /libs/libslds/src/hash/hash.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libslds 3 | 4 | * Copyright (C) Remy Saissy 5 | * libslds is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * libslds is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | /* Hashtable implementation. */ 23 | 24 | bool _hashtable_init(void **hash, unsigned int n) 25 | { 26 | unsigned int it; 27 | 28 | if (hash && n > 0) 29 | { 30 | for (it = 0; it < n; it++) 31 | hash[it] = 0; 32 | return (true); 33 | } 34 | return (false); 35 | } 36 | 37 | bool _hashtable_insert(void **hash, 38 | void *key, 39 | void *content, 40 | unsigned int m, 41 | hashing_function_p hash_func) 42 | { 43 | uint64_t hki; 44 | 45 | if (!hash || !key || !content || !hash_func) 46 | return (false); 47 | hki = hash_func(key); 48 | _slist_add_head(hash + hki, content, m); 49 | return (true); 50 | } 51 | 52 | void *_hashtable_lookup(void **hash, 53 | void *key, 54 | unsigned int m, 55 | hashing_function_p hash_func, 56 | hashing_compare_p hash_comp) 57 | { 58 | uint64_t hki; 59 | void *it; 60 | 61 | if (!hash || !key || !hash_func || !hash_comp) 62 | return (NULL); 63 | hki = hash_func(key); 64 | it = hash[hki]; 65 | while (it) 66 | { 67 | if ((hash_comp(key, it)) == 0) 68 | break; 69 | it = GET_FIELD(it, m, hashtable_t)->next; 70 | } 71 | return (it); 72 | } 73 | 74 | bool _hashtable_remove(void **hash, 75 | void *key, 76 | void *entry, 77 | unsigned int m, 78 | hashing_function_p hash_func) 79 | { 80 | uint64_t hki; 81 | void *prev_it; 82 | void *it; 83 | 84 | if (!hash || !key || !entry || !hash_func) 85 | return (false); 86 | hki = hash_func(key); 87 | prev_it = NULL; 88 | it = hash[hki]; 89 | while (it) 90 | { 91 | if (it == entry) 92 | { 93 | _slist_fast_remove(hash + hki, prev_it, entry, m); 94 | return (true); 95 | } 96 | prev_it = it; 97 | it = GET_FIELD(it, m, hashtable_t)->next; 98 | } 99 | return (false); 100 | } 101 | -------------------------------------------------------------------------------- /libs/libslds/src/hash/string_hashing.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libslds 3 | 4 | * Copyright (C) Remy Saissy 5 | * libslds is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * libslds is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | /** 23 | * String hashing function implementations. 24 | * Source: http://www.cse.yorku.ca/~oz/hash.html 25 | */ 26 | 27 | uint64_t hashing_string_djb2(void *key) 28 | { 29 | char *s; 30 | int c; 31 | uint64_t hash; 32 | 33 | s = (char *)key; 34 | hash = 5381; 35 | while ((c = *s++) && *s) 36 | hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ 37 | return (hash); 38 | } 39 | 40 | uint64_t hashing_string_sdbm(void *key) 41 | { 42 | char *s; 43 | int c; 44 | uint64_t hash; 45 | 46 | s = (char *)key; 47 | hash = 0; 48 | while ((c = *s++) & *s) 49 | hash = c + (hash << 6) + (hash << 16) - hash; 50 | return (hash); 51 | } 52 | 53 | uint64_t hashing_string_lose_lose(void *key) 54 | { 55 | char *s; 56 | int c; 57 | uint64_t hash; 58 | 59 | s = (char *)key; 60 | hash = 0; 61 | while ((c = *s++) & *s) 62 | hash += c; 63 | return (hash); 64 | } 65 | -------------------------------------------------------------------------------- /libs/libslds/src/list/clist.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libslds 3 | 4 | * Copyright (C) Remy Saissy 5 | * libslds is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * libslds is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | /* Circular linked list implementation. */ 23 | 24 | void _clist_init(void *clist, unsigned int m) 25 | { 26 | if (clist) 27 | { 28 | GET_FIELD(clist, m, clist_t)->prev = clist; 29 | GET_FIELD(clist, m, clist_t)->next = clist; 30 | } 31 | } 32 | 33 | void _clist_add_after(void **clist, void *new, unsigned int m) 34 | { 35 | if (!clist || !new) 36 | return; 37 | if (*clist) 38 | { 39 | GET_FIELD(new, m,clist_t)->next = GET_FIELD(*clist, m, clist_t)->next; 40 | GET_FIELD(new, m, clist_t)->prev = *clist; 41 | GET_FIELD(GET_FIELD(*clist, m, clist_t)->next, m, clist_t)->prev = new; 42 | GET_FIELD(*clist, m, clist_t)->next = new; 43 | } 44 | else 45 | { 46 | GET_FIELD(new, m, clist_t)->next = new; 47 | GET_FIELD(new, m, clist_t)->prev = new; 48 | *clist = new; 49 | } 50 | } 51 | 52 | void _clist_add_before(void **clist, void *new, unsigned int m) 53 | { 54 | if (!clist || !new) 55 | return; 56 | if (*clist) 57 | { 58 | GET_FIELD(new, m, clist_t)->prev = GET_FIELD(*clist, m, clist_t)->prev; 59 | GET_FIELD(new, m, clist_t)->next = *clist; 60 | GET_FIELD(GET_FIELD(*clist, m, clist_t)->prev, m, clist_t)->next = new; 61 | GET_FIELD(*clist, m, clist_t)->prev = new; 62 | } 63 | else 64 | { 65 | GET_FIELD(new, m, clist_t)->next = new; 66 | GET_FIELD(new, m, clist_t)->prev = new; 67 | *clist = new; 68 | } 69 | } 70 | 71 | void _clist_remove(void **clist, void *elem, unsigned int m) 72 | { 73 | if (!clist || !elem) 74 | return; 75 | if (*clist) 76 | { 77 | if (GET_FIELD(*clist, m, clist_t)->prev != *clist) 78 | { 79 | GET_FIELD(GET_FIELD(elem, m, clist_t)->next, m, clist_t)->prev = 80 | GET_FIELD(elem, m, clist_t)->prev; 81 | GET_FIELD(GET_FIELD(elem, m, clist_t)->prev, m, clist_t)->next = 82 | GET_FIELD(elem, m, clist_t)->next; 83 | if (*clist == elem) 84 | *clist = GET_FIELD(*clist, m, clist_t)->next; 85 | } 86 | else 87 | *clist = 0; 88 | } 89 | } 90 | 91 | 92 | /* queue implementation. */ 93 | 94 | void *_queue_remove(void **queue, unsigned int m) 95 | { 96 | void *ret; 97 | 98 | if (!queue) 99 | return (0); 100 | ret = 0; 101 | if (*queue) 102 | { 103 | ret = *queue; 104 | _clist_remove(queue, ret, m); 105 | } 106 | return (ret); 107 | } 108 | -------------------------------------------------------------------------------- /libs/libslds/src/list/slist.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libslds 3 | 4 | * Copyright (C) Remy Saissy 5 | * libslds is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * libslds is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | /* Single linked list implementation. */ 23 | 24 | void _slist_init(void *head, 25 | unsigned int m) 26 | { 27 | if (head) 28 | GET_FIELD(head, m, slist_t)->next = 0; 29 | } 30 | 31 | void _slist_add_head(void **head, 32 | void *new, 33 | unsigned int m) 34 | { 35 | if (head && new) 36 | { 37 | GET_FIELD(new, m, slist_t)->next = *head; 38 | *head = new; 39 | } 40 | } 41 | 42 | void _slist_add_after(void **head, 43 | void *slist, 44 | void *new, 45 | unsigned int m) 46 | { 47 | if (!head || !new) 48 | return; 49 | if (slist) 50 | { 51 | GET_FIELD(new, m, slist_t)->next = GET_FIELD(slist, m, slist_t)->next; 52 | GET_FIELD(slist, m, slist_t)->next = new; 53 | } 54 | else 55 | { 56 | if (*head) 57 | { 58 | GET_FIELD(new, m, slist_t)->next = 59 | GET_FIELD(*head, m, slist_t)->next; 60 | GET_FIELD(*head, m, slist_t)->next = new; 61 | } 62 | else 63 | { 64 | GET_FIELD(new, m, slist_t)->next = 0; 65 | *head = new; 66 | } 67 | } 68 | } 69 | 70 | void _slist_remove(void **head, 71 | void *slist, 72 | unsigned int m) 73 | { 74 | if (!head || !slist) 75 | return; 76 | if (*head && slist) 77 | { 78 | if (slist == *head) 79 | *head = GET_FIELD(slist, m, slist_t)->next; 80 | else 81 | { 82 | while (*head && GET_FIELD(*head, m, slist_t)->next != slist) 83 | *head = GET_FIELD(*head, m, slist_t)->next; 84 | GET_FIELD(*head, m, slist_t)->next = 85 | GET_FIELD(slist, m, slist_t)->next; 86 | GET_FIELD(slist, m, slist_t)->next = 0; 87 | } 88 | } 89 | } 90 | 91 | void _slist_fast_remove(void **head, 92 | void *pslist, 93 | void *slist, 94 | unsigned int m) 95 | { 96 | if (!head || !slist) 97 | return; 98 | if (!pslist || GET_FIELD(pslist, m, slist_t)->next != slist) 99 | _slist_remove(head, slist, m); 100 | else 101 | { 102 | if (*head && slist) 103 | { 104 | if (slist == *head) 105 | *head = GET_FIELD(slist, m, slist_t)->next; 106 | else 107 | { 108 | GET_FIELD(pslist, m, slist_t)->next = 109 | GET_FIELD(slist, m, slist_t)->next; 110 | GET_FIELD(slist, m, slist_t)->next = 0; 111 | } 112 | } 113 | } 114 | } 115 | 116 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/binary/aa_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements AA-trees. http://en.wikipedia.org/wiki/AA_tree 2 | #ifndef AATREE_H_ 3 | #define AATREE_H_ 4 | 5 | #endif /*AATREE_H_*/ 6 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/binary/avl_rotation.c: -------------------------------------------------------------------------------- 1 | /* 2 | * avl_rotation.c 3 | * 4 | * Created on: 5 déc. 2008 5 | * Author: remy 6 | */ 7 | 8 | #include 9 | #include "include/avl_rotation.h" 10 | 11 | //Let Q be P's right child. 12 | //Set Q to be the new root. 13 | //Set P's right child to be Q's left child. 14 | //Set Q's left child to be P. 15 | 16 | void *avl_single_rotate_with_left(void *node, 17 | unsigned int m) 18 | { 19 | void *tmp; 20 | 21 | tmp = GET_FIELD(node, m, bst_tree_t)->right; 22 | GET_FIELD(node, m, bst_tree_t)->right = GET_FIELD(tmp, m, bst_tree_t)->left; 23 | GET_FIELD(tmp, m, bst_tree_t)->left = node; 24 | return (tmp); 25 | } 26 | 27 | void *avl_single_rotate_with_right(void *node, 28 | unsigned int m) 29 | { 30 | void *tmp; 31 | 32 | tmp = GET_FIELD(node, m, bst_tree_t)->left; 33 | GET_FIELD(node, m, bst_tree_t)->left = GET_FIELD(tmp, m, bst_tree_t)->right; 34 | GET_FIELD(tmp, m, bst_tree_t)->right = node; 35 | return (tmp); 36 | } 37 | 38 | 39 | void *avl_parent_rotate_with_left(void *node, 40 | unsigned int m) 41 | { 42 | void *tmp; 43 | void *parent; 44 | 45 | tmp = GET_FIELD(node, m, ebst_tree_t)->right; 46 | GET_FIELD(node, m, ebst_tree_t)->right = GET_FIELD(tmp, m, ebst_tree_t)->left; 47 | if (GET_FIELD(tmp, m, ebst_tree_t)->left != NULL) 48 | GET_FIELD(GET_FIELD(tmp, m, ebst_tree_t)->left, m, ebst_tree_t)->parent = node; 49 | GET_FIELD(tmp, m, ebst_tree_t)->left = node; 50 | parent = GET_FIELD(node, m, ebst_tree_t)->parent; 51 | GET_FIELD(node, m, ebst_tree_t)->parent = tmp; 52 | if (parent != NULL) 53 | { 54 | if (node == GET_FIELD(parent, m, ebst_tree_t)->left) 55 | { 56 | GET_FIELD(parent, m, ebst_tree_t)->left = tmp; 57 | } 58 | else 59 | { 60 | GET_FIELD(parent, m, ebst_tree_t)->right = tmp; 61 | } 62 | } 63 | GET_FIELD(tmp, m, ebst_tree_t)->parent = parent; 64 | return (tmp); 65 | } 66 | 67 | void *avl_parent_rotate_with_right(void *node, 68 | unsigned int m) 69 | { 70 | void *tmp; 71 | void *parent; 72 | 73 | tmp = GET_FIELD(node, m, ebst_tree_t)->left; 74 | GET_FIELD(node, m, ebst_tree_t)->left = GET_FIELD(tmp, m, ebst_tree_t)->right; 75 | if (GET_FIELD(tmp, m, ebst_tree_t)->right != NULL) 76 | GET_FIELD(GET_FIELD(tmp, m, ebst_tree_t)->right, m, ebst_tree_t)->parent = node; 77 | GET_FIELD(tmp, m, ebst_tree_t)->right = node; 78 | parent = GET_FIELD(node, m, ebst_tree_t)->parent; 79 | GET_FIELD(node, m, ebst_tree_t)->parent = tmp; 80 | if (parent != NULL) 81 | { 82 | if (node == GET_FIELD(parent, m, ebst_tree_t)->left) 83 | { 84 | GET_FIELD(parent, m, ebst_tree_t)->left = tmp; 85 | } 86 | else 87 | { 88 | GET_FIELD(parent, m, ebst_tree_t)->right = tmp; 89 | } 90 | } 91 | GET_FIELD(tmp, m, ebst_tree_t)->parent = parent; 92 | return (tmp); 93 | } 94 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/binary/include/avl_rotation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avl_rotation.h 3 | * 4 | * Created on: 5 déc. 2008 5 | * Author: remy 6 | */ 7 | 8 | #ifndef AVL_ROTATION_H_ 9 | #define AVL_ROTATION_H_ 10 | 11 | /** 12 | * This header contains declaration for avl rotations in the libslds. 13 | */ 14 | 15 | void *avl_single_rotate_with_left(void *node, 16 | unsigned int m); 17 | 18 | void *avl_single_rotate_with_right(void *node, 19 | unsigned int m); 20 | 21 | 22 | void *avl_parent_rotate_with_left(void *node, 23 | unsigned int m); 24 | 25 | void *avl_parent_rotate_with_right(void *node, 26 | unsigned int m); 27 | 28 | 29 | 30 | #endif /* AVL_ROTATION_H_ */ 31 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/binary/include/dsw_algor.cm.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements the DSW algorithm. Useful for balancing binary trees. http://en.wikipedia.org/wiki/DSW_algorithm 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/binary/kd_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements the kd-tree. http://en.wikipedia.org/wiki/Kd-tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/binary/left_child_right_sibling_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements the left child right sibling tree. http://en.wikipedia.org/wiki/Left_child-right_sibling_binary_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/binary/radix_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements the radix tree. http://en.wikipedia.org/wiki/Radix_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/binary/randomized_btree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements the randomized btree. http://en.wikipedia.org/wiki/Randomized_binary_search_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/binary/scapegoat_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements the scapegoat tree. http://en.wikipedia.org/wiki/Scapegoat_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/binary/t_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements t-tree. http://en.wikipedia.org/wiki/T-tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/binary/treap.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements the treap tree. http://en.wikipedia.org/wiki/Treap 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/binary/weight_balanced_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements the weight balanced tree. http://en.wikipedia.org/wiki/Weight-balanced_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/234_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements 2-3-4 tree. http://en.wikipedia.org/wiki/2-3-4_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/23_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements 23trees. http://en.wikipedia.org/wiki/2-3_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/ab_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements (a,b) tree. http://en.wikipedia.org/wiki/(a%2Cb)_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/b_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: Implement B-trees. http://en.wikipedia.org/wiki/B-tree 2 | 3 | #ifndef BTREE_H_ 4 | #define BTREE_H_ 5 | 6 | #endif /*BTREE_H_*/ 7 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/bplus_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements b+ trees. http://en.wikipedia.org/wiki/B%2B_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/bstar_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements b* trees. http://en.wikipedia.org/wiki/B*-tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of libslds 3 | 4 | * Copyright (C) Remy Saissy 5 | * libslds is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | 10 | * libslds is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/fusion_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements the fusion tree. http://en.wikipedia.org/wiki/Fusion_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/gist_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements the gist tree. http://en.wikipedia.org/wiki/GiST 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/hilbert_rtree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements the Hilbert r-tree. http://en.wikipedia.org/wiki/Hilbert_R-tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/include/bsharp_tree.h: -------------------------------------------------------------------------------- 1 | /// TODO: implements a b# tree. http://en.wikipedia.org/wiki/B_sharp_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/oc_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements the octree. http://en.wikipedia.org/wiki/Octree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/quad_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements te quad tree. http://en.wikipedia.org/wiki/Quadtree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/r_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements r-tree. http://en.wikipedia.org/wiki/R-tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/rplus_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements the R+ tree. http://en.wikipedia.org/wiki/R%2B_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/rstar_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements a R* tree. http://en.wikipedia.org/wiki/R*_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/ternary_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements the ternary tree. http://en.wikipedia.org/wiki/Ternary_search_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/top_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements a top tree. http://en.wikipedia.org/wiki/Top_Trees 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/tpyramid_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements a t-pyramid tree. http://en.wikipedia.org/wiki/Randomized_binary_search_tree 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/trie_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements a trie tree. http://en.wikipedia.org/wiki/Trie 2 | -------------------------------------------------------------------------------- /libs/libslds/src/tree/nary/ub_tree.c: -------------------------------------------------------------------------------- 1 | /// TODO: implements ub trees. http://en.wikipedia.org/wiki/UB-tree 2 | -------------------------------------------------------------------------------- /mk_base_image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Kernel image 4 | KERNEL_IMAGE=root.img 5 | 6 | # Removing the previous image 7 | rm -rf ${KERNEL_IMAGE} 8 | 9 | # Create the actual disk image - 20MB 10 | dd if=/dev/zero of=${KERNEL_IMAGE} count=20 bs=1048576 11 | 12 | # Make the partition table, partition and set it bootable. 13 | parted --script ${KERNEL_IMAGE} mklabel msdos mkpart p ext2 1 20 set 1 boot on 14 | 15 | # Map the partitions from the image file 16 | kpartx -av ${KERNEL_IMAGE} 17 | 18 | # sleep a sec, wait for kpartx to create the device nodes 19 | sleep 1 20 | 21 | # Make an ext2 filesystem on the first partition. 22 | mkfs.ext2 /dev/mapper/loop0p1 23 | 24 | # Make the mount-point 25 | mkdir -p tmp/p1 26 | 27 | # Mount the filesystem via loopback 28 | mount /dev/mapper/loop0p1 tmp/p1 29 | 30 | # Copy in the files from the staging directory 31 | mkdir -p tmp/p1/boot/grub 32 | cp ../grub.cfg tmp/p1/boot/grub/grub.cfg 33 | 34 | # Create a device map for grub 35 | echo "(hd0) /dev/loop0" > tmp/p1/boot/grub/device.map 36 | 37 | # Use grub2-install to actually install Grub. The options are: 38 | # * No floppy polling. 39 | # * Use the device map we generated in the previous step. 40 | # * Include the basic set of modules we need in the Grub image. 41 | # * Install grub into the filesystem at our loopback mountpoint. 42 | # * Install the MBR to the loopback device itself. 43 | grub-install --no-floppy \ 44 | --modules="biosdisk part_msdos ext2 configfile normal multiboot" \ 45 | --root-directory=`pwd`/tmp/p1 \ 46 | /dev/loop0 47 | 48 | # Unmount the loopback 49 | umount tmp/p1 50 | 51 | # Unmap the image 52 | kpartx -d ${KERNEL_IMAGE} 53 | 54 | # hack to make everything owned by the original user, since it will currently be 55 | # owned by root... 56 | LOGNAME=`who am i | awk '{print $1}'` 57 | LOGGROUP=`groups $LOGNAME | awk '{print $3}'` 58 | chown $LOGNAME:$LOGGROUP -R . ${KERNEL_IMAGE} 59 | --------------------------------------------------------------------------------