From 8dbc66b68b12e1da65f352bcf62149cb9258478f Mon Sep 17 00:00:00 2001 From: Greg Bowne Date: Sat, 31 Aug 2024 16:50:33 -0700 Subject: [PATCH] Reset repository with new OS files --- .gitignore | 52 +++++++++++++++ CMakeLists.txt | 2 + Makefile | 0 README.md | 175 +++++++++++++++++++++++++++++++++++++++++++++++++ boot1.asm | 19 ++++++ boot2.asm | 63 ++++++++++++++++++ boot3.asm | 78 ++++++++++++++++++++++ boot4.asm | 85 ++++++++++++++++++++++++ build.sh | 0 kernel.c | 0 linker.ld | 26 ++++++++ 11 files changed, 500 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 Makefile create mode 100644 README.md create mode 100644 boot1.asm create mode 100644 boot2.asm create mode 100644 boot3.asm create mode 100644 boot4.asm create mode 100644 build.sh create mode 100644 kernel.c create mode 100644 linker.ld diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c6127b3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,52 @@ +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7328f9b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.13.4) + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md new file mode 100644 index 0000000..41e3b45 --- /dev/null +++ b/README.md @@ -0,0 +1,175 @@ +# ClassicOS + +This operating system uses standard operating system concepts used in the 32 bit environment. It will eventually be ported to 64 bit including IA64. +This ClassicOS operating system, aims to support major hardware and software technology existing from when the first 32 bit systems appeared on the market through the early 2000's and most of those have been listed below. + +## Programming + +This project uses the C library and Assembly language. + +## Toolchain + +GNU Make 4.2.1 +CMake 3.13.4 +GNU 8.3.0 +gcc (Debian 8.3.0-6) 8.3.0 +nasm 2.14 +GNU ld (GNU Binutils for Debian) 2.31.1 +binutils + +For testing, QEMU i386 and TigerVNC/VNCViewer on ::1:5900 + +## Development (Team, etc) + +This project will use MIT or the GPL license and will be fully open source. + +Ideal situations aside, My goal has always been: + +1-2 person working on bootloader +1-2 person working on kernel +1-2 person working on drivers +1-2 person working on issues/bugs +1-2 people working on applications/user-space +1-2 people working on Networking +1-2 people working on memmory issues, stack issues, etc. + +at least one person doing hardware and software testing and writing tests in a test framework + +At least one major bug fix a week +At least one minor buf fix a week +At least one new feature a month (or more) + +## CPU Processor Support + +This project initially aims to support all 32 bit Intel and AMD processors Including; + +-- Intel -- +i386 SX and DX Processors +i486 SX and DX Processors +Pentium Processors (60 to 120MHz) +Pentium Pro Processors +Pentium II Processors +Pentium II Xeon Processors +Pentium III Processors +Pentium III Xeon Processors +early Pentium 4 Processors (Willamette, Prescott, Northwood) + +-- AMD -- + +AMD k5 +AMD K6 +AMD am386 +AMD am486 +Athlon +Duron +Sempron + +## Device Support + +USB 1.0 +USB 1.1 +USB 2.0 +USB 2.1 +SATA 1 +UDMA +UltraATA 66/100/133 +SCSI-1 +SCSI-2 +SCSI-3 +Ultra-2 SCSI +Ultra-3 SCSI +ESDI +MFM/RLL + +## Booting + +BIOS from + +- primary hard disk partition +- primary floppy +- ISO 9660 CD-ROM, CD-R,CD-RW, +- DVD +- Removable media (Zip, Jaz, USB, Tape, Syquest, Bernoulli, CF, SmartMedia, SD etc) + +Might eventually support GRUB/GRUB2 and/or UEFI/EFI. + +Include support for AHCI and ACPI + +## Bus Support + +ISA +EISA +VESA/VESA Local Bus (VLB) +PCI +PCI-X +PCIe 1.0, 1.1, 2.0 +AGP +DIN 41416/NuBUS + +## Hardware support + +This OS aims to support major hardware existing from 1985 to early 2k's. + +## Memory Support + +up to 4GB + +## Features + +Has a GUI +Has a IDE +Has a text editor +Has compilers for compiled lanugages (C, C++, C#, Go, Java, Fortran, Pascal, Objective C, Haskell, ADA, Scala, Rust, Zig, Ocaml, Julia, Dart, Erlang, Elixir) +Has a Web Browser +Has a shell, tty, console, terminal +Has interpreters for interpreted languages like python 2 and python 3, JavaScript, BASIC, PHP, etc. +Has a git client +Has a video, audio editing and playing suite +Has a file browser (in GUI) +Has debuggers for languages/compilers, etc that output symbols, etc. + +## Video Support + +-- Modes -- +CGA +EGA +VGA +SVGA +MCGA +XGA +HGA / Hercules +XGA-2 +SXGA +UXGA +WXGA +8514/a +VESA SVGA +VESA/VLB +AGP (1.0, 2.0, 3.0, 3.5, Pro) - 66MHz - aka AGP 1X, 2X, 4X, 8X +PCI Graphics + +-- Resolutions -- + +## Networking + +Novell NE1000 +Novell NE2000 + +## Drivers + +-- Video card(s) +-- NIC's (3Com, Intel, etc.) +-- Audio + +## Filesystems + +- FAT12 +- FAT16/FAT16B/FAT16X +- FAT32/FAT32X +- NTFS +- HPFS +- HFS / HFS+ +- ext / ext2 / ext3 +- exFAT +- ZFS +- JFS diff --git a/boot1.asm b/boot1.asm new file mode 100644 index 0000000..ac395f7 --- /dev/null +++ b/boot1.asm @@ -0,0 +1,19 @@ +bits 16 +org 0x7c00 + +boot: + mov si,hello + mov ah, 0x0e +.loop: + lodsb + or al,al + jz halt + int 0x10 + jmp .loop +halt: + cli + hlt +hello: db "Hello world!",0 + +times 510 - ($-$$) db 0 +dw 0xaa55 diff --git a/boot2.asm b/boot2.asm new file mode 100644 index 0000000..0581bb6 --- /dev/null +++ b/boot2.asm @@ -0,0 +1,63 @@ +bits 16 +org 0x7c00 + +boot: + mov ax, 0x2401 + int 0x15 + mov ax, 0x3 + int 0x10 + cli + lgdt [gdt_pointer] + mov eax, cr0 + or eax,0x1 + mov cr0, eax + jmp CODE_SEG:boot2 +gdt_start: + dq 0x0 +gdt_code: + dw 0xFFFF + dw 0x0 + db 0x0 + db 10011010b + db 11001111b + db 0x0 +gdt_data: + dw 0xFFFF + dw 0x0 + db 0x0 + db 10010010b + db 11001111b + db 0x0 +gdt_end: +gdt_pointer: + dw gdt_end - gdt_start + dd gdt_start + +CODE_SEG equ gdt_code - gdt_start +DATA_SEG equ gdt_data - gdt_start + +bits 32 +boot2: + mov ax, DATA_SEG + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + mov esi,hello + mov ebx,0xb8000 +.loop: + lodsb + or al,al + jz halt + or eax,0x0100 + mov word [ebx], ax + add ebx,2 + jmp .loop +halt: + cli + hlt +hello: db "Hello world!",0 + +times 510 - ($-$$) db 0 +dw 0xaa55 diff --git a/boot3.asm b/boot3.asm new file mode 100644 index 0000000..13a7d89 --- /dev/null +++ b/boot3.asm @@ -0,0 +1,78 @@ +bits 16 +org 0x7c00 + +boot: + mov ax, 0x2401 + int 0x15 + + mov ax, 0x3 + int 0x10 + + mov [disk],dl + + mov ah, 0x2 ;read sectors + mov al, 1 ;sectors to read + mov ch, 0 ;cylinder idx + mov dh, 0 ;head idx + mov cl, 2 ;sector idx + mov dl, [disk] ;disk idx + mov bx, copy_target;target pointer + int 0x13 + cli + lgdt [gdt_pointer] + mov eax, cr0 + or eax,0x1 + mov cr0, eax + mov ax, DATA_SEG + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + jmp CODE_SEG:boot2 +gdt_start: + dq 0x0 +gdt_code: + dw 0xFFFF + dw 0x0 + db 0x0 + db 10011010b + db 11001111b + db 0x0 +gdt_data: + dw 0xFFFF + dw 0x0 + db 0x0 + db 10010010b + db 11001111b + db 0x0 +gdt_end: +gdt_pointer: + dw gdt_end - gdt_start + dd gdt_start +disk: + db 0x0 +CODE_SEG equ gdt_code - gdt_start +DATA_SEG equ gdt_data - gdt_start + +times 510 - ($-$$) db 0 +dw 0xaa55 +copy_target: +bits 32 + hello: db "Hello more than 512 bytes world!!",0 +boot2: + mov esi,hello + mov ebx,0xb8000 +.loop: + lodsb + or al,al + jz halt + or eax,0x0F00 + mov word [ebx], ax + add ebx,2 + jmp .loop +halt: + cli + hlt + +times 1024 - ($-$$) db 0 \ No newline at end of file diff --git a/boot4.asm b/boot4.asm new file mode 100644 index 0000000..bea5f84 --- /dev/null +++ b/boot4.asm @@ -0,0 +1,85 @@ +section .boot +bits 16 +global boot +boot: + mov ax, 0x2401 + int 0x15 + + mov ax, 0x3 + int 0x10 + + mov [disk],dl + + mov ah, 0x2 ;read sectors + mov al, 6 ;sectors to read + mov ch, 0 ;cylinder idx + mov dh, 0 ;head idx + mov cl, 2 ;sector idx + mov dl, [disk] ;disk idx + mov bx, copy_target;target pointer + int 0x13 + cli + lgdt [gdt_pointer] + mov eax, cr0 + or eax,0x1 + mov cr0, eax + mov ax, DATA_SEG + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + jmp CODE_SEG:boot2 +gdt_start: + dq 0x0 +gdt_code: + dw 0xFFFF + dw 0x0 + db 0x0 + db 10011010b + db 11001111b + db 0x0 +gdt_data: + dw 0xFFFF + dw 0x0 + db 0x0 + db 10010010b + db 11001111b + db 0x0 +gdt_end: +gdt_pointer: + dw gdt_end - gdt_start + dd gdt_start +disk: + db 0x0 +CODE_SEG equ gdt_code - gdt_start +DATA_SEG equ gdt_data - gdt_start + +times 510 - ($-$$) db 0 +dw 0xaa55 +copy_target: +bits 32 + hello: db "Hello more than 512 bytes world!!",0 +boot2: + mov esi,hello + mov ebx,0xb8000 +.loop: + lodsb + or al,al + jz halt + or eax,0x0F00 + mov word [ebx], ax + add ebx,2 + jmp .loop +halt: + mov esp,kernel_stack_top + extern kmain + call kmain + cli + hlt + +section .bss +align 4 +kernel_stack_bottom: equ $ + resb 16384 ; 16 KB +kernel_stack_top: diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..e69de29 diff --git a/kernel.c b/kernel.c new file mode 100644 index 0000000..e69de29 diff --git a/linker.ld b/linker.ld new file mode 100644 index 0000000..72956ac --- /dev/null +++ b/linker.ld @@ -0,0 +1,26 @@ +ENTRY(boot) +OUTPUT_FORMAT("binary") +SECTIONS { + . = 0x7c00; + .text : + { + *(.boot) + *(.text) + } + + .rodata : + { + *(.rodata) + } + + .data : + { + *(.data) + } + + .bss : + { + *(.bss) + } +} +