Skip to content

Commit

Permalink
Merge pull request #108 from skni-kod/develop
Browse files Browse the repository at this point in the history
It is finally happening, release 1.2 coming soon.
  • Loading branch information
MinusPL authored Feb 5, 2022
2 parents db019a1 + 12c01b0 commit da96088
Show file tree
Hide file tree
Showing 152 changed files with 9,207 additions and 869 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ scripts
docs

cloc.exe
cloc.bat
cloc.bat
.idea/vcs.xml
.idea/MicrOS.iml
.idea/misc.xml
debug.log
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
THREADS_COUNT := 1
WORKSPACE_DIR := ${CURDIR}

.PHONY: all
all:
# Delete old ELF and BIN files
find build -iname "*.elf" -type f -delete
find build -iname "*.bin" -type f -delete

find environment -iname "*.elf" -type f -delete
find library -iname "*.elf" -type f -delete
find os -iname "*.elf" -type f -delete

$(MAKE) -C os/bootloader

$(MAKE) -C library

for d in $(sort $(dir $(wildcard ./environment/*/))) ; do \
$(MAKE) -C $${d}; \
done

$(MAKE) -C os/kernel


.PHONY: clean
clean:
# Delete old ELF and BIN files
find build -iname "*.elf" -type f -delete
find build -iname "*.bin" -type f -delete

find environment -iname "*.elf" -type f -delete
find library -iname "*.elf" -type f -delete
find os -iname "*.elf" -type f -delete

$(MAKE) -C os/bootloader clean

$(MAKE) -C library clean

for d in $(sort $(dir $(wildcard ./environment/*/))) ; do \
$(MAKE) -C $${d} clean; \
done

$(MAKE) -C os/kernel clean
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ Documentation: https://tearth.github.io/MicrOS/
* Standard library for C
* ATA Hard disk drive support
* CPUID
* Multithreading

## TODO
* Other standards of hard disk drive support
* More advanced scheduler with priorities and IO blocking
* Support for network cards (and protocols related to them)
* Support for threads
* Lock/mutex, synchronization objects, queues...
* ...

Expand Down
4 changes: 2 additions & 2 deletions environment/cat/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
4 changes: 2 additions & 2 deletions environment/help/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
4 changes: 2 additions & 2 deletions environment/ls/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
4 changes: 2 additions & 2 deletions environment/mkdir/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
4 changes: 2 additions & 2 deletions environment/reboot/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
4 changes: 2 additions & 2 deletions environment/rename/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
4 changes: 2 additions & 2 deletions environment/rm/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
4 changes: 2 additions & 2 deletions environment/shell/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
4 changes: 2 additions & 2 deletions environment/shutdown/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
4 changes: 2 additions & 2 deletions environment/snake/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
4 changes: 2 additions & 2 deletions environment/space/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
4 changes: 2 additions & 2 deletions environment/tasks/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
35 changes: 29 additions & 6 deletions environment/tasks/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <stdlib.h>
#include <stdio.h>

bool show_threads;

void draw_process_tree(micros_process_user_info *processes, uint32_t root_id, uint32_t level, uint32_t count);
void print_total_process_count(int process_count);
void draw_bar(uint32_t filled_entries, uint32_t total_entries);
Expand All @@ -20,7 +22,7 @@ int main(int argc, char *argv[])
{
micros_console_clear();

printf("TASKS v1.1 @ MicrOS\n");
printf("TASKS v1.2 @ MicrOS\n");
printf("\n");

uint32_t processes_count = micros_process_get_processes_count();
Expand All @@ -33,8 +35,12 @@ int main(int argc, char *argv[])
for (uint32_t i = 0; i < processes_count; i++)
{
micros_process_user_info *process = &processes[i];
total_cpu_usage += process->cpu_usage;
total_memory_usage += process->memory_usage;

if (!process->is_thread)
{
total_cpu_usage += process->cpu_usage;
total_memory_usage += process->memory_usage;
}
}

micros_physical_memory_stats memory_stats;
Expand All @@ -60,7 +66,8 @@ int main(int argc, char *argv[])
print_memory_stats(&memory_stats);

printf("\n\n\n\n");
printf(" Press ESC to exit");
printf(" Press T to show/hide threads\n");
printf(" Press ESC to exit\n");

free(processes);
micros_process_current_process_sleep(1500);
Expand All @@ -74,6 +81,10 @@ int main(int argc, char *argv[])
{
break;
}
else if(pressed_key.scancode == key_t)
{
show_threads = !show_threads;
}
}
}

Expand All @@ -82,7 +93,7 @@ int main(int argc, char *argv[])
}

void draw_process_tree(micros_process_user_info *processes, uint32_t root_id, uint32_t level, uint32_t count)
{
{
micros_process_user_info *root_process = NULL;
for (uint32_t i = 0; i < count; i++)
{
Expand All @@ -92,6 +103,11 @@ void draw_process_tree(micros_process_user_info *processes, uint32_t root_id, ui
root_process = &processes[i];
}
}

if (!show_threads && root_process->is_thread)
{
return;
}

if (level != 0)
{
Expand Down Expand Up @@ -160,7 +176,14 @@ void draw_memory_usage_bar(micros_physical_memory_stats *memory_stats, uint32_t

void print_process_info(micros_process_user_info *process_info)
{
printf("%s - ID: %d", process_info->name, process_info->id);
if (show_threads)
{
printf("[%s] %s - ID: %d", process_info->is_thread ? "T" : "P", process_info->name, process_info->id);
}
else
{
printf("%s - ID: %d", process_info->name, process_info->id);
}

if (process_info->id != process_info->parent_id)
{
Expand Down
4 changes: 2 additions & 2 deletions environment/time/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
4 changes: 2 additions & 2 deletions environment/touch/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
4 changes: 2 additions & 2 deletions library/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ $(OUTPUT_FILE): $(C_OBJECTS) $(ASM_OBJECTS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "=== Compiling C file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(GCC) -c $(PWD)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)
@$(GCC) -c $(CURDIR)/$< -o $@ -MMD -MF $(@:.o=.d) $(GCC_COMPILE_FLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
@echo "=== Compiling asm file $< into object $@ ==="
@mkdir -p '$(@D)'
@$(NASM) $(PWD)/$< -f elf32 -o $@
@$(NASM) $(CURDIR)/$< -f elf32 -o $@

-include $(DEPS)

Expand Down
Loading

0 comments on commit da96088

Please sign in to comment.