diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..c2098a2 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "linux-gcc-x64", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "/usr/bin/gcc", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "linux-gcc-x64", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..3e5234c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": false, + "externalConsole": false, + "cwd": "/home/p7mj/Desktop/ISCCS-1", + "program": "/home/p7mj/Desktop/ISCCS-1/build/Debug/outDebug", + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..bb879da --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,59 @@ +{ + "C_Cpp_Runner.cCompilerPath": "gcc", + "C_Cpp_Runner.cppCompilerPath": "g++", + "C_Cpp_Runner.debuggerPath": "gdb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wcast-align", + "-Wconversion", + "-Wsign-conversion", + "-Wnull-dereference" + ], + "C_Cpp_Runner.msvcWarnings": [ + "/W4", + "/permissive-", + "/w14242", + "/w14287", + "/w14296", + "/w14311", + "/w14826", + "/w44062", + "/w44242", + "/w14905", + "/w14906", + "/w14263", + "/w44265", + "/w14928" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.useUndefinedSanitizer": false, + "C_Cpp_Runner.useLeakSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false, + "C_Cpp_Runner.useLinkTimeOptimization": false, + "C_Cpp_Runner.msvcSecureNoWarnings": false +} \ No newline at end of file diff --git a/boot.asm b/boot.asm new file mode 100644 index 0000000..d6e73c1 --- /dev/null +++ b/boot.asm @@ -0,0 +1,61 @@ +[bits 16] +section .text +global _start + +_start: + mov [BOOT_DRIVE], dl ; Save the boot drive number provided by BIOS + + mov bp, 0x9000 + mov sp, bp + + call load_kernel ; Load extra sectors from the disk + call switch_to_pm ; Transition to 32-bit mode + jmp $ + +%include "gdt.asm" + +[bits 16] +load_kernel: + mov bx, 0x7e00 ; Destination memory address for kernel code + mov dh, 30 ; Number of sectors to read + mov dl, [BOOT_DRIVE] + mov ah, 0x02 ; BIOS read sectors function + mov al, dh + mov ch, 0x00 + mov dh, 0x00 + mov cl, 0x02 ; Start reading from the second sector + + int 0x13 ; Trigger BIOS disk interrupt + + jc disk_error + ret + +disk_error: + jmp $ + +[bits 16] +switch_to_pm: + cli + lgdt [gdt_descriptor] + mov eax, cr0 + or eax, 0x1 + mov cr0, eax + jmp CODE_SEG:init_pm + +[bits 32] +extern main +init_pm: + mov ax, DATA_SEG + mov ds, ax + mov ss, ax + mov es, ax + mov fs, ax + mov gs, ax + + mov ebp, 0x90000 + mov esp, ebp + + call main + jmp $ + +BOOT_DRIVE db 0 \ No newline at end of file diff --git a/boot.o b/boot.o new file mode 100644 index 0000000..3a8f1d4 Binary files /dev/null and b/boot.o differ diff --git a/file.py b/file.py deleted file mode 100644 index e69de29..0000000 diff --git a/gdt.asm b/gdt.asm new file mode 100644 index 0000000..86ca333 --- /dev/null +++ b/gdt.asm @@ -0,0 +1,29 @@ +gdt_start: + dq 0x0 ; The null descriptor (mandatory) + +; Code Segment Descriptor +gdt_code: + dw 0xffff ; Limit + dw 0x0 ; Base (bits 0-15) + db 0x0 ; Base (bits 16-23) + db 10011010b ; Access byte + db 11001111b ; Flags + Limit (bits 16-19) + db 0x0 ; Base (bits 24-31) + +; Data Segment Descriptor +gdt_data: + dw 0xffff + dw 0x0 + db 0x0 + db 10010010b + db 11001111b + db 0x0 + +gdt_end: + +gdt_descriptor: + dw gdt_end - gdt_start - 1 + dd gdt_start + +CODE_SEG equ gdt_code - gdt_start +DATA_SEG equ gdt_data - gdt_start \ No newline at end of file diff --git a/kernel.c b/kernel.c new file mode 100644 index 0000000..33dbdbf --- /dev/null +++ b/kernel.c @@ -0,0 +1,25 @@ +void clear_screen() { + char* video_memory = (char*) 0xb8000; + for (int i = 0; i < 80 * 25 * 2; i += 2) { + video_memory[i] = ' '; // Clear char + video_memory[i+1] = 0x07; // Light grey on black + } +} + +void print_string(char* str, unsigned char color, int line) { + char* video_memory = (char*) 0xb8000; + int offset = line * 160; + + for (int i = 0; str[i] != '\0'; i++) { + video_memory[offset + (i * 2)] = str[i]; + video_memory[offset + (i * 2) + 1] = color; + } +} + +void main() { + clear_screen(); + print_string("Welcome to ISCCS OS!", 0x0a, 1); + print_string("Kernel Loaded in 32-bit Protected Mode.", 0x0f, 2); + + while(1); +} \ No newline at end of file diff --git a/kernel.o b/kernel.o new file mode 100644 index 0000000..2fecb8a Binary files /dev/null and b/kernel.o differ diff --git a/linker.ld b/linker.ld new file mode 100644 index 0000000..960e6d1 --- /dev/null +++ b/linker.ld @@ -0,0 +1,22 @@ +ENTRY(_start) +OUTPUT_FORMAT("binary") + +SECTIONS +{ + /* Start at the BIOS boot address */ + . = 0x7c00; + + .text : { + boot.o(.text) /* Ensure bootloader is at the very beginning */ + *(.text) /* Compiled C code follows */ + *(.rodata) /* REQUIRED: Text strings live here */ + } + + .data : { *(.data) } + .bss : { *(.bss) } + + /* Place the 0xAA55 signature exactly at the end of the first 512 bytes */ + .sig : AT(0x7dfe) { + SHORT(0xaa55); + } +} \ No newline at end of file diff --git a/networking.py b/networking.py deleted file mode 100644 index e69de29..0000000 diff --git a/os-image.bin b/os-image.bin new file mode 100755 index 0000000..d6dfb59 Binary files /dev/null and b/os-image.bin differ