forked from PoliEcho-holding-org/kern
Fixed everything to work with the new libc
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
/* Third stage "prekernel" */
|
/* Third stage "prekernel" */
|
||||||
|
OUTPUT_FORMAT("binary")
|
||||||
|
|
||||||
SECTIONS {
|
SECTIONS {
|
||||||
.text 0x50000 : {
|
.text 0x50000 : {
|
||||||
*(entry);
|
*(entry);
|
||||||
+22
-8
@@ -4,12 +4,26 @@
|
|||||||
|
|
||||||
include make.defaults
|
include make.defaults
|
||||||
|
|
||||||
bootloader: $(BOOT_DIR)/stage1.asm $(BOOT_DIR)/stage2.asm $(BOOT_DIR)/stage3.c $(LIBC) $(LIBK)
|
STAGE1 = $(BIN)/stage1.bin
|
||||||
@echo "Assembling $(BOOT_DIR)/stage1.asm..."
|
STAGE2 = $(BIN)/stage2.bin
|
||||||
$(AS) -fbin -o $(BIN)/stage1.bin $(BOOT_DIR)/stage1.asm $(ASFLAGS)
|
STAGE3 = $(BIN)/stage3.bin
|
||||||
@echo "Assembling $(BOOT_DIR)/stage2.asm..."
|
STAGE1_SRC = $(BOOT_DIR)/stage1.s
|
||||||
$(AS) -fbin -o $(BIN)/stage2.bin $(BOOT_DIR)/stage2.asm $(ASFLAGS)
|
STAGE2_SRC = $(BOOT_DIR)/stage2.s
|
||||||
@echo "Compiling $(BOOT_DIR)/stage3.c..."
|
STAGE3_SRC = $(BOOT_DIR)/stage3.c
|
||||||
$(CC) $(CFLAGS) -I$(LIBK_INC) -I$(LIBC_INC) -o $(BIN)/boot/stage3.o -c $(BOOT_DIR)/stage3.c
|
STAGE3_OBJ = $(BIN)/boot/stage3.o
|
||||||
$(LD) $(LDFLAGS) -T$(BOOT_DIR)/stage3.ld --oformat binary -o $(BIN)/stage3.bin $(BIN)/boot/stage3.o $(LIBC) $(LIBK)
|
|
||||||
|
bootloader: $(STAGE1) $(STAGE2) $(STAGE3)
|
||||||
|
|
||||||
|
$(STAGE1): $(STAGE1_SRC)
|
||||||
|
@echo "Assembling $<..."
|
||||||
|
$(AS) -fbin -o $@ $< $(ASFLAGS)
|
||||||
|
|
||||||
|
$(STAGE2): $(STAGE2_SRC)
|
||||||
|
@echo "Assembling $<..."
|
||||||
|
$(AS) -fbin -o $@ $< $(ASFLAGS)
|
||||||
|
|
||||||
|
$(STAGE3): $(STAGE3_SRC)
|
||||||
|
@echo "Compiling $(STAGE3_SRC)..."
|
||||||
|
$(CC) $(CFLAGS) -I$(LIBK_INC) -I$(LIBC_INC) -o $(STAGE3_OBJ) -c $<
|
||||||
|
$(LD) $(LDFLAGS) -T$(BOOT_DIR)/linker.ld -o $@ $(STAGE3_OBJ) $(LIBK)
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include <disk/disk.h>
|
#include <disk/disk.h>
|
||||||
#include <fs/impl.h>
|
#include <fs/impl.h>
|
||||||
#include <fs/fs.h>
|
#include <fs/fs.h>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
__attribute__ ((section("entry")))
|
__attribute__ ((section("entry")))
|
||||||
void main() {
|
void main() {
|
||||||
|
|||||||
+6
-6
@@ -119,7 +119,7 @@ void main() {
|
|||||||
char input[256];
|
char input[256];
|
||||||
char* inPtr = &input[0];
|
char* inPtr = &input[0];
|
||||||
|
|
||||||
reads(inPtr);
|
gets(inPtr, 256);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ int _m() {
|
|||||||
char input[256];
|
char input[256];
|
||||||
char* inputPtr = input;
|
char* inputPtr = input;
|
||||||
|
|
||||||
reads(input);
|
gets(input, 256);
|
||||||
|
|
||||||
if (*input == '\0') continue;
|
if (*input == '\0') continue;
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ int _m() {
|
|||||||
drawCircle(1500, 600, 300, WHITE);
|
drawCircle(1500, 600, 300, WHITE);
|
||||||
fillCircle(950, 750, 75, rgb(0xa2, 0xd6, 0xf9));
|
fillCircle(950, 750, 75, rgb(0xa2, 0xd6, 0xf9));
|
||||||
|
|
||||||
getc(); // Wait until we get a keystroke
|
getc(stdin); // Wait until we get a keystroke
|
||||||
printf("\x1b[J");
|
printf("\x1b[J");
|
||||||
} else if (strcmp(argv[0], "help") == 0) {
|
} else if (strcmp(argv[0], "help") == 0) {
|
||||||
printf("Available Commands:\n");
|
printf("Available Commands:\n");
|
||||||
@@ -286,7 +286,7 @@ int _m() {
|
|||||||
char c = fp->_ptr[i++];
|
char c = fp->_ptr[i++];
|
||||||
printf("%c", c < 32 ? '.' : c);
|
printf("%c", c < 32 ? '.' : c);
|
||||||
}
|
}
|
||||||
putc('\n');
|
putc('\n', stdout);
|
||||||
}
|
}
|
||||||
printf("%04x: ", i);
|
printf("%04x: ", i);
|
||||||
}
|
}
|
||||||
@@ -321,14 +321,14 @@ void listFiles() {
|
|||||||
uint32_t total = 0;
|
uint32_t total = 0;
|
||||||
while ((dentry + total)->name[0] != '\0') { total++; }
|
while ((dentry + total)->name[0] != '\0') { total++; }
|
||||||
|
|
||||||
putc(' '); // TODO
|
putc(' ', stdout); // TODO
|
||||||
printf("\bTotal %d\n", total);
|
printf("\bTotal %d\n", total);
|
||||||
|
|
||||||
while (dentry->name[0] != '\0') {
|
while (dentry->name[0] != '\0') {
|
||||||
inode_t* inode = (inode_t*)BOOT_FIRST_INODE_LOC + dentry->id;
|
inode_t* inode = (inode_t*)BOOT_FIRST_INODE_LOC + dentry->id;
|
||||||
|
|
||||||
printf("%s", dentry->name);
|
printf("%s", dentry->name);
|
||||||
for (uint32_t pad = (16 - strlen(dentry->name)); pad > 0; pad--) { putc(' '); }
|
for (uint32_t pad = (16 - strlen(dentry->name)); pad > 0; pad--) { putc(' ', stdout); }
|
||||||
|
|
||||||
switch (inode->type) {
|
switch (inode->type) {
|
||||||
case FT_FILE: printf("%dB\n", inode->sizeBytes); break;
|
case FT_FILE: printf("%dB\n", inode->sizeBytes); break;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
OUTPUT_FORMAT("binary")
|
||||||
|
|
||||||
SECTIONS {
|
SECTIONS {
|
||||||
.text 0xC0000000 : {
|
.text 0xC0000000 : {
|
||||||
*(entry);
|
*(entry);
|
||||||
+1
-1
@@ -7,5 +7,5 @@ include make.defaults
|
|||||||
$(KERNEL): $(KERNEL_SRC) $(LIBC) $(LIBK)
|
$(KERNEL): $(KERNEL_SRC) $(LIBC) $(LIBK)
|
||||||
@echo "Compiling $(KERNEL_SRC)..."
|
@echo "Compiling $(KERNEL_SRC)..."
|
||||||
$(CC) $(CFLAGS) -I$(LIBK_INC) -I$(LIBC_INC) -o $(BIN)/kernel/kernel.o -c $(KERNEL_SRC)
|
$(CC) $(CFLAGS) -I$(LIBK_INC) -I$(LIBC_INC) -o $(BIN)/kernel/kernel.o -c $(KERNEL_SRC)
|
||||||
$(LD) $(LDFLAGS) -T$(KERNEL_DIR)/kernel.ld --oformat binary -o $(BIN)/kernel.bin $(BIN)/kernel/kernel.o $(LIBC) $(LIBK)
|
$(LD) $(LDFLAGS) -T$(KERNEL_DIR)/linker.ld -o $@ $(BIN)/kernel/kernel.o $(LIBK)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,10 +2,10 @@
|
|||||||
#include <fs/fs.h>
|
#include <fs/fs.h>
|
||||||
#include <memory/addresses.h>
|
#include <memory/addresses.h>
|
||||||
#include <disk/disk.h>
|
#include <disk/disk.h>
|
||||||
#include <syscall.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
superblock_t* impl_superblock = (superblock_t*)SUPERBLOCK_LOC;
|
superblock_t* impl_superblock = (superblock_t*)SUPERBLOCK_LOC;
|
||||||
fsInfo_t* fsInfo = (fsInfo_t*)FS_INFO_LOC;
|
fsInfo_t* fsInfo = (fsInfo_t*)FS_INFO_LOC;
|
||||||
|
|||||||
+2
-2
@@ -6,12 +6,12 @@ include make.defaults
|
|||||||
|
|
||||||
LIBK_ASM=$(LIBK_DIR)/interrupt/isr.s
|
LIBK_ASM=$(LIBK_DIR)/interrupt/isr.s
|
||||||
|
|
||||||
$(LIBK): $(LIBK_SRC) $(LIBK_ASM)
|
$(LIBK): $(LIBK_SRC) $(LIBK_ASM) $(LIBC)
|
||||||
@echo "Building $(LIBK)..."
|
@echo "Building $(LIBK)..."
|
||||||
nasm -felf32 -o $(BIN)/libk/isr_asm.o $(LIBK_ASM)
|
nasm -felf32 -o $(BIN)/libk/isr_asm.o $(LIBK_ASM)
|
||||||
for f in $(LIBK_SRC); do\
|
for f in $(LIBK_SRC); do\
|
||||||
filename=$$(basename $$f .c);\
|
filename=$$(basename $$f .c);\
|
||||||
$(CC) $(CFLAGS) -I$(LIBC_INC) -I$(LIBK_INC) -o $(BIN)/libk/$$filename.o -c $$f;\
|
$(CC) $(CFLAGS) -I$(LIBC_INC) -I$(LIBK_INC) -o $(BIN)/libk/$$filename.o -c $$f;\
|
||||||
done
|
done
|
||||||
$(LD) $(LDFLAGS) -r -o $(LIBK) $(BIN)/libk/**.o
|
$(LD) $(LDFLAGS) -r -o $(LIBK) $(LIBC) $(BIN)/libk/**.o
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
int sys_read(intFrame_t* iframe) {
|
int sys_read(intFrame_t* iframe) {
|
||||||
char* s = (char*)iframe->ebx;
|
char* s = (char*)iframe->ebx;
|
||||||
reads(s);
|
gets(s, 0xffffffff);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
|
|
||||||
// System call table
|
// System call table
|
||||||
int (*syscalls[MAX_SYSCALLS])(intFrame_t*) = {
|
int (*syscalls[SYSCALL_COUNT])(intFrame_t*) = {
|
||||||
[SYS_EXIT] = sys_exit,
|
[SYS_EXIT] = sys_exit,
|
||||||
[SYS_READ] = sys_read,
|
[SYS_READ] = sys_read,
|
||||||
[SYS_WRITE] = sys_write,
|
[SYS_WRITE] = sys_write,
|
||||||
@@ -18,7 +18,7 @@ int (*syscalls[MAX_SYSCALLS])(intFrame_t*) = {
|
|||||||
|
|
||||||
// Syscall handler
|
// Syscall handler
|
||||||
int syscallHandler(intFrame_t* iframe) {
|
int syscallHandler(intFrame_t* iframe) {
|
||||||
if (iframe->eax > MAX_SYSCALLS-1) { // Syscall doesn't exist
|
if (iframe->eax > SYSCALL_COUNT-1) { // Syscall doesn't exist
|
||||||
debugf("Error: Syscall(%d) does not exist!\n", iframe->eax);
|
debugf("Error: Syscall(%d) does not exist!\n", iframe->eax);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Makfile variables
|
# Makefile variables
|
||||||
#
|
#
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
@@ -14,7 +14,7 @@ CFLAGS = -Wall -Wextra -Wno-pointer-sign -Wno-pointer-arith -Wno-unused-param
|
|||||||
-Os -std=c17 -nostdinc -g -Werror\
|
-Os -std=c17 -nostdinc -g -Werror\
|
||||||
-ffreestanding -fno-stack-protector -fno-builtin -fno-pie -fcommon\
|
-ffreestanding -fno-stack-protector -fno-builtin -fno-pie -fcommon\
|
||||||
-m32 -march=i386
|
-m32 -march=i386
|
||||||
LDFLAGS = -z notext -melf_i386 -nostdlib
|
LDFLAGS = -z notext -nostdlib -melf_i386
|
||||||
ASFLAGS =
|
ASFLAGS =
|
||||||
|
|
||||||
# Directories
|
# Directories
|
||||||
|
|||||||
Reference in New Issue
Block a user