-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New initial commit with new repository
- Loading branch information
0 parents
commit fb42165
Showing
37 changed files
with
2,218 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.o | ||
*.bin | ||
*.img | ||
src/output/* | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2022-2024 Erdem Ersoy (eersoy93) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# E93 | ||
|
||
Erdem Ersoy's (eersoy93's) monolithic operating system for PCs. | ||
|
||
## Building and Running | ||
|
||
In [Pardus 23](https://www.pardus.org.tr/), clone this repository. After that, install GCC x86 cross compiler, NASM and QEMU: | ||
|
||
`sudo apt install nasm qemu-system-x86 gcc-i686-linux-gnu` | ||
|
||
After that, move to the src directory: | ||
|
||
`cd src` | ||
|
||
After that, build the OS: | ||
|
||
`make` | ||
|
||
After building, you can run: | ||
|
||
`make run` | ||
|
||
## TODO | ||
|
||
- [X] Finish studying [os-tutorial](https://github.com/cfenollosa/os-tutorial). | ||
|
||
## References | ||
|
||
- [https://github.com/cfenollosa/os-tutorial](https://github.com/cfenollosa/os-tutorial) | ||
- [https://wiki.osdev.org/PC_Speaker](https://wiki.osdev.org/PC_Speaker) | ||
- [https://www.felixcloutier.com/x86/index.html](https://www.felixcloutier.com/x86/index.html) | ||
- [https://www.fountainware.com/EXPL/vga_color_palettes.htm](https://www.fountainware.com/EXPL/vga_color_palettes.htm) | ||
- [https://en.wikipedia.org/wiki/VGA_text_mode](https://en.wikipedia.org/wiki/VGA_text_mode) | ||
- [https://www.rapidtables.com/code/text/ascii-table.html](https://www.rapidtables.com/code/text/ascii-table.html) | ||
- [Pardus's Calculator :)](https://apps.pardus.org.tr/app/gnome-calculator) | ||
|
||
## Copyright and License | ||
|
||
Copyright (c) 2022-2024 Erdem Ersoy (eersoy93). | ||
|
||
Licensed with MIT License. See LICENSE file for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# DESCRIPTION: E93 Makefile | ||
# AUTHOR: Erdem Ersoy (eersoy93) | ||
# COPYRIGHT: Copyright (c) 2022-2024 Erdem Ersoy (eersoy93). | ||
# LICENSE: Licensed with MIT License. See LICENSE file for details. | ||
|
||
C_SOURCES = $(wildcard kernel/*.c drivers/*.c cpu/*.c libc/*.c) | ||
C_HEADERS = $(wildcard kernel/*.h drivers/*.h cpu/*.h libc/*.h) | ||
|
||
OBJ = ${C_SOURCES:.c=.o cpu/interrupts.o} | ||
|
||
CC = /usr/bin/i686-linux-gnu-gcc | ||
CFLAGS = -g -m32 -ffreestanding -fno-PIC -fno-stack-protector -nostartfiles -nodefaultlibs \ | ||
-Wall -Wextra -Werror | ||
|
||
e93-os.img: loader/loader.bin kernel.bin | ||
cat $^ > e93-os.bin | ||
dd if=/dev/zero bs=512 count=2880 >> $@ | ||
dd if=e93-os.bin of=$@ conv=notrunc | ||
|
||
kernel.bin: loader/kernel_entry.o ${OBJ} | ||
i686-linux-gnu-ld -no-pie -o $@ -Ttext 0x1000 $^ --oformat binary --allow-multiple-definition | ||
|
||
run: e93-os.img | ||
qemu-system-i386 -fda $< -audiodev alsa,id=default -machine pcspk-audiodev=default | ||
|
||
%.o: %.c ${C_HEADERS} | ||
${CC} ${CFLAGS} -ffreestanding -c $< -o $@ | ||
|
||
%.o: %.asm | ||
nasm $< -f elf -o $@ | ||
|
||
%.bin: %.asm | ||
nasm $< -f bin -o $@ | ||
|
||
clean: | ||
rm -f *.bin *.img *.o loader/*.bin kernel/*.o loader/*.o drivers/*.o cpu/*.o libc/*.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* DESCRIPTION: E93 Interrupt Descriptor Table Code File | ||
* AUTHOR: Erdem Ersoy (eersoy93) | ||
* COPYRIGHT: Copyright (c) 2022-2024 Erdem Ersoy (eersoy93). | ||
* LICENSE: Licensed with MIT License. See LICENSE file for details. | ||
*/ | ||
|
||
#include "idt.h" | ||
|
||
void set_idt_gate(int n, uint32_t handler) | ||
{ | ||
idt[n].offset_handler_function_address_low = low16(handler); | ||
idt[n].kernel_segment_selector = KERNEL_CS; | ||
idt[n].always_zero = (uint8_t) 0; | ||
idt[n].flags = 0x8E; // 1000 1110 | ||
idt[n].offset_handler_function_address_high = high16(handler); | ||
} | ||
|
||
void set_idt(void) | ||
{ | ||
idt_register.base = (uint32_t) &idt; | ||
idt_register.limit = sizeof(idt_gate_type) * IDT_ENTRIES_COUNT - 1; | ||
asm volatile("lidtl (%0)" : : "r" (&idt_register)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* DESCRIPTION: E93 Interrupt Descriptor Table Header File | ||
* AUTHOR: Erdem Ersoy (eersoy93) | ||
* COPYRIGHT: Copyright (c) 2022-2024 Erdem Ersoy (eersoy93). | ||
* LICENSE: Licensed with MIT License. See LICENSE file for details. | ||
*/ | ||
|
||
#ifndef IDT_H | ||
#define IDT_H | ||
|
||
#include "../cpu/types.h" | ||
|
||
#include <stdint.h> | ||
|
||
// Segment selectors | ||
#define KERNEL_CS (uint16_t)0x08 | ||
|
||
// Interrupt gate handler struct | ||
typedef struct | ||
{ | ||
uint16_t offset_handler_function_address_low; | ||
uint16_t kernel_segment_selector; | ||
uint8_t always_zero; | ||
|
||
/* 7: Interrupt is present | ||
* 6-5: CPU privilege level of the caller | ||
* 4: Zero for interrupt gates | ||
* 3-0: 32-bit interrupt gate */ | ||
uint8_t flags; | ||
uint16_t offset_handler_function_address_high; | ||
} __attribute__((packed)) idt_gate_type; | ||
|
||
// Interrupt handlers array pointer | ||
typedef struct | ||
{ | ||
uint16_t limit; | ||
uint32_t base; | ||
} __attribute__((packed)) idt_register_type; | ||
|
||
#define IDT_ENTRIES_COUNT 256 | ||
idt_gate_type idt[IDT_ENTRIES_COUNT]; | ||
idt_register_type idt_register; | ||
|
||
// IDT Functions | ||
void set_idt_gate(int n, uint32_t handler); | ||
void set_idt(void); | ||
|
||
#endif |
Oops, something went wrong.