diff --git a/,vscode/ClassicOS.code-workspace b/,vscode/ClassicOS.code-workspace new file mode 100644 index 0000000..b2a42c7 --- /dev/null +++ b/,vscode/ClassicOS.code-workspace @@ -0,0 +1,11 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {}, + "extensions": { + "recommendations": [] + } +} \ No newline at end of file diff --git a/,vscode/c_cpp_properties.json b/,vscode/c_cpp_properties.json new file mode 100644 index 0000000..93d0a09 --- /dev/null +++ b/,vscode/c_cpp_properties.json @@ -0,0 +1,67 @@ +{ + "env": { + "myDefaultIncludePath": ["${workspaceFolder}", "${workspaceFolder}/include"], + "myCompilerPath": "/usr/local/bin/" + }, + "configurations": [ + { + "name": "Linux", + "intelliSenseMode": "clang-x64", + "includePath": ["${myDefaultIncludePath}", "/another/path"], + "macFrameworkPath": ["/System/Library/Frameworks"], + "defines": ["FOO", "BAR=100"], + "forcedInclude": ["${workspaceFolder}/include/config.h"], + "compilerPath": "/usr/bin/clang", + "cStandard": "c17", + "cppStandard": "c++20", + "compileCommands": "/path/to/compile_commands.json", + "browse": { + "path": ["${workspaceFolder}"], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + }, + { + "name": "linux-gcc-x64", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "/usr/bin/gcc", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "linux-gcc-x64", + "compilerArgs": [ + "-Wall", + "-Wextra", + "-Wpedantic" + ], + "configurationProvider": "ms-vscode.makefile-tools" + }, + { + "name": "Linux", + "includePath": [ + "/usr/include/x86_64-linux-gnu/c++/5", + "/usr/include/c++/5", + "/usr/local/include", + "/usr/include/x86_64-linux-gnu", + "/usr/include", + "${workspaceRoot}" + ], + "defines": [], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ + "/usr/include/x86_64-linux-gnu/c++/5", + "/usr/include/c++/5", + "/usr/local/include", + "/usr/include/x86_64-linux-gnu", + "/usr/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + } + ], + "version": 4 + } \ No newline at end of file diff --git a/,vscode/compile_commands.json b/,vscode/compile_commands.json new file mode 100644 index 0000000..d098bc2 --- /dev/null +++ b/,vscode/compile_commands.json @@ -0,0 +1,12 @@ +[ + { + "directory": "/path/to/project", + "command": "gcc -c -o file1.o file1.c", + "file": "/path/to/project/file1.c" + }, + { + "directory": "/path/to/project", + "command": "g++ -c -o file2.o file2.cpp", + "file": "/path/to/project/file2.cpp" + } + ] \ No newline at end of file diff --git a/,vscode/extensions.json b/,vscode/extensions.json new file mode 100644 index 0000000..45d3df8 --- /dev/null +++ b/,vscode/extensions.json @@ -0,0 +1,11 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "13xforever.language-x86-64-assembly", + "franneck94.c-cpp-runne", + "formulahendry.code-runner", + "ms-vscode.cpptools", + "ms-vscode.cpptools-extension-pack" + ] +} \ No newline at end of file diff --git a/,vscode/launch.json b/,vscode/launch.json new file mode 100644 index 0000000..4ea0cec --- /dev/null +++ b/,vscode/launch.json @@ -0,0 +1,32 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "gcc-8 - Build and debug active file Level 1", + "type": "cppdbg", + "request": "launch", + "program": "${fileDirname}/${fileBasenameNoExtension}", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "Debug Build Level 1", + "miDebuggerPath": "/usr/bin/gdb", + "logging": { + "engineLogging": true + } + } + ] +} \ No newline at end of file diff --git a/,vscode/settings.json b/,vscode/settings.json new file mode 100644 index 0000000..6eab8c7 --- /dev/null +++ b/,vscode/settings.json @@ -0,0 +1,107 @@ +{ + "files.associations": { + "*.c": "c", + "*.h": "c", + "*.cpp": "cpp", + "*.hpp": "hpp", + "*.asm": "asm", + "*.bin": "bin" + }, + "files.fileAssociations": { + ".c": "c", + ".h": "c", + ".cpp": "cpp", + ".hpp": "cpp", + ".asm": "asm", + ".bin": "bin" + }, + "emmet.includeLanguages": { + "c": "c", + "cpp": "cpp", + "assembly": "asm" + }, + "C_Cpp_Runner.cCompilerPath": "/usr/bin", + "C_Cpp_Runner.cppCompilerPath": "/usr/bin", + "C_Cpp_Runner.debuggerPath": "/usr/bin", + "C_Cpp_Runner.cStandard": "c17", + "C_Cpp_Runner.cppStandard": "c++20", + "C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [ + "-dynamic-linker {/lib64/ld-linux-x86-64.so.2}" + ], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false, + "c-cpp-flylint.enable": true, + "c-cpp-flylint.debug": true, + "c-cpp-flylint.flexelint.enable": false, + "c-cpp-flylint.cppcheck.enable": true, + "c-cpp-flylint.clang.enable": false, + "C_Cpp_Config.cCompilerPath": "gcc", + "C_Cpp_Config.cppCompilerPath": "g++", + "C_Cpp_Config.debuggerPath": "gdb", + "C_Cpp_Config.makePath": "make", + "C_Cpp.clang_format_sortIncludes": true, + "C_Cpp.vcFormat.indent.preserveComments": true, + "C_Cpp.vcFormat.indent.namespaceContents": false, + "C_Cpp.vcFormat.indent.caseContentsWhenBlock": true, + "C_Cpp.vcFormat.space.pointerReferenceAlignment": "right", + "C_Cpp.default.browse.limitSymbolsToIncludedHeaders": false, + "C_Cpp.default.cppStandard": "c++20", + "C_Cpp.default.cStandard": "c17", + "C_Cpp.formatting": "clangFormat", + "[c]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "ms-vscode.cpptools" + }, + "[cpp]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "ms-vscode.cpptools" + }, + "C_Cpp.codeAnalysis.clangTidy.enabled": true, + "C_Cpp.configurationWarnings": "disabled", + "cmake.configureOnOpen": false, + "cmake.autoSelectActiveFolder": false, + "cmake.configureOnEdit": false, + "c-cpp-flylint.flexelint.configFile": "", + "c-cpp-flylint.flexelint.executable": "", + "c-cpp-flylint.language": "c", + "C_Cpp.autocompleteAddParentheses": true, + "C_Cpp.errorSquiggles": "Enabled", + "C_Cpp_Runner.makePath": "", + "cmake.sourceDirectory": "${workspaceFolder}", + "C_Cpp.default.compilerPath": "/usr/bin", + "C_Cpp.loggingLevel": "", + "C_Cpp.default.enableConfigurationSquiggles": "", + "C_Cpp.default.includePath": "/usr/bin", + "workbench.editorAssociations": { + "*.bin": "bin", + "*.c": "c", + "*.h": "c", + "*.cpp": "cpp", + "*.hpp": "hpp", + "*.asm": "asm" + }, + "C_Cpp.default.intelliSenseMode": "linux-clang-x86" +} \ No newline at end of file diff --git a/,vscode/tasks.json b/,vscode/tasks.json new file mode 100644 index 0000000..cbf6aa3 --- /dev/null +++ b/,vscode/tasks.json @@ -0,0 +1,15 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "", + "type": "cmake", + "command": "test", + "problemMatcher": [ + "" + ] + } + ] +} \ No newline at end of file diff --git a/.vs/appsettings.json b/.vs/appsettings.json new file mode 100644 index 0000000..aef2386 --- /dev/null +++ b/.vs/appsettings.json @@ -0,0 +1,13 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Error", + "Microsoft": "Warning" + }, + "Console": { + "LogLevel": { + "Microsoft": "Information" + } + } + } +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e3046bb --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1 @@ +cmake -DCMAKE_LINKER=/usr/bin/ld -DCMAKE_CXX_LINK_EXECUTABLE=" -o " \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index f0c53dc..4628804 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ # ClassicOS -An x86 Operating System for 386, 486, Pentium class (P-75, 100, Pentium II, P3, P4, etc + +An x86 Operating System for 386, 486, Pentium class (P-75, 100, Pentium II, P3, P4, etc) CPU's + +## Tooling + +These are the versions I use, but please use the latest possible versions. + +NASM version 2.14 +QEMU x86_64 +GNU ld (GNU Binutils for Debian) 2.31.1 or newer +dd (coreutils) 8.30 + +The C and C++ standards we are using for this are C17 and C++20 + +For C/C++: + clang version 7.0.1-8+deb10u2 (tags/RELEASE_701/final) + gcc version 8.3.0 (Debian 8.3.0-6) + g++ version 8.3.0 (Debian 8.3.0-6) + GNU gdb (Debian 8.2.1-2+b3) 8.2.1 + lldb version 7.0.1 diff --git a/build/boot.bin b/build/boot.bin new file mode 100755 index 0000000..be6606d Binary files /dev/null and b/build/boot.bin differ diff --git a/src/boot/boot.asm b/src/boot/boot.asm new file mode 100644 index 0000000..901d3b8 --- /dev/null +++ b/src/boot/boot.asm @@ -0,0 +1,61 @@ +; Set up the segment registers + xor ax, ax + mov ds, ax + mov es, ax + + ; Set up stack and jump to main + mov ss, ax + mov sp, 0x7c00 + jmp main + + ; Print 'Booting ClassicOS!' to the screen + print: + mov si, message + mov ah, 0x0e + .loop: + lodsb + test al, al + jz .done + int 0x10 + jmp .loop + .done: + ret + + ; Set the video mode to a 40 column text mode + set_video_mode: + mov ax, 0x0003 ; Set up a 80x25 text mode + int 0x10 + + ; Set the number of columns to 40 + mov ax, 0x1112 + mov bx, 0x0007 + int 0x10 + + ret + + ; Bootloader entry point + main: + ; Call the set_video_mode function + call set_video_mode + + ; Clear the screen + mov ah, 0x06 + mov al, 0 + xor bx, bx + xor cx, cx + mov dh, 24 + mov dl, 39 + int 0x10 + + ; Call the print function + call print + + ; Infinite loop + .loop: + jmp .loop + + ; Message to print + message db 'Booting ClassicOS!', 0 + + times 510-($-$$) db 0 + dw 0xaa55 diff --git a/src/boot/linker.ld b/src/boot/linker.ld new file mode 100644 index 0000000..0cfaef4 --- /dev/null +++ b/src/boot/linker.ld @@ -0,0 +1,8 @@ + ENTRY(boot) + SECTIONS { + . = 0x7c00; + .text : { + *(.text) + } + /* Add other sections as needed */ + } \ No newline at end of file diff --git a/src/drivers/screen/screen.c b/src/drivers/screen/screen.c new file mode 100644 index 0000000..d34b868 --- /dev/null +++ b/src/drivers/screen/screen.c @@ -0,0 +1,27 @@ +#include "screen.h" +#include + +void screen_init() { + // Initialize the screen driver + // Add any necessary initialization code here +} + +void set_40_column_mode() { + // Set the screen mode to 40 columns + union REGS regs; + regs.h.ah = 0x00; + regs.h.al = 0x03; + int86(0x10, ®s, ®s); +} + +void set_80_column_mode() { + // Set the screen mode to 80 columns + union REGS regs; + regs.h.ah = 0x00; + regs.h.al = 0x03; + int86(0x10, ®s, ®s); + + regs.h.ah = 0x00; + regs.h.al = 0x07; + int86(0x10, ®s, ®s); +} \ No newline at end of file diff --git a/src/drivers/screen/screen.h b/src/drivers/screen/screen.h new file mode 100644 index 0000000..f943148 --- /dev/null +++ b/src/drivers/screen/screen.h @@ -0,0 +1,13 @@ +#ifndef SCREEN_H +#define SCREEN_H + +// Function to initialize the screen driver +void screen_init(); + +// Function to set the screen mode to 40 columns +void set_40_column_mode(); + +// Function to set the screen mode to 80 columns +void set_80_column_mode(); + +#endif \ No newline at end of file diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c new file mode 100644 index 0000000..d647160 --- /dev/null +++ b/src/kernel/kernel.c @@ -0,0 +1,12 @@ +#include "kernel.h" + +void kernel_main() { + // Your kernel code here + // Example: Print a message to the screen + print_string("Welcome to ClassicOS!"); + + // Infinite loop to keep the kernel running + while (1) { + // Your kernel code here + } +} \ No newline at end of file diff --git a/src/kernel/kernel.h b/src/kernel/kernel.h new file mode 100644 index 0000000..1dc902c --- /dev/null +++ b/src/kernel/kernel.h @@ -0,0 +1,7 @@ +#ifndef KERNEL_H +#define KERNEL_H + +// Function to print a null-terminated string to the screen +void print_string(const char* str); + +#endif \ No newline at end of file