Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cb0665e
Quick Post Pull Clean Up
maxtyson123 Mar 29, 2025
e2c7a65
Docstring Updates
maxtyson123 Mar 29, 2025
09a6ddf
Clion & Compiler Warnings fix
maxtyson123 Mar 29, 2025
3d5026f
C++ Support (bit late ik)
maxtyson123 Mar 29, 2025
6cc1107
Clang Tidy
maxtyson123 Mar 30, 2025
de74bdd
Inline statics
maxtyson123 Mar 30, 2025
b0c5df4
Clean Up Main
maxtyson123 Mar 30, 2025
cde188d
Enum Classes
maxtyson123 Mar 30, 2025
56d214b
Fix TODOS: IPC Classes, FPU/SEE Enabled
maxtyson123 Mar 31, 2025
a849528
Clean up kernel main and PMM constructor
maxtyson123 Apr 2, 2025
488cc37
Fix up interrupt manager references
maxtyson123 Apr 2, 2025
3a899f4
Clean Up Apic, Clean Up VMM
maxtyson123 Apr 2, 2025
f44a6de
PMM To be more cohesive
maxtyson123 Apr 3, 2025
2dd21c0
Style Corrections
maxtyson123 Apr 3, 2025
aa71a76
Logger Rewrite (not a fan of style jsut yet)
maxtyson123 Apr 4, 2025
a043ea6
Boot Rewrite
maxtyson123 Apr 6, 2025
a899937
Progress Bar & Prod Targets
maxtyson123 Apr 8, 2025
ee99a22
Progress Bar & Prod Targets
maxtyson123 Apr 8, 2025
c9c88ce
Simpler bootscript
maxtyson123 Apr 10, 2025
102c2b6
Mac OS Dev Support (cant run grub yet)
maxtyson123 Apr 12, 2025
7842b1c
Boot MacOS, Boot ISO
maxtyson123 Apr 17, 2025
e19728c
Kernel Main clean up
maxtyson123 Apr 17, 2025
883db38
Style Fixes & Elf Bug Fix
maxtyson123 Apr 18, 2025
9090460
Clean Up
maxtyson123 Apr 18, 2025
652bfe4
Fix Workflow
maxtyson123 Apr 18, 2025
ee17936
Fix Workflow 2
maxtyson123 Apr 18, 2025
5bcb9af
Can compile
maxtyson123 Apr 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/max-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
jobs:
build-os:
# The type of runner that the job will run on
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand All @@ -32,7 +32,7 @@ jobs:
uses: actions/cache@v3
with:
path: toolchain/cross_compiler
key: ${{ runner.os }}-cross_compiler_2
key: ${{ runner.os }}-cross_compiler_3

- name: Build toolchain
if: steps.cache-toolchain.outputs.cache-hit != 'true'
Expand All @@ -42,9 +42,9 @@ jobs:

- name: Build MaxOS (Release)
run: |
cd toolchain
cd toolchain/post_process
./version.sh --force
cd ../
cd ../../
mkdir -p cmake-build
cd cmake-build
cmake .. -DCMAKE_TOOLCHAIN_FILE=toolchain/CMakeToolchain.txt
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
*.o
*.elf
*.o
*.elf
kernel.elf
.idea/.name
.idea/max-os.iml
Expand Down Expand Up @@ -58,6 +56,5 @@ cmake-build-debug/Testing/Temporary/LastTest.log
MaxOS.bin
MaxOS.iso
README.md
README.md
MaxOS.img
/.hushlogin
5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

484 changes: 484 additions & 0 deletions .idea/editor.xml

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 27 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ project(MaxOS C CXX ASM)
# Logs the compiler commands
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Dont enable runtime type information
# don't enable runtime type information
set(CMAKE_SKIP_RPATH TRUE)

