├── Bootloader
├── ExtendedOS
│ ├── img
│ │ └── MY_OS.bin
│ └── src
│ │ └── my_operating_system.asm
├── HelloWorld
│ ├── img
│ │ └── HelloWorld_OS.bin
│ └── src
│ │ └── hello_world.asm
├── HelloWorld_without_BIOS
│ ├── img
│ │ └── HelloWorld_withoutBIOS.bin
│ └── src
│ │ └── hello_world_without_bios.asm
├── README.txt
└── Sample
│ └── set_caret_pos
│ └── set_caret_pos.asm
├── CPUInfo
├── README.md
├── asm
│ ├── cpuinfo.asm
│ └── cpuinfo_asm.png
└── cpu_info_c
│ ├── boot.s
│ ├── c_cpuinfo.png
│ ├── clean.sh
│ ├── grub.cfg
│ ├── kernel.c
│ ├── kernel.h
│ ├── linker.ld
│ └── run.sh
├── GUI
├── Graphics in Assembly
│ └── Simple
│ │ ├── Readme.md
│ │ ├── dda_line_draw
│ │ ├── img
│ │ │ ├── dda_line_draw.bin
│ │ │ └── dda_line_draw.png
│ │ └── src
│ │ │ └── dda.asm
│ │ ├── drawpixel
│ │ ├── img
│ │ │ ├── draw_pixel.bin
│ │ │ └── draw_pixels.png
│ │ └── src
│ │ │ └── drawpixel.asm
│ │ └── rectangle
│ │ ├── Readme.md
│ │ ├── img
│ │ ├── rectangle.bin
│ │ └── rectangle.png
│ │ └── src
│ │ ├── Readme.txt
│ │ ├── dda.asm
│ │ ├── drawpixel.asm
│ │ └── rectangle.asm
├── README.md
├── ascii_chars
│ ├── ascii_chars_0_255.png
│ ├── boot.s
│ ├── clean.sh
│ ├── grub.cfg
│ ├── kernel.c
│ ├── kernel.h
│ ├── linker.ld
│ ├── run.sh
│ ├── types.h
│ ├── utils.c
│ └── utils.h
├── box
│ ├── boot.s
│ ├── box_demo_kernel.png
│ ├── clean.sh
│ ├── grub.cfg
│ ├── kernel.c
│ ├── kernel.h
│ ├── linker.ld
│ ├── run.sh
│ ├── types.h
│ ├── utils.c
│ └── utils.h
└── dosbox_gui
│ ├── boot.s
│ ├── clean.sh
│ ├── dosbox_gui.png
│ ├── grub.cfg
│ ├── kernel.c
│ ├── kernel.h
│ ├── linker.ld
│ ├── run.sh
│ ├── types.h
│ ├── utils.c
│ └── utils.h
├── Global_Descriptor_Table
├── README.md
├── asm
│ └── gdt.asm
└── kernel_C
│ ├── boot.s
│ ├── clean.sh
│ ├── gdt.c
│ ├── gdt.h
│ ├── grub.cfg
│ ├── kernel.c
│ ├── kernel.h
│ ├── linker.ld
│ ├── load_gdt.s
│ ├── run.sh
│ └── types.h
├── Interrupt_Descriptor_Table
├── README.md
├── boot.s
├── clean.sh
├── gdt.c
├── gdt.h
├── grub.cfg
├── idt.c
├── idt.h
├── idt_demo.png
├── isr.c
├── isr.h
├── kernel.c
├── kernel.h
├── linker.ld
├── load_gdt.s
├── load_idt.s
├── run.sh
├── types.h
├── util.c
└── util.h
├── Kernel
├── Keyboard
│ ├── README.md
│ ├── ascii.jpg
│ ├── boot.s
│ ├── char.c
│ ├── char.h
│ ├── clean.sh
│ ├── grub.cfg
│ ├── kernel.c
│ ├── kernel.h
│ ├── keyboard.h
│ ├── keyboard_demo.png
│ ├── keycodes.png
│ ├── linker.ld
│ ├── run.sh
│ ├── types.h
│ ├── utils.c
│ └── utils.h
├── README.md
└── Simple
│ ├── img
│ ├── kernel_1
│ │ └── MyOS.iso
│ └── kernel_2
│ │ └── MyOS.iso
│ └── src
│ ├── kernel_1
│ ├── boot.s
│ ├── grub.cfg
│ ├── kernel.c
│ ├── kernel.h
│ ├── linker.ld
│ └── run.sh
│ └── kernel_2
│ ├── boot.s
│ ├── grub.cfg
│ ├── kernel.c
│ ├── kernel.h
│ ├── linker.ld
│ └── run.sh
├── NEW KERNEL
├── ATA
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── 8259_pic.h
│ │ ├── console.h
│ │ ├── gdt.h
│ │ ├── ide.h
│ │ ├── idt.h
│ │ ├── io_ports.h
│ │ ├── isr.h
│ │ ├── kernel.h
│ │ ├── keyboard.h
│ │ ├── string.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ ├── screenshots
│ │ ├── ata_1.png
│ │ ├── ata_2.png
│ │ ├── ata_3.png
│ │ ├── ata_4.png
│ │ ├── ata_5.png
│ │ ├── ata_6.png
│ │ ├── ata_7.png
│ │ ├── ata_8.png
│ │ ├── ata_output.png
│ │ └── ata_output_check.png
│ └── src
│ │ ├── 8259_pic.c
│ │ ├── asm
│ │ ├── entry.asm
│ │ ├── exception.asm
│ │ ├── irq.asm
│ │ ├── load_gdt.asm
│ │ └── load_idt.asm
│ │ ├── console.c
│ │ ├── gdt.c
│ │ ├── ide.c
│ │ ├── idt.c
│ │ ├── io_ports.c
│ │ ├── isr.c
│ │ ├── kernel.c
│ │ ├── keyboard.c
│ │ ├── string.c
│ │ └── vga.c
├── BIOS32
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── 8259_pic.h
│ │ ├── bios32.h
│ │ ├── console.h
│ │ ├── gdt.h
│ │ ├── idt.h
│ │ ├── io_ports.h
│ │ ├── isr.h
│ │ ├── kernel.h
│ │ ├── string.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── kernel_bios32.png
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── 8259_pic.c
│ │ ├── asm
│ │ ├── bios32_call.asm
│ │ ├── entry.asm
│ │ ├── exception.asm
│ │ ├── irq.asm
│ │ ├── load_gdt.asm
│ │ └── load_idt.asm
│ │ ├── bios32.c
│ │ ├── console.c
│ │ ├── gdt.c
│ │ ├── idt.c
│ │ ├── io_ports.c
│ │ ├── isr.c
│ │ ├── kernel.c
│ │ ├── string.c
│ │ └── vga.c
├── Bitmap Text
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── 8259_pic.h
│ │ ├── bios32.h
│ │ ├── bitmap.h
│ │ ├── console.h
│ │ ├── gdt.h
│ │ ├── idt.h
│ │ ├── io_ports.h
│ │ ├── isr.h
│ │ ├── kernel.h
│ │ ├── keyboard.h
│ │ ├── kheap.h
│ │ ├── multiboot.h
│ │ ├── pmm.h
│ │ ├── string.h
│ │ ├── types.h
│ │ ├── vesa.h
│ │ └── vga.h
│ ├── kernel_bitmap_text.png
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── 8259_pic.c
│ │ ├── asm
│ │ ├── bios32_call.asm
│ │ ├── entry.asm
│ │ ├── exception.asm
│ │ ├── irq.asm
│ │ ├── load_gdt.asm
│ │ └── load_idt.asm
│ │ ├── bios32.c
│ │ ├── bitmap.c
│ │ ├── console.c
│ │ ├── gdt.c
│ │ ├── idt.c
│ │ ├── io_ports.c
│ │ ├── isr.c
│ │ ├── kernel.c
│ │ ├── keyboard.c
│ │ ├── kheap.c
│ │ ├── pmm.c
│ │ ├── string.c
│ │ ├── vesa.c
│ │ └── vga.c
├── Console
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── console.h
│ │ ├── io_ports.h
│ │ ├── kernel.h
│ │ ├── string.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── kernel_console.png
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── asm
│ │ └── entry.asm
│ │ ├── console.c
│ │ ├── io_ports.c
│ │ ├── kernel.c
│ │ ├── string.c
│ │ └── vga.c
├── FPU
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── 8259_pic.h
│ │ ├── console.h
│ │ ├── fpu.h
│ │ ├── gdt.h
│ │ ├── idt.h
│ │ ├── io_ports.h
│ │ ├── isr.h
│ │ ├── kernel.h
│ │ ├── keyboard.h
│ │ ├── string.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── kernel_fpu.png
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── 8259_pic.c
│ │ ├── asm
│ │ ├── entry.asm
│ │ ├── exception.asm
│ │ ├── irq.asm
│ │ ├── load_gdt.asm
│ │ └── load_idt.asm
│ │ ├── console.c
│ │ ├── fpu.c
│ │ ├── gdt.c
│ │ ├── idt.c
│ │ ├── io_ports.c
│ │ ├── isr.c
│ │ ├── kernel.c
│ │ ├── keyboard.c
│ │ ├── string.c
│ │ └── vga.c
├── GDT
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── console.h
│ │ ├── gdt.h
│ │ ├── io_ports.h
│ │ ├── kernel.h
│ │ ├── string.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── asm
│ │ ├── entry.asm
│ │ └── load_gdt.asm
│ │ ├── console.c
│ │ ├── gdt.c
│ │ ├── io_ports.c
│ │ ├── kernel.c
│ │ ├── string.c
│ │ └── vga.c
├── IDT
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── 8259_pic.h
│ │ ├── console.h
│ │ ├── gdt.h
│ │ ├── idt.h
│ │ ├── io_ports.h
│ │ ├── isr.h
│ │ ├── kernel.h
│ │ ├── string.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── kernel_idt.png
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── 8259_pic.c
│ │ ├── asm
│ │ ├── entry.asm
│ │ ├── exception.asm
│ │ ├── irq.asm
│ │ ├── load_gdt.asm
│ │ └── load_idt.asm
│ │ ├── console.c
│ │ ├── gdt.c
│ │ ├── idt.c
│ │ ├── io_ports.c
│ │ ├── isr.c
│ │ ├── kernel.c
│ │ ├── string.c
│ │ └── vga.c
├── KHeap
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── 8259_pic.h
│ │ ├── console.h
│ │ ├── gdt.h
│ │ ├── idt.h
│ │ ├── io_ports.h
│ │ ├── isr.h
│ │ ├── kernel.h
│ │ ├── keyboard.h
│ │ ├── kheap.h
│ │ ├── multiboot.h
│ │ ├── pmm.h
│ │ ├── string.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── kernel_kheap.png
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── 8259_pic.c
│ │ ├── asm
│ │ ├── entry.asm
│ │ ├── exception.asm
│ │ ├── irq.asm
│ │ ├── load_gdt.asm
│ │ └── load_idt.asm
│ │ ├── console.c
│ │ ├── gdt.c
│ │ ├── idt.c
│ │ ├── io_ports.c
│ │ ├── isr.c
│ │ ├── kernel.c
│ │ ├── keyboard.c
│ │ ├── kheap.c
│ │ ├── pmm.c
│ │ ├── string.c
│ │ └── vga.c
├── Keyboard
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── 8259_pic.h
│ │ ├── console.h
│ │ ├── gdt.h
│ │ ├── idt.h
│ │ ├── io_ports.h
│ │ ├── isr.h
│ │ ├── kernel.h
│ │ ├── keyboard.h
│ │ ├── string.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── kernel_keyboard.png
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── 8259_pic.c
│ │ ├── asm
│ │ ├── entry.asm
│ │ ├── exception.asm
│ │ ├── irq.asm
│ │ ├── load_gdt.asm
│ │ └── load_idt.asm
│ │ ├── console.c
│ │ ├── gdt.c
│ │ ├── idt.c
│ │ ├── io_ports.c
│ │ ├── isr.c
│ │ ├── kernel.c
│ │ ├── keyboard.c
│ │ ├── string.c
│ │ └── vga.c
├── Memory Info
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── console.h
│ │ ├── io_ports.h
│ │ ├── kernel.h
│ │ ├── multiboot.h
│ │ ├── string.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── kernel_memory_info.png
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── asm
│ │ └── entry.asm
│ │ ├── console.c
│ │ ├── io_ports.c
│ │ ├── kernel.c
│ │ ├── string.c
│ │ └── vga.c
├── Mouse
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── 8259_pic.h
│ │ ├── console.h
│ │ ├── gdt.h
│ │ ├── idt.h
│ │ ├── io_ports.h
│ │ ├── isr.h
│ │ ├── kernel.h
│ │ ├── keyboard.h
│ │ ├── mouse.h
│ │ ├── string.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── kernel_mouse_1.png
│ ├── kernel_mouse_2.png
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── 8259_pic.c
│ │ ├── asm
│ │ ├── entry.asm
│ │ ├── exception.asm
│ │ ├── irq.asm
│ │ ├── load_gdt.asm
│ │ └── load_idt.asm
│ │ ├── console.c
│ │ ├── gdt.c
│ │ ├── idt.c
│ │ ├── io_ports.c
│ │ ├── isr.c
│ │ ├── kernel.c
│ │ ├── keyboard.c
│ │ ├── mouse.c
│ │ ├── string.c
│ │ └── vga.c
├── Paging
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── 8259_pic.h
│ │ ├── console.h
│ │ ├── gdt.h
│ │ ├── idt.h
│ │ ├── io_ports.h
│ │ ├── isr.h
│ │ ├── kernel.h
│ │ ├── keyboard.h
│ │ ├── kheap.h
│ │ ├── multiboot.h
│ │ ├── paging.h
│ │ ├── pmm.h
│ │ ├── string.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── kernel_paging.png
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── 8259_pic.c
│ │ ├── asm
│ │ ├── entry.asm
│ │ ├── exception.asm
│ │ ├── irq.asm
│ │ ├── load_gdt.asm
│ │ └── load_idt.asm
│ │ ├── console.c
│ │ ├── gdt.c
│ │ ├── idt.c
│ │ ├── io_ports.c
│ │ ├── isr.c
│ │ ├── kernel.c
│ │ ├── keyboard.c
│ │ ├── kheap.c
│ │ ├── paging.c
│ │ ├── pmm.c
│ │ ├── string.c
│ │ └── vga.c
├── Physical Memory Manager
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── 8259_pic.h
│ │ ├── console.h
│ │ ├── gdt.h
│ │ ├── idt.h
│ │ ├── io_ports.h
│ │ ├── isr.h
│ │ ├── kernel.h
│ │ ├── keyboard.h
│ │ ├── multiboot.h
│ │ ├── pmm.h
│ │ ├── string.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── kernel_physical_mm.png
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── 8259_pic.c
│ │ ├── asm
│ │ ├── entry.asm
│ │ ├── exception.asm
│ │ ├── irq.asm
│ │ ├── load_gdt.asm
│ │ └── load_idt.asm
│ │ ├── console.c
│ │ ├── gdt.c
│ │ ├── idt.c
│ │ ├── io_ports.c
│ │ ├── isr.c
│ │ ├── kernel.c
│ │ ├── keyboard.c
│ │ ├── pmm.c
│ │ ├── string.c
│ │ └── vga.c
├── TSS
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── console.h
│ │ ├── gdt.h
│ │ ├── io_ports.h
│ │ ├── kernel.h
│ │ ├── string.h
│ │ ├── tss.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── asm
│ │ ├── entry.asm
│ │ ├── load_gdt.asm
│ │ └── load_tss.asm
│ │ ├── console.c
│ │ ├── gdt.c
│ │ ├── io_ports.c
│ │ ├── kernel.c
│ │ ├── string.c
│ │ ├── tss.c
│ │ └── vga.c
├── Terminal
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── 8259_pic.h
│ │ ├── console.h
│ │ ├── gdt.h
│ │ ├── idt.h
│ │ ├── io_ports.h
│ │ ├── isr.h
│ │ ├── kernel.h
│ │ ├── keyboard.h
│ │ ├── string.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── kernel_terminal.png
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── 8259_pic.c
│ │ ├── asm
│ │ ├── entry.asm
│ │ ├── exception.asm
│ │ ├── irq.asm
│ │ ├── load_gdt.asm
│ │ └── load_idt.asm
│ │ ├── console.c
│ │ ├── gdt.c
│ │ ├── idt.c
│ │ ├── io_ports.c
│ │ ├── isr.c
│ │ ├── kernel.c
│ │ ├── keyboard.c
│ │ ├── string.c
│ │ └── vga.c
├── Timer
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── 8259_pic.h
│ │ ├── console.h
│ │ ├── gdt.h
│ │ ├── idt.h
│ │ ├── io_ports.h
│ │ ├── isr.h
│ │ ├── kernel.h
│ │ ├── keyboard.h
│ │ ├── string.h
│ │ ├── timer.h
│ │ ├── types.h
│ │ └── vga.h
│ ├── kernel_timer.png
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ └── src
│ │ ├── 8259_pic.c
│ │ ├── asm
│ │ ├── entry.asm
│ │ ├── exception.asm
│ │ ├── irq.asm
│ │ ├── load_gdt.asm
│ │ └── load_idt.asm
│ │ ├── console.c
│ │ ├── gdt.c
│ │ ├── idt.c
│ │ ├── io_ports.c
│ │ ├── isr.c
│ │ ├── kernel.c
│ │ ├── keyboard.c
│ │ ├── string.c
│ │ ├── timer.c
│ │ └── vga.c
├── VESA VBE
│ ├── Makefile
│ ├── README.md
│ ├── config
│ │ ├── grub.cfg
│ │ └── linker.ld
│ ├── include
│ │ ├── 8259_pic.h
│ │ ├── bios32.h
│ │ ├── console.h
│ │ ├── gdt.h
│ │ ├── idt.h
│ │ ├── io_ports.h
│ │ ├── isr.h
│ │ ├── kernel.h
│ │ ├── keyboard.h
│ │ ├── kheap.h
│ │ ├── multiboot.h
│ │ ├── pmm.h
│ │ ├── string.h
│ │ ├── types.h
│ │ ├── vesa.h
│ │ └── vga.h
│ ├── kernel_vbe_graphics.png
│ ├── kernel_vbe_mode_info_1.png
│ ├── kernel_vbe_mode_info_2.png
│ ├── kernel_vbe_mode_info_3.png
│ ├── kernel_vbe_mode_info_4.png
│ ├── obj
│ │ ├── .gitkeep
│ │ └── asm
│ │ │ └── .gitkeep
│ ├── out
│ │ └── .gitkeep
│ ├── ref
│ │ ├── vbe20.pdf
│ │ └── vbe3.pdf
│ └── src
│ │ ├── 8259_pic.c
│ │ ├── asm
│ │ ├── bios32_call.asm
│ │ ├── entry.asm
│ │ ├── exception.asm
│ │ ├── irq.asm
│ │ ├── load_gdt.asm
│ │ └── load_idt.asm
│ │ ├── bios32.c
│ │ ├── console.c
│ │ ├── gdt.c
│ │ ├── idt.c
│ │ ├── io_ports.c
│ │ ├── isr.c
│ │ ├── kernel.c
│ │ ├── keyboard.c
│ │ ├── kheap.c
│ │ ├── pmm.c
│ │ ├── string.c
│ │ ├── vesa.c
│ │ └── vga.c
└── VGA
│ ├── Makefile
│ ├── README.md
│ ├── asm
│ ├── color_change.asm
│ ├── rotate_text.asm
│ └── vga_hello.asm
│ ├── config
│ ├── grub.cfg
│ └── linker.ld
│ ├── include
│ ├── 8259_pic.h
│ ├── bitmap.h
│ ├── console.h
│ ├── gdt.h
│ ├── idt.h
│ ├── io_ports.h
│ ├── isr.h
│ ├── kernel.h
│ ├── keyboard.h
│ ├── mouse.h
│ ├── string.h
│ ├── types.h
│ └── vga.h
│ ├── kernel_vga.png
│ ├── obj
│ ├── .gitkeep
│ └── asm
│ │ └── .gitkeep
│ ├── out
│ └── .gitkeep
│ └── src
│ ├── 8259_pic.c
│ ├── asm
│ ├── entry.asm
│ ├── exception.asm
│ ├── irq.asm
│ ├── load_gdt.asm
│ └── load_idt.asm
│ ├── bitmap.c
│ ├── console.c
│ ├── gdt.c
│ ├── idt.c
│ ├── io_ports.c
│ ├── isr.c
│ ├── kernel.c
│ ├── keyboard.c
│ ├── mouse.c
│ ├── string.c
│ └── vga.c
├── Pong-Game
├── game_screenshots
│ ├── Pong_Game_Intro.png
│ ├── Pong_Game_Lose.png
│ └── Pong_Game_Play.png
├── iso
│ └── Pong_Game.iso
└── src
│ ├── README.md
│ ├── bitmap.c
│ ├── bitmap.h
│ ├── boot.s
│ ├── clean.sh
│ ├── grub.cfg
│ ├── kernel.c
│ ├── kernel.h
│ ├── keyboard.h
│ ├── linker.ld
│ ├── pong.c
│ ├── pong.h
│ ├── run.sh
│ ├── types.h
│ ├── utils.c
│ ├── utils.h
│ ├── vga.c
│ └── vga.h
├── README.md
├── Tic-Tac-Toe
├── README.md
├── iso
│ └── TicTacToe.iso
├── src
│ ├── boot.s
│ ├── box.c
│ ├── box.h
│ ├── clean.sh
│ ├── grub.cfg
│ ├── kernel.c
│ ├── kernel.h
│ ├── keyboard.h
│ ├── linker.ld
│ ├── run.sh
│ ├── tic_tac_toe.c
│ ├── tic_tac_toe.h
│ ├── types.h
│ ├── utils.c
│ └── utils.h
└── tic_tac_toe.png
├── VGA
├── README.md
├── asm
│ ├── color_change.asm
│ ├── rotate_text.asm
│ └── vga_hello.asm
└── kernel_c
│ ├── Bitmap_Text
│ ├── bitmap.c
│ ├── bitmap.h
│ ├── boot.s
│ ├── clean.sh
│ ├── grub.cfg
│ ├── kernel.c
│ ├── kernel.h
│ ├── keyboard.h
│ ├── linker.ld
│ ├── run.sh
│ ├── types.h
│ ├── vga.c
│ └── vga.h
│ ├── Bounce Rect
│ ├── boot.s
│ ├── clean.sh
│ ├── grub.cfg
│ ├── kernel.c
│ ├── kernel.h
│ ├── keyboard.h
│ ├── linker.ld
│ ├── run.sh
│ ├── types.h
│ ├── vga.c
│ └── vga.h
│ ├── Colors
│ ├── boot.s
│ ├── clean.sh
│ ├── grub.cfg
│ ├── kernel.c
│ ├── kernel.h
│ ├── linker.ld
│ ├── run.sh
│ ├── types.h
│ ├── vga.c
│ └── vga.h
│ ├── Reference
│ └── Intel OpenSource HD Graphics.pdf
│ ├── Simple
│ ├── boot.s
│ ├── clean.sh
│ ├── grub.cfg
│ ├── kernel.c
│ ├── kernel.h
│ ├── linker.ld
│ ├── run.sh
│ ├── types.h
│ ├── vga.c
│ └── vga.h
│ └── kernel_vga_output.png
└── x86 Calculator
├── README.md
├── asm
├── README.md
├── img
│ └── x86calc.bin
├── src
│ └── calc_x86.asm
└── x86calc_screenshot.png
└── kernel_c
├── iso
└── x86_calculator.iso
├── src
├── boot.s
├── char.c
├── char.h
├── clean.sh
├── grub.cfg
├── kernel.c
├── kernel.h
├── keyboard.h
├── linker.ld
├── run.sh
├── types.h
├── utils.c
└── utils.h
└── x86calculator_output.png
/Bootloader/ExtendedOS/img/MY_OS.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Bootloader/ExtendedOS/img/MY_OS.bin
--------------------------------------------------------------------------------
/Bootloader/HelloWorld/img/HelloWorld_OS.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Bootloader/HelloWorld/img/HelloWorld_OS.bin
--------------------------------------------------------------------------------
/Bootloader/HelloWorld_without_BIOS/img/HelloWorld_withoutBIOS.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Bootloader/HelloWorld_without_BIOS/img/HelloWorld_withoutBIOS.bin
--------------------------------------------------------------------------------
/CPUInfo/README.md:
--------------------------------------------------------------------------------
1 | For More, Intel® 64 and IA-32 ArchitecturesSoftware Developer’s Manual
2 |
https://en.wikipedia.org/wiki/CPUID
3 |
CPU info in C Kernel code.
4 |
5 |
6 |
7 |
CPU info in Assembly code.
8 | Read values of FLAGS, Control Register(CR0), Segment Registers, Some CPU information, Current time stamp and displays on the screen.
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/CPUInfo/asm/cpuinfo_asm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/CPUInfo/asm/cpuinfo_asm.png
--------------------------------------------------------------------------------
/CPUInfo/cpu_info_c/boot.s:
--------------------------------------------------------------------------------
1 | # set magic number to 0x1BADB002 to identified by bootloader
2 | .set MAGIC, 0x1BADB002
3 |
4 | # set flags to 0
5 | .set FLAGS, 0
6 |
7 | # set the checksum
8 | .set CHECKSUM, -(MAGIC + FLAGS)
9 |
10 | # set multiboot enabled
11 | .section .multiboot
12 |
13 | # define type to long for each data defined as above
14 | .long MAGIC
15 | .long FLAGS
16 | .long CHECKSUM
17 |
18 |
19 | # set the stack bottom
20 | stackBottom:
21 |
22 | # define the maximum size of stack to 1024 bytes
23 | .skip 1024
24 |
25 |
26 | # set the stack top which grows from higher to lower
27 | stackTop:
28 |
29 | .section .text
30 | .global _start
31 | .type _start, @function
32 |
33 |
34 | _start:
35 |
36 | # assign current stack pointer location to stackTop
37 | mov $stackTop, %esp
38 |
39 | # call the kernel main source
40 | call kernel_entry
41 |
42 | cli
43 |
44 |
45 | # put system in infinite loop
46 | hltLoop:
47 |
48 | hlt
49 | jmp hltLoop
50 |
51 | .size _start, . - _start
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/CPUInfo/cpu_info_c/c_cpuinfo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/CPUInfo/cpu_info_c/c_cpuinfo.png
--------------------------------------------------------------------------------
/CPUInfo/cpu_info_c/clean.sh:
--------------------------------------------------------------------------------
1 | # shell file to clean compiled code
2 |
3 | # remove all .o object files
4 | rm *.o
5 |
6 | # remove isodir
7 | rm -r isodir
8 |
9 | # remove CPUInfo_OS.bin
10 | rm CPUInfo_OS.bin
11 |
12 | # remove CPUInfo_OS.iso
13 | rm CPUInfo_OS.iso
14 |
--------------------------------------------------------------------------------
/CPUInfo/cpu_info_c/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "CPUInfo_OS" {
2 | multiboot /boot/CPUInfo_OS.bin
3 | }
4 |
--------------------------------------------------------------------------------
/CPUInfo/cpu_info_c/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | typedef unsigned char uint8;
5 | typedef unsigned short uint16;
6 | typedef unsigned int uint32;
7 |
8 |
9 | #define VGA_ADDRESS 0xB8000
10 | #define BUFSIZE 2200
11 |
12 | uint16* vga_buffer;
13 |
14 | #define NULL 0
15 |
16 | enum vga_color {
17 | BLACK,
18 | BLUE,
19 | GREEN,
20 | CYAN,
21 | RED,
22 | MAGENTA,
23 | BROWN,
24 | GREY,
25 | DARK_GREY,
26 | BRIGHT_BLUE,
27 | BRIGHT_GREEN,
28 | BRIGHT_CYAN,
29 | BRIGHT_RED,
30 | BRIGHT_MAGENTA,
31 | YELLOW,
32 | WHITE,
33 | };
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/CPUInfo/cpu_info_c/linker.ld:
--------------------------------------------------------------------------------
1 | /* entry point of our kernel */
2 | ENTRY(_start)
3 |
4 | SECTIONS
5 | {
6 | /* we need 1MB of space atleast */
7 | . = 1M;
8 |
9 | /* text section */
10 | .text BLOCK(4K) : ALIGN(4K)
11 | {
12 | *(.multiboot)
13 | *(.text)
14 | }
15 |
16 | /* read only data section */
17 | .rodata BLOCK(4K) : ALIGN(4K)
18 | {
19 | *(.rodata)
20 | }
21 |
22 | /* data section */
23 | .data BLOCK(4K) : ALIGN(4K)
24 | {
25 | *(.data)
26 | }
27 |
28 | /* bss section */
29 | .bss BLOCK(4K) : ALIGN(4K)
30 | {
31 | *(COMMON)
32 | *(.bss)
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/CPUInfo/cpu_info_c/run.sh:
--------------------------------------------------------------------------------
1 | # Shell file to compile code
2 |
3 | # assemble boot.s file
4 | as --32 boot.s -o boot.o
5 |
6 | # compile kernel.c file
7 | gcc -m32 -c kernel.c -o kernel.o -std=gnu99 -ffreestanding -O2 -Wall -Wextra
8 |
9 | # linking all the object files to CPUInfo_OS.bin
10 | ld -m elf_i386 -T linker.ld kernel.o boot.o -o CPUInfo_OS.bin -nostdlib
11 |
12 | # check CPUInfo_OS.bin file is x86 multiboot file or not
13 | grub-file --is-x86-multiboot CPUInfo_OS.bin
14 |
15 | # building the iso file
16 | mkdir -p isodir/boot/grub
17 | cp CPUInfo_OS.bin isodir/boot/CPUInfo_OS.bin
18 | cp grub.cfg isodir/boot/grub/grub.cfg
19 | grub-mkrescue -o CPUInfo_OS.iso isodir
20 |
21 | # run it in qemu
22 | qemu-system-x86_64 -cdrom CPUInfo_OS.iso
23 |
--------------------------------------------------------------------------------
/GUI/Graphics in Assembly/Simple/Readme.md:
--------------------------------------------------------------------------------
1 | drawpixel : An Operating System code that plot a single pixel on a screen. It uses address 0xA000 to access video memory.
2 |
3 | dda_line_draw : A Digital Differential Analyzer(DDA) line drawing algorithm that draws a line by ploting group of pixels on the screen.
4 | This algorithm is implemented with integer values not floating point values.
5 | There are some drawbacks of this algorithm which are demonstrated in the code with screenshot image in /img directory.
6 |
7 | rectangle : Drawing a rectangles by drawing lines with points x,y,width and height.
8 |
--------------------------------------------------------------------------------
/GUI/Graphics in Assembly/Simple/dda_line_draw/img/dda_line_draw.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/GUI/Graphics in Assembly/Simple/dda_line_draw/img/dda_line_draw.bin
--------------------------------------------------------------------------------
/GUI/Graphics in Assembly/Simple/dda_line_draw/img/dda_line_draw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/GUI/Graphics in Assembly/Simple/dda_line_draw/img/dda_line_draw.png
--------------------------------------------------------------------------------
/GUI/Graphics in Assembly/Simple/drawpixel/img/draw_pixel.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/GUI/Graphics in Assembly/Simple/drawpixel/img/draw_pixel.bin
--------------------------------------------------------------------------------
/GUI/Graphics in Assembly/Simple/drawpixel/img/draw_pixels.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/GUI/Graphics in Assembly/Simple/drawpixel/img/draw_pixels.png
--------------------------------------------------------------------------------
/GUI/Graphics in Assembly/Simple/rectangle/Readme.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/GUI/Graphics in Assembly/Simple/rectangle/img/rectangle.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/GUI/Graphics in Assembly/Simple/rectangle/img/rectangle.bin
--------------------------------------------------------------------------------
/GUI/Graphics in Assembly/Simple/rectangle/img/rectangle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/GUI/Graphics in Assembly/Simple/rectangle/img/rectangle.png
--------------------------------------------------------------------------------
/GUI/Graphics in Assembly/Simple/rectangle/src/Readme.txt:
--------------------------------------------------------------------------------
1 | Just assemble the rectangle.asm source file
2 | dda.asm and drawpixel.asm files are included in rectangle.asm file.
3 |
4 | e.g:
5 | nasm -f bin rectangle.asm -o rectangle.bin
--------------------------------------------------------------------------------
/GUI/Graphics in Assembly/Simple/rectangle/src/drawpixel.asm:
--------------------------------------------------------------------------------
1 | ;draw a pixel at x,y location
2 | drawpixel :
3 |
4 | ;get x co-ordinate
5 | mov ax, word[X_PIX]
6 |
7 | ;get y co-ordinate
8 | mov bx, word[Y_PIX]
9 |
10 | ;clear destination index register for use as index in
11 | ;video memory pointed by es register
12 | xor di, di
13 |
14 | ;set y co-ordinate
15 | ;first increase video index by width of the current graphics mode(320*220)
16 | ;multiply index by y co-ordinate to set its location
17 | ;this is same as printing a new line in our kernel C code
18 | ;https://github.com/pritamzope/OS/tree/master/Kernel/Simple/src/kernel_3
19 | add di, word[VGA_WIDTH]
20 | imul di, bx
21 |
22 | ; set x co-ordinate by increasing index(di) by X value
23 | add di, ax
24 |
25 | ;get the color from PIXEL_COLOR memory
26 | mov ax, word[PIXEL_COLOR]
27 |
28 | ;plot the pixel with index(di) and pixel color(ax)
29 | mov [es:di], ax
30 |
31 | ret
32 |
--------------------------------------------------------------------------------
/GUI/README.md:
--------------------------------------------------------------------------------
1 | https://en.wikipedia.org/wiki/Box-drawing_character
2 |
3 | ASCII Chars
4 |
5 |
6 |
7 | Box Demo
8 |
9 |
10 |
11 | DOSBox GUI
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/GUI/ascii_chars/ascii_chars_0_255.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/GUI/ascii_chars/ascii_chars_0_255.png
--------------------------------------------------------------------------------
/GUI/ascii_chars/clean.sh:
--------------------------------------------------------------------------------
1 | # shell file to clean compiled code
2 |
3 | # remove all .o object files
4 | rm *.o
5 |
6 | # remove isodir
7 | rm -r isodir
8 |
9 | # remove GUI_ASCII_Chars_OS.bin
10 | rm GUI_ASCII_Chars_OS.bin
11 |
12 | # remove GUI_ASCII_Chars_OS.iso
13 | rm GUI_ASCII_Chars_OS.iso
--------------------------------------------------------------------------------
/GUI/ascii_chars/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "GUI_ASCII_Chars_OS" {
2 | multiboot /boot/GUI_ASCII_Chars_OS.bin
3 | }
4 |
--------------------------------------------------------------------------------
/GUI/ascii_chars/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | #define NULL 0
7 |
8 | #define VGA_ADDRESS 0xB8000
9 | #define BUFSIZE 2200
10 |
11 | uint16* vga_buffer;
12 |
13 | enum vga_color {
14 | BLACK,
15 | BLUE,
16 | GREEN,
17 | CYAN,
18 | RED,
19 | MAGENTA,
20 | BROWN,
21 | GREY,
22 | DARK_GREY,
23 | BRIGHT_BLUE,
24 | BRIGHT_GREEN,
25 | BRIGHT_CYAN,
26 | BRIGHT_RED,
27 | BRIGHT_MAGENTA,
28 | YELLOW,
29 | WHITE,
30 | };
31 |
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/GUI/ascii_chars/run.sh:
--------------------------------------------------------------------------------
1 | # Shell file to compile code
2 |
3 | # assemble boot.s file
4 | as --32 boot.s -o boot.o
5 |
6 | # compile kernel.c file
7 | gcc -m32 -c kernel.c -o kernel.o -std=gnu99 -ffreestanding -O1 -Wall -Wextra
8 |
9 | gcc -m32 -c utils.c -o utils.o -std=gnu99 -ffreestanding -O1 -Wall -Wextra
10 |
11 | # linking all the object files to GUI_ASCII_Chars_OS.bin
12 | ld -m elf_i386 -T linker.ld kernel.o utils.o boot.o -o GUI_ASCII_Chars_OS.bin -nostdlib
13 |
14 | # check GUI_ASCII_Chars_OS.bin file is x86 multiboot file or not
15 | grub-file --is-x86-multiboot GUI_ASCII_Chars_OS.bin
16 |
17 | # building the iso file
18 | mkdir -p isodir/boot/grub
19 | cp GUI_ASCII_Chars_OS.bin isodir/boot/GUI_ASCII_Chars_OS.bin
20 | cp grub.cfg isodir/boot/grub/grub.cfg
21 | grub-mkrescue -o GUI_ASCII_Chars_OS.iso isodir
22 |
23 | # run it in qemu
24 | qemu-system-x86_64 -cdrom GUI_ASCII_Chars_OS.iso
25 |
--------------------------------------------------------------------------------
/GUI/ascii_chars/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | typedef unsigned char uint8;
5 | typedef unsigned short uint16;
6 | typedef unsigned int uint32;
7 |
8 | #endif
9 |
10 |
11 |
--------------------------------------------------------------------------------
/GUI/ascii_chars/utils.c:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | uint32 strlen(const char* str)
4 | {
5 | uint32 length = 0;
6 | while(str[length])
7 | length++;
8 | return length;
9 | }
10 |
11 | uint32 digit_count(int num)
12 | {
13 | uint32 count = 0;
14 | if(num == 0)
15 | return 1;
16 | while(num > 0){
17 | count++;
18 | num = num/10;
19 | }
20 | return count;
21 | }
22 |
23 | void itoa(int num, char *number)
24 | {
25 | int dgcount = digit_count(num);
26 | int index = dgcount - 1;
27 | char x;
28 | if(num == 0 && dgcount == 1){
29 | number[0] = '0';
30 | number[1] = '\0';
31 | }else{
32 | while(num != 0){
33 | x = num % 10;
34 | number[index] = x + '0';
35 | index--;
36 | num = num / 10;
37 | }
38 | number[dgcount] = '\0';
39 | }
40 | }
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/GUI/ascii_chars/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef UTILS_H
2 | #define UTILS_H
3 |
4 | #include "types.h"
5 |
6 | extern uint32 strlen(const char*);
7 | extern uint32 digit_count(int);
8 | extern void itoa(int, char *);
9 |
10 | #endif
11 |
12 |
--------------------------------------------------------------------------------
/GUI/box/boot.s:
--------------------------------------------------------------------------------
1 | # set flags to 0
2 | .set FLAGS, 0
3 |
4 | # set magic number to 0x1BADB002 to identified by bootloader
5 | .set MAGIC, 0x1BADB002
6 |
7 | # set the checksum
8 | .set CHECKSUM, -(MAGIC + FLAGS)
9 |
10 | # set multiboot enabled
11 | .section .multiboot
12 |
13 | # define type to long for each data defined as above
14 | .long MAGIC
15 | .long FLAGS
16 | .long CHECKSUM
17 |
18 |
19 | # set the stack bottom
20 | stackBottom:
21 |
22 | # define the maximum size of stack to 512 bytes
23 | .skip 4096
24 |
25 |
26 | # set the stack top which grows from higher to lower
27 | stackTop:
28 |
29 | .section .text
30 | .global _start
31 | .type _start, @function
32 |
33 |
34 | _start:
35 |
36 |
37 | # assign current stack pointer location to stackTop
38 | mov $stackTop, %esp
39 |
40 | # call the kernel main function
41 | call kernel_entry
42 |
43 | cli
44 |
45 |
46 | # put system in infinite loop
47 | hltLoop:
48 |
49 | hlt
50 | jmp hltLoop
51 |
52 | .size _start, . - _start
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/GUI/box/box_demo_kernel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/GUI/box/box_demo_kernel.png
--------------------------------------------------------------------------------
/GUI/box/clean.sh:
--------------------------------------------------------------------------------
1 | # shell file to clean compiled code
2 |
3 | # remove all .o object files
4 | rm *.o
5 |
6 | # remove isodir
7 | rm -r isodir
8 |
9 | # remove GUI_Box_OS.bin
10 | rm GUI_Box_OS.bin
11 |
12 | # remove GUI_Box_OS.iso
13 | rm GUI_Box_OS.iso
--------------------------------------------------------------------------------
/GUI/box/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "GUI_Box_OS" {
2 | multiboot /boot/GUI_Box_OS.bin
3 | }
4 |
--------------------------------------------------------------------------------
/GUI/box/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | #define NULL 0
7 |
8 | #define VGA_ADDRESS 0xB8000
9 | #define BUFSIZE 2200
10 |
11 | uint16* vga_buffer;
12 |
13 | #define VGA_MAX_WIDTH 80
14 | #define VGA_MAX_HEIGHT 25
15 |
16 | #define BOX_MAX_WIDTH 78
17 | #define BOX_MAX_HEIGHT 23
18 |
19 | #define BOX_SINGLELINE 1
20 | #define BOX_DOUBLELINE 2
21 |
22 | enum vga_color {
23 | BLACK,
24 | BLUE,
25 | GREEN,
26 | CYAN,
27 | RED,
28 | MAGENTA,
29 | BROWN,
30 | GREY,
31 | DARK_GREY,
32 | BRIGHT_BLUE,
33 | BRIGHT_GREEN,
34 | BRIGHT_CYAN,
35 | BRIGHT_RED,
36 | BRIGHT_MAGENTA,
37 | YELLOW,
38 | WHITE,
39 | };
40 |
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/GUI/box/run.sh:
--------------------------------------------------------------------------------
1 | # Shell file to compile code
2 |
3 | # assemble boot.s file
4 | as --32 boot.s -o boot.o
5 |
6 | # compile kernel.c file
7 | gcc -m32 -c kernel.c -o kernel.o -std=gnu99 -ffreestanding -O1 -Wall -Wextra
8 |
9 | gcc -m32 -c utils.c -o utils.o -std=gnu99 -ffreestanding -O1 -Wall -Wextra
10 |
11 | # linking all the object files to GUI_Box_OS.bin
12 | ld -m elf_i386 -T linker.ld kernel.o utils.o boot.o -o GUI_Box_OS.bin -nostdlib
13 |
14 | # check GUI_Box_OS.bin file is x86 multiboot file or not
15 | grub-file --is-x86-multiboot GUI_Box_OS.bin
16 |
17 | # building the iso file
18 | mkdir -p isodir/boot/grub
19 | cp GUI_Box_OS.bin isodir/boot/GUI_Box_OS.bin
20 | cp grub.cfg isodir/boot/grub/grub.cfg
21 | grub-mkrescue -o GUI_Box_OS.iso isodir
22 |
23 | # run it in qemu
24 | qemu-system-x86_64 -cdrom GUI_Box_OS.iso
25 |
--------------------------------------------------------------------------------
/GUI/box/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | typedef unsigned char uint8;
5 | typedef unsigned short uint16;
6 | typedef unsigned int uint32;
7 |
8 | #endif
9 |
10 |
11 |
--------------------------------------------------------------------------------
/GUI/box/utils.c:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | uint32 strlen(const char* str)
4 | {
5 | uint32 length = 0;
6 | while(str[length])
7 | length++;
8 | return length;
9 | }
10 |
11 | uint32 digit_count(int num)
12 | {
13 | uint32 count = 0;
14 | if(num == 0)
15 | return 1;
16 | while(num > 0){
17 | count++;
18 | num = num/10;
19 | }
20 | return count;
21 | }
22 |
23 | void itoa(int num, char *number)
24 | {
25 | int dgcount = digit_count(num);
26 | int index = dgcount - 1;
27 | char x;
28 | if(num == 0 && dgcount == 1){
29 | number[0] = '0';
30 | number[1] = '\0';
31 | }else{
32 | while(num != 0){
33 | x = num % 10;
34 | number[index] = x + '0';
35 | index--;
36 | num = num / 10;
37 | }
38 | number[dgcount] = '\0';
39 | }
40 | }
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/GUI/box/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef UTILS_H
2 | #define UTILS_H
3 |
4 | #include "types.h"
5 |
6 | extern uint32 strlen(const char*);
7 | extern uint32 digit_count(int);
8 | extern void itoa(int, char *);
9 |
10 | #endif
11 |
12 |
--------------------------------------------------------------------------------
/GUI/dosbox_gui/clean.sh:
--------------------------------------------------------------------------------
1 | # shell file to clean compiled code
2 |
3 | # remove all .o object files
4 | rm *.o
5 |
6 | # remove isodir
7 | rm -r isodir
8 |
9 | # remove GUI_DosBox_OS.bin
10 | rm GUI_DosBox_OS.bin
11 |
12 | # remove GUI_DosBox_OS.iso
13 | rm GUI_DosBox_OS.iso
--------------------------------------------------------------------------------
/GUI/dosbox_gui/dosbox_gui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/GUI/dosbox_gui/dosbox_gui.png
--------------------------------------------------------------------------------
/GUI/dosbox_gui/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "GUI_DosBox_OS" {
2 | multiboot /boot/GUI_DosBox_OS.bin
3 | }
4 |
--------------------------------------------------------------------------------
/GUI/dosbox_gui/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | #define NULL 0
7 |
8 | #define VGA_ADDRESS 0xB8000
9 | #define BUFSIZE 2200
10 |
11 | uint16* vga_buffer;
12 |
13 | #define BOX_MAX_WIDTH 78
14 | #define BOX_MAX_HEIGHT 23
15 |
16 | #define BOX_SINGLELINE 1
17 | #define BOX_DOUBLELINE 2
18 |
19 | enum vga_color {
20 | BLACK,
21 | BLUE,
22 | GREEN,
23 | CYAN,
24 | RED,
25 | MAGENTA,
26 | BROWN,
27 | GREY,
28 | DARK_GREY,
29 | BRIGHT_BLUE,
30 | BRIGHT_GREEN,
31 | BRIGHT_CYAN,
32 | BRIGHT_RED,
33 | BRIGHT_MAGENTA,
34 | YELLOW,
35 | WHITE,
36 | };
37 |
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/GUI/dosbox_gui/run.sh:
--------------------------------------------------------------------------------
1 | # Shell file to compile code
2 |
3 | # assemble boot.s file
4 | as --32 boot.s -o boot.o
5 |
6 | # compile kernel.c file
7 | gcc -m32 -c kernel.c -o kernel.o -std=gnu99 -ffreestanding -O1 -Wall -Wextra
8 |
9 | gcc -m32 -c utils.c -o utils.o -std=gnu99 -ffreestanding -O1 -Wall -Wextra
10 |
11 | # linking all the object files to GUI_DosBox_OS.bin
12 | ld -m elf_i386 -T linker.ld kernel.o utils.o boot.o -o GUI_DosBox_OS.bin -nostdlib
13 |
14 | # check GUI_DosBox_OS.bin file is x86 multiboot file or not
15 | grub-file --is-x86-multiboot GUI_DosBox_OS.bin
16 |
17 | # building the iso file
18 | mkdir -p isodir/boot/grub
19 | cp GUI_DosBox_OS.bin isodir/boot/GUI_DosBox_OS.bin
20 | cp grub.cfg isodir/boot/grub/grub.cfg
21 | grub-mkrescue -o GUI_DosBox_OS.iso isodir
22 |
23 | # run it in qemu
24 | qemu-system-x86_64 -cdrom GUI_DosBox_OS.iso
25 |
--------------------------------------------------------------------------------
/GUI/dosbox_gui/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | typedef unsigned char uint8;
5 | typedef unsigned short uint16;
6 | typedef unsigned int uint32;
7 |
8 | #endif
9 |
10 |
11 |
--------------------------------------------------------------------------------
/GUI/dosbox_gui/utils.c:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | uint32 strlen(const char* str)
4 | {
5 | uint32 length = 0;
6 | while(str[length])
7 | length++;
8 | return length;
9 | }
10 |
11 | uint32 digit_count(int num)
12 | {
13 | uint32 count = 0;
14 | if(num == 0)
15 | return 1;
16 | while(num > 0){
17 | count++;
18 | num = num/10;
19 | }
20 | return count;
21 | }
22 |
23 | void itoa(int num, char *number)
24 | {
25 | int dgcount = digit_count(num);
26 | int index = dgcount - 1;
27 | char x;
28 | if(num == 0 && dgcount == 1){
29 | number[0] = '0';
30 | number[1] = '\0';
31 | }else{
32 | while(num != 0){
33 | x = num % 10;
34 | number[index] = x + '0';
35 | index--;
36 | num = num / 10;
37 | }
38 | number[dgcount] = '\0';
39 | }
40 | }
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/GUI/dosbox_gui/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef UTILS_H
2 | #define UTILS_H
3 |
4 | #include "types.h"
5 |
6 | extern uint32 strlen(const char*);
7 | extern uint32 digit_count(int);
8 | extern void itoa(int, char *);
9 |
10 | #endif
11 |
12 |
--------------------------------------------------------------------------------
/Global_Descriptor_Table/README.md:
--------------------------------------------------------------------------------
1 | Operating System - Setting up Global Descriptor Table(GDT)
2 |
3 |
4 |
5 | References:
6 |
7 | https://en.wikipedia.org/wiki/Global_Descriptor_Table
8 |
9 | http://www.jamesmolloy.co.uk/tutorial_html/4.-The%20GDT%20and%20IDT.html
10 |
11 | https://wiki.osdev.org/GDT_Tutorial
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Global_Descriptor_Table/kernel_C/clean.sh:
--------------------------------------------------------------------------------
1 | # shell file to clean compiled code
2 |
3 | # remove all .o object files
4 | rm *.o
5 |
6 | # remove isodir
7 | rm -r isodir
8 |
9 | # remove Global_Descriptor_Table_OS.bin
10 | rm Global_Descriptor_Table_OS.bin
11 |
12 | # remove Global_Descriptor_Table_OS.iso
13 | rm Global_Descriptor_Table_OS.iso
--------------------------------------------------------------------------------
/Global_Descriptor_Table/kernel_C/gdt.h:
--------------------------------------------------------------------------------
1 | #ifndef GDT_H
2 | #define GDT_H
3 |
4 | #include "types.h"
5 |
6 | #define NULL_SEGMENT 0
7 | #define CODE_SEGMENT 1
8 | #define DATA_SEGMENT 2
9 |
10 | struct GDT
11 | {
12 | uint16 segment_limit; // segment limit first 0-15 bits
13 | uint16 base_low; // base first 0-15 bits
14 | uint8 base_middle; // base 16-23 bits
15 | uint8 access; // access byte
16 | uint8 granularity; // high 4 bits (flags) low 4 bits (limit 4 last bits)(limit is 20 bit wide)
17 | uint8 base_high; // base 24-31 bits
18 | } __attribute__((packed));
19 |
20 |
21 | struct GDT_PTR
22 | {
23 | uint16 limit_size; // limit size of all GDT segments
24 | struct GDT* base_address; // base address of the first GDT segment
25 | } __attribute__((packed));
26 |
27 | extern struct GDT gdt_entries[3];
28 | extern struct GDT_PTR gdt_first;
29 |
30 | extern void init_gdt();
31 |
32 | #endif
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Global_Descriptor_Table/kernel_C/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "Global_Descriptor_Table_OS" {
2 | multiboot /boot/Global_Descriptor_Table_OS.bin
3 | }
4 |
--------------------------------------------------------------------------------
/Global_Descriptor_Table/kernel_C/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | #define VGA_ADDRESS 0xB8000
7 | #define BUFSIZE 2200
8 |
9 | uint16* vga_buffer;
10 |
11 | #define NULL 0
12 |
13 | enum vga_color {
14 | BLACK,
15 | BLUE,
16 | GREEN,
17 | CYAN,
18 | RED,
19 | MAGENTA,
20 | BROWN,
21 | GREY,
22 | DARK_GREY,
23 | BRIGHT_BLUE,
24 | BRIGHT_GREEN,
25 | BRIGHT_CYAN,
26 | BRIGHT_RED,
27 | BRIGHT_MAGENTA,
28 | YELLOW,
29 | WHITE,
30 | };
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/Global_Descriptor_Table/kernel_C/linker.ld:
--------------------------------------------------------------------------------
1 | /* entry point of our kernel */
2 | ENTRY(_start)
3 |
4 | SECTIONS
5 | {
6 | /* we need 1MB of space atleast */
7 | . = 1M;
8 |
9 | /* text section */
10 | .text BLOCK(4K) : ALIGN(4K)
11 | {
12 | *(.multiboot)
13 | *(.text)
14 | }
15 |
16 | /* read only data section */
17 | .rodata BLOCK(4K) : ALIGN(4K)
18 | {
19 | *(.rodata)
20 | }
21 |
22 | /* data section */
23 | .data BLOCK(4K) : ALIGN(4K)
24 | {
25 | *(.data)
26 | }
27 |
28 | /* bss section */
29 | .bss BLOCK(4K) : ALIGN(4K)
30 | {
31 | *(COMMON)
32 | *(.bss)
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/Global_Descriptor_Table/kernel_C/load_gdt.s:
--------------------------------------------------------------------------------
1 | .section .text
2 | .global load_gdt
3 |
4 | load_gdt:
5 | mov 4(%esp), %eax
6 | lgdt (%eax)
7 |
8 | mov $0x10, %eax
9 | mov %eax, %ds
10 | mov %eax, %es
11 | mov %eax, %fs
12 | mov %eax, %gs
13 | mov %eax, %ss
14 | jmp $0x8, $.long_jump
15 | .long_jump:
16 | ret
17 |
18 |
--------------------------------------------------------------------------------
/Global_Descriptor_Table/kernel_C/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | typedef unsigned char uint8;
5 | typedef unsigned short uint16;
6 | typedef unsigned int uint32;
7 | typedef signed char sint8;
8 | typedef signed short sint16;
9 | typedef signed int sint32;
10 | typedef uint8 byte;
11 | typedef uint16 word;
12 | typedef uint32 dword;
13 |
14 | #endif
15 |
16 |
--------------------------------------------------------------------------------
/Interrupt_Descriptor_Table/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | References :
4 |
5 | http://www.jamesmolloy.co.uk/tutorial_html/4.-The%20GDT%20and%20IDT.html
6 |
7 | https://wiki.osdev.org/Interrupt_Descriptor_Table
8 |
9 | https://en.wikipedia.org/wiki/Interrupt_descriptor_table
10 |
11 |
--------------------------------------------------------------------------------
/Interrupt_Descriptor_Table/boot.s:
--------------------------------------------------------------------------------
1 | # set magic number to 0x1BADB002 to identified by bootloader
2 | .set MAGIC, 0x1BADB002
3 |
4 | # set flags to 0
5 | .set FLAGS, 0
6 |
7 | # set the checksum
8 | .set CHECKSUM, -(MAGIC + FLAGS)
9 |
10 | # set multiboot enabled
11 | .section .multiboot
12 |
13 | # define type to long for each data defined as above
14 | .long MAGIC
15 | .long FLAGS
16 | .long CHECKSUM
17 |
18 |
19 | # set the stack bottom
20 | stackBottom:
21 |
22 | # define the maximum size of stack to 512 bytes
23 | .skip 1024
24 |
25 |
26 | # set the stack top which grows from higher to lower
27 | stackTop:
28 |
29 | .section .text
30 | .global _start
31 | .type _start, @function
32 |
33 | _start:
34 |
35 | # assign current stack pointer location to stackTop
36 | mov $stackTop, %esp
37 |
38 | # call the kernel main source
39 | call kernel_entry
40 |
41 | cli
42 |
43 |
44 | # put system in infinite loop
45 | hltLoop:
46 |
47 | hlt
48 | jmp hltLoop
49 |
50 | .size _start, . - _start
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/Interrupt_Descriptor_Table/clean.sh:
--------------------------------------------------------------------------------
1 | # shell file to clean compiled code
2 |
3 | # remove all .o object files
4 | rm *.o
5 |
6 | # remove isodir
7 | rm -r isodir
8 |
9 | # remove Interrupt_Descriptor_Table_OS.bin
10 | rm Interrupt_Descriptor_Table_OS.bin
11 |
12 | # remove Interrupt_Descriptor_Table_OS.iso
13 | rm Interrupt_Descriptor_Table_OS.iso
--------------------------------------------------------------------------------
/Interrupt_Descriptor_Table/gdt.h:
--------------------------------------------------------------------------------
1 | #ifndef GDT_H
2 | #define GDT_H
3 |
4 | #include "types.h"
5 |
6 | #define NULL_SEGMENT 0
7 | #define CODE_SEGMENT 1
8 | #define DATA_SEGMENT 2
9 |
10 | struct GDT
11 | {
12 | uint16 segment_limit; // segment limit first 0-15 bits
13 | uint16 base_low; // base first 0-15 bits
14 | uint8 base_middle; // base 16-23 bits
15 | uint8 access; // access byte
16 | uint8 granularity; // high 4 bits (flags) low 4 bits (limit 4 last bits)(limit is 20 bit wide)
17 | uint8 base_high; // base 24-31 bits
18 | } __attribute__((packed));
19 |
20 |
21 | struct GDT_PTR
22 | {
23 | uint16 limit_size; // limit size of all GDT segments
24 | struct GDT* base_address; // base address of the first GDT segment
25 | } __attribute__((packed));
26 |
27 | extern struct GDT gdt_entries[3];
28 | extern struct GDT_PTR gdt_first;
29 |
30 | extern void init_gdt();
31 |
32 | #endif
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Interrupt_Descriptor_Table/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "Interrupt_Descriptor_Table_OS" {
2 | multiboot /boot/Interrupt_Descriptor_Table_OS.bin
3 | }
4 |
--------------------------------------------------------------------------------
/Interrupt_Descriptor_Table/idt.h:
--------------------------------------------------------------------------------
1 | #ifndef IDT_H
2 | #define IDT_H
3 |
4 | #include "types.h"
5 |
6 | struct IDT
7 | {
8 | uint16 base_low; // lower 16 bits 0-15 of the address to jump to when this interrupt fires
9 | uint16 segment_selector; // code segment selector in GDT
10 | uint8 zero; // unused, always be zero
11 | uint8 type; // types trap, interrupt gates
12 | uint16 base_high; // upper 16 bits 16-31 of the address to jump to
13 | } __attribute__((packed));
14 |
15 |
16 | struct IDT_PTR
17 | {
18 | uint16 limit_size; // limit size of all IDT segments
19 | struct IDT* base_address; // base address of the first IDT segment
20 | } __attribute__((packed));
21 |
22 | extern struct IDT idt_entries[16];
23 | extern struct IDT_PTR idt_first;
24 |
25 | extern void init_idt();
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/Interrupt_Descriptor_Table/idt_demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Interrupt_Descriptor_Table/idt_demo.png
--------------------------------------------------------------------------------
/Interrupt_Descriptor_Table/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | #define VGA_ADDRESS 0xB8000
7 | #define BUFSIZE 2200
8 |
9 | uint16* vga_buffer;
10 |
11 | enum vga_color {
12 | BLACK,
13 | BLUE,
14 | GREEN,
15 | CYAN,
16 | RED,
17 | MAGENTA,
18 | BROWN,
19 | GREY,
20 | DARK_GREY,
21 | BRIGHT_BLUE,
22 | BRIGHT_GREEN,
23 | BRIGHT_CYAN,
24 | BRIGHT_RED,
25 | BRIGHT_MAGENTA,
26 | YELLOW,
27 | WHITE,
28 | };
29 |
30 | extern void print_new_line();
31 | extern void print_char(char);
32 | extern void print_string(char *);
33 | extern void print_int(int);
34 |
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/Interrupt_Descriptor_Table/linker.ld:
--------------------------------------------------------------------------------
1 | /* entry point of our kernel */
2 | ENTRY(_start)
3 |
4 | SECTIONS
5 | {
6 | /* we need 1MB of space atleast */
7 | . = 1M;
8 |
9 | /* text section */
10 | .text BLOCK(4K) : ALIGN(4K)
11 | {
12 | *(.multiboot)
13 | *(.text)
14 | }
15 |
16 | /* read only data section */
17 | .rodata BLOCK(4K) : ALIGN(4K)
18 | {
19 | *(.rodata)
20 | }
21 |
22 | /* data section */
23 | .data BLOCK(4K) : ALIGN(4K)
24 | {
25 | *(.data)
26 | }
27 |
28 | /* bss section */
29 | .bss BLOCK(4K) : ALIGN(4K)
30 | {
31 | *(COMMON)
32 | *(.bss)
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/Interrupt_Descriptor_Table/load_gdt.s:
--------------------------------------------------------------------------------
1 | .section .text
2 | .global load_gdt
3 |
4 | load_gdt:
5 | mov 4(%esp), %eax
6 | lgdt (%eax)
7 |
8 | mov $0x10, %eax
9 | mov %eax, %ds
10 | mov %eax, %es
11 | mov %eax, %fs
12 | mov %eax, %gs
13 | mov %eax, %ss
14 | jmp $0x8, $.long_jump
15 | .long_jump:
16 | ret
17 |
--------------------------------------------------------------------------------
/Interrupt_Descriptor_Table/load_idt.s:
--------------------------------------------------------------------------------
1 | .section .text
2 | .global load_idt
3 |
4 | load_idt:
5 | mov 4(%esp), %eax
6 | lidt (%eax)
7 | ret
8 |
--------------------------------------------------------------------------------
/Interrupt_Descriptor_Table/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef uint8 byte;
13 | typedef uint16 word;
14 | typedef uint32 dword;
15 |
16 | #endif
17 |
18 |
--------------------------------------------------------------------------------
/Interrupt_Descriptor_Table/util.c:
--------------------------------------------------------------------------------
1 | #include "util.h"
2 |
3 | uint32 strlen(const char* str)
4 | {
5 | uint32 length = 0;
6 | while(str[length])
7 | length++;
8 | return length;
9 | }
10 |
11 | uint32 digit_count(int num)
12 | {
13 | uint32 count = 0;
14 | if(num == 0)
15 | return 1;
16 | while(num > 0){
17 | count++;
18 | num = num/10;
19 | }
20 | return count;
21 | }
22 |
23 | void itoa(int num, char *number)
24 | {
25 | int dgcount = digit_count(num);
26 | int index = dgcount - 1;
27 | char x;
28 | if(num == 0 && dgcount == 1){
29 | number[0] = '0';
30 | number[1] = '\0';
31 | }else{
32 | while(num != 0){
33 | x = num % 10;
34 | number[index] = x + '0';
35 | index--;
36 | num = num / 10;
37 | }
38 | number[dgcount] = '\0';
39 | }
40 | }
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Interrupt_Descriptor_Table/util.h:
--------------------------------------------------------------------------------
1 | #ifndef UTIL_H
2 | #define UTIL_H
3 |
4 | #include "types.h"
5 |
6 | extern uint32 strlen(const char*);
7 | extern uint32 digit_count(int);
8 | extern void itoa(int, char *);
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/Kernel/Keyboard/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Kernel/Keyboard/ascii.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Kernel/Keyboard/ascii.jpg
--------------------------------------------------------------------------------
/Kernel/Keyboard/boot.s:
--------------------------------------------------------------------------------
1 | # set flags to 0
2 | .set FLAGS, 0
3 |
4 | # set magic number to 0x1BADB002 to identified by bootloader
5 | .set MAGIC, 0x1BADB002
6 |
7 | # set the checksum
8 | .set CHECKSUM, -(MAGIC + FLAGS)
9 |
10 | # set multiboot enabled
11 | .section .multiboot
12 |
13 | # define type to long for each data defined as above
14 | .long MAGIC
15 | .long FLAGS
16 | .long CHECKSUM
17 |
18 |
19 | # set the stack bottom
20 | stackBottom:
21 |
22 | # define the maximum size of stack to 512 bytes
23 | .skip 4096
24 |
25 |
26 | # set the stack top which grows from higher to lower
27 | stackTop:
28 |
29 | .section .text
30 | .global _start
31 | .type _start, @function
32 |
33 |
34 | _start:
35 |
36 | # assign current stack pointer location to stackTop
37 | mov $stackTop, %esp
38 |
39 | # call the kernel main function
40 | call kernel_entry
41 |
42 | cli
43 |
44 |
45 | # put system in infinite loop
46 | hltLoop:
47 |
48 | hlt
49 | jmp hltLoop
50 |
51 | .size _start, . - _start
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/Kernel/Keyboard/char.h:
--------------------------------------------------------------------------------
1 | #ifndef CHAR_H
2 | #define CHAR_H
3 |
4 | #include "types.h"
5 | #include "keyboard.h"
6 |
7 |
8 | extern char get_ascii_char(uint8);
9 |
10 | #endif
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Kernel/Keyboard/clean.sh:
--------------------------------------------------------------------------------
1 | # shell file to clean compiled code
2 |
3 | # remove all .o object files
4 | rm *.o
5 |
6 | # remove isodir
7 | rm -r isodir
8 |
9 | # remove Kernel_Keyboard_OS.bin
10 | rm Kernel_Keyboard_OS.bin
11 |
12 | # remove Kernel_Keyboard_OS.iso
13 | rm Kernel_Keyboard_OS.iso
--------------------------------------------------------------------------------
/Kernel/Keyboard/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "Kernel_Keyboard_OS" {
2 | multiboot /boot/Kernel_Keyboard_OS.bin
3 | }
4 |
--------------------------------------------------------------------------------
/Kernel/Keyboard/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | #define NULL 0
7 |
8 | #define VGA_ADDRESS 0xB8000
9 | #define BUFSIZE 2200
10 |
11 | uint16* vga_buffer;
12 |
13 | enum vga_color {
14 | BLACK,
15 | BLUE,
16 | GREEN,
17 | CYAN,
18 | RED,
19 | MAGENTA,
20 | BROWN,
21 | GREY,
22 | DARK_GREY,
23 | BRIGHT_BLUE,
24 | BRIGHT_GREEN,
25 | BRIGHT_CYAN,
26 | BRIGHT_RED,
27 | BRIGHT_MAGENTA,
28 | YELLOW,
29 | WHITE,
30 | };
31 |
32 |
33 | #include "keyboard.h"
34 |
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/Kernel/Keyboard/keyboard_demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Kernel/Keyboard/keyboard_demo.png
--------------------------------------------------------------------------------
/Kernel/Keyboard/keycodes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Kernel/Keyboard/keycodes.png
--------------------------------------------------------------------------------
/Kernel/Keyboard/run.sh:
--------------------------------------------------------------------------------
1 | # Shell file to compile code
2 |
3 | # assemble boot.s file
4 | as --32 boot.s -o boot.o
5 |
6 | # compile kernel.c file
7 | gcc -m32 -c kernel.c -o kernel.o -std=gnu99 -ffreestanding -O1 -Wall -Wextra
8 |
9 | gcc -m32 -c utils.c -o utils.o -std=gnu99 -ffreestanding -O1 -Wall -Wextra
10 |
11 | gcc -m32 -c char.c -o char.o -std=gnu99 -ffreestanding -O1 -Wall -Wextra
12 |
13 | # linking all the object files to Kernel_Keyboard_OS.bin
14 | ld -m elf_i386 -T linker.ld kernel.o utils.o char.o boot.o -o Kernel_Keyboard_OS.bin -nostdlib
15 |
16 | # check Kernel_Keyboard_OS.bin file is x86 multiboot file or not
17 | grub-file --is-x86-multiboot Kernel_Keyboard_OS.bin
18 |
19 | # building the iso file
20 | mkdir -p isodir/boot/grub
21 | cp Kernel_Keyboard_OS.bin isodir/boot/Kernel_Keyboard_OS.bin
22 | cp grub.cfg isodir/boot/grub/grub.cfg
23 | grub-mkrescue -o Kernel_Keyboard_OS.iso isodir
24 |
25 | # run it in qemu
26 | qemu-system-x86_64 -cdrom Kernel_Keyboard_OS.iso
27 |
--------------------------------------------------------------------------------
/Kernel/Keyboard/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | typedef unsigned char uint8;
5 | typedef unsigned short uint16;
6 | typedef unsigned int uint32;
7 |
8 | #endif
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Kernel/Keyboard/utils.c:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | uint32 strlen(const char* str)
4 | {
5 | uint32 length = 0;
6 | while(str[length])
7 | length++;
8 | return length;
9 | }
10 |
11 | uint32 digit_count(int num)
12 | {
13 | uint32 count = 0;
14 | if(num == 0)
15 | return 1;
16 | while(num > 0){
17 | count++;
18 | num = num/10;
19 | }
20 | return count;
21 | }
22 |
23 | void itoa(int num, char *number)
24 | {
25 | int dgcount = digit_count(num);
26 | int index = dgcount - 1;
27 | char x;
28 | if(num == 0 && dgcount == 1){
29 | number[0] = '0';
30 | number[1] = '\0';
31 | }else{
32 | while(num != 0){
33 | x = num % 10;
34 | number[index] = x + '0';
35 | index--;
36 | num = num / 10;
37 | }
38 | number[dgcount] = '\0';
39 | }
40 | }
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/Kernel/Keyboard/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef UTILS_H
2 | #define UTILS_H
3 |
4 | #include "types.h"
5 |
6 | extern uint32 strlen(const char*);
7 | extern uint32 digit_count(int);
8 | extern void itoa(int, char *);
9 |
10 | #endif
11 |
12 |
--------------------------------------------------------------------------------
/Kernel/Simple/img/kernel_1/MyOS.iso:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Kernel/Simple/img/kernel_1/MyOS.iso
--------------------------------------------------------------------------------
/Kernel/Simple/img/kernel_2/MyOS.iso:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Kernel/Simple/img/kernel_2/MyOS.iso
--------------------------------------------------------------------------------
/Kernel/Simple/src/kernel_1/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "MyOS" {
2 | multiboot /boot/MyOS.bin
3 | }
4 |
--------------------------------------------------------------------------------
/Kernel/Simple/src/kernel_1/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | typedef unsigned char uint8;
5 | typedef unsigned short uint16;
6 | typedef unsigned int uint32;
7 |
8 |
9 | #define VGA_ADDRESS 0xB8000
10 | #define BUFSIZE 2200
11 |
12 | uint16* vga_buffer;
13 |
14 | #define NULL 0
15 |
16 | enum vga_color {
17 | BLACK,
18 | BLUE,
19 | GREEN,
20 | CYAN,
21 | RED,
22 | MAGENTA,
23 | BROWN,
24 | GREY,
25 | DARK_GREY,
26 | BRIGHT_BLUE,
27 | BRIGHT_GREEN,
28 | BRIGHT_CYAN,
29 | BRIGHT_RED,
30 | BRIGHT_MAGENTA,
31 | YELLOW,
32 | WHITE,
33 | };
34 |
35 | #endif
--------------------------------------------------------------------------------
/Kernel/Simple/src/kernel_1/linker.ld:
--------------------------------------------------------------------------------
1 | /* entry point of our kernel */
2 | ENTRY(_start)
3 |
4 | SECTIONS
5 | {
6 | /* we need 1MB of space atleast */
7 | . = 1M;
8 |
9 | /* text section */
10 | .text BLOCK(4K) : ALIGN(4K)
11 | {
12 | *(.multiboot)
13 | *(.text)
14 | }
15 |
16 | /* read only data section */
17 | .rodata BLOCK(4K) : ALIGN(4K)
18 | {
19 | *(.rodata)
20 | }
21 |
22 | /* data section */
23 | .data BLOCK(4K) : ALIGN(4K)
24 | {
25 | *(.data)
26 | }
27 |
28 | /* bss section */
29 | .bss BLOCK(4K) : ALIGN(4K)
30 | {
31 | *(COMMON)
32 | *(.bss)
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/Kernel/Simple/src/kernel_1/run.sh:
--------------------------------------------------------------------------------
1 | #assemble boot.s file
2 | as --32 boot.s -o boot.o
3 |
4 | #compile kernel.c file
5 | gcc -m32 -c kernel.c -o kernel.o -std=gnu99 -ffreestanding -O2 -Wall -Wextra
6 |
7 | #linking the kernel with kernel.o and boot.o files
8 | ld -m elf_i386 -T linker.ld kernel.o boot.o -o MyOS.bin -nostdlib
9 |
10 | #check MyOS.bin file is x86 multiboot file or not
11 | grub-file --is-x86-multiboot MyOS.bin
12 |
13 | #building the iso file
14 | mkdir -p isodir/boot/grub
15 | cp MyOS.bin isodir/boot/MyOS.bin
16 | cp grub.cfg isodir/boot/grub/grub.cfg
17 | grub-mkrescue -o MyOS.iso isodir
18 |
19 | #run it in qemu
20 | qemu-system-x86_64 -cdrom MyOS.iso
21 |
--------------------------------------------------------------------------------
/Kernel/Simple/src/kernel_2/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "MyOS" {
2 | multiboot /boot/MyOS.bin
3 | }
4 |
--------------------------------------------------------------------------------
/Kernel/Simple/src/kernel_2/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | typedef unsigned char uint8;
5 | typedef unsigned short uint16;
6 | typedef unsigned int uint32;
7 |
8 |
9 | #define VGA_ADDRESS 0xB8000
10 | #define BUFSIZE 2200
11 |
12 | uint16* vga_buffer;
13 |
14 | #define NULL 0
15 |
16 | enum vga_color {
17 | BLACK,
18 | BLUE,
19 | GREEN,
20 | CYAN,
21 | RED,
22 | MAGENTA,
23 | BROWN,
24 | GREY,
25 | DARK_GREY,
26 | BRIGHT_BLUE,
27 | BRIGHT_GREEN,
28 | BRIGHT_CYAN,
29 | BRIGHT_RED,
30 | BRIGHT_MAGENTA,
31 | YELLOW,
32 | WHITE,
33 | };
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/Kernel/Simple/src/kernel_2/linker.ld:
--------------------------------------------------------------------------------
1 | /* entry point of our kernel */
2 | ENTRY(_start)
3 |
4 | SECTIONS
5 | {
6 | /* we need 1MB of space atleast */
7 | . = 1M;
8 |
9 | /* text section */
10 | .text BLOCK(4K) : ALIGN(4K)
11 | {
12 | *(.multiboot)
13 | *(.text)
14 | }
15 |
16 | /* read only data section */
17 | .rodata BLOCK(4K) : ALIGN(4K)
18 | {
19 | *(.rodata)
20 | }
21 |
22 | /* data section */
23 | .data BLOCK(4K) : ALIGN(4K)
24 | {
25 | *(.data)
26 | }
27 |
28 | /* bss section */
29 | .bss BLOCK(4K) : ALIGN(4K)
30 | {
31 | *(COMMON)
32 | *(.bss)
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/Kernel/Simple/src/kernel_2/run.sh:
--------------------------------------------------------------------------------
1 | #assemble boot.s file
2 | as --32 boot.s -o boot.o
3 |
4 | #compile kernel.c file
5 | gcc -m32 -c kernel.c -o kernel.o -std=gnu99 -ffreestanding -O2 -Wall -Wextra
6 |
7 | #linking the kernel with kernel.o and boot.o files
8 | ld -m elf_i386 -T linker.ld kernel.o boot.o -o MyOS.bin -nostdlib
9 |
10 | #check MyOS.bin file is x86 multiboot file or not
11 | grub-file --is-x86-multiboot MyOS.bin
12 |
13 | #building the iso file
14 | mkdir -p isodir/boot/grub
15 | cp MyOS.bin isodir/boot/MyOS.bin
16 | cp grub.cfg isodir/boot/grub/grub.cfg
17 | grub-mkrescue -o MyOS.iso isodir
18 |
19 | #run it in qemu
20 | qemu-system-x86_64 -cdrom MyOS.iso
21 |
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "ATA" {
2 | multiboot /boot/ATA.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | #define MAXIMUM_PAGES 16
7 |
8 | #define SCROLL_UP 1
9 | #define SCROLL_DOWN 2
10 |
11 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
12 |
13 | //initialize console
14 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
15 | void console_scroll(int line_count);
16 | void console_putchar(char ch);
17 | // revert back the printed character and add 0 to it
18 | void console_ungetchar();
19 | // revert back the printed character until n characters
20 | void console_ungetchar_bound(uint8 n);
21 |
22 | void console_gotoxy(uint16 x, uint16 y);
23 |
24 | void console_putstr(const char *str);
25 | void printf(const char *format, ...);
26 |
27 | // read string from console, but no backing
28 | void getstr(char *buffer);
29 |
30 | // read string from console, and erase or go back util bound occurs
31 | void getstr_bound(char *buffer, uint8 bound);
32 |
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/include/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | // symbols from linker.ld for section addresses
7 | extern uint8 __kernel_section_start;
8 | extern uint8 __kernel_section_end;
9 | extern uint8 __kernel_text_section_start;
10 | extern uint8 __kernel_text_section_end;
11 | extern uint8 __kernel_data_section_start;
12 | extern uint8 __kernel_data_section_end;
13 | extern uint8 __kernel_rodata_section_start;
14 | extern uint8 __kernel_rodata_section_end;
15 | extern uint8 __kernel_bss_section_start;
16 | extern uint8 __kernel_bss_section_end;
17 |
18 | #endif
19 |
20 |
21 |
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | int isalpha(char c);
23 | char upper(char c);
24 | char lower(char c);
25 |
26 | void itoa(char *buf, int base, int d);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef uint8 byte;
13 | typedef uint16 word;
14 | typedef uint32 dword;
15 |
16 | typedef enum {
17 | FALSE,
18 | TRUE
19 | } BOOL;
20 |
21 | #endif
22 |
23 |
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/ATA/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/ATA/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/ATA/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/screenshots/ata_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/ATA/screenshots/ata_1.png
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/screenshots/ata_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/ATA/screenshots/ata_2.png
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/screenshots/ata_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/ATA/screenshots/ata_3.png
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/screenshots/ata_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/ATA/screenshots/ata_4.png
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/screenshots/ata_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/ATA/screenshots/ata_5.png
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/screenshots/ata_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/ATA/screenshots/ata_6.png
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/screenshots/ata_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/ATA/screenshots/ata_7.png
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/screenshots/ata_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/ATA/screenshots/ata_8.png
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/screenshots/ata_output.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/ATA/screenshots/ata_output.png
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/screenshots/ata_output_check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/ATA/screenshots/ata_output_check.png
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/src/asm/entry.asm:
--------------------------------------------------------------------------------
1 | ; constants for multiboot header
2 | MBALIGN equ 1<<0
3 | MEMINFO equ 1<<1
4 | FLAGS equ MBALIGN | MEMINFO
5 | MAGIC equ 0x1BADB002
6 | CHECKSUM equ -(MAGIC + FLAGS)
7 |
8 | ; set multiboot section
9 | section .multiboot
10 | align 4
11 | dd MAGIC
12 | dd FLAGS
13 | dd CHECKSUM
14 |
15 | section .data
16 | align 4096
17 |
18 | ; initial stack
19 | section .initial_stack, nobits
20 | align 4
21 |
22 | stack_bottom:
23 | ; 1 MB of uninitialized data for stack
24 | resb 104856
25 | stack_top:
26 |
27 | ; kernel entry, main text section
28 | section .text
29 | global _start
30 |
31 |
32 | ; define _start, aligned by linker.ld script
33 | _start:
34 | mov esp, stack_top
35 | extern kmain
36 | push ebx
37 | call kmain
38 | loop:
39 | jmp loop
40 |
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/ATA/src/asm/load_idt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_idt
3 |
4 | load_idt:
5 | mov eax, [esp + 4]
6 | lidt [eax]
7 | ret
8 |
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "BIOS32" {
2 | multiboot /boot/BIOS32.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/include/bios32.h:
--------------------------------------------------------------------------------
1 | #ifndef BIOS32_H
2 | #define BIOS32_H
3 |
4 | #include "types.h"
5 | #include "isr.h"
6 |
7 | // defined in bios32_call.asm
8 | extern void BIOS32_START();
9 | extern void BIOS32_END();
10 | extern void *bios32_gdt_ptr;
11 | extern void *bios32_gdt_entries;
12 | extern void *bios32_idt_ptr;
13 | extern void *bios32_in_reg16_ptr;
14 | extern void *bios32_out_reg16_ptr;
15 | extern void *bios32_int_number_ptr;
16 |
17 | #define REBASE_ADDRESS(x) (void*)(0x7c00 + (void*)x - (uint32)BIOS32_START)
18 |
19 | // https://en.wikipedia.org/wiki/BIOS_interrupt_call
20 |
21 | void bios32_init();
22 | void bios32_service(uint8 int_num, REGISTERS16 * in_reg, REGISTERS16 * out_reg);
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
7 |
8 | //initialize console
9 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
10 |
11 | void console_putchar(char ch);
12 |
13 | // revert back the printed character and add 0 to it
14 | void console_ungetchar();
15 | // revert back the printed character until n characters
16 | void console_ungetchar_bound(uint8 n);
17 |
18 | void console_gotoxy(uint16 x, uint16 y);
19 |
20 | void console_putstr(const char *str);
21 | void printf(const char *format, ...);
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/include/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | // symbols from linker.ld for section addresses
7 | extern uint8 __kernel_section_start;
8 | extern uint8 __kernel_section_end;
9 | extern uint8 __kernel_text_section_start;
10 | extern uint8 __kernel_text_section_end;
11 | extern uint8 __kernel_data_section_start;
12 | extern uint8 __kernel_data_section_end;
13 | extern uint8 __kernel_rodata_section_start;
14 | extern uint8 __kernel_rodata_section_end;
15 | extern uint8 __kernel_bss_section_start;
16 | extern uint8 __kernel_bss_section_end;
17 |
18 | #endif
19 |
20 |
21 |
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | void itoa(char *buf, int base, int d);
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef uint8 byte;
13 | typedef uint16 word;
14 | typedef uint32 dword;
15 |
16 | #endif
17 |
18 |
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/kernel_bios32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/BIOS32/kernel_bios32.png
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/BIOS32/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/BIOS32/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/BIOS32/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/src/asm/entry.asm:
--------------------------------------------------------------------------------
1 | ; constants for multiboot header
2 | MBALIGN equ 1<<0
3 | MEMINFO equ 1<<1
4 | FLAGS equ MBALIGN | MEMINFO
5 | MAGIC equ 0x1BADB002
6 | CHECKSUM equ -(MAGIC + FLAGS)
7 |
8 | ; set multiboot section
9 | section .multiboot
10 | align 4
11 | dd MAGIC
12 | dd FLAGS
13 | dd CHECKSUM
14 |
15 | section .data
16 | align 4096
17 |
18 | ; initial stack
19 | section .initial_stack, nobits
20 | align 4
21 |
22 | stack_bottom:
23 | ; 1 MB of uninitialized data for stack
24 | resb 104856
25 | stack_top:
26 |
27 | ; kernel entry, main text section
28 | section .text
29 | global _start
30 |
31 |
32 | ; define _start, aligned by linker.ld script
33 | _start:
34 | mov esp, stack_top
35 | extern kmain
36 | push ebx
37 | call kmain
38 | loop:
39 | jmp loop
40 |
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/src/asm/load_idt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_idt
3 |
4 | load_idt:
5 | mov eax, [esp + 4]
6 | lidt [eax]
7 | ret
8 |
--------------------------------------------------------------------------------
/NEW KERNEL/BIOS32/src/kernel.c:
--------------------------------------------------------------------------------
1 | #include "kernel.h"
2 | #include "console.h"
3 | #include "string.h"
4 | #include "gdt.h"
5 | #include "idt.h"
6 | #include "bios32.h"
7 |
8 | void kmain() {
9 | gdt_init();
10 | idt_init();
11 |
12 | console_init(COLOR_WHITE, COLOR_BLACK);
13 |
14 | printf("initializing bios32...\n");
15 | bios32_init();
16 | printf("successfully initialized bios32\n");
17 |
18 | // https://en.wikipedia.org/wiki/BIOS_interrupt_call
19 | REGISTERS16 in = {0};
20 | REGISTERS16 out = {0};
21 | bios32_service(0x12, &in, &out);
22 | printf("Conventional Memory: %d KB\n", out.ax);
23 |
24 | }
25 |
26 |
27 |
--------------------------------------------------------------------------------
/NEW KERNEL/Bitmap Text/README.md:
--------------------------------------------------------------------------------
1 | ## Usage :-
2 |
3 | **Compile the source:**
4 | ```
5 | $ cd OS/NEW\ KERNEL/Bitmap\ Text
6 | $ make
7 | ```
8 |
9 | **Open created ISO in QEMU:**
10 | ```
11 | $ qemu-system-x86_64 out/BitmapTest.iso
12 | ```
13 | or
14 | ```
15 | $ qemu-system-i386 out/BitmapTest.iso
16 | ```
17 | **Clean the code:**
18 | ```
19 | $ cd OS/NEW\ KERNEL/Bitmap\ Text
20 | $ make clean
21 | ```
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/NEW KERNEL/Bitmap Text/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "Bitmap Text" {
2 | multiboot /boot/BitmapText.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/Bitmap Text/include/bios32.h:
--------------------------------------------------------------------------------
1 | #ifndef BIOS32_H
2 | #define BIOS32_H
3 |
4 | #include "types.h"
5 | #include "isr.h"
6 |
7 | // defined in bios32_call.asm
8 | extern void BIOS32_START();
9 | extern void BIOS32_END();
10 | extern void *bios32_gdt_ptr;
11 | extern void *bios32_gdt_entries;
12 | extern void *bios32_idt_ptr;
13 | extern void *bios32_in_reg16_ptr;
14 | extern void *bios32_out_reg16_ptr;
15 | extern void *bios32_int_number_ptr;
16 |
17 | #define REBASE_ADDRESS(x) (void*)(0x7c00 + (void*)x - (uint32)BIOS32_START)
18 |
19 | #define BIOS_CONVENTIONAL_MEMORY 0x7E00
20 |
21 |
22 | // https://en.wikipedia.org/wiki/BIOS_interrupt_call
23 |
24 | void bios32_init();
25 | // bios interrupt call
26 | void int86(uint8 interrupt, REGISTERS16 *in, REGISTERS16 *out);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/Bitmap Text/include/bitmap.h:
--------------------------------------------------------------------------------
1 | #ifndef BITMAP_H
2 | #define BITMAP_H
3 |
4 | #include "types.h"
5 |
6 | #define BITMAP_SIZE 20
7 |
8 | void bitmap_draw_char(char ch, int x, int y, int color);
9 |
10 | void bitmap_draw_string(const char *str, int x, int y, int color);
11 | void bitmap_draw_string_upper(char *str, int x, int y, int color);
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/NEW KERNEL/Bitmap Text/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | #define MAXIMUM_PAGES 16
7 |
8 | #define SCROLL_UP 1
9 | #define SCROLL_DOWN 2
10 |
11 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
12 |
13 | //initialize console
14 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
15 | void console_scroll(int line_count);
16 | void console_putchar(char ch);
17 | // revert back the printed character and add 0 to it
18 | void console_ungetchar();
19 | // revert back the printed character until n characters
20 | void console_ungetchar_bound(uint8 n);
21 |
22 | void console_gotoxy(uint16 x, uint16 y);
23 |
24 | void console_putstr(const char *str);
25 | void printf(const char *format, ...);
26 |
27 | // read string from console, but no backing
28 | void getstr(char *buffer);
29 |
30 | // read string from console, and erase or go back util bound occurs
31 | void getstr_bound(char *buffer, uint8 bound);
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/NEW KERNEL/Bitmap Text/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/Bitmap Text/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | int isalpha(char c);
23 | char upper(char c);
24 | char lower(char c);
25 |
26 | void itoa(char *buf, int base, int d);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/Bitmap Text/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef unsigned long long uint64;
13 | typedef uint8 byte;
14 | typedef uint16 word;
15 | typedef uint32 dword;
16 |
17 | typedef enum {
18 | FALSE,
19 | TRUE
20 | } BOOL;
21 |
22 | #endif
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/Bitmap Text/kernel_bitmap_text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Bitmap Text/kernel_bitmap_text.png
--------------------------------------------------------------------------------
/NEW KERNEL/Bitmap Text/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Bitmap Text/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Bitmap Text/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Bitmap Text/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Bitmap Text/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Bitmap Text/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Bitmap Text/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/Bitmap Text/src/asm/load_idt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_idt
3 |
4 | load_idt:
5 | mov eax, [esp + 4]
6 | lidt [eax]
7 | ret
8 |
--------------------------------------------------------------------------------
/NEW KERNEL/Console/README.md:
--------------------------------------------------------------------------------
1 | ## Requirements :-
2 |
3 | (install following packages using apt-get)
4 | 1) GNU/Linux :- Any distribution
5 | 2) make :- make utility
6 | 3) Assembler :- NASM Assembler(nasm)
7 | 4) GCC :- GNU Compiler Collection, C compiler
8 | 5) xorriso :- A package that creates, loads, manipulates ISO 9660 filesystem images.(man xorriso)
9 | 6) grub-mkrescue :- utility to make ISO image
10 | 7) QEMU :- Quick EMUlator to boot our kernel
11 |
12 |
13 | ## Usage :-
14 |
15 | **Compile the source:**
16 | ```
17 | $ cd OS/NEW\ KERNEL/Console
18 | $ make
19 | ```
20 |
21 | **Open created ISO in QEMU:**
22 | ```
23 | $ qemu-system-x86_64 out/Console.iso
24 | ```
25 | or
26 | ```
27 | $ qemu-system-i386 out/Console.iso
28 | ```
29 | **Clean the code:**
30 | ```
31 | $ cd OS/NEW\ KERNEL/Console
32 | $ make clean
33 | ```
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/NEW KERNEL/Console/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "Console" {
2 | multiboot /boot/Console.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/Console/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | #define MAXIMUM_PAGES 16
7 |
8 | #define SCROLL_UP 1
9 | #define SCROLL_DOWN 2
10 |
11 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
12 |
13 | //initialize console
14 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
15 | void console_scroll(int line_count);
16 | void console_putchar(char ch);
17 | // revert back the printed character and add 0 to it
18 | void console_ungetchar();
19 | // revert back the printed character until n characters
20 | void console_ungetchar_bound(uint8 n);
21 |
22 | void console_gotoxy(uint16 x, uint16 y);
23 |
24 | void console_putstr(const char *str);
25 | void printf(const char *format, ...);
26 |
27 | #endif
28 |
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/Console/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/Console/include/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | // symbols from linker.ld for section addresses
7 | extern uint8 __kernel_section_start;
8 | extern uint8 __kernel_section_end;
9 | extern uint8 __kernel_text_section_start;
10 | extern uint8 __kernel_text_section_end;
11 | extern uint8 __kernel_data_section_start;
12 | extern uint8 __kernel_data_section_end;
13 | extern uint8 __kernel_rodata_section_start;
14 | extern uint8 __kernel_rodata_section_end;
15 | extern uint8 __kernel_bss_section_start;
16 | extern uint8 __kernel_bss_section_end;
17 |
18 | #endif
19 |
20 |
--------------------------------------------------------------------------------
/NEW KERNEL/Console/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | void itoa(char *buf, int base, int d);
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/NEW KERNEL/Console/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef uint8 byte;
13 | typedef uint16 word;
14 | typedef uint32 dword;
15 |
16 | #endif
17 |
18 |
--------------------------------------------------------------------------------
/NEW KERNEL/Console/kernel_console.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Console/kernel_console.png
--------------------------------------------------------------------------------
/NEW KERNEL/Console/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Console/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Console/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Console/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Console/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Console/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Console/src/asm/entry.asm:
--------------------------------------------------------------------------------
1 | ; constants for multiboot header
2 | MBALIGN equ 1<<0
3 | MEMINFO equ 1<<1
4 | FLAGS equ MBALIGN | MEMINFO
5 | MAGIC equ 0x1BADB002
6 | CHECKSUM equ -(MAGIC + FLAGS)
7 |
8 | ; set multiboot section
9 | section .multiboot
10 | align 4
11 | dd MAGIC
12 | dd FLAGS
13 | dd CHECKSUM
14 |
15 | section .data
16 | align 4096
17 |
18 | ; initial stack
19 | section .initial_stack, nobits
20 | align 4
21 |
22 | stack_bottom:
23 | ; 1 MB of uninitialized data for stack
24 | resb 104856
25 | stack_top:
26 |
27 | ; kernel entry, main text section
28 | section .text
29 | global _start
30 |
31 |
32 | ; define _start, aligned by linker.ld script
33 | _start:
34 | mov esp, stack_top
35 | extern kmain
36 | push ebx
37 | call kmain
38 | loop:
39 | jmp loop
40 |
41 |
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/README.md:
--------------------------------------------------------------------------------
1 | ## Requirements :-
2 |
3 | (install following packages using apt-get)
4 | 1) GNU/Linux :- Any distribution
5 | 2) make :- make utility
6 | 3) Assembler :- NASM Assembler(nasm)
7 | 4) GCC :- GNU Compiler Collection, C compiler
8 | 5) xorriso :- A package that creates, loads, manipulates ISO 9660 filesystem images.(man xorriso)
9 | 6) grub-mkrescue :- utility to make ISO image
10 | 7) QEMU :- Quick EMUlator to boot our kernel
11 |
12 |
13 | ## Usage :-
14 |
15 | **Compile the source:**
16 | ```
17 | $ cd OS/NEW\ KERNEL/FPU
18 | $ make
19 | ```
20 |
21 | **Open created ISO in QEMU:**
22 | ```
23 | $ qemu-system-x86_64 out/FPU.iso
24 | ```
25 | or
26 | ```
27 | $ qemu-system-i386 out/FPU.iso
28 | ```
29 | **Clean the code:**
30 | ```
31 | $ cd OS/NEW\ KERNEL/FPU
32 | $ make clean
33 | ```
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "FPU" {
2 | multiboot /boot/FPU.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
7 |
8 | //initialize console
9 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
10 |
11 | void console_putchar(char ch);
12 | // revert back the printed character and add 0 to it
13 | void console_ungetchar();
14 | // revert back the printed character until n characters
15 | void console_ungetchar_bound(uint8 n);
16 |
17 | void console_gotoxy(uint16 x, uint16 y);
18 |
19 | void console_putstr(const char *str);
20 | void printf(const char *format, ...);
21 |
22 | // read string from console, but no backing
23 | void getstr(char *buffer);
24 |
25 | // read string from console, and erase or go back util bound occurs
26 | void getstr_bound(char *buffer, uint8 bound);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/include/fpu.h:
--------------------------------------------------------------------------------
1 | #ifndef FPU_H
2 | #define FPU_H
3 |
4 | void fpu_enable();
5 |
6 | #endif
7 |
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/include/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | // symbols from linker.ld for section addresses
7 | extern uint8 __kernel_section_start;
8 | extern uint8 __kernel_section_end;
9 | extern uint8 __kernel_text_section_start;
10 | extern uint8 __kernel_text_section_end;
11 | extern uint8 __kernel_data_section_start;
12 | extern uint8 __kernel_data_section_end;
13 | extern uint8 __kernel_rodata_section_start;
14 | extern uint8 __kernel_rodata_section_end;
15 | extern uint8 __kernel_bss_section_start;
16 | extern uint8 __kernel_bss_section_end;
17 |
18 | #endif
19 |
20 |
21 |
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 | int strncmp(const char *s1, const char *s2, int c);
16 |
17 | int strcpy(char *dst, const char *src);
18 |
19 | void strcat(char *dest, const char *src);
20 |
21 | int isspace(char c);
22 |
23 | int isalpha(char c);
24 | char upper(char c);
25 | char lower(char c);
26 |
27 | void itoa(char *buf, int base, int d);
28 |
29 | char *strstr(const char *in, const char *str);
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef uint8 byte;
13 | typedef uint16 word;
14 | typedef uint32 dword;
15 |
16 | typedef enum {
17 | FALSE,
18 | TRUE
19 | } BOOL;
20 |
21 | #endif
22 |
23 |
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/kernel_fpu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/FPU/kernel_fpu.png
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/FPU/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/FPU/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/FPU/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/src/asm/entry.asm:
--------------------------------------------------------------------------------
1 | ; constants for multiboot header
2 | MBALIGN equ 1<<0
3 | MEMINFO equ 1<<1
4 | FLAGS equ MBALIGN | MEMINFO
5 | MAGIC equ 0x1BADB002
6 | CHECKSUM equ -(MAGIC + FLAGS)
7 |
8 | ; set multiboot section
9 | section .multiboot
10 | align 4
11 | dd MAGIC
12 | dd FLAGS
13 | dd CHECKSUM
14 |
15 | section .data
16 | align 4096
17 |
18 | ; initial stack
19 | section .initial_stack, nobits
20 | align 4
21 |
22 | stack_bottom:
23 | ; 1 MB of uninitialized data for stack
24 | resb 104856
25 | stack_top:
26 |
27 | ; kernel entry, main text section
28 | section .text
29 | global _start
30 |
31 |
32 | ; define _start, aligned by linker.ld script
33 | _start:
34 | mov esp, stack_top
35 | extern kmain
36 | push ebx
37 | call kmain
38 | loop:
39 | jmp loop
40 |
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/src/asm/load_idt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_idt
3 |
4 | load_idt:
5 | mov eax, [esp + 4]
6 | lidt [eax]
7 | ret
8 |
--------------------------------------------------------------------------------
/NEW KERNEL/FPU/src/fpu.c:
--------------------------------------------------------------------------------
1 | #include "io_ports.h"
2 |
3 | void fpu_set_control_word(const uint16 cw) {
4 | asm volatile("fldcw %0" ::"m"(cw));
5 | }
6 |
7 | void fpu_enable() {
8 | uint32 cr4;
9 | asm volatile("mov %%cr4, %0" :"=r"(cr4));
10 | // set 9th bit to 1 in cr4
11 | cr4 |= 0x200;
12 | asm volatile("mov %0, %%cr4" ::"r"(cr4));
13 | fpu_set_control_word(0x37F); // fpu init
14 | fpu_set_control_word(0x37E); // invalid operand exceptions
15 | fpu_set_control_word(0x37A); // divide by zero
16 | }
17 |
--------------------------------------------------------------------------------
/NEW KERNEL/GDT/README.md:
--------------------------------------------------------------------------------
1 | ## Requirements :-
2 |
3 | (install following packages using apt-get)
4 | 1) GNU/Linux :- Any distribution
5 | 2) make :- make utility
6 | 3) Assembler :- NASM Assembler(nasm)
7 | 4) GCC :- GNU Compiler Collection, C compiler
8 | 5) xorriso :- A package that creates, loads, manipulates ISO 9660 filesystem images.(man xorriso)
9 | 6) grub-mkrescue :- utility to make ISO image
10 | 7) QEMU :- Quick EMUlator to boot our kernel
11 |
12 |
13 | ## Usage :-
14 |
15 | **Compile the source:**
16 | ```
17 | $ cd OS/NEW\ KERNEL/GDT
18 | $ make
19 | ```
20 |
21 | **Open created ISO in QEMU:**
22 | ```
23 | $ qemu-system-x86_64 out/GDT.iso
24 | ```
25 | or
26 | ```
27 | $ qemu-system-i386 out/GDT.iso
28 | ```
29 | **Clean the code:**
30 | ```
31 | $ cd OS/NEW\ KERNEL/GDT
32 | $ make clean
33 | ```
34 |
35 |
--------------------------------------------------------------------------------
/NEW KERNEL/GDT/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "GDT" {
2 | multiboot /boot/GDT.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/GDT/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
7 |
8 | //initialize console
9 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
10 |
11 | void console_putchar(char ch);
12 |
13 | // revert back the printed character and add 0 to it
14 | void console_ungetchar();
15 | // revert back the printed character until n characters
16 | void console_ungetchar_bound(uint8 n);
17 |
18 | void console_gotoxy(uint16 x, uint16 y);
19 |
20 | void console_putstr(const char *str);
21 | void printf(const char *format, ...);
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/GDT/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/GDT/include/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | // symbols from linker.ld for section addresses
7 | extern uint8 __kernel_section_start;
8 | extern uint8 __kernel_section_end;
9 | extern uint8 __kernel_text_section_start;
10 | extern uint8 __kernel_text_section_end;
11 | extern uint8 __kernel_data_section_start;
12 | extern uint8 __kernel_data_section_end;
13 | extern uint8 __kernel_rodata_section_start;
14 | extern uint8 __kernel_rodata_section_end;
15 | extern uint8 __kernel_bss_section_start;
16 | extern uint8 __kernel_bss_section_end;
17 |
18 | #endif
19 |
20 |
21 |
--------------------------------------------------------------------------------
/NEW KERNEL/GDT/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | void itoa(char *buf, int base, int d);
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/NEW KERNEL/GDT/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef uint8 byte;
13 | typedef uint16 word;
14 | typedef uint32 dword;
15 |
16 | #endif
17 |
18 |
--------------------------------------------------------------------------------
/NEW KERNEL/GDT/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/GDT/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/GDT/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/GDT/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/GDT/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/GDT/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/GDT/src/asm/entry.asm:
--------------------------------------------------------------------------------
1 | ; constants for multiboot header
2 | MBALIGN equ 1<<0
3 | MEMINFO equ 1<<1
4 | FLAGS equ MBALIGN | MEMINFO
5 | MAGIC equ 0x1BADB002
6 | CHECKSUM equ -(MAGIC + FLAGS)
7 |
8 | ; set multiboot section
9 | section .multiboot
10 | align 4
11 | dd MAGIC
12 | dd FLAGS
13 | dd CHECKSUM
14 |
15 | section .data
16 | align 4096
17 |
18 | ; initial stack
19 | section .initial_stack, nobits
20 | align 4
21 |
22 | stack_bottom:
23 | ; 1 MB of uninitialized data for stack
24 | resb 104856
25 | stack_top:
26 |
27 | ; kernel entry, main text section
28 | section .text
29 | global _start
30 |
31 |
32 | ; define _start, aligned by linker.ld script
33 | _start:
34 | mov esp, stack_top
35 | extern kmain
36 | push ebx
37 | call kmain
38 | loop:
39 | jmp loop
40 |
41 |
--------------------------------------------------------------------------------
/NEW KERNEL/GDT/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
25 |
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/README.md:
--------------------------------------------------------------------------------
1 | ## Requirements :-
2 |
3 | (install following packages using apt-get)
4 | 1) GNU/Linux :- Any distribution
5 | 2) make :- make utility
6 | 3) Assembler :- NASM Assembler(nasm)
7 | 4) GCC :- GNU Compiler Collection, C compiler
8 | 5) xorriso :- A package that creates, loads, manipulates ISO 9660 filesystem images.(man xorriso)
9 | 6) grub-mkrescue :- utility to make ISO image
10 | 7) QEMU :- Quick EMUlator to boot our kernel
11 |
12 |
13 | ## Usage :-
14 |
15 | **Compile the source:**
16 | ```
17 | $ cd OS/NEW\ KERNEL/IDT
18 | $ make
19 | ```
20 |
21 | **Open created ISO in QEMU:**
22 | ```
23 | $ qemu-system-x86_64 out/IDT.iso
24 | ```
25 | or
26 | ```
27 | $ qemu-system-i386 out/IDT.iso
28 | ```
29 | **Clean the code:**
30 | ```
31 | $ cd OS/NEW\ KERNEL/IDT
32 | $ make clean
33 | ```
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "IDT" {
2 | multiboot /boot/IDT.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
7 |
8 | //initialize console
9 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
10 |
11 | void console_putchar(char ch);
12 |
13 | // revert back the printed character and add 0 to it
14 | void console_ungetchar();
15 | // revert back the printed character until n characters
16 | void console_ungetchar_bound(uint8 n);
17 |
18 | void console_gotoxy(uint16 x, uint16 y);
19 |
20 | void console_putstr(const char *str);
21 | void printf(const char *format, ...);
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/include/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | // symbols from linker.ld for section addresses
7 | extern uint8 __kernel_section_start;
8 | extern uint8 __kernel_section_end;
9 | extern uint8 __kernel_text_section_start;
10 | extern uint8 __kernel_text_section_end;
11 | extern uint8 __kernel_data_section_start;
12 | extern uint8 __kernel_data_section_end;
13 | extern uint8 __kernel_rodata_section_start;
14 | extern uint8 __kernel_rodata_section_end;
15 | extern uint8 __kernel_bss_section_start;
16 | extern uint8 __kernel_bss_section_end;
17 |
18 | #endif
19 |
20 |
21 |
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | void itoa(char *buf, int base, int d);
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef uint8 byte;
13 | typedef uint16 word;
14 | typedef uint32 dword;
15 |
16 | #endif
17 |
18 |
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/kernel_idt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/IDT/kernel_idt.png
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/IDT/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/IDT/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/IDT/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/src/asm/entry.asm:
--------------------------------------------------------------------------------
1 | ; constants for multiboot header
2 | MBALIGN equ 1<<0
3 | MEMINFO equ 1<<1
4 | FLAGS equ MBALIGN | MEMINFO
5 | MAGIC equ 0x1BADB002
6 | CHECKSUM equ -(MAGIC + FLAGS)
7 |
8 | ; set multiboot section
9 | section .multiboot
10 | align 4
11 | dd MAGIC
12 | dd FLAGS
13 | dd CHECKSUM
14 |
15 | section .data
16 | align 4096
17 |
18 | ; initial stack
19 | section .initial_stack, nobits
20 | align 4
21 |
22 | stack_bottom:
23 | ; 1 MB of uninitialized data for stack
24 | resb 104856
25 | stack_top:
26 |
27 | ; kernel entry, main text section
28 | section .text
29 | global _start
30 |
31 |
32 | ; define _start, aligned by linker.ld script
33 | _start:
34 | mov esp, stack_top
35 | extern kmain
36 | push ebx
37 | call kmain
38 | loop:
39 | jmp loop
40 |
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/src/asm/load_idt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_idt
3 |
4 | load_idt:
5 | mov eax, [esp + 4]
6 | lidt [eax]
7 | ret
8 |
--------------------------------------------------------------------------------
/NEW KERNEL/IDT/src/kernel.c:
--------------------------------------------------------------------------------
1 | #include "kernel.h"
2 | #include "console.h"
3 | #include "string.h"
4 | #include "gdt.h"
5 | #include "idt.h"
6 |
7 | void kmain() {
8 | gdt_init();
9 | idt_init();
10 |
11 | console_init(COLOR_WHITE, COLOR_BLACK);
12 |
13 | // raise division by zero, eax=0x7b, ecx=0
14 | asm volatile("\txorl %edx, %edx");
15 | asm volatile("\tmovl $0x7b, %eax");
16 | asm volatile("\tmovl $0, %ecx");
17 | asm volatile("\tidivl %ecx");
18 | }
19 |
20 |
21 |
--------------------------------------------------------------------------------
/NEW KERNEL/KHeap/README.md:
--------------------------------------------------------------------------------
1 | ## Requirements :-
2 |
3 | (install following packages using apt-get)
4 | 1) GNU/Linux :- Any distribution
5 | 2) make :- make utility
6 | 3) Assembler :- NASM Assembler(nasm)
7 | 4) GCC :- GNU Compiler Collection, C compiler
8 | 5) xorriso :- A package that creates, loads, manipulates ISO 9660 filesystem images.(man xorriso)
9 | 6) grub-mkrescue :- utility to make ISO image
10 | 7) QEMU :- Quick EMUlator to boot our kernel
11 |
12 |
13 | ## Usage :-
14 |
15 | **Compile the source:**
16 | ```
17 | $ cd OS/NEW\ KERNEL/KHeap
18 | $ make
19 | ```
20 |
21 | **Open created ISO in QEMU:**
22 | ```
23 | $ qemu-system-x86_64 out/KHeap.iso
24 | ```
25 | or
26 | ```
27 | $ qemu-system-i386 out/KHeap.iso
28 | ```
29 | **Clean the code:**
30 | ```
31 | $ cd OS/NEW\ KERNEL/KHeap
32 | $ make clean
33 | ```
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/NEW KERNEL/KHeap/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "KHeap" {
2 | multiboot /boot/KHeap.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/KHeap/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
7 |
8 | //initialize console
9 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
10 |
11 | void console_putchar(char ch);
12 | // revert back the printed character and add 0 to it
13 | void console_ungetchar();
14 | // revert back the printed character until n characters
15 | void console_ungetchar_bound(uint8 n);
16 |
17 | void console_gotoxy(uint16 x, uint16 y);
18 |
19 | void console_putstr(const char *str);
20 | void printf(const char *format, ...);
21 |
22 | // read string from console, but no backing
23 | void getstr(char *buffer);
24 |
25 | // read string from console, and erase or go back util bound occurs
26 | void getstr_bound(char *buffer, uint8 bound);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/KHeap/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/KHeap/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | int isalpha(char c);
23 | char upper(char c);
24 | char lower(char c);
25 |
26 | void itoa(char *buf, int base, int d);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/KHeap/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef unsigned long long uint64;
13 | typedef uint8 byte;
14 | typedef uint16 word;
15 | typedef uint32 dword;
16 |
17 | typedef enum {
18 | FALSE,
19 | TRUE
20 | } BOOL;
21 |
22 | #endif
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/KHeap/kernel_kheap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/KHeap/kernel_kheap.png
--------------------------------------------------------------------------------
/NEW KERNEL/KHeap/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/KHeap/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/KHeap/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/KHeap/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/KHeap/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/KHeap/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/KHeap/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/KHeap/src/asm/load_idt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_idt
3 |
4 | load_idt:
5 | mov eax, [esp + 4]
6 | lidt [eax]
7 | ret
8 |
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/README.md:
--------------------------------------------------------------------------------
1 | ## Requirements :-
2 |
3 | (install following packages using apt-get)
4 | 1) GNU/Linux :- Any distribution
5 | 2) make :- make utility
6 | 3) Assembler :- NASM Assembler(nasm)
7 | 4) GCC :- GNU Compiler Collection, C compiler
8 | 5) xorriso :- A package that creates, loads, manipulates ISO 9660 filesystem images.(man xorriso)
9 | 6) grub-mkrescue :- utility to make ISO image
10 | 7) QEMU :- Quick EMUlator to boot our kernel
11 |
12 |
13 | ## Usage :-
14 |
15 | **Compile the source:**
16 | ```
17 | $ cd OS/NEW\ KERNEL/Keyboard
18 | $ make
19 | ```
20 |
21 | **Open created ISO in QEMU:**
22 | ```
23 | $ qemu-system-x86_64 out/Keyboard.iso
24 | ```
25 | or
26 | ```
27 | $ qemu-system-i386 out/Keyboard.iso
28 | ```
29 | **Clean the code:**
30 | ```
31 | $ cd OS/NEW\ KERNEL/Keyboard
32 | $ make clean
33 | ```
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "Keyboard" {
2 | multiboot /boot/Keyboard.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
7 |
8 | //initialize console
9 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
10 |
11 | void console_putchar(char ch);
12 | // revert back the printed character and add 0 to it
13 | void console_ungetchar();
14 | // revert back the printed character until n characters
15 | void console_ungetchar_bound(uint8 n);
16 |
17 | void console_gotoxy(uint16 x, uint16 y);
18 |
19 | void console_putstr(const char *str);
20 | void printf(const char *format, ...);
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/include/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | // symbols from linker.ld for section addresses
7 | extern uint8 __kernel_section_start;
8 | extern uint8 __kernel_section_end;
9 | extern uint8 __kernel_text_section_start;
10 | extern uint8 __kernel_text_section_end;
11 | extern uint8 __kernel_data_section_start;
12 | extern uint8 __kernel_data_section_end;
13 | extern uint8 __kernel_rodata_section_start;
14 | extern uint8 __kernel_rodata_section_end;
15 | extern uint8 __kernel_bss_section_start;
16 | extern uint8 __kernel_bss_section_end;
17 |
18 | #endif
19 |
20 |
21 |
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | int isalpha(char c);
23 | char upper(char c);
24 | char lower(char c);
25 |
26 | void itoa(char *buf, int base, int d);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef uint8 byte;
13 | typedef uint16 word;
14 | typedef uint32 dword;
15 |
16 | typedef enum {
17 | FALSE,
18 | TRUE
19 | } BOOL;
20 |
21 | #endif
22 |
23 |
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/kernel_keyboard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Keyboard/kernel_keyboard.png
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Keyboard/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Keyboard/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Keyboard/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/src/asm/entry.asm:
--------------------------------------------------------------------------------
1 | ; constants for multiboot header
2 | MBALIGN equ 1<<0
3 | MEMINFO equ 1<<1
4 | FLAGS equ MBALIGN | MEMINFO
5 | MAGIC equ 0x1BADB002
6 | CHECKSUM equ -(MAGIC + FLAGS)
7 |
8 | ; set multiboot section
9 | section .multiboot
10 | align 4
11 | dd MAGIC
12 | dd FLAGS
13 | dd CHECKSUM
14 |
15 | section .data
16 | align 4096
17 |
18 | ; initial stack
19 | section .initial_stack, nobits
20 | align 4
21 |
22 | stack_bottom:
23 | ; 1 MB of uninitialized data for stack
24 | resb 104856
25 | stack_top:
26 |
27 | ; kernel entry, main text section
28 | section .text
29 | global _start
30 |
31 |
32 | ; define _start, aligned by linker.ld script
33 | _start:
34 | mov esp, stack_top
35 | extern kmain
36 | push ebx
37 | call kmain
38 | loop:
39 | jmp loop
40 |
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/src/asm/load_idt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_idt
3 |
4 | load_idt:
5 | mov eax, [esp + 4]
6 | lidt [eax]
7 | ret
8 |
--------------------------------------------------------------------------------
/NEW KERNEL/Keyboard/src/kernel.c:
--------------------------------------------------------------------------------
1 | #include "kernel.h"
2 | #include "console.h"
3 | #include "string.h"
4 | #include "gdt.h"
5 | #include "idt.h"
6 | #include "keyboard.h"
7 |
8 | void kmain() {
9 | gdt_init();
10 | idt_init();
11 |
12 | console_init(COLOR_WHITE, COLOR_BLACK);
13 | keyboard_init();
14 |
15 | printf("Type something...\n");
16 | while(1) {
17 | printf("%c", kb_getchar());
18 | }
19 | }
20 |
21 |
22 |
--------------------------------------------------------------------------------
/NEW KERNEL/Memory Info/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "Memory Info" {
2 | multiboot /boot/Memory_Info.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/Memory Info/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
7 |
8 | //initialize console
9 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
10 |
11 | void printf(const char *format, ...);
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/NEW KERNEL/Memory Info/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/Memory Info/include/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | // symbols from linker.ld for section addresses
7 | extern uint8 __kernel_section_start;
8 | extern uint8 __kernel_section_end;
9 | extern uint8 __kernel_text_section_start;
10 | extern uint8 __kernel_text_section_end;
11 | extern uint8 __kernel_data_section_start;
12 | extern uint8 __kernel_data_section_end;
13 | extern uint8 __kernel_rodata_section_start;
14 | extern uint8 __kernel_rodata_section_end;
15 | extern uint8 __kernel_bss_section_start;
16 | extern uint8 __kernel_bss_section_end;
17 |
18 | #endif
19 |
--------------------------------------------------------------------------------
/NEW KERNEL/Memory Info/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | void itoa(char *buf, int base, int d);
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/NEW KERNEL/Memory Info/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef unsigned long long uint64;
13 | typedef uint8 byte;
14 | typedef uint16 word;
15 | typedef uint32 dword;
16 |
17 | #endif
18 |
19 |
--------------------------------------------------------------------------------
/NEW KERNEL/Memory Info/kernel_memory_info.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Memory Info/kernel_memory_info.png
--------------------------------------------------------------------------------
/NEW KERNEL/Memory Info/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Memory Info/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Memory Info/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Memory Info/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Memory Info/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Memory Info/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "Mouse" {
2 | multiboot /boot/Mouse.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
7 |
8 | //initialize console
9 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
10 |
11 | void console_putchar(char ch);
12 | // revert back the printed character and add 0 to it
13 | void console_ungetchar();
14 | // revert back the printed character until n characters
15 | void console_ungetchar_bound(uint8 n);
16 |
17 | void console_gotoxy(uint16 x, uint16 y);
18 |
19 | void console_putstr(const char *str);
20 | void printf(const char *format, ...);
21 |
22 | // read string from console, but no backing
23 | void getstr(char *buffer);
24 |
25 | // read string from console, and erase or go back util bound occurs
26 | void getstr_bound(char *buffer, uint8 bound);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/include/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | // symbols from linker.ld for section addresses
7 | extern uint8 __kernel_section_start;
8 | extern uint8 __kernel_section_end;
9 | extern uint8 __kernel_text_section_start;
10 | extern uint8 __kernel_text_section_end;
11 | extern uint8 __kernel_data_section_start;
12 | extern uint8 __kernel_data_section_end;
13 | extern uint8 __kernel_rodata_section_start;
14 | extern uint8 __kernel_rodata_section_end;
15 | extern uint8 __kernel_bss_section_start;
16 | extern uint8 __kernel_bss_section_end;
17 |
18 | #endif
19 |
20 |
21 |
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | int isalpha(char c);
23 | char upper(char c);
24 | char lower(char c);
25 |
26 | void itoa(char *buf, int base, int d);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef uint8 byte;
13 | typedef uint16 word;
14 | typedef uint32 dword;
15 |
16 | typedef enum {
17 | FALSE,
18 | TRUE
19 | } BOOL;
20 |
21 | #endif
22 |
23 |
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/kernel_mouse_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Mouse/kernel_mouse_1.png
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/kernel_mouse_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Mouse/kernel_mouse_2.png
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Mouse/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Mouse/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Mouse/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/src/asm/entry.asm:
--------------------------------------------------------------------------------
1 | ; constants for multiboot header
2 | MBALIGN equ 1<<0
3 | MEMINFO equ 1<<1
4 | FLAGS equ MBALIGN | MEMINFO
5 | MAGIC equ 0x1BADB002
6 | CHECKSUM equ -(MAGIC + FLAGS)
7 |
8 | ; set multiboot section
9 | section .multiboot
10 | align 4
11 | dd MAGIC
12 | dd FLAGS
13 | dd CHECKSUM
14 |
15 | section .data
16 | align 4096
17 |
18 | ; initial stack
19 | section .initial_stack, nobits
20 | align 4
21 |
22 | stack_bottom:
23 | ; 1 MB of uninitialized data for stack
24 | resb 104856
25 | stack_top:
26 |
27 | ; kernel entry, main text section
28 | section .text
29 | global _start
30 |
31 |
32 | ; define _start, aligned by linker.ld script
33 | _start:
34 | mov esp, stack_top
35 | extern kmain
36 | push ebx
37 | call kmain
38 | loop:
39 | jmp loop
40 |
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/src/asm/load_idt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_idt
3 |
4 | load_idt:
5 | mov eax, [esp + 4]
6 | lidt [eax]
7 | ret
8 |
--------------------------------------------------------------------------------
/NEW KERNEL/Mouse/src/kernel.c:
--------------------------------------------------------------------------------
1 | #include "kernel.h"
2 | #include "console.h"
3 | #include "string.h"
4 | #include "gdt.h"
5 | #include "idt.h"
6 | #include "keyboard.h"
7 | #include "mouse.h"
8 |
9 | void kmain() {
10 | gdt_init();
11 | idt_init();
12 |
13 | console_init(COLOR_WHITE, COLOR_BLACK);
14 | vga_disable_cursor();
15 | keyboard_init();
16 | mouse_init();
17 |
18 | printf("\n\n\t\t--Mouse Click Here--");
19 | }
20 |
21 |
22 |
--------------------------------------------------------------------------------
/NEW KERNEL/Paging/README.md:
--------------------------------------------------------------------------------
1 |
2 | ## Usage :-
3 |
4 | **Compile the source:**
5 | ```
6 | $ cd OS/NEW\ KERNEL/Paging
7 | $ make
8 | ```
9 |
10 | **Open created ISO in QEMU:**
11 | ```
12 | $ qemu-system-x86_64 -m 64 out/Paging.iso
13 | ```
14 | or
15 | ```
16 | $ qemu-system-i386 out/Paging.iso
17 | ```
18 | **Clean the code:**
19 | ```
20 | $ cd OS/NEW\ KERNEL/Paging
21 | $ make clean
22 | ```
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/NEW KERNEL/Paging/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "Paging" {
2 | multiboot /boot/Paging.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/Paging/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | #define MAXIMUM_PAGES 16
7 |
8 | #define SCROLL_UP 1
9 | #define SCROLL_DOWN 2
10 |
11 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
12 |
13 | //initialize console
14 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
15 | void console_scroll(int line_count);
16 | void console_putchar(char ch);
17 | // revert back the printed character and add 0 to it
18 | void console_ungetchar();
19 | // revert back the printed character until n characters
20 | void console_ungetchar_bound(uint8 n);
21 |
22 | void console_gotoxy(uint16 x, uint16 y);
23 |
24 | void console_putstr(const char *str);
25 | void printf(const char *format, ...);
26 |
27 | // read string from console, but no backing
28 | void getstr(char *buffer);
29 |
30 | // read string from console, and erase or go back util bound occurs
31 | void getstr_bound(char *buffer, uint8 bound);
32 |
33 | #endif
--------------------------------------------------------------------------------
/NEW KERNEL/Paging/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/Paging/include/paging.h:
--------------------------------------------------------------------------------
1 | #ifndef PAGING_H
2 | #define PAGING_H
3 |
4 | #include "isr.h"
5 | #include "types.h"
6 |
7 | #define PAGE_SIZE 4096
8 |
9 |
10 | void paging_init();
11 |
12 | void *paging_get_physical_address(void *virtual_addr);
13 | void paging_allocate_page(void *addr);
14 | void paging_free_page(void *virtual_addr);
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/NEW KERNEL/Paging/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | int isalpha(char c);
23 | char upper(char c);
24 | char lower(char c);
25 |
26 | void itoa(char *buf, int base, int d);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/Paging/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef unsigned long long uint64;
13 | typedef uint8 byte;
14 | typedef uint16 word;
15 | typedef uint32 dword;
16 |
17 | typedef enum {
18 | FALSE,
19 | TRUE
20 | } BOOL;
21 |
22 | #endif
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/Paging/kernel_paging.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Paging/kernel_paging.png
--------------------------------------------------------------------------------
/NEW KERNEL/Paging/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Paging/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Paging/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Paging/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Paging/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Paging/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Paging/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/Paging/src/asm/load_idt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_idt
3 |
4 | load_idt:
5 | mov eax, [esp + 4]
6 | lidt [eax]
7 | ret
8 |
--------------------------------------------------------------------------------
/NEW KERNEL/Physical Memory Manager/README.md:
--------------------------------------------------------------------------------
1 | Make sure you pass memory to qemu using -m option
2 | At least minimum 4 MB memory is required
3 |
4 |
5 | ## Usage :-
6 |
7 | **Compile the source:**
8 | ```
9 | $ cd OS/NEW\ KERNEL/Physical\ Memory\ Manager
10 | $ make
11 | ```
12 |
13 | **Open created ISO in QEMU:**
14 | ```
15 | $ qemu-system-x86_64 -m 64 out/Physical_MM.iso
16 | ```
17 | or
18 | ```
19 | $ qemu-system-i386 out/Physical_MM.iso
20 | ```
21 | **Clean the code:**
22 | ```
23 | $ cd OS/NEW\ KERNEL/Physical\ Memory\ Manager
24 | $ make clean
25 | ```
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/NEW KERNEL/Physical Memory Manager/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "Physical_MM" {
2 | multiboot /boot/Physical_MM.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/Physical Memory Manager/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
7 |
8 | //initialize console
9 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
10 |
11 | void console_putchar(char ch);
12 | // revert back the printed character and add 0 to it
13 | void console_ungetchar();
14 | // revert back the printed character until n characters
15 | void console_ungetchar_bound(uint8 n);
16 |
17 | void console_gotoxy(uint16 x, uint16 y);
18 |
19 | void console_putstr(const char *str);
20 | void printf(const char *format, ...);
21 |
22 | // read string from console, but no backing
23 | void getstr(char *buffer);
24 |
25 | // read string from console, and erase or go back util bound occurs
26 | void getstr_bound(char *buffer, uint8 bound);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/Physical Memory Manager/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/Physical Memory Manager/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | int isalpha(char c);
23 | char upper(char c);
24 | char lower(char c);
25 |
26 | void itoa(char *buf, int base, int d);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/Physical Memory Manager/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef unsigned long long uint64;
13 | typedef uint8 byte;
14 | typedef uint16 word;
15 | typedef uint32 dword;
16 |
17 | typedef enum {
18 | FALSE,
19 | TRUE
20 | } BOOL;
21 |
22 | #endif
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/Physical Memory Manager/kernel_physical_mm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Physical Memory Manager/kernel_physical_mm.png
--------------------------------------------------------------------------------
/NEW KERNEL/Physical Memory Manager/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Physical Memory Manager/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Physical Memory Manager/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Physical Memory Manager/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Physical Memory Manager/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Physical Memory Manager/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Physical Memory Manager/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/Physical Memory Manager/src/asm/load_idt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_idt
3 |
4 | load_idt:
5 | mov eax, [esp + 4]
6 | lidt [eax]
7 | ret
8 |
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/README.md:
--------------------------------------------------------------------------------
1 | ## Requirements :-
2 |
3 | (install following packages using apt-get)
4 | 1) GNU/Linux :- Any distribution
5 | 2) make :- make utility
6 | 3) Assembler :- NASM Assembler(nasm)
7 | 4) GCC :- GNU Compiler Collection, C compiler
8 | 5) xorriso :- A package that creates, loads, manipulates ISO 9660 filesystem images.(man xorriso)
9 | 6) grub-mkrescue :- utility to make ISO image
10 | 7) QEMU :- Quick EMUlator to boot our kernel
11 |
12 |
13 | ## Usage :-
14 |
15 | **Compile the source:**
16 | ```
17 | $ cd OS/NEW\ KERNEL/GDT
18 | $ make
19 | ```
20 |
21 | **Open created ISO in QEMU:**
22 | ```
23 | $ qemu-system-x86_64 out/GDT.iso
24 | ```
25 | or
26 | ```
27 | $ qemu-system-i386 out/GDT.iso
28 | ```
29 | **Clean the code:**
30 | ```
31 | $ cd OS/NEW\ KERNEL/GDT
32 | $ make clean
33 | ```
34 |
35 |
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "TSS" {
2 | multiboot /boot/TSS.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
7 |
8 | //initialize console
9 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
10 |
11 | void console_putchar(char ch);
12 |
13 | // revert back the printed character and add 0 to it
14 | void console_ungetchar();
15 | // revert back the printed character until n characters
16 | void console_ungetchar_bound(uint8 n);
17 |
18 | void console_gotoxy(uint16 x, uint16 y);
19 |
20 | void console_putstr(const char *str);
21 | void printf(const char *format, ...);
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/include/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | // symbols from linker.ld for section addresses
7 | extern uint8 __kernel_section_start;
8 | extern uint8 __kernel_section_end;
9 | extern uint8 __kernel_text_section_start;
10 | extern uint8 __kernel_text_section_end;
11 | extern uint8 __kernel_data_section_start;
12 | extern uint8 __kernel_data_section_end;
13 | extern uint8 __kernel_rodata_section_start;
14 | extern uint8 __kernel_rodata_section_end;
15 | extern uint8 __kernel_bss_section_start;
16 | extern uint8 __kernel_bss_section_end;
17 |
18 | #endif
19 |
20 |
21 |
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | void itoa(char *buf, int base, int d);
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/include/tss.h:
--------------------------------------------------------------------------------
1 | #ifndef TSS_H
2 | #define TSS_H
3 |
4 | #include "types.h"
5 |
6 | typedef struct {
7 | uint32 previous;
8 | uint32 esp0;
9 | uint32 ss0;
10 | uint32 esp1;
11 | uint32 ss1;
12 | uint32 esp2;
13 | uint32 ss2;
14 | uint32 cr3;
15 | uint32 eip;
16 | uint32 eflags;
17 | uint32 eax;
18 | uint32 ecx;
19 | uint32 edx;
20 | uint32 ebx;
21 | uint32 esp;
22 | uint32 ebp;
23 | uint32 esi;
24 | uint32 edi;
25 | uint32 es;
26 | uint32 cs;
27 | uint32 ss;
28 | uint32 ds;
29 | uint32 fs;
30 | uint32 gs;
31 | uint32 ldt;
32 | uint16 trap;
33 | uint16 iomap_base;
34 | } __attribute__((packed)) TSS;
35 |
36 | // asm tss functions
37 | extern void load_tss();
38 |
39 | void tss_init();
40 |
41 | void tss_set_stack(uint32 esp0);
42 |
43 | void tss_print();
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef uint8 byte;
13 | typedef uint16 word;
14 | typedef uint32 dword;
15 |
16 | #endif
17 |
18 |
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/TSS/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/TSS/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/TSS/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/src/asm/entry.asm:
--------------------------------------------------------------------------------
1 | ; constants for multiboot header
2 | MBALIGN equ 1<<0
3 | MEMINFO equ 1<<1
4 | FLAGS equ MBALIGN | MEMINFO
5 | MAGIC equ 0x1BADB002
6 | CHECKSUM equ -(MAGIC + FLAGS)
7 |
8 | ; set multiboot section
9 | section .multiboot
10 | align 4
11 | dd MAGIC
12 | dd FLAGS
13 | dd CHECKSUM
14 |
15 | section .data
16 | align 4096
17 |
18 | ; initial stack
19 | section .initial_stack, nobits
20 | align 4
21 |
22 | stack_bottom:
23 | ; 1 MB of uninitialized data for stack
24 | resb 104856
25 | stack_top:
26 |
27 | ; kernel entry, main text section
28 | section .text
29 | global _start
30 |
31 |
32 | ; define _start, aligned by linker.ld script
33 | _start:
34 | mov esp, stack_top
35 | extern kmain
36 | push ebx
37 | call kmain
38 | loop:
39 | jmp loop
40 |
41 |
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
25 |
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/src/asm/load_tss.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_tss
3 | global get_eip
4 |
5 | load_tss:
6 | mov ax, 0x2B
7 | ltr ax
8 | ret
9 |
10 | get_eip:
11 | pop eax
12 | jmp eax
13 |
14 |
--------------------------------------------------------------------------------
/NEW KERNEL/TSS/src/kernel.c:
--------------------------------------------------------------------------------
1 | #include "kernel.h"
2 | #include "console.h"
3 | #include "string.h"
4 | #include "gdt.h"
5 | #include "tss.h"
6 | #include "string.h"
7 |
8 | void kmain() {
9 | gdt_init();
10 | tss_init();
11 | console_init(COLOR_WHITE, COLOR_BLACK);
12 | tss_print();
13 | }
14 |
15 |
16 |
--------------------------------------------------------------------------------
/NEW KERNEL/Terminal/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "Terminal" {
2 | multiboot /boot/Terminal.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/Terminal/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | #define MAXIMUM_PAGES 16
7 |
8 | #define SCROLL_UP 1
9 | #define SCROLL_DOWN 2
10 |
11 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
12 |
13 | //initialize console
14 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
15 | void console_scroll(int line_count);
16 | void console_putchar(char ch);
17 | // revert back the printed character and add 0 to it
18 | void console_ungetchar();
19 | // revert back the printed character until n characters
20 | void console_ungetchar_bound(uint8 n);
21 |
22 | void console_gotoxy(uint16 x, uint16 y);
23 |
24 | void console_putstr(const char *str);
25 | void printf(const char *format, ...);
26 |
27 | // read string from console, but no backing
28 | void getstr(char *buffer);
29 |
30 | // read string from console, and erase or go back util bound occurs
31 | void getstr_bound(char *buffer, uint8 bound);
32 |
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/NEW KERNEL/Terminal/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/Terminal/include/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | // symbols from linker.ld for section addresses
7 | extern uint8 __kernel_section_start;
8 | extern uint8 __kernel_section_end;
9 | extern uint8 __kernel_text_section_start;
10 | extern uint8 __kernel_text_section_end;
11 | extern uint8 __kernel_data_section_start;
12 | extern uint8 __kernel_data_section_end;
13 | extern uint8 __kernel_rodata_section_start;
14 | extern uint8 __kernel_rodata_section_end;
15 | extern uint8 __kernel_bss_section_start;
16 | extern uint8 __kernel_bss_section_end;
17 |
18 | #endif
19 |
20 |
21 |
--------------------------------------------------------------------------------
/NEW KERNEL/Terminal/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 | int strncmp(const char *s1, const char *s2, int c);
16 |
17 | int strcpy(char *dst, const char *src);
18 |
19 | void strcat(char *dest, const char *src);
20 |
21 | int isspace(char c);
22 |
23 | int isalpha(char c);
24 | char upper(char c);
25 | char lower(char c);
26 |
27 | void itoa(char *buf, int base, int d);
28 |
29 | char *strstr(const char *in, const char *str);
30 |
31 | #endif
32 |
33 |
--------------------------------------------------------------------------------
/NEW KERNEL/Terminal/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef uint8 byte;
13 | typedef uint16 word;
14 | typedef uint32 dword;
15 |
16 | typedef enum {
17 | FALSE,
18 | TRUE
19 | } BOOL;
20 |
21 | #endif
22 |
23 |
--------------------------------------------------------------------------------
/NEW KERNEL/Terminal/kernel_terminal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Terminal/kernel_terminal.png
--------------------------------------------------------------------------------
/NEW KERNEL/Terminal/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Terminal/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Terminal/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Terminal/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Terminal/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Terminal/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Terminal/src/asm/entry.asm:
--------------------------------------------------------------------------------
1 | ; constants for multiboot header
2 | MBALIGN equ 1<<0
3 | MEMINFO equ 1<<1
4 | FLAGS equ MBALIGN | MEMINFO
5 | MAGIC equ 0x1BADB002
6 | CHECKSUM equ -(MAGIC + FLAGS)
7 |
8 | ; set multiboot section
9 | section .multiboot
10 | align 4
11 | dd MAGIC
12 | dd FLAGS
13 | dd CHECKSUM
14 |
15 | section .data
16 | align 4096
17 |
18 | ; initial stack
19 | section .initial_stack, nobits
20 | align 4
21 |
22 | stack_bottom:
23 | ; 1 MB of uninitialized data for stack
24 | resb 104856
25 | stack_top:
26 |
27 | ; kernel entry, main text section
28 | section .text
29 | global _start
30 |
31 |
32 | ; define _start, aligned by linker.ld script
33 | _start:
34 | mov esp, stack_top
35 | extern kmain
36 | push ebx
37 | call kmain
38 | loop:
39 | jmp loop
40 |
--------------------------------------------------------------------------------
/NEW KERNEL/Terminal/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/Terminal/src/asm/load_idt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_idt
3 |
4 | load_idt:
5 | mov eax, [esp + 4]
6 | lidt [eax]
7 | ret
8 |
--------------------------------------------------------------------------------
/NEW KERNEL/Timer/README.md:
--------------------------------------------------------------------------------
1 | ## Usage :-
2 |
3 | **Compile the source:**
4 | ```
5 | $ cd OS/NEW\ KERNEL/Timer
6 | $ make
7 | ```
8 |
9 | **Open created ISO in QEMU:**
10 | ```
11 | $ qemu-system-x86_64 out/Timer.iso
12 | ```
13 | or
14 | ```
15 | $ qemu-system-i386 out/Timer.iso
16 | ```
17 | **Clean the code:**
18 | ```
19 | $ cd OS/NEW\ KERNEL/Timer
20 | $ make clean
21 | ```
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/NEW KERNEL/Timer/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "Timer" {
2 | multiboot /boot/Timer.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/Timer/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
7 |
8 | //initialize console
9 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
10 |
11 | void console_putchar(char ch);
12 | // revert back the printed character and add 0 to it
13 | void console_ungetchar();
14 | // revert back the printed character until n characters
15 | void console_ungetchar_bound(uint8 n);
16 |
17 | void console_gotoxy(uint16 x, uint16 y);
18 |
19 | void console_putstr(const char *str);
20 | void printf(const char *format, ...);
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------
/NEW KERNEL/Timer/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/Timer/include/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | // symbols from linker.ld for section addresses
7 | extern uint8 __kernel_section_start;
8 | extern uint8 __kernel_section_end;
9 | extern uint8 __kernel_text_section_start;
10 | extern uint8 __kernel_text_section_end;
11 | extern uint8 __kernel_data_section_start;
12 | extern uint8 __kernel_data_section_end;
13 | extern uint8 __kernel_rodata_section_start;
14 | extern uint8 __kernel_rodata_section_end;
15 | extern uint8 __kernel_bss_section_start;
16 | extern uint8 __kernel_bss_section_end;
17 |
18 | #endif
19 |
20 |
21 |
--------------------------------------------------------------------------------
/NEW KERNEL/Timer/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | int isalpha(char c);
23 | char upper(char c);
24 | char lower(char c);
25 |
26 | void itoa(char *buf, int base, int d);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/Timer/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef uint8 byte;
13 | typedef uint16 word;
14 | typedef uint32 dword;
15 |
16 | typedef enum {
17 | FALSE,
18 | TRUE
19 | } BOOL;
20 |
21 | #endif
22 |
23 |
--------------------------------------------------------------------------------
/NEW KERNEL/Timer/kernel_timer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Timer/kernel_timer.png
--------------------------------------------------------------------------------
/NEW KERNEL/Timer/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Timer/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Timer/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Timer/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Timer/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/Timer/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/Timer/src/asm/entry.asm:
--------------------------------------------------------------------------------
1 | ; constants for multiboot header
2 | MBALIGN equ 1<<0
3 | MEMINFO equ 1<<1
4 | FLAGS equ MBALIGN | MEMINFO
5 | MAGIC equ 0x1BADB002
6 | CHECKSUM equ -(MAGIC + FLAGS)
7 |
8 | ; set multiboot section
9 | section .multiboot
10 | align 4
11 | dd MAGIC
12 | dd FLAGS
13 | dd CHECKSUM
14 |
15 | section .data
16 | align 4096
17 |
18 | ; initial stack
19 | section .initial_stack, nobits
20 | align 4
21 |
22 | stack_bottom:
23 | ; 1 MB of uninitialized data for stack
24 | resb 104856
25 | stack_top:
26 |
27 | ; kernel entry, main text section
28 | section .text
29 | global _start
30 |
31 |
32 | ; define _start, aligned by linker.ld script
33 | _start:
34 | mov esp, stack_top
35 | extern kmain
36 | push ebx
37 | call kmain
38 | loop:
39 | jmp loop
40 |
--------------------------------------------------------------------------------
/NEW KERNEL/Timer/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/Timer/src/asm/load_idt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_idt
3 |
4 | load_idt:
5 | mov eax, [esp + 4]
6 | lidt [eax]
7 | ret
8 |
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "VESA VBE 2.0" {
2 | multiboot /boot/VESA_VBE20.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/include/bios32.h:
--------------------------------------------------------------------------------
1 | #ifndef BIOS32_H
2 | #define BIOS32_H
3 |
4 | #include "types.h"
5 | #include "isr.h"
6 |
7 | // defined in bios32_call.asm
8 | extern void BIOS32_START();
9 | extern void BIOS32_END();
10 | extern void *bios32_gdt_ptr;
11 | extern void *bios32_gdt_entries;
12 | extern void *bios32_idt_ptr;
13 | extern void *bios32_in_reg16_ptr;
14 | extern void *bios32_out_reg16_ptr;
15 | extern void *bios32_int_number_ptr;
16 |
17 | #define REBASE_ADDRESS(x) (void*)(0x7c00 + (void*)x - (uint32)BIOS32_START)
18 |
19 | #define BIOS_CONVENTIONAL_MEMORY 0x7E00
20 |
21 |
22 | // https://en.wikipedia.org/wiki/BIOS_interrupt_call
23 |
24 | void bios32_init();
25 | // bios interrupt call
26 | void int86(uint8 interrupt, REGISTERS16 *in, REGISTERS16 *out);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | #define MAXIMUM_PAGES 16
7 |
8 | #define SCROLL_UP 1
9 | #define SCROLL_DOWN 2
10 |
11 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
12 |
13 | //initialize console
14 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
15 | void console_scroll(int line_count);
16 | void console_putchar(char ch);
17 | // revert back the printed character and add 0 to it
18 | void console_ungetchar();
19 | // revert back the printed character until n characters
20 | void console_ungetchar_bound(uint8 n);
21 |
22 | void console_gotoxy(uint16 x, uint16 y);
23 |
24 | void console_putstr(const char *str);
25 | void printf(const char *format, ...);
26 |
27 | // read string from console, but no backing
28 | void getstr(char *buffer);
29 |
30 | // read string from console, and erase or go back util bound occurs
31 | void getstr_bound(char *buffer, uint8 bound);
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | int isalpha(char c);
23 | char upper(char c);
24 | char lower(char c);
25 |
26 | void itoa(char *buf, int base, int d);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef unsigned long long uint64;
13 | typedef uint8 byte;
14 | typedef uint16 word;
15 | typedef uint32 dword;
16 |
17 | typedef enum {
18 | FALSE,
19 | TRUE
20 | } BOOL;
21 |
22 | #endif
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/kernel_vbe_graphics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/VESA VBE/kernel_vbe_graphics.png
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/kernel_vbe_mode_info_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/VESA VBE/kernel_vbe_mode_info_1.png
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/kernel_vbe_mode_info_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/VESA VBE/kernel_vbe_mode_info_2.png
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/kernel_vbe_mode_info_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/VESA VBE/kernel_vbe_mode_info_3.png
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/kernel_vbe_mode_info_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/VESA VBE/kernel_vbe_mode_info_4.png
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/VESA VBE/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/VESA VBE/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/VESA VBE/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/ref/vbe20.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/VESA VBE/ref/vbe20.pdf
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/ref/vbe3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/VESA VBE/ref/vbe3.pdf
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/src/asm/load_gdt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_gdt
3 |
4 | load_gdt:
5 | mov eax, [esp + 4] ; get gdt pointer
6 | lgdt [eax] ; load gdt
7 |
8 | mov ax, 0x10 ; kernel data segment
9 | mov ds, ax
10 | mov es, ax
11 | mov fs, ax
12 | mov gs, ax
13 | mov ss, ax
14 |
15 | cli ; clear interrupts
16 | mov eax, cr0 ; set bit 0 in cr0 to enter protected mode
17 | or eax, 1
18 | mov cr0, eax
19 |
20 | jmp 0x08:far_jump ; jump to far with code data segment
21 | far_jump:
22 | ret
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/VESA VBE/src/asm/load_idt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_idt
3 |
4 | load_idt:
5 | mov eax, [esp + 4]
6 | lidt [eax]
7 | ret
8 |
--------------------------------------------------------------------------------
/NEW KERNEL/VGA/README.md:
--------------------------------------------------------------------------------
1 | ## Requirements :-
2 |
3 | (install following packages using apt-get)
4 | 1) GNU/Linux :- Any distribution
5 | 2) make :- make utility
6 | 3) Assembler :- NASM Assembler(nasm)
7 | 4) GCC :- GNU Compiler Collection, C compiler
8 | 5) xorriso :- A package that creates, loads, manipulates ISO 9660 filesystem images.(man xorriso)
9 | 6) grub-mkrescue :- utility to make ISO image
10 | 7) QEMU :- Quick EMUlator to boot our kernel
11 |
12 |
13 | ## Usage :-
14 |
15 | **Compile the source:**
16 | ```
17 | $ cd OS/NEW\ KERNEL/VGA
18 | $ make
19 | ```
20 |
21 | **Open created ISO in QEMU:**
22 | ```
23 | $ qemu-system-x86_64 out/VGA.iso
24 | ```
25 | or
26 | ```
27 | $ qemu-system-i386 out/VGA.iso
28 | ```
29 | **Clean the code:**
30 | ```
31 | $ cd OS/NEW\ KERNEL/VGA
32 | $ make clean
33 | ```
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/NEW KERNEL/VGA/config/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "VGA" {
2 | multiboot /boot/VGA.bin
3 | }
4 |
--------------------------------------------------------------------------------
/NEW KERNEL/VGA/include/bitmap.h:
--------------------------------------------------------------------------------
1 | #ifndef BITMAP_H
2 | #define BITMAP_H
3 |
4 | #include "types.h"
5 |
6 | #define BITMAP_SIZE 8
7 |
8 | void draw_char(uint16 x, uint16 y, uint8 color, char ch);
9 | void draw_string(uint16 x, uint16 y, uint8 color, char *str);
10 |
11 | #endif
12 |
--------------------------------------------------------------------------------
/NEW KERNEL/VGA/include/console.h:
--------------------------------------------------------------------------------
1 | #ifndef CONSOLE_H
2 | #define CONSOLE_H
3 |
4 | #include "vga.h"
5 |
6 | void console_clear(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
7 |
8 | //initialize console
9 | void console_init(VGA_COLOR_TYPE fore_color, VGA_COLOR_TYPE back_color);
10 |
11 | void console_putchar(char ch);
12 | // revert back the printed character and add 0 to it
13 | void console_ungetchar();
14 | // revert back the printed character until n characters
15 | void console_ungetchar_bound(uint8 n);
16 |
17 | void console_gotoxy(uint16 x, uint16 y);
18 |
19 | void console_putstr(const char *str);
20 | void printf(const char *format, ...);
21 |
22 | // read string from console, but no backing
23 | void getstr(char *buffer);
24 |
25 | // read string from console, and erase or go back util bound occurs
26 | void getstr_bound(char *buffer, uint8 bound);
27 |
28 | #endif
--------------------------------------------------------------------------------
/NEW KERNEL/VGA/include/io_ports.h:
--------------------------------------------------------------------------------
1 | #ifndef IO_PORTS_H
2 | #define IO_PORTS_H
3 |
4 | #include "types.h"
5 |
6 | /**
7 | * read a byte from given port number
8 | */
9 | uint8 inportb(uint16 port);
10 |
11 | /**
12 | * write a given byte to given port number
13 | */
14 | void outportb(uint16 port, uint8 val);
15 |
16 | /**
17 | * read 2 bytes(short) from given port number
18 | */
19 | uint16 inports(uint16 port);
20 |
21 | /**
22 | * write given 2(short) bytes to given port number
23 | */
24 | void outports(uint16 port, uint16 data);
25 |
26 | /**
27 | * read 4 bytes(long) from given port number
28 | */
29 | uint32 inportl(uint16 port);
30 |
31 | /**
32 | * write given 4 bytes(long) to given port number
33 | */
34 | void outportl(uint16 port, uint32 data);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/NEW KERNEL/VGA/include/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | // symbols from linker.ld for section addresses
7 | extern uint8 __kernel_section_start;
8 | extern uint8 __kernel_section_end;
9 | extern uint8 __kernel_text_section_start;
10 | extern uint8 __kernel_text_section_end;
11 | extern uint8 __kernel_data_section_start;
12 | extern uint8 __kernel_data_section_end;
13 | extern uint8 __kernel_rodata_section_start;
14 | extern uint8 __kernel_rodata_section_end;
15 | extern uint8 __kernel_bss_section_start;
16 | extern uint8 __kernel_bss_section_end;
17 |
18 |
19 | #endif
20 |
21 |
22 |
--------------------------------------------------------------------------------
/NEW KERNEL/VGA/include/string.h:
--------------------------------------------------------------------------------
1 | #ifndef STRING_H
2 | #define STRING_H
3 |
4 | #include "types.h"
5 |
6 | void *memset(void *dst, char c, uint32 n);
7 |
8 | void *memcpy(void *dst, const void *src, uint32 n);
9 |
10 | int memcmp(uint8 *s1, uint8 *s2, uint32 n);
11 |
12 | int strlen(const char *s);
13 |
14 | int strcmp(const char *s1, char *s2);
15 |
16 | int strcpy(char *dst, const char *src);
17 |
18 | void strcat(char *dest, const char *src);
19 |
20 | int isspace(char c);
21 |
22 | int isalpha(char c);
23 | char upper(char c);
24 | char lower(char c);
25 |
26 | void itoa(char *buf, int base, int d);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/NEW KERNEL/VGA/include/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | #define NULL 0
5 |
6 | typedef unsigned char uint8;
7 | typedef unsigned short uint16;
8 | typedef unsigned int uint32;
9 | typedef signed char sint8;
10 | typedef signed short sint16;
11 | typedef signed int sint32;
12 | typedef unsigned long long uint64;
13 | typedef uint8 byte;
14 | typedef uint16 word;
15 | typedef uint32 dword;
16 |
17 | typedef enum {
18 | FALSE,
19 | TRUE
20 | } BOOL;
21 |
22 | #endif
23 |
24 |
--------------------------------------------------------------------------------
/NEW KERNEL/VGA/kernel_vga.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/VGA/kernel_vga.png
--------------------------------------------------------------------------------
/NEW KERNEL/VGA/obj/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/VGA/obj/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/VGA/obj/asm/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/VGA/obj/asm/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/VGA/out/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/NEW KERNEL/VGA/out/.gitkeep
--------------------------------------------------------------------------------
/NEW KERNEL/VGA/src/asm/load_idt.asm:
--------------------------------------------------------------------------------
1 | section .text
2 | global load_idt
3 |
4 | load_idt:
5 | mov eax, [esp + 4]
6 | lidt [eax]
7 | ret
8 |
--------------------------------------------------------------------------------
/NEW KERNEL/VGA/src/kernel.c:
--------------------------------------------------------------------------------
1 | #include "kernel.h"
2 | #include "string.h"
3 | #include "gdt.h"
4 | #include "idt.h"
5 | #include "vga.h"
6 | #include "console.h"
7 | #include "mouse.h"
8 | #include "keyboard.h"
9 | #include "bitmap.h"
10 |
11 | void kmain() {
12 | gdt_init();
13 | idt_init();
14 | console_init(WHITE, BLACK);
15 | keyboard_init();
16 | mouse_init();
17 | vga_graphics_init();
18 | vga_graphics_clear_color(WHITE);
19 | vga_graphics_draw_rect(10, 10, 10, 10, GREEN);
20 |
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/Pong-Game/game_screenshots/Pong_Game_Intro.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Pong-Game/game_screenshots/Pong_Game_Intro.png
--------------------------------------------------------------------------------
/Pong-Game/game_screenshots/Pong_Game_Lose.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Pong-Game/game_screenshots/Pong_Game_Lose.png
--------------------------------------------------------------------------------
/Pong-Game/game_screenshots/Pong_Game_Play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Pong-Game/game_screenshots/Pong_Game_Play.png
--------------------------------------------------------------------------------
/Pong-Game/iso/Pong_Game.iso:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Pong-Game/iso/Pong_Game.iso
--------------------------------------------------------------------------------
/Pong-Game/src/README.md:
--------------------------------------------------------------------------------
1 |
2 | Pong Game
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Pong-Game/src/bitmap.h:
--------------------------------------------------------------------------------
1 | #ifndef BITMAP_H
2 | #define BITMAP_H
3 |
4 | #include "types.h"
5 |
6 | #define BITMAP_SIZE 8
7 |
8 | void draw_char(uint16 x, uint16 y, uint8 color, char ch);
9 | void draw_string(uint16 x, uint16 y, uint8 color, char *str);
10 |
11 | #endif
12 |
--------------------------------------------------------------------------------
/Pong-Game/src/clean.sh:
--------------------------------------------------------------------------------
1 | # shell file to clean compiled code
2 |
3 | # remove all .o object files
4 | rm *.o
5 |
6 | # remove isodir
7 | rm -r isodir
8 |
9 | # remove Pong_Game.bin
10 | rm Pong_Game.bin
11 |
12 | # remove Pong_Game.iso
13 | rm Pong_Game.iso
--------------------------------------------------------------------------------
/Pong-Game/src/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "Pong Game" {
2 | multiboot /boot/Pong_Game.bin
3 | }
4 |
--------------------------------------------------------------------------------
/Pong-Game/src/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | #define NULL 0
7 |
8 | uint8 inb(uint16 port);
9 | void outb(uint16 port, uint8 data);
10 | uint8 get_input_keycode();
11 | void wait_for_io(uint32 timer_count);
12 | void sleep(uint32 timer_count);
13 |
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/Pong-Game/src/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | typedef unsigned char uint8;
5 | typedef unsigned short uint16;
6 | typedef unsigned int uint32;
7 |
8 | #endif
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Pong-Game/src/utils.c:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | uint32 strlen(const char* str)
4 | {
5 | uint32 length = 0;
6 | while(str[length])
7 | length++;
8 | return length;
9 | }
10 |
11 | uint32 digit_count(int num)
12 | {
13 | uint32 count = 0;
14 | if(num == 0)
15 | return 1;
16 | while(num > 0){
17 | count++;
18 | num = num/10;
19 | }
20 | return count;
21 | }
22 |
23 | void itoa(int num, char *number)
24 | {
25 | int dgcount = digit_count(num);
26 | int index = dgcount - 1;
27 | char x;
28 | if(num == 0 && dgcount == 1){
29 | number[0] = '0';
30 | number[1] = '\0';
31 | }else{
32 | while(num != 0){
33 | x = num % 10;
34 | number[index] = x + '0';
35 | index--;
36 | num = num / 10;
37 | }
38 | number[dgcount] = '\0';
39 | }
40 | }
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/Pong-Game/src/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef UTILS_H
2 | #define UTILS_H
3 |
4 | #include "types.h"
5 |
6 | #define TRUE 1
7 | #define FALSE 0
8 |
9 | extern uint32 strlen(const char*);
10 | extern uint32 digit_count(int);
11 | extern void itoa(int, char *);
12 |
13 | #endif
14 |
15 |
--------------------------------------------------------------------------------
/Tic-Tac-Toe/README.md:
--------------------------------------------------------------------------------
1 | https://github.com/pritamzope/OS/tree/master/GUI/box
2 |
3 | https://github.com/pritamzope/OS/tree/master/Kernel/Keyboard
4 |
5 |
6 | How to Play :
7 |
8 | Use arrow keys(UP,DOWN,LEFT,RIGHT) to move white box between cells and press SPACEBAR to select that cell.
9 |
10 | RED color for player 1 Box and BLUE color for player 2 box.
11 |
12 | See Turn for which player has a turn to select cell.
13 |
14 |
15 | [ If you are running this on actual hardware then increase the value of sleep() function in launch_game() in tic_tac_toe.c and in kernel_entry() in kernel.c So that will work normally and not too fast.
16 | I used 0x2FFFFFFF. ]
17 |
18 |
19 |
20 | Tic-Tac-Toe Game
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Tic-Tac-Toe/iso/TicTacToe.iso:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Tic-Tac-Toe/iso/TicTacToe.iso
--------------------------------------------------------------------------------
/Tic-Tac-Toe/src/box.h:
--------------------------------------------------------------------------------
1 | #ifndef BOX_H
2 | #define BOX_H
3 |
4 | #include "types.h"
5 |
6 |
7 | #define BOX_MAX_WIDTH 78
8 | #define BOX_MAX_HEIGHT 23
9 |
10 | #define BOX_SINGLELINE 1
11 | #define BOX_DOUBLELINE 2
12 |
13 |
14 | extern void draw_generic_box(uint16, uint16, uint16, uint16,
15 | uint8, uint8, uint8, uint8,
16 | uint8, uint8, uint8, uint8);
17 |
18 | extern void draw_box(uint8, uint16, uint16, uint16, uint16,
19 | uint8, uint8);
20 |
21 | extern void fill_box(uint8, uint16, uint16, uint16, uint16, uint8);
22 |
23 |
24 | #endif
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Tic-Tac-Toe/src/clean.sh:
--------------------------------------------------------------------------------
1 | # shell file to clean compiled code
2 |
3 | # remove all .o object files
4 | rm *.o
5 |
6 | # remove isodir
7 | rm -r isodir
8 |
9 | # remove TicTacToe.bin
10 | rm TicTacToe.bin
11 |
12 | # remove TicTacToe.iso
13 | rm TicTacToe.iso
--------------------------------------------------------------------------------
/Tic-Tac-Toe/src/grub.cfg:
--------------------------------------------------------------------------------
1 | menuentry "TicTacToe" {
2 | multiboot /boot/TicTacToe.bin
3 | }
4 |
--------------------------------------------------------------------------------
/Tic-Tac-Toe/src/kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef KERNEL_H
2 | #define KERNEL_H
3 |
4 | #include "types.h"
5 |
6 | #define NULL 0
7 |
8 | #define VGA_ADDRESS 0xB8000
9 | #define BUFSIZE 2200
10 |
11 | uint16* vga_buffer;
12 | extern uint32 vga_index;
13 |
14 | enum vga_color {
15 | BLACK,
16 | BLUE,
17 | GREEN,
18 | CYAN,
19 | RED,
20 | MAGENTA,
21 | BROWN,
22 | GREY,
23 | DARK_GREY,
24 | BRIGHT_BLUE,
25 | BRIGHT_GREEN,
26 | BRIGHT_CYAN,
27 | BRIGHT_RED,
28 | BRIGHT_MAGENTA,
29 | YELLOW,
30 | WHITE,
31 | };
32 |
33 | extern void clear_screen(uint8, uint8);
34 | extern void print_new_line();
35 | extern void print_char(char);
36 | extern void print_string(char *);
37 | extern void print_color_string(char *, uint8, uint8);
38 | extern void print_int(int);
39 | extern uint8 inb(uint16);
40 | extern void outb(uint16, uint8);
41 | extern byte get_input_keycode();
42 | extern void sleep(uint32);
43 | extern void gotoxy(uint16, uint16);
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/Tic-Tac-Toe/src/run.sh:
--------------------------------------------------------------------------------
1 | # Shell file to compile code
2 |
3 | # assemble boot.s file
4 | as --32 boot.s -o boot.o
5 |
6 | # compile kernel.c file
7 | gcc -m32 -c kernel.c -o kernel.o -std=gnu99 -ffreestanding -O1 -Wall -Wextra
8 |
9 | gcc -m32 -c utils.c -o utils.o -std=gnu99 -ffreestanding -O1 -Wall -Wextra
10 |
11 | gcc -m32 -c box.c -o box.o -std=gnu99 -ffreestanding -O1 -Wall -Wextra
12 |
13 | gcc -m32 -c tic_tac_toe.c -o tic_tac_toe.o -std=gnu99 -ffreestanding -O1 -Wall -Wextra
14 |
15 | # linking all the object files to TicTacToe.bin
16 | ld -m elf_i386 -T linker.ld boot.o kernel.o utils.o box.o tic_tac_toe.o -o TicTacToe.bin -nostdlib
17 |
18 | # check TicTacToe.bin file is x86 multiboot file or not
19 | grub-file --is-x86-multiboot TicTacToe.bin
20 |
21 | # building the iso file
22 | mkdir -p isodir/boot/grub
23 | cp TicTacToe.bin isodir/boot/TicTacToe.bin
24 | cp grub.cfg isodir/boot/grub/grub.cfg
25 | grub-mkrescue -o TicTacToe.iso isodir
26 |
27 | # run it in qemu
28 | qemu-system-x86_64 -cdrom TicTacToe.iso
29 |
--------------------------------------------------------------------------------
/Tic-Tac-Toe/src/tic_tac_toe.h:
--------------------------------------------------------------------------------
1 | #ifndef TIC_TAC_TOE_H
2 | #define TIC_TAC_TOE_H
3 |
4 | extern void launch_game();
5 |
6 |
7 | #endif
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Tic-Tac-Toe/src/types.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_H
2 | #define TYPES_H
3 |
4 | typedef unsigned char uint8;
5 | typedef unsigned short uint16;
6 | typedef unsigned int uint32;
7 | typedef char byte;
8 | typedef int bool;
9 |
10 | #endif
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Tic-Tac-Toe/src/utils.c:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | uint32 strlen(const char* str)
4 | {
5 | uint32 length = 0;
6 | while(str[length])
7 | length++;
8 | return length;
9 | }
10 |
11 | uint32 digit_count(int num)
12 | {
13 | uint32 count = 0;
14 | if(num == 0)
15 | return 1;
16 | while(num > 0){
17 | count++;
18 | num = num/10;
19 | }
20 | return count;
21 | }
22 |
23 | void itoa(int num, char *number)
24 | {
25 | int dgcount = digit_count(num);
26 | int index = dgcount - 1;
27 | char x;
28 | if(num == 0 && dgcount == 1){
29 | number[0] = '0';
30 | number[1] = '\0';
31 | }else{
32 | while(num != 0){
33 | x = num % 10;
34 | number[index] = x + '0';
35 | index--;
36 | num = num / 10;
37 | }
38 | number[dgcount] = '\0';
39 | }
40 | }
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/Tic-Tac-Toe/src/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef UTILS_H
2 | #define UTILS_H
3 |
4 | #include "types.h"
5 |
6 | #define TRUE 1
7 | #define FALSE 0
8 |
9 | extern uint32 strlen(const char*);
10 | extern uint32 digit_count(int);
11 | extern void itoa(int, char *);
12 |
13 | #endif
14 |
15 |
--------------------------------------------------------------------------------
/Tic-Tac-Toe/tic_tac_toe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pritamzope/OS/772a0f40924f4a156a05e83f0c778bfeacee968f/Tic-Tac-Toe/tic_tac_toe.png
--------------------------------------------------------------------------------
/VGA/README.md:
--------------------------------------------------------------------------------
1 |