Merge pull request #4 from mentos-team/compatibility

Compatibility
This commit is contained in:
Enrico Fraccaroli
2021-01-26 10:02:28 +01:00
committed by GitHub
5 changed files with 140 additions and 15 deletions
+36 -2
View File
@@ -1,5 +1,40 @@
# ------------------------------------------------------------------------------
# Initialize the project.
project(MentOs)
cmake_minimum_required(VERSION 2.8.4)
message(STATUS "Crosscompiling: ${CMAKE_CROSSCOMPILING}")
# ------------------------------------------------------------------------------
# Add operating system specific option.
message(STATUS "System name: ${CMAKE_HOST_SYSTEM_NAME}")
message(STATUS "Kernel version: ${CMAKE_SYSTEM_VERSION}")
if ((${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin") OR APPLE)
# Apple MacOSx
elseif ((${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") OR WIN32)
# Windows
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
else()
# Generic Unix System
find_program(LSB_RELEASE_EXEC lsb_release)
execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --release
OUTPUT_VARIABLE LSB_RELEASE_VERSION_SHORT
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "LSB version: ${LSB_RELEASE_VERSION_SHORT}")
if (${LSB_RELEASE_VERSION_SHORT} MATCHES "^18")
# Ubuntu 18
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
elseif (${LSB_RELEASE_VERSION_SHORT} MATCHES "^19")
# Ubuntu 19
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -display gtk)
elseif (${LSB_RELEASE_VERSION_SHORT} MATCHES "^20")
# Ubuntu 20
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -display gtk)
else()
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
endif()
endif()
# ------------------------------------------------------------------------------
# Add the debugging option.
set(DEBUGGING_TYPE "DEBUG_STDIO" CACHE STRING
@@ -28,7 +63,7 @@ add_custom_target(
COMMAND echo "---------------------------------------------"
COMMAND echo "Initializing 'initfs'..."
COMMAND echo "---------------------------------------------"
COMMAND initfscp -s ${CMAKE_SOURCE_DIR}/files -t ${CMAKE_BINARY_DIR}/initfs -m /dev
COMMAND ./initscp/initfscp -s ${CMAKE_SOURCE_DIR}/files -t ${CMAKE_BINARY_DIR}/initfs -m /dev
COMMAND echo "---------------------------------------------"
COMMAND echo "Done!"
COMMAND echo "---------------------------------------------"
@@ -49,7 +84,6 @@ elseif (${DEBUGGING_TYPE} STREQUAL DEBUG_STDIO)
endif ()
SET(EMULATOR_FLAGS ${EMULATOR_FLAGS} -vga std)
SET(EMULATOR_FLAGS ${EMULATOR_FLAGS} -k it)
SET(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
SET(EMULATOR_FLAGS ${EMULATOR_FLAGS} -m ${MEMORY_SIZE})
SET(EMULATOR_KERNEL -kernel mentos/kernel.bin)
SET(EMULATOR_FS -initrd initfs)
+65 -3
View File
@@ -36,6 +36,9 @@ Main Developers:
Prerequisites
-----------------
MentOS is compatible with the main Unix distribution operating systems. It has been tested with *Ubuntu* and *MacOS*, but specifically tested on *Ubuntu 18.04*.
For compiling the main system:
* nasm
@@ -47,17 +50,43 @@ For compiling the main system:
To run and try:
* qemu-system-x86
* qemu-system-i386
For debugging:
* ccmake
* gdb or cgdb
* cgdb
* xterm
For MacOS, you have additional dependencies:
* i386-elf-binutils
* i386-elf-gcc
Prerequisites installation commands
-----------------
For Ubuntu:
```
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y build-essential git cmake qemu-system-i386
sudo apt-get install -y cgdb xterm #<- for debug only
```
For MacOS:
You need to install additionally the i386-elf cross-compiler. The simplest installation method is through Homebrew package manager. Install [Homebrew](https://brew.sh/index_it) if you don't already have and exec the following commands:
```
brew update && brew upgrade
brew install i386-elf-binutils i386-elf-gcc git cmake qemu nasm
brew install cgdb xterm #<- for debug only
```
Compiling MentOS
-----------------
Compile and boot MentOS with qemu:
Compile and boot MentOS with qemu in Unix systems:
```
cd <clone_directory>
@@ -70,6 +99,12 @@ make qemu
If you want to access to the shell, use one of the usernames listed in files/passwd.
**For MacOS**, the steps are the same but instead of `cmake ..`, you have to put an additional argument in order to use the i386-elf cross-compiler:
```
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake ..
```
Change the scheduling algorithm
-----------------
@@ -80,6 +115,23 @@ MentOS provides three different scheduling algorithms:
* Completely Fair Scheduling
If you want to change the scheduling algorithm:
```
cd build
# Round Robin scheduling algorithm
cmake -DSCHEDULER_TYPE=SCHEDULER_RR ..
# Priority scheduling algorithm
cmake -DSCHEDULER_TYPE=SCHEDULER_PRIORITY ..
# Completely Fair Scheduling algorithm
cmake -DSCHEDULER_TYPE=SCHEDULER_CFS ..
make
make qemu
```
Otherwise you can use `ccmake`:
```
cd build
cmake ..
@@ -114,6 +166,16 @@ MentOS provides a Buddy System to manage the allocation and deallocation of
page frames in the physical memory.
If you want to enable the MentOS's Buddy System:
```
cd build
cmake -DENABLE_BUDDY_SYSTEM=ON ..
make
make qemu
```
Otherwise you can use `ccmake`:
```
cd build
cmake ..
+6
View File
@@ -6,6 +6,12 @@ project(initfscp C ASM)
# Set the project name.
set(PROJECT_NAME initfscp)
if (CMAKE_CROSSCOMPILING)
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_EXE_LINKER_FLAGS "")
endif (CMAKE_CROSSCOMPILING)
# ------------------------------------------------------------------------------
# Set the compiler options (original).
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
+19 -10
View File
@@ -1,10 +1,17 @@
# ------------------------------------------------------------------------------
# Initialize the project.
project(MentOs C ASM)
set(PROJECT_NAME MentOs)
# ------------------------------------------------------------------------------
# Set the project name.
set(PROJECT_NAME MentOs)
# Add operating system specific option.
if((${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin") OR APPLE) # Apple MacOSx
set(CMAKE_ASM_COMPILER nasm)
elseif ((${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") OR WIN32) # Windows
set(CMAKE_ASM_COMPILER ${CMAKE_SOURCE_DIR}/third_party/nasm/bin/nasm)
else () # Generic Unix System
set(CMAKE_ASM_COMPILER ${CMAKE_SOURCE_DIR}/third_party/nasm/bin/nasm)
endif ()
# ------------------------------------------------------------------------------
# Find doxygen
@@ -128,6 +135,10 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wuninitialized")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0")
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcommon")
endif()
# ------------------------------------------------------------------------------
if (CMAKE_BUILD_TYPE MATCHES "Release")
@@ -137,13 +148,11 @@ endif (CMAKE_BUILD_TYPE MATCHES "Release")
# ------------------------------------------------------------------------------
# Set the assembly flags.
enable_language(ASM)
set(CMAKE_ASM_COMPILER ${CMAKE_SOURCE_DIR}/third_party/nasm/bin/nasm)
SET(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g")
SET(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -O0")
SET(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -f elf")
SET(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -F dwarf")
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <FLAGS> -o <OBJECT> <SOURCE>")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -O0")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -f elf")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -F dwarf")
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <FLAGS> <SOURCE> -o <OBJECT>")
# ------------------------------------------------------------------------------
# Add the includes.
@@ -319,7 +328,7 @@ add_library(${PROJECT_NAME} ${SOURCE_FILES})
add_custom_command(
TARGET MentOs
POST_BUILD
COMMAND $(LD)
COMMAND ${CMAKE_LINKER}
-melf_i386
-static
--oformat elf32-i386
+14
View File
@@ -0,0 +1,14 @@
set(CMAKE_SYSTEM_NAME Generic)
if(CMAKE_VERSION VERSION_LESS "3.6.0")
INCLUDE(CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER(i386-elf-gcc Clang)
CMAKE_FORCE_CXX_COMPILER(i386-elf-g++ Clang)
else()
set(CMAKE_C_COMPILER i386-elf-gcc)
set(CMAKE_CXX_COMPILER i386-elf-g++)
set(CMAKE_AR i386-elf-ar)
endif()
set(CMAKE_LINKER i386-elf-ld)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib")