Skip to content

Commit

Permalink
64bit Booting (#7)
Browse files Browse the repository at this point in the history
* Toolchain for x86_64, Multiboot 2

* Begin Working on 64 bit boot process

* Kernel Boots

* Change to MaxOS

* Kernel Debug Printing

* Fixed Kernel Debug Printing

* Prep Merge

* Workflow fixes

* Add nasm
  • Loading branch information
maxtyson123 authored Jan 15, 2024
1 parent e51208c commit 2452708
Show file tree
Hide file tree
Showing 125 changed files with 1,440 additions and 895 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/max-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,24 @@ jobs:
- name: Install Ubuntu Dependencies
run: |
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 nasm
- name: Cache toolchain
id: cache-toolchain
uses: actions/cache@v3
with:
path: toolchain/cross_compiler
key: ${{ runner.os }}-cross_compiler_1
key: ${{ runner.os }}-cross_compiler_2

- name: Build toolchain
if: steps.cache-toolchain.outputs.cache-hit != 'true'
run: |
cd toolchain
./make_cross_compiler.sh --no-deps
- name: Build maxOS (Release)
- name: Build MaxOS (Release)
run: |
mkdir -p cmake-build
cd cmake-build
cmake .. -DCMAKE_TOOLCHAIN_FILE=toolchain/CMakeToolchain.txt
make install
Expand All @@ -50,7 +51,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: Kernel Binary
path: filesystem/boot/MaxOSk32
path: filesystem/boot/MaxOSk64

generate-docs:
# The type of runner that the job will run on
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ cmake-build-debug/CMakeFiles/untitled.dir/linklibs.rsp
cmake-build-debug/CMakeFiles/untitled.dir/objects1.rsp
cmake-build-debug/CMakeFiles/untitled.dir/progress.make
cmake-build-debug/Makefile
cmake-build-debug/maxOS.cbp
cmake-build-debug/MaxOS.cbp
cmake-build-debug/Testing/Temporary/LastTest.log
maxOS.bin
maxOS.iso
MaxOS.bin
MaxOS.iso
README.md
README.md
maxOS.img
MaxOS.img
/.hushlogin
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ ADD_CUSTOM_TARGET(image
# 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
BYPRODUCTS ${CMAKE_SOURCE_DIR}/maxOS.img
BYPRODUCTS ${CMAKE_SOURCE_DIR}/filesystem/boot/MaxOSk32
BYPRODUCTS ${CMAKE_SOURCE_DIR}/MaxOS.img
BYPRODUCTS ${CMAKE_SOURCE_DIR}/filesystem/boot/MaxOSk64

# Copy the files to the disk image
COMMENT "Copying files to disk image"
Expand Down
8 changes: 6 additions & 2 deletions filesystem/boot/grub.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
set timeout=0
set default=0
set timeout=0

menuentry "Max OS" {
multiboot /boot/MaxOSk32
echo "Max OS by Max Tyson || (64 Bit Mode)"
echo "===================================="
echo "Loading Kernel..."
multiboot2 /boot/MaxOSk64
boot
}
22 changes: 11 additions & 11 deletions kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Set the standard and flags
SET(CMAKE_CXX_STANDARD 20)
SET(CMAKE_CXX_FLAGS "-ffreestanding -fno-exceptions -fno-rtti -nostdlib -Wall -Wextra -Wno-address-of-packed-member -Wno-trigraphs")
SET(CMAKE_CXX_FLAGS " -ffreestanding -fno-exceptions -fno-rtti -fpermissive -nostdlib -Wall -Wextra -Wno-address-of-packed-member -Wno-trigraphs -mno-red-zone -mno-80387 -mno-mmx -mno-sse -mno-sse2 -mcmodel=kernel -g")

# Enable assembly
SET(CMAKE_ASM_FLAGS "")
SET(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <FLAGS> -o <OBJECT> <SOURCE>")
SET(CMAKE_ASM_FLAGS "-f elf64")
SET(CMAKE_ASM_COMPILE_OBJECT "nasm <FLAGS> -o <OBJECT> <SOURCE>")
FILE(GLOB_RECURSE ASM_SRCS src/*.s)
SET_SOURCE_FILES_PROPERTIES(${ASM_SRCS} PROPERTIES LANGUAGE ASM)

# Find all the cpp and s files in the src directory (recursive)
FILE(GLOB_RECURSE KERNEL_SRCS src/*.cpp src/*.s)

# Create the kernel
ADD_EXECUTABLE(MaxOSk32 ${KERNEL_SRCS})
TARGET_COMPILE_DEFINITIONS(MaxOSk32 PUBLIC MAXOS_KERNEL)
ADD_EXECUTABLE(MaxOSk64 ${KERNEL_SRCS})
TARGET_COMPILE_DEFINITIONS(MaxOSk64 PUBLIC MAXOS_KERNEL)

# Update the version before building
ADD_CUSTOM_COMMAND(
COMMENT "Versioning kernel"
TARGET MaxOSk32
TARGET MaxOSk64
PRE_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/toolchain/version.sh
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/kernel/include/common/version.h.tmp ${CMAKE_SOURCE_DIR}/kernel/include/common/version.h
Expand All @@ -28,12 +28,12 @@ ADD_CUSTOM_COMMAND(

# Linker
SET(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/kernel/src/linker.ld)
SET_TARGET_PROPERTIES(MaxOSk32 PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT})
TARGET_LINK_LIBRARIES(MaxOSk32 gcc)
TARGET_LINK_OPTIONS(MaxOSk32 PRIVATE -T ${LINKER_SCRIPT} -nostdlib)
SET_TARGET_PROPERTIES(MaxOSk64 PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT})
TARGET_LINK_LIBRARIES(MaxOSk64 gcc)
TARGET_LINK_OPTIONS(MaxOSk64 PRIVATE -T ${LINKER_SCRIPT} -nostdlib -n)

# Set the include directories
TARGET_INCLUDE_DIRECTORIES(MaxOSk32 PRIVATE include)
TARGET_INCLUDE_DIRECTORIES(MaxOSk64 PRIVATE include)

# Install kernel
INSTALL(TARGETS MaxOSk32 DESTINATION ${CMAKE_SOURCE_DIR}/filesystem/boot)
INSTALL(TARGETS MaxOSk64 DESTINATION ${CMAKE_SOURCE_DIR}/filesystem/boot)
2 changes: 1 addition & 1 deletion kernel/include/common/colour.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <stdint.h>

namespace maxOS{
namespace MaxOS{

namespace common
{
Expand Down
2 changes: 1 addition & 1 deletion kernel/include/common/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef MAXOS_COMMON_CONSTANTS_H
#define MAXOS_COMMON_CONSTANTS_H

namespace maxOS{
namespace MaxOS{

namespace common{

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/common/coordinates.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <stdint.h>
#include <common/pair.h>

namespace maxOS{
namespace MaxOS{

namespace common{

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/common/eventHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <stdint.h>
#include <common/vector.h>

namespace maxOS{
namespace MaxOS{

namespace common{

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/common/graphicsContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <stdint.h>
#include <common/colour.h>

namespace maxOS {
namespace MaxOS {

namespace common {

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/common/inputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <common/vector.h>
#include <common/string.h>

namespace maxOS{
namespace MaxOS{

namespace common{

Expand Down
12 changes: 12 additions & 0 deletions kernel/include/common/kprint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Created by 98max on 15/01/2024.
//

#ifndef MAXOS_KPRINT_H
#define MAXOS_KPRINT_H

#include <drivers/console/serial.h>

void _kprintf(const char* format, ...);

#endif // MAXOS_KPRINT_H
2 changes: 1 addition & 1 deletion kernel/include/common/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <common/vector.h>
#include <common/pair.h>

namespace maxOS{
namespace MaxOS{

namespace common{

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/common/outputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <common/inputStream.h>
#include <common/string.h>

namespace maxOS{
namespace MaxOS{

namespace common{

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/common/pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef MAXOS_PAIR_H
#define MAXOS_PAIR_H

namespace maxOS {
namespace MaxOS {

namespace common {

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/common/rectangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <common/vector.h>

namespace maxOS{
namespace MaxOS{

namespace common{

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/common/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <stdint.h>

namespace maxOS {
namespace MaxOS {

class String {
private:
Expand Down
2 changes: 1 addition & 1 deletion kernel/include/common/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <stdint.h>

namespace maxOS{
namespace MaxOS{

namespace common{

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/common/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <stdint.h>

namespace maxOS{
namespace MaxOS{

namespace common{

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/clock/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <common/vector.h>
#include <common/eventHandler.h>

namespace maxOS {
namespace MaxOS {

namespace drivers {

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/console/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <stdint.h>
#include <common/outputStream.h>

namespace maxOS {
namespace MaxOS {

namespace drivers {

Expand Down
41 changes: 41 additions & 0 deletions kernel/include/drivers/console/serial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// Created by 98max on 14/01/2024.
//

#ifndef MAXOS_SERIAL_H
#define MAXOS_SERIAL_H

#include <stdint.h>
#include <hardwarecommunication/port.h>
#include <drivers/driver.h>

namespace MaxOS {

namespace drivers {

class SerialConsole : public Driver {

private:
hardwarecommunication::Port8Bit m_data_port;
hardwarecommunication::Port8Bit m_interrupt_enable_port;
hardwarecommunication::Port8Bit m_fifo_control_port;
hardwarecommunication::Port8Bit m_line_control_port;
hardwarecommunication::Port8Bit m_modem_control_port;
hardwarecommunication::Port8Bit m_line_status_port;

public:
static SerialConsole* s_active_serial_console;

SerialConsole();
~SerialConsole();

void put_character(char c);

};

}
}



#endif // MAXOS_SERIAL_H
2 changes: 1 addition & 1 deletion kernel/include/drivers/console/textmode.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <drivers/driver.h>
#include <drivers/console/console.h>

namespace maxOS{
namespace MaxOS{

namespace drivers {

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/console/vesaboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <drivers/console/console.h>
#include <common/logo.h>

namespace maxOS{
namespace MaxOS{

namespace drivers {

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/disk/ata.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <stdint.h>


namespace maxOS{
namespace MaxOS{

namespace drivers{

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <common/eventHandler.h>
#include <common/string.h>

namespace maxOS
namespace MaxOS
{
namespace drivers {

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/ethernet/amd_am79c973.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <hardwarecommunication/port.h>


namespace maxOS{
namespace MaxOS{

namespace drivers{

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/ethernet/ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <common/vector.h>
#include <common/eventHandler.h>

namespace maxOS{
namespace MaxOS{

namespace drivers{

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/ethernet/intel_i217.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <memory/memorymanagement.h>
#include <drivers/ethernet/ethernet.h>

namespace maxOS{
namespace MaxOS{

namespace drivers {

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/ethernet/rawdatahandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <stdint.h>

namespace maxOS {
namespace MaxOS {

namespace drivers {

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/peripherals/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <hardwarecommunication/port.h>
#include <stdint.h>

namespace maxOS
namespace MaxOS
{
namespace drivers {

Expand Down
Loading

0 comments on commit 2452708

Please sign in to comment.