diff options
| -rw-r--r-- | Makefile | 25 | ||||
| -rw-r--r-- | src/header/crti.s | 12 | ||||
| -rw-r--r-- | src/header/crtn.s | 7 | ||||
| -rw-r--r-- | src/kernel/kernel.c | 2 | ||||
| -rw-r--r-- | src/kernel/print.c | 8 |
5 files changed, 40 insertions, 14 deletions
@@ -22,11 +22,19 @@ LINK_FILE = linker.ld LDFLAGS = -O2 -nostdlib -lgcc -ffreestanding OBJS = -C_OBJS := $(C:$(SRC)/%.c=$(BUILD)/C/%.o) -ASM_OBJS := $(ASM:$(SRC)/%.s=$(BUILD)/ASM/%.o) +C_OBJS := $(C:$(SRC)/%.c=$(BUILD)/%.o) +ASM_OBJS := $(ASM:$(SRC)/%.s=$(BUILD)/%.o) -OBJS += $(C_OBJS) -OBJS += $(ASM_OBJS) +CRTBEGIN_OBJ := $(shell $(CC) $(CFLAGS) -print-file-name=crtbegin.o) +CRTEND_OBJ := $(shell $(CC) $(CFLAGS) -print-file-name=crtend.o) +CRTI_OBJ = $(BUILD)/header/crti.o +CRTN_OBJ = $(BUILD)/header/crtn.o + +OBJS += $(CRTI_OBJ) $(CRTBEGIN_OBJ) +OBJS += $(C_OBJS) $(ASM_OBJS) +OBJS += $(CRTEND_OBJ) $(CRTN_OBJ) + +INTERNAL_OBJS = $(CRTI_OBJ) $(ASM_OBJS) $(C_OBJS) $(CRTN_OBJ) DEPS := $(OBJS:.o=.d) .PHONY: all @@ -42,19 +50,18 @@ $(OUT_DIR)/$(ISO).iso : $(OUT_DIR)/isodir/boot/$(ISO).bin $(OUT_DIR)/isodir/boot/$(ISO).bin : $(OBJS) $(CC) -T $(SRC)/$(LINK_FILE) -o $@ $(LDFLAGS) $^ -$(BUILD)/ASM/%.o: $(SRC)/%.s +$(BUILD)/%.o: $(SRC)/%.s mkdir -p $(BUILD) - mkdir -p $(BUILD)/ASM mkdir -p $(@D) $(ASSEMBLER) $^ -o $@ -$(BUILD)/C/%.o: $(SRC)/%.c +$(BUILD)/%.o: $(SRC)/%.c mkdir -p $(BUILD) - mkdir -p $(BUILD)/C mkdir -p $(@D) $(CC) $(CFLAGS) -c $^ -o $@ + clean: - rm -rf $(BUILD) + rm -rf $(INTERNAL_OBJS) rm -rf $(OUT_DIR)/$(ISO).iso rm -rf $(OUT_DIR)/isodir/boot/$(ISO).bin diff --git a/src/header/crti.s b/src/header/crti.s new file mode 100644 index 0000000..91e86fa --- /dev/null +++ b/src/header/crti.s @@ -0,0 +1,12 @@ +.section .init +.global _init +.type _init @function +_init: + push %ebp + movl %esp, %ebp + +.section .fini +.global _fini +_fini: + push %ebp + movl %esp, %ebp diff --git a/src/header/crtn.s b/src/header/crtn.s new file mode 100644 index 0000000..4874122 --- /dev/null +++ b/src/header/crtn.s @@ -0,0 +1,7 @@ +.section .init + popl %ebp + ret + +.section .fini + popl %ebp + ret diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index 50da3c6..a47a0a7 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -17,5 +17,5 @@ void kernel_main(void) { print_set_color(PRINT_COLOR_YELLOW, PRINT_COLOR_BLACK); printf("printf\n\tint: %d\n\tstring: %s\n\tchar: %c\n\tpercent: " "%%\n\tnothing: %n", - 1287, "World! ", 't'); + 99, "World! ", 't'); } diff --git a/src/kernel/print.c b/src/kernel/print.c index 35533cd..89f6722 100644 --- a/src/kernel/print.c +++ b/src/kernel/print.c @@ -24,8 +24,8 @@ uint8_t color = PRINT_COLOR_WHITE | PRINT_COLOR_BLACK << 4; void clear_row(size_t row) { // Define empty character struct Char empty = (struct Char){ - character : ' ', - color : color, + ' ', + color, }; // For every col in row, set vmem to empty @@ -82,8 +82,8 @@ void print_char(char character) { // set video memeory to requested character buffer[col + NUM_COLS * row] = (struct Char){ - character : (uint8_t)character, - color : color, + (uint8_t)character, + color, }; // iterate col |