# Set the standard to C++20
Expand All @@ -20,20 +20,26 @@ INCLUDE_DIRECTORIES(libraries/)
LINK_DIRECTORIES(${TOOLCHAIN_ROOT_DIR}/lib/gcc/${TOOLCHAIN_PLATFORM}/${GCC_VER}/)
LINK_DIRECTORIES(${TOOLCHAIN_ROOT_DIR}/${TOOLCHAIN_PLATFORM}/lib/)

# DEBUG / PROD
IF(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
ENDIF()

## Set flags based on build type
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DTARGET_DEBUG)
ENDIF()

# Look to build in these directories
ADD_SUBDIRECTORY(kernel)
#ADD_SUBDIRECTORY(libraries)
ADD_SUBDIRECTORY(programs)
#ADD_SUBDIRECTORY(ports)

ADD_CUSTOM_TARGET(optional_apps
# Build the optional apps
# COMMENT "Building optional apps"
# COMMAND ${CMAKE_COMMAND} -E env "SOURCE_DIR=${CMAKE_SOURCE_DIR}" ${CMAKE_SOURCE_DIR}/toolchain/build_optional_apps.sh
# USES_TERMINAL
)

ADD_CUSTOM_TARGET(image
# Everything needs to be installed (compiled) before we can create the disk image
# DEPENDS install (TODO Rewrite so auto installs)

# Create the disk image
COMMENT "Creating disk image"
COMMAND ${CMAKE_COMMAND} -E env "SOURCE_DIR=${CMAKE_SOURCE_DIR}" ${CMAKE_SOURCE_DIR}/toolchain/create_disk_img.sh
Expand All @@ -51,6 +57,9 @@ ADD_CUSTOM_TARGET(image
)

ADD_CUSTOM_TARGET(run
# Requires a bootable image to be created
DEPENDS image

# Run qemu
COMMENT "Running qemu"
COMMAND ${CMAKE_COMMAND} -E env "SOURCE_DIR=${CMAKE_SOURCE_DIR}" ${CMAKE_SOURCE_DIR}/toolchain/run_qemu.sh
Expand All @@ -59,21 +68,18 @@ ADD_CUSTOM_TARGET(run
USES_TERMINAL
)

ADD_CUSTOM_TARGET(debug
# Run qemu
COMMENT "Running qemu"
COMMAND ${CMAKE_COMMAND} -E env "SOURCE_DIR=${CMAKE_SOURCE_DIR}" ${CMAKE_SOURCE_DIR}/toolchain/run_qemu.sh --debug
# Run qemu with debug if the debug flag is set
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_CUSTOM_TARGET(gdb

# Ensure it runs in the terminal
USES_TERMINAL
)
# Requires a bootable image to be created
DEPENDS image

ADD_CUSTOM_TARGET(gdb
# Run GDB
COMMENT "Running GDB"
COMMAND ${CMAKE_COMMAND} -E env "SOURCE_DIR=${CMAKE_SOURCE_DIR}" ${CMAKE_SOURCE_DIR}/toolchain/run_gdb.sh
BYPRODUCTS ${CMAKE_SOURCE_DIR}/MaxOS.sym
# Run qemu
COMMENT "Running qemu with gdb"
COMMAND ${CMAKE_COMMAND} -E env "SOURCE_DIR=${CMAKE_SOURCE_DIR}" ${CMAKE_SOURCE_DIR}/toolchain/run_qemu.sh --debug

# Ensure it runs in the terminal
USES_TERMINAL
)
)
ENDIF()
63 changes: 45 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<!-- Improved compatibility of back to top link: See: https://github.com/maxtyson123/MaxOS/pull/73 -->
<a name="readme-top"></a>
<!--
*** Thanks for checking out the Best-README-Template. If you have a suggestion
*** that would make this better, please fork the repo and create a pull request
*** or simply open an issue with the tag "enhancement".
*** Don't forget to give the project a star!
*** Thanks again! Now go create something AMAZING! :D
-->



Expand Down Expand Up @@ -84,16 +77,18 @@ Max OS is a hobby operating system developed for the 64bit platform using C++ an

Max OS supports device drivers, memory management, multitasking, a GUI, and more. The project is being developed with the goal of being able to run on real hardware, however, it is currently only able to run on a virtual machine.

This GitHub repository contains the source code for the operating system, as well as the build scripts required to build the operating system from source. The repository also contains the latest built kernel, which can be downloaded from the workflow artifacts. To ensure a cleaner git history, each feature/change is done in a separate branch and then merged into the main branch once working. To see the history of each feature press on the pull request number. If you are intrested in the active developement find the latest branch <a href="https://github.com/maxtyson123/MaxOS/branches">Here</a>.
This GitHub repository contains the source code for the operating system, as well as the build scripts required to build the operating system from source. The repository also contains the latest built kernel, which can be downloaded from the workflow artifacts. To ensure a cleaner git history, each feature/change is done in a separate branch and then merged into the main branch once working. To see the history of each feature press on the pull request number. If you are intrested in the active development find the latest branch <a href="https://github.com/maxtyson123/MaxOS/branches">Here</a>.


_Note:_ Ignore all the networking code & drivers, they are very outdated, badly written and will soon be ported over to userspace and rewritten.
<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- GETTING STARTED -->
## Getting Started

This is how to build the Max OS operating system from source. (Alternatively, you can download the latest built kernel from the workflow artifacts)

Currently Max OS can only be built on a linux machine, but does support WSL. In the future I do plan to port the build system to Mac.
Currently, Max OS can only be built on a linux-like machine, but does support WSL & Mac. If you are using WSL, make sure the repo is on the WSL machine and not the Windows machine.

### Prerequisites

Expand All @@ -107,17 +102,29 @@ This is the list of required packages to build the operating system from source.
* texinfo
* libisl-dev
* cmake
* telnet

Linux:
```sh
sudo apt update
sudo apt install -y build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo libisl-dev cmake
sudo apt install -y build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo libisl-dev cmake telnet
```

Mac:
```sh
# Install Devtools (via Xcode or some other method)
# Install Homebrew
brew install coreutils bison gmp libmpc mpfr texinfo gcc@13 cmake nasm telnet
```


Note: If you want to run the operating system in a virtual machine, you will need to install QEMU. (If in WSL the script will look for a Windows installation of QEMU)

### Installation

- Upon first build follow steps 1-5
- If you change the file structure (e.g. add a new file) follow steps 3-5
- If you running on a new boot (eg you rebooted your computer) follow steps 4-5
- If you're running on a new boot (eg you rebooted your computer) follow steps 4-5
- If you only change a file follow step 5

1. Clone the repo
Expand All @@ -126,7 +133,7 @@ Note: If you want to run the operating system in a virtual machine, you will nee
cd MaxOS
```

2. Create the cross compiler (This will take a while)
2. Create the cross-compiler (This will take a while)
```sh
cd toolchain
./make_cross_compiler.sh
Expand All @@ -138,8 +145,8 @@ Note: If you want to run the operating system in a virtual machine, you will nee
# If you edit the CMakeLists.txt file you will need to delete the build directory contents (not the folder) and regenerate the makefiles
cd cmake-build

# Add -DDEBUG=ON to enable debug mode
cmake .. -DCMAKE_TOOLCHAIN_FILE=toolchain/CMakeToolchain.txt
# Change to -DCMAKE_BUILD_TYPE=Debug to enable debug mode
cmake .. -DCMAKE_TOOLCHAIN_FILE=toolchain/CMakeToolchain.txt -DCMAKE_BUILD_TYPE=Release
```

4. Clean the build directory
Expand All @@ -149,8 +156,26 @@ Note: If you want to run the operating system in a virtual machine, you will nee

5. Build the operating system & Run it in QEMU
```sh
make install image run
# Replace 'run' with 'gdb' on a debug build to make the kernel wait for gdb to attach on port 1234
make run
```

6. (OPTIONAL) I use CLion IDE for development, if you want to use it too follow these steps for IDE features:
- Cmake
- Open CLion
- Select "Open or Import"
- Select the `CMakeLists.txt` file in the root directory of the project
- Make sure the profile is set to these settings:
- CMake: `cmake .. -DCMAKE_TOOLCHAIN_FILE=toolchain/CMakeToolchain.txt`
- Directory: `cmake-[release/debug]`
- Click "OK"
- Wait for CLion to index the project (this may take a while)
- Code Style
- Go to Settings -> Editor -> Code Styles -> (cog) -> Import Scheme -> C/C++ -> Import Scheme -> From `docs/Styles/ClionCodeStyleSettings.xml`
- Debugger
- Run a gdb build with `make gdb`
- Create new configuration: Edit Configurations -> Add -> Remote Debugger
-

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Expand All @@ -162,10 +187,10 @@ Note: If you want to run the operating system in a virtual machine, you will nee
No user usage so far (userland will be added in the future)

#### Boot Console
![Boot Console](docs/Screenshots/Boot/Console20%v2.png)
![Boot Console](docs/Screenshots/Boot/Console_v3.png)

#### GUI
![GUI](docs/Screenshots/GUI/Windows20%VESA.png)
![GUI](docs/Screenshots/GUI/Windows_VESA.png)

<!-- ROADMAP -->
## Roadmap
Expand Down Expand Up @@ -196,13 +221,15 @@ No user usage so far (userland will be added in the future)
- [ ] DOOM Port
- [ ] UserSpace Drivers
- [ ] Userspace Networking
- [ ] Auto Updater & Image Builder
- [ ] Connect to Clion with SMB for files and GDB for debugging in userspace
- [ ] Auto Updater & Image Builder (ISO Release)
- [ ] Store
- [ ] User Switching
- [ ] Real Hardware Support
- [ ] Pretty GUI
- [ ] Port NeoVim, Wakatime & Some hot reloader
- [ ] Create port of my 2048
- [ ] Own LibC
- [ ] Compatibility Layer(s)

See the [open issues](https://github.com/maxtyson123/MaxOS/issues) for a full list of proposed features (and known issues).
Expand Down
2 changes: 1 addition & 1 deletion docs/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The following behaviors are considered harassment and are unacceptable within ou

* Violence, threats of violence or violent language directed against another person.
* Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language.
* Posting or displaying sexually explicit or violent material.
* Posting or displaying sexually or violent material.
* Posting or threatening to post other people's personally identifying information ("doxing").
* Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability.
* Inappropriate photography or recording.
Expand Down
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ We love your input! We want to make contributing to this project as easy and tra
We use GitHub to host code, to track issues and feature requests, as well as accept pull requests.

## Code Standard
To keep the code understanble please make sure it is formatted and reable. Please look in the coding style [docs](Styles/Coding%20Style.md) for more information.
To keep the code understandable please make sure it is formatted and reable. Please look in the coding style [docs](Styles/Coding%20Style.md) for more information.

## We Use [GitHub Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests
Pull requests are the best way to propose changes to the codebase (we use [GitHub Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:
Expand Down
4 changes: 2 additions & 2 deletions docs/Goals.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
- Chess
- 2048
- Conways game of life
- Solitare
- Solitaire
- Minesweeper
- Snake
- Paint
Expand Down Expand Up @@ -59,6 +59,6 @@

# Other
- Clipboard
- Privelges (Rings, read/write)
- Privileges (Rings, read/write)
- Apps installer
- App store
9 changes: 9 additions & 0 deletions docs/Idle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## How the idle proc works:
I was debugging along and released that on the first ever schedule it will
set current_thread->execution_state = cpu_state; where it is assumed cpu_state
is the current thread state (ie what we have just been scheduling) and
thus saves it in that thread. However, as the first thread has not had a
chance to be scheduled yet, the current state is not the expected first
thread's state and instead is the cpu state of the kernel.
Now I could either fix that or leave it in as a cool way of never fully
leaving kernelMain and also having a idle_proc
Loading