Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
You can visit The Video tutorial Linked to this archive at https://www.youtube.com/watch?v=CGkmfBHEODE
This Archive has been uploaded by Nidhal Abidi From IKOW
Please visit Iknow @ www.youtube.com/iknowbrain
or at:
www.iknowbrain.work
Thank you for your support :)
سلام

سامانه عامل از ابتدا، سامانه ای آزمایشی و آموزشی است که نوشتن سامانه عامل از ابتدا را به شما می آموزد.

شما می توانید راهنمای ویدیویی این سامانه عامل را از نشانی زیر مشاهده کنید
http://www.aparat.ir/v/mtKEP

You can visit The Video tutorial Linked to this archive at http://www.aparat.ir/v/mtKEP


4 changes: 1 addition & 3 deletions include/idt.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ typedef struct {
uint32 base;
} __attribute__((packed)) idt_register_t;

#define IDT_ENTRIES 256
idt_gate_t idt[IDT_ENTRIES];
idt_register_t idt_reg;



/* Functions implemented in idt.c */
Expand Down
2 changes: 1 addition & 1 deletion include/isr.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void isr30();
void isr31();


string exception_messages[32];
//string exception_messages[32];

void isr_install();

Expand Down
4 changes: 2 additions & 2 deletions include/screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define SCREEN_H
#include "system.h"
#include "string.h"
int cursorX , cursorY;
const uint8 sw ,sh ,sd ;
//int cursorX , cursorY;
//const uint8 sw ,sh ,sd ;
//We define the screen width, height, and depth.
void clearLine(uint8 from,uint8 to);

Expand Down
28 changes: 15 additions & 13 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ EMULATOR = qemu-system-i386
EMULATOR_FLAGS = -kernel

OBJS = obj/kasm.o obj/kc.o obj/idt.o obj/isr.o obj/kb.o obj/screen.o obj/string.o obj/system.o obj/util.o obj/shell.o
OUTPUT = iknow/boot/kernel.bin
OUTPUT = OSFS/boot/kernel.bin

run: all
$(EMULATOR) $(EMULATOR_FLAGS) $(OUTPUT)

all:$(OBJS)
mkdir iknow/ -p
mkdir iknow/boot/ -p
mkdir OSFS/ -p
mkdir OSFS/boot/ -p
$(LINKER) $(LDFLAGS) -o $(OUTPUT) $(OBJS)

obj/kasm.o:src/kernel.asm
mkdir obj/ -p
$(ASSEMBLER) $(ASFLAGS) -o obj/kasm.o src/kernel.asm

obj/kc.o:src/kernel.c
Expand Down Expand Up @@ -51,18 +52,19 @@ obj/shell.o:src/shell.c
build:all
#Activate the install xorr if you do not have it already installed
#sudo apt-get install xorriso
rm iknow/boot/grub/ -r -f
mkdir iknow/boot/grub/
echo set default=0 >> iknow/boot/grub/grub.cfg
echo set timeout=0 >> iknow/boot/grub/grub.cfg
echo menuentry "IKnow" { >> iknow/boot/grub/grub.cfg
echo set root='(hd96)' >> iknow/boot/grub/grub.cfg
echo multiboot /boot/kernel.bin >> iknow/boot/grub/grub.cfg
echo } >> iknow/boot/grub/grub.cfg
rm OSFS/boot/grub/ -r -f
mkdir OSFS/boot/grub/
echo set default=0 >> OSFS/boot/grub/grub.cfg
echo set timeout=5 >> OSFS/boot/grub/grub.cfg
echo menuentry "Salam 0.0.10" { >> OSFS/boot/grub/grub.cfg
echo set root='(hd96)' >> OSFS/boot/grub/grub.cfg
echo multiboot /boot/kernel.bin >> OSFS/boot/grub/grub.cfg
echo } >> OSFS/boot/grub/grub.cfg

grub-mkrescue -o iknow.iso iknow/
grub-mkrescue -o OSFS.iso OSFS/

clear:
rm -r -f obj/
rm -f obj/*.o
rm -r -f iknow/
rm -r -f OSFS/

4 changes: 4 additions & 0 deletions src/idt.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include "../include/idt.h"
#include "../include/util.h"

#define IDT_ENTRIES 256
idt_gate_t idt[IDT_ENTRIES];
idt_register_t idt_reg;

void set_idt_gate(int n, uint32 handler) {
idt[n].low_offset = low_16(handler);
idt[n].sel = KERNEL_CS;
Expand Down
76 changes: 39 additions & 37 deletions src/isr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,45 @@
#include "../include/screen.h"
#include "../include/util.h"

/* To print the message which defines every exception */
string exception_messages[] = {
"Division By Zero",
"Debug",
"Non Maskable Interrupt",
"Breakpoint",
"Into Detected Overflow",
"Out of Bounds",
"Invalid Opcode",
"No Coprocessor",

"Double Fault",
"Coprocessor Segment Overrun",
"Bad TSS",
"Segment Not Present",
"Stack Fault",
"General Protection Fault",
"Page Fault",
"Unknown Interrupt",

"Coprocessor Fault",
"Alignment Check",
"Machine Check",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",

"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved"
};

void isr_install() {
set_idt_gate(0, (uint32)isr0);
set_idt_gate(1, (uint32)isr1);
Expand Down Expand Up @@ -207,41 +246,4 @@ void isr31()



/* To print the message which defines every exception */
string exception_messages[] = {
"Division By Zero",
"Debug",
"Non Maskable Interrupt",
"Breakpoint",
"Into Detected Overflow",
"Out of Bounds",
"Invalid Opcode",
"No Coprocessor",

"Double Fault",
"Coprocessor Segment Overrun",
"Bad TSS",
"Segment Not Present",
"Stack Fault",
"General Protection Fault",
"Page Fault",
"Unknown Interrupt",

"Coprocessor Fault",
"Alignment Check",
"Machine Check",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",

"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved",
"Reserved"
};
45 changes: 38 additions & 7 deletions src/kernel.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,43 @@
#include "../include/kb.h"
#include "../include/isr.h"
#include "../include/idt.h"
#include "../include/util.h"
#include "../include/shell.h"
kmain()


int kmain()
{
isr_install();
isr_install(); //interrupt service routin
clearScreen();
print("Hi and Welcome to NIDOS operating system\nPlease enter a command\n");
launch_shell(0);
}
//int a = 5/0; //برای آزمایش وقفه- ۷
print("Salam\nWelcome to OSFS 0.0.10\n Hi Mohammad \nthanks\n\nPlease Enter a command \n");

launch_shell(0);
/* برای قسمت ۲ تا ۹ بود- به جای پوسته
while(1){
print ("\nOSFS> ");

string ch = readStr();
if(strEql(ch, "cmd")){
print("\nYou are allready in cmd");
}
else if(strEql(ch, "clear")){
clearScreen();
}
else{
print("\nBad command!");
}
print("\n");


}
برای آموزش قسمت اول بود
char* vidmem=(char *)0xb8000;
vidmem[0] = 'A';
vidmem[1] = 0x02;
vidmem[2] = 'L';
vidmem[3] = 0x02;
vidmem[4] = 'I';
vidmem[5] = 0x02;

*/
return 0;
}