ClassicOS/ask.txt

217 lines
7.2 KiB
Plaintext
Raw Normal View History

I am making a fully custom x86 32 bit IA32 Operating System in Visual Studio Code 1.81 for Debian Linux. This will not be a linux based OS. It's also not posix, linux, unix, windows, bsd or any other derivitive thereof but does use the same concepts. The system I am developing on has a Intel i7-3770k and is an x86_64 bit and runs Debian 10 Buster Linux with Linux Kernel version 4.19.0-25-amd64 (supports UNIX 98 PTY) and Bash 5.0.3 and the drive has an ext4 partition and a tempfs partition. I have the extension ms-vscode.cpptools installed on VSCode. I also have both gcc 8.3.0 and clang 7.0.1-8+deb10u2 installed. All of my compilers, debuggers, linkers are in /usr/bin. I have Coreutils 8.30, Binutils 2.31.1, Bison 3.3.2, Diffutils 3.7, Findutils 4.6.0.225, Gawk 4.2.1, Grep 3.3, Gzip 1.9, M4 1.4.18, Make 4.2.1, Patch 2.7.6, Perl 5.28.1, Python 3.7.3, Sed 4.7, Tar 1.30, Texinfo 6.5, Xz 5.2.4. The operating system would run on any system that has a 386 CPU up to a 32 bit only Prescott Pentium 4 released in 2004. I am using gcc to compile, ld to link, gdb to debug, nasm to do the assembly and qemu to emulate the system. it has a two stage bootloader. The os should boot from floppy, hard drive and optical media.
here is the file structure:
ClassicOS/
├── .github/
├── .vs/
├── .vscode/
├── CMakeLists.txt
├── README.md
├── build/
│ ├── boot.bin
│ ├── boot.o
├── include/
├── src/
│ ├── boot/
│ │ ├── grub/
│ │ │ ├── grub.cfg
│ │ │ └── menu.lst
│ │ ├── boot.asm
│ │ ├── boot.o
│ │ ├── boot2.asm
│ │ ├── linker.ld
│ ├── cpu/
│ │ ├── cpu.c
│ │ ├── cpu.h
│ ├── drivers/
│ │ ├── audio/
│ │ │ ├── audio.c
│ │ │ └── audio.h
│ │ ├── bus/
│ │ │ ├── eisa.c
│ │ │ ├── eisa.h
│ │ │ ├── isa.c
│ │ │ ├── isa.h
│ │ │ ├── mca.c
│ │ │ ├── mca.h
│ │ │ ├── pci.c
│ │ │ ├── pci.h
│ │ │ ├── vesa.c
│ │ │ └── vesa.h
│ │ ├── display/
│ │ │ ├── display.c
│ │ │ ├── display.h
│ │ │ ├── vga.c
│ │ │ └── vga.h
│ │ ├── io/
│ │ │ ├── io.c
│ │ │ ├── io.c
│ │ │ ├── serial.c
│ │ │ └── serial.h
│ │ ├── keyboard/
│ │ │ ├── keyboard.c
│ │ │ └── keyboard.h
│ │ ├── mouse/
│ │ │ ├── mouse.c
│ │ │ └── mouse.h
│ │ ├── network/
│ │ │ ├── ne2000.c
│ │ │ └── ne2000.h
│ │ ├── screen/
│ │ │ ├── console.c
│ │ │ ├── console.c
│ │ │ ├── screen.c
│ │ │ └── screen.h
│ │ ├── tty/
│ │ │ ├── tty.c
│ │ │ └── tty.h
│ ├── filesystem/
│ │ ├── fat16/
│ │ │ ├── fat16.h
│ │ │ └── fat16.h
│ │ ├── fat32/
│ │ │ ├── fat32.c
│ │ │ └── fat32.h
│ ├── gui/
│ │ ├── gui.c
│ │ ├── gui.h
│ ├── kernel/
│ │ ├── arch/
│ │ │ └── x86/
│ │ │ │ └── include/
│ │ │ │ │ ├── memory.h
│ │ │ │ │ ├── types.h
│ │ │ │ │ └── types.h
│ │ │ │ └── isr/
│ │ │ │ │ ├── exceptions.c
│ │ │ │ │ ├── exceptions.h
│ │ │ │ │ ├── isr.asm
│ │ │ │ │ ├── isr.c
│ │ │ │ │ └── isr.h
│ │ │ │ └── memory/
│ │ │ │ │ ├── memory.c
│ │ │ │ │ └── memory.o
│ │ │ ├── gdt.asm
│ │ │ ├── gdt.c
│ │ │ ├── gdt.h
│ │ │ ├── gdt.o
│ │ │ ├── idt.asm
│ │ │ ├── idt.c
│ │ │ ├── idt.h
│ │ │ ├── gdt.o
│ │ │ ├── isr.c
│ │ │ └── isr.h
│ │ └── malloc/
│ │ │ ├── kmalloc.c
│ │ │ └── kmalloc.h
│ │ ├── acpi.c
│ │ ├── acpi.h
│ │ ├── kernel.c
│ │ ├── kernel.h
│ │ ├── kernel.o
│ │ ├── linker.ld
│ │ ├── print.c
│ │ ├── print.h
│ │ ├── stack.c
│ │ ├── stack.h
│ │ ├── timer.c
│ │ └── timer.h
│ └── shell/
│ ├── shell.c
│ └── shell.h
│ ├── elf.C
│ └── elf.h
└── std/
This is my CMakeLists.txt
cmake_minimum_required(VERSION 3.13.4)
project(ClassicOS VERSION 0.0.1 LANGUAGES C)
# Source files
set(BOOT_SOURCE_FILES
src/boot/boot.asm
src/boot/linker.ld
)
set(GRUB_SOURCE_FILES
src/boot/grub/grub.cfg
src/boot/grub/menu.lst
)
set(DRIVERS_SOURCE_FILES
src/drivers/audio/audio.c
src/drivers/audio/audio.h
src/drivers/bus/eisa.c
src/drivers/bus/eisa.h
src/drivers/bus/isa.c
src/drivers/bus/isa.h
src/drivers/bus/mca.c
src/drivers/bus/mca.h
src/drivers/bus/pci.c
src/drivers/bus/pci.h
src/drivers/bus/vesa.c
src/drivers/bus/vesa.h
src/drivers/display/display.c
src/drivers/display/display.h
src/drivers/io/io.c
src/drivers/io/io.h
src/drivers/keyboard/keyboard.c
src/drivers/keyboard/keyboard.h
src/drivers/screen/screen.c
src/drivers/screen/screen.h
src/drivers/tty/tty.c
src/drivers/tty/tty.h
)
set(KERNEL_SOURCE_FILES
src/kernel/arch/x86/include/memory.h
src/kernel/arch/x86/include/types.h
src/kernel/arch/x86/include/types.h
src/kernel/arch/x86/memory/memory.c
src/kernel/arch/x86/gdt.c
src/kernel/arch/x86/gdt.c
src/kernel/arch/x86/idt.c
src/kernel/arch/x86/idt.h
src/kernel/arch/x86/isr.c
src/kernel/arch/x86/isr.h
src/kernel/kernel.c
src/kernel/kernel.h
src/kernel/linker.ld
src/kernel/print.c
)
add_executable(ClassicOS
${BOOT_SOURCE_FILES}
${GRUB_SOURCE_FILES}
${DRIVERS_SOURCE_FILES}
${KERNEL_SOURCE_FILES}
)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Enable testing
enable_testing()
target_link_libraries(ClassicOS PRIVATE)
set(CMAKE_C_COMPILER gcc)
set(CMAKE_LINKER ld)
set(CMAKE_EXE_LINKER_FLAGS "-g -s")
set(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} -e kernel_main")
set(CMAKE_CXX_FLAGS "-g -Wall")
set(CMAKE_C_FLAGS "-g -Wall -m32")
set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_GDB_COMMAND gdb)
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_ASM_COMPILER nasm)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} --32")
set(CMAKE_SYSTEM_PROCESSOR i386)
set(CMAKE_SYSTEM_NAME None)
set(CMAKE_ASM_NASM_COMPILER nasm)
set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
set_target_properties(ClassicOS PROPERTIES LINK_FLAGS "-T ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld")